From c60acc33dc59d43540a99bdf060ca28d24d36b1e Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Mon, 14 Apr 2003 19:13:15 +0000 Subject: [PATCH] * automake.in (%silent_variable_override): New variable. (macro_define): Warn about variable definitions overriding Automake variables. (rule_define): Warn about target definitions overriding Automake variables. Fix $condmsg definition. * automake.texi (Invoking Automake): Document the `override' category. * lib/Automake/ChannelDefs.pm (usage): Likewise. * lib/am/texinfos.am [!%?CYGNUS] (MAKEINFO): Do not define, this is already done in m4/init.m4. * tests/dejagnu2.test: Run $MAKE, don't only grep. Use -Wno-override, and make sure we get a warning without. * tests/exeext2.test, tests/substtarg.test: Use -Wno-override, and make sure we get a warning without. * tests/exeext3.test, tests/java2.test, tests/nolink.test, tests/subpkg.test, tests/vartest.test: Use -Wno-override. * tests/txinfo13.test: Use installcheck-local instead of overriding installcheck. * tests/txinfo2.test: Run $MAKE on the real Makefile (this test used to succeed thanks to a failure...) * tests/location.test: Adjust expected messages. * tests/Makefile.am (XFAIL_TESTS): Add txinfo5.test. --- ChangeLog | 25 +++++++++++++++++++++++++ Makefile.in | 1 + NEWS | 2 ++ automake.in | 28 +++++++++++++++++++++++++--- automake.texi | 2 ++ lib/Automake/ChannelDefs.pm | 11 +++++++++-- lib/am/texinfos.am | 1 - stamp-vti | 2 +- tests/Makefile.am | 2 +- tests/Makefile.in | 2 +- tests/dejagnu2.test | 22 ++++++++++++++++++---- tests/exeext2.test | 9 +++++---- tests/exeext3.test | 4 ++-- tests/java2.test | 4 ++-- tests/location.test | 6 +++--- tests/nolink.test | 8 +++++--- tests/subpkg.test | 4 ++-- tests/substtarg.test | 7 +++++-- tests/txinfo13.test | 4 ++-- tests/txinfo2.test | 17 +++++++++++++---- tests/vartar.test | 14 +++++++------- version.texi | 2 +- 22 files changed, 132 insertions(+), 45 deletions(-) diff --git a/ChangeLog b/ChangeLog index cae171a2f..0ed1cecd7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,28 @@ +2003-04-14 Alexandre Duret-Lutz + + * automake.in (%silent_variable_override): New variable. + (macro_define): Warn about variable definitions overriding + Automake variables. + (rule_define): Warn about target definitions overriding + Automake variables. Fix $condmsg definition. + * automake.texi (Invoking Automake): Document the `override' + category. + * lib/Automake/ChannelDefs.pm (usage): Likewise. + * lib/am/texinfos.am [!%?CYGNUS] (MAKEINFO): Do not define, + this is already done in m4/init.m4. + * tests/dejagnu2.test: Run $MAKE, don't only grep. Use + -Wno-override, and make sure we get a warning without. + * tests/exeext2.test, tests/substtarg.test: Use -Wno-override, + and make sure we get a warning without. + * tests/exeext3.test, tests/java2.test, tests/nolink.test, + tests/subpkg.test, tests/vartest.test: Use -Wno-override. + * tests/txinfo13.test: Use installcheck-local instead of overriding + installcheck. + * tests/txinfo2.test: Run $MAKE on the real Makefile (this test + used to succeed thanks to a failure...) + * tests/location.test: Adjust expected messages. + * tests/Makefile.am (XFAIL_TESTS): Add txinfo5.test. + 2003-04-12 Raja R Harinath * lib/Automake/DisjConditions.pm (true): Don't cache answer. diff --git a/Makefile.in b/Makefile.in index 216541b14..588a5c9d1 100644 --- a/Makefile.in +++ b/Makefile.in @@ -264,6 +264,7 @@ mostlyclean-vti: maintainer-clean-vti: -rm -f stamp-vti version.texi + TEXI2DVI = texi2dvi TEXI2PDF = $(TEXI2DVI) --pdf --batch diff --git a/NEWS b/NEWS index 1b422a54d..044a36e21 100644 --- a/NEWS +++ b/NEWS @@ -64,6 +64,8 @@ New in 1.7a: substituted from configure.ac. This has been requested by people dealing with non-POSIX ar implementations. +* New warning option: -Woverride. This will warn about any user + target or variable definitions which override Automake definitions. New in 1.7: * Autoconf 2.54 is required. diff --git a/automake.in b/automake.in index db375fcf3..c8fe09fed 100755 --- a/automake.in +++ b/automake.in @@ -276,6 +276,13 @@ my %ac_macro_for_var = YACC => 'AC_PROG_YACC', ); +# Variables that can be overriden without complaint from -Woverride +my %silent_variable_override = + (AR => 1, + ARFLAGS => 1, + DEJATOOL => 1, + JAVAC => 1); + # Copyright on generated Makefile.ins. my $gen_copyright = "\ # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 @@ -6376,9 +6383,19 @@ sub macro_define ($$$$$$$$) && $var_owner{$var}{$cond} != VAR_AUTOMAKE && $owner == VAR_AUTOMAKE) { + if (! exists $silent_variable_override{$var}) + { + my $condmsg = ($cond == TRUE + ? '' : (" in condition `" . $cond->human . "'")); + msg_cond_var ('override', $cond, $var, + "user variable `$var' defined here$condmsg...", + partial => 1); + msg ('override', $where, + "... overrides Automake variable `$var' defined here"); + } verb ("refusing to override the user definition of:\n" . macro_dump ($var) - ."with `$cond->human' => `$value'"); + ."with `" . $cond->human . "' => `$value'"); } else { @@ -7133,11 +7150,11 @@ sub rule_define ($$$$$) # Don't mention true conditions in diagnostics. my $condmsg = - $cond == TRUE ? " in condition `" . $cond->human . "'" : ''; + $cond == TRUE ? '' : " in condition `" . $cond->human . "'"; if ($owner == TARGET_USER) { - if ($oldowner eq TARGET_USER) + if ($oldowner == TARGET_USER) { # Ignore `%'-style pattern rules. We'd need the # dependencies to detect duplicates, and they are @@ -7174,6 +7191,11 @@ sub rule_define ($$$$$) { if ($oldowner == TARGET_USER) { + msg_cond_target ('override', $cond, $target, + "user target `$target' defined here" + . "$condmsg...", partial => 1); + msg ('override', $where, + "... overrides Automake target `$target' defined here"); # Don't overwrite the user definition of TARGET. return (); } diff --git a/automake.texi b/automake.texi index f33e8a260..afc24e4a6 100644 --- a/automake.texi +++ b/automake.texi @@ -1051,6 +1051,8 @@ warnings related to the GNU Coding Standards (@pxref{Top, , , standards, The GNU Coding Standards}). @item obsolete obsolete features or constructions +@item override +user redefinitions of Automake rules or variables @item portability portability issues (e.g., use of Make features which are known not portable) @item syntax diff --git a/lib/Automake/ChannelDefs.pm b/lib/Automake/ChannelDefs.pm index 7fb18a2d4..61bc1d568 100644 --- a/lib/Automake/ChannelDefs.pm +++ b/lib/Automake/ChannelDefs.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2002 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003 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 @@ -98,13 +98,18 @@ Warnings related to GNU Coding Standards. Warnings about obsolete features (silent by default). +=item C + +Warnings about user redefinitions of Automake rules or +variables (silent by default). + =item C Warnings about non-portable constructs. =item C -Weird syntax, unused variables, typos... +Warnings about weird syntax, unused variables, typos... =item C @@ -139,6 +144,7 @@ register_channel 'automake', type => 'fatal', backtrace => 1, register_channel 'gnu', type => 'warning'; register_channel 'obsolete', type => 'warning', silent => 1; +register_channel 'override', type => 'warning', silent => 1; register_channel 'portability', type => 'warning', silent => 1; register_channel 'syntax', type => 'warning'; register_channel 'unsupported', type => 'warning'; @@ -161,6 +167,7 @@ sub usage () print "Warning categories include: `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 `syntax' dubious syntactic constructs (default) `unsupported' unsupported or incomplete features (default) diff --git a/lib/am/texinfos.am b/lib/am/texinfos.am index b3c5972ac..de1e9fc83 100644 --- a/lib/am/texinfos.am +++ b/lib/am/texinfos.am @@ -24,7 +24,6 @@ if %?LOCAL-TEXIS% if ! %?CYGNUS% -MAKEINFO = @MAKEINFO@ TEXI2DVI = texi2dvi else %?CYGNUS% diff --git a/stamp-vti b/stamp-vti index 18895fa65..d4a984336 100644 --- a/stamp-vti +++ b/stamp-vti @@ -1,4 +1,4 @@ -@set UPDATED 10 April 2003 +@set UPDATED 14 April 2003 @set UPDATED-MONTH April 2003 @set EDITION 1.7a @set VERSION 1.7a diff --git a/tests/Makefile.am b/tests/Makefile.am index e0c9ae65c..26865e012 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to create Makefile.in -XFAIL_TESTS = subdir5.test auxdir2.test cond17.test +XFAIL_TESTS = subdir5.test auxdir2.test cond17.test txinfo5.test TESTS = \ acinclude.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 9a19ca9c3..ef296f6c7 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -104,7 +104,7 @@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ -XFAIL_TESTS = subdir5.test auxdir2.test cond17.test +XFAIL_TESTS = subdir5.test auxdir2.test cond17.test txinfo5.test TESTS = \ acinclude.test \ aclibobj.test \ diff --git a/tests/dejagnu2.test b/tests/dejagnu2.test index 388fe3eba..c6142b653 100755 --- a/tests/dejagnu2.test +++ b/tests/dejagnu2.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2001, 2002 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. # # This file is part of GNU Automake. # @@ -22,15 +22,29 @@ . ./defs || exit 1 +set -e + +echo 'AC_OUTPUT' >> configure.in + cat > Makefile.am << 'END' AUTOMAKE_OPTIONS = dejagnu site.exp: - echo foo + @echo foo END -$ACLOCAL || exit 1 -$AUTOMAKE || exit 1 +$ACLOCAL +$AUTOCONF +$AUTOMAKE -Wno-override grep site.exp Makefile.in test `grep '^site\.exp:' Makefile.in | wc -l` -eq 1 + +./configure +$MAKE site.exp >stdout +cat stdout +grep foo stdout + +$AUTOMAKE 2>stderr && exit 1 +cat stderr +grep 'Makefile.am:3:.*site.exp' stderr diff --git a/tests/exeext2.test b/tests/exeext2.test index c7bd71ccf..6402a5774 100755 --- a/tests/exeext2.test +++ b/tests/exeext2.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2001, 2002 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. # # This file is part of GNU Automake. # @@ -41,11 +41,12 @@ $ACLOCAL $AUTOMAKE -Wnone $AUTOMAKE -Wnone -Wobsolete 2>stderr && exit 1 cat stderr -grep maude stderr +grep 'deprecated.*maude' stderr $AUTOMAKE -Wall 2>stderr && exit 1 cat stderr -grep maude stderr +grep 'deprecated.*maude' stderr +grep 'overrid.*maude' stderr echo 'AUTOMAKE_OPTIONS = no-exeext' >> Makefile.am -$AUTOMAKE -Wall +$AUTOMAKE -Wall -Wno-override diff --git a/tests/exeext3.test b/tests/exeext3.test index a867f0077..f16a69d2f 100755 --- a/tests/exeext3.test +++ b/tests/exeext3.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2002 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003 Free Software Foundation, Inc. # # This file is part of GNU Automake. # @@ -36,7 +36,7 @@ maude$(EXEEXT): END $ACLOCAL -$AUTOMAKE +$AUTOMAKE -Wno-override $FGREP 'maude$(EXEEXT):' Makefile.in test 1 = `grep 'maude.*:' Makefile.in | wc -l` diff --git a/tests/java2.test b/tests/java2.test index 5ccf31b8c..f89bdf65e 100755 --- a/tests/java2.test +++ b/tests/java2.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2002 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003 Free Software Foundation, Inc. # # This file is part of GNU Automake. # @@ -48,6 +48,6 @@ END $ACLOCAL $AUTOCONF -$AUTOMAKE +$AUTOMAKE -Wno-override ./configure $MAKE diff --git a/tests/location.test b/tests/location.test index 7cb505272..8ee95c996 100755 --- a/tests/location.test +++ b/tests/location.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2002 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003 Free Software Foundation, Inc. # # This file is part of GNU Automake. # @@ -66,11 +66,11 @@ library.am: change your target to read `libfoo.a$(EXEEXT)' Makefile.am:3: while processing library `libfoo.a' program.am: target `libfoo.a$(EXEEXT)' was defined here Makefile.am:1: while processing program `libfoo.a' -program.am: redefinition of `libfoo.a' in condition `TRUE'... +program.am: redefinition of `libfoo.a'... Makefile.am:1: while processing program `libfoo.a' library.am: ... `libfoo.a' previously defined here Makefile.am:3: while processing library `libfoo.a' -tags.am: redefinition of `ctags' in condition `TRUE'... +tags.am: redefinition of `ctags'... program.am: ... `ctags' previously defined here Makefile.am:6: while processing program `ctags' EOF diff --git a/tests/nolink.test b/tests/nolink.test index e23f831e2..1c22b5318 100755 --- a/tests/nolink.test +++ b/tests/nolink.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2001, 2002 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. # # This file is part of GNU Automake. # @@ -22,6 +22,8 @@ . ./defs || exit 1 +set -e + cat > Makefile.am << 'END' AUTOMAKE_OPTIONS = no-exeext @@ -32,8 +34,8 @@ meal: beans.veg beef.meat cat beans.veg beef.meat > meal END -$ACLOCAL || exit 1 -$AUTOMAKE || exit 1 +$ACLOCAL +$AUTOMAKE -Wno-override grep '^meal.*:' Makefile.in | grep -v beef.meat && exit 1 diff --git a/tests/subpkg.test b/tests/subpkg.test index 84b230676..6b67124ec 100755 --- a/tests/subpkg.test +++ b/tests/subpkg.test @@ -88,12 +88,12 @@ EOF $ACLOCAL $AUTOCONF -$AUTOMAKE +$AUTOMAKE -Wno-override cd lib $ACLOCAL $AUTOCONF -$AUTOMAKE +$AUTOMAKE -Wno-override cd .. ./configure diff --git a/tests/substtarg.test b/tests/substtarg.test index 591e77465..9bc721468 100755 --- a/tests/substtarg.test +++ b/tests/substtarg.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2001, 2002 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. # # This file is part of GNU Automake. # @@ -47,6 +47,9 @@ END set -e $ACLOCAL -$AUTOMAKE +$AUTOMAKE 2>stderr && exit 1 +cat stderr +grep 'overrid.*libfake@SUBST@.a' stderr num=`grep '^libfake@SUBST@.a:' Makefile.in | wc -l` test $num -eq 1 +$AUTOMAKE -Wno-override diff --git a/tests/txinfo13.test b/tests/txinfo13.test index 077f63543..b32e98d40 100755 --- a/tests/txinfo13.test +++ b/tests/txinfo13.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2002 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003 Free Software Foundation, Inc. # # This file is part of GNU Automake. # @@ -32,7 +32,7 @@ cat > Makefile.am << 'END' info_TEXINFOS = subdir/main.texi subdir_main_TEXINFOS = subdir/inc.texi -installcheck: +installcheck-local: test -f $(infodir)/main.info END diff --git a/tests/txinfo2.test b/tests/txinfo2.test index e1e1b4650..900a2c3d1 100755 --- a/tests/txinfo2.test +++ b/tests/txinfo2.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 1996, 1997, 2001, 2002 Free Software Foundation, Inc. +# Copyright (C) 1996, 1997, 2001, 2002, 2003 Free Software Foundation, Inc. # # This file is part of GNU Automake. # @@ -23,6 +23,10 @@ . ./defs || exit 1 +set -e + +echo AC_OUTPUT >> configure.in + cat > Makefile.am << 'END' info_TEXINFOS = textutils.texi magic: @@ -33,7 +37,12 @@ END echo '@setfilename textutils.info' > textutils.texi : > textutils.info~ -$ACLOCAL || exit 1 -$AUTOMAKE || exit 1 -test -z "`$MAKE -s -f Makefile.in magic | grep '~'`" +$ACLOCAL +$AUTOCONF +$AUTOMAKE +./configure +$MAKE magic >stdout +cat stdout +grep '~' stdout && exit 1 +exit 0 diff --git a/tests/vartar.test b/tests/vartar.test index e6b7a3aa0..237bd2795 100755 --- a/tests/vartar.test +++ b/tests/vartar.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2001, 2002 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. # # This file is part of GNU Automake. # @@ -22,22 +22,22 @@ . ./defs || exit 1 +set -e + cat > Makefile.am << 'END' install = install install: $(install) install END -$ACLOCAL || exit 1 -$AUTOMAKE || exit 1 +$ACLOCAL +$AUTOMAKE -Wno-override -grep '^install = install$' Makefile.in || exit 1 +grep '^install = install$' Makefile.in cat > target.expected <<'EOF' install: $(install) install EOF sed -n '/^install:/,/^ /p' Makefile.in > target.value -diff target.expected target.value || exit 1 - -exit 0 +diff target.expected target.value diff --git a/version.texi b/version.texi index 18895fa65..d4a984336 100644 --- a/version.texi +++ b/version.texi @@ -1,4 +1,4 @@ -@set UPDATED 10 April 2003 +@set UPDATED 14 April 2003 @set UPDATED-MONTH April 2003 @set EDITION 1.7a @set VERSION 1.7a -- 2.47.2