On 2008-02-06 23:57Z, Adam Lichtl wrote:
> 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?

Returning to your original example, which was:

all : hello.x

%.x: %.o
        gcc $< -o $@

%.o: %.c
        gcc -c $<

First add this line:

hello.x: hello.o

and the '.o' file won't routinely be removed.

Then you don't need to specify a prerequisite for the '%.x'
rule; and you might want to use '$^' there instead of '$<'

%.x:
        gcc $^ -o $@

so that it'll work for another '.x' file built from several
source files, e.g.

hello_goodbye.x: hello.o goodbye.o



_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to