Skip to content

Instantly share code, notes, and snippets.

@rlespinasse
Last active September 26, 2020 10:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rlespinasse/d20168b330e249f467c2a59054b032a9 to your computer and use it in GitHub Desktop.
Save rlespinasse/d20168b330e249f467c2a59054b032a9 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
@rebornwwp
Copy link

good things. thanks very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment