I was answering another question --
Dependency ordering error for multi-job make on SO, and I posted the following makefile. The OP replied back saying if -j
wasn't specified on the command line, it wouldn't build the dir1/out/file.bar
target... Perplexed, I verified that it works with -j2
but not with -j1
. I've looked it over, and I'm not seeing what I missed. I thought I'd post it here in case someone knows, as I'm very curious...
$(shell mkdir dir1 >& /dev/null; touch dir1/file.foo; \
mkdir dir2 >& /dev/null; touch dir2/file.foo)
OUTDIRS = dir1/out dir2/out
OUTPUTS = dir1/out/file.bar dir2/out/file.bar
.DEFAULT_GOAL := all
$(OUTPUTS) : | $(OUTDIRS)
$(OUTDIRS) :
@echo "making $@"
sleep 1
mkdir -p $@
@echo "done making $@"
%.bar : ../%.foo
@echo "copying $< to $@"
@cp $< $@
all : outputs
@echo "done $@"
outputs : $(OUTPUTS)
@echo "created all output files"
clean :
@rm -rf dir1 dir2
I am running make 3.81, and OP was using 3.82. I tried running with make -d -j1 -r
, and I get the following snippet:
Finished prerequisites of target file `dir1/out/file.bar'.
Must remake target `dir1/out/file.bar'.
Successfully remade target file `dir1/out/file.bar'.
Considering target file `dir2/out/file.bar'.
File `dir2/out/file.bar' does not exist.
Considering target file `dir2/out/../file.foo'.
Finished prerequisites of target file `dir2/out/../file.foo'.
No need to remake target `dir2/out/../file.foo'.
Pruning file `dir1/out'.
Pruning file `dir2/out'.
Finished prerequisites of target file `dir2/out/file.bar'.
Must remake target `dir2/out/file.bar'.
copying dir2/out/../file.foo to dir2/out/file.bar
Successfully remade target file `dir2/out/file.bar'.
It seems to think it remade dir1/out/file.bar, but it didn't run any targets/recipes to do so... I'm wondering what I missed...