Skip to content

Instantly share code, notes, and snippets.

@vegarsti
Last active February 18, 2021 03:37
Show Gist options
  • Save vegarsti/8c901aded5312ed7618835f27b0740d2 to your computer and use it in GitHub Desktop.
Save vegarsti/8c901aded5312ed7618835f27b0740d2 to your computer and use it in GitHub Desktop.

I prefer a help rule in the Makefile, like so:

   help:
        @grep -P '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
Assuming that the trimmed Makefile read:

   build: ## Build the binary

   clean: ## Clean the binary and intermediate files

   distclean: clean ## Clean dependencies, intermediate files and binary

   deps: ## Install dependencies

   all: deps build ## Get dependencies and build binary

   release: distclean all ## distclean + all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment