help-make
[Top][All Lists]
Advanced

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

Re: Object files automatically deleted by pattern rule


From: Adam Lichtl
Subject: Re: Object files automatically deleted by pattern rule
Date: Wed, 06 Feb 2008 18:57:44 -0500
User-agent: Thunderbird 1.5.0.14 (Macintosh/20071210)

If possible, I'd like to preserve a class of files matching a pattern (such as all object files). I agree that I don't want them to be preserved if the build is interrupted. Would this do the trick?:

OBJ := hello.o

.SECONDARY: $(OBJ)

Or is there some more suave trick where I don't have to compile a list of all of my object files? This solution is fine, though, because my production Makefile already does have a list of the objects which it uses in the "clean" target.

-Adam

Paul Smith wrote:
On Wed, 2008-02-06 at 17:34 -0500, Adam Lichtl wrote:
Ah- great!  I was also reading up on .SECONDARY with no
prerequisites, but I suppose I should be specific and save just my object files with:

.PRECIOUS: %.o

Note that all you HAVE to do is mention the file you want to preserve
SOMEWHERE in the makefile, as a target _or_ prerequisite.

As soon as you do that, even if that rule is never used for anything,
the target won't be deleted.

.PRECIOUS is not exactly what you want, I think, because it says too
much.  Not only will it preserve the target on exit, but it will ALSO
preserve the target if make is interrupted or whatever.  This can lead
to incorrect builds, because the target will only be half-created but
since it exists and has a new timestamp, make won't try to recreate it.
Depending on the type of target and what you do with it, the failure
caused by this could be very subtle.

YMMV.





reply via email to

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