summaryrefslogtreecommitdiffstats
path: root/vnfs/VES5.0/evel/evel-library/bldjobs/Makefile
blob: ea30acca2e985df3419120a4d58f13be225d38ff (plain)
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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
#******************************************************************************
# The ECOMP Vendor Event Listener (EVEL) API client library Makefile.
#
# Make the various targets associated with housekeeping functions as part of
# Event Reporting library.
#
# NOTE: because Makefiles assign special meaning to the TAB character you
#       will need to set tabstops to 2 characters for the layout to look OK.
#
# License
# -------
#
# Copyright(c) <2016>, AT&T Intellectual Property.  All other rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
#    this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
#    this list of conditions and the following disclaimer in the documentation
#    and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
#    must display the following acknowledgement:  This product includes
#    software developed by the AT&T.
# 4. Neither the name of AT&T nor the names of its contributors may be used to
#    endorse or promote products derived from this software without specific
#    prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY AT&T INTELLECTUAL PROPERTY ''AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL AT&T INTELLECTUAL PROPERTY BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#******************************************************************************

ARCH=$(shell getconf LONG_BIT)
CODE_ROOT=$(CURDIR)/..
EVELLIB_ROOT=$(CODE_ROOT)/code/evel_library
EVELDEMO_ROOT=$(CODE_ROOT)/code/evel_demo
EVELUNIT_ROOT=$(CODE_ROOT)/code/evel_unit
EVELTRAINING_ROOT=$(CODE_ROOT)/code/evel_training
LIBS_DIR=$(CODE_ROOT)/libs/x86_$(ARCH)
OUTPUT_DIR=$(CODE_ROOT)/output/x86_$(ARCH)
DOCS_ROOT=$(CODE_ROOT)/docs
CC=gcc
SCP=scp
SSH=ssh
JAVA=java
DOXYGEN=doxygen
PLANTUML=/usr/local/bin/plantuml.jar
PLANTFLAGS=-tsvg

#******************************************************************************
# Standard compiler flags.                                                    *
#******************************************************************************
CPPFLAGS=-I $(EVELLIB_ROOT)
CFLAGS=-Wall -Wextra -m$(ARCH) -g -fPIC
LIBCFLAGS=-Wall -Wextra -m$(ARCH) -g -shared -fPIC

#******************************************************************************
# The testbed is a VM instance where we can install the EVEL example under    *
# CentOS.                                                                     *
#******************************************************************************
VNF_TESTBED_CENTOS=172.18.152.180
VNF_TESTBED_CENTOS_USER=centos
TESTBED_CENTOS_DOWNLOAD_PATH=/home/centos/download/evel_lib
TESTBED_CENTOS_INSTALL_PATH=/home/centos/evel

#******************************************************************************
# The testbed is a VM instance where we can install the EVEL example under    *
# Ubuntu.                                                                     *
#******************************************************************************
VNF_TESTBED_UBUNTU=172.18.152.179
VNF_TESTBED_UBUNTU_USER=ubuntu
TESTBED_UBUNTU_DOWNLOAD_PATH=/home/ubuntu/Downloads/evel_lib
TESTBED_UBUNTU_INSTALL_PATH=/home/ubuntu/evel

#******************************************************************************
# The test-collector is where we can send events to be consumed and checked   *
# during tests.                                                               *
#******************************************************************************
VNF_COLLECTOR_HOST=172.18.152.185
VNF_COLLECTOR_PORT=30000

#******************************************************************************
# A documentation server used by the team where we can install documentation. *
#******************************************************************************
TEAM_DOCS_SERVER=covlx8
DOCS_SERVER_PATH=/var/www/html/evel

#******************************************************************************
# Implicit rule to make dependency files.  Recipe copied from Gnu docs at:    *
# https://www.gnu.org/software/make/manual/html_node/Automatic-Prerequisites.html                                      *
#******************************************************************************
%.d: %.c
	@echo Making dependency file $(notdir $@) for $(notdir $<)
	@set -e; rm -f $@; \
         $(CC) -MM -MT $(<:.c=.o) $(CPPFLAGS) $< > $@.$$$$; \
         sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
         rm -f $@.$$$$

#******************************************************************************
# Implicit rule to make object files.                                         *
#******************************************************************************
%.o: %.c
	@echo Making $(notdir $@) from $(notdir $<)
	@$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<

