Created
September 29, 2012 18:57
-
-
Save ChimeraCoder/3804898 to your computer and use it in GitHub Desktop.
Test for environment variable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Taken from | |
#http://stackoverflow.com/questions/4728810/makefile-variable-as-prerequisite | |
#Remember that each make target is run within a separate sub-shell, which defaults to sh (not bash) | |
#so bash-specific default environment variables like $HOSTNAME will *not* be accessible *unless* | |
# they are exported *before* `make' is run; ie, `export HOSTNAME=$HOSTNAME' | |
change-hostname: assertenvar-USER assertenvar-TESTVAR assertenvar-HOSTNAME assertenvar-TEF | |
assertenvar-%: | |
@if [ -z ${${*}} ] ; then \ | |
echo "Environment variable $* not set"; \ | |
exit 1; \ | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment