build: mlx dpdk-rdma compatibility matrix
[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 --match 'v[0-9]*' | cut -d- -f1 | cut -dv -f2 | cut -d. -f1,2)
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 ifneq ($(shell which cmake3),)
31 CMAKE?=cmake3
32 else
33 CMAKE?=cmake
34 endif
35
36 ARCH_X86_64=$(filter x86_64,$(shell uname -m))
37
38 include packages.mk
39 include packages/ipsec-mb.mk
40 include packages/quicly.mk
41 include packages/rdma-core.mk
42 include packages/dpdk.mk
43 include packages/libbpf.mk
44
45 .PHONY: clean
46 clean:
47         @rm -rf $(B) $(I)
48
49 .PHONY: install
50 install: $(if $(ARCH_X86_64), ipsec-mb-install) dpdk-install rdma-core-install quicly-install libbpf-install
51
52 .PHONY: config
53 config: $(if $(ARCH_X86_64), ipsec-mb-config) dpdk-config rdma-core-config quicly-build
54
55 ##############################################################################
56 # .deb packaging
57 ##############################################################################
58
59 DEB_VER := $(PKG_VERSION)
60 DEB_ARCH=$(shell dpkg --print-architecture 2> /dev/null)
61 DEV_DEB=vpp-ext-deps_$(DEB_VER)-$(PKG_SUFFIX)_$(DEB_ARCH).deb
62 INSTALLED_VER=$(shell dpkg-query --showformat='$${Version}' --show vpp-ext-deps 2> /dev/null)
63
64 .PHONY: build-deb install-deb check-deb
65
66 deb/debian/changelog: Makefile
67         @echo "vpp-ext-deps ($(DEB_VER)-$(PKG_SUFFIX)) unstable; urgency=low" > $@
68         @echo "" >> $@
69         @echo "  * Version $(DEB_VER)" >> $@
70         @echo "" >> $@
71         @echo " -- VPP Dev <vpp-dev@lists.fd.io>  $(shell date -R)" >> $@
72
73 $(DEV_DEB): deb/debian/changelog
74         @cd deb && dpkg-buildpackage -b -uc -us
75         git clean -fdx deb
76
77 build-deb: $(DEV_DEB)
78
79 install-deb:
80 ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
81         @make $(DEV_DEB)
82         @sudo dpkg -i $(DEV_DEB)
83 else
84         @echo "=========================================================="
85         @echo " Up-to-date vpp-ext-deps package already installed"
86         @echo "=========================================================="
87 endif
88
89 check-deb:
90 ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
91         @echo "=========================================================="
92         @echo " Out of date vpp-ext-deps package installed."
93         @echo " Installed: $(INSTALLED_VER)"
94         @echo " Needed: $(DEB_VER)-$(PKG_SUFFIX)"
95         @echo ""
96         @echo " Please upgrade by invoking 'make install-ext-deps'"
97         @echo " from the top level directory."
98         @echo "=========================================================="
99 endif
100
101 ##############################################################################
102 # .rpm packaging
103 ##############################################################################
104
105 RPM_VER := $(PKG_VERSION)
106 RPM_ARCH=$(shell rpm --eval "%{_arch}" 2> /dev/null)
107 DEV_RPM=vpp-ext-deps-$(RPM_VER)-$(PKG_SUFFIX).$(RPM_ARCH).rpm
108 INSTALLED_RPM_VER=$(shell rpm -q --queryformat '%{VERSION}-%{RELEASE}' vpp-ext-deps 2> /dev/null | grep -v "vpp-ext-deps")
109
110 .PHONY: build-rpm install-rpm check-rpm
111
112 $(DEV_RPM): Makefile rpm/vpp-ext-deps.spec
113         @rpmbuild -bb \
114           --define "_topdir $(CURDIR)/rpm" \
115           --define "_version $(RPM_VER)" \
116           --define "_release $(PKG_SUFFIX)" \
117           $(CURDIR)/rpm/vpp-ext-deps.spec
118         mv rpm/RPMS/$(RPM_ARCH)/*.rpm .
119         @git clean -fdx rpm
120
121 build-rpm: $(DEV_RPM)
122
123 install-rpm:
124 ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
125         @$(MAKE) $(DEV_RPM)
126         sudo rpm -e vpp-ext-deps || true
127         sudo rpm -Uih --force $(DEV_RPM)
128 else
129         @echo "=========================================================="
130         @echo " Up-to-date vpp-ext-deps package already installed"
131         @echo "=========================================================="
132 endif
133
134 check-rpm:
135 ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
136         @echo "=========================================================="
137         @echo " Out of date vpp-ext-deps package installed."
138         @echo " Installed: $(INSTALLED_RPM_VER)"
139         @echo " Needed: $(RPM_VER)-$(PKG_SUFFIX)"
140         @echo ""
141         @echo " Please upgrade by invoking 'make install-ext-deps'"
142         @echo " from the top level directory."
143         @echo "=========================================================="
144 endif
145
146 ##############################################################################
147 # ebuild support
148 ##############################################################################
149
150 .PHONY: ebuild-build ebuild-install
151
152 ebuild-build:
153 ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
154         @echo "=========================================================="
155         @echo "Building vpp-ext-deps from source. Consider installing"
156         @echo "development package by invoking 'make install-ext-deps'"
157         @echo "from the top level directory"
158         @echo "=========================================================="
159         make config
160 else
161 ifneq ($(INSTALLED_VER),)
162         make check-deb
163 endif
164 ifneq ($(INSTALLED_RPM_VER),)
165         make check-rpm
166 endif
167 endif
168
169 ebuild-install:
170 ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
171         make install
172 endif