我有一个 Makefile:
#Build Configurations
CONFIGS = Debug Release Profile
#Config flags
Debug_Flags=dasd
Release_Flags=
.SECONDEXPANSION:
#Debug_safety_check Release_safety_check Profile_safety_check targets
$(addsuffix _safety_check,$(CONFIGS)):
#Check existence of variable
ifeq '$(origin $(subst safety_check,FLAGS,$@))' 'undefined'
$(error $(subst safety_check,FLAGS,$@) variable undefined)
endif
#How to make our configurations (do corresponding safety_checks)
$(CONFIGS): $$@_safety_check
此行不正确:
ifeq '$(origin $(subst safety_check,FLAGS,$@))' 'undefined'
我认为,这是因为在调用相应的安全检查时发生了 $@扩展。但是 ifeq 扩展“立即”发生,所以,事实上,我们得到这样的行:
ifeq '$(origin ' ') 'undefined'
是否存在某种从列表中检查变量定义的方法?