我有一個軟件堆棧,可以創建一些中間文件作爲構建過程的一部分。有一些問題出現,構建中斷。我想看看那些中間生成的文件。令我驚訝的是,這些文件作爲構建過程的一部分被刪除。如何撤銷中間文件刪除
Removing intermediate files...
rm fact_test_without_proxies.c fact_test_main.c fact_test_without_proxies.o
我經歷了Makefiles我沒有看到任何明確的規則刪除它們。是否有任何隱式規則來刪除中間文件。如果是,我怎麼能禁用這些隱式規則?
只有在使用--debug
選項執行make時,纔會看到打印Removing intermediate files...
。
[email protected]:~/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
謝謝,這確實有助於:) – Kamath 2012-03-12 05:33:00
不僅如此,使用.PRECIOUS意味着即使Make成功完成(即未被殺死或中斷),這些文件也不會被刪除。 「另外,如果目標是一箇中間文件,在不再需要它的時候不會被刪除,正如通常所做的那樣[...]在後一個方面,它與.SECONDARY特殊目標重疊。」 - https://www.gnu.org/software/make/manual/make.html – PonyEars 2014-06-19 00:50:28
+1:與'.SECONDARY'不同,這是POSIX:http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ make.html – 2015-03-18 05:09:07