Makefile考虑目标重制而不运行任何规则

时间:2017-06-12 21:13:09

标签: makefile

我在回答另一个问题 -  Dependency ordering error for multi-job make在SO上,我发布了以下makefile。 OP回复说,如果在命令行中没有指定-j,它就不会构建dir1/out/file.bar目标......感到困惑,我确认它可以与-j2一起使用但不是与-j1。我看了看,我没看到我错过了什么。我想我会把它发布在这里以防有人知道,因为我很好奇...

$(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

我正在运行make 3.81,OP正在使用3.82。我尝试使用make -d -j1 -r运行,然后获得以下代码段:

     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'.

它似乎认为它重新制作dir1 / out / file.bar,但它没有运行任何目标/食谱这样做......我想知道我错过了什么......

0 个答案:

没有答案