5

次の GNU makefile があります。

.PHONY a b c d

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

ターゲット 'd' を 2 回実行したいと思います。これは、b と c の両方で依存関係として指定されているためです。残念ながら、ターゲット 'd' は 1 回しか実行されません。実行中の 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 に答える