-
Notifications
You must be signed in to change notification settings - Fork 2
/
zimk.mk
137 lines (114 loc) · 3.39 KB
/
zimk.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
ZIMKPATH:=$(subst /zimk.mk,,$(lastword $(MAKEFILE_LIST)))
ifneq ($(ZIMKPATH),)
ZIMKPATH:=$(ZIMKPATH)/
endif
ifndef ZIMK__BASEDIR
ZIMK__BASEDIR:=$(CURDIR)
export ZIMK__BASEDIR
endif
ifeq ($(origin CC),default)
undefine CC
endif
ifeq ($(origin CXX),default)
undefine CXX
endif
ifeq ($(origin CPP),default)
undefine CPP
endif
ifeq ($(origin AR),default)
undefine AR
endif
MAKEOVERRIDES:= #
-include defaults.mk
include $(ZIMKPATH)lib/funcs.mk
include $(ZIMKPATH)lib/platform.mk
include $(ZIMKPATH)lib/uses.mk
ifdef ZIMK__RECURSE
include $(ZIMKPATH)lib/confvars.mk
include $(ZIMKPATH)lib/silent.mk
zinc:=
else
include $(ZIMKPATH)lib/pretty.mk
include $(ZIMKPATH)lib/confvars.mk
include $(ZIMKPATH)lib/config.mk
include $(ZIMKPATH)lib/silent.mk
include $(ZIMKPATH)lib/objs.mk
include $(ZIMKPATH)lib/dirs.mk
include $(ZIMKPATH)lib/deps.mk
include $(ZIMKPATH)lib/link.mk
include $(ZIMKPATH)lib/bin.mk
include $(ZIMKPATH)lib/lib.mk
ifndef MAKE_RESTARTS
ifneq ($(GIT),)
ifneq ($(filter-out $(NOBUILDTARGETS) install installsharedlibs \
installstaticlibs,$(MAKECMDGOALS)),)
ifneq ($(shell $(GIT) rev-parse --is-inside-work-tree $(CMDNOERR)),)
ZIMKSUBMODULECFG:=$(shell $(READ) $(subst /,$(PSEP),$(ZIMKPATH)).git $(CMDNOERR))
ifeq ($(words $(ZIMKSUBMODULECFG)),2)
ZIMKSUBMODULEGITDIR:=$(realpath $(ZIMKPATH)$(lastword $(ZIMKSUBMODULECFG)))
ifneq ($(ZIMKSUBMODULEGITDIR),)
ifneq ($(wildcard $(ZIMKSUBMODULEGITDIR)/FETCH_HEAD),)
$(subst /,$(PSEP),$(ZIMKPATH))zimk.mk: $(ZIMKSUBMODULEGITDIR)/FETCH_HEAD
$(VGIT)
$(VR)$(GIT) submodule update $(ZIMKPATH)
$(VR)$(call touch, $@)
endif
endif
endif
endif
endif
endif
endif
install:: $(DEFGOAL)
strip:: all
$(foreach v,CLEAN DISTCLEAN DISTCLEANDIRS \
,$(eval $v:=$$(subst /,$$(PSEP),$$($v))))
define ZIMK__SUBBUILDRULES
$$(subst /,$$(PSEP),$$($1_TARGET)): $$(subst /,$$(PSEP),$$($1_PREREQ))
+@$$(MAKE) -C $$(subst /,$$(PSEP),$$($1_SRCDIR)) \
$$(subst /,$$(PSEP),$$($1_MAKEARGS)) $$($1_MAKEGOAL)
sub_$1_clean:
+@$$(MAKE) -C $$(subst /,$$(PSEP),$$($1_SRCDIR)) \
$$(subst /,$$(PSEP),$$($1_MAKEARGS)) \
$$(or $$($1_CLEANGOAL),clean)
.PHONY: sub_$1_clean
CLEANGOALS+= sub_$1_clean
endef
$(foreach _S,$(SUBBUILD),$(eval $(call ZIMK__SUBBUILDRULES,$(_S))))
define ZIMK__CLEANLINE
$(ZIMK__TAB)$(VRM)
$(ZIMK__TAB)$(VR)$(call rmfile,$1)
endef
ZIMK__CLEANRECIPE=@:$(foreach f,$1\
,$(eval _ZIMK_0:=$f)$(call ZIMK__CLEANLINE,$f))
clean:: $(CLEANGOALS)
$(call ZIMK__CLEANRECIPE,$(CLEAN))
ZIMK__CONFIGS=$(foreach c,$(BUILDCFGS),.cache_$c.cfg $c.cfg) global.cfg
ZIMK__DISTCLEAN=$(BINBASEDIR) $(LIBBASEDIR) $(TESTBASEDIR) $(OBJBASEDIR)
define ZIMK__DISTCLEANLINE
$(ZIMK__TAB)$(VRMDR)
$(ZIMK__TAB)$(VR)$(call rmdir,$1)
endef
ZIMK__DISTCLEANRECIPE=@:$(foreach d,$1\
,$(eval _ZIMK_0:=$d)$(call ZIMK__DISTCLEANLINE,$d))
distclean:: $(CLEANGOALS) $(DISTCLEANGOALS)
$(call ZIMK__CLEANRECIPE,$(DISTCLEAN) $(ZIMK__CONFIGS))
$(call ZIMK__DISTCLEANRECIPE,$(DISTCLEANDIRS) $(ZIMK__DISTCLEAN))
ifdef POSIXSHELL
DISTVERSIONPREFIX?=v
TAR:=$(call findtool,tar)
dist:
@GIT="$(GIT)" TAR="$(TAR)" NODIST="$(NODIST)" $(SHELL) \
$(ZIMKPATH)scripts/mkdist.sh $(DISTVERSIONPREFIX) $(PKGNAME)
else
dist:
ifneq ($(filter dist,$(MAKECMDGOALS)),)
$(error The dist target is only supported with POSIX shells)
endif
endif
.PHONY: all sharedlibs staticlibs stripsharedlibs stripstaticlibs strip \
install installsharedlibs installstaticlibs clean distclean dist
.SUFFIXES:
endif # ZIMK__RECURSE
export MAKEFLAGS
# vim: noet:si:ts=8:sts=8:sw=8