[libvirt PATCH 077/351] meson: add wireshark build dependency

Pavel Hrdina phrdina at redhat.com
Thu Jul 16 09:55:13 UTC 2020


Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
---
 configure.ac         |  6 ----
 m4/virt-wireshark.m4 | 71 --------------------------------------------
 meson.build          | 44 +++++++++++++++++++++++++++
 meson_options.txt    |  2 ++
 4 files changed, 46 insertions(+), 77 deletions(-)
 delete mode 100644 m4/virt-wireshark.m4

diff --git a/configure.ac b/configure.ac
index 0b02b259c65..5e92466c4aa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -109,12 +109,10 @@ fi
 
 LIBVIRT_ARG_NSS
 LIBVIRT_ARG_PM_UTILS
-LIBVIRT_ARG_WIRESHARK
 LIBVIRT_ARG_YAJL
 
 LIBVIRT_CHECK_NWFILTER
 LIBVIRT_CHECK_PM_UTILS
-LIBVIRT_CHECK_WIRESHARK
 LIBVIRT_CHECK_XDR
 LIBVIRT_CHECK_YAJL
 
@@ -414,10 +412,6 @@ LIBVIRT_RESULT_LOGIN_SHELL
 LIBVIRT_RESULT_HOST_VALIDATE
 LIBVIRT_RESULT_TLS_PRIORITY
 AC_MSG_NOTICE([])
-AC_MSG_NOTICE([Developer Tools])
-AC_MSG_NOTICE([])
-LIBVIRT_RESULT_WIRESHARK
-AC_MSG_NOTICE([])
 AC_MSG_NOTICE([Privileges])
 AC_MSG_NOTICE([])
 LIBVIRT_RESULT_QEMU_PRIVILEGES
diff --git a/m4/virt-wireshark.m4 b/m4/virt-wireshark.m4
deleted file mode 100644
index 2eee8a6ce86..00000000000
--- a/m4/virt-wireshark.m4
+++ /dev/null
@@ -1,71 +0,0 @@
-dnl The libvirt.so wireshark plugin
-dnl
-dnl Copyright (C) 2015 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_WIRESHARK],[
-  LIBVIRT_ARG_WITH_FEATURE([WIRESHARK_DISSECTOR], [wireshark], [check], [2.4.0])
-  LIBVIRT_ARG_WITH([WS_PLUGINDIR],
-                   [wireshark plugins directory for use when installing
-                   wireshark plugin], [check])
-])
-
-AC_DEFUN([LIBVIRT_CHECK_WIRESHARK],[
-  LIBVIRT_CHECK_PKG([WIRESHARK_DISSECTOR], [wireshark], [2.4.0])
-
-  dnl Check for system location of wireshark plugins
-  if test "x$with_wireshark_dissector" != "xno" ; then
-    if test "x$with_ws_plugindir" = "xcheck" ; then
-      ws_plugindir="$($PKG_CONFIG --variable plugindir wireshark)"
-      ws_exec_prefix="$($PKG_CONFIG --variable exec_prefix wireshark)"
-      ws_modversion="$($PKG_CONFIG --modversion wireshark)"
-      if test "x$ws_plugindir" = "x" ; then
-        dnl On some systems the plugindir variable may not be stored within pkg config.
-        dnl Fall back to older style of constructing the plugin dir path.
-        ws_plugindir="$libdir/wireshark/plugins/$ws_modversion"
-      else
-        if test "x$ws_exec_prefix" = "x" ; then
-          dnl If wireshark's exec_prefix cannot be retrieved from pkg-config,
-          dnl this is our best bet
-          ws_exec_prefix="/usr"
-        fi
-        dnl Replace wireshark's exec_prefix with our own.
-        dnl Note that ${exec_prefix} is kept verbatim at this point in time,
-        dnl and will only be expanded later, when make is called: this makes
-        dnl it possible to override such prefix at compilation or installation
-        dnl time
-        ws_plugindir='${exec_prefix}'"${ws_plugindir#$ws_exec_prefix}"
-      fi
-
-      dnl Since wireshark 2.5.0 plugins can't live in top level
-      dnl plugindir but have to be under one of ["epan",
-      dnl "wiretap", "codecs"] subdir. The first one looks okay.
-      ws_plugindir="$ws_plugindir/epan"
-
-    elif test "x$with_ws_plugindir" = "xno" || test "x$with_ws_plugindir" = "xyes"; then
-      AC_MSG_ERROR([ws-plugindir must be used only with valid path])
-    else
-      ws_plugindir=$with_ws_plugindir
-    fi
-  fi
-
-  AC_SUBST([ws_plugindir])
-])
-
-AC_DEFUN([LIBVIRT_RESULT_WIRESHARK],[
-  LIBVIRT_RESULT_LIB([WIRESHARK_DISSECTOR])
-])
diff --git a/meson.build b/meson.build
index 3f05a1c0c6b..b710417db2f 100644
--- a/meson.build
+++ b/meson.build
@@ -1404,6 +1404,45 @@ else
   win32_link_flags = []
 endif
 
