- The
.makefilehelpbash script enables you to createmake helpandmake help:[ target ]commands which display documentation from comments in your Makefile. - The help documentation is designed to look and behave like manpages, e.g.
man make - The aim is to encourage documenting Makefile targets.
To install .makefilehelp run the following:
curl https://gist.githubusercontent.com/JasonHewison/25e49e25c6575793cfc75cf6a94e787a/raw/cc2d2ac9587457ab3d3f73a765ec632bab355ed4/.makefilehelp --output .makefilehelp
chmod +x .makefilehelp
./.makefilehelpThe make help and make help:help commands should now be available.
The example Makefile in this gist containes examples of how to provide documentation. You need to do is start the documentation with the following tag.
#[ target ]:e.g.
#start:Then any comments between that tag and the matching target will be included in the make help:[ target ] documentation.
If there are any non-comment elements in between, e.g. Makefile variables these will be ignored.
e.g.
#healthcheck:
# Does some sort of healthcheck thing.
# Has a default timeout of 1 minute.
TIMEOUT=60
healthcheck:
./do-healthcheck.sh ${TIMEOUT}Finally, when you run make help it is actually showing the help documentation for the help command.
You can customize the help text for each project you use it in and optionally include an overview of the project.
To run the following examples do the following:
echo "Setup an example folder"
mkdir makefilehelp-example
cd makefilehelp-example
curl https://gist.githubusercontent.com/JasonHewison/25e49e25c6575793cfc75cf6a94e787a/raw/dd4223d3752b39c029001034b0ae973c313b767d/Makefile-example --output Makefile
echo "Install .makefilehelp"
curl https://gist.githubusercontent.com/JasonHewison/25e49e25c6575793cfc75cf6a94e787a/raw/cc2d2ac9587457ab3d3f73a765ec632bab355ed4/.makefilehelp --output .makefilehelp
chmod +x .makefilehelp
./.makefilehelpYou should now be able to run the following examples.
make helpmake help:startmake help:magicmake help:bobThe .makefilehelp script is intended to help document Makefile's that are used as tooling for a repo.
In a lot of project's I've worked on Makefiles are used as a way of providing consistent tooling for all projects so that any engineer unfamiliar with a repo is able to make build, make test and make run.
Sometimes the more complicated a repo, the bigger and more unweildy a Makefile can become, being able to run make help is intended to assist new engineers in learning a repo and it's tooling.