Skip to content

Instantly share code, notes, and snippets.

@tomekc
Created May 17, 2022 09:53
Show Gist options
  • Save tomekc/d8212ed972d14828655d1b3ba52627fb to your computer and use it in GitHub Desktop.
Save tomekc/d8212ed972d14828655d1b3ba52627fb to your computer and use it in GitHub Desktop.
Makefile help

Default "help" target in Makefile

GREEN  := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE  := $(shell tput -Txterm setaf 7)
RESET  := $(shell tput -Txterm sgr0)

.PHONY: help
help: ## Show this help.
	@echo 'Usage:'
	@echo '  ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
	@echo ''
	@echo 'Targets:'
	@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "  ${YELLOW}%-28s${GREEN}%s${RESET}\n", $$1, $$2}' $(MAKEFILE_LIST)

Add comments to targets:

test: ## Run tests
   run-tests-command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment