From 075e96eba50013c583234b787562e09bb7535dd8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= <morten.sorvig@nokia.com>
Date: Thu, 29 Apr 2010 14:47:35 +0200
Subject: Say hello to Qt for Native Client.

This commits adds build system to support for the native
client compiler (x86-only for now), sets up global defines,
and adds compile fixes for QtCore and QtGui.

Details:

* Add mkspecs for linux-nacl-g++ and macx-nacl-c++
* Add nacl configure option
* Add qconfig-minimal-system-dependencies.h
* Define Q_OS_NACL in qglobal.h
* Add qnacalunimplemented.h/cpp with POSIX stubs.
* .pro file changes for cross-compiling on Mac
---
 configure                                          |  77 ++++-
 mkspecs/qws/linux-nacl-g++/qmake.conf              |  74 ++++
 mkspecs/qws/linux-nacl-g++/qplatformdefs.h         | 175 ++++++++++
 mkspecs/qws/macx-generic-g++/qmake.conf            |   6 +-
 mkspecs/qws/macx-nacl-g++/qmake.conf               |  95 ++++++
 mkspecs/qws/macx-nacl-g++/qplatformdefs.h          | 175 ++++++++++
 src/corelib/arch/qatomic_arch.h                    |   2 +
 src/corelib/corelib.pro                            |   2 +-
 src/corelib/global/global.pri                      |   4 +
 .../global/qconfig-minimal-system-dependencies.h   | 371 +++++++++++++++++++++
 src/corelib/global/qglobal.h                       |   6 +
 src/corelib/global/qnaclunimplemented.cpp          | 156 +++++++++
 src/corelib/global/qnaclunimplemented.h            |  85 +++++
 src/corelib/io/io.pri                              |  10 +-
 src/corelib/io/qresource.cpp                       |   2 +-
 src/corelib/kernel/kernel.pri                      |   4 +-
 src/corelib/kernel/qcore_unix.cpp                  |   3 +-
 src/corelib/kernel/qeventdispatcher_unix.cpp       |  14 +-
 src/corelib/kernel/qeventdispatcher_unix_p.h       |   2 +-
 src/corelib/thread/qthread_unix.cpp                |   2 +
 src/corelib/tools/tools.pri                        |   2 +-
 src/gui/kernel/mac.pri                             |   2 +-
 .../kernel/qplatformintegrationfactory_lite.cpp    |   2 +-
 src/gui/text/qfontdatabase_qws.cpp                 |   2 +
 src/src.pro                                        |   2 +
 25 files changed, 1254 insertions(+), 21 deletions(-)
 create mode 100644 mkspecs/qws/linux-nacl-g++/qmake.conf
 create mode 100644 mkspecs/qws/linux-nacl-g++/qplatformdefs.h
 create mode 100644 mkspecs/qws/macx-nacl-g++/qmake.conf
 create mode 100644 mkspecs/qws/macx-nacl-g++/qplatformdefs.h
 create mode 100644 src/corelib/global/qconfig-minimal-system-dependencies.h
 create mode 100644 src/corelib/global/qnaclunimplemented.cpp
 create mode 100644 src/corelib/global/qnaclunimplemented.h

diff --git a/configure b/configure
index 69df540..da34fb5 100755
--- a/configure
+++ b/configure
@@ -296,6 +296,12 @@ earlyArgParse()
                 VAL=$1
             fi
             ;;
+        -nacl)
+            shift;
+            VAR=nacl
+            VAL=$1
+            ;;
+
         -h|help|--help|-help)
             if [ "$VAL" = "yes" ]; then
                 OPT_HELP="$VAL"
@@ -353,6 +359,15 @@ earlyArgParse()
                 CFG_EMBEDDED=no
             fi
             ;;
+        nacl)
+            echo "Using NaCl at $VAL."
+            PLATFORM_X11=no
+            PLATFORM_MAC=no
+            PLATFORM_QWS=no
+            CFG_NACL_PATH=$VAL
+            CFG_EMBEDDED=nacl
+            ;;
+
         developer-build)
             CFG_DEV="yes"
             ;;
@@ -928,6 +943,44 @@ if [ -d "$relpath/src/plugins/gfxdrivers" ]; then
 fi
 
 #-------------------------------------------------------------------------------
+# Set Default NaCl options
+#-------------------------------------------------------------------------------
+if [ "$CFG_EMBEDDED" = "nacl" ]; then
+    echo "Setting NaCl options:"
+    echo "-static"
+    CFG_SHARED=no
+    echo "-embedded-lite nacl"
+    PLATFORM_EMBLITE=yes
+    echo "-fast"
+    OPT_FAST=yes
+    echo "-release"
+    CFG_DEBUG=no
+    echo "-qconfig minimal-system-dependencies"
+    CFG_QCONFIG=minimal-system-dependencies
+
+    if [ `uname` = "Linux" ]; then
+        I_FLAGS="$I_FLAGS -I${CFG_NACL_PATH}/toolchain/linux_x86/sdk/nacl-sdk/include"
+        L_FLAGS="$L_FLAGS -I${CFG_NACL_PATH}/toolchain/linux_x86/sdk/nacl-sdk/lib"
+    else
+        I_FLAGS="$I_FLAGS -I${CFG_NACL_PATH}/toolchain/mac_x86/sdk/nacl-sdk/include"
+        L_FLAGS="$L_FLAGS -I${CFG_NACL_PATH}/toolchain/mac_x86/sdk/nacl-sdk/lib"
+    fi
+
+    echo "-no-multimedia -no-webkit -no-phonon -no-nultimedia -no-mediaservices -no-xmlpatterns -no-script -no-sql-sqlite -nomake tests"
+    CFG_MULTIMEDIA=no
+    CFG_WEBKIT=no
+    CFG_PHONON=no
+    CFG_MULTIMEDIA=no
+    CFG_MEDIASERVICES=no
+    CFG_XMLPATTERNS=no
+    CFG_SCRIPT=no
+    CFG_SQLITE=no
+    CFG_SQL_sqlite=no
+    CFG_NOBUILD_PARTS="$CFG_NOBUILD_PARTS tests"
+    QT_CONFIG="$QT_CONFIG nacl"
+fi
+
+#-------------------------------------------------------------------------------
 # parse command line arguments
 #-------------------------------------------------------------------------------
 
@@ -1024,6 +1077,10 @@ while [ "$#" -gt 0 ]; do
             VAL=$1
         fi
 	;;
+    -nacl)
+        VAR=nacl
+        shift;
+    ;;
     -opengl)
         VAR=opengl
         # this option may or may not be followed by an argument
@@ -1262,6 +1319,8 @@ while [ "$#" -gt 0 ]; do
             CFG_EMBEDDED=no
         fi
         ;;
+    nacl)
+        ;;
     sse)
         if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
             CFG_SSE="$VAL"
@@ -3114,6 +3173,10 @@ if [ -z "$TEST_COMPILER" ]; then
     exit 1
 fi
 
+if [ "$CFG_EMBEDDED" = "nacl" ]; then
+    TEST_COMPILER="nacl-gcc"
+fi
+
 # auto-detect precompiled header support
 if [ "$CFG_PRECOMPILE" = "auto" ]; then
     if [ `echo "$CFG_MAC_ARCHS" | wc -w` -gt 1 ]; then
@@ -6599,6 +6662,13 @@ if [ "$PLATFORM_EMBLITE" = "yes" ]; then
     QT_CONFIG="$QT_CONFIG embedded_lite"
     rm -f "src/.moc/$QMAKE_OUTDIR/allmoc.cpp" # needs remaking if config changes
 fi
+
+if [ "$CFG_EMBEDDED" = "nacl" ]; then
+    QMAKE_CONFIG="$QMAKE_CONFIG nacl pepper"
+    QT_CONFIG="$QT_CONFIG nacl pepper"
+    rm -f "src/.moc/$QMAKE_OUTDIR/allmoc.cpp" # needs remaking if config changes
+fi
+
 QMakeVar set PRECOMPILED_DIR ".pch/$QMAKE_OUTDIR"
 QMakeVar set OBJECTS_DIR ".obj/$QMAKE_OUTDIR"
 QMakeVar set MOC_DIR ".moc/$QMAKE_OUTDIR"
@@ -7802,10 +7872,11 @@ QMAKE_LIBDIR_QT  = \$\$QT_BUILD_TREE/lib
 EOF
 
 # Ensure we can link to uninistalled libraries
