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-16 Alexandre Duret-Lutz <duret_g@epita.fr>
+
+ * 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 <duret_g@epita.fr>
* automake.in: Register warning channel `gnu'.
# 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';
print $gm_file $output_header;
print $gm_file $output_rules;
print $gm_file $output_trailer;
+
+ # Back out any warning setting.
+ &drop_channel_setup;
}
################################################################
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",
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}.
&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);
}
}
+=item C<dup_channel_setup ()>, C<drop_channel_setup ()>
+
+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<dup_channel_setup ()> saves a copy of the
+current configuration for later restoration by
+C<drop_channel_setup ()>.
+
+You can think of this as a stack of configurations whose first entry
+is the active one. C<dup_channel_setup ()> duplicates the first
+entry, while C<drop_channel_setup ()> 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
-@set UPDATED 12 July 2002
+@set UPDATED 16 July 2002
@set UPDATED-MONTH July 2002
@set EDITION 1.6a
@set VERSION 1.6a
vpath.test \
vtexi.test \
vtexi2.test \
+warnopts.test \
werror.test \
whoami.test \
xsource.test \
vpath.test \
vtexi.test \
vtexi2.test \
+warnopts.test \
werror.test \
whoami.test \
xsource.test \
# 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
--- /dev/null
+#! /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 <<END
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+mkdir sub
+
+# These two Makefile contain the same errors, but have different
+# warnings disabled.
+
+cat >Makefile.am <<END
+AUTOMAKE_OPTIONS = -Wno-obsolete
+INCLUDES = -Ifoo
+foo_SOURCES = unused
+SUBDIRS = sub
+END
+
+cat >sub/Makefile.am <<END
+AUTOMAKE_OPTIONS = -Wno-unused
+INCLUDES = -Ifoo
+foo_SOURCES = unused
+END
+
+$ACLOCAL
+$AUTOMAKE 2>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 <<END
+AC_INIT([warnopts], [1.0])
+AM_INIT_AUTOMAKE([-Wnone])
+AC_CONFIG_FILES([Makefile sub/Makefile])
+AC_OUTPUT
+END
+$ACLOCAL
+$AUTOMAKE
-@set UPDATED 12 July 2002
+@set UPDATED 16 July 2002
@set UPDATED-MONTH July 2002
@set EDITION 1.6a
@set VERSION 1.6a