autoconf-patches
[Top][All Lists]
Advanced

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

AC_PATH_PROGS_FEATURE_CHECK [was: Bug in gnulib-tools prevents bison fro


From: Eric Blake
Subject: AC_PATH_PROGS_FEATURE_CHECK [was: Bug in gnulib-tools prevents bison from bootstrapping]
Date: Sat, 01 Sep 2007 21:35:28 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070728 Thunderbird/2.0.0.6 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Noah Misch on 8/31/2007 8:23 PM:
> 
> Let's not second-guess the user.  It's nice to be able to easily override the
> configuration heuristic when it gets in the way.

That was my conclusion, too.

> 
>> How about the following two prototypes, then?
>>
>> # AC_PATH_PROGS_FEATURE_CHECK(VARIABLE, PROGNAME-LIST,
>> #                             FEATURE-TEST, [ACTION-IF-NOT_FOUND],
>> #                             [PATH=$PATH])
> 
> My inclination is to keep only this one, and to leave it to the user to 
> AC_SUBST
> the variable, if desired.

How about the following, then?

2007-09-01  Eric Blake  <address@hidden>

        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.  Make
        it clear that optional path parameter defaults to $PATH.
        * 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.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG2i9/84KuGfSFAYARAi8jAKCqryZCHNg8Jh5Sd2yXny1GrQgMkACfa2zu
7H1P7fb5Tjqbitjdy/8eoOY=
=DaRe
-----END PGP SIGNATURE-----
Index: NEWS
===================================================================
RCS file: /sources/autoconf/autoconf/NEWS,v
retrieving revision 1.432
diff -u -p -r1.432 NEWS
--- NEWS        20 Jul 2007 23:11:49 -0000      1.432
+++ NEWS        2 Sep 2007 03:34:02 -0000
@@ -1,6 +1,8 @@
+GNU Autoconf NEWS - User visible changes.
+
 * Major changes in Autoconf 2.61b (????-??-??)
 
-** 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.
 
@@ -24,7 +26,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.
Index: THANKS
===================================================================
RCS file: /sources/autoconf/autoconf/THANKS,v
retrieving revision 1.140
diff -u -p -r1.140 THANKS
--- THANKS      21 Aug 2007 20:23:17 -0000      1.140
+++ THANKS      2 Sep 2007 03:34:02 -0000
@@ -83,6 +83,7 @@ Gregory Giannoni            address@hidden
 Guido Draheim               address@hidden
 Guido Flohr                 address@hidden
 Guillermo Gomez             address@hidden
+Hans Aberg                  address@hidden
 Hans Olsson                 address@hidden
 Harlan Stenn                address@hidden
 Henk Krus                   address@hidden
Index: configure.ac
===================================================================
RCS file: /sources/autoconf/autoconf/configure.ac,v
retrieving revision 1.89
diff -u -p -r1.89 configure.ac
--- configure.ac        20 Jul 2007 23:11:50 -0000      1.89
+++ configure.ac        2 Sep 2007 03:34:02 -0000
@@ -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.  ##
@@ -154,10 +151,10 @@ AC_PROG_SED
 ## ------------ ##
 
 AC_CONFIG_FILES([Makefile doc/Makefile
-                 lib/Makefile lib/Autom4te/Makefile lib/autoscan/Makefile
-                 lib/m4sugar/Makefile
-                 lib/autoconf/Makefile lib/autotest/Makefile
-                 bin/Makefile])
+                lib/Makefile lib/Autom4te/Makefile lib/autoscan/Makefile
+                lib/m4sugar/Makefile
+                lib/autoconf/Makefile lib/autotest/Makefile
+                bin/Makefile])
 
 AC_OUTPUT
 # Report the state of this version of Autoconf if this is a beta.
Index: doc/autoconf.texi
===================================================================
RCS file: /sources/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.1166
diff -u -p -r1.1166 autoconf.texi
--- doc/autoconf.texi   22 Aug 2007 05:00:47 -0000      1.1166
+++ doc/autoconf.texi   2 Sep 2007 03:34:03 -0000
@@ -3837,16 +3837,19 @@ instead, like this:
 
 @example
 AC_PATH_PROG([INETD], [inetd], [/usr/libexec/inetd],
-             [$PATH:/usr/libexec:/usr/sbin:/usr/etc:/etc])
+             [$PATH$PATH_SEPARATOR/usr/libexec$PATH_SEPARATOR]dnl
+[/usr/sbin$PATH_SEPARATOR/usr/etc$PATH_SEPARATOR/etc])
 @end example
 
 You are strongly encouraged to declare the @var{variable} passed to
 @code{AC_CHECK_PROG} etc.@: as precious, @xref{Setting Output Variables},
 @code{AC_ARG_VAR}, for more details.
 
