]> xenbits.xensource.com Git - people/andrewcoop/hwloc.git/commitdiff
Remove Cairo dependency on X11 and factorize X11 tests
authorBrice Goglin <Brice.Goglin@inria.fr>
Wed, 6 Nov 2013 08:49:00 +0000 (09:49 +0100)
committerBrice Goglin <Brice.Goglin@inria.fr>
Wed, 6 Nov 2013 08:51:57 +0000 (09:51 +0100)
Per discussion on the mailing list, it doesn't look like Cairo needs
X11 any more (it doesn't on OS X to generate PDFs and PNGs).  So
remove the dependency in configure.ac.

Also, move the X11 tests from outside of the Cairo tests (and outside
of the GL tests) to be in the main configure logic.

By the way, rename HWLOC_HAVE_X11 into HWLOC_HAVE_X11_KEYSYM to avoid
confusion between Xlib.h/XOpenDisplay being available (what GL needs)
and Xutil.h+keysym.h being available too (what lstopo/X11 needs).

Based on a patch from Jeff, tweaked by me.

config/hwloc.m4
config/hwloc_internal.m4
utils/lstopo-cairo.c
utils/lstopo.c

index f957af37db9051c89d2d558825fffd8163760e54..38069335a58f70f6663b9c5892e6f327c8fd7fe3 100644 (file)
@@ -914,15 +914,39 @@ EOF])
     fi
     # don't add LIBS/CFLAGS/REQUIRES yet, depends on plugins
 
+    # X11 support
+    AC_PATH_XTRA
+
+    CPPFLAGS_save=$CPPFLAGS
+    LIBS_save=$LIBS
+
+    CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+    LIBS="$LIBS $X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS"
+    AC_CHECK_HEADERS([X11/Xlib.h],
+        [AC_CHECK_LIB([X11], [XOpenDisplay],
+            [
+             # the GL backend just needs XOpenDisplay
+             hwloc_enable_X11=yes
+             # lstopo needs more
+             AC_CHECK_HEADERS([X11/Xutil.h],
+                [AC_CHECK_HEADERS([X11/keysym.h],
+                    [AC_DEFINE([HWLOC_HAVE_X11_KEYSYM], [1], [Define to 1 if X11 headers including Xutil.h and keysym.h are available.])])
+                     AC_SUBST([HWLOC_X11_LIBS], ["-lX11"])
+                ])
+            ])
+         ])
+    CPPFLAGS=$CPPFLAGS_save
+    LIBS=$LIBS_save
+
     # GL Support 
     hwloc_gl_happy=no
     if test "x$enable_gl" != "xno"; then
-       hwloc_gl_happy=yes                                                              
+       hwloc_gl_happy=yes
+
+       AS_IF([test "$hwloc_enable_X11" != "yes"],
+              [AC_MSG_WARN([X11 not found; GL disabled])
+               hwloc_gl_happy=no])
 
-        AC_CHECK_HEADERS([X11/Xlib.h], [
-          AC_CHECK_LIB([X11], [XOpenDisplay], [:], [hwloc_gl_happy=no])
-        ], [hwloc_gl_happy=no])
-       
         AC_CHECK_HEADERS([NVCtrl/NVCtrl.h], [
           AC_CHECK_LIB([XNVCtrl], [XNVCTRLQueryTargetAttribute], [:], [hwloc_gl_happy=no], [-lXext])
         ], [hwloc_gl_happy=no])
@@ -1358,4 +1382,4 @@ AC_DEFUN([HWLOC_CHECK_LTDL_DEPS], [
   lt_cv_dlopen="$save_lt_cv_dlopen"
   lt_cv_dlopen_libs="$save_lt_cv_dlopen_libs"
   lt_cv_dlopen_self="$save_lt_cv_dlopen_self"
-])
\ No newline at end of file
+])
index b0ac0414253b9fe6a37dc3f2da2252280f709da5..bfc3f36284d199e88360c1eb5e0f545da0129671 100644 (file)
@@ -255,31 +255,6 @@ EOF
       HWLOC_PKG_CHECK_MODULES([CAIRO], [cairo], [cairo_fill],
                               [hwloc_cairo_happy=yes],
                               [hwloc_cairo_happy=no])
-      if test "x$hwloc_cairo_happy" = "xyes"; then
-        AC_PATH_XTRA
-       CFLAGS_save=$CFLAGS
-       LIBS_save=$LIBS
-
-       CFLAGS="$CFLAGS $X_CFLAGS"
-       LIBS="$LIBS $X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS"
-        AC_CHECK_HEADERS([X11/Xlib.h], [
-          AC_CHECK_HEADERS([X11/Xutil.h X11/keysym.h], [
-            AC_CHECK_LIB([X11], [XOpenDisplay], [
-              enable_X11=yes
-              AC_SUBST([HWLOC_X11_LIBS], ["-lX11"])
-              AC_DEFINE([HWLOC_HAVE_X11], [1], [Define to 1 if X11 libraries are available.])
-            ])]
-          )],,
-          [[#include <X11/Xlib.h>]]
-        )
-        if test "x$enable_X11" != "xyes"; then
-          AC_MSG_WARN([X11 headers not found, Cairo/X11 back-end disabled])
-          hwloc_cairo_happy=no
-        fi
-
-       CFLAGS=$CFLAGS_save
-       LIBS=$LIBS_save
-      fi
     fi
     
     if test "x$hwloc_cairo_happy" = "xyes"; then
index 3b28710d0aeacdf5f7f8b07355bdb4b625889f66..a4a68ada50d27f3e3474ca4c2c094da18dde4208 100644 (file)
@@ -22,7 +22,7 @@
 #include <cairo-svg.h>
 #endif /* CAIRO_HAS_SVG_SURFACE */
 
-#ifndef HWLOC_HAVE_X11
+#ifndef HWLOC_HAVE_X11_KEYSYM
 /* In case X11 headers aren't availble, forcefully disable Cairo/Xlib.  */
 # undef CAIRO_HAS_XLIB_SURFACE
 # define CAIRO_HAS_XLIB_SURFACE 0
index 5b8df2e50da024065c9da7e0606a62c65555c238..8dd3501b5acbe56e925084e4d98619d858d4454d 100644 (file)
@@ -632,7 +632,7 @@ main (int argc, char *argv[])
   switch (output_format) {
     case LSTOPO_OUTPUT_DEFAULT:
 #ifdef LSTOPO_HAVE_GRAPHICS
-#if CAIRO_HAS_XLIB_SURFACE && defined HWLOC_HAVE_X11
+#if CAIRO_HAS_XLIB_SURFACE && defined HWLOC_HAVE_X11_KEYSYM
       if (getenv("DISPLAY")) {
         if (logical == -1)
           logical = 0;