Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | # 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 |
| 15 | SHELL := /bin/bash |
| 16 | |
| 17 | DPDK_BUILD_DIR ?= $(CURDIR)/_build |
| 18 | DPDK_INSTALL_DIR ?= $(CURDIR)/_install |
Damjan Marion | 1901020 | 2016-03-24 17:17:47 +0100 | [diff] [blame] | 19 | DPDK_PKTMBUF_HEADROOM ?= 128 |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 20 | DPDK_DOWNLOAD_DIR ?= $(HOME)/Downloads |
| 21 | DPDK_MARCH ?= native |
Damjan Marion | 1c80e83 | 2016-05-11 23:07:18 +0200 | [diff] [blame] | 22 | DPDK_TUNE ?= generic |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 23 | DPDK_DEBUG ?= n |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 24 | DPDK_CRYPTO_PMD ?= n |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 25 | |
| 26 | B := $(DPDK_BUILD_DIR) |
| 27 | I := $(DPDK_INSTALL_DIR) |
Damjan Marion | e0a2d17 | 2016-11-08 20:39:21 +0100 | [diff] [blame] | 28 | DPDK_VERSION ?= 16.11 |
Thomas Monjalon | 96e10b5 | 2016-06-02 14:52:32 +0200 | [diff] [blame] | 29 | DPDK_BASE_URL ?= http://fast.dpdk.org/rel |
| 30 | DPDK_TARBALL := dpdk-$(DPDK_VERSION).tar.xz |
Damjan Marion | dab123b | 2016-03-29 16:43:58 +0200 | [diff] [blame] | 31 | DPDK_TAR_URL := $(DPDK_BASE_URL)/$(DPDK_TARBALL) |
Sachin | 734d291 | 2016-08-02 11:35:48 +0530 | [diff] [blame] | 32 | DPDK_16.07_TARBALL_MD5_CKSUM := 690a2bb570103e58d12f9806e8bf21be |
Damjan Marion | d4895d5 | 2016-11-14 21:45:20 +0100 | [diff] [blame] | 33 | DPDK_16.11_TARBALL_MD5_CKSUM := 06c1c577795360719d0b4fafaeee21e9 |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 34 | DPDK_SOURCE := $(B)/dpdk-$(DPDK_VERSION) |
Damjan Marion | e39a7b8 | 2016-04-26 14:54:57 +0200 | [diff] [blame] | 35 | |
| 36 | ifneq (,$(findstring clang,$(CC))) |
| 37 | DPDK_CC=clang |
| 38 | else |
| 39 | DPDK_CC=gcc |
| 40 | endif |
| 41 | |
Christophe Fontaine | 737547e | 2016-05-11 08:40:33 +0000 | [diff] [blame] | 42 | |
| 43 | ifeq (,$(DPDK_TARGET)) |
Damjan Marion | e39a7b8 | 2016-04-26 14:54:57 +0200 | [diff] [blame] | 44 | DPDK_TARGET := x86_64-native-linuxapp-$(DPDK_CC) |
Christophe Fontaine | 737547e | 2016-05-11 08:40:33 +0000 | [diff] [blame] | 45 | endif |
| 46 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 47 | JOBS := $(shell grep processor /proc/cpuinfo | wc -l) |
| 48 | |
| 49 | # compiler/linker custom arguments |
| 50 | DPDK_CPU_CFLAGS := -pie -fPIC |
Jean-Mickael Guerin | 966a8b8 | 2016-03-02 19:05:05 +0100 | [diff] [blame] | 51 | DPDK_CPU_LDFLAGS := |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 52 | DPDK_EXTRA_LDFLAGS := -g |
| 53 | |
| 54 | ifeq ($(DPDK_DEBUG),n) |
Damjan Marion | 1c80e83 | 2016-05-11 23:07:18 +0200 | [diff] [blame] | 55 | DPDK_EXTRA_CFLAGS := -g -mtune=$(DPDK_TUNE) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 56 | else |
Damjan Marion | e39a7b8 | 2016-04-26 14:54:57 +0200 | [diff] [blame] | 57 | DPDK_EXTRA_CFLAGS := -g -O0 |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 58 | endif |
| 59 | |
| 60 | # translate gcc march values to DPDK arch |
| 61 | ifeq ($(DPDK_MARCH),native) |
| 62 | DPDK_MACHINE:=native # autodetect host CPU |
| 63 | else ifeq ($(DPDK_MARCH),corei7) |
| 64 | DPDK_MACHINE:=nhm # Nehalem / Westmere |
| 65 | else ifeq ($(DPDK_MARCH),corei7-avx) |
| 66 | DPDK_MACHINE:=snb # Sandy Bridge |
| 67 | else ifeq ($(DPDK_MARCH),core-avx-i) |
| 68 | DPDK_MACHINE:=ivb # Ivy Bridge |
| 69 | else ifeq ($(DPDK_MARCH),core-avx2) |
| 70 | DPDK_MACHINE:=hsw # Haswell |
Christophe Fontaine | 737547e | 2016-05-11 08:40:33 +0000 | [diff] [blame] | 71 | else ifeq ($(DPDK_MARCH),armv7a) |
| 72 | DPDK_MACHINE:=armv7a # ARMv7 |
| 73 | else ifeq ($(DPDK_MARCH),armv8a) |
| 74 | DPDK_MACHINE:=armv8a # ARMv8 |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 75 | else |
| 76 | $(error Unknown DPDK_MARCH) |
| 77 | endif |
| 78 | |
| 79 | # assemble DPDK make arguments |
| 80 | DPDK_MAKE_ARGS := -C $(DPDK_SOURCE) -j $(JOBS) \ |
| 81 | T=$(DPDK_TARGET) \ |
| 82 | RTE_CONFIG_TEMPLATE=../custom-config \ |
| 83 | RTE_OUTPUT=$(I) \ |
| 84 | EXTRA_CFLAGS="$(DPDK_EXTRA_CFLAGS)" \ |
| 85 | EXTRA_LDFLAGS="$(DPDK_EXTRA_LDFLAGS)" \ |
| 86 | CPU_CFLAGS="$(DPDK_CPU_CFLAGS)" \ |
Christophe Fontaine | 737547e | 2016-05-11 08:40:33 +0000 | [diff] [blame] | 87 | CPU_LDFLAGS="$(DPDK_CPU_LDFLAGS)" \ |
| 88 | $(DPDK_MAKE_EXTRA_ARGS) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 89 | |
| 90 | DPDK_SOURCE_FILES := $(shell [ -e $(DPDK_SOURCE) ] && find $(DPDK_SOURCE) -name "*.[chS]") |
| 91 | |
| 92 | define set |
| 93 | @if grep -q CONFIG_$1 $@ ; \ |
| 94 | then sed -i -e 's/.*\(CONFIG_$1=\).*/\1$2/' $@ ; \ |
| 95 | else echo CONFIG_$1=$2 >> $@ ; \ |
| 96 | fi |
| 97 | endef |
| 98 | |
| 99 | all: build |
| 100 | |
| 101 | $(B)/custom-config: $(B)/.patch.ok Makefile |
Damjan Marion | 106f0ed | 2016-04-26 10:44:28 +0200 | [diff] [blame] | 102 | @echo --- generating custom config from $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) --- |
| 103 | @cpp -undef -ffreestanding -x assembler-with-cpp $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) $@ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 104 | $(call set,RTE_MACHINE,$(DPDK_MACHINE)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 105 | @# modify options |
Damjan Marion | 13f0718 | 2016-02-05 06:44:54 -0800 | [diff] [blame] | 106 | $(call set,RTE_MAX_LCORE,256) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 107 | $(call set,RTE_PKTMBUF_HEADROOM,$(DPDK_PKTMBUF_HEADROOM)) |
| 108 | $(call set,RTE_LIBEAL_USE_HPET,y) |
| 109 | $(call set,RTE_BUILD_COMBINE_LIBS,y) |
| 110 | $(call set,RTE_LIBRTE_I40E_16BYTE_RX_DESC,y) |
Damjan Marion | a155680 | 2016-06-26 20:12:40 +0200 | [diff] [blame] | 111 | $(call set,RTE_PCI_CONFIG,y) |
| 112 | $(call set,RTE_PCI_EXTENDED_TAG,"on") |
| 113 | $(call set,RTE_PCI_MAX_READ_REQUEST_SIZE,4096) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 114 | @# enable debug init for device drivers |
| 115 | $(call set,RTE_LIBRTE_I40E_DEBUG_INIT,$(DPDK_DEBUG)) |
| 116 | $(call set,RTE_LIBRTE_IXGBE_DEBUG_INIT,$(DPDK_DEBUG)) |
| 117 | $(call set,RTE_LIBRTE_E1000_DEBUG_INIT,$(DPDK_DEBUG)) |
| 118 | $(call set,RTE_LIBRTE_VIRTIO_DEBUG_INIT,$(DPDK_DEBUG)) |
| 119 | $(call set,RTE_LIBRTE_VMXNET3_DEBUG_INIT,$(DPDK_DEBUG)) |
John Lo | d9bf9ab | 2016-02-25 11:17:55 -0500 | [diff] [blame] | 120 | $(call set,RTE_LIBRTE_PMD_BOND,y) |
| 121 | $(call set,RTE_LIBRTE_IP_FRAG,y) |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 122 | $(call set,RTE_LIBRTE_PMD_AESNI_MB,$(DPDK_CRYPTO_PMD)) |
| 123 | $(call set,RTE_LIBRTE_PMD_AESNI_GCM,$(DPDK_CRYPTO_PMD)) |
| 124 | $(call set,RTE_LIBRTE_PMD_QAT,$(DPDK_CRYPTO_PMD)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 125 | @# not needed |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 126 | $(call set,RTE_LIBRTE_TIMER,n) |
| 127 | $(call set,RTE_LIBRTE_CFGFILE,n) |
| 128 | $(call set,RTE_LIBRTE_LPM,n) |
| 129 | $(call set,RTE_LIBRTE_ACL,n) |
| 130 | $(call set,RTE_LIBRTE_POWER,n) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 131 | $(call set,RTE_LIBRTE_DISTRIBUTOR,n) |
| 132 | $(call set,RTE_LIBRTE_REORDER,n) |
| 133 | $(call set,RTE_LIBRTE_PORT,n) |
| 134 | $(call set,RTE_LIBRTE_TABLE,n) |
| 135 | $(call set,RTE_LIBRTE_PIPELINE,n) |
| 136 | $(call set,RTE_KNI_KMOD,n) |
| 137 | @rm -f .config.ok |
| 138 | |
| 139 | $(CURDIR)/$(DPDK_TARBALL): |
| 140 | @mkdir -p $(B) |
| 141 | @if [ -e $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) ] ; \ |
| 142 | then cp $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) $(CURDIR) ; \ |
| 143 | else curl -o $(CURDIR)/$(DPDK_TARBALL) -LO $(DPDK_TAR_URL) ; \ |
| 144 | fi |
| 145 | @rm -f $(B)/.download.ok |
| 146 | |
| 147 | $(B)/.download.ok: $(CURDIR)/$(DPDK_TARBALL) |
| 148 | @openssl md5 $< | cut -f 2 -d " " - > $(B)/$(DPDK_TARBALL).md5sum |
Damjan Marion | bce6b6a | 2015-12-16 04:27:37 +0100 | [diff] [blame] | 149 | @([ "$$(<$(B)/$(DPDK_TARBALL).md5sum)" = "$(DPDK_$(DPDK_VERSION)_TARBALL_MD5_CKSUM)" ] || \ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 150 | ( echo "Bad Checksum! Please remove $< and retry" && \ |
| 151 | rm $(B)/$(DPDK_TARBALL).md5sum && false )) |
| 152 | @touch $@ |
| 153 | |
| 154 | .PHONY: download |
| 155 | download: $(B)/.download.ok |
| 156 | |
| 157 | $(B)/.extract.ok: $(B)/.download.ok |
| 158 | @echo --- extracting $(DPDK_TARBALL) --- |
Thomas Monjalon | 96e10b5 | 2016-06-02 14:52:32 +0200 | [diff] [blame] | 159 | @tar --directory $(B) --extract --file $(CURDIR)/$(DPDK_TARBALL) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 160 | @touch $@ |
| 161 | |
| 162 | .PHONY: extract |
| 163 | extract: $(B)/.extract.ok |
| 164 | |
| 165 | $(B)/.patch.ok: $(B)/.extract.ok |
Damjan Marion | 0df78dd | 2016-03-29 22:37:02 +0200 | [diff] [blame] | 166 | ifneq ($(wildcard $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch),) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 167 | @echo --- patching --- |
| 168 | for f in $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch ; do \ |
| 169 | echo Applying patch: $$(basename $$f) ; \ |
| 170 | patch -p1 -d $(DPDK_SOURCE) < $$f ; \ |
| 171 | done |
Damjan Marion | 0df78dd | 2016-03-29 22:37:02 +0200 | [diff] [blame] | 172 | endif |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 173 | @touch $@ |
| 174 | |
| 175 | .PHONY: patch |
| 176 | patch: $(B)/.patch.ok |
| 177 | |
| 178 | $(B)/.config.ok: $(B)/.patch.ok $(B)/custom-config |
| 179 | @make $(DPDK_MAKE_ARGS) config |
| 180 | @touch $@ |
| 181 | |
| 182 | .PHONY: config |
| 183 | config: $(B)/.config.ok |
| 184 | |
| 185 | $(B)/.build.ok: $(DPDK_SOURCE_FILES) |
| 186 | @if [ ! -e $(B)/.config.ok ] ; then echo 'Please run "make config" first' && false ; fi |
| 187 | @make $(DPDK_MAKE_ARGS) install |
| 188 | @dkms/create_deb_manifest.sh $(DPDK_VERSION) $(subst $(realpath ..)/,,$(B)) |
| 189 | @touch $@ |
| 190 | |
| 191 | .PHONY: build |
| 192 | build: $(B)/.build.ok |
| 193 | |
| 194 | .PHONY: clean |
| 195 | clean: |
| 196 | @rm -rf $(B) $(I) |
| 197 | |