+machine_args = []
+
+# ppc64 does not support -march= at all, use -mcpu and -mtune for that
+if host_machine.cpu_family().startswith('ppc')
+ machine_args += '-mcpu=' + machine
+ machine_args += '-mtune=' + machine
+else
+ machine_args += '-march=' + machine
+endif
+
+toolchain = cc.get_id()
+dpdk_conf.set_quoted('RTE_TOOLCHAIN', toolchain)
+dpdk_conf.set('RTE_TOOLCHAIN_' + toolchain.to_upper(), 1)
+
+dpdk_conf.set('RTE_ARCH_64', cc.sizeof('void *') == 8)
+
+if not is_windows
+ add_project_link_arguments('-Wl,--no-as-needed', language: 'c')
+endif
+
+# use pthreads if available for the platform
+if not is_windows
+ add_project_link_arguments('-pthread', language: 'c')
+ dpdk_extra_ldflags += '-pthread'
+endif
+
+# on some OS, maths functions are in a separate library
+if cc.find_library('m', required : false).found()
+ # some libs depend on maths lib
+ add_project_link_arguments('-lm', language: 'c')
+ dpdk_extra_ldflags += '-lm'
+endif
+
+# for linux link against dl, for bsd execinfo
+if is_linux
+ link_lib = 'dl'
+elif is_freebsd
+ link_lib = 'execinfo'
+else
+ link_lib = ''
+endif
+
+# if link_lib is empty, do not add it to project properties
+if link_lib != ''
+ add_project_link_arguments('-l' + link_lib, language: 'c')
+ dpdk_extra_ldflags += '-l' + link_lib
+endif
+
+# check for libraries used in multiple places in DPDK
+has_libnuma = 0
+numa_dep = cc.find_library('numa', required: false)
+if numa_dep.found() and cc.has_header('numaif.h')
+ dpdk_conf.set10('RTE_HAS_LIBNUMA', true)
+ has_libnuma = 1
+ add_project_link_arguments('-lnuma', language: 'c')
+ dpdk_extra_ldflags += '-lnuma'
+endif
+
+has_libfdt = 0
+fdt_dep = cc.find_library('libfdt', required: false)
+if fdt_dep.found() and cc.has_header('fdt.h')
+ dpdk_conf.set10('RTE_HAS_LIBFDT', true)
+ has_libfdt = 1
+ add_project_link_arguments('-lfdt', language: 'c')
+ dpdk_extra_ldflags += '-lfdt'
+endif
+
+# check for libbsd
+libbsd = dependency('libbsd', required: false)
+if libbsd.found()
+ dpdk_conf.set('RTE_USE_LIBBSD', 1)
+endif
+
+# check for pcap
+pcap_dep = dependency('pcap', required: false)
+if pcap_dep.found()
+ # pcap got a pkg-config file only in 1.9.0 and before that meson uses
+ # an internal pcap-config finder, which is not compatible with
+ # cross-compilation, so try to fallback to find_library
+ pcap_dep = cc.find_library('pcap', required: false)
+endif
+if pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep)
+ dpdk_conf.set('RTE_PORT_PCAP', 1)
+ dpdk_extra_ldflags += '-lpcap'
+endif
+
+# for clang 32-bit compiles we need libatomic for 64-bit atomic ops
+if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false
+ atomic_dep = cc.find_library('atomic', required: true)
+ add_project_link_arguments('-latomic', language: 'c')
+ dpdk_extra_ldflags += '-latomic'
+endif