blob: a1352a69cbfeab91f7e60383146c809517c07298 [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
Damjan Marion2ce7f982017-01-09 20:24:50 +010034
Ed Warnickecb9cada2015-12-08 15:45:58 -070035.PHONY: clean
36clean:
37 @rm -rf $(B) $(I)
38
Damjan Marion2ce7f982017-01-09 20:24:50 +010039##############################################################################
40# .deb packaging
41##############################################################################
42
Damjan Marion4a6cb832018-09-18 18:41:38 +020043DEB_VER := $(PKG_VERSION)
Damjan Marion2ce7f982017-01-09 20:24:50 +010044DEB_ARCH=$(shell dpkg --print-architecture 2> /dev/null)
Damjan Marion4a6cb832018-09-18 18:41:38 +020045DEV_DEB=vpp-ext-deps_$(DEB_VER)-$(PKG_SUFFIX)_$(DEB_ARCH).deb
46INSTALLED_VER=$(shell dpkg-query --showformat='$${Version}' --show vpp-ext-deps 2> /dev/null)
Damjan Marion2ce7f982017-01-09 20:24:50 +010047
48.PHONY: build-deb install-deb check-deb
49
50deb/debian/changelog: Makefile
Damjan Marion4a6cb832018-09-18 18:41:38 +020051 @echo "vpp-ext-deps ($(DEB_VER)-$(PKG_SUFFIX)) unstable; urgency=low" > $@
Damjan Marion2ce7f982017-01-09 20:24:50 +010052 @echo "" >> $@
Damjan Marion4a6cb832018-09-18 18:41:38 +020053 @echo " * Version $(DEB_VER)" >> $@
Damjan Marion2ce7f982017-01-09 20:24:50 +010054 @echo "" >> $@
55 @echo " -- VPP Dev <vpp-dev@lists.fd.io> $(shell date -R)" >> $@
56
57$(DEV_DEB): deb/debian/changelog
58 @cd deb && dpkg-buildpackage -b -uc -us
59 git clean -fdx deb
60
61build-deb: $(DEV_DEB)
62
63install-deb:
Damjan Marion4a6cb832018-09-18 18:41:38 +020064ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
Ed Warnicke798150b2017-11-08 13:39:31 -070065 @echo "=========================================================="
Damjan Marion4a6cb832018-09-18 18:41:38 +020066 @echo " Out of date vpp-ext-deps package installed."
67 @echo " Installed: $(INSTALLED_VER)"
68 @echo " Needed: $(DEB_VER)-$(PKG_SUFFIX)"
Ed Warnicke798150b2017-11-08 13:39:31 -070069 @echo "=========================================================="
Damjan Marion2ce7f982017-01-09 20:24:50 +010070 @make $(DEV_DEB)
71 @sudo dpkg -i $(DEV_DEB)
72else
73 @echo "=========================================================="
Damjan Marion4a6cb832018-09-18 18:41:38 +020074 @echo " Up-to-date vpp-ext-deps package already installed"
Damjan Marion2ce7f982017-01-09 20:24:50 +010075 @echo "=========================================================="
76endif
77
78check-deb:
Damjan Marion4a6cb832018-09-18 18:41:38 +020079ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
Damjan Marion2ce7f982017-01-09 20:24:50 +010080 @echo "=========================================================="
81 @echo " Outdated DPDK package detected:"
Damjan Marion4a6cb832018-09-18 18:41:38 +020082 @echo " Installed: vpp-ext-deps $(INSTALLED_VER)"
83 @echo " Current: vpp-ext-deps $(DEB_VER)-$(PKG_SUFFIX)"
Damjan Marion2ce7f982017-01-09 20:24:50 +010084 @echo ""
Damjan Marion4a6cb832018-09-18 18:41:38 +020085 @echo " Please upgrade by invoking 'make install-ext-deps'"
Damjan Marion2ce7f982017-01-09 20:24:50 +010086 @echo " from the top level directory."
87 @echo "=========================================================="
88endif
89
90##############################################################################
91# .rpm packaging
92##############################################################################
93
Damjan Marion4a6cb832018-09-18 18:41:38 +020094RPM_VER := $(PKG_VERSION)
Damjan Marion2ce7f982017-01-09 20:24:50 +010095RPM_ARCH=$(shell rpm --eval "%{_arch}" 2> /dev/null)
Damjan Marion4a6cb832018-09-18 18:41:38 +020096DEV_RPM=vpp-ext-deps-$(RPM_VER)-$(PKG_SUFFIX).$(RPM_ARCH).rpm
97INSTALLED_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 +010098
99.PHONY: build-rpm install-rpm check-rpm
100
Damjan Marion4a6cb832018-09-18 18:41:38 +0200101$(DEV_RPM): Makefile rpm/vpp-ext-deps.spec
Damjan Marion2ce7f982017-01-09 20:24:50 +0100102 @rpmbuild -bb \
103 --define "_topdir $(CURDIR)/rpm" \
Damjan Marion4a6cb832018-09-18 18:41:38 +0200104 --define "_version $(RPM_VER)" \
Damjan Marion2ce7f982017-01-09 20:24:50 +0100105 --define "_release $(PKG_SUFFIX)" \
Damjan Marion4a6cb832018-09-18 18:41:38 +0200106 $(CURDIR)/rpm/vpp-ext-deps.spec
Damjan Marion2ce7f982017-01-09 20:24:50 +0100107 mv rpm/RPMS/$(RPM_ARCH)/*.rpm .
Damjan Marion561f2732018-09-21 12:27:45 +0200108 @git clean -fdx rpm
Damjan Marion2ce7f982017-01-09 20:24:50 +0100109
110build-rpm: $(DEV_RPM)
111
112install-rpm:
Damjan Marion74447d42018-09-27 14:04:43 +0200113ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100114 @$(MAKE) $(DEV_RPM)
Marco Varlesefe7740e2018-10-25 11:49:39 +0200115 sudo rpm -Uih --force $(DEV_RPM)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100116else
117 @echo "=========================================================="
118 @echo " Up-to-date DPDK package already installed"
119 @echo "=========================================================="
120endif
121
122check-rpm:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200123ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
Damjan Marion2ce7f982017-01-09 20:24:50 +0100124 @echo "=========================================================="
125 @echo " Outdated DPDK package detected:"
Damjan Marion4a6cb832018-09-18 18:41:38 +0200126 @echo " Installed: vpp-ext-deps $(INSTALLED_RPM_VER)"
127 @echo " Current: vpp-ext-deps $(RPM_VER)-$(PKG_SUFFIX)"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100128 @echo ""
Damjan Marion4a6cb832018-09-18 18:41:38 +0200129 @echo " Please upgrade by invoking 'make install-ext-deps'"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100130 @echo " from the top level directory."
131 @echo "=========================================================="
132endif
133
134##############################################################################
135# ebuild support
136##############################################################################
137
138.PHONY: ebuild-build ebuild-install
139
140ebuild-build:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200141ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100142 @echo "=========================================================="
143 @echo "Building DPDK from source. Consider installing development"
Damjan Marion4a6cb832018-09-18 18:41:38 +0200144 @echo "package by invoking 'make install-ext-deps' from the"
Damjan Marion2ce7f982017-01-09 20:24:50 +0100145 @echo "top level directory"
146 @echo "=========================================================="
147 make config
148else
Damjan Marion4a6cb832018-09-18 18:41:38 +0200149ifneq ($(INSTALLED_VER),)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100150 make check-deb
151endif
152ifneq ($(INSTALLED_RPM_VER),)
153 make check-rpm
154endif
155endif
156
157ebuild-install:
Damjan Marion4a6cb832018-09-18 18:41:38 +0200158ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100159 make install
160endif