blob: b4a099c57e1a73a9ed9cab558af97cde02314986 [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 .)
Renato Botelho do Couto8a424332024-06-05 17:49:09 +000024ifeq ($(shell uname), FreeBSD)
Tom Jones26eec752024-02-07 13:17:17 +000025JOBS := $(shell nproc)
26else
Chris Lukeb2861e82017-06-14 11:24:41 -040027JOBS := $(if $(shell [ -f /proc/cpuinfo ] && head /proc/cpuinfo),\
Damjan Marion93242842017-11-13 20:09:21 +010028 $(shell grep -c ^processor /proc/cpuinfo), 2)
Tom Jones26eec752024-02-07 13:17:17 +000029endif # FreeBSD
Ed Warnickecb9cada2015-12-08 15:45:58 -070030
Damjan Marion561f2732018-09-21 12:27:45 +020031B := $(BUILD_DIR)
32I := $(INSTALL_DIR)
Dave Wallace0ef24292024-09-13 14:29:24 -040033ifeq ($(WORKSPACE),)
34L := $(B)
35else
36L := $(WORKSPACE)/archives/vpp-ext-deps
37$(shell rm -rf $(L) && mkdir -p $(L))
38endif
Ed Warnickecb9cada2015-12-08 15:45:58 -070039
Thomas F Herbertdc66aad2019-03-29 15:41:48 -040040ifneq ($(shell which cmake3),)
41CMAKE?=cmake3
42else
43CMAKE?=cmake
44endif
45
PiotrX Kleski9235d432020-10-12 15:33:11 +020046ARCH_X86_64=$(filter x86_64,$(shell uname -m))
Damjan Marion01fe7ab2023-10-23 18:36:18 +020047AARCH64=$(filter aarch64,$(shell uname -m))
PiotrX Kleski9235d432020-10-12 15:33:11 +020048
Damjan Marion561f2732018-09-21 12:27:45 +020049include packages.mk
Damjan Marion561f2732018-09-21 12:27:45 +020050include packages/ipsec-mb.mk
Aloys Augustin7cae0032019-04-01 16:43:29 +020051include packages/quicly.mk
Tom Jonesb077d662024-01-24 10:46:44 +000052ifneq ($(shell uname), FreeBSD)
Benoît Gannefe750c22019-03-25 11:41:34 +010053include packages/rdma-core.mk
Yulong Peif9a17482023-01-05 02:26:32 +000054include packages/xdp-tools.mk
Damjan Marion01fe7ab2023-10-23 18:36:18 +020055include packages/octeon-roc.mk
Tom Jones70522a12024-02-01 16:10:44 +000056endif # ! FreeBSD
Dave Wallace056b7d02024-09-30 21:00:13 -040057include packages/dpdk.mk
Damjan Marion2ce7f982017-01-09 20:24:50 +010058
Ed Warnickecb9cada2015-12-08 15:45:58 -070059.PHONY: clean
60clean:
61 @rm -rf $(B) $(I)
62
Benoît Gannefe750c22019-03-25 11:41:34 +010063.PHONY: install
Tom Jonesb077d662024-01-24 10:46:44 +000064ifeq ($(shell uname), FreeBSD)
Tom Jones70522a12024-02-01 16:10:44 +000065install: $(if $(ARCH_X86_64), ipsec-mb-install) dpdk-install quicly-install
Tom Jonesb077d662024-01-24 10:46:44 +000066else
Damjan Marion01fe7ab2023-10-23 18:36:18 +020067install: $(if $(ARCH_X86_64), ipsec-mb-install) dpdk-install rdma-core-install quicly-install xdp-tools-install $(if $(AARCH64), octeon-roc-install)
Tom Jonesb077d662024-01-24 10:46:44 +000068endif # FreeBSD
Benoît Gannefe750c22019-03-25 11:41:34 +010069
70.PHONY: config
Tom Jonesb077d662024-01-24 10:46:44 +000071ifeq ($(shell uname), FreeBSD)
Tom Jones70522a12024-02-01 16:10:44 +000072config: $(if $(ARCH_X86_64), ipsec-mb-config) dpdk-config quicly-build
Tom Jonesb077d662024-01-24 10:46:44 +000073else
Damjan Marionaa659ef2022-04-05 19:26:51 +020074config: $(if $(ARCH_X86_64), ipsec-mb-config) dpdk-config rdma-core-config quicly-build
Tom Jonesb077d662024-01-24 10:46:44 +000075endif # FreeBSD
Benoît Gannefe750c22019-03-25 11:41:34 +010076
Damjan Marion2ce7f982017-01-09 20:24:50 +010077##############################################################################
78# .deb packaging
79##############################################################################
80
Damjan Marion4a6cb832018-09-18 18:41:38 +020081DEB_VER := $(PKG_VERSION)
Damjan Marion2ce7f982017-01-09 20:24:50 +010082DEB_ARCH=$(shell dpkg --print-architecture 2> /dev/null)
Damjan Marion4a6cb832018-09-18 18:41:38 +020083DEV_DEB=vpp-ext-deps_$(DEB_VER)-$(PKG_SUFFIX)_$(DEB_ARCH).deb
84INSTALLED_VER=$(shell dpkg-query --showformat='$${Version}' --show vpp-ext-deps 2> /dev/null)
Damjan Marion2ce7f982017-01-09 20:24:50 +010085
86.PHONY: build-deb install-deb check-deb
87
88deb/debian/changelog: Makefile
Damjan Marion4a6cb832018-09-18 18:41:38 +020089 @echo "vpp-ext-deps ($(DEB_VER)-$(PKG_SUFFIX)) unstable; urgency=low" > $@
Damjan Marion2ce7f982017-01-09 20:24:50 +010090 @echo "" >> $@
Damjan Marion4a6cb832018-09-18 18:41:38 +020091 @echo " * Version $(DEB_VER)" >> $@
Damjan Marion2ce7f982017-01-09 20:24:50 +010092 @echo "" >> $@
Andrew Yourtchenko5ca8bfc2023-10-18 21:18:32 +000093 @echo " -- VPP Dev <vpp-dev@lists.fd.io> $(shell date -R --date=@${SOURCE_DATE_EPOCH})" >> $@
Damjan Marion2ce7f982017-01-09 20:24:50 +010094
95$(DEV_DEB): deb/debian/changelog
96 @cd deb && dpkg-buildpackage -b -uc -us
Damjan Mariond93638e2019-03-29 21:22:09 +010097 git clean -fdx deb
Damjan Marion2ce7f982017-01-09 20:24:50 +010098
99build-deb: $(DEV_DEB)
100
101install-deb:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200102ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
Renato Botelho do Couto893daca2024-06-05 18:11:46 +0000103 @$(MAKE) $(DEV_DEB)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100104 @sudo dpkg -i $(DEV_DEB)
105else
106 @echo "=========================================================="
Damjan Marion4a6cb832018-09-18 18:41:38 +0200107 @echo " Up-to-date vpp-ext-deps package already installed"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100108 @echo "=========================================================="
109endif
110
111check-deb:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200112ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
Damjan Marion2ce7f982017-01-09 20:24:50 +0100113 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +0100114 @echo " Out of date vpp-ext-deps package installed."
115 @echo " Installed: $(INSTALLED_VER)"
116 @echo " Needed: $(DEB_VER)-$(PKG_SUFFIX)"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100117 @echo ""
Damjan Marion4a6cb832018-09-18 18:41:38 +0200118 @echo " Please upgrade by invoking 'make install-ext-deps'"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100119 @echo " from the top level directory."
120 @echo "=========================================================="
121endif
122
123##############################################################################
124# .rpm packaging
125##############################################################################
126
Damjan Marion4a6cb832018-09-18 18:41:38 +0200127RPM_VER := $(PKG_VERSION)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100128RPM_ARCH=$(shell rpm --eval "%{_arch}" 2> /dev/null)
Damjan Marion4a6cb832018-09-18 18:41:38 +0200129DEV_RPM=vpp-ext-deps-$(RPM_VER)-$(PKG_SUFFIX).$(RPM_ARCH).rpm
jiangxiaoming5ab7dc42020-12-30 15:25:15 +0800130INSTALLED_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 +0100131
132.PHONY: build-rpm install-rpm check-rpm
133
Damjan Marion4a6cb832018-09-18 18:41:38 +0200134$(DEV_RPM): Makefile rpm/vpp-ext-deps.spec
Damjan Marion2ce7f982017-01-09 20:24:50 +0100135 @rpmbuild -bb \
136 --define "_topdir $(CURDIR)/rpm" \
Damjan Marion4a6cb832018-09-18 18:41:38 +0200137 --define "_version $(RPM_VER)" \
Damjan Marion2ce7f982017-01-09 20:24:50 +0100138 --define "_release $(PKG_SUFFIX)" \
Damjan Marion4a6cb832018-09-18 18:41:38 +0200139 $(CURDIR)/rpm/vpp-ext-deps.spec
Damjan Marion2ce7f982017-01-09 20:24:50 +0100140 mv rpm/RPMS/$(RPM_ARCH)/*.rpm .
Damjan Mariond93638e2019-03-29 21:22:09 +0100141 @git clean -fdx rpm
Damjan Marion2ce7f982017-01-09 20:24:50 +0100142
143build-rpm: $(DEV_RPM)
144
145install-rpm:
Damjan Marion74447d42018-09-27 14:04:43 +0200146ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100147 @$(MAKE) $(DEV_RPM)
Dave Barachb2528482019-07-01 19:08:33 -0400148 sudo rpm -e vpp-ext-deps || true
Marco Varlesefe7740e2018-10-25 11:49:39 +0200149 sudo rpm -Uih --force $(DEV_RPM)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100150else
151 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +0100152 @echo " Up-to-date vpp-ext-deps package already installed"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100153 @echo "=========================================================="
154endif
155
156check-rpm:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200157ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
Damjan Marion2ce7f982017-01-09 20:24:50 +0100158 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +0100159 @echo " Out of date vpp-ext-deps package installed."
160 @echo " Installed: $(INSTALLED_RPM_VER)"
161 @echo " Needed: $(RPM_VER)-$(PKG_SUFFIX)"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100162 @echo ""
Damjan Marion4a6cb832018-09-18 18:41:38 +0200163 @echo " Please upgrade by invoking 'make install-ext-deps'"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100164 @echo " from the top level directory."
165 @echo "=========================================================="
166endif
167
168##############################################################################
169# ebuild support
170##############################################################################
171
172.PHONY: ebuild-build ebuild-install
173
174ebuild-build:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200175ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100176 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +0100177 @echo "Building vpp-ext-deps from source. Consider installing"
178 @echo "development package by invoking 'make install-ext-deps'"
179 @echo "from the top level directory"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100180 @echo "=========================================================="
Tom Jones0aa0d6f2024-01-18 10:48:17 +0000181 $(MAKE) config
Damjan Marion2ce7f982017-01-09 20:24:50 +0100182else
Damjan Marion4a6cb832018-09-18 18:41:38 +0200183ifneq ($(INSTALLED_VER),)
Renato Botelho do Couto893daca2024-06-05 18:11:46 +0000184 $(MAKE) check-deb
Damjan Marion2ce7f982017-01-09 20:24:50 +0100185endif
186ifneq ($(INSTALLED_RPM_VER),)
Tom Jones0aa0d6f2024-01-18 10:48:17 +0000187 $(MAKE) check-rpm
Damjan Marion2ce7f982017-01-09 20:24:50 +0100188endif
189endif
190
191ebuild-install:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200192ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
Tom Jones0aa0d6f2024-01-18 10:48:17 +0000193 $(MAKE) install
Damjan Marion2ce7f982017-01-09 20:24:50 +0100194endif