[英]Makefile base target and its dependent
我有一個make結構像:
base :
build.sh base.output
//# if base.output is newer than sub-base.output by 1 minute then build the below -- How do i do this ?
sub-base :
build.sh sub-base.output
基本上,如果基本文件夾/目標更改,則需要構建所有從屬文件夾/目標。
我當時正在考慮編寫一個shell腳本來檢查時間戳,但是makefile提供了更好的方法嗎?
這是makefile的作用。 這是他們的目的。
只需將以下內容用作您的makefile。
base.output:
build.sh base.output
sub-base.output: base.output
build.sh sub-base.output
然后運行make base.output
將運行該配方,並且make sub-base.output
將運行build.sh sub-base.output
但是僅當sub-base.output
早於base.output
。
您還應該在其目標行上列出base.output
所有先決條件,以使make正確處理它。
或者,如果沒有,則需要使用force target 。
FORCE: ;
base.output: FORCE
build.sh base.output
強制make建立base.output
即使它已經存在。
如果你想保持能力說make base
或make sub-base
,那么你需要偽目標為那些為好。
.PHONY: base sub-base
base: base.output
sub-base: sub-base.output
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.