Skip to content

Instantly share code, notes, and snippets.

@SimonLammer
Last active October 14, 2023 18:33
Show Gist options
  • Save SimonLammer/ba500cc2ba332cfec756bcd5369b40e6 to your computer and use it in GitHub Desktop.
Save SimonLammer/ba500cc2ba332cfec756bcd5369b40e6 to your computer and use it in GitHub Desktop.
Makefile help (list available make targets)
# have an intermediate _help, to move the actual help target to the file end
_help: help
#= Section 1
target1:
echo target1
target2: target1
echo target2
target3: target2 # target 3 description
echo target3
target4: # target 4 description
echo target4
#= Miscellaneous
help: # Shows this help message
@sed -nr \
-e 's/^#= (.*)/\n\n\1:/p' \
-e 's/^([^_][_a-zA-Z0-9-]*):([^#]*)(# (.*))?/ \1|\4/p' \
${MAKEFILE_LIST} \
| column -t -s '|'
@SimonLammer
Copy link
Author

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