I have a question regarding the GNU makefile example below:
.PHONY: $(subdirs) build x y
subdirs = a b c
build: x y
x: target=prepare
x: $(subdirs)
y: target=build
y: $(subdirs)
$(subdirs):
$(make) -f $@/makefile $(target)
When I run make, I expect make to be called for each sub-directory specifying the target 'prepare' then the target 'build'. Unfortunately, the $(subdirs) target executes once (making the 'prepare' target), but doesn't execute again for the 'build' target.
It appears that for rule x, make determines the $(subdirs) target needs to be run, but for rule y, the $(subdirs) target is up-to-date.
Is there any way to fix this?
Thanks!