address@hidden AC_CHECK_PROG (@var{variable}, @var{prog-to-check-for}, 
@var{value-if-found}, @ovar{value-if-not-found}, @ovar{path},  @ovar{reject})
address@hidden AC_CHECK_PROG (@var{variable}, @var{prog-to-check-for}, @
+  @var{value-if-found}, @ovar{value-if-not-found}, @
+  @dvar{path, $PATH}, @ovar{reject})
 @acindex{CHECK_PROG}
-Check whether program @var{prog-to-check-for} exists in @env{PATH}.  If
+Check whether program @var{prog-to-check-for} exists in @var{path}.  If
 it is found, set @var{variable} to @var{value-if-found}, otherwise to
 @var{value-if-not-found}, if given.  Always pass over @var{reject} (an
 absolute file name) even if it is the first found in the search path; in
@@ -3856,10 +3859,11 @@ that case, set @var{variable} using the 
 @var{variable}.
 @end defmac
 
address@hidden AC_CHECK_PROGS (@var{variable}, @var{progs-to-check-for}, 
@ovar{value-if-not-found}, @ovar{path})
address@hidden AC_CHECK_PROGS (@var{variable}, @var{progs-to-check-for}, @
+  @ovar{value-if-not-found}, @dvar{path, $PATH})
 @acindex{CHECK_PROGS}
 Check for each program in the blank-separated list
address@hidden existing in the @env{PATH}.  If one is found, set
address@hidden existing in the @var{path}.  If one is found, set
 @var{variable} to the name of that program.  Otherwise, continue
 checking the next program in the list.  If none of the programs in the
 list are found, set @var{variable} to @var{value-if-not-found}; if
@@ -3867,7 +3871,8 @@ list are found, set @var{variable} to @v
 is not changed.  Calls @code{AC_SUBST} for @var{variable}.
 @end defmac
 
address@hidden AC_CHECK_TARGET_TOOL (@var{variable}, @var{prog-to-check-for}, 
@ovar{value-if-not-found}, @ovar{path})
address@hidden AC_CHECK_TARGET_TOOL (@var{variable}, @var{prog-to-check-for}, @
+  @ovar{value-if-not-found}, @dvar{path, $PATH})
 @acindex{CHECK_TARGET_TOOL}
 Like @code{AC_CHECK_PROG}, but first looks for @var{prog-to-check-for}
 with a prefix of the target type as determined by
@@ -3884,7 +3889,8 @@ compiler driver @r{(@command{gcc} for th
 uses to produce objects, archives or executables}.
 @end defmac
 
address@hidden AC_CHECK_TOOL (@var{variable}, @var{prog-to-check-for}, 
@ovar{value-if-not-found}, @ovar{path})
address@hidden AC_CHECK_TOOL (@var{variable}, @var{prog-to-check-for}, @
+  @ovar{value-if-not-found}, @dvar{path, $PATH})
 @acindex{CHECK_TOOL}
 Like @code{AC_CHECK_PROG}, but first looks for @var{prog-to-check-for}
 with a prefix of the host type as determined by
@@ -3896,8 +3902,8 @@ AC_CHECK_TOOL([RANLIB], [ranlib], [:])
 @end example
 @noindent
 sets @code{RANLIB} to @file{i386-gnu-ranlib} if that program exists in
address@hidden, or otherwise to @samp{ranlib} if that program exists in
address@hidden, or to @samp{:} if neither program exists.
address@hidden, or otherwise to @samp{ranlib} if that program exists in
address@hidden, or to @samp{:} if neither program exists.
 
 In the future, when cross-compiling this macro will @emph{only}
 accept program names that are prefixed with the host type.
@@ -3905,7 +3911,8 @@ For more information, see @ref{Specifyin
 system type}.
 @end defmac
 
address@hidden AC_CHECK_TARGET_TOOLS (@var{variable}, @var{progs-to-check-for}, 
@ovar{value-if-not-found}, @ovar{path})
address@hidden AC_CHECK_TARGET_TOOLS (@var{variable}, @var{progs-to-check-for}, 
@
+  @ovar{value-if-not-found}, @dvar{path, $PATH})
 @acindex{CHECK_TARGET_TOOLS}
 Like @code{AC_CHECK_TARGET_TOOL}, each of the tools in the list
 @var{progs-to-check-for} are checked with a prefix of the target type as
@@ -3919,7 +3926,8 @@ is not specified, the value of @var{vari
 @code{AC_SUBST} for @var{variable}.
 @end defmac
 
address@hidden AC_CHECK_TOOLS (@var{variable}, @var{progs-to-check-for}, 
@ovar{value-if-not-found}, @ovar{path})
address@hidden AC_CHECK_TOOLS (@var{variable}, @var{progs-to-check-for}, @
+  @ovar{value-if-not-found}, @dvar{path, $PATH})
 @acindex{CHECK_TOOLS}
 Like @code{AC_CHECK_TOOL}, each of the tools in the list
 @var{progs-to-check-for} are checked with a prefix of the host type as
@@ -3935,26 +3943,73 @@ In the future, when cross-compiling this
 accept program names that are not prefixed with the host type.
 @end defmac
 
address@hidden AC_PATH_PROG (@var{variable}, @var{prog-to-check-for}, 
@ovar{value-if-not-found}, @ovar{path})
address@hidden AC_PATH_PROG (@var{variable}, @var{prog-to-check-for}, @
+  @ovar{value-if-not-found}, @dvar{path, $PATH})
 @acindex{PATH_PROG}
 Like @code{AC_CHECK_PROG}, but set @var{variable} to the absolute
 name of @var{prog-to-check-for} if found.
 @end defmac
 
address@hidden AC_PATH_PROGS (@var{variable}, @var{progs-to-check-for}, 
@ovar{value-if-not-found}, @ovar{path})
address@hidden AC_PATH_PROGS (@var{variable}, @var{progs-to-check-for}, @
+  @ovar{value-if-not-found}, @dvar{path, $PATH})
 @acindex{PATH_PROGS}
 Like @code{AC_CHECK_PROGS}, but if any of @var{progs-to-check-for}
 are found, set @var{variable} to the absolute name of the program
 found.
 @end defmac
 
address@hidden AC_PATH_TARGET_TOOL (@var{variable}, @var{prog-to-check-for}, 
@ovar{value-if-not-found}, @ovar{path})
address@hidden AC_PATH_PROGS_FEATURE_CHECK (@var{variable}, @
+  @var{progs-to-check-for}, @var{feature-test}, @
+  @ovar{action-if-not-found}, @dvar{path, $PATH})
address@hidden
+This macro was introduced in Autoconf 2.62.  If @var{variable} is not
+empty, then set the cache variable @address@hidden 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 @address@hidden
+set to the absolute name of the candidate program.  If no invocation of
address@hidden sets the shell variable
address@hidden@var{variable}}, then @var{action-if-not-found} is
+executed.  @var{feature-test} will be run even when
address@hidden@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 @address@hidden:}.
+
+Note that this macro has some subtle differences from
address@hidden  It is designed to be run inside
address@hidden, therefore, it should have no side effect.  In
+particular, @var{variable} is not set to the final value of
address@hidden@var{variable}}, nor is @code{AC_SUBST} automatically
+run.  Also, on failure, any action can be performed, whereas
address@hidden only performs
address@hidden@address@hidden
+
+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
address@hidden or is not the first implementation on @env{PATH}.
+
address@hidden
+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])
address@hidden example
address@hidden defmac
+
address@hidden AC_PATH_TARGET_TOOL (@var{variable}, @var{prog-to-check-for}, @
+  @ovar{value-if-not-found}, @dvar{path, $PATH})
 @acindex{PATH_TARGET_TOOL}
 Like @code{AC_CHECK_TARGET_TOOL}, but set @var{variable} to the absolute
 name of the program if it is found.
 @end defmac
 
