Check for glibtoolize, allow overrides from env
authorMarko Kreen <markokr@gmail.com>
Tue, 5 Jun 2012 11:42:56 +0000 (14:42 +0300)
committerMarko Kreen <markokr@gmail.com>
Tue, 5 Jun 2012 11:53:33 +0000 (14:53 +0300)
mk/std-autogen.sh

index d823952c1bc7a7fd91fac0c2bbbedb6ffd5389a9..93ba852ffccb8a56b03047da3ad58cad79324970 100755 (executable)
@@ -6,6 +6,8 @@
 # - it installs ltmain.sh, if LT_INIT or *LIBTOOL macro is used
 #
 
+set -e
+
 USUAL_DIR="$1"
 test -n "${USUAL_DIR}" || USUAL_DIR="."
 
@@ -14,27 +16,41 @@ test -f "${USUAL_DIR}/m4/usual.m4" || {
   exit 1
 }
 
+# default programs
+ACLOCAL=${ACLOCAL:-aclocal}
+AUTOCONF=${AUTOCONF:-autoconf}
+AUTOHEADER=${AUTOHEADER:-autoheader}
+
+# detect first glibtoolize then libtoolize
+if test "x$LIBTOOLIZE" = "x"; then
+  LIBTOOLIZE=glibtoolize
+  which $LIBTOOLIZE >/dev/null 2>&1 \
+    || LIBTOOLIZE=libtoolize
+fi
+
 # 
 # Workarounds for libtoolize randomness - it does not update
 # the files if they exist, except it requires install-sh.
 #
 rm -f config.guess config.sub install-sh ltmain.sh libtool
 cp -p ${USUAL_DIR}/mk/install-sh .
-if libtoolize --help | grep "[-][-]install" > /dev/null; then
-  libtoolize -i -f -q -c
+if ${LIBTOOLIZE} --help | grep "[-][-]install" > /dev/null; then
+  ${LIBTOOLIZE} -i -f -q -c
 else
-  libtoolize -c
+  ${LIBTOOLIZE} -c
 fi
 
 # drop ltmain.sh if libtool is not used
-grep -E 'LT_INIT|LIBTOOL' configure.ac > /dev/null || rm -f ltmain.sh
+grep -E 'LT_INIT|LIBTOOL' configure.ac > /dev/null \
+  || rm -f ltmain.sh
 
 # Now generate configure & config.h
-aclocal -I ${USUAL_DIR}/m4
+${ACLOCAL} -I ${USUAL_DIR}/m4
 
-grep AC_CONFIG_HEADER configure.ac > /dev/null && autoheader
+grep AC_CONFIG_HEADER configure.ac > /dev/null \
+  && ${AUTOHEADER}
 
-autoconf
+${AUTOCONF}
 
 # clean junk
 rm -rf autom4te.* aclocal*