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 foreach class:driver_classes
17 config_flag_fmt = '' # format string used to set the value in dpdk_conf
18 driver_name_fmt = '' # format string for driver name, used to name
19 # the library, the dependency and to find the
20 # version file for linking
25 drv_path = join_paths(class, drv)
27 # set up empty variables used for build
28 build = true # set to false to disable, e.g. missing deps
31 allow_experimental_apis = false
35 if cc.has_argument('-Wno-format-truncation')
36 cflags += '-Wno-format-truncation'
38 includes = [include_directories(drv_path)]
39 # set up internal deps. Drivers can append/override as necessary
41 # ext_deps: Stores external library dependency got
42 # using dependency() or cc.find_library(). For most cases, we
43 # probably also need to specify the "-l" flags in
44 # pkgconfig_extra_libs variable too, so that it can be reflected
45 # in the pkgconfig output for static builds
47 pkgconfig_extra_libs = []
49 # pull in driver directory which should assign to each of the above
53 dpdk_conf.set(config_flag_fmt.format(name.to_upper()),1)
54 lib_name = driver_name_fmt.format(name)
56 if allow_experimental_apis
57 cflags += '-DALLOW_EXPERIMENTAL_API'
60 # get dependency objs from strings
64 shared_objs += [get_variable('shared_rte_' + d)]
65 static_objs += [get_variable('static_rte_' + d)]
67 shared_objs += ext_deps
68 static_objs += ext_deps
69 dpdk_extra_ldflags += pkgconfig_extra_libs
71 # generate pmdinfo sources by building a temporary
72 # lib and then running pmdinfogen on the contents of
73 # that lib. The final lib reuses the object files and
74 # adds in the new source file.
75 out_filename = lib_name + '.pmd.c'
76 tmp_lib = static_library('tmp_' + lib_name,
78 include_directories: includes,
79 dependencies: static_objs,
81 objs += tmp_lib.extract_all_objects()
82 sources = custom_target(out_filename,
83 command: [pmdinfo, tmp_lib.full_path(),
84 '@OUTPUT@', pmdinfogen],
86 depends: [pmdinfogen, tmp_lib])
88 if get_option('per_library_versions')
89 lib_version = '@0@.1'.format(version)
90 so_version = '@0@'.format(version)
92 pver = meson.project_version().split('.')
93 lib_version = '@0@.@1@'.format(pver.get(0),
95 so_version = lib_version
98 # now build the static driver
99 static_lib = static_library(lib_name,
102 include_directories: includes,
103 dependencies: static_objs,
107 # now build the shared driver
108 version_map = '@0@/@1@/@2@_version.map'.format(
109 meson.current_source_dir(),
111 shared_lib = shared_library(lib_name,
114 include_directories: includes,
115 dependencies: shared_objs,
117 link_args: '-Wl,--version-script=' + version_map,
118 link_depends: version_map,
119 version: lib_version,
120 soversion: so_version,
122 install_dir: driver_install_path)
124 # create a dependency object and add it to the global dictionary so
125 # testpmd or other built-in apps can find it if necessary
126 shared_dep = declare_dependency(link_with: shared_lib,
127 include_directories: includes,
128 dependencies: shared_objs)
129 static_dep = declare_dependency(link_with: static_lib,
130 include_directories: includes,
131 dependencies: static_objs)
133 dpdk_drivers += static_lib
135 set_variable('shared_@0@'.format(lib_name), shared_dep)
136 set_variable('static_@0@'.format(lib_name), static_dep)