1From 194ec61843b9598ce90873c812b817c4b96e2e0d Mon Sep 17 00:00:00 2001
2From: Baruch Siach <baruch@tkos.co.il>
3Date: Thu, 2 Sep 2021 12:56:00 +0300
4Subject: [PATCH] Detect libpcap dependencies using pkg-config
5
6When building statically the link command line must include all
7dependencies of all libraries. libpcap can optionally depend on libnl.
8mausezahn can't build statically in this case.
9
10Use pkg-config in configure and in the link command to construct the
11library flags we need to link with libpcap.
12
13Signed-off-by: Baruch Siach <baruch@tkos.co.il>
14Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
15---
16Upstream status: commit 194ec61843b9598ce90873c812b817c4b96e2e0d
17
18 configure          | 4 +++-
19 mausezahn/Makefile | 2 +-
20 2 files changed, 4 insertions(+), 2 deletions(-)
21
22diff --git a/configure b/configure
23index 510826a798f5..598ae2433a7a 100755
24--- a/configure
25+++ b/configure
26@@ -588,7 +588,9 @@ int main(void)
27 }
28 EOF
29
30-	$CC -o $TMPDIR/pcaptest $TMPDIR/pcaptest.c -lpcap >> config.log 2>&1
31+	$CC -o $TMPDIR/pcaptest $TMPDIR/pcaptest.c \
32+		$($PKG_CONFIG --libs libpcap 2>> config.log) \
33+		>> config.log 2>&1
34 	if [ ! -x $TMPDIR/pcaptest ] ; then
35 		echo "[NO]"
36 		echo "CONFIG_LIBPCAP=0" >> Config
37diff --git a/mausezahn/Makefile b/mausezahn/Makefile
38index ca16b6579583..9544565355cc 100644
39--- a/mausezahn/Makefile
40+++ b/mausezahn/Makefile
41@@ -1,6 +1,6 @@
42 mausezahn-libs =	-lcli \
43 			-lnet \
44-			-lpcap \
45+			$(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --libs libpcap 2> /dev/null ) \
46 			-lrt \
47 			-lpthread \
48 			-lm
49--
502.33.0
51
52