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 'event'] # depends on common, bus, mempool and net.
12 foreach class:driver_classes
15 config_flag_fmt = '' # format string used to set the value in dpdk_conf
16 driver_name_fmt = '' # format string for driver name, used to name
17 # the library, the dependency and to find the
18 # version file for linking
23 drv_path = join_paths(class, drv)
25 # set up empty variables used for build
26 build = true # set to false to disable, e.g. missing deps
29 allow_experimental_apis = false
33 includes = [include_directories(drv_path)]
34 # set up internal deps. Drivers can append/override as necessary
36 # ext_deps: Stores external library dependency got
37 # using dependency() or cc.find_library(). For most cases, we
38 # probably also need to specify the "-l" flags in
39 # pkgconfig_extra_libs variable too, so that it can be reflected
40 # in the pkgconfig output for static builds
42 pkgconfig_extra_libs = []
44 # pull in driver directory which should assign to each of the above
48 dpdk_conf.set(config_flag_fmt.format(name.to_upper()),1)
49 lib_name = driver_name_fmt.format(name)
51 if allow_experimental_apis
52 cflags += '-DALLOW_EXPERIMENTAL_API'
55 # get dependency objs from strings
59 shared_objs += [get_variable('shared_rte_' + d)]
60 static_objs += [get_variable('static_rte_' + d)]
62 shared_objs += ext_deps
63 static_objs += ext_deps
64 dpdk_extra_ldflags += pkgconfig_extra_libs
66 # generate pmdinfo sources by building a temporary
67 # lib and then running pmdinfogen on the contents of
68 # that lib. The final lib reuses the object files and
69 # adds in the new source file.
70 out_filename = lib_name + '.pmd.c'
71 tmp_lib = static_library('tmp_' + lib_name,
73 include_directories: includes,
74 dependencies: static_objs,
76 objs += tmp_lib.extract_all_objects()
77 sources = custom_target(out_filename,
78 command: [pmdinfo, tmp_lib.full_path(),
79 '@OUTPUT@', pmdinfogen],
81 depends: [pmdinfogen, tmp_lib])
83 if get_option('per_library_versions')
84 lib_version = '@0@.1'.format(version)
85 so_version = '@0@'.format(version)
87 pver = meson.project_version().split('.')
88 lib_version = '@0@.@1@'.format(pver.get(0),
90 so_version = lib_version
93 # now build the static driver
94 static_lib = static_library(lib_name,
97 include_directories: includes,
98 dependencies: static_objs,
102 # now build the shared driver
103 version_map = '@0@/@1@/@2@_version.map'.format(
104 meson.current_source_dir(),
106 shared_lib = shared_library(lib_name,
109 include_directories: includes,
110 dependencies: shared_objs,
112 link_args: '-Wl,--version-script=' + version_map,
113 link_depends: version_map,
114 version: lib_version,
115 soversion: so_version,
117 install_dir: driver_install_path)
119 # create a dependency object and add it to the global dictionary so
120 # testpmd or other built-in apps can find it if necessary
121 shared_dep = declare_dependency(link_with: shared_lib,
122 include_directories: includes,
123 dependencies: shared_objs)
124 static_dep = declare_dependency(link_with: static_lib,
125 include_directories: includes,
126 dependencies: static_objs)
128 dpdk_drivers += static_lib
130 set_variable('shared_@0@'.format(lib_name), shared_dep)
131 set_variable('static_@0@'.format(lib_name), static_dep)