blob: 82804f20db936691f25c6eeaaed556986cb6236f [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
21DPDK_MARCH ?= native
Damjan Marion1c80e832016-05-11 23:07:18 +020022DPDK_TUNE ?= generic
Ed Warnickecb9cada2015-12-08 15:45:58 -070023DPDK_DEBUG ?= n
Damjan Marion696f1ad2016-12-23 22:42:41 +010024DPDK_CRYPTO_PMD ?= n
25DPDK_MLX5_PMD ?= n
Ed Warnickecb9cada2015-12-08 15:45:58 -070026
27B := $(DPDK_BUILD_DIR)
28I := $(DPDK_INSTALL_DIR)
Damjan Marione0a2d172016-11-08 20:39:21 +010029DPDK_VERSION ?= 16.11
Thomas Monjalon96e10b52016-06-02 14:52:32 +020030DPDK_BASE_URL ?= http://fast.dpdk.org/rel
31DPDK_TARBALL := dpdk-$(DPDK_VERSION).tar.xz
Damjan Mariondab123b2016-03-29 16:43:58 +020032DPDK_TAR_URL := $(DPDK_BASE_URL)/$(DPDK_TARBALL)
Sachin734d2912016-08-02 11:35:48 +053033DPDK_16.07_TARBALL_MD5_CKSUM := 690a2bb570103e58d12f9806e8bf21be
Damjan Mariond4895d52016-11-14 21:45:20 +010034DPDK_16.11_TARBALL_MD5_CKSUM := 06c1c577795360719d0b4fafaeee21e9
Ed Warnickecb9cada2015-12-08 15:45:58 -070035DPDK_SOURCE := $(B)/dpdk-$(DPDK_VERSION)
Damjan Marione39a7b82016-04-26 14:54:57 +020036
37ifneq (,$(findstring clang,$(CC)))
38DPDK_CC=clang
39else
40DPDK_CC=gcc
41endif
42
Christophe Fontaine737547e2016-05-11 08:40:33 +000043
44ifeq (,$(DPDK_TARGET))
Damjan Marione39a7b82016-04-26 14:54:57 +020045DPDK_TARGET := x86_64-native-linuxapp-$(DPDK_CC)
Christophe Fontaine737547e2016-05-11 08:40:33 +000046endif
47
Ed Warnickecb9cada2015-12-08 15:45:58 -070048JOBS := $(shell grep processor /proc/cpuinfo | wc -l)
49
50# compiler/linker custom arguments
51DPDK_CPU_CFLAGS := -pie -fPIC
Jean-Mickael Guerin966a8b82016-03-02 19:05:05 +010052DPDK_CPU_LDFLAGS :=
Ed Warnickecb9cada2015-12-08 15:45:58 -070053DPDK_EXTRA_LDFLAGS := -g
54
55ifeq ($(DPDK_DEBUG),n)
Damjan Marion1c80e832016-05-11 23:07:18 +020056DPDK_EXTRA_CFLAGS := -g -mtune=$(DPDK_TUNE)
Ed Warnickecb9cada2015-12-08 15:45:58 -070057else
Damjan Marione39a7b82016-04-26 14:54:57 +020058DPDK_EXTRA_CFLAGS := -g -O0
Ed Warnickecb9cada2015-12-08 15:45:58 -070059endif
60
61# translate gcc march values to DPDK arch
62ifeq ($(DPDK_MARCH),native)
63DPDK_MACHINE:=native # autodetect host CPU
64else ifeq ($(DPDK_MARCH),corei7)
65DPDK_MACHINE:=nhm # Nehalem / Westmere
66else ifeq ($(DPDK_MARCH),corei7-avx)
67DPDK_MACHINE:=snb # Sandy Bridge
68else ifeq ($(DPDK_MARCH),core-avx-i)
69DPDK_MACHINE:=ivb # Ivy Bridge
70else ifeq ($(DPDK_MARCH),core-avx2)
71DPDK_MACHINE:=hsw # Haswell
Christophe Fontaine737547e2016-05-11 08:40:33 +000072else ifeq ($(DPDK_MARCH),armv7a)
73DPDK_MACHINE:=armv7a # ARMv7
74else ifeq ($(DPDK_MARCH),armv8a)
75DPDK_MACHINE:=armv8a # ARMv8
Ed Warnickecb9cada2015-12-08 15:45:58 -070076else
77$(error Unknown DPDK_MARCH)
78endif
79
80# assemble DPDK make arguments
81DPDK_MAKE_ARGS := -C $(DPDK_SOURCE) -j $(JOBS) \
82 T=$(DPDK_TARGET) \
83 RTE_CONFIG_TEMPLATE=../custom-config \
84 RTE_OUTPUT=$(I) \
85 EXTRA_CFLAGS="$(DPDK_EXTRA_CFLAGS)" \
86 EXTRA_LDFLAGS="$(DPDK_EXTRA_LDFLAGS)" \
87 CPU_CFLAGS="$(DPDK_CPU_CFLAGS)" \
Christophe Fontaine737547e2016-05-11 08:40:33 +000088 CPU_LDFLAGS="$(DPDK_CPU_LDFLAGS)" \
89 $(DPDK_MAKE_EXTRA_ARGS)
Ed Warnickecb9cada2015-12-08 15:45:58 -070090
91DPDK_SOURCE_FILES := $(shell [ -e $(DPDK_SOURCE) ] && find $(DPDK_SOURCE) -name "*.[chS]")
92
93define set
94@if grep -q CONFIG_$1 $@ ; \
95 then sed -i -e 's/.*\(CONFIG_$1=\).*/\1$2/' $@ ; \
96 else echo CONFIG_$1=$2 >> $@ ; \
97fi
98endef
99
100all: build
101
102$(B)/custom-config: $(B)/.patch.ok Makefile
Damjan Marion106f0ed2016-04-26 10:44:28 +0200103 @echo --- generating custom config from $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) ---
104 @cpp -undef -ffreestanding -x assembler-with-cpp $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) $@
Ed Warnickecb9cada2015-12-08 15:45:58 -0700105 $(call set,RTE_MACHINE,$(DPDK_MACHINE))
Ed Warnickecb9cada2015-12-08 15:45:58 -0700106 @# modify options
Damjan Marion13f07182016-02-05 06:44:54 -0800107 $(call set,RTE_MAX_LCORE,256)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700108 $(call set,RTE_PKTMBUF_HEADROOM,$(DPDK_PKTMBUF_HEADROOM))
109 $(call set,RTE_LIBEAL_USE_HPET,y)
110 $(call set,RTE_BUILD_COMBINE_LIBS,y)
111 $(call set,RTE_LIBRTE_I40E_16BYTE_RX_DESC,y)
Damjan Mariona1556802016-06-26 20:12:40 +0200112 $(call set,RTE_PCI_CONFIG,y)
113 $(call set,RTE_PCI_EXTENDED_TAG,"on")
114 $(call set,RTE_PCI_MAX_READ_REQUEST_SIZE,4096)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700115 @# enable debug init for device drivers
116 $(call set,RTE_LIBRTE_I40E_DEBUG_INIT,$(DPDK_DEBUG))
117 $(call set,RTE_LIBRTE_IXGBE_DEBUG_INIT,$(DPDK_DEBUG))
118 $(call set,RTE_LIBRTE_E1000_DEBUG_INIT,$(DPDK_DEBUG))
119 $(call set,RTE_LIBRTE_VIRTIO_DEBUG_INIT,$(DPDK_DEBUG))
120 $(call set,RTE_LIBRTE_VMXNET3_DEBUG_INIT,$(DPDK_DEBUG))
John Lod9bf9ab2016-02-25 11:17:55 -0500121 $(call set,RTE_LIBRTE_PMD_BOND,y)
122 $(call set,RTE_LIBRTE_IP_FRAG,y)
Sergio Gonzalez Monroya10f62b2016-11-25 13:36:12 +0000123 $(call set,RTE_LIBRTE_PMD_AESNI_MB,$(DPDK_CRYPTO_PMD))
124 $(call set,RTE_LIBRTE_PMD_AESNI_GCM,$(DPDK_CRYPTO_PMD))
125 $(call set,RTE_LIBRTE_PMD_QAT,$(DPDK_CRYPTO_PMD))
Damjan Marion696f1ad2016-12-23 22:42:41 +0100126 $(call set,RTE_LIBRTE_MLX5_PMD,$(DPDK_MLX5_PMD))
Ed Warnickecb9cada2015-12-08 15:45:58 -0700127 @# not needed
Ed Warnickecb9cada2015-12-08 15:45:58 -0700128 $(call set,RTE_LIBRTE_TIMER,n)
129 $(call set,RTE_LIBRTE_CFGFILE,n)
130 $(call set,RTE_LIBRTE_LPM,n)
131 $(call set,RTE_LIBRTE_ACL,n)
132 $(call set,RTE_LIBRTE_POWER,n)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700133 $(call set,RTE_LIBRTE_DISTRIBUTOR,n)
134 $(call set,RTE_LIBRTE_REORDER,n)
135 $(call set,RTE_LIBRTE_PORT,n)
136 $(call set,RTE_LIBRTE_TABLE,n)
137 $(call set,RTE_LIBRTE_PIPELINE,n)
138 $(call set,RTE_KNI_KMOD,n)
Damjan Marion68fda1c2017-01-01 16:53:22 +0100139 $(call set,RTE_EAL_IGB_UIO,n)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700140 @rm -f .config.ok
141
142$(CURDIR)/$(DPDK_TARBALL):
143 @mkdir -p $(B)
144 @if [ -e $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) ] ; \
145 then cp $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) $(CURDIR) ; \
146 else curl -o $(CURDIR)/$(DPDK_TARBALL) -LO $(DPDK_TAR_URL) ; \
147 fi
148 @rm -f $(B)/.download.ok
149
150$(B)/.download.ok: $(CURDIR)/$(DPDK_TARBALL)
151 @openssl md5 $< | cut -f 2 -d " " - > $(B)/$(DPDK_TARBALL).md5sum
Damjan Marionbce6b6a2015-12-16 04:27:37 +0100152 @([ "$$(<$(B)/$(DPDK_TARBALL).md5sum)" = "$(DPDK_$(DPDK_VERSION)_TARBALL_MD5_CKSUM)" ] || \
Ed Warnickecb9cada2015-12-08 15:45:58 -0700153 ( echo "Bad Checksum! Please remove $< and retry" && \
154 rm $(B)/$(DPDK_TARBALL).md5sum && false ))
155 @touch $@
156
157.PHONY: download
158download: $(B)/.download.ok
159
160$(B)/.extract.ok: $(B)/.download.ok
161 @echo --- extracting $(DPDK_TARBALL) ---
Thomas Monjalon96e10b52016-06-02 14:52:32 +0200162 @tar --directory $(B) --extract --file $(CURDIR)/$(DPDK_TARBALL)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700163 @touch $@
164
165.PHONY: extract
166extract: $(B)/.extract.ok
167
168$(B)/.patch.ok: $(B)/.extract.ok
Damjan Marion0df78dd2016-03-29 22:37:02 +0200169ifneq ($(wildcard $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch),)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700170 @echo --- patching ---
171 for f in $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch ; do \
172 echo Applying patch: $$(basename $$f) ; \
173 patch -p1 -d $(DPDK_SOURCE) < $$f ; \
174 done
Damjan Marion0df78dd2016-03-29 22:37:02 +0200175endif
Ed Warnickecb9cada2015-12-08 15:45:58 -0700176 @touch $@
177
178.PHONY: patch
179patch: $(B)/.patch.ok
180
181$(B)/.config.ok: $(B)/.patch.ok $(B)/custom-config
182 @make $(DPDK_MAKE_ARGS) config
183 @touch $@
184
185.PHONY: config
186config: $(B)/.config.ok
187
188$(B)/.build.ok: $(DPDK_SOURCE_FILES)
189 @if [ ! -e $(B)/.config.ok ] ; then echo 'Please run "make config" first' && false ; fi
190 @make $(DPDK_MAKE_ARGS) install
191 @dkms/create_deb_manifest.sh $(DPDK_VERSION) $(subst $(realpath ..)/,,$(B))
192 @touch $@
193
194.PHONY: build
195build: $(B)/.build.ok
196
197.PHONY: clean
198clean:
199 @rm -rf $(B) $(I)
200