Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
156 lines (122 loc) · 3.64 KB
/
Copy pathMakefile
File metadata and controls
156 lines (122 loc) · 3.64 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
ERL ?= erl
REBAR3 ?= rebar3
ERLFLAGS = -pa ./.eunit -pa ./ebin -pa ./deps/*/ebin
DEPS_PLT = ./.deps_plt
DEPS = erts kernel stdlib
REBAR = REBAR_GLOBAL_CONFIG_DIR=${HOME} REBAR_CACHE_DIR=${HOME}/.cache/rebar3 $(REBAR3)
CHECK_ERL = command -v $(ERL) >/dev/null 2>&1 || { echo "erlang (erl) is not installed" >&2; exit 1; }
CHECK_REBAR3 = command -v $(REBAR3) >/dev/null 2>&1 || { echo "rebar3 is not installed" >&2; exit 1; }
CHECK_PKGCONF = command -v pkg-config >/dev/null 2>&1 || { echo "pkg-config is not installed" >&2; exit 1; }
CHECK_EMACS = command -v emacs >/dev/null 2>&1 || { echo "emacs is not installed" >&2; exit 1; }
CHECK_GIT = command -v git >/dev/null 2>&1 || { echo "git is not installed" >&2; exit 1; }
CHECK_GIT_DESCRIBE = \
$(CHECK_GIT) ; \
git rev-parse --is-inside-work-tree >/dev/null 2>&1 || { echo "not a git checkout; version (git describe) cannot be computed" >&2; exit 1; } ; \
git describe --tags --match 'v*' >/dev/null 2>&1 || { \
echo "git describe failed (no tags reachable); fetch tags and full history (try: git fetch --tags --force --unshallow)" >&2; \
exit 1; \
}
CHECK_TOOLS = \
$(CHECK_ERL) ; \
$(CHECK_REBAR3) ; \
$(CHECK_PKGCONF)
CHECK_FORMAT_TOOLS = \
$(CHECK_TOOLS) ; \
$(CHECK_EMACS)
CHECK_RELEASE_TOOLS = \
$(CHECK_TOOLS) ; \
$(CHECK_GIT_DESCRIBE)
.PHONY: all compile doc clean lint format format-check tree test ct dialyzer \
typer shell distclean deps update-deps clean-common-test-data rebuild \
compile_test dev-toolchain build-dev build-release build-release-debug \
build-release-tar escript
all: build-release
deps:
@$(CHECK_TOOLS)
$(REBAR) get-deps
$(REBAR) compile
update-deps:
@$(CHECK_TOOLS)
$(REBAR) update-deps
$(REBAR) compile
compile:
@$(CHECK_TOOLS)
$(REBAR) compile
compile_test:
@$(CHECK_TOOLS)
$(REBAR) as test compile
lint:
@$(CHECK_TOOLS)
$(REBAR) lint
format:
@$(CHECK_FORMAT_TOOLS)
$(REBAR) fmt
format-check:
@$(CHECK_FORMAT_TOOLS) ; \
$(CHECK_GIT)
$(REBAR) fmt
git --no-pager diff --exit-code
tree:
@$(CHECK_TOOLS)
$(REBAR) tree
build-release:
@$(CHECK_RELEASE_TOOLS)
$(REBAR) as prod release
# CHECK_TOOLS only asks whether the tools exist. The dev environment is pinned
# to particular versions of them, so it checks for itself -- see the script.
dev-toolchain:
@./scripts/dev-toolchain.sh
build-dev: dev-toolchain
@$(CHECK_RELEASE_TOOLS)
$(REBAR) as dev release
build-release-debug:
@$(CHECK_RELEASE_TOOLS)
CFLAGS="$(CFLAGS) -v" \
LDFLAGS="$(LDFLAGS) -v" \
REBAR_DEBUG=1 \
$(REBAR) as prod release
build-release-tar:
@$(CHECK_RELEASE_TOOLS)
$(REBAR) as prod tar
doc:
@$(CHECK_TOOLS)
$(REBAR) doc
test: compile_test
@$(CHECK_TOOLS)
@APPS=$$(for d in applications/*; do \
if [ -d "$$d/test" ] && find "$$d/test" -type f -name "*test*.erl" -print 2>/dev/null | head -n 1 | grep -q .; then \
basename "$$d"; \
fi; \
done); \
KAZOO_CONFIG=./config/config-test.ini ERL_LIBS=./_build/test/lib/ ./scripts/eunit_run.escript $$APPS
ct:
@$(CHECK_TOOLS)
KAZOO_CONFIG=./config/config-test.ini $(REBAR) ct
$(DEPS_PLT):
@echo Building local plt at $(DEPS_PLT)
@echo
@$(CHECK_TOOLS)
dialyzer --output_plt $(DEPS_PLT) --build_plt --apps $(DEPS) -r apps
dialyzer: $(DEPS_PLT)
@$(CHECK_TOOLS)
dialyzer --fullpath --plt $(DEPS_PLT) -Wrace_conditions -r ./_build/default/lib
typer:
@$(CHECK_TOOLS)
typer --plt $(DEPS_PLT) -r ./src
shell: deps compile
@$(CHECK_TOOLS)
- @$(REBAR) skip_deps=true eunit
@$(ERL) $(ERLFLAGS)
clean:
@$(CHECK_TOOLS)
- rm -rf ./_build
$(REBAR) clean
distclean: clean
- rm -rf $(DEPS_PLT)
- rm -rvf ./deps
clean-common-test-data:
@:
escript:
@$(CHECK_TOOLS)
$(REBAR) escriptize
rebuild: distclean deps compile escript dialyzer test