+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
+
+libexecinfo = cc.find_library('libexecinfo', required: false)
+if libexecinfo.found() and cc.has_header('execinfo.h')
+ add_project_link_arguments('-lexecinfo', language: 'c')
+ dpdk_extra_ldflags += '-lexecinfo'
+endif
+
+libarchive = dependency('libarchive', required: false, method: 'pkg-config')
+if libarchive.found()
+ dpdk_conf.set('RTE_HAS_LIBARCHIVE', 1)
+ # Push libarchive link dependency at the project level to support
+ # statically linking dpdk apps. Details at:
+ # https://inbox.dpdk.org/dev/20210605004024.660267a1@sovereign/
+ add_project_link_arguments('-larchive', language: 'c')
+ dpdk_extra_ldflags += '-larchive'
+endif
+
+# check for libbsd
+libbsd = dependency('libbsd', required: false, method: 'pkg-config')
+if libbsd.found()
+ dpdk_conf.set('RTE_USE_LIBBSD', 1)
+endif
+
+# check for pcap
+pcap_dep = dependency('libpcap', required: false, method: 'pkg-config')
+pcap_lib = is_windows ? 'wpcap' : 'pcap'
+if not pcap_dep.found()
+ # pcap got a pkg-config file only in 1.9.0
+ pcap_dep = cc.find_library(pcap_lib, 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 += '-l@0@'.format(pcap_lib)
+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'