5

我有以下 GNU 生成文件:

.PHONY a b c d

a: b c
b: d
c: d
d:
    echo HI

我希望目标“d”运行两次——因为它被 b & c 指定为依赖项。不幸的是,目标“d”只会执行一次。运行 make 的输出将只是“HI”,而不是“HI HI”。

我怎样才能解决这个问题?

谢谢!

为了澄清,目标是这样的:

subdirs =  a b c

build: x y

x: target=build
x: $(subdirs)

y: target=prepare
y: $(subdirs)

$(subdirs):
    $(make) -f $@/makefile $(target)
4

2 回答 2

3
build: x y

x: target=build
y: target=prepare

x y: 
    echo hi $(target) $@
    touch $@

另请参阅GNU Makefile 规则从单个源文件生成几个目标,因为它是对与此相反的问题的答案。

于 2011-01-10T12:28:17.103 回答
1

你是否试图做这样的事情:

.PHONY: a b c

define print-hi
@echo HI
endef

a: b c
b:
    $(print-hi)
c:
    $(print-hi)
于 2009-08-02T03:00:49.860 回答