[ulogd2 PATCH 04/10] build: use pkg-config or pcap-config for libpcap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Recent versions of libpcap have supported pkg-config.  Older versions
provide an pcap-config script.  Use pkg-config if available, otherwise
fall back to pcap_config.

Signed-off-by: Jeremy Sowden <jeremy@xxxxxxxxxx>
---
 acinclude.m4 | 79 ----------------------------------------------------
 configure.ac | 30 ++++++++++++++++++--
 2 files changed, 27 insertions(+), 82 deletions(-)

diff --git a/acinclude.m4 b/acinclude.m4
index a49ed316e65a..6d88c3a53cff 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -93,82 +93,3 @@ fi
 
 ])
 
-dnl @synopsis CT_CHECK_PCAP
-dnl
-dnl This macro tries to find the headers and libraries for libpcap.
-dnl
-dnl If includes are found, the variable PCAP_INC will be set. If
-dnl libraries are found, the variable PCAP_LIB will be set. if no check
-dnl was successful, the script exits with a error message.
-dnl
-dnl @category InstalledPackages
-dnl @author Harald Welte <laforge@xxxxxxxxxxxx>
-dnl @version 2006-01-07
-dnl @license AllPermissive
-
-AC_DEFUN([CT_CHECK_PCAP], [
-
-AC_ARG_WITH(pcap,
-	[  --with-pcap=PREFIX		Prefix of your libpcap installation],
-	[pcap_prefix=$withval], [pcap_prefix=])
-AC_ARG_WITH(pcap-inc,
-	[  --with-pcap-inc=PATH		Path to the include directory of pcap],
-	[pcap_inc=$withval], [pcap_inc=/usr/include])
-AC_ARG_WITH(pcap-lib,
-	[  --with-pcap-lib=PATH		Path to the libraries of pcap],
-	[pcap_lib=$withval], [pcap_lib=/usr/lib])
-
-
-AC_SUBST(PCAP_INC)
-AC_SUBST(PCAP_LIB)
-AC_SUBST(HAVE_PCAP_LIB)
-
-if test "$pcap_prefix" != "no"; then
-
-if test "$pcap_prefix" != ""; then
-   AC_MSG_CHECKING([for libpcap includes in $pcap_prefix/include])
-   if test -f "$pcap_prefix/include/pcap.h" ; then
-      PCAP_INC="-I$pcap_prefix/include"
-      AC_MSG_RESULT([yes])
-   else
-      AC_MSG_WARN(pcap.h not found)
-   fi
-   AC_MSG_CHECKING([for libpcap in $pcap_prefix/lib])
-   if test -f "$pcap_prefix/lib/libpcap.so" ; then
-      PCAP_LIB="-L$pcap_prefix/lib -lpcap";
-      AC_MSG_RESULT([yes])
-   else
-      AC_MSG_WARN(libpcap.so not found)
-   fi
-else
-  if test "$pcap_inc" != ""; then
-    AC_MSG_CHECKING([for libpcap includes in $pcap_inc])
-    if test -f "$pcap_inc/pcap.h" ; then
-      PCAP_INC="-I$pcap_inc"
-      AC_MSG_RESULT([yes])
-    else
-      AC_MSG_WARN(pcap.h not found)
-    fi
-  fi
-  if test "$pcap_lib" != ""; then
-    AC_MSG_CHECKING([for libpcap in $pcap_lib])
-    if test -f "$pcap_lib/libpcap.so" ; then
-      PCAP_LIB="-L$pcap_lib -lpcap";
-      AC_MSG_RESULT([yes])
-    else
-      AC_MSG_WARN(libpcap.so not found)
-    fi
-  fi
-fi
-
-if test "$PCAP_INC" = "" ; then
-  AC_CHECK_HEADER([pcap.h], [], AC_MSG_WARN(pcap.h not found))
-fi
-if test "$PCAP_LIB" = "" ; then
-  AC_CHECK_LIB(pcap, pcap_close, [HAVE_PCAP_LIB="yes"], AC_MSG_WARN(libpcap.so not found))
-fi
-
-fi
-
-])
-
diff --git a/configure.ac b/configure.ac
index 524fc151e2f3..bbca53e4c394 100644
--- a/configure.ac
+++ b/configure.ac
@@ -153,9 +153,33 @@ AM_CONDITIONAL([HAVE_DBI], [test "x$libdbi_LIBS" != "x"])
 
 AC_ARG_ENABLE([pcap],
               [AS_HELP_STRING([--enable-pcap], [Enable PCAP output plugin [default=test]])])
-AS_IF([test "x$enable_pcap" != "xno"],
-      [AC_SEARCH_LIBS([pcap_close], [pcap], [libpcap_LIBS="-lpcap"; LIBS=""])
-       AC_SUBST([libpcap_LIBS])])
+AS_IF([test "x$enable_pcap" != "xno"], [
+
+  PKG_CHECK_EXISTS([libpcap], [PKG_CHECK_MODULES([libpcap], [libpcap])], [
+
+    AC_ARG_WITH([pcap-config],
+                [AS_HELP_STRING([--with-pcap-config=PATH], [Path to the pcap-config script])],
+                [pcap_config="$withval"], [pcap_config=pcap-config])
+
+    AC_MSG_CHECKING([for pcap-config])
+
+    AS_IF([command -v "$pcap_config" >/dev/null], [
+
+      libpcap_CFLAGS="`$pcap_config --cflags`"
+      libpcap_LIBS="`$pcap_config --libs`"
+
+      AC_SUBST([libpcap_CFLAGS])
+      AC_SUBST([libpcap_LIBS])
+
+      AC_MSG_RESULT([$pcap_config])
+
+    ], [
+      AC_MSG_RESULT([no])
+    ])
+
+  ])
+
+])
 AS_IF([test "x$libpcap_LIBS" != "x"], [enable_pcap=yes], [enable_pcap=no])
 AM_CONDITIONAL([HAVE_PCAP], [test "x$libpcap_LIBS" != "x"])
 
-- 
2.34.1




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux