From: Alexandre Duret-Lutz Date: Tue, 16 Jul 2002 21:46:59 +0000 (+0000) Subject: * lib/Automake/Channels.pm (dup_channel_setup, X-Git-Tag: Release-1-6b~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=91c2a87f2419bd8604138fd8bc885f68d16ff434;p=thirdparty%2Fautomake.git * lib/Automake/Channels.pm (dup_channel_setup, drop_channel_setup): New functions. (@EXPORT): Add them. * automake.in (generate_makefile): Call dup_channel_setup and drop_channel_setup. (process_option_list): Recognize --warnings and -W options. * automake.texi (Options): Document them. * tests/pluseq5.test: Check that -Wno-obsolete will disable the warning. * tests/warnopts.test: New file. * tests/Makefile.am (TESTS): Add warnopts.test. --- diff --git a/ChangeLog b/ChangeLog index e5d304f48..440623d99 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2002-07-16 Alexandre Duret-Lutz + + * lib/Automake/Channels.pm (dup_channel_setup, + drop_channel_setup): New functions. + (@EXPORT): Add them. + * automake.in (generate_makefile): Call dup_channel_setup and + drop_channel_setup. + (process_option_list): Recognize --warnings and -W options. + * automake.texi (Options): Document them. + * tests/pluseq5.test: Check that -Wno-obsolete will disable the + warning. + * tests/warnopts.test: New file. + * tests/Makefile.am (TESTS): Add warnopts.test. + 2002-07-12 Alexandre Duret-Lutz * automake.in: Register warning channel `gnu'. diff --git a/automake.in b/automake.in index 068ed51b7..4e5869b33 100755 --- a/automake.in +++ b/automake.in @@ -1527,6 +1527,9 @@ sub generate_makefile # Reset all the Makefile.am related variables. &initialize_per_input; + # Any warning setting now local to this Makefile.am. + &dup_channel_setup; + # Name of input file ("Makefile.am") and output file # ("Makefile.in"). These have no directory components. $am_file_name = basename ($makefile) . '.am'; @@ -1689,6 +1692,9 @@ sub generate_makefile print $gm_file $output_header; print $gm_file $output_rules; print $gm_file $output_trailer; + + # Back out any warning setting. + &drop_channel_setup; } ################################################################ @@ -1836,6 +1842,14 @@ sub process_option_list return 1; } } + elsif (/^(?:--warnings=|-W)(.*)$/) + { + foreach my $cat (split (',', $1)) + { + msg 'unsupported', $where, "unknown warning category `$cat'" + if switch_warning $cat; + } + } else { err ($where, "option `$_' not recognized", diff --git a/automake.texi b/automake.texi index c97bff50a..97271ee50 100644 --- a/automake.texi +++ b/automake.texi @@ -4289,12 +4289,21 @@ the source file. For instance if the source file is A version number (e.g. @samp{0.30}) can be specified. If Automake is not newer than the version specified, creation of the @file{Makefile.in} will be suppressed. + +@item @code{-W@var{category}} or @code{--warnings=@var{category}} +@cindex Option, warnings +These options behave exactly like their command-line counterpart +(@pxref{Invoking Automake}). This allows you to enable or disable some +warning categories on a per-file basis. You can also setup some warnings +for your entire project; for instance try @code{AM_INIT_AUTOMAKE([-Wall])} +in your @file{configure.in}. + @end table Unrecognized options are diagnosed by @code{automake}. If you want an option to apply to all the files in the tree, you can use -the @code{AM_AUTOMAKE_OPTIONS} macro in @file{configure.in}. +the @code{AM_INIT_AUTOMAKE} macro in @file{configure.in}. @xref{Macros}. diff --git a/lib/Automake/Channels.pm b/lib/Automake/Channels.pm index 9019b1d1b..b543c178f 100644 --- a/lib/Automake/Channels.pm +++ b/lib/Automake/Channels.pm @@ -67,6 +67,7 @@ our @EXPORT = qw ($exit_code $warnings_are_errors &reset_local_duplicates &reset_global_duplicates ®ister_channel &msg &exists_channel &channel_type &setup_channel &setup_channel_type + &dup_channel_setup &drop_channel_setup US_GLOBAL US_LOCAL UP_NONE UP_TEXT UP_LOC_TEXT); @@ -491,6 +492,39 @@ sub setup_channel_type ($%) } } +=item C, C + +Sometimes it is necessary to make temporary modifications to channels. +For instance one may want to disable a warning while processing a +particular file, and then restore the initial setup. These two +functions make it easy: C saves a copy of the +current configuration for later restoration by +C. + +You can think of this as a stack of configurations whose first entry +is the active one. C duplicates the first +entry, while C just deletes it. + +=cut + +our @_saved_channels = (); + +sub dup_channel_setup () +{ + my %channels_copy; + foreach my $k1 (keys %channels) + { + $channels_copy{$k1} = {%{$channels{$k1}}}; + } + push @_saved_channels, \%channels_copy; +} + +sub drop_channel_setup () +{ + my $saved = pop @_saved_channels; + %channels = %$saved; +} + =back =head1 HISTORY diff --git a/stamp-vti b/stamp-vti index 92aa9a843..e5cda01db 100644 --- a/stamp-vti +++ b/stamp-vti @@ -1,4 +1,4 @@ -@set UPDATED 12 July 2002 +@set UPDATED 16 July 2002 @set UPDATED-MONTH July 2002 @set EDITION 1.6a @set VERSION 1.6a diff --git a/tests/Makefile.am b/tests/Makefile.am index 912883b9e..cea03ebd5 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -394,6 +394,7 @@ version6.test \ vpath.test \ vtexi.test \ vtexi2.test \ +warnopts.test \ werror.test \ whoami.test \ xsource.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index b686fac17..3bfe8fe4f 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -481,6 +481,7 @@ version6.test \ vpath.test \ vtexi.test \ vtexi2.test \ +warnopts.test \ werror.test \ whoami.test \ xsource.test \ diff --git a/tests/pluseq5.test b/tests/pluseq5.test index 1c444c9d7..ab73a6839 100755 --- a/tests/pluseq5.test +++ b/tests/pluseq5.test @@ -34,3 +34,12 @@ test `grep ': ' stderr | wc -l` = 1 || exit 1 # By the way, Automake should suggest using AM_CPPFLAGS, # because INCLUDES is an obsolete name. grep AM_CPPFLAGS stderr || exit 1 + +# A way to suppress the obsolete warning is to use +# -Wno-obsolete: +echo 'AUTOMAKE_OPTIONS = -Wno-obsolete' >> Makefile.am +$AUTOMAKE 2>stderr && exit 1 +cat stderr +grep AM_CPPFLAGS stderr && exit 1 +# CHECK_FALSE should still be mentioned. +grep ':.*CHECK_FALSE$' stderr || exit 1 diff --git a/tests/warnopts.test b/tests/warnopts.test new file mode 100755 index 000000000..3857f8b64 --- /dev/null +++ b/tests/warnopts.test @@ -0,0 +1,54 @@ +#! /bin/sh + +# Make sure that we can enable or disable warnings on a per-file basis. + +. $srcdir/defs || exit 1 + +set -e + + +cat >>configure.in <Makefile.am <sub/Makefile.am <stderr && exit 1 +cat stderr +# The expected diagnostic is +# Makefile.am:3: unused variable: `foo_SOURCES' +# sub/Makefile.am:2: `INCLUDES' is the old name for `AM_CPPFLAGS' +grep '^Makefile.am:.*foo_SOURCES' stderr +grep '^sub/Makefile.am:.*INCLUDES' stderr +grep '^sub/Makefile.am:.*foo_SOURCES' stderr && exit 1 +grep '^Makefile.am:.*INCLUDES' stderr && exit 1 +# Only two lines of warnings. +test `wc -l < stderr` = 2 + +# If we add a global -Wnone, all warnings should disappear. +cat >configure.in <