#******************************************************************************
# Implicit rule to make diagram files using PlantUML.                         *
#******************************************************************************
%.svg : %.plantuml
	@echo Making $(notdir $@)
	$(JAVA) -jar $(PLANTUML) $(PLANTFLAGS) $<

all:     api_library \
         evel_library_demo \
         evel_library_training

clean:   api_library_clean \
         evel_unit_clean \
         evel_library_demo_clean \
         evel_library_training_clean \
         docs_clean

install: evel_install_centos evel_install_ubuntu

test: evel_test_centos evel_test_ubuntu

docs:    docs_clean doxygen_docs


#******************************************************************************
# Build the EVEL libraries.                                                   *
#******************************************************************************
API_SOURCES=$(EVELLIB_ROOT)/evel.c \
            $(EVELLIB_ROOT)/metadata.c \
            $(EVELLIB_ROOT)/ring_buffer.c \
            $(EVELLIB_ROOT)/double_list.c \
            $(EVELLIB_ROOT)/hashtable.c \
            $(EVELLIB_ROOT)/evel_event.c \
            $(EVELLIB_ROOT)/evel_fault.c \
            $(EVELLIB_ROOT)/evel_mobile_flow.c \
            $(EVELLIB_ROOT)/evel_option.c \
            $(EVELLIB_ROOT)/evel_jsonobject.c \
            $(EVELLIB_ROOT)/evel_other.c \
            $(EVELLIB_ROOT)/evel_json_buffer.c \
            $(EVELLIB_ROOT)/evel_reporting_measurement.c \
            $(EVELLIB_ROOT)/evel_heartbeat_fields.c \
            $(EVELLIB_ROOT)/evel_sipsignaling.c \
            $(EVELLIB_ROOT)/evel_scaling_measurement.c \
            $(EVELLIB_ROOT)/evel_state_change.c \
            $(EVELLIB_ROOT)/evel_strings.c \
            $(EVELLIB_ROOT)/evel_syslog.c \
            $(EVELLIB_ROOT)/evel_throttle.c \
            $(EVELLIB_ROOT)/evel_internal_event.c \
            $(EVELLIB_ROOT)/evel_event_mgr.c \
            $(EVELLIB_ROOT)/evel_voicequality.c \
            $(EVELLIB_ROOT)/evel_logging.c \
            $(EVELLIB_ROOT)/jsmn.c
API_OBJECTS=$(API_SOURCES:.c=.o)
-include $(API_SOURCES:.c=.d)

api_library: $(LIBS_DIR)/libevel.so \
             $(LIBS_DIR)/libevel.a

$(LIBS_DIR)/libevel.a: $(API_OBJECTS)
	@echo	Linking API Static Library
	@$(CC) $(LIBCFLAGS) -o $@ $+

$(LIBS_DIR)/libevel.so: $(API_OBJECTS)
	@echo	Linking API Shared Library
	@$(CC) $(LIBCFLAGS) -L $(QLIBCLIBSDIR) -lqlibc -o $@ $+

