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