-if linkerSupportsFlag -rpath-link "$outpath/lib"; then
-    echo "QMAKE_LFLAGS    += -Wl,-rpath-link,\$\$QT_BUILD_TREE/lib" >> "$CACHEFILE.tmp"
+if [ "$CFG_EMBEDDED" != "nacl" ]; then
+    if linkerSupportsFlag -rpath-link "$outpath/lib"; then
+        echo "QMAKE_LFLAGS    += -Wl,-rpath-link,\$\$QT_BUILD_TREE/lib" >> "$CACHEFILE.tmp"
+    fi
 fi
-
 if [ -n "$QT_CFLAGS_PSQL" ]; then
     echo "QT_CFLAGS_PSQL   = $QT_CFLAGS_PSQL" >> "$CACHEFILE.tmp"
 fi
diff --git a/mkspecs/qws/linux-nacl-g++/qmake.conf b/mkspecs/qws/linux-nacl-g++/qmake.conf
new file mode 100644
index 0000000..83ce65b
--- /dev/null
+++ b/mkspecs/qws/linux-nacl-g++/qmake.conf
@@ -0,0 +1,74 @@
+#
+# qmake configuration for building with nacl-g++
+#
+
+include(../../common/unix.conf)
+include(../../common/qws.conf)
+
+QT                      = core gui
+
+# copy of ../../common/g++.conf, with modifications:
+
+QMAKE_CC                = nacl-gcc
+QMAKE_CXX               = nacl-g++
+QMAKE_LINK              = nacl-g++
+QMAKE_LINK_SHLIB        = nacl-g++
+
+#QMAKE_CC		= gcc
+QMAKE_CFLAGS		+= -pipe -DXP_UNIX -DNACL_STANDALONE=1
+QMAKE_CFLAGS_DEPS	+= -M
+QMAKE_CFLAGS_WARN_ON	+= -Wall -W
+QMAKE_CFLAGS_WARN_OFF	+= -w
+QMAKE_CFLAGS_RELEASE	+= -O2
+QMAKE_CFLAGS_DEBUG	+= -g
+QMAKE_CFLAGS_SHLIB	+= -fPIC
+#QMAKE_CFLAGS_STATIC_LIB	+= -fPIC
+QMAKE_CFLAGS_YACC	+= -Wno-unused -Wno-parentheses
+QMAKE_CFLAGS_HIDESYMS   += -fvisibility=hidden
+QMAKE_CFLAGS_PRECOMPILE += -x c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}
+QMAKE_CFLAGS_USE_PRECOMPILE += -include ${QMAKE_PCH_OUTPUT_BASE}
+
+#QMAKE_CXX		= g++
+QMAKE_CXXFLAGS		+= $$QMAKE_CFLAGS
+QMAKE_CXXFLAGS_DEPS	+= $$QMAKE_CFLAGS_DEPS
+QMAKE_CXXFLAGS_WARN_ON	+= $$QMAKE_CFLAGS_WARN_ON
+QMAKE_CXXFLAGS_WARN_OFF	+= $$QMAKE_CFLAGS_WARN_OFF
+QMAKE_CXXFLAGS_RELEASE	+= $$QMAKE_CFLAGS_RELEASE
+QMAKE_CXXFLAGS_DEBUG	+= $$QMAKE_CFLAGS_DEBUG
+QMAKE_CXXFLAGS_SHLIB	+= $$QMAKE_CFLAGS_SHLIB
+QMAKE_CXXFLAGS_STATIC_LIB += $$QMAKE_CFLAGS_STATIC_LIB
+QMAKE_CXXFLAGS_YACC	+= $$QMAKE_CFLAGS_YACC
+QMAKE_CXXFLAGS_HIDESYMS += $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden
+QMAKE_CXXFLAGS_PRECOMPILE += -x c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}
+QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
+
+#QMAKE_LINK		= g++
+#QMAKE_LINK_SHLIB	= g++
+QMAKE_LINK_C		= gcc
+QMAKE_LINK_C_SHLIB	= gcc
+QMAKE_LFLAGS		+=
+QMAKE_LFLAGS_RELEASE	+= -Wl,-O1
+QMAKE_LFLAGS_DEBUG	+=
+QMAKE_LFLAGS_APP	+=
+QMAKE_LFLAGS_SHLIB	+= -shared
+QMAKE_LFLAGS_PLUGIN	+= $$QMAKE_LFLAGS_SHLIB
+QMAKE_LFLAGS_SONAME	+= -Wl,-soname,
+QMAKE_LFLAGS_THREAD	+=
+QMAKE_LFLAGS_NOUNDEF	+= -Wl,--no-undefined
+QMAKE_LFLAGS_RPATH	= -Wl,-rpath,
+
+QMAKE_LIBS = -lgoogle_nacl_imc -lgoogle_nacl_npruntime -lgoogle_nacl_pgl -lgoogle_nacl_gpu -lpthread -lsrpc
+
+QMAKE_PCH_OUTPUT_EXT    = .gch
+
+# -Bsymbolic-functions (ld) support
+QMAKE_LFLAGS_BSYMBOLIC_FUNC = -Wl,-Bsymbolic-functions
+QMAKE_LFLAGS_DYNAMIC_LIST = -Wl,--dynamic-list,
+
+# modifications to linux.conf
+QMAKE_AR                = nacl-ar q
+QMAKE_OBJCOPY           = nacl-objcopy
+QMAKE_STRIP             = nacl-strip
+QMAKE_LIBS_DYNLOAD	=
+
+load(qt_config)
diff --git a/mkspecs/qws/linux-nacl-g++/qplatformdefs.h b/mkspecs/qws/linux-nacl-g++/qplatformdefs.h
new file mode 100644
index 0000000..a670ee5
--- /dev/null
+++ b/mkspecs/qws/linux-nacl-g++/qplatformdefs.h
@@ -0,0 +1,175 @@
+/****************************************************************************
+ **
+ ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ ** All rights reserved.
+ ** Contact: Nokia Corporation (qt-info@nokia.com)
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+ **
+ ** $QT_BEGIN_LICENSE:LGPL$
+ ** No Commercial Usage
+ ** This file contains pre-release code and may not be distributed.
+ ** You may use this file in accordance with the terms and conditions
+ ** contained in the Technology Preview License Agreement accompanying
+ ** this package.
+ **
+ ** GNU Lesser General Public License Usage
+ ** Alternatively, this file may be used under the terms of the GNU Lesser
+ ** General Public License version 2.1 as published by the Free Software
+ ** Foundation and appearing in the file LICENSE.LGPL included in the
+ ** packaging of this file.  Please review the following information to
+ ** ensure the GNU Lesser General Public License version 2.1 requirements
+ ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+ **
+ ** In addition, as a special exception, Nokia gives you certain additional
+ ** rights.  These rights are described in the Nokia Qt LGPL Exception
+ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+ **
+ ** If you have questions regarding the use of this file, please contact
+ ** Nokia at qt-info@nokia.com.
+ **
+ **
+ **
+ **
+ **
+ **
+ **
+ **
+ ** $QT_END_LICENSE$
+ **
+ ****************************************************************************/
+
+#ifndef QPLATFORMDEFS_H
+#define QPLATFORMDEFS_H
+
+// Get Qt defines/settings
+
+#define _POSIX_TIMERS
+
+#include "qglobal.h"
+
+
+#define _POSIX_TIMERS
+// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs
+
+// 1) need to reset default environment if _BSD_SOURCE is defined
+// 2) need to specify POSIX thread interfaces explicitly in glibc 2.0
+// 3) it seems older glibc need this to include the X/Open stuff
+#ifndef _GNU_SOURCE
+#  define _GNU_SOURCE
+#endif
+
+#include <unistd.h>
+
+
+// We are hot - unistd.h should have turned on the specific APIs we requested
+
+#include <sys/features.h>
+#include <pthread.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <grp.h>
+#include <pwd.h>
+#include <signal.h>
+//#include <dlfcn.h>
+
+#include <sys/types.h>
+//#include <sys/ioctl.h>
+//#include <sys/ipc.h>
+
+#include <sys/time.h>
+//#include <sys/shm.h>
+//#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+//#include <netinet/in.h>
+#ifndef QT_NO_IPV6IFNAME
+#include <net/if.h>
+#endif
+
+// extra disabling.
+#ifdef __native_client__ 
+#define QT_NO_FSFILEENGINE
+#define QT_NO_TRANSLATION
+#endif
+
+#ifdef QT_LARGEFILE_SUPPORT
+#define QT_STATBUF              struct stat64
+#define QT_STATBUF4TSTAT        struct stat64
+#define QT_STAT                 ::stat64
+#define QT_FSTAT                ::fstat64
+#define QT_LSTAT                ::lstat64
+#define QT_OPEN                 ::open64
+#define QT_TRUNCATE             ::truncate64
+#define QT_FTRUNCATE            ::ftruncate64
+#define QT_LSEEK                ::lseek64
+#else
+#define QT_STATBUF              struct stat
+#define QT_STATBUF4TSTAT        struct stat
+#define QT_STAT                 ::stat
+#define QT_FSTAT                ::fstat
+#define QT_LSTAT                ::lstat
+#define QT_OPEN                 ::open
+#define QT_TRUNCATE             ::truncate
+#define QT_FTRUNCATE            ::ftruncate
+#define QT_LSEEK                ::lseek
+#endif
+
+#ifdef QT_LARGEFILE_SUPPORT
+#define QT_FOPEN                ::fopen64
+#define QT_FSEEK                ::fseeko64
+#define QT_FTELL                ::ftello64
+#define QT_FGETPOS              ::fgetpos64
+#define QT_FSETPOS              ::fsetpos64
+#define QT_FPOS_T               fpos64_t
+#define QT_OFF_T                off64_t
+#else
+#define QT_FOPEN                ::fopen
+#define QT_FSEEK                ::fseek
+#define QT_FTELL                ::ftell
+#define QT_FGETPOS              ::fgetpos
+#define QT_FSETPOS              ::fsetpos
+#define QT_FPOS_T               fpos_t
+#define QT_OFF_T                long
+#endif
+
+#define QT_STAT_REG		S_IFREG
+#define QT_STAT_DIR		S_IFDIR
+#define QT_STAT_MASK		S_IFMT
+#define QT_STAT_LNK		S_IFLNK
+#define QT_SOCKET_CONNECT	::connect
+#define QT_SOCKET_BIND		::bind
+#define QT_FILENO		fileno
+#define QT_CLOSE		::close
+#define QT_READ			::read
+#define QT_WRITE		::write
+#define QT_ACCESS		::access
+#define QT_GETCWD		::getcwd
+#define QT_CHDIR		::chdir
+#define QT_MKDIR		::mkdir
+#define QT_RMDIR		::rmdir
+#define QT_OPEN_LARGEFILE       O_LARGEFILE
+#define QT_OPEN_RDONLY		O_RDONLY
+#define QT_OPEN_WRONLY		O_WRONLY
+#define QT_OPEN_RDWR		O_RDWR
+#define QT_OPEN_CREAT		O_CREAT
+#define QT_OPEN_TRUNC		O_TRUNC
+#define QT_OPEN_APPEND		O_APPEND
+
+#define QT_SIGNAL_RETTYPE	void
+#define QT_SIGNAL_ARGS		int
+#define QT_SIGNAL_IGNORE	SIG_IGN
+
+#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+#define QT_SOCKLEN_T		socklen_t
+#else
+#define QT_SOCKLEN_T		int
+#endif
+
+#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+#define QT_SNPRINTF		::snprintf
+#define QT_VSNPRINTF		::vsnprintf
+#endif
+
+
+#endif // QPLATFORMDEFS_H
diff --git a/mkspecs/qws/macx-generic-g++/qmake.conf b/mkspecs/qws/macx-generic-g++/qmake.conf
index 9096712..63bfc57 100644
--- a/mkspecs/qws/macx-generic-g++/qmake.conf
+++ b/mkspecs/qws/macx-generic-g++/qmake.conf
@@ -2,6 +2,8 @@
 # qmake configuration for macx-g++ with Qtopia Core
 #
 
