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:
6 # http://www.apache.org/licenses/LICENSE-2.0
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.
14 export WS_ROOT=$(CURDIR)
15 export BR=$(WS_ROOT)/build-root
16 CCACHE_DIR?=$(BR)/.ccache
22 MACHINE=$(shell uname -m)
27 define disable_plugins
30 $(patsubst %,"plugin %_plugin.so { disable }",$(subst $(,), ,$(1))) \
35 MINIMAL_STARTUP_CONF=" \
38 cli-listen /run/vpp/cli.sock \
40 $(if $(wildcard startup.vpp),"exec startup.vpp",) \
42 $(if $(DPDK_CONFIG), "dpdk { $(DPDK_CONFIG) }",) \
43 $(call disable_plugins,$(DISABLED_PLUGINS)) \
46 GDB_ARGS= -ex "handle SIGUSR1 noprint nostop"
51 # We allow Darwin (MacOS) for docs generation; VPP build will still fail.
52 ifneq ($(shell uname),Darwin)
53 OS_ID = $(shell grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
54 OS_VERSION_ID= $(shell grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
57 ifeq ($(filter ubuntu debian,$(OS_ID)),$(OS_ID))
59 else ifeq ($(filter rhel centos fedora,$(OS_ID)),$(OS_ID))
63 # +libganglia1-dev if building the gmond plugin
65 DEB_DEPENDS = curl build-essential autoconf automake ccache
66 DEB_DEPENDS += debhelper dkms git libtool libapr1-dev dh-python
67 DEB_DEPENDS += libconfuse-dev git-review exuberant-ctags cscope pkg-config
68 DEB_DEPENDS += lcov chrpath autoconf libnuma-dev
69 DEB_DEPENDS += python3-all python3-setuptools check
70 DEB_DEPENDS += 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 DEB_DEPENDS += libnl-3-dev libnl-route-3-dev
75 # python3.6 on 16.04 requires python36-dev
77 LIBFFI=libffi6 # works on all but 20.04 and debian-testing
79 ifeq ($(OS_VERSION_ID),18.04)
80 DEB_DEPENDS += python-dev python-all python-pip python-virtualenv
81 DEB_DEPENDS += libssl-dev
82 DEB_DEPENDS += clang-9 clang-format-10
83 else ifeq ($(OS_VERSION_ID),20.04)
84 DEB_DEPENDS += python3-virtualenv
85 DEB_DEPENDS += libssl-dev
86 DEB_DEPENDS += libelf-dev # for libbpf (af_xdp)
87 DEB_DEPENDS += clang-format-10
89 else ifeq ($(OS_VERSION_ID),20.10)
90 DEB_DEPENDS += python3-virtualenv
91 DEB_DEPENDS += libssl-dev
92 DEB_DEPENDS += libelf-dev # for libbpf (af_xdp)
93 DEB_DEPENDS += clang-format-10
95 else ifeq ($(OS_ID)-$(OS_VERSION_ID),debian-10)
96 DEB_DEPENDS += python3-virtualenv virtualenv
97 DEB_DEPENDS += libssl-dev
98 DEB_DEPENDS += libelf-dev # for libbpf (af_xdp)
100 DEB_DEPENDS += libssl-dev
101 DEB_DEPENDS += libelf-dev # for libbpf (af_xdp)
105 DEB_DEPENDS += $(LIBFFI)
107 RPM_DEPENDS = redhat-lsb glibc-static
108 RPM_DEPENDS += apr-devel
109 RPM_DEPENDS += numactl-devel
110 RPM_DEPENDS += check check-devel
111 RPM_DEPENDS += selinux-policy selinux-policy-devel
112 RPM_DEPENDS += ninja-build
113 RPM_DEPENDS += libuuid-devel
114 RPM_DEPENDS += mbedtls-devel
115 RPM_DEPENDS += ccache
117 RPM_DEPENDS += elfutils-libelf-devel
118 RPM_DEPENDS += libnl3-devel
120 ifeq ($(OS_ID),fedora)
121 RPM_DEPENDS += dnf-utils
122 RPM_DEPENDS += subunit subunit-devel
123 RPM_DEPENDS += compat-openssl10-devel
124 RPM_DEPENDS += python3-devel # needed for python3 -m pip install psutil
125 RPM_DEPENDS += python3-ply # for vppapigen
126 RPM_DEPENDS += python3-virtualenv python3-jsonschema
128 RPM_DEPENDS_GROUPS = 'C Development Tools and Libraries'
129 else ifeq ($(OS_ID)-$(OS_VERSION_ID),centos-8)
130 RPM_DEPENDS += yum-utils
131 RPM_DEPENDS += compat-openssl10 openssl-devel
132 RPM_DEPENDS += python2-devel python36-devel python3-ply
133 RPM_DEPENDS += python3-virtualenv python3-jsonschema
134 RPM_DEPENDS += libarchive cmake
135 RPM_DEPENDS_GROUPS = 'Development Tools'
137 RPM_DEPENDS += yum-utils
138 RPM_DEPENDS += openssl-devel
139 RPM_DEPENDS += python36-ply # for vppapigen
140 RPM_DEPENDS += python3-devel python3-pip
141 RPM_DEPENDS += python-virtualenv python36-jsonschema
142 RPM_DEPENDS += devtoolset-9 devtoolset-9-libasan-devel
143 RPM_DEPENDS += cmake3
144 RPM_DEPENDS_GROUPS = 'Development Tools'
147 # +ganglia-devel if building the ganglia plugin
149 RPM_DEPENDS += chrpath libffi-devel rpm-build
151 RPM_DEPENDS_DEBUG = glibc-debuginfo e2fsprogs-debuginfo
152 RPM_DEPENDS_DEBUG += krb5-debuginfo openssl-debuginfo
153 RPM_DEPENDS_DEBUG += zlib-debuginfo nss-softokn-debuginfo
154 RPM_DEPENDS_DEBUG += yum-plugin-auto-update-debug-info
156 ifneq ($(wildcard $(STARTUP_DIR)/startup.conf),)
157 STARTUP_CONF ?= $(STARTUP_DIR)/startup.conf
160 ifeq ($(findstring y,$(UNATTENDED)),y)
167 ifneq ($(SAMPLE_PLUGIN),no)
168 TARGETS += sample-plugin
172 @echo "========================================================================"
174 @echo "========================================================================"
180 @echo "Make Targets:"
181 @echo " install-dep[s] - install software dependencies"
182 @echo " wipe - wipe all products of debug build "
183 @echo " wipe-release - wipe all products of release build "
184 @echo " build - build debug binaries"
185 @echo " build-release - build release binaries"
186 @echo " build-coverity - build coverity artifacts"
187 @echo " rebuild - wipe and build debug binaries"
188 @echo " rebuild-release - wipe and build release binaries"
189 @echo " run - run debug binary"
190 @echo " run-release - run release binary"
191 @echo " debug - run debug binary with debugger"
192 @echo " debug-release - run release binary with debugger"
193 @echo " test - build and run tests"
194 @echo " test-help - show help on test framework"
195 @echo " run-vat - run vpp-api-test tool"
196 @echo " pkg-deb - build DEB packages"
197 @echo " pkg-deb-debug - build DEB debug packages"
198 @echo " pkg-snap - build SNAP package"
199 @echo " snap-clean - clean up snap build environment"
200 @echo " pkg-rpm - build RPM packages"
201 @echo " install-ext-dep[s] - install external development dependencies"
202 @echo " ctags - (re)generate ctags database"
203 @echo " gtags - (re)generate gtags database"
204 @echo " cscope - (re)generate cscope database"
205 @echo " compdb - (re)generate compile_commands.json"
206 @echo " checkstyle - check coding style"
207 @echo " checkstyle-commit - check commit message format"
208 @echo " checkstyle-test - check test framework coding style"
209 @echo " checkstyle-test-diff - check test framework coding style (only changed files)"
210 @echo " checkstyle-api - check api for incompatible changes"
211 @echo " fixstyle - fix coding style"
212 @echo " doxygen - DEPRECATED - use 'make docs'"
213 @echo " bootstrap-doxygen - DEPRECATED"
214 @echo " wipe-doxygen - DEPRECATED"
215 @echo " checkfeaturelist - check FEATURE.yaml according to schema"
216 @echo " featurelist - dump feature list in markdown"
217 @echo " json-api-files - (re)-generate json api files"
218 @echo " json-api-files-debug - (re)-generate json api files for debug target"
219 @echo " go-api-files - (re)-generate golang api files"
220 @echo " docs - Build the Sphinx documentation"
221 @echo " docs-venv - Build the virtual environment for the Sphinx docs"
222 @echo " docs-clean - Remove the generated files from the Sphinx docs"
224 @echo "Make Arguments:"
225 @echo " V=[0|1] - set build verbosity level"
226 @echo " STARTUP_CONF=<path> - startup configuration file"
227 @echo " (e.g. /etc/vpp/startup.conf)"
228 @echo " STARTUP_DIR=<path> - startup directory (e.g. /etc/vpp)"
229 @echo " It also sets STARTUP_CONF if"
230 @echo " startup.conf file is present"
231 @echo " GDB=<path> - gdb binary to use for debugging"
232 @echo " PLATFORM=<name> - target platform. default is vpp"
233 @echo " TEST=<filter> - apply filter to test set, see test-help"
234 @echo " DPDK_CONFIG=<conf> - add specified dpdk config commands to"
235 @echo " autogenerated startup.conf"
236 @echo " (e.g. \"no-pci\" )"
237 @echo " SAMPLE_PLUGIN=yes - in addition build/run/debug sample plugin"
238 @echo " DISABLED_PLUGINS=<list> - comma separated list of plugins which"
239 @echo " should not be loaded"
241 @echo "Current Argument Values:"
243 @echo " STARTUP_CONF = $(STARTUP_CONF)"
244 @echo " STARTUP_DIR = $(STARTUP_DIR)"
245 @echo " GDB = $(GDB)"
246 @echo " PLATFORM = $(PLATFORM)"
247 @echo " DPDK_VERSION = $(DPDK_VERSION)"
248 @echo " DPDK_CONFIG = $(DPDK_CONFIG)"
249 @echo " SAMPLE_PLUGIN = $(SAMPLE_PLUGIN)"
250 @echo " DISABLED_PLUGINS = $(DISABLED_PLUGINS)"
253 ifeq ($(findstring y,$(UNATTENDED)),y)
256 ifeq ($(filter ubuntu debian,$(OS_ID)),$(OS_ID))
257 @MISSING=$$(apt-get install -y -qq -s $(DEB_DEPENDS) | grep "^Inst ") ; \
258 if [ -n "$$MISSING" ] ; then \
259 echo "\nPlease install missing packages: \n$$MISSING\n" ; \
260 echo "by executing \"make install-dep\"\n" ; \
264 else ifneq ("$(wildcard /etc/redhat-release)","")
265 @for i in $(RPM_DEPENDS) ; do \
266 RPM=$$(basename -s .rpm "$${i##*/}" | cut -d- -f1,2,3,4) ; \
267 MISSING+=$$(rpm -q $$RPM | grep "^package") ; \
269 if [ -n "$$MISSING" ] ; then \
270 echo "Please install missing RPMs: \n$$MISSING\n" ; \
271 echo "by executing \"make install-dep\"\n" ; \
280 @echo "'make bootstrap' is not needed anymore"
284 ifeq ($(filter ubuntu debian,$(OS_ID)),$(OS_ID))
285 @sudo -E apt-get update
286 @sudo -E apt-get $(APT_ARGS) $(CONFIRM) $(FORCE) install $(DEB_DEPENDS)
287 else ifneq ("$(wildcard /etc/redhat-release)","")
289 @sudo -E yum-config-manager --enable rhel-server-rhscl-7-rpms
290 @sudo -E yum groupinstall $(CONFIRM) $(RPM_DEPENDS_GROUPS)
291 @sudo -E yum install $(CONFIRM) $(RPM_DEPENDS)
292 @sudo -E debuginfo-install $(CONFIRM) glibc openssl-libs mbedtls-devel zlib
293 else ifeq ($(OS_ID)-$(OS_VERSION_ID),centos-8)
294 @sudo -E dnf install $(CONFIRM) dnf-plugins-core epel-release
295 @sudo -E dnf config-manager --set-enabled \
296 $(shell dnf repolist all 2>/dev/null|grep -i powertools|cut -d' ' -f1)
297 @sudo -E dnf groupinstall $(CONFIRM) $(RPM_DEPENDS_GROUPS)
298 @sudo -E dnf install --skip-broken $(CONFIRM) $(RPM_DEPENDS)
299 else ifeq ($(OS_ID),centos)
300 @sudo -E yum install $(CONFIRM) centos-release-scl-rh epel-release
301 @sudo -E yum groupinstall $(CONFIRM) $(RPM_DEPENDS_GROUPS)
302 @sudo -E yum install $(CONFIRM) $(RPM_DEPENDS)
303 @sudo -E yum install $(CONFIRM) --enablerepo=base-debuginfo $(RPM_DEPENDS_DEBUG)
304 else ifeq ($(OS_ID),fedora)
305 @sudo -E dnf groupinstall $(CONFIRM) $(RPM_DEPENDS_GROUPS)
306 @sudo -E dnf install $(CONFIRM) $(RPM_DEPENDS)
307 @sudo -E debuginfo-install $(CONFIRM) glibc openssl-libs mbedtls-devel zlib
310 $(error "This option currently works only on Ubuntu, Debian, RHEL, or CentOS systems")
312 git config commit.template .git_commit_template.txt
315 install-deps: install-dep
318 @make -C $(BR) PLATFORM=$(PLATFORM) TAG=$(1) $(2)
321 $(BR)/scripts/.version:
322 ifneq ("$(wildcard /etc/redhat-release)","")
323 $(shell $(BR)/scripts/version rpm-string > $(BR)/scripts/.version)
325 $(shell $(BR)/scripts/version > $(BR)/scripts/.version)
328 DIST_FILE = $(BR)/vpp-$(shell src/scripts/version).tar
329 DIST_SUBDIR = vpp-$(shell src/scripts/version|cut -f1 -d-)
333 @if git rev-parse 2> /dev/null ; then \
335 --prefix=$(DIST_SUBDIR)/ \
339 git describe --long > $(BR)/.version ; \
341 (cd .. ; tar -cf $(DIST_FILE) $(DIST_SUBDIR) --exclude=*.tar) ; \
342 src/scripts/version > $(BR)/.version ; \
345 --file $(DIST_FILE) \
346 --transform='s,.*/.version,$(DIST_SUBDIR)/src/scripts/.version,' \
348 @$(RM) $(BR)/.version $(DIST_FILE).xz
349 @xz -v --threads=0 $(DIST_FILE)
350 @$(RM) $(BR)/vpp-latest.tar.xz
351 @ln -rs $(DIST_FILE).xz $(BR)/vpp-latest.tar.xz
354 build: $(BR)/.deps.ok
355 $(call make,$(PLATFORM)_debug,$(addsuffix -install,$(TARGETS)))
359 @$(RM) $(BR)/*.tar.xz
362 wipe: wipedist test-wipe $(BR)/.deps.ok
363 $(call make,$(PLATFORM)_debug,$(addsuffix -wipe,$(TARGETS)))
364 @find . -type f -name "*.api.json" ! -path "./src/*" -exec rm {} \;
369 .PHONY: build-release
370 build-release: $(BR)/.deps.ok
371 $(call make,$(PLATFORM),$(addsuffix -install,$(TARGETS)))
374 wipe-release: test-wipe $(BR)/.deps.ok
375 $(call make,$(PLATFORM),$(addsuffix -wipe,$(TARGETS)))
377 .PHONY: rebuild-release
378 rebuild-release: wipe-release build-release
380 export TEST_DIR ?= $(WS_ROOT)/test
381 export RND_SEED ?= $(shell python3 -c 'import time; print(time.time())')
384 $(if $(filter-out $(3),retest),make -C $(BR) PLATFORM=$(1) TAG=$(2) vpp-install,)
385 $(eval libs:=lib lib64)
387 VPP_BUILD_DIR=$(BR)/build-$(2)-native \
388 VPP_BIN=$(BR)/install-$(2)-native/vpp/bin/vpp \
389 VPP_INSTALL_PATH=$(BR)/install-$(2)-native/ \
390 EXTENDED_TESTS=$(EXTENDED_TESTS) \
393 RND_SEED=$(RND_SEED) \
394 CACHE_OUTPUT=$(CACHE_OUTPUT) \
400 $(call test,vpp,vpp,test)
404 $(call test,vpp,vpp_debug,test)
408 $(call test,vpp,vpp_gcov,test)
412 $(eval EXTENDED_TESTS=yes)
413 $(call test,vpp,vpp,test)
415 .PHONY: test-all-debug
417 $(eval EXTENDED_TESTS=yes)
418 $(call test,vpp,vpp_debug,test)
421 papi-wipe: test-wipe-papi
422 $(call banner,"This command is deprecated. Please use 'test-wipe-papi'")
424 .PHONY: test-wipe-papi
426 @make -C test wipe-papi
438 $(call test,vpp,vpp,shell)
440 .PHONY: test-shell-debug
442 $(call test,vpp,vpp_debug,shell)
444 .PHONY: test-shell-gcov
446 $(call test,vpp,vpp_gcov,shell)
450 @make -C test test-dep
454 @echo "make test-doc is DEPRECATED: use 'make doc'"
457 .PHONY: test-wipe-doc
459 @echo "make test-wipe-doc is DEPRECATED"
464 $(eval EXTENDED_TESTS=yes)
465 $(call test,vpp,vpp_gcov,cov)
467 .PHONY: test-wipe-cov
469 @make -C test wipe-cov
471 .PHONY: test-wipe-all
473 @make -C test wipe-all
475 .PHONY: test-checkstyle
477 @make -C test checkstyle
479 .PHONY: test-checkstyle-diff
480 test-checkstyle-diff:
481 @make -C test checkstyle-diff
483 .PHONY: test-refresh-deps
485 @make -C test refresh-deps
489 $(call test,vpp,vpp,retest)
493 $(call test,vpp,vpp_debug,retest)
497 $(eval EXTENDED_TESTS=yes)
498 $(call test,vpp,vpp,retest)
500 .PHONY: retest-all-debug
502 $(eval EXTENDED_TESTS=yes)
503 $(call test,vpp,vpp_debug,retest)
505 .PHONY: test-start-vpp-in-gdb
506 test-start-vpp-in-gdb:
507 $(call test,vpp,vpp,start-gdb)
509 .PHONY: test-start-vpp-debug-in-gdb
510 test-start-vpp-debug-in-gdb:
511 $(call test,vpp,vpp_debug,start-gdb)
513 ifeq ("$(wildcard $(STARTUP_CONF))","")
515 @echo "WARNING: STARTUP_CONF not defined or file doesn't exist."
516 @echo " Running with minimal startup config: $(MINIMAL_STARTUP_CONF)\n"
517 @cd $(STARTUP_DIR) && \
518 $(SUDO) $(2) $(1)/vpp/bin/vpp $(MINIMAL_STARTUP_CONF)
522 @cd $(STARTUP_DIR) && \
523 $(SUDO) $(2) $(1)/vpp/bin/vpp $(shell cat $(STARTUP_CONF) | sed -e 's/#.*//')
528 @find src -name '*.[chS]' > $@
534 $(call run, $(BR)/install-$(PLATFORM)_debug-native)
538 $(call run, $(BR)/install-$(PLATFORM)-native)
542 $(call run, $(BR)/install-$(PLATFORM)_debug-native,$(GDB) $(GDB_ARGS) --args)
544 .PHONY: build-coverity
546 $(call make,$(PLATFORM)_coverity,install-packages)
547 @make -C build-root PLATFORM=vpp TAG=vpp_coverity libmemif-install
549 .PHONY: debug-release
551 $(call run, $(BR)/install-$(PLATFORM)-native,$(GDB) $(GDB_ARGS) --args)
555 $(call make,$(PLATFORM)_debug,vpp-api-test-install)
559 @$(SUDO) $(BR)/install-$(PLATFORM)_debug-native/vpp/bin/vpp_api_test
563 $(call make,$(PLATFORM),vpp-package-deb)
569 SNAPCRAFT_BUILD_ENVIRONMENT_MEMORY=8G \
570 SNAPCRAFT_BUILD_ENVIRONMENT_CPU=6 \
579 .PHONY: pkg-deb-debug
581 $(call make,$(PLATFORM)_debug,vpp-package-deb)
589 make -C extras/rpm srpm
591 .PHONY: install-ext-deps
593 make -C build/external install-$(PKG)
595 .PHONY: install-ext-dep
596 install-ext-dep: install-ext-deps
598 .PHONY: json-api-files
600 $(WS_ROOT)/src/tools/vppapigen/generate_json.py
602 .PHONY: json-api-files-debug
603 json-api-files-debug:
604 $(WS_ROOT)/src/tools/vppapigen/generate_json.py --debug-target
607 go-api-files: json-api-files
608 $(WS_ROOT)/src/tools/vppapigen/generate_go.py
612 @ctags --totals --tag-relative=yes -L $<
617 @gtags --gtagslabel=ctags
625 @ninja -C build-root/build-vpp_debug-native/vpp build.ninja
626 @ninja -C build-root/build-vpp_debug-native/vpp -t compdb | \
627 src/scripts/compdb_cleanup.py > compile_commands.json
630 checkstyle: checkfeaturelist
631 @extras/scripts/checkstyle.sh
633 .PHONY: checkstyle-commit
635 @extras/scripts/check_commit_msg.sh
637 .PHONY: checkstyle-test
638 checkstyle-test: test-checkstyle
640 .PHONY: checkstyle-all
641 checkstyle-all: checkstyle-commit checkstyle checkstyle-test
645 @extras/scripts/checkstyle.sh --fix
647 .PHONY: checkstyle-api
649 @extras/scripts/crcchecker.py --check-patchset
651 # necessary because Bug 1696324 - Update to python3.6 breaks PyYAML dependencies
652 # Status: CLOSED CANTFIX
653 # https://bugzilla.redhat.com/show_bug.cgi?id=1696324
654 .PHONY: centos-pyyaml
656 ifeq ($(OS_ID)-$(OS_VERSION_ID),centos-8)
657 @sudo -E yum install $(CONFIRM) python3-pyyaml
661 featurelist: centos-pyyaml
662 @extras/scripts/fts.py --all --markdown
664 .PHONY: checkfeaturelist
665 checkfeaturelist: centos-pyyaml
666 @extras/scripts/fts.py --validate --all
669 # Build the documentation
672 .PHONY: bootstrap-doxygen
674 @echo "make bootstrap-doxygen is DEPRECATED"
679 @echo "make doxygen is DEPRECATED: use 'make docs'"
684 @echo "make wipe-doxygen is DEPRECATED"
689 @make -C $(WS_ROOT)/docs $*
693 @make -C $(WS_ROOT)/docs docs
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 $(PKG) packages")
706 MAKE_VERIFY_GATE_OS ?= ubuntu-18.04
709 ifeq ($(OS_ID)-$(OS_VERSION_ID),$(MAKE_VERIFY_GATE_OS))
710 $(call banner,"Testing vppapigen")
711 @src/tools/vppapigen/test_vppapigen.py
712 $(call banner,"Running tests")
713 @make COMPRESS_FAILED_TEST_LOGS=yes RETRIES=3 test
715 $(call banner,"Skipping tests. Tests under 'make verify' supported on $(MAKE_VERIFY_GATE_OS)")