Index: /trunk/README.OS2
===================================================================
--- /trunk/README.OS2	(revision 982)
+++ /trunk/README.OS2	(revision 983)
@@ -56,4 +56,11 @@
 script (discussed in section "COMPILING QT" below) will automatically disable
 the corresponding feature:
+
+  - Perl 5.8.2 or above. This is required if you want to perform a shadow build
+    of the Qt library (which is a recommended way to go). Please refer to
+    section "COMPILING QT" for more information about shadow builds. Recent
+    builds of Perl for OS/2 are available here:
+
+      http://os2ports.smedley.info/index.php?page=perl
 
   - MAPSYM 4.00.000 (Oct 4 2001) to enable generation of symbol (.SYM) files for
@@ -232,31 +239,56 @@
 libraries) and proceed directly to the next section.
 
-When the environment is set up, go to the directory where you unpacked the
-Qt4 source tree and type:
-
-  configure.cmd
-
-This will set up the Qt library (by creating necessary configuration and include
-files and a bunch of Makefiles for variuos components) and build the qmake tool.
-
-The next step is to type:
-
-  make
-
-This will compile and link the Qt library. Note that by default both the release
-and the debug version of the library are built (please be patient, it may take
-quite some time depending on your hardware). The release and debug libraries can
-co-exist in the same source tree and may be used in parallel: all the debug DLLs
-get a 'd' letter in their name preceeding the Qt major version number and use
-separate directories for object files.
-
-To save time, you may build the release and the debug versions of the Qt library
-separately by typing 'make release' or 'make debug' accordingly instead of just
-'make'.
+When the environment is set up as described above, you may build the Qt library.
+There are two distinct ways of doing this: in the source tree or in a separate
+directory of your choice. In the first case, all results of the build process
+(intermediate object files as well as final executables and DLLs) will be placed
+right in the source tree. In the second case, they will be placed in the
+separate directory -- this is called a shadow build.
+
+Shadow builds are the recommended way to go because they keep the source
+directories clean and also allow to use the same source tree for creating any
+number of builds, each with its own build options.
+
+To perform a shadow build, do the following steps:
+
+  1. Create a directory outside the Qt4 source tree.
+
+  2. Go to that directory.
+
+  3. Type:
+
+     <source_tree>\configure.cmd
+
+     where <source_tree> is the directory containing the Qt4 source tree. This
+     will create all necessary configuration files, headers, Makefiles and will
+     also build the qmake tool which is necessary to control the rest of the
+     build process (note that building qmake will take some time).
+
+  4. Once the configure process is finished, type:
+
+     make
+
+  Note that by the default the shadow build will produce the release version of
+  the Qt library. This may be changed by passing command line options to
+  configure.cmd at step 3.
+
+To perform a normal build, you execute 'configure.cmd' followed by 'make' right
+in the directory containing the Qt4 source tree. The default in this case is to
+build both the debug and release versions of the Qt library.
+
+Please keep in mind that in case of the dual debug and release build (where both
+flavors are stored in the same build directory), only DLL and LIB files will be
+separated (because the debug versions of them will have the 'd' suffix in the
+file name). Executable files are normally taken from the release build but,
+since the file names are identical, sometimes they may be overwritten by the
+debug versions (e.g. when you rebuild parts of the library later). For this
+reason, performing dual builds is not recommended.
+
+The Qt library is huge so the build process will take several hours (or even
+several dozen of hours) depending on your hardware and configure options.
 
 Once the library is successfully built, you may try to compile the demos and
 examples by visiting the individual example subdirectories in the source tree
-and typing 'qmake' followed by one of 'make', 'make release' or 'make debug'
-in that subdirectory.
+and typing 'qmake' followed by 'make'.
 
 NOTE:
