http: fix user agent in request
[vpp.git] / Makefile
1 # Copyright (c) 2021 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 SHELL:=$(shell which bash)
18 GDB?=gdb
19 PLATFORM?=vpp
20 SAMPLE_PLUGIN?=no
21 STARTUP_DIR?=$(PWD)
22 MACHINE=$(shell uname -m)
23 SUDO?=sudo -E
24 DPDK_CONFIG?=no-pci
25
26 ifeq ($(strip $(SHELL)),)
27 $(error "bash not found, VPP requires bash to build")
28 endif
29
30 ,:=,
31 define disable_plugins
32 $(if $(1), \
33   "plugins {" \
34   $(patsubst %,"plugin %_plugin.so { disable }",$(subst $(,), ,$(1))) \
35   " }" \
36   ,)
37 endef
38
39 MINIMAL_STARTUP_CONF="                                                  \
40 unix {                                                                  \
41         interactive                                                     \
42         cli-listen /run/vpp/cli.sock                                    \
43         gid $(shell id -g)                                              \
44         $(if $(wildcard startup.vpp),"exec startup.vpp",)               \
45 }                                                                       \
46 $(if $(DPDK_CONFIG), "dpdk { $(DPDK_CONFIG) }",)                        \
47 $(if $(EXTRA_VPP_CONFIG), "$(EXTRA_VPP_CONFIG)",)                       \
48 $(call disable_plugins,$(DISABLED_PLUGINS))                             \
49 "
50
51 GDB_ARGS= -ex "handle SIGUSR1 noprint nostop"
52
53 #
54 # OS Detection
55 #
56 # We allow Darwin (MacOS) for docs generation; VPP build will still fail.
57 ifneq ($(shell uname),Darwin)
58 OS_ID        = $(shell grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
59 OS_VERSION_ID= $(shell grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
60 endif
61
62 ifeq ($(filter ubuntu debian linuxmint,$(OS_ID)),$(OS_ID))
63 PKG=deb
64 else ifeq ($(filter rhel centos fedora opensuse-leap rocky almalinux,$(OS_ID)),$(OS_ID))
65 PKG=rpm
66 endif
67
68 # +libganglia1-dev if building the gmond plugin
69
70 DEB_DEPENDS  = curl build-essential autoconf automake ccache
71 DEB_DEPENDS += debhelper dkms git libtool libapr1-dev dh-python
72 DEB_DEPENDS += libconfuse-dev git-review exuberant-ctags cscope pkg-config
73 DEB_DEPENDS += gcovr lcov chrpath autoconf libnuma-dev
74 DEB_DEPENDS += python3-all python3-setuptools check
75 DEB_DEPENDS += libffi-dev python3-ply
76 DEB_DEPENDS += cmake ninja-build python3-jsonschema python3-yaml
77 DEB_DEPENDS += python3-venv  # ensurepip
78 DEB_DEPENDS += python3-dev python3-pip
79 DEB_DEPENDS += libnl-3-dev libnl-route-3-dev libmnl-dev
80 # DEB_DEPENDS += enchant  # for docs
81 DEB_DEPENDS += python3-virtualenv
82 DEB_DEPENDS += libssl-dev
83 DEB_DEPENDS += libelf-dev libpcap-dev # for libxdp (af_xdp)
84 DEB_DEPENDS += iperf3 # for 'make test TEST=vcl'
85 DEB_DEPENDS += nasm
86 DEB_DEPENDS += iperf ethtool  # for 'make test TEST=vm_vpp_interfaces'
87 DEB_DEPENDS += libpcap-dev
88 DEB_DEPENDS += tshark
89 DEB_DEPENDS += jq # for extracting test summary from .json report (hs-test)
90
91 LIBFFI=libffi6 # works on all but 20.04 and debian-testing
92
93 ifeq ($(OS_VERSION_ID),22.04)
94         DEB_DEPENDS += python3-virtualenv
95         DEB_DEPENDS += libssl-dev
96         DEB_DEPENDS += clang clang-format-11
97         LIBFFI=libffi7
98         DEB_DEPENDS += enchant-2  # for docs
99 else ifeq ($(OS_VERSION_ID),20.04)
100         DEB_DEPENDS += python3-virtualenv
101         DEB_DEPENDS += libssl-dev
102         DEB_DEPENDS += clang clang-format-11
103         LIBFFI=libffi7
104         DEB_DEPENDS += enchant-2  # for docs
105 else ifeq ($(OS_VERSION_ID),20.10)
106         DEB_DEPENDS += clang clang-format-11
107         LIBFFI=libffi8ubuntu1
108 else ifeq ($(OS_ID)-$(OS_VERSION_ID),debian-10)
109         DEB_DEPENDS += virtualenv
110 else ifeq ($(OS_ID)-$(OS_VERSION_ID),debian-11)
111         DEB_DEPENDS += virtualenv
112         DEB_DEPENDS += clang clang-format-11
113         LIBFFI=libffi7
114 else ifeq ($(OS_ID)-$(OS_VERSION_ID),debian-12)
115         DEB_DEPENDS += virtualenv
116         DEB_DEPENDS += clang-14 clang-format-14
117         # for extras/scripts/checkstyle.sh
118         export CLANG_FORMAT_VER=14
119         LIBFFI=libffi8
120 else
121         DEB_DEPENDS += clang-11 clang-format-11
122         LIBFFI=libffi7
123         DEB_DEPENDS += enchant-2  # for docs
124 endif
125
126 DEB_DEPENDS += $(LIBFFI)
127
128 RPM_DEPENDS  = glibc-static
129 RPM_DEPENDS += apr-devel
130 RPM_DEPENDS += numactl-devel
131 RPM_DEPENDS += check check-devel
132 RPM_DEPENDS += selinux-policy selinux-policy-devel
133 RPM_DEPENDS += ninja-build
134 RPM_DEPENDS += ccache
135 RPM_DEPENDS += xmlto
136 RPM_DEPENDS += elfutils-libelf-devel libpcap-devel
137 RPM_DEPENDS += libnl3-devel libmnl-devel
138 RPM_DEPENDS += nasm
139
140 ifeq ($(OS_ID),fedora)
141         RPM_DEPENDS += dnf-utils
142         RPM_DEPENDS += subunit subunit-devel
143         RPM_DEPENDS += compat-openssl10-devel
144         RPM_DEPENDS += python3-devel  # needed for python3 -m pip install psutil
145         RPM_DEPENDS += python3-ply  # for vppapigen
146         RPM_DEPENDS += python3-virtualenv python3-jsonschema
147         RPM_DEPENDS += cmake
148         RPM_DEPENDS_GROUPS = 'C Development Tools and Libraries'
149 else ifeq ($(OS_ID),rocky)
150         RPM_DEPENDS += yum-utils
151         RPM_DEPENDS += subunit subunit-devel
152         RPM_DEPENDS += openssl-devel
153         RPM_DEPENDS += python3-devel  # needed for python3 -m pip install psutil
154         RPM_DEPENDS += python3-ply  # for vppapigen
155         RPM_DEPENDS += python3-virtualenv python3-jsonschema
156         RPM_DEPENDS += infiniband-diags llvm clang cmake
157         RPM_DEPENDS_GROUPS = 'Development Tools'
158 else ifeq ($(OS_ID),almalinux)
159         RPM_DEPENDS += yum-utils
160         RPM_DEPENDS += subunit subunit-devel
161         RPM_DEPENDS += openssl-devel
162         RPM_DEPENDS += python3-devel  # needed for python3 -m pip install psutil
163         RPM_DEPENDS += python3-ply  # for vppapigen
164         RPM_DEPENDS += python3-virtualenv python3-jsonschema
165         RPM_DEPENDS += infiniband-diags llvm clang cmake
166         RPM_DEPENDS_GROUPS = 'Development Tools'
167 else ifeq ($(OS_ID)-$(OS_VERSION_ID),centos-8)
168         RPM_DEPENDS += yum-utils
169         RPM_DEPENDS += compat-openssl10 openssl-devel
170         RPM_DEPENDS += python2-devel python36-devel python3-ply
171         RPM_DEPENDS += python3-virtualenv python3-jsonschema
172         RPM_DEPENDS += libarchive cmake
173         RPM_DEPENDS += infiniband-diags libibumad
174         RPM_DEPENDS += libpcap-devel llvm-toolset
175         RPM_DEPENDS_GROUPS = 'Development Tools'
176 else
177         RPM_DEPENDS += yum-utils
178         RPM_DEPENDS += openssl-devel
179         RPM_DEPENDS += python36-ply  # for vppapigen
180         RPM_DEPENDS += python3-devel python3-pip
181         RPM_DEPENDS += python-virtualenv python36-jsonschema
182         RPM_DEPENDS += devtoolset-9 devtoolset-9-libasan-devel
183         RPM_DEPENDS += cmake3
184         RPM_DEPENDS_GROUPS = 'Development Tools'
185 endif
186
187 # +ganglia-devel if building the ganglia plugin
188
189 RPM_DEPENDS += chrpath libffi-devel rpm-build
190
191 RPM_DEPENDS_DEBUG  = glibc-debuginfo e2fsprogs-debuginfo
192 RPM_DEPENDS_DEBUG += krb5-debuginfo openssl-debuginfo
193 RPM_DEPENDS_DEBUG += zlib-debuginfo nss-softokn-debuginfo
194 RPM_DEPENDS_DEBUG += yum-plugin-auto-update-debug-info
195
196 RPM_SUSE_BUILDTOOLS_DEPS = autoconf automake ccache check-devel chrpath
197 RPM_SUSE_BUILDTOOLS_DEPS += clang cmake indent libtool make ninja python3-ply
198
199 RPM_SUSE_DEVEL_DEPS = glibc-devel-static libnuma-devel libelf-devel
200 RPM_SUSE_DEVEL_DEPS += libopenssl-devel lsb-release
201 RPM_SUSE_DEVEL_DEPS += libpcap-devel llvm-devel
202 RPM_SUSE_DEVEL_DEPS += curl libstdc++-devel bison gcc-c++ zlib-devel
203
204 RPM_SUSE_PYTHON_DEPS = python3-devel python3-pip python3-rpm-macros
205
206 RPM_SUSE_PLATFORM_DEPS = shadow rpm-build
207
208 ifeq ($(OS_ID),opensuse-leap)
209         RPM_SUSE_DEVEL_DEPS += xmlto openssl-devel asciidoc git nasm
210         RPM_SUSE_PYTHON_DEPS += python3 python3-ply python3-virtualenv
211         RPM_SUSE_PLATFORM_DEPS += distribution-release
212 endif
213
214 RPM_SUSE_DEPENDS += $(RPM_SUSE_BUILDTOOLS_DEPS) $(RPM_SUSE_DEVEL_DEPS) $(RPM_SUSE_PYTHON_DEPS) $(RPM_SUSE_PLATFORM_DEPS)
215
216 ifneq ($(wildcard $(STARTUP_DIR)/startup.conf),)
217         STARTUP_CONF ?= $(STARTUP_DIR)/startup.conf
218 endif
219
220 ifeq ($(findstring y,$(UNATTENDED)),y)
221 DEBIAN_FRONTEND=noninteractive
222 CONFIRM=-y
223 FORCE=--allow-downgrades --allow-remove-essential --allow-change-held-packages
224 endif
225
226 TARGETS = vpp
227
228 ifneq ($(SAMPLE_PLUGIN),no)
229 TARGETS += sample-plugin
230 endif
231
232 define banner
233         @echo "========================================================================"
234         @echo " $(1)"
235         @echo "========================================================================"
236         @echo " "
237 endef
238
239 .PHONY: help
240 help:
241         @echo "Make Targets:"
242         @echo " install-dep[s]       - install software dependencies"
243         @echo " wipe                 - wipe all products of debug build "
244         @echo " wipe-release         - wipe all products of release build "
245         @echo " build                - build debug binaries"
246         @echo " build-release        - build release binaries"
247         @echo " build-coverity       - build coverity artifacts"
248         @echo " rebuild              - wipe and build debug binaries"
249         @echo " rebuild-release      - wipe and build release binaries"
250         @echo " run                  - run debug binary"
251         @echo " run-release          - run release binary"
252         @echo " debug                - run debug binary with debugger"
253         @echo " debug-release        - run release binary with debugger"
254         @echo " test                 - build and run tests"
255         @echo " test-help            - show help on test framework"
256         @echo " run-vat              - run vpp-api-test tool"
257         @echo " pkg-deb              - build DEB packages"
258         @echo " pkg-deb-debug        - build DEB debug packages"
259         @echo " pkg-snap             - build SNAP package"
260         @echo " snap-clean           - clean up snap build environment"
261         @echo " pkg-rpm              - build RPM packages"
262         @echo " install-ext-dep[s]   - install external development dependencies"
263         @echo " ctags                - (re)generate ctags database"
264         @echo " gtags                - (re)generate gtags database"
265         @echo " cscope               - (re)generate cscope database"
266         @echo " compdb               - (re)generate compile_commands.json"
267         @echo " checkstyle           - check coding style"
268         @echo " checkstyle-commit    - check commit message format"
269         @echo " checkstyle-python    - check python coding style using 'black' formatter"
270         @echo " checkstyle-api       - check api for incompatible changes"
271         @echo " fixstyle             - fix coding style"
272         @echo " fixstyle-python      - fix python coding style using 'black' formatter"
273         @echo " doxygen              - DEPRECATED - use 'make docs'"
274         @echo " bootstrap-doxygen    - DEPRECATED"
275         @echo " wipe-doxygen         - DEPRECATED"
276         @echo " checkfeaturelist     - check FEATURE.yaml according to schema"
277         @echo " featurelist          - dump feature list in markdown"
278         @echo " json-api-files       - (re)-generate json api files"
279         @echo " json-api-files-debug - (re)-generate json api files for debug target"
280         @echo " go-api-files         - (re)-generate golang api files"
281         @echo " docs                 - Build the Sphinx documentation"
282         @echo " docs-venv            - Build the virtual environment for the Sphinx docs"
283         @echo " docs-clean           - Remove the generated files from the Sphinx docs"
284         @echo " docs-rebuild         - Rebuild all of the Sphinx documentation"
285         @echo ""
286         @echo "Make Arguments:"
287         @echo " V=[0|1]                  - set build verbosity level"
288         @echo " STARTUP_CONF=<path>      - startup configuration file"
289         @echo "                            (e.g. /etc/vpp/startup.conf)"
290         @echo " STARTUP_DIR=<path>       - startup directory (e.g. /etc/vpp)"
291         @echo "                            It also sets STARTUP_CONF if"
292         @echo "                            startup.conf file is present"
293         @echo " GDB=<path>               - gdb binary to use for debugging"
294         @echo " PLATFORM=<name>          - target platform. default is vpp"
295         @echo " DPDK_CONFIG=<conf>       - add specified dpdk config commands to"
296         @echo "                            autogenerated startup.conf"
297         @echo "                            (e.g. \"no-pci\" )"
298         @echo " SAMPLE_PLUGIN=yes        - in addition build/run/debug sample plugin"
299         @echo " DISABLED_PLUGINS=<list>  - comma separated list of plugins which"
300         @echo "                            should not be loaded"
301         @echo ""
302         @echo "Current Argument Values:"
303         @echo " V                 = $(V)"
304         @echo " STARTUP_CONF      = $(STARTUP_CONF)"
305         @echo " STARTUP_DIR       = $(STARTUP_DIR)"
306         @echo " GDB               = $(GDB)"
307         @echo " PLATFORM          = $(PLATFORM)"
308         @echo " DPDK_VERSION      = $(DPDK_VERSION)"
309         @echo " DPDK_CONFIG       = $(DPDK_CONFIG)"
310         @echo " SAMPLE_PLUGIN     = $(SAMPLE_PLUGIN)"
311         @echo " DISABLED_PLUGINS  = $(DISABLED_PLUGINS)"
312
313 $(BR)/.deps.ok:
314 ifeq ($(findstring y,$(UNATTENDED)),y)
315         $(MAKE) install-dep
316 endif
317 ifeq ($(filter ubuntu debian linuxmint,$(OS_ID)),$(OS_ID))
318         @MISSING=$$(apt-get install -y -qq -s $(DEB_DEPENDS) | grep "^Inst ") ; \
319         if [ -n "$$MISSING" ] ; then \
320           echo "\nPlease install missing packages: \n$$MISSING\n" ; \
321           echo "by executing \"make install-dep\"\n" ; \
322           exit 1 ; \
323         fi ; \
324         exit 0
325 else ifneq ("$(wildcard /etc/redhat-release)","")
326         @for i in $(RPM_DEPENDS) ; do \
327             RPM=$$(basename -s .rpm "$${i##*/}" | cut -d- -f1,2,3,4)  ; \
328             MISSING+=$$(rpm -q $$RPM | grep "^package")    ;    \
329         done                                                       ;    \
330         if [ -n "$$MISSING" ] ; then \
331           echo "Please install missing RPMs: \n$$MISSING\n" ; \
332           echo "by executing \"make install-dep\"\n" ; \
333           exit 1 ; \
334         fi ; \
335         exit 0
336 endif
337         @touch $@
338
339 .PHONY: bootstrap
340 bootstrap:
341         @echo "'make bootstrap' is not needed anymore"
342
343 .PHONY: install-dep
344 install-dep:
345 ifeq ($(filter ubuntu debian linuxmint,$(OS_ID)),$(OS_ID))
346         @sudo -E apt-get update
347         @sudo -E apt-get $(APT_ARGS) $(CONFIRM) $(FORCE) install $(DEB_DEPENDS)
348 else ifneq ("$(wildcard /etc/redhat-release)","")
349 ifeq ($(OS_ID),rhel)
350         @sudo -E yum-config-manager --enable rhel-server-rhscl-7-rpms
351         @sudo -E yum groupinstall $(CONFIRM) $(RPM_DEPENDS_GROUPS)
352         @sudo -E yum install $(CONFIRM) $(RPM_DEPENDS)
353         @sudo -E debuginfo-install $(CONFIRM) glibc openssl-libs zlib
354 else ifeq ($(OS_ID),rocky)
355         @sudo -E dnf install $(CONFIRM) dnf-plugins-core epel-release
356         @sudo -E dnf config-manager --set-enabled \
357           $(shell dnf repolist all 2>/dev/null|grep -i crb|cut -d' ' -f1|grep -v source)
358         @sudo -E dnf groupinstall $(CONFIRM) $(RPM_DEPENDS_GROUPS)
359         @sudo -E dnf install $(CONFIRM) $(RPM_DEPENDS)
360 else ifeq ($(OS_ID)-$(OS_VERSION_ID),centos-8)
361         @sudo -E dnf install $(CONFIRM) dnf-plugins-core epel-release
362         @sudo -E dnf config-manager --set-enabled \
363           $(shell dnf repolist all 2>/dev/null|grep -i powertools|cut -d' ' -f1|grep -v source)
364         @sudo -E dnf groupinstall $(CONFIRM) $(RPM_DEPENDS_GROUPS)
365         @sudo -E dnf install --skip-broken $(CONFIRM) $(RPM_DEPENDS)
366 else ifeq ($(OS_ID),centos)
367         @sudo -E yum install $(CONFIRM) centos-release-scl-rh epel-release
368         @sudo -E yum groupinstall $(CONFIRM) $(RPM_DEPENDS_GROUPS)
369         @sudo -E yum install $(CONFIRM) $(RPM_DEPENDS)
370         @sudo -E yum install $(CONFIRM) --enablerepo=base-debuginfo $(RPM_DEPENDS_DEBUG)
371 else ifeq ($(OS_ID),fedora)
372         @sudo -E dnf groupinstall $(CONFIRM) $(RPM_DEPENDS_GROUPS)
373         @sudo -E dnf install $(CONFIRM) $(RPM_DEPENDS)
374         @sudo -E debuginfo-install $(CONFIRM) glibc openssl-libs zlib
375 endif
376 else ifeq ($(filter opensuse-leap-15.3 opensuse-leap-15.4 ,$(OS_ID)-$(OS_VERSION_ID)),$(OS_ID)-$(OS_VERSION_ID))
377         @sudo -E zypper refresh
378         @sudo -E zypper install  -y $(RPM_SUSE_DEPENDS)
379 else
380         $(error "This option currently works only on Ubuntu, Debian, RHEL, CentOS or openSUSE-leap systems")
381 endif
382         git config commit.template .git_commit_template.txt
383
384 .PHONY: install-deps
385 install-deps: install-dep
386
387 define make
388         @$(MAKE) -C $(BR) PLATFORM=$(PLATFORM) TAG=$(1) $(2)
389 endef
390
391 $(BR)/scripts/.version:
392 ifneq ("$(wildcard /etc/redhat-release)","")
393         $(shell $(BR)/scripts/version rpm-string > $(BR)/scripts/.version)
394 else
395         $(shell $(BR)/scripts/version > $(BR)/scripts/.version)
396 endif
397
398 DIST_FILE = $(BR)/vpp-$(shell src/scripts/version).tar
399 DIST_SUBDIR = vpp-$(shell src/scripts/version|cut -f1 -d-)
400
401 .PHONY: dist
402 dist:
403         @if git rev-parse 2> /dev/null ; then \
404             git archive \
405               --prefix=$(DIST_SUBDIR)/ \
406               --format=tar \
407               -o $(DIST_FILE) \
408             HEAD ; \
409             git describe --long > $(BR)/.version ; \
410         else \
411             (cd .. ; tar -cf $(DIST_FILE) $(DIST_SUBDIR) --exclude=*.tar) ; \
412             src/scripts/version > $(BR)/.version ; \
413         fi
414         @tar --append \
415           --file $(DIST_FILE) \
416           --transform='s,.*/.version,$(DIST_SUBDIR)/src/scripts/.version,' \
417           $(BR)/.version
418         @$(RM) $(BR)/.version $(DIST_FILE).xz
419         @xz -v --threads=0 $(DIST_FILE)
420         @$(RM) $(BR)/vpp-latest.tar.xz
421         @ln -rs $(DIST_FILE).xz $(BR)/vpp-latest.tar.xz
422
423 .PHONY: build
424 build: $(BR)/.deps.ok
425         $(call make,$(PLATFORM)_debug,$(addsuffix -install,$(TARGETS)))
426
427 .PHONY: wipedist
428 wipedist:
429         @$(RM) $(BR)/*.tar.xz
430
431 .PHONY: wipe
432 wipe: wipedist test-wipe $(BR)/.deps.ok
433         $(call make,$(PLATFORM)_debug,$(addsuffix -wipe,$(TARGETS)))
434         @find . -type f -name "*.api.json" ! -path "./src/*" -exec rm {} \;
435
436 .PHONY: rebuild
437 rebuild: wipe build
438
439 .PHONY: build-release
440 build-release: $(BR)/.deps.ok
441         $(call make,$(PLATFORM),$(addsuffix -install,$(TARGETS)))
442
443 .PHONY: wipe-release
444 wipe-release: test-wipe $(BR)/.deps.ok
445         $(call make,$(PLATFORM),$(addsuffix -wipe,$(TARGETS)))
446
447 .PHONY: rebuild-release
448 rebuild-release: wipe-release build-release
449
450 export TEST_DIR ?= $(WS_ROOT)/test
451
452 define test
453         $(if $(filter-out $(2),retest),$(MAKE) -C $(BR) PLATFORM=vpp TAG=$(1) CC=$(CC) vpp-install,)
454         $(eval libs:=lib lib64)
455         $(MAKE) -C test \
456           VPP_BUILD_DIR=$(BR)/build-$(1)-native/vpp \
457           VPP_BIN=$(BR)/install-$(1)-native/vpp/bin/vpp \
458           VPP_INSTALL_PATH=$(BR)/install-$(1)-native/ \
459           EXTENDED_TESTS=$(EXTENDED_TESTS) \
460           TEST_GCOV=$(TEST_GCOV) \
461           PYTHON=$(PYTHON) \
462           OS_ID=$(OS_ID) \
463           RND_SEED=$(RND_SEED) \
464           CACHE_OUTPUT=$(CACHE_OUTPUT) \
465           TAG=$(1) \
466           $(2)
467 endef
468
469 .PHONY: test
470 test:
471 ifeq ($(CC),cc)
472         $(eval CC=clang)
473 endif
474         $(call test,vpp,test)
475
476 .PHONY: test-debug
477 test-debug:
478 ifeq ($(CC),cc)
479         $(eval CC=clang)
480 endif
481         $(call test,vpp_debug,test)
482
483 .PHONY: test-cov
484 test-cov:
485         $(eval CC=gcc)
486         $(eval TEST_GCOV=1)
487         $(call test,vpp_gcov,cov)
488
489 .PHONY: test-cov-build
490 test-cov-build:
491         $(eval CC=gcc)
492         $(eval TEST_GCOV=1)
493         $(call test,vpp_gcov,test)
494
495 .PHONY: test-cov-prep
496 test-cov-prep:
497         $(eval CC=gcc)
498         $(call test,vpp_gcov,cov-prep)
499
500 .PHONY: test-cov-post
501 test-cov-post:
502         $(eval CC=gcc)
503         $(call test,vpp_gcov,cov-post)
504
505 .PHONY: test-all
506 test-all:
507         $(eval EXTENDED_TESTS=1)
508         $(call test,vpp,test)
509
510 .PHONY: test-all-debug
511 test-all-debug:
512         $(eval EXTENDED_TESTS=1)
513         $(call test,vpp_debug,test)
514
515 .PHONY: test-all-cov
516 test-all-cov:
517         $(eval CC=gcc)
518         $(eval TEST_GCOV=1)
519         $(eval EXTENDED_TESTS=1)
520         $(call test,vpp_gcov,test)
521
522 .PHONY: papi-wipe
523 papi-wipe: test-wipe-papi
524         $(call banner,"This command is deprecated. Please use 'test-wipe-papi'")
525
526 .PHONY: test-wipe-papi
527 test-wipe-papi:
528         @$(MAKE) -C test wipe-papi
529
530 .PHONY: test-help
531 test-help:
532         @$(MAKE) -C test help
533
534 .PHONY: test-wipe
535 test-wipe:
536         @$(MAKE) -C test wipe
537
538 .PHONY: test-shell
539 test-shell:
540         $(call test,vpp,shell)
541
542 .PHONY: test-shell-debug
543 test-shell-debug:
544         $(call test,vpp_debug,shell)
545
546 .PHONY: test-shell-cov
547 test-shell-cov:
548         $(eval CC=gcc)
549         $(eval TEST_GCOV=1)
550         $(call test,vpp_gcov,shell)
551
552 .PHONY: test-dep
553 test-dep:
554         @make -C test test-dep
555
556 .PHONY: test-doc
557 test-doc:
558         @echo "make test-doc is DEPRECATED: use 'make docs'"
559         sleep 300
560
561 .PHONY: test-wipe-doc
562 test-wipe-doc:
563         @echo "make test-wipe-doc is DEPRECATED"
564         sleep 300
565
566 .PHONY: test-wipe-cov
567 test-wipe-cov:
568         $(call make,$(PLATFORM)_gcov,$(addsuffix -wipe,$(TARGETS)))
569         @$(MAKE) -C test wipe-cov
570
571 .PHONY: test-wipe-all
572 test-wipe-all:
573         @$(MAKE) -C test wipe-all
574
575 # Note: All python venv consolidated in test/Makefile, test/requirements*.txt
576 .PHONY: test-checkstyle
577 test-checkstyle:
578         $(warning test-checkstyle is deprecated. Running checkstyle-python.")
579         @$(MAKE) -C test checkstyle-python-all
580
581 # Note: All python venv consolidated in test/Makefile, test/requirements*.txt
582 .PHONY: test-checkstyle-diff
583 test-checkstyle-diff:
584         $(warning test-checkstyle-diff is deprecated. Running checkstyle-python.")
585         @$(MAKE) -C test checkstyle-python-all
586
587 .PHONY: test-refresh-deps
588 test-refresh-deps:
589         @$(MAKE) -C test refresh-deps
590
591 .PHONY: retest
592 retest:
593         $(call test,vpp,retest)
594
595 .PHONY: retest-debug
596 retest-debug:
597         $(call test,vpp_debug,retest)
598
599 .PHONY: retest-all
600 retest-all:
601         $(eval EXTENDED_TESTS=1)
602         $(call test,vpp,retest)
603
604 .PHONY: retest-all-debug
605 retest-all-debug:
606         $(eval EXTENDED_TESTS=1)
607         $(call test,vpp_debug,retest)
608
609 .PHONY: test-start-vpp-in-gdb
610 test-start-vpp-in-gdb:
611         $(call test,vpp,start-gdb)
612
613 .PHONY: test-start-vpp-debug-in-gdb
614 test-start-vpp-debug-in-gdb:
615         $(call test,vpp_debug,start-gdb)
616
617 ifeq ("$(wildcard $(STARTUP_CONF))","")
618 define run
619         @echo "WARNING: STARTUP_CONF not defined or file doesn't exist."
620         @echo "         Running with minimal startup config: $(MINIMAL_STARTUP_CONF)\n"
621         @cd $(STARTUP_DIR) && \
622           $(SUDO) $(2) $(1)/vpp/bin/vpp $(MINIMAL_STARTUP_CONF)
623 endef
624 else
625 define run
626         @cd $(STARTUP_DIR) && \
627           $(SUDO) $(2) $(1)/vpp/bin/vpp $(shell cat $(STARTUP_CONF) | sed -e 's/#.*//')
628 endef
629 endif
630
631 %.files: .FORCE
632         @find src -name '*.[chS]' > $@
633
634 .FORCE:
635
636 .PHONY: run
637 run:
638         $(call run, $(BR)/install-$(PLATFORM)_debug-native)
639
640 .PHONY: run-release
641 run-release:
642         $(call run, $(BR)/install-$(PLATFORM)-native)
643
644 .PHONY: debug
645 debug:
646         $(call run, $(BR)/install-$(PLATFORM)_debug-native,$(GDB) $(GDB_ARGS) --args)
647
648 .PHONY: build-coverity
649 build-coverity:
650         $(call make,$(PLATFORM)_coverity,install-packages)
651         @$(MAKE) -C build-root PLATFORM=vpp TAG=vpp_coverity libmemif-install
652
653 .PHONY: debug-release
654 debug-release:
655         $(call run, $(BR)/install-$(PLATFORM)-native,$(GDB) $(GDB_ARGS) --args)
656
657 .PHONY: build-vat
658 build-vat:
659         $(call make,$(PLATFORM)_debug,vpp-api-test-install)
660
661 .PHONY: run-vat
662 run-vat:
663         @$(SUDO) $(BR)/install-$(PLATFORM)_debug-native/vpp/bin/vpp_api_test
664
665 .PHONY: pkg-deb
666 pkg-deb:
667         $(call make,$(PLATFORM),vpp-package-deb)
668
669 .PHONY: pkg-snap
670 pkg-snap:
671         cd extras/snap ;                        \
672         ./prep ;                                \
673         SNAPCRAFT_BUILD_ENVIRONMENT_MEMORY=8G   \
674         SNAPCRAFT_BUILD_ENVIRONMENT_CPU=6       \
675         snapcraft --debug
676
677 .PHONY: snap-clean
678 snap-clean:
679         cd extras/snap ;                        \
680         snapcraft clean ;                       \
681         rm -f *.snap *.tgz
682
683 .PHONY: pkg-deb-debug
684 pkg-deb-debug:
685         $(call make,$(PLATFORM)_debug,vpp-package-deb)
686
687 .PHONY: pkg-rpm
688 pkg-rpm: dist
689         $(MAKE) -C extras/rpm
690
691 .PHONY: pkg-srpm
692 pkg-srpm: dist
693         $(MAKE) -C extras/rpm srpm
694
695 .PHONY: install-ext-deps
696 install-ext-deps:
697         $(MAKE) -C build/external install-$(PKG)
698
699 .PHONY: install-ext-dep
700 install-ext-dep: install-ext-deps
701
702 .PHONY: json-api-files
703 json-api-files:
704         $(WS_ROOT)/src/tools/vppapigen/generate_json.py
705
706 .PHONY: json-api-files-debug
707 json-api-files-debug:
708         $(WS_ROOT)/src/tools/vppapigen/generate_json.py --debug-target
709
710 .PHONY: go-api-files
711 go-api-files: json-api-files
712         $(WS_ROOT)/src/tools/vppapigen/generate_go.py $(ARGS)
713
714 .PHONY: ctags
715 ctags: ctags.files
716         @ctags --totals --tag-relative=yes -L $<
717         @rm $<
718
719 .PHONY: gtags
720 gtags: ctags
721         @gtags --gtagslabel=ctags
722
723 .PHONY: cscope
724 cscope: cscope.files
725         @cscope -b -q -v
726
727 .PHONY: compdb
728 compdb:
729         @ninja -C build-root/build-vpp_debug-native/vpp build.ninja
730         @ninja -C build-root/build-vpp_debug-native/vpp -t compdb | \
731           src/scripts/compdb_cleanup.py > compile_commands.json
732
733 .PHONY: checkstyle
734 checkstyle: checkfeaturelist
735         @extras/scripts/checkstyle.sh
736
737 .PHONY: checkstyle-commit
738 checkstyle-commit:
739         @extras/scripts/check_commit_msg.sh
740
741 .PHONY: checkstyle-test
742 checkstyle-test:
743         $(warning test-checkstyle is deprecated. Running checkstyle-python.")
744         @$(MAKE) -C test checkstyle-python-all
745
746 # Note: All python venv consolidated in test/Makefile, test/requirements*.txt
747 .PHONY: checkstyle-python
748 checkstyle-python:
749         @$(MAKE) -C test checkstyle-python-all
750
751 .PHONY: checkstyle-all
752 checkstyle-all: checkstyle-commit checkstyle checkstyle-python docs-spell
753
754 .PHONY: fixstyle
755 fixstyle:
756         @extras/scripts/checkstyle.sh --fix
757
758 # Note: All python venv consolidated in test/Makefile, test/requirements*.txt
759 .PHONY: fixstyle-python
760 fixstyle-python:
761         @$(MAKE) -C test fixstyle-python-all
762
763 .PHONY: checkstyle-api
764 checkstyle-api:
765         @extras/scripts/crcchecker.py --check-patchset
766
767 # necessary because Bug 1696324 - Update to python3.6 breaks PyYAML dependencies
768 # Status:       CLOSED CANTFIX
769 # https://bugzilla.redhat.com/show_bug.cgi?id=1696324
770 .PHONY: centos-pyyaml
771 centos-pyyaml:
772 ifeq ($(OS_ID)-$(OS_VERSION_ID),centos-8)
773         @sudo -E yum install $(CONFIRM) python3-pyyaml
774 endif
775
776 .PHONY: featurelist
777 featurelist: centos-pyyaml
778         @extras/scripts/fts.py --all --markdown
779
780 .PHONY: checkfeaturelist
781 checkfeaturelist: centos-pyyaml
782         @extras/scripts/fts.py --validate --all
783
784 #
785 # Build the documentation
786 #
787
788 .PHONY: bootstrap-doxygen
789 bootstrap-doxygen:
790         @echo "make bootstrap-doxygen is DEPRECATED"
791         sleep 300
792
793 .PHONY: doxygen
794 doxygen: docs
795         @echo "make doxygen is DEPRECATED: use 'make docs'"
796         sleep 300
797
798 .PHONY: wipe-doxygen
799 wipe-doxygen:
800         @echo "make wipe-doxygen is DEPRECATED"
801         sleep 300
802
803 .PHONY: docs-%
804 docs-%:
805         @$(MAKE) -C $(WS_ROOT)/docs $*
806
807 .PHONY: docs
808 docs:
809         @$(MAKE) -C $(WS_ROOT)/docs docs
810
811 .PHONY: pkg-verify
812 pkg-verify: install-dep $(BR)/.deps.ok install-ext-deps
813         $(call banner,"Building for PLATFORM=vpp")
814         @$(MAKE) -C build-root PLATFORM=vpp TAG=vpp wipe-all install-packages
815         $(call banner,"Building sample-plugin")
816         @$(MAKE) -C build-root PLATFORM=vpp TAG=vpp sample-plugin-install
817         $(call banner,"Building libmemif")
818         @$(MAKE) -C build-root PLATFORM=vpp TAG=vpp libmemif-install
819         $(call banner,"Building $(PKG) packages")
820         @$(MAKE) pkg-$(PKG)
821
822 # Note: 'make verify' target is not used by ci-management scripts
823 MAKE_VERIFY_GATE_OS ?= ubuntu-22.04
824 .PHONY: verify
825 verify: pkg-verify
826 ifeq ($(OS_ID)-$(OS_VERSION_ID),$(MAKE_VERIFY_GATE_OS))
827         $(call banner,"Testing vppapigen")
828         @src/tools/vppapigen/test_vppapigen.py
829         $(call banner,"Running tests")
830         @$(MAKE) COMPRESS_FAILED_TEST_LOGS=yes RETRIES=3 test
831 else
832         $(call banner,"Skipping tests. Tests under 'make verify' supported on $(MAKE_VERIFY_GATE_OS)")
833 endif
834
835 .PHONY: check-dpdk-mlx
836 check-dpdk-mlx:
837         @[ $$($(MAKE) -sC build/external dpdk-show-DPDK_MLX_DEFAULT) = y ]