blob: c56e16d1f51e9f13b574be5beee6c6fdd2a3549b [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
Damjan Marion4a6cb832018-09-18 18:41:38 +020022PKG_VERSION ?= $(shell git describe --abbrev=0 | cut -d- -f1 | cut -dv -f2)
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)
Marco Varlesefe7740e2018-10-25 11:49:39 +0200124 sudo rpm -Uih --force $(DEV_RPM)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100125else
126 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +0100127 @echo " Up-to-date vpp-ext-deps package already installed"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100128 @echo "=========================================================="
129endif
130
131check-rpm:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200132ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
Damjan Marion2ce7f982017-01-09 20:24:50 +0100133 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +0100134 @echo " Out of date vpp-ext-deps package installed."
135 @echo " Installed: $(INSTALLED_RPM_VER)"
136 @echo " Needed: $(RPM_VER)-$(PKG_SUFFIX)"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100137 @echo ""
Damjan Marion4a6cb832018-09-18 18:41:38 +0200138 @echo " Please upgrade by invoking 'make install-ext-deps'"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100139 @echo " from the top level directory."
140 @echo "=========================================================="
141endif
142
143##############################################################################
144# ebuild support
145##############################################################################
146
147.PHONY: ebuild-build ebuild-install
148
149ebuild-build:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200150ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100151 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +0100152 @echo "Building vpp-ext-deps from source. Consider installing"
153 @echo "development package by invoking 'make install-ext-deps'"
154 @echo "from the top level directory"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100155 @echo "=========================================================="
156 make config
157else
Damjan Marion4a6cb832018-09-18 18:41:38 +0200158ifneq ($(INSTALLED_VER),)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100159 make check-deb
160endif
161ifneq ($(INSTALLED_RPM_VER),)
162 make check-rpm
163endif
164endif
165
166ebuild-install:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200167ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100168 make install
169endif