autoconf-patches
[Top][All Lists]
Advanced

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

[PATCH 1/2] Improve handling of missing aux scripts.


From: Zack Weinberg
Subject: [PATCH 1/2] Improve handling of missing aux scripts.
Date: Tue, 20 Oct 2020 17:04:34 -0400

Another regression identified by the Debian archive rebuild was that
more macros require the presence of config.sub and config.guess now.
‘autoreconf --install’ doesn’t install these itself, it relies on
‘automake --add-missing’ to do that; so, packages that don’t use
Automake will fail at the configure stage after configure is
regenerated.  To make matters worse, AC_CONFIG_AUX_DIRS assumes that
everyone who needs config.sub and config.guess also needs install-sh,
so in about half of the affected packages, the failure manifested as a
complaint about install-sh being missing -- technically true but
adding install-sh wouldn’t have resolved the problem by itself.

This patch overhauls the AC_CONFIG_AUX_DIR(S) mechanism so that a
configure script knows the complete set of aux scripts that were
AC_REQUIRE_AUX_FILE’d for it, checks for the existence of all of
them, and not any others.  Thus, this configure script

    AC_INIT([test], [1.0])
    AC_FUNC_MALLOC
    AC_CONFIG_HEADERS([config.h])
    AC_OUTPUT

will work fine in a directory that contains config.sub and
config.guess but not install-sh.  Also, if it’s in a directory
that *doesn’t* contain config.sub and config.guess, it will print an
accurate error message

    configure: error: cannot find required auxiliary files: config.guess 
config.sub

instead of the misleading

    configure: error: cannot find install-sh, install.sh, or shtool in "." 
"./.." "./../.."

A side-effect: it doesn’t make sense for AC_CONFIG_SUBDIRS to demand
the presence of Cygnus configure in the aux dir, on the off-chance
that one of the subdirectories *might* be using it -- I have no idea
where someone would even get a copy of that nowadays -- so I dropped
that feature.  I rather suspect nobody has needed it in over a decade.

I also documented the expanded need for config.sub and config.guess in
NEWS as well as the manual.

I will commit these patches tomorrow afternoon if I don't hear any
comments by then.

zw

* NEWS: Document expanded need for config.sub and config.guess.
  Document removed support for Cygnus configure in subdirectories.

* doc/autoconf.texi: Clarify exactly when install-sh, config.sub,
  and/or config.guess are required.  Document canonical online sources
  for these scripts.  Revise documentation of AC_CONFIG_AUX_DIR and
  AC_REQUIRE_AUX_FILE.  Minor improvements to documentation of
  AC_CONFIG_SRCDIR.  Remove mentions of Cygnus configure in
  subdirectories.

* lib/autoconf/general.m4
  (_AC_INIT_PARSE_ARGS): Remove mention of Cygnus configure;
  clarify function of configure.gnu.
  (AC_CONFIG_AUX_DIR): Support multiple invocations.
  (AC_CONFIG_AUX_DIRS): Now an undocumented compatibility interface
  rather than an internal subroutine; just runs AC_CONFIG_AUX_DIR on
  each of its arguments.
  (AC_CONFIG_AUX_DIR_DEFAULT): Now a backward compatibility stub that
  requires _AC_INIT_AUX_DIR without adding anything to _AC_AUX_FILES.

  (AC_REQUIRE_AUX_FILE): Now adds the named aux file to _AC_AUX_FILES
  and requires _AC_INIT_AUX_DIR, as well as being a trace hook.

  (_AC_INIT_AUX_DIR): New home of the loop searching for necessary aux
  files (formerly in AC_CONFIG_AUX_DIRS).  Looks for all the necessary
  aux files, not just for install-sh.

  (ac_config_guess, ac_config_sub, ac_configure): Issue deprecation
  warnings if these undocumented shell variables are actually used.

  (AC_CANONICAL_BUILD, AC_CANONICAL_HOST, AC_CANONICAL_TARGET):
  No need to require AC_CONFIG_AUX_DIR_DEFAULT.
  Can rely on $ac_aux_dir ending with a slash.

  * lib/autoconf/programs.m4 (AC_PROG_INSTALL, AC_PROG_MKDIR_P):
  No need to require AC_CONFIG_AUX_DIR_DEFAULT.

  * lib/autoconf/status.m4 (_AC_CONFIG_SUBDIRS):
  No need to require AC_CONFIG_AUX_DIR_DEFAULT.
  Remove check for Cygnus configure; clarify function of configure.gnu.

  * lib/autotest/general.m4: Remove mention of Cygnus configure.

  * tests/torture.at (Missing auxiliary files): New test.
---
 NEWS                     |  37 ++++++
 doc/autoconf.texi        | 196 ++++++++++++++++---------------
 lib/autoconf/general.m4  | 242 ++++++++++++++++++++++++++++-----------
 lib/autoconf/programs.m4 |   6 +-
 lib/autoconf/status.m4   |   7 +-
 lib/autotest/general.m4  |   2 -
 tests/torture.at         |  38 ++++++
 7 files changed, 360 insertions(+), 168 deletions(-)