address@hidden AC_PATH_TOOL (@var{variable}, @var{prog-to-check-for}, 
@ovar{value-if-not-found}, @ovar{path})
address@hidden AC_PATH_TOOL (@var{variable}, @var{prog-to-check-for}, @
+  @ovar{value-if-not-found}, @dvar{path, $PATH})
 @acindex{PATH_TOOL}
 Like @code{AC_CHECK_TOOL}, but set @var{variable} to the absolute
 name of the program if it is found.
Index: lib/autoconf/programs.m4
===================================================================
RCS file: /sources/autoconf/autoconf/lib/autoconf/programs.m4,v
retrieving revision 1.67
diff -u -p -r1.67 programs.m4
--- lib/autoconf/programs.m4    20 Jul 2007 23:11:53 -0000      1.67
+++ lib/autoconf/programs.m4    2 Sep 2007 03:34:03 -0000
@@ -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])
+])
+
+
 # _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 li
     # 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"
Index: m4/m4.m4
===================================================================
RCS file: /sources/autoconf/autoconf/m4/m4.m4,v
retrieving revision 1.7
diff -u -p -r1.7 m4.m4
--- m4/m4.m4    2 Feb 2007 14:07:38 -0000       1.7
+++ m4/m4.m4    2 Sep 2007 03:34:03 -0000
@@ -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 lo
 # 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_REQUIRE([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])
+])])
Index: tests/mktests.sh
===================================================================
RCS file: /sources/autoconf/autoconf/tests/mktests.sh,v
retrieving revision 1.61
diff -u -p -r1.61 mktests.sh
--- tests/mktests.sh    20 Jul 2007 23:11:55 -0000      1.61
+++ tests/mktests.sh    2 Sep 2007 03:34:03 -0000
@@ -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.])
 
Index: tests/semantics.at
===================================================================
RCS file: /sources/autoconf/autoconf/tests/semantics.at,v
retrieving revision 1.64
diff -u -p -r1.64 semantics.at
--- tests/semantics.at  20 Jul 2007 23:11:55 -0000      1.64
+++ tests/semantics.at  2 Sep 2007 03:34:03 -0000
@@ -548,6 +548,71 @@ 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=:
+
+# 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.  ##

reply via email to

[Prev in Thread] Current Thread [Next in Thread]