1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2017-2019 Intel Corporation
5 # process all libraries equally, as far as possible
6 # "core" libs first, then others alphabetically as far as possible
7 # NOTE: for speed of meson runs, the dependencies in the subdirectories
8 # sometimes skip deps that would be implied by others, e.g. if mempool is
9 # given as a dep, no need to mention ring. This is especially true for the
10 # core libs which are widely reused, so their deps are kept to a minimum.
12 'kvargs', # eal depends on kvargs
13 'telemetry', # basic info querying
14 'eal', # everything depends on eal
16 'rcu', # rcu depends on ring
24 'metrics', # bitrate/latency stats depends on this
25 'hash', # efd depends on this
26 'timer', # eventdev depends on this
57 'ipsec', # ipsec lib depends on net, crypto and security
58 'fib', #fib lib depends on rib
59 'port', # pkt framework libs which use other libs from above
60 'pdump', # pdump lib depends on bpf
63 'flow_classify', # flow_classify lib depends on pkt framework table lib
89 opt_disabled_libs = run_command(list_dir_globs, get_option('disable_libs'),
90 check: true).stdout().split()
91 foreach l:opt_disabled_libs
92 if not optional_libs.contains(l)
93 warning('Cannot disable mandatory library "@0@"'.format(l))
100 default_cflags = machine_args
101 default_cflags += ['-DALLOW_EXPERIMENTAL_API']
102 default_cflags += ['-DALLOW_INTERNAL_API']
104 if cc.has_argument('-Wno-format-truncation')
105 default_cflags += '-Wno-format-truncation'
108 enabled_libs = [] # used to print summary at the end
112 reason = '<unknown reason>' # set if build == false to explain why
114 use_function_versioning = false
117 indirect_headers = [] # public headers not directly included by apps
118 driver_sdk_headers = [] # public headers included by drivers
120 cflags = default_cflags
121 objs = [] # other object files to link against, used e.g. for
122 # instruction-set optimized versions of code
124 # use "deps" for internal DPDK dependencies, and "ext_deps" for
125 # external package/library requirements
128 # eal is standard dependency once built
129 if dpdk_conf.has('RTE_LIB_EAL')
133 if disabled_libs.contains(l)
135 reason = 'explicitly disabled via build config'
140 warning('Library name, "@0@", and directory name, "@1@", do not match'.format(name, l))
143 shared_deps = ext_deps
144 static_deps = ext_deps
149 if not is_variable('shared_rte_' + d)
151 reason = 'missing internal dependency, "@0@"'.format(d)
152 message('Disabling @1@ [@2@]: missing internal dependency "@0@"'
153 .format(d, name, 'lib/' + l))
155 shared_deps += [get_variable('shared_rte_' + d)]
156 static_deps += [get_variable('static_rte_' + d)]
161 dpdk_libs_disabled += name
162 set_variable(name.underscorify() + '_disable_reason', reason)
167 dpdk_conf.set('RTE_LIB_' + name.to_upper(), 1)
168 install_headers(headers)
169 install_headers(indirect_headers)
170 if get_option('enable_driver_sdk')
171 install_headers(driver_sdk_headers)
173 dpdk_chkinc_headers += headers
175 libname = 'rte_' + name
176 includes += include_directories(l)
178 if developer_mode and is_windows and use_function_versioning
179 message('@0@: Function versioning is not supported by Windows.'.format(name))
182 if use_function_versioning
183 cflags += '-DRTE_USE_FUNCTION_VERSIONING'
185 cflags += '-DRTE_LOG_DEFAULT_LOGTYPE=lib.' + l
187 # first build static lib
188 static_lib = static_library(libname,
192 dependencies: static_deps,
193 include_directories: includes,
195 static_dep = declare_dependency(
196 include_directories: includes,
197 dependencies: static_deps)
199 if not use_function_versioning or is_windows
200 # use pre-build objects to build shared lib
202 objs += static_lib.extract_all_objects(recursive: false)
204 # for compat we need to rebuild with
205 # RTE_BUILD_SHARED_LIB defined
206 cflags += '-DRTE_BUILD_SHARED_LIB'
208 version_map = '@0@/@1@/version.map'.format(
209 meson.current_source_dir(), l)
210 implib = 'librte_' + l + '.dll.a'
212 def_file = custom_target(libname + '_def',
213 command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
215 output: '@0@_exports.def'.format(libname))
217 mingw_map = custom_target(libname + '_mingw',
218 command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
220 output: '@0@_mingw.map'.format(libname))
223 lk_args = ['-Wl,/def:' + def_file.full_path()]
224 if meson.version().version_compare('<0.54.0')
225 lk_args += ['-Wl,/implib:lib\\' + implib]
229 lk_args = ['-Wl,--version-script=' + mingw_map.full_path()]
231 lk_args = ['-Wl,--version-script=' + version_map]
235 lk_deps = [version_map, def_file, mingw_map]
236 if developer_mode and not is_windows
237 # on unix systems check the output of the
238 # check-symbols.sh script, using it as a
239 # dependency of the .so build
240 lk_deps += custom_target(name + '.sym_chk',
241 command: [check_symbols,
242 version_map, '@INPUT@'],
245 output: name + '.sym_chk')
248 shared_lib = shared_library(libname,
252 dependencies: shared_deps,
253 include_directories: includes,
255 link_depends: lk_deps,
256 version: abi_version,
257 soversion: so_version,
259 shared_dep = declare_dependency(link_with: shared_lib,
260 include_directories: includes,
261 dependencies: shared_deps)
263 dpdk_libraries = [shared_lib] + dpdk_libraries
264 dpdk_static_libraries = [static_lib] + dpdk_static_libraries
266 set_variable('shared_rte_' + name, shared_dep)
267 set_variable('static_rte_' + name, static_dep)
269 message('lib/@0@: Defining dependency "@1@"'.format(l, name))