devsecops

A simple Makefile 'help' command

In this article I’m going to show you how to add a make help command to your makefiles that quickly and easily shows simple documentation for your commands: To add the help command to your makefile, add a recipe like so: .PHONY: help help: # Show help for each of the Makefile recipes. @grep -E '^[a-zA-Z0-9 -]+:.*#' Makefile | sort | while read -r l; do printf "\033[1;32m$$(echo $$l | cut -f 1 -d':')\033[00m:$$(echo $$l | cut -f 2- -d'#')\n"; done Now just make sure that each of your recipes has a comment that follows the recipe name, which will be used as its documentation.
Read more