Skip to content

Instantly share code, notes, and snippets.

@distractdiverge
Last active March 27, 2020 16:59
Show Gist options
  • Save distractdiverge/277b25c3ee567b3cae8219ccd153d261 to your computer and use it in GitHub Desktop.
Save distractdiverge/277b25c3ee567b3cae8219ccd153d261 to your computer and use it in GitHub Desktop.
Self-Documenting Makefile
# Colors -- https://www.linuxjournal.com/article/8603
BLACK = "\\033[30m"
RED = "\\033[31m"
GREEN = "\\033[32m"
YELLOW = "\\033[33m"
BLUE = "\\033[34m"
MAGENTA = "\\033[35m"
CYAN = "\\033[36m"
WHITE = "\\033[37m"
END = "\\033[0m"
UNDERLINE = "\\033[4m"
COLWIDTH=8
help: Makefile ## Print this help
@echo ""
@printf "%s ${CYAN}%s${END}\n" "make" "<target>"
@echo ""
@printf "$(UNDERLINE)$(CYAN)%-$(COLWIDTH)s: $(END) $(UNDERLINE)%s$(END)\n" "<target>" "<description>"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort |awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-$(COLWIDTH)s: \033[0m %s\n", $$1, $$2}'
@echo ""
@echo ""
.DEFAULT_GOAL := help
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment