-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
57 lines (42 loc) · 1.28 KB
/
Copy pathMakefile
File metadata and controls
57 lines (42 loc) · 1.28 KB
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
.PHONY: all dialyze atomize test clean
all: atomizer
ERLS=$(wildcard src/*.erl)
HRLS=$(wildcard src/*.hrl)
BEAMS=$(ERLS:src/%.erl=ebin/%.beam)
ERLC_OPTS = -pa ebin +debug_info
atomizer: bin/atomizer
bin/atomizer: $(BEAMS)
mkdir -p bin
erl -noinput -eval '$(erl_build_escript)'
chmod +x bin/atomizer
ebin:
mkdir -p ebin
ebin/%.beam: src/%.erl $(HRLS) | ebin
erlc $(ERLC_OPTS) -o ebin $<
define erl_build_escript
FileList = [{filename:join("atomizer", Name), Bin} \
|| Name <- filelib:wildcard(filename:join("ebin", "*.{beam,app}")), \
{ok, Bin} <- [file:read_file(Name)]], \
{ok, {_Name, ZipBin}} = zip:zip("dummy-name", FileList, [memory]), \
EscriptBin = <<"#!/usr/bin/env escript\n" \
"%%\n" \
"%%! -escript main atomizer_cli\n", \
ZipBin/binary>>, \
ok = file:write_file("bin/atomizer", EscriptBin), halt().
endef
DIALYZER_PLT = plt/dialyzer.plt
export DIALYZER_PLT
PLT_APPS = erts kernel stdlib
DIALYZER_OPTS ?= -Werror_handling -Wrace_conditions
dialyze: $(BEAMS) $(DIALYZER_PLT)
dialyzer $(DIALYZER_OPTS) ebin
$(DIALYZER_PLT):
mkdir -p plt
dialyzer --build_plt --apps $(PLT_APPS) || test $$? -eq 2
atomize: atomizer
./bin/atomizer src
test: dialyze atomize
clean:
rm -rf bin ebin
cleanall: clean
rm -rf plt