help-make
[Top][All Lists]
Advanced

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

Object files automatically deleted by pattern rule


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

Hello,

I have a simple Makefile which builds an executable using a pattern rule. When the target it built, make automatically removes the object files generated during the build process. How can I stop this? I've played around with having multiple targets and objects, and this behavior is robust. Also, changing the $(RM) variable has no effect.

Here is a sample Makefile which reproduces the problem:
-----------
all : hello.x

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

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

And the output:
--------------
gcc -c hello.c
gcc hello.o -o hello.x
rm hello.o
--------------

If I use the following Makefile instead:
-----------
hello.x: hello.o
        gcc $< -o $@

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

Then I get:
-----------
gcc -c hello.c
gcc hello.o -o hello.x
-----------

What gives?

Any help would be appreciated.  I am using GNU Make 3.81.

Thanks,
-Adam





reply via email to

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