diff --git a/autogen.sh b/autogen.sh index 2deaa93..bd2cbae 100755 --- a/autogen.sh +++ b/autogen.sh @@ -44,9 +44,25 @@ automake_min_vers=`extract_version AM_INIT_AUTOMAKE` libtoolize_min_vers=`extract_version AC_PROG_LIBTOOL` aclocal_min_vers=$automake_min_vers +atleastver() { + i=1 + a=`echo $1 | cut -d. -f$i` + b=`echo $2 | cut -d. -f$i` + while test -n "$a" -a -n "$b" + do + if test "$a" -lt "$b" ; then + return 1 + fi + i=$(( $i + 1 )) + a=`echo $1 | cut -d. -f$i` + b=`echo $2 | cut -d. -f$i` + done + return 0 +} + + if ($AUTOCONF --version) < /dev/null > /dev/null 2>&1 ; then - if ($AUTOCONF --version | head -n 1 | awk 'NR==1 { if( $(NF) >= '$autoconf_min_vers') \ - exit 1; exit 0; }'); + if ! atleastver `$AUTOCONF --version | head -n 1 | cut -d\ -f4` $autoconf_min_vers then echo "$ARGV0: ERROR: \`$AUTOCONF' is too old." $AUTOCONF --version @@ -72,8 +88,8 @@ if test x"$AUTOMAKE" = x || test x"$ACLOCAL" = x ; then for ver in "" "-1.9" "-1.8" "-1.7" ; do am="automake$ver" if ($am --version) < /dev/null > /dev/null 2>&1 ; then - if ($am --version | head -n 1 | awk 'NR==1 { if( $(NF) >= '$automake_min_vers') \ - exit 1; exit 0; }'); then : ; else + if ! atleastver `$am --version | head -n 1 | cut -d\ -f4` $automake_min_vers + then am_ver=$ver break; fi @@ -89,21 +105,19 @@ fi # aren't sufficiently new. # if ($AUTOMAKE --version) < /dev/null > /dev/null 2>&1 ; then - if ($AUTOMAKE --version | head -n 1 | awk 'NR==1 { if( $(NF) >= '$automake_min_vers') \ - exit 1; exit 0; }'); - then + if ! atleastver `$AUTOMAKE --version | head -n 1 | cut -d\ -f4` $automake_min_vers + then echo "$ARGV0: ERROR: \`$AUTOMAKE' is too old." $AUTOMAKE --version echo " (version $automake_min_vers or newer is required)" DIE="yes" fi if ($ACLOCAL --version) < /dev/null > /dev/null 2>&1; then - if ($ACLOCAL --version | head -n 1 | awk 'NR==1 { if( $(NF) >= '$aclocal_min_vers' ) \ - exit 1; exit 0; }' ); - then - echo "$ARGV0: ERROR: \`$ACLOCAL' is too old." + if ! atleastver `$ACLOCAL --version | head -n 1 | cut -d\ -f4` $aclocal_min_vers + then + echo -n "$ARGV0: ERROR: \`$ACLOCAL' is too old, " + $ACLOCAL --version | head -n 1 | awk 'NR==1 { print "[version ", $(NF), "], (version '$aclocal_min_vers' or newer is required)."; exit 0; }' $ACLOCAL --version - echo " (version $aclocal_min_vers or newer is required)" DIE="yes" fi else @@ -122,8 +136,7 @@ else fi if ($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 ; then - if ($LIBTOOLIZE --version | awk 'NR==1 { if( $4 >= '$libtoolize_min_vers') \ - exit 1; exit 0; }'); + if ! atleastver `$LIBTOOLIZE --version | head -n 1 | cut -d\ -f4` $libtoolize_min_vers then echo "$ARGV0: ERROR: \`$LIBTOOLIZE' is too old." echo " (version $libtoolize_min_vers or newer is required)"