我的目標是生成一個文件(MyOut.elf)和,如果這個文件生成,生成其他兩個文件(MyOut.s19和size.txt)依賴於該文件。make:.SECONDARY目標打破buld
我在makefile文件相當多的新手,但我寫了下面:
.DEFAULT_GOAL := full
full: MyOut.elf MyOut.s19 size.txt
@echo TARGET
# Tool invocations
MyOut.s19: MyOut.elf
@echo 'Building S19 : [email protected]'
@echo 'MyOut.s19: MyOut.elf' > MyOut.s19
@echo 'Finished building target: [email protected]'
@echo ' '
size.txt: MyOut.elf
@echo 'Building section size summary : [email protected]'
@echo 'size.txt: MyOut.elf' > size.txt
@echo 'Finished building target: [email protected]'
@echo ' '
all: MyOut.elf
MyOut.elf:
@echo 'Building ELF: [email protected]'
@echo 'MyOut.elf' > MyOut.elf
@echo 'Finished building target: [email protected]'
@echo ' '
.PHONY: full
#.SECONDARY:
現在,如果我跑make
,一切正常:
> make
Building ELF: MyOut.elf
Finished building target: MyOut.elf
Building S19 : MyOut.s19
Finished building target: MyOut.s19
Building section size summary : size.txt
Finished building target: size.txt
TARGET
相反,如果我取消註釋最後一行.SECONDARY:
,依賴鏈似乎「中斷」,因爲它在第一個目標(MyOut.elf)後停止:
> del *.elf
> make
Building ELF: MyOut.elf
Finished building target: MyOut.elf
TARGET
然後,如果我運行make再次,依賴文件MyOut.s19
和size.txt
內置:
> make
Building S19 : MyOut.s19
Finished building target: MyOut.s19
Building section size summary : size.txt
Finished building target: size.txt
TARGET
所以,我的問題是:
- 這究竟是爲什麼?
- 我該如何克服這個問題? (注:我不能去除.SECONDARY指令,因爲這是由Eclipse將自動生成的生成文件的一部分)
當您刪除'* .elf'時,如果您還從前一個make run中刪除了另外兩個文件,會發生什麼? – Kusalananda
@Kusalananda:如果我刪除所有的輸出文件,所有三個都正確重建。 – Nova
...如果你取消註釋'.SECONDARY:',刪除'elf'文件並運行make,全部都被重建? – Kusalananda