aboutsummaryrefslogtreecommitdiffstats
path: root/lib/snmp/test/Makefile
blob: f22b7ea8eec818b0d8ddc033e404eb5109433bd7 (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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
#-*-makefile-*-   ; force emacs to enter makefile-mode

# %CopyrightBegin%
# 
# Copyright Ericsson AB 1997-2012. 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 = $(SNMP_VSN)


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

include modules.mk

SNMP_ROOT = ..
SNMP_SUITE = snmp_SUITE

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

SNMP_TEST_DATA = snmp_test_data

SNMP_MIB_DIR = $(SNMP_TEST_DATA)

SNMP_BIN_TARGET_DIR = $(SNMP_TEST_DATA)

MIB_SOURCE  = $(MIB_FILES:%.mib=$(SNMP_MIB_DIR)/%.mib)

MIB_TARGETS = \
	$(MIB_FILES:%.mib=$(SNMP_BIN_TARGET_DIR)/%.bin) \
	$(MIB_FILES:%.mib=$(SNMP_BIN_TARGET_DIR)/%.hrl)
ERL_TARGETS = $(MODULES:%=$(EBIN)/%.$(EMULATOR))

TEST_SERVER_TARGETS = $(TEST_SERVER_MODULES:%=$(EBIN)/%.$(EMULATOR))

TARGET_FILES = $(ERL_TARGETS) 

SOURCE = $(ERL_FILES) $(HRL_FILES) 

# The script 'make_emakefile' only exist in R9 and later
# So, if it does not exist, then use the old method
# (compile the erl-files and install the beam-files)
EMAKEFILE  = Emakefile
MAKE_EMAKE = $(wildcard $(ERL_TOP)/make/make_emakefile)

ifeq ($(MAKE_EMAKE),)
BUILDTARGET   = $(TARGET_FILES)
RELTEST_FILES = $(SPECS) $(SOURCE) $(TARGET_FILES)
else
BUILDTARGET   = $(MIB_TARGETS) emakebuild
RELTEST_FILES = $(EMAKEFILE) $(SPECS) $(SOURCE) 
endif

COVER_SPEC_FILE = snmp.cover


# ----------------------------------------------------
# Release directory specification
# ----------------------------------------------------
RELSYSDIR = $(RELEASE_PATH)/snmp_test


# ----------------------------------------------------
# SNMP FLAGS
# ----------------------------------------------------
ifeq ($(SNMP_DEBUG),)
  # SNMP_DEBUG = d
endif

ifeq ($(SNMP_DEBUG),e)
  SNMP_FLAGS += -Dsnmp_error
endif
ifeq ($(SNMP_DEBUG),l)
  SNMP_FLAGS += -Dsnmp_log
endif
ifeq ($(SNMP_DEBUG),d)
  SNMP_FLAGS += -Dsnmp_debug
endif

ifeq ($(DONT_USE_TS),true)
  SNMP_FLAGS += -DDONT_USE_TEST_SERVER
endif

SNMP_MIB_FLAGS += -pa ../ebin +version 

ifneq ($(MIBS_VERBOSITY),) 
  SNMP_MIB_FLAGS += +'{verbosity,$(MIBS_VERBOSITY)}'
endif

ifeq ($(SNMP_DESC),true)
  USE_DESCRIPTION = +'{description,true}'
endif

GROUP_CHECK = +'{group_check,false}'

SNMP_MIB_FLAGS += $(GROUP_CHECK) $(USE_DESCRIPTION) -I$(SNMP_BIN_TARGET_DIR)

ifndef SUITE
SUITE = snmp_SUITE
endif

ESTOP = -s init stop

ifeq ($(DONT_STOP),true)
MAYBE_ESTOP =
else
MAYBE_ESTOP = $(ESTOP)
endif

ifeq ($(MERL),)
MERL = erl
endif

ARGS += -noshell

ifeq ($(DISABLE_TC_TIMEOUT),true)
ARGS += -snmp_test_timeout
endif


# ----------------------------------------------------
# FLAGS
# ----------------------------------------------------
EBIN = .

ERL_COMPILE_FLAGS += -I../../snmp/src/app \
                     -I../../snmp/src/misc \
                     -I../../snmp/src/agent \
                     -I../../snmp/src/manager \
                     -I$(ERL_TOP)/lib/test_server/include \
                     -I../../snmp/include \
                     -Dsnmp_test_data=snmp_test_data \
                     -Dversion=\"$(VSN)$(PRE_VSN)\" \
                     +'{parse_transform,sys_pre_attributes}' \
                     +'{attribute,insert,app_vsn,$(APP_VSN)}' \
                     $(SNMP_FLAGS)

ERL_SNMP_FLAGS = $(SNMP_MIB_FLAGS) \
                 -I../priv/mibs

$(SNMP_BIN_TARGET_DIR)/%.bin: $(SNMP_MIB_DIR)/%.mib
	$(ERLC) $(ERL_SNMP_FLAGS) -o $(SNMP_MIB_DIR) $<

$(SNMP_BIN_TARGET_DIR)/%.hrl: $(SNMP_BIN_TARGET_DIR)/%.bin
	$(ERLC) $(ERL_SNMP_FLAGS) -o $(SNMP_BIN_TARGET_DIR) $<


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

tests debug opt: $(BUILDTARGET)

.PHONY: emakebuild

emakebuild: $(EMAKEFILE)

targets: mib $(EMAKEFILE) 
	erl -make

old_targets: $(TARGET_FILES) $(TEST_SERVER_TARGETS)

$(EMAKEFILE):  Makefile
	$(MAKE_EMAKE) $(ERL_COMPILE_FLAGS) -o$(EBIN) '*_SUITE_make' > $(EMAKEFILE)
	$(MAKE_EMAKE) $(ERL_COMPILE_FLAGS) -o$(EBIN) $(MODULES) >> $(EMAKEFILE)

clean:
	rm -f $(EMAKEFILE)
	rm -f $(TARGET_FILES) 
	rm -f core

docs:

appup: snmp_appup_mgr.$(EMULATOR)

mib: $(MIB_TARGETS)

make: old_targets

test: make
	$(MERL) $(ARGS) -sname snmp_test $(ERL_PATH) \
            -s snmp_test_server run $(SUITE) \
            $(MAYBE_ESTOP)

agent: make
	$(MERL) $(ARGS) -sname snmp_agent_test $(ERL_PATH) \
            -s snmp_test_server run snmp_agent_test \
            $(MAYBE_ESTOP)

manager: make
	$(MERL) $(ARGS) -sname snmp_manager_test $(ERL_PATH) \
            -s snmp_test_server run snmp_manager_test \
            $(MAYBE_ESTOP)

appup: make
	$(MERL) $(ARGS) -sname snmp_appup_test $(ERL_PATH) \
            -s snmp_test_server run snmp_appup_test \
            $(MAYBE_ESTOP)


$(SNMP_BIN_TARGET_DIR)/Klas4.bin: $(SNMP_BIN_TARGET_DIR)/Klas3.bin

$(SNMP_BIN_TARGET_DIR)/SA-MIB.bin: $(SNMP_BIN_TARGET_DIR)/OLD-SNMPEA-MIB.bin

$(SNMP_BIN_TARGET_DIR)/Test3.bin: $(SNMP_BIN_TARGET_DIR)/Test2.bin


# ----------------------------------------------------
# Release Target
# ---------------------------------------------------- 
include $(ERL_TOP)/make/otp_release_targets.mk

release_spec:

release_tests_spec: opt
	$(INSTALL_DIR) "$(RELSYSDIR)"
	$(INSTALL_DATA) $(RELTEST_FILES) $(COVER_SPEC_FILE) "$(RELSYSDIR)"
	chmod -R u+w "$(RELSYSDIR)"
	tar cf - snmp_test_data | (cd "$(RELSYSDIR)"; tar xf -)

release_docs_spec:


info:
	@echo "SNMP_DEBUG        = $(SNMP_DEBUG)"
	@echo "SNMP_FLAGS        = $(SNMP_FLAGS)"
	@echo ""
	@echo "SNMP_MIB_DIR      = $(SNMP_MIB_DIR)"
	@echo "MIB_SOURCE        = $(MIB_SOURCE)"
	@echo "MIB_TARGETS       = $(MIB_TARGETS)"
	@echo "SNMP_MIB_FLAGS    = $(SNMP_MIB_FLAGS)"
	@echo ""
	@echo "ERL_COMPILE_FLAGS = $(ERL_COMPILE_FLAGS)"
	@echo ""
	@echo "RELSYSDIR         = "$(RELSYSDIR)""
	@echo ""
	@echo "SOURCE            = $(SOURCE)"
	@echo ""
	@echo "TARGET_FILES      = $(TARGET_FILES)"
	@echo ""
	@echo "EMAKEFILE         = $(EMAKEFILE)"
	@echo "MAKE_EMAKE        = $(MAKE_EMAKE)"
	@echo "BUILDTARGET       = $(BUILDTARGET)"
	@echo "RELTEST_FILES     = $(RELTEST_FILES)"
	@echo ""