Skip to content

Instantly share code, notes, and snippets.

@Dimfred
Created September 30, 2023 17:44
Show Gist options
  • Save Dimfred/c8ca3e2c5a720598d3c5d39a87575ee1 to your computer and use it in GitHub Desktop.
Save Dimfred/c8ca3e2c5a720598d3c5d39a87575ee1 to your computer and use it in GitHub Desktop.
make help target (parses the makefile itself and prints the target and description, which is provided behind ##)
target1: ## does some stuff
echo target1
target2: target1 ## this wil l only print target2 not target1
echo target2
help: ## prints help for target1 and target2
@grep '##' $(MAKEFILE_LIST) \
| grep -Ev 'grep|###' \
| sed -e 's/^\([^:]*\):[^#]*##\([^#]*\)$$/\1:\2/' \
| awk -F ":" '{ printf "%-18s%s\n", $$1 ":", $$2 }' \
| grep -v 'sed'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment