Skip to content

Instantly share code, notes, and snippets.

@ktrysmt
Last active January 18, 2019 14:29
Show Gist options
  • Save ktrysmt/0ea24312f28c5d958e11a9af7efe563d to your computer and use it in GitHub Desktop.
Save ktrysmt/0ea24312f28c5d958e11a9af7efe563d to your computer and use it in GitHub Desktop.
Plain Makefile boilerplate
.DEFAULT_GOAL := help
THIS_FILE := $(lastword $(MAKEFILE_LIST))
target: ## run the target ## make target env=development
@echo $@ # print target name
@$(MAKE) -f $(THIS_FILE) inner-target # invoke other target
inner-target:
@echo $@ # print target name
help: ## print this message
@echo "Example operations by makefile."
@echo ""
@echo "Usage: make SUB_COMMAND argument_name=argument_value"
@echo ""
@echo "Command list:"
@echo ""
@printf "\033[36m%-30s\033[0m %-50s %s\n" "[Sub command]" "[Description]" "[Example]"
@grep -E '^[/a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | perl -pe 's%^([/a-zA-Z_-]+):.*?(##)%$$1 $$2%' | awk -F " *?## *?" '{printf "\033[36m%-30s\033[0m %-50s %s\n", $$1, $$2, $$3}'
.PHONY: help target other-target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment