blob: 9c9708cdabba28130e3488c0ee71efc0f9791005 [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 Marion206b2d42017-08-25 19:10:57 +020027DPDK_VERSION ?= 17.08
Steve Shin268e64e2017-10-09 15:04:56 -070028PKG_SUFFIX ?= vpp2
Thomas Monjalon96e10b52016-06-02 14:52:32 +020029DPDK_BASE_URL ?= http://fast.dpdk.org/rel
30DPDK_TARBALL := dpdk-$(DPDK_VERSION).tar.xz
Damjan Mariondab123b2016-03-29 16:43:58 +020031DPDK_TAR_URL := $(DPDK_BASE_URL)/$(DPDK_TARBALL)
Damjan Marion6a5be212017-05-11 14:55:43 +020032DPDK_17.05_TARBALL_MD5_CKSUM := 0a68c31cd6a6cabeed0a4331073e4c05
Marco Varlese3a079ce2017-08-14 10:53:28 +020033DPDK_17.08_TARBALL_MD5_CKSUM := 0641f59ea8ea98afefa7cfa2699f6241
Ed Warnickecb9cada2015-12-08 15:45:58 -070034DPDK_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
45IPSEC_MB_VER ?= 0.46
46ISA_L_CRYPTO_VER := 2.18.0
47
Marco Varlese8ddd5182017-08-14 16:07:00 +020048ifeq ($(MACHINE),$(filter $(MACHINE),x86_64))
Thomas F Herbert4b0ac822017-08-29 16:07:51 -040049 AESNI ?= y
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +010050# DPDK pre 17.08 depends on ISA-L Crypto library for GCM PMD
51 ifneq ($(firstword $(sort $(DPDK_VERSION), 17.08)), 17.08)
52 ISA_L_CRYPTO_LIB = y
53 IPSEC_MB_VER = 0.45
54 $(info Building ISA-L Crypto $(ISA_L_CRYPTO_VER) library)
55 endif
56$(info Building IPSec-MB $(IPSEC_MB_VER) library)
Thomas F Herbert4b0ac822017-08-29 16:07:51 -040057else
58 AESNI ?= N
Marco Varlese8ddd5182017-08-14 16:07:00 +020059endif
60
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +010061AESNIMB_LIB_TARBALL := v$(IPSEC_MB_VER).tar.gz
Radu Nicolau6ca42d32017-02-16 13:54:42 +000062AESNIMB_LIB_TARBALL_URL := http://github.com/01org/intel-ipsec-mb/archive/$(AESNIMB_LIB_TARBALL)
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +010063AESNIMB_LIB_SOURCE := $(B)/intel-ipsec-mb-$(IPSEC_MB_VER)
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +010064
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +010065ISA_L_CRYPTO_LIB_TARBALL := v$(ISA_L_CRYPTO_VER).tar.gz
66ISA_L_CRYPTO_LIB_TARBALL_URL := http://github.com/01org/isa-l_crypto/archive/$(ISA_L_CRYPTO_LIB_TARBALL)
67ISA_L_CRYPTO_LIB_SOURCE := $(B)/isa-l_crypto-$(ISA_L_CRYPTO_VER)
68ISA_L_CRYPTO_INSTALL_DIR := $(ISA_L_CRYPTO_LIB_SOURCE)/install
Damjan Marione39a7b82016-04-26 14:54:57 +020069
70ifneq (,$(findstring clang,$(CC)))
71DPDK_CC=clang
Damjan Marion78edb8e2017-02-06 22:28:52 +010072else ifneq (,$(findstring icc,$(CC)))
73DPDK_CC=icc
Damjan Marione39a7b82016-04-26 14:54:57 +020074else
75DPDK_CC=gcc
76endif
77
Damjan Marion78edb8e2017-02-06 22:28:52 +010078##############################################################################
Damjan Marion1664f9b2017-04-24 20:48:53 +020079# Intel x86
Damjan Marion78edb8e2017-02-06 22:28:52 +010080##############################################################################
Damjan Marion1664f9b2017-04-24 20:48:53 +020081ifeq ($(MACHINE),$(filter $(MACHINE),x86_64 i686))
82DPDK_TARGET ?= $(MACHINE)-native-linuxapp-$(DPDK_CC)
Damjan Marion78edb8e2017-02-06 22:28:52 +010083DPDK_MACHINE ?= nhm
84DPDK_TUNE ?= core-avx2
Brian Brooksa7191842017-09-06 13:19:48 -050085
86##############################################################################
87# ARM64
88##############################################################################
Brian Brooks97465522017-08-28 13:05:26 -050089else ifeq ($(MACHINE),aarch64)
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
133else
134$(warning Unknown Cavium CPU)
135endif
Brian Brooks97465522017-08-28 13:05:26 -0500136endif
Damjan Marion78edb8e2017-02-06 22:28:52 +0100137
138##############################################################################
Brian Brooksa7191842017-09-06 13:19:48 -0500139# Unknown platform
Damjan Marion78edb8e2017-02-06 22:28:52 +0100140##############################################################################
141else
Brian Brooksa7191842017-09-06 13:19:48 -0500142$(error Unknown platform)
Christophe Fontaine737547e2016-05-11 08:40:33 +0000143endif
144
Chris Lukeb2861e82017-06-14 11:24:41 -0400145# /proc/cpuinfo does not exist on platforms without a /proc and on some
146# platforms, notably inside containers, it has no content. In those cases
147# we assume there's 1 processor; we use 2*ncpu for the -j option.
148# NB: GNU Make 4.2 will let us use '$(file </proc/cpuinfo)' to both test
149# for file presence and content; for now this will have to do.
150JOBS := $(if $(shell [ -f /proc/cpuinfo ] && head /proc/cpuinfo),\
151 $(shell expr 2 '*' $$(grep -c ^processor /proc/cpuinfo)), 2)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700152
153# compiler/linker custom arguments
154DPDK_CPU_CFLAGS := -pie -fPIC
Ed Warnickecb9cada2015-12-08 15:45:58 -0700155
156ifeq ($(DPDK_DEBUG),n)
Damjan Marion1c80e832016-05-11 23:07:18 +0200157DPDK_EXTRA_CFLAGS := -g -mtune=$(DPDK_TUNE)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700158else
Damjan Marione39a7b82016-04-26 14:54:57 +0200159DPDK_EXTRA_CFLAGS := -g -O0
Ed Warnickecb9cada2015-12-08 15:45:58 -0700160endif
161
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100162ifeq ($(ISA_L_CRYPTO_LIB),y)
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100163DPDK_EXTRA_CFLAGS += -I$(ISA_L_CRYPTO_INSTALL_DIR)/include -Wl,-z,muldefs
Peter Mikusad625f52017-05-31 15:23:59 +0000164DPDK_EXTRA_LDFLAGS += -L$(I)/lib
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100165endif
Radu Nicolau2e3677b2017-02-20 12:27:02 +0000166DPDK_MAKE_EXTRA_ARGS += AESNI_MULTI_BUFFER_LIB_PATH=$(AESNIMB_LIB_SOURCE)
Radu Nicolau2e3677b2017-02-20 12:27:02 +0000167
Ed Warnickecb9cada2015-12-08 15:45:58 -0700168# assemble DPDK make arguments
169DPDK_MAKE_ARGS := -C $(DPDK_SOURCE) -j $(JOBS) \
170 T=$(DPDK_TARGET) \
171 RTE_CONFIG_TEMPLATE=../custom-config \
Ed Warnickecb9cada2015-12-08 15:45:58 -0700172 EXTRA_CFLAGS="$(DPDK_EXTRA_CFLAGS)" \
173 EXTRA_LDFLAGS="$(DPDK_EXTRA_LDFLAGS)" \
174 CPU_CFLAGS="$(DPDK_CPU_CFLAGS)" \
Damjan Marion2ce7f982017-01-09 20:24:50 +0100175 DESTDIR=$(I) \
Christophe Fontaine737547e2016-05-11 08:40:33 +0000176 $(DPDK_MAKE_EXTRA_ARGS)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700177
Ed Warnickecb9cada2015-12-08 15:45:58 -0700178define set
179@if grep -q CONFIG_$1 $@ ; \
180 then sed -i -e 's/.*\(CONFIG_$1=\).*/\1$2/' $@ ; \
181 else echo CONFIG_$1=$2 >> $@ ; \
182fi
183endef
184
185all: build
186
187$(B)/custom-config: $(B)/.patch.ok Makefile
Damjan Marion106f0ed2016-04-26 10:44:28 +0200188 @echo --- generating custom config from $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) ---
189 @cpp -undef -ffreestanding -x assembler-with-cpp $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) $@
Ed Warnickecb9cada2015-12-08 15:45:58 -0700190 $(call set,RTE_MACHINE,$(DPDK_MACHINE))
Ed Warnickecb9cada2015-12-08 15:45:58 -0700191 @# modify options
Damjan Marion13f07182016-02-05 06:44:54 -0800192 $(call set,RTE_MAX_LCORE,256)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700193 $(call set,RTE_PKTMBUF_HEADROOM,$(DPDK_PKTMBUF_HEADROOM))
194 $(call set,RTE_LIBEAL_USE_HPET,y)
195 $(call set,RTE_BUILD_COMBINE_LIBS,y)
Damjan Mariona1556802016-06-26 20:12:40 +0200196 $(call set,RTE_PCI_CONFIG,y)
197 $(call set,RTE_PCI_EXTENDED_TAG,"on")
198 $(call set,RTE_PCI_MAX_READ_REQUEST_SIZE,4096)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700199 @# enable debug init for device drivers
200 $(call set,RTE_LIBRTE_I40E_DEBUG_INIT,$(DPDK_DEBUG))
201 $(call set,RTE_LIBRTE_IXGBE_DEBUG_INIT,$(DPDK_DEBUG))
202 $(call set,RTE_LIBRTE_E1000_DEBUG_INIT,$(DPDK_DEBUG))
203 $(call set,RTE_LIBRTE_VIRTIO_DEBUG_INIT,$(DPDK_DEBUG))
204 $(call set,RTE_LIBRTE_VMXNET3_DEBUG_INIT,$(DPDK_DEBUG))
John Lod9bf9ab2016-02-25 11:17:55 -0500205 $(call set,RTE_LIBRTE_PMD_BOND,y)
206 $(call set,RTE_LIBRTE_IP_FRAG,y)
Sergio Gonzalez Monroyd04b60b2017-01-20 15:35:23 +0000207 $(call set,RTE_LIBRTE_PMD_QAT,y)
Sergio Gonzalez Monroy618f7b02017-07-19 16:22:28 +0100208 $(call set,RTE_LIBRTE_PMD_AESNI_MB,$(AESNI))
209 $(call set,RTE_LIBRTE_PMD_AESNI_GCM,$(AESNI))
Damjan Marion6a5be212017-05-11 14:55:43 +0200210 $(call set,RTE_LIBRTE_MLX4_PMD,$(DPDK_MLX4_PMD))
Damjan Marion696f1ad2016-12-23 22:42:41 +0100211 $(call set,RTE_LIBRTE_MLX5_PMD,$(DPDK_MLX5_PMD))
Ed Warnickecb9cada2015-12-08 15:45:58 -0700212 @# not needed
Damjan Marion844e0eb2017-08-21 22:27:04 +0200213 $(call set,RTE_LIBRTE_PMD_TAP,n)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700214 $(call set,RTE_LIBRTE_TIMER,n)
215 $(call set,RTE_LIBRTE_CFGFILE,n)
216 $(call set,RTE_LIBRTE_LPM,n)
217 $(call set,RTE_LIBRTE_ACL,n)
218 $(call set,RTE_LIBRTE_POWER,n)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700219 $(call set,RTE_LIBRTE_DISTRIBUTOR,n)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700220 $(call set,RTE_LIBRTE_PORT,n)
221 $(call set,RTE_LIBRTE_TABLE,n)
222 $(call set,RTE_LIBRTE_PIPELINE,n)
223 $(call set,RTE_KNI_KMOD,n)
Damjan Marion68fda1c2017-01-01 16:53:22 +0100224 $(call set,RTE_EAL_IGB_UIO,n)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700225 @rm -f .config.ok
226
227$(CURDIR)/$(DPDK_TARBALL):
Ed Warnickecb9cada2015-12-08 15:45:58 -0700228 @if [ -e $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) ] ; \
229 then cp $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) $(CURDIR) ; \
230 else curl -o $(CURDIR)/$(DPDK_TARBALL) -LO $(DPDK_TAR_URL) ; \
231 fi
232 @rm -f $(B)/.download.ok
233
Sergio Gonzalez Monroy6184db32017-10-27 08:58:38 +0100234$(CURDIR)/$(NASM_TARBALL):
235 @if [ -e $(DPDK_DOWNLOAD_DIR)/$(NASM_TARBALL) ] ; \
236 then cp $(DPDK_DOWNLOAD_DIR)/$(NASM_TARBALL) $(CURDIR) ; \
237 else curl -o $(CURDIR)/$(NASM_TARBALL) -LO $(NASM_TAR_URL) ; \
238 fi
239
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000240$(CURDIR)/$(AESNIMB_LIB_TARBALL):
241 @if [ -e $(DPDK_DOWNLOAD_DIR)/$(AESNIMB_LIB_TARBALL) ] ; \
242 then cp $(DPDK_DOWNLOAD_DIR)/$(AESNIMB_LIB_TARBALL) $(CURDIR) ; \
243 else curl -o $@ -LO $(AESNIMB_LIB_TARBALL_URL) ; \
244 fi
245
246$(CURDIR)/$(ISA_L_CRYPTO_LIB_TARBALL):
247 @if [ -e $(DPDK_DOWNLOAD_DIR)/$(ISA_L_CRYPTO_LIB_TARBALL) ] ; \
248 then cp $(DPDK_DOWNLOAD_DIR)/$(ISA_L_CRYPTO_LIB_TARBALL) $(CURDIR) ; \
249 else curl -o $@ -LO $(ISA_L_CRYPTO_LIB_TARBALL_URL) ; \
250 fi
251
252DPDK_DOWNLOADS = $(CURDIR)/$(DPDK_TARBALL)
Sergio Gonzalez Monroy618f7b02017-07-19 16:22:28 +0100253ifeq ($(AESNI),y)
Sergio Gonzalez Monroy6184db32017-10-27 08:58:38 +0100254DPDK_DOWNLOADS += $(CURDIR)/$(NASM_TARBALL)
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000255DPDK_DOWNLOADS += $(CURDIR)/$(AESNIMB_LIB_TARBALL)
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100256endif
257ifeq ($(ISA_L_CRYPTO_LIB),y)
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000258DPDK_DOWNLOADS += $(CURDIR)/$(ISA_L_CRYPTO_LIB_TARBALL)
Sergio Gonzalez Monroy618f7b02017-07-19 16:22:28 +0100259endif
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000260
261$(B)/.download.ok: $(DPDK_DOWNLOADS)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100262 @mkdir -p $(B)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700263 @openssl md5 $< | cut -f 2 -d " " - > $(B)/$(DPDK_TARBALL).md5sum
Damjan Marionbce6b6a2015-12-16 04:27:37 +0100264 @([ "$$(<$(B)/$(DPDK_TARBALL).md5sum)" = "$(DPDK_$(DPDK_VERSION)_TARBALL_MD5_CKSUM)" ] || \
Ed Warnickecb9cada2015-12-08 15:45:58 -0700265 ( echo "Bad Checksum! Please remove $< and retry" && \
266 rm $(B)/$(DPDK_TARBALL).md5sum && false ))
267 @touch $@
268
269.PHONY: download
270download: $(B)/.download.ok
271
272$(B)/.extract.ok: $(B)/.download.ok
273 @echo --- extracting $(DPDK_TARBALL) ---
Thomas Monjalon96e10b52016-06-02 14:52:32 +0200274 @tar --directory $(B) --extract --file $(CURDIR)/$(DPDK_TARBALL)
Marco Varlese8ddd5182017-08-14 16:07:00 +0200275ifeq ($(AESNI),y)
Sergio Gonzalez Monroy6184db32017-10-27 08:58:38 +0100276 @echo --- extracting $(NASM_TARBALL) ---
277 @tar --directory $(B) --extract --file $(CURDIR)/$(NASM_TARBALL)
Radu Nicolau6ca42d32017-02-16 13:54:42 +0000278 @echo --- extracting $(AESNIMB_LIB_TARBALL) ---
279 @tar --directory $(B) --extract --file $(CURDIR)/$(AESNIMB_LIB_TARBALL)
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100280endif
281ifeq ($(ISA_L_CRYPTO_LIB),y)
Radu Nicolau2e3677b2017-02-20 12:27:02 +0000282 @echo --- extracting $(ISA_L_CRYPTO_LIB_TARBALL) ---
283 @tar --directory $(B) --extract --file $(CURDIR)/$(ISA_L_CRYPTO_LIB_TARBALL)
Marco Varlese8ddd5182017-08-14 16:07:00 +0200284endif
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100285 @touch $@
Ed Warnickecb9cada2015-12-08 15:45:58 -0700286
287.PHONY: extract
288extract: $(B)/.extract.ok
289
290$(B)/.patch.ok: $(B)/.extract.ok
Damjan Marion0df78dd2016-03-29 22:37:02 +0200291ifneq ($(wildcard $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch),)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700292 @echo --- patching ---
Damjan Marion2ce7f982017-01-09 20:24:50 +0100293 @for f in $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch ; do \
Ed Warnickecb9cada2015-12-08 15:45:58 -0700294 echo Applying patch: $$(basename $$f) ; \
295 patch -p1 -d $(DPDK_SOURCE) < $$f ; \
296 done
Damjan Marion0df78dd2016-03-29 22:37:02 +0200297endif
Ed Warnickecb9cada2015-12-08 15:45:58 -0700298 @touch $@
299
300.PHONY: patch
301patch: $(B)/.patch.ok
302
303$(B)/.config.ok: $(B)/.patch.ok $(B)/custom-config
304 @make $(DPDK_MAKE_ARGS) config
305 @touch $@
306
307.PHONY: config
308config: $(B)/.config.ok
309
Sergio Gonzalez Monroy6184db32017-10-27 08:58:38 +0100310.PHONY: build-nasm
311build-nasm:
312 cd $(NASM_SOURCE) && sh configure && make -j
313
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100314.PHONY: build-ipsec-mb
315build-ipsec-mb:
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000316 mkdir -p $(I)/lib/
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100317 # Do not build GCM stuff if we are building ISA_L
Sergio Gonzalez Monroydb93cd92017-08-26 15:22:05 +0100318 make -C $(AESNIMB_LIB_SOURCE) -j NO_GCM=$(ISA_L_CRYPTO_LIB) \
Sergio Gonzalez Monroy6184db32017-10-27 08:58:38 +0100319 DEBUG=$(DPDK_DEBUG) EXTRA_CFLAGS=-fPIC NASM=$(NASM_SOURCE)/nasm
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000320 cp $(AESNIMB_LIB_SOURCE)/libIPSec_MB.a $(I)/lib/
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100321
322.PHONY: build-isal-crypto
323build-isal-crypto:
324 mkdir -p $(I)/lib/
325 cd $(ISA_L_CRYPTO_LIB_SOURCE) && ./autogen.sh && \
Sergio Gonzalez Monroy4aef5b72017-08-14 09:26:44 +0100326 ./configure --prefix=$(ISA_L_CRYPTO_INSTALL_DIR) \
327 --libdir=$(ISA_L_CRYPTO_INSTALL_DIR)/lib CFLAGS='-fPIC -DPIC -O2'
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000328 make -C $(ISA_L_CRYPTO_LIB_SOURCE) -j install
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100329 cp $(ISA_L_CRYPTO_INSTALL_DIR)/lib/libisal_crypto.a $(I)/lib/
330
331.PHONY: build-dpdk
332build-dpdk:
333 @if [ ! -e $(B)/.config.ok ] ; then echo 'Please run "make config" first' && false ; fi
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000334 @make $(DPDK_MAKE_ARGS) install
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100335
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100336# Order matters
337ifeq ($(AESNI),y)
Sergio Gonzalez Monroy6184db32017-10-27 08:58:38 +0100338BUILD_TARGETS += build-nasm
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100339BUILD_TARGETS += build-ipsec-mb
340endif
341ifeq ($(ISA_L_CRYPTO_LIB),y)
342BUILD_TARGETS += build-isal-crypto
343endif
344BUILD_TARGETS += build-dpdk
345
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100346$(B)/.build.ok: $(BUILD_TARGETS)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700347 @touch $@
348
349.PHONY: build
350build: $(B)/.build.ok
351
Damjan Marion2ce7f982017-01-09 20:24:50 +0100352.PHONY: install
353install: $(B)/.build.ok
354
Ed Warnickecb9cada2015-12-08 15:45:58 -0700355.PHONY: clean
356clean:
357 @rm -rf $(B) $(I)
358
Damjan Marion2ce7f982017-01-09 20:24:50 +0100359##############################################################################
360# .deb packaging
361##############################################################################
362
363DEB_ARCH=$(shell dpkg --print-architecture 2> /dev/null)
364DEV_DEB=vpp-dpdk-dev_$(DPDK_VERSION)-$(PKG_SUFFIX)_$(DEB_ARCH).deb
365INSTALLED_DEB_VER=$(shell dpkg-query --showformat='$${Version}' --show vpp-dpdk-dev 2> /dev/null)
366
367.PHONY: build-deb install-deb check-deb
368
369deb/debian/changelog: Makefile
370 @echo "vpp-dpdk ($(DPDK_VERSION)-$(PKG_SUFFIX)) unstable; urgency=low" > $@
371 @echo "" >> $@
372 @echo " * DPDK Release $(DPDK_VERSION)" >> $@
373 @echo "" >> $@
374 @echo " -- VPP Dev <vpp-dev@lists.fd.io> $(shell date -R)" >> $@
375
376$(DEV_DEB): deb/debian/changelog
377 @cd deb && dpkg-buildpackage -b -uc -us
378 git clean -fdx deb
379
380build-deb: $(DEV_DEB)
381
382install-deb:
383ifneq ($(INSTALLED_DEB_VER),$(DPDK_VERSION)-$(PKG_SUFFIX))
384 @make $(DEV_DEB)
385 @sudo dpkg -i $(DEV_DEB)
386else
387 @echo "=========================================================="
388 @echo " Up-to-date DPDK package already installed"
389 @echo "=========================================================="
390endif
391
392check-deb:
393ifneq ($(INSTALLED_DEB_VER),$(DPDK_VERSION)-$(PKG_SUFFIX))
394 @echo "=========================================================="
395 @echo " Outdated DPDK package detected:"
396 @echo " Installed: vpp-dpdk-dev $(INSTALLED_DEB_VER)"
397 @echo " Current: vpp-dpdk-dev $(DPDK_VERSION)-$(PKG_SUFFIX)"
398 @echo ""
399 @echo " Please upgrade by invoking 'make dpdk-install-dev'"
400 @echo " from the top level directory."
401 @echo "=========================================================="
402endif
403
404##############################################################################
405# .rpm packaging
406##############################################################################
407
408RPM_ARCH=$(shell rpm --eval "%{_arch}" 2> /dev/null)
409DEV_RPM=vpp-dpdk-devel-$(DPDK_VERSION)-$(PKG_SUFFIX).$(RPM_ARCH).rpm
Damjan Marion248968b2017-01-20 23:59:28 +0100410INSTALLED_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 +0100411
412.PHONY: build-rpm install-rpm check-rpm
413
414$(DEV_RPM): Makefile rpm/vpp-dpdk.spec
415 @rpmbuild -bb \
416 --define "_topdir $(CURDIR)/rpm" \
417 --define "_version $(DPDK_VERSION)" \
418 --define "_release $(PKG_SUFFIX)" \
419 $(CURDIR)/rpm/vpp-dpdk.spec
420 mv rpm/RPMS/$(RPM_ARCH)/*.rpm .
421 git clean -fdx rpm
422
423build-rpm: $(DEV_RPM)
424
425install-rpm:
426ifneq ($(INSTALLED_RPM_VER),$(DPDK_VERSION)-$(PKG_SUFFIX))
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100427 @$(MAKE) $(DEV_RPM)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100428 sudo rpm -Uih $(DEV_RPM)
429else
430 @echo "=========================================================="
431 @echo " Up-to-date DPDK package already installed"
432 @echo "=========================================================="
433endif
434
435check-rpm:
436ifneq ($(INSTALLED_RPM_VER),$(DPDK_VERSION)-$(PKG_SUFFIX))
437 @echo "=========================================================="
438 @echo " Outdated DPDK package detected:"
439 @echo " Installed: vpp-dpdk-devel $(INSTALLED_RPM_VER)"
440 @echo " Current: vpp-dpdk-devel $(DPDK_VERSION)-$(PKG_SUFFIX)"
441 @echo ""
442 @echo " Please upgrade by invoking 'make dpdk-install-dev'"
443 @echo " from the top level directory."
444 @echo "=========================================================="
445endif
446
447##############################################################################
448# ebuild support
449##############################################################################
450
451.PHONY: ebuild-build ebuild-install
452
453ebuild-build:
454ifeq ($(INSTALLED_DEB_VER)$(INSTALLED_RPM_VER),)
455 @echo "=========================================================="
456 @echo "Building DPDK from source. Consider installing development"
457 @echo "package by invoking 'make dpdk-install-dev' from the"
458 @echo "top level directory"
459 @echo "=========================================================="
460 make config
461else
462ifneq ($(INSTALLED_DEB_VER),)
463 make check-deb
464endif
465ifneq ($(INSTALLED_RPM_VER),)
466 make check-rpm
467endif
468endif
469
470ebuild-install:
471ifeq ($(INSTALLED_DEB_VER)$(INSTALLED_RPM_VER),)
472 make install
473endif