help-make
[Top][All Lists]
Advanced

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

Re: Multiple Target-Specific Variable Assignment


From: Paul D. Smith
Subject: Re: Multiple Target-Specific Variable Assignment
Date: Fri, 30 Mar 2001 17:40:37 -0500

%% address@hidden writes:

  et> What is the syntax for defining multiple target-specific variables? For
  et> instance, I'd like to define both SUBDIRS and OBJS for the target,
  et> main.  Is the following Makefile code sample correct?

  et> OBJS = objs.o I.o dont.o want.o

  et> main: SUBDIRS = /usr/local/lib
  et> main: OBJS = foo.o
  et> main: OBJS += nice.o

Yes, this is correct.  Note there have been problems with this syntax
not working correctly in some versions of GNU make.  You don't say what
version you're using but you should be sure you have 3.79.1 (there may
even be fixes to this later than that, if it doesn't work).

  et> main: $(OBJS)
  et>      $(CC) -o main $(OBS)

This won't work, though.

Target-specific variables are only in-scope during the evaluation of the
command script (and other target-specific settings), just like automatic
variables.  So, the value of $(OBJS) in the prerequisites list will get
only the global value, not the target-specific value.

See the manual.

HTH.

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