-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
122 lines (79 loc) · 2.66 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
# vim: set noet ts=8 sw=8:
.PHONY: units clean count build_tests tests dialyzer_plt dialyzer docs
ERLC ?= erlc
DIALYZER ?= dialyzer
EFLAGS += -DVSN='"$(VSN)"' +debug_info +warn_exported_vars +warn_unused_vars +warn_unused_import +warn_missing_spec
DFLAGS += -n -Wunmatched_returns -Wunderspecs -Wrace_conditions -Wbehaviours
ESRC ?= src
EBIN ?= ebin
TEST ?= test
SCRIPTS ?= scripts
include vsn.mk
VSN := $(PURITY_VSN)
FILES := purity purity_collect purity_analyse \
purity_cli purity_plt \
purity_utils purity_stats purity_bifs \
cl_parser core_aliases runtest
SRC := $(addsuffix .erl, $(FILES))
BIN := $(addprefix $(EBIN)/, $(addsuffix .beam, $(FILES)))
CHEATS := predef/cheats predef/bifs predef/primops
APP_FILE := purity.app
APP_SRC := $(APP_FILE).src
APP := $(EBIN)/$(APP_FILE)
GENERATED := $(ESRC)/purity_bifs.erl
TEST_SRC := $(wildcard $(TEST)/*.erl)
TEST_BIN := $(patsubst %.erl, %.beam, $(TEST_SRC))
all: $(EBIN) $(GENERATED) $(BIN) $(APP)
## Dependencies ##
## Generic rules ##
# Mercurial does not track empty directories, so create build dir if missing.
$(EBIN):
mkdir -p $(EBIN)
$(EBIN)/%.beam: $(ESRC)/%.erl $(ESRC)/%.hrl
@echo " h ERLC $<"
@$(ERLC) $(EFLAGS) -o $(EBIN) $<
$(EBIN)/%.beam: $(ESRC)/%.erl $(ESRC)/%_tests.hrl
@echo " t ERLC $<"
@$(ERLC) $(EFLAGS) -o $(EBIN) $<
$(EBIN)/%.beam: $(ESRC)/%.erl
@echo " ERLC $<"
@$(ERLC) $(EFLAGS) -o $(EBIN) $<
$(TEST)/%.beam: $(TEST)/%.erl
@echo "T ERLC $<"
@$(ERLC) $(EFLAGS) -o $(dir $<) $<
#.erl.beam:
%.beam: %.erl
$(ERLC) $(EFLAGS) -o $(dir $@) $<
%.html: %.txt
asciidoc $<
$(ESRC)/purity_bifs.erl: $(CHEATS)
@$(SCRIPTS)/purity_bifs $^ > $@
$(APP): $(ESRC)/$(APP_SRC) vsn.mk
sed -e 's/%VSN%/$(VSN)/' $< > $@
## Specific rules ##
build_tests: $(TEST_BIN)
@echo "Done building test files."
tests: $(BIN) build_tests
$(SCRIPTS)/runtests $(TEST_BIN)
units:
EFLAGS=-DTEST $(MAKE)
@./scripts/utests `echo src/*_tests.hrl | sed 's/_tests//g'`
dialyzer: $(EBIN) $(BIN)
$(DIALYZER) $(DFLAGS) -c $(BIN)
dialyzer_plt:
$(DIALYZER) --build_plt --apps erts compiler dialyzer hipe kernel stdlib syntax_tools
README.html: README.asciidoc TODO changelog
asciidoc -a numbered $<
# eDoc related stuff:
APP_NAME = purity
DOCOPTS = [{def,{vsn,"$(VSN)"}},{stylesheet,"style.css"},todo]
DOCFILES := $(addsuffix .html, $(FILES) index overview-summary modules-frame packages-frame)\
erlang.png edoc-info
docs:
erl -noshell -run edoc_run application "'$(APP_NAME)'" '"."' '$(DOCOPTS)'
clean:
$(RM) $(BIN)
distclean: clean
$(RM) $(TEST_BIN) $(GENERATED) $(APP) README.html $(addprefix doc/,$(DOCFILES))
count:
@sloccount . | awk '/^SLOC\t/,/^Total Physical/ { print }' | grep -v '^$$'