forked from delamonpansie/octopus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.in
255 lines (205 loc) · 6.28 KB
/
Makefile.in
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# This makefile based on ideas from http://make.paulandlesley.org/
# Thanks to Paul D. Smith <[email protected]>
export LC_ALL=C
.SUFFIXES:
ROOT:=$(CURDIR)
CORO_IMPL = ASM
@SET_MAKE@
CC = @CC@
CPP = @CPP@
CFLAGS = @CFLAGS@
XCFLAGS = @XCFLAGS@
# no -Wextra & -Werror on bundled builds: compiler is unknown
ifeq (@BUNDLE@,)
WCFLAGS = @WCFLAGS@
endif
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
RANLIB = @RANLIB@
AR = ar
ARFLAGS = rc
RAGEL = @RAGEL@
RAGELFLAGS = @RAGELFLAGS@
DOT = @DOT@
CONFETTI = @CONFETTI@
GIT = @GIT@
HAVE_GIT = @HAVE_GIT@
ECHO = @ECHO@
CAT = cat
SED = @SED@
NM = @NM@
OBJCOPY = @OBJCOPY@
OCAMLOPT = @OCAMLOPT@
OCAMLC = @OCAMLC@
OCAMLDEP = @OCAMLDEP@
HAVE_RAGEL = @HAVE_RAGEL@
HAVE_CONFETTI = @HAVE_CONFETTI@
HAVE_LCOV = @HAVE_LCOV@
COVERAGE = @COVERAGE@
LIBS = @LIBS@
HAVE_CC_FLAG_W_NO_COMMENT = @HAVE_CC_FLAG_W_NO_COMMENT@
HAVE_CC_FLAG_W_NO_UNUSED_VALUE = @HAVE_CC_FLAG_W_NO_UNUSED_VALUE@
modules = @modules@
clients = @clients@
srcdir = @srcdir@
VPATH := @srcdir@
ifneq ($(words $(srcdir)),1)
$(error source dir must not contain spaces)
endif
MAKEFLAGS += --no-print-directory
%.o: XCPPFLAGS += -I. -Iinclude
primary_module=$(firstword $(modules))
binary=octopus$(if $(WITH_MODNAME),_$(primary_module),)
XCFLAGS += $(foreach m,$(modules),-DMOD_$(m)=1)
DCFLAGS=$(filter -g%,$(XCFLAGS) $(CFLAGS))
%.o: XCFLAGS += -Wno-strict-aliasing -funwind-tables
ifeq ("$(origin V)", "command line")
VERBOSE = $(V)
endif
ifeq (,$(VERBOSE))
E:=@echo
Q:=@
else
E:=@:
Q:=
endif
all: $(binary) $(foreach client,$(clients),$(client)_all)
subdirs += third_party
subdirs += src-ml
subdirs += src-lua
subdirs += $(foreach dir,$(modules),mod/$(dir))
subdirs += $(foreach dir,$(clients),client/$(dir))
ifeq (,$(filter libiproto,$(clients)))
subdirs += client/libiproto
endif
subdirs += src cfg
sub-Makefile = $(foreach dir,$(subdirs),$(srcdir)/$(dir)/Makefile)
-include $(sub-Makefile)
-include cfg/defs.mk
$(binary): $(obj)
$E "CC $@"
$Q$(CC) $^ $(LIBS) $(XLIBS) $(XLDFLAGS) $(LDFLAGS) $(CFLAGS) -o $@
$(obj): Makefile $(sub-Makefile)
-include $(obj:.o=.d)
-include $(cmx:.cmx=.d) $(cmx:.cmx=.i.d)
dist-clean += $(obj:.o=.d) $(cmx:.cmx=.d) $(cmx:.cmx=.i.d)
$(filter-out $(no-extra-warns),$(obj)): XCFLAGS += $(WCFLAGS)
%.o: %.m
@mkdir -p $(dir $@)
$(E) "CC $@"
$(Q)$(CC) $(XCPPFLAGS) $(XCFLAGS) $(CPPFLAGS) $(CFLAGS) -Wno-protocol -fobjc-exceptions -c $< -o $@
%.o: %.c
@mkdir -p $(dir $@)
$(E) "CC $@"
$(Q)$(CC) $(XCPPFLAGS) $(XCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
ifeq (1,$(HAVE_RAGEL))
%.m: %.rl
@mkdir -p $(dir $@)
$(E) "RAGEL $@"
$(Q)$(RAGEL) -G2 $< -o $@
%.dot: %.rl
@mkdir -p $(dir $@)
$(E) "RAGEL $@"
$(Q)$(RAGEL) -p -V $< -o $(basename $@).dot
%.png: %.dot
@mkdir -p $(dir $@)
$(E) "DOT $@"
$(Q)$(DOT) -Tpng $< -o $(basename $@).png
endif
ifeq (1,$(HAVE_CONFETTI))
%.cfg: %.cfg_tmpl
@mkdir -p $(dir $@)
$(E) "CNFTI $@"
$(Q)$(CONFETTI) -i $< -n $(notdir $(basename $<))$(if $(findstring _cfg,$<),,_cfg) -f $@
%.h: %.cfg_tmpl
@mkdir -p $(dir $@)
$(E) "CNFTI $@"
$(Q)$(CONFETTI) -i $< -n $(notdir $(basename $<))$(if $(findstring _cfg,$<),,_cfg) -h $@
%.c: %.cfg_tmpl | %.h %.cfg
@mkdir -p $(dir $@)
$(E) "CNFTI $@"
$(Q)$(CONFETTI) -i $< -n $(notdir $(basename $<))$(if $(findstring _cfg,$<),,_cfg) -c $@
endif
FORCE:
.PHONY: FORCE
ifeq (1,$(HAVE_GIT))
BUNDLE=NONE
octopus_version.h: FORCE
@echo -n 'const char octopus_version_string[] = "' > $@_
@(cd $(srcdir) && $(GIT) describe --always HEAD) | tr -d \\n >> $@_
@(cd $(srcdir) && $(GIT) branch) | grep '\*' | cut -f2 -d' ' | sed 's/^master$$//' | tr -d \\n >> $@_
@echo '";' >> $@_
@echo 'const char octopus_bundle_string[] = "$(BUNDLE)";' >> $@_;
@diff -q $@ $@_ 2>/dev/null >/dev/null || (echo "GEN $@"; cp $@_ $@)
@rm $@_
all_modules = $(sort $(modules) $(foreach path,$(wildcard mod/*),$(notdir $(path))))
$(foreach mod,$(all_modules),mod/$(mod)/$(mod)_version.h): FORCE
@mkdir -p $(dir $@)
@echo -n 'const char $(subst -,_,$(subst .h,,$(notdir $@)))_string[] = "' > $@_
@(cd $(srcdir)/$(dir $@) && $(GIT) describe --always HEAD) | sed 's/.*-g/g/' | tr -d \\n >> $@_
@echo '";' >> $@_
@diff -q $@ $@_ 2>/dev/null >/dev/null || (echo "GEN $@"; cp $@_ $@)
@rm $@_
dist += $(foreach mod,$(all_modules),mod/$(mod)/$(mod)_version.h)
endif
.PHONY: distclean clean
clean:
$(E) "CLEAN $(binary)"
$(Q)rm -rf $(obj) $(patsubst %.o,%.gcno,$(obj))
$(Q)rm -rf $(dep) $(binary) lcov test/var
luaclean:
$(E) "CLEAN luajit"
$(Q)echo 'include $$(VPATH)Makefile' | $(MAKE) -C third_party/luajit/src -f - CC="$(CC)" E="$(E)" Q="$(Q)" VPATH=$(LUAJIT_VPATH) clean
configure-byproducts += autom4te.cache config.log config.status
configure-byproducts += include/config.h Makefile
distclean: clean luaclean
$(Q)rm -rf $(dist-clean)
$(Q)rm -rf $(configure-byproducts) configure install.sh
$(Q)rm -rf TAGS test/var test/*.rej
.PHONY: TAGS
TAGS:
ctags-exuberant --langmap=ObjectiveC:.m.h.rl -eR
.PHONY: test
define run_test
$(foreach test,$(sort $(wildcard $(foreach mod,$(modules),mod/$(mod)/test/test_*))),./$(test)
)
endef
test: $(binary)
@$(run_test)
ifeq (1,$(COVERAGE))
clean: clean-coverage
ifeq (1,$(HAVE_LCOV))
octopus.cov: $(patsubst %.o,%.gcda,$(obj)) $(patsubst %.o,%.gcno,$(obj))
lcov --output-file $@ --base-directory . --capture --directory .
lcov --output-file $@ --remove $@ y.tab.c prscfg.l prscfg.y prscfg_scan.c /usr/\*
octopus.coverage/index.html: octopus.cov
genhtml --output-directory $(dir $@) $<
else
octopus.cov: $(patsubst %.o,%.gcda,$(obj)) $(patsubst %.o,%.gcno,$(obj))
python scripts/zcov/zcov-scan $@
octopus.coverage/index.html: octopus.cov
python scripts/zcov/zcov-genhtml $< $(dir $@)
endif
$(patsubst %.o,%.gcda,$(obj)): test
.PHONY: coverage clean-coverage
coverage: octopus.coverage/index.html
sensible-browser $<
clean-coverage:
@rm -rf $(patsubst %.o,%.gcda,$(obj)) \
octopus.coverage octopus.cov
endif
Makefile: config.status $(srcdir)/include/config.h.in $(srcdir)/Makefile.in $(sub-Makefile)
./config.status
config.status: $(srcdir)/configure
./config.status --recheck
$(srcdir)/configure: configure.ac third_party/libev/libev.m4
cd $(srcdir) && autoconf
.PHONY: dist pre-dist
pre-dist: configure $(dist) octopus_version.h
@rm -rf $(configure-byproducts)
dist:
@./scripts/make-dist.sh $(foreach mod,$(modules),mod/$(mod))
$(eval $(obj): $(defered_depend))
ifeq (1,$(I))
$(info * build with $(filter -D%,$(CFLAGS)))
endif