xref: /spdk/lib/env_dpdk/env.mk (revision c39647df83e4be9bcc49025132c48bf2414ef8b1)
1#
2#  BSD LICENSE
3#
4#  Copyright (c) Intel Corporation.
5#  All rights reserved.
6#  Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
7#
8#  Redistribution and use in source and binary forms, with or without
9#  modification, are permitted provided that the following conditions
10#  are met:
11#
12#    * Redistributions of source code must retain the above copyright
13#      notice, this list of conditions and the following disclaimer.
14#    * Redistributions in binary form must reproduce the above copyright
15#      notice, this list of conditions and the following disclaimer in
16#      the documentation and/or other materials provided with the
17#      distribution.
18#    * Neither the name of Intel Corporation nor the names of its
19#      contributors may be used to endorse or promote products derived
20#      from this software without specific prior written permission.
21#
22#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26#  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33#
34
35# This makefile snippet must define the following flags:
36# ENV_CFLAGS
37# ENV_CXXFLAGS
38# ENV_LIBS
39# ENV_LINKER_ARGS
40
41DPDK_DIR = $(CONFIG_DPDK_DIR)
42
43export DPDK_ABS_DIR = $(abspath $(DPDK_DIR))
44
45ifneq ($(CONFIG_DPDK_LIB_DIR),)
46DPDK_LIB_DIR = $(CONFIG_DPDK_LIB_DIR)
47else
48DPDK_LIB_DIR = $(DPDK_ABS_DIR)/lib
49endif
50
51ifneq ($(CONFIG_DPDK_INC_DIR),)
52DPDK_INC_DIR = $(CONFIG_DPDK_INC_DIR)
53else
54ifneq (, $(wildcard $(DPDK_ABS_DIR)/include/rte_config.h))
55DPDK_INC_DIR := $(DPDK_ABS_DIR)/include
56else
57DPDK_INC_DIR := $(DPDK_ABS_DIR)/include/dpdk
58endif
59endif
60
61DPDK_INC := -I$(DPDK_INC_DIR)
62
63DPDK_LIB_LIST = rte_eal rte_mempool rte_ring rte_mbuf rte_bus_pci rte_pci rte_mempool_ring
64DPDK_LIB_LIST += rte_telemetry rte_kvargs
65
66ifeq ($(OS),Linux)
67DPDK_LIB_LIST += rte_power rte_ethdev rte_net
68endif
69
70# There are some complex dependencies when using crypto, reduce or both so
71# here we add the feature specific ones and set a flag to add the common
72# ones after that.
73DPDK_FRAMEWORK=n
74ifeq ($(CONFIG_CRYPTO),y)
75DPDK_FRAMEWORK=y
76ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_crypto_ipsec_mb.*))
77# PMD name as of DPDK 21.11
78DPDK_LIB_LIST += rte_crypto_ipsec_mb
79else
80ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_crypto_aesni_mb.*))
81# PMD name for DPDK 21.08 and earlier
82DPDK_LIB_LIST += rte_crypto_aesni_mb
83endif
84endif
85endif
86
87ifeq ($(CONFIG_REDUCE),y)
88DPDK_FRAMEWORK=y
89DPDK_LIB_LIST += rte_compress_isal
90ifeq ($(CONFIG_REDUCE_MLX5),y)
91DPDK_LIB_LIST += rte_common_mlx5 rte_compress_mlx5
92# Introduced in DPDK 21.08
93ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_bus_auxiliary.*))
94DPDK_LIB_LIST += rte_bus_auxiliary
95endif
96endif
97endif
98
99ifeq ($(DPDK_FRAMEWORK),y)
100DPDK_LIB_LIST += rte_cryptodev rte_compressdev rte_bus_vdev
101DPDK_LIB_LIST += rte_common_qat
102endif
103
104LINK_HASH=n
105
106ifeq ($(CONFIG_VHOST),y)
107DPDK_LIB_LIST += rte_vhost
108ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_dmadev.*))
109# Introduced in DPDK 21.11, and rte_vhost became dependent on
110# it shortly thereafter
111DPDK_LIB_LIST += rte_dmadev
112endif
113LINK_HASH=y
114ifneq ($(DPDK_FRAMEWORK),y)
115DPDK_LIB_LIST += rte_cryptodev
116endif
117endif
118
119ifeq ($(CONFIG_FC),y)
120LINK_HASH=y
121endif
122
123ifeq ($(LINK_HASH),y)
124DPDK_LIB_LIST += rte_hash
125ifneq (, $(wildcard $(DPDK_LIB_DIR)/librte_rcu.*))
126DPDK_LIB_LIST += rte_rcu
127endif
128endif
129
130
131DPDK_LIB_LIST_SORTED = $(sort $(DPDK_LIB_LIST))
132
133DPDK_SHARED_LIB = $(DPDK_LIB_LIST_SORTED:%=$(DPDK_LIB_DIR)/lib%.so)
134DPDK_STATIC_LIB = $(DPDK_LIB_LIST_SORTED:%=$(DPDK_LIB_DIR)/lib%.a)
135DPDK_SHARED_LIB_LINKER_ARGS = $(call add_no_as_needed,$(DPDK_SHARED_LIB))
136DPDK_STATIC_LIB_LINKER_ARGS = $(call add_whole_archive,$(DPDK_STATIC_LIB))
137
138ENV_CFLAGS = $(DPDK_INC) -DALLOW_EXPERIMENTAL_API
139ENV_CXXFLAGS = $(ENV_CFLAGS)
140
141DPDK_PRIVATE_LINKER_ARGS =
142
143ifeq ($(CONFIG_IPSEC_MB),y)
144DPDK_PRIVATE_LINKER_ARGS += -lIPSec_MB -L$(IPSEC_MB_DIR)
145endif
146
147ifeq ($(CONFIG_REDUCE),y)
148DPDK_PRIVATE_LINKER_ARGS += -lisal -L$(ISAL_DIR)/.libs
149ifeq ($(CONFIG_REDUCE_MLX5),y)
150DPDK_PRIVATE_LINKER_ARGS += -lmlx5
151endif
152endif
153
154ifneq (,$(wildcard $(DPDK_INC_DIR)/rte_config.h))
155ifneq (,$(shell grep -e "define RTE_LIBRTE_VHOST_NUMA 1" -e "define RTE_EAL_NUMA_AWARE_HUGEPAGES 1" $(DPDK_INC_DIR)/rte_config.h))
156DPDK_PRIVATE_LINKER_ARGS += -lnuma
157endif
158endif
159
160# DPDK built with meson puts those defines elsewhere
161ifneq (,$(wildcard $(DPDK_INC_DIR)/rte_build_config.h))
162ifneq (,$(shell grep -e "define RTE_LIBRTE_VHOST_NUMA 1" -e "define RTE_EAL_NUMA_AWARE_HUGEPAGES 1" $(DPDK_INC_DIR)/rte_build_config.h))
163DPDK_PRIVATE_LINKER_ARGS += -lnuma
164endif
165endif
166
167ifeq ($(OS),Linux)
168DPDK_PRIVATE_LINKER_ARGS += -ldl
169endif
170ifeq ($(OS),FreeBSD)
171DPDK_PRIVATE_LINKER_ARGS += -lexecinfo
172endif
173
174ifeq ($(CONFIG_SHARED),y)
175ENV_DPDK_FILE = $(call spdk_lib_list_to_shared_libs,env_dpdk)
176ENV_LIBS = $(ENV_DPDK_FILE) $(DPDK_SHARED_LIB)
177DPDK_LINKER_ARGS = -Wl,-rpath-link $(DPDK_LIB_DIR) $(DPDK_SHARED_LIB_LINKER_ARGS)
178ENV_LINKER_ARGS = $(ENV_DPDK_FILE) $(DPDK_LINKER_ARGS)
179else
180ENV_DPDK_FILE = $(call spdk_lib_list_to_static_libs,env_dpdk)
181ENV_LIBS = $(ENV_DPDK_FILE) $(DPDK_STATIC_LIB)
182DPDK_LINKER_ARGS = -Wl,-rpath-link $(DPDK_LIB_DIR) $(DPDK_STATIC_LIB_LINKER_ARGS)
183ENV_LINKER_ARGS = $(ENV_DPDK_FILE) $(DPDK_LINKER_ARGS)
184ENV_LINKER_ARGS += $(DPDK_PRIVATE_LINKER_ARGS)
185endif
186