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