From f0e51dee8cdf9a86e7163436fe86cd6b2233ae7c Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Tue, 3 Feb 2009 16:41:48 +0000 Subject: [PATCH] add libpcap detection git-svn-id: http://svn.openzap.org/svn/openzap/trunk@639 a93c3328-9c30-0410-af19-c9cd2b2d52af --- libs/openzap/acinclude.m4 | 1 + libs/openzap/build/libpcap.m4 | 38 +++++++++++++++++++++++++++++++++-- libs/openzap/configure.ac | 1 + 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 libs/openzap/acinclude.m4 diff --git a/libs/openzap/acinclude.m4 b/libs/openzap/acinclude.m4 new file mode 100644 index 0000000000..908ddba855 --- /dev/null +++ b/libs/openzap/acinclude.m4 @@ -0,0 +1 @@ +m4_include([build/libpcap.m4]) diff --git a/libs/openzap/build/libpcap.m4 b/libs/openzap/build/libpcap.m4 index 77fce6a2f0..fd3bbe1da0 100644 --- a/libs/openzap/build/libpcap.m4 +++ b/libs/openzap/build/libpcap.m4 @@ -34,6 +34,18 @@ ac_cv_found_pcap_lib=no) LIBS=$saved_LIBS ]) +AC_DEFUN([TEST_LIBPATH], [ +changequote(<<, >>) +define(<>, translit(ac_cv_found_$2_lib, <<- *>>, <<__p>>)) +changequote([, ]) +if test "$AC_CV_FOUND" = "yes"; then + if test \! -r "$1/lib$2.a" -a \! -r "$1/lib$2.so" -a \! -r "$1/lib$2.sl" -a \! -r "$1/lib$2.dylib"; then + AC_CV_FOUND=no + fi +fi +]) + + AC_DEFUN([PCAP_LIB_WHERE], [ for i in $1; do AC_MSG_CHECKING(for pcap library in $i) @@ -49,7 +61,29 @@ AC_DEFUN([PCAP_LIB_WHERE], [ done ]) -AC_DEFUN([PCAP], [ +AC_DEFUN([FIND_LIB_SUBDIR], +[dnl +AC_ARG_WITH([lib-subdir], AC_HELP_STRING([--with-lib-subdir=DIR],[Find libraries in DIR instead of lib])) +AC_CHECK_SIZEOF(long) +AC_CACHE_CHECK([what directory libraries are found in], [ac_cv_cmu_lib_subdir], +[test "X$with_lib_subdir" = "Xyes" && with_lib_subdir= +test "X$with_lib_subdir" = "Xno" && with_lib_subdir= + if test "X$with_lib_subdir" = "X" ; then + ac_cv_cmu_lib_subdir=lib + if test $ac_cv_sizeof_long -eq 4 ; then + test -d /usr/lib32 && ac_cv_cmu_lib_subdir=lib32 + fi + if test $ac_cv_sizeof_long -eq 8 ; then + test -d /usr/lib64 && ac_cv_cmu_lib_subdir=lib64 + fi + else + ac_cv_cmu_lib_subdir=$with_lib_subdir + fi]) + AC_SUBST(LIB_SUBDIR, $ac_cv_cmu_lib_subdir) + ]) + + +AC_DEFUN([AX_LIB_PCAP], [ AC_REQUIRE([FIND_LIB_SUBDIR]) AC_ARG_WITH(pcap, [ --with-pcap=PREFIX Compile with PCAP support], @@ -78,7 +112,7 @@ AC_ARG_WITH(pcap-include, ac_cv_pcap_where_lib=$with_pcap_lib fi if test "X$ac_cv_pcap_where_lib" = "X"; then - PCAP_LIB_WHERE(/usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64) + PCAP_LIB_WHERE(/usr/$LIB_SUBDIR /usr/local/$LIB_SUBDIR) fi if test "X$with_pcap_include" != "X"; then diff --git a/libs/openzap/configure.ac b/libs/openzap/configure.ac index 471030debf..3aedc1a354 100644 --- a/libs/openzap/configure.ac +++ b/libs/openzap/configure.ac @@ -101,6 +101,7 @@ AC_SUBST(DYNAMIC_LIB_EXTEN) AC_CHECK_LIB([dl], [dlopen]) AC_CHECK_LIB([pthread], [pthread_create]) AC_CHECK_LIB([m], [cos]) +AX_LIB_PCAP AC_CHECK_HEADERS([netinet/sctp.h netdb.h sys/select.h]) AC_CHECK_FUNC([gethostbyname_r],