1# SPDX-License-Identifier: BSD-3-Clause 2# Copyright(c) 2017 Intel Corporation 3 4# driver .so files often depend upon the bus drivers for their connect bus, 5# e.g. ixgbe depends on librte_bus_pci. This means that the bus drivers need 6# to be in the library path, so symlink the drivers from the main lib directory. 7meson.add_install_script('../buildtools/symlink-drivers-solibs.sh', 8 get_option('libdir'), 9 pmd_subdir_opt) 10 11# set the machine type and cflags for it 12if meson.is_cross_build() 13 machine = host_machine.cpu() 14else 15 machine = get_option('machine') 16endif 17 18# machine type 'default' is special, it defaults to the per arch agreed common 19# minimal baseline needed for DPDK. 20# That might not be the most optimized, but the most portable version while 21# still being able to support the CPU features required for DPDK. 22# This can be bumped up by the DPDK project, but it can never be an 23# invariant like 'native' 24if machine == 'default' 25 if host_machine.cpu_family().startswith('x86') 26 # matches the old pre-meson build systems default 27 machine = 'corei7' 28 elif host_machine.cpu_family().startswith('arm') 29 machine = 'armv7-a' 30 elif host_machine.cpu_family().startswith('aarch') 31 # arm64 manages defaults in config/arm/meson.build 32 machine = 'default' 33 elif host_machine.cpu_family().startswith('ppc') 34 machine = 'power8' 35 endif 36endif 37 38dpdk_conf.set('RTE_MACHINE', machine) 39machine_args = [] 40 41# ppc64 does not support -march= at all, use -mcpu and -mtune for that 42if host_machine.cpu_family().startswith('ppc') 43 machine_args += '-mcpu=' + machine 44 machine_args += '-mtune=' + machine 45else 46 machine_args += '-march=' + machine 47endif 48 49toolchain = cc.get_id() 50dpdk_conf.set_quoted('RTE_TOOLCHAIN', toolchain) 51dpdk_conf.set('RTE_TOOLCHAIN_' + toolchain.to_upper(), 1) 52 53add_project_link_arguments('-Wl,--no-as-needed', language: 'c') 54dpdk_extra_ldflags += '-Wl,--no-as-needed' 55 56# use pthreads 57add_project_link_arguments('-pthread', language: 'c') 58dpdk_extra_ldflags += '-pthread' 59 60# some libs depend on maths lib 61add_project_link_arguments('-lm', language: 'c') 62dpdk_extra_ldflags += '-lm' 63 64# for linux link against dl, for bsd execinfo 65if host_machine.system() == 'linux' 66 link_lib = 'dl' 67else 68 link_lib = 'execinfo' 69endif 70add_project_link_arguments('-l' + link_lib, language: 'c') 71dpdk_extra_ldflags += '-l' + link_lib 72 73# check for libraries used in multiple places in DPDK 74has_libnuma = 0 75numa_dep = cc.find_library('numa', required: false) 76if numa_dep.found() and cc.has_header('numaif.h') 77 dpdk_conf.set10('RTE_HAS_LIBNUMA', true) 78 has_libnuma = 1 79 add_project_link_arguments('-lnuma', language: 'c') 80 dpdk_extra_ldflags += '-lnuma' 81endif 82 83# check for strlcpy 84if host_machine.system() == 'linux' and cc.find_library('bsd', 85 required: false).found() and cc.has_header('bsd/string.h') 86 dpdk_conf.set('RTE_USE_LIBBSD', 1) 87 add_project_link_arguments('-lbsd', language: 'c') 88 dpdk_extra_ldflags += '-lbsd' 89endif 90 91# add -include rte_config to cflags 92add_project_arguments('-include', 'rte_config.h', language: 'c') 93 94# enable extra warnings and disable any unwanted warnings 95warning_flags = [ 96 '-Wsign-compare', 97 '-Wcast-qual', 98 '-Wno-address-of-packed-member' 99] 100if cc.sizeof('void *') == 4 101# for 32-bit, don't warn about casting a 32-bit pointer to 64-bit int - it's fine!! 102 warning_flags += '-Wno-pointer-to-int-cast' 103endif 104foreach arg: warning_flags 105 if cc.has_argument(arg) 106 add_project_arguments(arg, language: 'c') 107 endif 108endforeach 109 110# set other values pulled from the build options 111dpdk_conf.set('RTE_MAX_LCORE', get_option('max_lcores')) 112dpdk_conf.set('RTE_MAX_NUMA_NODES', get_option('max_numa_nodes')) 113dpdk_conf.set('RTE_LIBEAL_USE_HPET', get_option('use_hpet')) 114dpdk_conf.set('RTE_EAL_ALLOW_INV_SOCKET_ID', get_option('allow_invalid_socket_id')) 115# values which have defaults which may be overridden 116dpdk_conf.set('RTE_MAX_VFIO_GROUPS', 64) 117dpdk_conf.set('RTE_DRIVER_MEMPOOL_BUCKET_SIZE_KB', 64) 118dpdk_conf.set('RTE_LIBRTE_DPAA2_USE_PHYS_IOVA', true) 119 120compile_time_cpuflags = [] 121if host_machine.cpu_family().startswith('x86') 122 arch_subdir = 'x86' 123elif host_machine.cpu_family().startswith('arm') or host_machine.cpu_family().startswith('aarch') 124 arch_subdir = 'arm' 125elif host_machine.cpu_family().startswith('ppc') 126 arch_subdir = 'ppc_64' 127endif 128subdir(arch_subdir) 129dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS', ','.join(compile_time_cpuflags)) 130 131# set the install path for the drivers 132dpdk_conf.set_quoted('RTE_EAL_PMD_PATH', eal_pmd_path) 133 134install_headers('rte_config.h', subdir: get_option('include_subdir_arch')) 135 136# enable VFIO only if it is linux OS 137dpdk_conf.set('RTE_EAL_VFIO', host_machine.system() == 'linux') 138