1 |
jmc |
1.1 |
dnl libpcap.m4--PCAP libraries and includes |
2 |
|
|
dnl Derrick Brashear |
3 |
|
|
dnl from KTH krb and Arla |
4 |
|
|
dnl $Id: libpcap.m4,v 1.7 2002/12/21 18:44:24 cg2v Exp $ |
5 |
|
|
|
6 |
|
|
AC_DEFUN(CMU_PCAP_INC_WHERE1, [ |
7 |
|
|
ac_cv_found_pcap_inc=no |
8 |
|
|
if test -f "$1/pcap.h" ; then |
9 |
|
|
ac_cv_found_pcap_inc=yes |
10 |
|
|
fi |
11 |
|
|
]) |
12 |
|
|
|
13 |
|
|
AC_DEFUN(CMU_PCAP_INC_WHERE, [ |
14 |
|
|
for i in $1; do |
15 |
|
|
AC_MSG_CHECKING(for pcap header in $i) |
16 |
|
|
CMU_PCAP_INC_WHERE1($i) |
17 |
|
|
if test "$ac_cv_found_pcap_inc" = "yes"; then |
18 |
|
|
ac_cv_pcap_where_inc=$i |
19 |
|
|
AC_MSG_RESULT(found) |
20 |
|
|
break |
21 |
|
|
else |
22 |
|
|
AC_MSG_RESULT(no found) |
23 |
|
|
fi |
24 |
|
|
done |
25 |
|
|
]) |
26 |
|
|
|
27 |
|
|
AC_DEFUN(CMU_PCAP_LIB_WHERE1, [ |
28 |
|
|
saved_LIBS=$LIBS |
29 |
|
|
LIBS="$saved_LIBS -L$1 -lpcap" |
30 |
|
|
AC_TRY_LINK(, |
31 |
|
|
[pcap_lookupdev("");], |
32 |
|
|
[ac_cv_found_pcap_lib=yes], |
33 |
|
|
ac_cv_found_pcap_lib=no) |
34 |
|
|
LIBS=$saved_LIBS |
35 |
|
|
]) |
36 |
|
|
|
37 |
|
|
AC_DEFUN(CMU_PCAP_LIB_WHERE, [ |
38 |
|
|
for i in $1; do |
39 |
|
|
AC_MSG_CHECKING(for pcap library in $i) |
40 |
|
|
CMU_PCAP_LIB_WHERE1($i) |
41 |
|
|
CMU_TEST_LIBPATH($i, pcap) |
42 |
|
|
if test "$ac_cv_found_pcap_lib" = "yes" ; then |
43 |
|
|
ac_cv_pcap_where_lib=$i |
44 |
|
|
AC_MSG_RESULT(found) |
45 |
|
|
break |
46 |
|
|
else |
47 |
|
|
AC_MSG_RESULT(no found) |
48 |
|
|
fi |
49 |
|
|
done |
50 |
|
|
]) |
51 |
|
|
|
52 |
|
|
AC_DEFUN(CMU_PCAP, [ |
53 |
|
|
AC_ARG_WITH(pcap, |
54 |
|
|
[ --with-pcap=PREFIX Compile with PCAP support], |
55 |
|
|
[if test "X$with_pcap" = "X"; then |
56 |
|
|
with_pcap=yes |
57 |
|
|
fi]) |
58 |
|
|
AC_ARG_WITH(pcap-lib, |
59 |
|
|
[ --with-pcap-lib=dir use pcap libraries in dir], |
60 |
|
|
[if test "$withval" = "yes" -o "$withval" = "no"; then |
61 |
|
|
AC_MSG_ERROR([No argument for --with-pcap-lib]) |
62 |
|
|
fi]) |
63 |
|
|
AC_ARG_WITH(pcap-include, |
64 |
|
|
[ --with-pcap-include=dir use pcap headers in dir], |
65 |
|
|
[if test "$withval" = "yes" -o "$withval" = "no"; then |
66 |
|
|
AC_MSG_ERROR([No argument for --with-pcap-include]) |
67 |
|
|
fi]) |
68 |
|
|
|
69 |
|
|
if test "X$with_pcap" != "X"; then |
70 |
|
|
if test "$with_pcap" != "yes"; then |
71 |
|
|
ac_cv_pcap_where_lib=$with_pcap/lib |
72 |
|
|
ac_cv_pcap_where_inc=$with_pcap/include |
73 |
|
|
fi |
74 |
|
|
fi |
75 |
|
|
|
76 |
|
|
if test "X$with_pcap_lib" != "X"; then |
77 |
|
|
ac_cv_pcap_where_lib=$with_pcap_lib |
78 |
|
|
fi |
79 |
|
|
if test "X$ac_cv_pcap_where_lib" = "X"; then |
80 |
|
|
CMU_PCAP_LIB_WHERE(/usr/ng/lib /usr/lib /usr/local/lib) |
81 |
|
|
fi |
82 |
|
|
|
83 |
|
|
if test "X$with_pcap_include" != "X"; then |
84 |
|
|
ac_cv_pcap_where_inc=$with_pcap_include |
85 |
|
|
fi |
86 |
|
|
if test "X$ac_cv_pcap_where_inc" = "X"; then |
87 |
|
|
CMU_PCAP_INC_WHERE(/usr/ng/include /usr/include /usr/local/include) |
88 |
|
|
fi |
89 |
|
|
|
90 |
|
|
AC_MSG_CHECKING(whether to include pcap) |
91 |
|
|
if test "X$ac_cv_pcap_where_lib" = "X" -a "X$ac_cv_pcap_where_inc" = "X"; then |
92 |
|
|
ac_cv_found_pcap=no |
93 |
|
|
AC_MSG_RESULT(no) |
94 |
|
|
else |
95 |
|
|
ac_cv_found_pcap=yes |
96 |
|
|
AC_MSG_RESULT(yes) |
97 |
|
|
PCAP_INC_DIR=$ac_cv_pcap_where_inc |
98 |
|
|
PCAP_LIB_DIR=$ac_cv_pcap_where_lib |
99 |
|
|
PCAP_INC_FLAGS="-I${PCAP_INC_DIR}" |
100 |
|
|
PCAP_LIB_FLAGS="-L${PCAP_LIB_DIR} -lpcap" |
101 |
|
|
if test "X$RPATH" = "X"; then |
102 |
|
|
RPATH="" |
103 |
|
|
fi |
104 |
|
|
case "${host}" in |
105 |
|
|
*-*-linux*) |
106 |
|
|
if test "X$RPATH" = "X"; then |
107 |
|
|
RPATH="-Wl,-rpath,${PCAP_LIB_DIR}" |
108 |
|
|
else |
109 |
|
|
RPATH="${RPATH}:${PCAP_LIB_DIR}" |
110 |
|
|
fi |
111 |
|
|
;; |
112 |
|
|
*-*-hpux*) |
113 |
|
|
if test "X$RPATH" = "X"; then |
114 |
|
|
RPATH="-Wl,+b${PCAP_LIB_DIR}" |
115 |
|
|
else |
116 |
|
|
RPATH="${RPATH}:${PCAP_LIB_DIR}" |
117 |
|
|
fi |
118 |
|
|
;; |
119 |
|
|
*-*-irix*) |
120 |
|
|
if test "X$RPATH" = "X"; then |
121 |
|
|
RPATH="-Wl,-rpath,${PCAP_LIB_DIR}" |
122 |
|
|
else |
123 |
|
|
RPATH="${RPATH}:${PCAP_LIB_DIR}" |
124 |
|
|
fi |
125 |
|
|
;; |
126 |
|
|
*-*-solaris2*) |
127 |
|
|
if test "$ac_cv_prog_gcc" = yes; then |
128 |
|
|
if test "X$RPATH" = "X"; then |
129 |
|
|
RPATH="-Wl,-R${PCAP_LIB_DIR}" |
130 |
|
|
else |
131 |
|
|
RPATH="${RPATH}:${PCAP_LIB_DIR}" |
132 |
|
|
fi |
133 |
|
|
else |
134 |
|
|
RPATH="${RPATH} -R${PCAP_LIB_DIR}" |
135 |
|
|
fi |
136 |
|
|
;; |
137 |
|
|
esac |
138 |
|
|
AC_SUBST(RPATH) |
139 |
|
|
fi |
140 |
|
|
]) |