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 alphebetically 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
54 'ipsec', # ipsec lib depends on net, crypto and security
55 'fib', #fib lib depends on rib
56 'port', # pkt framework libs which use other libs from above
59 'flow_classify', # flow_classify lib depends on pkt framework table lib
81 ] # only supported libraries for windows
91 opt_disabled_libs = run_command(list_dir_globs, get_option('disable_libs'),
92 check: true).stdout().split()
93 foreach l:opt_disabled_libs
94 if not optional_libs.contains(l)
95 warning('Cannot disable mandatory library "@0@"'.format(l))
102 default_cflags = machine_args
103 default_cflags += ['-DALLOW_EXPERIMENTAL_API']
104 default_cflags += ['-DALLOW_INTERNAL_API']
106 if cc.has_argument('-Wno-format-truncation')
107 default_cflags += '-Wno-format-truncation'
110 enabled_libs = [] # used to print summary at the end
114 reason = '<unknown reason>' # set if build == false to explain why
116 use_function_versioning = false
119 indirect_headers = [] # public headers not directly included by apps
120 driver_sdk_headers = [] # public headers included by drivers
122 cflags = default_cflags
123 objs = [] # other object files to link against, used e.g. for
124 # instruction-set optimized versions of code
126 # use "deps" for internal DPDK dependencies, and "ext_deps" for
127 # external package/library requirements
130 # eal is standard dependency once built
131 if dpdk_conf.has('RTE_LIB_EAL')
135 if disabled_libs.contains(l)
137 reason = 'explicitly disabled via build config'
142 warning('Library name, "@0@", and directory name, "@1@", do not match'.format(name, l))
146 dpdk_libs_disabled += name
147 set_variable(name.underscorify() + '_disable_reason', reason)
151 shared_deps = ext_deps
152 static_deps = ext_deps
154 if not is_variable('shared_rte_' + d)
155 error('Missing internal dependency "@0@" for @1@ [@2@]'
156 .format(d, name, 'lib/' + l))
158 shared_deps += [get_variable('shared_rte_' + d)]
159 static_deps += [get_variable('static_rte_' + d)]
163 dpdk_conf.set('RTE_LIB_' + name.to_upper(), 1)
164 install_headers(headers)
165 install_headers(indirect_headers)
166 if get_option('enable_driver_sdk')
167 install_headers(driver_sdk_headers)
169 dpdk_chkinc_headers += headers
171 libname = 'rte_' + name
172 includes += include_directories(l)
174 if developer_mode and is_windows and use_function_versioning
175 message('@0@: Function versioning is not supported by Windows.'.format(name))
178 if use_function_versioning
179 cflags += '-DRTE_USE_FUNCTION_VERSIONING'
181 cflags += '-DRTE_LOG_DEFAULT_LOGTYPE=lib.' + l
183 # first build static lib
184 static_lib = static_library(libname,
188 dependencies: static_deps,
189 include_directories: includes,
191 static_dep = declare_dependency(
192 include_directories: includes,
193 dependencies: static_deps)
195 if not use_function_versioning or is_windows
196 # use pre-build objects to build shared lib
198 objs += static_lib.extract_all_objects(recursive: false)
200 # for compat we need to rebuild with
201 # RTE_BUILD_SHARED_LIB defined
202 cflags += '-DRTE_BUILD_SHARED_LIB'
204 version_map = '@0@/@1@/version.map'.format(
205 meson.current_source_dir(), l)
206 implib = 'librte_' + l + '.dll.a'
208 def_file = custom_target(libname + '_def',
209 command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
211 output: '@0@_exports.def'.format(libname))
213 mingw_map = custom_target(libname + '_mingw',
214 command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
216 output: '@0@_mingw.map'.format(libname))
219 lk_args = ['-Wl,/def:' + def_file.full_path()]
220 if meson.version().version_compare('<0.54.0')
221 lk_args += ['-Wl,/implib:lib\\' + implib]
225 lk_args = ['-Wl,--version-script=' + mingw_map.full_path()]
227 lk_args = ['-Wl,--version-script=' + version_map]
231 lk_deps = [version_map, def_file, mingw_map]
232 if developer_mode and not is_windows
233 # on unix systems check the output of the
234 # check-symbols.sh script, using it as a
235 # dependency of the .so build
236 lk_deps += custom_target(name + '.sym_chk',
237 command: [check_symbols,
238 version_map, '@INPUT@'],
241 output: name + '.sym_chk')
244 shared_lib = shared_library(libname,
248 dependencies: shared_deps,
249 include_directories: includes,
251 link_depends: lk_deps,
252 version: abi_version,
253 soversion: so_version,
255 shared_dep = declare_dependency(link_with: shared_lib,
256 include_directories: includes,
257 dependencies: shared_deps)
259 dpdk_libraries = [shared_lib] + dpdk_libraries
260 dpdk_static_libraries = [static_lib] + dpdk_static_libraries
262 set_variable('shared_rte_' + name, shared_dep)
263 set_variable('static_rte_' + name, static_dep)
265 message('lib/@0@: Defining dependency "@1@"'.format(l, name))