In a Makefile, a deploy
recipe needs a environment variable ENV
to be set to properly execute itself, whereas others don\'t care, e.g.:
You can create an implicit guard target, that checks that the variable in the stem is defined, like this:
guard-%:
@ if [ "${${*}}" = "" ]; then \
echo "Environment variable $* not set"; \
exit 1; \
fi
You then add a guard-ENVVAR
target anywhere you want to assert that a variable is defined, like this:
change-hostname: guard-HOSTNAME
./changeHostname.sh ${HOSTNAME}
If you call make change-hostname
, without adding HOSTNAME=somehostname
in the call, then you'll get an error, and the build will fail.