1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2017-2019 Intel Corporation
4 # Defines the order of dependencies evaluation
8 'mempool', # depends on common and bus.
9 'net', # depends on common, bus, mempool
10 'raw', # depends on common, bus and net.
11 'crypto', # depends on common, bus and mempool (net in future).
12 'compress', # depends on common, bus, mempool.
13 'regex', # depends on common, bus, regexdev.
14 'vdpa', # depends on common, bus and mempool.
15 'event', # depends on common, bus, mempool and net.
16 'baseband', # depends on common and bus.
19 disabled_drivers = run_command(list_dir_globs, get_option('disable_drivers'),
22 default_cflags = machine_args
23 default_cflags += ['-DALLOW_EXPERIMENTAL_API']
24 default_cflags += ['-DALLOW_INTERNAL_API']
26 if cc.has_argument('-Wno-format-truncation')
27 default_cflags += '-Wno-format-truncation'
30 foreach subpath:subdirs
33 config_flag_fmt = '' # format string used to set the value in dpdk_conf
34 driver_name_fmt = '' # format string for driver name, used to name
35 # the library, the dependency and to find the
36 # version file for linking
38 # subpath can be either "class" or "class/driver"
39 if subpath.contains('/')
40 driver_path = subpath.split('/')
41 class = driver_path[0]
42 drivers += driver_path[1]
48 # save class name on first occurrence
49 if not dpdk_driver_classes.contains(class)
50 dpdk_driver_classes += class
52 # get already enabled drivers of the same class
53 enabled_drivers = get_variable(class + '_drivers', [])
56 drv_path = join_paths(class, drv)
58 # set up empty variables used for build
59 build = true # set to false to disable, e.g. missing deps
60 reason = '<unknown reason>' # set if build == false to explain
65 cflags = default_cflags
66 includes = [include_directories(drv_path)]
67 # set up internal deps. Drivers can append/override as necessary
69 # ext_deps: Stores external library dependency got
70 # using dependency() (preferred) or find_library().
71 # For the find_library() case (but not with dependency()) we also
72 # need to specify the "-l" flags in pkgconfig_extra_libs variable
73 # too, so that it can be reflected in the pkgconfig output for
76 pkgconfig_extra_libs = []
78 if disabled_drivers.contains(drv_path)
80 reason = 'Explicitly disabled via build config'
82 # pull in driver directory which should update all the local variables
87 # get dependency objs from strings
88 shared_deps = ext_deps
89 static_deps = ext_deps
91 if not is_variable('shared_rte_' + d)
93 reason = 'Missing internal dependency, "@0@"'.format(d)
94 message('Disabling @1@ [@2@]: missing internal dependency "@0@"'
95 .format(d, name, 'drivers/' + drv_path))
97 shared_deps += [get_variable('shared_rte_' + d)]
98 static_deps += [get_variable('static_rte_' + d)]
104 # some driver directories are placeholders which
105 # are never built, so we allow suppression of the
106 # component disable printout in those cases
108 dpdk_drvs_disabled += drv_path
109 set_variable(drv_path.underscorify() +
110 '_disable_reason', reason)
113 enabled_drivers += name
118 dpdk_conf.set(config_flag_fmt.format(fmt_name.to_upper()),1)
119 lib_name = driver_name_fmt.format(fmt_name)
121 dpdk_extra_ldflags += pkgconfig_extra_libs
123 # generate pmdinfo sources by building a temporary
124 # lib and then running pmdinfogen on the contents of
125 # that lib. The final lib reuses the object files and
126 # adds in the new source file.
128 out_filename = lib_name + '.pmd.c'
129 tmp_lib = static_library('tmp_' + lib_name,
131 include_directories: includes,
132 dependencies: static_deps,
134 objs += tmp_lib.extract_all_objects()
135 sources = custom_target(out_filename,
136 command: [pmdinfo, tmp_lib.full_path(),
137 '@OUTPUT@', pmdinfogen],
138 output: out_filename,
139 depends: [pmdinfogen, tmp_lib])
142 # now build the static driver
143 static_lib = static_library(lib_name,
146 include_directories: includes,
147 dependencies: static_deps,
151 # now build the shared driver
152 version_map = '@0@/@1@/@2@_version.map'.format(
153 meson.current_source_dir(),
155 implib = 'lib' + lib_name + '.dll.a'
157 def_file = custom_target(lib_name + '_def',
158 command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
160 output: '@0@_exports.def'.format(lib_name))
162 mingw_map = custom_target(lib_name + '_mingw',
163 command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
165 output: '@0@_mingw.map'.format(lib_name))
167 lk_deps = [version_map, def_file, mingw_map]
170 lk_args = ['-Wl,/def:' + def_file.full_path(),
171 '-Wl,/implib:drivers\\' + implib]
173 lk_args = ['-Wl,--version-script=' + mingw_map.full_path()]
176 lk_args = ['-Wl,--version-script=' + version_map]
177 # on unix systems check the output of the
178 # check-symbols.sh script, using it as a
179 # dependency of the .so build
180 lk_deps += custom_target(lib_name + '.sym_chk',
181 command: [check_symbols,
182 version_map, '@INPUT@'],
185 output: lib_name + '.sym_chk')
188 shared_lib = shared_library(lib_name,
191 include_directories: includes,
192 dependencies: shared_deps,
195 link_depends: lk_deps,
196 version: abi_version,
197 soversion: so_version,
199 install_dir: driver_install_path)
201 # create a dependency object and add it to the global dictionary so
202 # testpmd or other built-in apps can find it if necessary
203 shared_dep = declare_dependency(link_with: shared_lib,
204 include_directories: includes,
205 dependencies: shared_deps)
206 static_dep = declare_dependency(
207 include_directories: includes,
208 dependencies: static_deps)
210 dpdk_drivers += static_lib
212 set_variable('shared_@0@'.format(lib_name), shared_dep)
213 set_variable('static_@0@'.format(lib_name), static_dep)
214 dependency_name = ''.join(lib_name.split('rte_'))
215 message('drivers/@0@: Defining dependency "@1@"'.format(
216 drv_path, dependency_name))
220 set_variable(class + '_drivers', enabled_drivers)