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