【发布时间】:2017-12-20 16:39:58
【问题描述】:
所以,我有一个带有 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 使用第一条规则)。但是,如果我在没有navbar.part 的情况下尝试make about.html,make 会:
- 找到先决条件 about.md
- ??放弃履行 $(HEADER)
- 尝试使用 matchany 规则生成 about.html
我期待 make 会:
- 找到先决条件 about.md
- 使用 match-anything 规则创建先决条件 $(HEADER)
- 满足所有先决条件后,最后执行第一条规则
从阅读调试跟踪来看,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
有什么想法吗?
【问题讨论】: