[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
make question (target dependent variable)
From: |
James |
Subject: |
make question (target dependent variable) |
Date: |
11 Jan 2006 16:10:23 -0800 |
User-agent: |
G2/0.2 |
The goal is to set CFLAGS differently for different targets.
test-1.mk works (see below), but I have hundreds of targets, so to
shorten the makefile,
I am trying something like test-2.mk, which fails. Any idea?
Basically, can I defer the expansion of CFLAGS (with $@) until the
evaluation of the rules for the target? I tried functions like "define"
or "eval" but failed.
--------------------------------------
$ cat test-1.mk
P = pp qq
T = pp rr
CFLAGS = -c
.PHONY: $(T)
all: $(T)
pp: CFLAGS += -g
pp:
@echo $@ $(CFLAGS)
rr:
@echo $@ $(CFLAGS)
--------------------------------------
$ make -f test-1.mk
pp -c -g
rr -c
--------------------------------------
$ cat test-2.mk
P = pp qq
T = pp rr
CFLAGS = -c
ifneq ($(strip $(foreach f,$(P),$(findstring $(f),$@))),)
CFLAGS += -g
endif
.PHONY: $(T)
all: $(T)
$(T):
@echo $@ $(CFLAGS)
--------------------------------------
$ make -f test-2.mk
pp -c
rr -c
James
- make question (target dependent variable),
James <=