diff options
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | THANKS | 1 | ||||
-rw-r--r-- | lib/Automake/Variable.pm | 66 | ||||
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/Makefile.in | 1 | ||||
-rwxr-xr-x | tests/cond21.test | 7 | ||||
-rwxr-xr-x | tests/cond38.test | 71 |
7 files changed, 125 insertions, 34 deletions
@@ -1,3 +1,15 @@ +2005-06-24 Alexandre Duret-Lutz <adl@gnu.org> + + * lib/Automake/Variable.pm (define, _new): Remember the helper + variable created for the last conditional += on each variable, and + only append further += in the same condition to this last helper + variable, not to older helper variables. This way the order of + the items appended to the variable is preserved. + * tests/cond21.test: Adjust. + * tests/cond38.test: New file. + * tests/Makefile.am (TESTS): Add cond38.test. + Report from Ed Hartnett. + 2005-06-22 Alexandre Duret-Lutz <adl@gnu.org> * tests/aclocal5.test: Adjust to recent CVS Autoconf changes. @@ -56,6 +56,7 @@ Dieter Baron dillo@stieltjes.smc.univie.ac.at Dmitry Mikhin dmitrym@acres.com.au Doug Evans devans@cygnus.com Duncan Gibson duncan@thermal.esa.int +Ed Hartnett ed@unidata.ucar.edu Eleftherios Gkioulekas lf@amath.washington.edu Elena A. Vengerova helen@oktetlabs.ru Elmar Hoffmann elho@elho.net diff --git a/lib/Automake/Variable.pm b/lib/Automake/Variable.pm index bd87f254d..549630920 100644 --- a/lib/Automake/Variable.pm +++ b/lib/Automake/Variable.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2003, 2004 Free Software Foundation, Inc. +# Copyright (C) 2003, 2004, 2005 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 @@ -193,10 +193,8 @@ my %_silent_variable_override = JAVAC => 1, JAVAROOT => 1); -# This hash records helper variables used to implement conditional '+='. -# Keys have the form "VAR:CONDITIONS". The value associated to a key is -# the named of the helper variable used to append to VAR in CONDITIONS. -my %_appendvar = (); +# Count of helper variables used to implement conditional '+='. +my $_appendvar; # Each call to C<Automake::Variable::traverse_recursively> gets an # unique label. This is used to detect recursively defined variables. @@ -335,7 +333,7 @@ sub reset () { %_variable_dict = (); %_primary_dict = (); - %_appendvar = (); + $_appendvar = 0; @_var_order = (); %_gen_varname = (); $_traversal = 0; @@ -436,6 +434,7 @@ sub _new ($$) my ($class, $name) = @_; my $self = Automake::Item::new ($class, $name); $self->{'scanned'} = 0; + $self->{'last-append'} = []; # helper variable for last conditional append. $_variable_dict{$name} = $self; if ($name =~ /_([[:alnum:]]+)$/) { @@ -892,6 +891,7 @@ sub define ($$$$$$$$) if ($type eq '+' && ! $new_var) { $def->append ($value, $comment); + $self->{'last-append'} = []; # Only increase owners. A VAR_CONFIGURE variable augmented in a # Makefile.am becomes a VAR_MAKEFILE variable. @@ -924,32 +924,39 @@ sub define ($$$$$$$$) # @COND_TRUE@FOO = foo1 bar # @COND_FALSE@FOO = foo2 bar + my $lastappend = []; # Do we need an helper variable? if ($cond != TRUE) { - # Does the helper variable already exists? - my $key = "$var:" . $cond->string; - if (exists $_appendvar{$key}) - { - # Yes, let's simply append to it. - $var = $_appendvar{$key}; - $owner = VAR_AUTOMAKE; - $self = var ($var); - $def = $self->rdef ($cond); - $new_var = 0; - } - else - { - # No, create it. - my $num = 1 + keys (%_appendvar); - my $hvar = "am__append_$num"; - $_appendvar{$key} = $hvar; - &define ($hvar, VAR_AUTOMAKE, '+', - $cond, $value, $comment, $where, $pretty); - # Now HVAR is to be added to VAR. - $comment = ''; - $value = "\$($hvar)"; - } + # Can we reuse the helper variable created for the previous + # append? (We cannot reuse older helper variables because + # we must preserve the order of items appended to the + # variable.) + my $condstr = $cond->string; + my $key = "$var:$condstr"; + my ($appendvar, $appendvarcond) = @{$self->{'last-append'}}; + if ($appendvar && $condstr eq $appendvarcond) + { + # Yes, let's simply append to it. + $var = $appendvar; + $owner = VAR_AUTOMAKE; + $self = var ($var); + $def = $self->rdef ($cond); + $new_var = 0; + } + else + { + # No, create it. + my $num = ++$_appendvar; + my $hvar = "am__append_$num"; + $lastappend = [$hvar, $condstr]; + &define ($hvar, VAR_AUTOMAKE, '+', + $cond, $value, $comment, $where, $pretty); + + # Now HVAR is to be added to VAR. + $comment = ''; + $value = "\$($hvar)"; + } } # Add VALUE to all definitions of SELF. @@ -980,6 +987,7 @@ sub define ($$$$$$$$) $where, $pretty); } } + $self->{'last-append'} = $lastappend; } # 3. first assignment (=, :=, or +=) else diff --git a/tests/Makefile.am b/tests/Makefile.am index 452b4f7b0..75e92e09b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -138,6 +138,7 @@ cond34.test \ cond35.test \ cond36.test \ cond37.test \ +cond38.test \ condd.test \ condhook.test \ condinc.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index c4557e677..0c89e00bb 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -258,6 +258,7 @@ cond34.test \ cond35.test \ cond36.test \ cond37.test \ +cond38.test \ condd.test \ condhook.test \ condinc.test \ diff --git a/tests/cond21.test b/tests/cond21.test index c6fbd20ec..56f682cbf 100755 --- a/tests/cond21.test +++ b/tests/cond21.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2002 Free Software Foundation, Inc. +# Copyright (C) 2002, 2005 Free Software Foundation, Inc. # # This file is part of GNU Automake. # @@ -43,9 +43,6 @@ if COND2 else FOO += foon2 endif -## Note that we add `foo1b' after `foo2'; however because it is appended in -## the same condition as `foo1', it should use the same helper variable -## and thus appear right after `foo1' in the output. if COND1 FOO += foo1b else @@ -80,4 +77,4 @@ $AUTOCONF $AUTOMAKE -a ./configure $MAKE test | $FGREP 'BAR: bar12 bar bar3 :BAR' -$MAKE test | $FGREP 'FOO: foo foo1 foo1b foo2 :FOO' +$MAKE test | $FGREP 'FOO: foo foo1 foo2 foo1b :FOO' diff --git a/tests/cond38.test b/tests/cond38.test new file mode 100755 index 000000000..154c1277e --- /dev/null +++ b/tests/cond38.test @@ -0,0 +1,71 @@ +#!/bin/sh +# Copyright (C) 2005 Free Software Foundation, Inc. +# +# This file is part of GNU Automake. +# +# GNU Automake 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. +# +# GNU Automake 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 Automake; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. + +# Check conditional variable ordering. +# Report from Ed Hartnett. + +. ./defs + +set -e + +cat >>configure.in <<'EOF' +AM_CONDITIONAL([CASE_A], :) +AM_CONDITIONAL([CASE_B], :) +AC_OUTPUT +EOF + +cat >>Makefile.am <<'EOF' +SUBDIRS = a +if CASE_A +SUBDIRS += b +endif +SUBDIRS += c +if CASE_A +SUBDIRS += d +if CASE_B +SUBDIRS += e +endif +SUBDIRS += f +endif +SUBDIRS += g +if CASE_B +SUBDIRS += h +endif +if CASE_B +SUBDIRS += iXYZ +SUBDIRS += jZYX +endif +print: + @echo BEG: $(SUBDIRS) :END +EOF + +mkdir a b c d e f g h iXYZ jZYX + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +./configure +$MAKE print >stdout +cat stdout +# Check good ordering +grep 'BEG: a b c d e f g h iXYZ jZYX :END' stdout +# Make sure no extra variable was created for the last 3 items. +grep 'append.*=.* h iXYZ jZYX' Makefile |