Skip to content

Instantly share code, notes, and snippets.

@eagafonov
Forked from jeffsp/Makefile
Created January 15, 2022 00:41
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 eagafonov/194551ea188008689443bb069e1d2929 to your computer and use it in GitHub Desktop.
Save eagafonov/194551ea188008689443bb069e1d2929 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment