autoconf/tests
Zack Weinberg 96a8e5f1c9
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-14 14:04:46 -04:00
..
atlocal.in Look harder for a shell whose -n is known to work. 2020-06-29 23:17:15 -07:00
autoscan.at maint: make update-copyright 2020-01-01 11:45:50 -08:00
autotest.at Simplify Makefiles embedded in autotest.at 2020-07-27 13:27:47 -04:00
base.at Warn if AC_INIT or AC_OUTPUT are missing from configure.ac (#107986) 2020-08-14 14:04:46 -04:00
c.at Warn if AC_INIT or AC_OUTPUT are missing from configure.ac (#107986) 2020-08-14 14:04:46 -04:00
compile.at Warn if AC_INIT or AC_OUTPUT are missing from configure.ac (#107986) 2020-08-14 14:04:46 -04:00
erlang.at maint: make update-copyright 2020-01-01 11:45:50 -08:00
foreign.at maint: make update-copyright 2020-01-01 11:45:50 -08:00
fortran.at Test AC_FC_LINE_LENGTH only to 250 columns 2020-07-17 15:07:31 -07:00
go.at maint: make update-copyright 2020-01-01 11:45:50 -08:00
local.at AT_CHECK_MACRO: Preserve config.log and config.status from run 1. 2020-08-05 10:45:22 -04:00
local.mk maint: make update-copyright 2020-01-01 11:45:50 -08:00
m4sh.at Warn if AC_INIT or AC_OUTPUT are missing from configure.ac (#107986) 2020-08-14 14:04:46 -04:00
m4sugar.at maint: make update-copyright 2020-01-01 11:45:50 -08:00
mktests.sh maint: make update-copyright 2020-01-01 11:45:50 -08:00
semantics.at Warn if AC_INIT or AC_OUTPUT are missing from configure.ac (#107986) 2020-08-14 14:04:46 -04:00
statesave.m4 maint: make update-copyright 2020-01-01 11:45:50 -08:00
suite.at maint: make update-copyright 2020-01-01 11:45:50 -08:00
tools.at Warn if AC_INIT or AC_OUTPUT are missing from configure.ac (#107986) 2020-08-14 14:04:46 -04:00
torture.at Warn if AC_INIT or AC_OUTPUT are missing from configure.ac (#107986) 2020-08-14 14:04:46 -04:00
wrapper.as Warn if AC_INIT or AC_OUTPUT are missing from configure.ac (#107986) 2020-08-14 14:04:46 -04:00