/
Makefile
73 lines (56 loc) · 1.95 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
APP = echessd
VERSION = $(shell awk '{gsub("[()]","",$$2);print$$2;exit}' debian/changelog)
.PHONY: all compile html clean eunit dialyze all-tests
all: $(APP)
COPTS = {outdir, ebin}, {i, \"include\"}, warn_unused_function, \
warn_bif_clash, warn_deprecated_function, warn_obsolete_guard, verbose, \
warn_shadow_vars, warn_export_vars, warn_unused_records, \
warn_unused_import, warn_export_all, warnings_as_errors
ifdef DEBUG
COPTS := $(COPTS), debug_info
endif
ifdef TEST
COPTS := $(COPTS), {d, 'TEST'}
endif
compile:
mkdir -p ebin
sed "s/{{VERSION}}/$(VERSION)/" src/$(APP).app.in > ebin/$(APP).app
echo '["src/*"].' > Emakefile
erl -noinput -eval "up_to_date=make:all([$(COPTS)]),halt()"
$(APP): compile
rm -f -- $(APP).zip
zip -j $(APP) ebin/*
zip $(APP) priv/$(APP).lang priv/$(APP).styles priv/www/*
echo '#!/usr/bin/env escript' > $(APP)
echo '%%!-smp -kernel inet_dist_use_interface {127,0,0,1}' >> $(APP)
cat $(APP).zip >> $(APP)
rm -f -- $(APP).zip
chmod 755 $(APP)
FIGURES = $(patsubst %.dot, %.png, $(wildcard doc/*.dot))
EDOC_OPTS = {application, $(APP)}, {preprocess, true}
html: $(FIGURES)
sed "s/{{VERSION}}/$(VERSION)/" doc/overview.edoc.in > doc/overview.edoc
erl -noinput -eval 'edoc:application($(APP),".",[$(EDOC_OPTS)]),halt()'
%.png: %.dot
dot -T png $< > $@
eunit:
$(MAKE) TEST=y clean compile
erl -noinput -pa ebin \
-eval 'ok=eunit:test({application,$(APP)},[verbose]),halt()'
PLT = .dialyzer_plt
DIALYZER_OPTS = -Wunmatched_returns -Werror_handling
dialyze: $(PLT)
$(MAKE) DEBUG=y clean compile
dialyzer --plt $< -r . $(DIALYZER_OPTS) --src
dialyzer --plt $< -r . $(DIALYZER_OPTS)
$(PLT):
dialyzer --build_plt --output_plt $@ \
--apps erts inets kernel stdlib crypto compiler mnesia
all-tests:
$(MAKE) eunit
$(MAKE) dialyze
clean:
rm -rf -- ebin doc/*.html doc/*.css doc/*.png doc/edoc-info \
$(APP).zip $(APP) erl_crash.dump Emakefile doc/overview.edoc \
*.log *.log.* tmp_file
find . -type f -name '*~' -delete