hc
2024-08-19 eb6b9ee90f50f13c5abb885ce483802d6262f2b5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
configure.in: use pkg-config for libpcap detection
 
The detection of libpcap was based in ${prefix}, which doesn't make
sense in a cross-compilation context and can cause host leakage into
the target build.
 
So instead, let's use pkg-config to detect libpcap, since it is anyway
already use in this configure.in to detect libglib.
 
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
 
Index: b/configure.in
===================================================================
--- a/configure.in
+++ b/configure.in
@@ -75,25 +75,13 @@
      fi
      ;;
   esac ],
-[ if test -f ${prefix}/include/pcap.h; then
-     PCAP_CFLAGS="-I${prefix}/include"
-     PCAPLIB="-L${exec_prefix}/lib -lpcap"
-  elif test -f /usr/include/pcap/pcap.h; then
-     PCAP_CFLAGS="-I/usr/include/pcap"
-     PCAPLIB="-lpcap"
-  else
-    TMP=$LIBS
-    LIBS="-lpcap $LIBS"
-    AC_TRY_LINK([#include <pcap.h>], pcap_open_offline("",""),
-    LIBPCAP_FOUND=1,LIBPCAP_FOUND=0)
-    LIBS=$TMP
-    if test $LIBPCAP_FOUND = 1 ; then
-        PCAPLIB="-lpcap"
-    else
-        AC_ERROR(libpcap not found)
-    fi
-  fi
-  AC_MSG_RESULT(yes) ]
+[
+    PKG_PROG_PKG_CONFIG
+    PKG_CHECK_MODULES(LIBPCAP, libpcap)
+    AC_MSG_RESULT(yes)
+    PCAP_CFLAGS=${LIBPCAP_CFLAGS}
+    PCAPLIB=${LIBPCAP_LIBS}
+]
 )
 AC_SUBST(PCAP_CFLAGS)
 AC_SUBST(PCAPLIB)