blob: ed54840881a420699ebc9035b4824c6b59cab8b7 [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 Marion1d3ab722018-02-16 09:07:42 +010027DPDK_VERSION ?= 18.02
Damjan Marion7f0d1d32017-11-21 16:22:55 +010028PKG_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 Marion45b48502017-11-17 09:46:41 +010032DPDK_17.11_TARBALL_MD5_CKSUM := 53ee9e054a8797c9e67ffa0eb5d0c701
Damjan Marion07510dd2018-02-15 11:59:04 +010033DPDK_18.02_TARBALL_MD5_CKSUM := ca13077a014a2102c6e10153dfa3b920
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
Damjan Marion07510dd2018-02-15 11:59:04 +010043ifeq ($(DPDK_VERSION),17.11)
Damjan Marion45b48502017-11-17 09:46:41 +010044IPSEC_MB_VER ?= 0.47
Damjan Marion07510dd2018-02-15 11:59:04 +010045else
46IPSEC_MB_VER ?= 0.48
Damjan Marion45b48502017-11-17 09:46:41 +010047endif
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +010048
Marco Varlese8ddd5182017-08-14 16:07:00 +020049ifeq ($(MACHINE),$(filter $(MACHINE),x86_64))
Thomas F Herbert4b0ac822017-08-29 16:07:51 -040050 AESNI ?= y
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +010051$(info Building IPSec-MB $(IPSEC_MB_VER) library)
Thomas F Herbert4b0ac822017-08-29 16:07:51 -040052else
53 AESNI ?= N
Marco Varlese8ddd5182017-08-14 16:07:00 +020054endif
55
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +010056AESNIMB_LIB_TARBALL := v$(IPSEC_MB_VER).tar.gz
Radu Nicolau6ca42d32017-02-16 13:54:42 +000057AESNIMB_LIB_TARBALL_URL := http://github.com/01org/intel-ipsec-mb/archive/$(AESNIMB_LIB_TARBALL)
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +010058AESNIMB_LIB_SOURCE := $(B)/intel-ipsec-mb-$(IPSEC_MB_VER)
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +010059
Damjan Marione39a7b82016-04-26 14:54:57 +020060ifneq (,$(findstring clang,$(CC)))
61DPDK_CC=clang
Damjan Marion78edb8e2017-02-06 22:28:52 +010062else ifneq (,$(findstring icc,$(CC)))
63DPDK_CC=icc
Damjan Marione39a7b82016-04-26 14:54:57 +020064else
65DPDK_CC=gcc
66endif
67
Damjan Marion78edb8e2017-02-06 22:28:52 +010068##############################################################################
Damjan Marion1664f9b2017-04-24 20:48:53 +020069# Intel x86
Damjan Marion78edb8e2017-02-06 22:28:52 +010070##############################################################################
Damjan Marion1664f9b2017-04-24 20:48:53 +020071ifeq ($(MACHINE),$(filter $(MACHINE),x86_64 i686))
72DPDK_TARGET ?= $(MACHINE)-native-linuxapp-$(DPDK_CC)
Damjan Marion78edb8e2017-02-06 22:28:52 +010073DPDK_MACHINE ?= nhm
74DPDK_TUNE ?= core-avx2
Brian Brooksa7191842017-09-06 13:19:48 -050075
76##############################################################################
77# ARM64
78##############################################################################
Brian Brooks97465522017-08-28 13:05:26 -050079else ifeq ($(MACHINE),aarch64)
80export CROSS=""
Brian Brooks97465522017-08-28 13:05:26 -050081DPDK_TARGET ?= arm64-armv8a-linuxapp-$(DPDK_CC)
82DPDK_MACHINE ?= armv8a
83DPDK_TUNE ?= generic
Brian Brooksa7191842017-09-06 13:19:48 -050084
85CPU_IMP_ARM = 0x41
86CPU_IMP_CAVIUM = 0x43
87
88CPU_PART_ARM_CORTEX_A53 = 0xd03
89CPU_PART_ARM_CORTEX_A57 = 0xd07
90CPU_PART_ARM_CORTEX_A72 = 0xd08
91CPU_PART_ARM_CORTEX_A73 = 0xd09
92
93CPU_PART_CAVIUM_THUNDERX = 0x0a1
94CPU_PART_CAVIUM_THUNDERX_81XX = 0x0a2
95CPU_PART_CAVIUM_THUNDERX_83XX = 0x0a3
96
97MIDR_IMPLEMENTER=$(shell awk '/implementer/ {print $$4;exit}' /proc/cpuinfo)
98MIDR_PARTNUM=$(shell awk '/part/ {print $$4;exit}' /proc/cpuinfo)
99
100ifeq ($(MIDR_IMPLEMENTER),$(CPU_IMP_ARM))
101##############################################################################
102# Arm Cortex
103##############################################################################
104CPU_PART_ARM_TUNE := $(CPU_PART_ARM_CORTEX_A53)/cortex-a53 \
105 $(CPU_PART_ARM_CORTEX_A57)/cortex-a57 \
106 $(CPU_PART_ARM_CORTEX_A72)/cortex-a72 \
107 $(CPU_PART_ARM_CORTEX_A73)/cortex-a73
108CPU_TUNE = $(notdir $(filter $(MIDR_PARTNUM)/%,$(CPU_PART_ARM_TUNE)))
109ifneq ($(CPU_TUNE),)
110DPDK_TUNE = $(CPU_TUNE)
111else
112$(warning Unknown Arm CPU)
113endif
114
115else ifeq ($(MIDR_IMPLEMENTER),$(CPU_IMP_CAVIUM))
116##############################################################################
117# Cavium ThunderX
118##############################################################################
119ifneq (,$(findstring $(MIDR_PARTNUM),$(CPU_PART_CAVIUM_THUNDERX) \
120 $(CPU_PART_CAVIUM_THUNDERX_81XX) $(CPU_PART_CAVIUM_THUNDERX_83XX)))
121DPDK_TARGET = arm64-thunderx-linuxapp-$(DPDK_CC)
122DPDK_MACHINE = thunderx
123else
124$(warning Unknown Cavium CPU)
125endif
Brian Brooks97465522017-08-28 13:05:26 -0500126endif
Damjan Marion78edb8e2017-02-06 22:28:52 +0100127
128##############################################################################
Brian Brooksa7191842017-09-06 13:19:48 -0500129# Unknown platform
Damjan Marion78edb8e2017-02-06 22:28:52 +0100130##############################################################################
131else
Brian Brooksa7191842017-09-06 13:19:48 -0500132$(error Unknown platform)
Christophe Fontaine737547e2016-05-11 08:40:33 +0000133endif
134
Chris Lukeb2861e82017-06-14 11:24:41 -0400135# /proc/cpuinfo does not exist on platforms without a /proc and on some
136# platforms, notably inside containers, it has no content. In those cases
137# we assume there's 1 processor; we use 2*ncpu for the -j option.
138# NB: GNU Make 4.2 will let us use '$(file </proc/cpuinfo)' to both test
139# for file presence and content; for now this will have to do.
140JOBS := $(if $(shell [ -f /proc/cpuinfo ] && head /proc/cpuinfo),\
Damjan Marion93242842017-11-13 20:09:21 +0100141 $(shell grep -c ^processor /proc/cpuinfo), 2)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700142
143# compiler/linker custom arguments
144DPDK_CPU_CFLAGS := -pie -fPIC
Ed Warnickecb9cada2015-12-08 15:45:58 -0700145
146ifeq ($(DPDK_DEBUG),n)
Damjan Marion1c80e832016-05-11 23:07:18 +0200147DPDK_EXTRA_CFLAGS := -g -mtune=$(DPDK_TUNE)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700148else
Damjan Marione39a7b82016-04-26 14:54:57 +0200149DPDK_EXTRA_CFLAGS := -g -O0
Ed Warnickecb9cada2015-12-08 15:45:58 -0700150endif
151
Radu Nicolau2e3677b2017-02-20 12:27:02 +0000152DPDK_MAKE_EXTRA_ARGS += AESNI_MULTI_BUFFER_LIB_PATH=$(AESNIMB_LIB_SOURCE)
Radu Nicolau2e3677b2017-02-20 12:27:02 +0000153
Ed Warnickecb9cada2015-12-08 15:45:58 -0700154# assemble DPDK make arguments
155DPDK_MAKE_ARGS := -C $(DPDK_SOURCE) -j $(JOBS) \
156 T=$(DPDK_TARGET) \
157 RTE_CONFIG_TEMPLATE=../custom-config \
Ed Warnickecb9cada2015-12-08 15:45:58 -0700158 EXTRA_CFLAGS="$(DPDK_EXTRA_CFLAGS)" \
159 EXTRA_LDFLAGS="$(DPDK_EXTRA_LDFLAGS)" \
160 CPU_CFLAGS="$(DPDK_CPU_CFLAGS)" \
Damjan Marion2ce7f982017-01-09 20:24:50 +0100161 DESTDIR=$(I) \
Christophe Fontaine737547e2016-05-11 08:40:33 +0000162 $(DPDK_MAKE_EXTRA_ARGS)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700163
Ed Warnickecb9cada2015-12-08 15:45:58 -0700164define set
165@if grep -q CONFIG_$1 $@ ; \
166 then sed -i -e 's/.*\(CONFIG_$1=\).*/\1$2/' $@ ; \
167 else echo CONFIG_$1=$2 >> $@ ; \
168fi
169endef
170
171all: build
172
173$(B)/custom-config: $(B)/.patch.ok Makefile
Damjan Marion106f0ed2016-04-26 10:44:28 +0200174 @echo --- generating custom config from $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) ---
175 @cpp -undef -ffreestanding -x assembler-with-cpp $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) $@
Ed Warnickecb9cada2015-12-08 15:45:58 -0700176 $(call set,RTE_MACHINE,$(DPDK_MACHINE))
Ed Warnickecb9cada2015-12-08 15:45:58 -0700177 @# modify options
Damjan Marion13f07182016-02-05 06:44:54 -0800178 $(call set,RTE_MAX_LCORE,256)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700179 $(call set,RTE_PKTMBUF_HEADROOM,$(DPDK_PKTMBUF_HEADROOM))
180 $(call set,RTE_LIBEAL_USE_HPET,y)
181 $(call set,RTE_BUILD_COMBINE_LIBS,y)
Damjan Mariona1556802016-06-26 20:12:40 +0200182 $(call set,RTE_PCI_CONFIG,y)
183 $(call set,RTE_PCI_EXTENDED_TAG,"on")
184 $(call set,RTE_PCI_MAX_READ_REQUEST_SIZE,4096)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700185 @# enable debug init for device drivers
186 $(call set,RTE_LIBRTE_I40E_DEBUG_INIT,$(DPDK_DEBUG))
187 $(call set,RTE_LIBRTE_IXGBE_DEBUG_INIT,$(DPDK_DEBUG))
188 $(call set,RTE_LIBRTE_E1000_DEBUG_INIT,$(DPDK_DEBUG))
189 $(call set,RTE_LIBRTE_VIRTIO_DEBUG_INIT,$(DPDK_DEBUG))
190 $(call set,RTE_LIBRTE_VMXNET3_DEBUG_INIT,$(DPDK_DEBUG))
John Lod9bf9ab2016-02-25 11:17:55 -0500191 $(call set,RTE_LIBRTE_PMD_BOND,y)
192 $(call set,RTE_LIBRTE_IP_FRAG,y)
Sergio Gonzalez Monroyd04b60b2017-01-20 15:35:23 +0000193 $(call set,RTE_LIBRTE_PMD_QAT,y)
Sergio Gonzalez Monroy618f7b02017-07-19 16:22:28 +0100194 $(call set,RTE_LIBRTE_PMD_AESNI_MB,$(AESNI))
195 $(call set,RTE_LIBRTE_PMD_AESNI_GCM,$(AESNI))
Damjan Marion6a5be212017-05-11 14:55:43 +0200196 $(call set,RTE_LIBRTE_MLX4_PMD,$(DPDK_MLX4_PMD))
Damjan Marion696f1ad2016-12-23 22:42:41 +0100197 $(call set,RTE_LIBRTE_MLX5_PMD,$(DPDK_MLX5_PMD))
Ed Warnickecb9cada2015-12-08 15:45:58 -0700198 @# not needed
Damjan Marion844e0eb2017-08-21 22:27:04 +0200199 $(call set,RTE_LIBRTE_PMD_TAP,n)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700200 $(call set,RTE_LIBRTE_TIMER,n)
201 $(call set,RTE_LIBRTE_CFGFILE,n)
202 $(call set,RTE_LIBRTE_LPM,n)
203 $(call set,RTE_LIBRTE_ACL,n)
204 $(call set,RTE_LIBRTE_POWER,n)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700205 $(call set,RTE_LIBRTE_DISTRIBUTOR,n)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700206 $(call set,RTE_LIBRTE_PORT,n)
207 $(call set,RTE_LIBRTE_TABLE,n)
208 $(call set,RTE_LIBRTE_PIPELINE,n)
Damjan Marion45b48502017-11-17 09:46:41 +0100209 $(call set,RTE_LIBRTE_FLOW_CLASSIFY,n)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700210 $(call set,RTE_KNI_KMOD,n)
Damjan Marion68fda1c2017-01-01 16:53:22 +0100211 $(call set,RTE_EAL_IGB_UIO,n)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700212 @rm -f .config.ok
213
214$(CURDIR)/$(DPDK_TARBALL):
Ed Warnickecb9cada2015-12-08 15:45:58 -0700215 @if [ -e $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) ] ; \
216 then cp $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) $(CURDIR) ; \
217 else curl -o $(CURDIR)/$(DPDK_TARBALL) -LO $(DPDK_TAR_URL) ; \
218 fi
219 @rm -f $(B)/.download.ok
220
Sergio Gonzalez Monroy6184db32017-10-27 08:58:38 +0100221$(CURDIR)/$(NASM_TARBALL):
222 @if [ -e $(DPDK_DOWNLOAD_DIR)/$(NASM_TARBALL) ] ; \
223 then cp $(DPDK_DOWNLOAD_DIR)/$(NASM_TARBALL) $(CURDIR) ; \
224 else curl -o $(CURDIR)/$(NASM_TARBALL) -LO $(NASM_TAR_URL) ; \
225 fi
226
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000227$(CURDIR)/$(AESNIMB_LIB_TARBALL):
228 @if [ -e $(DPDK_DOWNLOAD_DIR)/$(AESNIMB_LIB_TARBALL) ] ; \
229 then cp $(DPDK_DOWNLOAD_DIR)/$(AESNIMB_LIB_TARBALL) $(CURDIR) ; \
230 else curl -o $@ -LO $(AESNIMB_LIB_TARBALL_URL) ; \
231 fi
232
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000233DPDK_DOWNLOADS = $(CURDIR)/$(DPDK_TARBALL)
Sergio Gonzalez Monroy618f7b02017-07-19 16:22:28 +0100234ifeq ($(AESNI),y)
Sergio Gonzalez Monroy6184db32017-10-27 08:58:38 +0100235DPDK_DOWNLOADS += $(CURDIR)/$(NASM_TARBALL)
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000236DPDK_DOWNLOADS += $(CURDIR)/$(AESNIMB_LIB_TARBALL)
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100237endif
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000238
239$(B)/.download.ok: $(DPDK_DOWNLOADS)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100240 @mkdir -p $(B)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700241 @openssl md5 $< | cut -f 2 -d " " - > $(B)/$(DPDK_TARBALL).md5sum
Damjan Marionbce6b6a2015-12-16 04:27:37 +0100242 @([ "$$(<$(B)/$(DPDK_TARBALL).md5sum)" = "$(DPDK_$(DPDK_VERSION)_TARBALL_MD5_CKSUM)" ] || \
Ed Warnickecb9cada2015-12-08 15:45:58 -0700243 ( echo "Bad Checksum! Please remove $< and retry" && \
244 rm $(B)/$(DPDK_TARBALL).md5sum && false ))
245 @touch $@
246
247.PHONY: download
248download: $(B)/.download.ok
249
250$(B)/.extract.ok: $(B)/.download.ok
251 @echo --- extracting $(DPDK_TARBALL) ---
Thomas Monjalon96e10b52016-06-02 14:52:32 +0200252 @tar --directory $(B) --extract --file $(CURDIR)/$(DPDK_TARBALL)
Marco Varlese8ddd5182017-08-14 16:07:00 +0200253ifeq ($(AESNI),y)
Sergio Gonzalez Monroy6184db32017-10-27 08:58:38 +0100254 @echo --- extracting $(NASM_TARBALL) ---
255 @tar --directory $(B) --extract --file $(CURDIR)/$(NASM_TARBALL)
Radu Nicolau6ca42d32017-02-16 13:54:42 +0000256 @echo --- extracting $(AESNIMB_LIB_TARBALL) ---
257 @tar --directory $(B) --extract --file $(CURDIR)/$(AESNIMB_LIB_TARBALL)
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100258endif
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100259 @touch $@
Ed Warnickecb9cada2015-12-08 15:45:58 -0700260
261.PHONY: extract
262extract: $(B)/.extract.ok
263
264$(B)/.patch.ok: $(B)/.extract.ok
Damjan Marion0df78dd2016-03-29 22:37:02 +0200265ifneq ($(wildcard $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch),)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700266 @echo --- patching ---
Damjan Marion2ce7f982017-01-09 20:24:50 +0100267 @for f in $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch ; do \
Ed Warnickecb9cada2015-12-08 15:45:58 -0700268 echo Applying patch: $$(basename $$f) ; \
269 patch -p1 -d $(DPDK_SOURCE) < $$f ; \
270 done
Damjan Marion0df78dd2016-03-29 22:37:02 +0200271endif
Ed Warnickecb9cada2015-12-08 15:45:58 -0700272 @touch $@
273
274.PHONY: patch
275patch: $(B)/.patch.ok
276
277$(B)/.config.ok: $(B)/.patch.ok $(B)/custom-config
278 @make $(DPDK_MAKE_ARGS) config
279 @touch $@
280
281.PHONY: config
282config: $(B)/.config.ok
283
Sergio Gonzalez Monroy6184db32017-10-27 08:58:38 +0100284.PHONY: build-nasm
285build-nasm:
286 cd $(NASM_SOURCE) && sh configure && make -j
287
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100288.PHONY: build-ipsec-mb
289build-ipsec-mb:
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000290 mkdir -p $(I)/lib/
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100291 # Do not build GCM stuff if we are building ISA_L
Damjan Marion07510dd2018-02-15 11:59:04 +0100292 make -C $(AESNIMB_LIB_SOURCE) -j \
Damjan Marion66e0ce82018-02-21 11:37:24 +0100293 EXTRA_CFLAGS=-fPIC NASM=$(NASM_SOURCE)/nasm
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000294 cp $(AESNIMB_LIB_SOURCE)/libIPSec_MB.a $(I)/lib/
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100295
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100296.PHONY: build-dpdk
297build-dpdk:
298 @if [ ! -e $(B)/.config.ok ] ; then echo 'Please run "make config" first' && false ; fi
Sergio Gonzalez Monroyfa80f2e2017-03-07 14:39:29 +0000299 @make $(DPDK_MAKE_ARGS) install
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100300
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100301# Order matters
302ifeq ($(AESNI),y)
Sergio Gonzalez Monroy6184db32017-10-27 08:58:38 +0100303BUILD_TARGETS += build-nasm
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100304BUILD_TARGETS += build-ipsec-mb
305endif
Sergio Gonzalez Monroyacdc3062017-08-24 14:09:17 +0100306BUILD_TARGETS += build-dpdk
307
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100308$(B)/.build.ok: $(BUILD_TARGETS)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700309 @touch $@
310
311.PHONY: build
312build: $(B)/.build.ok
313
Damjan Marion2ce7f982017-01-09 20:24:50 +0100314.PHONY: install
315install: $(B)/.build.ok
316
Ed Warnickecb9cada2015-12-08 15:45:58 -0700317.PHONY: clean
318clean:
319 @rm -rf $(B) $(I)
320
Damjan Marion2ce7f982017-01-09 20:24:50 +0100321##############################################################################
322# .deb packaging
323##############################################################################
324
325DEB_ARCH=$(shell dpkg --print-architecture 2> /dev/null)
326DEV_DEB=vpp-dpdk-dev_$(DPDK_VERSION)-$(PKG_SUFFIX)_$(DEB_ARCH).deb
327INSTALLED_DEB_VER=$(shell dpkg-query --showformat='$${Version}' --show vpp-dpdk-dev 2> /dev/null)
328
329.PHONY: build-deb install-deb check-deb
330
331deb/debian/changelog: Makefile
332 @echo "vpp-dpdk ($(DPDK_VERSION)-$(PKG_SUFFIX)) unstable; urgency=low" > $@
333 @echo "" >> $@
334 @echo " * DPDK Release $(DPDK_VERSION)" >> $@
335 @echo "" >> $@
336 @echo " -- VPP Dev <vpp-dev@lists.fd.io> $(shell date -R)" >> $@
337
338$(DEV_DEB): deb/debian/changelog
339 @cd deb && dpkg-buildpackage -b -uc -us
340 git clean -fdx deb
341
342build-deb: $(DEV_DEB)
343
344install-deb:
345ifneq ($(INSTALLED_DEB_VER),$(DPDK_VERSION)-$(PKG_SUFFIX))
Ed Warnicke798150b2017-11-08 13:39:31 -0700346 @echo "=========================================================="
347 @echo " Out of date DPDK package installed."
348 @echo " Installed: $(INSTALLED_DEB_VER)"
349 @echo " Needed: $(DPDK_VERSION)-$(PKG_SUFFIX)"
350 @echo "=========================================================="
Damjan Marion2ce7f982017-01-09 20:24:50 +0100351 @make $(DEV_DEB)
352 @sudo dpkg -i $(DEV_DEB)
353else
354 @echo "=========================================================="
355 @echo " Up-to-date DPDK package already installed"
356 @echo "=========================================================="
357endif
358
359check-deb:
360ifneq ($(INSTALLED_DEB_VER),$(DPDK_VERSION)-$(PKG_SUFFIX))
361 @echo "=========================================================="
362 @echo " Outdated DPDK package detected:"
363 @echo " Installed: vpp-dpdk-dev $(INSTALLED_DEB_VER)"
364 @echo " Current: vpp-dpdk-dev $(DPDK_VERSION)-$(PKG_SUFFIX)"
365 @echo ""
366 @echo " Please upgrade by invoking 'make dpdk-install-dev'"
367 @echo " from the top level directory."
368 @echo "=========================================================="
369endif
370
371##############################################################################
372# .rpm packaging
373##############################################################################
374
375RPM_ARCH=$(shell rpm --eval "%{_arch}" 2> /dev/null)
376DEV_RPM=vpp-dpdk-devel-$(DPDK_VERSION)-$(PKG_SUFFIX).$(RPM_ARCH).rpm
Damjan Marion248968b2017-01-20 23:59:28 +0100377INSTALLED_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 +0100378
379.PHONY: build-rpm install-rpm check-rpm
380
381$(DEV_RPM): Makefile rpm/vpp-dpdk.spec
382 @rpmbuild -bb \
383 --define "_topdir $(CURDIR)/rpm" \
384 --define "_version $(DPDK_VERSION)" \
385 --define "_release $(PKG_SUFFIX)" \
386 $(CURDIR)/rpm/vpp-dpdk.spec
387 mv rpm/RPMS/$(RPM_ARCH)/*.rpm .
388 git clean -fdx rpm
389
390build-rpm: $(DEV_RPM)
391
392install-rpm:
393ifneq ($(INSTALLED_RPM_VER),$(DPDK_VERSION)-$(PKG_SUFFIX))
Sergio Gonzalez Monroy3b12cdc2017-06-06 15:29:16 +0100394 @$(MAKE) $(DEV_RPM)
Damjan Marion2ce7f982017-01-09 20:24:50 +0100395 sudo rpm -Uih $(DEV_RPM)
396else
397 @echo "=========================================================="
398 @echo " Up-to-date DPDK package already installed"
399 @echo "=========================================================="
400endif
401
402check-rpm:
403ifneq ($(INSTALLED_RPM_VER),$(DPDK_VERSION)-$(PKG_SUFFIX))
404 @echo "=========================================================="
405 @echo " Outdated DPDK package detected:"
406 @echo " Installed: vpp-dpdk-devel $(INSTALLED_RPM_VER)"
407 @echo " Current: vpp-dpdk-devel $(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# ebuild support
416##############################################################################
417
418.PHONY: ebuild-build ebuild-install
419
420ebuild-build:
421ifeq ($(INSTALLED_DEB_VER)$(INSTALLED_RPM_VER),)
422 @echo "=========================================================="
423 @echo "Building DPDK from source. Consider installing development"
424 @echo "package by invoking 'make dpdk-install-dev' from the"
425 @echo "top level directory"
426 @echo "=========================================================="
427 make config
428else
429ifneq ($(INSTALLED_DEB_VER),)
430 make check-deb
431endif
432ifneq ($(INSTALLED_RPM_VER),)
433 make check-rpm
434endif
435endif
436
437ebuild-install:
438ifeq ($(INSTALLED_DEB_VER)$(INSTALLED_RPM_VER),)
439 make install
440endif