srv6-mobile: Fix the coverity issues
[vpp.git] / Makefile
1 # Copyright (c) 2016 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 export WS_ROOT=$(CURDIR)
15 export BR=$(WS_ROOT)/build-root
16 CCACHE_DIR?=$(BR)/.ccache
17 GDB?=gdb
18 PLATFORM?=vpp
19 SAMPLE_PLUGIN?=no
20 STARTUP_DIR?=$(PWD)
21 MACHINE=$(shell uname -m)
22 SUDO?=sudo
23 DPDK_CONFIG?=no-pci
24
25 ,:=,
26 define disable_plugins
27 $(if $(1), \
28   "plugins {" \
29   $(patsubst %,"plugin %_plugin.so { disable }",$(subst $(,), ,$(1))) \
30   " }" \
31   ,)
32 endef
33
34 MINIMAL_STARTUP_CONF="                                                  \
35 unix {                                                                  \
36         interactive                                                     \
37         cli-listen /run/vpp/cli.sock                                    \
38         gid $(shell id -g)                                              \
39         $(if $(wildcard startup.vpp),"exec startup.vpp",)               \
40 }                                                                       \
41 $(if $(DPDK_CONFIG), "dpdk { $(DPDK_CONFIG) }",)                        \
42 $(call disable_plugins,$(DISABLED_PLUGINS))                             \
43 "
44
45 GDB_ARGS= -ex "handle SIGUSR1 noprint nostop"
46
47 #
48 # OS Detection
49 #
50 # We allow Darwin (MacOS) for docs generation; VPP build will still fail.
51 ifneq ($(shell uname),Darwin)
52 OS_ID        = $(shell grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
53 OS_VERSION_ID= $(shell grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
54 endif
55
56 ifeq ($(filter ubuntu debian,$(OS_ID)),$(OS_ID))
57 PKG=deb
58 else ifeq ($(filter rhel centos fedora opensuse opensuse-leap opensuse-tumbleweed,$(OS_ID)),$(OS_ID))
59 PKG=rpm
60 endif
61
62 # +libganglia1-dev if building the gmond plugin
63
64 DEB_DEPENDS  = curl build-essential autoconf automake ccache
65 DEB_DEPENDS += debhelper dkms git libtool libapr1-dev dh-systemd
66 DEB_DEPENDS += libconfuse-dev git-review exuberant-ctags cscope pkg-config
67 DEB_DEPENDS += lcov chrpath autoconf indent clang-format libnuma-dev
68 DEB_DEPENDS += python-all python3-all python3-setuptools
69 DEB_DEPENDS += python-virtualenv python-pip check
70 DEB_DEPENDS += libboost-all-dev libffi-dev python3-ply libmbedtls-dev
71 DEB_DEPENDS += cmake ninja-build uuid-dev python3-jsonschema python3-yaml
72 DEB_DEPENDS += python3-venv  # ensurepip
73 DEB_DEPENDS += python3-dev   # needed for python3 -m pip install psutil
74 # python3.6 on 16.04 requires python36-dev
75
76 LIBFFI=libffi6 # works on all but 20.04
77
78 ifeq ($(OS_VERSION_ID),16.04)
79         DEB_DEPENDS += python-dev
80         DEB_DEPENDS += libssl-dev
81 else ifeq ($(OS_VERSION_ID),18.04)
82         DEB_DEPENDS += python-dev
83         DEB_DEPENDS += libssl-dev
84 else ifeq ($(OS_VERSION_ID),20.04)
85         LIBFFI=libffi7
86 else ifeq ($(OS_ID)-$(OS_VERSION_ID),debian-8)
87         DEB_DEPENDS += libssl-dev
88         APT_ARGS = -t jessie-backports
89 else ifeq ($(OS_ID)-$(OS_VERSION_ID),debian-9)
90         DEB_DEPENDS += libssl1.0-dev
91 else
92         DEB_DEPENDS += libssl-dev
93 endif
94
95 DEB_DEPENDS += $(LIBFFI)
96
97 RPM_DEPENDS  = redhat-lsb glibc-static
98 RPM_DEPENDS += apr-devel
99 RPM_DEPENDS += numactl-devel
100 RPM_DEPENDS += check check-devel
101 RPM_DEPENDS += boost boost-devel
102 RPM_DEPENDS += selinux-policy selinux-policy-devel
103 RPM_DEPENDS += ninja-build
104 RPM_DEPENDS += libuuid-devel
105 RPM_DEPENDS += mbedtls-devel
106
107 ifeq ($(OS_ID),fedora)
108         RPM_DEPENDS += dnf-utils
109         RPM_DEPENDS += subunit subunit-devel
110         RPM_DEPENDS += compat-openssl10-devel
111         RPM_DEPENDS += python3-devel  # needed for python3 -m pip install psutil
112         RPM_DEPENDS += python3-ply  # for vppapigen
113         RPM_DEPENDS += python3-virtualenv python3-jsonschema
114         RPM_DEPENDS += cmake
115         RPM_DEPENDS_GROUPS = 'C Development Tools and Libraries'
116 else ifeq ($(OS_ID)-$(OS_VERSION_ID),centos-8)
117         RPM_DEPENDS += yum-utils
118         RPM_DEPENDS += compat-openssl10
119         RPM_DEPENDS += python36-devel python3-ply
120         RPM_DEPENDS += python3-virtualenv python3-jsonschema
121         RPM_DEPENDS += cmake
122         RPM_DEPENDS_GROUPS = 'Development Tools'
123 else
124         RPM_DEPENDS += yum-utils
125         RPM_DEPENDS += openssl-devel
126         RPM_DEPENDS += python36-ply  # for vppapigen
127         RPM_DEPENDS += python3-devel python3-pip
128         RPM_DEPENDS += python-virtualenv python36-jsonschema
129         RPM_DEPENDS += devtoolset-7
130         RPM_DEPENDS += cmake3
131         RPM_DEPENDS_GROUPS = 'Development Tools'
132 endif
133
134 # +ganglia-devel if building the ganglia plugin
135
136 RPM_DEPENDS += chrpath libffi-devel rpm-build
137 # lowercase- replace spaces with dashes.
138 SUSE_NAME= $(shell grep '^NAME=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g' | sed -e 's/ /-/' | awk '{print tolower($$0)}')
139 SUSE_ID= $(shell grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g' | cut -d' ' -f2)
140 RPM_SUSE_BUILDTOOLS_DEPS = autoconf automake ccache check-devel chrpath
141 RPM_SUSE_BUILDTOOLS_DEPS += clang cmake indent libtool make ninja python3-ply
142
143 RPM_SUSE_DEVEL_DEPS = glibc-devel-static libnuma-devel
144 RPM_SUSE_DEVEL_DEPS += libopenssl-devel openssl-devel mbedtls-devel libuuid-devel
145
146 RPM_SUSE_PYTHON_DEPS = python-devel python3-devel python-pip python3-pip
147 RPM_SUSE_PYTHON_DEPS += python-rpm-macros python3-rpm-macros
148
149 RPM_SUSE_PLATFORM_DEPS = distribution-release shadow rpm-build
150
151 ifeq ($(OS_ID),opensuse)
152 ifeq ($(SUSE_NAME),tumbleweed)
153         RPM_SUSE_DEVEL_DEPS = libboost_headers1_68_0-devel-1.68.0  libboost_thread1_68_0-devel-1.68.0 gcc
154         RPM_SUSE_PYTHON_DEPS += python3-ply python2-virtualenv
155 endif
156 ifeq ($(SUSE_ID),15.0)
157         RPM_SUSE_DEVEL_DEPS += libboost_headers-devel libboost_thread-devel gcc
158         RPM_SUSE_PYTHON_DEPS += python3-ply python2-virtualenv
159 else
160         RPM_SUSE_DEVEL_DEPS += libboost_headers1_68_0-devel-1.68.0 gcc6
161         RPM_SUSE_PYTHON_DEPS += python-virtualenv
162 endif
163 endif
164
165 ifeq ($(OS_ID),opensuse-leap)
166 ifeq ($(SUSE_ID),15.0)
167         RPM_SUSE_DEVEL_DEPS += libboost_headers-devel libboost_thread-devel gcc git curl
168         RPM_SUSE_PYTHON_DEPS += python3-ply python2-virtualenv
169 endif
170 endif
171
172 RPM_SUSE_DEPENDS += $(RPM_SUSE_BUILDTOOLS_DEPS) $(RPM_SUSE_DEVEL_DEPS) $(RPM_SUSE_PYTHON_DEPS) $(RPM_SUSE_PLATFORM_DEPS)
173
174 ifneq ($(wildcard $(STARTUP_DIR)/startup.conf),)
175         STARTUP_CONF ?= $(STARTUP_DIR)/startup.conf
176 endif
177
178 ifeq ($(findstring y,$(UNATTENDED)),y)
179 CONFIRM=-y
180 FORCE=--force-yes
181 endif
182
183 TARGETS = vpp
184
185 ifneq ($(SAMPLE_PLUGIN),no)
186 TARGETS += sample-plugin
187 endif
188
189 define banner
190         @echo "========================================================================"
191         @echo " $(1)"
192         @echo "========================================================================"
193         @echo " "
194 endef
195
196 .PHONY: help
197 help:
198         @echo "Make Targets:"
199         @echo " install-dep[s]       - install software dependencies"
200         @echo " wipe                 - wipe all products of debug build "
201         @echo " wipe-release         - wipe all products of release build "
202         @echo " build                - build debug binaries"
203         @echo " build-release        - build release binaries"
204         @echo " build-coverity       - build coverity artifacts"
205         @echo " rebuild              - wipe and build debug binaries"
206         @echo " rebuild-release      - wipe and build release binaries"
207         @echo " run                  - run debug binary"
208         @echo " run-release          - run release binary"
209         @echo " debug                - run debug binary with debugger"
210         @echo " debug-release        - run release binary with debugger"
211         @echo " test                 - build and run tests"
212         @echo " test-help            - show help on test framework"
213         @echo " run-vat              - run vpp-api-test tool"
214         @echo " pkg-deb              - build DEB packages"
215         @echo " pkg-deb-debug        - build DEB debug packages"
216         @echo " pkg-snap             - build SNAP package"
217         @echo " snap-clean           - clean up snap build environment"
218         @echo " vom-pkg-deb          - build vom DEB packages"
219         @echo " vom-pkg-deb-debug    - build vom DEB debug packages"
220         @echo " pkg-rpm              - build RPM packages"
221         @echo " install-ext-dep[s]   - install external development dependencies"
222         @echo " ctags                - (re)generate ctags database"
223         @echo " gtags                - (re)generate gtags database"
224         @echo " cscope               - (re)generate cscope database"
225         @echo " checkstyle           - check coding style"
226         @echo " checkstyle-commit    - check commit message format"
227         @echo " checkstyle-test      - check test framework coding style"
228         @echo " fixstyle             - fix coding style"
229         @echo " doxygen              - (re)generate documentation"
230         @echo " bootstrap-doxygen    - setup Doxygen dependencies"
231         @echo " wipe-doxygen         - wipe all generated documentation"
232         @echo " checkfeaturelist     - check FEATURE.yaml according to schema"
233         @echo " featurelist          - dump feature list in markdown"
234         @echo " json-api-files       - (re)-generate json api files"
235         @echo " json-api-files-debug - (re)-generate json api files for debug target"
236         @echo " docs                 - Build the Sphinx documentation"
237         @echo " docs-venv            - Build the virtual environment for the Sphinx docs"
238         @echo " docs-clean           - Remove the generated files from the Sphinx docs"
239         @echo ""
240         @echo "Make Arguments:"
241         @echo " V=[0|1]                  - set build verbosity level"
242         @echo " STARTUP_CONF=<path>      - startup configuration file"
243         @echo "                            (e.g. /etc/vpp/startup.conf)"
244         @echo " STARTUP_DIR=<path>       - startup directory (e.g. /etc/vpp)"
245         @echo "                            It also sets STARTUP_CONF if"
246         @echo "                            startup.conf file is present"
247         @echo " GDB=<path>               - gdb binary to use for debugging"
248         @echo " PLATFORM=<name>          - target platform. default is vpp"
249         @echo " TEST=<filter>            - apply filter to test set, see test-help"
250         @echo " DPDK_CONFIG=<conf>       - add specified dpdk config commands to"
251         @echo "                            autogenerated startup.conf"
252         @echo "                            (e.g. \"no-pci\" )"
253         @echo " SAMPLE_PLUGIN=yes        - in addition build/run/debug sample plugin"
254         @echo " DISABLED_PLUGINS=<list>  - comma separated list of plugins which"
255         @echo "                            should not be loaded"
256         @echo ""
257         @echo "Current Argument Values:"
258         @echo " V                 = $(V)"
259         @echo " STARTUP_CONF      = $(STARTUP_CONF)"
260         @echo " STARTUP_DIR       = $(STARTUP_DIR)"
261         @echo " GDB               = $(GDB)"
262         @echo " PLATFORM          = $(PLATFORM)"
263         @echo " DPDK_VERSION      = $(DPDK_VERSION)"
264         @echo " DPDK_CONFIG       = $(DPDK_CONFIG)"
265         @echo " SAMPLE_PLUGIN     = $(SAMPLE_PLUGIN)"
266         @echo " DISABLED_PLUGINS  = $(DISABLED_PLUGINS)"
267
268 $(BR)/.deps.ok:
269 ifeq ($(findstring y,$(UNATTENDED)),y)
270         make install-dep
271 endif
272 ifeq ($(filter ubuntu debian,$(OS_ID)),$(OS_ID))
273         @MISSING=$$(apt-get install -y -qq -s $(DEB_DEPENDS) | grep "^Inst ") ; \
274         if [ -n "$$MISSING" ] ; then \
275           echo "\nPlease install missing packages: \n$$MISSING\n" ; \
276           echo "by executing \"make install-dep\"\n" ; \
277           exit 1 ; \
278         fi ; \
279         exit 0
280 else ifneq ("$(wildcard /etc/redhat-release)","")
281         @for i in $(RPM_DEPENDS) ; do \
282             RPM=$$(basename -s .rpm "$${i##*/}" | cut -d- -f1,2,3)  ;   \
283             MISSING+=$$(rpm -q $$RPM | grep "^package")    ;    \
284         done                                                       ;    \
285         if [ -n "$$MISSING" ] ; then \
286           echo "Please install missing RPMs: \n$$MISSING\n" ; \
287           echo "by executing \"make install-dep\"\n" ; \
288           exit 1 ; \
289         fi ; \
290         exit 0
291 endif
292         @touch $@
293
294 .PHONY: bootstrap
295 bootstrap:
296         @echo "'make bootstrap' is not needed anymore"
297
298 .PHONY: install-dep
299 install-dep:
300 ifeq ($(filter ubuntu debian,$(OS_ID)),$(OS_ID))
301 ifeq ($(OS_VERSION_ID),14.04)
302         @sudo -E apt-get $(CONFIRM) $(FORCE) install software-properties-common
303 endif
304 ifeq ($(OS_ID)-$(OS_VERSION_ID),debian-8)
305         @grep -q jessie-backports /etc/apt/sources.list /etc/apt/sources.list.d/* 2> /dev/null \
306            || ( echo "Please install jessie-backports" ; exit 1 )
307 endif
308         @sudo -E apt-get update
309         @sudo -E apt-get $(APT_ARGS) $(CONFIRM) $(FORCE) install $(DEB_DEPENDS)
310 else ifneq ("$(wildcard /etc/redhat-release)","")
311 ifeq ($(OS_ID),rhel)
312         @sudo -E yum-config-manager --enable rhel-server-rhscl-7-rpms
313         @sudo -E yum groupinstall $(CONFIRM) $(RPM_DEPENDS_GROUPS)
314         @sudo -E yum install $(CONFIRM) $(RPM_DEPENDS)
315         @sudo -E debuginfo-install $(CONFIRM) glibc openssl-libs mbedtls-devel zlib
316 else ifeq ($(OS_ID)-$(OS_VERSION_ID),centos-8)
317         @sudo -E dnf groupinstall $(CONFIRM) $(RPM_DEPENDS_GROUPS)
318         @sudo -E dnf install $(CONFIRM) $(RPM_DEPENDS)
319 else ifeq ($(OS_ID),centos)
320         @sudo -E yum install $(CONFIRM) centos-release-scl-rh epel-release
321         @sudo -E yum groupinstall $(CONFIRM) $(RPM_DEPENDS_GROUPS)
322         @sudo -E yum install $(CONFIRM) $(RPM_DEPENDS)
323         @sudo -E debuginfo-install $(CONFIRM) glibc openssl-libs mbedtls-devel zlib
324 else ifeq ($(OS_ID),fedora)
325         @sudo -E dnf groupinstall $(CONFIRM) $(RPM_DEPENDS_GROUPS)
326         @sudo -E dnf install $(CONFIRM) $(RPM_DEPENDS)
327         @sudo -E debuginfo-install $(CONFIRM) glibc openssl-libs mbedtls-devel zlib
328 endif
329 else ifeq ($(filter opensuse-tumbleweed,$(OS_ID)),$(OS_ID))
330         @sudo -E zypper refresh
331         @sudo -E zypper install -y $(RPM_SUSE_DEPENDS)
332 else ifeq ($(filter opensuse-leap,$(OS_ID)),$(OS_ID))
333         @sudo -E zypper refresh
334         @sudo -E zypper install  -y $(RPM_SUSE_DEPENDS)
335 else ifeq ($(filter opensuse,$(OS_ID)),$(OS_ID))
336         @sudo -E zypper refresh
337         @sudo -E zypper install -y $(RPM_SUSE_DEPENDS)
338 else
339         $(error "This option currently works only on Ubuntu, Debian, RHEL, CentOS or openSUSE systems")
340 endif
341         git config commit.template .git_commit_template.txt
342
343 .PHONY: install-deps
344 install-deps: install-dep
345
346 define make
347         @make -C $(BR) PLATFORM=$(PLATFORM) TAG=$(1) $(2)
348 endef
349
350 $(BR)/scripts/.version:
351 ifneq ("$(wildcard /etc/redhat-release)","")
352         $(shell $(BR)/scripts/version rpm-string > $(BR)/scripts/.version)
353 else
354         $(shell $(BR)/scripts/version > $(BR)/scripts/.version)
355 endif
356
357 DIST_FILE = $(BR)/vpp-$(shell src/scripts/version).tar
358 DIST_SUBDIR = vpp-$(shell src/scripts/version|cut -f1 -d-)
359
360 .PHONY: dist
361 dist:
362         @if git rev-parse 2> /dev/null ; then \
363             git archive \
364               --prefix=$(DIST_SUBDIR)/ \
365               --format=tar \
366               -o $(DIST_FILE) \
367             HEAD ; \
368             git describe > $(BR)/.version ; \
369         else \
370             (cd .. ; tar -cf $(DIST_FILE) $(DIST_SUBDIR) --exclude=*.tar) ; \
371             src/scripts/version > $(BR)/.version ; \
372         fi
373         @tar --append \
374           --file $(DIST_FILE) \
375           --transform='s,.*/.version,$(DIST_SUBDIR)/src/scripts/.version,' \
376           $(BR)/.version
377         @$(RM) $(BR)/.version $(DIST_FILE).xz
378         @xz -v --threads=0 $(DIST_FILE)
379         @$(RM) $(BR)/vpp-latest.tar.xz
380         @ln -rs $(DIST_FILE).xz $(BR)/vpp-latest.tar.xz
381
382 .PHONY: build
383 build: $(BR)/.deps.ok
384         $(call make,$(PLATFORM)_debug,$(addsuffix -install,$(TARGETS)))
385
386 .PHONY: wipedist
387 wipedist:
388         @$(RM) $(BR)/*.tar.xz
389
390 .PHONY: wipe
391 wipe: wipedist test-wipe $(BR)/.deps.ok
392         $(call make,$(PLATFORM)_debug,$(addsuffix -wipe,$(TARGETS)))
393         @find . -type f -name "*.api.json" ! -path "./test/*" -exec rm {} \;
394
395 .PHONY: rebuild
396 rebuild: wipe build
397
398 .PHONY: build-release
399 build-release: $(BR)/.deps.ok
400         $(call make,$(PLATFORM),$(addsuffix -install,$(TARGETS)))
401
402 .PHONY: wipe-release
403 wipe-release: test-wipe $(BR)/.deps.ok
404         $(call make,$(PLATFORM),$(addsuffix -wipe,$(TARGETS)))
405
406 .PHONY: rebuild-release
407 rebuild-release: wipe-release build-release
408
409 libexpand = $(subst $(subst ,, ),:,$(foreach lib,$(1),$(BR)/install-$(2)-native/vpp/$(lib)/$(3)))
410
411 export TEST_DIR ?= $(WS_ROOT)/test
412 export RND_SEED ?= $(shell python3 -c 'import time; print(time.time())')
413
414 define test
415         $(if $(filter-out $(3),retest),make -C $(BR) PLATFORM=$(1) TAG=$(2) vpp-install,)
416         $(eval libs:=lib lib64)
417         make -C test \
418           VPP_BUILD_DIR=$(BR)/build-$(2)-native \
419           VPP_BIN=$(BR)/install-$(2)-native/vpp/bin/vpp \
420           VPP_PLUGIN_PATH=$(call libexpand,$(libs),$(2),vpp_plugins) \
421           VPP_TEST_PLUGIN_PATH=$(call libexpand,$(libs),$(2),vpp_api_test_plugins) \
422           VPP_INSTALL_PATH=$(BR)/install-$(2)-native/ \
423           LD_LIBRARY_PATH=$(call libexpand,$(libs),$(2),) \
424           EXTENDED_TESTS=$(EXTENDED_TESTS) \
425           PYTHON=$(PYTHON) \
426           OS_ID=$(OS_ID) \
427           RND_SEED=$(RND_SEED) \
428           CACHE_OUTPUT=$(CACHE_OUTPUT) \
429           $(3)
430 endef
431
432 .PHONY: test
433 test:
434         $(call test,vpp,vpp,test)
435
436 .PHONY: test-debug
437 test-debug:
438         $(call test,vpp,vpp_debug,test)
439
440 .PHONY: test-gcov
441 test-gcov:
442         $(call test,vpp,vpp_gcov,test)
443
444 .PHONY: test-all
445 test-all:
446         $(if $(filter-out $(3),retest),make -C $(BR) PLATFORM=vpp TAG=vpp vom-install,)
447         $(eval EXTENDED_TESTS=yes)
448         $(call test,vpp,vpp,test)
449
450 .PHONY: test-all-debug
451 test-all-debug:
452         $(if $(filter-out $(3),retest),make -C $(BR) PLATFORM=vpp TAG=vpp_debug vom-install,)
453         $(eval EXTENDED_TESTS=yes)
454         $(call test,vpp,vpp_debug,test)
455
456 .PHONY: papi-wipe
457 papi-wipe: test-wipe-papi
458         $(call banner,"This command is deprecated. Please use 'test-wipe-papi'")
459
460 .PHONY: test-wipe-papi
461 test-wipe-papi:
462         @make -C test papi-wipe
463
464 .PHONY: test-help
465 test-help:
466         @make -C test help
467
468 .PHONY: test-wipe
469 test-wipe:
470         @make -C test wipe
471
472 .PHONY: test-shell
473 test-shell:
474         $(call test,vpp,vpp,shell)
475
476 .PHONY: test-shell-debug
477 test-shell-debug:
478         $(call test,vpp,vpp_debug,shell)
479
480 .PHONY: test-shell-gcov
481 test-shell-gcov:
482         $(call test,vpp,vpp_gcov,shell)
483
484 .PHONY: test-dep
485 test-dep:
486         @make -C test test-dep
487
488 .PHONY: test-doc
489 test-doc:
490         @make -C test doc
491
492 .PHONY: test-wipe-doc
493 test-wipe-doc:
494         @make -C test wipe-doc
495
496 .PHONY: test-cov
497 test-cov:
498         @make -C $(BR) PLATFORM=vpp TAG=vpp_gcov vom-install
499         $(eval EXTENDED_TESTS=yes)
500         $(call test,vpp,vpp_gcov,cov)
501
502 .PHONY: test-wipe-cov
503 test-wipe-cov:
504         @make -C test wipe-cov
505
506 .PHONY: test-wipe-all
507 test-wipe-all:
508         @make -C test wipe-all
509
510 .PHONY: test-checkstyle
511 test-checkstyle:
512         @make -C test checkstyle
513
514 .PHONY: test-refresh-deps
515 test-refresh-deps:
516         @make -C test refresh-deps
517
518 .PHONY: retest
519 retest:
520         $(call test,vpp,vpp,retest)
521
522 .PHONY: retest-debug
523 retest-debug:
524         $(call test,vpp,vpp_debug,retest)
525
526 .PHONY: retest-all
527 retest-all:
528         $(eval EXTENDED_TESTS=yes)
529         $(call test,vpp,vpp,retest)
530
531 .PHONY: retest-all-debug
532 retest-all-debug:
533         $(eval EXTENDED_TESTS=yes)
534         $(call test,vpp,vpp_debug,retest)
535
536 ifeq ("$(wildcard $(STARTUP_CONF))","")
537 define run
538         @echo "WARNING: STARTUP_CONF not defined or file doesn't exist."
539         @echo "         Running with minimal startup config: $(MINIMAL_STARTUP_CONF)\n"
540         @cd $(STARTUP_DIR) && \
541           $(SUDO) $(2) $(1)/vpp/bin/vpp $(MINIMAL_STARTUP_CONF)
542 endef
543 else
544 define run
545         @cd $(STARTUP_DIR) && \
546           $(SUDO) $(2) $(1)/vpp/bin/vpp $(shell cat $(STARTUP_CONF) | sed -e 's/#.*//')
547 endef
548 endif
549
550 %.files: .FORCE
551         @find . \( -name '*\.[chyS]' -o -name '*\.java' -o -name '*\.lex' \) -and \
552                 \( -not -path './build-root*' -o -path \
553                 './build-root/build-vpp_debug-native/dpdk*' \) > $@
554
555 .FORCE:
556
557 .PHONY: run
558 run:
559         $(call run, $(BR)/install-$(PLATFORM)_debug-native)
560
561 .PHONY: run-release
562 run-release:
563         $(call run, $(BR)/install-$(PLATFORM)-native)
564
565 .PHONY: debug
566 debug:
567         $(call run, $(BR)/install-$(PLATFORM)_debug-native,$(GDB) $(GDB_ARGS) --args)
568
569 .PHONY: build-coverity
570 build-coverity:
571         $(call make,$(PLATFORM)_coverity,install-packages)
572
573 .PHONY: debug-release
574 debug-release:
575         $(call run, $(BR)/install-$(PLATFORM)-native,$(GDB) $(GDB_ARGS) --args)
576
577 .PHONY: build-vat
578 build-vat:
579         $(call make,$(PLATFORM)_debug,vpp-api-test-install)
580
581 .PHONY: run-vat
582 run-vat:
583         @$(SUDO) $(BR)/install-$(PLATFORM)_debug-native/vpp/bin/vpp_api_test
584
585 .PHONY: pkg-deb
586 pkg-deb:
587         $(call make,$(PLATFORM),vpp-package-deb)
588
589 .PHONY: pkg-snap
590 pkg-snap:
591         cd extras/snap ;                        \
592         ./prep ;                                \
593         SNAPCRAFT_BUILD_ENVIRONMENT_MEMORY=8G   \
594         SNAPCRAFT_BUILD_ENVIRONMENT_CPU=6       \
595         snapcraft --debug
596
597 .PHONY: snap-clean
598 snap-clean:
599         cd extras/snap ;                        \
600         snapcraft clean ;                       \
601         rm -f *.snap *.tgz
602
603 .PHONY: vom-pkg-deb
604 vom-pkg-deb: pkg-deb
605         $(call make,$(PLATFORM),vom-package-deb)
606
607 .PHONY: pkg-deb-debug
608 pkg-deb-debug:
609         $(call make,$(PLATFORM)_debug,vpp-package-deb)
610
611 .PHONY: vom-pkg-deb-debug
612 vom-pkg-deb-debug: pkg-deb-debug
613         $(call make,$(PLATFORM)_debug,vom-package-deb)
614
615 .PHONY: pkg-rpm
616 pkg-rpm: dist
617         make -C extras/rpm
618
619 .PHONY: pkg-srpm
620 pkg-srpm: dist
621         make -C extras/rpm srpm
622
623 .PHONY: dpdk-install-dev
624 dpdk-install-dev:
625         $(call banner,"This command is deprecated. Please use 'make install-ext-deps'")
626         make -C build/external install-$(PKG)
627
628 .PHONY: install-ext-deps
629 install-ext-deps:
630         make -C build/external install-$(PKG)
631
632 .PHONY: install-ext-dep
633 install-ext-dep: install-ext-deps
634
635 .PHONY: json-api-files
636 json-api-files:
637         $(WS_ROOT)/src/tools/vppapigen/generate_json.py
638
639 .PHONY: json-api-files-debug
640 json-api-files-debug:
641         $(WS_ROOT)/src/tools/vppapigen/generate_json.py --debug-target
642
643 .PHONY: ctags
644 ctags: ctags.files
645         @ctags --totals --tag-relative -L $<
646         @rm $<
647
648 .PHONY: gtags
649 gtags: ctags
650         @gtags --gtagslabel=ctags
651
652 .PHONY: cscope
653 cscope: cscope.files
654         @cscope -b -q -v
655
656 .PHONY: checkstyle
657 checkstyle: checkfeaturelist
658         @build-root/scripts/checkstyle.sh
659
660 .PHONY: checkstyle-commit
661 checkstyle-commit:
662         @extras/scripts/check_commit_msg.sh
663
664 .PHONY: checkstyle-test
665 checkstyle-test: test-checkstyle
666
667 .PHONY: checkstyle-all
668 checkstyle-all: checkstyle-commit checkstyle checkstyle-test
669
670 .PHONY: fixstyle
671 fixstyle:
672         @build-root/scripts/checkstyle.sh --fix
673
674 # necessary because Bug 1696324 - Update to python3.6 breaks PyYAML dependencies
675 # Status:       CLOSED CANTFIX
676 # https://bugzilla.redhat.com/show_bug.cgi?id=1696324
677 .PHONY: centos-pyyaml
678 centos-pyyaml:
679 ifeq ($(OS_ID)-$(OS_VERSION_ID),centos-7)
680         @python3 -m pip install pyyaml
681 endif
682 ifeq ($(OS_ID)-$(OS_VERSION_ID),centos-8)
683         @sudo -E yum install $(CONFIRM) python3-pyyaml
684 endif
685
686 .PHONY: featurelist
687 featurelist: centos-pyyaml
688         @build-root/scripts/fts.py --all --markdown
689
690 .PHONY: checkfeaturelist
691 checkfeaturelist: centos-pyyaml
692         @build-root/scripts/fts.py --validate --all
693
694 #
695 # Build the documentation
696 #
697
698 # Doxygen configuration and our utility scripts
699 export DOXY_DIR ?= $(WS_ROOT)/doxygen
700
701 define make-doxy
702         @OS_ID="$(OS_ID)" make -C $(DOXY_DIR) $@
703 endef
704
705 .PHONY: bootstrap-doxygen
706 bootstrap-doxygen:
707         $(call make-doxy)
708
709 .PHONY: doxygen
710 doxygen: bootstrap-doxygen
711         $(call make-doxy)
712
713 .PHONY: wipe-doxygen
714 wipe-doxygen:
715         $(call make-doxy)
716
717 # Sphinx Documents
718 export DOCS_DIR = $(WS_ROOT)/docs
719 export VENV_DIR = $(WS_ROOT)/sphinx_venv
720 export SPHINX_SCRIPTS_DIR = $(WS_ROOT)/docs/scripts
721
722 .PHONY: docs-venv
723 docs-venv:
724         @($(SPHINX_SCRIPTS_DIR)/sphinx-make.sh venv)
725
726 .PHONY: docs
727 docs: $(DOCS_DIR)
728         @($(SPHINX_SCRIPTS_DIR)/sphinx-make.sh html)
729
730 .PHONY: docs-clean
731 docs-clean:
732         @rm -rf $(DOCS_DIR)/_build
733         @rm -rf $(VENV_DIR)
734
735 .PHONY: pkg-verify
736 pkg-verify: install-dep $(BR)/.deps.ok install-ext-deps
737         $(call banner,"Building for PLATFORM=vpp using gcc")
738         @make -C build-root PLATFORM=vpp TAG=vpp wipe-all install-packages
739         $(call banner,"Building sample-plugin")
740         @make -C build-root PLATFORM=vpp TAG=vpp sample-plugin-install
741         $(call banner,"Building libmemif")
742         @make -C build-root PLATFORM=vpp TAG=vpp libmemif-install
743         $(call banner,"Building VOM")
744         @make -C build-root PLATFORM=vpp TAG=vpp vom-install
745         $(call banner,"Building $(PKG) packages")
746         @make pkg-$(PKG)
747 ifeq ($(OS_ID),ubuntu)
748         $(call banner,"Building VOM $(PKG) package")
749         @make vom-pkg-deb
750 endif
751
752 MAKE_VERIFY_GATE_OS ?= ubuntu-18.04
753 .PHONY: verify
754 verify: pkg-verify
755 ifeq ($(OS_ID)-$(OS_VERSION_ID),$(MAKE_VERIFY_GATE_OS))
756         $(call banner,"Testing vppapigen")
757         @src/tools/vppapigen/test_vppapigen.py
758         $(call banner,"Running tests")
759         @make COMPRESS_FAILED_TEST_LOGS=yes RETRIES=3 test
760 else
761         $(call banner,"Skipping tests. Tests under 'make verify' supported on $(MAKE_VERIFY_GATE_OS)")
762 endif