Skip to content

Instantly share code, notes, and snippets.

@fabiodbr
Last active February 18, 2020 16:58
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 fabiodbr/e809e2b58a6ad2d49e6a14505461e178 to your computer and use it in GitHub Desktop.
Save fabiodbr/e809e2b58a6ad2d49e6a14505461e178 to your computer and use it in GitHub Desktop.
Self-Documented Makefile
##--------------------
## Makefile Template
## Author:Fabio Rizzi
##--------------------
.DEFAULT_GOAL := help
args = `arg="$(filter-out $@,$(MAKECMDGOALS))" && echo $${arg:-${1}}`
export LANG?=en_US.UTF-8
VARIABLE:=\
line1 \
line2 \
lineN \
.PHONY: print
print: ## print VARIABLE
@for var in $(VARIABLE); do echo $$var; done
.PHONY: example
example: other_example ## make example -- <args>
@echo example args: $(call args,)
.PHONY: other_example
other_example: ## called by 'example'
@echo other_example
.PHONY: help
help: ## Show this help
@printf "\nusage : make <commands> \n\nthe following commands are available: \n\n"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@printf "\n"
@fabiodbr
Copy link
Author

fabiodbr commented Feb 18, 2020

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