Created
March 5, 2020 14:14
-
-
Save rebornwwp/f0a6169c10668d0304f5b5be4cc22aff to your computer and use it in GitHub Desktop.
Makefile help target example
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 with help target. from https://blog.thapaliya.com/posts/well-documented-makefiles/ | |
.DEFAULT_GOAL:=help | |
SHELL:=/bin/bash | |
##@ Dependencies | |
.PHONY: deps | |
deps: ## Check dependencies | |
$(info Checking and getting dependencies) | |
##@ Cleanup | |
.PHONY: clean | |
clean: ## Cleanup the project folders | |
$(info Cleaning up things) | |
##@ Building | |
.PHONY: build watch | |
build: clean deps ## Build the project | |
$(info Building the project) | |
watch: clean deps ## Watch file changes and build | |
$(info Watching and building the project) | |
##@ Helpers | |
.PHONY: help | |
help: ## Display this help | |
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment