bug-make
[Top][All Lists]
Advanced

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

target specific variable


From: Sebastian Glita
Subject: target specific variable
Date: Tue, 26 Mar 2002 16:20:31 +0200

    Hi,
 
    I have attached a tar'ed gzip'ed example.
    After running `make', I asked myself: Where did the `-ggdb' flag go ???
   
    I append flags to object files separately like this:
    sources := main.c util.c
    objects := $(sources:.c=.o)
    $(objects): CFLAGS += -ggdb
    main.o: CFLAGS += -DAUTHOR='"myself"'
 
    but "+=" for target-specific variables ignores their previously, defered for expansions, values.
   I took *little* time to debug what `make' was doing, and I came up
with the following question:
    Why doesn't `make' append new values to old values (without expanding the old values) for target specific variables, and instead discards the old value ?
 
    My temporary  humble solution is:
    In the file `variable.c', in the function
 
struct variable *
try_variable_definition (flocp, line, origin, target_var)
     const struct floc *flocp;
     char *line;
     enum variable_origin origin;
     int target_var;
 
I modified like this:
 
/* Calculate the variable's new value in VALUE.  */
 
  switch (flavor)
    {
    ...
    case f_append:
      /* If we have += but we're in a target variable context, defer the
         append until the context expansion. ??? IT DEFERS THE REPLACE, NOT THE APPEND ?!?! */
      if (target_var)
        {
          append = 1;
          /* I REMOVED THESE 3 LINES */
          /*
          flavor = f_recursive;
          value = p;
          break;
          */
        }
 /* An appending variable definition "var += value".
  Extract the old value and append the new one.  */
v = lookup_variable (expanded_name, strlen (expanded_name));
if (v == 0)
{
   /* There was no old value.
      This becomes a normal recursive definition.  */
   value = p;
   flavor = f_recursive;
}
else
{
   /* Paste the old and new values together in VALUE.  */
 
   unsigned int oldlen, newlen;
 
   if (append || /*I ADDED THIS */
        v->recursive)
     /* The previous definition of the variable was recursive.
        The new value comes from the unexpanded old and new values.  */
     flavor = f_recursive;
    else
        ...
 }
    It works well now from this point of view !
 
    I have a `K7 Athlon' running `Red Hat Linux 7.2' machine.
 
This is the output of `make --version':
----
GNU Make version 3.79.1, by Richard Stallman and Roland McGrath.
Built for i686-pc-linux-gnu
Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
        Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
 
Report bugs to <address@hidden>.
----
 
Sincerely,
 
Sebastian Glita
student
Computer Science Faculty
Timisoara
Romania
 

Attachment: bug.tgz
Description: application/compressed


reply via email to

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