help-make
[Top][All Lists]
Advanced

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

Re: adding to existing makefile variables


From: Paul D. Smith
Subject: Re: adding to existing makefile variables
Date: Wed, 4 Jun 2003 17:31:53 -0400

%% Edward Peschko <address@hidden> writes:

  >   ep> CFLAGS = '$(CFLAGS) -g'

  >> Is this something in the makefile or on the command line?  I'm confused,
  >> because I thought you said you didn't want to change the makefiles but
  >> the above looks like a makefile setting, not a command line setting.

  ep> On the command line. The idea would be that make would use the
  ep> CFLAGS environmental variable, see that it contains a CFLAGS make
  ep> variable, and then use that make variable plus the extra on the
  ep> end of it.

Ah, OK, then you need to quote it more than that since the whitespace
would cause the shell to break it up into separate words; I guess you
mean something like:

  make CFLAGS='$(CFLAGS) -g'

  >> Anyway, that syntax is not acceptable.  It is completely contrary to the
  >> rules that make variables use for expansion.  Plus make does not use
  >> quoting.

  ep> Why is it 'completely contrary to the rules that make variables
  ep> use for expansion'?

Referencing a recursive variable inside the setting of another recursive
variable gives an infinite loop during expansion.

A "better" syntax would be one of these:

  make CFLAGS:='$(CFLAGS) -g'

or the one you originally asked about:

  make CFLAGS+='$(CFLAGS) -g'

However, this change would not necessarily be simple and would require
serious thought before implementation.  Right now make has a very
strict hierarchy for controlling which values take precedence between
command line settings, makefile settings, and environment
settings... what you propose slurs at least one of those lines and
shouldn't be considered lightly.  There are many issues involved,
including when the variable value is set, how to handle recursive
invocations of make, etc.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "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]