是否有一种方法可以使用本地的Makefile if-else条件,并使它尊重目标特定变量重新赋值?
示例Makefile:
#!/usr/bin/make
CONFIG = Debug
.PHONY: test printme
test: override CONFIG=Release
test: printme
@echo "Done."
printme:
ifeq "$(CONFIG)" "Debug"
@echo "should be DEBUG -> $(CONFIG)"
else
@echo "should be RELEASE -> $(CONFIG)"
endif
运行
make test
会输出以下内容:should be DEBUG -> Release
Done.
我需要的输出是
应该是 RELEASE -> Release
,我该如何实现呢?需要使用shell条件语句吗?
ifeq
时不存在,因此无法基本上考虑它们。您必须使用 shell 条件语句或在配方中使用$(if ...)
函数。 - MadScientist