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