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