16c9457c2SBruce Richardson# SPDX-License-Identifier: BSD-3-Clause 282ba4416SAnand Rawat# Copyright(c) 2017-2019 Intel Corporation 3844514c7SBruce Richardson 45b9656b1SBruce Richardson 55b9656b1SBruce Richardson# process all libraries equally, as far as possible 67be78d02SJosh Soref# "core" libs first, then others alphabetically as far as possible 75b9656b1SBruce Richardson# NOTE: for speed of meson runs, the dependencies in the subdirectories 85b9656b1SBruce Richardson# sometimes skip deps that would be implied by others, e.g. if mempool is 95b9656b1SBruce Richardson# given as a dep, no need to mention ring. This is especially true for the 105b9656b1SBruce Richardson# core libs which are widely reused, so their deps are kept to a minimum. 11b543d1a7SBruce Richardsonlibraries = [ 1209ce4131SBruce Richardson 'log', 13c10cdce1SThomas Monjalon 'kvargs', # eal depends on kvargs 14e3e579f5SChengwen Feng 'argparse', 15eeb486f3SCiara Power 'telemetry', # basic info querying 168990c8c0SLuca Boccassi 'eal', # everything depends on eal 17*077596a4SPaul Szczepanek 'ptr_compress', 18706d306eSHonnappa Nagarahalli 'ring', 19706d306eSHonnappa Nagarahalli 'rcu', # rcu depends on ring 209cc02b17SBruce Richardson 'mempool', 219cc02b17SBruce Richardson 'mbuf', 229cc02b17SBruce Richardson 'net', 239cc02b17SBruce Richardson 'meter', 249cc02b17SBruce Richardson 'ethdev', 259cc02b17SBruce Richardson 'pci', # core 266efc0672SStephen Hemminger 'cmdline', 275b9656b1SBruce Richardson 'metrics', # bitrate/latency stats depends on this 285b9656b1SBruce Richardson 'hash', # efd depends on this 29eb54ef42SErik Gabriel Carrillo 'timer', # eventdev depends on this 309cc02b17SBruce Richardson 'acl', 319cc02b17SBruce Richardson 'bbdev', 329cc02b17SBruce Richardson 'bitratestats', 3310f726efSStephen Hemminger 'bpf', 349cc02b17SBruce Richardson 'cfgfile', 359cc02b17SBruce Richardson 'compressdev', 369cc02b17SBruce Richardson 'cryptodev', 379cc02b17SBruce Richardson 'distributor', 3866a30a29SAmit Prakash Shukla 'dmadev', # eventdev depends on this 399cc02b17SBruce Richardson 'efd', 409cc02b17SBruce Richardson 'eventdev', 41ecca8a0bSMattias Rönnblom 'dispatcher', # dispatcher depends on eventdev 428b8036a6SElena Agostini 'gpudev', 439cc02b17SBruce Richardson 'gro', 449cc02b17SBruce Richardson 'gso', 459cc02b17SBruce Richardson 'ip_frag', 469cc02b17SBruce Richardson 'jobstats', 479cc02b17SBruce Richardson 'latencystats', 489cc02b17SBruce Richardson 'lpm', 499cc02b17SBruce Richardson 'member', 508d23ce8fSStephen Hemminger 'pcapng', 519cc02b17SBruce Richardson 'power', 529cc02b17SBruce Richardson 'rawdev', 539cc02b17SBruce Richardson 'regexdev', 54d82cac58SJerin Jacob 'mldev', 559cc02b17SBruce Richardson 'rib', 569cc02b17SBruce Richardson 'reorder', 579cc02b17SBruce Richardson 'sched', 589cc02b17SBruce Richardson 'security', 599cc02b17SBruce Richardson 'stack', 609cc02b17SBruce Richardson 'vhost', 619cc02b17SBruce Richardson 'ipsec', # ipsec lib depends on net, crypto and security 62a702bd09SAnoob Joseph 'pdcp', # pdcp lib depends on crypto and security 639cc02b17SBruce Richardson 'fib', #fib lib depends on rib 649cc02b17SBruce Richardson 'port', # pkt framework libs which use other libs from above 6510f726efSStephen Hemminger 'pdump', # pdump lib depends on bpf 669cc02b17SBruce Richardson 'table', 679cc02b17SBruce Richardson 'pipeline', 689cc02b17SBruce Richardson 'graph', 699cc02b17SBruce Richardson 'node', 709cc02b17SBruce Richardson] 715b9656b1SBruce Richardson 72e20a715bSBruce Richardsonalways_enable = [ 73e20a715bSBruce Richardson 'cmdline', 74e20a715bSBruce Richardson 'eal', 75e20a715bSBruce Richardson 'ethdev', 76e20a715bSBruce Richardson 'hash', 77e20a715bSBruce Richardson 'kvargs', 78e20a715bSBruce Richardson 'log', 79e20a715bSBruce Richardson 'mbuf', 80e20a715bSBruce Richardson 'mempool', 81e20a715bSBruce Richardson 'meter', 82e20a715bSBruce Richardson 'net', 83e20a715bSBruce Richardson 'pci', 84e20a715bSBruce Richardson 'rcu', 85e20a715bSBruce Richardson 'ring', 86e20a715bSBruce Richardson 'stack', 87e20a715bSBruce Richardson 'telemetry', 880bf58322SBruce Richardson] 890bf58322SBruce Richardson 904b076fb6SDavid Marchandenable_deprecated_libs = [] 914b076fb6SDavid Marchandforeach l:run_command(list_dir_globs, get_option('enable_deprecated_libs'), 924b076fb6SDavid Marchand check: true).stdout().split() 934b076fb6SDavid Marchand if not dpdk_libs_deprecated.contains(l) 944b076fb6SDavid Marchand continue 954b076fb6SDavid Marchand endif 964b076fb6SDavid Marchand enable_deprecated_libs += l 974b076fb6SDavid Marchandendforeach 984b076fb6SDavid Marchand 99934c0ccbSDavid Marchanddisable_libs = run_command(list_dir_globs, get_option('disable_libs'), check: true).stdout().split() 1000bf58322SBruce Richardson 101934c0ccbSDavid Marchandenable_libs = run_command(list_dir_globs, get_option('enable_libs'), check: true).stdout().split() 102021fec80SBruce Richardsonrequire_libs = true 103934c0ccbSDavid Marchandif enable_libs.length() == 0 104021fec80SBruce Richardson require_libs = false 105e20a715bSBruce Richardson enable_libs = libraries 106e20a715bSBruce Richardsonelse 107934c0ccbSDavid Marchand enable_libs += always_enable 108e20a715bSBruce Richardsonendif 1090bf58322SBruce Richardson 1102d148778SHaiyue Wangdefault_cflags = machine_args 1112d148778SHaiyue Wangdefault_cflags += ['-DALLOW_EXPERIMENTAL_API'] 1122d148778SHaiyue Wangdefault_cflags += ['-DALLOW_INTERNAL_API'] 1132d148778SHaiyue Wang 1143e3eeb4dSBruce Richardsonif cc.has_argument('-Wno-format-truncation') 1153e3eeb4dSBruce Richardson default_cflags += '-Wno-format-truncation' 1163e3eeb4dSBruce Richardsonendif 117806c45ddSBruce Richardson 1185b9656b1SBruce Richardsonforeach l:libraries 1195b9656b1SBruce Richardson build = true 1208baad6f8SBruce Richardson reason = '<unknown reason>' # set if build == false to explain why 1215b9656b1SBruce Richardson name = l 122a5d4ea59SBruce Richardson use_function_versioning = false 12370cc4e1fSDavid Marchand annotate_locks = true 1245b9656b1SBruce Richardson sources = [] 1255b9656b1SBruce Richardson headers = [] 12605050ac4SBruce Richardson indirect_headers = [] # public headers not directly included by apps 12719cc526dSTyler Retzlaff driver_sdk_headers = [] # public headers included by drivers 128610beca4SBruce Richardson includes = [] 1293e3eeb4dSBruce Richardson cflags = default_cflags 130610beca4SBruce Richardson objs = [] # other object files to link against, used e.g. for 131610beca4SBruce Richardson # instruction-set optimized versions of code 132610beca4SBruce Richardson 1335b9656b1SBruce Richardson # use "deps" for internal DPDK dependencies, and "ext_deps" for 1345b9656b1SBruce Richardson # external package/library requirements 1355b9656b1SBruce Richardson ext_deps = [] 136610beca4SBruce Richardson deps = [] 13734b3d7a4SBruce Richardson # eal is standard dependency once built 138a8d0d473SBruce Richardson if dpdk_conf.has('RTE_LIB_EAL') 13934b3d7a4SBruce Richardson deps += ['eal'] 140092ee516SGaetan Rivet endif 1415b9656b1SBruce Richardson 1424b076fb6SDavid Marchand if dpdk_libs_deprecated.contains(l) 1434b076fb6SDavid Marchand if not enable_deprecated_libs.contains(l) 1440bf58322SBruce Richardson build = false 1454b076fb6SDavid Marchand reason = 'not in enabled deprecated libraries build config' 1460bf58322SBruce Richardson else 147dfd5b25bSBruce Richardson warning('Enabling deprecated library, "@0@"'.format(l)) 148dfd5b25bSBruce Richardson endif 149934c0ccbSDavid Marchand elif not enable_libs.contains(l) 150934c0ccbSDavid Marchand build = false 151934c0ccbSDavid Marchand reason = 'not in enabled libraries build config' 152934c0ccbSDavid Marchand elif disable_libs.contains(l) 153934c0ccbSDavid Marchand if always_enable.contains(l) 154934c0ccbSDavid Marchand warning('Cannot disable mandatory library "@0@"'.format(l)) 155934c0ccbSDavid Marchand else 1564b076fb6SDavid Marchand build = false 1574b076fb6SDavid Marchand reason = 'explicitly disabled via build config' 1584b076fb6SDavid Marchand endif 159934c0ccbSDavid Marchand endif 1604b076fb6SDavid Marchand 1614b076fb6SDavid Marchand if build 16299a2dd95SBruce Richardson subdir(l) 163021fec80SBruce Richardson if not build and require_libs 164021fec80SBruce Richardson error('Cannot build explicitly requested lib "@0@".\n'.format(name) 165021fec80SBruce Richardson +'\tReason: ' + reason) 166021fec80SBruce Richardson endif 1670bf58322SBruce Richardson endif 16899a2dd95SBruce Richardson if name != l 16999a2dd95SBruce Richardson warning('Library name, "@0@", and directory name, "@1@", do not match'.format(name, l)) 17099a2dd95SBruce Richardson endif 1715b9656b1SBruce Richardson 172e7162699SBruce Richardson shared_deps = ext_deps 173e7162699SBruce Richardson static_deps = ext_deps 174e7162699SBruce Richardson foreach d:deps 175e7162699SBruce Richardson if not build 176e7162699SBruce Richardson break 177e7162699SBruce Richardson endif 178e7162699SBruce Richardson if not is_variable('shared_rte_' + d) 179e7162699SBruce Richardson build = false 180e7162699SBruce Richardson reason = 'missing internal dependency, "@0@"'.format(d) 181dfd5b25bSBruce Richardson if dpdk_libs_deprecated.contains(d) 182dfd5b25bSBruce Richardson reason += ' (deprecated lib)' 183dfd5b25bSBruce Richardson endif 184e7162699SBruce Richardson message('Disabling @1@ [@2@]: missing internal dependency "@0@"' 185e7162699SBruce Richardson .format(d, name, 'lib/' + l)) 186021fec80SBruce Richardson if require_libs 187021fec80SBruce Richardson error('Cannot build explicitly requested lib "@0@".\n'.format(name) 188021fec80SBruce Richardson + '\tPlease add missing dependency "@0@" to "enable_libs" option'.format(d)) 189021fec80SBruce Richardson endif 190e7162699SBruce Richardson else 191e7162699SBruce Richardson shared_deps += [get_variable('shared_rte_' + d)] 192e7162699SBruce Richardson static_deps += [get_variable('static_rte_' + d)] 193e7162699SBruce Richardson endif 194e7162699SBruce Richardson endforeach 195e7162699SBruce Richardson 1967d611e35SBruce Richardson if not build 1977d611e35SBruce Richardson dpdk_libs_disabled += name 198a206a015SDavid Marchand set_variable('lib_' + name.underscorify() + '_disable_reason', reason) 1997d611e35SBruce Richardson continue 2007d611e35SBruce Richardson endif 2017d611e35SBruce Richardson 2029a04396dSDavid Marchand dpdk_libs_enabled += name 203762bfcccSBruce Richardson dpdk_conf.set('RTE_LIB_' + name.to_upper(), 1) 2045b9656b1SBruce Richardson install_headers(headers) 20505050ac4SBruce Richardson install_headers(indirect_headers) 20619cc526dSTyler Retzlaff if get_option('enable_driver_sdk') 20719cc526dSTyler Retzlaff install_headers(driver_sdk_headers) 20819cc526dSTyler Retzlaff endif 20905050ac4SBruce Richardson dpdk_chkinc_headers += headers 210b232b2aaSBruce Richardson dpdk_chkinc_headers += driver_sdk_headers 2115b9656b1SBruce Richardson 212610beca4SBruce Richardson libname = 'rte_' + name 21399a2dd95SBruce Richardson includes += include_directories(l) 21445d7cf91SMarkus Theil dpdk_includes += include_directories(l) 215610beca4SBruce Richardson 21620a65d0aSPaul Szczepanek # special case for header only libraries 21720a65d0aSPaul Szczepanek if sources.length() == 0 21820a65d0aSPaul Szczepanek shared_dep = declare_dependency(include_directories: includes, 21920a65d0aSPaul Szczepanek dependencies: shared_deps) 22020a65d0aSPaul Szczepanek static_dep = declare_dependency(include_directories: includes, 22120a65d0aSPaul Szczepanek dependencies: static_deps) 22220a65d0aSPaul Szczepanek set_variable('shared_rte_' + name, shared_dep) 22320a65d0aSPaul Szczepanek set_variable('static_rte_' + name, static_dep) 22420a65d0aSPaul Szczepanek dpdk_shared_lib_deps += shared_dep 22520a65d0aSPaul Szczepanek dpdk_static_lib_deps += static_dep 22620a65d0aSPaul Szczepanek if developer_mode 22720a65d0aSPaul Szczepanek message('lib/@0@: Defining dependency "@1@"'.format(l, name)) 22820a65d0aSPaul Szczepanek endif 22920a65d0aSPaul Szczepanek continue 23020a65d0aSPaul Szczepanek endif 23120a65d0aSPaul Szczepanek 2322223b6ceSDavid Marchand if developer_mode and is_windows and use_function_versioning 2337d611e35SBruce Richardson message('@0@: Function versioning is not supported by Windows.'.format(name)) 2342f59f3b0SFady Bader endif 2355b9656b1SBruce Richardson 236a5d4ea59SBruce Richardson if use_function_versioning 237a5d4ea59SBruce Richardson cflags += '-DRTE_USE_FUNCTION_VERSIONING' 238a5d4ea59SBruce Richardson endif 239eeded204SDavid Marchand cflags += '-DRTE_LOG_DEFAULT_LOGTYPE=lib.' + l 240bb9d6b23SDavid Marchand if annotate_locks and cc.get_id() == 'clang' and cc.version().version_compare('>=3.5.0') 241657a98f3SDavid Marchand cflags += '-DRTE_ANNOTATE_LOCKS' 242657a98f3SDavid Marchand cflags += '-Wthread-safety' 243657a98f3SDavid Marchand endif 2445b9656b1SBruce Richardson 2453e5c3d58SBruce Richardson # first build static lib 2463e5c3d58SBruce Richardson static_lib = static_library(libname, 2475b9656b1SBruce Richardson sources, 2485b9656b1SBruce Richardson objects: objs, 2495b9656b1SBruce Richardson c_args: cflags, 2503e5c3d58SBruce Richardson dependencies: static_deps, 2513e5c3d58SBruce Richardson include_directories: includes, 2523e5c3d58SBruce Richardson install: true) 253e2db26f7SBruce Richardson static_dep = declare_dependency( 2543e5c3d58SBruce Richardson include_directories: includes, 2553e5c3d58SBruce Richardson dependencies: static_deps) 2563e5c3d58SBruce Richardson 2572f59f3b0SFady Bader if not use_function_versioning or is_windows 258a5d4ea59SBruce Richardson # use pre-build objects to build shared lib 2593e5c3d58SBruce Richardson sources = [] 260bd0d13a8SBruce Richardson objs += static_lib.extract_all_objects(recursive: false) 261a5d4ea59SBruce Richardson else 262a5d4ea59SBruce Richardson # for compat we need to rebuild with 263a5d4ea59SBruce Richardson # RTE_BUILD_SHARED_LIB defined 264a5d4ea59SBruce Richardson cflags += '-DRTE_BUILD_SHARED_LIB' 265a5d4ea59SBruce Richardson endif 2664c773788SBruce Richardson 2676c8aed5aSDavid Marchand version_map = '@0@/@1@/version.map'.format(meson.current_source_dir(), l) 2686c8aed5aSDavid Marchand lk_deps = [version_map] 2696c8aed5aSDavid Marchand 2706c8aed5aSDavid Marchand if is_ms_linker 271309bf90bSTal Shnaiderman def_file = custom_target(libname + '_def', 272309bf90bSTal Shnaiderman command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'], 2734c773788SBruce Richardson input: version_map, 274309bf90bSTal Shnaiderman output: '@0@_exports.def'.format(libname)) 2756c8aed5aSDavid Marchand lk_deps += [def_file] 276309bf90bSTal Shnaiderman 277e5c42402STyler Retzlaff if is_ms_compiler 278e5c42402STyler Retzlaff lk_args = ['/def:' + def_file.full_path()] 279e5c42402STyler Retzlaff else 2806c8aed5aSDavid Marchand lk_args = ['-Wl,/def:' + def_file.full_path()] 281e5c42402STyler Retzlaff endif 2826c8aed5aSDavid Marchand else 2836c8aed5aSDavid Marchand if is_windows 284309bf90bSTal Shnaiderman mingw_map = custom_target(libname + '_mingw', 285309bf90bSTal Shnaiderman command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'], 286309bf90bSTal Shnaiderman input: version_map, 287309bf90bSTal Shnaiderman output: '@0@_mingw.map'.format(libname)) 2886c8aed5aSDavid Marchand lk_deps += [mingw_map] 2894816484bSDmitry Kozlyuk 290309bf90bSTal Shnaiderman lk_args = ['-Wl,--version-script=' + mingw_map.full_path()] 291309bf90bSTal Shnaiderman else 29282ba4416SAnand Rawat lk_args = ['-Wl,--version-script=' + version_map] 2934816484bSDmitry Kozlyuk endif 294309bf90bSTal Shnaiderman endif 2954816484bSDmitry Kozlyuk 2962223b6ceSDavid Marchand if developer_mode and not is_windows 297ff962da3SBruce Richardson # on unix systems check the output of the 2984c824734SHaiyue Wang # check-symbols.sh script, using it as a 299ff962da3SBruce Richardson # dependency of the .so build 3004c824734SHaiyue Wang lk_deps += custom_target(name + '.sym_chk', 3014c824734SHaiyue Wang command: [check_symbols, 302ff962da3SBruce Richardson version_map, '@INPUT@'], 303ff962da3SBruce Richardson capture: true, 304ff962da3SBruce Richardson input: static_lib, 3054c824734SHaiyue Wang output: name + '.sym_chk') 30682ba4416SAnand Rawat endif 3074c773788SBruce Richardson 3083e5c3d58SBruce Richardson shared_lib = shared_library(libname, 3093e5c3d58SBruce Richardson sources, 3103e5c3d58SBruce Richardson objects: objs, 3113e5c3d58SBruce Richardson c_args: cflags, 3123e5c3d58SBruce Richardson dependencies: shared_deps, 313610beca4SBruce Richardson include_directories: includes, 31482ba4416SAnand Rawat link_args: lk_args, 315ff962da3SBruce Richardson link_depends: lk_deps, 3167762e013SDavid Marchand version: abi_version, 3177b67398eSBruce Richardson soversion: so_version, 3185b9656b1SBruce Richardson install: true) 3193e5c3d58SBruce Richardson shared_dep = declare_dependency(link_with: shared_lib, 320610beca4SBruce Richardson include_directories: includes, 3213e5c3d58SBruce Richardson dependencies: shared_deps) 3225b9656b1SBruce Richardson 3233e5c3d58SBruce Richardson dpdk_libraries = [shared_lib] + dpdk_libraries 32457ae0ec6SKevin Laatz dpdk_static_libraries = [static_lib] + dpdk_static_libraries 325610beca4SBruce Richardson 326ae783b42SBruce Richardson set_variable('shared_rte_' + name, shared_dep) 327ae783b42SBruce Richardson set_variable('static_rte_' + name, static_dep) 328f93a605fSBruce Richardson dpdk_shared_lib_deps += shared_dep 329f93a605fSBruce Richardson dpdk_static_lib_deps += static_dep 330d317f7ebSBruce Richardson if developer_mode 33199a2dd95SBruce Richardson message('lib/@0@: Defining dependency "@1@"'.format(l, name)) 332d317f7ebSBruce Richardson endif 3335b9656b1SBruce Richardsonendforeach 334