Skip to content

Instantly share code, notes, and snippets.

@mgrabovsky
Last active July 22, 2016 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgrabovsky/1fba409010e064f5cab6 to your computer and use it in GitHub Desktop.
Save mgrabovsky/1fba409010e064f5cab6 to your computer and use it in GitHub Desktop.
Self-documenting Makefile
#:This list
.PHONY: ?
?:;@for file in "Makefile $$(perl -lne 'print for m|^include\s+(.*)$$|g' Makefile)"; do \
perl -0777 -ne 'while (m/#:\s*(.*?)\n\.PHONY:\s*(.*?)\n/sg) { print "make $$2\t# $$1\n"; }' "$${file}"; \
done | sort -u | column -ts $$'\t'
# Source: https://github.com/gtramontina/sourcing/blob/023cae5/Makefile#L68-L72
.PHONY: help
help: ## This piece
@grep -P '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
# Source: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment