From ece6e4ed61f20605a7a77bb820177a42a06ef45c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lawrence=20Vel=C3=A1zquez?= <larryv@macports.org>
Date: Mon, 2 Feb 2015 23:22:40 -0500
Subject: [PATCH 08/16] (MP) Force contrib builds to use MacPorts' tools

Specifically:
- fribidi: Autotools, Make
- libdvdnav: Autotools
- libdvdread: Autotools
- libogg: Autotools
- libvorbis: Autotools

Some component of the build (I can't figure out which) prepends Xcode's
toolchain directories to `PATH`, causing Xcode's tools to shadow
MacPorts'. Xcode 3.x in particular provides old versions of Autotools,
which break at least one contrib build.
---
 contrib/fribidi/A01-use-MacPorts-tools.patch | 62 ++++++++++++++++++++++++++++
 contrib/fribidi/module.defs                  |  2 +-
 contrib/libdvdnav/module.defs                |  2 +-
 contrib/libdvdread/module.defs               |  2 +-
 contrib/libogg/module.defs                   |  2 +-
 contrib/libvorbis/module.defs                |  2 +-
 6 files changed, 67 insertions(+), 5 deletions(-)
 create mode 100644 contrib/fribidi/A01-use-MacPorts-tools.patch

diff --git a/contrib/fribidi/A01-use-MacPorts-tools.patch b/contrib/fribidi/A01-use-MacPorts-tools.patch
new file mode 100644
index 0000000..f6ec6dd
--- /dev/null
+++ b/contrib/fribidi/A01-use-MacPorts-tools.patch
@@ -0,0 +1,62 @@
+Index: fribidi-0.19.2/bootstrap
+===================================================================
+--- fribidi-0.19.2.orig/bootstrap
++++ fribidi-0.19.2/bootstrap
+@@ -100,7 +100,7 @@ test -n "$INSTALL" && ADDMISSING=--add-m
+ 
+ # use autoreconf if possible, just check for version 2+
+ if test "$AUTORECONF" = auto; then
+-	case `autoreconf --version 2>/dev/null` in
++	case `$PREFIX/bin/autoreconf --version 2>/dev/null` in
+ 		*"autoreconf (GNU Autoconf) 2."* )
+ 			echo Usable autoreconf found, running
+ 		;;
+@@ -111,34 +111,34 @@ if test "$AUTORECONF" = auto; then
+ fi
+ 
+ if test -n "$AUTORECONF";  then
+-	$DRYRUN autoreconf $HELP $VERSION $VERBOSE $DEBUG $FORCE $INSTALL $SYMLINK $MAKE $WARNS $AUTORECONFFLAGS || exit $?
++	$DRYRUN $PREFIX/bin/autoreconf $HELP $VERSION $VERBOSE $DEBUG $FORCE $INSTALL $SYMLINK $MAKE $WARNS $AUTORECONFFLAGS || exit $?
+ else
+ 
+ # add files 'config.guess', 'config.sub', 'ltconfig', 'ltmain.sh'
+ test -f Makefile.am && MY_LIBTOOLIZEFLAGS=--automake
+ 
+ if grep -q '^ *AC_PROG_LIBTOOL' configure.ac configure.in 2>/dev/null; then
+-	$DRYRUN libtoolize $HELP $VERSION $COPY $DEBUG $FORCE $MY_LIBTOOLIZEFLAGS $LIBTOOLIZEFLAGS || exit $?
++	$DRYRUN $PREFIX/bin/glibtoolize $HELP $VERSION $COPY $DEBUG $FORCE $MY_LIBTOOLIZEFLAGS $LIBTOOLIZEFLAGS || exit $?
+ fi
+ 
+ # generate 'aclocal.m4'
+ if test -f configure.ac -o configure.in; then
+-	$DRYRUN aclocal $HELP $VERSION $VERBOSE $FORCE $ACLOCALFLAGS || exit $?
++	$DRYRUN $PREFIX/bin/aclocal $HELP $VERSION $VERBOSE $FORCE $ACLOCALFLAGS || exit $?
+ fi
+ 
+ # generate 'config.h.in'
+ if test -f configure.ac -o configure.in; then
+-	$DRYRUN autoheader $HELP $VERSION $VERBOSE $DEBUG $FORCE $WARNS $AUTOHEADERFLAGS || exit $?
++	$DRYRUN $PREFIX/bin/autoheader $HELP $VERSION $VERBOSE $DEBUG $FORCE $WARNS $AUTOHEADERFLAGS || exit $?
+ fi
+ 
+ #  generate Makefile.in's from Makefile.am's
+ if test -f Makefile.am; then
+-	$DRYRUN automake $HELP $VERSION $VERBOSE $ADDMISSING $COPY $FORCE $WARNS $AUTOMAKEFLAGS || exit $?
++	$DRYRUN $PREFIX/bin/automake $HELP $VERSION $VERBOSE $ADDMISSING $COPY $FORCE $WARNS $AUTOMAKEFLAGS || exit $?
+ fi
+ 
+ # generate configure from configure.ac
+ if test -f configure.ac -o -f configure.in; then
+-	$DRYRUN autoconf $HELP $VERSION $VERBOSE $DEBUG $FORCE $WARNS $AUTOCONFFLAGS || exit $?
++	$DRYRUN $PREFIX/bin/autoconf $HELP $VERSION $VERBOSE $DEBUG $FORCE $WARNS $AUTOCONFFLAGS || exit $?
+ fi
+ 
+ fi # !AUTOCONF
+@@ -156,6 +156,6 @@ fi
+ # make
+ if test -n "$MAKE"; then
+ 	if test -f Makefile; then
+-		$DRYRUN make $MAKEFLAGS || exit $?
++		$DRYRUN $MAKE_CMD $MAKEFLAGS || exit $?
+ 	fi
+ fi
diff --git a/contrib/fribidi/module.defs b/contrib/fribidi/module.defs
index d64e580..64259b3 100644
--- a/contrib/fribidi/module.defs
+++ b/contrib/fribidi/module.defs
@@ -3,4 +3,4 @@ $(eval $(call import.CONTRIB.defs,FRIBIDI))
 
 FRIBIDI.FETCH.url = http://download.handbrake.fr/handbrake/contrib/fribidi-0.19.2.tar.gz
 
