help-make
[Top][All Lists]
Advanced

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

Re: Modification time versus existence


From: Brendan Heading
Subject: Re: Modification time versus existence
Date: Mon, 03 Mar 2008 22:03:25 +0000
User-agent: Thunderbird 2.0.0.12 (Windows/20080213)

Thanks, Paul. One of those should fit the bill.



Paul Smith wrote:
On Mon, 2008-03-03 at 17:55 +0000, Brendan Heading wrote:
Is there a way for me to get make to rebuild a target only if it does
not exist, and not merely when it's timestamp is updated ?

You could do something like:

        foo : $(if $(wildcard somefile),,somefile)

The $(if ...) will expand to empty if somefile exists, and "somefile" if
it doesn't.  This isn't quite the same as you asked for because it
requires changing the rules that depend on the target, rather than just
the target itself.

The example that I have in mind is that a certain file requires that a
certain directory exists; however, during the make, other files are
added to that same directory meaning that it's timestamp is updated.
Make then tries to remake the file even though the directory already
existed.

This is typically handled using order-only prerequisites, and declaring
the directory as .PHONY.  See the GNU make manual.






reply via email to

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