]> sourceware.org Git - automake.git/commitdiff
2002-05-31 Richard Boulton <richard@tartarus.org>
authorAlexandre Duret-Lutz <adl@gnu.org>
Fri, 31 May 2002 17:46:15 +0000 (17:46 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Fri, 31 May 2002 17:46:15 +0000 (17:46 +0000)
        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
automake.in
tests/Makefile.am
tests/Makefile.in
tests/cond22.test [new file with mode: 0755]

index f74dfe9b02e45e576caedf4ec0087d5d2036ad63..0166369e45e4c874dd2795c014a17878494461e1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2002-05-31  Richard Boulton <richard@tartarus.org>
+
+       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  <eggert@twinsun.com>
 
        * lib/am/distdir.am (distdir): Don't assume that 'grep -F' works;
index 8695d9d7ddd3d3b9a51c6386e5b1f0610aa5fd3f..8cfad3409ca2f6494662e515faae6a90436c293a 100755 (executable)
@@ -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};
 
index 9ab3b2bbd09ed563433f562fbfa2c7d4dad07290..d96e2afa1bf7eb81d2d76461cf2e044e5d667b05 100644 (file)
@@ -83,6 +83,7 @@ cond18.test \
 cond19.test \
 cond20.test \
 cond21.test \
+cond22.test \
 condd.test \
 condincl.test \
 condincl2.test \
index dd1b57661711e6ffa2bee3691ac2c46b099ee9f0..acc61e5f12336d50a7f5283852a92d1168307946 100644 (file)
@@ -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 (executable)
index 0000000..ce89aee
--- /dev/null
@@ -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
This page took 0.038942 seconds and 5 git commands to generate.