blob: 869cac22f7b035066276e187fc79a7bfd6067520 [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
Ed Warnickecb9cada2015-12-08 15:45:58 -070020DPDK_DOWNLOAD_DIR ?= $(HOME)/Downloads
Ed Warnickecb9cada2015-12-08 15:45:58 -070021DPDK_DEBUG ?= n
Damjan Marion6a5be212017-05-11 14:55:43 +020022DPDK_MLX4_PMD ?= n
Damjan Marion696f1ad2016-12-23 22:42:41 +010023DPDK_MLX5_PMD ?= n
Ed Warnickecb9cada2015-12-08 15:45:58 -070024
25B := $(DPDK_BUILD_DIR)
26I := $(DPDK_INSTALL_DIR)
Damjan Marion7f0d1d32017-11-21 16:22:55 +010027DPDK_VERSION ?= 17.11
28PKG_SUFFIX ?= vpp1
Damjan Marionde3ff7a2017-11-29 12:28:38 +010029DPDK_BASE_URL ?= http://fast.dpdk.org/rel
Thomas Monjalon96e10b52016-06-02 14:52:32 +020030DPDK_TARBALL := dpdk-$(DPDK_VERSION).tar.xz
Damjan Mariondab123b2016-03-29 16:43:58 +020031DPDK_TAR_URL := $(DPDK_BASE_URL)/$(DPDK_TARBALL)
Damjan Marionde3ff7a2017-11-29 12:28:38 +010032DPDK_17.08_TARBALL_MD5_CKSUM := 0641f59ea8ea98afefa7cfa2699f6241
Damjan Marion45b48502017-11-17 09:46:41 +010033DPDK_17.11_TARBALL_MD5_CKSUM := 53ee9e054a8797c9e67ffa0eb5d0c701
Damjan Marionde3ff7a2017-11-29 12:28:38 +010034DPDK_SOURCE := $(B)/dpdk-$(DPDK_VERSION)
Damjan Marion5f22f4d2017-08-21 22:19:04 +020035MACHINE=$(shell uname -m)
Radu Nicolau2e3677b2017-02-20 12:27:02 +000036
Sergio Gonzalez Monroy6184db32017-10-27 08:58:38 +010037NASM_BASE_URL := http://www.nasm.us/pub/nasm/releasebuilds
38NASM_VER := 2.13.01
39NASM_TARBALL := nasm-$(NASM_VER).tar.xz
40NASM_TAR_URL := $(NASM_BASE_URL)/$(NASM_VER)/$(NASM_TARBALL)
41NASM_SOURCE := $(B)/nasm-$(NASM_VER)
42
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +010043ISA_L_CRYPTO_LIB := n
44
Damjan Marion45b48502017-11-17 09:46:41 +010045ifeq ($(DPDK_VERSION),17.08)
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +010046IPSEC_MB_VER ?= 0.46
Damjan Marion45b48502017-11-17 09:46:41 +010047else
48IPSEC_MB_VER ?= 0.47
49endif
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +010050ISA_L_CRYPTO_VER := 2.18.0
51
Marco Varlese8ddd5182017-08-14 16:07:00 +020052ifeq ($(MACHINE),$(filter $(MACHINE),x86_64))
Thomas F Herbert4b0ac822017-08-29 16:07:51 -040053 AESNI ?= y
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +010054# DPDK pre 17.08 depends on ISA-L Crypto library for GCM PMD
55 ifneq ($(firstword $(sort $(DPDK_VERSION), 17.08)), 17.08)
56 ISA_L_CRYPTO_LIB = y
57 IPSEC_MB_VER = 0.45
58 $(info Building ISA-L Crypto $(ISA_L_CRYPTO_VER) library)
59 endif
60$(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
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +010069ISA_L_CRYPTO_LIB_TARBALL := v$(ISA_L_CRYPTO_VER).tar.gz
70ISA_L_CRYPTO_LIB_TARBALL_URL := http://github.com/01org/isa-l_crypto/archive/$(ISA_L_CRYPTO_LIB_TARBALL)
71ISA_L_CRYPTO_LIB_SOURCE := $(B)/isa-l_crypto-$(ISA_L_CRYPTO_VER)
72ISA_L_CRYPTO_INSTALL_DIR := $(ISA_L_CRYPTO_LIB_SOURCE)/install
Damjan Marione39a7b82016-04-26 14:54:57 +020073
74ifneq (,$(findstring clang,$(CC)))
75DPDK_CC=clang
Damjan Marion78edb8e2017-02-06 22:28:52 +010076else ifneq (,$(findstring icc,$(CC)))
77DPDK_CC=icc
Damjan Marione39a7b82016-04-26 14:54:57 +020078else
79DPDK_CC=gcc
80endif
81
Damjan Marion78edb8e2017-02-06 22:28:52 +010082##############################################################################
Damjan Marion1664f9b2017-04-24 20:48:53 +020083# Intel x86
Damjan Marion78edb8e2017-02-06 22:28:52 +010084##############################################################################
Damjan Marion1664f9b2017-04-24 20:48:53 +020085ifeq ($(MACHINE),$(filter $(MACHINE),x86_64 i686))
86DPDK_TARGET ?= $(MACHINE)-native-linuxapp-$(DPDK_CC)
Damjan Marion78edb8e2017-02-06 22:28:52 +010087DPDK_MACHINE ?= nhm
88DPDK_TUNE ?= core-avx2
Brian Brooksa7191842017-09-06 13:19:48 -050089
90##############################################################################
91# ARM64
92##############################################################################
Brian Brooks97465522017-08-28 13:05:26 -050093else ifeq ($(MACHINE),aarch64)
94export CROSS=""
Brian Brooks97465522017-08-28 13:05:26 -050095DPDK_TARGET ?= arm64-armv8a-linuxapp-$(DPDK_CC)
96DPDK_MACHINE ?= armv8a
97DPDK_TUNE ?= generic
Brian Brooksa7191842017-09-06 13:19:48 -050098
99CPU_IMP_ARM = 0x41
100CPU_IMP_CAVIUM = 0x43
101
102CPU_PART_ARM_CORTEX_A53 = 0xd03
103CPU_PART_ARM_CORTEX_A57 = 0xd07
104CPU_PART_ARM_CORTEX_A72 = 0xd08
105CPU_PART_ARM_CORTEX_A73 = 0xd09
106
107CPU_PART_CAVIUM_THUNDERX = 0x0a1
108CPU_PART_CAVIUM_THUNDERX_81XX = 0x0a2
109CPU_PART_CAVIUM_THUNDERX_83XX = 0x0a3
110
111MIDR_IMPLEMENTER=$(shell awk '/implementer/ {print $$4;exit}' /proc/cpuinfo)
112MIDR_PARTNUM=$(shell awk '/part/ {print $$4;exit}' /proc/cpuinfo)
113
114ifeq ($(MIDR_IMPLEMENTER),$(CPU_IMP_ARM))
115##############################################################################
116# Arm Cortex
117##############################################################################
118CPU_PART_ARM_TUNE := $(CPU_PART_ARM_CORTEX_A53)/cortex-a53 \
119 $(CPU_PART_ARM_CORTEX_A57)/cortex-a57 \
120 $(CPU_PART_ARM_CORTEX_A72)/cortex-a72 \
121 $(CPU_PART_ARM_CORTEX_A73)/cortex-a73
122CPU_TUNE = $(notdir $(filter $(MIDR_PARTNUM)/%,$(CPU_PART_ARM_TUNE)))
123ifneq ($(CPU_TUNE),)
124DPDK_TUNE = $(CPU_TUNE)
125else
126$(warning Unknown Arm CPU)
127endif
128
129else ifeq ($(MIDR_IMPLEMENTER),$(CPU_IMP_CAVIUM))
130##############################################################################
131# Cavium ThunderX
132##############################################################################
133ifneq (,$(findstring $(MIDR_PARTNUM),$(CPU_PART_CAVIUM_THUNDERX) \
134 $(CPU_PART_CAVIUM_THUNDERX_81XX) $(CPU_PART_CAVIUM_THUNDERX_83XX)))
135DPDK_TARGET = arm64-thunderx-linuxapp-$(DPDK_CC)
136DPDK_MACHINE = thunderx
137else
138$(warning Unknown Cavium CPU)
139endif
Brian Brooks97465522017-08-28 13:05:26 -0500140endif
Damjan Marion78edb8e2017-02-06 22:28:52 +0100141
142##############################################################################
Brian Brooksa7191842017-09-06 13:19:48 -0500143# Unknown platform
Damjan Marion78edb8e2017-02-06 22:28:52 +0100144##############################################################################
145else
Brian Brooksa7191842017-09-06 13:19:48 -0500146$(error Unknown platform)
Christophe Fontaine737547e2016-05-11 08:40:33 +0000147endif
148
Chris Lukeb2861e82017-06-14 11:24:41 -0400149# /proc/cpuinfo does not exist on platforms without a /proc and on some
150# platforms, notably inside containers, it has no content. In those cases
151# we assume there's 1 processor; we use 2*ncpu for the -j option.
152# NB: GNU Make 4.2 will let us use '$(file </proc/cpuinfo)' to both test
153# for file presence and content; for now this will have to do.
154JOBS := $(if $(shell [ -f /proc/cpuinfo ] && head /proc/cpuinfo),\
Damjan Marion93242842017-11-13 20:09:21 +0100155 $(shell grep -c ^processor /proc/cpuinfo), 2)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700156
157# compiler/linker custom arguments
158DPDK_CPU_CFLAGS := -pie -fPIC
Ed Warnickecb9cada2015-12-08 15:45:58 -0700159
160ifeq ($(DPDK_DEBUG),n)
Damjan Marion1c80e832016-05-11 23:07:18 +0200161DPDK_EXTRA_CFLAGS := -g -mtune=$(DPDK_TUNE)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700162else
Damjan Marione39a7b82016-04-26 14:54:57 +0200163DPDK_EXTRA_CFLAGS := -g -O0
Ed Warnickecb9cada2015-12-08 15:45:58 -0700164endif
165
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100166ifeq ($(ISA_L_CRYPTO_LIB),y)
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100167DPDK_EXTRA_CFLAGS += -I$(ISA_L_CRYPTO_INSTALL_DIR)/include -Wl,-z,muldefs
Peter Mikusad625f52017-05-31 15:23:59 +0000168DPDK_EXTRA_LDFLAGS += -L$(I)/lib
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100169endif
Radu Nicolau2e3677b2017-02-20 12:27:02 +0000170DPDK_MAKE_EXTRA_ARGS += AESNI_MULTI_BUFFER_LIB_PATH=$(AESNIMB_LIB_SOURCE)
Radu Nicolau2e3677b2017-02-20 12:27:02 +0000171
Ed Warnickecb9cada2015-12-08 15:45:58 -0700172# assemble DPDK make arguments
173DPDK_MAKE_ARGS := -C $(DPDK_SOURCE) -j $(JOBS) \
174 T=$(DPDK_TARGET) \
175 RTE_CONFIG_TEMPLATE=../custom-config \
Ed Warnickecb9cada2015-12-08 15:45:58 -0700176 EXTRA_CFLAGS="$(DPDK_EXTRA_CFLAGS)" \
177 EXTRA_LDFLAGS="$(DPDK_EXTRA_LDFLAGS)" \
178 CPU_CFLAGS="$(DPDK_CPU_CFLAGS)" \
Damjan Marion2ce7f982017-01-09 20:24:50 +0100179 DESTDIR=$(I) \
Christophe Fontaine737547e2016-05-11 08:40:33 +0000180 $(DPDK_MAKE_EXTRA_ARGS)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700181
Ed Warnickecb9cada2015-12-08 15:45:58 -0700182define set
183@if grep -q CONFIG_$1 $@ ; \
184 then sed -i -e 's/.*\(CONFIG_$1=\).*/\1$2/' $@ ; \
185 else echo CONFIG_$1=$2 >> $@ ; \
186fi
187endef
188
189all: build
190
191$(B)/custom-config: $(B)/.patch.ok Makefile
Damjan Marion106f0ed2016-04-26 10:44:28 +0200192 @echo --- generating custom config from $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) ---
193 @cpp -undef -ffreestanding -x assembler-with-cpp $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) $@
Ed Warnickecb9cada2015-12-08 15:45:58 -0700194 $(call set,RTE_MACHINE,$(DPDK_MACHINE))
Ed Warnickecb9cada2015-12-08 15:45:58 -0700195 @# modify options
Damjan Marion13f07182016-02-05 06:44:54 -0800196 $(call set,RTE_MAX_LCORE,256)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700197 $(call set,RTE_PKTMBUF_HEADROOM,$(DPDK_PKTMBUF_HEADROOM))
198 $(call set,RTE_LIBEAL_USE_HPET,y)
199 $(call set,RTE_BUILD_COMBINE_LIBS,y)
Damjan Mariona1556802016-06-26 20:12:40 +0200200 $(call set,RTE_PCI_CONFIG,y)
201 $(call set,RTE_PCI_EXTENDED_TAG,"on")
202 $(call set,RTE_PCI_MAX_READ_REQUEST_SIZE,4096)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700203 @# enable debug init for device drivers
204 $(call set,RTE_LIBRTE_I40E_DEBUG_INIT,$(DPDK_DEBUG))
205 $(call set,RTE_LIBRTE_IXGBE_DEBUG_INIT,$(DPDK_DEBUG))
206 $(call set,RTE_LIBRTE_E1000_DEBUG_INIT,$(DPDK_DEBUG))
207 $(call set,RTE_LIBRTE_VIRTIO_DEBUG_INIT,$(DPDK_DEBUG))
208 $(call set,RTE_LIBRTE_VMXNET3_DEBUG_INIT,$(DPDK_DEBUG))
John Lod9bf9ab2016-02-25 11:17:55 -0500209 $(call set,RTE_LIBRTE_PMD_BOND,y)
210 $(call set,RTE_LIBRTE_IP_FRAG,y)
Sergio Gonzalez Monroyd04b60b2017-01-20 15:35:23 +0000211 $(call set,RTE_LIBRTE_PMD_QAT,y)
Sergio Gonzalez Monroy618f7b02017-07-19 16:22:28 +0100212 $(call set,RTE_LIBRTE_PMD_AESNI_MB,$(AESNI))
213 $(call set,RTE_LIBRTE_PMD_AESNI_GCM,$(AESNI))
Damjan Marion6a5be212017-05-11 14:55:43 +0200214 $(call set,RTE_LIBRTE_MLX4_PMD,$(DPDK_MLX4_PMD))
Damjan Marion696f1ad2016-12-23 22:42:41 +0100215 $(call set,RTE_LIBRTE_MLX5_PMD,$(DPDK_MLX5_PMD))
Ed Warnickecb9cada2015-12-08 15:45:58 -0700216 @# not needed
Damjan Marion844e0eb2017-08-21 22:27:04 +0200217 $(call set,RTE_LIBRTE_PMD_TAP,n)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700218 $(call set,RTE_LIBRTE_TIMER,n)
219 $(call set,RTE_LIBRTE_CFGFILE,n)
220 $(call set,RTE_LIBRTE_LPM,n)
221 $(call set,RTE_LIBRTE_ACL,n)
222 $(call set,RTE_LIBRTE_POWER,n)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700223 $(call set,RTE_LIBRTE_DISTRIBUTOR,n)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700224 $(call set,RTE_LIBRTE_PORT,n)
225 $(call set,RTE_LIBRTE_TABLE,n)
226 $(call set,RTE_LIBRTE_PIPELINE,n)
Damjan Marion45b48502017-11-17 09:46:41 +0100227 $(call set,RTE_LIBRTE_FLOW_CLASSIFY,n)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700228 $(call set,RTE_KNI_KMOD,n)
Damjan Marion68fda1c2017-01-01 16:53:22 +0100229 $(call set,RTE_EAL_IGB_UIO,n)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700230 @rm -f .config.ok
231
232$(CURDIR)/$(DPDK_TARBALL):
Ed Warnickecb9cada2015-12-08 15:45:58 -0700233 @if [ -e $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) ] ; \
234 then cp $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) $(CURDIR) ; \
235 else curl -o $(CURDIR)/$(DPDK_TARBALL) -LO $(DPDK_TAR_URL) ; \
236 fi
237 @rm -f $(B)/.download.ok
238
Sergio Gonzalez Monroy6184db32017-10-27 08:58:38 +0100239$(CURDIR)/$(NASM_TARBALL):
240 @if [ -e $(DPDK_DOWNLOAD_DIR)/$(NASM_TARBALL) ] ; \
241 then cp $(DPDK_DOWNLOAD_DIR)/$(NASM_TARBALL) $(CURDIR) ; \
242 else curl -o $(CURDIR)/$(NASM_TARBALL) -LO $(NASM_TAR_URL) ; \
243 fi
244
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000245$(CURDIR)/$(AESNIMB_LIB_TARBALL):
246 @if [ -e $(DPDK_DOWNLOAD_DIR)/$(AESNIMB_LIB_TARBALL) ] ; \
247 then cp $(DPDK_DOWNLOAD_DIR)/$(AESNIMB_LIB_TARBALL) $(CURDIR) ; \
248 else curl -o $@ -LO $(AESNIMB_LIB_TARBALL_URL) ; \
249 fi
250
251$(CURDIR)/$(ISA_L_CRYPTO_LIB_TARBALL):
252 @if [ -e $(DPDK_DOWNLOAD_DIR)/$(ISA_L_CRYPTO_LIB_TARBALL) ] ; \
253 then cp $(DPDK_DOWNLOAD_DIR)/$(ISA_L_CRYPTO_LIB_TARBALL) $(CURDIR) ; \
254 else curl -o $@ -LO $(ISA_L_CRYPTO_LIB_TARBALL_URL) ; \
255 fi
256
257DPDK_DOWNLOADS = $(CURDIR)/$(DPDK_TARBALL)
Sergio Gonzalez Monroy618f7b02017-07-19 16:22:28 +0100258ifeq ($(AESNI),y)
Sergio Gonzalez Monroy6184db32017-10-27 08:58:38 +0100259DPDK_DOWNLOADS += $(CURDIR)/$(NASM_TARBALL)
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000260DPDK_DOWNLOADS += $(CURDIR)/$(AESNIMB_LIB_TARBALL)
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100261endif
262ifeq ($(ISA_L_CRYPTO_LIB),y)
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000263DPDK_DOWNLOADS += $(CURDIR)/$(ISA_L_CRYPTO_LIB_TARBALL)
Sergio Gonzalez Monroy618f7b02017-07-19 16:22:28 +0100264endif
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000265
266$(B)/.download.ok: $(DPDK_DOWNLOADS)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100267 @mkdir -p $(B)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700268 @openssl md5 $< | cut -f 2 -d " " - > $(B)/$(DPDK_TARBALL).md5sum
Damjan Marionbce6b6a2015-12-16 04:27:37 +0100269 @([ "$$(<$(B)/$(DPDK_TARBALL).md5sum)" = "$(DPDK_$(DPDK_VERSION)_TARBALL_MD5_CKSUM)" ] || \
Ed Warnickecb9cada2015-12-08 15:45:58 -0700270 ( echo "Bad Checksum! Please remove $< and retry" && \
271 rm $(B)/$(DPDK_TARBALL).md5sum && false ))
272 @touch $@
273
274.PHONY: download
275download: $(B)/.download.ok
276
277$(B)/.extract.ok: $(B)/.download.ok
278 @echo --- extracting $(DPDK_TARBALL) ---
Thomas Monjalon96e10b52016-06-02 14:52:32 +0200279 @tar --directory $(B) --extract --file $(CURDIR)/$(DPDK_TARBALL)
Marco Varlese8ddd5182017-08-14 16:07:00 +0200280ifeq ($(AESNI),y)
Sergio Gonzalez Monroy6184db32017-10-27 08:58:38 +0100281 @echo --- extracting $(NASM_TARBALL) ---
282 @tar --directory $(B) --extract --file $(CURDIR)/$(NASM_TARBALL)
Radu Nicolau6ca42d32017-02-16 13:54:42 +0000283 @echo --- extracting $(AESNIMB_LIB_TARBALL) ---
284 @tar --directory $(B) --extract --file $(CURDIR)/$(AESNIMB_LIB_TARBALL)
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100285endif
286ifeq ($(ISA_L_CRYPTO_LIB),y)
Radu Nicolau2e3677b2017-02-20 12:27:02 +0000287 @echo --- extracting $(ISA_L_CRYPTO_LIB_TARBALL) ---
288 @tar --directory $(B) --extract --file $(CURDIR)/$(ISA_L_CRYPTO_LIB_TARBALL)
Marco Varlese8ddd5182017-08-14 16:07:00 +0200289endif
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100290 @touch $@
Ed Warnickecb9cada2015-12-08 15:45:58 -0700291
292.PHONY: extract
293extract: $(B)/.extract.ok
294
295$(B)/.patch.ok: $(B)/.extract.ok
Damjan Marion0df78dd2016-03-29 22:37:02 +0200296ifneq ($(wildcard $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch),)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700297 @echo --- patching ---
Damjan Marion2ce7f982017-01-09 20:24:50 +0100298 @for f in $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch ; do \
Ed Warnickecb9cada2015-12-08 15:45:58 -0700299 echo Applying patch: $$(basename $$f) ; \
300 patch -p1 -d $(DPDK_SOURCE) < $$f ; \
301 done
Damjan Marion0df78dd2016-03-29 22:37:02 +0200302endif
Ed Warnickecb9cada2015-12-08 15:45:58 -0700303 @touch $@
304
305.PHONY: patch
306patch: $(B)/.patch.ok
307
308$(B)/.config.ok: $(B)/.patch.ok $(B)/custom-config
309 @make $(DPDK_MAKE_ARGS) config
310 @touch $@
311
312.PHONY: config
313config: $(B)/.config.ok
314
Sergio Gonzalez Monroy6184db32017-10-27 08:58:38 +0100315.PHONY: build-nasm
316build-nasm:
317 cd $(NASM_SOURCE) && sh configure && make -j
318
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100319.PHONY: build-ipsec-mb
320build-ipsec-mb:
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000321 mkdir -p $(I)/lib/
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100322 # Do not build GCM stuff if we are building ISA_L
Sergio Gonzalez Monroydb93cd92017-08-26 15:22:05 +0100323 make -C $(AESNIMB_LIB_SOURCE) -j NO_GCM=$(ISA_L_CRYPTO_LIB) \
Sergio Gonzalez Monroy6184db32017-10-27 08:58:38 +0100324 DEBUG=$(DPDK_DEBUG) EXTRA_CFLAGS=-fPIC NASM=$(NASM_SOURCE)/nasm
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000325 cp $(AESNIMB_LIB_SOURCE)/libIPSec_MB.a $(I)/lib/
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100326
327.PHONY: build-isal-crypto
328build-isal-crypto:
329 mkdir -p $(I)/lib/
330 cd $(ISA_L_CRYPTO_LIB_SOURCE) && ./autogen.sh && \
Sergio Gonzalez Monroy4aef5b72017-08-14 09:26:44 +0100331 ./configure --prefix=$(ISA_L_CRYPTO_INSTALL_DIR) \
332 --libdir=$(ISA_L_CRYPTO_INSTALL_DIR)/lib CFLAGS='-fPIC -DPIC -O2'
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000333 make -C $(ISA_L_CRYPTO_LIB_SOURCE) -j install
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100334 cp $(ISA_L_CRYPTO_INSTALL_DIR)/lib/libisal_crypto.a $(I)/lib/
335
336.PHONY: build-dpdk
337build-dpdk:
338 @if [ ! -e $(B)/.config.ok ] ; then echo 'Please run "make config" first' && false ; fi
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000339 @make $(DPDK_MAKE_ARGS) install
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100340
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100341# Order matters
342ifeq ($(AESNI),y)
Sergio Gonzalez Monroy6184db32017-10-27 08:58:38 +0100343BUILD_TARGETS += build-nasm
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100344BUILD_TARGETS += build-ipsec-mb
345endif
346ifeq ($(ISA_L_CRYPTO_LIB),y)
347BUILD_TARGETS += build-isal-crypto
348endif
349BUILD_TARGETS += build-dpdk
350
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100351$(B)/.build.ok: $(BUILD_TARGETS)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700352 @touch $@
353
354.PHONY: build
355build: $(B)/.build.ok
356
Damjan Marion2ce7f982017-01-09 20:24:50 +0100357.PHONY: install
358install: $(B)/.build.ok
359
Ed Warnickecb9cada2015-12-08 15:45:58 -0700360.PHONY: clean
361clean:
362 @rm -rf $(B) $(I)
363
Damjan Marion2ce7f982017-01-09 20:24:50 +0100364##############################################################################
365# .deb packaging
366##############################################################################
367
368DEB_ARCH=$(shell dpkg --print-architecture 2> /dev/null)
369DEV_DEB=vpp-dpdk-dev_$(DPDK_VERSION)-$(PKG_SUFFIX)_$(DEB_ARCH).deb
370INSTALLED_DEB_VER=$(shell dpkg-query --showformat='$${Version}' --show vpp-dpdk-dev 2> /dev/null)
371
372.PHONY: build-deb install-deb check-deb
373
374deb/debian/changelog: Makefile
375 @echo "vpp-dpdk ($(DPDK_VERSION)-$(PKG_SUFFIX)) unstable; urgency=low" > $@
376 @echo "" >> $@
377 @echo " * DPDK Release $(DPDK_VERSION)" >> $@
378 @echo "" >> $@
379 @echo " -- VPP Dev <vpp-dev@lists.fd.io> $(shell date -R)" >> $@
380
381$(DEV_DEB): deb/debian/changelog
382 @cd deb && dpkg-buildpackage -b -uc -us
383 git clean -fdx deb
384
385build-deb: $(DEV_DEB)
386
387install-deb:
388ifneq ($(INSTALLED_DEB_VER),$(DPDK_VERSION)-$(PKG_SUFFIX))
Ed Warnicke798150b2017-11-08 13:39:31 -0700389 @echo "=========================================================="
390 @echo " Out of date DPDK package installed."
391 @echo " Installed: $(INSTALLED_DEB_VER)"
392 @echo " Needed: $(DPDK_VERSION)-$(PKG_SUFFIX)"
393 @echo "=========================================================="
Damjan Marion2ce7f982017-01-09 20:24:50 +0100394 @make $(DEV_DEB)
395 @sudo dpkg -i $(DEV_DEB)
396else
397 @echo "=========================================================="
398 @echo " Up-to-date DPDK package already installed"
399 @echo "=========================================================="
400endif
401
402check-deb:
403ifneq ($(INSTALLED_DEB_VER),$(DPDK_VERSION)-$(PKG_SUFFIX))
404 @echo "=========================================================="
405 @echo " Outdated DPDK package detected:"
406 @echo " Installed: vpp-dpdk-dev $(INSTALLED_DEB_VER)"
407 @echo " Current: vpp-dpdk-dev $(DPDK_VERSION)-$(PKG_SUFFIX)"
408 @echo ""
409 @echo " Please upgrade by invoking 'make dpdk-install-dev'"
410 @echo " from the top level directory."
411 @echo "=========================================================="
412endif
413
414##############################################################################
415# .rpm packaging
416##############################################################################
417
418RPM_ARCH=$(shell rpm --eval "%{_arch}" 2> /dev/null)
419DEV_RPM=vpp-dpdk-devel-$(DPDK_VERSION)-$(PKG_SUFFIX).$(RPM_ARCH).rpm
Damjan Marion248968b2017-01-20 23:59:28 +0100420INSTALLED_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 +0100421
422.PHONY: build-rpm install-rpm check-rpm
423
424$(DEV_RPM): Makefile rpm/vpp-dpdk.spec
425 @rpmbuild -bb \
426 --define "_topdir $(CURDIR)/rpm" \
427 --define "_version $(DPDK_VERSION)" \
428 --define "_release $(PKG_SUFFIX)" \
429 $(CURDIR)/rpm/vpp-dpdk.spec
430 mv rpm/RPMS/$(RPM_ARCH)/*.rpm .
431 git clean -fdx rpm
432
433build-rpm: $(DEV_RPM)
434
435install-rpm:
436ifneq ($(INSTALLED_RPM_VER),$(DPDK_VERSION)-$(PKG_SUFFIX))
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100437 @$(MAKE) $(DEV_RPM)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100438 sudo rpm -Uih $(DEV_RPM)
439else
440 @echo "=========================================================="
441 @echo " Up-to-date DPDK package already installed"
442 @echo "=========================================================="
443endif
444
445check-rpm:
446ifneq ($(INSTALLED_RPM_VER),$(DPDK_VERSION)-$(PKG_SUFFIX))
447 @echo "=========================================================="
448 @echo " Outdated DPDK package detected:"
449 @echo " Installed: vpp-dpdk-devel $(INSTALLED_RPM_VER)"
450 @echo " Current: vpp-dpdk-devel $(DPDK_VERSION)-$(PKG_SUFFIX)"
451 @echo ""
452 @echo " Please upgrade by invoking 'make dpdk-install-dev'"
453 @echo " from the top level directory."
454 @echo "=========================================================="
455endif
456
457##############################################################################
458# ebuild support
459##############################################################################
460
461.PHONY: ebuild-build ebuild-install
462
463ebuild-build:
464ifeq ($(INSTALLED_DEB_VER)$(INSTALLED_RPM_VER),)
465 @echo "=========================================================="
466 @echo "Building DPDK from source. Consider installing development"
467 @echo "package by invoking 'make dpdk-install-dev' from the"
468 @echo "top level directory"
469 @echo "=========================================================="
470 make config
471else
472ifneq ($(INSTALLED_DEB_VER),)
473 make check-deb
474endif
475ifneq ($(INSTALLED_RPM_VER),)
476 make check-rpm
477endif
478endif
479
480ebuild-install:
481ifeq ($(INSTALLED_DEB_VER)$(INSTALLED_RPM_VER),)
482 make install
483endif