Commit Graph

708 Commits

Author SHA1 Message Date
Paul Eggert
64df9b4523 Autoconf now quotes 'like this' instead of `like this'
Autoconf’s diagnostics now follow current GNU coding standards,
which say that diagnostics in the C locale should quote 'like this'
with plain apostrophes instead of the older GNU style `like this'
with grave accent and apostrophe.
2021-07-20 16:04:21 -05:00
Zack Weinberg
6d38e9fa2b
trunk post-release administrivia
Matching the commits on the release branch:

* NEWS: Bring over record of release notes.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2021-01-28 17:54:10 -05:00
Zack Weinberg
300349c84b
make update-copyright 2021-01-28 15:19:21 -05:00
Zack Weinberg
697c1a07cd
maint: add outline for future NEWS 2020-12-08 20:53:13 -05:00
Zack Weinberg
29ed3a774d
maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2020-12-08 13:04:16 -05:00
Zack Weinberg
97fbc5c184
Release 2.70. 2020-12-08 11:31:19 -05:00
Zack Weinberg
b045574cb2
AC_INCLUDES_DEFAULT: Check for presence of C90 hosted headers (#110393)
Since 1993, Autoconf has been assuming that it is safe to include any
of the headers defined by ISO C90 without checking for them; this is
inaccurate, since only a subset are necessarily available in a
C90 *freestanding* environment.

It is OK to assume the presence of a header in a macro that checks
specifically for something declared by that header (if the header is
not present, we will think the specific declaration is unavailable,
which is probably accurate for modern embedded environments).  It is
also OK to continue recommending that user code use these headers
unconditionally—anyone working with a freestanding environment knows
it.  But it is not OK for very generic code within Autoconf itself,
such as AC_INCLUDES_DEFAULT, to make this assumption.

Note that the set of headers that are not always available includes
stdio.h, which we have been assuming can be included unconditionally
for even longer.

In AC_INCLUDES_DEFAULT, revert to checking for string.h and stdlib.h
before including them.  Also revert to defining STDC_HEADERS only when
string.h and stdlib.h are available (but do not check for float.h and
stdarg.h, as these are part of the freestanding set).  Add a new check
for stdio.h.  Sort the inclusion list by standard (C90 freestanding;
C90 hosted; C99; POSIX) and alphabetically within each group.  Revise
all the documentation and update the testsuite.

This partially reverts commit 86c213d0e3
and is a partial fix for bug #110393.

* lib/autoconf/headers.m4 (AC_CHECK_INCLUDES_DEFAULT): Check for
  stdio.h, stdlib.h, and string.h before including them.  Define
  STDC_HEADERS only when string.h and stdlib.h are both available.
  Organize includes list by standard, then alphabetically.

* doc/autoconf.texi, NEWS: Update to match.

* tests/local.at (AT_CHECK_DEFINES): Make regexes more specific.
  Also expect a definition of HAVE_STDIO_H.
* tests/c.at, tests/semantics.at, tests/tools.at: Use <float.h>,
  not <stdio.h>, as a header that we expect always to exist.
  Add HAVE_STDIO_H to various lists of macros that are expected to
  appear in config.h.
2020-12-06 11:40:39 -05:00
Zack Weinberg
c38538737c
Revert "AC_PROG_CC: define via AC_DEFUN_ONCE". (#110350)
Revert commit 18c140b50b, restoring
AC_PROG_CC to being defined as an ordinary AC_DEFUN.  This broke
third-party macros (e.g. the Autoconf Macro Archive’s
AX_PROG_CC_FOR_BUILD) that intentionally invoked AC_PROG_CC a second
time with its guts redefined via a whole bunch of ‘pushdef’s.  I don’t
think we want to support this long-term, but needing access to a
build-native compiler in cross-compilation is common enough that we
should have *some* supported way to do it, and it may as well be
AX_PROG_CC_FOR_BUILD until we come up with something better.

If we go back to AC_DEFUN_ONCE for AC_PROG_CC in the future, we should
do it consistently for all the “find me a compiler” macros -- it
was *only* done for AC_PROG_CC in 18c140b5.

The rationale for AC_DEFUN_ONCE seems to have been to reduce the size
of the generated configure script.  The bulk of the size accountable to
AC_PROG_CC is the test programs for figuring out which version of the
C standard is available, so I tweaked _AC_C_STD_TRY (and _AC_CXX_STD_TRY)
to emit that text only once per program, into shell variables which
can then be referenced repeatedly.

Fixes bug #110350.

* NEWS, doc/autoconf.texi: Revert documentation changes associated
  with AC_PROG_CC being a one-shot macro.
* lib/autoconf/c.m4 (AC_PROG_CC): Revert to defining with AC_DEFUN.
  (_AC_C_STD_TRY, _AC_CXX_STD_TRY): Emit the test program only once,
  even if invoked multiple times with the same arguments.

* tests/foreign.at (AX_PROG_CC_FOR_BUILD, AX_PROG_CXX_FOR_BUILD):
  New tests.
2020-12-04 16:41:43 -05:00
Zack Weinberg
2a7a441b43
Autotest: add official way to execute code before all/each test.
Currently, there isn’t any documented way for an Autotest testsuite to
add custom code to be run either right before the main driver loop, or
at the point of each AT_SETUP.  For instance, there’s no good place to
put environment variable sanitization that should apply to the entire
testsuite (but isn’t universally relevant), or shell function
definitions to be used by custom test macros.

Autoconf’s test suite is poking shell functions directly into the
PREPARE_TESTS diversion, and doing environment variable sanitization
in each individual test.  Both of these are obviously undesirable.

This patch adds three new AT_* macros that can be used to do these
things in an officially-supported way: AT_PREPARE_TESTS adds code to
be run right before the main driver loop, AT_PREPARE_EACH_TEST adds
code to be run at the beginning of each test, and AT_TEST_HELPER_FN
defines a shell function that will be available to each test.  In
Autoconf’s test suite, I use AT_PREPARE_TESTS to factor out
environment variable sanitization that *ought* to apply across the
board, and AT_TEST_HELPER_FN for the helper function used by
AT_CHECK_ENV.

(This fixes the testsuite bug reported by Jannick at
https://lists.gnu.org/archive/html/autoconf/2020-10/msg00052.html :
CONFIG_SITE in the parent environment will no longer be visible to tests.)

It would be nice to give an example of when AT_PREPARE_EACH_TEST is
useful, in the documentation, but I didn’t find one in the autoconf
test suite.

* lib/autotest/general.m4 (AT_PREPARE_TESTS, AT_PREPARE_EACH_TEST)
  (AT_TEST_HELPER_FN): New macros.
  (AT_INIT, AT_TESTED): Emit the code to report tested programs only
  if it’s needed, and make sure it’s after any code added by
  AT_PREPARE_TESTS.

* tests/local.at: Add AT_PREPARE_TESTS block that ensures
  $MAKE is set sensibly and $MAKEFLAGS and $CONFIG_SITE are unset.
  Use AT_TEST_HELPER_FN for the helper function needed by AT_CHECK_ENV.
  (AT_CHECK_MAKE): No need to sanitize $MAKE or $MAKEFLAGS here.
* tests/base.at, tests/compile.at, tests/m4sh.at, tests/torture.at:
  No need to unset or neutralize $CONFIG_SITE in individual tests.
* tests/autotest.at: Add tests for new macros.

* doc/autoconf.texi, NEWS: Document new macros.
2020-12-02 10:29:25 -05:00
Zack Weinberg
d7b0636850
Add a note to NEWS about ac_cv_header_stdlib_h not being set...
... even though HAVE_STDLIB_H is.
2020-12-01 09:04:26 -05:00
Zack Weinberg
f44695c56b
Add more release notes about compatibility problems.
See https://savannah.gnu.org/support/?110382 and
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97998 for background.
2020-11-30 11:45:28 -05:00
Zack Weinberg
b8c150bd0d
AT_CHECK_MACRO: test C++ as well as C, cross as well as native
Many of the reported regressions in Autoconf 2.70 betas went unnoticed
for years because Autoconf’s bundled test suite didn’t test most of
the macros with a C++ compiler and/or in cross compilation mode.
There’s a special makefile target ‘maintainer-check-c++’ that runs all
the tests with CC=g++, but that doesn’t catch the regressions either,
because it doesn’t compare the configure results with what you’d have
gotten with a C compiler.  Also, C and C++ have diverged to the point
where setting CC to a C++ compiler doesn’t work reliably anymore.

This patch overhauls AT_CHECK_MACRO to test each macro four times:
(C compiler, C++ compiler) x (native mode, cross-compilation mode).
All four tests are expected to produce the same config.cache and
config.h, except for certain predictable differences due to running
AC_PROG_CXX instead of AC_PROG_CC, and a short list of known,
acceptable differences, maintained in mktests.pl.

There are two classes of known, acceptable differences.  Macros that
use AC_RUN_IFELSE aren’t tested in cross-compilation mode at all,
because they may crash the script (this is temporary and will be
revisited after 2.70).  Macros that correctly detect a difference
between C and C++ (e.g. AC_HEADER_STDBOOL will notice that C++ doesn’t
have the _Bool type) are annotated with the specific cache variable
and #define that varies.

mktests.pl now also has the capability to provide values for the
MACRO-USE, ADDITIONAL-COMMANDS, and AUTOCONF-FLAGS arguments to
AT_CHECK_(AU_)MACRO, on a per-macro basis, but that’s not used in this
patch.

Some of the manual uses of AT_CHECK_MACRO do not need to test C++
and/or cross compilation; for them, there is a new test helper,
AT_CHECK_CONFIGURE_AC.  Another new helper, AT_PRESERVE_CONFIG_STATUS,
is used extensively in AT_CHECK_(AU_)MACRO but may be also useful in
manual tests that need to do multiple configure runs.

This change supersedes AT_CHECK_MACRO_CROSS and
‘make maintainer-check-c++’, which are removed.

In my testing, setting CC to a C++ compiler no longer works at all,
for reasons that are impractical to fix (e.g. C++ compilers choke on
the test for C2011 features) so I have added a note to NEWS saying
that this is not supported anymore.

 * tests/local.at (AT_CHECK_MACRO): Default behavior is now to test
   the macro in both native and cross-compilation mode, and expect the
   results to be identical.  If the macro transitively required
   AC_PROG_CC, and a C++ compiler is available, then test it twice
   more with AC_LANG([C++]) in effect, and again expect the results to
   be identical.  New fifth argument TEST-PARAMETERS can modify this
   behavior.
   (_AT_FILTER_CXX_CV_VARIES, _AT_FILTER_CXX_DEFINE_VARIES): New,
   subroutines of AT_CHECK_MACRO.

   (AT_CHECK_MACRO_CROSS): Remove, subsumed by new AT_CHECK_MACRO
   behavior.
   (AT_CHECK_AU_MACRO): Forward to AT_CHECK_MACRO for the basic test;
   then do the same autoupdate test as before, as a separate test group.

   (at_check_env): Also ignore OPENMP_CXXFLAGS.
   (AT_CONFIG_CMP): Add third argument EXTRA-VARIANCE that specifies
   additional variables that are expected to vary in a particular test.
   (_AT_CONFIG_CMP_PRUNE): New, subroutine of AT_CONFIG_CMP.
   (AT_DEFINES_CMP): New helper macro that compares config.h headers,
   with the ability to ignore variation in specific defines.
   (_AT_DEFINES_CMP_PRUNE): New, subroutine of AT_DEFINES_CMP.

   (AT_PRESERVE_CONFIG_STATUS): New helper that makes copies of
   config.h, config.log, config.status, and state-env.after under
   names that won’t be clobbered by a subsequent run of configure.

   (AT_CHECK_CONFIGURE_AC): New helper that defines a complete test
   group consisting of a single invocation of _AT_CHECK_AC_MACRO;
   effectively what AT_CHECK_MACRO used to be.
   (_AT_CHECK_AC_MACRO): Correct documentation comment; the PRE-TESTS
   argument has always been optional.

 * tests/mktests.pl (test_parameters): New global data object giving
   extra arguments to pass to AT_CHECK_MACRO/AT_CHECK_AU_MACRO on a
   per-macro basis.
   (emit_test): New function that handles emitting calls to
   AT_CHECK_(AU_)MACRO with the desired arguments.
   (scan_m4_files): Use emit_test.

   (au_exclude_list): Add AC_HAVE_LIBRARY, AC_COMPILE_CHECK,
   AC_TRY_CPP, AC_TRY_COMPILE, AC_TRY_LINK, and AC_TRY_RUN.

 * tests/semantics.at (AC_CHECK_LIB, AC_SEARCH_LIBS): Rewrite test
   using symbols from zlib instead of libm, to get consistent behavior
   from C and C++.
   (AC_SEARCH_LIBS (none needed)): Revise to clarify what is being tested.
   (AC_CHECK_DECLS): Use _AC_LANG_ABBREV when inspecting cache variables.
   (AC_CHECK_ALIGNOF, AC_CHECK_ALIGNOF struct)
   (AC_CHECK_SIZEOF, AC_CHECK_SIZEOF struct)
   No need for AT_CHECK_MACRO_CROSS.
   (AC_CHECK_FILES): Switch to AT_CHECK_CONFIGURE_AC.
   (AC_SYS_RESTARTABLE_SYSCALLS, AC_FUNC_WAIT3): Do not test in cross
   compilation mode.
   (AC_TRY_CPP, AC_TRY_COMPILE, AC_TRY_LINK, AC_TRY_RUN)
   (AC_COMPILE_CHECK, AC_HAVE_LIBRARY): New manual AT_CHECK_AU_MACRO tests.

 * tests/c.at (Extensions, C keywords, AC_PROG_CPP requires AC_PROG_CC)
   (AC_NO_EXECUTABLES (working linker), AC_NO_EXECUTABLES (broken linker)):
   Switch to AT_CHECK_CONFIGURE_AC. Also convert case statements to AS_CASE.
   (Broken/missing compilers): Pass CC=no-such-compiler on the command
   line instead of hardwiring it in the configure script.

 * tests/local.mk (maintainer-check-c++): Remove target.
   (maintainer-check): Run the ordinary ‘make check’ as well as
   ‘make maintainer-check-posix’.
2020-11-30 11:45:27 -05:00
Zack Weinberg
fd633e92cb
AS_IF: Handle else clause being empty after macro expansion (#110369)
AS_IF can emit a syntactically invalid shell if-then-else,

  if CONDITION
  then :
    # ...
  else
  fi

when its IF-FALSE argument consists of macros that don’t produce any
shell code.  This was a documented limitation in AS_IF, but it’s a bad
limitation to have, because macros that *used* to expand to shell
commands might start expanding to nothing in future releases.  For
instance, this broke the libzmq configure script, which did

  AC_PROG_CC
  AX_CHECK_COMPILE_FLAG([-std=gnu11],
    [CFLAGS+=" -std=gnu11"],
    [AC_PROG_CC_C99])

Perfectly valid in 2.69, but in 2.70 AC_PROG_CC_C99 doesn’t produce
any shell code and the script crashes.

We had that limitation for good reason: we can’t just put ‘:’ at the
beginning of the else-clause, like we do for the then-clause, because
that would clobber $? and the IF-FALSE commands might want to inspect
it.  (This doesn’t matter for the then-clause, because $? is always
zero at the beginning of a then-clause anyway.)  The simplest and
least inefficient shell construct I can find that works in this
context is a shell function that does ‘return $?’.  Due to awkward
M4sh initialization ordering constraints (AS_IF gets used before we
can safely use shell functions) an indirection through a shell
variable is necessary.  The structure of a m4sh script is now

  #! /bin/sh
  ## M4sh Initialization
  as_nop=:

  ...
  ## M4sh Shell Functions

  as_fn_nop () { return $?; }
  as_nop=as_fn_nop
  ...

and AS_IF emits

  if CONDITION
  then :
    # ...
  else $as_nop
    # ...
  fi

The uses of AS_IF that appear before the beginning of the M4sh Shell
Functions section are all under our control and they don’t need to
look at $?.

If anyone has a better idea for how to make this work I will be glad
to hear it.

Fixes bug #110369.

* lib/m4sugar/m4sh.m4
  (_AS_IF_ELSE): When $1 is nonempty, invoke _AS_EMPTY_ELSE_PREPARE.
  Emit $as_nop at beginning of else clause.
  (_AS_BOURNE_COMPATIBLE): Initialize as_nop to ‘:’.
  (_AS_EMPTY_ELSE_PREPARE): New macro which emits a definition of
  as_fn_nop and resets as_nop to as_fn_nop.
  (AS_PREPARE, _AS_PREPARE): Invoke _AS_EMPTY_ELSE_PREPARE.
  (_AS_UNSET_PREPARE): Tweak white space.

* tests/m4sh.at (AS_IF and AS_CASE): Test AS_IF’s IF-FALSE argument
  being empty after macro expansion.

* doc/autoconf.texi (AS_IF): Remove warning about use with
  ‘run-if-false’ argument empty after macro expansion.
2020-11-15 14:16:16 -05:00
Zack Weinberg
3b411849a0
m4sh: Require shell to support $(...) command substitution.
As of the 2020-11-07 update, config.sub and config.guess
unconditionally use $(...) command substitution; see
<https://lists.gnu.org/archive/html/config-patches/2020-11/msg00011.html>.

Therefore, add this to the set of required shell features, searched
for by _AS_DETECT_BETTER_SHELL.  On a system where /bin/sh doesn’t
support $(...), $CONFIG_SHELL will be set to one that does (and the
primary configure script will be re-executed using that shell).
AC_CANONICAL_* use $CONFIG_SHELL to execute config.guess/sub, so they
will keep working.  This also means that configure scripts and
third-party macros that use $(...) will quietly start working
correctly on such ancient systems.

The test code is simple, but sufficient to weed out Solaris 10’s
/bin/sh, which doesn’t support $(...) but *does* support shell
functions.

I’m not going to touch any of the existing uses of `...` command
substitution in Autoconf proper for now, but it might make sense to
bulk upgrade them early in the 2.71 release cycle; if nothing else,
it would remove a major obstacle to running shellcheck over our
scripts.

* lib/m4sugar/m4sh.m4 (_AS_MODERN_CMDSUBST_WORKS): New macro.
  (AS_INIT, AS_SHELL_SANITIZE): Call _AS_DETECT_REQUIRED for
  _AS_MODERN_CMDSUBST_WORKS.
* NEWS: Mention the requirement for $(...).
2020-11-09 15:15:23 -05:00
Zack Weinberg
47b08afd96
Mention AM_GNU_GETTEXT_REQUIRE_VERSION support in NEWS. 2020-11-09 13:25:14 -05:00
Zack Weinberg
46f384f850
Revert to 2.69-compatible behavior in AC_PROG_LEX (#110346)
Commit 29ede6b96f caused AC_PROG_LEX to
stop looking for a library that provides yywrap.  This broke several
packages in a Debian archive rebuild.

Revert all the way to the 2.69 behavior, which was to set LEXLIB to
-ll or -lfl if that library defines yywrap, but allow AC_PROG_LEX to
succeed if neither -ll nor -lfl exists on the system, even if a lex
program that doesn't define yywrap would need it.
(This behavior was a bug, but people have come to depend on it.
See https://savannah.gnu.org/support/index.php?110269 and the
thread starting from
https://lists.gnu.org/r/autoconf-patches/2020-07/msg00013.html
for gory details.)

To provide a path away from bug-compatibility, AC_PROG_LEX now takes
one argument, documented as a whitespace-separated list of options.
Two options are defined: ‘yywrap’ means to look for yywrap and behave
as if lex is unavailable if it isn’t found; ‘noyywrap’ means to not
look for yywrap at all.  These are mutually exclusive.

Fixes bug #110346.

* lib/autoconf/programs.m4 (AC_PROG_LEX): Add an argument which
  can be either ‘yywrap’, meaning to look for yywrap in -ll, or
  ‘noyywrap’, meaning to not look for yywrap at all.  In the
  absence of either option, issue an obsoletion warning and
  revert to behavior bug-compatible with 2.69.

* tests/semantics.at: Add more tests of AC_PROG_LEX.
* tests/mktests.sh: Exclude AC_PROG_LEX from autogenerated tests.

* doc/autoconf.texi: Update documentation of AC_PROG_LEX.
* NEWS: Update notes on AC_PROG_LEX.
2020-11-02 16:56:32 -05:00
Zack Weinberg
f1047b2e96
AC_OPENMP: Avoid clobbering ‘mp’ and/or ‘penmp’ (#110353)
Some of the compiler options that AC_OPENMP tests, mean “enable
OpenMP” to one compiler, but “write output to a file named ‘mp’ or
‘penmp’” to other compilers.  The author of AC_OPENMP believed that
this could only happen if compilation was *successful*, but didn’t
realize that one of the options means “write *preprocessed* output to
a file named ‘penmp’” to SunPRO C, and that this *would* succeed on
the test program.  (AC_LINK_IFELSE fails anyway, because the
compilation didn’t create conftest$exeext.)

The option that actually means “enable OpenMP” to SunPRO C is earlier
in the list than the option that means “write preprocessed output to a
file named ‘penmp’”, so we might never have noticed this, but for a
second bug: if you have a bad combination of Solaris operating system
patches installed, it’s possible for this compiler to
successfully *compile* a program that uses OpenMP, but then fail
to *link* it because the OpenMP runtime library is out of sync with
the core C library.  AC_OPENMP doesn’t distinguish this case from
“that option doesn’t mean ‘enable OpenMP’” so it goes on to other
entries in the list and hits the “write preprocessed output” one.

Implement four layers of defensive measures against this mess:

 - Use an #error directive instead of a compile-time syntax error
   to halt compilation when _OPENMP is not defined.
 - For each option that might mean “enable OpenMP”, first do an
   AC_COMPILE_IFELSE to find out whether it really means that, and
   then an AC_LINK_IFELSE to find out whether it works.  If the
   compilation succeeds but the link fails, bail out of the loop and
   declare OpenMP to be unsupported.
 - If a file named ‘mp’ or ‘openmp’ exists in configure’s working
   directory when AC_OPENMP begins, error out.  This means it is safe
   to delete any file named ‘mp’ or ‘openmp’ that exists at the *end*
   of AC_OPENMP.
 - If a file named ‘mp’ or ‘openmp’ exists in the top level of the
   source tree with a configure.ac that uses AC_OPENMP, have autoconf
   error out, too.

Fixes bug #110353.  Problem reported by Dagobert Michelsen.

* lib/autoconf/c.m4 (_AC_LANG_OPENMP(C)): Change ‘choke me’ to
  ‘#error "OpenMP not supported"’.
  (AC_OPENMP): AC_REQUIRE _AC_OPENMP_SAFE_WD.  For each option, do
  both a compile test and a link test; if the compile test succeeds
  but the link fails, don’t go on to other candidate options.
  Delete files named ‘mp’ and ‘penmp’ after the loop.
  (_AC_OPENMP_SAFE_WD): New macro, subroutine of AC_OPENMP.  If files
  named ‘mp’ or ‘penmp’ exist, error out both at autoconf time and at
  configure time.

* tests/torture.at (Files clobbered by AC_OPENMP): New test.
* doc/autoconf.texi: Document requirement not to have files
  named ‘mp’ or ‘penmp’ next to a configure.ac that uses AC_OPENMP.
2020-11-02 13:15:00 -05:00
Zack Weinberg
33c3a47c04
Don’t search for X11 when cross compiling (#110345)
This is undesirable because X11 development headers and libraries
found by searching /usr are much more likely to belong to the build
operating system than the host operating system (being cross-compiled
for).  A particularly problematic case, from the original bug report,
is “using a sysroot where the target is binary compatible with the
host.  In this case AC_PATH_X will happily look at /usr and say that
yes, X is available, even if the sysroot doesn't have X.”

To cross-compile X client applications, the recommended procedure is
to put X11 headers and libraries for the host system in the cross
compiler’s default search path; alternatively, --x-includes and
--x-libraries can be used.

Fixes bug #110345.  Problem reported by Ross Burton.

 * lib/autoconf/libs.m4 (_AC_PATH_X): Before doing anything else,
   see whether a test compilation with no special options (just -lX11)
   will work.  If it doesn’t, only invoke _AC_PATH_X_XMKMF and
   _AC_PATH_X_DIRECT when not cross compiling.
2020-11-01 19:51:47 -05:00
Zack Weinberg
35a1c64600
Improve handling of missing aux scripts (autoreconf)
Make ‘autoreconf --install’ add config.sub, config.guess, and
install-sh to the source tree when necessary.  This is only relevant
for packages that don’t use Automake, because ‘automake --add-missing’
already adds these scripts to the source tree, but apparently there
are plenty of packages out there that don’t use Automake, didn’t need
config.{sub,guess} with autoconf 2.69, and do need them with 2.70.
Such packages will need to have their equivalent of ‘make dist’
manually updated to ship the new files, of course.

This patch also has ‘autoreconf’ issue an error if aux files are
missing and ‘--install’ *wasn’t* used, or if --install *was* used but
could not install all the missing files.  This error is more likely to
be caught by maintainers than the configure-time error added in the
previous patch.  It is not currently practical to make autoconf itself
issue this error message, because of how the autoconf wrapper script
is different from all the other wrapper scripts.  Also, autoreconf
runs automake *after* autoconf, so we’d get spurious errors from
packages that do use automake.

* bin/autoreconf.in ($buildauxdir): New package global, initialized
  to $pkgdatadir/build-aux, or to $ENV{autom4te_buildauxdir} if that’s set.
  (find_missing_aux_files, can_install_aux_files, try_install_aux_files)
  (install_aux_file, make_executable): New subs.
  (autoreconf_current_directory): Trace AC_REQUIRE_AUX_FILE.
  After running all tools that might install aux files, try to
  install aux files ourself if --install was given.
  After that, report on any that are still missing.
* lib/autom4te.in (Autoreconf-preselections): Add AC_REQUIRE_AUX_FILE.
  Make list order consistent with list order in autoreconf.in.
* tests/wrapper.as: Set autom4te_buildauxdir to point to location of
  config.guess, config.sub, and install-sh within the source tree.

* lib/local.mk: Install config.guess, config.sub, and install-sh
  into $(pkgdatadir)/build-aux.

* doc/autoconf.texi: Document that autoreconf can now install
  config.guess, config.sub, and install-sh itself without help from
  automake, but packages not using automake will need to arrange for
  tarball distribution of these files by hand.

* tests/torture.at (Missing auxiliary files): Test autoreconf as well.
2020-10-20 16:57:01 -04:00
Zack Weinberg
4c59bf27d7
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.
2020-10-20 13:59:26 -04:00
Paul Eggert
3cdc910d22 doc: improve AS_CASE, AS_IF doc
See the thread containing:
https://lists.gnu.org/r/bug-gnulib/2020-10/msg00033.html
* doc/autoconf.texi: Distinguish between Solaris 10 and later.
(Balancing Parentheses): Mention the Posix syntax for ‘case’,
typically a better solution nowadays.
(AS_CASE, AS_IF): Mention AC_REQUIRE, portability, parens.
(Prerequisite Macros): Tighten up example and make it less dated.
Say that AS_CASE and AS_IF are not needed outside macros.
* NEWS: Don’t mention AS_FOR.  It’s not documented, and for
good reason since it is so ... quirky.
2020-10-11 23:56:26 -07:00
Zack Weinberg
326c9a5474
Fix regressions when using the C++ compiler to perform tests.
The Debian project has done an archive rebuild using autoconf 2.69c,
which found several serious regressions from 2.69 where test programs
used to be accepted by a C++ compiler, but are now rejected.  Part of
the problem is that newer C++ compilers are more likely to reject
“traditional” sloppy C, but part of it is that bug fixes since 2.69
did not consider the possibility of test macros being used with
AC_LANG([C++]) in effect.

I’m still working on test suite improvements that will catch these
regressions in the future, but I don’t see any reason to delay the
actual bugfixes.  (I’ve gotten far enough on the test suite changes
that I know they _will_ catch the bugs.)

* NEWS: Document that AC_FUNC_STRERROR_R no longer tries to detect a
  strerror_r that exists in the C library but isn’t declared by string.h.

* lib/autoconf/c.m4
  (AC_LANG_CALL(C++)): New macro.  Use a more robust technique for
  avoiding a type conflict with any intrinsic prototype.
  (AC_LANG_CALL(C)): Remove #ifdef __cplusplus, this macro is no longer
  used to generate C++ code.

* lib/autoconf/functions.m4
  (AC_FUNC_CLOSEDIR_VOID): Rely on <dirent.h> to declare closedir.
  Simplify test program.  Use AC_COMPILE_IFELSE, not AC_RUN_IFELSE.
  (_AC_FUNC_MALLOC_IF, _AC_FUNC_REALLOC_IF): Use void *, not char *,
  for variable holding a value returned by malloc/realloc respectively.
  (AC_FUNC_STRERROR_R): Don’t AC_CHECK_FUNCS_ONCE strerror_r.
  AC_DEFINE HAVE_STRERROR_R if and only if we are also going to define
  HAVE_DECL_STRERROR_R.  Remove AC_RUN_IFELSE fallback when strerror_r
  is not declared.

* lib/autoconf/headers.m4 (AC_USG): Use "", not 0, for the first
  argument to rindex.
2020-10-10 11:23:09 -04:00
Zack Weinberg
1b52a8609b
NEWS: Mention more bug fixes. 2020-10-05 16:22:25 -04:00
Zack Weinberg
04d14ad18a
Reorganize 2.70 NEWS
The changes are now classified into “backward incompatibilities”,
“new features”, “obsolete features and new warnings”,
“notable bug fixes”, and “autotest enhancements”.

Also make the warning about argument-quotation bugs more prominent
and explicit.  (See for instance Savannah bug 110319.)
2020-09-26 13:40:23 -04:00
Zack Weinberg
119beb0325
Autoupdate AC_{DIAGNOSE,FATAL,OBSOLETE,WARNING} and _AC_COMPUTE_INT.
While working on the previous patches I noticed that all of these
macros are officially obsolete, but autoupdate doesn’t replace them.

_AC_COMPUTE_INT is easy to autoupdate.  AC_{DIAGNOSE,FATAL,WARNING}
require a little special handling because their replacements are
m4sugar macros, and autoupdate normally expands m4sugar macros as it
goes.  Fortunately, the same workaround as is used for AC_FOREACH can
be applied.  AC_OBSOLETE also needs that workaround, and cannot be
fully replaced automatically.

The bulk of the patch is removing internal uses of AC_DIAGNOSE.

* lib/autoconf/autoupdate.m4
* lib/autoconf/c.m4
* lib/autoconf/functions.m4
* lib/autoconf/general.m4
* lib/autoconf/headers.m4
* lib/autoconf/lang.m4
* lib/autoconf/status.m4
* lib/autoconf/types.m4
* tests/local.at
* tests/tools.at:
  Use, and/or refer to, m4_warn instead of AC_DIAGNOSE.

* lib/autoconf/general.m4 (_AC_COMPUTE_INT): Define using AU_DEFUN.
  (AC_DIAGNOSE, AC_FATAL, AC_WARNING): Autoupdate to m4_warn,
  m4_fatal, and m4_warn([syntax], [$1]) respectively, using the same
  paired AU_DEFUN/AC_DEFUN trick that is used for AC_FOREACH.
  (AC_OBSOLETE): Autoupdate to m4_warn([obsolete], [$1]) and advise
  hand-conversion to AU_DEFUN.

* lib/autoconf/autoupdate.m4 (AU_DEFUN): Tweak quoting so m4_warn([$3])
  is emitted into the edited configure.ac instead of being expanded at
  autoupdate time.

* tests/tools.at (autoupdating AC_FOREACH): Adjust grep expressions.
  (autoupdating AC_DIAGNOSE and AC_WARNING): New test.
  (autoupdating AC_FATAL): New test.
  (autoupdating AC_OBSOLETE): New test.
* tests/mktests.sh (ac_exclude_list, au_exclude_list):
  Exclude AC_DIAGNOSE, AC_FATAL, AC_FOREACH, AC_OBSOLETE, and AC_WARNING
  if not already excluded.
2020-09-22 15:46:44 -04:00
Zack Weinberg
1d4b7c049e
Manually sync ChannelDefs.pm from automake.
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.
2020-09-22 15:46:42 -04:00
Eli Schwartz
b3b3af821a
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.
2020-08-18 08:49:18 -04:00
Eli Schwartz
dd880a0a6d
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.
2020-08-18 08:44:13 -04:00
Zack Weinberg
aba75f6d4a
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.
2020-08-18 08:24:05 -04:00
Zack Weinberg
6a0c023944
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.
2020-08-18 08:24:00 -04:00
Paul Eggert
0c39ab024f 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.
2020-07-17 15:07:31 -07:00
Zack Weinberg
f7693b83f2
Revise documentation for AC_PROG_LEX.
- Better explanation of the additional tests performed by this macro,
   once the tool has been located.

 - Update advice re using Flex to generate a bundled lex.yy.c.

 - Remove text describing a bug in Automake that has long since been
   corrected.
2020-07-16 14:48:09 -04:00
Paul Eggert
29ede6b96f AC_PROG_LEX no longer sets LEXLIB for yywrap
Suggested by Zack Weinberg in:
https://lists.gnu.org/r/autoconf-patches/2020-07/msg00016.html
* lib/autoconf/programs.m4 (_AC_PROG_LEX_YYTEXT_DECL):
Define yywrap too.
2020-07-16 10:48:09 -07:00
Paul Eggert
d45c2e2f5b 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.
2020-07-15 13:30:56 -07:00
Nick Alcock
60e1c17ee0
NEWS: don’t describe Automake 1.13 as “upcoming.”
Automake 1.13 was released eight years ago.  The current version is
1.16.2.
2020-07-14 13:23:00 -04:00
Zack Weinberg
a1acd8e66b
Formally obsolete AC_CONFIG_HEADER (#105403)
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.
2020-07-12 11:59:14 -04:00
Zack Weinberg
d5cb54d02d
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.
2020-07-12 11:26:47 -04:00
Zack Weinberg
83798d2971
NEWS: add notes about known breakage due to pickier macros.
These are all cases where the offending configure script or
third-party macro was always incorrect, but autoconf 2.69 let you get
away with it.
2020-07-10 14:16:18 -04:00
Zack Weinberg
5016cdc03a
NEWS: mention that AS_INIT no longer embeds full paths to source files.
(Change made in c6daae41276a49b52a9d5e2f70c95651364ed619.)

Also reorder some of the NEWS entries more logically.
2020-07-09 13:59:05 -04:00
Zack Weinberg
0a0a337886 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.
2020-06-29 23:17:15 -07:00
Zack Weinberg
8a09003664
Define $as_echo and $as_echo_n for backward compatibility.
Commit 2b59b6f8a7 removed the internal
shell variables $as_echo and $as_echo_n.  It turns out that these are
used by several widely-used third-party m4 files (notably both
gnulib-common.m4 from gnulib, and ax_pthread.m4 from the Autoconf
macro archive) as well as any number of existing configure.ac’s.

Restore these shell variables, unconditionally defining them to use
printf.  Issue -Wobsolete warnings if they are used, recommending the
use of AS_ECHO and AS_ECHO_N respectively.  Add a test which checks
both that they do work and that they trigger warnings.
2020-03-13 14:50:50 -04:00
Jim Meyering
d78a7dd95f maint: make update-copyright 2020-01-01 11:45:50 -08:00
Daniel Colascione
f0aa3cc07a fix quoting 2018-03-19 20:19:46 -07:00
Paul Eggert
d3dcd5895d Prefer HTTPS to FTP and HTTP 2017-09-16 17:48:51 -07:00
Jim Meyering
60460b91d0 maint: update copyright dates for 2017
* all files: Run "make update-copyright".
* doc/autoconf.texi: Update manually.
2017-01-01 05:18:32 -08:00
Daniel Elstner
78ad1b0b2c autoheader: check templates of all config headers
* bin/autoheader.in: When checking for missing templates, take
all config headers into account, not just the one generated by
autoheader.  This makes it possible to use AC_DEFINE() for
secondary headers without duplicating the template into the
first header.
* tests/tools.at: Add a check for autoheader with multiple
config headers.
* NEWS: Document the new behavior.
Message-Id: <1482336946.31331.2.camel@gmail.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2016-12-21 10:31:54 -06:00
Eric Blake
501ccbbfdb AC_CHECK_HEADERS_ONCE: honor current AC_LANG
Previously, AC_CHECK_HEADERS_ONCE collected a list of header names
to check, but ran the checks using the AC_LANG that was active
during the first encounter of the macro.  In practice, this is
usually the C language, and we haven't had actual reports of projects
attempting to use AC_CHECK_HEADERS_ONCE across multiple languages,
rather this was discovered by code inspection.

With this patch, the code now tracks a separate per-language list of
names to check.  Note, however, that it is only possible to check for
a given header name in one language; attempting to add a name again
under AC_CHECK_HEADERS_ONCE while a different language is active is a
no-op (this still makes sense because the side-effect of defining
the CPP macro HAVE_HEADER does not include a language prefix).

* lib/autoconf/headers.m4 (_AC_CHECK_HEADER_ONCE)
(_AC_HEADERS_EXPANSION):
* NEWS: Mention it.

Signed-off-by: Eric Blake <eblake@redhat.com>
2016-12-21 08:32:29 -06:00
Eric Blake
4523f7c32b AC_CHECK_FUNCS_ONCE: honor current AC_LANG
Previously, AC_CHECK_FUNCS_ONCE collected a list of function names
to check, but ran the checks using the AC_LANG that was active
during the first encounter of the macro.  In practice, this is
usually the C language, and we haven't had actual reports of projects
attempting to use AC_CHECK_FUNCS_ONCE across multiple languages,
rather this was discovered by code inspection.

With this patch, the code now tracks a separate per-language list of
names to check.  Note, however, that it is only possible to check for
a given function name in one language; attempting to add a name again
under AC_CHECK_FUNCS_ONCE while a different language is active is a
no-op (this still makes sense because the side-effect of defining
the CPP macro HAVE_FUNC does not include a language prefix).

* lib/autoconf/functions.m4 (_AC_CHECK_FUNC_ONCE)
(_AC_FUNCS_EXPANSION):
* NEWS: Mention it.

Signed-off-by: Eric Blake <eblake@redhat.com>
2016-12-20 13:34:20 -06:00
Paul Eggert
9021c82280 AC_USE_SYSTEM_EXTENSIONS: port to more ISO C TSes
* doc/autoconf.texi (C and Posix Variants): Rename from "Posix
Variants", and document updated behavior.
* lib/autoconf/specific.m4 (AC_USE_SYSTEM_EXTENSIONS): Also define
__STDC_WANT_IEC_60559_ATTRIBS_EXT__,
__STDC_WANT_IEC_60559_DFP_EXT__,
__STDC_WANT_IEC_60559_TYPES_EXT__, and
__STDC_WANT_MATH_SPEC_FUNCS__.  From a suggestion by Joseph Myers in:
http://lists.gnu.org/archive/html/autoconf-patches/2016-09/msg00011.html
2016-09-15 10:10:14 -07:00
Paul Eggert
4f08ddfe35 AC_USE_SYSTEM_EXTENSIONS: port to recent ISO C
* lib/autoconf/specific.m4 (AC_USE_SYSTEM_EXTENSIONS):
Also define __STDC_WANT_IEC_60559_BFP_EXT__,
__STDC_WANT_IEC_60559_FUNCS_EXT__, and __STDC_WANT_LIB_EXT2__.
* NEWS, doc/autoconf.texi (Posix Variants):
Document this.  Also, document other changes in this area
that were not properly documented before.
2016-09-13 18:28:47 -07:00