Skip to content

Instantly share code, notes, and snippets.

@jeffsp
Last active January 15, 2022 00:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jeffsp/3e1b2e10b9181681a604dd9ec6d64ecf to your computer and use it in GitHub Desktop.
Save jeffsp/3e1b2e10b9181681a604dd9ec6d64ecf to your computer and use it in GitHub Desktop.
Easy way to embed help in a GNU make Makefile
.PHONY: target1 # Target 1 help text
target1: target2 target3
@echo "Target 1"
.PHONY: target2 # Target 2 help text
target2:
@echo "Target 2"
.PHONY: target3
target3:
@echo "No help for this target"
.PHONY: help # Generate list of targets with descriptions
help:
@grep '^.PHONY: .* #' Makefile | sed 's/\.PHONY: \(.*\) # \(.*\)/\1 \2/' | expand -t20
@jeffsp
Copy link
Author

jeffsp commented Apr 14, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment