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 'raw'] # depends on common, bus, mempool, net and event.
14 default_cflags = machine_args
15 if cc.has_argument('-Wno-format-truncation')
16 default_cflags += '-Wno-format-truncation'
18 foreach class:driver_classes
21 config_flag_fmt = '' # format string used to set the value in dpdk_conf
22 driver_name_fmt = '' # format string for driver name, used to name
23 # the library, the dependency and to find the
24 # version file for linking
29 drv_path = join_paths(class, drv)
31 # set up empty variables used for build
32 build = true # set to false to disable, e.g. missing deps
35 allow_experimental_apis = false
38 cflags = default_cflags
39 includes = [include_directories(drv_path)]
40 # set up internal deps. Drivers can append/override as necessary
42 # ext_deps: Stores external library dependency got
43 # using dependency() or cc.find_library(). For most cases, we
44 # probably also need to specify the "-l" flags in
45 # pkgconfig_extra_libs variable too, so that it can be reflected
46 # in the pkgconfig output for static builds
48 pkgconfig_extra_libs = []
50 # pull in driver directory which should assign to each of the above
54 dpdk_conf.set(config_flag_fmt.format(name.to_upper()),1)
55 lib_name = driver_name_fmt.format(name)
57 if allow_experimental_apis
58 cflags += '-DALLOW_EXPERIMENTAL_API'
61 # get dependency objs from strings
65 if not is_variable('shared_rte_' + d)
66 error('Missing dependency ' + d +
67 ' for driver ' + lib_name)
69 shared_objs += [get_variable('shared_rte_' + d)]
70 static_objs += [get_variable('static_rte_' + d)]
72 shared_objs += ext_deps
73 static_objs += ext_deps
74 dpdk_extra_ldflags += pkgconfig_extra_libs
76 # generate pmdinfo sources by building a temporary
77 # lib and then running pmdinfogen on the contents of
78 # that lib. The final lib reuses the object files and
79 # adds in the new source file.
80 out_filename = lib_name + '.pmd.c'
81 tmp_lib = static_library('tmp_' + lib_name,
83 include_directories: includes,
84 dependencies: static_objs,
86 objs += tmp_lib.extract_all_objects()
87 sources = custom_target(out_filename,
88 command: [pmdinfo, tmp_lib.full_path(),
89 '@OUTPUT@', pmdinfogen],
91 depends: [pmdinfogen, tmp_lib])
93 if get_option('per_library_versions')
94 lib_version = '@0@.1'.format(version)
95 so_version = '@0@'.format(version)
97 pver = meson.project_version().split('.')
98 lib_version = '@0@.@1@'.format(pver.get(0),
100 so_version = lib_version
103 # now build the static driver
104 static_lib = static_library(lib_name,
107 include_directories: includes,
108 dependencies: static_objs,
112 # now build the shared driver
113 version_map = '@0@/@1@/@2@_version.map'.format(
114 meson.current_source_dir(),
116 shared_lib = shared_library(lib_name,
119 include_directories: includes,
120 dependencies: shared_objs,
122 link_args: '-Wl,--version-script=' + version_map,
123 link_depends: version_map,
124 version: lib_version,
125 soversion: so_version,
127 install_dir: driver_install_path)
129 # create a dependency object and add it to the global dictionary so
130 # testpmd or other built-in apps can find it if necessary
131 shared_dep = declare_dependency(link_with: shared_lib,
132 include_directories: includes,
133 dependencies: shared_objs)
134 static_dep = declare_dependency(link_with: static_lib,
135 include_directories: includes,
136 dependencies: static_objs)
138 dpdk_drivers += static_lib
140 set_variable('shared_@0@'.format(lib_name), shared_dep)
141 set_variable('static_@0@'.format(lib_name), static_dep)