help-make
[Top][All Lists]
Advanced

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

Re: appending to variables from the command line


From: Paul D. Smith
Subject: Re: appending to variables from the command line
Date: Mon, 3 Feb 2003 14:44:34 -0500

%% Bob Mroczka <address@hidden> writes:

  bm> Is there a way to append to variables defined in a Makefile from
  bm> the command line?  I have tried calling make (3.80) like this:

  bm> make 'DEFS+=-I/usr/local/include'

Nope.

  bm> but this does not work, the command line variable definition
  bm> overrides the Makefile variable.

Typically the way this is done is to reserve some set of variables for
the user to use on the command line.  For instance, the GNU standards
require that the normal variables CFLAGS, CPPFLAGS, etc. be reserved for
the user to override on the command line.

Then in the makefile you use a different variable for your unchangeable
settings and include both in the compile line:

  %.o : %.c
            $(CC) $(_local_CFLAGS) $(CFLAGS) -o $@ -c $<

or whatever.

-- 
-------------------------------------------------------------------------------
 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]