1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2017-2019 Intel Corporation
8 # Defines the order in which the drivers are buit.
9 dpdk_driver_classes = ['common',
11 'mempool', # depends on common and bus.
12 'net', # depends on common, bus and mempool.
13 'crypto', # depends on common, bus and mempool (net in future).
14 'compress', # depends on common, bus, mempool.
15 'event', # depends on common, bus, mempool and net.
16 'baseband', # depends on common and bus.
17 'raw'] # depends on common, bus, mempool, net and event.
19 default_cflags = machine_args
20 if cc.has_argument('-Wno-format-truncation')
21 default_cflags += '-Wno-format-truncation'
24 foreach class:dpdk_driver_classes
27 config_flag_fmt = '' # format string used to set the value in dpdk_conf
28 driver_name_fmt = '' # format string for driver name, used to name
29 # the library, the dependency and to find the
30 # version file for linking
36 drv_path = join_paths(class, drv)
38 # set up empty variables used for build
39 build = true # set to false to disable, e.g. missing deps
40 reason = '<unknown reason>' # set if build == false to explain
43 allow_experimental_apis = false
46 cflags = default_cflags
47 includes = [include_directories(drv_path)]
48 # set up internal deps. Drivers can append/override as necessary
50 # ext_deps: Stores external library dependency got
51 # using dependency() (preferred) or find_library().
52 # For the find_library() case (but not with dependency()) we also
53 # need to specify the "-l" flags in pkgconfig_extra_libs variable
54 # too, so that it can be reflected in the pkgconfig output for
57 pkgconfig_extra_libs = []
59 # pull in driver directory which should assign to each of the above
63 # some driver directories are placeholders which
64 # are never built, so we allow suppression of the
65 # component disable printout in those cases
67 dpdk_drvs_disabled += drv_path
68 set_variable(drv_path.underscorify() +
69 '_disable_reason', reason)
74 dpdk_conf.set(config_flag_fmt.format(name.to_upper()),1)
75 lib_name = driver_name_fmt.format(name)
77 if allow_experimental_apis
78 cflags += '-DALLOW_EXPERIMENTAL_API'
81 # get dependency objs from strings
85 if not is_variable('shared_rte_' + d)
86 error('Missing dependency ' + d +
87 ' for driver ' + lib_name)
89 shared_objs += [get_variable('shared_rte_' + d)]
90 static_objs += [get_variable('static_rte_' + d)]
92 shared_objs += ext_deps
93 static_objs += ext_deps
94 dpdk_extra_ldflags += pkgconfig_extra_libs
96 # generate pmdinfo sources by building a temporary
97 # lib and then running pmdinfogen on the contents of
98 # that lib. The final lib reuses the object files and
99 # adds in the new source file.
100 out_filename = lib_name + '.pmd.c'
101 tmp_lib = static_library('tmp_' + lib_name,
103 include_directories: includes,
104 dependencies: static_objs,
106 objs += tmp_lib.extract_all_objects()
107 sources = custom_target(out_filename,
108 command: [pmdinfo, tmp_lib.full_path(),
109 '@OUTPUT@', pmdinfogen],
110 output: out_filename,
111 depends: [pmdinfogen, tmp_lib])
113 if get_option('per_library_versions')
114 lib_version = '@0@.1'.format(version)
115 so_version = '@0@'.format(version)
117 lib_version = major_version
118 so_version = major_version
121 # now build the static driver
122 static_lib = static_library(lib_name,
125 include_directories: includes,
126 dependencies: static_objs,
130 # now build the shared driver
131 version_map = '@0@/@1@/@2@_version.map'.format(
132 meson.current_source_dir(),
134 shared_lib = shared_library(lib_name,
137 include_directories: includes,
138 dependencies: shared_objs,
140 link_args: '-Wl,--version-script=' + version_map,
141 link_depends: version_map,
142 version: lib_version,
143 soversion: so_version,
145 install_dir: driver_install_path)
147 # create a dependency object and add it to the global dictionary so
148 # testpmd or other built-in apps can find it if necessary
149 shared_dep = declare_dependency(link_with: shared_lib,
150 include_directories: includes,
151 dependencies: shared_objs)
152 static_dep = declare_dependency(link_with: static_lib,
153 include_directories: includes,
154 dependencies: static_objs)
156 dpdk_drivers += static_lib
158 set_variable('shared_@0@'.format(lib_name), shared_dep)
159 set_variable('static_@0@'.format(lib_name), static_dep)
163 set_variable(class + '_drivers', class_drivers)