Use WARNINGS to pass down warnings options from autoreconf.
autoreconf runs a bunch of subsidiary tools, and is expected to pass
along various command-line settings, such as those controlling
warnings. It has historically done this via the command line.
However, not all of the tools recognize the same set of command-line
warnings options. There’s an existing check for whether aclocal and
automake understand ‘--warnings’ at all, but it currently assumes that
automake will accept the same set of warnings *categories* that
autoconf does. This hasn’t actually been true for many years
and is known to cause problems; see the discussion starting at
<https://lists.gnu.org/archive/html/autoconf/2020-09/msg00000.html>.
Previous patches in this series (and related patches applied to
automake) have restored agreement between the current development
trunks of the two sets of tools on the set of warnings categories, but
we still need to deal with the possibility of the *installed* tools
not being in agreement.
If we use the WARNINGS environment variable to pass down warnings
options, instead of the command line, then all the tools are already
coded to ignore unknown warning categories, and this ceases to be an
issue. And we no longer need the check for ‘--warnings’ support in
automake, either.
Also, autoreconf as well should suppress warnings from its first
invocation of autoconf, which is for tracing purposes only and may
emit spurious warnings because aclocal.m4 is not yet in place.
* bin/autoreconf.in
($aclocal_supports_warnings, $automake_supports_warnings): Delete.
(@warning): Make local to sub parse_args.
(parse_args): Do not add --warnings options to $autoconf,
$autoheader, $aclocal, or $automake. Instead, set $ENV{WARNINGS}
appropriately. No longer necessary to probe for --warnings support
from aclocal and automake.
(autoreconf_current_directory): Set $ENV{WARNINGS} temporarily to
“none” when running autoconf in trace mode. Fix typo in comment.
Close $traces immediately after we’re done with it.
* tests/torture.at (Specific warnings options for autoreconf):
New test.
Disable all warnings when running autoconf as a subprocess.
autoheader and autoscan both run autoconf in trace mode, and
autoheader makes a point of passing down the warnings options.
This means autoheader prints warnings that a regular invocation
of autoconf would also print, so in the common case where both
are being run by autoreconf, the warnings are duplicated.
autoscan doesn’t pass down warnings options but it _does_ leave
the WARNINGS environment variable alone, which means it may issue
completely spurious warnings because the configure script is still
under construction.
Change this so that both programs disable all warnings for the
subsidiary invocation of autoconf, by not passing any warnings
options themselves, and by setting the WARNINGS environment variable
to “none” for the subprocess. For this to work correctly, the
‘args: --warnings syntax’ line has to be removed from autom4te.cfg
(m4sugar section). Since syntax warnings are on by default anyway,
the sole effect of this is to allow WARNINGS=none to turn off syntax
warnings.
The test suite changes are all to remove expectations of duplicate
diagnostics from autoheader.
* bin/autoheader.in: Do not pass warnings options down to subsidiary
autoconf, and set WARNINGS=none in the environment for that process.
* bin/autoscan.in: Set WARNINGS=none in the environment for subsidiary
autoconf.
* lib/autom4te.in (M4sugar): Remove ‘--warnings syntax’.
* tests/semantics.at, tests/torture.at: No longer expect various
diagnostics from autoheader as well as autoconf.
New utility function Autom4te::ChannelDefs::merge_WARNINGS.
This function merges a list of warnings categories into the environment
variable WARNINGS, returning a new value to set it to. The intended use
is in code of the form
{
local $ENV{WARNINGS} = merge_WARNINGS ("this", "that");
# run a command here with WARNINGS=this,that,etc
}
This is not used yet, but will be in the next patch.
* lib/Autom4te/ChannelDefs.pm (merge_WARNINGS): New function.
ChannelDefs.pm *ought* to be kept in sync between automake and autoconf,
because it defines the set of valid -W options, and autoreconf assumes
that it can pass arbitrary -W options to all of the tools it invokes.
However, it isn’t covered by either project’s ‘make fetch’ and it hasn’t
actually *been* in sync for more than 17 years.
This patch manually brings over all of the changes made on the
automake side. Once the complementary patch is applied by the
automake team, both versions of the file will be the same, and then we
can add it to the list in fetch.pl and not have this problem any more
in the future.
There are some user-visible consequences to bringing this file back
into sync. The only one worth mentioning in NEWS is that the ‘obsolete’
category of warnings is now on by default. This had quite a bit of
fallout throughout the testsuite. There are also some new warning
categories that get mentioned in --help output, but we don’t actually
generate any warnings in those categories, so people using ‘-Wall’
won’t see any change. More diagnostics are automatically tagged with
‘warning:’ or ‘error:’, which also had some fallout in the testsuite.
Finally, ‘-Werror’ no longer causes complaints about unknown warning
categories to be treated as hard errors.
Internally, there are some small API changes: ‘parse_warnings’ is no
longer usable as a ‘getopt’ callback function, and we now have a stub
Autom4te/Config.pm to match the automake code’s expectations. (This
file *should* also be synced from automake by ‘make fetch’, but we
can’t quite do that yet because it’s a generated file and our build
system is not prepared to handle adding *two* directories to @INC when
running a not-yet-installed Perl script. I plan to fix that after 2.70.)
As a side-effect of adding a Config.pm, ‘prog_error’ now says to
report the bug to bug-autoconf, not bug-automake. If this is why we
mostly haven’t been using prog_error for internal errors, we can stop
avoiding it. (I did not change anything to use prog_error in this
patch.)
* lib/Autom4te/ChannelDefs.pm: Merge from automake.
* lib/Autom4te/Config.pm: New file.
* lib/local.mk (dist_perllib_DATA): Add Autom4te/Config.pm.
* bin/autoconf.as: Update list of warning categories to match
Autom4te::ChannelDefs::usage.
* bin/autoheader.in (@warnings): New global.
(parse_args): Don’t use parse_warnings as a getopt callback.
(main): Add warnings options from our command line to $autoconf.
No need to turn on 'obsolete' warnings explicitly.
No need to include "warning: " in warning messages.
* bin/autom4te.in (parse_args): Don’t use parse_warnings as a getopt callback.
(main): No need to include "warning: " in warning messages.
* bin/autoreconf.in (parse_args): parse_warnings now takes only one argument.
* bin/autoupdate.in: Set WARNINGS=none in environment for all child processes.
* tests/local.at
(AT_CHECK_M4): Handle `autom4te: error: /usr/bin/m4 ...` like
`autom4te: /usr/bin/m4 ...`.
(_AT_CHECK_AC_MACRO): Add AUTOCONF-FLAGS argument, passed to both
autoconf and autoheader.
(AT_CHECK_MACRO): Default AUTOCONF-FLAGS argument to empty.
Pass that argument to autoheader as well as autoconf.
(AT_CHECK_AU_MACRO): Expect a “macro ‘NAME’ is obsolete’ diagnostic
on the first run of autoconf. Pass -Wno-obsolete to autoconf on the
second run, and to autoheader on both runs.
* tests/base.at
* tests/c.at
* tests/compile.at
* tests/m4sh.at
* tests/m4sugar.at
* tests/semantics.at
* tests/tools.at
* tests/torture.at:
No need to pass -Wobsolete to autoconf.
Pass -Wno-obsolete to autoheader where needed to avoid handling
the same warning twice.
Update various expectations for diagnostics to match behavior
changes.
* tests/tools.at (autoupdating AU_ALIAS): Add an AC_CONFIG_HEADERS
line to the test configure.ac to eliminate an unrelated diagnostic.
Jonathan Wakely [Tue, 22 Sep 2020 19:45:10 +0000 (15:45 -0400)]
doc: Fix cross-reference for AC_TRY_LINK
The documentation for AC_TRY_LINK has a cross-reference to "Running
the Compiler". This should be "Running the Linker" instead. Also
make the link in AC_TRY_LINK_FUNC consistent.
Commit 9b5c0f17741836e99d0a801c6309389d391c03f9 introduced a bug where
autoconf --help would only print “Try 'autoconf --help' for more information.”
Correct this.
* bin/autoconf.as: Print $help, not $usage_err, for --help.
Consistently use AS_ECHO, not bare echo.
Consistently use ‘our’ instead of ‘use vars’ in Perl.
At file scope of a file containing at most one ‘package’ declaration,
‘use vars’ is exactly equivalent to ‘our’, and the latter is preferred
starting with Perl 5.6.0, which happens to be the oldest version we
support.
In one place ‘our’ was not actually necessary and was switched to ‘my’.
(This change has already been made in Automake and applied to the
shared Perl code via the previous ‘make fetch’ commit.)
* lib/Autom4te/C4che.pm
* lib/Autom4te/ChannelDefs.pm
* lib/Autom4te/General.pm: Replace all uses of ‘use vars’ with ‘our’.
* bin/autoheader.in: Replace all uses of ‘use vars’ with ‘our’.
Remove an unnecessary ‘local’.
* bin/autoscan.in: Convert ‘use vars’ variables to ‘my’ variables.
‘make fetch’ was updating several auxiliary files from the copy
embedded in Gnulib instead of from their official home. This patch
teaches fetch.pl to update as many as possible of them from their
official homes. The remaining exception is GNU license files, which,
except for fdl.texi, do not appear to have a public version control
system. Gnulib has a script for updating them, but it appears one
must be logged into some specific FSF-operated shell host for it to
work.
The files affected, and their official homes, are:
This change exposed a bug in fetch.sh: there is a subtle difference
between File::Spec->catpath and ->catfile and I should have been using
the latter.
* build-aux/fetch.pl: Can now fetch from arbitrary Savannah
repositories, not just from gnulib and automake. Fetch as
many files as possible from their official home, instead of
from gnulib. Use File::Spec->catfile, not ->catpath.
Strip trailing whitespace from all files.
Using HTTP::Tiny to talk to the network, instead of wget, means that
we can make just one TCP connection to git.savannah.gnu.org to do the
whole job, which is quite a bit faster. It should also be more
robust against weird characters in filenames / URLs and stuff.
The script has a higher requirement for Perl than is the standard in
autoconf -- 5.14 (first version with HTTP::Tiny), with IO::Socket::SSL
installed -- but that’s ok, I hope, because it’s maintainer-only and
not installed.
fetch.sh was the sole user of move-if-change, and the Perl script does
that job itself, but I left move-if-change in build-aux and on the fetch
list anyway, in case we discover another use for it in the future.
* build-aux/fetch.sh: Replace with...
* build-aux/fetch.pl: ... reimplementation in Perl.
* cfg.mk (fetch): Update to match.
All of the AC_PROG_*CPP macros fall back to ‘/lib/cpp’ if invoking the
relevant compiler with ‘-E’ doesn’t work. This is an obsolete
location to find the C preprocessor. Linux distributions tend to ship
a compatibility symlink, as do Solaris and AIX (as of the versions in the
GCC compile farm, anyway), but the BSDs no longer do.
The tests for this fallback are already expecting ‘cpp’ to be a
command findable via $PATH, so make the probe macros do the same
thing. (We still try ‘/lib/cpp’ if ‘cpp’ _isn’t_ in $PATH.)
* lib/autoconf/c.m4
(AC_PROG_CPP, AC_PROG_CXXCPP, AC_PROG_OBJCPP, AC_PROG_OBJCXXCPP):
If $CC / $CXX / $OBJC / $OBJCXX -E (respectively) does not run the
preprocessor, look for ‘cpp’ in $PATH before falling back to ‘/lib/cpp’.
* doc/autoconf.texi
(AC_PROG_CPP, AC_PROG_CXXCPP, AC_PROG_OBJCPP, AC_PROG_OBJCXXCPP):
Update to match.
Add Configure_ac.pm to set of files to be synced from automake.
This file seems to have been accidentally left off of the list of .pm
files that should be kept the same between automake and autom4te.
It’s already almost identical in both codebases.
It would make sense to sync ChannelDefs.pm too, but the copies of that
file in the two codebases have diverged; they would need to be
reconciled by hand first.
‘make fetch’ pulls the files maintained by Automake from gitweb, so we
always get the HEAD revision at the time of the operation. The files
maintained by Gnulib, on the other hand, are just copied from whatever
local gnulib checkout you happen to have on your hard drive at the
time, which might not have been updated recently and might not even be
checked out from gnulib trunk.
This patch makes us use the same logic for Gnulib that we do for
Automake. It also pulls all of the code out of cfg.mk to a separate
shell script. The lists of files to update from each repository are
also moved to that file.
* build-aux/fetch.sh: New script. Lists of files to fetch from
Gnulib and Automake are now kept here.
* cfg.mk (fetch): Run fetch.sh, it does all the work.
(gnulib-update, autom4te-update, WGETFLAGS, automake_gitweb)
(autom4te_files, move_if_change): Delete.
Zack Weinberg [Mon, 31 Aug 2020 15:37:19 +0000 (11:37 -0400)]
Fatalize all warnings in Perl code.
Search-and-replace change ‘use warnings;’ to ‘use warnings FATAL => 'all';’
in all Perl code.
Notwithstanding the dire cautions in ‘perldoc warnings’ about this,
I think it’s the right call for us. One file was already doing it.
No new testsuite failures are observed on Linux with Perl 5.30.3
nor on NetBSD with Perl 5.6.1.
* bin/autoheader.in, bin/autom4te.in, bin/autoreconf.in
* bin/autoscan.in, bin/autoupdate.in, bin/ifnames.in
* lib/Autom4te/C4che.pm, lib/Autom4te/ChannelDefs.pm
* lib/Autom4te/Channels.pm, lib/Autom4te/Configure_ac.pm
* lib/Autom4te/FileUtils.pm, lib/Autom4te/General.pm
* lib/Autom4te/Request.pm, lib/Autom4te/XFile.pm:
Make all warnings from the Perl interpreter into fatal errors.
Zack Weinberg [Mon, 31 Aug 2020 15:23:00 +0000 (11:23 -0400)]
Rationalize ‘use’ order in Perl code.
All the Perl scripts and modules now ‘use’ other modules in the
following order:
- use 5.006; use strict; use warnings; in that order.
If a file was not already use-ing one of these three, it was added.
- The BEGIN block that adds the installation directory for the
Autom4te:: modules to @INC, if necessary.
- All stdlib modules whose name begins with a capital letter,
in ASCII sort order.
- All Autom4te:: modules, in ASCII sort order.
- ‘use vars qw (...)’, if any, last.
Also, ‘use foo qw (...)’ and @ISA lists have been sorted into ASCII
sort order. (@EXPORT lists, which often follow immediately after @ISA
lists, have *not* been sorted, as these appear to have been organized
semantically in many cases.) qw delimiters have been normalized to
round parentheses with a space between the qw and the open paren.
* bin/autoheader.in, bin/autom4te.in, bin/autoreconf.in
* bin/autoscan.in, bin/autoupdate.in, bin/ifnames.in
* lib/Autom4te/C4che.pm, lib/Autom4te/ChannelDefs.pm
* lib/Autom4te/Channels.pm, lib/Autom4te/Configure_ac.pm
* lib/Autom4te/FileUtils.pm, lib/Autom4te/General.pm
* lib/Autom4te/Getopt.pm, lib/Autom4te/Request.pm
* lib/Autom4te/XFile.pm: Rationalize order and format of ‘use’
directives and @ISA lists. Add any of ‘use 5.006’, ‘use strict’,
and ‘use warnings’ that was not already present.
Serhii Popovych [Wed, 10 Feb 2016 16:32:44 +0000 (16:32 +0000)]
perl: Replace -w option in shebangs with ‘use warnings’ in code
Some downstream redistributors for Autoconf wish to use
‘/usr/bin/env perl’ as the #! line for the installed Perl scripts.
This does not work with command-line options on the #! line, as the
kernel doesn’t support supplying more than one argument to a #!
interpreter (this limitation is universal across Unixes that
support #!, as far as I know).
Remove ‘-w’ from all perl #! lines and instead add ‘use warnings’
to all the scripts and .pm files that didn’t already have it.
This ‘use’ directive was added to Perl in version 5.6.0 (aka 5.006)
so there is no change to our minimum Perl requirement.
(It is necessary to add ‘use warnings’ to all the .pm files as well as
the scripts, because the ‘-w’ command-line option turns on warnings
globally, but ‘use warnings’ does so only for the current lexical scope.)
Patch uplifted from OpenEmbedded, originally by Serhii Popovych.
It’s a mechanical search-and-replace change so I do not believe a
copyright assignment is necessary.
* bin/autom4te.in, bin/autoreconf.in, bin/autoscan.in
* bin/autoupdate.in, bin/ifnames.in: Remove -w from #! line
and add ‘use warnings’ to imports.
Zack Weinberg [Fri, 28 Aug 2020 20:44:59 +0000 (16:44 -0400)]
BUGS: Remove mention of old shells lacking functions.
The change to require shell functions in configure scripts happened
circa 2009, well before the release of autoconf 2.69; if this was
causing problems for people we would have heard about it by now.
Zack Weinberg [Fri, 28 Aug 2020 20:42:28 +0000 (16:42 -0400)]
Fix testsuite failures from ‘make maintainer-check-c++’.
‘make maintainer-check-c++’ has two test failures that don’t show in
an ordinary ‘make check’. One of these is a pair of problems with the
semantics.at test of AC_CHECK_DECL(S):
* AC_CHECK_DECL cannot handle a function argument whose declared type
is ‘char []’; it generates a cast to the array type, which is
invalid in both C and C++. This was masked by an M4 quotation bug,
causing it to emit a cast to ‘char’ instead, prodicing code that
was valid C but invalid C++. I don’t think it’s practical to teach
AC_CHECK_DECL to do argument type decay, so I changed the type
signature in the AC_CHECK_DECL call (not in the actual declaration)
to ‘char *’. Conveniently this also avoids the quotation issue.
* In C++, apparently ‘extern struct { int x; } foo;’ is invalid.
(clang++ explains at length: “variable ‘foo’ is used but not
defined in this translation unit, and cannot be defined in any
other translation unit because its type does not have linkage.”)
Fixed by giving the struct a tag.
The other failure is an actual bug in AC_PROG_LEX: the test program
used by _AC_PROG_LEX_YYTEXT_DECL uses the flex utility function
‘input’, which is renamed to ‘yyinput’ when the scanner is compiled as
C++. Fixed with ifdefs in the offending action--it might seem cleaner
to use a macro defined in a %{ %} block, but that would be inserted into
the skeleton *above* the declaration of (yy)input, so I didn’t feel
it was safe.
* tests/semantics.at (AC_CHECK_DECLS): Adjust test programs for C++
compatibility and to work around lack of support for argument type
decay.
* programs.m4 (_AC_PROG_LEX_YYTEXT_DECL): Call yyinput(), not input(),
in scanner action when scanner is compiled as C++.
Zack Weinberg [Fri, 28 Aug 2020 17:59:05 +0000 (13:59 -0400)]
Suppress ‘make syntax-check’ complaint about use of strcmp.
Recently ‘make syntax-check’ added a lint rule discouraging use of
bare ‘strcmp’ (in favor of gnulib’s streq/strneq wrappers), which
triggers on some code in c.m4’s test for C++98 compliance.
This lint rule makes sense for typical C programs coded to GNU’s
standards, but not for autoconf’s test programs. There is no way to
disable it from outside the code, so this patch adds parentheses
around the name ‘strcmp’, which is sufficient to disable this
grep-based lint but doesn’t change the meaning of the code as
understood by an actual C++ compiler.
* c.m4 (_AC_CXX_CXX98_TEST_HEADER): Suppress ‘make syntax-check’
error on use of strcmp.
Zack Weinberg [Thu, 27 Aug 2020 14:14:53 +0000 (10:14 -0400)]
AS_INIT: ensure fds 0, 1, 2 are open
A patch was recently proposed for GNU libc to make *all* processes
start up with file descriptors 0, 1, and 2 guaranteed to be open.
Part of the rationale for this patch was that configure scripts fail
catastrophically if these fds are closed, even if you just want to run
--help or --version, e.g.
$ ./configure --version <&-; echo $?
./configure: line 555: 0: Bad file descriptor
1
configure scripts cannot rely on behavior specific to GNU libc, so
whether or not that patch gets committed, it makes sense for us to
make configure scripts robust against being started up with closed
stdin/stdout/stderr.
This patch adds code to ensure fds 0, 1, and 2 are open, early in
_AS_SHELL_SANITIZE. It uses a construct, ‘(exec 3>&n)’, that’s known
not to work in very old shells, but that’s OK because those shells
will be rejected by _AS_DETECT_BETTER_SHELL anyway. The worst-case
scenario is that the “This script requires a shell more modern than
all the shells I found on your system” error message won’t get printed.
When these fds are found not to be open, we open them on /dev/null, in
the normal I/O direction (0 for reading, 1 and 2 for writing). There
is a case for opening them in the *opposite* direction so that, for
instance, writes to fd 1 will fail when fd 1 started out closed.
However, that would expose latent bugs that I think should be dealt
with *after* 2.70. (See Savannah bug #110300 for more detail.)
I also took the opportunity to rationalize the order of operations in
_AS_SHELL_SANITIZE a little. All the special shell and environment
variables that we care about are dealt with immediately after
AS_BOURNE_COMPATIBLE, and _AS_PATH_SEPARATOR_PREPARE happens
immediately before the first use of _AS_PATH_WALK.
* lib/m4sugar/m4sh.m4 (_AS_ENSURE_STANDARD_FDS): New macro.
(_AS_SHELL_SANITIZE): Move the “Unset variables that we do not need”
and “NLS nuisances” blocks immediately after setting IFS; merge the
unsetting of CDPATH into the main unsetting loop; move invocation of
_AS_PATH_SEPARATOR_PREPARE to immediately above the “Find who we are”
block; invoke _AS_ENSURE_STANDARD_FDS immediately before
_AS_PATH_SEPARATOR_PREPARE.
* tests/base.at (configure with closed standard fds): New test.
* tests/torture.at (--help and --version in unwritable directory): New test.
Zack Weinberg [Wed, 26 Aug 2020 19:15:34 +0000 (15:15 -0400)]
Add ‘START_TIME’ and ‘ToD’ to shell variable filter list.
NetBSD sh has invented more magic shell variables with values related
to the current time: ‘START_TIME’ and ‘ToD’. Like ‘SECONDS’, these
can cause spurious testsuite failures and should be filtered out when
checking for undesirable changes to the environment.
* tests/local.at (_AT_CHECK_ENV, AT_CONFIG_CMP): Add shell variables
START_TIME and ToD to filter list.
Zack Weinberg [Wed, 26 Aug 2020 19:12:12 +0000 (15:12 -0400)]
Pass $(MAKE) down to testsuite.
If Make is not available under the command name ‘make’, only some
other name (e.g. ‘gmake’) then the test suite’s internal invocations
of Make will all fail unless you explicitly set MAKE=<the other name>
in the environment, which is obnoxious. Pass the value of $(MAKE)
down to the testsuite so that ‘gmake check’ Just Works.
Zack Weinberg [Fri, 21 Aug 2020 17:13:38 +0000 (13:13 -0400)]
Generate manpages directly from source code.
We generate manpages for autoconf’s installed programs (autoconf,
autoheader, etc.) using help2man, which runs each program in order to
learn its --help output. Each manpage therefore has a dependency on
the existence of the corresponding program, but this dependency is
intentionally left out of the Makefile so that one can build from a
tarball release (which will include prebuilt manpages) without having
help2man installed.
But when building from a git checkout with high levels of
parallelism (-j20 or so), the missing dependency can lead to build
failures, because help2man will try to run the program before it
exists. In an earlier patch I tried to work around this with a
recursive make invocation in the ‘.x.1’ rule, to ensure the existence
of the program. That only traded one concurrency bug for another, now
we could have two jobs trying to build the same program simultaneously
and they would clobber each other’s work and the build would still
fail.
Instead, this patch introduces a utility script ‘help-extract.pl’ that
reads --help and --version information directly from the source code
for each program. This utility, wrapped appropriately for each
program, is what help2man now runs. Usage is a little weird because
help2man doesn’t let you specify any arguments to the “executable”
that it runs, but it works, and lets us write all of the true
dependencies of each manpage into the Makefile without naming any file
that would be created during a build from a tarball. help-extract.pl
is a Perl script, so it introduces no new build-time requirements.
A downside is that we have to make sure each of the script sources in
bin/, and also part of lib/Autom4te/ChannelDefs.pm, are parseable by
help-extract. The most important constraints are that the text output
by --help must be defined in a global variable named ‘help’, and its
definition has to be formatted just the way these definitions are
currently formatted. Similarly for --version. Furthermore, only some
non-literal substitutions are possible in these texts; each has to be
explicitly supported in help-extract.pl. The current list of supported
substitutions is $0, @PACKAGE_NAME@, @VERSION@, @RELEASE_YEAR@, and
Autom4te::ChannelDefs::usage.
The generated manpages themselves are character-for-character
identical before and after this patch.
* build-aux/help-extract.pl: New build script that extracts --help
and --version output from manpages.
* man/autoconf.w, man/autoheader.w, man/autom4te.w, man/autoreconf.w
* man/autoscan.w, man/autoupdate.w, man/ifnames.w: New shell scripts
which wrap build-aux/help-extract.pl.
* man/local.mk: Generate each manpage by running help2man on the
corresponding .w script, not on the built utility itself.
Revise all dependencies to match.
* bin/autoconf.as: Rename ‘usage’ variable to ‘help’ and
‘help’ variable to ‘usage_err’.
* bin/autoheader.in: Call Autom4te::ChannelDefs::usage with no
function-call parentheses, matching all the other scripts.
* bin/autom4te.in: Initialize $version with a regular double-quoted
string, not a heredoc, matching all the other scripts.
* bin/autoscan.in: Remove global variable $configure_scan.
Zack Weinberg [Fri, 21 Aug 2020 17:43:50 +0000 (13:43 -0400)]
Fix ‘make distcheck’ failure due to generated manpages in build dir.
If we are doing a VPATH build and we generate the manpages,
they will be written to the build directory, and should be
deleted by ‘make distclean’; ‘make distcheck’ fails if this
is not done. However, if we are doing a build in the source
directory, the manpages might have been shipped to us and we
should *not* delete them in ‘make distclean’.
* man/local.mk (distclean-local-man): New rule. Delete $(dist_man_MANS)
in VPATH builds only.
(MOSTLYCLEANFILES, .x.1): Don’t use globs to decide what to delete.
Zack Weinberg [Thu, 20 Aug 2020 15:04:20 +0000 (11:04 -0400)]
tests: New helper macro AT_CHECK_MAKE.
This macro factors out some repeated code surrounding tests that run
make, such as honoring $MAKE, *not* honoring $MAKEFLAGS, and
normalizing the exit status. Partially addresses bug #110267
(problems with Sun’s make barfing on GNU make options from
$MAKEFLAGS).
Also addresses some unrelated problems I noticed while changing all
the tests that run make to use this macro:
The shtool test is now properly skipped if shtool is not available on
the host system.
Some of the Fortran tests would create an executable and then run it,
others would create an executable and then the AT_CHECK operation that
would run it was commented out. There’s no evidence in the changelog
or the git history for why this was done. I uncommented all of the
commented-out cases; this can be undone easily if it causes
problems. (It can’t be an issue with cross-compilation because some
of the tests do run the executable.)
* tests/local.at (AT_CHECK_MAKE): New macro wrapping an AT_CHECK
invocation of make. All tests that run make updated to use this macro.
* tests/fortran.at: Uncomment all AT_CHECKs that run the just-compiled
program.
* tests/foreign.at (shtool): Skip the test if shtool is not available
from the host system. Simplify shell logic.
Zack Weinberg [Thu, 20 Aug 2020 17:13:04 +0000 (13:13 -0400)]
Properly skip erlang tests when erl/erlc are not available.
Fallout from the previous change, which I should’ve tested on a
machine without Erlang tools installed, before pushing.
It bugs me a little that we have to put these special exit codes into
autoconf itself instead of the testsuite, but it is what it is.
* lib/autoconf/erlang.m4 (AC_ERLANG_NEED_ERLC, AC_ERLANG_NEED_ERL):
Exit with code 77 on failure so testsuite understands to skip Erlang
tests in this case.
(AC_ERLANG_CHECK_LIB): Use AC_ERLANG_NEED_ERLC and AC_ERLANG_NEED_ERL
instead of the _PATH_ versions.
Zack Weinberg [Tue, 18 Aug 2020 20:47:42 +0000 (16:47 -0400)]
_AC_COMPILER_EXEEXT_CROSS: exit 77 if test program does not run
This causes our testsuite to report a skipped test, rather than a
failure, if the detected compiler for _AC_LANG produces broken
executables. It matches the behavior of _AC_COMPILER_EXEEXT_DEFAULT,
which has exited with that code for a long time if it hits the
“_AC_LANG compiler cannot *create* executables” failure case.
Partially addresses bug #110267. The Solaris 10 machine I have access
to, has a broken gccgo installation that generates executables that
crash on startup. Without this patch, test “358: Go” fails. With
this patch, it is skipped.
Zack Weinberg [Tue, 18 Aug 2020 19:46:02 +0000 (15:46 -0400)]
Generate manpages in build directory.
It is not necessary to generate the manpages in the source directory
during a split build; ‘make dist’ can still find them in the build
directory and put them in the tarball.
Also add some defensive logic to the .x.1 rule to ensure that
bin/command and tests/command exist before generating man/command.1.
Without this, if you do a sufficiently parallel build, help2man may
generate the manpage from an older installed copy of ‘command’.
(Ideally, we wouldn’t have to run ‘command’ at all and this would not
be an issue, but ‘help2man’ doesn’t appear to support that.)
After this patch, the only files written to the source directory
during the ‘make’ phase of a split build (starting from a clean Git
checkout) are
These are not under our control, they’re being created by automake’s
built-in rules for Texinfo documentation.
* man/local.mk: Replace all instances of $(mansrcdir) with literal ‘man’.
(.x.1): Ensure that bin/command, tests/command, and the man
directory exist before creating man/command.1.
Zack Weinberg [Tue, 18 Aug 2020 19:01:10 +0000 (15:01 -0400)]
Delete a dummy ChangeLog in ‘make distclean’.
‘make distcheck’ from git may create a dummy ChangeLog file in the
build directory. Delete this on ‘make distclean’, but don’t delete
a real ChangeLog (generated by the gen-ChangeLog rule).
* Makefile.am (distclean-local): Delete ChangeLog if it is the dummy
created to pacify automake.
Zack Weinberg [Tue, 18 Aug 2020 18:54:24 +0000 (14:54 -0400)]
Don’t distribute tests/ac*.at.
tests/ac*.at are generated files containing basic test cases for all
the public AC_* macros that can be invoked without arguments. They’re
generated using a simple awk script, and we already require awk at
build time because of automake, so there is no reason to ship them in
the tarball. If we don’t ship them in the tarball, we can simplify
the logic in tests/local.mk, and avoid writing these files to the
source directory in a split build.
This should fix a problem with split builds using Solaris’ dmake
(see bug #110289).
tests/mktests.sh probably doesn’t work right if any of its argument
paths have spaces in their names, but that’s a separate issue.
* tests/local.mk (tests/mktests.stamp): Don’t change directory or
rewrite the contents of $(AUTOCONF_FILES).
(TESTSUITE_GENERATED_AT): Remove $(srcdir) prefix.
Add tests/acerlang.at (accidentally omitted).
(CLEANFILES): Add $(TESTSUITE_GENERATED_AT), mktests.stamp and mktests.tmp.
(MAINTAINERCLEANFILES): Don’t set.
(EXTRA_DIST): Include only the hand-written .at files, $(TESTSUITE_HAND_AT).
* configure.ac: Run AC_PROG_AWK, if for some reason AM_INIT_AUTOMAKE
hasn’t done it for us.
* tests/mktests.sh: Use $AWK if set in environment. Shell script linting.
Eli Schwartz [Sun, 17 Mar 2019 19:01:22 +0000 (15:01 -0400)]
autoreconf: integrate intltoolize into the standard configuration tools
In addition to the gtkdocize tool, gtk-related software may utilize the
IT_PROG_INTLTOOL macro in order to require the intltoolize tool. So too
here should the tool be run by autoreconf itself, in order to guarantee
its initialization via the unified frontend for all autotools projects.
Eli Schwartz [Sun, 17 Mar 2019 19:01:21 +0000 (15:01 -0400)]
autoreconf: integrate gtkdocize into the standard reconfiguration tools
When the GTK_DOC_CHECK macro is in use, this flags a given configure.ac
as belonging the the common class of gtk-related software that requires
the gtkdocize tool to be run before autoreconf, in order to install the
gtk-doc macro and Makefile fragment. Make this easier to accomplish via
teaching autoreconf how to detect and run this tool automatically; this
gets us one step closer to a world in which `autoreconf -fi` on its own
is enough to bootstrap any autotools project into a configurable state.
Zack Weinberg [Fri, 14 Aug 2020 17:16:58 +0000 (13:16 -0400)]
Warn if AC_INIT or AC_OUTPUT are missing from configure.ac (#107986)
It is almost always incorrect for a configure script to omit either
AC_INIT or AC_OUTPUT. Issue warnings in the ‘syntax’ category for
this.
The implementation is, unfortunately, a bit of a kludge. To check for
the _absence_ of a macro invocation, we can use m4_provide_if inside a
m4_wrap hook. However, if we activate the m4_wrap hook directly from
general.m4, we get spurious warnings at freeze time. We also get
warnings whenever a script that’s missing AC_INIT and/or AC_OUTPUT
is *traced*, which means we get double warnings from autoconf, and
autoheader and aclocal complain about it too, which seems unnecessary.
A clean way to deal with this would be to make the hook look for a
special macro that’s defined only when autoconf (the program) is
invoked without any --trace arguments. Unfortunately, autom4te
doesn’t pass --define down to M4, and changing that would involve
coordinating with Automake (the project), so instead I’ve gone for the
kludge: a new file lib/autoconf/trailer.m4 that calls m4_wrap. This
file is *not* included in autoconf.m4f, but it’s installed, and it’s
added to the m4 invocation by autoconf (the program) only when not
tracing. (It still uses m4_wrap, because we pass it to m4 *before*
configure.ac, because otherwise we get nonsense locations for any
*other* diagnostics coming out of this autoconf invocation. I don’t
know why.)
The additional checks in autoreconf are intended to make sure that if
autoreconf skips a directory entirely, you get told why.
Lots of tests in the testsuite didn’t bother with AC_OUTPUT, and
somewhat fewer didn’t bother with AC_INIT; where possible I just added
them.
Suggested by David A. Wheeler, who submitted a patch, but I didn’t
wind up using any of his code. (His implementation used an extra
tracing pass, only checked for a missing AC_INIT, and invented a new
command-line option to turn off this specific warning. I thought this
was tidier overall, despite the kludge.)
* lib/autoconf/general.m4 (_AC_FINALIZE): New macro: code to be run
when generating configure, after the entire configure.ac is
processed. Currently only checks that AC_INIT and AC_OUTPUT were
called at some point, issuing syntax-category warnings if not.
(AC_INIT, AC_OUTPUT): m4_provide self.
* lib/autoconf/trailer.m4: New file that just calls m4_wrap([_AC_FINALIZE]).
* lib/local.mk: Install new file.
* bin/autoconf.as: Add trailer.m4 to the final invocation of autom4te,
but only when not tracing.
* bin/autoreconf.in (autoreconf_current_directory): Distinguish in
diagnostics between “directory skipped because it doesn’t have a
configure.ac or configure.in” (e.g. Cygnus configure) and “directory
has a configure.ac but it doesn’t appear to be autoconf input.”
* tests/*.at: Fix all tests affected by the new warnings.
Zack Weinberg [Thu, 6 Aug 2020 18:51:32 +0000 (14:51 -0400)]
Trim whitespace from arguments of AC_INIT (#107986)
Specifically, all five arguments, if present, are passed through
m4_normalize before doing anything else with them. For instance,
AC_INIT([ GNU Hello ], [1.0]) is now equivalent to
AC_INIT([GNU Hello], [1.0]).
As a consequence, newlines in the arguments to AC_INIT are now
converted to spaces and no longer trigger warnings.
Also, diagnose inappropriate contents of the fourth and fifth
arguments as well as the first three. The fifth argument should be
“usable as-is in single- and double-quoted strings and quoted and
unquoted here-docs,” like the first three. (This is the check
performed by _AC_INIT_LITERAL.) The fourth argument (TARNAME) is used
to construct filenames, so apply an even more stringent test, namely
AS_LITERAL_WORD_IF.
Suggested by David A. Wheeler, who submitted a patch, but I didn’t
wind up using any of his code.
* lib/autoconf/general.m4 (_AC_INIT_LITERAL): Not necessary to check
for newlines anymore.
(_AC_INIT_PACKAGE): Pass all five arguments through m4_normalize
before doing anything else with them. New warning: apply
_AC_INIT_LITERAL to fifth argument (URL). New warning: complain
if fourth argument (TARNAME) is not a literal word according to
AS_LITERAL_WORD_IF. Simplify a conditional by using m4_default.
* tests/base.at (AC_INIT with unusual version strings): Adjust to
match above changes, add more subtests.
Paul Eggert [Fri, 7 Aug 2020 00:37:42 +0000 (17:37 -0700)]
Pacify -Werror in two places
Although this cannot easily be done in general, there are a couple
of places where it’s easy.
* lib/autoconf/c.m4 (AC_LANG_INT_SAVE (C)):
Change ‘()’ to ‘(void)’ to pacify picky compilers.
Problem reported by Vincent Lefevre in:
https://lists.gnu.org/r/autoconf-patches/2020-08/msg00000.html
(AC_C_INLINE): Likewise.
Zack Weinberg [Wed, 5 Aug 2020 14:45:22 +0000 (10:45 -0400)]
AT_CHECK_MACRO: Preserve config.log and config.status from run 1.
AT_CHECK_MACRO runs a test configure script twice and looks for
differences in the results. If something goes wrong, it’ll be helpful
for debugging to preserve the config.log and config.status files from
both runs.
* tests/local.at (AT_CHECK_MACRO): Also copy config.log and
config.status to config-log.$at_run and config-status.$at_run
respectively.
Only probe C++ language features, not library, for speed (#110285)
The test programs used by _AC_PROG_CXX_CXX98 and _AC_PROG_CXX_CXX11
can take several seconds to compile, even on current-generation CPUs.
Each of them may be test-compiled up to six times as the configure
script searches for appropriate command-line switches. This is
reported to cancel out all of the other performance gains made since
2.69.
Replace these programs with simpler ones that do not exercise the C++
standard *library* and can be compiled in less than a second each.
On my computer, which is quite new, the minimal configure script
AC_INIT
AC_PROG_CXX
executes in 4.5 seconds (wall-clock) before this change and 0.5
seconds after.
* lib/autoconf/c.m4 (_AC_CXX_CXX98_TEST_HEADER, _AC_CXX_CXX98_TEST_BODY):
Rewrite to test only C++ 1998 language features, not library features.
(_AC_CXX_CXX11_TEST_HEADER, _AC_CXX_CXX11_TEST_BODY):
Similarly for C++ 2011.
* doc/autoconf.texi (AC_PROG_CXX): Document this change.
Filter out _AST_FEATURES when comparing environment state. (#110283)
ksh93 uses an environment variable called _AST_FEATURES to communicate
with subshell instances of itself. Its value may change at any time
so AT_CHECK_ENV and AT_CONFIG_CMP should ignore it.
This was responsible for many spurious testsuite failures on
OpenIndiana. Problem reported by Bob Friesenhahn.
* tests/local.at (_AT_CHECK_ENV, AT_CONFIG_CMP): Add _AST_FEATURES to
list of variables set by shells to unstable values.
Zack Weinberg [Tue, 4 Aug 2020 12:46:59 +0000 (08:46 -0400)]
Partially revert e54e3f90: restore use of $(MAKE) in error message.
In commit 14d58bfd, the error message printed by the
‘abort-due-to-no-makefile’ rule in GNUmakefile was changed to refer to
the value of ‘$(MAKE)’ instead of a literal ‘make’. A subsequent
‘make fetch’ (e54e3f90) clobbered this. Put it back.
Paul Eggert [Sun, 2 Aug 2020 23:31:13 +0000 (16:31 -0700)]
Expect OpenIndiana test failure
On OpenIndiana, Perl file locking does not work atop NFS.
* tests/tools.at (autom4te cache locking):
Expect this test to file if Perl file locking does not work.
Paul Eggert [Sun, 2 Aug 2020 23:24:50 +0000 (16:24 -0700)]
Work around ksh93 bug that broke config.status
* lib/autoconf/status.m4 (_AC_OUTPUT_HEADER):
Use ‘>&1’, which is a no-op, to work around a bug in ksh93
Version JM 93t+ 2010-03-05 as used in OpenIndiana.
The bug causes ‘printf "foo"’ to mistakenly succeed in
some cases even though the underlying ‘write’ syscall fails.
The ‘>&1’ causes the printf to fail, as it should.
Paul Eggert [Sun, 2 Aug 2020 00:53:03 +0000 (17:53 -0700)]
Fix regression: autotools and whitespace in file names
* bin/autoheader.in (templates_for_header): Fix previous change by
not warning about file names with shell metacharacters, as this is
OK for command-line file names.
Paul Eggert [Sat, 1 Aug 2020 18:47:10 +0000 (11:47 -0700)]
Fix regression that broke Automake ‘make check’
Problem reported by Ken Moffat (sr#110287); the problem was
introduced in 2016-12-21T16:15:46Z!daniel.kitta@gmail.com.
* bin/autoheader.in (templates_for_header):
When generating warnings about symbols lacking templates,
downgrade template read failure from a fatal error to a warning.
Also, don’t even try to read from a template file whose name has
shell metavariables (which Autoconf 2.50 withdrew support for);
just warn about that, too. These changes cause the Automake
tests to merely generate warnings that are ignored, instead
of failing.
* doc/autoconf.texi (Configuration Files, Configuration Headers)
(Configuration Commands, Configuration Links):
Also document here that the file names should not contain
shell metacharacters, to make this constraint more obvious.
Bruno Haible [Fri, 31 Jul 2020 20:57:51 +0000 (13:57 -0700)]
doc: Refer to Gnulib where it makes sense.
* doc/autoconf.texi (Particular Functions): Point to Gnulib wherever Gnulib has
more workarounds than mentioned for the particular macro, namely for
AC_FUNC_CHOWN, AC_FUNC_FSEEKO, AC_FUNC_GETGROUPS, AC_FUNC_GETMNTENT,
AC_FUNC_MBRTOWC, AC_FUNC_STRERROR_R, AC_FUNC_STRTOLD.
Bruno Haible [Fri, 31 Jul 2020 20:57:37 +0000 (13:57 -0700)]
doc: Refer to Gnulib instead of asking clients to provide replacement code.
* doc/autoconf.texi (Particular Functions): Point to Gnulib for all macros that
may call AC_LIBOBJ, namely AC_FUNC_ALLOCA, AC_FUNC_MALLOC, AC_FUNC_OBSTACK,
AC_FUNC_REALLOC, AC_FUNC_STRNLEN.
Paul Eggert [Fri, 31 Jul 2020 01:51:14 +0000 (18:51 -0700)]
Remove obsolete Cray support
Gnulib removed this recently, and we should be consistent.
* doc/autoconf.texi (Autoheader Macros):
Use a more up-to-date example.
* lib/autoconf/functions.m4 (CRAY_STACKSEG_END): Remove.
This is backported from the following Gnulib patch:
https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=41a2d446c7984f8f39e3eeca40c6d30630969c10
This is a follow-up for the various patches to address problems with
tests 221 and 222 with various non-GNU make implementations. We’re
not trying to exercise Make at all in these tests; it’s just a
convenient way to invoke the compiler found by AC_PROG_CC on a test
program. The tests will be more reliable if we minimize the number of
Make features we are using. So: no implicit rules at all, and no
intermediates. Generate ‘testprog’ directly from ‘testprog.c’.
Also copy from fortran.at a more thorough set of substitution
variables for the compilation command, mainly for consistency,
and don’t use Makefile variables, again for consistency with
fortran.at.
(This is also, theoretically, faster since we’re only invoking the
compiler driver once, but it’s probably not enough of a difference to
measure.)
Paul Eggert [Wed, 22 Jul 2020 19:56:19 +0000 (12:56 -0700)]
Port AC_F77_LIBRARY_LDFLAGS to oneAPI HPC Toolkit
Problem reported by Bill Dieter in:
https://lists.gnu.org/r/bug-autoconf/2020-07/msg00089.html
* lib/autoconf/fortran.m4 (_AC_FC_LIBRARY_LDFLAGS):
Defend against ‘clang -mllvm -loopopt=0’.
Paul Eggert [Mon, 20 Jul 2020 22:10:33 +0000 (15:10 -0700)]
Don’t assume plain ‘make’ in C unit tests
Problem reported by Bruno Haible in:
https://savannah.gnu.org/support/?110273#comment6
* lib/autoconf/general.m4 (_AC_ARG_VAR_VALIDATE):
* tests/autotest.at (C unit tests, C unit tests (EXEEXT)):
Prefer ‘${MAKE-make}’ to ‘make’ in shell code.
Paul Eggert [Sat, 18 Jul 2020 01:42:26 +0000 (18:42 -0700)]
Port build procedure to AIX 7.1
* lib/freeze.mk (MY_AUTOM4TE, build_libdir, m4f_dependencies):
Prefer ‘$(top_build_prefix)’ to ‘$(top_builddir)/’.
The difference matters on AIX 7.1, where ‘make’ doesn’t know that
bin/autom4te and ./bin/autom4te are the same file,
and gets confused about dependencies without this change.
‘$(top_build_prefix)bin/autom4te’ expands to ‘bin/automake’
whereas ‘$(top_builddir)/bin/autom4te’ expands to
‘./bin/automake’, and the former works where the latter doesn’t.
Paul Eggert [Fri, 17 Jul 2020 22:06:49 +0000 (15:06 -0700)]
Test AC_FC_LINE_LENGTH only to 250 columns
* NEWS, doc/autoconf.texi, lib/autoconf/fortran.m4:
Document 250, not 254.
* tests/fortran.at (AC_FC_LINE_LENGTH): Test lines with 250
columns not 253, since Oracle Studio 12.6 Fortran 95 8.8
2017/05/30 goes up only to 250.
Paul Eggert [Fri, 17 Jul 2020 00:35:36 +0000 (17:35 -0700)]
Fix ${VAR-NONWORD} bugs
* lib/autoconf/functions.m4 (AC_FUNC_SELECT_ARGTYPES):
* lib/autoconf/programs.m4 (AC_FUNC_SELECT_ARGTYPES):
* lib/autotest/general.m4 (AT_INIT):
Rewrite to avoid ${VAR-VALUE} where VALUE is not a shell word.
tests/autotest.at: don’t use suffix rules to generate executables
In two tests, when @EXEEXT@ is empty, we were generating Makefiles
containing suffix rules with only one explicit suffix, e.g.
.o:
$(CC) -o $@ $^
Solaris 10’s ‘dmake’ does not understand this as a rule to create
‘foo’ from ‘foo.o’. That’s not the point of the tests, so use
ordinary per-rule commands to link the executables in these tests
instead.
Paul Eggert [Thu, 16 Jul 2020 16:46:28 +0000 (09:46 -0700)]
Fix AC_PROG_LEX regression
Problem reported by Ross Burton in:
https://savannah.gnu.org/support/?110269
* lib/autoconf/programs.m4 (_AC_PROG_LEX_YYTEXT_DECL):
If tests indicate that LEX or LEXLIB does not work, set LEX to ":"
and LEXLIB empty, instead of failing out of 'configure' entirely.
Bruno Haible [Wed, 15 Jul 2020 20:34:24 +0000 (22:34 +0200)]
doc: More clarifications regarding --host and --build.
* doc/autoconf.texi (Specifying Target Triplets): Describe the effects
of --host in more detail. Don't recommend to specify --build when
specifying --host. Add another example regarding MinGW.
Paul Eggert [Wed, 15 Jul 2020 20:29:29 +0000 (13:29 -0700)]
Revert mistaken patch for Bison
Problem reported by Bruno Haible in:
https://savannah.gnu.org/support/?110266
* lib/autoconf/programs.m4 (AC_PROG_YACC):
Go back to using bison -y instead of bison -o y.tab.c.
Paul Eggert [Wed, 15 Jul 2020 17:32:14 +0000 (10:32 -0700)]
Revert mistaken patch for Wine
* lib/autoconf/lang.m4 (_AC_COMPILER_EXEEXT_CROSS):
Revert patch trying to cater to GNU/Linux builds
for Wine. They should use --build as well as --host.
Problem reported by Bruno Haible in:
https://savannah.gnu.org/support/?110268
This macro was replaced by AC_CONFIG_HEADERS many years ago (before
the beginning of the VCS history) and isn’t even documented, but we
never got around to making autoupdate notice it. Problem reported
*in 2006* by jensseidel@users.sf.net.
There was one use of AC_CONFIG_HEADER in our source tree, which is
converted. Also, to avoid confusing people reading old NEWS or TODO
entries, all mentions of AC_CONFIG_HEADER therein are also replaced
with AC_CONFIG_HEADERS.
* lib/autoconf/status.m4 (AC_CONFIG_HEADER): Make an AU_ALIAS for
AC_CONFIG_HEADERS.
Add AC_PROG_EGREP to AU_DEFUN for AC_HEADER_STDC (#110215)
AC_HEADER_STDC used to use AC_EGREP_CPP, and therefore had the side
effect of AC_REQUIRE([AC_PROG_EGREP]). In 2.70 AC_HEADER_STDC is an
AU_DEFUN and, before this change, the replacement didn’t invoke
AC_PROG_EGREP, which broke configure scripts that assumed $EGREP would
be set. Problem reported by Ross Burton.
* lib/autoconf/headers.m4 (AU::AC_HEADER_STDC): Also invoke AC_PROG_EGREP.
Tom [Sun, 12 Jul 2020 14:44:11 +0000 (10:44 -0400)]
Fix logic error in _AC_PROG_LEX_YYTEXT_DECL (#109320)
The search for the appropriate value for @LEXLIB@ did not distinguish
correctly between success (‘break’ out of a shell for loop, having set
$ac_cv_lib_lex) and failure (normal termination of the loop, value in
$ac_cv_lib_lex is garbage). Bug report and original patch by
Tom <tom@ojodeagua.com> with refinements by Zack Weinberg.
* lib/autoconf/programs.m4 (_AC_PROG_LEX_YYTEXT_DECL):
Error out if we cannot find the library that (f)lex scanners
need to be linked against, instead of continuing with @LEXLIB@
set to the empty string.
Update hyperlinks in the manual and README-hacking.
Lots of http:// -> https:// conversions;
refer to XZ Utils instead of the obsolete LZMA Utils;
remove dead link to dbaspot.com;
replace mention of -fmudflap with -fsanitize=
and add a proper cross-reference to the GCC manual for that.
Update links in COPYING, COPYINGv3, and COPYING.EXCEPTION.
- COPYINGv3 now exactly matches
https://www.gnu.org/licenses/gpl-3.0.txt
as of 2020-07-10.
The only change was to turn a bunch of http:// URLs
into https:// URLs.
- COPYING now exactly matches
https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
as of 2020-07-10
except that the FSF’s old postal address has been deleted
and <https://fsf.org/> inserted
(consistent with COPYINGv3).
Besides the above, the only change was to whitespace.
- A typo in a URL in COPYING.EXCEPTION was corrected.
Paul Eggert [Fri, 10 Jul 2020 20:42:26 +0000 (13:42 -0700)]
Document AS_IF(..., ..., [[]]) glitch
* doc/autoconf.texi (Common Shell Constructs):
Note the if-false arg problem reported by Jannick in:
https://lists.gnu.org/r/autoconf/2020-03/msg00045.html
Paul Eggert [Fri, 10 Jul 2020 19:03:44 +0000 (12:03 -0700)]
Fix ac_compiler_gnu bug
Problem and fix reported by Jannick in:
https://lists.gnu.org/r/autoconf/2020-03/msg00045.html
except that I omitted the comment, which I thought unnecessary.
* lib/autoconf/lang.m4 (_AC_LANG_COMPILER_GNU): Set
ac_compiler_gnu regardless of whether result was from cache.
Paul Eggert [Fri, 3 Jul 2020 05:23:59 +0000 (22:23 -0700)]
Fix AC_CHECK_LIB quoting bug
Problem reported by Bert Wesarg in:
https://lists.gnu.org/archive/html/autoconf/2016-04/msg00020.html
* lib/autoconf/libs.m4 (AC_CHECK_LIB): Fix quoting bug.
* tests/semantics.at (AC_CHECK_LIB): Add a test for the bug.
Zack Weinberg [Tue, 30 Jun 2020 02:13:23 +0000 (19:13 -0700)]
Consistently expand macros in whitespace-separated lists.
Several of the most commonly used Autoconf macros (starting with
AC_CHECK_FUNCS and AC_CHECK_HEADERS) take a whitespace-separated list
of symbols as their primary argument. It would abstractly be best if
this list were _not_ subject to M4 macro expansion, in case there’s a
collision between a M4 macro name and something to be looked for.
However, we have historically not been careful about this, and there’s
been reports of configure scripts using ‘dnl’ to write comments inside
the list. The AS_LITERAL_IF optimizations added to AC_CHECK_FUNCS and
AC_CHECK_HEADERS since 2.69 broke some of those scripts with bizarre
shell syntax errors.
Also, the macro expansion behavior is not consistent among all of the
macros that take whitespace-separated lists, nor is it consistent
between autoconf and autoheader.
Address this by introducing a new m4sugar macro, currently called
‘m4_validate_w’ (I’m open to suggestions for better names). Here’s
its documentation comment:
| m4_validate_w(STRING): Expands into m4_normalize(m4_expand([STRING])),
| but if that is not the same as just m4_normalize([STRING]),
| issue a warning.
The text of the warning is
| configure.ac:N: warning: whitespace-separated-list contains macros;
| configure.ac:N: in a future version of Autoconf they will not be expanded
If the unexpanded form of the string contains the token ‘dnl’ then
there’s an additional line:
| configure.ac:N: note: ‘dnl’ is a macro
All of the public macros that take a whitespace-separated list of
symbols are changed to pass that argument through m4_validate_w before
doing anything else with it, and the test suite is updated to verify
consistent behavior for every last one of them.
This addresses Savannah issues #110210 and #110211, and the harmless
but annoying autoheader behavior described at
https://lists.gnu.org/archive/html/bug-autoconf/2018-02/msg00005.html .
In order to avoid expanding relatively expensive m4sugar macros
multiple times per top-level macro invocation, several of the affected
Autoconf macros are restructured along the same lines as I did for
AC_REPLACE_FUNCS in the previous patch.
* lib/m4sugar/m4sugar.m4 (m4_validate_w): New macro.
* lib/autoconf/functions.m4 (AC_CHECK_FUNCS, AC_CHECK_FUNCS_ONCE)
(AC_REPLACE_FUNCS)
* lib/autoconf/general.m4 (AC_CONFIG_MACRO_DIRS, AC_CHECK_FILES)
* lib/autoconf/headers.m4 (AC_CHECK_HEADERS, AC_CHECK_HEADERS_ONCE)
* lib/autoconf/status.m4 (AC_CONFIG_SUBDIRS): Pass $1 through
m4_validate_w before use.
* lib/autoconf/headers.m4 (AC_CHECK_HEADERS): Refactor with helpers
_AC_CHECK_HEADERS_ONE_U, _AC_CHECK_HEADERS_ONE_S, _AC_CHECK_HEADERS_ONE_C.
(AC_CHECK_HEADERS_ONCE): Eliminate _AC_CHECK_HEADERS_ONCE.
(AC_CHECK_INCLUDES_DEFAULT): Don’t use _AC_CHECK_HEADERS_ONCE.
* lib/autoconf/functions.m4 (AC_CHECK_FUNCS): Refactor with helpers
_AC_CHECK_FUNCS_ONE_U, _AC_CHECK_FUNCS_ONE_S, _AC_CHECK_FUNCS_ONE_C.
* lib/autoconf/status.m4 (_AC_CONFIG_SUBDIRS): No need to use m4_normalize.
* tests/semantics.at: Add tests for expansion of M4 macros in
whitespace-separated list arguments to all of the above.
Zack Weinberg [Tue, 30 Jun 2020 01:55:39 +0000 (18:55 -0700)]
AC_REPLACE_FUNCS: invoke _AH_CHECK_FUNC and AC_LIBSOURCE unconditionally.
While investigating something else, I noticed that AC_REPLACE_FUNCS
calls _AH_CHECK_FUNC and AC_LIBSOURCE in the success branch of an
AC_CHECK_FUNC. This doesn’t work; both of those are marker macros
that need to be expanded unconditionally at m4 time so that traces
(placed by autoheader and automake, respectively) will fire. In order
to fix this while keeping the code readable, I would up doing a major
refactor. There are now four internal macros implementing AC_REPLACE_FUNCS.
_AC_REPLACE_FUNC_U is called unconditionally for every shell word in
the list passed to AC_REPLACE_FUNCS, and does _AH_CHECK_FUNC +
AC_LIBSOURCE if it can, or issues a warning if it can’t. (It could
make sense to make this a public function, if we think shell variables
in the AC_REPLACE_FUNCS list need to be supported long-term. I dunno
if there’s a use case that can’t be handled by AC_REPLACE_FUNCS inside
a shell conditional just as well.)
_AC_REPLACE_FUNC_L and _AC_REPLACE_FUNC_NL implement the actual test
performed for each function to be replaced; the difference is that _L
(for literal) can only be used on a function whose name is known at m4
expansion time, _NL (nonliteral) works regardless. _AC_REPLACE_FUNCS,
which already existed, handles looping either at m4 time or shell time
as appropriate. AC_REPLACE_FUNCS remains a thin wrapper that runs
_AC_REPLACE_FUNCS(m4_flatten([$1])).
The _bulk_ of the patch is changes to the testsuite so that it notices
the original bug. Specifically, AT_CHECK_AUTOHEADER now takes an
argument which is a whitespace-separated list of preprocessor macro
names that ought to appear in the generated config.h.in. This can be
set to ‘ignore’ to skip the test, and unfortunately that’s what the
“trivial” per-macro tests have to do (AT_CHECK_MACRO and friends), so
coverage is not ideal, but it’s better than what we had. Also,
AT_CHECK_M4 now normalizes the backtrace lines that appear in the
output of an AC_DIAGNOSE, e.g.
configure.ac:6: warning: The macro `AC_LANG_SAVE' is obsolete.
configure.ac:6: You should run autoupdate.
../../lib/autoconf/lang.m4:125: AC_LANG_SAVE is expanded from...
configure.ac:6: the top level
becomes
configure.ac:6: warning: The macro `AC_LANG_SAVE' is obsolete.
configure.ac:6: You should run autoupdate.
lang.m4: AC_LANG_SAVE is expanded from...
configure.ac:6: the top level
This allows us to write tests for these diagnostics that don’t depend
on the relationship between the source and build directories, and
won’t break when unrelated patches change the line number of a macro
definition.
* lib/autoconf/functions.m4 (AC_REPLACE_FUNCS, _AC_REPLACE_FUNCS)
(_AC_REPLACE_FUNC): Refactor into AC_REPLACE_FUNCS,
_AC_REPLACE_FUNCS, _AC_REPLACE_FUNC_U, _AC_REPLACE_FUNC_L,
_AC_REPLACE_FUNC_NL. Ensure that _AH_CHECK_FUNC and
AC_LIBSOURCE are invoked unconditionally at m4 expansion
time for each literal function name in the argument to
AC_CHECK_FUNCS. Issue warnings about non-literal names.
* tests/local.at (AT_CHECK_M4): Normalize backtrace lines from
the output of AC_DIAGNOSE / m4_warn.
(AT_CHECK_AUTOHEADER): Add arg EXPECTED-TMPLS
giving a list of preprocessor macro names that should appear
in the generated config.h.in. Use AT_CHECK_M4 to invoke autoheader.
(_AT_CHECK_AC_MACRO, AT_CHECK_MACRO, AT_CHECK_AU_MACRO):
Update uses of AT_CHECK_AUTOHEADER.
* tests/fortran.at, tests/semantics.at, tests/tools.at
* tests/torture.at: Update all uses of AT_CHECK_AUTOHEADER.
* tests/semantics.at (AC_REPLACE_FUNCS test): Make somewhat
more thorough, using new functionality of AT_CHECK_M4 and
AT_CHECK_AUTOHEADER.
Zack Weinberg [Tue, 30 Jun 2020 01:40:48 +0000 (18:40 -0700)]
Look harder for a shell whose -n is known to work.
The test suite was insisting on using /bin/sh -n for syntax checking,
which meant that if /bin/sh wasn’t one of the short list of shells
whose -n is known to work, we would skip all of the syntax-check
tests, even if some other shell was available that would work.
Instead do like _AS_DETECT_BETTER_SHELL, and loop over possible
shells, starting with $SHELL and going on to a hardwired list of
known-good possibilities. The result is written to the substitution
variable @SHELL_N@ and the testsuite uses that.
(Should we invoke AC_PATH_PROG on the result of the search if it’s not
already absolute?)
* configure.ac: Search for a shell whose -n mode is known to
work, instead of just checking /bin/sh. Set @SHELL_N@ to
what we find.
* tests/atlocal.in: Propagate @SHELL_N@ to testsuite.
* tests/local.at (AT_CHECK_SHELL_SYNTAX): Use $SHELL_N instead
of hardcoding /bin/sh. Update test for usable shell -n.
(AT_CHECK_AUTOCONF): Update test for usable shell -n.
* tests/tools.at: Update test for usable shell -n.