diff --git a/NEWS b/NEWS
index 356a28b0..1883faab 100644
--- a/NEWS
+++ b/NEWS
@@ -47,8 +47,31 @@ GNU Autoconf NEWS - User visible changes.
    - AC_REQUIRE cannot be applied to macros that need to be used with
      arguments.  Instead, invoke the macro normally, with its arguments.
 
+*** More macros use config.sub and config.guess internally.
+
+  As a consequence of improved support for cross compilation (see below),
+  more macros now use the auxiliary scripts ‘config.sub’ and ‘config.guess’.
+  If you use any of the affected macros, these scripts must be available
+  when your configure script is run, even if you have no intention of
+  ever cross-compiling your program.
+
+  If you are using Automake, the auxiliary scripts your configure script
+  needs will be added to your source tree by ‘autoreconf --install’ or
+  ‘automake --add-missing’, and will be automatically included in your
+  distribution tarball.  If you are not using Automake, you will need
+  to add them yourself.  See the “Input” section of the manual for
+  where to get the auxiliary scripts that may be needed by autoconf macros.
+
 *** Older versions of automake and aclocal (< 1.8) are no longer supported.
 
+*** AC_CONFIG_SUBDIRS no longer directly supports Cygnus configure.
+
+  If you are still using an Autoconf script to drive configuration of
+  a multi-package build tree where some subdirectories use Cygnus
+  configure, copy or link $ac_aux_dir/configure into each subdirectory
+  where it is needed.  Please also contact us; we were under the
+  impression nobody used this very old tool anymore.
+
 *** AC_CHECK_HEADER and AC_CHECK_HEADERS only do a compilation test.
 
   This completes the transition from preprocessor-based header tests
@@ -188,6 +211,20 @@ GNU Autoconf NEWS - User visible changes.
   useful effect is to trigger those checks, with this macro.  It is
   unlikely to be useful otherwise.
 
+*** AC_REQUIRE_AUX_FILE has been improved.
+
+  Configure scripts now check, on startup, for the availability of all
+  the aux files that were mentioned in an AC_REQUIRE_AUX_FILE
+  invocation.  This should help prevent certain classes of packaging
+  errors.
+
+  Also, it is no longer necessary for third-party macros that use
+  AC_REQUIRE_AUX_FILE to mention AC_CONFIG_AUX_DIR_DEFAULT.  However,
+  if you are using AC_CONFIG_AUX_DIR_DEFAULT *without* also using
+  AC_REQUIRE_AUX_FILE, please start using AC_REQUIRE_AUX_FILE to
+  specify the aux files you actually need, so that the check can be
+  effective.
+
 ** Obsolete features and new warnings
 
 *** Use of the long-deprecated name ‘configure.in’ for the autoconf
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 9a52fbdb..21bc1af9 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -2041,81 +2041,27 @@ Notices
 
 
 @node Input
-@section Finding @command{configure} Input
+@section Configure Input: Source Code, Macros, and Auxiliary Files
+
+The following macros help you manage the contents of your source tree.
 
 @anchor{AC_CONFIG_SRCDIR}
 @defmac AC_CONFIG_SRCDIR (@var{unique-file-in-source-dir})
 @acindex{CONFIG_SRCDIR}
-@var{unique-file-in-source-dir} is some file that is in the package's
-source directory; @command{configure} checks for this file's existence to
-make sure that the directory that it is told contains the source code in
-fact does.  Occasionally people accidentally specify the wrong directory
-with @option{--srcdir}; this is a safety check.  @xref{configure
-Invocation}, for more information.
+Distinguish this package's source directory from other source
+directories that might happen to exist in the filesystem.
+@var{unique-file-in-source-dir} should name a file that is unique to
+this package.  @command{configure} will verify that this file exists in
+@file{@var{srcdir}}, before it runs any other checks.
+
+Use of this macro is strongly recommended.  It protects against people
+accidentally specifying the wrong directory with @option{--srcdir}.
+@xref{configure Invocation}, for more information.
 @end defmac
 