api_library_clean:
	@echo	Cleaning API Library
	@$(RM) $(LIBS_DIR)/libevel.so
	@$(RM) $(API_OBJECTS)
	@$(RM) $(EVELLIB_ROOT)/*.d

#******************************************************************************
# Build the EVEL library demo.                                                *
#******************************************************************************
DEMO_SOURCES=$(EVELDEMO_ROOT)/evel_demo.c $(EVELDEMO_ROOT)/evel_test_control.c
DEMO_OBJECTS=$(DEMO_SOURCES:.c=.o)
-include $(DEMO_SOURCES:.c=.d)

evel_library_demo: api_library \
                   $(OUTPUT_DIR)/evel_demo

$(OUTPUT_DIR)/evel_demo: $(DEMO_OBJECTS)
	@echo	Linking EVEL demo
	@$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ \
                          -L $(LIBS_DIR) \
                          $(DEMO_OBJECTS) \
                          -level \
                          -lpthread \
                          -lcurl

evel_library_demo_clean:
	@echo	Cleaning EVEL demo
	@$(RM) $(OUTPUT_DIR)/evel_demo
	@$(RM) $(API_OBJECTS)
	@$(RM) $(DEMO_OBJECTS)
	@$(RM) $(EVELLIB_ROOT)/*.d
	@$(RM) $(EVELDEMO_ROOT)/*.d

#******************************************************************************
# Build the EVEL library unit test.                                           *
#******************************************************************************
UNIT_SOURCES=$(EVELUNIT_ROOT)/evel_unit.c
UNIT_OBJECTS=$(UNIT_SOURCES:.c=.o)
-include $(UNIT_SOURCES:.c=.d)

evel_unit: api_library \
           $(OUTPUT_DIR)/evel_unit

$(OUTPUT_DIR)/evel_unit: $(UNIT_OBJECTS)
	@echo	Linking EVEL unit test
	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ \
                          -L $(LIBS_DIR) \
                          $(UNIT_OBJECTS) \
                          -level \
                          -lpthread \
                          -lcurl

evel_unit_clean:
	@echo	Cleaning EVEL unit test
	@$(RM) $(OUTPUT_DIR)/evel_unit
	@$(RM) $(API_OBJECTS)
	@$(RM) $(UNIT_OBJECTS)
	@$(RM) $(EVELLIB_ROOT)/*.d
	@$(RM) $(EVELUNIT_ROOT)/*.d

#******************************************************************************
# Build the EVEL library training files.                                      *
#******************************************************************************
evel_library_training:
	@echo	Making EVEL training
	@$(MAKE) -s -C $(EVELTRAINING_ROOT)/01-hello-world
	@$(MAKE) -s -C $(EVELTRAINING_ROOT)/02-library-link
	@$(MAKE) -s -C $(EVELTRAINING_ROOT)/03-include-header
	@$(MAKE) -s -C $(EVELTRAINING_ROOT)/04-basic-lifecycle
	@$(MAKE) -s -C $(EVELTRAINING_ROOT)/05-raise-event
	@$(MAKE) -s -C $(EVELTRAINING_ROOT)/06-username-password
	@$(MAKE) -s -C $(EVELTRAINING_ROOT)/07-raise-measurement
	@$(MAKE) -s -C $(EVELTRAINING_ROOT)/08-raise-mobile-flow
	@$(MAKE) -s -C $(EVELTRAINING_ROOT)/09-raise-state-change
	@$(MAKE) -s -C $(EVELTRAINING_ROOT)/10-raise-syslog
	@$(MAKE) -s -C $(EVELTRAINING_ROOT)/11-raise-other
	@$(MAKE) -s -C $(EVELTRAINING_ROOT)/12-suppress-fault-fields
	@$(MAKE) -s -C $(EVELTRAINING_ROOT)/13-suppress-fault-pairs
	@$(MAKE) -s -C $(EVELTRAINING_ROOT)/14-measurement-interval
	@$(MAKE) -s -C $(EVELTRAINING_ROOT)/15-raise-signaling
	@$(MAKE) -s -C $(EVELTRAINING_ROOT)/16-raise-service

evel_library_training_clean:
	@echo	Cleaning EVEL training
	@$(RM) $(EVELTRAINING_ROOT)/*/hello_evel_world

#******************************************************************************
# Copy the EVEL demo onto the CentOS testbed as a package and build it.       *
#******************************************************************************
evel_install_centos: delivery
	@echo Installing EVEL library on CentOS testbed...
	@$(SSH) $(VNF_TESTBED_CENTOS_USER)@$(VNF_TESTBED_CENTOS) \
          rm -rf $(TESTBED_CENTOS_DOWNLOAD_PATH) \; \
          mkdir -p $(TESTBED_CENTOS_DOWNLOAD_PATH) \; \
          mkdir -p $(TESTBED_CENTOS_INSTALL_PATH)
	@$(SCP) -r $(CODE_ROOT)/output/evel-library-package.tgz \
           $(VNF_TESTBED_CENTOS_USER)@$(VNF_TESTBED_CENTOS):$(TESTBED_CENTOS_DOWNLOAD_PATH)
	@$(SSH) $(VNF_TESTBED_CENTOS_USER)@$(VNF_TESTBED_CENTOS) \
          tar zx --directory $(TESTBED_CENTOS_INSTALL_PATH) \
                 --file $(TESTBED_CENTOS_DOWNLOAD_PATH)/evel-library-package.tgz
	@echo Making EVEL library on testbed...
	@$(SSH) $(VNF_TESTBED_CENTOS_USER)@$(VNF_TESTBED_CENTOS) \
           cd $(TESTBED_CENTOS_INSTALL_PATH)/bldjobs \; \
           make clean all

