我的 Makefile
是:
.PHONY: check
check:
ifneq $(shell echo 123), $(shell echo 123)
$(error Not equal)
endif
当我运行时,出现错误:
$ make
Makefile:3: *** Not equal. Stop.
但这应该仅在它们不同时才发生,但事实并非如此。为什么?
最佳答案
ifneq
不能缩进。按照您编写的方式,它是通过 shell 命令运行的,这意味着 $(error)
make 命令首先评估。
我猜你想要 make check
仅在 make check
时才实际运行两个命令被调用,并比较它们的输出。你可以做:
.PHONY: check
check:
if [ "`echo 123`" != "`echo 123`" ]; then \
echo "Not equal"; \
exit 1; \
fi
关于shell - 如何比较Makefile中的两个shell命令输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36346340/