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