来自https://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html#Automatic-Variables 的
$?The names of all the prerequisites that are newer than the target, with spaces between them.
所以,给出一个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,我得到:
$ 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在这里,我们有两个严重的问题:
foo将比all“更新”-- Make not展开$?到D/foo,至少在上面的第二种情况下(即并行执行(-j)模式)。为什么?$? -确实做了-被扩展到D/foo。我想,我有一个假设,即并行还是非并行,使will 总是在执行目标之前暂停,first检查所有先决条件的是否已经完成了各自的构建。
那么,对于这两种情况,$?变量不应该进行相同的扩展吗?
发布于 2015-08-21 04:08:36
我认为这里有两个问题。
第一种是双冒号规则看起来像假目标,因为它们强迫make将目标视为“更新”,而不考虑实际的修改时间。(这就是为什么非并行版本的行为方式。)从foo ::更改为foo :,在$?输出中根本没有foo。)
第二件事是,尽管如此,使用并行模式似乎迫使make重新考虑其先决条件的修改时间(因此避免了以前的行为)。
这是猜测,也不是确定的,因为我还没有深入研究代码,看看是否真的发生了这种情况,但它解释了这里的结果(它还解释了另一个几乎相同的这里问题的结果)。
https://stackoverflow.com/questions/32131796
复制相似问题