Makefile目标无法识别依赖项操作

时间:2020-01-15 14:46:37

标签: makefile

我写了这个简单的Makefile来说明我的问题。

$make target
  • dep称为依赖项并提取图像
  • 但是对docker image list -q $(IMG)后续检查未找到我的图片。

这是怎么回事,我该如何解决?


IMG := hello-world

.PHONY: target
target: dep
ifeq ($(shell docker image list -q $(IMG)),)
        echo "docker image list did not recognize the pull"
endif

.PHONY: dep
dep:
        @docker pull $(IMG)

1 个答案:

答案 0 :(得分:1)

该测试不是后续。在执行任何规则之前,将其替换到Makefile中。

您可能想在List<Integer> arr = new ArrayList<>(); for (int i=1; i<=n; i++) { arr.add(sc.nextInt()); } 规则的命令中执行该测试:

target

我们可以将命令更改为只运行target: dep if test -z "$$(docker image list -q $(IMG))"; then \ echo "docker image list did not recognize the pull" >&2; \ false; \ fi -如果图像存在,它将返回true状态,​​否则返回false:

docker image inspect