]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
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 6d1bf3a02aefc5ebfaa46cb2c78ce47fdc3ca0df..2d3a261a4416ef31325fca182d715d74afb920af 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 d3192d9ee4b5617252246289a86b2daa63485538..ea5da72ff45fcb60ed2a4e5a40cec51f093c77c2 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 1e24bb2ba5dbda8b9dfe5686f54b31f6f422b05f..f0c867f6518b9f8487c55655bb0cdf744936b188 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 3d52ba8fbb89c9e476d3c915fefe4f0f363ccf34..98829c9ac3c90fdf2c07531b3708d61655a78c96 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 ddd8d7139528076ed84f10f5aa84387b6baa5043..d12b8504d436e64b4aa5085eba9d636049369f44 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