-
-@c FIXME: Remove definitively once --install explained.
-@c
-@c Small packages may store all their macros in @code{aclocal.m4}.  As the
-@c set of macros grows, or for maintenance reasons, a maintainer may prefer
-@c to split the macros in several files.  In this case, Autoconf must be
-@c told which files to load, and in which order.
-@c
-@c @defmac AC_INCLUDE (@var{file}@dots{})
-@c @acindex{INCLUDE}
-@c @c FIXME: There is no longer shell globbing.
-@c Read the macro definitions that appear in the listed files.  A list of
-@c space-separated file names or shell globbing patterns is expected.  The
-@c files are read in the order they're listed.
-@c
-@c Because the order of definition of macros is important (only the last
-@c definition of a macro is used), beware that it is @code{AC_INIT} that
-@c loads @file{acsite.m4} and @file{aclocal.m4}.  Note that
-@c @code{AC_INCLUDE}ing a file before @code{AC_INIT} or within
-@c @file{aclocal.m4} is different from doing so after @code{AC_INIT}: in
-@c the latter case, non-macro lines from included files may end up in the
-@c @file{configure} script, whereas in the former case, they'd be discarded
-@c just like any text that appear before @code{AC_INIT}.
-@c @end defmac
-
-Packages that do manual configuration or use the @command{install} program
-might need to tell @command{configure} where to find some other shell
-scripts by calling @code{AC_CONFIG_AUX_DIR}, though the default places
-it looks are correct for most cases.
-
-@defmac AC_CONFIG_AUX_DIR (@var{dir})
-@acindex{CONFIG_AUX_DIR}
-Use the auxiliary build tools (e.g., @file{install-sh},
-@file{config.sub}, @file{config.guess}, Cygnus @command{configure},
-Automake and Libtool scripts, etc.)@: that are in directory @var{dir}.
-These are auxiliary files used in configuration.  @var{dir} can be
-either absolute or relative to @file{@var{srcdir}}.  The default is
-@file{@var{srcdir}} or @file{@var{srcdir}/..} or
-@file{@var{srcdir}/../..}, whichever is the first that contains
-@file{install-sh}.  The other files are not checked for, so that using
-@code{AC_PROG_INSTALL} does not automatically require distributing the
-other auxiliary files.  It checks for @file{install.sh} also, but that
-name is obsolete because some @command{make} have a rule that creates
-@file{install} from it if there is no makefile.
-
-The auxiliary directory is commonly named @file{build-aux}.
-If you need portability to DOS variants, do not name the
-auxiliary directory @file{aux}.  @xref{File System Conventions}.
-@end defmac
-
-@defmac AC_REQUIRE_AUX_FILE (@var{file})
-@acindex{REQUIRE_AUX_FILE}
-Declares that @var{file} is expected in the directory defined above.  In
-Autoconf proper, this macro does nothing: its sole purpose is to be
-traced by third-party tools to produce a list of expected auxiliary
-files.  For instance it is called by macros like @code{AC_PROG_INSTALL}
-(@pxref{Particular Programs}) or @code{AC_CANONICAL_BUILD}
-(@pxref{Canonicalizing}) to register the auxiliary files they need.
-@end defmac
-
-Similarly, packages that use @command{aclocal} should declare where
-local macros can be found using @code{AC_CONFIG_MACRO_DIRS}.
+Packages that use @command{aclocal} to generate @file{aclocal.m4}
+should declare where local macros can be found using
+@code{AC_CONFIG_MACRO_DIRS}.
 
 @defmac AC_CONFIG_MACRO_DIRS (@var{dir1} [@var{dir2} ... @var{dirN}])
 @defmacx AC_CONFIG_MACRO_DIR (@var{dir})
@@ -2158,6 +2104,68 @@ Input
 without any backslash-newlines.
 @end defmac
 
