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