-
Notifications
You must be signed in to change notification settings - Fork 28
/
Makefunc.mk
85 lines (72 loc) · 2.46 KB
/
Makefunc.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#
# Makefunc.mk
#
# version: v2.0
# last update: 2018/12/24
#
##################################################
#
# make support
#
MAKE-ND = $(MAKE) --no-print-directory
# export variables
# $(call EXPORT,ELS CORT_ARGS) \
# EMACS=$* $(MAKE) -C .make-$* check 2>&1 | tee -a $(LOGFILE)
#
# => ELS='leaf.el leaf-core.el' CORT_ARGS='-l leaf-tests.el -f cort-run-tests' \
# EMACS=emacs-26.1 make -C .make-emacs-26.1 check 2>&1 | tee -a .make-check.log
EXPORT = $(foreach var,$1,$(var)='$($(var))')
##################################################
#
# strings utils
#
STRCUT = $(shell echo $1 | awk -F $2 '{print $3}')
STRCUTREV = $(shell echo $1 | awk -F $2 '{print $$(NF-$3)}')
##################################################
#
# dictionary
# (KEY)/(VAL) data class
#
MAKEDIC = $(join $(addsuffix /, $1), $2)
KEY2VAL = $(shell echo $1 | grep -Po '(?<=$2/)[^\s]+')
VAL2KEY = $(shell echo $1 | grep -Po '[^\s]+(?=/$2)')
##################################################
#
# color
#
ECHO_COLOR = printf "%b\e[%bm=== %b ===\e[m%b\n" $3 $1 $2 $4
ECHO_COLOR- = printf "%b\e[%bm%b\e[m%b" $3 $1 $2 $4
ECHO_BLACK = $(call ECHO_COLOR,"30",$1,$2,$3)
ECHO_RED = $(call ECHO_COLOR,"31",$1,$2,$3)
ECHO_GREEN = $(call ECHO_COLOR,"32",$1,$2,$3)
ECHO_YELLOW = $(call ECHO_COLOR,"33",$1,$2,$3)
ECHO_BLUE = $(call ECHO_COLOR,"34",$1,$2,$3)
ECHO_MAGENTA = $(call ECHO_COLOR,"35",$1,$2,$3)
ECHO_CYAN = $(call ECHO_COLOR,"36",$1,$2,$3)
ECHO_WHITE = $(call ECHO_COLOR,"37",$1,$2,$3)
ECHO_BLACK- = $(call ECHO_COLOR-,"30",$1,$2,$3)
ECHO_RED- = $(call ECHO_COLOR-,"31",$1,$2,$3)
ECHO_GREEN- = $(call ECHO_COLOR-,"32",$1,$2,$3)
ECHO_YELLOW- = $(call ECHO_COLOR-,"33",$1,$2,$3)
ECHO_BLUE- = $(call ECHO_COLOR-,"34",$1,$2,$3)
ECHO_MAGENTA- = $(call ECHO_COLOR-,"35",$1,$2,$3)
ECHO_CYAN- = $(call ECHO_COLOR-,"36",$1,$2,$3)
ECHO_WHITE = $(call ECHO_COLOR-,"37",$1,$2,$3)
COLOR_BLACK = tput setaf 0
COLOR_RED = tput setaf 1
COLOR_GREEN = tput setaf 2
COLOR_YELLOW = tput setaf 3
COLOR_BLUE = tput setaf 4
COLOR_MAGENTA = tput setaf 5
COLOR_CYAN = tput setaf 6
COLOR_WHITE = tput setaf 7
COLOR_DEFAULT = tput sgr0
colortest:
$(call ECHO_BLACK, "black" , "", "")
$(call ECHO_RED, "red" , "", "")
$(call ECHO_GREEN, "green" , "", "")
$(call ECHO_YELLOW, "yellow" , "", "")
$(call ECHO_BLUE, "blue" , "", "")
$(call ECHO_MAGENTA, "magenta", "", "")
$(call ECHO_CYAN, "cyan" , "", "")
$(call ECHO_WHOTE, "white" , "", "")