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 = ['bus',
6 'mempool', # depends on bus.
7 'net', # depends on bus and mempool.
8 'crypto', # depenss on bus, mempool (net in future).
9 'event'] # depends on bus, mempool and net.
11 foreach class:driver_classes
14 config_flag_fmt = '' # format string used to set the value in dpdk_conf
15 driver_name_fmt = '' # format string for driver name, used to name
16 # the library, the dependency and to find the
17 # version file for linking
22 drv_path = join_paths(class, drv)
24 # set up empty variables used for build
25 build = true # set to false to disable, e.g. missing deps
28 allow_experimental_apis = false
32 includes = [include_directories(drv_path)]
33 # set up internal deps. Drivers can append/override as necessary
35 # ext_deps: Stores external library dependency got
36 # using dependency() or cc.find_library(). For most cases, we
37 # probably also need to specify the "-l" flags in
38 # pkgconfig_extra_libs variable too, so that it can be reflected
39 # in the pkgconfig output for static builds
41 pkgconfig_extra_libs = []
43 # pull in driver directory which should assign to each of the above
47 dpdk_conf.set(config_flag_fmt.format(name.to_upper()),1)
48 lib_name = driver_name_fmt.format(name)
50 if allow_experimental_apis
51 cflags += '-DALLOW_EXPERIMENTAL_API'
54 # get dependency objs from strings
58 shared_objs += [get_variable('shared_rte_' + d)]
59 static_objs += [get_variable('static_rte_' + d)]
61 shared_objs += ext_deps
62 static_objs += ext_deps
63 dpdk_extra_ldflags += pkgconfig_extra_libs
65 # generate pmdinfo sources by building a temporary
66 # lib and then running pmdinfogen on the contents of
67 # that lib. The final lib reuses the object files and
68 # adds in the new source file.
69 out_filename = lib_name + '.pmd.c'
70 tmp_lib = static_library('tmp_' + lib_name,
72 include_directories: includes,
73 dependencies: static_objs,
75 objs += tmp_lib.extract_all_objects()
76 sources = custom_target(out_filename,
77 command: [pmdinfo, tmp_lib.full_path(),
78 '@OUTPUT@', pmdinfogen],
80 depends: [pmdinfogen, tmp_lib])
82 if get_option('per_library_versions')
83 lib_version = '@0@.1'.format(version)
84 so_version = '@0@'.format(version)
86 pver = meson.project_version().split('.')
87 lib_version = '@0@.@1@'.format(pver.get(0),
89 so_version = lib_version
92 # now build the static driver
93 static_lib = static_library(lib_name,
96 include_directories: includes,
97 dependencies: static_objs,
101 # now build the shared driver
102 version_map = '@0@/@1@/@2@_version.map'.format(
103 meson.current_source_dir(),
105 shared_lib = shared_library(lib_name,
108 include_directories: includes,
109 dependencies: shared_objs,
111 link_args: '-Wl,--version-script=' + version_map,
112 link_depends: version_map,
113 version: lib_version,
114 soversion: so_version,
116 install_dir: driver_install_path)
118 # create a dependency object and add it to the global dictionary so
119 # testpmd or other built-in apps can find it if necessary
120 shared_dep = declare_dependency(link_with: shared_lib,
121 include_directories: includes,
122 dependencies: shared_objs)
123 static_dep = declare_dependency(link_with: static_lib,
124 include_directories: includes,
125 dependencies: static_objs)
127 dpdk_drivers += static_lib
129 set_variable('shared_@0@'.format(lib_name), shared_dep)
130 set_variable('static_@0@'.format(lib_name), static_dep)