Skip to content

Instantly share code, notes, and snippets.

@blackandred
Created October 11, 2018 04:54
Show Gist options
  • Save blackandred/584544839d7634bf3e5e5fb09f6e509a to your computer and use it in GitHub Desktop.
Save blackandred/584544839d7634bf3e5e5fb09f6e509a to your computer and use it in GitHub Desktop.
Makefile template
.SILENT:
# Colors
COLOR_RESET = \033[0m
COLOR_INFO = \033[32m
COLOR_COMMENT = \033[33m
## This help screen
help:
printf "${COLOR_COMMENT}Usage:${COLOR_RESET}\n"
printf " make [target]\n\n"
printf "${COLOR_COMMENT}Available targets:${COLOR_RESET}\n"
awk '/^[a-zA-Z\-\_0-9\.@]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " ${COLOR_INFO}%-16s${COLOR_RESET}\t\t%s\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
## This is a task description
some_task:
echo "Hello"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment