bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: Automatically removed temporary object files


From: Micah Cowan
Subject: Re: Automatically removed temporary object files
Date: Fri, 06 Jun 2008 10:38:58 -0700
User-agent: Thunderbird 2.0.0.14 (X11/20080505)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Frank wrote:
> I've a problem that temporary object files are deleted, which I do not
> want.
> 
> Example:
> 
> Makefile:
> 
> OBJECTS = A.o B.o C.o
> 
> %.exe: %.c $(OBJECTS)
>     gcc $< $(OBJECTS) -o $@
> 
> %.o: %.c
>     gcc -c $< -o $@
> 
> Calling:
> 
> $ make test.exe
> 
> results in:
> 
> gcc -c A.c -o A.o
> gcc -c B.c -o B.o
> gcc -c C.c -o C.o
> gcc test.c A.o B.o C.o -o test.exe
> rm A.o B.o C.o
> 
> Please, watch the last line: There is an 'rm' which I did not write in
> the makefile.
> How can I disable that? It does not make sense to compiler A, B, and C
> over and over again if test.c changes.

Hi Frank. Please have a look at the .PRECIOUS and .SECONDARY targets at
http://www.gnu.org/software/make/manual/html_node/Special-Targets.html#Special-Targets
(but you want .SECONDARY, not .PRECIOUS, as the latter won't delete
them, even if they don't finish compiling, meaning it will keep garbage).

For a deeper understanding of why it's happening, and other ways you
might avoid it (such as explicit rules), see
http://www.gnu.org/software/make/manual/html_node/Chained-Rules.html

- --
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer,
and GNU Wget Project Maintainer.
http://micah.cowan.name/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFISXYy7M8hyUobTrERAmw0AJ0VR+DFclSqnF/bc2GQA/HcVBHfYQCgjjWN
HVTvMiWewZD6p8ujidBR004=
=qF3p
-----END PGP SIGNATURE-----




reply via email to

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