我必须在现有的Makefile
中集成许多HTML文件的生成。 问题是HTML文件需要驻留在许多不同的目录中。 我的想法是写的源文件(* .ST)转换为相应的HTML文件GNU make有许多目标目录
%.html: %.st
$(HPC) -o [email protected] $<
,并依赖于所有的HTML文件
all: $(html)
如果HTML规则的隐含规则文件不在builddir中make
未找到隐含规则:*** No rule to make target
。 如果我改变,像这样
$(rootdir)/build/doc/2009/06/01/%.html: %.st
$(HPC) -o [email protected] $<
它的发现隐含的规则,但我必须有一个隐含的规则在项目几乎每一个文件。 根据在GNU make
手动Implicit Rule Search Algorithm,规则搜索的工作原理是这样的:
- t分裂成目录部分,称为d,其余的,所谓的ñ。例如,对于 示例,如果t是
src/foo.o', then d is
src /'且n是`foo.o'。- 列出其中一个目标匹配t或n的所有模式规则。 如果目标模式包含一个 斜线,则它与t相匹配; 否则,针对n。
为何隐含规则没有找到,什么是最优雅的解决方案,假设GNU make
使用?
这里是我的Makefile
一个精简版:
rootdir = /home/user/project/doc
HPC = /usr/local/bin/hpc
html = $(rootdir)/build/doc/2009/06/01/some.html
%.html: %.st
$(HPC) -o [email protected] $<
#This works, but requires a rule for every output dir
#$(rootdir)/build/doc/2009/06/01/%.html: %.st
# $(HPC) -o [email protected] $<
.PHONY: all
all: $(html)
这可行,但不幸的是源布局是固定的,真正的Makefile使用VPATH。 – 2009-06-01 09:44:50