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

SimonLammer commented Aug 26, 2023

$ make
Section 1:
  target1
  target2
  target3                    target 3 description
  target4                    target 4 description
Miscellaneous:
  help                       Shows this help message
$ make target1
echo target1
target1
$ make target2
echo target1
target1
echo target2
target2
$ make target3
echo target1
target1
echo target2
target2
echo target3
target3
$ make target4
echo target4
target4

@SimonLammer
Copy link
Author

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