misc: add knob to generate compile_commands.json
[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 " compdb               - (re)generate compile_commands.json"
227         @echo " checkstyle           - check coding style"
228         @echo " checkstyle-commit    - check commit message format"
229         @echo " checkstyle-test      - check test framework coding style"
230         @echo " fixstyle             - fix coding style"
231         @echo " doxygen              - (re)generate documentation"
232         @echo " bootstrap-doxygen    - setup Doxygen dependencies"
233         @echo " wipe-doxygen         - wipe all generated documentation"
234         @echo " checkfeaturelist     - check FEATURE.yaml according to schema"
235         @echo " featurelist          - dump feature list in markdown"
236         @echo " json-api-files       - (re)-generate json api files"
237         @echo " json-api-files-debug - (re)-generate json api files for debug target"
238         @echo " docs                 - Build the Sphinx documentation"
239         @echo " docs-venv            - Build the virtual environment for the Sphinx docs"
240         @echo " docs-clean           - Remove the generated files from the Sphinx docs"
241         @echo ""
242         @echo "Make Arguments:"
243         @echo " V=[0|1]                  - set build verbosity level"
244         @echo " STARTUP_CONF=<path>      - startup configuration file"
245         @echo "                            (e.g. /etc/vpp/startup.conf)"
246         @echo " STARTUP_DIR=<path>       - startup directory (e.g. /etc/vpp)"
247         @echo "                            It also sets STARTUP_CONF if"
248         @echo "                            startup.conf file is present"
249         @echo " GDB=<path>               - gdb binary to use for debugging"
250         @echo " PLATFORM=<name>          - target platform. default is vpp"
251         @echo " TEST=<filter>            - apply filter to test set, see test-help"
252         @echo " DPDK_CONFIG=<conf>       - add specified dpdk config commands to"
253         @echo "                            autogenerated startup.conf"
254         @echo "                            (e.g. \"no-pci\" )"
255         @echo " SAMPLE_PLUGIN=yes        - in addition build/run/debug sample plugin"
256         @echo " DISABLED_PLUGINS=<list>  - comma separated list of plugins which"
257         @echo "                            should not be loaded"
258         @echo ""
259         @echo "Current Argument Values:"
260         @echo " V                 = $(V)"
261         @echo " STARTUP_CONF      = $(STARTUP_CONF)"
262         @echo " STARTUP_DIR       = $(STARTUP_DIR)"
263         @echo " GDB               = $(GDB)"
264         @echo " PLATFORM          = $(PLATFORM)"
265         @echo " DPDK_VERSION      = $(DPDK_VERSION)"
266         @echo " DPDK_CONFIG       = $(DPDK_CONFIG)"
267         @echo " SAMPLE_PLUGIN     = $(SAMPLE_PLUGIN)"
268         @echo " DISABLED_PLUGINS  = $(DISABLED_PLUGINS)"
269
270 $(BR)/.deps.ok:
271 ifeq ($(findstring y,$(UNATTENDED)),y)
272         make install-dep
273 endif
274 ifeq ($(filter ubuntu debian,$(OS_ID)),$(OS_ID))
275         @MISSING=$$(apt-get install -y -qq -s $(DEB_DEPENDS) | grep "^Inst ") ; \
276         if [ -n "$$MISSING" ] ; then \
277           echo "\nPlease install missing packages: \n$$MISSING\n" ; \
278           echo "by executing \"make install-dep\"\n" ; \
279           exit 1 ; \
280         fi ; \
281         exit 0
282 else ifneq ("$(wildcard /etc/redhat-release)","")
283         @for i in $(RPM_DEPENDS) ; do \
284             RPM=$$(basename -s .rpm "$${i##*/}" | cut -d- -f1,2,3)  ;   \
285             MISSING+=$$(rpm -q $$RPM | grep "^package")    ;    \
286         done                                                       ;    \
287         if [ -n "$$MISSING" ] ; then \
288           echo "Please install missing RPMs: \n$$MISSING\n" ; \
289           echo "by executing \"make install-dep\"\n" ; \
290           exit 1 ; \
291         fi ; \
292         exit 0
293 endif
294         @touch $@
295
296 .PHONY: bootstrap
297 bootstrap:
298         @echo "'make bootstrap' is not needed anymore"
299
300 .PHONY: install-dep
301 install-dep:
302 ifeq ($(filter ubuntu debian,$(OS_ID)),$(OS_ID))
303 ifeq ($(OS_VERSION_ID),14.04)
304         @sudo -E apt-get $(CONFIRM) $(FORCE) install software-properties-common
305 endif
306 ifeq ($(OS_ID)-$(OS_VERSION_ID),debian-8)
307         @grep -q jessie-backports /etc/apt/sources.list /etc/apt/sources.list.d/* 2> /dev/null \
308            || ( echo "Please install jessie-backports" ; exit 1 )
309 endif
310         @sudo -E apt-get update
311         @sudo -E apt-get $(APT_ARGS) $(CONFIRM) $(FORCE) install $(DEB_DEPENDS)
312 else ifneq ("$(wildcard /etc/redhat-release)","")
313 ifeq ($(OS_ID),rhel)
314         @sudo -E yum-config-manager --enable rhel-server-rhscl-7-rpms
315         @sudo -E yum groupinstall $(CONFIRM) $(RPM_DEPENDS_GROUPS)
316         @sudo -E yum install $(CONFIRM) $(RPM_DEPENDS)
317         @sudo -E debuginfo-install $(CONFIRM) glibc openssl-libs mbedtls-devel zlib
318 else ifeq ($(OS_ID)-$(OS_VERSION_ID),centos-8)
319         @sudo -E dnf groupinstall $(CONFIRM) $(RPM_DEPENDS_GROUPS)
320         @sudo -E dnf install $(CONFIRM) $(RPM_DEPENDS)
321 else ifeq ($(OS_ID),centos)
322         @sudo -E yum install $(CONFIRM) centos-release-scl-rh epel-release
323         @sudo -E yum groupinstall $(CONFIRM) $(RPM_DEPENDS_GROUPS)
324         @sudo -E yum install $(CONFIRM) $(RPM_DEPENDS)
325         @sudo -E debuginfo-install $(CONFIRM) glibc openssl-libs mbedtls-devel zlib
326 else ifeq ($(OS_ID),fedora)
327         @sudo -E dnf groupinstall $(CONFIRM) $(RPM_DEPENDS_GROUPS)
328         @sudo -E dnf install $(CONFIRM) $(RPM_DEPENDS)
329         @sudo -E debuginfo-install $(CONFIRM) glibc openssl-libs mbedtls-devel zlib
330 endif
331 else ifeq ($(filter opensuse-tumbleweed,$(OS_ID)),$(OS_ID))
332         @sudo -E zypper refresh
333         @sudo -E zypper install -y $(RPM_SUSE_DEPENDS)
334 else ifeq ($(filter opensuse-leap,$(OS_ID)),$(OS_ID))
335         @sudo -E zypper refresh
336         @sudo -E zypper install  -y $(RPM_SUSE_DEPENDS)
337 else ifeq ($(filter opensuse,$(OS_ID)),$(OS_ID))
338         @sudo -E zypper refresh
339         @sudo -E zypper install -y $(RPM_SUSE_DEPENDS)
340 else
341         $(error "This option currently works only on Ubuntu, Debian, RHEL, CentOS or openSUSE systems")
342 endif
343         git config commit.template .git_commit_template.txt
344
345 .PHONY: install-deps
346 install-deps: install-dep
347
348 define make
349         @make -C $(BR) PLATFORM=$(PLATFORM) TAG=$(1) $(2)
350 endef
351
352 $(BR)/scripts/.version:
353 ifneq ("$(wildcard /etc/redhat-release)","")
354         $(shell $(BR)/scripts/version rpm-string > $(BR)/scripts/.version)
355 else
356         $(shell $(BR)/scripts/version > $(BR)/scripts/.version)
357 endif
358
359 DIST_FILE = $(BR)/vpp-$(shell src/scripts/version).tar
360 DIST_SUBDIR = vpp-$(shell src/scripts/version|cut -f1 -d-)
361
362 .PHONY: dist
363 dist:
364         @if git rev-parse 2> /dev/null ; then \
365             git archive \
366               --prefix=$(DIST_SUBDIR)/ \
367               --format=tar \
368               -o $(DIST_FILE) \
369             HEAD ; \
370             git describe > $(BR)/.version ; \
371         else \
372             (cd .. ; tar -cf $(DIST_FILE) $(DIST_SUBDIR) --exclude=*.tar) ; \
373             src/scripts/version > $(BR)/.version ; \
374         fi
375         @tar --append \
376           --file $(DIST_FILE) \
377           --transform='s,.*/.version,$(DIST_SUBDIR)/src/scripts/.version,' \
378           $(BR)/.version
379         @$(RM) $(BR)/.version $(DIST_FILE).xz
380         @xz -v --threads=0 $(DIST_FILE)
381         @$(RM) $(BR)/vpp-latest.tar.xz
382         @ln -rs $(DIST_FILE).xz $(BR)/vpp-latest.tar.xz
383
384 .PHONY: build
385 build: $(BR)/.deps.ok
386         $(call make,$(PLATFORM)_debug,$(addsuffix -install,$(TARGETS)))
387
388 .PHONY: wipedist
389 wipedist:
390         @$(RM) $(BR)/*.tar.xz
391
392 .PHONY: wipe
393 wipe: wipedist test-wipe $(BR)/.deps.ok
394         $(call make,$(PLATFORM)_debug,$(addsuffix -wipe,$(TARGETS)))
395         @find . -type f -name "*.api.json" ! -path "./test/*" -exec rm {} \;
396
397 .PHONY: rebuild
398 rebuild: wipe build
399
400 .PHONY: build-release
401 build-release: $(BR)/.deps.ok
402         $(call make,$(PLATFORM),$(addsuffix -install,$(TARGETS)))
403
404 .PHONY: wipe-release
405 wipe-release: test-wipe $(BR)/.deps.ok
406         $(call make,$(PLATFORM),$(addsuffix -wipe,$(TARGETS)))
407
408 .PHONY: rebuild-release
409 rebuild-release: wipe-release build-release
410
411 libexpand = $(subst $(subst ,, ),:,$(foreach lib,$(1),$(BR)/install-$(2)-native/vpp/$(lib)/$(3)))
412
413 export TEST_DIR ?= $(WS_ROOT)/test
414 export RND_SEED ?= $(shell python3 -c 'import time; print(time.time())')
415
416 define test
417         $(if $(filter-out $(3),retest),make -C $(BR) PLATFORM=$(1) TAG=$(2) vpp-install,)
418         $(eval libs:=lib lib64)
419         make -C test \
420           VPP_BUILD_DIR=$(BR)/build-$(2)-native \
421           VPP_BIN=$(BR)/install-$(2)-native/vpp/bin/vpp \
422           VPP_PLUGIN_PATH=$(call libexpand,$(libs),$(2),vpp_plugins) \
423           VPP_TEST_PLUGIN_PATH=$(call libexpand,$(libs),$(2),vpp_api_test_plugins) \
424           VPP_INSTALL_PATH=$(BR)/install-$(2)-native/ \
425           LD_LIBRARY_PATH=$(call libexpand,$(libs),$(2),) \
426           EXTENDED_TESTS=$(EXTENDED_TESTS) \
427           PYTHON=$(PYTHON) \
428           OS_ID=$(OS_ID) \
429           RND_SEED=$(RND_SEED) \
430           CACHE_OUTPUT=$(CACHE_OUTPUT) \
431           $(3)
432 endef
433
434 .PHONY: test
435 test:
436         $(call test,vpp,vpp,test)
437
438 .PHONY: test-debug
439 test-debug:
440         $(call test,vpp,vpp_debug,test)
441
442 .PHONY: test-gcov
443 test-gcov:
444         $(call test,vpp,vpp_gcov,test)
445
446 .PHONY: test-all
447 test-all:
448         $(if $(filter-out $(3),retest),make -C $(BR) PLATFORM=vpp TAG=vpp vom-install,)
449         $(eval EXTENDED_TESTS=yes)
450         $(call test,vpp,vpp,test)
451
452 .PHONY: test-all-debug
453 test-all-debug:
454         $(if $(filter-out $(3),retest),make -C $(BR) PLATFORM=vpp TAG=vpp_debug vom-install,)
455         $(eval EXTENDED_TESTS=yes)
456         $(call test,vpp,vpp_debug,test)
457
458 .PHONY: papi-wipe
459 papi-wipe: test-wipe-papi
460         $(call banner,"This command is deprecated. Please use 'test-wipe-papi'")
461
462 .PHONY: test-wipe-papi
463 test-wipe-papi:
464         @make -C test wipe-papi
465
466 .PHONY: test-help
467 test-help:
468         @make -C test help
469
470 .PHONY: test-wipe
471 test-wipe:
472         @make -C test wipe
473
474 .PHONY: test-shell
475 test-shell:
476         $(call test,vpp,vpp,shell)
477
478 .PHONY: test-shell-debug
479 test-shell-debug:
480         $(call test,vpp,vpp_debug,shell)
481
482 .PHONY: test-shell-gcov
483 test-shell-gcov:
484         $(call test,vpp,vpp_gcov,shell)
485
486 .PHONY: test-dep
487 test-dep:
488         @make -C test test-dep
489
490 .PHONY: test-doc
491 test-doc:
492         @make -C test doc
493
494 .PHONY: test-wipe-doc
495 test-wipe-doc:
496         @make -C test wipe-doc
497
498 .PHONY: test-cov
499 test-cov:
500         @make -C $(BR) PLATFORM=vpp TAG=vpp_gcov vom-install
501         $(eval EXTENDED_TESTS=yes)
502         $(call test,vpp,vpp_gcov,cov)
503
504 .PHONY: test-wipe-cov
505 test-wipe-cov:
506         @make -C test wipe-cov
507
508 .PHONY: test-wipe-all
509 test-wipe-all:
510         @make -C test wipe-all
511
512 .PHONY: test-checkstyle
513 test-checkstyle:
514         @make -C test checkstyle
515
516 .PHONY: test-refresh-deps
517 test-refresh-deps:
518         @make -C test refresh-deps
519
520 .PHONY: retest
521 retest:
522         $(call test,vpp,vpp,retest)
523
524 .PHONY: retest-debug
525 retest-debug:
526         $(call test,vpp,vpp_debug,retest)
527
528 .PHONY: retest-all
529 retest-all:
530         $(eval EXTENDED_TESTS=yes)
531         $(call test,vpp,vpp,retest)
532
533 .PHONY: retest-all-debug
534 retest-all-debug:
535         $(eval EXTENDED_TESTS=yes)
536         $(call test,vpp,vpp_debug,retest)
537
538 ifeq ("$(wildcard $(STARTUP_CONF))","")
539 define run
540         @echo "WARNING: STARTUP_CONF not defined or file doesn't exist."
541         @echo "         Running with minimal startup config: $(MINIMAL_STARTUP_CONF)\n"
542         @cd $(STARTUP_DIR) && \
543           $(SUDO) $(2) $(1)/vpp/bin/vpp $(MINIMAL_STARTUP_CONF)
544 endef
545 else
546 define run
547         @cd $(STARTUP_DIR) && \
548           $(SUDO) $(2) $(1)/vpp/bin/vpp $(shell cat $(STARTUP_CONF) | sed -e 's/#.*//')
549 endef
550 endif
551
552 %.files: .FORCE
553         @find . \( -name '*\.[chyS]' -o -name '*\.java' -o -name '*\.lex' \) -and \
554                 \( -not -path './build-root*' -o -path \
555                 './build-root/build-vpp_debug-native/dpdk*' \) > $@
556
557 .FORCE:
558
559 .PHONY: run
560 run:
561         $(call run, $(BR)/install-$(PLATFORM)_debug-native)
562
563 .PHONY: run-release
564 run-release:
565         $(call run, $(BR)/install-$(PLATFORM)-native)
566
567 .PHONY: debug
568 debug:
569         $(call run, $(BR)/install-$(PLATFORM)_debug-native,$(GDB) $(GDB_ARGS) --args)
570
571 .PHONY: build-coverity
572 build-coverity:
573         $(call make,$(PLATFORM)_coverity,install-packages)
574
575 .PHONY: debug-release
576 debug-release:
577         $(call run, $(BR)/install-$(PLATFORM)-native,$(GDB) $(GDB_ARGS) --args)
578
579 .PHONY: build-vat
580 build-vat:
581         $(call make,$(PLATFORM)_debug,vpp-api-test-install)
582
583 .PHONY: run-vat
584 run-vat:
585         @$(SUDO) $(BR)/install-$(PLATFORM)_debug-native/vpp/bin/vpp_api_test
586
587 .PHONY: pkg-deb
588 pkg-deb:
589         $(call make,$(PLATFORM),vpp-package-deb)
590
591 .PHONY: pkg-snap
592 pkg-snap:
593         cd extras/snap ;                        \
594         ./prep ;                                \
595         SNAPCRAFT_BUILD_ENVIRONMENT_MEMORY=8G   \
596         SNAPCRAFT_BUILD_ENVIRONMENT_CPU=6       \
597         snapcraft --debug
598
599 .PHONY: snap-clean
600 snap-clean:
601         cd extras/snap ;                        \
602         snapcraft clean ;                       \
603         rm -f *.snap *.tgz
604
605 .PHONY: vom-pkg-deb
606 vom-pkg-deb: pkg-deb
607         $(call make,$(PLATFORM),vom-package-deb)
608
609 .PHONY: pkg-deb-debug
610 pkg-deb-debug:
611         $(call make,$(PLATFORM)_debug,vpp-package-deb)
612
613 .PHONY: vom-pkg-deb-debug
614 vom-pkg-deb-debug: pkg-deb-debug
615         $(call make,$(PLATFORM)_debug,vom-package-deb)
616
617 .PHONY: pkg-rpm
618 pkg-rpm: dist
619         make -C extras/rpm
620
621 .PHONY: pkg-srpm
622 pkg-srpm: dist
623         make -C extras/rpm srpm
624
625 .PHONY: dpdk-install-dev
626 dpdk-install-dev:
627         $(call banner,"This command is deprecated. Please use 'make install-ext-deps'")
628         make -C build/external install-$(PKG)
629
630 .PHONY: install-ext-deps
631 install-ext-deps:
632         make -C build/external install-$(PKG)
633
634 .PHONY: install-ext-dep
635 install-ext-dep: install-ext-deps
636
637 .PHONY: json-api-files
638 json-api-files:
639         $(WS_ROOT)/src/tools/vppapigen/generate_json.py
640
641 .PHONY: json-api-files-debug
642 json-api-files-debug:
643         $(WS_ROOT)/src/tools/vppapigen/generate_json.py --debug-target
644
645 .PHONY: ctags
646 ctags: ctags.files
647         @ctags --totals --tag-relative -L $<
648         @rm $<
649
650 .PHONY: gtags
651 gtags: ctags
652         @gtags --gtagslabel=ctags
653
654 .PHONY: cscope
655 cscope: cscope.files
656         @cscope -b -q -v
657
658 .PHONY: compdb
659 compdb:
660         @ninja -C build-root/build-vpp_debug-native/vpp -t compdb > compile_commands.json
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