Allow variable override of, rather than by, silent variables.
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sun, 11 Oct 2009 11:33:43 +0000 (13:33 +0200)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sun, 11 Oct 2009 11:36:04 +0000 (13:36 +0200)
When overriding variables, check the VAR_SILENT status of the
old condition, not the new one: we allow non-silent overrides
of silent variables (these do not hit ordering bugs in the
automake output), but there is no use case for doing so the
other way round.  Fixes conditional overrides of variables
annotated AM_SUBST_NOTMAKE in configure.ac.

* lib/Automake/Variable.pm (_check_ambiguous_condition): Check
for VAR_SILENT in $ambig_cond not $cond.
* tests/cond44.test, tests/cond45.test: New tests, analogous to
cond23.test and cond24.test.
* tests/Makefile.am: Update.
Spotted originally in binutils/bfd.

Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
ChangeLog
lib/Automake/Makefile.in
lib/Automake/Variable.pm
tests/Makefile.am
tests/Makefile.in
tests/cond44.test [new file with mode: 0755]
tests/cond45.test [new file with mode: 0755]

index 6d1bf3a..2d3a261 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2009-10-11  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
+       Allow variable override of, rather than by, silent variables.
+       When overriding variables, check the VAR_SILENT status of the
+       old condition, not the new one: we allow non-silent overrides
+       of silent variables (these do not hit ordering bugs in the
+       automake output), but there is no use case for doing so the
+       other way round.  Fixes conditional overrides of variables
+       annotated AM_SUBST_NOTMAKE in configure.ac.
+       * lib/Automake/Variable.pm (_check_ambiguous_condition): Check
+       for VAR_SILENT in $ambig_cond not $cond.
+       * tests/cond44.test, tests/cond45.test: New tests, analogous to
+       cond23.test and cond24.test.
+       * tests/Makefile.am: Update.
+       Spotted originally in binutils/bfd.
+
        Fix `make clean check' for the Automake package.
        * lib/Automake/Makefile.am (SUBDIRS): Add `.' before `tests',
        so that Config.pm is built first.
index d3192d9..ea5da72 100644 (file)
@@ -206,7 +206,9 @@ target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-SUBDIRS = tests
+
+# `make clean check' should build Config.pm first.
+SUBDIRS = . tests
 perllibdir = $(pkgvdatadir)/Automake
 dist_perllib_DATA = \
   ChannelDefs.pm \
index 1e24bb2..f0c867f 100644 (file)
@@ -466,8 +466,9 @@ sub _check_ambiguous_condition ($$$)
   my $var = $self->name;
   my ($message, $ambig_cond) = $self->conditions->ambiguous_p ($var, $cond);
 
-  # We allow silent variables to be overridden silently.
-  my $def = $self->def ($cond);
+  # We allow silent variables to be overridden silently,
+  # by either silent or non-silent variables.
+  my $def = $self->def ($ambig_cond);
   if ($message && !($def && $def->pretty == VAR_SILENT))
     {
       msg 'syntax', $where, "$message ...", partial => 1;
index 3d52ba8..98829c9 100644 (file)
@@ -185,6 +185,8 @@ cond40.test \
 cond41.test \
 cond42.test \
 cond43.test \
+cond44.test \
+cond45.test \
 condd.test \
 condhook.test \
 condinc.test \
index ddd8d71..d12b850 100644 (file)
@@ -419,6 +419,8 @@ cond40.test \
 cond41.test \
 cond42.test \
 cond43.test \
+cond44.test \
+cond45.test \
 condd.test \
 condhook.test \
 condinc.test \
diff --git a/tests/cond44.test b/tests/cond44.test
new file mode 100755 (executable)
index 0000000..ac907f1
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/sh
+# Copyright (C) 2002, 2003, 2009 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 <http://www.gnu.org/licenses/>.
+
+# Check that redefinitions of AC_SUBST'ed AM_SUBST_NOTMAKE'd variables
+# are not diagnosed.  See cond23.test.
+
+. ./defs
+
+set -e
+
+cat >>configure.in <<EOF
+AM_CONDITIONAL([COND], [true])
+AM_SUBST_NOTMAKE([libdir])
+AC_OUTPUT
+EOF
+
+cat >Makefile.am <<EOF
+if COND
+libdir = mumble
+endif
+EOF
+
+$ACLOCAL
+AUTOMAKE_run 0
+grep 'libdir was already defined' stderr && Exit 1
+grep '^libdir = ' Makefile.in && Exit 1
+Exit 0
diff --git a/tests/cond45.test b/tests/cond45.test
new file mode 100755 (executable)
index 0000000..57dd339
--- /dev/null
@@ -0,0 +1,41 @@
+#!/bin/sh
+# Copyright (C) 2002, 2003, 2009 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 <http://www.gnu.org/licenses/>.
+
+# Check that redefinitions of AC_SUBST'ed AM_SUBST_NOTMAKE'd variables
+# are not diagnosed.  See cond24.test.
+
+. ./defs
+
+set -e
+
+cat >>configure.in <<EOF
+AC_SUBST([foo], [bar])
+AM_SUBST_NOTMAKE([foo])
+AM_CONDITIONAL([COND], [true])
+AC_OUTPUT
+EOF
+
+cat >Makefile.am <<EOF
+if COND
+foo = baz
+endif
+EOF
+
+$ACLOCAL
+AUTOMAKE_run 0
+grep 'foo was already defined' stderr && Exit 1
+grep '^foo =' Makefile.in && Exit 1
+Exit 0