From: Christophe CURIS <christophe.cu...@free.fr>

The original check was not compliant with autoconf's syntax, did not have
a very good behaviour for user and was not easy to make evolve.

The new macro:
 - uses as much as possible autoconf macros for portability and code
consistency;
 - checks also for header usability with the compiler;
 - provides a consistent behaviour on yes/no/auto (if user explicitly
enables support, do not silently disable if not found; if library is found
but not the header, complain to let user install it or explicitly disable
support)

The feature is also no more disabled by default, as it is something user
would expect from a modern window manager.

Signed-off-by: Christophe CURIS <christophe.cu...@free.fr>
---
 configure.ac        | 46 +++++++++-------------------------------
 m4/wm_xext_check.m4 | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 71 insertions(+), 36 deletions(-)

diff --git a/configure.ac b/configure.ac
index 99df9c6..e5fad66 100644
--- a/configure.ac
+++ b/configure.ac
@@ -499,6 +499,16 @@ AC_ARG_ENABLE([shape],
     [enable_shape=auto])
 WM_XEXT_CHECK_XSHAPE
 
+dnl XINERAMA support
+dnl ================
+AC_ARG_ENABLE([xinerama],
+    [AS_HELP_STRING([--enable-xinerama], [enable Xinerama extension support])],
+    [AS_CASE(["$enableval"],
+        [yes|no], [],
+        [AC_MSG_ERROR([bad value $enableval for --enable-xinerama]) ]) ],
+    [enable_xinerama=auto])
+WM_XEXT_CHECK_XINERAMA
+
 dnl XRandR support
 dnl ==============
 xrandr=no
@@ -583,41 +593,6 @@ AC_SUBST(XFTFLAGS)
 AC_SUBST(XFTLIBS)
 
 
-dnl XINERAMA support
-dnl ================
-xinerama=no
-AC_ARG_ENABLE(xinerama, AS_HELP_STRING([--enable-xinerama], [enable Xinerama 
extension support]),
-               xinerama=$enableval, xinerama=no)
-
-LIBXINERAMA=
-if test "$xinerama" = yes; then
-       AC_CHECK_LIB(Xinerama, XineramaQueryScreens, 
-                [LIBXINERAMA=-lXinerama
-                xfxine=yes],
-               xfxine=no, $XLFLAGS $XLIBS)
-
-       AC_CHECK_LIB(Xext, XineramaGetInfo,
-                [sunxine=yes
-                ], sunxine=no, $XLFLAGS $XLIBS)
-
-       if test "$xfxine" = yes; then
-               xine=1
-       fi
-
-       if test "$sunxine" = yes; then
-           xine=1
-           AC_DEFINE(SOLARIS_XINERAMA, 1, 
-               [define if you want support for the XINERAMA extension and are 
in Solaris (set by configure)])
-       fi
-
-       if test "$xine" = 1; then
-           AC_DEFINE(USE_XINERAMA, 1,
-               [define if you want support for the XINERAMA extension (set by 
configure)])
-       fi
-fi
-AC_SUBST(LIBXINERAMA)
-
-
 dnl MIT-SHM support
 dnl ===============
 shm=yes
@@ -855,7 +830,6 @@ echo "Supported X extensions:             :$supported_xext"
 echo "Supported graphic format libraries  :$supported_gfx"
 echo "Unsupported features                :$unsupported"
 echo "Antialiased text support in WINGs   : $xft"
-echo "Xinerama extension support          : $xinerama"
 echo "XRandR extension support            : $xrandr"
 echo "Translated message files to install : $mof"
 dnl echo "Supported languages beside English  : $languages"
diff --git a/m4/wm_xext_check.m4 b/m4/wm_xext_check.m4
index e535574..8ba1f79 100644
--- a/m4/wm_xext_check.m4
+++ b/m4/wm_xext_check.m4
@@ -37,3 +37,64 @@ AC_DEFUN_ONCE([WM_XEXT_CHECK_XSHAPE],
      CFLAGS="$wm_save_CFLAGS"],
     [supported_xext], [XLIBS], [enable_shape], [-])dnl
 ]) dnl AC_DEFUN