+@prindex @command{config.guess}
+@prindex @command{config.sub}
+@prindex @command{install-sh}
+
+Some Autoconf macros require auxiliary scripts.  @code{AC_PROG_INSTALL}
+and @code{AC_PROG_@w{MKDIR_P}} (@pxref{Particular Programs}) require a
+fallback implementation of @command{install} called @file{install-sh},
+and the @code{AC_CANONICAL} macros (@pxref{Manual Configuration})
+require the system-identification scripts @file{config.sub} and
+@file{config.guess}.  Third-party tools, such as Automake and Libtool,
+may require additional auxiliary scripts.
+
+By default, @command{configure} looks for these scripts next to itself,
+in @file{@var{srcdir}}.  For convenience when working with subdirectories
+with their own configure scripts (@pxref{Subdirectories}), if the
+scripts are not in @file{@var{srcdir}} it will also look in
+@file{@var{srcdir}/..} and @file{@var{srcdir}/../..}.  All of the
+scripts must be found in the same directory.
+
+If these default locations are not adequate, or simply to reduce clutter
+at the top level of the source tree, packages can use
+@code{AC_CONFIG_AUX_DIR} to declare where to look for auxiliary scripts.
+
+@defmac AC_CONFIG_AUX_DIR (@var{dir})
+@acindex{CONFIG_AUX_DIR}
+Look for auxiliary scripts in @var{dir}.  Normally, @var{dir} should be a
+relative path, which is taken as relative to @file{@var{srcdir}}.
+If @var{dir} is an absolute path or contains shell variables, however,
+it is used as-is.
+
+When the goal of using @code{AC_CONFIG_AUX_DIR} is to reduce clutter at
+the top level of the source tree, the conventional name for @var{dir} is
+@file{build-aux}.  If you need portability to DOS variants, do not name
+the auxiliary directory @file{aux}.  @xref{File System Conventions}.
+@end defmac
+
+@defmac AC_REQUIRE_AUX_FILE (@var{file})
+@acindex{REQUIRE_AUX_FILE}
+@vrindex ac_aux_dir
+Declare that @var{file} is an auxiliary script needed by this configure
+script, and set the shell variable @code{ac_aux_dir} to the directory
+where it can be found.  The value of @code{ac_aux_dir} is guaranteed to
+end with a @samp{/}.
+
+Macros that need auxiliary scripts must use this macro to register each
+script they need.
+@end defmac
+
+Some third-party tools can install and update auxiliary scripts in your
+source tree for you; for instance, Automake's @option{--add-missing}
+mode does this for many commonly-needed scripts, including
+@file{install-sh}, @file{config.sub}, and @file{config.guess}.
+If you are only using Autoconf, however, you will need to add auxiliary
+scripts to your source tree yourself, and arrange for them to be
+included in release tarballs.
+@command{configure} will report any missing scripts when run.
+
+The scripts needed by Autoconf core macros are included with the
+Autoconf source tree.  @file{install-sh} can be downloaded from
+@url{https://git.savannah.gnu.org/cgit/automake.git/plain/lib/install-sh}.
+@file{config.sub} and @file{config.guess} can be downloaded from
+@url{https://git.savannah.gnu.org/cgit/config.git/tree/}.
 
 @node Output
 @section Outputting Files
@@ -3759,14 +3767,11 @@ Subdirectories
 fi
 @end example
 
-@c NB: Yes, below we mean configure.in, not configure.ac.
 If a given @var{dir} contains @command{configure.gnu}, it is run instead
 of @command{configure}.  This is for packages that might use a
 non-Autoconf script @command{Configure}, which can't be called through a
 wrapper @command{configure} since it would be the same file on
-case-insensitive file systems.  Likewise, if a @var{dir} contains
-@file{configure.in} but no @command{configure}, the Cygnus
-@command{configure} script found by @code{AC_CONFIG_AUX_DIR} is used.
+case-insensitive file systems.
 
 The subdirectory @command{configure} scripts are given the same command
 line options that were given to this @command{configure} script, with minor
@@ -4098,6 +4103,7 @@ Particular Programs
 @ovindex INSTALL_DATA
 @ovindex INSTALL_SCRIPT
 @caindex path_install
+@prindex @command{install-sh}
 Set output variable @code{INSTALL} to the name of a BSD-compatible
 @command{install} program, if one is found in the current @env{PATH}.
 Otherwise, set @code{INSTALL} to @samp{@var{dir}/install-sh -c},
@@ -4117,14 +4123,14 @@ Particular Programs
 macro requires @command{install} to be able to install multiple files into a
 target directory in a single invocation.
 
-Autoconf comes with a copy of @file{install-sh} that you can use.  If
-you use @code{AC_PROG_INSTALL}, you must include either
-@file{install-sh} or @file{install.sh} in your distribution; otherwise
-@command{configure} produces an error message saying it can't find
-them---even if the system you're on has a good @command{install} program.
-This check is a safety measure to prevent you from accidentally leaving
-that file out, which would prevent your package from installing on
-systems that don't have a BSD-compatible @command{install} program.
+Autoconf comes with a copy of @file{install-sh} that you can use.
+If you use @code{AC_PROG_INSTALL}, you must include @file{install-sh}
+in your distribution; otherwise @command{configure} produces an error
+message saying it can't find it---even if the system you're on has a
+good @command{install} program.  This check is a safety measure to
+prevent you from accidentally leaving that file out, which would prevent
+your package from installing on systems that don't have a BSD-compatible
+@command{install} program.
 
 If you need to use your own installation program because it has features
 not found in standard @command{install} programs, there is no reason to use
@@ -4139,6 +4145,7 @@ Particular Programs
 @acindex{PROG_MKDIR_P}
 @ovindex MKDIR_P
 @caindex path_mkdir
+@prindex @command{install-sh}
 Set output variable @code{MKDIR_P} to a program that ensures that for
 each argument, a directory named by this argument exists, creating it
 and its parent directories if needed, and without race conditions when
@@ -22033,11 +22040,22 @@ Manual Configuration
 
 A few kinds of features can't be guessed automatically by running test
 programs.  For example, the details of the object-file format, or
-special options that need to be passed to the compiler or linker.  You
-can check for such features using ad-hoc means, such as having
-@command{configure} check the output of the @code{uname} program, or
-looking for libraries that are unique to particular systems.  However,
-Autoconf provides a uniform method for handling unguessable features.
+special options that need to be passed to the compiler or linker.
+Autoconf provides a uniform method for handling unguessable features,
+by giving each operating system a @dfn{canonical system type}, also
+known as a @dfn{canonical name} or @dfn{target triplet}.
+
+@prindex @command{config.guess}
+@prindex @command{config.sub}
+
+If you use any of the macros described in this chapter, you must
+distribute the helper scripts @command{config.guess} and
+@command{config.sub} along with your source code.  Some Autoconf macros
+use these macros internally, so you may need to distribute these scripts
+even if you do not use any of these macros yourself.  @xref{Input}, for
+information about the @code{AC_CONFIG_AUX_DIR} macro which you can use
+to control in which directory @command{configure} looks for helper
+scripts, and where to get the scripts from.
 
 @menu
 * Specifying Target Triplets::  Specifying target triplets
@@ -22168,12 +22186,6 @@ Canonicalizing
 type, run the following macros to get canonical system names.  These
 variables are not set before the macro call.
 
-If you use these macros, you must distribute @command{config.guess} and
-@command{config.sub} along with your source code.  @xref{Output}, for
-information about the @code{AC_CONFIG_AUX_DIR} macro which you can use
-to control in which directory @command{configure} looks for those scripts.
-
-
 @defmac AC_CANONICAL_BUILD
 @acindex{CANONICAL_BUILD}
 @ovindex build
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index eaa1d91b..9baa22df 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -640,8 +640,6 @@ do
   *)    ac_optarg=yes ;;
   esac
 
-  # Accept the important Cygnus configure options, so we can diagnose typos.
-
   case $ac_dashdash$ac_option in
   --)
     ac_dashdash=yes ;;
