blob: 053fe76520513907e3ca7143d42a3ee8973d8799 [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
17DPDK_BUILD_DIR ?= $(CURDIR)/_build
18DPDK_INSTALL_DIR ?= $(CURDIR)/_install
Damjan Marion19010202016-03-24 17:17:47 +010019DPDK_PKTMBUF_HEADROOM ?= 128
Damjan Marion3473e492018-02-24 19:21:14 +010020DPDK_CACHE_LINE_SIZE ?= 64
Ed Warnickecb9cada2015-12-08 15:45:58 -070021DPDK_DOWNLOAD_DIR ?= $(HOME)/Downloads
Ed Warnickecb9cada2015-12-08 15:45:58 -070022DPDK_DEBUG ?= n
Damjan Marion6a5be212017-05-11 14:55:43 +020023DPDK_MLX4_PMD ?= n
Damjan Marion696f1ad2016-12-23 22:42:41 +010024DPDK_MLX5_PMD ?= n
Rui Cai60bd3022018-05-11 21:52:22 +000025DPDK_TAP_PMD ?= n
26DPDK_FAILSAFE_PMD ?= n
Ed Warnickecb9cada2015-12-08 15:45:58 -070027
28B := $(DPDK_BUILD_DIR)
29I := $(DPDK_INSTALL_DIR)
Damjan Marionb0e08942018-06-07 12:01:51 +020030DPDK_VERSION ?= 18.05
Matthew Smith7b13e0d2018-07-06 17:00:00 -050031PKG_SUFFIX ?= vpp2
Damjan Marionde3ff7a2017-11-29 12:28:38 +010032DPDK_BASE_URL ?= http://fast.dpdk.org/rel
Thomas Monjalon96e10b52016-06-02 14:52:32 +020033DPDK_TARBALL := dpdk-$(DPDK_VERSION).tar.xz
Damjan Mariondab123b2016-03-29 16:43:58 +020034DPDK_TAR_URL := $(DPDK_BASE_URL)/$(DPDK_TARBALL)
Damjan Marion0e969ac2018-06-06 14:23:42 +020035DPDK_18.05_TARBALL_MD5_CKSUM := 9fc86367cd9407ff6a8dfea56c4eddc4
Damjan Marion3bf6c2b2018-08-12 00:26:45 +020036DPDK_18.08_TARBALL_MD5_CKSUM := da5e7fb25ab063c47e53929fb8c58be5
Damjan Marion5f22f4d2017-08-21 22:19:04 +020037MACHINE=$(shell uname -m)
Radu Nicolau2e3677b2017-02-20 12:27:02 +000038
Damjan Marion0e969ac2018-06-06 14:23:42 +020039# replace dot with space, and if 3rd word exists we deal with stable dpdk rel
40ifeq ($(word 3,$(subst ., ,$(DPDK_VERSION))),)
41DPDK_SOURCE := $(B)/dpdk-$(DPDK_VERSION)
42else
43DPDK_SOURCE := $(B)/dpdk-stable-$(DPDK_VERSION)
44endif
45
Sergio Gonzalez Monroy6184db32017-10-27 08:58:38 +010046NASM_BASE_URL := http://www.nasm.us/pub/nasm/releasebuilds
47NASM_VER := 2.13.01
48NASM_TARBALL := nasm-$(NASM_VER).tar.xz
49NASM_TAR_URL := $(NASM_BASE_URL)/$(NASM_VER)/$(NASM_TARBALL)
50NASM_SOURCE := $(B)/nasm-$(NASM_VER)
51
Damjan Marion0e969ac2018-06-06 14:23:42 +020052ifneq (,$(findstring 18.02,$(DPDK_VERSION)))
Damjan Marion07510dd2018-02-15 11:59:04 +010053IPSEC_MB_VER ?= 0.48
Damjan Marion0e969ac2018-06-06 14:23:42 +020054else
55IPSEC_MB_VER ?= 0.49
Damjan Marion45b48502017-11-17 09:46:41 +010056endif
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +010057
Marco Varlese8ddd5182017-08-14 16:07:00 +020058ifeq ($(MACHINE),$(filter $(MACHINE),x86_64))
Thomas F Herbert4b0ac822017-08-29 16:07:51 -040059 AESNI ?= y
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +010060$(info Building IPSec-MB $(IPSEC_MB_VER) library)
Thomas F Herbert4b0ac822017-08-29 16:07:51 -040061else
62 AESNI ?= N
Marco Varlese8ddd5182017-08-14 16:07:00 +020063endif
64
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +010065AESNIMB_LIB_TARBALL := v$(IPSEC_MB_VER).tar.gz
Radu Nicolau6ca42d32017-02-16 13:54:42 +000066AESNIMB_LIB_TARBALL_URL := http://github.com/01org/intel-ipsec-mb/archive/$(AESNIMB_LIB_TARBALL)
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +010067AESNIMB_LIB_SOURCE := $(B)/intel-ipsec-mb-$(IPSEC_MB_VER)
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +010068
Damjan Marione39a7b82016-04-26 14:54:57 +020069ifneq (,$(findstring clang,$(CC)))
70DPDK_CC=clang
Damjan Marion78edb8e2017-02-06 22:28:52 +010071else ifneq (,$(findstring icc,$(CC)))
72DPDK_CC=icc
Damjan Marione39a7b82016-04-26 14:54:57 +020073else
74DPDK_CC=gcc
75endif
76
Damjan Marion78edb8e2017-02-06 22:28:52 +010077##############################################################################
Damjan Marion1664f9b2017-04-24 20:48:53 +020078# Intel x86
Damjan Marion78edb8e2017-02-06 22:28:52 +010079##############################################################################
Damjan Marion1664f9b2017-04-24 20:48:53 +020080ifeq ($(MACHINE),$(filter $(MACHINE),x86_64 i686))
81DPDK_TARGET ?= $(MACHINE)-native-linuxapp-$(DPDK_CC)
Damjan Marion78edb8e2017-02-06 22:28:52 +010082DPDK_MACHINE ?= nhm
83DPDK_TUNE ?= core-avx2
Brian Brooksa7191842017-09-06 13:19:48 -050084
85##############################################################################
86# ARM64
87##############################################################################
Brian Brooks97465522017-08-28 13:05:26 -050088else ifeq ($(MACHINE),aarch64)
Bin Huang096e6be2018-05-24 16:43:19 +080089CROSS :=
90export CROSS
Brian Brooks97465522017-08-28 13:05:26 -050091DPDK_TARGET ?= arm64-armv8a-linuxapp-$(DPDK_CC)
92DPDK_MACHINE ?= armv8a
93DPDK_TUNE ?= generic
Brian Brooksa7191842017-09-06 13:19:48 -050094
95CPU_IMP_ARM = 0x41
96CPU_IMP_CAVIUM = 0x43
97
98CPU_PART_ARM_CORTEX_A53 = 0xd03
99CPU_PART_ARM_CORTEX_A57 = 0xd07
100CPU_PART_ARM_CORTEX_A72 = 0xd08
101CPU_PART_ARM_CORTEX_A73 = 0xd09
102
103CPU_PART_CAVIUM_THUNDERX = 0x0a1
104CPU_PART_CAVIUM_THUNDERX_81XX = 0x0a2
105CPU_PART_CAVIUM_THUNDERX_83XX = 0x0a3
106
107MIDR_IMPLEMENTER=$(shell awk '/implementer/ {print $$4;exit}' /proc/cpuinfo)
108MIDR_PARTNUM=$(shell awk '/part/ {print $$4;exit}' /proc/cpuinfo)
109
110ifeq ($(MIDR_IMPLEMENTER),$(CPU_IMP_ARM))
111##############################################################################
112# Arm Cortex
113##############################################################################
114CPU_PART_ARM_TUNE := $(CPU_PART_ARM_CORTEX_A53)/cortex-a53 \
115 $(CPU_PART_ARM_CORTEX_A57)/cortex-a57 \
116 $(CPU_PART_ARM_CORTEX_A72)/cortex-a72 \
117 $(CPU_PART_ARM_CORTEX_A73)/cortex-a73
118CPU_TUNE = $(notdir $(filter $(MIDR_PARTNUM)/%,$(CPU_PART_ARM_TUNE)))
119ifneq ($(CPU_TUNE),)
120DPDK_TUNE = $(CPU_TUNE)
121else
122$(warning Unknown Arm CPU)
123endif
124
125else ifeq ($(MIDR_IMPLEMENTER),$(CPU_IMP_CAVIUM))
126##############################################################################
127# Cavium ThunderX
128##############################################################################
129ifneq (,$(findstring $(MIDR_PARTNUM),$(CPU_PART_CAVIUM_THUNDERX) \
130 $(CPU_PART_CAVIUM_THUNDERX_81XX) $(CPU_PART_CAVIUM_THUNDERX_83XX)))
131DPDK_TARGET = arm64-thunderx-linuxapp-$(DPDK_CC)
132DPDK_MACHINE = thunderx
Dave Barach473f4612018-05-29 17:06:45 -0400133DPDK_CACHE_LINE_SIZE := 128
Brian Brooksa7191842017-09-06 13:19:48 -0500134else
135$(warning Unknown Cavium CPU)
136endif
Brian Brooks97465522017-08-28 13:05:26 -0500137endif
Damjan Marion78edb8e2017-02-06 22:28:52 +0100138
139##############################################################################
Brian Brooksa7191842017-09-06 13:19:48 -0500140# Unknown platform
Damjan Marion78edb8e2017-02-06 22:28:52 +0100141##############################################################################
142else
Brian Brooksa7191842017-09-06 13:19:48 -0500143$(error Unknown platform)
Christophe Fontaine737547e2016-05-11 08:40:33 +0000144endif
145
Chris Lukeb2861e82017-06-14 11:24:41 -0400146# /proc/cpuinfo does not exist on platforms without a /proc and on some
147# platforms, notably inside containers, it has no content. In those cases
148# we assume there's 1 processor; we use 2*ncpu for the -j option.
149# NB: GNU Make 4.2 will let us use '$(file </proc/cpuinfo)' to both test
150# for file presence and content; for now this will have to do.
151JOBS := $(if $(shell [ -f /proc/cpuinfo ] && head /proc/cpuinfo),\
Damjan Marion93242842017-11-13 20:09:21 +0100152 $(shell grep -c ^processor /proc/cpuinfo), 2)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700153
154# compiler/linker custom arguments
Sirshak Das6495c4b2018-05-29 21:06:28 -0500155ifeq ($(DPDK_CC),clang)
156DPDK_CPU_CFLAGS := -fPIE -fPIC
157else
Ed Warnickecb9cada2015-12-08 15:45:58 -0700158DPDK_CPU_CFLAGS := -pie -fPIC
Sirshak Das6495c4b2018-05-29 21:06:28 -0500159endif
Ed Warnickecb9cada2015-12-08 15:45:58 -0700160
161ifeq ($(DPDK_DEBUG),n)
Damjan Marion1c80e832016-05-11 23:07:18 +0200162DPDK_EXTRA_CFLAGS := -g -mtune=$(DPDK_TUNE)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700163else
Damjan Marione39a7b82016-04-26 14:54:57 +0200164DPDK_EXTRA_CFLAGS := -g -O0
Ed Warnickecb9cada2015-12-08 15:45:58 -0700165endif
166
Damjan Marion0e969ac2018-06-06 14:23:42 +0200167ifeq ($(AESNI),y)
168IPSEC_MB_BUILD_PATH := $(B)/intel-ipsec-mb-$(IPSEC_MB_VER)
169DPDK_EXTRA_CFLAGS += -L$(IPSEC_MB_BUILD_PATH) -I$(IPSEC_MB_BUILD_PATH)
170endif
171
Radu Nicolau2e3677b2017-02-20 12:27:02 +0000172DPDK_MAKE_EXTRA_ARGS += AESNI_MULTI_BUFFER_LIB_PATH=$(AESNIMB_LIB_SOURCE)
Radu Nicolau2e3677b2017-02-20 12:27:02 +0000173
Ed Warnickecb9cada2015-12-08 15:45:58 -0700174# assemble DPDK make arguments
175DPDK_MAKE_ARGS := -C $(DPDK_SOURCE) -j $(JOBS) \
176 T=$(DPDK_TARGET) \
177 RTE_CONFIG_TEMPLATE=../custom-config \
Ed Warnickecb9cada2015-12-08 15:45:58 -0700178 EXTRA_CFLAGS="$(DPDK_EXTRA_CFLAGS)" \
179 EXTRA_LDFLAGS="$(DPDK_EXTRA_LDFLAGS)" \
180 CPU_CFLAGS="$(DPDK_CPU_CFLAGS)" \
Damjan Marion2ce7f982017-01-09 20:24:50 +0100181 DESTDIR=$(I) \
Christophe Fontaine737547e2016-05-11 08:40:33 +0000182 $(DPDK_MAKE_EXTRA_ARGS)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700183
Ed Warnickecb9cada2015-12-08 15:45:58 -0700184define set
185@if grep -q CONFIG_$1 $@ ; \
186 then sed -i -e 's/.*\(CONFIG_$1=\).*/\1$2/' $@ ; \
187 else echo CONFIG_$1=$2 >> $@ ; \
188fi
189endef
190
191all: build
192
193$(B)/custom-config: $(B)/.patch.ok Makefile
Damjan Marion106f0ed2016-04-26 10:44:28 +0200194 @echo --- generating custom config from $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) ---
195 @cpp -undef -ffreestanding -x assembler-with-cpp $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) $@
Ed Warnickecb9cada2015-12-08 15:45:58 -0700196 $(call set,RTE_MACHINE,$(DPDK_MACHINE))
Ed Warnickecb9cada2015-12-08 15:45:58 -0700197 @# modify options
Damjan Marion13f07182016-02-05 06:44:54 -0800198 $(call set,RTE_MAX_LCORE,256)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700199 $(call set,RTE_PKTMBUF_HEADROOM,$(DPDK_PKTMBUF_HEADROOM))
Damjan Marion3473e492018-02-24 19:21:14 +0100200 $(call set,RTE_CACHE_LINE_SIZE,$(DPDK_CACHE_LINE_SIZE))
Ed Warnickecb9cada2015-12-08 15:45:58 -0700201 $(call set,RTE_LIBEAL_USE_HPET,y)
202 $(call set,RTE_BUILD_COMBINE_LIBS,y)
Damjan Mariona1556802016-06-26 20:12:40 +0200203 $(call set,RTE_PCI_CONFIG,y)
204 $(call set,RTE_PCI_EXTENDED_TAG,"on")
205 $(call set,RTE_PCI_MAX_READ_REQUEST_SIZE,4096)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700206 @# enable debug init for device drivers
207 $(call set,RTE_LIBRTE_I40E_DEBUG_INIT,$(DPDK_DEBUG))
208 $(call set,RTE_LIBRTE_IXGBE_DEBUG_INIT,$(DPDK_DEBUG))
209 $(call set,RTE_LIBRTE_E1000_DEBUG_INIT,$(DPDK_DEBUG))
210 $(call set,RTE_LIBRTE_VIRTIO_DEBUG_INIT,$(DPDK_DEBUG))
211 $(call set,RTE_LIBRTE_VMXNET3_DEBUG_INIT,$(DPDK_DEBUG))
John Lod9bf9ab2016-02-25 11:17:55 -0500212 $(call set,RTE_LIBRTE_PMD_BOND,y)
213 $(call set,RTE_LIBRTE_IP_FRAG,y)
Sergio Gonzalez Monroyd04b60b2017-01-20 15:35:23 +0000214 $(call set,RTE_LIBRTE_PMD_QAT,y)
Sergio Gonzalez Monroy618f7b02017-07-19 16:22:28 +0100215 $(call set,RTE_LIBRTE_PMD_AESNI_MB,$(AESNI))
216 $(call set,RTE_LIBRTE_PMD_AESNI_GCM,$(AESNI))
Damjan Marion6a5be212017-05-11 14:55:43 +0200217 $(call set,RTE_LIBRTE_MLX4_PMD,$(DPDK_MLX4_PMD))
Damjan Marion696f1ad2016-12-23 22:42:41 +0100218 $(call set,RTE_LIBRTE_MLX5_PMD,$(DPDK_MLX5_PMD))
Damjan Marion3bf6c2b2018-08-12 00:26:45 +0200219 $(call set,RTE_LIBRTE_PMD_SOFTNIC,n)
Amir Zeidner0e7fe4f2018-03-05 14:32:22 +0200220 $(call set,RTE_LIBRTE_MLX4_DLOPEN_DEPS,$(DPDK_MLX4_PMD))
221 $(call set,RTE_LIBRTE_MLX5_DLOPEN_DEPS,$(DPDK_MLX5_PMD))
Rui Cai60bd3022018-05-11 21:52:22 +0000222 $(call set,RTE_LIBRTE_PMD_TAP,$(DPDK_TAP_PMD))
223 $(call set,RTE_LIBRTE_PMD_FAILSAFE,$(DPDK_FAILSAFE_PMD))
Ed Warnickecb9cada2015-12-08 15:45:58 -0700224 @# not needed
Ed Warnickecb9cada2015-12-08 15:45:58 -0700225 $(call set,RTE_LIBRTE_CFGFILE,n)
226 $(call set,RTE_LIBRTE_LPM,n)
227 $(call set,RTE_LIBRTE_ACL,n)
228 $(call set,RTE_LIBRTE_POWER,n)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700229 $(call set,RTE_LIBRTE_DISTRIBUTOR,n)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700230 $(call set,RTE_LIBRTE_PORT,n)
231 $(call set,RTE_LIBRTE_TABLE,n)
232 $(call set,RTE_LIBRTE_PIPELINE,n)
Damjan Marion45b48502017-11-17 09:46:41 +0100233 $(call set,RTE_LIBRTE_FLOW_CLASSIFY,n)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700234 $(call set,RTE_KNI_KMOD,n)
Damjan Marion68fda1c2017-01-01 16:53:22 +0100235 $(call set,RTE_EAL_IGB_UIO,n)
Marco Varlese1355fcd2018-02-22 16:03:35 +0100236 @# currently broken in 18.02
237 $(call set,RTE_LIBRTE_DPAA_BUS,n)
238 $(call set,RTE_LIBRTE_DPAA_MEMPOOL,n)
239 $(call set,RTE_LIBRTE_DPAA_PMD,n)
240 $(call set,RTE_LIBRTE_PMD_DPAA_SEC,n)
241 $(call set,RTE_LIBRTE_PMD_DPAA_EVENTDEV,n)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700242 @rm -f .config.ok
243
244$(CURDIR)/$(DPDK_TARBALL):
Ed Warnickecb9cada2015-12-08 15:45:58 -0700245 @if [ -e $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) ] ; \
246 then cp $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) $(CURDIR) ; \
247 else curl -o $(CURDIR)/$(DPDK_TARBALL) -LO $(DPDK_TAR_URL) ; \
248 fi
249 @rm -f $(B)/.download.ok
250
Sergio Gonzalez Monroy6184db32017-10-27 08:58:38 +0100251$(CURDIR)/$(NASM_TARBALL):
252 @if [ -e $(DPDK_DOWNLOAD_DIR)/$(NASM_TARBALL) ] ; \
253 then cp $(DPDK_DOWNLOAD_DIR)/$(NASM_TARBALL) $(CURDIR) ; \
254 else curl -o $(CURDIR)/$(NASM_TARBALL) -LO $(NASM_TAR_URL) ; \
255 fi
256
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000257$(CURDIR)/$(AESNIMB_LIB_TARBALL):
258 @if [ -e $(DPDK_DOWNLOAD_DIR)/$(AESNIMB_LIB_TARBALL) ] ; \
259 then cp $(DPDK_DOWNLOAD_DIR)/$(AESNIMB_LIB_TARBALL) $(CURDIR) ; \
260 else curl -o $@ -LO $(AESNIMB_LIB_TARBALL_URL) ; \
261 fi
262
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000263DPDK_DOWNLOADS = $(CURDIR)/$(DPDK_TARBALL)
Sergio Gonzalez Monroy618f7b02017-07-19 16:22:28 +0100264ifeq ($(AESNI),y)
Sergio Gonzalez Monroy6184db32017-10-27 08:58:38 +0100265DPDK_DOWNLOADS += $(CURDIR)/$(NASM_TARBALL)
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000266DPDK_DOWNLOADS += $(CURDIR)/$(AESNIMB_LIB_TARBALL)
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100267endif
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000268
269$(B)/.download.ok: $(DPDK_DOWNLOADS)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100270 @mkdir -p $(B)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700271 @openssl md5 $< | cut -f 2 -d " " - > $(B)/$(DPDK_TARBALL).md5sum
Damjan Marionbce6b6a2015-12-16 04:27:37 +0100272 @([ "$$(<$(B)/$(DPDK_TARBALL).md5sum)" = "$(DPDK_$(DPDK_VERSION)_TARBALL_MD5_CKSUM)" ] || \
Ed Warnickecb9cada2015-12-08 15:45:58 -0700273 ( echo "Bad Checksum! Please remove $< and retry" && \
274 rm $(B)/$(DPDK_TARBALL).md5sum && false ))
275 @touch $@
276
277.PHONY: download
278download: $(B)/.download.ok
279
280$(B)/.extract.ok: $(B)/.download.ok
281 @echo --- extracting $(DPDK_TARBALL) ---
Thomas Monjalon96e10b52016-06-02 14:52:32 +0200282 @tar --directory $(B) --extract --file $(CURDIR)/$(DPDK_TARBALL)
Marco Varlese8ddd5182017-08-14 16:07:00 +0200283ifeq ($(AESNI),y)
Sergio Gonzalez Monroy6184db32017-10-27 08:58:38 +0100284 @echo --- extracting $(NASM_TARBALL) ---
285 @tar --directory $(B) --extract --file $(CURDIR)/$(NASM_TARBALL)
Radu Nicolau6ca42d32017-02-16 13:54:42 +0000286 @echo --- extracting $(AESNIMB_LIB_TARBALL) ---
287 @tar --directory $(B) --extract --file $(CURDIR)/$(AESNIMB_LIB_TARBALL)
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100288endif
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100289 @touch $@
Ed Warnickecb9cada2015-12-08 15:45:58 -0700290
291.PHONY: extract
292extract: $(B)/.extract.ok
293
294$(B)/.patch.ok: $(B)/.extract.ok
Damjan Marion0df78dd2016-03-29 22:37:02 +0200295ifneq ($(wildcard $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch),)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700296 @echo --- patching ---
Damjan Marion2ce7f982017-01-09 20:24:50 +0100297 @for f in $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch ; do \
Ed Warnickecb9cada2015-12-08 15:45:58 -0700298 echo Applying patch: $$(basename $$f) ; \
299 patch -p1 -d $(DPDK_SOURCE) < $$f ; \
300 done
Damjan Marion0df78dd2016-03-29 22:37:02 +0200301endif
Ed Warnickecb9cada2015-12-08 15:45:58 -0700302 @touch $@
303
304.PHONY: patch
305patch: $(B)/.patch.ok
306
307$(B)/.config.ok: $(B)/.patch.ok $(B)/custom-config
308 @make $(DPDK_MAKE_ARGS) config
309 @touch $@
310
311.PHONY: config
312config: $(B)/.config.ok
313
Sergio Gonzalez Monroy6184db32017-10-27 08:58:38 +0100314.PHONY: build-nasm
315build-nasm:
316 cd $(NASM_SOURCE) && sh configure && make -j
317
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100318.PHONY: build-ipsec-mb
319build-ipsec-mb:
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000320 mkdir -p $(I)/lib/
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100321 # Do not build GCM stuff if we are building ISA_L
Damjan Marion0e969ac2018-06-06 14:23:42 +0200322 make -C $(AESNIMB_LIB_SOURCE) -j SHARED=n \
Damjan Marion66e0ce82018-02-21 11:37:24 +0100323 EXTRA_CFLAGS=-fPIC NASM=$(NASM_SOURCE)/nasm
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000324 cp $(AESNIMB_LIB_SOURCE)/libIPSec_MB.a $(I)/lib/
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100325
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100326.PHONY: build-dpdk
327build-dpdk:
328 @if [ ! -e $(B)/.config.ok ] ; then echo 'Please run "make config" first' && false ; fi
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000329 @make $(DPDK_MAKE_ARGS) install
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100330
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100331# Order matters
332ifeq ($(AESNI),y)
Sergio Gonzalez Monroy6184db32017-10-27 08:58:38 +0100333BUILD_TARGETS += build-nasm
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100334BUILD_TARGETS += build-ipsec-mb
335endif
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100336BUILD_TARGETS += build-dpdk
337
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100338$(B)/.build.ok: $(BUILD_TARGETS)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700339 @touch $@
340
341.PHONY: build
342build: $(B)/.build.ok
343
Damjan Marion2ce7f982017-01-09 20:24:50 +0100344.PHONY: install
345install: $(B)/.build.ok
346
Ed Warnickecb9cada2015-12-08 15:45:58 -0700347.PHONY: clean
348clean:
349 @rm -rf $(B) $(I)
350
Damjan Marion2ce7f982017-01-09 20:24:50 +0100351##############################################################################
352# .deb packaging
353##############################################################################
354
355DEB_ARCH=$(shell dpkg --print-architecture 2> /dev/null)
356DEV_DEB=vpp-dpdk-dev_$(DPDK_VERSION)-$(PKG_SUFFIX)_$(DEB_ARCH).deb
357INSTALLED_DEB_VER=$(shell dpkg-query --showformat='$${Version}' --show vpp-dpdk-dev 2> /dev/null)
358
359.PHONY: build-deb install-deb check-deb
360
361deb/debian/changelog: Makefile
362 @echo "vpp-dpdk ($(DPDK_VERSION)-$(PKG_SUFFIX)) unstable; urgency=low" > $@
363 @echo "" >> $@
364 @echo " * DPDK Release $(DPDK_VERSION)" >> $@
365 @echo "" >> $@
366 @echo " -- VPP Dev <vpp-dev@lists.fd.io> $(shell date -R)" >> $@
367
368$(DEV_DEB): deb/debian/changelog
369 @cd deb && dpkg-buildpackage -b -uc -us
370 git clean -fdx deb
371
372build-deb: $(DEV_DEB)
373
374install-deb:
375ifneq ($(INSTALLED_DEB_VER),$(DPDK_VERSION)-$(PKG_SUFFIX))
Ed Warnicke798150b2017-11-08 13:39:31 -0700376 @echo "=========================================================="
377 @echo " Out of date DPDK package installed."
378 @echo " Installed: $(INSTALLED_DEB_VER)"
379 @echo " Needed: $(DPDK_VERSION)-$(PKG_SUFFIX)"
380 @echo "=========================================================="
Damjan Marion2ce7f982017-01-09 20:24:50 +0100381 @make $(DEV_DEB)
382 @sudo dpkg -i $(DEV_DEB)
383else
384 @echo "=========================================================="
385 @echo " Up-to-date DPDK package already installed"
386 @echo "=========================================================="
387endif
388
389check-deb:
390ifneq ($(INSTALLED_DEB_VER),$(DPDK_VERSION)-$(PKG_SUFFIX))
391 @echo "=========================================================="
392 @echo " Outdated DPDK package detected:"
393 @echo " Installed: vpp-dpdk-dev $(INSTALLED_DEB_VER)"
394 @echo " Current: vpp-dpdk-dev $(DPDK_VERSION)-$(PKG_SUFFIX)"
395 @echo ""
396 @echo " Please upgrade by invoking 'make dpdk-install-dev'"
397 @echo " from the top level directory."
398 @echo "=========================================================="
399endif
400
401##############################################################################
402# .rpm packaging
403##############################################################################
404
405RPM_ARCH=$(shell rpm --eval "%{_arch}" 2> /dev/null)
406DEV_RPM=vpp-dpdk-devel-$(DPDK_VERSION)-$(PKG_SUFFIX).$(RPM_ARCH).rpm
Damjan Marion248968b2017-01-20 23:59:28 +0100407INSTALLED_RPM_VER=$(shell rpm -q --queryformat '%{VERSION}-%{RELEASE}' vpp-dpdk-devel 2> /dev/null | grep -v "not inst")
Damjan Marion2ce7f982017-01-09 20:24:50 +0100408
409.PHONY: build-rpm install-rpm check-rpm
410
411$(DEV_RPM): Makefile rpm/vpp-dpdk.spec
412 @rpmbuild -bb \
413 --define "_topdir $(CURDIR)/rpm" \
414 --define "_version $(DPDK_VERSION)" \
415 --define "_release $(PKG_SUFFIX)" \
416 $(CURDIR)/rpm/vpp-dpdk.spec
417 mv rpm/RPMS/$(RPM_ARCH)/*.rpm .
418 git clean -fdx rpm
419
420build-rpm: $(DEV_RPM)
421
422install-rpm:
423ifneq ($(INSTALLED_RPM_VER),$(DPDK_VERSION)-$(PKG_SUFFIX))
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100424 @$(MAKE) $(DEV_RPM)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100425 sudo rpm -Uih $(DEV_RPM)
426else
427 @echo "=========================================================="
428 @echo " Up-to-date DPDK package already installed"
429 @echo "=========================================================="
430endif
431
432check-rpm:
433ifneq ($(INSTALLED_RPM_VER),$(DPDK_VERSION)-$(PKG_SUFFIX))
434 @echo "=========================================================="
435 @echo " Outdated DPDK package detected:"
436 @echo " Installed: vpp-dpdk-devel $(INSTALLED_RPM_VER)"
437 @echo " Current: vpp-dpdk-devel $(DPDK_VERSION)-$(PKG_SUFFIX)"
438 @echo ""
439 @echo " Please upgrade by invoking 'make dpdk-install-dev'"
440 @echo " from the top level directory."
441 @echo "=========================================================="
442endif
443
444##############################################################################
445# ebuild support
446##############################################################################
447
448.PHONY: ebuild-build ebuild-install
449
450ebuild-build:
451ifeq ($(INSTALLED_DEB_VER)$(INSTALLED_RPM_VER),)
452 @echo "=========================================================="
453 @echo "Building DPDK from source. Consider installing development"
454 @echo "package by invoking 'make dpdk-install-dev' from the"
455 @echo "top level directory"
456 @echo "=========================================================="
457 make config
458else
459ifneq ($(INSTALLED_DEB_VER),)
460 make check-deb
461endif
462ifneq ($(INSTALLED_RPM_VER),)
463 make check-rpm
464endif
465endif
466
467ebuild-install:
468ifeq ($(INSTALLED_DEB_VER)$(INSTALLED_RPM_VER),)
469 make install
470endif