summaryrefslogtreecommitdiff
blob: 252a71db47c7b78037aadb792a6b8f214d1cbcc2 (plain)
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
49
50
51
52
53
54
55
56
57
58
59
--- a/configure.ac
+++ b/configure.ac
@@ -12,6 +12,8 @@
 AC_PROG_CXX
 LT_INIT([disable-static])
 
+PKG_PROG_PKG_CONFIG
+
 AC_CHECK_TYPE(u_int32_t, uint32_t)
 AC_CHECK_TYPE(u_int64_t, uint64_t)
 AC_CHECK_TYPE(u_int16_t, uint16_t)
@@ -20,46 +22,7 @@
 AC_CANONICAL_HOST
 
 ## Checks for libpcap
-AC_MSG_CHECKING(for libpcap)
-AC_ARG_WITH(libpcap,
-[  --with-libpcap=DIR      use libpcap in DIR],
-[ case "$withval" in
-  yes|no)
-     AC_MSG_RESULT(no)
-     ;;
-  *)
-     AC_MSG_RESULT($withval)
-     if test -f $withval/pcap.h -a -f $withval/libpcap.a; then
-        owd=`pwd`
-        if cd $withval; then withval=`pwd`; cd $owd; fi
-	PCAPINC="-I$withval -I$withval/bpf"
-	PCAPLIB="-L$withval -lpcap"
-     elif test -f $withval/include/pcap.h -a \
-	       -f $withval/include/net/bpf.h -a \
-	       -f $withval/lib/libpcap.a; then
-	owd=`pwd`
-	if cd $withval; then withval=`pwd`; cd $owd; fi
-	PCAPINC="-I$withval/include"
-	PCAPLIB="-L$withval/lib -lpcap"
-     else
-        AC_ERROR(pcap.h, net/bpf.h, or libpcap.a not found in $withval)
-     fi
-     ;;
-  esac ],
-[ if test -f ${prefix}/include/pcap.h; then
-     PCAPINC="-I${prefix}/include"
-     PCAPLIB="-L${prefix}/lib -lpcap"
-  elif test -f /usr/include/pcap/pcap.h; then
-     PCAPINC="-I/usr/include/pcap"
-     PCAPLIB="-lpcap"
-  elif test -f /usr/include/pcap.h; then
-     PCAPLIB="-lpcap"
-  else
-     AC_MSG_RESULT(no)
-     AC_ERROR(libpcap not found)
-  fi
-  AC_MSG_RESULT(yes) ]
-)
+PKG_CHECK_MODULES([PCAP], [libpcap], [PCAPINC="${PCAP_CFLAGS}"; PCAPLIB="${PCAP_LIBS}"],AC_MSG_ERROR([libpcap is required]))
 AC_SUBST(PCAPINC)
 AC_SUBST(PCAPLIB)
 AC_CHECK_LIB([pcap], [pcap_set_immediate_mode],