help-make
[Top][All Lists]
Advanced

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

Target dependent variable problem


From: Casey Liscum
Subject: Target dependent variable problem
Date: Fri, 6 Apr 2001 14:35:20 -0400

I have something like this:

#####################
BIN = bin.test
TARGETS = $(BIN)/exe

$(TARGETS): INCLUDES += -Ifoo

debug: DEFINES += -DDEBUG

$(TARGETS): $(BIN)/obj.o

all debug: $(TARGETS)

$(BIN)/%:
        @echo -e For \'address@hidden':\\n  DEFINES=\'$(DEFINES)\'\\n  \
            INCLUDES=\'$(INCLUDES)\'
#####################

My output is this:
$ make
For 'bin.test/obj.o':
 DEFINES=''
 INCLUDES='-Ifoo'
For 'bin.test/exe':
 DEFINES=''
 INCLUDES='-Ifoo'

So far so good, but when I do make debug...
$ make debug
For 'bin.test/obj.o':
 DEFINES=''
 INCLUDES='-Ifoo'
For 'bin.test/exe':
 DEFINES='-DDEBUG'
 INCLUDES='-Ifoo'

I need DEFINES to have it's debug value for both exe and obj.o.  What
am I doing wrong here?

DEFINES keeps its value for both targets (exe, obj.o) if I remove the
line:
    $(TARGETS): INCLUDES += -Ifoo
..but this is a necessary declaration.


I can get around this whole thing by replacing the line:
    debug: DEFINES += -DDEBUG
with this:
    ifeq ($(MAKECMDGOALS),debug) 
    DEFINES += -DDEBUG 
    endif

Is there some better way to do this (i.e. Is the preceding a no-no)?

Many thanks in advance!
Casey

-- 
Casey W. Liscum
Drexel University - Mathematics and Computer Science
"Now I can look at you in peace; I don't eat you any more."
         -- Franz Kafka, while admiring fish in an aquarium



reply via email to

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