forked from spotinst/charts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.util.mk
57 lines (54 loc) · 1.1 KB
/
Makefile.util.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
##@ Utility
define TODO_HELP_INFO
# Show to-do items per file.
#
# Example:
# make todo
endef
.PHONY: todo
ifeq ($(HELP),y)
todo:
$(Q) echo "$$TODO_HELP_INFO"
else
todo: ## Show to-do items per file
$(Q) grep \
--exclude-dir=vendor \
--exclude-dir=.idea \
--text \
--color \
-nRo \
-E 'TODO.*' \
.
endif
define VARS_HELP_INFO
# Output all variables.
#
# Example:
# make vars
#
# See:
# [1] https://stackoverflow.com/a/59097246
# [2] https://www.gnu.org/software/make/manual/html_node/Origin-Function.html
endef
.PHONY: vars
ifeq ($(HELP),y)
vars:
$(Q) echo "$$VARS_HELP_INFO"
else
vars: ## Output all variables
$(foreach v, $(.VARIABLES), $(if $(filter file,$(origin $(v))), $(info $(v)=$($(v)))))
endif
define HELP_INFO
# Display this help.
#
# Example:
# make help
endef
.PHONY: help
ifeq ($(HELP),y)
help:
$(Q) echo "$$HELP_INFO"
else
help: ## Display this help
$(Q) awk 'BEGIN {FS = ":.*##"; printf "Usage: make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) }' $(MAKEFILE_LIST)
endif