+include(../../common/unix.conf)
+
 MAKEFILE_GENERATOR	= UNIX
 TARGET_PLATFORM		= macx
 TEMPLATE		= app
@@ -18,7 +20,7 @@ QMAKE_YACCFLAGS		= -d
 QMAKE_CFLAGS		= -pipe
 QMAKE_CFLAGS_WARN_ON	= -Wall -W
 QMAKE_CFLAGS_WARN_OFF	=
-QMAKE_CFLAGS_RELEASE	= -O2 -fno-default-inline
+QMAKE_CFLAGS_RELEASE	= -O2
 QMAKE_CFLAGS_DEBUG	= -g
 QMAKE_CFLAGS_SHLIB	= -fPIC
 QMAKE_CFLAGS_YACC	= -Wno-unused -Wno-parentheses
@@ -29,7 +31,7 @@ QMAKE_CXX		= $(TB)c++
 QMAKE_CXXFLAGS		= $$QMAKE_CFLAGS -DQT_NO_QWS_TRANSFORMED
 QMAKE_CXXFLAGS_WARN_ON	= $$QMAKE_CFLAGS_WARN_ON
 QMAKE_CXXFLAGS_WARN_OFF	= $$QMAKE_CFLAGS_WARN_OFF
-QMAKE_CXXFLAGS_RELEASE	= $$QMAKE_CFLAGS_RELEASE
+QMAKE_CXXFLAGS_RELEASE	= $$QMAKE_CFLAGS_RELEASE -fno-default-inline
 QMAKE_CXXFLAGS_DEBUG	= $$QMAKE_CFLAGS_DEBUG
 QMAKE_CXXFLAGS_SHLIB	= $$QMAKE_CFLAGS_SHLIB
 QMAKE_CXXFLAGS_YACC	= $$QMAKE_CFLAGS_YACC
