[dpdk-dev] [PATCH v8 6/6] build: use dependency for pcap and fallback to find_library
luca.boccassi at gmail.com
luca.boccassi at gmail.com
Tue Feb 26 18:46:37 CET 2019
From: Luca Boccassi <luca.boccassi at microsoft.com>
pcap has historically shipped a custom pcap-config binary tool which
does the job of pkg-config. It was never compatible with cross
compilation.
Meson uses it when using dependency(), which then means cross
compilation fails.
Set pcap-config to empty in the meson cross compilation files so
that Meson will not use it, and add a fallback in case
dependency() fails.
libpcap 1.9.0 finally ships a pkg-config file so everything will
work out of the box in the future.
Signed-off-by: Luca Boccassi <luca.boccassi at microsoft.com>
---
v8: added back pcap change separately. Tested with bootlin
cross-compilation toolchain, everything seems to work.
config/arm/arm64_armv8_linuxapp_gcc | 1 +
config/arm/arm64_dpaa2_linuxapp_gcc | 1 +
config/arm/arm64_dpaa_linuxapp_gcc | 1 +
config/arm/arm64_thunderx_linuxapp_gcc | 1 +
drivers/net/pcap/meson.build | 16 ++++++++++++----
5 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/config/arm/arm64_armv8_linuxapp_gcc b/config/arm/arm64_armv8_linuxapp_gcc
index 987c02fbb..513760917 100644
--- a/config/arm/arm64_armv8_linuxapp_gcc
+++ b/config/arm/arm64_armv8_linuxapp_gcc
@@ -3,6 +3,7 @@ c = 'aarch64-linux-gnu-gcc'
cpp = 'aarch64-linux-gnu-cpp'
ar = 'aarch64-linux-gnu-gcc-ar'
strip = 'aarch64-linux-gnu-strip'
+pcap-config = ''
[host_machine]
system = 'linux'
diff --git a/config/arm/arm64_dpaa2_linuxapp_gcc b/config/arm/arm64_dpaa2_linuxapp_gcc
index 7ec74ec4b..0df8c8f7d 100644
--- a/config/arm/arm64_dpaa2_linuxapp_gcc
+++ b/config/arm/arm64_dpaa2_linuxapp_gcc
@@ -4,6 +4,7 @@ cpp = 'aarch64-linux-gnu-cpp'
ar = 'aarch64-linux-gnu-ar'
as = 'aarch64-linux-gnu-as'
strip = 'aarch64-linux-gnu-strip'
+pcap-config = ''
[host_machine]
system = 'linux'
diff --git a/config/arm/arm64_dpaa_linuxapp_gcc b/config/arm/arm64_dpaa_linuxapp_gcc
index 73a8f0b81..f4b85a84b 100644
--- a/config/arm/arm64_dpaa_linuxapp_gcc
+++ b/config/arm/arm64_dpaa_linuxapp_gcc
@@ -4,6 +4,7 @@ cpp = 'aarch64-linux-gnu-cpp'
ar = 'aarch64-linux-gnu-ar'
as = 'aarch64-linux-gnu-as'
strip = 'aarch64-linux-gnu-strip'
+pcap-config = ''
[host_machine]
system = 'linux'
diff --git a/config/arm/arm64_thunderx_linuxapp_gcc b/config/arm/arm64_thunderx_linuxapp_gcc
index 967d9d46d..14b801998 100644
--- a/config/arm/arm64_thunderx_linuxapp_gcc
+++ b/config/arm/arm64_thunderx_linuxapp_gcc
@@ -3,6 +3,7 @@ c = 'aarch64-linux-gnu-gcc'
cpp = 'aarch64-linux-gnu-cpp'
ar = 'aarch64-linux-gnu-gcc-ar'
strip = 'aarch64-linux-gnu-strip'
+pcap-config = ''
[host_machine]
system = 'linux'
diff --git a/drivers/net/pcap/meson.build b/drivers/net/pcap/meson.build
index 0c4e0201a..2c2fd11e4 100644
--- a/drivers/net/pcap/meson.build
+++ b/drivers/net/pcap/meson.build
@@ -1,12 +1,20 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2017 Intel Corporation
-pcap_dep = cc.find_library('pcap', required: false)
-if pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep)
+pcap_dep = dependency('pcap', required: false)
+if pcap_dep.found()
build = true
else
- build = false
+ # 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)
+ if pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep)
+ build = true
+ pkgconfig_extra_libs += '-lpcap'
+ else
+ build = false
+ endif
endif
sources = files('rte_eth_pcap.c')
ext_deps += pcap_dep
-pkgconfig_extra_libs += '-lpcap'
--
2.20.1
More information about the dev
mailing list