-
-
Save Boldewyn/5575397 to your computer and use it in GitHub Desktop.
Search Makefiles recursively and run make(1) there, if one is found
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/bash | |
# | |
# Search Makefiles recursively and run make(1) there, if one is found | |
# | |
DEPTH=$(pwd | tr -c -d / | wc -c) | |
MOD=. | |
while [[ $DEPTH > 0 ]] | |
do | |
if [[ -f $MOD/Makefile ]] | |
then | |
if [[ $MOD == "." ]]; then | |
make "$@" | |
else | |
echo "make -C $MOD $@" | |
make -C $MOD "$@" | |
fi | |
exit 0 | |
fi | |
MOD=$MOD/.. | |
let DEPTH-- | |
done | |
echo "No Makefile found." >&2 | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What is missing is to detect another
-C
in themk
args and merge it with the-C
of the detected Makefile.