From 229251afd85b3fa1bd5c923c7f72262f8c092c3b Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Fri, 12 Mar 2010 22:59:56 +0000
Subject: [PATCH] Add minimal support for QNX to configure.

Recognize QNX and define __QNX__ under it.

Don't use -lpthreads as the thread functions are in libc under QNX.

Use wxX11 by default.

See #11790.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63664 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 configure                          | 22 ++++++++++++++++++++-
 configure.in                       | 31 ++++++++++++++++++++++++++----
 docs/doxygen/mainpages/const_cpp.h |  1 +
 setup.h.in                         |  1 +
 4 files changed, 50 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index 5c972b531b..ee0c8da219 100755
--- a/configure
+++ b/configure
@@ -2698,6 +2698,14 @@ _ACEOF
 
     DEFAULT_DEFAULT_wxUSE_MOTIF=1
   ;;
+  *-*-qnx*)
+    USE_QNX=1
+    cat >>confdefs.h <<\_ACEOF
+#define __QNX__ 1
+_ACEOF
+
+    DEFAULT_DEFAULT_wxUSE_X11=1
+  ;;
   *-*-solaris2* )
     USE_SUN=1
     USE_SOLARIS=1
@@ -39480,6 +39488,10 @@ echo "$as_me: WARNING: BeOS threads are not yet supported... disabled" >&2;}
                 fi
                 ;;
 
+          *-*-qnx*)
+                                                THREAD_OPTS=""
+                ;;
+
           *-*-*UnixWare*)
                                 if test "x$GCC" != "xyes"; then
                     THREAD_OPTS="-Ethread"
@@ -39487,7 +39499,15 @@ echo "$as_me: WARNING: BeOS threads are not yet supported... disabled" >&2;}
                 ;;
         esac
 
-                                THREAD_OPTS="$THREAD_OPTS pthread none"
+        case "${host}" in
+            *-*-qnx*)
+                                                                THREAD_OPTS="none pthread"
+                ;;
+
+            *)
+                                                                                THREAD_OPTS="$THREAD_OPTS pthread none"
+                ;;
+        esac
 
                 THREADS_OK=no
         for flag in $THREAD_OPTS; do
diff --git a/configure.in b/configure.in
index 58f3c1bc74..ae00631622 100644
--- a/configure.in
+++ b/configure.in
@@ -184,6 +184,11 @@ case "${host}" in
     AC_DEFINE(__SVR4__)
     DEFAULT_DEFAULT_wxUSE_MOTIF=1
   ;;
+  *-*-qnx*)
+    USE_QNX=1
+    AC_DEFINE(__QNX__)
+    DEFAULT_DEFAULT_wxUSE_X11=1
+  ;;
   *-*-solaris2* )
     USE_SUN=1
     USE_SOLARIS=1
@@ -4921,6 +4926,12 @@ if test "$TOOLKIT" != "MSW" -a "$USE_OS2" != 1; then
                 fi
                 ;;
 
+          *-*-qnx*)
+                dnl under QNX thread functions are in libc so we don't need any
+                dnl special options to link with them
+                THREAD_OPTS=""
+                ;;
+
           *-*-*UnixWare*)
                 dnl flying by man pages here: Caldera online docs use this
                 if test "x$GCC" != "xyes"; then
@@ -4929,10 +4940,22 @@ if test "$TOOLKIT" != "MSW" -a "$USE_OS2" != 1; then
                 ;;
         esac
 
-        dnl simply linking with libpthread should make the test below work but
-        dnl it's far from certain that the threaded programs compiled without
-        dnl any special switches actually work, so try it after all the others
-        THREAD_OPTS="$THREAD_OPTS pthread none"
+        case "${host}" in
+            *-*-qnx*)
+                dnl -lpthread works, i.e. AC_TRY_LINK() would pass, but results
+                dnl in warnings and is not needed under QNX so try without it
+                dnl first
+                THREAD_OPTS="none pthread"
+                ;;
+
+            *)
+                dnl simply linking with libpthread should make the test below
+                dnl work but it's far from certain that the threaded programs
+                dnl compiled without any special switches actually work, so try
+                dnl it after all the others
+                THREAD_OPTS="$THREAD_OPTS pthread none"
+                ;;
+        esac
 
         dnl now test for all possibilities
         THREADS_OK=no
diff --git a/docs/doxygen/mainpages/const_cpp.h b/docs/doxygen/mainpages/const_cpp.h
index c5c8ecbfc2..898de55e15 100644
--- a/docs/doxygen/mainpages/const_cpp.h
+++ b/docs/doxygen/mainpages/const_cpp.h
@@ -103,6 +103,7 @@ symbols, although this has not always been followed.
 @itemdef{__LINUX__, Linux}
 @itemdef{__MACH__, Mach-O Architecture (Mac OS X only builds)}
 @itemdef{__OSF__, OSF/1}
+@itemdef{__QNX__, QNX Neutrino RTOS}
 @itemdef{__PALMOS__, PalmOS}
 @itemdef{__SGI__, IRIX}
 @itemdef{__SOLARIS__, Solaris}
diff --git a/setup.h.in b/setup.h.in
index 40a2cb30e2..74d7911cf9 100644
--- a/setup.h.in
+++ b/setup.h.in
@@ -97,6 +97,7 @@
 #undef __NETBSD__
 #undef __OPENBSD__
 #undef __OSF__
+#undef __QNX__
 #undef __SGI__
 #undef __SOLARIS__
 #undef __SUN__
-- 
2.45.2