From: Eric Blake Date: Sat, 8 Sep 2007 14:48:49 +0000 (+0000) Subject: Improve M4 path searching during configure. X-Git-Tag: v2.62~276 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3aee13bfac4e3fdaf79d2a94158594210e62e02;p=thirdparty%2Fautoconf.git Improve M4 path searching during configure. * lib/autoconf/programs.m4 (AC_PATH_PROGS_FEATURE_CHECK): New macro. (_AC_PATH_PROG_FEATURE_CHECK): Rename... (_AC_PATH_PROGS_FEATURE_CHECK): ...to this, add defaulted action parameter, and kill side effects. (_AC_PROG_GREP, AC_PROG_SED): Adjust callers. (_AC_FEATURE_CHECK_LENGTH): Kill extra whitespace. * m4/m4.m4 (AC_PROG_GNU_M4): Don't stop searching until working m4 is found. (AC_PATH_PROGS_FEATURE_CHECK): Add backwards compatibility hack to allow bootstrapping with autoconf 2.61. * configure.ac (M4): AC_PROG_GNU_M4 now exits on failure. * configure: Regenerate. * doc/autoconf.texi (Generic Programs): Document new macro. * tests/mktests.sh (au_exclude_script): Exclude auto-testing new macro. * tests/semantics.at (AC_PATH_PROGS_FEATURE_CHECK): New test. * NEWS: Document the change. * THANKS: Update. Reported by Hans Aberg. --- diff --git a/ChangeLog b/ChangeLog index 891654e3..fb41f2a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,27 @@ 2007-09-08 Eric Blake + Improve M4 path searching during configure. + * lib/autoconf/programs.m4 (AC_PATH_PROGS_FEATURE_CHECK): New + macro. + (_AC_PATH_PROG_FEATURE_CHECK): Rename... + (_AC_PATH_PROGS_FEATURE_CHECK): ...to this, add defaulted action + parameter, and kill side effects. + (_AC_PROG_GREP, AC_PROG_SED): Adjust callers. + (_AC_FEATURE_CHECK_LENGTH): Kill extra whitespace. + * m4/m4.m4 (AC_PROG_GNU_M4): Don't stop searching until working m4 + is found. + (AC_PATH_PROGS_FEATURE_CHECK): Add backwards compatibility hack to + allow bootstrapping with autoconf 2.61. + * configure.ac (M4): AC_PROG_GNU_M4 now exits on failure. + * configure: Regenerate. + * doc/autoconf.texi (Generic Programs): Document new macro. + * tests/mktests.sh (au_exclude_script): Exclude auto-testing new + macro. + * tests/semantics.at (AC_PATH_PROGS_FEATURE_CHECK): New test. + * NEWS: Document the change. + * THANKS: Update. + Reported by Hans Aberg. + * doc/autoconf.texi (Generic Programs): Fix typo. 2007-09-06 Eric Blake diff --git a/NEWS b/NEWS index c21997e0..74027037 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +GNU Autoconf NEWS - User visible changes. + * Major changes in Autoconf 2.61b (????-??-??) ** Autoconf is now licensed under the General Public License version 3 @@ -6,7 +8,7 @@ generated by autoconf under the license of your own program. FIXME - revisit this line once exception clause is finalized. -** New macro AC_OPENMP. +** New macros AC_OPENMP, AC_PATH_PROGS_FEATURE_CHECK. ** AC_C_BIGENDIAN now supports universal binaries a la Mac OS X. @@ -40,7 +42,8 @@ ** Autoconf now requires GNU M4 1.4.5 or later. Earlier versions of M4 have a bug in macro tracing that interferes with the interaction between - Autoconf and Automake. GNU M4 1.4.8 or later is recommended. + Autoconf and Automake. GNU M4 1.4.8 or later is recommended. The + configure search for a working M4 is improved. ** Warnings are now generated by default when an installer invokes 'configure' with an unknown --enable-* or --with-* option. diff --git a/THANKS b/THANKS index 3c0af397..c896a1fa 100644 --- a/THANKS +++ b/THANKS @@ -124,6 +124,7 @@ Guido Draheim Guido.Draheim@gmx.de Guido Flohr gufl0000@stud.uni-sb.de Guido van Rossum ? Guillermo Gomez gomez@mi.uni-erlangen.de +Hans Aberg haberg@math.su.se Hans Olsson Hans.Olsson@dna.lth.se Harlan Stenn stenn@whimsy.udel.edu Henk Krus h.krus@cyclone.nl diff --git a/configure b/configure index c5a4b753..a97a5517 100755 --- a/configure +++ b/configure @@ -692,6 +692,7 @@ with_lispdir ac_precious_vars='build_alias host_alias target_alias +M4 EMACS EMACSLOADPATH' @@ -1315,6 +1316,8 @@ Optional Packages: --with-lispdir override the default lisp directory Some influential environment variables: + M4 Location of GNU M4 1.4.5 or later. Defaults to the first program + of `m4', `gm4', or `gnum4' on PATH that meets Autoconf needs. EMACS the Emacs editor command EMACSLOADPATH the Emacs library search path @@ -1634,18 +1637,21 @@ _ACEOF # Let the site file select an alternate cache file if it wants to. -# Prefer explicitly selected file to automatically selected ones. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE if test -n "$CONFIG_SITE"; then - set x "$CONFIG_SITE" + ac_site_file1=$CONFIG_SITE elif test "x$prefix" != xNONE; then - set x "$prefix/share/config.site" "$prefix/etc/config.site" + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site else - set x "$ac_default_prefix/share/config.site" \ - "$ac_default_prefix/etc/config.site" + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site fi -shift -for ac_site_file +for ac_site_file in "$ac_site_file1" "$ac_site_file2" do + test "x$ac_site_file" = xNONE && continue if test -r "$ac_site_file"; then { $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} @@ -2336,89 +2342,63 @@ fi # We use an absolute name for GNU m4 so even if users have another m4 first in # their path, the installer can configure with a path that has GNU m4 -# first and get that path embedded in the installed autoconf and +# on it and get that path embedded in the installed autoconf and # autoheader scripts. -for ac_prog in gm4 gnum4 m4 -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } + + { $as_echo "$as_me:$LINENO: checking for GNU M4 that supports accurate traces" >&5 +$as_echo_n "checking for GNU M4 that supports accurate traces... " >&6; } if test "${ac_cv_path_M4+set}" = set; then $as_echo_n "(cached) " >&6 else - case $M4 in - [\\/]* | ?:[\\/]*) - ac_cv_path_M4="$M4" # Let the user override the test with a path. - ;; - *) + if test -z "$M4"; then + ac_path_M4_found=false + # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_M4="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done + for ac_prog in m4 gm4 gnum4; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_M4="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_M4" && $as_test_x "$ac_path_M4"; } || continue + test -z "`echo if'def(mac,bug)d'nl | $ac_path_M4 --trace=mac 2>&1`" \ + && ac_cv_path_M4=$ac_path_M4 ac_path_M4_found=: + $ac_path_M4_found && break 3 + done + done done IFS=$as_save_IFS - - ;; -esac -fi -M4=$ac_cv_path_M4 -if test -n "$M4"; then - { $as_echo "$as_me:$LINENO: result: $M4" >&5 -$as_echo "$M4" >&6; } + if test -z "$ac_cv_path_M4"; then + { { $as_echo "$as_me:$LINENO: error: no acceptable m4 could be found in \$PATH. +GNU M4 1.4.5 or later is required; 1.4.8 is recommended" >&5 +$as_echo "$as_me: error: no acceptable m4 could be found in \$PATH. +GNU M4 1.4.5 or later is required; 1.4.8 is recommended" >&2;} + { (exit 1); exit 1; }; } + fi else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + ac_cv_path_M4=$M4 fi - - test -n "$M4" && break -done -test -n "$M4" || M4="m4" - -{ $as_echo "$as_me:$LINENO: checking whether m4 supports accurate traces" >&5 -$as_echo_n "checking whether m4 supports accurate traces... " >&6; } -if test "${ac_cv_prog_gnu_m4+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_cv_prog_gnu_m4=no -if test x"$M4" != x \ - && test -z "`echo if'def(mac,bug)d'nl | $M4 --trace=mac 2>&1`" ; then - ac_cv_prog_gnu_m4=yes -fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_gnu_m4" >&5 -$as_echo "$ac_cv_prog_gnu_m4" >&6; } -if test $ac_cv_prog_gnu_m4 = yes ; then +{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_M4" >&5 +$as_echo "$ac_cv_path_M4" >&6; } + M4=$ac_cv_path_M4 { $as_echo "$as_me:$LINENO: checking how m4 supports trace files" >&5 $as_echo_n "checking how m4 supports trace files... " >&6; } if test "${ac_cv_prog_gnu_m4_debugfile+set}" = set; then $as_echo_n "(cached) " >&6 else case `$M4 --help < /dev/null 2>&1` in - *debugfile*) ac_cv_prog_gnu_m4_debugfile=--debugfile ;; - *) ac_cv_prog_gnu_m4_debugfile=--error-output ;; - esac + *debugfile*) ac_cv_prog_gnu_m4_debugfile=--debugfile ;; + *) ac_cv_prog_gnu_m4_debugfile=--error-output ;; + esac fi { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_gnu_m4_debugfile" >&5 $as_echo "$ac_cv_prog_gnu_m4_debugfile" >&6; } M4_DEBUGFILE=$ac_cv_prog_gnu_m4_debugfile -fi -if test x"$ac_cv_prog_gnu_m4" != xyes; then - { { $as_echo "$as_me:$LINENO: error: GNU M4 1.4.5 or later is required; 1.4.8 is recommended" >&5 -$as_echo "$as_me: error: GNU M4 1.4.5 or later is required; 1.4.8 is recommended" >&2;} - { (exit 1); exit 1; }; } -fi ## ----------- ## ## Man pages. ## @@ -2685,24 +2665,19 @@ $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if test "${ac_cv_path_GREP+set}" = set; then $as_echo_n "(cached) " >&6 else - # Extract the first word of "grep ggrep" to use in msg output -if test -z "$GREP"; then -set dummy grep ggrep; ac_prog_name=$2 -if test "${ac_cv_path_GREP+set}" = set; then - $as_echo_n "(cached) " >&6 -else + if test -z "$GREP"; then ac_path_GREP_found=false -# Loop through the user's path and test for each of PROGNAME-LIST -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue - # Check for GNU ac_path_GREP and select it if it is found. + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue +# Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) @@ -2730,29 +2705,20 @@ case `"$ac_path_GREP" --version 2>&1` in rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac - - $ac_path_GREP_found && break 3 + $ac_path_GREP_found && break 3 + done done done - -done IFS=$as_save_IFS - - -fi - -GREP="$ac_cv_path_GREP" -if test -z "$GREP"; then - { { $as_echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -$as_echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + if test -z "$ac_cv_path_GREP"; then + { { $as_echo "$as_me:$LINENO: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +$as_echo "$as_me: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} { (exit 1); exit 1; }; } -fi - + fi else ac_cv_path_GREP=$GREP fi - fi { $as_echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } @@ -2767,24 +2733,19 @@ else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else - # Extract the first word of "egrep" to use in msg output -if test -z "$EGREP"; then -set dummy egrep; ac_prog_name=$2 -if test "${ac_cv_path_EGREP+set}" = set; then - $as_echo_n "(cached) " >&6 -else + if test -z "$EGREP"; then ac_path_EGREP_found=false -# Loop through the user's path and test for each of PROGNAME-LIST -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue - # Check for GNU ac_path_EGREP and select it if it is found. + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue +# Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) @@ -2812,29 +2773,20 @@ case `"$ac_path_EGREP" --version 2>&1` in rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac - - $ac_path_EGREP_found && break 3 + $ac_path_EGREP_found && break 3 + done done done - -done IFS=$as_save_IFS - - -fi - -EGREP="$ac_cv_path_EGREP" -if test -z "$EGREP"; then - { { $as_echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -$as_echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + if test -z "$ac_cv_path_EGREP"; then + { { $as_echo "$as_me:$LINENO: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +$as_echo "$as_me: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} { (exit 1); exit 1; }; } -fi - + fi else ac_cv_path_EGREP=$EGREP fi - fi fi { $as_echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 @@ -2853,24 +2805,19 @@ else done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed $as_unset ac_script || ac_script= - # Extract the first word of "sed gsed" to use in msg output -if test -z "$SED"; then -set dummy sed gsed; ac_prog_name=$2 -if test "${ac_cv_path_SED+set}" = set; then - $as_echo_n "(cached) " >&6 -else + if test -z "$SED"; then ac_path_SED_found=false -# Loop through the user's path and test for each of PROGNAME-LIST -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue - # Check for GNU ac_path_SED and select it if it is found. + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue +# Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) @@ -2898,24 +2845,16 @@ case `"$ac_path_SED" --version 2>&1` in rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac - - $ac_path_SED_found && break 3 + $ac_path_SED_found && break 3 + done done done - -done IFS=$as_save_IFS - - -fi - -SED="$ac_cv_path_SED" -if test -z "$SED"; then - { { $as_echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in \$PATH" >&5 -$as_echo "$as_me: error: no acceptable $ac_prog_name could be found in \$PATH" >&2;} + if test -z "$ac_cv_path_SED"; then + { { $as_echo "$as_me:$LINENO: error: no acceptable sed could be found in \$PATH" >&5 +$as_echo "$as_me: error: no acceptable sed could be found in \$PATH" >&2;} { (exit 1); exit 1; }; } -fi - + fi else ac_cv_path_SED=$SED fi diff --git a/configure.ac b/configure.ac index 84170f77..bbb3e87f 100644 --- a/configure.ac +++ b/configure.ac @@ -79,12 +79,9 @@ AC_PATH_PROG([EXPR], [expr]) # We use an absolute name for GNU m4 so even if users have another m4 first in # their path, the installer can configure with a path that has GNU m4 -# first and get that path embedded in the installed autoconf and +# on it and get that path embedded in the installed autoconf and # autoheader scripts. AC_PROG_GNU_M4 -if test x"$ac_cv_prog_gnu_m4" != xyes; then - AC_MSG_ERROR([GNU M4 1.4.5 or later is required; 1.4.8 is recommended]) -fi ## ----------- ## ## Man pages. ## diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 19374863..9f7c77ae 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -3960,6 +3960,49 @@ are found, set @var{variable} to the absolute name of the program found. @end defmac +@defmac AC_PATH_PROGS_FEATURE_CHECK (@var{variable}, @ + @var{progs-to-check-for}, @var{feature-test}, @ + @ovar{action-if-not-found}, @dvar{path, $PATH}) +@acindex{PATH_PROGS_FEATURE_CHECK} +This macro was introduced in Autoconf 2.62. If @var{variable} is not +empty, then set the cache variable @code{$ac_cv_path_@var{variable}} to +its value. Otherwise, check for each program in the blank-separated +list @var{progs-to-check-for} existing in @var{path}. For each program +found, execute @var{feature-test} with @code{$ac_path_@var{variable}} +set to the absolute name of the candidate program. If no invocation of +@var{feature-test} sets the shell variable +@code{$ac_cv_path_@var{variable}}, then @var{action-if-not-found} is +executed. @var{feature-test} will be run even when +@code{ac_cv_path_@var{variable}} is set, to provide the ability to +choose a better candidate found later in @var{path}; to accept the +current setting and bypass all futher checks, @var{feature-test} can +execute @code{ac_path_@var{variable}_found=:}. + +Note that this macro has some subtle differences from +@code{AC_CHECK_PROGS}. It is designed to be run inside +@code{AC_CACHE_VAL}, therefore, it should have no side effects. In +particular, @var{variable} is not set to the final value of +@code{ac_cv_path_@var{variable}}, nor is @code{AC_SUBST} automatically +run. Also, on failure, any action can be performed, whereas +@code{AC_CHECK_PROGS} only performs +@code{@var{variable}=@var{value-if-not-found}}. + +Here is an example, similar to what Autoconf uses in its own configure +script. It will search for an implementation of @command{m4} that +supports the @code{indir} builtin, even if it goes by the name +@command{gm4} or is not the first implementation on @env{PATH}. + +@example +AC_CACHE_CHECK([for m4 that supports indir], [ac_cv_path_M4], + [AC_PATH_PROGS_FEATURE_CHECK([M4], [m4 gm4], + [[m4out=`echo 'changequote([,])indir([divnum])' | $ac_path_M4` + test "x$m4out" = x0 \ + && ac_cv_path_M4=$ac_path_M4 ac_path_M4_found=:]], + [AC_MSG_ERROR([could not find m4 that supports indir])])]) +AC_SUBST([M4], [$ac_cv_path_M4]) +@end example +@end defmac + @defmac AC_PATH_TARGET_TOOL (@var{variable}, @var{prog-to-check-for}, @ @ovar{value-if-not-found}, @dvar{path, $PATH}) @acindex{PATH_TARGET_TOOL} diff --git a/lib/autoconf/programs.m4 b/lib/autoconf/programs.m4 index ba8468a2..9ebdf039 100644 --- a/lib/autoconf/programs.m4 +++ b/lib/autoconf/programs.m4 @@ -2,7 +2,7 @@ # Checking for programs. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# 2002, 2003, 2004, 2005, 2006, 2007 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 @@ -422,54 +422,73 @@ AC_DEFUN([AC_PROG_GREP], # AIX silently truncates long lines before matching. # NeXT understands only one -e and truncates long lines. m4_define([_AC_PROG_GREP], -[_AC_PATH_PROG_FEATURE_CHECK([$1], [$2], +[_AC_PATH_PROGS_FEATURE_CHECK([$1], [$2], [_AC_FEATURE_CHECK_LENGTH([ac_path_$1], [ac_cv_path_$1], - ["$ac_path_$1" $3], [$1])], [$PATH$PATH_SEPARATOR/usr/xpg4/bin]) + ["$ac_path_$1" $3], [$1])], [], + [$PATH$PATH_SEPARATOR/usr/xpg4/bin])dnl ]) -# _AC_PATH_PROG_FEATURE_CHECK(VARIABLE, PROGNAME-LIST, FEATURE-TEST, [PATH]) -# -------------------------------------------------------------------------- +# _AC_PATH_PROGS_FEATURE_CHECK(VARIABLE, PROGNAME-LIST, FEATURE-TEST, +# [ACTION-IF-NOT-FOUND], [PATH=$PATH]) +# ------------------------------------------------------------------- # FEATURE-TEST is called repeatedly with $ac_path_VARIABLE set to the # name of a program in PROGNAME-LIST found in PATH. FEATURE-TEST must set # $ac_cv_path_VARIABLE to the path of an acceptable program, or else -# _AC_PATH_PROG_FEATURE_CHECK will report that no acceptable program -# was found, and abort. If a suitable $ac_path_VARIABLE is found in the -# FEATURE-TEST macro, it can set $ac_path_VARIABLE_found=':' to accept -# that value without any further checks. -m4_define([_AC_PATH_PROG_FEATURE_CHECK], -[# Extract the first word of "$2" to use in msg output -if test -z "$$1"; then -set dummy $2; ac_prog_name=$[2] -AC_CACHE_VAL([ac_cv_path_$1], -[ac_path_$1_found=false -# Loop through the user's path and test for each of PROGNAME-LIST -_AS_PATH_WALK([$4], -[for ac_prog in $2; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_$1="$as_dir/$ac_prog$ac_exec_ext" - AS_EXECUTABLE_P(["$ac_path_$1"]) || continue - $3 - $ac_path_$1_found && break 3 - done -done -]) -]) -$1="$ac_cv_path_$1" -if test -z "$$1"; then - AC_MSG_ERROR([no acceptable $ac_prog_name could be found in dnl -m4_default([$4], [\$PATH])]) -fi -AC_SUBST([$1]) +# ACTION-IF-NOT-FOUND is executed; the default action (for internal use +# only) issues a fatal error message. If a suitable $ac_path_VARIABLE is +# found in the FEATURE-TEST macro, it can set $ac_path_VARIABLE_found=':' +# to accept that value without any further checks. +m4_define([_AC_PATH_PROGS_FEATURE_CHECK], +[if test -z "$$1"; then + ac_path_$1_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + _AS_PATH_WALK([$5], + [for ac_prog in $2; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_$1="$as_dir/$ac_prog$ac_exec_ext" + AS_EXECUTABLE_P(["$ac_path_$1"]) || continue +$3 + $ac_path_$1_found && break 3 + done + done])dnl + if test -z "$ac_cv_path_$1"; then + m4_default([$4], + [AC_MSG_ERROR([no acceptable m4_bpatsubst([$2], [ .*]) could be dnl +found in m4_default([$5], [\$PATH])])]) + fi else ac_cv_path_$1=$$1 fi ]) +# AC_PATH_PROGS_FEATURE_CHECK(VARIABLE, PROGNAME-LIST, +# FEATURE-TEST, [ACTION-IF-NOT-FOUND=:], +# [PATH=$PATH]) +# ---------------------------------------------------------------- +# Designed to be used inside AC_CACHE_VAL. It is recommended, +# but not required, that the user also use AC_ARG_VAR([VARIABLE]). +# If VARIABLE is not empty, set the cache variable +# $ac_cv_path_VARIABLE to VARIABLE without any further tests. +# Otherwise, call FEATURE_TEST repeatedly with $ac_path_VARIABLE +# set to the name of a program in PROGNAME-LIST found in PATH. If +# no invocation of FEATURE-TEST sets $ac_cv_path_VARIABLE to the +# path of an acceptable program, ACTION-IF-NOT-FOUND is executed. +# FEATURE-TEST is invoked even when $ac_cv_path_VARIABLE is set, +# in case a better candidate occurs later in PATH; to accept the +# current setting and bypass further checks, FEATURE-TEST can set +# $ac_path_VARIABLE_found=':'. Note that, unlike AC_CHECK_PROGS, +# this macro does not have any side effect on the current value +# of VARIABLE. +m4_define([AC_PATH_PROGS_FEATURE_CHECK], +[_$0([$1], [$2], [$3], m4_default([$4], [:]), [$5])dnl +]) + + # _AC_FEATURE_CHECK_LENGTH(PROGPATH, CACHE-VAR, CHECK-CMD, [MATCH-STRING]) # ------------------------------------------------------------------------ -# For use as the FEATURE-TEST argument to _AC_PATH_PROG_FEATURE_TEST. +# For use as the FEATURE-TEST argument to _AC_PATH_PROGS_FEATURE_TEST. # On each iteration run CHECK-CMD on an input file, storing the value # of PROGPATH in CACHE-VAR if the CHECK-CMD succeeds. The input file # is always one line, starting with only 10 characters, and doubling @@ -503,7 +522,7 @@ dnl # for best performing tool in a list breaks down. # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done - rm -f conftest.in conftest.tmp conftest.nl conftest.out]) + rm -f conftest.in conftest.tmp conftest.nl conftest.out])dnl ]) @@ -863,7 +882,7 @@ AC_DEFUN([AC_PROG_SED], done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed $as_unset ac_script || ac_script= - _AC_PATH_PROG_FEATURE_CHECK(SED, [sed gsed], + _AC_PATH_PROGS_FEATURE_CHECK(SED, [sed gsed], [_AC_FEATURE_CHECK_LENGTH([ac_path_SED], [ac_cv_path_SED], ["$ac_path_SED" -f conftest.sed])])]) SED="$ac_cv_path_SED" diff --git a/m4/m4.m4 b/m4/m4.m4 index 70b99f89..70f30767 100644 --- a/m4/m4.m4 +++ b/m4/m4.m4 @@ -1,4 +1,4 @@ -# m4.m4 serial 3 +# m4.m4 serial 4 dnl Copyright (C) 2000, 2006, 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -12,20 +12,29 @@ dnl with or without modifications, as long as this notice is preserved. # Also, check whether --error-output (through 1.4.x) or --debugfile (2.0) # is supported, and AC_SUBST M4_DEBUGFILE accordingly. AC_DEFUN([AC_PROG_GNU_M4], -[AC_PATH_PROGS([M4], [gm4 gnum4 m4], [m4]) -AC_CACHE_CHECK([whether m4 supports accurate traces], [ac_cv_prog_gnu_m4], -[ac_cv_prog_gnu_m4=no -dnl Creative quoting here to avoid raw dnl and ifdef in configure. -if test x"$M4" != x \ - && test -z "`echo if'def(mac,bug)d'nl | $M4 --trace=mac 2>&1`" ; then - ac_cv_prog_gnu_m4=yes -fi]) -if test $ac_cv_prog_gnu_m4 = yes ; then + [AC_ARG_VAR([M4], [Location of GNU M4 1.4.5 or later. Defaults to the first + program of `m4', `gm4', or `gnum4' on PATH that meets Autoconf needs.]) + AC_CACHE_CHECK([for GNU M4 that supports accurate traces], [ac_cv_path_M4], + [AC_PATH_PROGS_FEATURE_CHECK([M4], [m4 gm4 gnum4], + [dnl Creative quoting here to avoid raw dnl and ifdef in configure. + test -z "`echo if'def(mac,bug)d'nl | $ac_path_M4 --trace=mac 2>&1`" \ + && ac_cv_path_M4=$ac_path_M4 ac_path_M4_found=:], + [AC_MSG_ERROR([no acceptable m4 could be found in \$PATH. +GNU M4 1.4.5 or later is required; 1.4.8 is recommended])])]) + M4=$ac_cv_path_M4 AC_CACHE_CHECK([how m4 supports trace files], [ac_cv_prog_gnu_m4_debugfile], - [case `$M4 --help < /dev/null 2>&1` in - *debugfile*) ac_cv_prog_gnu_m4_debugfile=--debugfile ;; - *) ac_cv_prog_gnu_m4_debugfile=--error-output ;; - esac]) - AC_SUBST([M4_DEBUGFILE], $ac_cv_prog_gnu_m4_debugfile) -fi + [case `$M4 --help < /dev/null 2>&1` in + *debugfile*) ac_cv_prog_gnu_m4_debugfile=--debugfile ;; + *) ac_cv_prog_gnu_m4_debugfile=--error-output ;; + esac]) + AC_SUBST([M4_DEBUGFILE], [$ac_cv_prog_gnu_m4_debugfile]) ]) + +# Compatibility for bootstrapping with Autoconf 2.61. +dnl FIXME - replace this with AC_PREREQ([2.62]) after the release. +# AC_PATH_PROGS_FEATURE_CHECK was added the same time the slightly broken, +# undocumented _AC_PATH_PROG_FEATURE_CHECK was deleted. +m4_ifndef([AC_PATH_PROGS_FEATURE_CHECK], + [m4_define([AC_PATH_PROGS_FEATURE_CHECK], + [_AC_PATH_PROG_FEATURE_CHECK([$1], [$2], [$3], [$5]) +])]) diff --git a/tests/mktests.sh b/tests/mktests.sh index f804056a..a7145e99 100755 --- a/tests/mktests.sh +++ b/tests/mktests.sh @@ -2,7 +2,7 @@ # Build some of the Autoconf test files. -# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software +# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software # Foundation, Inc. # This program is free software; you can redistribute it and/or modify @@ -91,6 +91,7 @@ ac_exclude_list=' # Performed in the semantics tests. /^AC_CHECK_(ALIGNOF|DECL|FILE|FUNC|HEADER|LIB|MEMBER|PROG|SIZEOF|(TARGET_)?TOOL|TYPE)S?$/ {next} + /^AC_PATH_PROGS_FEATURE_CHECK$/ {next} # Fail when the source does not exist. /^AC_CONFIG/ {next} @@ -202,7 +203,8 @@ do ## Do not edit by hand. ## ## --------------------- ## - # Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + # Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007 Free Software + # Foundation, Inc. AT_BANNER([Testing autoconf/$base macros.]) diff --git a/tests/semantics.at b/tests/semantics.at index 4c294a88..68553650 100644 --- a/tests/semantics.at +++ b/tests/semantics.at @@ -548,6 +548,79 @@ AT_CLEANUP +# ----------------------------- # +# AC_PATH_PROGS_FEATURE_CHECK. # +# ----------------------------- # + +AT_SETUP([AC_PATH_PROGS_FEATURE_CHECK]) + +AT_CHECK_PROGS_PREPARE + +AT_DATA([configure.ac], +[[AC_INIT +pwd=`pwd` +p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6" +path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'` +fail=false + +# Find first candidate and stop search +AC_PATH_PROGS_FEATURE_CHECK(TOOL1, [tool better], + [$ac_path_TOOL1 && ac_cv_path_TOOL1=$ac_path_TOOL1 ac_path_TOOL1_found=:], + fail=:, $path) +test -z "$TOOL1" || fail=: +test "$ac_cv_path_TOOL1" = "$pwd/path/1/tool" || fail=: + +# Keep searching each candidate +AC_PATH_PROGS_FEATURE_CHECK(TOOL2, [tool better], + [$ac_path_TOOL2 && ac_cv_path_TOOL2=$ac_path_TOOL2], + fail=:, $path) +test "$ac_cv_path_TOOL2" = "$pwd/path/6/better" || fail=: + +# Only accept better candidate +AC_PATH_PROGS_FEATURE_CHECK(TOOL3, [tool better], + [case "$ac_path_TOOL3" in #( + *better) ac_cv_path_TOOL3=$ac_path_TOOL3;; + esac], + fail=:, $path) +test "$ac_cv_path_TOOL3" = "$pwd/path/6/better" || fail=: + +# When a tool is not found, and no action is given for not-found, +# the variable is left empty. +AC_PATH_PROGS_FEATURE_CHECK(TOOL4, missing, + [ac_cv_path_TOOL4=$ac_path_TOOL4], [], $path) +test -z "$ac_cv_path_TOOL4" || fail=: + +# Test action when tool is not found +AC_PATH_PROGS_FEATURE_CHECK(TOOL5, missing, [], + [ac_cv_path_TOOL5='not found'], $path) +test "$ac_cv_path_TOOL5" = "not found" || fail=: + +# Test that pre-set tool bypasses feature test +TOOL6=$pwd/path/6/better +AC_PATH_PROGS_FEATURE_CHECK(TOOL6, tool, fail=:, fail=:, $path) +test "$ac_cv_path_TOOL6" = "$pwd/path/6/better" || fail=: + +# A blank pre-set does not bypass feature test +TOOL7= +AC_PATH_PROGS_FEATURE_CHECK(TOOL7, [tool better], + [$ac_path_TOOL7 && ac_cv_path_TOOL7=$ac_path_TOOL7 ac_path_TOOL7_found=:], + fail=:, $path) +test -z "$TOOL7" || fail=: +test "$ac_cv_path_TOOL7" = "$pwd/path/1/tool" || fail=: + +# No AC-OUTPUT, we don't need config.status. +$fail && + AC_MSG_ERROR([[PATH_PROG failed]]) +AS_EXIT(0) +]]) + +AT_CHECK_AUTOCONF +AT_CHECK_CONFIGURE + +AT_CLEANUP + + + ## -------------- ## ## AC_PATH_XTRA. ##