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