1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2017-2019 Intel Corporation
4 # Defines the order in which the drivers are buit.
5 dpdk_driver_classes = ['common',
7 'mempool', # depends on common and bus.
8 'net', # depends on common, bus, mempool
9 'raw', # depends on common, bus and net.
10 'crypto', # depends on common, bus and mempool (net in future).
11 'compress', # depends on common, bus, mempool.
12 'regex', # depends on common, bus, regexdev.
13 'vdpa', # depends on common, bus and mempool.
14 'event', # depends on common, bus, mempool and net.
15 'baseband'] # depends on common and bus.
17 disabled_drivers = run_command(list_dir_globs, get_option('disable_drivers'),
20 default_cflags = machine_args
21 default_cflags += ['-DALLOW_EXPERIMENTAL_API']
22 default_cflags += ['-DALLOW_INTERNAL_API']
24 if cc.has_argument('-Wno-format-truncation')
25 default_cflags += '-Wno-format-truncation'
28 foreach class:dpdk_driver_classes
31 config_flag_fmt = '' # format string used to set the value in dpdk_conf
32 driver_name_fmt = '' # format string for driver name, used to name
33 # the library, the dependency and to find the
34 # version file for linking
40 drv_path = join_paths(class, drv)
42 # set up empty variables used for build
43 build = true # set to false to disable, e.g. missing deps
44 reason = '<unknown reason>' # set if build == false to explain
49 cflags = default_cflags
50 includes = [include_directories(drv_path)]
51 # set up internal deps. Drivers can append/override as necessary
53 # ext_deps: Stores external library dependency got
54 # using dependency() (preferred) or find_library().
55 # For the find_library() case (but not with dependency()) we also
56 # need to specify the "-l" flags in pkgconfig_extra_libs variable
57 # too, so that it can be reflected in the pkgconfig output for
60 pkgconfig_extra_libs = []
62 if disabled_drivers.contains(drv_path)
64 reason = 'Explicitly disabled via build config'
66 # pull in driver directory which should update all the local variables
71 # get dependency objs from strings
72 shared_deps = ext_deps
73 static_deps = ext_deps
75 if not is_variable('shared_rte_' + d)
77 reason = 'Missing internal dependency, "@0@"'.format(d)
78 message('Disabling @1@ [@2@]: missing internal dependency "@0@"'
79 .format(d, name, 'drivers/' + drv_path))
81 shared_deps += [get_variable('shared_rte_' + d)]
82 static_deps += [get_variable('static_rte_' + d)]
88 # some driver directories are placeholders which
89 # are never built, so we allow suppression of the
90 # component disable printout in those cases
92 dpdk_drvs_disabled += drv_path
93 set_variable(drv_path.underscorify() +
94 '_disable_reason', reason)
102 dpdk_conf.set(config_flag_fmt.format(fmt_name.to_upper()),1)
103 lib_name = driver_name_fmt.format(fmt_name)
105 dpdk_extra_ldflags += pkgconfig_extra_libs
107 # generate pmdinfo sources by building a temporary
108 # lib and then running pmdinfogen on the contents of
109 # that lib. The final lib reuses the object files and
110 # adds in the new source file.
112 out_filename = lib_name + '.pmd.c'
113 tmp_lib = static_library('tmp_' + lib_name,
115 include_directories: includes,
116 dependencies: static_deps,
118 objs += tmp_lib.extract_all_objects()
119 sources = custom_target(out_filename,
120 command: [pmdinfo, tmp_lib.full_path(),
121 '@OUTPUT@', pmdinfogen],
122 output: out_filename,
123 depends: [pmdinfogen, tmp_lib])
126 # now build the static driver
127 static_lib = static_library(lib_name,
130 include_directories: includes,
131 dependencies: static_deps,
135 # now build the shared driver
136 version_map = '@0@/@1@/@2@_version.map'.format(
137 meson.current_source_dir(),
139 implib = 'lib' + lib_name + '.dll.a'
141 def_file = custom_target(lib_name + '_def',
142 command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
144 output: '@0@_exports.def'.format(lib_name))
146 mingw_map = custom_target(lib_name + '_mingw',
147 command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
149 output: '@0@_mingw.map'.format(lib_name))
151 lk_deps = [version_map, def_file, mingw_map]
154 lk_args = ['-Wl,/def:' + def_file.full_path(),
155 '-Wl,/implib:drivers\\' + implib]
157 lk_args = ['-Wl,--version-script=' + mingw_map.full_path()]
160 lk_args = ['-Wl,--version-script=' + version_map]
161 # on unix systems check the output of the
162 # check-symbols.sh script, using it as a
163 # dependency of the .so build
164 lk_deps += custom_target(lib_name + '.sym_chk',
165 command: [check_symbols,
166 version_map, '@INPUT@'],
169 output: lib_name + '.sym_chk')
172 shared_lib = shared_library(lib_name,
175 include_directories: includes,
176 dependencies: shared_deps,
179 link_depends: lk_deps,
180 version: abi_version,
181 soversion: so_version,
183 install_dir: driver_install_path)
185 # create a dependency object and add it to the global dictionary so
186 # testpmd or other built-in apps can find it if necessary
187 shared_dep = declare_dependency(link_with: shared_lib,
188 include_directories: includes,
189 dependencies: shared_deps)
190 static_dep = declare_dependency(
191 include_directories: includes,
192 dependencies: static_deps)
194 dpdk_drivers += static_lib
196 set_variable('shared_@0@'.format(lib_name), shared_dep)
197 set_variable('static_@0@'.format(lib_name), static_dep)
198 dependency_name = ''.join(lib_name.split('rte_'))
199 message('drivers/@0@: Defining dependency "@1@"'.format(
200 drv_path, dependency_name))
204 set_variable(class + '_drivers', class_drivers)