[PATCH vdagent 1/2] build: make GTK+ optional

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

 



From: Jakub Janků <jjanku@xxxxxxxxxx>

Add --with-gtk configure option.
If used, favor GTK+ over Xlib.
---
 configure.ac          | 13 ++++++++++++-
 src/vdagent/vdagent.c |  8 +++++++-
 src/vdagent/x11.c     |  6 ++++++
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1eb17a9..89f617c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -75,6 +75,16 @@ if test "x$init_systemd" = "xyes"; then
   fi
 fi
 
+AC_ARG_WITH([gtk],
+            [AS_HELP_STRING([--with-gtk], [Use GTK+ instead of Xlib])],
+            [],
+            [with_gtk="auto"])
+if test "x$with_gtk" != "xno"; then
+  PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= 3.10],
+                    [AC_DEFINE([WITH_GTK], [1], [If defined, vdagent will favor GTK+ over Xlib])],
+                    [AS_IF([test "x$with_gtk" = "xyes"], [AC_MSG_ERROR([GTK+ requested but not found])])])
+fi
+
 AC_ARG_ENABLE([pciaccess],
               [AS_HELP_STRING([--enable-pciaccess], [Enable libpciaccess use for auto generation of Xinerama xorg.conf (default: yes)])],
               [enable_pciaccess="$enableval"],
@@ -86,7 +96,6 @@ AC_ARG_ENABLE([static-uinput],
               [enable_static_uinput="no"])
 
 PKG_CHECK_MODULES([GLIB2], [glib-2.0 >= 2.34])
-PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= 3.10])
 PKG_CHECK_MODULES(X, [xfixes xrandr >= 1.3 xinerama x11])
 PKG_CHECK_MODULES(SPICE, [spice-protocol >= 0.12.13])
 PKG_CHECK_MODULES(ALSA, [alsa >= 1.0.22])
@@ -210,6 +219,8 @@ AC_MSG_NOTICE([
         install systemd service:  ${init_systemd}
         udevdir:                  ${udevdir}
 
+        use GTK+:                 ${with_gtk}
+
         Now type 'make' to build $PACKAGE
 
 ])
diff --git a/src/vdagent/vdagent.c b/src/vdagent/vdagent.c
index d86ee25..6bd52fa 100644
--- a/src/vdagent/vdagent.c
+++ b/src/vdagent/vdagent.c
@@ -36,7 +36,9 @@
 #include <spice/vd_agent.h>
 #include <poll.h>
 #include <glib-unix.h>
-#include <gtk/gtk.h>
+#ifdef WITH_GTK
+# include <gtk/gtk.h>
+#endif
 
 #include "udscs.h"
 #include "vdagentd-proto.h"
@@ -401,7 +403,9 @@ int main(int argc, char *argv[])
     g_option_context_set_summary(context,
                                  "\tSpice session guest agent: X11\n"
                                  "\tVersion: " VERSION);
+#ifdef WITH_GTK
     g_option_context_add_group(context, gtk_get_option_group(FALSE));
+#endif
     g_option_context_parse(context, &argc, &argv, &error);
     g_option_context_free(context);
 
@@ -429,8 +433,10 @@ int main(int argc, char *argv[])
     if (do_daemonize)
         parent_socket = daemonize();
 
+#ifdef WITH_GTK
     gdk_set_allowed_backends("x11");
     gtk_init(NULL, NULL);
+#endif
 
 reconnect:
     if (version_mismatch) {
diff --git a/src/vdagent/x11.c b/src/vdagent/x11.c
index 9700847..e6c3e9e 100644
--- a/src/vdagent/x11.c
+++ b/src/vdagent/x11.c
@@ -31,11 +31,17 @@
    Calling XPending when-ever we return to the mainloop also ensures any
    pending writes are flushed. */
 
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
 #include <glib.h>
+#ifdef WITH_GTK
 #include <gdk/gdk.h>
 #ifdef GDK_WINDOWING_X11
 #include <gdk/gdkx.h>
 #endif
+#endif
 #include <stdlib.h>
 #include <limits.h>
 #include <string.h>
-- 
2.14.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]