I'm trying to require that an environment variable be set in a Makefile when running a specific target. I'm using the technique from the answer to this question, where you setup another target that will guarantee an environment variable to be set.
Mine looks like this:
require-%:
@ if [ "${${*}}" = "" ]; then \
$(error You must pass the $* environment variable); \
fi
With that target setup, this is expected:
$ make require-FOO
Makefile:3: *** You must pass the FOO environment variable. Stop.
However, when testing, I can never get it to not error:
$ make require-FOO FOO=something
Makefile:3: *** You must pass the FOO environment variable. Stop.
$ make require-FOO FOO=true
Makefile:3: *** You must pass the FOO environment variable. Stop.
$ make require-FOO FOO='a string'
Makefile:3: *** You must pass the FOO environment variable. Stop.
Even when I comment out the if
block in the target:
require-%:
# @ if [ "${${*}}" = "" ]; then \
# $(error You must pass the $* environment variable); \
# fi
I still get an error when running it:
$ make require-FOO FOO=something
Makefile:3: *** You must pass the FOO environment variable. Stop.
What's am I doing wrong? How can I get this to work?