From 4fb0dcac3aad64c02d480d7aeb7969bcf1c2fe38 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 25 Feb 2011 12:49:54 +0000 Subject: [PATCH 2/2] Check for X even if X11 autolaunching is disabled DBUS_ENABLE_X11_AUTOLAUNCH obviously requires DBUS_BUILD_X11. However, the converse is not true. If DBUS_BUILD_X11 is defined, dbus-launch will be able to connect to the X server to determine when the session ends; most distributors will want this, but it can be disabled with the standard Autoconf option --without-x. If DBUS_ENABLE_X11_AUTOLAUNCH is *also* defined, dbus-launch and libdbus will be willing to perform autolaunch. Again, most distributors will want this, but it can be disabled with --disable-x11-autolaunch. --- cmake/config.h.cmake | 5 +++++ configure.ac | 13 ++++++++----- dbus/dbus-sysdeps-unix.c | 2 +- test/name-test/test-autolaunch.c | 2 +- tools/dbus-launch.c | 13 +++++++++---- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 295e028..b7a6f02 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -83,6 +83,11 @@ #endif #cmakedefine DBUS_BUILD_X11 1 +/* For the moment, the cmake build system doesn't have an equivalent of + * the autoconf build system's --disable-x11-autolaunch */ +#ifdef DBUS_BUILD_X11 +# define DBUS_ENABLE_X11_AUTOLAUNCH 1 +#endif #define _DBUS_VA_COPY_ASSIGN(a1,a2) { a1 = a2; } diff --git a/configure.ac b/configure.ac index 815783d..b948fc7 100644 --- a/configure.ac +++ b/configure.ac @@ -1075,9 +1075,6 @@ if test "x$dbus_win" = xyes; then fi enable_x11_autolaunch=no -fi - -if test "x$enable_x11_autolaunch" = xno; then have_x11=no else AC_PATH_XTRA @@ -1095,11 +1092,17 @@ if test "x$enable_x11_autolaunch,$have_x11" = xyes,no; then AC_MSG_ERROR([X11 auto-launch requires X headers/libraries]) else # move from "auto" to "yes" or "no" if necessary - enable_x11_autolaunch="$have_x11" + if test "x$enable_x11_autolaunch" != xno; then + enable_x11_autolaunch="$have_x11" + fi +fi + +if test "x$have_x11" = xyes ; then + AC_DEFINE([DBUS_BUILD_X11], [1], [Define to build X11 functionality]) fi if test "x$enable_x11_autolaunch" = xyes ; then - AC_DEFINE([DBUS_BUILD_X11], [1], [Define to enable X11 auto-launch]) + AC_DEFINE([DBUS_ENABLE_X11_AUTOLAUNCH], [1], [Define to enable X11 auto-launch]) fi AC_SUBST([DBUS_X_CFLAGS]) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index e9ea253..b3e9303 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -3257,7 +3257,7 @@ _dbus_get_autolaunch_address (const char *scope, DBusString *address, DBusError *error) { -#ifdef DBUS_BUILD_X11 +#ifdef DBUS_ENABLE_X11_AUTOLAUNCH /* Perform X11-based autolaunch. (We also support launchd-based autolaunch, * but that's done elsewhere, and if it worked, this function wouldn't * be called.) */ diff --git a/test/name-test/test-autolaunch.c b/test/name-test/test-autolaunch.c index d50dfbf..5e51989 100644 --- a/test/name-test/test-autolaunch.c +++ b/test/name-test/test-autolaunch.c @@ -20,7 +20,7 @@ main (int argc, char *argv[]) conn = dbus_bus_get (DBUS_BUS_SESSION, &error); -#ifdef DBUS_BUILD_X11 +#ifdef DBUS_ENABLE_X11_AUTOLAUNCH if (dbus_error_is_set (&error)) { fprintf (stderr, "*** Failed to autolaunch session bus: %s\n", diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index ce9c7b1..d430499 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -914,7 +914,11 @@ main (int argc, char **argv) fprintf (stderr, "Autolaunch requested, but X11 support not compiled in.\n" "Cannot continue.\n"); exit (1); -#else +#else /* DBUS_BUILD_X11 */ +#ifndef DBUS_ENABLE_X11_AUTOLAUNCH + fprintf (stderr, "X11 autolaunch support disabled at compile time.\n"); + exit (1); +#else /* DBUS_ENABLE_X11_AUTOLAUNCH */ char *address; pid_t pid; long wid; @@ -951,11 +955,12 @@ main (int argc, char **argv) bourne_shell_syntax, binary_syntax, argc, argv, remaining_args); exit (0); } +#endif /* DBUS_ENABLE_X11_AUTOLAUNCH */ } - else if (read_machine_uuid_if_needed()) + else if (read_machine_uuid_if_needed()) { x11_init(); -#endif +#endif /* DBUS_BUILD_X11 */ } @@ -1174,7 +1179,7 @@ main (int argc, char **argv) close (bus_pid_to_launcher_pipe[READ_END]); -#ifdef DBUS_BUILD_X11 +#ifdef DBUS_ENABLE_X11_AUTOLAUNCH if (xdisplay != NULL) { verbose("Saving x11 address\n"); -- 1.7.4.1