blob: af2512c4614d647b68ee45ccf4f0196f235a9934 [file] [log] [blame]
Ed Warnickecb9cada2015-12-08 15:45:58 -07001# Copyright (c) 2015 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# Scripts require non-POSIX parts of bash
Tom Jonesc3b416c2024-01-18 14:51:44 +000015SHELL := $(shell which bash)
Ed Warnickecb9cada2015-12-08 15:45:58 -070016
Damjan Marion561f2732018-09-21 12:27:45 +020017DL_CACHE_DIR = $(HOME)/Downloads
Damjan Marion561f2732018-09-21 12:27:45 +020018MAKE_ARGS ?= -j
19BUILD_DIR ?= $(CURDIR)/_build
20INSTALL_DIR ?= $(CURDIR)/_install
Renato Botelho do Coutodcd08b22022-03-08 15:40:49 -030021PKG_VERSION ?= $(shell git describe --abbrev=0 --match 'v[0-9]*' | cut -d- -f1 | cut -dv -f2 | cut -d. -f1,2)
Damjan Marion4f5f8d72018-10-11 09:18:26 -070022PKG_SUFFIX ?= $(shell git log --oneline v$(PKG_VERSION)-rc0.. . | wc -l)
Andrew Yourtchenko5ca8bfc2023-10-18 21:18:32 +000023SOURCE_DATE_EPOCH ?= $(shell git log -1 --pretty=%ct .)
Chris Lukeb2861e82017-06-14 11:24:41 -040024JOBS := $(if $(shell [ -f /proc/cpuinfo ] && head /proc/cpuinfo),\
Damjan Marion93242842017-11-13 20:09:21 +010025 $(shell grep -c ^processor /proc/cpuinfo), 2)
Ed Warnickecb9cada2015-12-08 15:45:58 -070026
Damjan Marion561f2732018-09-21 12:27:45 +020027B := $(BUILD_DIR)
28I := $(INSTALL_DIR)
Ed Warnickecb9cada2015-12-08 15:45:58 -070029
Thomas F Herbertdc66aad2019-03-29 15:41:48 -040030ifneq ($(shell which cmake3),)
31CMAKE?=cmake3
32else
33CMAKE?=cmake
34endif
35
PiotrX Kleski9235d432020-10-12 15:33:11 +020036ARCH_X86_64=$(filter x86_64,$(shell uname -m))
Damjan Marion01fe7ab2023-10-23 18:36:18 +020037AARCH64=$(filter aarch64,$(shell uname -m))
PiotrX Kleski9235d432020-10-12 15:33:11 +020038
Damjan Marion561f2732018-09-21 12:27:45 +020039include packages.mk
Damjan Marion561f2732018-09-21 12:27:45 +020040include packages/ipsec-mb.mk
Aloys Augustin7cae0032019-04-01 16:43:29 +020041include packages/quicly.mk
Benoît Gannefe750c22019-03-25 11:41:34 +010042include packages/rdma-core.mk
Mohammed Hawari4e939ce2022-09-19 16:26:25 +020043include packages/dpdk.mk
Yulong Peif9a17482023-01-05 02:26:32 +000044include packages/xdp-tools.mk
Damjan Marion01fe7ab2023-10-23 18:36:18 +020045include packages/octeon-roc.mk
Damjan Marion2ce7f982017-01-09 20:24:50 +010046
Ed Warnickecb9cada2015-12-08 15:45:58 -070047.PHONY: clean
48clean:
49 @rm -rf $(B) $(I)
50
Benoît Gannefe750c22019-03-25 11:41:34 +010051.PHONY: install
Damjan Marion01fe7ab2023-10-23 18:36:18 +020052install: $(if $(ARCH_X86_64), ipsec-mb-install) dpdk-install rdma-core-install quicly-install xdp-tools-install $(if $(AARCH64), octeon-roc-install)
Benoît Gannefe750c22019-03-25 11:41:34 +010053
54.PHONY: config
Damjan Marionaa659ef2022-04-05 19:26:51 +020055config: $(if $(ARCH_X86_64), ipsec-mb-config) dpdk-config rdma-core-config quicly-build
Benoît Gannefe750c22019-03-25 11:41:34 +010056
Damjan Marion2ce7f982017-01-09 20:24:50 +010057##############################################################################
58# .deb packaging
59##############################################################################
60
Damjan Marion4a6cb832018-09-18 18:41:38 +020061DEB_VER := $(PKG_VERSION)
Damjan Marion2ce7f982017-01-09 20:24:50 +010062DEB_ARCH=$(shell dpkg --print-architecture 2> /dev/null)
Damjan Marion4a6cb832018-09-18 18:41:38 +020063DEV_DEB=vpp-ext-deps_$(DEB_VER)-$(PKG_SUFFIX)_$(DEB_ARCH).deb
64INSTALLED_VER=$(shell dpkg-query --showformat='$${Version}' --show vpp-ext-deps 2> /dev/null)
Damjan Marion2ce7f982017-01-09 20:24:50 +010065
66.PHONY: build-deb install-deb check-deb
67
68deb/debian/changelog: Makefile
Damjan Marion4a6cb832018-09-18 18:41:38 +020069 @echo "vpp-ext-deps ($(DEB_VER)-$(PKG_SUFFIX)) unstable; urgency=low" > $@
Damjan Marion2ce7f982017-01-09 20:24:50 +010070 @echo "" >> $@
Damjan Marion4a6cb832018-09-18 18:41:38 +020071 @echo " * Version $(DEB_VER)" >> $@
Damjan Marion2ce7f982017-01-09 20:24:50 +010072 @echo "" >> $@
Andrew Yourtchenko5ca8bfc2023-10-18 21:18:32 +000073 @echo " -- VPP Dev <vpp-dev@lists.fd.io> $(shell date -R --date=@${SOURCE_DATE_EPOCH})" >> $@
Damjan Marion2ce7f982017-01-09 20:24:50 +010074
75$(DEV_DEB): deb/debian/changelog
76 @cd deb && dpkg-buildpackage -b -uc -us
Damjan Mariond93638e2019-03-29 21:22:09 +010077 git clean -fdx deb
Damjan Marion2ce7f982017-01-09 20:24:50 +010078
79build-deb: $(DEV_DEB)
80
81install-deb:
Damjan Marion4a6cb832018-09-18 18:41:38 +020082ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
Damjan Marion2ce7f982017-01-09 20:24:50 +010083 @make $(DEV_DEB)
84 @sudo dpkg -i $(DEV_DEB)
85else
86 @echo "=========================================================="
Damjan Marion4a6cb832018-09-18 18:41:38 +020087 @echo " Up-to-date vpp-ext-deps package already installed"
Damjan Marion2ce7f982017-01-09 20:24:50 +010088 @echo "=========================================================="
89endif
90
91check-deb:
Damjan Marion4a6cb832018-09-18 18:41:38 +020092ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
Damjan Marion2ce7f982017-01-09 20:24:50 +010093 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +010094 @echo " Out of date vpp-ext-deps package installed."
95 @echo " Installed: $(INSTALLED_VER)"
96 @echo " Needed: $(DEB_VER)-$(PKG_SUFFIX)"
Damjan Marion2ce7f982017-01-09 20:24:50 +010097 @echo ""
Damjan Marion4a6cb832018-09-18 18:41:38 +020098 @echo " Please upgrade by invoking 'make install-ext-deps'"
Damjan Marion2ce7f982017-01-09 20:24:50 +010099 @echo " from the top level directory."
100 @echo "=========================================================="
101endif
102
103##############################################################################
104# .rpm packaging
105##############################################################################
106
Damjan Marion4a6cb832018-09-18 18:41:38 +0200107RPM_VER := $(PKG_VERSION)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100108RPM_ARCH=$(shell rpm --eval "%{_arch}" 2> /dev/null)
Damjan Marion4a6cb832018-09-18 18:41:38 +0200109DEV_RPM=vpp-ext-deps-$(RPM_VER)-$(PKG_SUFFIX).$(RPM_ARCH).rpm
jiangxiaoming5ab7dc42020-12-30 15:25:15 +0800110INSTALLED_RPM_VER=$(shell rpm -q --queryformat '%{VERSION}-%{RELEASE}' vpp-ext-deps 2> /dev/null | grep -v "vpp-ext-deps")
Damjan Marion2ce7f982017-01-09 20:24:50 +0100111
112.PHONY: build-rpm install-rpm check-rpm
113
Damjan Marion4a6cb832018-09-18 18:41:38 +0200114$(DEV_RPM): Makefile rpm/vpp-ext-deps.spec
Damjan Marion2ce7f982017-01-09 20:24:50 +0100115 @rpmbuild -bb \
116 --define "_topdir $(CURDIR)/rpm" \
Damjan Marion4a6cb832018-09-18 18:41:38 +0200117 --define "_version $(RPM_VER)" \
Damjan Marion2ce7f982017-01-09 20:24:50 +0100118 --define "_release $(PKG_SUFFIX)" \
Damjan Marion4a6cb832018-09-18 18:41:38 +0200119 $(CURDIR)/rpm/vpp-ext-deps.spec
Damjan Marion2ce7f982017-01-09 20:24:50 +0100120 mv rpm/RPMS/$(RPM_ARCH)/*.rpm .
Damjan Mariond93638e2019-03-29 21:22:09 +0100121 @git clean -fdx rpm
Damjan Marion2ce7f982017-01-09 20:24:50 +0100122
123build-rpm: $(DEV_RPM)
124
125install-rpm:
Damjan Marion74447d42018-09-27 14:04:43 +0200126ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100127 @$(MAKE) $(DEV_RPM)
Dave Barachb2528482019-07-01 19:08:33 -0400128 sudo rpm -e vpp-ext-deps || true
Marco Varlesefe7740e2018-10-25 11:49:39 +0200129 sudo rpm -Uih --force $(DEV_RPM)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100130else
131 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +0100132 @echo " Up-to-date vpp-ext-deps package already installed"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100133 @echo "=========================================================="
134endif
135
136check-rpm:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200137ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
Damjan Marion2ce7f982017-01-09 20:24:50 +0100138 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +0100139 @echo " Out of date vpp-ext-deps package installed."
140 @echo " Installed: $(INSTALLED_RPM_VER)"
141 @echo " Needed: $(RPM_VER)-$(PKG_SUFFIX)"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100142 @echo ""
Damjan Marion4a6cb832018-09-18 18:41:38 +0200143 @echo " Please upgrade by invoking 'make install-ext-deps'"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100144 @echo " from the top level directory."
145 @echo "=========================================================="
146endif
147
148##############################################################################
149# ebuild support
150##############################################################################
151
152.PHONY: ebuild-build ebuild-install
153
154ebuild-build:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200155ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100156 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +0100157 @echo "Building vpp-ext-deps from source. Consider installing"
158 @echo "development package by invoking 'make install-ext-deps'"
159 @echo "from the top level directory"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100160 @echo "=========================================================="
Tom Jones0aa0d6f2024-01-18 10:48:17 +0000161 $(MAKE) config
Damjan Marion2ce7f982017-01-09 20:24:50 +0100162else
Damjan Marion4a6cb832018-09-18 18:41:38 +0200163ifneq ($(INSTALLED_VER),)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100164 make check-deb
165endif
166ifneq ($(INSTALLED_RPM_VER),)
Tom Jones0aa0d6f2024-01-18 10:48:17 +0000167 $(MAKE) check-rpm
Damjan Marion2ce7f982017-01-09 20:24:50 +0100168endif
169endif
170
171ebuild-install:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200172ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
Tom Jones0aa0d6f2024-01-18 10:48:17 +0000173 $(MAKE) install
Damjan Marion2ce7f982017-01-09 20:24:50 +0100174endif