views:

87

answers:

1

I have the following GNU makefile:

.PHONY a b c d

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

I would like the target 'd' to be run twice -- since it is specified as a dependency by both b & c. Unfortunately, the target 'd' will be executed only once. The output of running make will simply be 'HI', instead of 'HI HI'.

How can I fix this?

Thanks!

To Clarify, the goal is something like this:

subdirs =  a b c

build: x y

x: target=build
x: $(subdirs)

y: target=prepare
y: $(subdirs)

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

Are you trying to do something like this:

.PHONY: a b c

define print-hi
@echo HI
endef

a: b c
b:
    $(print-hi)
c:
    $(print-hi)
Karl Voigtland
Not quite. More something like this:subdirs = a b cbuild: x yx: target=buildx: $(subdirs)y: target=preparez: $(subdirs)$(subdirs): $(make) -f $@/makefile $(target)