blob: 307faf067deb670557bb71e79e15f1e90c1c2a69 [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
19DPDK_PKTMBUF_HEADROOM ?= 256
20DPDK_DOWNLOAD_DIR ?= $(HOME)/Downloads
21DPDK_MARCH ?= native
22DPDK_DEBUG ?= n
23
24B := $(DPDK_BUILD_DIR)
25I := $(DPDK_INSTALL_DIR)
Damjan Marioneec5a512016-02-02 15:37:58 +010026DPDK_VERSION ?= 2.2.0
Ed Warnickecb9cada2015-12-08 15:45:58 -070027DPDK_TARBALL := dpdk-$(DPDK_VERSION).tar.gz
28DPDK_TAR_URL := http://dpdk.org/browse/dpdk/snapshot/$(DPDK_TARBALL)
Damjan Marionbce6b6a2015-12-16 04:27:37 +010029DPDK_2.1.0_TARBALL_MD5_CKSUM := 205a0d12bfd6eb717d57506272f43519
30DPDK_2.2.0_TARBALL_MD5_CKSUM := 22e2fd68cd5504f43fe9a5a6fd6dd938
Ed Warnickecb9cada2015-12-08 15:45:58 -070031DPDK_SOURCE := $(B)/dpdk-$(DPDK_VERSION)
32DPDK_TARGET := x86_64-native-linuxapp-gcc
33JOBS := $(shell grep processor /proc/cpuinfo | wc -l)
34
35# compiler/linker custom arguments
36DPDK_CPU_CFLAGS := -pie -fPIC
37DPDK_CPU_LDFLAGS := -pie -fPIC
38DPDK_EXTRA_LDFLAGS := -g
39
40ifeq ($(DPDK_DEBUG),n)
41DPDK_EXTRA_CFLAGS := -g
42else
43DPDK_EXTRA_CFLAGS := -g -O0
44endif
45
46# translate gcc march values to DPDK arch
47ifeq ($(DPDK_MARCH),native)
48DPDK_MACHINE:=native # autodetect host CPU
49else ifeq ($(DPDK_MARCH),corei7)
50DPDK_MACHINE:=nhm # Nehalem / Westmere
51else ifeq ($(DPDK_MARCH),corei7-avx)
52DPDK_MACHINE:=snb # Sandy Bridge
53else ifeq ($(DPDK_MARCH),core-avx-i)
54DPDK_MACHINE:=ivb # Ivy Bridge
55else ifeq ($(DPDK_MARCH),core-avx2)
56DPDK_MACHINE:=hsw # Haswell
57else
58$(error Unknown DPDK_MARCH)
59endif
60
61# assemble DPDK make arguments
62DPDK_MAKE_ARGS := -C $(DPDK_SOURCE) -j $(JOBS) \
63 T=$(DPDK_TARGET) \
64 RTE_CONFIG_TEMPLATE=../custom-config \
65 RTE_OUTPUT=$(I) \
66 EXTRA_CFLAGS="$(DPDK_EXTRA_CFLAGS)" \
67 EXTRA_LDFLAGS="$(DPDK_EXTRA_LDFLAGS)" \
68 CPU_CFLAGS="$(DPDK_CPU_CFLAGS)" \
69 CPU_LDFLAGS="$(DPDK_CPU_LDFLAGS)"
70
71DPDK_SOURCE_FILES := $(shell [ -e $(DPDK_SOURCE) ] && find $(DPDK_SOURCE) -name "*.[chS]")
72
73define set
74@if grep -q CONFIG_$1 $@ ; \
75 then sed -i -e 's/.*\(CONFIG_$1=\).*/\1$2/' $@ ; \
76 else echo CONFIG_$1=$2 >> $@ ; \
77fi
78endef
79
80all: build
81
82$(B)/custom-config: $(B)/.patch.ok Makefile
83 @echo --- generating custom config from $(DPDK_SOURCE)/config/common_linuxapp ---
84 @cp $(DPDK_SOURCE)/config/common_linuxapp $@
85 $(call set,RTE_MACHINE,$(DPDK_MACHINE))
86 $(call set,RTE_ARCH,"x86_64")
87 $(call set,RTE_ARCH_X86_64,y)
88 $(call set,RTE_ARCH_64,y)
89 $(call set,RTE_TOOLCHAIN_GCC,y)
90 $(call set,RTE_TOOLCHAIN,"gcc")
91 @# modify options
Damjan Marion13f07182016-02-05 06:44:54 -080092 $(call set,RTE_MAX_LCORE,256)
Ed Warnickecb9cada2015-12-08 15:45:58 -070093 $(call set,RTE_PKTMBUF_HEADROOM,$(DPDK_PKTMBUF_HEADROOM))
94 $(call set,RTE_LIBEAL_USE_HPET,y)
95 $(call set,RTE_BUILD_COMBINE_LIBS,y)
96 $(call set,RTE_LIBRTE_I40E_16BYTE_RX_DESC,y)
97 $(call set,RTE_LIBRTE_I40E_ITR_INTERVAL,16)
98 @# enable debug init for device drivers
99 $(call set,RTE_LIBRTE_I40E_DEBUG_INIT,$(DPDK_DEBUG))
100 $(call set,RTE_LIBRTE_IXGBE_DEBUG_INIT,$(DPDK_DEBUG))
101 $(call set,RTE_LIBRTE_E1000_DEBUG_INIT,$(DPDK_DEBUG))
102 $(call set,RTE_LIBRTE_VIRTIO_DEBUG_INIT,$(DPDK_DEBUG))
103 $(call set,RTE_LIBRTE_VMXNET3_DEBUG_INIT,$(DPDK_DEBUG))
John Lod9bf9ab2016-02-25 11:17:55 -0500104 $(call set,RTE_LIBRTE_PMD_BOND,y)
105 $(call set,RTE_LIBRTE_IP_FRAG,y)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700106 @# not needed
Ed Warnickecb9cada2015-12-08 15:45:58 -0700107 $(call set,RTE_LIBRTE_TIMER,n)
108 $(call set,RTE_LIBRTE_CFGFILE,n)
109 $(call set,RTE_LIBRTE_LPM,n)
110 $(call set,RTE_LIBRTE_ACL,n)
111 $(call set,RTE_LIBRTE_POWER,n)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700112 $(call set,RTE_LIBRTE_DISTRIBUTOR,n)
113 $(call set,RTE_LIBRTE_REORDER,n)
114 $(call set,RTE_LIBRTE_PORT,n)
115 $(call set,RTE_LIBRTE_TABLE,n)
116 $(call set,RTE_LIBRTE_PIPELINE,n)
117 $(call set,RTE_KNI_KMOD,n)
118 @rm -f .config.ok
119
120$(CURDIR)/$(DPDK_TARBALL):
121 @mkdir -p $(B)
122 @if [ -e $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) ] ; \
123 then cp $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) $(CURDIR) ; \
124 else curl -o $(CURDIR)/$(DPDK_TARBALL) -LO $(DPDK_TAR_URL) ; \
125 fi
126 @rm -f $(B)/.download.ok
127
128$(B)/.download.ok: $(CURDIR)/$(DPDK_TARBALL)
129 @openssl md5 $< | cut -f 2 -d " " - > $(B)/$(DPDK_TARBALL).md5sum
Damjan Marionbce6b6a2015-12-16 04:27:37 +0100130 @([ "$$(<$(B)/$(DPDK_TARBALL).md5sum)" = "$(DPDK_$(DPDK_VERSION)_TARBALL_MD5_CKSUM)" ] || \
Ed Warnickecb9cada2015-12-08 15:45:58 -0700131 ( echo "Bad Checksum! Please remove $< and retry" && \
132 rm $(B)/$(DPDK_TARBALL).md5sum && false ))
133 @touch $@
134
135.PHONY: download
136download: $(B)/.download.ok
137
138$(B)/.extract.ok: $(B)/.download.ok
139 @echo --- extracting $(DPDK_TARBALL) ---
140 @tar --directory $(B) --extract --file $(CURDIR)/$(DPDK_TARBALL) --gzip
141 @touch $@
142
143.PHONY: extract
144extract: $(B)/.extract.ok
145
146$(B)/.patch.ok: $(B)/.extract.ok
147 @echo --- patching ---
148 for f in $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch ; do \
149 echo Applying patch: $$(basename $$f) ; \
150 patch -p1 -d $(DPDK_SOURCE) < $$f ; \
151 done
152 @touch $@
153
154.PHONY: patch
155patch: $(B)/.patch.ok
156
157$(B)/.config.ok: $(B)/.patch.ok $(B)/custom-config
158 @make $(DPDK_MAKE_ARGS) config
159 @touch $@
160
161.PHONY: config
162config: $(B)/.config.ok
163
164$(B)/.build.ok: $(DPDK_SOURCE_FILES)
165 @if [ ! -e $(B)/.config.ok ] ; then echo 'Please run "make config" first' && false ; fi
166 @make $(DPDK_MAKE_ARGS) install
167 @dkms/create_deb_manifest.sh $(DPDK_VERSION) $(subst $(realpath ..)/,,$(B))
168 @touch $@
169
170.PHONY: build
171build: $(B)/.build.ok
172
173.PHONY: clean
174clean:
175 @rm -rf $(B) $(I)
176