[libvirt] [PATCH] rpm-build: use pkg-config to detect wireshark presence

Wireshark supports pkg-config since 1.11.3. Right now we build wireshark-dissectior tool as default trough rpm build only on fedora >= 21 and there is newer wireshark that supports pkg-config. If someone wants to build libvirt with wireshark-dissector against older wireshark, they should specify the location by hand. This patch is mainly to fix wrong dependency on wireshark binary as it doesn't make sense to require that binary file to just get version info of that package in makefile. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- configure.ac | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/configure.ac b/configure.ac index 2fedd1a..75a0688 100644 --- a/configure.ac +++ b/configure.ac @@ -2669,25 +2669,12 @@ if test "$with_wireshark_dissector" != "no"; then ]) dnl Search for wireshark(or tshark) command - AC_PATH_PROG([WIRESHARK], [wireshark]) - AC_PATH_PROG([WIRESHARK], [tshark]) - if test -z "$WIRESHARK"; then - LIBVIRT_WS_HANDLE_ERROR([command not found wireshark or tshark]) - else - dnl Check for wireshark headers - save_CPPFLAGS="$CPPFLAGS" - WS_DISSECTOR_CPPFLAGS="$WS_DISSECTOR_CPPFLAGS -I`dirname $WIRESHARK`/../include/wireshark" - CPPFLAGS="$CPPFLAGS $WS_DISSECTOR_CPPFLAGS" - AC_CHECK_HEADERS([wireshark/config.h],, [ - LIBVIRT_WS_HANDLE_ERROR([wireshark/config.h is required for wireshark-dissector support]) - ]) - AC_CHECK_HEADERS([wireshark/epan/packet.h wireshark/epan/dissectors/packet-tcp.h],, [ - LIBVIRT_WS_HANDLE_ERROR([wireshark/epan/{packet,packet-tcp}.h are required for wireshark-dissector support]) - ], [ - #include <wireshark/config.h> - ]) - CPPFLAGS="$save_CPPFLAGS" - fi + PKG_CHECK_MODULES([WIRESHARK], [wireshark], [ + WS_DISSECTOR_CPPFLAGS="$WS_DISSECTOR_CPPFLAGS `$PKG_CONFIG --cflags wireshark`" + ws_version=`$PKG_CONFIG --modversion wireshark` + ], [ + LIBVIRT_WS_HANDLE_ERROR([pkg-config 'wireshark' is required for wireshark-dissector support]) + ]) if test "$with_wireshark_dissector" != "no"; then with_wireshark_dissector=yes fi @@ -2701,7 +2688,6 @@ AC_ARG_WITH([ws-plugindir], [ws_plugindir=$withval]) if test "$with_wireshark_dissector" != "no" && test -z "$ws_plugindir"; then - ws_version=`$WIRESHARK -v | head -1 | cut -f 2 -d' '` ws_plugindir="$libdir/wireshark/plugins/$ws_version" fi AC_SUBST([ws_plugindir]) -- 2.0.5

On Mon, Mar 16, 2015 at 01:41:15PM +0100, Pavel Hrdina wrote:
Wireshark supports pkg-config since 1.11.3. Right now we build wireshark-dissectior tool as default trough rpm build only on fedora >= 21 and there is newer wireshark that supports pkg-config. If someone wants to build libvirt with wireshark-dissector against older wireshark, they should specify the location by hand.
This patch is mainly to fix wrong dependency on wireshark binary as it doesn't make sense to require that binary file to just get version info of that package in makefile.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Be nice to go one step further and switch over to using LIBVIRT_CHECK_PKG and having the code in m4/virt-wireshark.m4. Just copy virt-fuse.m4 as a equivalently simple module Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On Mon, Mar 16, 2015 at 12:46:04PM +0000, Daniel P. Berrange wrote:
On Mon, Mar 16, 2015 at 01:41:15PM +0100, Pavel Hrdina wrote:
Wireshark supports pkg-config since 1.11.3. Right now we build wireshark-dissectior tool as default trough rpm build only on fedora >= 21 and there is newer wireshark that supports pkg-config. If someone wants to build libvirt with wireshark-dissector against older wireshark, they should specify the location by hand.
This patch is mainly to fix wrong dependency on wireshark binary as it doesn't make sense to require that binary file to just get version info of that package in makefile.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Be nice to go one step further and switch over to using LIBVIRT_CHECK_PKG and having the code in m4/virt-wireshark.m4. Just copy virt-fuse.m4 as a equivalently simple module
At first I thought that I'll be nice, but this is not that simple module. Wireshark requires glib-2.0 and also there is an optional argument --with-ws-plugindir. This is actually the only thing I tried to avoid, but you're right that if I'm touching this code that it would be nice to make a separate m4 module. I'll send a v2. Thanks for review. Pavel
Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On Mon, Mar 16, 2015 at 02:38:40PM +0100, Pavel Hrdina wrote:
On Mon, Mar 16, 2015 at 12:46:04PM +0000, Daniel P. Berrange wrote:
On Mon, Mar 16, 2015 at 01:41:15PM +0100, Pavel Hrdina wrote:
Wireshark supports pkg-config since 1.11.3. Right now we build wireshark-dissectior tool as default trough rpm build only on fedora >= 21 and there is newer wireshark that supports pkg-config. If someone wants to build libvirt with wireshark-dissector against older wireshark, they should specify the location by hand.
This patch is mainly to fix wrong dependency on wireshark binary as it doesn't make sense to require that binary file to just get version info of that package in makefile.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Be nice to go one step further and switch over to using LIBVIRT_CHECK_PKG and having the code in m4/virt-wireshark.m4. Just copy virt-fuse.m4 as a equivalently simple module
At first I thought that I'll be nice, but this is not that simple module. Wireshark requires glib-2.0 and also there is an optional argument --with-ws-plugindir. This is actually the only thing I tried to avoid, but you're right that if I'm touching this code that it would be nice to make a separate m4 module. I'll send a v2.
You shouldn't need to check for glib2.0 yourself - if that dependancy is declared in the wireshark.pc (as it should be), then pkg-config itself will check that for you. Moving the --with-ws-plugindir arg declaration into the virt-wireshark.m4 file is pretty straightforward - we do that in a number of cases already so just checkout some more existing examples. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (2)
-
Daniel P. Berrange
-
Pavel Hrdina