tl;dr running make help
prints:
Usage: make TARGET
help:
Print this help
hello:
Print hello and exit
Really, that's pretty much it.
world:
Print world and exit
help: | |
@: # Print this help | |
@printf 'Usage: make TARGET\n' | |
@awk ' \ | |
/^[^\t:]+:/ { \ | |
split($$0, s, ":"); \ | |
cmd=s[1]; \ | |
} /^\t@: #/ { \ | |
split($$0, t, ": # "); \ | |
body=t[2]; \ | |
doprnt=1; \ | |
} { \ | |
if (doprnt == 1) { \ | |
if (cmd != "") { \ | |
printf("\n\033[33m%s\033[0m:\n", cmd); \ | |
cmd="" \ | |
}; \ | |
printf("\t%s\n", body); \ | |
doprnt=0; \ | |
body=""; \ | |
}; \ | |
} \ | |
' Makefile | |
hello: | |
@: # Print hello and exit | |
@: # | |
@: # Really, that's pretty much it. | |
echo hello | |
world: | |
@: # Print world and exit | |
echo world | |
.PHONY: help hello world |