Closed rsmith-nl closed 6 months ago
Thanks for the suggestion.
I'll keep the Makefile course around for a bit, but I have started suggesting taskfile.dev as an alternative to folks now. It just seems more flexible for the day-to-day devwork. It also has better support for documentation features like this.
By adding special comments to the targets in the Makefile, it is possible to automatically generate help. Below is my standard Makefile for python programs.
The important bits are:
1) The comments starting with
##
on the same line as the targets 2) thesed
command in theall
target.The
sed
command reads the Makefile, and extracts the lines that contain##
. It then replaces the colon up to and including##
with a tab and prints the line. This gives a target followed by a tab followed by the help text.Tested with both BSD make and GNU make.
Calling
make
with no arguments gives: