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