[blam] autogen.sh: better check for automake and aclocal versions



commit 0a36f0864e899fff8f03763164725b94c4256cc2
Author: Andrés G. Aragoneses <knocte gmail com>
Date:   Thu Jun 13 22:32:52 2013 +0200

    autogen.sh: better check for automake and aclocal versions
    
    Using the "-x.y" suffix when calling these tools is not a very good way
    to do this because the user might have higher versions which also work.
    
    So we bring the function check_autotools_version() from banshee's
    autogen.sh script [1], but slightly modified to work with /bin/sh instead
    of bash.
    
    [1] https://git.gnome.org/browse/banshee/tree/autogen.sh
    
    Signed-off-by: Carlos Martín Nieto <cmn dwim me>

 autogen.sh |   54 ++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 44 insertions(+), 10 deletions(-)
---
diff --git a/autogen.sh b/autogen.sh
index 730a56a..288ad37 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -1,10 +1,52 @@
 #!/bin/sh
 # Run this to generate all the initial makefiles, etc.
 
+error () {
+       echo "Error: $1" 1>&2
+       exit 1
+}
+
+check_autotool_version () {
+       which $1 >/dev/null 2>&1 || {
+               error "$1 is not installed, and is required to configure $PACKAGE"
+       }
+
+       version=`$1 --version | head -n 1 | cut -f4 -d' '`
+
+       major=`echo $version | cut -f1 -d.`
+       minor=`echo $version | cut -f2 -d.`
+       rev=`echo $version | cut -f3 -d. | sed 's/[^0-9].*$//'`
+       if test "x$rev" = "x" ; then
+               rev=0
+       fi
+
+       major_check=`echo $2 | cut -f1 -d.`
+       minor_check=`echo $2 | cut -f2 -d.`
+       rev_check=`echo $2 | cut -f3 -d.`
+       if test "x$rev_check" = "x" ; then
+               rev_check=0
+       fi
+
+       if [ $major -lt $major_check ]; then
+               do_bail=yes
+       elif [ $minor -lt $minor_check ] && [ $major = $major_check ]; then
+               do_bail=yes
+       elif [ $rev -lt $rev_check ] && [ $minor = $minor_check ] && [ $major = $major_check ]; then
+               do_bail=yes
+       fi
+
+       if [ x"$do_bail" = x"yes" ]; then
+               error "$1 version $2 or better is required to configure $PROJECT"
+       fi
+}
+
+check_autotool_version aclocal 1.10
+check_autotool_version automake 1.10
+
 : ${AUTOCONF=autoconf}
 : ${AUTOHEADER=autoheader}
-: ${AUTOMAKE=automake-1.10}
-: ${ACLOCAL=aclocal-1.10}
+: ${ACLOCAL=automake}
+: ${ACLOCAL=aclocal}
 : ${LIBTOOLIZE=libtoolize}
 : ${INTLTOOLIZE=intltoolize}
 : ${LIBTOOL=libtool}
@@ -44,14 +86,6 @@ fi
   }
 }
 
-($AUTOMAKE --version) < /dev/null > /dev/null 2>&1 || {
-       echo
-       echo "You must have automake installed to compile $PROJECT."
-       echo "Get ftp://sourceware.cygnus.com/pub/automake/automake-1.4.tar.gz";
-       echo "(or a newer version if it is available)"
-       DIE=1
-}
-
 (grep "^AM_PROG_LIBTOOL" configure.in >/dev/null) && {
   ($LIBTOOL --version) < /dev/null > /dev/null 2>&1 || {
     echo


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]