From 0375e1931d0129ca48281844deb36c8e9f233916 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Fri, 31 May 2002 17:46:22 +0000 Subject: [PATCH] 2002-05-31 Richard Boulton Fix PR automake/326: * automake.in (define_objects_from_sources): Calculate the result in all conditions before passing this to subobjname to pick a name to store the result in. (subobjname): Expect a list of condition/value pairs as input. Combine this list and use it as the key to determine the variable name. * test/cond22.test: New file. * tests/Makefile.am (TESTS): Add cond21.test --- ChangeLog | 11 +++++++++++ automake.in | 41 ++++++++++++++++++++++++++++------------- tests/Makefile.am | 1 + tests/Makefile.in | 1 + tests/cond22.test | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 96 insertions(+), 13 deletions(-) create mode 100755 tests/cond22.test diff --git a/ChangeLog b/ChangeLog index f74dfe9..0166369 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2002-05-31 Richard Boulton + + Fix PR automake/326: + * automake.in (define_objects_from_sources): Calculate the result in + all conditions before passing this to subobjname to pick a name to + store the result in. + (subobjname): Expect a list of condition/value pairs as input. + Combine this list and use it as the key to determine the variable name. + * test/cond22.test: New file. + * tests/Makefile.am (TESTS): Add cond21.test + 2002-05-30 Paul Eggert * lib/am/distdir.am (distdir): Don't assume that 'grep -F' works; diff --git a/automake.in b/automake.in index 8695d9d..8cfad34 100755 --- a/automake.in +++ b/automake.in @@ -605,7 +605,9 @@ my @substtos; my %require_file_found = (); # This keeps track of all variables defined by subobjname. -# The key is the variable _content_, and the value is the variable name. +# The value stored is the variable names. +# The key has the form "(COND1)VAL1(COND2)VAL2..." where VAL1 and VAL2 +# are the values of the variable for condition COND1 and COND2. my %subobjvar = (); # This hash records helper variables used to implement '+=' in conditionals. @@ -2134,7 +2136,7 @@ sub handle_single_transform_list ($$$$@) return @result; } -# $BOOL +# ($LINKER, $OBJVAR) # define_objects_from_sources ($VAR, $OBJVAR, $NODEFINE, $ONE_FILE, # $OBJ, $PARENT, $TOPPARENT) # --------------------------------------------------------------------- @@ -2174,6 +2176,7 @@ sub define_objects_from_sources ($$$$$$$) $vars_scanned{$var} = 1; my $needlinker = ""; + my @allresults = (); foreach my $cond (variable_conditions ($var)) { my @result; @@ -2228,12 +2231,18 @@ sub define_objects_from_sources ($$$$$$$) $needlinker = "true" if @transformed; } } - - # Find an name for the variable, unless imposed. - $objvar = subobjname (@result) unless defined $objvar; - # Define _OBJECTS conditionally. - define_pretty_variable ($objvar, $cond, (@result)) - unless $nodefine; + push (@allresults, [$cond, @result]); + } + # Find a name for the variable, unless imposed. + $objvar = subobjname (@allresults) unless defined $objvar; + # Define _OBJECTS conditionally + unless ($nodefine) + { + foreach my $pair (@allresults) + { + my ($cond, @result) = @$pair; + define_pretty_variable ($objvar, $cond, @result); + } } delete $vars_scanned{$var}; @@ -2242,11 +2251,12 @@ sub define_objects_from_sources ($$$$$$$) # $VARNAME -# subobjname (@OBJECTS) -# --------------------- -# Return a name for an object variable that holds @OBJECTS. +# subobjname (@DEFINITIONS) +# ------------------------- +# Return a name for an object variable that with definitions @DEFINITIONS. +# @DEFINITIONS is a list of pair [$COND, @OBJECTS]. # -# If we already have an object variable containing @OBJECTS, reuse it. +# If we already have an object variable containing @DEFINITIONS, reuse it. # This way, we avoid combinatorial explosion of the generated # variables. Especially, in a Makefile such as: # @@ -2276,7 +2286,12 @@ sub define_objects_from_sources ($$$$$$$) # small C programs, all testing the same set of source files. sub subobjname (@) { - my $key = "@_"; + my $key = ''; + foreach my $pair (@_) + { + my ($cond, @values) = @$pair; + $key .= "($cond)@values"; + } return $subobjvar{$key} if exists $subobjvar{$key}; diff --git a/tests/Makefile.am b/tests/Makefile.am index 9ab3b2b..d96e2af 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -83,6 +83,7 @@ cond18.test \ cond19.test \ cond20.test \ cond21.test \ +cond22.test \ condd.test \ condincl.test \ condincl2.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index dd1b576..acc61e5 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -167,6 +167,7 @@ cond18.test \ cond19.test \ cond20.test \ cond21.test \ +cond22.test \ condd.test \ condincl.test \ condincl2.test \ diff --git a/tests/cond22.test b/tests/cond22.test new file mode 100755 index 0000000..ce89aee --- /dev/null +++ b/tests/cond22.test @@ -0,0 +1,55 @@ +#! /bin/sh + +# Regression test for bug when sources listed in conditional. +# Report from Richard Boulton. PR/326. + +. $srcdir/defs || exit 1 + +set -e + +cat >> configure.in << 'END' +AC_PROG_CC +AM_CONDITIONAL(ONE, true) +AM_CONDITIONAL(TWO, false) +AM_CONDITIONAL(THREE, false) +AC_OUTPUT +END + +cat > Makefile.am << 'END' +bin_PROGRAMS = targ + +if ONE +SONE = one.c +endif + +if TWO +STWO = +else +STWO = two.c +endif + +if THREE +STHREE = +else +STHREE = three.c +endif + +if THREE +STHREE2 = +else +STHREE2 = three2.c +endif + +targ_SOURCES = $(SONE) $(STWO) $(STHREE) $(STHREE2) + +echo: + echo BEG: $(targ_OBJECTS) :END; +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE +./configure +OBJEXT=oo $MAKE -e echo > output +cat output +$FGREP 'BEG: one.oo two.oo three.oo three2.oo :END' output -- 2.7.4