1 dnl libpcap.m4--PCAP libraries and includes
3 dnl from KTH krb and Arla
4 dnl $Id: libpcap.m4,v 1.9 2005/04/26 19:14:08 shadow Exp $
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
13 AC_DEFUN([CMU_PCAP_INC_WHERE], [
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
22 AC_MSG_RESULT(no found)
27 AC_DEFUN([CMU_PCAP_LIB_WHERE1], [
29 LIBS="$saved_LIBS -L$1 -lpcap"
31 [pcap_lookupdev("");],
32 [ac_cv_found_pcap_lib=yes],
33 ac_cv_found_pcap_lib=no)
37 AC_DEFUN([CMU_PCAP_LIB_WHERE], [
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
47 AC_MSG_RESULT(no found)
52 AC_DEFUN([CMU_PCAP], [
53 AC_REQUIRE([CMU_FIND_LIB_SUBDIR])
55 [ --with-pcap=PREFIX Compile with PCAP support],
56 [if test "X$with_pcap" = "X"; then
60 [ --with-pcap-lib=dir use pcap libraries in dir],
61 [if test "$withval" = "yes" -o "$withval" = "no"; then
62 AC_MSG_ERROR([No argument for --with-pcap-lib])
64 AC_ARG_WITH(pcap-include,
65 [ --with-pcap-include=dir use pcap headers in dir],
66 [if test "$withval" = "yes" -o "$withval" = "no"; then
67 AC_MSG_ERROR([No argument for --with-pcap-include])
70 if test "X$with_pcap" != "X"; then
71 if test "$with_pcap" != "yes"; then
72 ac_cv_pcap_where_lib=$with_pcap/$CMU_LIB_SUBDIR
73 ac_cv_pcap_where_inc=$with_pcap/include
77 if test "X$with_pcap_lib" != "X"; then
78 ac_cv_pcap_where_lib=$with_pcap_lib
80 if test "X$ac_cv_pcap_where_lib" = "X"; then
81 CMU_PCAP_LIB_WHERE(/usr/ng/$CMU_LIB_SUBDIR /usr/$CMU_LIB_SUBDIR /usr/local/$CMU_LIB_SUBDIR)
84 if test "X$with_pcap_include" != "X"; then
85 ac_cv_pcap_where_inc=$with_pcap_include
87 if test "X$ac_cv_pcap_where_inc" = "X"; then
88 CMU_PCAP_INC_WHERE(/usr/ng/include /usr/include /usr/local/include)
91 AC_MSG_CHECKING(whether to include pcap)
92 if test "X$ac_cv_pcap_where_lib" = "X" -a "X$ac_cv_pcap_where_inc" = "X"; then
98 PCAP_INC_DIR=$ac_cv_pcap_where_inc
99 PCAP_LIB_DIR=$ac_cv_pcap_where_lib
100 PCAP_INC_FLAGS="-I${PCAP_INC_DIR}"
101 PCAP_LIB_FLAGS="-L${PCAP_LIB_DIR} -lpcap"
102 if test "X$RPATH" = "X"; then
107 if test "X$RPATH" = "X"; then
108 RPATH="-Wl,-rpath,${PCAP_LIB_DIR}"
110 RPATH="${RPATH}:${PCAP_LIB_DIR}"
114 if test "X$RPATH" = "X"; then
115 RPATH="-Wl,+b${PCAP_LIB_DIR}"
117 RPATH="${RPATH}:${PCAP_LIB_DIR}"
121 if test "X$RPATH" = "X"; then
122 RPATH="-Wl,-rpath,${PCAP_LIB_DIR}"
124 RPATH="${RPATH}:${PCAP_LIB_DIR}"
128 if test "$ac_cv_prog_gcc" = yes; then
129 if test "X$RPATH" = "X"; then
130 RPATH="-Wl,-R${PCAP_LIB_DIR}"
132 RPATH="${RPATH}:${PCAP_LIB_DIR}"
135 RPATH="${RPATH} -R${PCAP_LIB_DIR}"