blob: d73ddb62e2eac08dc8234fa113d87ce58d4e2b09 [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
24
25B := $(DPDK_BUILD_DIR)
26I := $(DPDK_INSTALL_DIR)
Dave Barach3389bbc2016-08-02 13:31:31 -040027DPDK_VERSION ?= 16.07
Thomas Monjalon96e10b52016-06-02 14:52:32 +020028DPDK_BASE_URL ?= http://fast.dpdk.org/rel
29DPDK_TARBALL := dpdk-$(DPDK_VERSION).tar.xz
Damjan Mariondab123b2016-03-29 16:43:58 +020030DPDK_TAR_URL := $(DPDK_BASE_URL)/$(DPDK_TARBALL)
Thomas Monjalon96e10b52016-06-02 14:52:32 +020031DPDK_16.04_TARBALL_MD5_CKSUM := d1f82e7d7589b3b2f623c155442b8306
Sachin734d2912016-08-02 11:35:48 +053032DPDK_16.07_TARBALL_MD5_CKSUM := 690a2bb570103e58d12f9806e8bf21be
Ed Warnickecb9cada2015-12-08 15:45:58 -070033DPDK_SOURCE := $(B)/dpdk-$(DPDK_VERSION)
Damjan Marione39a7b82016-04-26 14:54:57 +020034
35ifneq (,$(findstring clang,$(CC)))
36DPDK_CC=clang
37else
38DPDK_CC=gcc
39endif
40
Christophe Fontaine737547e2016-05-11 08:40:33 +000041
42ifeq (,$(DPDK_TARGET))
Damjan Marione39a7b82016-04-26 14:54:57 +020043DPDK_TARGET := x86_64-native-linuxapp-$(DPDK_CC)
Christophe Fontaine737547e2016-05-11 08:40:33 +000044endif
45
Ed Warnickecb9cada2015-12-08 15:45:58 -070046JOBS := $(shell grep processor /proc/cpuinfo | wc -l)
47
48# compiler/linker custom arguments
49DPDK_CPU_CFLAGS := -pie -fPIC
Jean-Mickael Guerin966a8b82016-03-02 19:05:05 +010050DPDK_CPU_LDFLAGS :=
Ed Warnickecb9cada2015-12-08 15:45:58 -070051DPDK_EXTRA_LDFLAGS := -g
52
53ifeq ($(DPDK_DEBUG),n)
Damjan Marion1c80e832016-05-11 23:07:18 +020054DPDK_EXTRA_CFLAGS := -g -mtune=$(DPDK_TUNE)
Ed Warnickecb9cada2015-12-08 15:45:58 -070055else
Damjan Marione39a7b82016-04-26 14:54:57 +020056DPDK_EXTRA_CFLAGS := -g -O0
Ed Warnickecb9cada2015-12-08 15:45:58 -070057endif
58
59# translate gcc march values to DPDK arch
60ifeq ($(DPDK_MARCH),native)
61DPDK_MACHINE:=native # autodetect host CPU
62else ifeq ($(DPDK_MARCH),corei7)
63DPDK_MACHINE:=nhm # Nehalem / Westmere
64else ifeq ($(DPDK_MARCH),corei7-avx)
65DPDK_MACHINE:=snb # Sandy Bridge
66else ifeq ($(DPDK_MARCH),core-avx-i)
67DPDK_MACHINE:=ivb # Ivy Bridge
68else ifeq ($(DPDK_MARCH),core-avx2)
69DPDK_MACHINE:=hsw # Haswell
Christophe Fontaine737547e2016-05-11 08:40:33 +000070else ifeq ($(DPDK_MARCH),armv7a)
71DPDK_MACHINE:=armv7a # ARMv7
72else ifeq ($(DPDK_MARCH),armv8a)
73DPDK_MACHINE:=armv8a # ARMv8
Ed Warnickecb9cada2015-12-08 15:45:58 -070074else
75$(error Unknown DPDK_MARCH)
76endif
77
78# assemble DPDK make arguments
79DPDK_MAKE_ARGS := -C $(DPDK_SOURCE) -j $(JOBS) \
80 T=$(DPDK_TARGET) \
81 RTE_CONFIG_TEMPLATE=../custom-config \
82 RTE_OUTPUT=$(I) \
83 EXTRA_CFLAGS="$(DPDK_EXTRA_CFLAGS)" \
84 EXTRA_LDFLAGS="$(DPDK_EXTRA_LDFLAGS)" \
85 CPU_CFLAGS="$(DPDK_CPU_CFLAGS)" \
Christophe Fontaine737547e2016-05-11 08:40:33 +000086 CPU_LDFLAGS="$(DPDK_CPU_LDFLAGS)" \
87 $(DPDK_MAKE_EXTRA_ARGS)
Ed Warnickecb9cada2015-12-08 15:45:58 -070088
89DPDK_SOURCE_FILES := $(shell [ -e $(DPDK_SOURCE) ] && find $(DPDK_SOURCE) -name "*.[chS]")
90
91define set
92@if grep -q CONFIG_$1 $@ ; \
93 then sed -i -e 's/.*\(CONFIG_$1=\).*/\1$2/' $@ ; \
94 else echo CONFIG_$1=$2 >> $@ ; \
95fi
96endef
97
98all: build
99
100$(B)/custom-config: $(B)/.patch.ok Makefile
Damjan Marion106f0ed2016-04-26 10:44:28 +0200101 @echo --- generating custom config from $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) ---
102 @cpp -undef -ffreestanding -x assembler-with-cpp $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) $@
Ed Warnickecb9cada2015-12-08 15:45:58 -0700103 $(call set,RTE_MACHINE,$(DPDK_MACHINE))
Ed Warnickecb9cada2015-12-08 15:45:58 -0700104 @# modify options
Damjan Marion13f07182016-02-05 06:44:54 -0800105 $(call set,RTE_MAX_LCORE,256)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700106 $(call set,RTE_PKTMBUF_HEADROOM,$(DPDK_PKTMBUF_HEADROOM))
107 $(call set,RTE_LIBEAL_USE_HPET,y)
108 $(call set,RTE_BUILD_COMBINE_LIBS,y)
109 $(call set,RTE_LIBRTE_I40E_16BYTE_RX_DESC,y)
Damjan Mariona1556802016-06-26 20:12:40 +0200110 $(call set,RTE_PCI_CONFIG,y)
111 $(call set,RTE_PCI_EXTENDED_TAG,"on")
112 $(call set,RTE_PCI_MAX_READ_REQUEST_SIZE,4096)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700113 @# enable debug init for device drivers
114 $(call set,RTE_LIBRTE_I40E_DEBUG_INIT,$(DPDK_DEBUG))
115 $(call set,RTE_LIBRTE_IXGBE_DEBUG_INIT,$(DPDK_DEBUG))
116 $(call set,RTE_LIBRTE_E1000_DEBUG_INIT,$(DPDK_DEBUG))
117 $(call set,RTE_LIBRTE_VIRTIO_DEBUG_INIT,$(DPDK_DEBUG))
118 $(call set,RTE_LIBRTE_VMXNET3_DEBUG_INIT,$(DPDK_DEBUG))
John Lod9bf9ab2016-02-25 11:17:55 -0500119 $(call set,RTE_LIBRTE_PMD_BOND,y)
120 $(call set,RTE_LIBRTE_IP_FRAG,y)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700121 @# not needed
Ed Warnickecb9cada2015-12-08 15:45:58 -0700122 $(call set,RTE_LIBRTE_TIMER,n)
123 $(call set,RTE_LIBRTE_CFGFILE,n)
124 $(call set,RTE_LIBRTE_LPM,n)
125 $(call set,RTE_LIBRTE_ACL,n)
126 $(call set,RTE_LIBRTE_POWER,n)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700127 $(call set,RTE_LIBRTE_DISTRIBUTOR,n)
128 $(call set,RTE_LIBRTE_REORDER,n)
129 $(call set,RTE_LIBRTE_PORT,n)
130 $(call set,RTE_LIBRTE_TABLE,n)
131 $(call set,RTE_LIBRTE_PIPELINE,n)
132 $(call set,RTE_KNI_KMOD,n)
133 @rm -f .config.ok
134
135$(CURDIR)/$(DPDK_TARBALL):
136 @mkdir -p $(B)
137 @if [ -e $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) ] ; \
138 then cp $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) $(CURDIR) ; \
139 else curl -o $(CURDIR)/$(DPDK_TARBALL) -LO $(DPDK_TAR_URL) ; \
140 fi
141 @rm -f $(B)/.download.ok
142
143$(B)/.download.ok: $(CURDIR)/$(DPDK_TARBALL)
144 @openssl md5 $< | cut -f 2 -d " " - > $(B)/$(DPDK_TARBALL).md5sum
Damjan Marionbce6b6a2015-12-16 04:27:37 +0100145 @([ "$$(<$(B)/$(DPDK_TARBALL).md5sum)" = "$(DPDK_$(DPDK_VERSION)_TARBALL_MD5_CKSUM)" ] || \
Ed Warnickecb9cada2015-12-08 15:45:58 -0700146 ( echo "Bad Checksum! Please remove $< and retry" && \
147 rm $(B)/$(DPDK_TARBALL).md5sum && false ))
148 @touch $@
149
150.PHONY: download
151download: $(B)/.download.ok
152
153$(B)/.extract.ok: $(B)/.download.ok
154 @echo --- extracting $(DPDK_TARBALL) ---
Thomas Monjalon96e10b52016-06-02 14:52:32 +0200155 @tar --directory $(B) --extract --file $(CURDIR)/$(DPDK_TARBALL)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700156 @touch $@
157
158.PHONY: extract
159extract: $(B)/.extract.ok
160
161$(B)/.patch.ok: $(B)/.extract.ok
Damjan Marion0df78dd2016-03-29 22:37:02 +0200162ifneq ($(wildcard $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch),)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700163 @echo --- patching ---
164 for f in $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch ; do \
165 echo Applying patch: $$(basename $$f) ; \
166 patch -p1 -d $(DPDK_SOURCE) < $$f ; \
167 done
Damjan Marion0df78dd2016-03-29 22:37:02 +0200168endif
Ed Warnickecb9cada2015-12-08 15:45:58 -0700169 @touch $@
170
171.PHONY: patch
172patch: $(B)/.patch.ok
173
174$(B)/.config.ok: $(B)/.patch.ok $(B)/custom-config
175 @make $(DPDK_MAKE_ARGS) config
176 @touch $@
177
178.PHONY: config
179config: $(B)/.config.ok
180
181$(B)/.build.ok: $(DPDK_SOURCE_FILES)
182 @if [ ! -e $(B)/.config.ok ] ; then echo 'Please run "make config" first' && false ; fi
183 @make $(DPDK_MAKE_ARGS) install
184 @dkms/create_deb_manifest.sh $(DPDK_VERSION) $(subst $(realpath ..)/,,$(B))
185 @touch $@
186
187.PHONY: build
188build: $(B)/.build.ok
189
190.PHONY: clean
191clean:
192 @rm -rf $(B) $(I)
193