diff --git a/mkspecs/qws/macx-nacl-g++/qmake.conf b/mkspecs/qws/macx-nacl-g++/qmake.conf
new file mode 100644
index 0000000..0a54b4b
--- /dev/null
+++ b/mkspecs/qws/macx-nacl-g++/qmake.conf
@@ -0,0 +1,95 @@
+#
+# qmake configuration for macx-nacl-g++ with embedded-lite
+#
+
+include(../../common/unix.conf)
+
+MAKEFILE_GENERATOR	= UNIX
+TEMPLATE		= app
+CONFIG			+= qt warn_on release link_prl
+QT                      += core gui
+QMAKE_INCREMENTAL_STYLE = sublib
+QMAKE_EXTENSION_SHLIB	= dylib
+
+
+QMAKE_CC                = nacl-gcc
+QMAKE_CXX               = nacl-g++
+QMAKE_LINK              = nacl-g++
+QMAKE_LINK_SHLIB        = nacl-g++
+
+#QMAKE_CC		= $(TB)cc
+QMAKE_LEX		= flex
+QMAKE_LEXFLAGS		=
+QMAKE_YACC		= yacc
+QMAKE_YACCFLAGS		= -d
+QMAKE_CFLAGS		= -pipe -DXP_UNIX -DNACL_STANDALONE=1
+QMAKE_CFLAGS_WARN_ON	= -Wall -W
+QMAKE_CFLAGS_WARN_OFF	=
+QMAKE_CFLAGS_RELEASE	= -O2
+QMAKE_CFLAGS_DEBUG	= -g
+QMAKE_CFLAGS_SHLIB	= -fPIC
+QMAKE_CFLAGS_YACC	= -Wno-unused -Wno-parentheses
+QMAKE_CFLAGS_THREAD	= -D_REENTRANT
+QMAKE_CFLAGS_HIDESYMS   = -fvisibility=hidden
+
+#QMAKE_CXX		= $(TB)c++
+QMAKE_CXXFLAGS		= $$QMAKE_CFLAGS -DQT_NO_QWS_TRANSFORMED
+QMAKE_CXXFLAGS_WARN_ON	= $$QMAKE_CFLAGS_WARN_ON
+QMAKE_CXXFLAGS_WARN_OFF	= $$QMAKE_CFLAGS_WARN_OFF
+QMAKE_CXXFLAGS_RELEASE	= $$QMAKE_CFLAGS_RELEASE -fno-default-inline
+QMAKE_CXXFLAGS_DEBUG	= $$QMAKE_CFLAGS_DEBUG
+QMAKE_CXXFLAGS_SHLIB	= $$QMAKE_CFLAGS_SHLIB
+QMAKE_CXXFLAGS_YACC	= $$QMAKE_CFLAGS_YACC
+QMAKE_CXXFLAGS_THREAD	= $$QMAKE_CFLAGS_THREAD
+QMAKE_CXXFLAGS_HIDESYMS = $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden
+
+QMAKE_INCDIR		=
+QMAKE_LIBDIR		=
+QMAKE_INCDIR_X11	=
+QMAKE_LIBDIR_X11	=
+QMAKE_INCDIR_QT		= $$[QT_INSTALL_HEADERS]
+QMAKE_LIBDIR_QT		= $$[QT_INSTALL_LIBS]
+QMAKE_INCDIR_OPENGL	= 
+QMAKE_LIBDIR_OPENGL	= 
+QMAKE_INCDIR_QTOPIA	= $(QPEDIR)/include
+QMAKE_LIBDIR_QTOPIA	= $(QPEDIR)/lib
+
+#QMAKE_LINK		= $$QMAKE_CXX
+#QMAKE_LINK_SHLIB	= $$QMAKE_CXX
+QMAKE_LFLAGS		=
+QMAKE_LFLAGS_RELEASE	=
+QMAKE_LFLAGS_DEBUG	=
+QMAKE_LFLAGS_SHLIB	= -dynamiclib 
+QMAKE_LFLAGS_INCREMENTAL = -undefined suppress -flat_namespace
+QMAKE_LFLAGS_PLUGIN	= -bundle
+QMAKE_LFLAGS_SONAME	= 
+QMAKE_LFLAGS_THREAD	=
+
+QMAKE_LIBS		= -lgoogle_nacl_imc -lgoogle_nacl_npruntime -lgoogle_nacl_pgl -lgoogle_nacl_gpu -lpthread -lsrpc 
+QMAKE_LIBS_X11		=
+QMAKE_LIBS_X11SM	=
+QMAKE_LIBS_QT		= -lqte
+QMAKE_LIBS_QT_THREAD	= -lqte-mt
+QMAKE_LIBS_QT_OPENGL	= -lqgl
+QMAKE_LIBS_QTOPIA	= -lqpe -lqtopia
+QMAKE_LIBS_THREAD	= 
+QMAKE_LIBS_OPENGL	=
+
+QMAKE_MOC		= $$[QT_INSTALL_BINS]/moc
+QMAKE_UIC		= $$[QT_INSTALL_BINS]/uic
+
+QMAKE_AR                = nacl-ar q
+QMAKE_OBJCOPY           = nacl-objcopy
+QMAKE_STRIP             = nacl-strip
+QMAKE_RANLIB		=
+
+QMAKE_TAR		= tar -cf
+QMAKE_GZIP		= gzip -9f
+
+QMAKE_COPY		= cp -f
+QMAKE_MOVE		= mv -f
+QMAKE_DEL_FILE		= rm -f
+QMAKE_DEL_DIR		= rmdir
+QMAKE_CHK_DIR_EXISTS	= test -d
+QMAKE_MKDIR		= mkdir -p
+load(qt_config)
diff --git a/mkspecs/qws/macx-nacl-g++/qplatformdefs.h b/mkspecs/qws/macx-nacl-g++/qplatformdefs.h
new file mode 100644
index 0000000..a670ee5
--- /dev/null
+++ b/mkspecs/qws/macx-nacl-g++/qplatformdefs.h
@@ -0,0 +1,175 @@
+/****************************************************************************
+ **
+ ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ ** All rights reserved.
+ ** Contact: Nokia Corporation (qt-info@nokia.com)
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+ **
+ ** $QT_BEGIN_LICENSE:LGPL$
+ ** No Commercial Usage
+ ** This file contains pre-release code and may not be distributed.
+ ** You may use this file in accordance with the terms and conditions
+ ** contained in the Technology Preview License Agreement accompanying
+ ** this package.
+ **
+ ** GNU Lesser General Public License Usage
+ ** Alternatively, this file may be used under the terms of the GNU Lesser
+ ** General Public License version 2.1 as published by the Free Software
+ ** Foundation and appearing in the file LICENSE.LGPL included in the
+ ** packaging of this file.  Please review the following information to
+ ** ensure the GNU Lesser General Public License version 2.1 requirements
+ ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+ **
+ ** In addition, as a special exception, Nokia gives you certain additional
+ ** rights.  These rights are described in the Nokia Qt LGPL Exception
+ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+ **
+ ** If you have questions regarding the use of this file, please contact
+ ** Nokia at qt-info@nokia.com.
+ **
+ **
+ **
+ **
+ **
+ **
+ **
+ **
+ ** $QT_END_LICENSE$
+ **
+ ****************************************************************************/
+
+#ifndef QPLATFORMDEFS_H
+#define QPLATFORMDEFS_H
+
+// Get Qt defines/settings
+
+#define _POSIX_TIMERS
+
+#include "qglobal.h"
+
+
+#define _POSIX_TIMERS
+// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs
+
+// 1) need to reset default environment if _BSD_SOURCE is defined
+// 2) need to specify POSIX thread interfaces explicitly in glibc 2.0
+// 3) it seems older glibc need this to include the X/Open stuff
+#ifndef _GNU_SOURCE
+#  define _GNU_SOURCE
+#endif
+
+#include <unistd.h>
+
+
+// We are hot - unistd.h should have turned on the specific APIs we requested
+
+#include <sys/features.h>
+#include <pthread.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <grp.h>
+#include <pwd.h>
+#include <signal.h>
+//#include <dlfcn.h>
+
+#include <sys/types.h>
+//#include <sys/ioctl.h>
+//#include <sys/ipc.h>
+
+#include <sys/time.h>
+//#include <sys/shm.h>
+//#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+//#include <netinet/in.h>
+#ifndef QT_NO_IPV6IFNAME
+#include <net/if.h>
+#endif
+
+// extra disabling.
+#ifdef __native_client__ 
+#define QT_NO_FSFILEENGINE
+#define QT_NO_TRANSLATION
+#endif
+
+#ifdef QT_LARGEFILE_SUPPORT
+#define QT_STATBUF              struct stat64
+#define QT_STATBUF4TSTAT        struct stat64
+#define QT_STAT                 ::stat64
+#define QT_FSTAT                ::fstat64
+#define QT_LSTAT                ::lstat64
+#define QT_OPEN                 ::open64
+#define QT_TRUNCATE             ::truncate64
+#define QT_FTRUNCATE            ::ftruncate64
+#define QT_LSEEK                ::lseek64
+#else
+#define QT_STATBUF              struct stat
+#define QT_STATBUF4TSTAT        struct stat
+#define QT_STAT                 ::stat
+#define QT_FSTAT                ::fstat
+#define QT_LSTAT                ::lstat
+#define QT_OPEN                 ::open
+#define QT_TRUNCATE             ::truncate
+#define QT_FTRUNCATE            ::ftruncate
+#define QT_LSEEK                ::lseek
+#endif
+
+#ifdef QT_LARGEFILE_SUPPORT
+#define QT_FOPEN                ::fopen64
+#define QT_FSEEK                ::fseeko64
+#define QT_FTELL                ::ftello64
+#define QT_FGETPOS              ::fgetpos64
+#define QT_FSETPOS              ::fsetpos64
+#define QT_FPOS_T               fpos64_t
+#define QT_OFF_T                off64_t
+#else
+#define QT_FOPEN                ::fopen
+#define QT_FSEEK                ::fseek
+#define QT_FTELL                ::ftell
+#define QT_FGETPOS              ::fgetpos
+#define QT_FSETPOS              ::fsetpos
+#define QT_FPOS_T               fpos_t
+#define QT_OFF_T                long
+#endif
+
+#define QT_STAT_REG		S_IFREG
+#define QT_STAT_DIR		S_IFDIR
+#define QT_STAT_MASK		S_IFMT
+#define QT_STAT_LNK		S_IFLNK
+#define QT_SOCKET_CONNECT	::connect
+#define QT_SOCKET_BIND		::bind
+#define QT_FILENO		fileno
+#define QT_CLOSE		::close
+#define QT_READ			::read
+#define QT_WRITE		::write
+#define QT_ACCESS		::access
+#define QT_GETCWD		::getcwd
+#define QT_CHDIR		::chdir
+#define QT_MKDIR		::mkdir
+#define QT_RMDIR		::rmdir
+#define QT_OPEN_LARGEFILE       O_LARGEFILE
+#define QT_OPEN_RDONLY		O_RDONLY
+#define QT_OPEN_WRONLY		O_WRONLY
+#define QT_OPEN_RDWR		O_RDWR
+#define QT_OPEN_CREAT		O_CREAT
+#define QT_OPEN_TRUNC		O_TRUNC
+#define QT_OPEN_APPEND		O_APPEND
+
+#define QT_SIGNAL_RETTYPE	void
+#define QT_SIGNAL_ARGS		int
+#define QT_SIGNAL_IGNORE	SIG_IGN
+
+#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+#define QT_SOCKLEN_T		socklen_t
+#else
+#define QT_SOCKLEN_T		int
+#endif
+
+#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+#define QT_SNPRINTF		::snprintf
+#define QT_VSNPRINTF		::vsnprintf
+#endif
+
+
+#endif // QPLATFORMDEFS_H
diff --git a/src/corelib/arch/qatomic_arch.h b/src/corelib/arch/qatomic_arch.h
index 00b288b..5106d29 100644
--- a/src/corelib/arch/qatomic_arch.h
+++ b/src/corelib/arch/qatomic_arch.h
@@ -88,6 +88,8 @@ QT_BEGIN_HEADER
 #  include "QtCore/qatomic_sh.h"
 #elif defined(QT_ARCH_SH4A)
 #  include "QtCore/qatomic_sh4a.h"
