我必須在現有的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