/
Makefile
288 lines (237 loc) · 8.9 KB
/
Makefile
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
XDIST?=dev
VSN?=$(shell grep '{rel, "hibari"' rel/reltool.config | sed 's/^.*rel, "hibari", "\(.*\)",/\1/')
ARCH=$(shell erl -noshell -eval 'io:format(erlang:system_info(system_architecture)), halt().')
WORDSIZE=$(shell erl -noshell -eval 'io:format(integer_to_list(try erlang:system_info({wordsize, external}) of Val -> 8*Val catch error:badarg -> 8*erlang:system_info(wordsize) end)), halt().')
RELPKG=hibari-$(VSN)-$(XDIST)-$(ARCH)-$(WORDSIZE)
RELTGZ=$(RELPKG).tgz
RELMD5=hibari-$(VSN)-$(XDIST)-$(ARCH)-$(WORDSIZE)-md5sum.txt
OTPREL=$(shell erl -noshell -eval 'io:format(erlang:system_info(otp_release)), halt().')
PLT=$(HOME)/.dialyzer_plt.$(OTPREL)
DIALYZE_IGNORE_WARN?=dialyze-ignore-warnings.txt
DIALYZE_NOSPEC_IGNORE_WARN?=dialyze-nospec-ignore-warnings.txt
ifeq ($(shell uname -s),Darwin)
ifeq ($(shell uname -m),x86_64)
otp_configure_flags= --enable-darwin-64bit
else
otp_configure_flags= --enable-darwin-universal
endif
else
otp_configure_flags=
endif
.PHONY: all test \
compile compile-eqc compile-proper \
eunit-compile eqc-compile proper-compile \
eunit eunit-core eunit-thrift \
eqc proper \
doc \
build-plt check-plt \
dialyze dialyze-spec dialyze-nospec \
dialyze-eunit dialyze-eunit-spec dialyze-eunit-nospec \
dialyze-eqc dialyze-eqc-spec dialyze-eqc-nospec \
dialyze-proper dialyze-proper-spec dialyze-proper-nospec \
ctags etags \
clean realclean distclean \
otp_make_release_tests otp_run_release_tests \
bootstrap-package check-package package generate
all: compile
test: eunit
bootstrap-package: package
@echo "bootstrapping package: $(RELPKG) ..."
@-./tmp/hibari/bin/hibari stop &> /dev/null
@rm -rf ./tmp
@mkdir ./tmp
tar -C ./tmp -xzf ../$(RELTGZ)
./tmp/hibari/bin/hibari start
@sleep 10
./tmp/hibari/bin/hibari-admin bootstrap
@sleep 1
check-package: bootstrap-package
@echo "checking package: $(RELPKG) ..."
./tmp/hibari/bin/hibari-admin client-add hibari@127.0.0.1
@sleep 1
./tmp/hibari/bin/hibari-admin client-list
./tmp/hibari/bin/hibari-admin client-delete hibari@127.0.0.1
./tmp/hibari/bin/hibari checkpoint
./tmp/hibari/bin/hibari stop
package: generate
@echo "packaging: $(RELPKG) ..."
@rm -f ../$(RELTGZ) ../$(RELMD5)
@tar -C ./rel -czf ../$(RELTGZ) hibari
@(cd .. && (md5sum $(RELTGZ) 2> /dev/null || md5 -r $(RELTGZ) 2> /dev/null) | tee $(RELMD5))
@(cd .. && ls -l $(RELTGZ) $(RELMD5))
generate: clean compile
@echo "generating: $(RELPKG) ..."
@find ./lib -name svn -type l | xargs rm -f
@find ./lib -name rr-cache -type l | xargs rm -f
./rebar generate
@perl -i -pe 's/%% (.* generated) at .*//g;' \
rel/hibari/releases/*/*.rel \
rel/hibari/releases/*/*.script
compile:
@echo "compiling: $(RELPKG) ..."
./rebar compile
compile-eqc:
@echo "compiling-eqc: $(RELPKG) ..."
./rebar compile -D QC -D QC_EQC
compile-proper:
@echo "compiling-proper: $(RELPKG) ..."
./rebar compile -D QC -D QC_PROPER
eunit-compile: compile
@echo "eunit test compiling: $(RELPKG) ..."
./rebar eunit-compile
eqc-compile: compile-eqc
@echo "eqc test compiling: $(RELPKG) ..."
./rebar eunit-compile -D QC -D QC_EQC
proper-compile: compile-proper
@echo "proper test compiling: $(RELPKG) ..."
./rebar eunit-compile -D QC -D QC_PROPER
eunit: eunit-compile
@echo "eunit testing: $(RELPKG) ..."
./rebar eunit skip_apps=meck
eunit-core: eunit-compile
@echo "eunit testing (core): $(RELPKG) ..."
./rebar eunit skip_apps='meck,asciiedoc,edown,gdss_ubf_proto,ubf_thrift,ubf'
eunit-thrift: eunit-compile
@echo "eunit testing (thrift): $(RELPKG) ..."
./rebar eunit skip_apps='gdss_brick,gdss_client,gdss_admin,cluster_info,partition_detector,congestion_watcher,gmt_util,riak_err,meck,asciiedoc,edown'
eqc: eqc-compile
@echo "eqc testing: $(RELPKG) ... not implemented yet"
proper: proper-compile
@echo "proper testing: $(RELPKG) ... not implemented yet"
doc: compile
@echo "edoc generating: $(RELPKG) ..."
./rebar doc
build-plt: $(PLT)
check-plt: $(PLT)
dialyzer --plt $(PLT) --check_plt
dialyze: dialyze-spec
dialyze-spec: build-plt clean compile
@echo "dialyzing w/spec: $(RELPKG) ..."
dialyzer --plt $(PLT) -Wunmatched_returns -r ./lib | fgrep -v -f $(DIALYZE_IGNORE_WARN)
dialyze-nospec: build-plt clean compile
@echo "dialyzing w/o spec: $(RELPKG) ..."
dialyzer --plt $(PLT) --no_spec -Wno_undefined_callbacks -r ./lib | fgrep -v -f $(DIALYZE_NOSPEC_IGNORE_WARN)
dialyze-eunit: dialyze-eunit-spec
dialyze-eunit-spec: build-plt clean eunit-compile
@echo "dialyzing .eunit w/spec: $(RELPKG) ..."
#TODO dialyzer --plt $(PLT) -Wunmatched_returns -r `find ./lib -name .eunit -print | xargs echo` | fgrep -v -f $(DIALYZE_IGNORE_WARN)
dialyzer --plt $(PLT) -r `find ./lib -name .eunit -print | xargs echo` | fgrep -v -f $(DIALYZE_IGNORE_WARN)
dialyze-eunit-nospec: build-plt clean eunit-compile
@echo "dialyzing .eunit w/o spec: $(RELPKG) ..."
./rebar eunit-compile
dialyzer --plt $(PLT) --no_spec -Wno_undefined_callbacks -r `find ./lib -name .eunit -print | xargs echo` | fgrep -v -f $(DIALYZE_NOSPEC_IGNORE_WARN)
dialyze-eqc: dialyze-eqc-spec
dialyze-eqc-spec: build-plt clean eqc-compile
@echo "dialyzing .eqc w/spec: $(RELPKG) ..."
#TODO dialyzer --plt $(PLT) -Wunmatched_returns -r `find ./lib -name .eunit -print | xargs echo` | fgrep -v -f $(DIALYZE_IGNORE_WARN)
dialyzer --plt $(PLT) -r `find ./lib -name .eunit -print | xargs echo` | fgrep -v -f $(DIALYZE_IGNORE_WARN)
dialyze-eqc-nospec: build-plt clean eqc-compile
@echo "dialyzing .eqc w/o spec: $(RELPKG) ..."
./rebar eqc-compile
dialyzer --plt $(PLT) --no_spec -Wno_undefined_callbacks -r `find ./lib -name .eunit -print | xargs echo` | fgrep -v -f $(DIALYZE_NOSPEC_IGNORE_WARN)
dialyze-proper: dialyze-proper-spec
dialyze-proper-spec: build-plt clean proper-compile
@echo "dialyzing .proper w/spec: $(RELPKG) ..."
#TODO dialyzer --plt $(PLT) -Wunmatched_returns -r `find ./lib -name .eunit -print | xargs echo` | fgrep -v -f $(DIALYZE_IGNORE_WARN)
dialyzer --plt $(PLT) -r `find ./lib -name .eunit -print | xargs echo` | fgrep -v -f $(DIALYZE_IGNORE_WARN)
dialyze-proper-nospec: build-plt clean proper-compile
@echo "dialyzing .proper w/o spec: $(RELPKG) ..."
./rebar proper-compile
dialyzer --plt $(PLT) --no_spec -Wno_undefined_callbacks -r `find ./lib -name .eunit -print | xargs echo` | fgrep -v -f $(DIALYZE_NOSPEC_IGNORE_WARN)
ctags:
find ./lib -name "*.[he]rl" -print | fgrep -v .eunit | ctags -
find ./lib -name "*.app.src" -print | fgrep -v .eunit | ctags -a -
find ./lib -name "*.config" -print | fgrep -v .eunit | ctags -a -
find ./lib -name "*.[ch]" -print | fgrep -v .eunit | ctags -a -
etags:
find ./lib -name "*.[he]rl" -print | fgrep -v .eunit | etags -
find ./lib -name "*.app.src" -print | fgrep -v .eunit | etags -a -
find ./lib -name "*.config" -print | fgrep -v .eunit | etags -a -
find ./lib -name "*.[ch]" -print | fgrep -v .eunit | etags -a -
clean:
@echo "cleaning: $(RELPKG) ..."
./rebar clean
realclean: clean
@echo "realcleaning: $(RELPKG) ..."
rm -f $(PLT) TAGS
distclean:
@echo "distcleaning: $(RELPKG) ..."
repo forall -v -c 'git clean -fdx --exclude=lib/'
$(PLT):
@echo "building: $(PLT) ..."
dialyzer --build_plt --output_plt $(PLT) --apps \
asn1 \
compiler \
crypto \
dialyzer \
edoc \
erts \
et \
eunit \
gs \
hipe \
inets \
kernel \
mnesia \
observer \
parsetools \
public_key \
runtime_tools \
sasl \
ssl \
stdlib \
syntax_tools \
tools \
webtool \
xmerl
otp: otp.git
make -C $(CURDIR)/otp.git install
otp.git:
rm -rf $(CURDIR)/otp
mkdir -p $(CURDIR)/otp
git clone git://github.com/erlang/otp.git otp.git
(cd $(CURDIR)/otp.git && \
git co OTP_R15B && \
./otp_build autoconf && \
./configure \
--disable-hipe \
--enable-debug \
--enable-kernel-poll \
--enable-threads \
--enable-dynamic-ssl-lib \
--enable-shared-zlib \
--enable-smp-support \
$(otp_configure_flags) \
--prefix=$(CURDIR)/otp)
make -C $(CURDIR)/otp.git
otp-debug: otp.git
env ERL_TOP=$(CURDIR)/otp.git make -C otp.git/erts/emulator debug FLAVOR=smp
otp-valgrind: otp.git
env ERL_TOP=$(CURDIR)/otp.git make -C otp.git/erts/emulator valgrind FLAVOR=smp
cerl-debug: otp.git
env ERL_TOP=$(CURDIR)/otp.git otp.git/bin/cerl -debug
cerl-valgrind: otp.git
env ERL_TOP=$(CURDIR)/otp.git otp.git/bin/cerl -valgrind
## See https://github.com/erlang/otp/wiki/Running-tests for details
otp_make_release_tests: otp.git
rm -rf otp.git/release/tests
env ERL_TOP=$(CURDIR)/otp.git ERL_LIBS=$(CURDIR)/otp.git/lib \
make -C otp.git release_tests
otp_run_release_tests: otp_make_release_tests
@echo ""
@echo "** Warning killing all local beam, beam.smp, and epmd programs **"
@echo ""
sleep 10
killall -q -9 beam || true
killall -q -9 beam.smp || true
killall -q -9 epmd || true
@echo ""
@echo "** Open '$(CURDIR)/otp.git/release/tests/test_server/index.html' in your browser**"
@echo ""
sleep 10
(cd $(CURDIR)/otp.git/release/tests/test_server && \
env ERL_TOP=$(CURDIR)/otp.git ERL_LIBS=$(CURDIR)/otp.git/lib \
$(CURDIR)/otp.git/bin/erl \
-s ts install \
-s ts run \
-s erlang halt)