In one of my previous blog. I wrote how you could make your life easier when you start using Makefile. But when you start using Makefile in many projects. The targets that you use may vary from project to project.
In this blog post I will address a trick how you could write a help
target. Lets imagine that we have a project that allow you to build
, start
and stop
a docker container. These names are pretty straightforward. But without looking in the Makefile you never know for sure.
By calling the help
target you could list all available targets:
When you have a look at the Makefile used for this blog post. It looks like this:
You need to add the help
target. And for each target you need to supply a help text. And each target needs a prefix with ##
.
By adding a help
target to your Makefile you make it easier to use for others. But also for yourself because you don’t need to remember each target in the Makefile.
Photo by lalesh aldarwish