+
+
+# WM_XEXT_CHECK_XINERAMA
+# ----------------------
+#
+# Check for the Xinerama extension for multiscreen-as-one support
+# The check depends on variable 'enable_xinerama' being either:
+#   yes  - detect, fail if not found
+#   no   - do not detect, disable support
+#   auto - detect, disable if not found
+#
+# When found, append appropriate stuff in LIBXINERAMA, and append info to
+# the variable 'supported_xext'
+# When not found, append info to variable 'unsupported'
+AC_DEFUN_ONCE([WM_XEXT_CHECK_XINERAMA],
+[LIBXINERAMA=""
+AS_IF([test "x$enable_xinerama" = "xno"],
+    [unsupported="$unsupported Xinerama"],
+    [AC_CACHE_CHECK([for Xinerama support library], [wm_cv_xext_xinerama],
+        [wm_cv_xext_xinerama=no
+         dnl
+         dnl We check that the library is available
+         wm_save_LIBS="$LIBS"
+         for wm_arg in dnl
+dnl           Lib flag   % Function name        % info
+             "-lXinerama % XineramaQueryScreens" dnl
+             "-lXext     % XineramaGetInfo      % solaris" ; do
+           AS_IF([wm_fn_lib_try_link "`echo "$wm_arg" | dnl
+sed -e 's,^[[^%]]*% *,,' | sed -e 's, *%.*$,,' `" dnl
+"$XLFLAGS $XLIBS `echo "$wm_arg" | sed -e 's, *%.*$,,' `"],
+             [wm_cv_xext_xinerama="`echo "$wm_arg" | sed -e 's, *%[[^%]]*, ,' 
`"
+              break])
+         done
+         LIBS="$wm_save_LIBS"
+         AS_IF([test "x$enable_xinerama$wm_cv_xext_xinerama" = "xyesno"],
+            [AC_MSG_ERROR([explicit Xinerama support requested but no library 
found])])
+         dnl
+         dnl A library was found, check if header is available and compile
+         wm_save_CFLAGS="$CFLAGS"
+         AS_CASE([`echo "$wm_cv_xext_xinerama" | sed -e 's,^[[^%]]*,,' `],
+             [*solaris*], [wm_header="X11/extensions/xinerama.h" ; 
wm_fct="XineramaGetInfo(NULL, 0, NULL, NULL, &intval)"],
+             [wm_header="X11/extensions/Xinerama.h" ; 
wm_fct="XineramaQueryScreens(NULL, &intval)"])
+         AS_IF([wm_fn_lib_try_compile "$wm_header" "int intval;" "$wm_fct" ""],
+             [],
+             [AC_MSG_ERROR([found $wm_cv_xext_xinerama but cannot compile with 
the header])])
+         AS_UNSET([wm_header])
+         AS_UNSET([wm_fct])
+         CFLAGS="$wm_save_CFLAGS"])
+     AS_IF([test "x$wm_cv_xext_xinerama" = "xno"],
+        [unsupported="$unsupported Xinerama"
+         enable_xinerama="no"],
+        [LIBXINERAMA="`echo "$wm_cv_xext_xinerama" | sed -e 's, *%.*$,,' `"
+         AC_DEFINE([USE_XINERAMA], [1],
+             [defined when usable Xinerama library with header was found])
+         AS_CASE([`echo "$wm_cv_xext_xinerama" | sed -e 's,^[[^%]]*,,' `],
+             [*solaris*], [AC_DEFINE([SOLARIS_XINERAMA], [1],
+                 [defined when the Solaris Xinerama extension was detected])])
+         supported_xext="$supported_xext Xinerama"])
+    ])
+AC_SUBST(LIBXINERAMA)dnl
+])
-- 
1.8.4.rc3


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.

Reply via email to