Last active
March 15, 2019 07:22
-
-
Save iberianpig/c1f63d1f5bc48ddb9405840e7fb75518 to your computer and use it in GitHub Desktop.
`makef` override original ./Makefile with $MAKEF_PATH
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
function makef() { | |
make -f "$(makef_path)" "$@" | |
} | |
_makef() | |
{ | |
COMPREPLY=( $(compgen -W "$(grep -oE '^[a-zA-Z0-9_-]+:([^=]|$)' "$(makef_path)" | sed 's/[^a-zA-Z0-9_.-]*$//')" $2) ) | |
} | |
complete -F _makef makef | |
makef_path() | |
{ | |
local path | |
if [ -a "$MAKEF_PATH" ]; then | |
if [ -a ./Makefile ]; then | |
path=$(tempfile) | |
cat ./Makefile "$MAKEF_PATH" > "$path" | |
else | |
path="$MAKEF_PATH" | |
fi | |
elif [ -a ./Makefile ]; then | |
path="./Makefile" | |
fi | |
echo $path | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment