|
From: | John Graham-Cumming |
Subject: | Re: conditional macro definitions |
Date: | Tue, 22 Nov 2005 07:02:40 +0100 |
User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040208 Thunderbird/0.5 Mnenhy/0.6.0.104 |
bill wrote:
Thanks to everyone who responded to that question. I'm a little confused about how to deal with the issue that the conditionaldefinition seems to occur too late. In the following example, I modify the value of $(DIR) when the target is debug. But the target$(DIR) maintains the old value. So when I "make debug", there is no rule to build /tmp/debug. How do I make the conditional values betargets? % rmdir /tmp/foo % cat makefile DIR = /tmp/foo debug : DIR = /tmp/debug all: $(DIR) debug: all $(DIR): mkdir -p $@ ...
You can't do that and have it work! All the rule definitions get parsed and set when the Makefile is read. Hence the value of DIR used from the Makefile is first read (/tmp/foo) is used to define the rule for $(DIR) at the end of you Makefile.
My recommendation is that you live with the 'make DEBUG=1' style and then set DIR based on an ifeq before any rules that use $(DIR). You could use the MAKECMDGOALS that I also mentioned previously but to be honest I think that would be odd, and the 'make DEBUG=1' style is an idiom which most people understand.
John. -- John Graham-Cumming address@hidden Home: http://www.jgc.org/ POPFile: http://getpopfile.org/ GNU Make Standard Library: http://gmsl.sf.net/ Fast, Parallel Builds: http://www.electric-cloud.com/ Sign up for my Spam and Anti-spam Newsletter at http://www.jgc.org/ PGP key: http://www.jgc.org/pgp/
[Prev in Thread] | Current Thread | [Next in Thread] |