Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to undo intermediate file deletion

Tags:

makefile

I have a software stack that creates some intermediate files as a part of build process. There is some problem come up and the build breaks. I want to have a look at those intermediate generated files. To my surprise those files are being deleted as a part of build process.

Removing intermediate files... rm fact_test_without_proxies.c fact_test_main.c fact_test_without_proxies.o 

I went through the Makefiles I don't see any explicit rules deleting them. Can there be any implicit rules to delete intermediate files. If yes how can I disable those implicit rules ?

I see the print Removing intermediate files... only if make is executed with --debug option.

skmt@tux:~/coding/factorial/ut$ make --debug GNU Make 3.81 Copyright (C) 2006  Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  This program built for x86_64-pc-linux-gnu Reading makefiles... Updating goal targets....  File `check' does not exist.    File `test_dept_run' does not exist.      File `fact_test' does not exist.        File `fact_using_proxies.o' does not exist.            File `fact_test_without_proxies' does not exist.             File `fact_test_without_proxies.o' does not exist.              File `fact_test_without_proxies.c' does not exist.               File `fact_test_main.c' does not exist.              Must remake target `fact_test_main.c'. nm -p fact_test.o | build_main_from_symbols >fact_test_main.c              Successfully remade target file `fact_test_main.c'.             Must remake target `fact_test_without_proxies.c'. cp fact_test_main.c fact_test_without_proxies.c             Successfully remade target file `fact_test_without_proxies.c'.            Must remake target `fact_test_without_proxies.o'. gcc  -I../src  -c -o fact_test_without_proxies.o fact_test_without_proxies.c            Successfully remade target file `fact_test_without_proxies.o'.           Must remake target `fact_test_without_proxies'. gcc   fact_test_without_proxies.o fact.o fact_test.o   -o fact_test_without_proxies fact.o: In function `unknown': fact.c:(.text+0x67): undefined reference to `do_update' collect2: ld returned 1 exit status make: *** [fact_test_without_proxies] Error 1 Removing intermediate files... rm fact_test_without_proxies.c fact_test_main.c fact_test_without_proxies.o 
like image 435
Kamath Avatar asked Mar 09 '12 17:03

Kamath


1 Answers

If you're using GNUMake, you can use the special target .PRECIOUS:

.PRECIOUS: fact_test_without_proxies.c fact_test_main.c fact_test_without_proxies.o 

or just

.PRECIOUS: %.c %.o 

Its only effect is that these files will not be deleted if Make is killed or interrupted.

like image 188
Beta Avatar answered Oct 18 '22 16:10

Beta