summaryrefslogtreecommitdiff
path: root/lib/Autom4te
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2020-09-12 14:59:56 -0400
committerZack Weinberg <zackw@panix.com>2020-09-22 15:46:42 -0400
commit1d4b7c049e6a8e918a0ca3361418cf7776f2e6fa (patch)
treed04d571ee5faea6804c47fd1e2599fd543bb2c3e /lib/Autom4te
parent8285f302a95021670d733a59ee690a56edb8a5b0 (diff)
downloadautoconf-1d4b7c049e6a8e918a0ca3361418cf7776f2e6fa.tar.gz
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.
Diffstat (limited to 'lib/Autom4te')
-rw-r--r--lib/Autom4te/ChannelDefs.pm172
-rw-r--r--lib/Autom4te/Config.pm43
2 files changed, 176 insertions, 39 deletions
diff --git a/lib/Autom4te/ChannelDefs.pm b/lib/Autom4te/ChannelDefs.pm
index 84e634e8..21f444b9 100644
--- a/lib/Autom4te/ChannelDefs.pm
+++ b/lib/Autom4te/ChannelDefs.pm
@@ -1,10 +1,9 @@
-# Copyright (C) 2002-2003, 2006, 2008-2017, 2020 Free Software
-# Foundation, Inc.
+# Copyright (C) 2002-2020 Free Software Foundation, Inc.
-# This program is free software: you can redistribute it and/or modify
+# 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.
+# the Free Software Foundation; either version 2, 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
@@ -16,8 +15,6 @@
package Autom4te::ChannelDefs;
-use Autom4te::Channels;
-
=head1 NAME
Autom4te::ChannelDefs - channel definitions for Automake and helper functions
@@ -53,6 +50,17 @@ use warnings FATAL => 'all';
use Exporter;
+use Autom4te::Channels;
+use Autom4te::Config;
+BEGIN
+{
+ if ($perl_threads)
+ {
+ require threads;
+ import threads;
+ }
+}
+
our @ISA = qw (Exporter);
our @EXPORT = qw (&prog_error &error &fatal &verb
&switch_warning &parse_WARNINGS &parse_warnings);
@@ -79,7 +87,7 @@ Errors related to GNU Standards.
=item C<error-gnu/warn>
-Errors related to GNU Standards that should be warnings in "foreign" mode.
+Errors related to GNU Standards that should be warnings in 'foreign' mode.
=item C<error-gnits>
@@ -99,7 +107,7 @@ Warnings related to GNU Coding Standards.
=item C<obsolete>
-Warnings about obsolete features (silent by default).
+Warnings about obsolete features.
=item C<override>
@@ -110,9 +118,21 @@ variables (silent by default).
Warnings about non-portable constructs.
+=item C<portability-recursive>
+
+Warnings about recursive variable expansions (C<$(foo$(x))>).
+These are not universally supported, but are more portable than
+the other non-portable constructs diagnosed by C<-Wportability>.
+These warnings are turned on by C<-Wportability> but can then be
+turned off separately by C<-Wno-portability-recursive>.
+
+=item C<extra-portability>
+
+Extra warnings about non-portable constructs covering obscure tools.
+
=item C<syntax>
-Warnings about weird syntax, unused variables, typos ...
+Warnings about weird syntax, unused variables, typos...
=item C<unsupported>
@@ -134,7 +154,7 @@ Informative messages.
# Do not forget to update &usage and the manual
# if you add or change a warning channel.
-register_channel 'fatal', type => 'fatal', ordered => 0;
+register_channel 'fatal', type => 'fatal', uniq_part => UP_NONE, ordered => 0;
register_channel 'error', type => 'error';
register_channel 'error-gnu', type => 'error';
register_channel 'error-gnu/warn', type => 'error';
@@ -143,20 +163,27 @@ register_channel 'automake', type => 'fatal', backtrace => 1,
header => ("####################\n" .
"## Internal Error ##\n" .
"####################\n"),
- footer => "\nPlease contact <bug-automake\@gnu.org>.",
- ordered => 0;
+ footer => "\nPlease contact <$PACKAGE_BUGREPORT>.",
+ uniq_part => UP_NONE, ordered => 0;
register_channel 'cross', type => 'warning', silent => 1;
register_channel 'gnu', type => 'warning';
-register_channel 'obsolete', type => 'warning', silent => 1;
+register_channel 'obsolete', type => 'warning';
register_channel 'override', type => 'warning', silent => 1;
register_channel 'portability', type => 'warning', silent => 1;
+register_channel 'extra-portability', type => 'warning', silent => 1;
+register_channel 'portability-recursive', type => 'warning', silent => 1;
register_channel 'syntax', type => 'warning';
register_channel 'unsupported', type => 'warning';
-register_channel 'verb', type => 'debug', silent => 1, ordered => 0;
+register_channel 'verb', type => 'debug', silent => 1, uniq_part => UP_NONE,
+ ordered => 0;
register_channel 'note', type => 'debug', silent => 0;
+setup_channel_type 'warning', header => 'warning: ';
+setup_channel_type 'error', header => 'error: ';
+setup_channel_type 'fatal', header => 'error: ';
+
=head2 FUNCTIONS
=over 4
@@ -170,17 +197,19 @@ Return the warning category descriptions.
sub usage ()
{
return "Warning categories include:
- `cross' cross compilation issues
- `gnu' GNU coding standards (default in gnu and gnits modes)
- `obsolete' obsolete features or constructions
- `override' user redefinitions of Automake rules or variables
- `portability' portability issues (default in gnu and gnits modes)
- `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
- `error' treat warnings as errors";
+ 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
+ error treat warnings as errors";
}
=item C<prog_error ($MESSAGE, [%OPTIONS])>
@@ -233,6 +262,8 @@ C<--verbose> messages.
sub verb ($;%)
{
my ($msg, %opts) = @_;
+ $msg = "thread " . threads->tid . ": " . $msg
+ if $perl_threads;
msg 'verb', '', $msg, %opts;
}
@@ -274,6 +305,38 @@ sub switch_warning ($)
elsif (channel_type ($cat) eq 'warning')
{
setup_channel $cat, silent => $has_no;
+ #
+ # Handling of portability warnings is trickier. For relevant tests,
+ # see 'dollarvar2', 'extra-portability' and 'extra-portability3'.
+ #
+ # -Wportability-recursive and -Wno-portability-recursive should not
+ # have any effect on other 'portability' or 'extra-portability'
+ # warnings, so there's no need to handle them separately or ad-hoc.
+ #
+ if ($cat eq 'extra-portability' && ! $has_no) # -Wextra-portability
+ {
+ # -Wextra-portability must enable 'portability' and
+ # 'portability-recursive' warnings.
+ setup_channel 'portability', silent => 0;
+ setup_channel 'portability-recursive', silent => 0;
+ }
+ if ($cat eq 'portability') # -Wportability or -Wno-portability
+ {
+ if ($has_no) # -Wno-portability
+ {
+ # -Wno-portability must disable 'extra-portability' and
+ # 'portability-recursive' warnings.
+ setup_channel 'portability-recursive', silent => 1;
+ setup_channel 'extra-portability', silent => 1;
+ }
+ else # -Wportability
+ {
+ # -Wportability must enable 'portability-recursive'
+ # warnings. But it should have no influence over the
+ # 'extra-portability' warnings.
+ setup_channel 'portability-recursive', silent => 0;
+ }
+ }
}
else
{
@@ -288,36 +351,62 @@ Parse the WARNINGS environment variable.
=cut
+# Used to communicate from parse_WARNINGS to parse_warnings.
+our $_werror = 0;
+
sub parse_WARNINGS ()
{
if (exists $ENV{'WARNINGS'})
{
# Ignore unknown categories. This is required because WARNINGS
# should be honored by many tools.
- switch_warning $_ foreach (split (',', $ENV{'WARNINGS'}));
+ # For the same reason, do not turn on -Werror at this point, just
+ # record that we saw it; parse_warnings will turn on -Werror after
+ # the command line has been processed.
+ foreach (split (',', $ENV{'WARNINGS'}))
+ {
+ if (/^(no-)?error$/)
+ {
+ $_werror = !defined $1;
+ }
+ else
+ {
+ switch_warning $_;
+ }
+ }
}
}
-=item C<parse_warnings ($OPTION, @ARGUMENT)>
+=item C<parse_warnings (@CATEGORIES)>
Parse the argument of C<--warning=CATEGORY> or C<-WCATEGORY>.
+C<@CATEGORIES> is the accumulated set of warnings categories.
+Use like this:
-C<$OPTIONS> is C<"--warning"> or C<"-W">, C<@ARGUMENT> is a list of
-C<CATEGORY>.
-
-This can be used as an argument to C<Getopt>.
+ Autom4te::GetOpt::parse_options (
+ # ...
+ 'W|warnings=s' => \@warnings,
+ )
+ # possibly call set_strictness here
+ parse_warnings @warnings;
=cut
-sub parse_warnings ($@)
+sub parse_warnings (@)
{
- my ($opt, @categories) = @_;
-
- foreach my $cat (map { split ',' } @categories)
+ foreach my $cat (map { split ',' } @_)
{
- msg 'unsupported', "unknown warning category `$cat'"
- if switch_warning $cat;
+ if ($cat =~ /^(no-)?error$/)
+ {
+ $_werror = !defined $1;
+ }
+ elsif (switch_warning $cat)
+ {
+ msg 'unsupported', "unknown warning category '$cat'";
+ }
}
+
+ switch_warning ($_werror ? 'error' : 'no-error');
}
=item C<set_strictness ($STRICTNESS_NAME)>
@@ -336,6 +425,7 @@ sub set_strictness ($)
setup_channel 'error-gnu/warn', silent => 0, type => 'error';
setup_channel 'error-gnits', silent => 1;
setup_channel 'portability', silent => 0;
+ setup_channel 'extra-portability', silent => 1;
setup_channel 'gnu', silent => 0;
}
elsif ($name eq 'gnits')
@@ -344,6 +434,7 @@ sub set_strictness ($)
setup_channel 'error-gnu/warn', silent => 0, type => 'error';
setup_channel 'error-gnits', silent => 0;
setup_channel 'portability', silent => 0;
+ setup_channel 'extra-portability', silent => 1;
setup_channel 'gnu', silent => 0;
}
elsif ($name eq 'foreign')
@@ -352,11 +443,12 @@ sub set_strictness ($)
setup_channel 'error-gnu/warn', silent => 0, type => 'warning';
setup_channel 'error-gnits', silent => 1;
setup_channel 'portability', silent => 1;
+ setup_channel 'extra-portability', silent => 1;
setup_channel 'gnu', silent => 1;
}
else
{
- prog_error "level `$name' not recognized\n";
+ prog_error "level '$name' not recognized";
}
}
@@ -372,6 +464,8 @@ Written by Alexandre Duret-Lutz E<lt>F<adl@gnu.org>E<gt>.
=cut
+1;
+
### Setup "GNU" style for perl-mode and cperl-mode.
## Local Variables:
## perl-indent-level: 2
diff --git a/lib/Autom4te/Config.pm b/lib/Autom4te/Config.pm
new file mode 100644
index 00000000..23c5ac14
--- /dev/null
+++ b/lib/Autom4te/Config.pm
@@ -0,0 +1,43 @@
+# -*- Perl -*-
+# Copyright (C) 2003-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 2, 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/>.
+
+package Autom4te::Config;
+
+# This is a stub version of Automake/Config.pm.
+# It defines only the variables that are necessary in order to fetch
+# Autom4te/ChannelDefs.pm from Automake/ChannelDefs.pm
+# (see build-aux/fetch.pl).
+# We would like to fetch Automake/Config.pm as well,
+# but that file is generated when automake is built,
+# and autoconf's build machinery is not prepared to do that.
+# Revisit after 2.70.
+
+use 5.006;
+use strict;
+use warnings FATAL => 'all';
+
+use Exporter;
+
+our @ISA = qw (Exporter);
+our @EXPORT = qw ($PACKAGE_BUGREPORT $perl_threads);
+
+# this must be kept in sync with configure.ac
+our $PACKAGE_BUGREPORT = 'bug-autoconf@gnu.org';
+
+# autom4te currently has no use for threads
+our $perl_threads = 0;
+
+1;