Skip to content

Instantly share code, notes, and snippets.

@iserdmi
Created May 31, 2022 12:24
Show Gist options
  • Save iserdmi/395e0406bcfc563a0f1128e1a8055bb5 to your computer and use it in GitHub Desktop.
Save iserdmi/395e0406bcfc563a0f1128e1a8055bb5 to your computer and use it in GitHub Desktop.
Call Makefile from child directory
m() {
findfiledir() {
if [ -f "$1" ]; then
echo "$PWD"
elif [ "$PWD" = / ]; then
false
else
(cd .. && findfiledir "$1")
fi
}
initdir=$(pwd)
makefiledir=$(findfiledir Makefile)
if [ -n "$makefiledir" ]; then
cd "$makefiledir"
make "$@"
cd "$initdir"
else
echo "Makefile does not exists in parent directories"
fi
}
@iserdmi
Copy link
Author

iserdmi commented May 31, 2022

echo "\n`curl https://gist.githubusercontent.com/iserdmi/395e0406bcfc563a0f1128e1a8055bb5/raw/4cf6ee1fb4fddaa21d8175d3ed2ba3fd561f6158/m.sh`" >> ~/.bashrc

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