1# 2# BSD LICENSE 3# 4# Copyright (c) Intel Corporation. 5# All rights reserved. 6# 7# Redistribution and use in source and binary forms, with or without 8# modification, are permitted provided that the following conditions 9# are met: 10# 11# * Redistributions of source code must retain the above copyright 12# notice, this list of conditions and the following disclaimer. 13# * Redistributions in binary form must reproduce the above copyright 14# notice, this list of conditions and the following disclaimer in 15# the documentation and/or other materials provided with the 16# distribution. 17# * Neither the name of Intel Corporation nor the names of its 18# contributors may be used to endorse or promote products derived 19# from this software without specific prior written permission. 20# 21# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32# 33 34SPDK_ROOT_DIR := $(abspath $(CURDIR)/..) 35include $(SPDK_ROOT_DIR)/mk/spdk.common.mk 36 37.PHONY: all clean install uninstall 38 39DPDK_OPTS = -Denable_docs=false 40DPDK_CFLAGS = 41 42DPDK_KMODS = false 43ifeq ($(OS),FreeBSD) 44DPDK_KMODS = true 45endif 46DPDK_OPTS += -Denable_kmods=$(DPDK_KMODS) 47 48# the drivers we use 49DPDK_DRIVERS = bus bus/pci bus/vdev mempool/ring 50 51# common crypto/reduce drivers 52ifeq ($(findstring y,$(CONFIG_CRYPTO)$(CONFIG_REDUCE)),y) 53DPDK_DRIVERS += crypto/qat compress/qat common/qat 54endif 55 56ifeq ($(CONFIG_CRYPTO),y) 57# crypto/qat is just a stub, the compress/qat pmd is used instead 58DPDK_DRIVERS += crypto crypto/aesni_mb 59DPDK_CFLAGS += -I$(IPSEC_MB_DIR) 60DPDK_LDFLAGS += -L$(IPSEC_MB_DIR) 61endif 62 63ifeq ($(CONFIG_REDUCE),y) 64DPDK_DRIVERS += compress compress/isal 65DPDK_CFLAGS += -I$(ISAL_DIR) 66DPDK_LDFLAGS += -L$(ISAL_DIR)/.libs -lisal 67endif 68 69DPDK_OPTS += -Dmachine=$(TARGET_ARCHITECTURE) 70 71ifneq ($(CONFIG_CROSS_PREFIX),) 72$(error Automatic DPDK cross build is not supported. Please compile DPDK manually \ 73with e.g. `meson build --cross-file config/arm/arm64_armv8_linux_gcc`) 74endif 75 76DPDK_CFLAGS += -fPIC 77 78ifeq ($(CONFIG_DEBUG),y) 79DPDK_CFLAGS += -O0 -g 80endif 81 82ifeq ($(CONFIG_WERROR),y) 83DPDK_CFLAGS += -Werror 84else 85DPDK_CFLAGS += -Wno-error 86endif 87 88ifeq ($(CONFIG_CET),y) 89DPDK_CFLAGS += -fcf-protection 90DPDK_LDFLAGS += -fcf-protection 91endif 92 93ifdef EXTRA_DPDK_CFLAGS 94$(warning EXTRA_DPDK_CFLAGS defined, possibly to work around an unsupported compiler version) 95$(shell sleep 1) 96endif 97 98# Allow users to specify EXTRA_DPDK_CFLAGS if they want to build DPDK using unsupported compiler versions 99DPDK_CFLAGS += $(EXTRA_DPDK_CFLAGS) 100 101ifeq ($(CC_TYPE),gcc) 102GCC_MAJOR = $(shell echo __GNUC__ | $(CC) -E -x c - | tail -n 1) 103ifeq ($(shell test $(GCC_MAJOR) -ge 10 && echo 1), 1) 104#1. gcc 10 complains on operations with zero size arrays in rte_cryptodev.c, so 105#disable this warning 106#2. gcc 10 disables fcommon by default and complains on multiple definition of 107#aesni_mb_logtype_driver symbol which is defined in header file and presented in sevral 108#translation units 109DPDK_CFLAGS += -Wno-stringop-overflow -fcommon 110endif 111endif 112 113# Force-disable scan-build 114SUB_CC = $(patsubst %ccc-analyzer,$(DEFAULT_CC),$(CC)) 115 116DPDK_ALL_DRIVER_DIRS = $(shell find $(SPDK_ROOT_DIR)/dpdk/drivers -mindepth 1 -type d) 117DPDK_ALL_DRIVERS = $(DPDK_ALL_DRIVER_DIRS:$(SPDK_ROOT_DIR)/dpdk/drivers/%=%) 118DPDK_DISABLED_DRVERS = $(filter-out $(DPDK_DRIVERS),$(DPDK_ALL_DRIVERS)) 119 120ifeq ($(OS),Linux) 121SED_INPLACE_FLAG = "-i" 122MESON_PREFIX = $(SPDK_ROOT_DIR)/dpdk/build 123else 124SED_INPLACE_FLAG = "-i ''" 125MESON_PREFIX = "/" 126endif 127 128# Some ninja versions come with a (broken?) jobserver which defaults to use 129# only 1 thread for the build. We workaround this by specifying -j to ninja 130# with the same value as top-makefile. This is OK as long as DPDK is not built 131# in parralel with anything else, which is the case for now. 132ifeq ($(MAKE_PID),) 133MAKE_PID := $(shell echo $$PPID) 134endif 135 136MAKE_NUMJOBS := $(shell ps T | sed -nE 's/\s*$(MAKE_PID)\s.* (-j|--jobs=)( *[0-9]+).*/\1\2/p') 137 138all: $(SPDK_ROOT_DIR)/dpdk/build-tmp 139 $(Q)# DPDK doesn't handle nested make calls, so unset MAKEFLAGS 140 $(Q)env -u MAKEFLAGS ninja -C $(SPDK_ROOT_DIR)/dpdk/build-tmp $(MAKE_NUMJOBS) 141 $(Q) \ 142 # Meson on FreeBSD sometimes appends --prefix value to the default DESTDIR (which is e.g. \ 143 # /usr/local) instead of replacing it. --prefix needs to be an absolute path, so we set \ 144 # it to / and then set DESTDIR directly, so libs and headers are copied to "DESTDIR//". \ 145 # DPDK kernel modules are set to install in $DESTDIR/boot/modules, but we move them \ 146 # to DESTDIR/kmod to be consistent with the makefile build. \ 147 # \ 148 # Also use meson install --only-changed instead of ninja install so that the shared \ 149 # libraries don't get reinstalled when they haven't been rebuilt - this avoids all of \ 150 # our applications getting relinked even when nothing has changed. 151 $(Q)if [ "$(OS)" = "FreeBSD" ]; then \ 152 env -u MAKEFLAGS DESTDIR=$(SPDK_ROOT_DIR)/dpdk/build ninja -C $(SPDK_ROOT_DIR)/dpdk/build-tmp $(MAKE_NUMJOBS) install > /dev/null && \ 153 mv $(SPDK_ROOT_DIR)/dpdk/build/boot/modules $(SPDK_ROOT_DIR)/dpdk/build/kmod; \ 154 else \ 155 env -u MAKEFLAGS meson install -C $(SPDK_ROOT_DIR)/dpdk/build-tmp --only-changed > /dev/null; \ 156 fi 157 158$(SPDK_ROOT_DIR)/dpdk/build-tmp: $(SPDK_ROOT_DIR)/mk/cc.mk $(SPDK_ROOT_DIR)/include/spdk/config.h 159 $(Q)rm -rf $(SPDK_ROOT_DIR)/dpdk/build $(SPDK_ROOT_DIR)/dpdk/build-tmp 160 $(Q)cd "$(SPDK_ROOT_DIR)/dpdk"; CC="$(SUB_CC)" meson --prefix="$(MESON_PREFIX)" --libdir lib -Dc_args="$(DPDK_CFLAGS)" -Dc_link_args="$(DPDK_LDFLAGS)" $(DPDK_OPTS) -Ddisable_drivers="$(shell echo $(DPDK_DISABLED_DRVERS) | sed -E "s/ +/,/g")" build-tmp 161 $(Q)sed $(SED_INPLACE_FLAG) 's/#define RTE_EAL_PMD_PATH .*/#define RTE_EAL_PMD_PATH ""/g' $(SPDK_ROOT_DIR)/dpdk/build-tmp/rte_build_config.h 162 $(Q) \ 163 # TODO Meson build adds libbsd dependency when it's available. This means any app will be \ 164 # forced to link with -lbsd, but only if it's available on the system. The clean way to \ 165 # handle this would be to rely on DPDK's pkg-config file which will contain the -lbsd when \ 166 # required. For now just remove the libbsd dependency. DPDK will fallback to its internal \ 167 # functions. 168 $(Q)sed $(SED_INPLACE_FLAG) 's/#define RTE_USE_LIBBSD .*//g' $(SPDK_ROOT_DIR)/dpdk/build-tmp/rte_build_config.h 169 170clean: 171 $(Q)rm -rf $(SPDK_ROOT_DIR)/dpdk/build $(SPDK_ROOT_DIR)/dpdk/build-tmp 172 173install: 174 @: 175 176uninstall: 177 @: 178