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