Add RDMA ibverb driver plugin
[vpp.git] / build / external / Makefile
1 # 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
15 SHELL := /bin/bash
16
17 DL_CACHE_DIR = $(HOME)/Downloads
18 MAKE ?= make
19 MAKE_ARGS ?= -j
20 BUILD_DIR        ?= $(CURDIR)/_build
21 INSTALL_DIR      ?= $(CURDIR)/_install
22 PKG_VERSION ?= $(shell git describe --abbrev=0 | cut -d- -f1 | cut -dv -f2)
23 PKG_SUFFIX ?= $(shell git log --oneline v$(PKG_VERSION)-rc0.. . | wc -l)
24 JOBS := $(if $(shell [ -f /proc/cpuinfo ] && head /proc/cpuinfo),\
25         $(shell grep -c ^processor /proc/cpuinfo), 2)
26
27 B := $(BUILD_DIR)
28 I := $(INSTALL_DIR)
29
30 include packages.mk
31 include packages/nasm.mk
32 include packages/ipsec-mb.mk
33 include packages/dpdk.mk
34 include packages/rdma-core.mk
35
36 .PHONY: clean
37 clean:
38         @rm -rf $(B) $(I)
39
40 .PHONY: install
41 install: dpdk-install rdma-core-install
42
43 .PHONY: config
44 config: dpdk-config rdma-core-config
45
46 ##############################################################################
47 # .deb packaging
48 ##############################################################################
49
50 DEB_VER := $(PKG_VERSION)
51 DEB_ARCH=$(shell dpkg --print-architecture 2> /dev/null)
52 DEV_DEB=vpp-ext-deps_$(DEB_VER)-$(PKG_SUFFIX)_$(DEB_ARCH).deb
53 INSTALLED_VER=$(shell dpkg-query --showformat='$${Version}' --show vpp-ext-deps 2> /dev/null)
54
55 .PHONY: build-deb install-deb check-deb
56
57 deb/debian/changelog: Makefile
58         @echo "vpp-ext-deps ($(DEB_VER)-$(PKG_SUFFIX)) unstable; urgency=low" > $@
59         @echo "" >> $@
60         @echo "  * Version $(DEB_VER)" >> $@
61         @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
66         git clean -fdx deb
67
68 build-deb: $(DEV_DEB)
69
70 install-deb:
71 ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
72         @make $(DEV_DEB)
73         @sudo dpkg -i $(DEV_DEB)
74 else
75         @echo "=========================================================="
76         @echo " Up-to-date vpp-ext-deps package already installed"
77         @echo "=========================================================="
78 endif
79
80 check-deb:
81 ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
82         @echo "=========================================================="
83         @echo " Out of date vpp-ext-deps package installed."
84         @echo " Installed: $(INSTALLED_VER)"
85         @echo " Needed: $(DEB_VER)-$(PKG_SUFFIX)"
86         @echo ""
87         @echo " Please upgrade by invoking 'make install-ext-deps'"
88         @echo " from the top level directory."
89         @echo "=========================================================="
90 endif
91
92 ##############################################################################
93 # .rpm packaging
94 ##############################################################################
95
96 RPM_VER := $(PKG_VERSION)
97 RPM_ARCH=$(shell rpm --eval "%{_arch}" 2> /dev/null)
98 DEV_RPM=vpp-ext-deps-$(RPM_VER)-$(PKG_SUFFIX).$(RPM_ARCH).rpm
99 INSTALLED_RPM_VER=$(shell rpm -q --queryformat '%{VERSION}-%{RELEASE}' vpp-ext-deps 2> /dev/null | grep -v "not inst")
100
101 .PHONY: build-rpm install-rpm check-rpm
102
103 $(DEV_RPM): Makefile rpm/vpp-ext-deps.spec
104         @rpmbuild -bb \
105           --define "_topdir $(CURDIR)/rpm" \
106           --define "_version $(RPM_VER)" \
107           --define "_release $(PKG_SUFFIX)" \
108           $(CURDIR)/rpm/vpp-ext-deps.spec
109         mv rpm/RPMS/$(RPM_ARCH)/*.rpm .
110         @git clean -fdx rpm
111
112 build-rpm: $(DEV_RPM)
113
114 install-rpm:
115 ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
116         @$(MAKE) $(DEV_RPM)
117         sudo rpm -Uih --force $(DEV_RPM)
118 else
119         @echo "=========================================================="
120         @echo " Up-to-date vpp-ext-deps package already installed"
121         @echo "=========================================================="
122 endif
123
124 check-rpm:
125 ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
126         @echo "=========================================================="
127         @echo " Out of date vpp-ext-deps package installed."
128         @echo " Installed: $(INSTALLED_RPM_VER)"
129         @echo " Needed: $(RPM_VER)-$(PKG_SUFFIX)"
130         @echo ""
131         @echo " Please upgrade by invoking 'make install-ext-deps'"
132         @echo " from the top level directory."
133         @echo "=========================================================="
134 endif
135
136 ##############################################################################
137 # ebuild support
138 ##############################################################################
139
140 .PHONY: ebuild-build ebuild-install
141
142 ebuild-build:
143 ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
144         @echo "=========================================================="
145         @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"
148         @echo "=========================================================="
149         make config
150 else
151 ifneq ($(INSTALLED_VER),)
152         make check-deb
153 endif
154 ifneq ($(INSTALLED_RPM_VER),)
155         make check-rpm
156 endif
157 endif
158
159 ebuild-install:
160 ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
161         make install
162 endif