autoconf/bin/autoconf.as
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

209 lines
6.9 KiB
Bash

AS_INIT[]dnl -*- shell-script -*-
m4_divert_push([HEADER-COPYRIGHT])dnl
# @configure_input@
# autoconf -- create 'configure' using m4 macros.
# Copyright (C) 1992-1994, 1996, 1999-2017, 2020 Free Software
# Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
m4_divert_pop([HEADER-COPYRIGHT])dnl back to BODY
AS_ME_PREPARE[]dnl
help=["\
Usage: $0 [OPTION]... [TEMPLATE-FILE]
Generate a configuration script from a TEMPLATE-FILE if given, or
'configure.ac' if present, or else 'configure.in'. Output is sent
to the standard output if TEMPLATE-FILE is given, else into
'configure'.
Operation modes:
-h, --help print this help, then exit
-V, --version print version number, then exit
-v, --verbose verbosely report processing
-d, --debug don't remove temporary files
-f, --force consider all files obsolete
-o, --output=FILE save output in FILE (stdout is the default)
-W, --warnings=CATEGORY report the warnings falling in CATEGORY
Warning categories include:
cross cross compilation issues
gnu GNU coding standards (default in gnu and gnits modes)
obsolete obsolete features or constructions (default)
override user redefinitions of Automake rules or variables
portability portability issues (default in gnu and gnits modes)
portability-recursive nested Make variables (default with -Wportability)
extra-portability extra portability issues related to obscure tools
syntax dubious syntactic constructs (default)
unsupported unsupported or incomplete features (default)
all all the warnings
no-CATEGORY turn off warnings in CATEGORY
none turn off all the warnings
The environment variables 'M4' and 'WARNINGS' are honored.
Library directories:
-B, --prepend-include=DIR prepend directory DIR to search path
-I, --include=DIR append directory DIR to search path
Tracing:
-t, --trace=MACRO[:FORMAT] report the list of calls to MACRO
-i, --initialization also trace Autoconf's initialization process
In tracing mode, no configuration script is created. FORMAT defaults
to '\$f:\$l:\$n:\$%'; see 'autom4te --help' for information about FORMAT.
Report bugs to <bug-autoconf@gnu.org>.
GNU Autoconf home page: <https://www.gnu.org/software/autoconf/>.
General help using GNU software: <https://www.gnu.org/gethelp/>."]
version=["\
autoconf (@PACKAGE_NAME@) @VERSION@
Copyright (C) @RELEASE_YEAR@ Free Software Foundation, Inc.
License GPLv3+/Autoconf: GNU GPL version 3 or later
<https://gnu.org/licenses/gpl.html>, <https://gnu.org/licenses/exceptions.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by David J. MacKenzie and Akim Demaille."]
usage_err="\
Try '$as_me --help' for more information."
exit_missing_arg='
m4_bpatsubst([AS_ERROR([option '$[1]' requires an argument$as_nl$usage_err])],
['], ['\\''])'
# restore font-lock: '
# Variables.
: ${AUTOM4TE='@bindir@/@autom4te-name@'}
: ${trailer_m4='@pkgdatadir@/autoconf/trailer.m4'}
autom4te_options=
outfile=
verbose=false
# Parse command line.
while test $# -gt 0 ; do
option=[`expr "x$1" : 'x\(--[^=]*\)' \| \
"x$1" : 'x\(-.\)'`]
optarg=[`expr "x$1" : 'x--[^=]*=\(.*\)' \| \
"x$1" : 'x-.\(.*\)'`]
case $1 in
--version | -V )
AS_ECHO(["$version"]); exit ;;
--help | -h )
AS_ECHO(["$help"]); exit ;;
--verbose | -v )
verbose=:
autom4te_options="$autom4te_options $1"; shift ;;
# Arguments passed as is to autom4te.
--debug | -d | \
--force | -f | \
--include=* | -I?* | \
--prepend-include=* | -B?* | \
--warnings=* | -W?* )
case $1 in
*\'*) arg=`AS_ECHO(["$1"]) | sed "s/'/'\\\\\\\\''/g"` ;; #'
*) arg=$1 ;;
esac
autom4te_options="$autom4te_options '$arg'"; shift ;;
# Options with separated arg passed as is to autom4te.
--include | -I | \
--prepend-include | -B | \
--warnings | -W )
test $# = 1 && eval "$exit_missing_arg"
case $2 in
*\'*) arg=`AS_ECHO(["$2"]) | sed "s/'/'\\\\\\\\''/g"` ;; #'
*) arg=$2 ;;
esac
autom4te_options="$autom4te_options $option '$arg'"
shift; shift ;;
--trace=* | -t?* )
traces="$traces --trace='"`AS_ECHO(["$optarg"]) | sed "s/'/'\\\\\\\\''/g"`"'"
shift ;;
--trace | -t )
test $# = 1 && eval "$exit_missing_arg"
traces="$traces --trace='"`AS_ECHO(["$[2]"]) | sed "s/'/'\\\\\\\\''/g"`"'"
shift; shift ;;
--initialization | -i )
autom4te_options="$autom4te_options --melt"
shift;;
--output=* | -o?* )
outfile=$optarg
shift ;;
--output | -o )
test $# = 1 && eval "$exit_missing_arg"
outfile=$2
shift; shift ;;
-- ) # Stop option processing
shift; break ;;
- ) # Use stdin as input.
break ;;
-* )
exec >&2
AS_ERROR([invalid option '$[1]'$as_nl$usage_err]) ;;
* )
break ;;
esac
done
# Find the input file.
case $# in
0)
if test -f configure.ac; then
if test -f configure.in; then
AS_ECHO(["$as_me: warning: both 'configure.ac' and 'configure.in' are present."]) >&2
AS_ECHO(["$as_me: warning: proceeding with 'configure.ac'."]) >&2
fi
infile=configure.ac
elif test -f configure.in; then
infile=configure.in
else
AS_ERROR([no input file])
fi
test -z "$traces" && test -z "$outfile" && outfile=configure;;
1)
infile=$1 ;;
*) exec >&2
AS_ERROR([invalid number of arguments$as_nl$usage_err]) ;;
esac
# Unless specified, the output is stdout.
test -z "$outfile" && outfile=-
# Don't read trailer.m4 if we are tracing.
if test -n "$traces"; then
trailer_m4=""
else
# The extra quotes will be stripped by eval.
trailer_m4=\""$trailer_m4"\"
fi
# Run autom4te with expansion.
# trailer.m4 is read _before_ $infile, despite the name,
# because putting it afterward screws up autom4te's location tracing.
eval set x "$autom4te_options" \
--language=autoconf --output=\"\$outfile\" "$traces" \
$trailer_m4 \"\$infile\"
shift
$verbose && AS_ECHO(["$as_me: running $AUTOM4TE $*"]) >&2
exec "$AUTOM4TE" "$@"