[Top][All Lists]

[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: Fri, 08 Feb 2008 14:39:47 -0500
User-agent: Thunderbird (Macintosh/20071210)

That does exactly what I want it to do- thank you!

Greg Chicares wrote:
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


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 '$<'

        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

reply via email to

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