A simple and elegant way to add self-documenting help to your Makefiles. Works with both GNU Make and BSD Make.
With make-help you document Makefile targets directly in the source using special comments. These comments are automatically extracted and displayed when running make help.
Just run make in this project to see how it works! Including make.mk at the top of your main Makefile means the default target will show documentation for all targets in your project.
Add help text to your Makefiles using #_# comments for your targets:
#_# mytarget: Description of what this target does
#_# Additional details can go on multiple lines
#_# Indentation is preserved
mytarget:
command here- Works with both GNU Make and BSD Make
- Supports multi-line help text and preserves formatting
- Works across included Makefiles
- Skips BSD system Makefiles
- Simple and lightweight implementation
- Easy to integrate into existing projects
-
Copy the
mk/directory to your project (containing help.mk, help.gnu.mk, and help.bsd.mk) -
Add this line before other targets in your Makefile:
include mk/help.mkThat's it! Now running make will show help for all documented targets.
The included example Makefile demonstrates the features:
#_# foo: A top-level target
foo:
echo this is foo
#_# bar: A top-level target with additional help
#_# All of the help comments are included in the output
bar:
echo this is barRunning make will display the documentation for all targets.
This project is released into the public domain. Feel free to use it however you like!
Feel free to open issues or submit pull requests on GitHub.