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