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