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