Last active
February 18, 2020 16:58
-
-
Save fabiodbr/e809e2b58a6ad2d49e6a14505461e178 to your computer and use it in GitHub Desktop.
Self-Documented Makefile
This file contains hidden or 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
##-------------------- | |
## 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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Inspired from: