1# SPDX-License-Identifier: BSD-3-Clause 2# Copyright(c) 2017-2019 Intel Corporation 3 4 5# process all libraries equally, as far as possible 6# "core" libs first, then others alphabetically as far as possible 7# NOTE: for speed of meson runs, the dependencies in the subdirectories 8# sometimes skip deps that would be implied by others, e.g. if mempool is 9# given as a dep, no need to mention ring. This is especially true for the 10# core libs which are widely reused, so their deps are kept to a minimum. 11libraries = [ 12 'kvargs', # eal depends on kvargs 13 'telemetry', # basic info querying 14 'eal', # everything depends on eal 15 'ring', 16 'rcu', # rcu depends on ring 17 'mempool', 18 'mbuf', 19 'net', 20 'meter', 21 'ethdev', 22 'pci', # core 23 'cmdline', 24 'metrics', # bitrate/latency stats depends on this 25 'hash', # efd depends on this 26 'timer', # eventdev depends on this 27 'acl', 28 'bbdev', 29 'bitratestats', 30 'bpf', 31 'cfgfile', 32 'compressdev', 33 'cryptodev', 34 'distributor', 35 'efd', 36 'eventdev', 37 'gpudev', 38 'gro', 39 'gso', 40 'ip_frag', 41 'jobstats', 42 'kni', 43 'latencystats', 44 'lpm', 45 'member', 46 'pcapng', 47 'power', 48 'rawdev', 49 'regexdev', 50 'dmadev', 51 'rib', 52 'reorder', 53 'sched', 54 'security', 55 'stack', 56 'vhost', 57 'ipsec', # ipsec lib depends on net, crypto and security 58 'fib', #fib lib depends on rib 59 'port', # pkt framework libs which use other libs from above 60 'pdump', # pdump lib depends on bpf 61 'table', 62 'pipeline', 63 'flow_classify', # flow_classify lib depends on pkt framework table lib 64 'graph', 65 'node', 66] 67 68optional_libs = [ 69 'bitratestats', 70 'gpudev', 71 'gro', 72 'gso', 73 'kni', 74 'jobstats', 75 'latencystats', 76 'metrics', 77 'pdump', 78 'power', 79 'vhost', 80] 81 82disabled_libs = [] 83opt_disabled_libs = run_command(list_dir_globs, get_option('disable_libs'), 84 check: true).stdout().split() 85foreach l:opt_disabled_libs 86 if not optional_libs.contains(l) 87 warning('Cannot disable mandatory library "@0@"'.format(l)) 88 continue 89 endif 90 disabled_libs += l 91endforeach 92 93 94default_cflags = machine_args 95default_cflags += ['-DALLOW_EXPERIMENTAL_API'] 96default_cflags += ['-DALLOW_INTERNAL_API'] 97 98if cc.has_argument('-Wno-format-truncation') 99 default_cflags += '-Wno-format-truncation' 100endif 101 102enabled_libs = [] # used to print summary at the end 103 104foreach l:libraries 105 build = true 106 reason = '<unknown reason>' # set if build == false to explain why 107 name = l 108 use_function_versioning = false 109 sources = [] 110 headers = [] 111 indirect_headers = [] # public headers not directly included by apps 112 driver_sdk_headers = [] # public headers included by drivers 113 includes = [] 114 cflags = default_cflags 115 objs = [] # other object files to link against, used e.g. for 116 # instruction-set optimized versions of code 117 118 # use "deps" for internal DPDK dependencies, and "ext_deps" for 119 # external package/library requirements 120 ext_deps = [] 121 deps = [] 122 # eal is standard dependency once built 123 if dpdk_conf.has('RTE_LIB_EAL') 124 deps += ['eal'] 125 endif 126 127 if disabled_libs.contains(l) 128 build = false 129 reason = 'explicitly disabled via build config' 130 else 131 subdir(l) 132 endif 133 if name != l 134 warning('Library name, "@0@", and directory name, "@1@", do not match'.format(name, l)) 135 endif 136 137 if not build 138 dpdk_libs_disabled += name 139 set_variable(name.underscorify() + '_disable_reason', reason) 140 continue 141 endif 142 143 shared_deps = ext_deps 144 static_deps = ext_deps 145 foreach d:deps 146 if not is_variable('shared_rte_' + d) 147 error('Missing internal dependency "@0@" for @1@ [@2@]' 148 .format(d, name, 'lib/' + l)) 149 endif 150 shared_deps += [get_variable('shared_rte_' + d)] 151 static_deps += [get_variable('static_rte_' + d)] 152 endforeach 153 154 enabled_libs += name 155 dpdk_conf.set('RTE_LIB_' + name.to_upper(), 1) 156 install_headers(headers) 157 install_headers(indirect_headers) 158 if get_option('enable_driver_sdk') 159 install_headers(driver_sdk_headers) 160 endif 161 dpdk_chkinc_headers += headers 162 163 libname = 'rte_' + name 164 includes += include_directories(l) 165 166 if developer_mode and is_windows and use_function_versioning 167 message('@0@: Function versioning is not supported by Windows.'.format(name)) 168 endif 169 170 if use_function_versioning 171 cflags += '-DRTE_USE_FUNCTION_VERSIONING' 172 endif 173 cflags += '-DRTE_LOG_DEFAULT_LOGTYPE=lib.' + l 174 175 # first build static lib 176 static_lib = static_library(libname, 177 sources, 178 objects: objs, 179 c_args: cflags, 180 dependencies: static_deps, 181 include_directories: includes, 182 install: true) 183 static_dep = declare_dependency( 184 include_directories: includes, 185 dependencies: static_deps) 186 187 if not use_function_versioning or is_windows 188 # use pre-build objects to build shared lib 189 sources = [] 190 objs += static_lib.extract_all_objects(recursive: false) 191 else 192 # for compat we need to rebuild with 193 # RTE_BUILD_SHARED_LIB defined 194 cflags += '-DRTE_BUILD_SHARED_LIB' 195 endif 196 version_map = '@0@/@1@/version.map'.format( 197 meson.current_source_dir(), l) 198 implib = 'librte_' + l + '.dll.a' 199 200 def_file = custom_target(libname + '_def', 201 command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'], 202 input: version_map, 203 output: '@0@_exports.def'.format(libname)) 204 205 mingw_map = custom_target(libname + '_mingw', 206 command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'], 207 input: version_map, 208 output: '@0@_mingw.map'.format(libname)) 209 210 if is_ms_linker 211 lk_args = ['-Wl,/def:' + def_file.full_path()] 212 if meson.version().version_compare('<0.54.0') 213 lk_args += ['-Wl,/implib:lib\\' + implib] 214 endif 215 else 216 if is_windows 217 lk_args = ['-Wl,--version-script=' + mingw_map.full_path()] 218 else 219 lk_args = ['-Wl,--version-script=' + version_map] 220 endif 221 endif 222 223 lk_deps = [version_map, def_file, mingw_map] 224 if developer_mode and not is_windows 225 # on unix systems check the output of the 226 # check-symbols.sh script, using it as a 227 # dependency of the .so build 228 lk_deps += custom_target(name + '.sym_chk', 229 command: [check_symbols, 230 version_map, '@INPUT@'], 231 capture: true, 232 input: static_lib, 233 output: name + '.sym_chk') 234 endif 235 236 shared_lib = shared_library(libname, 237 sources, 238 objects: objs, 239 c_args: cflags, 240 dependencies: shared_deps, 241 include_directories: includes, 242 link_args: lk_args, 243 link_depends: lk_deps, 244 version: abi_version, 245 soversion: so_version, 246 install: true) 247 shared_dep = declare_dependency(link_with: shared_lib, 248 include_directories: includes, 249 dependencies: shared_deps) 250 251 dpdk_libraries = [shared_lib] + dpdk_libraries 252 dpdk_static_libraries = [static_lib] + dpdk_static_libraries 253 254 set_variable('shared_rte_' + name, shared_dep) 255 set_variable('static_rte_' + name, static_dep) 256 if developer_mode 257 message('lib/@0@: Defining dependency "@1@"'.format(l, name)) 258 endif 259endforeach 260