I have a tool which generates multiple output files, which is notoriously hard to model in make. I'm using the recipe at GNU Makefile rule generating a few targets from a single source file, which seems simple and reliable. And it almost works.
Unfortunately, I'm seeing some very odd behaviour with regard to parallel builds, where it seems to be dropping dependencies sometimes; and I don't understand why.
Here's my test case:
out3: out1 out2
touch out3
.INTERMEDIATE: out.intermediate
out1 out2: out.intermediate
out.intermediate: in
touch out1 out2
If I build it once, it works:
$ touch in
$ make -f test.mk out3 -j4
touch out1 out2
touch out3
out1
and out2
are built together, once, which is good; then out3
is built from the result.
Now I touch the input file, simulating an incremental build, and try again:
$ touch in
$ make -f test.mk out3 -j4
touch out1 out2
That's rebuild out1
and out2
, correctly... but it hasn't rebuilt out3
, which it should have. Then if I do another build:
$ make -f test.mk out3 -j4
touch out3
...and it catches up.
This only applies to parallel builds. -j1
builds work fine.
This is bad --- I need to be able to rely on correct builds. Does anyone have any idea as to what's going on?
This is GNU Make 4.1.