-FRIBIDI.CONFIGURE.bootstrap = ./bootstrap --verbose;
+FRIBIDI.CONFIGURE.bootstrap = MAKE_CMD="$(MAKE)" PREFIX="$(PREFIX)" ./bootstrap --verbose;
diff --git a/contrib/libdvdnav/module.defs b/contrib/libdvdnav/module.defs
index 5adcdfe..0de5c1f 100644
--- a/contrib/libdvdnav/module.defs
+++ b/contrib/libdvdnav/module.defs
@@ -2,7 +2,7 @@ $(eval $(call import.MODULE.defs,LIBDVDNAV,libdvdnav,PKGCONFIG LIBDVDREAD))
 $(eval $(call import.CONTRIB.defs,LIBDVDNAV))
 
 LIBDVDNAV.FETCH.url = http://download.handbrake.fr/handbrake/contrib/libdvdnav-5.0.1-0-gaa3659d.tar.gz
-LIBDVDNAV.CONFIGURE.bootstrap = rm -fr aclocal.m4 autom4te.cache configure; autoreconf -I m4 -fiv;
+LIBDVDNAV.CONFIGURE.bootstrap = rm -fr aclocal.m4 autom4te.cache configure; $(PREFIX)/bin/autoreconf -I m4 -fiv;
 
 ifneq (max,$(LIBDVDNAV.GCC.g))
     LIBDVDNAV.GCC.D += NDEBUG
diff --git a/contrib/libdvdread/module.defs b/contrib/libdvdread/module.defs
index 4ab0fab..7f26c6d 100644
--- a/contrib/libdvdread/module.defs
+++ b/contrib/libdvdread/module.defs
@@ -2,7 +2,7 @@ $(eval $(call import.MODULE.defs,LIBDVDREAD,libdvdread,PKGCONFIG))
 $(eval $(call import.CONTRIB.defs,LIBDVDREAD))
 
 LIBDVDREAD.FETCH.url = http://download.handbrake.fr/handbrake/contrib/libdvdread-5.0.0-6-gcb1ae87.tar.gz
-LIBDVDREAD.CONFIGURE.bootstrap = rm -fr aclocal.m4 autom4te.cache configure; autoreconf -I m4 -fiv;
+LIBDVDREAD.CONFIGURE.bootstrap = rm -fr aclocal.m4 autom4te.cache configure; $(PREFIX)/bin/autoreconf -I m4 -fiv;
 
 ifeq (1-mingw,$(BUILD.cross)-$(BUILD.system))
     LIBDVDREAD.CONFIGURE.extra = --enable-dlfcn
diff --git a/contrib/libogg/module.defs b/contrib/libogg/module.defs
index 4b1c8c9..c758c98 100644
--- a/contrib/libogg/module.defs
+++ b/contrib/libogg/module.defs
@@ -6,4 +6,4 @@ LIBOGG.EXTRACT.tarbase = libogg-1.3.0
 
 LIBOGG.CONFIGURE.extra = --disable-sdl
 
-LIBOGG.CONFIGURE.bootstrap = rm -fr aclocal.m4 autom4te.cache configure; autoreconf -fiv;
+LIBOGG.CONFIGURE.bootstrap = rm -fr aclocal.m4 autom4te.cache configure; $(PREFIX)/bin/autoreconf -fiv;
diff --git a/contrib/libvorbis/module.defs b/contrib/libvorbis/module.defs
index 84d018f..05a8755 100644
--- a/contrib/libvorbis/module.defs
+++ b/contrib/libvorbis/module.defs
@@ -6,4 +6,4 @@ LIBVORBIS.EXTRACT.tarbase = aotuv-b6.03_20110424
 
 LIBVORBIS.CONFIGURE.extra = --with-ogg=$(call fn.ABSOLUTE,$(CONTRIB.build/)) HAVE_PKG_CONFIG="no"
 
-LIBVORBIS.CONFIGURE.bootstrap = rm -fr aclocal.m4 autom4te.cache configure; autoreconf -I m4 -fiv;
+LIBVORBIS.CONFIGURE.bootstrap = rm -fr aclocal.m4 autom4te.cache configure; $(PREFIX)/bin/autoreconf -I m4 -fiv;
-- 
2.3.0

