Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kisom
Created August 31, 2017 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kisom/a589cc0cb3026d12624790122a212cd5 to your computer and use it in GitHub Desktop.
Save kisom/a589cc0cb3026d12624790122a212cd5 to your computer and use it in GitHub Desktop.
preflights in Makefiles
.PHONY: envdir
serve: envdir
$(eval ENVDIR := $(shell ./preflight.sh))
$(ENVDIR) /usr/local/myservice/env python -m SimpleHTTPServer 8000
#!/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