1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2017 Intel Corporation
4 driver_classes = ['bus', 'crypto', 'event', 'mempool', 'net']
6 foreach class:driver_classes
9 config_flag_fmt = '' # format string used to set the value in dpdk_conf
10 driver_name_fmt = '' # format string for driver name, used to name
11 # the library, the dependency and to find the
12 # version file for linking
17 drv_path = join_paths(class, drv)
19 # set up empty variables used for build
20 build = true # set to false to disable, e.g. missing deps
23 allow_experimental_apis = false
26 cflags = [machine_arg]
27 includes = [include_directories(drv_path)]
28 # set up internal deps. Drivers can append/override as necessary
30 # ext_deps: Stores external library dependency got
31 # using dependency() or cc.find_library(). For most cases, we
32 # probably also need to specify the "-l" flags in
33 # pkgconfig_extra_libs variable too, so that it can be reflected
34 # in the pkgconfig output for static builds
36 pkgconfig_extra_libs = []
38 # pull in driver directory which should assign to each of the above
42 dpdk_conf.set(config_flag_fmt.format(name.to_upper()),1)
44 if allow_experimental_apis
45 cflags += '-DALLOW_EXPERIMENTAL_API'
48 # get dependency objs from strings
52 shared_objs += [get_variable('shared_rte_' + d)]
53 static_objs += [get_variable('static_rte_' + d)]
55 shared_objs += ext_deps
56 static_objs += ext_deps
57 dpdk_extra_ldflags += pkgconfig_extra_libs
59 # generate pmdinfo sources
60 pmdinfogen_srcs = run_command('grep', '--files-with-matches',
61 'RTE_PMD_REGISTER_.*(.*)', sources).stdout().strip().split()
62 foreach src: pmdinfogen_srcs
63 out_filename = '@0@.pmd.c'.format(src.split('/')[-1])
64 tmp_lib = static_library('tmp_@0@'.format(src.underscorify()),
65 src, include_directories: includes,
66 dependencies: static_objs,
68 sources += custom_target(out_filename,
69 command: [pmdinfo, tmp_lib.full_path(),
70 '@OUTPUT@', pmdinfogen],
72 depends: [pmdinfogen, tmp_lib])
75 if get_option('per_library_versions')
76 lib_version = '@0@.1'.format(version)
77 so_version = '@0@'.format(version)
79 pver = meson.project_version().split('.')
80 lib_version = '@0@.@1@'.format(pver.get(0),
82 so_version = lib_version
85 # now build the static driver
86 lib_name = driver_name_fmt.format(name)
87 static_lib = static_library(lib_name,
90 include_directories: includes,
91 dependencies: static_objs,
95 # now build the shared driver
97 objs += static_lib.extract_all_objects()
98 version_map = '@0@/@1@/@2@_version.map'.format(
99 meson.current_source_dir(),
101 shared_lib = shared_library(lib_name,
104 include_directories: includes,
105 dependencies: shared_objs,
107 link_args: '-Wl,--version-script=' + version_map,
108 link_depends: version_map,
109 version: lib_version,
110 soversion: so_version,
112 install_dir: driver_install_path)
114 # create a dependency object and add it to the global dictionary so
115 # testpmd or other built-in apps can find it if necessary
116 shared_dep = declare_dependency(link_with: shared_lib,
117 include_directories: includes,
118 dependencies: shared_objs)
119 static_dep = declare_dependency(link_with: static_lib,
120 include_directories: includes,
121 dependencies: static_objs)
123 dpdk_drivers += static_lib
125 set_variable('shared_@0@'.format(lib_name), shared_dep)
126 set_variable('static_@0@'.format(lib_name), static_dep)