Created
March 25, 2020 15:12
-
-
Save sirn/6a2f4c0b1cb917ef54b1fb813330d8e8 to your computer and use it in GitHub Desktop.
Making Makefile Awesome
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
help: | |
@: # Print this help | |
@printf 'Usage: make TARGET\n\n' | |
@printf 'You must run make with one of the following targets to continue:\n' | |
@printf 'Run make VERBOSE=1 TARGET for verbose log.\n' | |
@awk ' \ | |
/^[^\t:]+:/ { \ | |
split($$0, s, ":"); \ | |
cmd=s[1]; \ | |
} /^\t@: #/ { \ | |
split($$0, t, ": # "); \ | |
body=t[2]; \ | |
doprnt=1; \ | |
} { \ | |
if (doprnt == 1) { \ | |
if (cmd != "") { \ | |
printf("\n\033[33m%s\033[0m:\n", cmd); \ | |
cmd="" \ | |
}; \ | |
printf("\t%s\n", body); \ | |
doprnt=0; \ | |
body=""; \ | |
}; \ | |
} \ | |
' Makefile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For VERBOSE=1 to work, you need this somewhere in Makefile: