[libvirt] [PATCH 23/89] configure: move libpcap check to its own file

Pavel Hrdina phrdina at redhat.com
Fri Dec 16 09:10:51 UTC 2016


Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
---
 configure.ac       | 42 +++---------------------------------
 m4/virt-libpcap.m4 | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 66 insertions(+), 39 deletions(-)
 create mode 100644 m4/virt-libpcap.m4

diff --git a/configure.ac b/configure.ac
index e80528d211..c040707397 100644
--- a/configure.ac
+++ b/configure.ac
@@ -112,7 +112,6 @@ fi
 dnl Required minimum versions of all libs we depend on
 PARTED_REQUIRED="1.8.0"
 DEVMAPPER_REQUIRED=1.0.0
-LIBPCAP_REQUIRED="1.0.0"
 LIBNL_REQUIRED="1.1"
 PARALLELS_SDK_REQUIRED="7.0.22"
 dnl Where we look for daemons and admin binaries during configure
@@ -1010,39 +1009,8 @@ if test "$with_numad" = "yes"; then
 fi
 AM_CONDITIONAL([HAVE_NUMAD], [test "$with_numad" != "no"])
 
-dnl pcap lib
-LIBPCAP_CONFIG="pcap-config"
-LIBPCAP_CFLAGS=""
-LIBPCAP_LIBS=""
-LIBPCAP_FOUND="no"
-
-LIBVIRT_ARG_WITH_ALT([LIBPCAP], [libpcap location], [check])
-if test "$with_qemu" = "yes"; then
-  case $with_libpcap in
-    no)     LIBPCAP_CONFIG= ;;
-    ''|yes|check) LIBPCAP_CONFIG="pcap-config" ;;
-    *)      LIBPCAP_CONFIG="$with_libpcap/bin/pcap-config" ;;
-  esac
-  AS_IF([test "x$LIBPCAP_CONFIG" != "x"], [
-    AC_MSG_CHECKING(libpcap $LIBPCAP_CONFIG >= $LIBPCAP_REQUIRED )
-    if ! $LIBPCAP_CONFIG --libs > /dev/null 2>&1 ; then
-      AC_MSG_RESULT(no)
-    else
-      LIBPCAP_LIBS="`$LIBPCAP_CONFIG --libs`"
-      LIBPCAP_CFLAGS="`$LIBPCAP_CONFIG --cflags`"
-      LIBPCAP_FOUND="yes"
-      AC_MSG_RESULT(yes)
-    fi
-  ])
-fi
-
-if test "x$LIBPCAP_FOUND" = "xyes"; then
-  AC_DEFINE_UNQUOTED([HAVE_LIBPCAP], 1, [whether libpcap can be used])
-fi
-
-AC_SUBST([LIBPCAP_CFLAGS])
-AC_SUBST([LIBPCAP_LIBS])
-
+LIBVIRT_ARG_LIBPCAP
+LIBVIRT_CHECK_LIBPCAP
 
 
 dnl
@@ -2161,6 +2129,7 @@ LIBVIRT_RESULT_FUSE
 LIBVIRT_RESULT_GLUSTER
 LIBVIRT_RESULT_GNUTLS
 LIBVIRT_RESULT_HAL
+LIBVIRT_RESULT_LIBPCAP
 LIBVIRT_RESULT_LIBSSH
 LIBVIRT_RESULT_LIBXML
 LIBVIRT_RESULT_NETCF
@@ -2192,11 +2161,6 @@ AC_MSG_NOTICE([xenlight: $LIBXL_CFLAGS $LIBXL_LIBS])
 else
 AC_MSG_NOTICE([xenlight: no])
 fi
-if test "$with_qemu" = "yes" && test "$LIBPCAP_FOUND" != "no"; then
-AC_MSG_NOTICE([    pcap: $LIBPCAP_CFLAGS $LIBPCAP_LIBS])
-else
-AC_MSG_NOTICE([    pcap: no])
-fi
 if test "$have_libnl" = "yes" ; then
 AC_MSG_NOTICE([      nl: $LIBNL_CFLAGS $LIBNL_LIBS])
 else
diff --git a/m4/virt-libpcap.m4 b/m4/virt-libpcap.m4
new file mode 100644
index 0000000000..a360194ee7
--- /dev/null
+++ b/m4/virt-libpcap.m4
@@ -0,0 +1,63 @@
+dnl The pcap library
+dnl
+dnl Copyright (C) 2016 Red Hat, Inc.
+dnl
+dnl This library is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU Lesser General Public
+dnl License as published by the Free Software Foundation; either
+dnl version 2.1 of the License, or (at your option) any later version.
+dnl
+dnl This library is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl Lesser General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU Lesser General Public
+dnl License along with this library.  If not, see
+dnl <http://www.gnu.org/licenses/>.
+dnl
+
+AC_DEFUN([LIBVIRT_ARG_LIBPCAP], [
+  LIBVIRT_ARG_WITH_ALT([LIBPCAP], [libpcap location], [check])
+])
+
+AC_DEFUN([LIBVIRT_CHECK_LIBPCAP], [
+  LIBPCAP_REQUIRED="1.0.0"
+  LIBPCAP_CONFIG="pcap-config"
+  LIBPCAP_CFLAGS=""
+  LIBPCAP_LIBS=""
+  LIBPCAP_FOUND="no"
+
+  if test "$with_qemu" = "yes"; then
+    case $with_libpcap in
+      no)     LIBPCAP_CONFIG= ;;
+      ''|yes|check) LIBPCAP_CONFIG="pcap-config" ;;
+      *)      LIBPCAP_CONFIG="$with_libpcap/bin/pcap-config" ;;
+    esac
+    AS_IF([test "x$LIBPCAP_CONFIG" != "x"], [
+      AC_MSG_CHECKING(libpcap $LIBPCAP_CONFIG >= $LIBPCAP_REQUIRED )
+      if ! $LIBPCAP_CONFIG --libs > /dev/null 2>&1 ; then
+        AC_MSG_RESULT(no)
+      else
+        LIBPCAP_LIBS="`$LIBPCAP_CONFIG --libs`"
+        LIBPCAP_CFLAGS="`$LIBPCAP_CONFIG --cflags`"
+        LIBPCAP_FOUND="yes"
+        AC_MSG_RESULT(yes)
+      fi
+    ])
+  fi
+
+  if test "x$LIBPCAP_FOUND" = "xyes"; then
+    AC_DEFINE_UNQUOTED([HAVE_LIBPCAP], 1, [whether libpcap can be used])
+    with_libpcap="yes"
+  else
+    with_libpcap="no"
+  fi
+
+  AC_SUBST([LIBPCAP_CFLAGS])
+  AC_SUBST([LIBPCAP_LIBS])
+])
+
+AC_DEFUN([LIBVIRT_RESULT_LIBPCAP], [
+  LIBVIRT_RESULT_LIB([LIBPCAP])
+])
-- 
2.11.0




More information about the libvir-list mailing list