bug-make
[Top][All Lists]
Advanced

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

Re: Bug with repeated instances of per-target variable assignment


From: Paul D. Smith
Subject: Re: Bug with repeated instances of per-target variable assignment
Date: Thu, 5 Oct 2000 11:04:55 -0400

%% "David Zuhn" <address@hidden> writes:

  dz> INCS = -Iblorch

  dz> foo.o: INCS += -Ifoo
  dz> foo.o: INCS += -Ibar
  dz> foo.o: INCS += -Ibaz

  dz> foo.o: foo.c
  dz>   $(CC) $(INCS) -c $< -o $@

  dz> when I run a 'make', the command contains -Iblorch -Ibaz, with no
  dz> reference to the additional assignments of -Ifoo or -Ibar.  I was
  dz> expecting to see an expansion of $(INCS) as "-Iblorch -Ifoo -Ibar
  dz> -Ibaz".

This is PR/1831, which is already fixed in the source.  Unfortunately,
due to the recent re-org of the GNU systems you can't currently access
the GNU make bug database and get the patch to fix it.

Try this patch:

--- make-3.79.1/variable.c      Fri May 19 12:36:08 2000
+++ make/variable.c     Mon Aug 21 12:25:30 2000
@@ -201,9 +201,6 @@
          sptr = value;
          scnt = 0;
 
-          if (listp)
-            *listp = current_variable_set_list;
-
          while ((sptr = strchr (sptr, '$')))
            {
              scnt++;
@@ -903,19 +900,23 @@
       value = p;
       break;
     case f_append:
-      /* If we have += but we're in a target variable context, defer the
-         append until the context expansion.  */
+      {
+        struct variable_set_list *saved_next = current_variable_set_list->next;
+
+        /* If we have += but we're in a target variable context, we want to
+           append only with other variables in the context of this target.  */
       if (target_var)
         {
           append = 1;
-          flavor = f_recursive;
-          value = p;
-          break;
+            current_variable_set_list->next = 0;
         }
 
       /* An appending variable definition "var += value".
         Extract the old value and append the new one.  */
       v = lookup_variable (expanded_name, strlen (expanded_name));
+
+        current_variable_set_list->next = saved_next;
+
       if (v == 0)
        {
          /* There was no old value.
@@ -931,7 +932,7 @@
 
          if (v->recursive)
            /* The previous definition of the variable was recursive.
-              The new value comes from the unexpanded old and new values.  */
+                 The new value is the unexpanded old and new values. */
            flavor = f_recursive;
          else
            /* The previous definition of the variable was simple.
@@ -949,6 +950,7 @@
          bcopy (p, &value[oldlen + 1], newlen + 1);
        }
     }
+    }
 
 #ifdef __MSDOS__
   /* Many Unix Makefiles include a line saying "SHELL=/bin/sh", but


-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://www.paulandlesley.org/gmake/
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist



reply via email to

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