-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
135 lines (107 loc) · 3.87 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
122
123
124
125
126
127
128
129
130
131
132
133
134
## ----------------------------------------------------------------------------
##
## Copyright (c) 2005 - 2012 Nebularis.
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included in
## all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
## FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
## IN THE SOFTWARE.
## ----------------------------------------------------------------------------
LOGLEVEL ?= 0
SOURCE_DIR=src
TEST_DIR=test
EBIN_DIR=ebin
DEPS=$(shell erl -noshell -eval '[io:format("~p~n", [element(1, D)]) || D <- proplists:get_value(deps, element(2, file:consult("rebar.config")))], halt(0).')
LATEST_STABLE=$(shell git log stable --oneline -1 --format="%h")
SYSTEST_EXE ?= ./priv/bin/systest
CT_FIXED = $(shell erl -noshell -eval 'io:format([list_to_integer(X) || X <- string:tokens(erlang:system_info(version), ".")] >= [5,10,3]), halt().')
## rules start here
REBAR=bin/rebar
REBAR_CLI=$(REBAR_OPTS) $(call erlc_minusd_flag,$(CT_FIXED),CT_FIXED)
define erlc_minusd_flag
$(if $(filter true,$(1)),-D$(2))
endef
.PHONY: all
all: escriptize
.PHONY: info
info: $(REBAR)
$(info SysTest $(shell git describe --abbrev=0 ${LATEST_STABLE}))
$(info $(shell $(REBAR) -V))
$(info 3rd Party Dependencies: ${DEPS})
$(info Executable: ${SYSTEST_EXE})
@true
.PHONY: clean
clean:
$(REBAR) skip_deps=true clean ${REBAR_OPTS}
.PHONY: doc
doc:
$(REBAR) skip_deps=true doc ${REBAR_OPTS}
.PHONY: publish-wiki
publish-wiki:
$(REBAR) skip_deps=true publish-wiki ${REBAR_OPTS}
.PHONY: dist-clean
dist-clean: clean
rm -rf deps
rm -rf bin
rm -rf priv/bin/systest*
rm -rf .eunit
compile: $(REBAR)
$(REBAR) get-deps compile ${REBAR_CLI}
$(SYSTEST_EXE): escriptize
.PHONY: escriptize
escriptize: compile
ERL_FLAGS="-pa ebin" \
$(REBAR) skip_deps=true escriptize ${REBAR_OPTS}
.PHONY: verify
verify:
ERL_FLAGS="-pa ebin" \
$(REBAR) skip_deps=true clean compile xref -v 4
.PHONY: eunit
eunit: $(REBAR)
$(REBAR) skip_deps=true -C test.config eunit ${REBAR_OPTS}
.PHONY: test-compile
test-compile: $(REBAR)
$(REBAR) skip_deps=true -C test.config test-compile ${REBAR_OPTS}
.PHONY: test-all
test-all: xref eunit test
.PHONY: xref
xref: compile
ERL_FLAGS="-pa deps/rebar/ebin" $(REBAR) skip_deps=true xref
.PHONY: test
test: escriptize test-default test-errors test-time-traps
.PHONY: test-dependencies
test-dependencies: escriptize test-compile
.PHONY: test-default
test-default: test-dependencies
$(call systest,$@,$(SYSTEST_FLAGS))
.PHONY: test-errors
test-errors: test-error-handling test-timeouts
.PHONY: test-error-handling
test-error-handling: test-dependencies
$(call systest,$@,-c $(SYSTEST_FLAGS))
.PHONY: test-timeouts
test-timeouts: test-dependencies
$(call systest,$@,-c $(SYSTEST_FLAGS))
.PHONY: test-time-traps
test-time-traps: test-dependencies
$(call systest,test-error-handling,-Z systest_error_handling_SUITE:timetrap_failure -ci)
bin/%:
mkdir -p deps
mkdir -p bin
git clone -b systest https://github.com/hyperthunk/$*.git deps/$*
PATH="bin:${PATH}" $(MAKE) -C deps/$*
cp deps/$*/$* bin/$*
include build/common.mk