Created
September 5, 2015 13:35
-
-
Save 0x5742/744bf31b54ffb501ade8 to your computer and use it in GitHub Desktop.
a wrapper for make that searches parent directories
This file contains hidden or 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 | |
| # I always felt 'make' ought to do this. | |
| # Search parent directories until Makefile is found, and build there. | |
| # All options are passed directly to make, with a possible -C if none exists. | |
| # (If -C or -f are given on the command line, no searching is done.) | |
| dir="." | |
| findparents=true | |
| for arg in "$@"; do | |
| case "$arg" in | |
| -C*|-f*) findparents=false ;; | |
| esac | |
| done | |
| while $findparents; do | |
| for fn in makefile Makefile; do | |
| if [ -e "$dir/$fn" ]; then | |
| #echo "==> $fn found in $dir" | |
| test $dir = '.' || set -- -C "$dir" "$@" | |
| break | |
| fi | |
| done | |
| if [ "$dir" -ef "$dir/.." ]; then | |
| break | |
| else | |
| dir="$dir/.." | |
| fi | |
| done | |
| exec ${MAKE:-make} "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment