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
31 cflags = [machine_arg]
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)
49 if allow_experimental_apis
50 cflags += '-DALLOW_EXPERIMENTAL_API'
53 # get dependency objs from strings
57 shared_objs += [get_variable('shared_rte_' + d)]
58 static_objs += [get_variable('static_rte_' + d)]
60 shared_objs += ext_deps
61 static_objs += ext_deps
62 dpdk_extra_ldflags += pkgconfig_extra_libs
64 # generate pmdinfo sources
65 pmdinfogen_srcs = run_command('grep', '--files-with-matches',
66 'RTE_PMD_REGISTER_.*(.*)', sources).stdout().strip().split()
67 foreach src: pmdinfogen_srcs
68 out_filename = '@0@.pmd.c'.format(src.split('/')[-1])
69 tmp_lib = static_library('tmp_@0@'.format(src.underscorify()),
70 src, include_directories: includes,
71 dependencies: static_objs,
73 sources += custom_target(out_filename,
74 command: [pmdinfo, tmp_lib.full_path(),
75 '@OUTPUT@', pmdinfogen],
77 depends: [pmdinfogen, tmp_lib])
80 if get_option('per_library_versions')
81 lib_version = '@0@.1'.format(version)
82 so_version = '@0@'.format(version)
84 pver = meson.project_version().split('.')
85 lib_version = '@0@.@1@'.format(pver.get(0),
87 so_version = lib_version
90 # now build the static driver
91 lib_name = driver_name_fmt.format(name)
92 static_lib = static_library(lib_name,
95 include_directories: includes,
96 dependencies: static_objs,
100 # now build the shared driver
102 objs += static_lib.extract_all_objects()
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)