-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
58 lines (42 loc) · 1.75 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
ERL ?= erl
ERLC ?= $(ERL)c
EDOC ?= edoc
ifeq ($(NAME),)
NAME != $(ERL) -noshell -eval 'io:put_chars(filename:basename(hd(filelib:wildcard("src/*.app.src")), ".app.src")).' -s init stop
endif
ERLC_OPTS := +debug_info +inline
ERLC_DEFS := $(shell $(ERL) -noshell -eval 'is_binary(catch <<0:16/float>>) andalso io:put_chars("-DHAVE_float16")' -s init stop)
SOURCES = $(wildcard src/*.erl)
MODULES = $(SOURCES:src/%.erl=ebin/%.beam)
TEST_SOURCES = $(wildcard test/*.erl)
EUNIT_MODULES = $(SOURCES:src/%.erl=.eunit/%.beam) $(TEST_SOURCES:test/%.erl=.eunit/%.beam)
APP = ebin/$(NAME).app
APP_SRC = src/$(NAME).app.src
app: $(APP)
doc: doc/edoc-info
$(APP): $(APP_SRC) $(MODULES)
$(ERL) -noshell -eval '$(APP_SCRIPT)' -s init stop
$(MODULES): $(SOURCES) ebin/
$(ERLC) -o ebin $(ERLC_OPTS) $(ERLC_DEFS) $(SOURCES)
ebin/:
mkdir ebin
doc/edoc-info: $(SOURCES)
$(ERL) -noshell -eval "edoc:application('.', [$(EDOC_OPTS)])." -s init stop
$(EUNIT_MODULES): $(SOURCES) $(TEST_SOURCES) .eunit/
$(ERLC) -o .eunit $(ERLC_OPTS) $(ERLC_DEFS) -DTEST $(SOURCES) $(TEST_SOURCES)
.eunit/:
mkdir .eunit
eunit: $(EUNIT_MODULES)
cd .eunit && $(ERL) -noshell -eval 'eunit:test($(NAME), [$(EUNIT_OPTS)]).' -s init stop
clean:
rm -rf ebin doc .eunit
define APP_SCRIPT
{ok, [{application, $(NAME), L}]} = file:consult("$(APP_SRC)"), \
file:write_file("$(APP)", \
io_lib:format("{application, $(NAME), ~91p}.~n", \
[lists:keystore(modules, 1, L, \
{modules, \
lists:map(fun(F) -> list_to_atom(filename:basename(F, ".beam")) end, \
filelib:wildcard("*.beam", "ebin"))})]), \
[raw]).
endef