Skip to content

Instantly share code, notes, and snippets.

@taraspos
Last active December 8, 2020 14:14
Show Gist options
  • Save taraspos/00fb83f19733681e3b14b968bea999b0 to your computer and use it in GitHub Desktop.
Save taraspos/00fb83f19733681e3b14b968bea999b0 to your computer and use it in GitHub Desktop.
Multi-file documented Makefile
# improved version of help from the article https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
# but with the support of included makefiles
.PHONY: help
help:
@for m in $(MAKEFILE_LIST); do \
grep -E '^[a-zA-Z0-9_\/%-]+:.*?## .*$$' $$m | \
sort | \
awk -v f="$$m" ' BEGIN {FS = ":.*?## "}; NR == 1 { printf "%s:\n", f } {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}';\
done
command1: ## example command1
@echo "You just run command1"
include common.Makefile
command2: ## example command2
@echo "You just run command2"
@taraspos
Copy link
Author

taraspos commented Dec 8, 2020

And you would get result like:

$ make
Makefile:
   command2             example command2
common.Makefile:
   command1             example command1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment