blob: 6b5f9058dda9bc373be3d86ce6f22a1eaa33d60f [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)
Ed Warnickecb9cada2015-12-08 15:45:58 -070033
Thomas F Herbertdc66aad2019-03-29 15:41:48 -040034ifneq ($(shell which cmake3),)
35CMAKE?=cmake3
36else
37CMAKE?=cmake
38endif
39
PiotrX Kleski9235d432020-10-12 15:33:11 +020040ARCH_X86_64=$(filter x86_64,$(shell uname -m))
Damjan Marion01fe7ab2023-10-23 18:36:18 +020041AARCH64=$(filter aarch64,$(shell uname -m))
PiotrX Kleski9235d432020-10-12 15:33:11 +020042
Damjan Marion561f2732018-09-21 12:27:45 +020043include packages.mk
Damjan Marion561f2732018-09-21 12:27:45 +020044include packages/ipsec-mb.mk
Aloys Augustin7cae0032019-04-01 16:43:29 +020045include packages/quicly.mk
Tom Jonesb077d662024-01-24 10:46:44 +000046ifneq ($(shell uname), FreeBSD)
Benoît Gannefe750c22019-03-25 11:41:34 +010047include packages/rdma-core.mk
Mohammed Hawari4e939ce2022-09-19 16:26:25 +020048include packages/dpdk.mk
Yulong Peif9a17482023-01-05 02:26:32 +000049include packages/xdp-tools.mk
Damjan Marion01fe7ab2023-10-23 18:36:18 +020050include packages/octeon-roc.mk
Tom Jonesb077d662024-01-24 10:46:44 +000051endif # FreeBSD
Damjan Marion2ce7f982017-01-09 20:24:50 +010052
Ed Warnickecb9cada2015-12-08 15:45:58 -070053.PHONY: clean
54clean:
55 @rm -rf $(B) $(I)
56
Benoît Gannefe750c22019-03-25 11:41:34 +010057.PHONY: install
Tom Jonesb077d662024-01-24 10:46:44 +000058ifeq ($(shell uname), FreeBSD)
59install: $(if $(ARCH_X86_64), ipsec-mb-install) quicly-install
60else
Damjan Marion01fe7ab2023-10-23 18:36:18 +020061install: $(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 +000062endif # FreeBSD
Benoît Gannefe750c22019-03-25 11:41:34 +010063
64.PHONY: config
Tom Jonesb077d662024-01-24 10:46:44 +000065ifeq ($(shell uname), FreeBSD)
66config: $(if $(ARCH_X86_64), ipsec-mb-config) quicly-build
67else
Damjan Marionaa659ef2022-04-05 19:26:51 +020068config: $(if $(ARCH_X86_64), ipsec-mb-config) dpdk-config rdma-core-config quicly-build
Tom Jonesb077d662024-01-24 10:46:44 +000069endif # FreeBSD
Benoît Gannefe750c22019-03-25 11:41:34 +010070
Damjan Marion2ce7f982017-01-09 20:24:50 +010071##############################################################################
72# .deb packaging
73##############################################################################
74
Damjan Marion4a6cb832018-09-18 18:41:38 +020075DEB_VER := $(PKG_VERSION)
Damjan Marion2ce7f982017-01-09 20:24:50 +010076DEB_ARCH=$(shell dpkg --print-architecture 2> /dev/null)
Damjan Marion4a6cb832018-09-18 18:41:38 +020077DEV_DEB=vpp-ext-deps_$(DEB_VER)-$(PKG_SUFFIX)_$(DEB_ARCH).deb
78INSTALLED_VER=$(shell dpkg-query --showformat='$${Version}' --show vpp-ext-deps 2> /dev/null)
Damjan Marion2ce7f982017-01-09 20:24:50 +010079
80.PHONY: build-deb install-deb check-deb
81
82deb/debian/changelog: Makefile
Damjan Marion4a6cb832018-09-18 18:41:38 +020083 @echo "vpp-ext-deps ($(DEB_VER)-$(PKG_SUFFIX)) unstable; urgency=low" > $@
Damjan Marion2ce7f982017-01-09 20:24:50 +010084 @echo "" >> $@
Damjan Marion4a6cb832018-09-18 18:41:38 +020085 @echo " * Version $(DEB_VER)" >> $@
Damjan Marion2ce7f982017-01-09 20:24:50 +010086 @echo "" >> $@
Andrew Yourtchenko5ca8bfc2023-10-18 21:18:32 +000087 @echo " -- VPP Dev <vpp-dev@lists.fd.io> $(shell date -R --date=@${SOURCE_DATE_EPOCH})" >> $@
Damjan Marion2ce7f982017-01-09 20:24:50 +010088
89$(DEV_DEB): deb/debian/changelog
90 @cd deb && dpkg-buildpackage -b -uc -us
Damjan Mariond93638e2019-03-29 21:22:09 +010091 git clean -fdx deb
Damjan Marion2ce7f982017-01-09 20:24:50 +010092
93build-deb: $(DEV_DEB)
94
95install-deb:
Damjan Marion4a6cb832018-09-18 18:41:38 +020096ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
Renato Botelho do Couto893daca2024-06-05 18:11:46 +000097 @$(MAKE) $(DEV_DEB)
Damjan Marion2ce7f982017-01-09 20:24:50 +010098 @sudo dpkg -i $(DEV_DEB)
99else
100 @echo "=========================================================="
Damjan Marion4a6cb832018-09-18 18:41:38 +0200101 @echo " Up-to-date vpp-ext-deps package already installed"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100102 @echo "=========================================================="
103endif
104
105check-deb:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200106ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
Damjan Marion2ce7f982017-01-09 20:24:50 +0100107 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +0100108 @echo " Out of date vpp-ext-deps package installed."
109 @echo " Installed: $(INSTALLED_VER)"
110 @echo " Needed: $(DEB_VER)-$(PKG_SUFFIX)"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100111 @echo ""
Damjan Marion4a6cb832018-09-18 18:41:38 +0200112 @echo " Please upgrade by invoking 'make install-ext-deps'"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100113 @echo " from the top level directory."
114 @echo "=========================================================="
115endif
116
117##############################################################################
118# .rpm packaging
119##############################################################################
120
Damjan Marion4a6cb832018-09-18 18:41:38 +0200121RPM_VER := $(PKG_VERSION)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100122RPM_ARCH=$(shell rpm --eval "%{_arch}" 2> /dev/null)
Damjan Marion4a6cb832018-09-18 18:41:38 +0200123DEV_RPM=vpp-ext-deps-$(RPM_VER)-$(PKG_SUFFIX).$(RPM_ARCH).rpm
jiangxiaoming5ab7dc42020-12-30 15:25:15 +0800124INSTALLED_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 +0100125
126.PHONY: build-rpm install-rpm check-rpm
127
Damjan Marion4a6cb832018-09-18 18:41:38 +0200128$(DEV_RPM): Makefile rpm/vpp-ext-deps.spec
Damjan Marion2ce7f982017-01-09 20:24:50 +0100129 @rpmbuild -bb \
130 --define "_topdir $(CURDIR)/rpm" \
Damjan Marion4a6cb832018-09-18 18:41:38 +0200131 --define "_version $(RPM_VER)" \
Damjan Marion2ce7f982017-01-09 20:24:50 +0100132 --define "_release $(PKG_SUFFIX)" \
Damjan Marion4a6cb832018-09-18 18:41:38 +0200133 $(CURDIR)/rpm/vpp-ext-deps.spec
Damjan Marion2ce7f982017-01-09 20:24:50 +0100134 mv rpm/RPMS/$(RPM_ARCH)/*.rpm .
Damjan Mariond93638e2019-03-29 21:22:09 +0100135 @git clean -fdx rpm
Damjan Marion2ce7f982017-01-09 20:24:50 +0100136
137build-rpm: $(DEV_RPM)
138
139install-rpm:
Damjan Marion74447d42018-09-27 14:04:43 +0200140ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100141 @$(MAKE) $(DEV_RPM)
Dave Barachb2528482019-07-01 19:08:33 -0400142 sudo rpm -e vpp-ext-deps || true
Marco Varlesefe7740e2018-10-25 11:49:39 +0200143 sudo rpm -Uih --force $(DEV_RPM)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100144else
145 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +0100146 @echo " Up-to-date vpp-ext-deps package already installed"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100147 @echo "=========================================================="
148endif
149
150check-rpm:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200151ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
Damjan Marion2ce7f982017-01-09 20:24:50 +0100152 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +0100153 @echo " Out of date vpp-ext-deps package installed."
154 @echo " Installed: $(INSTALLED_RPM_VER)"
155 @echo " Needed: $(RPM_VER)-$(PKG_SUFFIX)"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100156 @echo ""
Damjan Marion4a6cb832018-09-18 18:41:38 +0200157 @echo " Please upgrade by invoking 'make install-ext-deps'"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100158 @echo " from the top level directory."
159 @echo "=========================================================="
160endif
161
162##############################################################################
163# ebuild support
164##############################################################################
165
166.PHONY: ebuild-build ebuild-install
167
168ebuild-build:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200169ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100170 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +0100171 @echo "Building vpp-ext-deps from source. Consider installing"
172 @echo "development package by invoking 'make install-ext-deps'"
173 @echo "from the top level directory"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100174 @echo "=========================================================="
Tom Jones0aa0d6f2024-01-18 10:48:17 +0000175 $(MAKE) config
Damjan Marion2ce7f982017-01-09 20:24:50 +0100176else
Damjan Marion4a6cb832018-09-18 18:41:38 +0200177ifneq ($(INSTALLED_VER),)
Renato Botelho do Couto893daca2024-06-05 18:11:46 +0000178 $(MAKE) check-deb
Damjan Marion2ce7f982017-01-09 20:24:50 +0100179endif
180ifneq ($(INSTALLED_RPM_VER),)
Tom Jones0aa0d6f2024-01-18 10:48:17 +0000181 $(MAKE) check-rpm
Damjan Marion2ce7f982017-01-09 20:24:50 +0100182endif
183endif
184
185ebuild-install:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200186ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
Tom Jones0aa0d6f2024-01-18 10:48:17 +0000187 $(MAKE) install
Damjan Marion2ce7f982017-01-09 20:24:50 +0100188endif