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.
11 'raw'] # depends on common, bus, mempool, net and event.
13 foreach class:driver_classes
16 config_flag_fmt = '' # format string used to set the value in dpdk_conf
17 driver_name_fmt = '' # format string for driver name, used to name
18 # the library, the dependency and to find the
19 # version file for linking
24 drv_path = join_paths(class, drv)
26 # set up empty variables used for build
27 build = true # set to false to disable, e.g. missing deps
30 allow_experimental_apis = false
34 includes = [include_directories(drv_path)]
35 # set up internal deps. Drivers can append/override as necessary
37 # ext_deps: Stores external library dependency got
38 # using dependency() or cc.find_library(). For most cases, we
39 # probably also need to specify the "-l" flags in
40 # pkgconfig_extra_libs variable too, so that it can be reflected
41 # in the pkgconfig output for static builds
43 pkgconfig_extra_libs = []
45 # pull in driver directory which should assign to each of the above
49 dpdk_conf.set(config_flag_fmt.format(name.to_upper()),1)
50 lib_name = driver_name_fmt.format(name)
52 if allow_experimental_apis
53 cflags += '-DALLOW_EXPERIMENTAL_API'
56 # get dependency objs from strings
60 shared_objs += [get_variable('shared_rte_' + d)]
61 static_objs += [get_variable('static_rte_' + d)]
63 shared_objs += ext_deps
64 static_objs += ext_deps
65 dpdk_extra_ldflags += pkgconfig_extra_libs
67 # generate pmdinfo sources by building a temporary
68 # lib and then running pmdinfogen on the contents of
69 # that lib. The final lib reuses the object files and
70 # adds in the new source file.
71 out_filename = lib_name + '.pmd.c'
72 tmp_lib = static_library('tmp_' + lib_name,
74 include_directories: includes,
75 dependencies: static_objs,
77 objs += tmp_lib.extract_all_objects()
78 sources = custom_target(out_filename,
79 command: [pmdinfo, tmp_lib.full_path(),
80 '@OUTPUT@', pmdinfogen],
82 depends: [pmdinfogen, tmp_lib])
84 if get_option('per_library_versions')
85 lib_version = '@0@.1'.format(version)
86 so_version = '@0@'.format(version)
88 pver = meson.project_version().split('.')
89 lib_version = '@0@.@1@'.format(pver.get(0),
91 so_version = lib_version
94 # now build the static driver
95 static_lib = static_library(lib_name,
98 include_directories: includes,
99 dependencies: static_objs,
103 # now build the shared driver
104 version_map = '@0@/@1@/@2@_version.map'.format(
105 meson.current_source_dir(),
107 shared_lib = shared_library(lib_name,
110 include_directories: includes,
111 dependencies: shared_objs,
113 link_args: '-Wl,--version-script=' + version_map,
114 link_depends: version_map,
115 version: lib_version,
116 soversion: so_version,
118 install_dir: driver_install_path)
120 # create a dependency object and add it to the global dictionary so
121 # testpmd or other built-in apps can find it if necessary
122 shared_dep = declare_dependency(link_with: shared_lib,
123 include_directories: includes,
124 dependencies: shared_objs)
125 static_dep = declare_dependency(link_with: static_lib,
126 include_directories: includes,
127 dependencies: static_objs)
129 dpdk_drivers += static_lib
131 set_variable('shared_@0@'.format(lib_name), shared_dep)
132 set_variable('static_@0@'.format(lib_name), static_dep)