Index: /trunk/bin/syncqt.cmd
===================================================================
--- /trunk/bin/syncqt.cmd	(revision 983)
+++ /trunk/bin/syncqt.cmd	(revision 983)
@@ -0,0 +1,13 @@
+/*--------------------------------------------------------------------
+ *
+ * Synchronizes Qt header files - internal development tool.
+ *
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+ * Contact: Nokia Corporation (qt-info@nokia.com)
+ *
+ *------------------------------------------------------------------*/
+parse source . . Script
+ScriptDir = strip(filespec('D', Script) || filespec('P', Script), 'T', '\')
+parse arg aArgs
+'@set QTDIR='ScriptDir'\..'
+'@call perl -S syncqt' aArgs
Index: /trunk/configure.cmd
===================================================================
--- /trunk/configure.cmd	(revision 982)
+++ /trunk/configure.cmd	(revision 983)
@@ -513,4 +513,34 @@
     end
 
+    /*--------------------------------------------------------------------------
+     build tree initialization
+    --------------------------------------------------------------------------*/
+
+    /* find the perl command */
+    G.PERL = SysSearchPath('PATH', 'perl.exe')
+    if (G.PERL == "") then
+        G.PERL = SysSearchPath('PATH', 'perl.cmd')
+
+    /* is this a shadow build? */
+    if (G.OPT_SHADOW == "maybe") then do
+        G.OPT_SHADOW = "no"
+        if (translate(G.RelPath) \== translate(G.OutPath) &,
+            \FileExists(G.OutPath"\configure.cmd")) then do
+            G.OPT_SHADOW = "yes"
+        end
+    end
+
+    if (G.OPT_SHADOW == "yes") then do
+        if (FileExists(G.RelPath"\.qmake.cache") |,
+            FileExists(G.RelPath"\src\corelib\global\qconfig.h") |,
+            FileExists(G.RelPath"\src\corelib\global\qconfig.cpp")) then do
+            call SayErr "You cannot make a shadow build from a source tree",
+                        "containing a previous build."
+            call SayErr "Cannot proceed."
+            call Done 1
+        end
+        call SayVerbose "Performing shadow build..."
+    end
+
     /* skip this if the user just needs help... */
     if (G.OPT_HELP \== "yes") then do
@@ -522,4 +552,12 @@
                 G.CFG_DEBUG = "no"
             end
+            else if (G.CFG_DEV == "yes") then do
+                G.CFG_DEBUG_RELEASE = "no"
+                G.CFG_DEBUG = "yes"
+            end
+            else if (G.OPT_SHADOW == "yes") then do
+                G.CFG_DEBUG_RELEASE = "no"
+                G.CFG_DEBUG = "no"
+            end
             else do
                 G.CFG_DEBUG_RELEASE = "yes"
@@ -527,4 +565,5 @@
             end
         end
+
         if (G.CFG_DEBUG_RELEASE == "yes") then
             G.QMAKE_CONFIG = Join(G.QMAKE_CONFIG, "build_all")
@@ -533,9 +572,76 @@
             G.QMAKE_CONFIG = Join(G.QMAKE_CONFIG, "silent")
 
-        if (G.OPT_FAST == "auto") then
+        /* if the source tree is different from the build tree,
+         * symlink or copy part of the sources */
+        if (G.OPT_SHADOW == "yes") then do
+            call SaySay "Preparing build tree..."
+
+            if (G.PERL == "") then do
+                call SayErr "You need perl in your PATH to make a shadow build."
+                call SayErr "Cannot proceed."
+                call Done 1
+            end
+
+            if (\DirExists(G.OutPath"\bin")) then
+                call MakeDir G.OutPath"\bin"
+
+            /* make a syncqt script that can be used in the shadow */
+            call DeleteFile G.OutPath"\bin\syncqt.cmd"
+            call MakeDir G.OutPath"\bin"
+            call charout G.OutPath"\bin\syncqt.cmd",,
+                "/**/"G.EOL||,
+                "parse arg aArgs"G.EOL||,
+                "'@set QTDIR="G.RelPath"'"G.EOL||,
+                "'@call perl -S """G.RelPath"""\bin\syncqt",
+                    "-outdir """G.OutPath"""' aArgs"G.EOL
+            call charout G.OutPath"\bin\syncqt.cmd"
+
+            /* copy includes */
+            cmd = ""
+            G.SYNCQT_OPTS = ""
+            if (G.CFG_DEV == "yes") then
+                G.SYNCQT_OPTS = Join(G.SYNCQT_OPTS, "-check-includes")
+            if (G.OPT_SHADOW == "yes") then
+                cmd = 'call' G.OutPath'\bin\syncqt.cmd' G.SYNCQT_OPTS
+            else if (G.CFG_DEV == "yes" | \DirExists(G.RelPath"\include") |,
+                     DirExists(G.RelPath"\.git")) then
+                cmd = 'call' G.RelPath'\bin\syncqt.cmd' G.SYNCQT_OPTS
+            if (cmd \== '') then do
+                cmd
+                if (rc \= 0) then do
+                    call SayErr cmd "failed with exit code "rc"."
+                    call SayErr "Cannot proceed."
+                    call Done 1
+                end
+            end
+
+            /* copy parts of the mkspecs directory */
+            call DeleteDir G.OutPath"\mkspecs"
+            call SysFileTree G.RelPath"\mkspecs\os2-*", 'found', 'DO'
+            do i = 1 to found.0
+                call CopyDir found.i, G.OutPath"\mkspecs\"filespec('N', found.i)
+            end
+            call CopyDir G.RelPath"\mkspecs\features", G.OutPath"\mkspecs\features"
+            call CopyDir G.RelPath"\mkspecs\modules", G.OutPath"\mkspecs\modules"
+            call DeleteDir G.OutPath"\mkspecs\default"
+
+/*@todo
+            # symlink the doc directory
+            rm -rf "$outpath/doc"
+            ln -s "$relpath/doc" "$outpath/doc"
+
+            # make sure q3porting.xml can be found
+            mkdir -p "$outpath/tools/porting/src"
+            rm -f "$outpath/tools/porting/src/q3porting.xml"
+            ln -s "$relpath/tools/porting/src/q3porting.xml" "$outpath/tools/porting/src"
+*/
+        end
+
+        if (G.OPT_FAST == "auto") then do
            if (G.CFG_DEV == "yes") then G.OPT_FAST = "yes"
            else G.OPT_FAST = "no"
-
-        /* find a make command */
+        end
+
+        /* find the make command */
         G.MAKE = GetEnv("MAKE")
         if (G.MAKE == "") then do
@@ -898,4 +1004,6 @@
     call SayLog "Creating qmake. Please wait..."
 
+    call MakeDir G.OutPath"\qmake"
+
     /* take the correct Makefile and fix it */
     MakefilePlatform = G.RelPath"\qmake\Makefile."G.PLATFORM
@@ -961,16 +1069,6 @@
     call PutToAtExitSlot exs, 'call MoveFile "'qconfig_h'", "'qmake_qconfig_h'"'
 
-    list.1 = G.OutPath"\include\QtCore\qconfig.h"
-    list.2 = G.OutPath"\include\Qt\qconfig.h"
-    list.0 = 2
-    do i = 1 to list.0
-        if (\FileExists(list.i)) then do
-            call charout list.i, '#include "..\..\src\corelib\global\qconfig.h"'G.EOL
-            call charout list.i
-        end
-    end
-
     curdir = directory()
-    call directory G.RelPath"\qmake"
+    call directory G.OutPath"\qmake"
 
     address "cmd" G.MAKE G.MAKE_JOBS
@@ -2344,5 +2442,5 @@
 MakeDir: procedure expose (Globals)
     parse arg aDir
-    aDir = translate(aDir, '\', '/')
+    aDir = FixDirNoSlash(aDir)
     curdir = directory()
     base = aDir
Index: /trunk/qmake/Makefile.os2-g++
===================================================================
--- /trunk/qmake/Makefile.os2-g++	(revision 982)
+++ /trunk/qmake/Makefile.os2-g++	(revision 983)
@@ -14,9 +14,12 @@
 CXX	    =	g++
 CFLAGS	    =	-O -s -Zomf \
-		-I. -Igenerators -Igenerators/unix \
-		-Igenerators/win32 -Igenerators/mac \
-        -Igenerators/symbian -Igenerators/os2 \
+		-I$(SOURCE_PATH)/qmake \
+		-I$(SOURCE_PATH)/qmake/generators \
+		-I$(SOURCE_PATH)/qmake/generators/unix \
+		-I$(SOURCE_PATH)/qmake/generators/win32 \
+		-I$(SOURCE_PATH)/qmake/generators/mac \
+        -I$(SOURCE_PATH)/qmake/generators/symbian \
+		-I$(SOURCE_PATH)/qmake/generators/os2 \
 		-I$(BUILD_PATH)/include -I$(BUILD_PATH)/include/QtCore \
-		-I$(SOURCE_PATH)/include -I$(SOURCE_PATH)/include/QtCore \
 		-I$(BUILD_PATH)/src/corelib/global \
 		-I$(BUILD_PATH)/src/corelib/xml \
@@ -47,31 +50,31 @@
 
 SOURCES     = \
-		project.cpp \
-		property.cpp \
-		main.cpp \
-		generators/makefile.cpp \
-		generators/unix/unixmake2.cpp \
-		generators/unix/unixmake.cpp \
-		meta.cpp \
-		option.cpp \
-		generators/win32/winmakefile.cpp \
-		generators/win32/mingw_make.cpp \
-		generators/makefiledeps.cpp \
-		generators/metamakefile.cpp \
-		generators/mac/pbuilder_pbx.cpp \
-		generators/xmloutput.cpp \
-		generators/win32/borland_bmake.cpp \
-		generators/win32/msvc_nmake.cpp \
-		generators/projectgenerator.cpp \
-		generators/win32/msvc_vcproj.cpp \
-		generators/win32/msvc_vcxproj.cpp \
-		generators/win32/msvc_objectmodel.cpp \
-		generators/win32/msbuild_objectmodel.cpp \
-		generators/symbian/symmake.cpp \
-		generators/symbian/symmake_abld.cpp \
-		generators/symbian/symmake_sbsv2.cpp \
-		generators/symbian/initprojectdeploy_symbian.cpp \
-		generators/symbian/symbiancommon.cpp \
-		generators/os2/gnumake.cpp
+		$(SOURCE_PATH)/qmake/project.cpp \
+		$(SOURCE_PATH)/qmake/property.cpp \
+		$(SOURCE_PATH)/qmake/main.cpp \
+		$(SOURCE_PATH)/qmake/generators/makefile.cpp \
+		$(SOURCE_PATH)/qmake/generators/unix/unixmake2.cpp \
+		$(SOURCE_PATH)/qmake/generators/unix/unixmake.cpp \
+		$(SOURCE_PATH)/qmake/meta.cpp \
+		$(SOURCE_PATH)/qmake/option.cpp \
+		$(SOURCE_PATH)/qmake/generators/win32/winmakefile.cpp \
+		$(SOURCE_PATH)/qmake/generators/win32/mingw_make.cpp \
+		$(SOURCE_PATH)/qmake/generators/makefiledeps.cpp \
+		$(SOURCE_PATH)/qmake/generators/metamakefile.cpp \
+		$(SOURCE_PATH)/qmake/generators/mac/pbuilder_pbx.cpp \
+		$(SOURCE_PATH)/qmake/generators/xmloutput.cpp \
+		$(SOURCE_PATH)/qmake/generators/win32/borland_bmake.cpp \
+		$(SOURCE_PATH)/qmake/generators/win32/msvc_nmake.cpp \
+		$(SOURCE_PATH)/qmake/generators/projectgenerator.cpp \
+		$(SOURCE_PATH)/qmake/generators/win32/msvc_vcproj.cpp \
+		$(SOURCE_PATH)/qmake/generators/win32/msvc_vcxproj.cpp \
+		$(SOURCE_PATH)/qmake/generators/win32/msvc_objectmodel.cpp \
+		$(SOURCE_PATH)/qmake/generators/win32/msbuild_objectmodel.cpp \
+		$(SOURCE_PATH)/qmake/generators/symbian/symmake.cpp \
+		$(SOURCE_PATH)/qmake/generators/symbian/symmake_abld.cpp \
+		$(SOURCE_PATH)/qmake/generators/symbian/symmake_sbsv2.cpp \
+		$(SOURCE_PATH)/qmake/generators/symbian/initprojectdeploy_symbian.cpp \
+		$(SOURCE_PATH)/qmake/generators/symbian/symbiancommon.cpp \
+		$(SOURCE_PATH)/qmake/generators/os2/gnumake.cpp
 
 # Qt code (taken from qmake.pri)
@@ -139,5 +142,5 @@
 	@mkdir $(OBJECTS_DIR)
 
-Makefile: Makefile.os2-g++
+Makefile: $(SOURCE_PATH)/qmake/Makefile.os2-g++
 	@echo "Out of date, please rerun configure"
 
Index: /trunk/qmake/qmake.pro
===================================================================
--- /trunk/qmake/qmake.pro	(revision 982)
+++ /trunk/qmake/qmake.pro	(revision 983)
@@ -29,7 +29,7 @@
            generators/symbian \
            generators/os2 \
-           $$QT_SOURCE_TREE/include \
-           $$QT_SOURCE_TREE/include/QtCore \
-           $$QT_SOURCE_TREE/qmake
+           $$QT_BUILD_TREE/include \
+           $$QT_BUILD_TREE/include/QtCore \
+           $$QT_BUILD_TREE/src/corelib/global
 
 VPATH += $$QT_SOURCE_TREE/tools/shared
