[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: make: variable assignment after target?
From: |
Paul D. Smith |
Subject: |
Re: make: variable assignment after target? |
Date: |
26 Aug 2004 18:39:18 -0400 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 |
%% michalk@awpi.com (Brian K. Michalk) writes:
bkm> I want to do something like this:
bkm> ----------------
bkm> INCLUDEDIR = $(KERNELDIR)/include
bkm> all: module
bkm> module: dm5806_20040322.o dm5806_20040820.o
bkm> dm5806_20040322.o: dm5806.c
bkm> KERNELDIR := /usr/src/20040322
bkm> gcc $(CFLAGS) -o dm5806_20040322.o dm5806.c
bkm> dm5806_20040820.o: dm5806.c
bkm> KERNELDIR := /usr/src/20040820
bkm> gcc $(CFLAGS) -o dm5806_20040820.o dm5806.c
bkm> ----------------
bkm> I want to have several kernel source trees, and compile modules
bkm> against the various trees, where INCLUDEDIR is deferred, and then
bkm> KERNELDIR is set after the target is known, however this is not
bkm> allowed.
If INCLUDEDIR is only used within command scripts and isn't used in
target or prerequisite lists, you can use target-specific variables.
See the GNU make manual for details.
INCLUDEDIR = $(KERNELDIR)/include
all: module
module: dm5806_20040322.o dm5806_20040820.o
dm5806_20040322.o: KERNELDIR := /usr/src/20040322
dm5806_20040322.o: dm5806.c
gcc $(CFLAGS) -o dm5806_20040322.o dm5806.c
dm5806_20040820.o: KERNELDIR := /usr/src/20040820
dm5806_20040820.o: dm5806.c
gcc $(CFLAGS) -o dm5806_20040820.o dm5806.c
Note you need a recent version of GNU make for this to work.
--
-------------------------------------------------------------------------------
Paul D. Smith <psmith@gnu.org> 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