-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
97 lines (79 loc) · 2.77 KB
/
Makefile
File metadata and controls
97 lines (79 loc) · 2.77 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
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
include app.mk
# Special characters
comma := ,
empty :=
space := $(empty) $(empty)
# Compiler
ERL := erl
ERLC := erlc
# Default apps
SED := sed
RM := rm
RUN_TEST := run_test
# Application Layout
APPSRC := $(wildcard src/*.app.src)
APP := $(APPSRC:src/%.src=%)
APPNAME := $(APPSRC:src/%.app.src=%)
HRLS := $(wildcard include/*.hrl) $(wildcard src/*.hrl)
ERLS := $(wildcard src/*.erl)
BEAMS := $(ERLS:src/%.erl=ebin/%.beam)
MODS := $(subst $(space),$(comma),$(ERLS:src/%.erl=%))
OVERVIEW := $(wildcard doc/overview.edoc)
CONFSRC := $(wildcard test/conf/*.conf.src)
CONF := $(CONFSRC:.src=)
SPECSRC := $(wildcard test/conf/*.spec.src)
SPEC := $(SPECSRC:.src=)
TESTERLS := $(wildcard test/*_SUITE.erl)
TESTBEAMS := $(ERLS:src/%.erl=test/%.beam)
STUBERLS := $(wildcard test/stubs/*.erl)
STUBBEAMS := $(STUBERLS:.erl=.beam)
# Compiler options
EDOC_INCL := $(subst $(space),$(comma),$(INCLUDE:%="%"))
EDOC += {title,"$(APPNAME)"} {includes,[$(EDOC_INCL)]}
EDOC_OPTS := $(subst $(space),$(comma),$(strip $(EDOC)))
INCLUDE := $(INCLUDE:%=-I %)
CODE_PATH := $(CODE_PATH:%=-pa %)
TEST_EFLAGS += +debug_info
# Targets
.PHONY: all clean dialyze doc test
.SUFFIXES: .erl .hrl .beam .app.src .app .rel .conf.src .conf .spec.src .spec
all: $(BEAMS) ebin/$(APP)
doc: doc/index.html
test: $(TESTBEAMS) $(TESTERLS) $(STUBBEAMS) test/$(APP) $(CONF) $(SPEC)
$(RUN_TEST) -dir test/ -config ./test/conf/*.conf -spec ./test/conf/*.spec -cover ./test/conf/cover.conf
dialyze:
dialyzer --verbose --src -c src $(CODE_PATH) $(INCLUDE)
clean:
@$(RM) -f ebin/*.beam
@$(RM) -f ebin/*.app
@$(RM) -f doc/*.html
@$(RM) -f doc/edoc-info
@$(RM) -f doc/erlang.png
@$(RM) -f doc/stylesheet.css
@$(RM) -f test/*.beam
@$(RM) -f test/*.app
@$(RM) -f test/stubs/*.beam
@$(RM) -f test/variables-ct*
@$(RM) -rf test/log/*
@$(RM) -f test/conf/*.conf
@$(RM) -f test/conf/*.spec
# Rules
ebin/%.beam: src/%.erl $(HRLS) app.mk
$(ERLC) $(EFLAGS) $(INCLUDE) $(CODE_PATH) -o ebin $<
test/%.beam: src/%.erl $(HRLS) app.mk
$(ERLC) $(EFLAGS) $(INCLUDE) $(CODE_PATH) $(TEST_EFLAGS) -o test $<
test/stubs/%.beam: test/stubs/%.erl
$(ERLC) $(EFLAGS) $(INCLUDE) $(CODE_PATH) $(STUB_EFLAGS) -o test/stubs $<
%/$(APP): $(APPSRC) $(ERLS) app.mk
$(SED) -e "s;%APPNAME%;$(APPNAME);" \
-e "s;%MODULES%;$(MODS);" \
-e "s;%VSN%;$(VSN);" \
$< > $@
test/conf/%.conf: test/conf/%.conf.src
$(SED) -e "s;%MODULES%;$(MODS);g" \
-e "s;%TEST_DIR%;$(CURDIR)/test;g" \
$^ > $@
test/conf/%.spec: test/conf/%.spec.src
$(SED) "s;%TEST_DIR%;$(CURDIR)/test;g" $^ > $@
doc/index.html: $(ERLS) $(HRLS) $(OVERVIEW) app.mk
$(ERL) -noshell -run edoc_run application '$(APPNAME)' '"."' '[$(EDOC_OPTS)]'