help-make
[Top][All Lists]
Advanced

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

how to force immediate evaluation of a variable


From: Kris Thielemans
Subject: how to force immediate evaluation of a variable
Date: Wed, 24 Mar 2004 17:12:12 -0000

Hi

I'm getting into recursive makefiles, and in a few directories want to
include a file that will do most of the tricks. That file looks for instance
as follows

--- clean.mk ---
clean_$(dir):
        rm $(dir)*.o

my makefiles in the subdirectory do then

-- somesubdir.mk ----
dir := location
include ../clean.mk

The trouble I have is that for the target, $(dir) is evaluated when the
include is done, but for the command line, it is included after reading the
whole makefile. However, by then, dir will be set to the last subdirectory
in my list.

How can I force make to do this otherwise?


I found the following (too long) work-around:

--- clean.mk ---
define clean_dir_target
clean_$(1):
        rm -f $(1)/*.oP
endef

$(eval $(call clean_dir_target,$(dir)))


that's not really readable, and seems to work only from make 3.80 anyway.
Any other suggestions?

thanks!


Kris Thielemans
Hammersmith Imanet
Cyclotron Building
Hammersmith Hospital
Du Cane Road
London W12 ONN, United Kingdom

web site address: http://www.hammersmithimanet.com/~kris





reply via email to

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