Skip to content

Instantly share code, notes, and snippets.

@rebornwwp
Forked from rlespinasse/Makefile
Created September 26, 2020 10:26
Show Gist options
  • Save rebornwwp/9ba6f9446f7c30d8b349be3636eb7720 to your computer and use it in GitHub Desktop.
Save rebornwwp/9ba6f9446f7c30d8b349be3636eb7720 to your computer and use it in GitHub Desktop.
guard-makefile
task-who-need-specific-envvar: guard-SPECIFIC_ENVVAR
@echo ${SPECIFIC_ENVVAR}
guard-%:
@ if [ "${${*}}" = "" ]; then \
echo "Environment variable $* not set"; \
exit 1; \
fi
# $ make task-who-need-specific-envvar
# Environment variable SPECIFIC_ENVVAR not set
# make: *** [guard-SPECIFIC_ENVVAR] Error 1
# $ make task-who-need-specific-envvar SPECIFIC_ENVVAR=value
# value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment