blob: b0e3cee4faa51d2ff3bbfc6722b61bb8172a7ba3 [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
Andrew Yourtchenkoe36f44a2019-03-27 15:22:40 +010022PKG_VERSION ?= $(shell git describe --abbrev=0 | 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)
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
Damjan Marion561f2732018-09-21 12:27:45 +020036include packages.mk
37include packages/nasm.mk
38include packages/ipsec-mb.mk
Aloys Augustin7cae0032019-04-01 16:43:29 +020039include packages/quicly.mk
Damjan Marion561f2732018-09-21 12:27:45 +020040include packages/dpdk.mk
Benoît Gannefe750c22019-03-25 11:41:34 +010041include packages/rdma-core.mk
Benoît Ganne4a76d6f2020-06-12 08:47:34 +020042include packages/libbpf.mk
Damjan Marion2ce7f982017-01-09 20:24:50 +010043
Ed Warnickecb9cada2015-12-08 15:45:58 -070044.PHONY: clean
45clean:
46 @rm -rf $(B) $(I)
47
Benoît Gannefe750c22019-03-25 11:41:34 +010048.PHONY: install
Benoît Ganne4a76d6f2020-06-12 08:47:34 +020049install: dpdk-install rdma-core-install quicly-install libbpf-install
Benoît Gannefe750c22019-03-25 11:41:34 +010050
51.PHONY: config
52config: dpdk-config rdma-core-config
53
Damjan Marion2ce7f982017-01-09 20:24:50 +010054##############################################################################
55# .deb packaging
56##############################################################################
57
Damjan Marion4a6cb832018-09-18 18:41:38 +020058DEB_VER := $(PKG_VERSION)
Damjan Marion2ce7f982017-01-09 20:24:50 +010059DEB_ARCH=$(shell dpkg --print-architecture 2> /dev/null)
Damjan Marion4a6cb832018-09-18 18:41:38 +020060DEV_DEB=vpp-ext-deps_$(DEB_VER)-$(PKG_SUFFIX)_$(DEB_ARCH).deb
61INSTALLED_VER=$(shell dpkg-query --showformat='$${Version}' --show vpp-ext-deps 2> /dev/null)
Damjan Marion2ce7f982017-01-09 20:24:50 +010062
63.PHONY: build-deb install-deb check-deb
64
65deb/debian/changelog: Makefile
Damjan Marion4a6cb832018-09-18 18:41:38 +020066 @echo "vpp-ext-deps ($(DEB_VER)-$(PKG_SUFFIX)) unstable; urgency=low" > $@
Damjan Marion2ce7f982017-01-09 20:24:50 +010067 @echo "" >> $@
Damjan Marion4a6cb832018-09-18 18:41:38 +020068 @echo " * Version $(DEB_VER)" >> $@
Damjan Marion2ce7f982017-01-09 20:24:50 +010069 @echo "" >> $@
70 @echo " -- VPP Dev <vpp-dev@lists.fd.io> $(shell date -R)" >> $@
71
72$(DEV_DEB): deb/debian/changelog
73 @cd deb && dpkg-buildpackage -b -uc -us
Damjan Mariond93638e2019-03-29 21:22:09 +010074 git clean -fdx deb
Damjan Marion2ce7f982017-01-09 20:24:50 +010075
76build-deb: $(DEV_DEB)
77
78install-deb:
Damjan Marion4a6cb832018-09-18 18:41:38 +020079ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
Damjan Marion2ce7f982017-01-09 20:24:50 +010080 @make $(DEV_DEB)
81 @sudo dpkg -i $(DEV_DEB)
82else
83 @echo "=========================================================="
Damjan Marion4a6cb832018-09-18 18:41:38 +020084 @echo " Up-to-date vpp-ext-deps package already installed"
Damjan Marion2ce7f982017-01-09 20:24:50 +010085 @echo "=========================================================="
86endif
87
88check-deb:
Damjan Marion4a6cb832018-09-18 18:41:38 +020089ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
Damjan Marion2ce7f982017-01-09 20:24:50 +010090 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +010091 @echo " Out of date vpp-ext-deps package installed."
92 @echo " Installed: $(INSTALLED_VER)"
93 @echo " Needed: $(DEB_VER)-$(PKG_SUFFIX)"
Damjan Marion2ce7f982017-01-09 20:24:50 +010094 @echo ""
Damjan Marion4a6cb832018-09-18 18:41:38 +020095 @echo " Please upgrade by invoking 'make install-ext-deps'"
Damjan Marion2ce7f982017-01-09 20:24:50 +010096 @echo " from the top level directory."
97 @echo "=========================================================="
98endif
99
100##############################################################################
101# .rpm packaging
102##############################################################################
103
Damjan Marion4a6cb832018-09-18 18:41:38 +0200104RPM_VER := $(PKG_VERSION)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100105RPM_ARCH=$(shell rpm --eval "%{_arch}" 2> /dev/null)
Damjan Marion4a6cb832018-09-18 18:41:38 +0200106DEV_RPM=vpp-ext-deps-$(RPM_VER)-$(PKG_SUFFIX).$(RPM_ARCH).rpm
107INSTALLED_RPM_VER=$(shell rpm -q --queryformat '%{VERSION}-%{RELEASE}' vpp-ext-deps 2> /dev/null | grep -v "not inst")
Damjan Marion2ce7f982017-01-09 20:24:50 +0100108
109.PHONY: build-rpm install-rpm check-rpm
110
Damjan Marion4a6cb832018-09-18 18:41:38 +0200111$(DEV_RPM): Makefile rpm/vpp-ext-deps.spec
Damjan Marion2ce7f982017-01-09 20:24:50 +0100112 @rpmbuild -bb \
113 --define "_topdir $(CURDIR)/rpm" \
Damjan Marion4a6cb832018-09-18 18:41:38 +0200114 --define "_version $(RPM_VER)" \
Damjan Marion2ce7f982017-01-09 20:24:50 +0100115 --define "_release $(PKG_SUFFIX)" \
Damjan Marion4a6cb832018-09-18 18:41:38 +0200116 $(CURDIR)/rpm/vpp-ext-deps.spec
Damjan Marion2ce7f982017-01-09 20:24:50 +0100117 mv rpm/RPMS/$(RPM_ARCH)/*.rpm .
Damjan Mariond93638e2019-03-29 21:22:09 +0100118 @git clean -fdx rpm
Damjan Marion2ce7f982017-01-09 20:24:50 +0100119
120build-rpm: $(DEV_RPM)
121
122install-rpm:
Damjan Marion74447d42018-09-27 14:04:43 +0200123ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100124 @$(MAKE) $(DEV_RPM)
Dave Barachb2528482019-07-01 19:08:33 -0400125 sudo rpm -e vpp-ext-deps || true
Marco Varlesefe7740e2018-10-25 11:49:39 +0200126 sudo rpm -Uih --force $(DEV_RPM)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100127else
128 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +0100129 @echo " Up-to-date vpp-ext-deps package already installed"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100130 @echo "=========================================================="
131endif
132
133check-rpm:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200134ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
Damjan Marion2ce7f982017-01-09 20:24:50 +0100135 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +0100136 @echo " Out of date vpp-ext-deps package installed."
137 @echo " Installed: $(INSTALLED_RPM_VER)"
138 @echo " Needed: $(RPM_VER)-$(PKG_SUFFIX)"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100139 @echo ""
Damjan Marion4a6cb832018-09-18 18:41:38 +0200140 @echo " Please upgrade by invoking 'make install-ext-deps'"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100141 @echo " from the top level directory."
142 @echo "=========================================================="
143endif
144
145##############################################################################
146# ebuild support
147##############################################################################
148
149.PHONY: ebuild-build ebuild-install
150
151ebuild-build:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200152ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100153 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +0100154 @echo "Building vpp-ext-deps from source. Consider installing"
155 @echo "development package by invoking 'make install-ext-deps'"
156 @echo "from the top level directory"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100157 @echo "=========================================================="
158 make config
159else
Damjan Marion4a6cb832018-09-18 18:41:38 +0200160ifneq ($(INSTALLED_VER),)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100161 make check-deb
162endif
163ifneq ($(INSTALLED_RPM_VER),)
164 make check-rpm
165endif
166endif
167
168ebuild-install:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200169ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100170 make install
171endif