顯示具有 tools - make 標籤的文章。 顯示所有文章
顯示具有 tools - make 標籤的文章。 顯示所有文章

2010年6月5日 星期六

gmake之4.8 Special Built-in Target Names - .PRECIOUS


4.8 Special Built-in Target Names - .PRECIOUS
The targets which .PRECIOUS depends on are given the following special treatment: if make is killed or interrupted during the execution of their commands, the target is not deleted. See Section 5.6 [Interrupting or Killing make], page 49. Also, if the target is an intermediate file, it will not be deleted after it is no longer needed, as is normally done. See Section 10.4 [Chains of Implicit Rules], page 107. In this latter respect it overlaps with the .SECONDARY special target. You can also list the target pattern of an implicit rule (such as ‘%.o’) as a prerequisite file of the special target .PRECIOUS to preserve intermediate files created by rules whose target patterns match that file’s name.

簡單的說就是當make在執行某個target的時候,如果make被kill或者被interrupted(ctrl+c),那麼target file就會被刪除,如果加到.PRECIOUS就不會刪除。

brook@ubuntu:~$ more Makefile
#.PRECIOUS: obj/x.o
obj/x.o:
        gcc -c x.c -o obj/x.o
        sleep 5;
brook@ubuntu:~$ make -f Makefile
gcc -c x.c -o obj/x.o
sleep 5;
^Cmake: *** Deleting file `obj/x.o'
make: *** [obj/x.o] Interrupt

brook@ubuntu1:~$ more Makefile
.PRECIOUS: obj/x.o
obj/x.o:
        gcc -c x.c -o obj/x.o
        sleep 5;
brook@ubuntu1:~$ make -f Makefile
gcc -c x.c -o obj/x.o
sleep 5;
^Cmake: *** [obj/x.o] Interrupt

brook@ubuntu1:~/excerise/Make$



熱門文章