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 'baseband', # depends on common and bus. 13 'raw'] # depends on common, bus, mempool, net and event. 14 15default_cflags = machine_args 16if cc.has_argument('-Wno-format-truncation') 17 default_cflags += '-Wno-format-truncation' 18endif 19 20foreach class:driver_classes 21 drivers = [] 22 std_deps = [] 23 config_flag_fmt = '' # format string used to set the value in dpdk_conf 24 driver_name_fmt = '' # format string for driver name, used to name 25 # the library, the dependency and to find the 26 # version file for linking 27 28 subdir(class) 29 class_drivers = [] 30 31 foreach drv:drivers 32 drv_path = join_paths(class, drv) 33 34 # set up empty variables used for build 35 build = true # set to false to disable, e.g. missing deps 36 name = drv 37 version = 1 38 allow_experimental_apis = false 39 sources = [] 40 objs = [] 41 cflags = default_cflags 42 includes = [include_directories(drv_path)] 43 # set up internal deps. Drivers can append/override as necessary 44 deps = std_deps 45 # ext_deps: Stores external library dependency got 46 # using dependency() or cc.find_library(). For most cases, we 47 # probably also need to specify the "-l" flags in 48 # pkgconfig_extra_libs variable too, so that it can be reflected 49 # in the pkgconfig output for static builds 50 ext_deps = [] 51 pkgconfig_extra_libs = [] 52 53 # pull in driver directory which should assign to each of the above 54 subdir(drv_path) 55 56 if build 57 class_drivers += name 58 59 dpdk_conf.set(config_flag_fmt.format(name.to_upper()),1) 60 lib_name = driver_name_fmt.format(name) 61 62 if allow_experimental_apis 63 cflags += '-DALLOW_EXPERIMENTAL_API' 64 endif 65 66 # get dependency objs from strings 67 shared_objs = [] 68 static_objs = [] 69 foreach d:deps 70 if not is_variable('shared_rte_' + d) 71 error('Missing dependency ' + d + 72 ' for driver ' + lib_name) 73 endif 74 shared_objs += [get_variable('shared_rte_' + d)] 75 static_objs += [get_variable('static_rte_' + d)] 76 endforeach 77 shared_objs += ext_deps 78 static_objs += ext_deps 79 dpdk_extra_ldflags += pkgconfig_extra_libs 80 81 # generate pmdinfo sources by building a temporary 82 # lib and then running pmdinfogen on the contents of 83 # that lib. The final lib reuses the object files and 84 # adds in the new source file. 85 out_filename = lib_name + '.pmd.c' 86 tmp_lib = static_library('tmp_' + lib_name, 87 sources, 88 include_directories: includes, 89 dependencies: static_objs, 90 c_args: cflags) 91 objs += tmp_lib.extract_all_objects() 92 sources = custom_target(out_filename, 93 command: [pmdinfo, tmp_lib.full_path(), 94 '@OUTPUT@', pmdinfogen], 95 output: out_filename, 96 depends: [pmdinfogen, tmp_lib]) 97 98 if get_option('per_library_versions') 99 lib_version = '@[email protected]'.format(version) 100 so_version = '@0@'.format(version) 101 else 102 lib_version = major_version 103 so_version = major_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 if meson.version().version_compare('>=0.47') 149 # prior to 0.47, set_variable can't take array params 150 set_variable(class + '_drivers', class_drivers) 151 endif 152endforeach 153