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 alphebetically 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 'gro', 71 'gso', 72 'kni', 73 'jobstats', 74 'latencystats', 75 'metrics', 76 'pdump', 77 'power', 78 'vhost', 79] 80 81disabled_libs = [] 82opt_disabled_libs = run_command(list_dir_globs, get_option('disable_libs'), 83 check: true).stdout().split() 84foreach l:opt_disabled_libs 85 if not optional_libs.contains(l) 86 warning('Cannot disable mandatory library "@0@"'.format(l)) 87 continue 88 endif 89 disabled_libs += l 90endforeach 91 92 93default_cflags = machine_args 94default_cflags += ['-DALLOW_EXPERIMENTAL_API'] 95default_cflags += ['-DALLOW_INTERNAL_API'] 96 97if cc.has_argument('-Wno-format-truncation') 98 default_cflags += '-Wno-format-truncation' 99endif 100 101enabled_libs = [] # used to print summary at the end 102 103foreach l:libraries 104 build = true 105 reason = '<unknown reason>' # set if build == false to explain why 106 name = l 107 use_function_versioning = false 108 sources = [] 109 headers = [] 110 indirect_headers = [] # public headers not directly included by apps 111 driver_sdk_headers = [] # public headers included by drivers 112 includes = [] 113 cflags = default_cflags 114 objs = [] # other object files to link against, used e.g. for 115 # instruction-set optimized versions of code 116 117 # use "deps" for internal DPDK dependencies, and "ext_deps" for 118 # external package/library requirements 119 ext_deps = [] 120 deps = [] 121 # eal is standard dependency once built 122 if dpdk_conf.has('RTE_LIB_EAL') 123 deps += ['eal'] 124 endif 125 126 if disabled_libs.contains(l) 127 build = false 128 reason = 'explicitly disabled via build config' 129 else 130 subdir(l) 131 endif 132 if name != l 133 warning('Library name, "@0@", and directory name, "@1@", do not match'.format(name, l)) 134 endif 135 136 if not build 137 dpdk_libs_disabled += name 138 set_variable(name.underscorify() + '_disable_reason', reason) 139 continue 140 endif 141 142 shared_deps = ext_deps 143 static_deps = ext_deps 144 foreach d:deps 145 if not is_variable('shared_rte_' + d) 146 error('Missing internal dependency "@0@" for @1@ [@2@]' 147 .format(d, name, 'lib/' + l)) 148 endif 149 shared_deps += [get_variable('shared_rte_' + d)] 150 static_deps += [get_variable('static_rte_' + d)] 151 endforeach 152 153 enabled_libs += name 154 dpdk_conf.set('RTE_LIB_' + name.to_upper(), 1) 155 install_headers(headers) 156 install_headers(indirect_headers) 157 if get_option('enable_driver_sdk') 158 install_headers(driver_sdk_headers) 159 endif 160 dpdk_chkinc_headers += headers 161 162 libname = 'rte_' + name 163 includes += include_directories(l) 164 165 if developer_mode and is_windows and use_function_versioning 166 message('@0@: Function versioning is not supported by Windows.'.format(name)) 167 endif 168 169 if use_function_versioning 170 cflags += '-DRTE_USE_FUNCTION_VERSIONING' 171 endif 172 cflags += '-DRTE_LOG_DEFAULT_LOGTYPE=lib.' + l 173 174 # first build static lib 175 static_lib = static_library(libname, 176 sources, 177 objects: objs, 178 c_args: cflags, 179 dependencies: static_deps, 180 include_directories: includes, 181 install: true) 182 static_dep = declare_dependency( 183 include_directories: includes, 184 dependencies: static_deps) 185 186 if not use_function_versioning or is_windows 187 # use pre-build objects to build shared lib 188 sources = [] 189 objs += static_lib.extract_all_objects(recursive: false) 190 else 191 # for compat we need to rebuild with 192 # RTE_BUILD_SHARED_LIB defined 193 cflags += '-DRTE_BUILD_SHARED_LIB' 194 endif 195 version_map = '@0@/@1@/version.map'.format( 196 meson.current_source_dir(), l) 197 implib = 'librte_' + l + '.dll.a' 198 199 def_file = custom_target(libname + '_def', 200 command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'], 201 input: version_map, 202 output: '@0@_exports.def'.format(libname)) 203 204 mingw_map = custom_target(libname + '_mingw', 205 command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'], 206 input: version_map, 207 output: '@0@_mingw.map'.format(libname)) 208 209 if is_ms_linker 210 lk_args = ['-Wl,/def:' + def_file.full_path()] 211 if meson.version().version_compare('<0.54.0') 212 lk_args += ['-Wl,/implib:lib\\' + implib] 213 endif 214 else 215 if is_windows 216 lk_args = ['-Wl,--version-script=' + mingw_map.full_path()] 217 else 218 lk_args = ['-Wl,--version-script=' + version_map] 219 endif 220 endif 221 222 lk_deps = [version_map, def_file, mingw_map] 223 if developer_mode and not is_windows 224 # on unix systems check the output of the 225 # check-symbols.sh script, using it as a 226 # dependency of the .so build 227 lk_deps += custom_target(name + '.sym_chk', 228 command: [check_symbols, 229 version_map, '@INPUT@'], 230 capture: true, 231 input: static_lib, 232 output: name + '.sym_chk') 233 endif 234 235 shared_lib = shared_library(libname, 236 sources, 237 objects: objs, 238 c_args: cflags, 239 dependencies: shared_deps, 240 include_directories: includes, 241 link_args: lk_args, 242 link_depends: lk_deps, 243 version: abi_version, 244 soversion: so_version, 245 install: true) 246 shared_dep = declare_dependency(link_with: shared_lib, 247 include_directories: includes, 248 dependencies: shared_deps) 249 250 dpdk_libraries = [shared_lib] + dpdk_libraries 251 dpdk_static_libraries = [static_lib] + dpdk_static_libraries 252 253 set_variable('shared_rte_' + name, shared_dep) 254 set_variable('static_rte_' + name, static_dep) 255 if developer_mode 256 message('lib/@0@: Defining dependency "@1@"'.format(l, name)) 257 endif 258endforeach 259