@@ -1163,7 +1161,8 @@ if test "$ac_init_help" = "recursive"; then
       continue
     _AC_SRCDIRS(["$ac_dir"])
     cd "$ac_dir" || { ac_status=$?; continue; }
-    # Check for guested configure.
+    # Check for configure.gnu first; this name is used for a wrapper for
+    # Metaconfig's "Configure" on case-insensitive filesystems.
     if test -f "$ac_srcdir/configure.gnu"; then
       echo &&
       $SHELL "$ac_srcdir/configure.gnu" --help=recursive
@@ -1744,60 +1743,188 @@ 
program_transform_name=`AS_ECHO(["$program_transform_name"]) | sed "$ac_script"`
 
 # AC_CONFIG_AUX_DIR(DIR)
 # ----------------------
-# Find install-sh, config.sub, config.guess, and Cygnus configure
-# in directory DIR.  These are auxiliary files used in configuration.
-# DIR can be either absolute or relative to $srcdir.
+# Find auxiliary scripts (e.g. install-sh, config.sub, config.guess)
+# in DIR.  If DIR is a literal shell word and not an absolute path,
+# it is interpreted relative to $srcdir; otherwise it is assumed to be
+# usable as-is.  If this macro is used more than once, it builds up a
+# list of directories to search, first to last.  If this macro is not
+# used at all, the default is to look in $srcdir and two levels of
+# parent directories above $srcdir; see _AC_INIT_SRCDIR.
+#
+# This macro may be used as a trace hook by tools that wish to know
+# where the auxiliary files should be.
+#
+# Note: paths starting with a DOS drive letter count as absolute, but
+# we do *not* check for backslash as a directory separator, because
+# anything with a backslash in it will be considered non-literal by
+# AS_LITERAL_WORD_IF and won't reach the m4_bmatch.  This is correct
+# behavior, because DIR will wind up inside a double-quoted shell string.
 AC_DEFUN([AC_CONFIG_AUX_DIR],
-[AC_CONFIG_AUX_DIRS($1 "$srcdir"/$1)])
+  [m4_append_uniq([_AC_AUX_DIR_CANDIDATES],
+    AS_LITERAL_WORD_IF([$1],
+      [m4_bmatch([$1],
+                 [^/],       [$1],
+                 [^[a-z]:/], [$1],
+                            [${srcdir}/$1])],
+      [$1]),
+    [${PATH_SEPARATOR}])])
+
+
+# AC_CONFIG_AUX_DIRS(DIRS)
+# ------------------------
+# Find auxiliary scripts (e.g. install-sh, config.sub, config.guess)
+# in any of the whitespace-separated directories named DIRS.
+# This macro is not documented; it used to be an internal subroutine,
+# but its name didn't begin with an underscore, so we're preserving it
+# for the small number of configure scripts that used it themselves.
+# It might be promoted to an official interface in the future.
+AC_DEFUN([AC_CONFIG_AUX_DIRS],
+[m4_map_args_w(m4_validate_w([$1]), [AC_CONFIG_AUX_DIR(], [)])])
+
+
+# AC_REQUIRE_AUX_FILE(FILE)
+# -------------------------
+# Declare that FILE is a required auxiliary file.  FILE must be literal.
+# At configure time, if we cannot locate a directory containing all of the
+# required auxiliary files, the script will bomb out.  This macro may also
+# be used as a trace hook by tools that wish to identify all of the required
+# auxiliary files.
+m4_define([AC_REQUIRE_AUX_FILE],
+[AS_LITERAL_WORD_IF([$1],
+  [m4_do(
+    [AC_REQUIRE([_AC_INIT_AUX_DIR])],
+    [m4_set_add([_AC_AUX_FILES], [$1])]
+  )],
+  [m4_fatal([$0: requires a literal argument])])])
 
 
 # AC_CONFIG_AUX_DIR_DEFAULT
 # -------------------------
-# The default is `$srcdir' or `$srcdir/..' or `$srcdir/../..'.
-# There's no need to call this macro explicitly; just AC_REQUIRE it.
+# No longer needed (AC_REQUIRE_AUX_FILE now does the whole job) but
+# preserved for backward compatibility with third-party macros.
+# Not yet being removed by autoupdate, because we don't know if any
+# third-party macros used this without also using AC_REQUIRE_AUX_FILE.
+# That usage is now considered incorrect, but removing it would break
+# those macros.
 AC_DEFUN([AC_CONFIG_AUX_DIR_DEFAULT],
-[AC_CONFIG_AUX_DIRS("$srcdir" "$srcdir/.." "$srcdir/../..")])
+[AC_REQUIRE([_AC_INIT_AUX_DIR])])
 
 
-# AC_CONFIG_AUX_DIRS(DIR ...)
-# ---------------------------
-# Internal subroutine.
-# Search for the configuration auxiliary files in directory list $1.
-# We look only for install-sh, so users of AC_PROG_INSTALL
-# do not automatically need to distribute the other auxiliary files.
-AC_DEFUN([AC_CONFIG_AUX_DIRS],
-[ac_aux_dir=
-for ac_dir in $1
-do
-  if test -f "$ac_dir/install-sh"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/install-sh -c"
-    break
-  elif test -f "$ac_dir/install.sh"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/install.sh -c"
-    break
-  elif test -f "$ac_dir/shtool"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/shtool install -c"
+# _AC_INIT_AUX_DIR
+# ----------------
+# Internal subroutine: AC_REQUIREd by AC_REQUIRE_AUX_FILE and
+# AC_CONFIG_AUX_DIR_DEFAULT.  Emits the shell code that actually
+# searches for the aux directory.  If AC_REQUIRE_AUX_FILE has
+# been used at least once, the aux directory must contain all
+# of the files that were AC_REQUIRE_AUX_FILE'd.  If it was never
+# used, fall back to the old behavior of looking only for install-sh.
+# (This fallback can be removed once we drop AC_CONFIG_AUX_DIR_DEFAULT.)
+AC_DEFUN([_AC_INIT_AUX_DIR],
+[m4_wrap_lifo(
+  [m4_do(
+    [m4_set_empty([_AC_AUX_FILES],
+      [m4_do(
+        [m4_warn([syntax],
+          [AC_CONFIG_AUX_DIR_DEFAULT used without AC_REQUIRE_AUX_FILE])],
+        [m4_set_add([_AC_AUX_FILES], [install-sh])])])],
+  [m4_divert_text([INIT_PREPARE],
+[
+# Auxiliary files required by this configure script.
+ac_aux_files="m4_set_dump([_AC_AUX_FILES], [ ])"
+
+# Locations in which to look for auxiliary files.
+ac_aux_dir_candidates="m4_ifset([_AC_AUX_DIR_CANDIDATES],
+  [m4_defn([_AC_AUX_DIR_CANDIDATES])],
+  [${srcdir}${PATH_SEPARATOR}${srcdir}/..${PATH_SEPARATOR}${srcdir}/../..])"
+
+# Search for a directory containing all of the required auxiliary files,
+# $ac_aux_files, from the $PATH-style list $ac_aux_dir_candidates.
+# If we don't find one directory that contains all the files we need,
+# we report the set of missing files from the *first* directory in
+# $ac_aux_dir_candidates and give up.
+ac_missing_aux_files=""
+ac_first_candidate=:
+_AS_ECHO_LOG([looking for aux files: $ac_aux_files])
+_AS_PATH_WALK([$ac_aux_dir_candidates], [
+  _AS_ECHO_LOG([ trying $as_dir])
+  ac_aux_dir_found=yes
+  ac_install_sh=
+  for ac_aux in $ac_aux_files
+  do
+    # As a special case, if "install-sh" is required, that requirement
+    # can be satisfied by any of "install-sh", "install.sh", or "shtool",
+    # and $ac_install_sh is set appropriately for whichever one is found.
+    if test x"$ac_aux" = x"install-sh"
+    then
+      if test -f "${as_dir}install-sh"; then
+        _AS_ECHO_LOG([  ${as_dir}install-sh found])
+        ac_install_sh="${as_dir}install-sh -c"
+      elif test -f "${as_dir}install.sh"; then
+        _AS_ECHO_LOG([  ${as_dir}install.sh found])
+        ac_install_sh="${as_dir}install.sh -c"
+      elif test -f "${as_dir}shtool"; then
+        _AS_ECHO_LOG([  ${as_dir}shtool found])
+        ac_install_sh="${as_dir}shtool install -c"
+      else
+        ac_aux_dir_found=no
+        if $ac_first_candidate; then
+          ac_missing_aux_files="${ac_missing_aux_files} install-sh"
+        else
+          break
+        fi
+      fi
+    else
+      if test -f "${as_dir}${ac_aux}"; then
+        _AS_ECHO_LOG([  ${as_dir}${ac_aux} found])
+      else
+        ac_aux_dir_found=no
+        if $ac_first_candidate; then
+          ac_missing_aux_files="${ac_missing_aux_files} ${ac_aux}"
+        else
+          break
+        fi
+      fi
+    fi
+  done
+  if test "$ac_aux_dir_found" = yes; then
+    ac_aux_dir="$as_dir"
     break
   fi
-done
-if test -z "$ac_aux_dir"; then
-  AC_MSG_ERROR([cannot find install-sh, install.sh, or shtool in $1])
-fi
+  ac_first_candidate=false
+],
+  [AC_MSG_ERROR([cannot find required auxiliary files:$ac_missing_aux_files])])
 
 # These three variables are undocumented and unsupported,
 # and are intended to be withdrawn in a future Autoconf release.
 # They can cause serious problems if a builder's source tree is in a directory
 # whose full name contains unusual characters.
-ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
-ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
-ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
+dnl The quadrigraphs prevent spurious deprecation warnings.
+if test -f "${ac_aux_dir}config.guess"; then
+  ac_@&t@config_guess="$SHELL ${ac_aux_dir}config.guess"
+fi
+if test -f "${ac_aux_dir}config.sub"; then
+  ac_@&t@config_sub="$SHELL ${ac_aux_dir}config.sub"
+fi
+if test -f "$ac_aux_dir/configure"; then
+  ac_@&t@configure="$SHELL ${ac_aux_dir}configure"
+fi
+])])])])
 
-AC_PROVIDE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
-])# AC_CONFIG_AUX_DIRS
+# Deprecation warnings for the unsupported variables above.
+m4_define([ac_config_guess],
+[m4_warn([obsolete],
+ [$ac_config_guess is obsolete and unsafe.  Please stop using it.
+Contact autoconf@gnu.org if you really need it.])ac_@&t@config_guess])
 
+m4_define([ac_config_sub],
+[m4_warn([obsolete],
+ [$ac_config_sub is obsolete and unsafe.  Please stop using it.
+Contact autoconf@gnu.org if you really need it.])ac_@&t@config_sub])
+
+m4_define([ac_configure],
+[m4_warn([obsolete],
+ [$ac_configure is obsolete and unsafe.  Please stop using it.
+Contact autoconf@gnu.org if you really need it.])ac_@&t@config_sub])
 
 
 
@@ -1850,20 +1977,6 @@ AC_DEFUN([AC_CONFIG_MACRO_DIR],
 [_$0S(_$0S_USED()[$0], [$1])])
 
 
-## --------------------- ##
-## Requiring aux files.  ##
-## --------------------- ##
-
-# AC_REQUIRE_AUX_FILE(FILE)
-# -------------------------
-# This macro does nothing, it's a hook to be read with `autoconf --trace'.
-# It announces FILE is required in the auxdir.
-m4_define([AC_REQUIRE_AUX_FILE],
-[AS_LITERAL_WORD_IF([$1], [],
-              [m4_fatal([$0: requires a literal argument])])])
-
-
-
 ## ----------------------------------- ##
 ## Getting the canonical system type.  ##
 ## ----------------------------------- ##
@@ -1904,25 +2017,24 @@ AC_SUBST([$1_os])dnl
 # AC_CANONICAL_BUILD
 # ------------------
 AC_DEFUN_ONCE([AC_CANONICAL_BUILD],
-[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
-AC_REQUIRE_AUX_FILE([config.sub])dnl
+[AC_REQUIRE_AUX_FILE([config.sub])dnl
 AC_REQUIRE_AUX_FILE([config.guess])dnl
 m4_divert_once([HELP_CANON],
 [[
 System types:
   --build=BUILD     configure for building on BUILD [guessed]]])dnl
 # Make sure we can run config.sub.
-$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
-  AC_MSG_ERROR([cannot run $SHELL $ac_aux_dir/config.sub])
+$SHELL "${ac_aux_dir}config.sub" sun4 >/dev/null 2>&1 ||
+  AC_MSG_ERROR([cannot run $SHELL ${ac_aux_dir}config.sub])
 
 AC_CACHE_CHECK([build system type], [ac_cv_build],
 [ac_build_alias=$build_alias
 test "x$ac_build_alias" = x &&
-  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+  ac_build_alias=`$SHELL "${ac_aux_dir}config.guess"`
 test "x$ac_build_alias" = x &&
   AC_MSG_ERROR([cannot guess build type; you must specify one])
-ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
-  AC_MSG_ERROR([$SHELL $ac_aux_dir/config.sub $ac_build_alias failed])
+ac_cv_build=`$SHELL "${ac_aux_dir}config.sub" $ac_build_alias` ||
+  AC_MSG_ERROR([$SHELL ${ac_aux_dir}config.sub $ac_build_alias failed])
 ])
 _AC_CANONICAL_SPLIT(build)
 ])# AC_CANONICAL_BUILD
@@ -1938,8 +2050,8 @@ AC_CACHE_CHECK([host system type], [ac_cv_host],
 [if test "x$host_alias" = x; then
   ac_cv_host=$ac_cv_build
 else
-  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
-    AC_MSG_ERROR([$SHELL $ac_aux_dir/config.sub $host_alias failed])
+  ac_cv_host=`$SHELL "${ac_aux_dir}config.sub" $host_alias` ||
+    AC_MSG_ERROR([$SHELL ${ac_aux_dir}config.sub $host_alias failed])
 fi
 ])
 _AC_CANONICAL_SPLIT([host])
@@ -1957,8 +2069,8 @@ AC_CACHE_CHECK([target system type], [ac_cv_target],
 [if test "x$target_alias" = x; then
   ac_cv_target=$ac_cv_host
 else
-  ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` ||
-    AC_MSG_ERROR([$SHELL $ac_aux_dir/config.sub $target_alias failed])
+  ac_cv_target=`$SHELL "${ac_aux_dir}config.sub" $target_alias` ||
+    AC_MSG_ERROR([$SHELL ${ac_aux_dir}config.sub $target_alias failed])
 fi
 ])
 _AC_CANONICAL_SPLIT([target])
diff --git a/lib/autoconf/programs.m4 b/lib/autoconf/programs.m4
index 86ba3948..a895e59a 100644
--- a/lib/autoconf/programs.m4
+++ b/lib/autoconf/programs.m4
@@ -524,8 +524,7 @@ m4_ifval([$3],
 AN_MAKEVAR([INSTALL], [AC_PROG_INSTALL])
 AN_PROGRAM([install], [AC_PROG_INSTALL])
 AC_DEFUN_ONCE([AC_PROG_INSTALL],
-[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
-AC_REQUIRE_AUX_FILE([install-sh])dnl
+[AC_REQUIRE_AUX_FILE([install-sh])dnl
 # Find a good install program.  We prefer a C program (faster),
 # so one script is as good as another.  But avoid the broken or
 # incompatible versions:
@@ -662,8 +661,7 @@ AC_SUBST(INSTALL_DATA)dnl
 # directories to create.
 AN_MAKEVAR([MKDIR_P], [AC_PROG_MKDIR_P])
 AC_DEFUN_ONCE([AC_PROG_MKDIR_P],
-[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
-AC_REQUIRE_AUX_FILE([install-sh])dnl
+[AC_REQUIRE_AUX_FILE([install-sh])dnl
 AC_MSG_CHECKING([for a race-free mkdir -p])
 if test -z "$MKDIR_P"; then
   AC_CACHE_VAL([ac_cv_path_mkdir],
diff --git a/lib/autoconf/status.m4 b/lib/autoconf/status.m4
index 1389f328..b604368a 100644
--- a/lib/autoconf/status.m4
+++ b/lib/autoconf/status.m4
@@ -1097,7 +1097,6 @@ AC_DEFUN([AC_CONFIG_SUBDIRS],
 [_$0(m4_validate_w([$1]))])
 
 m4_define([_AC_CONFIG_SUBDIRS],
-[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])]dnl
 [AC_REQUIRE([AC_DISABLE_OPTION_CHECKING])]dnl
 [AS_LITERAL_IF([$1], [],
               [m4_warn([syntax], [$0: you should use literals])])]dnl
@@ -1191,14 +1190,12 @@ if test "$no_recursion" != yes; then
 
     cd "$ac_dir"
 
-    # Check for guested configure; otherwise get Cygnus style configure.
+    # Check for configure.gnu first; this name is used for a wrapper for
+    # Metaconfig's "Configure" on case-insensitive filesystems.
     if test -f "$ac_srcdir/configure.gnu"; then
       ac_sub_configure=$ac_srcdir/configure.gnu
     elif test -f "$ac_srcdir/configure"; then
       ac_sub_configure=$ac_srcdir/configure
-    elif test -f "$ac_srcdir/configure.in"; then
-      # This should be Cygnus configure.
-      ac_sub_configure=$ac_aux_dir/configure
     else
       AC_MSG_WARN([no configuration information is in $ac_dir])
       ac_sub_configure=
diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index 6a6d1a47..f29ce490 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -479,8 +479,6 @@ do
   *)    at_optarg= ;;
   esac
 
-  # Accept the important Cygnus configure options, so we can diagnose typos.
-
   case $at_option in
     --help | -h )
        at_help_p=:
diff --git a/tests/torture.at b/tests/torture.at
index 631f34f4..f9bcf5e5 100644
--- a/tests/torture.at
+++ b/tests/torture.at
@@ -1926,3 +1926,41 @@ AT_CHECK([autoreconf -Werror -Wportability-recursive], 
0, [], [])
 rm -rf configure config.h.in Makefile.in aclocal.m4 autom4te.cache
 
 AT_CLEANUP
+
+## ------------------------- ##
+## Missing auxiliary files.  ##
+## ------------------------- ##
+
+AT_SETUP([Missing auxiliary files])
+
+AT_DATA([configure.ac],
+[[AC_INIT([GNU foo], [1.0])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_CANONICAL_HOST
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([], [1], [ignore],
+[configure: error: cannot find required auxiliary files: config.guess 
config.sub
+])
+
+: > build-aux/config.guess
+
+AT_CHECK_CONFIGURE([], [1], [ignore],
+[configure: error: cannot find required auxiliary files: config.sub
+])
+
+AT_DATA([configure.ac],
+[[AC_INIT([GNU foo], [1.0])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_PROG_INSTALL
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([], [1], [ignore],
+[configure: error: cannot find required auxiliary files: install-sh
+])
+
+AT_CLEANUP
-- 
2.28.0




reply via email to

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