blob: e5dff3c43e5efd84553feac83eb715207700ae1a [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
Damjan Marion2ce7f982017-01-09 20:24:50 +010042
Ed Warnickecb9cada2015-12-08 15:45:58 -070043.PHONY: clean
44clean:
45 @rm -rf $(B) $(I)
46
Benoît Gannefe750c22019-03-25 11:41:34 +010047.PHONY: install
Aloys Augustin7cae0032019-04-01 16:43:29 +020048install: dpdk-install rdma-core-install quicly-install
Benoît Gannefe750c22019-03-25 11:41:34 +010049
50.PHONY: config
51config: dpdk-config rdma-core-config
52
Damjan Marion2ce7f982017-01-09 20:24:50 +010053##############################################################################
54# .deb packaging
55##############################################################################
56
Damjan Marion4a6cb832018-09-18 18:41:38 +020057DEB_VER := $(PKG_VERSION)
Damjan Marion2ce7f982017-01-09 20:24:50 +010058DEB_ARCH=$(shell dpkg --print-architecture 2> /dev/null)
Damjan Marion4a6cb832018-09-18 18:41:38 +020059DEV_DEB=vpp-ext-deps_$(DEB_VER)-$(PKG_SUFFIX)_$(DEB_ARCH).deb
60INSTALLED_VER=$(shell dpkg-query --showformat='$${Version}' --show vpp-ext-deps 2> /dev/null)
Damjan Marion2ce7f982017-01-09 20:24:50 +010061
62.PHONY: build-deb install-deb check-deb
63
64deb/debian/changelog: Makefile
Damjan Marion4a6cb832018-09-18 18:41:38 +020065 @echo "vpp-ext-deps ($(DEB_VER)-$(PKG_SUFFIX)) unstable; urgency=low" > $@
Damjan Marion2ce7f982017-01-09 20:24:50 +010066 @echo "" >> $@
Damjan Marion4a6cb832018-09-18 18:41:38 +020067 @echo " * Version $(DEB_VER)" >> $@
Damjan Marion2ce7f982017-01-09 20:24:50 +010068 @echo "" >> $@
69 @echo " -- VPP Dev <vpp-dev@lists.fd.io> $(shell date -R)" >> $@
70
71$(DEV_DEB): deb/debian/changelog
72 @cd deb && dpkg-buildpackage -b -uc -us
Damjan Mariond93638e2019-03-29 21:22:09 +010073 git clean -fdx deb
Damjan Marion2ce7f982017-01-09 20:24:50 +010074
75build-deb: $(DEV_DEB)
76
77install-deb:
Damjan Marion4a6cb832018-09-18 18:41:38 +020078ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
Damjan Marion2ce7f982017-01-09 20:24:50 +010079 @make $(DEV_DEB)
80 @sudo dpkg -i $(DEV_DEB)
81else
82 @echo "=========================================================="
Damjan Marion4a6cb832018-09-18 18:41:38 +020083 @echo " Up-to-date vpp-ext-deps package already installed"
Damjan Marion2ce7f982017-01-09 20:24:50 +010084 @echo "=========================================================="
85endif
86
87check-deb:
Damjan Marion4a6cb832018-09-18 18:41:38 +020088ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
Damjan Marion2ce7f982017-01-09 20:24:50 +010089 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +010090 @echo " Out of date vpp-ext-deps package installed."
91 @echo " Installed: $(INSTALLED_VER)"
92 @echo " Needed: $(DEB_VER)-$(PKG_SUFFIX)"
Damjan Marion2ce7f982017-01-09 20:24:50 +010093 @echo ""
Damjan Marion4a6cb832018-09-18 18:41:38 +020094 @echo " Please upgrade by invoking 'make install-ext-deps'"
Damjan Marion2ce7f982017-01-09 20:24:50 +010095 @echo " from the top level directory."
96 @echo "=========================================================="
97endif
98
99##############################################################################
100# .rpm packaging
101##############################################################################
102
Damjan Marion4a6cb832018-09-18 18:41:38 +0200103RPM_VER := $(PKG_VERSION)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100104RPM_ARCH=$(shell rpm --eval "%{_arch}" 2> /dev/null)
Damjan Marion4a6cb832018-09-18 18:41:38 +0200105DEV_RPM=vpp-ext-deps-$(RPM_VER)-$(PKG_SUFFIX).$(RPM_ARCH).rpm
106INSTALLED_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 +0100107
108.PHONY: build-rpm install-rpm check-rpm
109
Damjan Marion4a6cb832018-09-18 18:41:38 +0200110$(DEV_RPM): Makefile rpm/vpp-ext-deps.spec
Damjan Marion2ce7f982017-01-09 20:24:50 +0100111 @rpmbuild -bb \
112 --define "_topdir $(CURDIR)/rpm" \
Damjan Marion4a6cb832018-09-18 18:41:38 +0200113 --define "_version $(RPM_VER)" \
Damjan Marion2ce7f982017-01-09 20:24:50 +0100114 --define "_release $(PKG_SUFFIX)" \
Damjan Marion4a6cb832018-09-18 18:41:38 +0200115 $(CURDIR)/rpm/vpp-ext-deps.spec
Damjan Marion2ce7f982017-01-09 20:24:50 +0100116 mv rpm/RPMS/$(RPM_ARCH)/*.rpm .
Damjan Mariond93638e2019-03-29 21:22:09 +0100117 @git clean -fdx rpm
Damjan Marion2ce7f982017-01-09 20:24:50 +0100118
119build-rpm: $(DEV_RPM)
120
121install-rpm:
Damjan Marion74447d42018-09-27 14:04:43 +0200122ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100123 @$(MAKE) $(DEV_RPM)
Dave Barachb2528482019-07-01 19:08:33 -0400124 sudo rpm -e vpp-ext-deps || true
Marco Varlesefe7740e2018-10-25 11:49:39 +0200125 sudo rpm -Uih --force $(DEV_RPM)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100126else
127 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +0100128 @echo " Up-to-date vpp-ext-deps package already installed"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100129 @echo "=========================================================="
130endif
131
132check-rpm:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200133ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
Damjan Marion2ce7f982017-01-09 20:24:50 +0100134 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +0100135 @echo " Out of date vpp-ext-deps package installed."
136 @echo " Installed: $(INSTALLED_RPM_VER)"
137 @echo " Needed: $(RPM_VER)-$(PKG_SUFFIX)"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100138 @echo ""
Damjan Marion4a6cb832018-09-18 18:41:38 +0200139 @echo " Please upgrade by invoking 'make install-ext-deps'"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100140 @echo " from the top level directory."
141 @echo "=========================================================="
142endif
143
144##############################################################################
145# ebuild support
146##############################################################################
147
148.PHONY: ebuild-build ebuild-install
149
150ebuild-build:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200151ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100152 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +0100153 @echo "Building vpp-ext-deps from source. Consider installing"
154 @echo "development package by invoking 'make install-ext-deps'"
155 @echo "from the top level directory"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100156 @echo "=========================================================="
157 make config
158else
Damjan Marion4a6cb832018-09-18 18:41:38 +0200159ifneq ($(INSTALLED_VER),)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100160 make check-deb
161endif
162ifneq ($(INSTALLED_RPM_VER),)
163 make check-rpm
164endif
165endif
166
167ebuild-install:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200168ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100169 make install
170endif