1# SPDX-License-Identifier: BSD-3-Clause 2# Copyright(c) 2017 Intel Corporation 3 4# Defines the order in which the drivers are buit. 5driver_classes = ['common', 6 'bus', 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 'compress', # depends on common, bus, mempool. 11 'event', # depends on common, bus, mempool and net. 12 'raw'] # depends on common, bus, mempool, net and event. 13 14default_cflags = machine_args 15if cc.has_argument('-Wno-format-truncation') 16 default_cflags += '-Wno-format-truncation' 17endif 18foreach class:driver_classes 19 drivers = [] 20 std_deps = [] 21 config_flag_fmt = '' # format string used to set the value in dpdk_conf 22 driver_name_fmt = '' # format string for driver name, used to name 23 # the library, the dependency and to find the 24 # version file for linking 25 26 subdir(class) 27 class_drivers = [] 28 29 foreach drv:drivers 30 drv_path = join_paths(class, drv) 31 32 # set up empty variables used for build 33 build = true # set to false to disable, e.g. missing deps 34 name = drv 35 version = 1 36 allow_experimental_apis = false 37 sources = [] 38 objs = [] 39 cflags = default_cflags 40 includes = [include_directories(drv_path)] 41 # set up internal deps. Drivers can append/override as necessary 42 deps = std_deps 43 # ext_deps: Stores external library dependency got 44 # using dependency() or cc.find_library(). For most cases, we 45 # probably also need to specify the "-l" flags in 46 # pkgconfig_extra_libs variable too, so that it can be reflected 47 # in the pkgconfig output for static builds 48 ext_deps = [] 49 pkgconfig_extra_libs = [] 50 51 # pull in driver directory which should assign to each of the above 52 subdir(drv_path) 53 54 if build 55 class_drivers += name 56 57 dpdk_conf.set(config_flag_fmt.format(name.to_upper()),1) 58 lib_name = driver_name_fmt.format(name) 59 60 if allow_experimental_apis 61 cflags += '-DALLOW_EXPERIMENTAL_API' 62 endif 63 64 # get dependency objs from strings 65 shared_objs = [] 66 static_objs = [] 67 foreach d:deps 68 if not is_variable('shared_rte_' + d) 69 error('Missing dependency ' + d + 70 ' for driver ' + lib_name) 71 endif 72 shared_objs += [get_variable('shared_rte_' + d)] 73 static_objs += [get_variable('static_rte_' + d)] 74 endforeach 75 shared_objs += ext_deps 76 static_objs += ext_deps 77 dpdk_extra_ldflags += pkgconfig_extra_libs 78 79 # generate pmdinfo sources by building a temporary 80 # lib and then running pmdinfogen on the contents of 81 # that lib. The final lib reuses the object files and 82 # adds in the new source file. 83 out_filename = lib_name + '.pmd.c' 84 tmp_lib = static_library('tmp_' + lib_name, 85 sources, 86 include_directories: includes, 87 dependencies: static_objs, 88 c_args: cflags) 89 objs += tmp_lib.extract_all_objects() 90 sources = custom_target(out_filename, 91 command: [pmdinfo, tmp_lib.full_path(), 92 '@OUTPUT@', pmdinfogen], 93 output: out_filename, 94 depends: [pmdinfogen, tmp_lib]) 95 96 if get_option('per_library_versions') 97 lib_version = '@[email protected]'.format(version) 98 so_version = '@0@'.format(version) 99 else 100 pver = meson.project_version().split('.') 101 lib_version = '@0@.@1@'.format(pver.get(0), 102 pver.get(1)) 103 so_version = lib_version 104 endif 105 106 # now build the static driver 107 static_lib = static_library(lib_name, 108 sources, 109 objects: objs, 110 include_directories: includes, 111 dependencies: static_objs, 112 c_args: cflags, 113 install: true) 114 115 # now build the shared driver 116 version_map = '@0@/@1@/@2@_version.map'.format( 117 meson.current_source_dir(), 118 drv_path, lib_name) 119 shared_lib = shared_library(lib_name, 120 sources, 121 objects: objs, 122 include_directories: includes, 123 dependencies: shared_objs, 124 c_args: cflags, 125 link_args: '-Wl,--version-script=' + version_map, 126 link_depends: version_map, 127 version: lib_version, 128 soversion: so_version, 129 install: true, 130 install_dir: driver_install_path) 131 132 # create a dependency object and add it to the global dictionary so 133 # testpmd or other built-in apps can find it if necessary 134 shared_dep = declare_dependency(link_with: shared_lib, 135 include_directories: includes, 136 dependencies: shared_objs) 137 static_dep = declare_dependency(link_with: static_lib, 138 include_directories: includes, 139 dependencies: static_objs) 140 141 dpdk_drivers += static_lib 142 143 set_variable('shared_@0@'.format(lib_name), shared_dep) 144 set_variable('static_@0@'.format(lib_name), static_dep) 145 endif # build 146 endforeach 147 148 set_variable(class + '_drivers', class_drivers) 149endforeach 150