所以,我有一个带有2个模式规则的Makefile,其中一个是终端Match-Anything;目标是about.html
(例如):
vpath %.md $(SOURCE_DIR)
HEADER := assets/navbar.part
%.html : %.md $(HEADER)
pandoc [...] $< -o $@
%::
cp $(SOURCE_DIR)/$@ $@
如果我执行make assets/navbar.part
,然后执行make about.html
(例如),一切正常(navbar.part
使用匹配任何东西,而about.html使用第一个规则)。但如果我尝试make about.html
没有navbar.part
存在,make
做:
我期待make
会:
从阅读调试跟踪,似乎Make永远不会真正尝试满足$(HEADER)
先决条件:
Considering target file 'about.html'.
File 'about.html' does not exist.
Looking for an implicit rule for 'about.html'.
Trying pattern rule with stem 'about'.
Trying implicit prerequisite 'about.md'.
Found prerequisite 'about.md' as VPATH '../website/about.md'
Trying rule prerequisite 'assets/navbar.part'.
Trying pattern rule with stem 'about.html'.
Found an implicit rule for 'about.html'.
Considering target file 'about.md'.
Finished prerequisites of target file 'about.md'.
No need to remake target 'about.md'; using VPATH name '../website/about.md'.
Finished prerequisites of target file 'about.html'.
Must remake target 'about.html'.
cp -f ../website/about.html about.html
有任何想法吗?
在挖掘手册后,我发现section 10.8说:
对于列表中的每个模式规则:
因为$(HEADER)不符合ought to exist
的定义:
它失败;然而,如果我们尝试make
专门$(HEADER),然后尝试make about.html
它成功,它成功,因为那时$(HEADER)是一个现有的文件。