automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FYI: fix for PR/326


From: Alexandre Duret-Lutz
Subject: FYI: fix for PR/326
Date: Fri, 31 May 2002 19:43:32 +0200
User-agent: Gnus/5.090006 (Oort Gnus v0.06) Emacs/21.2 (i386-debian-linux-gnu)

I'm checking in this patch, see the PR for the discussion.
This is the branch-1-6 version (HEAD uses $FGREP instead of fgrep).

2002-05-31  Richard Boulton <address@hidden>

        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

Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1287.2.7
diff -u -r1.1287.2.7 automake.in
--- automake.in 14 May 2002 14:13:23 -0000      1.1287.2.7
+++ automake.in 31 May 2002 17:29:38 -0000
@@ -660,7 +660,9 @@
 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 = ();
 
 ## --------------------------------- ##
@@ -2190,7 +2192,7 @@
     return @result;
 }
 
-# $BOOL
+# ($LINKER, $OBJVAR)
 # define_objects_from_sources ($VAR, $OBJVAR, $NODEFINE, $ONE_FILE,
 #                              $OBJ, $PARENT, $TOPPARENT)
 # ---------------------------------------------------------------------
@@ -2230,6 +2232,7 @@
     $vars_scanned{$var} = 1;
 
     my $needlinker = "";
+    my @allresults = ();
     foreach my $cond (variable_conditions ($var))
     {
        my @result;
@@ -2284,12 +2287,18 @@
                $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};
@@ -2298,11 +2307,12 @@
 
 
 # $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, address@hidden)
 #
-# 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:
 #
@@ -2332,7 +2342,12 @@
 # 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: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.385.2.10
diff -u -r1.385.2.10 Makefile.am
--- tests/Makefile.am   24 May 2002 10:39:40 -0000      1.385.2.10
+++ tests/Makefile.am   31 May 2002 17:29:39 -0000
@@ -82,6 +82,7 @@
 cond18.test \
 cond19.test \
 cond20.test \
+cond22.test \
 condd.test \
 condincl.test \
 condincl2.test \
Index: tests/Makefile.in
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.in,v
retrieving revision 1.499.2.13
diff -u -r1.499.2.13 Makefile.in
--- tests/Makefile.in   24 May 2002 10:39:40 -0000      1.499.2.13
+++ tests/Makefile.in   31 May 2002 17:29:39 -0000
@@ -158,6 +158,7 @@
 cond18.test \
 cond19.test \
 cond20.test \
+cond22.test \
 condd.test \
 condincl.test \
 condincl2.test \
Index: tests/cond22.test
===================================================================
RCS file: tests/cond22.test
diff -N tests/cond22.test
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ tests/cond22.test   31 May 2002 17:29:39 -0000
@@ -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

-- 
Alexandre Duret-Lutz




reply via email to

[Prev in Thread] Current Thread [Next in Thread]