+#elif defined(QT_ARCH_NACL)
+#  include "QtCore/qatomic_generic.h"
 #else
 #  error "Qt has not been ported to this architecture"
 #endif
diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro
index 83fa044..5a810b1 100644
--- a/src/corelib/corelib.pro
+++ b/src/corelib/corelib.pro
@@ -18,7 +18,7 @@ include(codecs/codecs.pri)
 include(statemachine/statemachine.pri)
 include(xml/xml.pri)
 
-mac|darwin:LIBS_PRIVATE += -framework ApplicationServices
+!nacl:mac|darwin:LIBS_PRIVATE += -framework ApplicationServices
 
 mac:lib_bundle:DEFINES += QT_NO_DEBUG_PLUGIN_CHECK
 win32:DEFINES-=QT_NO_CAST_TO_ASCII
diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri
index b916b4d..758c5ee 100644
--- a/src/corelib/global/global.pri
+++ b/src/corelib/global/global.pri
@@ -13,6 +13,10 @@ SOURCES += \
 	global/qmalloc.cpp \
         global/qnumeric.cpp
 
+nacl {
+    SOURCES += global/qnaclunimplemented.cpp
+}
+
 # qlibraryinfo.cpp includes qconfig.cpp
 INCLUDEPATH += $$QT_BUILD_TREE/src/corelib/global
 
