Skip to content

Instantly share code, notes, and snippets.

@ysugimoto
Last active February 3, 2018 06:02
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 ysugimoto/272abcb25d6874ada8bd632fe8eb1e02 to your computer and use it in GitHub Desktop.
Save ysugimoto/272abcb25d6874ada8bd632fe8eb1e02 to your computer and use it in GitHub Desktop.
Find up `Makefile` and run it
#!/bin/sh
MPATH=$PWD
MAKECOMMAND=$(which make)
if [ "${MAKECOMMAND}" = "" ]; then
echo "make command could't find in your \$PATH. Did you install it?"
exit 1
fi
while :; do
if [ -f "${MPATH}/Makefile" ]; then
break
elif [ "${MPATH}" = "/" ]; then
echo "Couldn't find up Makefile."
exit 1
fi
MPATH=$(cd "$(dirname "${MPATH}")"; pwd) || exit
done
cd "${MPATH}" && make "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment