Created
August 31, 2017 04:09
-
-
Save kisom/a589cc0cb3026d12624790122a212cd5 to your computer and use it in GitHub Desktop.
preflights in Makefiles
This file contains 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
.PHONY: envdir | |
serve: envdir | |
$(eval ENVDIR := $(shell ./preflight.sh)) | |
$(ENVDIR) /usr/local/myservice/env python -m SimpleHTTPServer 8000 |
This file contains 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
#!/bin/sh | |
TARGET="${1:-envdir}" | |
PACKAGE="${PACKAGE:-${TARGET}}" | |
TARGET_PATH="$(command -v ${TARGET} 2>/dev/null)" | |
if [ -n "${TARGET_PATH}" ] | |
then | |
echo "${TARGET_PATH}" | |
exit 0 | |
else | |
echo "${TARGET} missing, attempting to install." > /dev/stderr | |
case "$(uname -o)" in | |
GNU/Linux) | |
sudo apt-get install "${PACKAGE}" ;; | |
Darwin) | |
brew install "${PACKAGE}";; | |
*) | |
echo "$(uname -o) isn't implemented yet; PR maybe?" > /dev/stderr ;; | |
esac | |
# You need to exit, otherwise all of the package output will be captured | |
# in stdout. | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment