aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/test/Makefile
blob: 47f84a8a42e9dee97ff2e5d543f980d6dcfc8c6f (plain) (blame)
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# 
# %CopyrightBegin%
#
# Copyright Ericsson AB 2010-2013. All Rights Reserved.
#
# The contents of this file are subject to the Erlang Public License,
# Version 1.1, (the "License"); you may not use this file except in
# compliance with the License. You should have received a copy of the
# Erlang Public License along with this software. If not, it can be
# retrieved online at http://www.erlang.org/.
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
# the License for the specific language governing rights and limitations
# under the License.
#
# %CopyrightEnd%

include $(ERL_TOP)/make/target.mk
include $(ERL_TOP)/make/$(TARGET)/otp.mk

# ----------------------------------------------------
# Application version
# ----------------------------------------------------

include ../vsn.mk

VSN = $(DIAMETER_VSN)

# ----------------------------------------------------
# Release directory specification
# ----------------------------------------------------

RELSYSDIR = $(RELEASE_PATH)/diameter_test

# ----------------------------------------------------
# Target Specs
# ----------------------------------------------------

include modules.mk

ERL_FILES    = $(MODULES:%=%.erl)
TARGET_FILES = $(MODULES:%=%.$(EMULATOR))

SUITE_MODULES = $(filter diameter_%_SUITE, $(MODULES))
SUITES        = $(SUITE_MODULES:diameter_%_SUITE=%)

DATA_DIRS = $(sort $(dir $(DATA)))

# ----------------------------------------------------
# FLAGS
# ----------------------------------------------------

# This is only used to compile suite locally when running with a
# target like 'all' below. Target release_tests only installs source.
ERL_COMPILE_FLAGS += +warn_export_vars \
                     +warn_unused_vars \
                     -I ../include \
                     -I ../src/gen \
                     $(STRICT_FLAGS)

# ----------------------------------------------------
# Targets
# ----------------------------------------------------

all debug opt: $(TARGET_FILES)

strict:
	$(MAKE) opt STRICT_FLAGS=-Werror

# Require success ...
run: $(SUITES)

# ... or not.
any: opt
	$(MAKE) -i $(SUITES)

clean:
	rm -f $(TARGET_FILES) 
	rm -f depend.mk

realclean: clean
	rm -rf log

docs:

list = echo $(1):; echo $($(1)) | tr ' ' '\n' | sort | sed 's@^@  @'

info:
	@echo ========================================
	@$(call list,MODULES)
	@echo
	@$(call list,HRL_FILES)
	@echo
	@$(call list,SUITES)
	@echo ========================================

help:
	@echo ========================================
	@echo "Useful targets:"
	@echo
	@echo "    all:"
	@echo "        Compile all test suites."
	@echo
	@echo "    run:"
	@echo "        Compile and run all test suites, stop on failure."
	@echo
	@echo "    any:"
	@echo "        Compile and run all test suites, ignore any failures."
	@echo
	@echo "    $(SUITES):"
	@echo "        Compile and run a specific test suite."
	@echo
	@echo "    clean | realclean:"
	@echo "        Remove generated files."
	@echo
	@echo "    info:"
	@echo "        Echo some relevant variables."
	@echo ========================================

.PHONY: all any run clean debug docs help info opt realclean strict

# ----------------------------------------------------
# Special Targets
# ----------------------------------------------------

# Exit with a non-zero status if the output looks to indicate failure.
# diameter_ct:run/1 itself can't tell (it seems). The absolute -pa is
# because ct will change directories.
$(SUITES): log opt
	$(ERL) -noinput \
	       -pa $(realpath ../ebin) \
	       -sname diameter_test_$@ \
	       -s diameter_ct run diameter_$@_SUITE \
	       -s init stop \
	| awk '{print} / FAILED /{rc=1} END{exit rc}' rc=0
# Shorter in sed but requires a GNU extension (ie. Q).

log:
	mkdir $@

.PHONY: $(SUITES)

# ----------------------------------------------------
# Release Targets
# ---------------------------------------------------- 

/%: % force
	sed -f release.sed $< > "$(RELSYSDIR)$@"

include $(ERL_TOP)/make/otp_release_targets.mk

release_spec release_docs_spec:

release_tests_spec:
	$(INSTALL_DIR)  "$(RELSYSDIR)"
	$(INSTALL_DATA) $(TEST_SPEC_FILE) \
	                $(COVER_SPEC_FILE) \
	                $(HRL_FILES) \
	                "$(RELSYSDIR)"
	$(MAKE) $(DATA_DIRS:%/=release_data_%)
	$(MAKE) $(ERL_FILES:%=/%)

$(DATA_DIRS:%/=release_data_%): release_data_%:
	$(INSTALL_DIR) "$(RELSYSDIR)/$*"
	$(INSTALL_DATA) $(filter $*/%, $(DATA)) "$(RELSYSDIR)/$*"

force:

.PHONY: release_spec release_docs_spec release_test_specs
.PHONY: force
.PHONY: $(DATA_DIRS:%/=release_data_%)

# Can't just make $(ERL_FILES:%=/%) phony since then implicit rule
# searching is skipped.

# ----------------------------------------------------

depend: depend.mk

# Generate dependencies makefile.
depend.mk: depend.sed $(MODULES:%=%.erl) Makefile
	(for f in $(MODULES); do \
	     (echo $$f; cat $$f.erl) | sed -f $<; \
	 done) \
	> $@

-include depend.mk

.PHONY: depend