diff --git a/src/corelib/global/qconfig-minimal-system-dependencies.h b/src/corelib/global/qconfig-minimal-system-dependencies.h
new file mode 100644
index 0000000..c7e3633
--- /dev/null
+++ b/src/corelib/global/qconfig-minimal-system-dependencies.h
@@ -0,0 +1,371 @@
+/****************************************************************************
+ **
+ ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ ** All rights reserved.
+ ** Contact: Nokia Corporation (qt-info@nokia.com)
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+ **
+ ** $QT_BEGIN_LICENSE:LGPL$
+ ** No Commercial Usage
+ ** This file contains pre-release code and may not be distributed.
+ ** You may use this file in accordance with the terms and conditions
+ ** contained in the Technology Preview License Agreement accompanying
+ ** this package.
+ **
+ ** GNU Lesser General Public License Usage
+ ** Alternatively, this file may be used under the terms of the GNU Lesser
+ ** General Public License version 2.1 as published by the Free Software
+ ** Foundation and appearing in the file LICENSE.LGPL included in the
+ ** packaging of this file.  Please review the following information to
+ ** ensure the GNU Lesser General Public License version 2.1 requirements
+ ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+ **
+ ** In addition, as a special exception, Nokia gives you certain additional
+ ** rights.  These rights are described in the Nokia Qt LGPL Exception
+ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+ **
+ ** If you have questions regarding the use of this file, please contact
+ ** Nokia at qt-info@nokia.com.
+ **
+ **
+ **
+ **
+ **
+ **
+ **
+ **
+ ** $QT_END_LICENSE$
+ **
+ ****************************************************************************/
+
+#define QT_FONTS_ARE_RESOURCES
+
+/* Data structures */
+#ifndef QT_NO_QUUID_STRING
+#  define QT_NO_QUUID_STRING
+#endif
+#ifndef QT_NO_STL
+#  define QT_NO_STL
+#endif
+#ifndef QT_NO_TEXTDATE
+#  define QT_NO_TEXTDATE
+#endif
+#ifndef QT_NO_DATESTRING
+#  define QT_NO_DATESTRING
+#endif
+
+/* Dialogs */
+#ifndef QT_NO_FILEDIALOG
+#  define QT_NO_FILEDIALOG
+#endif
+#ifndef QT_NO_PRINTDIALOG
+#  define QT_NO_PRINTDIALOG
+#endif
+#ifndef QT_NO_PRINTPREVIEWDIALOG
+#  define QT_NO_PRINTPREVIEWDIALOG
+#endif
+
+
+/* File I/O */
+#ifndef QT_NO_DOM
+#  define QT_NO_DOM
+#endif
+#ifndef QT_NO_FILESYSTEMWATCHER
+#  define QT_NO_FILESYSTEMWATCHER
+#endif
+#ifndef QT_NO_FSFILEENGINE
+#  define QT_NO_FSFILEENGINE
+#endif
+#ifndef QT_NO_FILESYSTEMMODEL
+#  define QT_NO_FILESYSTEMMODEL
+#endif
+#ifndef QT_NO_FILESYSTEMMODEL
+#  define QT_NO_FILESYSTEMMODEL
+#endif
+#ifndef QT_NO_PROCESS
+#  define QT_NO_PROCESS
+#endif
+#ifndef QT_NO_TEMPORARYFILE
+#  define QT_NO_TEMPORARYFILE
+#endif
+#ifndef QT_NO_SETTINGS
+#  define QT_NO_SETTINGS
+#endif
+#ifndef QT_NO_LIBRARY
+#  define QT_NO_LIBRARY
+#endif
+
+/* Fonts */
+#ifndef QT_NO_QWS_QPF2
+#  define QT_NO_QWS_QPF2
+#endif
+
+/* Images */
+#ifndef QT_NO_IMAGEFORMATPLUGIN
+#  define QT_NO_IMAGEFORMATPLUGIN
+#endif
+#ifndef QT_NO_IMAGE_HEURISTIC_MASK
+#  define QT_NO_IMAGE_HEURISTIC_MASK
+#endif
+#ifndef QT_NO_IMAGE_TEXT
+#  define QT_NO_IMAGE_TEXT
+#endif
+#ifndef QT_NO_MOVIE
+#  define QT_NO_MOVIE
+#endif
+
+/* Internationalization */
+#ifndef QT_NO_BIG_CODECS
+#  define QT_NO_BIG_CODECS
+#endif
+#ifndef QT_NO_QWS_INPUTMETHODS
+#  define QT_NO_QWS_INPUTMETHODS
+#endif
+#ifndef QT_NO_TEXTCODEC
+#  define QT_NO_TEXTCODEC
+#endif
+#ifndef QT_NO_CODECS
+#  define QT_NO_CODECS
+#endif
+#ifndef QT_NO_TEXTCODECPLUGIN
+#  define QT_NO_TEXTCODECPLUGIN
+#endif
+#ifndef QT_NO_TRANSLATION
+#  define QT_NO_TRANSLATION
+#endif
+#ifndef QT_NO_TRANSLATION_UTF8
+#  define QT_NO_TRANSLATION_UTF8
+#endif
+
+/* ItemViews */
+
+#ifndef QT_NO_DIRMODEL
+#  define QT_NO_DIRMODEL
+#endif
+
+/* Kernel */
+#ifndef QT_NO_CLIPBOARD
+#  define QT_NO_CLIPBOARD
+#endif
+#ifndef QT_NO_CSSPARSER
+#  define QT_NO_CSSPARSER
+#endif
+#ifndef QT_NO_CURSOR
+#  define QT_NO_CURSOR
+#endif
+#ifndef QT_NO_DRAGANDDROP
+#  define QT_NO_DRAGANDDROP
+#endif
+#ifndef QT_NO_EFFECTS
+#  define QT_NO_EFFECTS
+#endif
+#ifndef QT_NO_SESSIONMANAGER
+#  define QT_NO_SESSIONMANAGER
+#endif
+#ifndef QT_NO_SHAREDMEMORY
+#  define QT_NO_SHAREDMEMORY
+#endif
+#ifndef QT_NO_SOUND
+#  define QT_NO_SOUND
+#endif
+#ifndef QT_NO_SYSTEMLOCALE
+#  define QT_NO_SYSTEMSEMAPHORE
+#endif
+#ifndef QT_NO_SYSTEMSEMAPHORE
+#  define QT_NO_SYSTEMSEMAPHORE
+#endif
+#ifndef QT_NO_TABLETEVENT
+#  define QT_NO_TABLETEVENT
+#endif
+#ifndef QT_NO_CRASHHANDLER
+#  define QT_NO_CRASHHANDLER
+#endif
+#ifndef QT_NO_CONCURRENT
+#  define QT_NO_CONCURRENT
+#endif
+#ifndef QT_NO_XMLSTREAM
+#  define QT_NO_XMLSTREAM
+#endif
+#ifndef QT_NO_XMLSTREAMREADER
+#  define QT_NO_XMLSTREAMREADER
+#endif
+#ifndef QT_NO_XMLSTREAMWRITER
+#  define QT_NO_XMLSTREAMWRITER
+#endif
+
+/* Networking */
+#ifndef QT_NO_COP
+#  define QT_NO_COP
+#endif
+#ifndef QT_NO_HOSTINFO
+#  define QT_NO_HOSTINFO
+#endif
+#ifndef QT_NO_HTTP
+#  define QT_NO_HTTP
+#endif
+#ifndef QT_NO_NETWORKPROXY
+#  define QT_NO_NETWORKPROXY
+#endif
+#ifndef QT_NO_SOCKS5
+#  define QT_NO_SOCKS5
+#endif
+#ifndef QT_NO_UDPSOCKET
+#  define QT_NO_UDPSOCKET
+#endif
+#ifndef QT_NO_URLINFO
+#  define QT_NO_URLINFO
+#endif
+#ifndef QT_NO_FTP
+#  define QT_NO_FTP
+#endif
+
+/* Painting */
+#ifndef QT_NO_COLORNAMES
+#  define QT_NO_COLORNAMES
+#endif
+#ifndef QT_NO_DIRECTPAINTER
+#  define QT_NO_DIRECTPAINTER
+#endif
+#ifndef QT_NO_PAINTONSCREEN
+#  define QT_NO_PAINTONSCREEN
+#endif
+#ifndef QT_NO_PAINT_DEBUG
+#  define QT_NO_PAINT_DEBUG
+#endif
+#ifndef QT_NO_PICTURE
+#  define QT_NO_PICTURE
+#endif
+#ifndef QT_NO_PRINTER
+#  define QT_NO_PRINTER
+#endif
+#ifndef QT_NO_CUPS
+#  define QT_NO_CUPS
+#endif
+
+/* Qt for Embedded Linux */
+#ifndef QT_NO_QWSEMBEDWIDGET
+#  define QT_NO_QWSEMBEDWIDGET
+#endif
+#ifndef QT_NO_QWS_ALPHA_CURSOR
+#  define QT_NO_QWS_ALPHA_CURSOR
+#endif
+#ifndef QT_NO_QWS_CURSOR
+#  define QT_NO_QWS_CURSOR
+#endif
+#ifndef QT_NO_QWS_DECORATION_DEFAULT
+#  define QT_NO_QWS_DECORATION_DEFAULT
+#endif
+#ifndef QT_NO_QWS_DECORATION_STYLED
+#  define QT_NO_QWS_DECORATION_STYLED
+#endif
+#ifndef QT_NO_QWS_DECORATION_WINDOWS
+#  define QT_NO_QWS_DECORATION_WINDOWS
+#endif
+#ifndef QT_NO_QWS_MANAGER
+#  define QT_NO_QWS_MANAGER
+#endif
+#ifndef QT_NO_QWS_KEYBOARD
+#  define QT_NO_QWS_KEYBOARD
+#endif
+#ifndef QT_NO_QWS_MOUSE
+#  define QT_NO_QWS_MOUSE
+#endif
+#ifndef QT_NO_QWS_MOUSE_AUTO
+#  define QT_NO_QWS_MOUSE_AUTO
+#endif
+#ifndef QT_NO_QWS_MOUSE_MANUAL
+#  define QT_NO_QWS_MOUSE_MANUAL
+#endif
+#ifndef QT_NO_QWS_MULTIPROCESS
+#  define QT_NO_QWS_MULTIPROCESS
+#endif
+#ifndef QT_NO_QWS_SOUNDSERVER
+#  define QT_NO_QWS_SOUNDSERVER
+#endif
+#ifndef QT_NO_SXE
+#  define QT_NO_SXE
+#endif
+#ifndef QT_NO_QWS_PROPERTIES
+#  define QT_NO_QWS_PROPERTIES
+#endif
+#ifndef QT_NO_QWS_PROXYSCREEN
+#  define QT_NO_QWS_PROXYSCREEN
+#endif
+#ifndef QT_NO_QWS_DYNAMICSCREENTRANSFORMATION
+#  define QT_NO_QWS_DYNAMICSCREENTRANSFORMATION
+#endif
+#ifndef QT_NO_QWS_LINUXFB
+#  define QT_NO_QWS_LINUXFB
+#endif
+#ifndef QT_NO_QWS_MOUSE_PC
+#  define QT_NO_QWS_MOUSE_PC
+#endif
+#ifndef QT_NO_QWS_MOUSE_LINUXTP
+#  define QT_NO_QWS_MOUSE_LINUXTP
+#endif
+#ifndef QT_NO_QWS_QPF
+#  define QT_NO_QWS_QPF
+#endif
+
+/* SVG */
+#ifndef QT_NO_SVG
+#  define QT_NO_SVG
+#endif
+#ifndef QT_NO_GRAPHICSSVGITEM
+#  define QT_NO_GRAPHICSSVGITEM
+#endif
+#ifndef QT_NO_SVGGENERATOR
+#  define QT_NO_SVGGENERATOR
+#endif
+#ifndef QT_NO_SVGRENDERER
+#  define QT_NO_SVGRENDERER
+#endif
+#ifndef QT_NO_SVGWIDGET
+#  define QT_NO_SVGWIDGET
+#endif
+
+/* Styles */
+#ifndef QT_NO_STYLE_MOTIF
+#  define QT_NO_STYLE_MOTIF
+#endif
+#ifndef QT_NO_STYLE_CDE
+#  define QT_NO_STYLE_CDE
+#endif
+#ifndef QT_NO_STYLE_STYLESHEET
+#  define QT_NO_STYLE_STYLESHEET
+#endif
+#ifndef QT_NO_STYLE_WINDOWSCE
+#  define QT_NO_STYLE_WINDOWSCE
+#endif
+#ifndef QT_NO_STYLE_WINDOWSMOBILE
+#  define QT_NO_STYLE_WINDOWSMOBILE
+#endif
+#ifndef QT_NO_STYLE_WINDOWSVISTA
+#  define QT_NO_STYLE_WINDOWSVISTA
+#endif
+#ifndef QT_NO_STYLE_WINDOWSXP
+#  define QT_NO_STYLE_WINDOWSXP
+#endif
+
+/* Utilities */
+#ifndef QT_NO_ACCESSIBILITY
+#  define QT_NO_ACCESSIBILITY
+#endif
+#ifndef QT_NO_COMPLETER
+#  define QT_NO_COMPLETER
+#endif
+#ifndef QT_NO_DESKTOPSERVICES
+#  define QT_NO_DESKTOPSERVICES
+#endif
+#ifndef QT_NO_SCRIPT
+#  define QT_NO_SCRIPT
+#endif
+#ifndef QT_NO_SYSTEMTRAYICON
+#  define QT_NO_SYSTEMTRAYICON
+#endif
+
+/* Windows */
+#ifndef QT_NO_WIN_ACTIVEQT
+#  define QT_NO_WIN_ACTIVEQT
+#endif
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index ca3219f..45153b8 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -216,6 +216,8 @@ namespace QT_NAMESPACE {}
 #  define Q_OS_ULTRIX
 #elif defined(sinix)
 #  define Q_OS_RELIANT
+#elif defined(__native_client__)
+#  define Q_OS_NACL
 #elif defined(__linux__) || defined(__linux)
 #  define Q_OS_LINUX
 #elif defined(__FreeBSD__) || defined(__DragonFly__)
@@ -2661,6 +2663,10 @@ QT_LICENSED_MODULE(DBus)
 #  define QT_NO_PROCESS
 #endif
 
+#ifdef Q_OS_NACL
+#include <qnaclunimplemented.h>
+#endif
+
 QT_END_NAMESPACE
 QT_END_HEADER
 
