blob: fb3cd94e52683e9cd6e8f70e2b2a82a10b09f111 [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
15SHELL := /bin/bash
16
Damjan Marion561f2732018-09-21 12:27:45 +020017DL_CACHE_DIR = $(HOME)/Downloads
18MAKE ?= make
19MAKE_ARGS ?= -j
20BUILD_DIR ?= $(CURDIR)/_build
21INSTALL_DIR ?= $(CURDIR)/_install
Renato Botelho do Coutodcd08b22022-03-08 15:40:49 -030022PKG_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 -070023PKG_SUFFIX ?= $(shell git log --oneline v$(PKG_VERSION)-rc0.. . | wc -l)
Andrew Yourtchenko5ca8bfc2023-10-18 21:18:32 +000024SOURCE_DATE_EPOCH ?= $(shell git log -1 --pretty=%ct .)
Chris Lukeb2861e82017-06-14 11:24:41 -040025JOBS := $(if $(shell [ -f /proc/cpuinfo ] && head /proc/cpuinfo),\
Damjan Marion93242842017-11-13 20:09:21 +010026 $(shell grep -c ^processor /proc/cpuinfo), 2)
Ed Warnickecb9cada2015-12-08 15:45:58 -070027
Damjan Marion561f2732018-09-21 12:27:45 +020028B := $(BUILD_DIR)
29I := $(INSTALL_DIR)
Ed Warnickecb9cada2015-12-08 15:45:58 -070030
Thomas F Herbertdc66aad2019-03-29 15:41:48 -040031ifneq ($(shell which cmake3),)
32CMAKE?=cmake3
33else
34CMAKE?=cmake
35endif
36
PiotrX Kleski9235d432020-10-12 15:33:11 +020037ARCH_X86_64=$(filter x86_64,$(shell uname -m))
38
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 Marion2ce7f982017-01-09 20:24:50 +010045
Ed Warnickecb9cada2015-12-08 15:45:58 -070046.PHONY: clean
47clean:
48 @rm -rf $(B) $(I)
49
Benoît Gannefe750c22019-03-25 11:41:34 +010050.PHONY: install
Yulong Peif9a17482023-01-05 02:26:32 +000051install: $(if $(ARCH_X86_64), ipsec-mb-install) dpdk-install rdma-core-install quicly-install xdp-tools-install
Benoît Gannefe750c22019-03-25 11:41:34 +010052
53.PHONY: config
Damjan Marionaa659ef2022-04-05 19:26:51 +020054config: $(if $(ARCH_X86_64), ipsec-mb-config) dpdk-config rdma-core-config quicly-build
Benoît Gannefe750c22019-03-25 11:41:34 +010055
Damjan Marion2ce7f982017-01-09 20:24:50 +010056##############################################################################
57# .deb packaging
58##############################################################################
59
Damjan Marion4a6cb832018-09-18 18:41:38 +020060DEB_VER := $(PKG_VERSION)
Damjan Marion2ce7f982017-01-09 20:24:50 +010061DEB_ARCH=$(shell dpkg --print-architecture 2> /dev/null)
Damjan Marion4a6cb832018-09-18 18:41:38 +020062DEV_DEB=vpp-ext-deps_$(DEB_VER)-$(PKG_SUFFIX)_$(DEB_ARCH).deb
63INSTALLED_VER=$(shell dpkg-query --showformat='$${Version}' --show vpp-ext-deps 2> /dev/null)
Damjan Marion2ce7f982017-01-09 20:24:50 +010064
65.PHONY: build-deb install-deb check-deb
66
67deb/debian/changelog: Makefile
Damjan Marion4a6cb832018-09-18 18:41:38 +020068 @echo "vpp-ext-deps ($(DEB_VER)-$(PKG_SUFFIX)) unstable; urgency=low" > $@
Damjan Marion2ce7f982017-01-09 20:24:50 +010069 @echo "" >> $@
Damjan Marion4a6cb832018-09-18 18:41:38 +020070 @echo " * Version $(DEB_VER)" >> $@
Damjan Marion2ce7f982017-01-09 20:24:50 +010071 @echo "" >> $@
Andrew Yourtchenko5ca8bfc2023-10-18 21:18:32 +000072 @echo " -- VPP Dev <vpp-dev@lists.fd.io> $(shell date -R --date=@${SOURCE_DATE_EPOCH})" >> $@
Damjan Marion2ce7f982017-01-09 20:24:50 +010073
74$(DEV_DEB): deb/debian/changelog
75 @cd deb && dpkg-buildpackage -b -uc -us
Damjan Mariond93638e2019-03-29 21:22:09 +010076 git clean -fdx deb
Damjan Marion2ce7f982017-01-09 20:24:50 +010077
78build-deb: $(DEV_DEB)
79
80install-deb:
Damjan Marion4a6cb832018-09-18 18:41:38 +020081ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
Damjan Marion2ce7f982017-01-09 20:24:50 +010082 @make $(DEV_DEB)
83 @sudo dpkg -i $(DEV_DEB)
84else
85 @echo "=========================================================="
Damjan Marion4a6cb832018-09-18 18:41:38 +020086 @echo " Up-to-date vpp-ext-deps package already installed"
Damjan Marion2ce7f982017-01-09 20:24:50 +010087 @echo "=========================================================="
88endif
89
90check-deb:
Damjan Marion4a6cb832018-09-18 18:41:38 +020091ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
Damjan Marion2ce7f982017-01-09 20:24:50 +010092 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +010093 @echo " Out of date vpp-ext-deps package installed."
94 @echo " Installed: $(INSTALLED_VER)"
95 @echo " Needed: $(DEB_VER)-$(PKG_SUFFIX)"
Damjan Marion2ce7f982017-01-09 20:24:50 +010096 @echo ""
Damjan Marion4a6cb832018-09-18 18:41:38 +020097 @echo " Please upgrade by invoking 'make install-ext-deps'"
Damjan Marion2ce7f982017-01-09 20:24:50 +010098 @echo " from the top level directory."
99 @echo "=========================================================="
100endif
101
102##############################################################################
103# .rpm packaging
104##############################################################################
105
Damjan Marion4a6cb832018-09-18 18:41:38 +0200106RPM_VER := $(PKG_VERSION)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100107RPM_ARCH=$(shell rpm --eval "%{_arch}" 2> /dev/null)
Damjan Marion4a6cb832018-09-18 18:41:38 +0200108DEV_RPM=vpp-ext-deps-$(RPM_VER)-$(PKG_SUFFIX).$(RPM_ARCH).rpm
jiangxiaoming5ab7dc42020-12-30 15:25:15 +0800109INSTALLED_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 +0100110
111.PHONY: build-rpm install-rpm check-rpm
112
Damjan Marion4a6cb832018-09-18 18:41:38 +0200113$(DEV_RPM): Makefile rpm/vpp-ext-deps.spec
Damjan Marion2ce7f982017-01-09 20:24:50 +0100114 @rpmbuild -bb \
115 --define "_topdir $(CURDIR)/rpm" \
Damjan Marion4a6cb832018-09-18 18:41:38 +0200116 --define "_version $(RPM_VER)" \
Damjan Marion2ce7f982017-01-09 20:24:50 +0100117 --define "_release $(PKG_SUFFIX)" \
Damjan Marion4a6cb832018-09-18 18:41:38 +0200118 $(CURDIR)/rpm/vpp-ext-deps.spec
Damjan Marion2ce7f982017-01-09 20:24:50 +0100119 mv rpm/RPMS/$(RPM_ARCH)/*.rpm .
Damjan Mariond93638e2019-03-29 21:22:09 +0100120 @git clean -fdx rpm
Damjan Marion2ce7f982017-01-09 20:24:50 +0100121
122build-rpm: $(DEV_RPM)
123
124install-rpm:
Damjan Marion74447d42018-09-27 14:04:43 +0200125ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100126 @$(MAKE) $(DEV_RPM)
Dave Barachb2528482019-07-01 19:08:33 -0400127 sudo rpm -e vpp-ext-deps || true
Marco Varlesefe7740e2018-10-25 11:49:39 +0200128 sudo rpm -Uih --force $(DEV_RPM)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100129else
130 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +0100131 @echo " Up-to-date vpp-ext-deps package already installed"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100132 @echo "=========================================================="
133endif
134
135check-rpm:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200136ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
Damjan Marion2ce7f982017-01-09 20:24:50 +0100137 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +0100138 @echo " Out of date vpp-ext-deps package installed."
139 @echo " Installed: $(INSTALLED_RPM_VER)"
140 @echo " Needed: $(RPM_VER)-$(PKG_SUFFIX)"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100141 @echo ""
Damjan Marion4a6cb832018-09-18 18:41:38 +0200142 @echo " Please upgrade by invoking 'make install-ext-deps'"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100143 @echo " from the top level directory."
144 @echo "=========================================================="
145endif
146
147##############################################################################
148# ebuild support
149##############################################################################
150
151.PHONY: ebuild-build ebuild-install
152
153ebuild-build:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200154ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100155 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +0100156 @echo "Building vpp-ext-deps from source. Consider installing"
157 @echo "development package by invoking 'make install-ext-deps'"
158 @echo "from the top level directory"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100159 @echo "=========================================================="
160 make config
161else
Damjan Marion4a6cb832018-09-18 18:41:38 +0200162ifneq ($(INSTALLED_VER),)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100163 make check-deb
164endif
165ifneq ($(INSTALLED_RPM_VER),)
166 make check-rpm
167endif
168endif
169
170ebuild-install:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200171ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100172 make install
173endif