From b652130dc00dfab7322751275e42f59943c7e8e3 Mon Sep 17 00:00:00 2001
From: Tom Cooksey <thomas.cooksey@nokia.com>
Date: Wed, 1 Apr 2009 11:07:16 +0200
Subject: Add config test for XLib

Previously, it was entirely possible to successfully configure Qt/X11
without any X11 installed. The problems would only start showing up once
you stated building. This is not very useful if you're cross-compiling
and trying to setup the paths correctly.

Reviewed-by: Denis
---
 config.tests/x11/xlib/xlib.cpp | 9 +++++++++
 config.tests/x11/xlib/xlib.pro | 3 +++
 configure                      | 8 ++++++++
 3 files changed, 20 insertions(+)
 create mode 100644 config.tests/x11/xlib/xlib.cpp
 create mode 100644 config.tests/x11/xlib/xlib.pro

diff --git a/config.tests/x11/xlib/xlib.cpp b/config.tests/x11/xlib/xlib.cpp
new file mode 100644
index 0000000..8d25bf5
--- /dev/null
+++ b/config.tests/x11/xlib/xlib.cpp
@@ -0,0 +1,9 @@
+#include <X11/Xlib.h>
+
+int main(int, char **)
+{
+    Display *d = XOpenDisplay(NULL);
+    XCloseDisplay(d);
+    return 0;
+}
+
diff --git a/config.tests/x11/xlib/xlib.pro b/config.tests/x11/xlib/xlib.pro
new file mode 100644
index 0000000..658161e
--- /dev/null
+++ b/config.tests/x11/xlib/xlib.pro
@@ -0,0 +1,3 @@
+CONFIG += x11
+CONFIG -= qt
+SOURCES = xlib.cpp
diff --git a/configure b/configure
index f79b1e2..7e66a98 100755
--- a/configure
+++ b/configure
@@ -4727,6 +4727,14 @@ if [ "$PLATFORM_X11" = "yes" ]; then
         X11TESTS_FLAGS="$X11TESTS_FLAGS -fpermissive"
     fi
 
+    # Check we actually have X11 :-)
+    if ! "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/xlib "XLib" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS; then
+        echo "Basic XLib functionality test failed!"
+        echo " You might need to modify the include and library search paths by editing"
+        echo " QMAKE_INCDIR_X11 and QMAKE_LIBDIR_X11 in ${XQMAKESPEC}."
+        exit 1
+    fi
+
     # auto-detect OpenGL support (es1 = OpenGL ES 1.x Common, es1cl = ES 1.x common lite, es2 = OpenGL ES 2.x)
     if [ "$CFG_OPENGL" = "auto" ] || [ "$CFG_OPENGL" = "yes" ]; then
         if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/opengl "OpenGL" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS; then
-- 
cgit v0.12