Skip to content

Instantly share code, notes, and snippets.

@kujenga
Forked from prwhite/Makefile
Created May 22, 2021 23:28
Show Gist options
  • Save kujenga/35080514f7693d50e76057bef7899d7b to your computer and use it in GitHub Desktop.
Save kujenga/35080514f7693d50e76057bef7899d7b to your computer and use it in GitHub Desktop.
Add a help target to a Makefile that will allow all targets to be self documenting
# Add the following 'help' target to your Makefile
# And add help text after each target name starting with '\#\#'
help: ## Show this help.
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\(.*\):.*##\(.*\)/\1:\t\2/'
# Everything below is an example
target00: ## This message will show up when typing 'make help'
@echo does nothing
target01: ## This message will also show up when typing 'make help'
@echo does something
# Remember that targets can have multiple entries (if your target specifications are very long, etc.)
target02: ## This message will show up too!!!
target02: target00 target01
@echo does even more
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment