# HG changeset patch # User Jim Meyering # Date 1239998628 -7200 # Node ID 9456d3e6e79a8ac58c390d64cc9c8a04aee00fe6 # Parent 8b1dcb465dff3e3d536c6abb45f85b141bde4b75 bootstrap: sync from coreutils * build-aux/bootstrap: Honor variables like $ACLOCAL, etc., just as autoreconf does. Verify a list of prerequisite package-name,version-number pairs if defined in bootstrap.conf. Refer to README-prereq, if prerequisites are not satisfied. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-06-28 Jim Meyering + + bootstrap: sync from coreutils + * build-aux/bootstrap: Honor variables like $ACLOCAL, etc., + just as autoreconf does. Verify a list of prerequisite + package-name,version-number pairs if defined in bootstrap.conf. + Refer to README-prereq, if prerequisites are not satisfied. + 2009-06-27 Eric Blake tests: add test for bogus NULL definition diff --git a/build-aux/bootstrap b/build-aux/bootstrap --- a/build-aux/bootstrap +++ b/build-aux/bootstrap @@ -2,7 +2,7 @@ # Bootstrap this package from checked-out sources. -# Copyright (C) 2003-2008 Free Software Foundation, Inc. +# Copyright (C) 2003-2009 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -52,6 +52,9 @@ If the file $0.conf exists in the same directory as this script, its contents are read as shell variables to configure the bootstrap. +For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR +are honored. + Running without arguments will suffice in most cases. " } @@ -195,7 +198,7 @@ file=$1 str=$2 test -f $file || touch $file - echo "$str" | sort -u - $file | cmp -s - $file \ + echo "$str" | sort -u - $file | cmp - $file > /dev/null \ || echo "$str" | sort -u - $file -o $file \ || exit 1 } @@ -222,6 +225,100 @@ done fi +# Note this deviates from the version comparison in automake +# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a +# but this should suffice as we won't be specifying old +# version formats or redundant trailing .0 in bootstrap.conf. +# If we did want full compatibility then we should probably +# use m4_version_compare from autoconf. +sort_ver() { # sort -V is not generally available + ver1="$1" + ver2="$2" + + # split on '.' and compare each component + i=1 + while : ; do + p1=$(echo "$ver1" | cut -d. -f$i) + p2=$(echo "$ver2" | cut -d. -f$i) + if [ ! "$p1" ]; then + echo "$1 $2" + break + elif [ ! "$p2" ]; then + echo "$2 $1" + break + elif [ ! "$p1" = "$p2" ]; then + if [ "$p1" -gt "$p2" ] 2>/dev/null; then # numeric comparison + echo "$2 $1" + elif [ "$p2" -gt "$p1" ] 2>/dev/null; then # numeric comparison + echo "$1 $2" + else # numeric, then lexicographic comparison + lp=$(printf "$p1\n$p2\n" | LANG=C sort -n | tail -n1) + if [ "$lp" = "$p2" ]; then + echo "$1 $2" + else + echo "$2 $1" + fi + fi + break + fi + i=$(($i+1)) + done +} + +get_version() { + app=$1 + + $app --version >/dev/null 2>&1 || return 1 + + $app --version 2>&1 | + sed -n 's/[^0-9.]*\([0-9]\{1,\}\.[.a-z0-9-]*\).*/\1/p + t done + d + :done + q' +} + +check_versions() { + ret=0 + + while read app req_ver; do + # Honor $APP variables ($TAR, $AUTOCONF, etc.) + appvar=`echo $app | tr '[a-z]' '[A-Z]'` + test "$appvar" = TAR && appvar=AMTAR + eval "app=\${$appvar-$app}" + inst_ver=$(get_version $app) + if [ ! "$inst_ver" ]; then + echo "Error: '$app' not found" >&2 + ret=1 + elif [ ! "$req_ver" = "-" ]; then + latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2) + if [ ! "$latest_ver" = "$inst_ver" ]; then + echo "Error: '$app' version == $inst_ver is too old" >&2 + echo " '$app' version >= $req_ver is required" >&2 + ret=1 + fi + fi + done + + return $ret +} + +print_versions() { + echo "Program Min_version" + echo "----------------------" + printf "$buildreq" + echo "----------------------" + # can't depend on column -t +} + +if ! printf "$buildreq" | check_versions; then + test -f README-prereq && + echo "Please see README-prereq for notes on obtaining these prerequisite programs:" >&2 + echo + print_versions + exit 1 +fi + echo "$0: Bootstrapping from checked-out $package sources..." # See if we can use gnulib's git-merge-changelog merge driver. @@ -323,9 +420,9 @@ cksum_file="$ref_po_dir/$po.s1" if ! test -f "$cksum_file" || ! test -f "$po_dir/$po.po" || - ! sha1sum -c --status "$cksum_file" < "$new_po" > /dev/null; then + ! ${SHA1SUM-sha1sum} -c --status "$cksum_file" < "$new_po" > /dev/null; then echo "updated $po_dir/$po.po..." - cp "$new_po" "$po_dir/$po.po" && sha1sum < "$new_po" > "$cksum_file" + cp "$new_po" "$po_dir/$po.po" && ${SHA1SUM-sha1sum} < "$new_po" > "$cksum_file" fi done } @@ -487,7 +584,7 @@ if test $file = Makefile.am; then copied=$copied${sep}$gnulib_mk; sep=$nl remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g" - sed "$remove_intl" $1/$dir/$file | cmp -s - $dir/$gnulib_mk || { + sed "$remove_intl" $1/$dir/$file | cmp - $dir/$gnulib_mk > /dev/null || { echo "$0: Copying $1/$dir/$file to $dir/$gnulib_mk ..." && rm -f $dir/$gnulib_mk && sed "$remove_intl" $1/$dir/$file >$dir/$gnulib_mk @@ -569,9 +666,9 @@ with_gettext=no if test $with_gettext = yes; then - echo "$0: (cd $bt2; autopoint) ..." + echo "$0: (cd $bt2; ${AUTOPOINT-autopoint}) ..." cp configure.ac $bt2 && - (cd $bt2 && autopoint && rm configure.ac) && + (cd $bt2 && ${AUTOPOINT-autopoint} && rm configure.ac) && slurp $bt2 $bt || exit fi rm -fr $bt $bt2 || exit @@ -592,10 +689,10 @@ for command in \ libtool \ - 'aclocal --force -I m4' \ - 'autoconf --force' \ - 'autoheader --force' \ - 'automake --add-missing --copy --force-missing'; + "${ACLOCAL-aclocal} --force -I m4" \ + "${AUTOCONF-autoconf} --force" \ + "${AUTOHEADER-autoheader} --force" \ + "${AUTOMAKE-automake} --add-missing --copy --force-missing" do if test "$command" = libtool; then use_libtool=0 @@ -608,7 +705,7 @@ && use_libtool=1 test $use_libtool = 0 \ && continue - command='libtoolize -c -f' + command="${LIBTOOLIZE-libtoolize} -c -f" fi echo "$0: $command ..." $command || exit