-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_libpcap.m4
More file actions
68 lines (59 loc) · 1.41 KB
/
check_libpcap.m4
File metadata and controls
68 lines (59 loc) · 1.41 KB
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
60
61
62
63
64
65
66
67
68
###
### libpcap
###
AC_ARG_WITH([libpcap], AC_HELP_STRING([--with-libpcap=DIR], [libpcap installation path]),
[], [ withval="yes" ])
AC_MSG_CHECKING([for libpcap headers])
if test x_$withval = x_yes; then
withval="/usr /usr/local"
fi
libpcap_cflags=""
libpcap_ldflags=""
libpcap_libs="-lpcap"
libpcap_dir=""
for dir in $withval; do
if test -f "$dir/include/pcap.h"; then
found_libpcap_dir="yes"
libpcap_dir="$dir"
if test x_$dir != x_/usr; then
libpcap_cflags="-I$dir/include"
fi
break;
fi
done
if test x_$found_libpcap_dir = x_yes; then
AC_MSG_RESULT([$dir])
else
AC_MSG_ERROR([cannot find libpcap.h in $withval])
fi
AC_MSG_CHECKING([for libpcap library])
if test x_$libpcap_dir != x_/usr; then
libpcap_ldflags="-L$libpcap_dir/lib"
fi
save_cflags="$CFLAGS"
save_ldflags="$LDFLAGS"
save_libs="$LIBS"
CFLAGS="$CFLAGS $libpcap_cflags"
LDFLAGS="$LDFLAGS $libpcap_ldflags"
LIBS="$LIBS $libpcap_libs"
AC_LINK_IFELSE(
AC_LANG_PROGRAM([[
#include <pcap.h>
]],
[[
pcap_open_offline(0, 0);
]]),
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_LIBPCAP], [1], [Define to 1 if libpcap works.])
,
AC_MSG_FAILURE([cannot find libpcap library])
libpcap_cflags=""
libpcap_ldflags=""
libpcap_libs=""
)
CFLAGS="$save_cflags"
LDFLAGS="$save_ldflags"
LIBS="$save_libs"
AC_SUBST([libpcap_cflags])
AC_SUBST([libpcap_ldflags])
AC_SUBST([libpcap_libs])