我按以下方式构建了makefile。
.PHONY: DEPTARG1 DEPTARG2
$(info BUILD_AGAIN is $(BUILD_AGAIN))
TARGET: DEPTARG1 DEPTARG2
ifeq ($(BUILD_AGAIN),y)
DEPTARG1:
@echo Building $@
DEPTARG2:
@echo Building $@
endif
如果 BUILD-AGAIN 为 n,我预计此 makefile 会引发错误,因为它没有可用的依赖项。但它没有。欢迎任何想法。
作为附加信息, DETARG1和DEPTARG2是虚假目标。
BUILD_AGAIN 为 y 时的输出
BUILD_AGAIN is y
Building DEPTARG1
Building DEPTARG2
BUILD_AGAIN 为 n 时的输出
BUILD_AGAIN is n
make: Nothing to be done for `TARGET'.