From the docs:
$?
The names of all the prerequisites that are newer than the target, with spaces between them.
So, given a makefile:
# Force make to search for 'foo' in the VPATH directory
$(shell rm -rf foo)
# If 'D' is a "regular" file, we remove it first.
$(shell rm -rf D)
$(shell mkdir D)
# Suggest a VPATH-file, for Make to "associate" with 'foo'.
$(shell touch D/foo)
$(shell sleep 1)
# Target 'all' is newer than prerequisite 'D/foo'
$(shell touch all)
VPATH = D
all : foo phony
echo '$?'
foo ::
touch '$@'
.PHONY: phony
.PRECIOUS : D/foo
And running, I get:
$ make -r
touch 'D/foo'
echo 'D/foo phony'
D/foo phony
# Try again, but this time, with parallel-execution mode.
$ make -r -j
touch 'D/foo'
echo 'phony'
phony
Here, we have 2 serious issues:
- Given the simple and explicit recipe to "touch" the prerequisite
foo
, which Make clearly executes - hence will guarantee thatfoo
will be "newer" thanall
- Make still does not expand$?
toD/foo
, at-least in the 2nd case above (i.e. for the parallel-execution (-j
) mode). Why? - If you come up with an explanation for the above, shouldn't it also explain, why in the 1st case (non-parallel execution),
$?
- does indeed - get expanded toD/foo
.
I guess, I had an assumption, that parallel vs. non-parallel aside, Make will always pause before executing a target, and first check if all of its prerequisites had already finished their respective builds.
So, shouldn't the $?
variable be identically expanded for both cases?