From 1b172e581123db9cb9fc77fe24f1789b20a4c14a Mon Sep 17 00:00:00 2001 From: Angira Kekteeva Date: Sun, 16 Oct 2022 20:34:34 +0400 Subject: [PATCH] [#213] Makefile: Add help Signed-off-by: Angira Kekteeva --- Makefile | 3 +++ help.mk | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 help.mk diff --git a/Makefile b/Makefile index d961a94..005fa28 100644 --- a/Makefile +++ b/Makefile @@ -39,6 +39,7 @@ dep: @CGO_ENABLED=0 \ go mod tidy -v && echo OK +# Run `make %` in Golang container, for more information run `make help.docker/%` docker/%: $(if $(filter $*,all $(BINS)), \ @echo "=> Running 'make $*' in clean Docker environment" && \ @@ -109,3 +110,5 @@ version: clean: rm -rf vendor rm -rf $(BINDIR) + +include help.mk diff --git a/help.mk b/help.mk new file mode 100644 index 0000000..b5fbbc9 --- /dev/null +++ b/help.mk @@ -0,0 +1,22 @@ +.PHONY: help + +# Show this help prompt +help: + @echo ' Usage:' + @echo '' + @echo ' make ' + @echo '' + @echo ' Targets:' + @echo '' + @awk '/^#/{ comment = substr($$0,3) } comment && /^[a-zA-Z][a-zA-Z0-9.%_/-]+ ?:/{ print " ", $$1, comment }' $(MAKEFILE_LIST) | column -t -s ':' | grep -v 'IGNORE' | sort | uniq + +# Show help for docker/% IGNORE +help.docker/%: + $(eval TARGETS:=$(notdir all lint) ${BINS}) + @echo ' Usage:' + @echo '' + @echo ' make docker/% -- Run `make %` in Golang container' + @echo '' + @echo ' Supported docker targets:' + @echo '' + @$(foreach bin, $(TARGETS), echo ' ' $(bin);)