Skip to content

Instantly share code, notes, and snippets.

@amitu
Created April 12, 2016 07:49
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 amitu/95b413d8da17c229dd494d0a0bff2790 to your computer and use it in GitHub Desktop.
Save amitu/95b413d8da17c229dd494d0a0bff2790 to your computer and use it in GitHub Desktop.
Self documenting makefile
.DEFAULT_GOAL := help
node_modules: ## Install dependencies.
node_modules: package.json
npm install
help: ## Show this help.
@IFS=$$'\n' ; \
help_lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##/:/'`); \
for help_line in $${help_lines[@]}; do \
IFS=$$':' ; \
help_split=($$help_line) ; \
help_command=`echo $${help_split[0]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
help_info=`echo $${help_split[2]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
printf '\033[36m'; \
printf "%-15s %s" $$help_command ; \
printf '\033[0m'; \
printf "%s\n" $$help_info; \
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment