diff options
author | Zack Weinberg <zackw@panix.com> | 2020-10-20 13:27:22 -0400 |
---|---|---|
committer | Zack Weinberg <zackw@panix.com> | 2020-10-20 13:59:26 -0400 |
commit | 4c59bf27d7083088290219450c81d999431b43f1 (patch) | |
tree | 39a068621e88e2d00183013d889b92b5815367f9 /lib | |
parent | 2a94d5b1541ea7e988893c7ca6e7fa20e2ea97b6 (diff) | |
download | autoconf-4c59bf27d7083088290219450c81d999431b43f1.tar.gz |
Improve handling of missing aux scripts.
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.
* 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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/autoconf/general.m4 | 242 | ||||
-rw-r--r-- | lib/autoconf/programs.m4 | 6 | ||||
-rw-r--r-- | lib/autoconf/status.m4 | 7 | ||||
-rw-r--r-- | lib/autotest/general.m4 | 2 |
4 files changed, 181 insertions, 76 deletions
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=: |