I have a list defined in the make file and the user is supposed to set an environment variable which I need to find in this list. Is there a way using gnu make to do this? I want to do this outside any recipe, before make starts building any targets. It is a QA check to make sure user sets the env. variable to a value within a range/list.
On terminal:
setenv ENV_PARAM x
In Makefile:
PARAMS := a b c
if ${ENV_PARAM} exists in $(PARAMS)
true
else
false
endif
@MadScientist's answer works. Is there a way to wrap the if block with a foreach loop to test multiple parameters?
KEYS := PARAMS FACTORS
PARAMS := a b c
FACTORS := x y z
foreach v in ($(KEYS)) {
ifneq ($(filter $(ENV_$(v)),$(v)),)
$(info $(ENV_$(v)) exists in $(v))
else
$(info $(ENV_$(v)) does not exist in $(v))
endif
}