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 34# This makefile snippet must define the following flags: 35# ENV_CFLAGS 36# ENV_CXXFLAGS 37# ENV_LIBS 38# ENV_LINKER_ARGS 39 40DPDK_DIR = $(CONFIG_DPDK_DIR) 41 42export DPDK_ABS_DIR = $(abspath $(DPDK_DIR)) 43 44ifneq (, $(wildcard $(DPDK_ABS_DIR)/include/rte_config.h)) 45DPDK_INC_DIR := $(DPDK_ABS_DIR)/include 46else 47DPDK_INC_DIR := $(DPDK_ABS_DIR)/include/dpdk 48endif 49DPDK_INC := -I$(DPDK_INC_DIR) 50 51ifeq ($(CONFIG_SHARED),y) 52DPDK_LIB_EXT = .so 53else 54DPDK_LIB_EXT = .a 55endif 56 57DPDK_LIB_LIST = rte_eal rte_mempool rte_ring rte_mbuf 58 59# librte_mempool_ring was new added from DPDK 17.05. Link this library used for 60# ring based mempool management API. 61ifneq (, $(wildcard $(DPDK_ABS_DIR)/lib/librte_mempool_ring.*)) 62DPDK_LIB_LIST += rte_mempool_ring 63endif 64 65# librte_malloc was removed after DPDK 2.1. Link this library conditionally based on its 66# existence to maintain backward compatibility. 67ifneq ($(wildcard $(DPDK_ABS_DIR)/lib/librte_malloc.*),) 68DPDK_LIB_LIST += rte_malloc 69endif 70 71# librte_pci and librte_bus_pci were added in DPDK 17.11. Link these libraries conditionally 72# based on their existence to maintain backward compatibility. 73ifneq (, $(wildcard $(DPDK_ABS_DIR)/lib/librte_pci.*)) 74DPDK_LIB_LIST += rte_pci 75endif 76 77ifneq (, $(wildcard $(DPDK_ABS_DIR)/lib/librte_bus_pci.*)) 78DPDK_LIB_LIST += rte_bus_pci 79endif 80 81# DPDK 20.05 eal dependency 82ifneq (, $(wildcard $(DPDK_ABS_DIR)/lib/librte_telemetry.*)) 83DPDK_LIB_LIST += rte_telemetry 84endif 85 86# There are some complex dependencies when using crypto, reduce or both so 87# here we add the feature specific ones and set a flag to add the common 88# ones after that. 89DPDK_FRAMEWORK=n 90ifeq ($(CONFIG_CRYPTO),y) 91DPDK_FRAMEWORK=y 92DPDK_LIB_LIST += rte_pmd_aesni_mb rte_reorder 93endif 94 95ifeq ($(CONFIG_REDUCE),y) 96DPDK_FRAMEWORK=y 97DPDK_LIB_LIST += rte_pmd_isal 98endif 99 100ifeq ($(DPDK_FRAMEWORK),y) 101DPDK_LIB_LIST += rte_cryptodev rte_compressdev rte_bus_vdev rte_pmd_qat 102endif 103 104ifneq (, $(wildcard $(DPDK_ABS_DIR)/lib/librte_kvargs.*)) 105DPDK_LIB_LIST += rte_kvargs 106endif 107 108LINK_HASH=n 109 110ifeq ($(CONFIG_VHOST),y) 111ifneq ($(CONFIG_VHOST_INTERNAL_LIB),y) 112DPDK_LIB_LIST += rte_vhost rte_net 113LINK_HASH=y 114ifneq ($(DPDK_FRAMEWORK),y) 115DPDK_LIB_LIST += rte_cryptodev 116endif 117endif 118endif 119 120ifeq ($(CONFIG_RAID5),y) 121LINK_HASH=y 122endif 123 124ifeq ($(LINK_HASH),y) 125DPDK_LIB_LIST += rte_hash 126endif 127 128define dpdk_lib_list_to_libs 129$(1:%=$(DPDK_ABS_DIR)/lib/lib%$(DPDK_LIB_EXT)) 130endef 131 132define dpdk_env_linker_args 133$(ENV_DPDK_FILE) -Wl,--whole-archive,--no-as-needed $(call dpdk_lib_list_to_libs,$1) -Wl,--no-whole-archive 134endef 135 136DPDK_LIB = $(call dpdk_lib_list_to_libs,$(DPDK_LIB_LIST)) 137 138# SPDK memory registration requires experimental (deprecated) rte_memory API for DPDK 18.05 139ENV_CFLAGS = $(DPDK_INC) -Wno-deprecated-declarations 140ENV_CXXFLAGS = $(ENV_CFLAGS) 141ifeq ($(CONFIG_SHARED),y) 142ENV_DPDK_FILE = $(call spdk_lib_list_to_shared_libs,env_dpdk) 143else 144ENV_DPDK_FILE = $(call spdk_lib_list_to_static_libs,env_dpdk) 145endif 146ENV_LIBS = $(ENV_DPDK_FILE) $(DPDK_LIB) 147ENV_LINKER_ARGS = -Wl,-rpath-link $(DPDK_ABS_DIR)/lib 148ENV_LINKER_ARGS += $(call dpdk_env_linker_args,$(DPDK_LIB_LIST)) 149 150ifeq ($(CONFIG_IPSEC_MB),y) 151ENV_LINKER_ARGS += -lIPSec_MB -L$(IPSEC_MB_DIR) 152endif 153 154ifeq ($(CONFIG_REDUCE),y) 155ENV_LINKER_ARGS += -lisal -L$(ISAL_DIR)/.libs 156endif 157 158ifneq (,$(wildcard $(DPDK_INC_DIR)/rte_config.h)) 159ifneq (,$(shell grep -e "define RTE_LIBRTE_VHOST_NUMA 1" -e "define RTE_EAL_NUMA_AWARE_HUGEPAGES 1" $(DPDK_INC_DIR)/rte_config.h)) 160ENV_LINKER_ARGS += -lnuma 161endif 162endif 163 164# DPDK built with meson puts those defines elsewhere 165ifneq (,$(wildcard $(DPDK_INC_DIR)/rte_build_config.h)) 166ifneq (,$(shell grep -e "define RTE_LIBRTE_VHOST_NUMA 1" -e "define RTE_EAL_NUMA_AWARE_HUGEPAGES 1" $(DPDK_INC_DIR)/rte_build_config.h)) 167ENV_LINKER_ARGS += -lnuma 168endif 169endif 170 171ifeq ($(OS),Linux) 172ENV_LINKER_ARGS += -ldl 173endif 174ifeq ($(OS),FreeBSD) 175ENV_LINKER_ARGS += -lexecinfo 176endif 177