Skip to content

Instantly share code, notes, and snippets.

@wojtek-oledzki
Last active October 17, 2016 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wojtek-oledzki/198af2c5c2bb732d8e0ba5e87d1aba1d to your computer and use it in GitHub Desktop.
Save wojtek-oledzki/198af2c5c2bb732d8e0ba5e87d1aba1d to your computer and use it in GitHub Desktop.
Makefile with help
.DEFAULT_GOAL := help
.PHONY: help
## This is demo target
# Example: make demo
demo:
echo "D E M O"
## Prints this help
help:
@awk -v skip=1 \
'/^##/ { sub(/^[#[:blank:]]*/, "", $$0); doc_h=$$0; doc=""; skip=0; next } \
skip { next } \
/^#/ { doc=doc "\n" substr($$0, 2); next } \
/:/ { sub(/:.*/, "", $$0); printf "\033[34m%-30s\033[0m\033[1m%s\033[0m %s\n\n", $$0, doc_h, doc; skip=1 }' \
$(MAKEFILE_LIST)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment