1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2017-2019 Intel Corporation
4 # Defines the order of dependencies evaluation
8 'common/mlx5', # depends on bus.
9 'mempool', # depends on common and bus.
10 'net', # depends on common, bus, mempool
11 'raw', # depends on common, bus and net.
12 'crypto', # depends on common, bus and mempool (net in future).
13 'compress', # depends on common, bus, mempool.
14 'regex', # depends on common, bus, regexdev.
15 'vdpa', # depends on common, bus and mempool.
16 'event', # depends on common, bus, mempool and net.
17 'baseband', # depends on common and bus.
20 disabled_drivers = run_command(list_dir_globs, get_option('disable_drivers'),
23 default_cflags = machine_args
24 default_cflags += ['-DALLOW_EXPERIMENTAL_API']
25 default_cflags += ['-DALLOW_INTERNAL_API']
27 if cc.has_argument('-Wno-format-truncation')
28 default_cflags += '-Wno-format-truncation'
31 foreach subpath:subdirs
34 config_flag_fmt = '' # format string used to set the value in dpdk_conf
35 driver_name_fmt = '' # format string for driver name, used to name
36 # the library, the dependency and to find the
37 # version file for linking
39 # subpath can be either "class" or "class/driver"
40 if subpath.contains('/')
41 driver_path = subpath.split('/')
42 class = driver_path[0]
43 drivers += driver_path[1]
49 # save class name on first occurrence
50 if not dpdk_driver_classes.contains(class)
51 dpdk_driver_classes += class
53 # get already enabled drivers of the same class
54 enabled_drivers = get_variable(class + '_drivers', [])
57 drv_path = join_paths(class, drv)
59 # set up empty variables used for build
60 build = true # set to false to disable, e.g. missing deps
61 reason = '<unknown reason>' # set if build == false to explain
66 cflags = default_cflags
67 includes = [include_directories(drv_path)]
68 # set up internal deps. Drivers can append/override as necessary
70 # ext_deps: Stores external library dependency got
71 # using dependency() (preferred) or find_library().
72 # For the find_library() case (but not with dependency()) we also
73 # need to specify the "-l" flags in pkgconfig_extra_libs variable
74 # too, so that it can be reflected in the pkgconfig output for
77 pkgconfig_extra_libs = []
79 if disabled_drivers.contains(drv_path)
81 reason = 'Explicitly disabled via build config'
83 # pull in driver directory which should update all the local variables
88 # get dependency objs from strings
89 shared_deps = ext_deps
90 static_deps = ext_deps
92 if not is_variable('shared_rte_' + d)
94 reason = 'Missing internal dependency, "@0@"'.format(d)
95 message('Disabling @1@ [@2@]: missing internal dependency "@0@"'
96 .format(d, name, 'drivers/' + drv_path))
98 shared_deps += [get_variable('shared_rte_' + d)]
99 static_deps += [get_variable('static_rte_' + d)]
105 # some driver directories are placeholders which
106 # are never built, so we allow suppression of the
107 # component disable printout in those cases
109 dpdk_drvs_disabled += drv_path
110 set_variable(drv_path.underscorify() +
111 '_disable_reason', reason)
114 enabled_drivers += name
119 dpdk_conf.set(config_flag_fmt.format(fmt_name.to_upper()),1)
120 # for driver compatibility, since we changed the
121 # default to match that of make. Remove in future release
122 # after following deprecation process
123 if config_flag_fmt.contains('_PMD_@0@') and (class == 'crypto'
124 or class == 'compress'
126 alt_flag_fmt = '_@0@_PMD'.join(
127 config_flag_fmt.split('_PMD_@0@'))
128 if config_flag_fmt.contains('EVENTDEV')
129 alt_flag_fmt = '_@0@_EVENTDEV_PMD'.join(
130 config_flag_fmt.split('_PMD_@0@_EVENTDEV'))
132 dpdk_conf.set(alt_flag_fmt.format(
133 fmt_name.to_upper()), 1)
135 lib_name = driver_name_fmt.format(fmt_name)
137 dpdk_extra_ldflags += pkgconfig_extra_libs
139 # generate pmdinfo sources by building a temporary
140 # lib and then running pmdinfogen on the contents of
141 # that lib. The final lib reuses the object files and
142 # adds in the new source file.
144 out_filename = lib_name + '.pmd.c'
145 tmp_lib = static_library('tmp_' + lib_name,
147 include_directories: includes,
148 dependencies: static_deps,
150 objs += tmp_lib.extract_all_objects()
151 sources = custom_target(out_filename,
152 command: [pmdinfo, tmp_lib.full_path(),
153 '@OUTPUT@', pmdinfogen],
154 output: out_filename,
155 depends: [pmdinfogen, tmp_lib])
158 # now build the static driver
159 static_lib = static_library(lib_name,
162 include_directories: includes,
163 dependencies: static_deps,
167 # now build the shared driver
168 version_map = '@0@/@1@/@2@_version.map'.format(
169 meson.current_source_dir(),
171 implib = 'lib' + lib_name + '.dll.a'
173 def_file = custom_target(lib_name + '_def',
174 command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
176 output: '@0@_exports.def'.format(lib_name))
178 mingw_map = custom_target(lib_name + '_mingw',
179 command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
181 output: '@0@_mingw.map'.format(lib_name))
183 lk_deps = [version_map, def_file, mingw_map]
186 lk_args = ['-Wl,/def:' + def_file.full_path(),
187 '-Wl,/implib:drivers\\' + implib]
189 lk_args = ['-Wl,--version-script=' + mingw_map.full_path()]
192 lk_args = ['-Wl,--version-script=' + version_map]
193 # on unix systems check the output of the
194 # check-symbols.sh script, using it as a
195 # dependency of the .so build
196 lk_deps += custom_target(lib_name + '.sym_chk',
197 command: [check_symbols,
198 version_map, '@INPUT@'],
201 output: lib_name + '.sym_chk')
204 shared_lib = shared_library(lib_name,
207 include_directories: includes,
208 dependencies: shared_deps,
211 link_depends: lk_deps,
212 version: abi_version,
213 soversion: so_version,
215 install_dir: driver_install_path)
217 # create a dependency object and add it to the global dictionary so
218 # testpmd or other built-in apps can find it if necessary
219 shared_dep = declare_dependency(link_with: shared_lib,
220 include_directories: includes,
221 dependencies: shared_deps)
222 static_dep = declare_dependency(
223 include_directories: includes,
224 dependencies: static_deps)
226 dpdk_drivers += static_lib
228 set_variable('shared_@0@'.format(lib_name), shared_dep)
229 set_variable('static_@0@'.format(lib_name), static_dep)
230 dependency_name = ''.join(lib_name.split('rte_'))
231 message('drivers/@0@: Defining dependency "@1@"'.format(
232 drv_path, dependency_name))
236 set_variable(class + '_drivers', enabled_drivers)