help-make
[Top][All Lists]
Advanced

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

Re: phony targets and dependency files (*.d)


From: Paul D. Smith
Subject: Re: phony targets and dependency files (*.d)
Date: Tue, 6 Nov 2001 09:24:33 -0500

> The problem is that the phony target ultraclean, always insists on
> creating the *.d files if they don't exist.

Certainly.

This doesn't have anything to do with phony targets.

The whole idea behind this method is based on this behavior: after make
includes a file, or if it can't find a file that it wants to include, it
checks to see if it can be rebuilt.  If it can, make rebuilds it and
after it's done rebuilding all the makefiles it re-execs itself.

This all happens long, long before it tries to run the "ultraclean"
rule, and even if it didn't there's no way make can know that the rule
will just delete them again.


What you want to do is have make not perform the "include" step if the
user has specified the "ultraclean" rule; that way make won't try to
rebuild the included files.

You can do this by using ifeq or ifneq or whatever and checking the make
variable $(MAKECMDGOALS) to see whether the user asked for "ultraclean";
only if they didn't would you "include" the .d files.


However, there's a better way to handle automatic dependencies than
this, where all of this is unnecessary.  See my web page below.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://www.paulandlesley.org/gmake/
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist



reply via email to

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