Friday, 31 July 2015

making Makefile Self documenting

I have use 'make' on the last few projects, just to control all the CMD line build tools we now need to use.

I found a neat trick a little while ago, that automatically shows you what CMDs are available.

#
# Why use Makefile?
# because you get help lists & auto-complete on complex commands
#

help:           ## Show this help.
 @fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'

# linebreak
: ## ======================================================================

# make all output silent - ie: no CMDs shown
#.SILENT:

gitStatus: ## show GIT status
  @git status -b --column -s

Simple copy this into the top of your Makefile, and add comments as shown using ## after the cmd name.
Now when you call 'make' without any arguments, you will see a list of available commands with their descriptions.

A brilliant tool for projects with loads of cmd line tools to remember.

1 comment:

  1. I found this post quite helpful, especially the way the concepts are explained step by step. It’s beginner-friendly. You may also want to check How to Become a Data Analyst and Full stack developer course in kochi.

    ReplyDelete