help-make
[Top][All Lists]
Advanced

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

Re: Modification time versus existence


From: Paul Smith
Subject: Re: Modification time versus existence
Date: Mon, 03 Mar 2008 13:00:58 -0500

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.

-- 
-----------------------------------------------------------------------------
 Paul D. Smith <address@hidden>                 http://make.mad-scientist.us
 "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]