Last active
July 22, 2016 12:36
-
-
Save mgrabovsky/1fba409010e064f5cab6 to your computer and use it in GitHub Desktop.
Self-documenting Makefile
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
#: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 |
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
.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