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