-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrules.mk
72 lines (53 loc) · 1.43 KB
/
rules.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
SOURCE_FILE=$(TOPDIR)/extra-sources.sh
export SOURCE_FILE
empty=
space=$(empty) $(empty)
lowerCase=$(shell echo $(1) | tr '[A-Z]' '[a-z]')
upperCase=$(shell echo $(1) | tr '[a-z]' '[A-Z]')
TMP_FILE=TMP_FILE
_Y:=\\033[33m
_B:=\\033[37m
_N:=\\033[m
define CMESSAGE
printf "$($(1))%s$(_N)\n" "$(2)"
endef
define MESSAGE
$(call CMESSAGE,_Y,$(1))
endef
ifneq ($(_DIR),)
FOO__=$(shell ))
endif
ifeq ($(V),s)
SUBMAKE=$(MAKE)
else
QUIET=@
define SUBMAKE
@cmd() { $(call MESSAGE, make[$(MAKELEVEL)] $$*); $(MAKE) --no-print-directory $$* 1>/dev/null; }; cmd
endef
endif
RM=$(QUIET) rm -f
SUB_MAKEFILES=$(wildcard ./*/Makefile)
SUB_DIRS=$(subst ./,,$(subst / , ,$(dir $(SUB_MAKEFILES)) ))
SUB_DIRS_RESEARCH=_$(subst $(space),_,$(SUB_DIRS))_
define gen-var-targets-sourcing
files-$(1)=$$(strip $$(wildcard $(1)/*.sh))
$(1):
$$(foreach _f,$$(files-$(1)),echo "source $$(realpath $$(_f))" >>$(TMP_FILE);)
endef
# Param 1 : file to source
define Add/Source/File/Environment
echo "source $$(realpath $(1))" >>$(SOURCE_FILE)
endef
# Param 1 : Directory that is added to the PATH variable
define Append/Directory/Global/Path
echo "PATH=\"\$${PATH}:$$(realpath $(1))\"" >>$(SOURCE_FILE)
endef
export Add/Source/File/Environment Append/Directory/Global/Path
ALL_RULES=home work install common clean
ALL_REAL_RULES=$(filter-out install clean,$(ALL_RULES))
.PHONY: $(ALL_RULES)
remove-TMP:
$(RM) $(TMP_FILE)
remove-source:
$(RM) $(SOURCE_FILE)
clean: remove-TMP