List Info

Thread: Modification time versus existence




Modification time versus existence
country flaguser name
United Kingdom
2008-03-03 11:55:55
Hi, 

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 ? 

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. 

regards 

Brendan 



_______________________________________________
Help-make mailing list
Help-makegnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make

Re: Modification time versus existence
user name
2008-03-03 12:00:58
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 <psmithgnu.org>                
http://make.mad-scientis
t.us
 "Please remain calm--I may be mad, but I am a
professional."--Mad Scientist






_______________________________________________
Help-make mailing list
Help-makegnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make

Re: Modification time versus existence
country flaguser name
United Kingdom
2008-03-03 16:03:25
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.
> 



_______________________________________________
Help-make mailing list
Help-makegnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )