blob: 084d694e88c786269f3ba934eb7628914e8d3bfa [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
Damjan Marion561f2732018-09-21 12:27:45 +020030include packages.mk
31include packages/nasm.mk
32include packages/ipsec-mb.mk
33include packages/dpdk.mk
Benoît Gannefe750c22019-03-25 11:41:34 +010034include packages/rdma-core.mk
Damjan Marion2ce7f982017-01-09 20:24:50 +010035
Ed Warnickecb9cada2015-12-08 15:45:58 -070036.PHONY: clean
37clean:
38 @rm -rf $(B) $(I)
39
Benoît Gannefe750c22019-03-25 11:41:34 +010040.PHONY: install
Damjan Mariond93638e2019-03-29 21:22:09 +010041install: dpdk-install rdma-core-install
Benoît Gannefe750c22019-03-25 11:41:34 +010042
43.PHONY: config
44config: dpdk-config rdma-core-config
45
Damjan Marion2ce7f982017-01-09 20:24:50 +010046##############################################################################
47# .deb packaging
48##############################################################################
49
Damjan Marion4a6cb832018-09-18 18:41:38 +020050DEB_VER := $(PKG_VERSION)
Damjan Marion2ce7f982017-01-09 20:24:50 +010051DEB_ARCH=$(shell dpkg --print-architecture 2> /dev/null)
Damjan Marion4a6cb832018-09-18 18:41:38 +020052DEV_DEB=vpp-ext-deps_$(DEB_VER)-$(PKG_SUFFIX)_$(DEB_ARCH).deb
53INSTALLED_VER=$(shell dpkg-query --showformat='$${Version}' --show vpp-ext-deps 2> /dev/null)
Damjan Marion2ce7f982017-01-09 20:24:50 +010054
55.PHONY: build-deb install-deb check-deb
56
57deb/debian/changelog: Makefile
Damjan Marion4a6cb832018-09-18 18:41:38 +020058 @echo "vpp-ext-deps ($(DEB_VER)-$(PKG_SUFFIX)) unstable; urgency=low" > $@
Damjan Marion2ce7f982017-01-09 20:24:50 +010059 @echo "" >> $@
Damjan Marion4a6cb832018-09-18 18:41:38 +020060 @echo " * Version $(DEB_VER)" >> $@
Damjan Marion2ce7f982017-01-09 20:24:50 +010061 @echo "" >> $@
62 @echo " -- VPP Dev <vpp-dev@lists.fd.io> $(shell date -R)" >> $@
63
64$(DEV_DEB): deb/debian/changelog
65 @cd deb && dpkg-buildpackage -b -uc -us
Damjan Mariond93638e2019-03-29 21:22:09 +010066 git clean -fdx deb
Damjan Marion2ce7f982017-01-09 20:24:50 +010067
68build-deb: $(DEV_DEB)
69
70install-deb:
Damjan Marion4a6cb832018-09-18 18:41:38 +020071ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
Damjan Marion2ce7f982017-01-09 20:24:50 +010072 @make $(DEV_DEB)
73 @sudo dpkg -i $(DEV_DEB)
74else
75 @echo "=========================================================="
Damjan Marion4a6cb832018-09-18 18:41:38 +020076 @echo " Up-to-date vpp-ext-deps package already installed"
Damjan Marion2ce7f982017-01-09 20:24:50 +010077 @echo "=========================================================="
78endif
79
80check-deb:
Damjan Marion4a6cb832018-09-18 18:41:38 +020081ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
Damjan Marion2ce7f982017-01-09 20:24:50 +010082 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +010083 @echo " Out of date vpp-ext-deps package installed."
84 @echo " Installed: $(INSTALLED_VER)"
85 @echo " Needed: $(DEB_VER)-$(PKG_SUFFIX)"
Damjan Marion2ce7f982017-01-09 20:24:50 +010086 @echo ""
Damjan Marion4a6cb832018-09-18 18:41:38 +020087 @echo " Please upgrade by invoking 'make install-ext-deps'"
Damjan Marion2ce7f982017-01-09 20:24:50 +010088 @echo " from the top level directory."
89 @echo "=========================================================="
90endif
91
92##############################################################################
93# .rpm packaging
94##############################################################################
95
Damjan Marion4a6cb832018-09-18 18:41:38 +020096RPM_VER := $(PKG_VERSION)
Damjan Marion2ce7f982017-01-09 20:24:50 +010097RPM_ARCH=$(shell rpm --eval "%{_arch}" 2> /dev/null)
Damjan Marion4a6cb832018-09-18 18:41:38 +020098DEV_RPM=vpp-ext-deps-$(RPM_VER)-$(PKG_SUFFIX).$(RPM_ARCH).rpm
99INSTALLED_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 +0100100
101.PHONY: build-rpm install-rpm check-rpm
102
Damjan Marion4a6cb832018-09-18 18:41:38 +0200103$(DEV_RPM): Makefile rpm/vpp-ext-deps.spec
Damjan Marion2ce7f982017-01-09 20:24:50 +0100104 @rpmbuild -bb \
105 --define "_topdir $(CURDIR)/rpm" \
Damjan Marion4a6cb832018-09-18 18:41:38 +0200106 --define "_version $(RPM_VER)" \
Damjan Marion2ce7f982017-01-09 20:24:50 +0100107 --define "_release $(PKG_SUFFIX)" \
Damjan Marion4a6cb832018-09-18 18:41:38 +0200108 $(CURDIR)/rpm/vpp-ext-deps.spec
Damjan Marion2ce7f982017-01-09 20:24:50 +0100109 mv rpm/RPMS/$(RPM_ARCH)/*.rpm .
Damjan Mariond93638e2019-03-29 21:22:09 +0100110 @git clean -fdx rpm
Damjan Marion2ce7f982017-01-09 20:24:50 +0100111
112build-rpm: $(DEV_RPM)
113
114install-rpm:
Damjan Marion74447d42018-09-27 14:04:43 +0200115ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100116 @$(MAKE) $(DEV_RPM)
Marco Varlesefe7740e2018-10-25 11:49:39 +0200117 sudo rpm -Uih --force $(DEV_RPM)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100118else
119 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +0100120 @echo " Up-to-date vpp-ext-deps package already installed"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100121 @echo "=========================================================="
122endif
123
124check-rpm:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200125ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
Damjan Marion2ce7f982017-01-09 20:24:50 +0100126 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +0100127 @echo " Out of date vpp-ext-deps package installed."
128 @echo " Installed: $(INSTALLED_RPM_VER)"
129 @echo " Needed: $(RPM_VER)-$(PKG_SUFFIX)"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100130 @echo ""
Damjan Marion4a6cb832018-09-18 18:41:38 +0200131 @echo " Please upgrade by invoking 'make install-ext-deps'"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100132 @echo " from the top level directory."
133 @echo "=========================================================="
134endif
135
136##############################################################################
137# ebuild support
138##############################################################################
139
140.PHONY: ebuild-build ebuild-install
141
142ebuild-build:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200143ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100144 @echo "=========================================================="
Benoît Gannefe750c22019-03-25 11:41:34 +0100145 @echo "Building vpp-ext-deps from source. Consider installing"
146 @echo "development package by invoking 'make install-ext-deps'"
147 @echo "from the top level directory"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100148 @echo "=========================================================="
149 make config
150else
Damjan Marion4a6cb832018-09-18 18:41:38 +0200151ifneq ($(INSTALLED_VER),)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100152 make check-deb
153endif
154ifneq ($(INSTALLED_RPM_VER),)
155 make check-rpm
156endif
157endif
158
159ebuild-install:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200160ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100161 make install
162endif