%% [EMAIL PROTECTED] 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 <[EMAIL PROTECTED]>          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

_______________________________________________
Help-make mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/help-make

Reply via email to