+wireshark_version = '2.4.0'
+wireshark_dep = dependency('wireshark', version: '>=' + wireshark_version, required: get_option('wireshark_dissector'))
+if wireshark_dep.found()
+  wireshark_plugindir = get_option('wireshark_plugindir')
+  if wireshark_plugindir == ''
+    wireshark_plugindir = wireshark_dep.get_pkgconfig_variable('plugindir')
+  endif
+
+  # On some systems the plugindir variable may not be stored within pkg config.
+  # Fall back to older style of constructing the plugin dir path.
+  if wireshark_plugindir == ''
+    wireshark_modversion = wireshark_dep.version()
+    wireshark_plugindir = '@0@/wireshark/plugins/@1@'.format(
+      libdir, wireshark_modversion
+    )
+  else
+    wireshark_prefix = wireshark_dep.get_pkgconfig_variable('prefix')
+    if wireshark_prefix == ''
+      # If wireshark's prefix cannot be retrieved from pkg-config,
+      # this is our best bet.
+      wireshark_prefix = '/usr'
+    endif
+    # Replace wireshark's prefix with our own.
+    # There is no replace method in meson so we have to workaround it.
+    rc = run_command(
+      'python3', '-c',
+      'print("@0@".replace("@1@", "@2@"))'.format(
+        wireshark_plugindir, wireshark_prefix, prefix,
+      ),
+      check: true,
+    )
+    wireshark_plugindir = rc.stdout().strip()
+  endif
+
+  # Since wireshark 2.5.0 plugins can't live in top level plugindir but have
+  # to be under one of ["epan", "wiretap", "codecs"] subdir. The first one looks okay.
+  wireshark_plugindir = wireshark_plugindir / 'epan'
+endif
+
 
 # generic build dependencies checks
 
@@ -1537,3 +1576,8 @@ misc_summary = {
   'Warning Flags': supported_cc_flags,
 }
 summary(misc_summary, section: 'Miscellaneous', bool_yn: true, list_sep: ' ')
+
+devtools_summary = {
+  'wireshark_dissector': wireshark_dep.found(),
+}
+summary(devtools_summary, section: 'Developer Tools', bool_yn: true)
diff --git a/meson_options.txt b/meson_options.txt
index 025cc663027..25aa81621f9 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -41,3 +41,5 @@ option('selinux', type: 'feature', value: 'auto', description: 'selinux support'
 option('selinux_mount', type: 'string', value: '', description: 'set SELinux mount point')
 option('udev', type: 'feature', value: 'auto', description: 'udev support')
 option('virtualport', type: 'feature', value: 'auto', description: 'enable virtual port support')
+option('wireshark_dissector', type: 'feature', value: 'auto', description: 'wireshark support')
+option('wireshark_plugindir', type: 'string', value: '', description: 'wireshark plugins directory for use when installing wireshark plugin')
-- 
2.26.2




More information about the libvir-list mailing list