所以,我有一个带有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
有什么想法吗?
答案 0 :(得分:1)
在挖掘手册后,我发现section 10.8表示:
对于列表中的每个模式规则:
因为$(HEADER)不符合ought to exist
的定义:
make
专门用$(HEADER),然后尝试make about.html
它就会成功,因为当时$(HEADER)是一个现有文件。