1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2017 Intel Corporation
4 # Defines the order in which the drivers are buit.
5 driver_classes = ['common',
7 'mempool', # depends on common and bus.
8 'net', # depends on common, bus and mempool.
9 'crypto', # depends on common, bus and mempool (net in future).
10 'compress', # depends on common, bus, mempool.
11 'event', # depends on common, bus, mempool and net.
12 'baseband', # depends on common and bus.
13 'raw'] # depends on common, bus, mempool, net and event.
15 default_cflags = machine_args
16 if cc.has_argument('-Wno-format-truncation')
17 default_cflags += '-Wno-format-truncation'
19 foreach class:driver_classes
22 config_flag_fmt = '' # format string used to set the value in dpdk_conf
23 driver_name_fmt = '' # format string for driver name, used to name
24 # the library, the dependency and to find the
25 # version file for linking
31 drv_path = join_paths(class, drv)
33 # set up empty variables used for build
34 build = true # set to false to disable, e.g. missing deps
37 allow_experimental_apis = false
40 cflags = default_cflags
41 includes = [include_directories(drv_path)]
42 # set up internal deps. Drivers can append/override as necessary
44 # ext_deps: Stores external library dependency got
45 # using dependency() or cc.find_library(). For most cases, we
46 # probably also need to specify the "-l" flags in
47 # pkgconfig_extra_libs variable too, so that it can be reflected
48 # in the pkgconfig output for static builds
50 pkgconfig_extra_libs = []
52 # pull in driver directory which should assign to each of the above
58 dpdk_conf.set(config_flag_fmt.format(name.to_upper()),1)
59 lib_name = driver_name_fmt.format(name)
61 if allow_experimental_apis
62 cflags += '-DALLOW_EXPERIMENTAL_API'
65 # get dependency objs from strings
69 if not is_variable('shared_rte_' + d)
70 error('Missing dependency ' + d +
71 ' for driver ' + lib_name)
73 shared_objs += [get_variable('shared_rte_' + d)]
74 static_objs += [get_variable('static_rte_' + d)]
76 shared_objs += ext_deps
77 static_objs += ext_deps
78 dpdk_extra_ldflags += pkgconfig_extra_libs
80 # generate pmdinfo sources by building a temporary
81 # lib and then running pmdinfogen on the contents of
82 # that lib. The final lib reuses the object files and
83 # adds in the new source file.
84 out_filename = lib_name + '.pmd.c'
85 tmp_lib = static_library('tmp_' + lib_name,
87 include_directories: includes,
88 dependencies: static_objs,
90 objs += tmp_lib.extract_all_objects()
91 sources = custom_target(out_filename,
92 command: [pmdinfo, tmp_lib.full_path(),
93 '@OUTPUT@', pmdinfogen],
95 depends: [pmdinfogen, tmp_lib])
97 if get_option('per_library_versions')
98 lib_version = '@0@.1'.format(version)
99 so_version = '@0@'.format(version)
101 pver = meson.project_version().split('.')
102 lib_version = '@0@.@1@'.format(pver.get(0),
104 so_version = lib_version
107 # now build the static driver
108 static_lib = static_library(lib_name,
111 include_directories: includes,
112 dependencies: static_objs,
116 # now build the shared driver
117 version_map = '@0@/@1@/@2@_version.map'.format(
118 meson.current_source_dir(),
120 shared_lib = shared_library(lib_name,
123 include_directories: includes,
124 dependencies: shared_objs,
126 link_args: '-Wl,--version-script=' + version_map,
127 link_depends: version_map,
128 version: lib_version,
129 soversion: so_version,
131 install_dir: driver_install_path)
133 # create a dependency object and add it to the global dictionary so
134 # testpmd or other built-in apps can find it if necessary
135 shared_dep = declare_dependency(link_with: shared_lib,
136 include_directories: includes,
137 dependencies: shared_objs)
138 static_dep = declare_dependency(link_with: static_lib,
139 include_directories: includes,
140 dependencies: static_objs)
142 dpdk_drivers += static_lib
144 set_variable('shared_@0@'.format(lib_name), shared_dep)
145 set_variable('static_@0@'.format(lib_name), static_dep)
149 if meson.version().version_compare('>=0.47')
150 # prior to 0.47, set_variable can't take array params
151 set_variable(class + '_drivers', class_drivers)