diff --git a/src/corelib/global/qnaclunimplemented.cpp b/src/corelib/global/qnaclunimplemented.cpp
new file mode 100644
index 0000000..618ff3e
--- /dev/null
+++ b/src/corelib/global/qnaclunimplemented.cpp
@@ -0,0 +1,156 @@
+/****************************************************************************
+ **
+ ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ ** All rights reserved.
+ ** Contact: Nokia Corporation (qt-info@nokia.com)
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+ **
+ ** $QT_BEGIN_LICENSE:LGPL$
+ ** No Commercial Usage
+ ** This file contains pre-release code and may not be distributed.
+ ** You may use this file in accordance with the terms and conditions
+ ** contained in the Technology Preview License Agreement accompanying
+ ** this package.
+ **
+ ** GNU Lesser General Public License Usage
+ ** Alternatively, this file may be used under the terms of the GNU Lesser
+ ** General Public License version 2.1 as published by the Free Software
+ ** Foundation and appearing in the file LICENSE.LGPL included in the
+ ** packaging of this file.  Please review the following information to
+ ** ensure the GNU Lesser General Public License version 2.1 requirements
+ ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+ **
+ ** In addition, as a special exception, Nokia gives you certain additional
+ ** rights.  These rights are described in the Nokia Qt LGPL Exception
+ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+ **
+ ** If you have questions regarding the use of this file, please contact
+ ** Nokia at qt-info@nokia.com.
+ **
+ **
+ **
+ **
+ **
+ **
+ **
+ **
+ ** $QT_END_LICENSE$
+ **
+ ****************************************************************************/
+
+#include "qnaclunimplemented.h"
+#include <pthread.h>
+#include <qglobal.h>
+
+/*
+    The purpose of this file is to stub out certain functions
+    that are not provided by the Native Client SDK. This is
+    done as an alterative to sprinkling the Qt sources with
+    NACL ifdefs.
+
+    There are two main classes of functions:
+
+    - Fuctions that are called but can have no effect:
+    For these we simply give an empty implementation
+
+    - Functions that are referenced in the source code, but
+    is not/must not be called at run-time:
+    These we either leave undefined or implement with a
+    qFatal.
+
+    This is a work in progress.
+*/
+
+extern "C" {
+
+void pthread_cleanup_push(void (*)(void *), void *)
+{
+
+}
+
+void pthread_cleanup_pop(int)
+{
+
+}
+
+int pthread_setcancelstate(int, int *)
+{
+    return 0;
+}
+
+int pthread_setcanceltype(int, int *)
+{
+    return 0;
+}
+
+void pthread_testcancel(void)
+{
+
+}
+
+
+int pthread_cancel(pthread_t)
+{
+    return 0;
+}
+
+int pthread_attr_setinheritsched(pthread_attr_t *,int)
+{
+    return 0;
+}
+
+
+int pthread_attr_getinheritsched(const pthread_attr_t *, int *)
+{
+    return 0;
+}
+
+// event dispatcher, select
+//struct fd_set;
+//struct timeval;
+
+int fcntl(int, int, ...)
+{
+    return 0;
+}
+
+int sigaction(int, const struct sigaction *, struct sigaction *)
+{
+    return 0;
+}
+
+int open(const char *, int, ...)
+{
+    return 0;
+}
+
+int open64(const char *, int, ...)
+{
+    return 0;
+}
+
+int access(const char *, int)
+{
+    return 0;
+}
+
+typedef long off64_t;
+off64_t ftello64(void *)
+{
+    qFatal("ftello64 called");
+    return 0;
+}
+
+off64_t lseek64(int, off_t, int)
+{
+    qFatal("lseek64 called");
+    return 0;
+}
+
+} // Extern C
+
+int select(int, fd_set *, fd_set *, fd_set *, struct timeval *)
+{
+    return 0;
+}
diff --git a/src/corelib/global/qnaclunimplemented.h b/src/corelib/global/qnaclunimplemented.h
new file mode 100644
index 0000000..84085b5
--- /dev/null
+++ b/src/corelib/global/qnaclunimplemented.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+ **
+ ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ ** All rights reserved.
+ ** Contact: Nokia Corporation (qt-info@nokia.com)
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+ **
+ ** $QT_BEGIN_LICENSE:LGPL$
+ ** No Commercial Usage
+ ** This file contains pre-release code and may not be distributed.
+ ** You may use this file in accordance with the terms and conditions
+ ** contained in the Technology Preview License Agreement accompanying
+ ** this package.
+ **
+ ** GNU Lesser General Public License Usage
+ ** Alternatively, this file may be used under the terms of the GNU Lesser
+ ** General Public License version 2.1 as published by the Free Software
+ ** Foundation and appearing in the file LICENSE.LGPL included in the
+ ** packaging of this file.  Please review the following information to
+ ** ensure the GNU Lesser General Public License version 2.1 requirements
+ ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+ **
+ ** In addition, as a special exception, Nokia gives you certain additional
+ ** rights.  These rights are described in the Nokia Qt LGPL Exception
+ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+ **
+ ** If you have questions regarding the use of this file, please contact
+ ** Nokia at qt-info@nokia.com.
+ **
+ **
+ **
+ **
+ **
+ **
+ **
+ **
+ ** $QT_END_LICENSE$
+ **
+ ****************************************************************************/
+
+#ifndef QNACLUNIMPLEMENTED_H
+#define QNACLUNIMPLEMENTED_H
+
+#ifdef Q_OS_NACL
+
+// pthread
+#include <pthread.h>
+#define PTHREAD_CANCEL_DISABLE 1
+#define PTHREAD_CANCEL_ENABLE 2
+#define PTHREAD_INHERIT_SCHED 3
+
+extern "C" {
+
+void pthread_cleanup_push(void (*handler)(void *), void *arg);
+void pthread_cleanup_pop(int execute);
+
+int pthread_setcancelstate(int state, int *oldstate);
+int pthread_setcanceltype(int type, int *oldtype);
+void pthread_testcancel(void);
+int pthread_cancel(pthread_t thread);
+
+int pthread_attr_setinheritsched(pthread_attr_t *attr,
+    int inheritsched);
+int pthread_attr_getinheritsched(const pthread_attr_t *attr, 
+    int *inheritsched);
+
+// event dispatcher, select
+//struct fd_set;
+//struct timeval;
+int fcntl(int fildes, int cmd, ...);
+int sigaction(int sig, const struct sigaction * act, struct sigaction * oact);
+
+typedef long off64_t;
+off64_t ftello64(void *stream);
+off64_t lseek64(int fildes, off_t offset, int whence);
+int open64(const char *path, int oflag, ...);
+
+}
+
+int select(int nfds, fd_set * readfds, fd_set * writefds, fd_set * errorfds, struct timeval * timeout);
+
+#endif //Q_OS_NACL
+
+#endif //QNACLUNIMPLEMENTED_H 
diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri
index ef448b1..7c14886 100644
--- a/src/corelib/io/io.pri
+++ b/src/corelib/io/io.pri
@@ -69,7 +69,7 @@ win32 {
         SOURCES += io/qfsfileengine_iterator_unix.cpp
         symbian:SOURCES += io/qprocess_symbian.cpp
         else:SOURCES += io/qprocess_unix.cpp
-        macx-*: {
+        !nacl:macx-*: {
             HEADERS += io/qfilesystemwatcher_fsevents_p.h
             SOURCES += io/qsettings_mac.cpp io/qfilesystemwatcher_fsevents.cpp
         }
@@ -84,9 +84,11 @@ win32 {
                     io/qfilesystemwatcher_dnotify_p.h
         }
 
-        freebsd-*|macx-*|darwin-*|openbsd-*:{
-            SOURCES += io/qfilesystemwatcher_kqueue.cpp
-            HEADERS += io/qfilesystemwatcher_kqueue_p.h
+        !nacl {
+            freebsd-*|macx-*|darwin-*|openbsd-*:{
+                SOURCES += io/qfilesystemwatcher_kqueue.cpp
+                HEADERS += io/qfilesystemwatcher_kqueue_p.h
+            }
         }
 
         symbian {
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index 8e76e9e..783fbb0 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -928,7 +928,7 @@ public:
     }
 };
 
-#if defined(Q_OS_UNIX)
+#if defined(Q_OS_UNIX) && ! defined (Q_OS_NACL)
 #define QT_USE_MMAP
 #endif
 
diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri
index 1851e04..6f53a3f 100644
--- a/src/corelib/kernel/kernel.pri
+++ b/src/corelib/kernel/kernel.pri
@@ -78,12 +78,12 @@ wince*: {
 		kernel/qfunctions_wince.h
 }
 
-mac:!embedded {
+mac:!embedded:!embedded_lite {
     SOURCES += \
         kernel/qcoreapplication_mac.cpp
 }
 
-mac {
+mac:!nacl {
        SOURCES += \
 		kernel/qcore_mac.cpp
 }
diff --git a/src/corelib/kernel/qcore_unix.cpp b/src/corelib/kernel/qcore_unix.cpp
index e0d92c0..685576b 100644
--- a/src/corelib/kernel/qcore_unix.cpp
+++ b/src/corelib/kernel/qcore_unix.cpp
@@ -42,7 +42,8 @@
 #include "qcore_unix_p.h"
 #include "qelapsedtimer.h"
 
-#ifndef Q_OS_VXWORKS
+#ifdef Q_OS_NACL
+#elif !defined (Q_OS_VXWORKS)
 # if !defined(Q_OS_HPUX) || defined(__ia64)
 #  include <sys/select.h>
 # endif
diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp
index f7d45ac..0c336e7 100644
--- a/src/corelib/kernel/qeventdispatcher_unix.cpp
+++ b/src/corelib/kernel/qeventdispatcher_unix.cpp
@@ -112,7 +112,9 @@ QEventDispatcherUNIXPrivate::QEventDispatcherUNIXPrivate()
     bool pipefail = false;
 
     // initialize the common parts of the event loop
-#if defined(Q_OS_INTEGRITY)
+#if defined(Q_OS_NACL)
+   // do nothing.
+#elif defined(Q_OS_INTEGRITY)
     // INTEGRITY doesn't like a "select" on pipes, so use socketpair instead
     if (socketpair(AF_INET, SOCK_STREAM, PF_INET, thread_pipe) == -1) {
         perror("QEventDispatcherUNIXPrivate(): Unable to create socket pair");
@@ -157,7 +159,9 @@ QEventDispatcherUNIXPrivate::QEventDispatcherUNIXPrivate()
 
 QEventDispatcherUNIXPrivate::~QEventDispatcherUNIXPrivate()
 {
-#if defined(Q_OS_VXWORKS)
+#if defined(Q_OS_NACL)
+   // do nothing.
+#elif defined(Q_OS_VXWORKS)
     close(thread_pipe[0]);
 
     char name[20];
@@ -312,7 +316,7 @@ int QEventDispatcherUNIXPrivate::doSelect(QEventLoop::ProcessEventsFlags flags,
 
 QTimerInfoList::QTimerInfoList()
 {
-#if (_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC)
+#if (_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC) && !defined(Q_OS_NACL)
     if (!QElapsedTimer::isMonotonic()) {
         // not using monotonic timers, initialize the timeChanged() machinery
         previousTime = qt_gettime();
@@ -364,6 +368,10 @@ timeval qAbs(const timeval &t)
 */
 bool QTimerInfoList::timeChanged(timeval *delta)
 {
+#ifdef Q_OS_NACL
+    Q_UNUSED(delta)
+    return false; // Calling "times" crashes.
+#endif
     struct tms unused;
     clock_t currentTicks = times(&unused);
 
diff --git a/src/corelib/kernel/qeventdispatcher_unix_p.h b/src/corelib/kernel/qeventdispatcher_unix_p.h
index cbe58de..d38acf3 100644
--- a/src/corelib/kernel/qeventdispatcher_unix_p.h
+++ b/src/corelib/kernel/qeventdispatcher_unix_p.h
@@ -64,7 +64,7 @@
 #  include <sys/times.h>
 #else
 #  include <sys/time.h>
-#  if !defined(Q_OS_HPUX) || defined(__ia64)
+#  if (!defined(Q_OS_HPUX) || defined(__ia64)) && !defined(Q_OS_NACL)
 #    include <sys/select.h>
 #  endif
 #endif
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index 6b34b5f..47a13d7 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -457,6 +457,7 @@ void QThread::usleep(unsigned long usecs)
 // Does some magic and calculate the Unix scheduler priorities
 // sched_policy is IN/OUT: it must be set to a valid policy before calling this function
 // sched_priority is OUT only
+#if defined(Q_OS_DARWIN) || !defined(Q_OS_OPENBSD) && !defined(Q_OS_SYMBIAN) && defined(_POSIX_THREAD_PRIORITY_SCHEDULING) && (_POSIX_THREAD_PRIORITY_SCHEDULING-0 >= 0)
 static bool calculateUnixPriority(int priority, int *sched_policy, int *sched_priority)
 {
 #ifdef SCHED_IDLE
@@ -484,6 +485,7 @@ static bool calculateUnixPriority(int priority, int *sched_policy, int *sched_pr
     *sched_priority = prio;
     return true;
 }
+#endif
 
 void QThread::start(Priority priority)
 {
diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri
index 4e0ebbc..f540f14 100644
--- a/src/corelib/tools/tools.pri
+++ b/src/corelib/tools/tools.pri
@@ -83,7 +83,7 @@ SOURCES += \
 
 symbian:SOURCES+=tools/qlocale_symbian.cpp
 
-mac:SOURCES += tools/qelapsedtimer_mac.cpp
+!nacl:mac:SOURCES += tools/qelapsedtimer_mac.cpp
 else:symbian:SOURCES += tools/qelapsedtimer_symbian.cpp
 else:unix:SOURCES += tools/qelapsedtimer_unix.cpp
 else:win32:SOURCES += tools/qelapsedtimer_win.cpp
diff --git a/src/gui/kernel/mac.pri b/src/gui/kernel/mac.pri
index 1538510..eb47ce9 100644
--- a/src/gui/kernel/mac.pri
+++ b/src/gui/kernel/mac.pri
@@ -1,4 +1,4 @@
-!x11:!embedded:mac {
+!x11:!embedded:!nacl:mac {
    LIBS_PRIVATE += -framework Carbon -lz
    *-mwerks:INCLUDEPATH += compat
 }
diff --git a/src/gui/kernel/qplatformintegrationfactory_lite.cpp b/src/gui/kernel/qplatformintegrationfactory_lite.cpp
index 9a00dea..cd7d171 100644
--- a/src/gui/kernel/qplatformintegrationfactory_lite.cpp
+++ b/src/gui/kernel/qplatformintegrationfactory_lite.cpp
@@ -60,8 +60,8 @@ QPlatformIntegration *QPlatformIntegrationFactory::create(const QString& key)
     QStringList paramList = key.split(QLatin1Char(':'));
     QString platform = paramList.takeFirst().toLower();
 
-    qDebug() << loader()->keys();
 #if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
+    qDebug() << loader()->keys();
     if (QPlatformIntegrationFactoryInterface *factory = qobject_cast<QPlatformIntegrationFactoryInterface*>(loader()->instance(platform)))
         ret = factory->create(platform, paramList);
 #endif
diff --git a/src/gui/text/qfontdatabase_qws.cpp b/src/gui/text/qfontdatabase_qws.cpp
index 4dd5019..09fb07c 100644
--- a/src/gui/text/qfontdatabase_qws.cpp
+++ b/src/gui/text/qfontdatabase_qws.cpp
@@ -388,12 +388,14 @@ static void initializeDb()
 
     }
 #endif
+#ifndef QT_NO_QWS_QPF2
     QDir dir(fontpath, QLatin1String("*.qpf2"));
     for (int i = 0; i < int(dir.count()); ++i) {
         const QByteArray file = QFile::encodeName(dir.absoluteFilePath(dir[i]));
         //qDebug() << "looking at" << file;
         db->addQPF2File(file);
     }
+#endif
 #endif //QT_FONTS_ARE_RESOURCES
 
 
diff --git a/src/src.pro b/src/src.pro
index 9c4831c..d15e973 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -5,6 +5,8 @@ unset(SRC_SUBDIRS)
 win32:SRC_SUBDIRS += src_winmain
 symbian:SRC_SUBDIRS += src_s60main
 SRC_SUBDIRS += src_corelib src_xml src_network src_sql src_testlib
+nacl: SRC_SUBDIRS -= src_network src_testlib
+win32:SRC_SUBDIRS += src_activeqt
 !symbian:contains(QT_CONFIG, dbus):SRC_SUBDIRS += src_dbus
 !contains(QT_CONFIG, no-gui): SRC_SUBDIRS += src_gui
 !wince*:!symbian:!vxworks:contains(QT_CONFIG, qt3support): SRC_SUBDIRS += src_qt3support
-- 
cgit v0.12