#******************************************************************************
# Copy the EVEL demo onto the Ubuntu testbed as a package and build it.       *
#******************************************************************************
evel_install_ubuntu: delivery
	@echo Installing EVEL library on Ubuntu testbed...
	@$(SSH) $(VNF_TESTBED_UBUNTU_USER)@$(VNF_TESTBED_UBUNTU) \
          rm -rf $(TESTBED_UBUNTU_DOWNLOAD_PATH) \; \
          mkdir -p $(TESTBED_UBUNTU_DOWNLOAD_PATH) \; \
          mkdir -p $(TESTBED_UBUNTU_INSTALL_PATH)
	@$(SCP) -r $(CODE_ROOT)/output/evel-library-package.tgz \
           $(VNF_TESTBED_UBUNTU_USER)@$(VNF_TESTBED_UBUNTU):$(TESTBED_UBUNTU_DOWNLOAD_PATH)
	@$(SSH) $(VNF_TESTBED_UBUNTU_USER)@$(VNF_TESTBED_UBUNTU) \
          tar zx --directory $(TESTBED_UBUNTU_INSTALL_PATH) \
                 --file $(TESTBED_UBUNTU_DOWNLOAD_PATH)/evel-library-package.tgz
	@echo Making EVEL library on testbed...
	@$(SSH) $(VNF_TESTBED_UBUNTU_USER)@$(VNF_TESTBED_UBUNTU) \
           cd $(TESTBED_UBUNTU_INSTALL_PATH)/bldjobs \; \
           make clean all

#******************************************************************************
# Make sure that the Centos platform is up to date and then run the software  *
# against a test collector.  Validating correct operation is not presently    *
# automated.                                                                  *
#******************************************************************************
evel_test_centos: evel_install_centos
	@echo Testing EVEL Demo application on CentOS...
	@$(SSH) $(VNF_TESTBED_CENTOS_USER)@$(VNF_TESTBED_CENTOS) \
           source .bash_profile \; \
           $(TESTBED_CENTOS_INSTALL_PATH)/output/x86_$(ARCH)/evel_demo \
                                                 --fqdn $(VNF_COLLECTOR_HOST) \
                                                 --port $(VNF_COLLECTOR_PORT) \
                                                 --verbose

#******************************************************************************
# Make sure that the Ubuntu platform is up to date and then run the software  *
# against a test collector.  Validating correct operation is not presently    *
# automated.                                                                  *
#******************************************************************************
evel_test_ubuntu: evel_install_ubuntu
	@echo Testing EVEL Demo application on Ubuntu...
	@$(SSH) $(VNF_TESTBED_UBUNTU_USER)@$(VNF_TESTBED_UBUNTU) \
           source .profile \; \
           $(TESTBED_UBUNTU_INSTALL_PATH)/output/x86_$(ARCH)/evel_demo \
                                                 --fqdn $(VNF_COLLECTOR_HOST) \
                                                 --port $(VNF_COLLECTOR_PORT) \
                                                 --verbose

#******************************************************************************
# Making a clean delivery has some very specific dependencies which are order *
# dependent, so we recursively make a series of targets to do a clean  build  *
# of all of the required deliverables and then finally zipping up.            *
#******************************************************************************
delivery:
	@$(MAKE) -s delivery_baseline
	@$(MAKE) -s package

delivery_baseline:	docs

#******************************************************************************
# Package the software for delivery.                                          *
#******************************************************************************
package: api_library_clean \
         evel_unit_clean \
         evel_library_demo_clean \
         evel_library_training_clean \
         docs
	@echo Packaging the software for delivery
	@cd $(CODE_ROOT) && tar cfz output/evel-library-package.tgz  bldjobs \
                                                      code \
                                                      docs \
                                                      libs/x86_64/README \
                                                      output/x86_64/README \
                                                      readme.md

package_clean:
	@echo Clean delivery packages
	@$(RM) $(OUTPUTDIR)/*.tgz

#******************************************************************************
# Create project documentation.                                               *
#******************************************************************************
doxygen_docs:
	@echo Making Doxygen documentation
	@$(DOXYGEN) Doxyfile

pdf_docs: doxygen_docs  # This target is slightly broken.  Run manually.
	@echo	Making PDF...
	@$(MAKE) -C $(DOCS_ROOT)/source/evel/latex

docs_clean:
	@echo Cleaning docs...
	@$(RM) $(DOCS_ROOT)/*.svg
	@$(RM) -r $(DOCS_ROOT)/source/evel/html \
	          $(DOCS_ROOT)/source/evel/latex

docs_install: docs
	@echo Copying docs to team web-server...
	@$(SCP) -r $(DOCS_ROOT)/source/evel/html/* \
	          root@$(TEAM_DOCS_SERVER):$(DOCS_SERVER_PATH)