1 # Copyright (c) 2020 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:
6 # http://www.apache.org/licenses/LICENSE-2.0
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.
14 DPDK_PKTMBUF_HEADROOM ?= 128
19 DPDK_MLX5_COMMON_PMD ?= n
21 DPDK_FAILSAFE_PMD ?= n
22 DPDK_MACHINE ?= default
25 dpdk_base_url ?= http://fast.dpdk.org/rel
26 dpdk_tarball := dpdk-$(dpdk_version).tar.xz
27 dpdk_tarball_md5sum_20.08 := 64badd32cd6bc0761befc8f2402c2148
28 dpdk_tarball_md5sum := $(dpdk_tarball_md5sum_$(dpdk_version))
29 dpdk_url := $(dpdk_base_url)/$(dpdk_tarball)
30 dpdk_tarball_strip_dirs := 1
34 DPDK_BUILD_TYPE:=release
35 ifeq ($(DPDK_DEBUG), y)
36 DPDK_BUILD_TYPE:=debug
39 DPDK_DRIVERS_DISABLED := baseband/\*, \
61 DPDK_LIBS_DISABLED := acl, \
86 # Adjust disabled pmd and libs depending on user provided variables
87 ifeq ($(DPDK_MLX4_PMD), n)
88 DPDK_DRIVERS_DISABLED += ,net/mlx4
90 ifeq ($(DPDK_MLX5_PMD), n)
91 DPDK_DRIVERS_DISABLED += ,net/mlx5
93 ifeq ($(DPDK_MLX5_COMMON_PMD), n)
94 DPDK_DRIVERS_DISABLED += ,common/mlx5
96 ifeq ($(DPDK_TAP_PMD), n)
97 DPDK_DRIVERS_DISABLED += ,net/tap
99 ifeq ($(DPDK_FAILSAFE_PMD), n)
100 DPDK_DRIVERS_DISABLED += ,net/failsafe
103 # Sanitize DPDK_DRIVERS_DISABLED and DPDK_LIBS_DISABLED
104 DPDK_DRIVERS_DISABLED := $(shell echo $(DPDK_DRIVERS_DISABLED) | tr -d '\\\t ')
105 DPDK_LIBS_DISABLED := $(shell echo $(DPDK_LIBS_DISABLED) | tr -d '\\\t ')
108 # post-meson-setup snippet to alter rte_build_config.h
110 if grep -q RTE_$(1) $(dpdk_src_dir)/config/rte_config.h ; then \
111 sed -i -e 's/$(HASH)define RTE_$(1).*/$(HASH)define RTE_$(1) $(DPDK_$(1))/' \
112 $(dpdk_src_dir)/config/rte_config.h; \
113 elif grep -q RTE_$(1) $(dpdk_build_dir)/rte_build_config.h ; then \
114 sed -i -e 's/$(HASH)define RTE_$(1).*/$(HASH)define RTE_$(1) $(DPDK_$(1))/' \
115 $(dpdk_build_dir)/rte_build_config.h; \
117 echo '$(HASH)define RTE_$(1) $(DPDK_$(1))' \
118 >> $(dpdk_build_dir)/rte_build_config.h ; \
122 define dpdk_config_def
123 if [[ "$(DPDK_$(1))" == "y" ]]; then \
124 if ! grep -q "RTE_$(1)" $(dpdk_build_dir)/rte_build_config.h \
125 $(dpdk_src_dir)/config/rte_config.h ; then \
126 echo '$(HASH)define RTE_$(1) 1' \
127 >> $(dpdk_build_dir)/rte_build_config.h ; \
129 elif [[ "$(DPDK_$(1))" == "n" ]]; then \
130 sed -i '/$(HASH)define RTE_$(1) .*/d' $(dpdk_build_dir)/rte_build_config.h \
131 $(dpdk_src_dir)/config/rte_config.h ; \
136 --default-library static \
138 --prefix $(dpdk_install_dir) \
140 "-Ddisable_drivers=$(DPDK_DRIVERS_DISABLED)" \
141 "-Ddisable_libs=$(DPDK_LIBS_DISABLED)" \
143 -Dmachine=$(DPDK_MACHINE) \
144 --buildtype=$(DPDK_BUILD_TYPE)
146 define dpdk_config_cmds
147 cd $(dpdk_build_dir) && \
148 rm -rf ../dpdk-meson-venv && \
149 mkdir -p ../dpdk-meson-venv && \
150 python3 -m venv ../dpdk-meson-venv && \
151 source ../dpdk-meson-venv/bin/activate && \
152 pip3 install meson==0.54 && \
153 meson setup $(dpdk_src_dir) \
156 | tee $(dpdk_config_log) && \
158 echo "DPDK post meson configuration" && \
159 echo "Altering rte_build_config.h" && \
160 $(call dpdk_config,PKTMBUF_HEADROOM) && \
161 $(call dpdk_config_def,USE_LIBBSD)
164 define dpdk_build_cmds
165 cd $(dpdk_build_dir) && \
166 source ../dpdk-meson-venv/bin/activate && \
167 meson compile -C . | tee $(dpdk_build_log) && \
171 define dpdk_install_cmds
172 cd $(dpdk_build_dir) && \
173 source ../dpdk-meson-venv/bin/activate && \
175 cd $(dpdk_install_dir)/lib && \
176 echo "GROUP ( $$(ls librte*.a ) )" > libdpdk.a && \
177 rm -rf librte*.so librte*.so.* dpdk/*/librte*.so dpdk/*/librte*.so.* && \
179 rm -rf $(dpdk_build_dir)/../dpdk-meson-venv
182 $(eval $(call package,dpdk))