]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
meson: add libpcap build option
authorPavel Hrdina <phrdina@redhat.com>
Wed, 24 Jun 2020 11:27:03 +0000 (13:27 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Mon, 3 Aug 2020 07:26:59 +0000 (09:26 +0200)
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
configure.ac
m4/virt-libpcap.m4 [deleted file]
meson.build
meson_options.txt

index d024e1c7e40f3ca23f92d6c0d7418f523845166c..0946a78336405682eeec3f7b06625147aff9a5de 100644 (file)
@@ -110,7 +110,6 @@ fi
 
 # Check for compiler and library settings.
 
-LIBVIRT_ARG_LIBPCAP
 LIBVIRT_ARG_LIBSSH
 LIBVIRT_ARG_LIBXML
 LIBVIRT_ARG_NETCF
@@ -130,7 +129,6 @@ LIBVIRT_ARG_VIRTUALPORT
 LIBVIRT_ARG_WIRESHARK
 LIBVIRT_ARG_YAJL
 
-LIBVIRT_CHECK_LIBPCAP
 LIBVIRT_CHECK_LIBSSH
 LIBVIRT_CHECK_LIBXML
 LIBVIRT_CHECK_NETCF
@@ -428,7 +426,6 @@ LIBVIRT_RESULT_DRIVER_MODULES
 AC_MSG_NOTICE([])
 AC_MSG_NOTICE([Libraries])
 AC_MSG_NOTICE([])
-LIBVIRT_RESULT_LIBPCAP
 LIBVIRT_RESULT_LIBSSH
 LIBVIRT_RESULT_LIBXL
 LIBVIRT_RESULT_LIBXML
diff --git a/m4/virt-libpcap.m4 b/m4/virt-libpcap.m4
deleted file mode 100644 (file)
index 605c2fd..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-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([LIBPCAP], [libpcap location], [check])
-])
-
-AC_DEFUN([LIBVIRT_CHECK_LIBPCAP], [
-  LIBPCAP_REQUIRED="1.5.0"
-  LIBPCAP_CONFIG="pcap-config"
-  LIBPCAP_CFLAGS=""
-  LIBPCAP_LIBS=""
-
-  if test "x$with_libpcap" != "xno"; then
-    case $with_libpcap in
-      ''|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
-        if test "x$with_libpcap" != "xcheck"; then
-          AC_MSG_ERROR([You must install libpcap >= $LIBPCAP_REQUIRED to compile libvirt])
-        fi
-        AC_MSG_RESULT(no)
-        with_libpcap="no"
-      else
-        LIBPCAP_LIBS="`$LIBPCAP_CONFIG --libs`"
-        LIBPCAP_CFLAGS="`$LIBPCAP_CONFIG --cflags`"
-        with_libpcap="yes"
-        AC_MSG_RESULT(yes)
-      fi
-    ])
-  fi
-
-  if test "x$with_libpcap" = "xyes"; then
-    AC_DEFINE_UNQUOTED([HAVE_LIBPCAP], 1, [whether libpcap can be used])
-  fi
-
-  AC_SUBST([LIBPCAP_CFLAGS])
-  AC_SUBST([LIBPCAP_LIBS])
-])
-
-AC_DEFUN([LIBVIRT_RESULT_LIBPCAP], [
-  LIBVIRT_RESULT_LIB([LIBPCAP])
-])
index 4cf6c588b2530ccd9e5033f25484a2d8cd168abb..809d76695ef02885d38c6c62168679d35be87926 100644 (file)
@@ -1110,6 +1110,23 @@ if libparted_dep.found()
   endif
 endif
 
+libpcap_version = '1.5.0'
+libpcap_dep = dependency('libpcap', version: '>=' + libpcap_version, required: false)
+if not libpcap_dep.found()
+  pcap_config_prog = find_program('pcap-config', required: get_option('libpcap'))
+  if pcap_config_prog.found()
+    pcap_args = run_command(pcap_config_prog, '--cflags').stdout().strip().split()
+    pcap_libs = run_command(pcap_config_prog, '--libs').stdout().strip().split()
+    libpcap_dep = declare_dependency(
+      compile_args: pcap_args,
+      link_args: pcap_libs,
+    )
+  endif
+endif
+if libpcap_dep.found()
+  conf.set('HAVE_LIBPCAP', 1)
+endif
+
 use_macvtap = false
 if not get_option('macvtap').disabled()
   if (cc.has_header_symbol('linux/if_link.h', 'MACVLAN_MODE_BRIDGE') and
@@ -1275,6 +1292,7 @@ libs_summary = {
   'hal': hal_dep.found(),
   'libiscsi': libiscsi_dep.found(),
   'libnl': libnl_dep.found(),
+  'libpcap': libpcap_dep.found(),
   'macvtap': conf.has('WITH_MACVTAP'),
   'readline': readline_dep.found(),
 }
index 14deaa75354105dbbec2a1dd223e2eac95c0d0e2..a47f8de6a39c3325119ed858280b9bdd1717111a 100644 (file)
@@ -25,6 +25,7 @@ option('fuse', type: 'feature', value: 'auto', description: 'fuse support')
 option('glusterfs', type: 'feature', value: 'auto', description: 'glusterfs support')
 option('hal', type: 'feature', value: 'auto', description: 'hal support')
 option('libiscsi', type: 'feature', value: 'auto', description: 'libiscsi support')
+option('libpcap', type: 'feature', value: 'auto', description: 'libpcap support')
 option('macvtap', type: 'feature', value: 'auto', description: 'enable macvtap device')
 option('readline', type: 'feature', value: 'auto', description: 'readline support')