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', 'mbuf', 'net', 'meter', 'ethdev', 'pci', # core 18 'cmdline', 19 'metrics', # bitrate/latency stats depends on this 20 'hash', # efd depends on this 21 'timer', # eventdev depends on this 22 'acl', 'bbdev', 'bitratestats', 'cfgfile', 23 'compressdev', 'cryptodev', 24 'distributor', 'efd', 'eventdev', 25 'gro', 'gso', 'ip_frag', 'jobstats', 26 'kni', 'latencystats', 'lpm', 'member', 27 'power', 'pdump', 'rawdev', 'regexdev', 28 'rib', 'reorder', 'sched', 'security', 'stack', 'vhost', 29 # ipsec lib depends on net, crypto and security 30 'ipsec', 31 #fib lib depends on rib 32 'fib', 33 # add pkt framework libs which use other libs from above 34 'port', 'table', 'pipeline', 35 # flow_classify lib depends on pkt framework table lib 36 'flow_classify', 'bpf', 'graph', 'node'] 37 38if is_windows 39 libraries = [ 40 'kvargs', 41 'telemetry', 42 'eal', 43 'ring', 44 'rcu', 45 'mempool', 'mbuf', 'net', 'meter', 'ethdev', 'pci', 46 'cmdline', 47 'hash', 48 'cfgfile', 49 ] # only supported libraries for windows 50endif 51 52default_cflags = machine_args 53default_cflags += ['-DALLOW_EXPERIMENTAL_API'] 54default_cflags += ['-DALLOW_INTERNAL_API'] 55 56if cc.has_argument('-Wno-format-truncation') 57 default_cflags += '-Wno-format-truncation' 58endif 59 60enabled_libs = [] # used to print summary at the end 61 62foreach l:libraries 63 build = true 64 reason = '<unknown reason>' # set if build == false to explain why 65 name = l 66 use_function_versioning = false 67 sources = [] 68 headers = [] 69 indirect_headers = [] # public headers not directly included by apps 70 driver_sdk_headers = [] # public headers included by drivers 71 includes = [] 72 cflags = default_cflags 73 objs = [] # other object files to link against, used e.g. for 74 # instruction-set optimized versions of code 75 76 # use "deps" for internal DPDK dependencies, and "ext_deps" for 77 # external package/library requirements 78 ext_deps = [] 79 deps = [] 80 # eal is standard dependency once built 81 if dpdk_conf.has('RTE_LIB_EAL') 82 deps += ['eal'] 83 endif 84 85 dir_name = 'librte_' + l 86 subdir(dir_name) 87 88 if build 89 shared_deps = ext_deps 90 static_deps = ext_deps 91 foreach d:deps 92 if not is_variable('shared_rte_' + d) 93 error('Missing internal dependency "@0@" for @1@ [@2@]' 94 .format(d, name, 'lib/' + dir_name)) 95 endif 96 shared_deps += [get_variable('shared_rte_' + d)] 97 static_deps += [get_variable('static_rte_' + d)] 98 endforeach 99 endif 100 101 if not build 102 dpdk_libs_disabled += name 103 set_variable(name.underscorify() + '_disable_reason', reason) 104 else 105 enabled_libs += name 106 dpdk_conf.set('RTE_LIB_' + name.to_upper(), 1) 107 install_headers(headers) 108 install_headers(indirect_headers) 109 if get_option('enable_driver_sdk') 110 install_headers(driver_sdk_headers) 111 endif 112 dpdk_chkinc_headers += headers 113 114 libname = 'rte_' + name 115 includes += include_directories(dir_name) 116 117 if sources.length() == 0 118 # if no C files, just set a dependency on header path 119 shared_dep = declare_dependency(include_directories: includes) 120 static_dep = shared_dep 121 else 122 if is_windows and use_function_versioning and developer_mode 123 message('@0@: Function versioning is not supported by Windows.' 124 .format(name)) 125 endif 126 127 if use_function_versioning 128 cflags += '-DRTE_USE_FUNCTION_VERSIONING' 129 endif 130 131 # first build static lib 132 static_lib = static_library(libname, 133 sources, 134 objects: objs, 135 c_args: cflags, 136 dependencies: static_deps, 137 include_directories: includes, 138 install: true) 139 static_dep = declare_dependency( 140 include_directories: includes, 141 dependencies: static_deps) 142 143 if not use_function_versioning or is_windows 144 # use pre-build objects to build shared lib 145 sources = [] 146 objs += static_lib.extract_all_objects(recursive: false) 147 else 148 # for compat we need to rebuild with 149 # RTE_BUILD_SHARED_LIB defined 150 cflags += '-DRTE_BUILD_SHARED_LIB' 151 endif 152 version_map = '@0@/@1@/version.map'.format( 153 meson.current_source_dir(), dir_name) 154 implib = dir_name + '.dll.a' 155 156 def_file = custom_target(libname + '_def', 157 command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'], 158 input: version_map, 159 output: '@0@_exports.def'.format(libname)) 160 161 mingw_map = custom_target(libname + '_mingw', 162 command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'], 163 input: version_map, 164 output: '@0@_mingw.map'.format(libname)) 165 166 if is_ms_linker 167 lk_args = ['-Wl,/def:' + def_file.full_path()] 168 if meson.version().version_compare('<0.54.0') 169 lk_args += ['-Wl,/implib:lib\\' + implib] 170 endif 171 else 172 if is_windows 173 lk_args = ['-Wl,--version-script=' + mingw_map.full_path()] 174 else 175 lk_args = ['-Wl,--version-script=' + version_map] 176 endif 177 endif 178 179 lk_deps = [version_map, def_file, mingw_map] 180 if developer_mode and not is_windows 181 # on unix systems check the output of the 182 # check-symbols.sh script, using it as a 183 # dependency of the .so build 184 lk_deps += custom_target(name + '.sym_chk', 185 command: [check_symbols, 186 version_map, '@INPUT@'], 187 capture: true, 188 input: static_lib, 189 output: name + '.sym_chk') 190 endif 191 192 shared_lib = shared_library(libname, 193 sources, 194 objects: objs, 195 c_args: cflags, 196 dependencies: shared_deps, 197 include_directories: includes, 198 link_args: lk_args, 199 link_depends: lk_deps, 200 version: abi_version, 201 soversion: so_version, 202 install: true) 203 shared_dep = declare_dependency(link_with: shared_lib, 204 include_directories: includes, 205 dependencies: shared_deps) 206 207 dpdk_libraries = [shared_lib] + dpdk_libraries 208 dpdk_static_libraries = [static_lib] + dpdk_static_libraries 209 endif # sources.length() > 0 210 211 set_variable('shared_rte_' + name, shared_dep) 212 set_variable('static_rte_' + name, static_dep) 213 if developer_mode 214 message('lib/@0@: Defining dependency "@1@"'.format( 215 dir_name, name)) 216 endif 217 endif # if build 218endforeach 219