Index: /trunk/configure.cmd
===================================================================
--- /trunk/configure.cmd	(revision 45)
+++ /trunk/configure.cmd	(revision 46)
@@ -39,13 +39,6 @@
 
 G.QMAKE_OUTDIR      = ""
-G.QMAKE_VARS_FILE   = ".qmake.vars"
 
 G.CFG_DEV           = "no"
-
-/* Qt for OS/2 is always the open source edition */
-G.Licensee      = "Open Source"
-G.Edition       = "OpenSource"
-G.EditionString = "Open Source"
-G.QT_EDITION    = "QT_EDITION_OPENSOURCE"
 
 
@@ -84,5 +77,5 @@
 call MagicLogHook arg(1)
 
-call Main
+call Main arg(1)
 
 call Done 0
@@ -95,6 +88,10 @@
 /**
  *  Just do the job.
+ *
+ *  @param aArgs    Comand line arguments.
  */
 Main: procedure expose (Globals)
+
+    parse arg aArgs
 
     /* the directory of this script is the "source tree */
@@ -103,6 +100,73 @@
     G.OutPath = directory()
 
-    /* reset the vars file */
-    call DeleteFile G.QMAKE_VARS_FILE
+    /* QTDIR may be set and point to an old or system-wide Qt installation */
+    call UnsetEnv "QTDIR"
+
+    /*--------------------------------------------------------------------------
+     Qt version detection
+    --------------------------------------------------------------------------*/
+
+    G.QT_VERSION = ""
+    G.QT_MAJOR_VERSION = ""
+    G.QT_MINOR_VERSION = 0
+    G.QT_PATCH_VERSION = 0
+
+    G.QT_PACKAGEDATE = ""
+
+    qglobal_h = G.RelPath"\src\corelib\global\qglobal.h"
+
+    i = 2 /* number of lines to match */
+    do while lines(qglobal_h)
+        str = linein(qglobal_h)
+        parse var str w1 w2 w3
+        if (w1 == '#define' & w2 == 'QT_VERSION_STR') then do
+            parse var w3 '"'G.QT_VERSION'"'
+            i = i -1
+        end
+        else if (w1 == '#define' & w2 == 'QT_PACKAGEDATE_STR') then do
+            parse var w3 '"'G.QT_PACKAGEDATE'"'
+            i = i -1
+        end
+        if (i == 0) then leave
+    end
+
+    if (G.QT_VERSION \== "") then do
+        parse var G.QT_VERSION maj'.'minor'.'patch
+        if (patch == "" | verify(patch, '0123456789') = 0) then do
+            if (patch \== "") then
+                G.QT_PATCH_VERSION = patch
+            if (minor == "" | verify(minor, '0123456789') = 0) then do
+                if (minor \== "") then
+                    G.QT_MINOR_VERSION = minor
+                if (maj \== "" & verify(maj, '0123456789') = 0) then
+                    G.QT_MAJOR_VERSION = maj
+            end
+        end
+    end
+    if (G.QT_MAJOR_VERSION == "") then do
+       call SayErr "Cannot process version from qglobal.h: """G.QT_VERSION""""
+       call SayErr "Cannot proceed."
+       call Done 1
+    end
+
+    if (G.QT_PACKAGEDATE == "") then do
+       call SayErr "Unable to determine package date from qglobal.h: """G.QT_PACKAGEDATE""""
+       call SayErr "Cannot proceed."
+       call Done 1
+    end
+
+    /*--------------------------------------------------------------------------
+     check the license
+    --------------------------------------------------------------------------*/
+
+    /* Qt for OS/2 is always the open source edition */
+    G.Licensee      = "Open Source"
+    G.Edition       = "OpenSource"
+    G.EditionString = "Open Source"
+    G.QT_EDITION    = "QT_EDITION_OPENSOURCE"
+
+    /*--------------------------------------------------------------------------
+     initalize variables
+    --------------------------------------------------------------------------*/
 
     call QMakeVar "add", "styles", "cde mac motif plastique cleanlooks windows"
@@ -114,7 +178,4 @@
     QMakeVar add mouse-drivers "pc linuxtp"
 */
-
-    /* QTDIR may be set and point to an old or system-wide Qt installation */
-    call UnsetEnv "QTDIR"
 
     /* @todo cleanup the option list below when it's clear which options are
@@ -203,9 +264,10 @@
     G.CFG_GLIB = "auto"
     G.CFG_GSTREAMER = "auto"
-    G.CFG_DBUS = "auto"
     G.CFG_NAS = "no"
-    G.CFG_OPENSSL = "auto"
 */
     G.CFG_QGTKSTYLE = "auto"
+    G.CFG_OPENSSL = "auto"
+    G.CFG_OPENSSL_LIBS = ""
+    G.CFG_DBUS = "auto"
     G.CFG_LARGEFILE = "auto"
     G.CFG_PTMALLOC = "no"
@@ -213,6 +275,4 @@
     G.CFG_PRECOMPILE = "auto"
     G.CFG_SEPARATE_DEBUG_INFO = "auto"
-    G.CFG_REDUCE_EXPORTS = "auto"
-    G.CFG_REDUCE_RELOCATIONS = "no"
 /* @todo do we really need this?
     G.CFG_MMX = "auto"
@@ -240,5 +300,4 @@
     G.CFG_FRAMEWORK = "auto"
 */
-    G.CFG_SXE = "no"
     G.CFG_PREFIX_INSTALL = "yes"
     G.CFG_SDK = ""
@@ -273,4 +332,5 @@
     G.QT_HOST_PREFIX = ""
 
+    G.QT_LIBINFIX = ""
     G.QT_NAMESPACE = ""
 
@@ -344,8 +404,16 @@
     end
 
-    /* parse command line arguments
+    /*--------------------------------------------------------------------------
+     parse command line arguments
     --------------------------------------------------------------------------*/
 
     /* @todo */
+    if (aArgs \== "") then do
+        call SayErr
+        call SayErr "Sorry, command line arguments are not yet processed."
+        call SayErr "Please run the script again without the arguments."
+        call SayErr
+        call Done 1
+    end
 
     if (G.CFG_QCONFIG \== "full" & G.CFG_QT3SUPPORT == "yes") then do
@@ -705,5 +773,19 @@
     --------------------------------------------------------------------------*/
 
-    /* nothing yet */
+    /* the current "tests" don't actually need qmake, we just keep the
+     * structure similar to ./configure */
+
+    /* enable all image formats and ZLIB by default */
+    if (G.CFG_TIFF == "auto")   then G.CFG_TIFF = "yes"
+    if (G.CFG_PNG == "auto")    then G.CFG_PNG = "yes"
+    if (G.CFG_JPEG == "auto")   then G.CFG_JPEG = "yes"
+    if (G.CFG_MNG == "auto")    then G.CFG_MNG = "yes"
+    if (G.CFG_ZLIB == "auto")   then G.CFG_ZLIB = "yes"
+
+    if (G.CFG_QGTKSTYLE == "auto")  then G.CFG_QGTKSTYLE = "no"
+    if (G.CFG_OPENSSL == "auto")    then G.CFG_OPENSSL = "no"
+    if (G.CFG_DBUS == "auto")       then G.CFG_DBUS = "no"
+
+    if (G.CFG_GRAPHICS_SYSTEM == "default") then G.CFG_GRAPHICS_SYSTEM = "raster"
 
     /*--------------------------------------------------------------------------
@@ -742,8 +824,4 @@
         G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_OPENGL")
 
-    /* safe execution environment */
-    if (G.CFG_SXE \== "no") then
-        G.QT_CONFIG = Join(G.QT_CONFIG, "sxe")
-
     /* build up the variables for output */
     if (G.CFG_DEBUG == "yes") then do
@@ -764,9 +842,9 @@
     end
 
-    call QMakeVar "set", "PRECOMPILED_DIR", ".pch\"G.QMAKE_OUTDIR
-    call QMakeVar "set", "OBJECTS_DIR", ".obj\"G.QMAKE_OUTDIR
-    call QMakeVar "set", "MOC_DIR", ".moc\"G.QMAKE_OUTDIR
-    call QMakeVar "set", "RCC_DIR", ".rcc\"G.QMAKE_OUTDIR
-    call QMakeVar "set", "UI_DIR", ".uic\"G.QMAKE_OUTDIR
+    call QMakeVar "set", "PRECOMPILED_DIR", "tmp\pch\"G.QMAKE_OUTDIR
+    call QMakeVar "set", "OBJECTS_DIR", "tmp\obj\"G.QMAKE_OUTDIR
+    call QMakeVar "set", "MOC_DIR", "tmp\moc\"G.QMAKE_OUTDIR
+    call QMakeVar "set", "RCC_DIR", "tmp\rcc\"G.QMAKE_OUTDIR
+    call QMakeVar "set", "UI_DIR", "tmp\uic\"G.QMAKE_OUTDIR
 
     if (G.CFG_LARGEFILE == "yes") then
@@ -780,8 +858,4 @@
         G.QMAKE_CONFIG = Join(G.QMAKE_CONFIG, "GNUmake")
 
-    if (G.CFG_REDUCE_EXPORTS == "yes") then
-        G.QT_CONFIG = Join(G.QT_CONFIG, "reduce_exports")
-    if (G.CFG_REDUCE_RELOCATIONS == "yes") then
-        G.QT_CONFIG = Join(G.QT_CONFIG, "reduce_relocations")
     if (G.CFG_PRECOMPILE == "yes") then
         G.QMAKE_CONFIG = Join(G.QMAKE_CONFIG, "precompile_header")
@@ -882,15 +956,15 @@
     if (G.CFG_GSTREAMER == "yes") then
         G.QT_CONFIG = Join(G.QT_CONFIG, "gstreamer")
-    if (G.CFG_DBUS == "yes") then
-        G.QT_CONFIG = Join(G.QT_CONFIG, "dbus")
     if (G.CFG_DBUS == "linked") then
         G.QT_CONFIG = Join(G.QT_CONFIG dbus, "dbus-linked")
     if (G.CFG_NAS == "system") then
         G.QT_CONFIG = Join(G.QT_CONFIG, "nas")
-    if (G.CFG_OPENSSL == "yes") then
-        G.QT_CONFIG = Join(G.QT_CONFIG, "openssl")
     if (G.CFG_OPENSSL == "linked") then
         G.QT_CONFIG = Join(G.QT_CONFIG, "openssl-linked")
 */
+    if (G.CFG_OPENSSL == "yes") then
+        G.QT_CONFIG = Join(G.QT_CONFIG, "openssl")
+    if (G.CFG_DBUS == "yes") then
+        G.QT_CONFIG = Join(G.QT_CONFIG, "dbus")
 
     if (G.D_FLAGS \== "") then
@@ -914,5 +988,5 @@
     end
     if (G.CFG_XMLPATTERNS == "auto" & G.CFG_EXCEPTIONS \== "no") then
-        G.CFG_XMLPATTERNS = "yes"
+        G.CFG_XMLPATTERNS = "yes" /* QtXmlPatterns is fine for GCC 3.3.x */
     else if (G.CFG_EXCEPTIONS == "no") then
         G.CFG_XMLPATTERNS = "no"
@@ -928,5 +1002,5 @@
 
     if (G.CFG_WEBKIT == "auto") then
-        G.CFG_WEBKIT = "yes"
+        G.CFG_WEBKIT = "no" /* WebKit seems to require G++ >= 3.4.x */
 
     if (G.CFG_WEBKIT == "yes") then
@@ -944,7 +1018,8 @@
     if (G.CFG_SCRIPTTOOLS == "yes") then
         G.QT_CONFIG = Join(G.QT_CONFIG, "scripttools")
-    else
-        G.CFG_SCRIPTTOOLS="no"
+    else do
+        G.CFG_SCRIPTTOOLS = "no"
         G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_SCRIPTTOOLS")
+    end
 
     if (G.CFG_EXCEPTIONS == "no") then do
@@ -1031,10 +1106,11 @@
                 do j = 1 to words(BUILD_OPTIONS)
                     w = word(BUILD_OPTIONS, j)
-                    if (w == opt) then leave
-                    if (w > opt) then do
-                        insert(opt" ", BUILD_OPTIONS, wordindex(BUILD_OPTIONS, j))
+                    c = compare(opt, w)
+                    if (c == 0) then leave
+                    if (substr(opt, c, 1) < substr(w, c, 1)) then do
+                        BUILD_OPTIONS = insert(opt" ", BUILD_OPTIONS, wordindex(BUILD_OPTIONS, j) - 1)
                         leave
                     end
-                    if (j == words(BUILD_OPTIONS) then
+                    if (j == words(BUILD_OPTIONS)) then
                         BUILD_OPTIONS = Join(BUILD_OPTIONS, opt)
                 end
@@ -1056,10 +1132,11 @@
             do j = 1 to words(DEFS)
                 w = word(DEFS, j)
-                if (w == opt) then leave
-                if (w > opt) then do
-                    insert(opt" ", DEFS, wordindex(DEFS, j))
+                c = compare(opt, w)
+                if (c == 0) then leave
+                if (substr(opt, c, 1) < substr(w, c, 1)) then do
+                    DEFS = insert(opt" ", DEFS, wordindex(DEFS, j) - 1)
                     leave
                 end
-                if (j == words(DEFS) then
+                if (j == words(DEFS)) then
                     DEFS = DEFS" "opt
             end
@@ -1126,5 +1203,5 @@
 '#define QT_ARCH_'translate(G.CFG_ARCH)||G.EOL,
 ''G.EOL||,
-'/* Compile time features */'||G.EOL
+'/* Compile time features */'||G.EOL||G.EOL
 
     if (G.CFG_LARGEFILE == "yes") then
@@ -1134,9 +1211,512 @@
         call charout qconfig_h_new, '"#define QT_BUILD_INTERNAL'G.EOL||G.EOL
 
+    /* Add turned on SQL drivers */
+    SQL_DRIVERS = ""
+    SQL_PLUGINS = ""
+    do i = 1 to words(G.CFG_SQL_AVAILABLE)
+        drv = word(G.CFG_SQL_AVAILABLE, i)
+        val = value("G.CFG_SQL_"drv)
+        if (val == "qt") then do
+            G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_SQL_"translate(drv))
+            SQL_DRIVERS = Join(SQL_DRIVERS, drv)
+        end
+        else if (val == "plugin") then
+            SQL_PLUGINS = Join(SQL_PLUGINS, drv)
+    end
+
+    if (SQL_DRIVERS \== "") then
+        call QMakeVar "set", "sql-drivers", SQL_DRIVERS
+    if (SQL_PLUGINS \== "") then
+        call QMakeVar "set", "sql-plugins", SQL_PLUGINS
+
+    /* Add other configuration options to the qconfig.h file */
+    if (G.CFG_GIF == "yes") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_BUILTIN_GIF_READER=1")
+    if (G.CFG_TIFF \== "yes") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_IMAGEFORMAT_TIFF")
+    if (G.CFG_PNG \== "yes") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_IMAGEFORMAT_PNG")
+    if (G.CFG_JPEG \== "yes") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_IMAGEFORMAT_JPEG")
+    if (G.CFG_MNG \== "yes") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_IMAGEFORMAT_MNG")
+    if (G.CFG_ZLIB \== "yes") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_ZLIB")
+    if (G.CFG_EXCEPTIONS == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_EXCEPTIONS")
+/* @todo detect what's actually relevant
+    if (G.CFG_IPV6 == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_IPV6")
+*/
+    if (G.CFG_QGTKSTYLE \== "yes") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_STYLE_GTK")
+    if (G.CFG_OPENSSL == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_OPENSSL")
+    if (G.CFG_DBUS == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_DBUS")
+
+    if (G.CFG_GRAPHICS_SYSTEM == "raster") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_GRAPHICSSYSTEM_RASTER")
+    if (G.CFG_GRAPHICS_SYSTEM == "opengl") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_GRAPHICSSYSTEM_OPENGL")
+
+    /* X11/Unix/Mac only configs */
+/* @todo detect what's actually relevant
+    if (G.CFG_CUPS == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_CUPS")
+    if (G.CFG_ICONV == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_ICONV")
+    if (G.CFG_GLIB \== "yes") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_GLIB")
+    if (G.CFG_GSTREAMER \== "yes") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_GSTREAMER")
+    if (G.CFG_CLOCK_MONOTONIC == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_CLOCK_MONOTONIC")
+    if (G.CFG_MREMAP == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_MREMAP")
+    if (G.CFG_GETADDRINFO == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_GETADDRINFO")
+    if (G.CFG_IPV6IFNAME == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_IPV6IFNAME")
+    if (G.CFG_GETIFADDRS == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_GETIFADDRS")
+    if (G.CFG_INOTIFY == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_INOTIFY")
+    if (G.CFG_NAS == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_NAS")
+    if (G.CFG_NIS == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_NIS")
+    if (G.CFG_OPENSSL == "linked") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_LINKED_OPENSSL")
+
+    if (G.CFG_SM == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_SESSIONMANAGER")
+    if (G.CFG_XCURSOR == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_XCURSOR")
+    if (G.CFG_XFIXES == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_XFIXES")
+    if (G.CFG_FONTCONFIG == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_FONTCONFIG")
+    if (G.CFG_XINERAMA == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_XINERAMA")
+    if (G.CFG_XKB == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_XKB")
+    if (G.CFG_XRANDR == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_XRANDR")
+    if (G.CFG_XRENDER == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_XRENDER")
+    if (G.CFG_MITSHM == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_MITSHM")
+    if (G.CFG_XSHAPE == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_SHAPE")
+    if (G.CFG_XINPUT == "no") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS QT_NO_XINPUT, "QT_NO_TABLET")
+
+    if (G.CFG_XCURSOR == "runtime") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_RUNTIME_XCURSOR")
+    if (G.CFG_XINERAMA == "runtime") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_RUNTIME_XINERAMA")
+    if (G.CFG_XFIXES == "runtime") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_RUNTIME_XFIXES")
+    if (G.CFG_XRANDR == "runtime") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_RUNTIME_XRANDR")
+    if (G.CFG_XINPUT == "runtime") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_RUNTIME_XINPUT")
+*/
+
+    /* do primitive sorting (the list is not so big so it should be fine) */
+    sorted = ""
+    do i = 1 to words(G.QCONFIG_FLAGS)
+        w = word(G.QCONFIG_FLAGS, i)
+        if (sorted == "") then
+            sorted = w
+        else
+        do j = 1 to words(sorted)
+            w2 = word(sorted, j)
+            c = compare(w, w2)
+            if (c == 0) then leave
+            if (substr(w, c, 1) < substr(w2, c, 1)) then do
+                sorted = insert(w" ", sorted, wordindex(sorted, j) - 1)
+                leave
+            end
+            if (j == words(sorted)) then
+                sorted = sorted" "w
+        end
+    end
+    G.QCONFIG_FLAGS = sorted
+
+    if (G.QCONFIG_FLAGS \== "") then do
+        do i = 1 to words(G.QCONFIG_FLAGS)
+            cfg = word(G.QCONFIG_FLAGS, i)
+            parse value cfg with cfgd'='cfgv /* trim pushed 'Foo=Bar' defines */
+            cfg = strip(cfgd' 'cfgv)         /* turn first '=' into a space */
+            /* figure out define logic, so we can output the correct
+             * ifdefs to override the global defines in a project */
+            cfgdNeg = ""
+            if (StartsWith(cfg, "QT_NO_")) then
+                /* QT_NO_option can be forcefully turned on by QT_option */
+                cfgdNeg = "QT_"substr(cfg, 7)
+            else if (StartsWith(cfg, "QT_")) then
+                /* QT_option can be forcefully turned off by QT_NO_option */
+                cfgdNeg = "QT_NO_"substr(cfg, 4)
+            if (cfgdNeg == "") then
+                call charout qconfig_h_new,,
+'#ifndef 'cfgd||G.EOL||,
+'# define 'cfg||G.EOL||,
+'#endif'G.EOL||G.EOL
+            else
+                call charout qconfig_h_new,,
+'#if defined('cfgd') && defined('cfgdNeg')'G.EOL||,
+'# undef 'cfgd||G.EOL||,
+'#elif !defined('cfgd') && !defined('cfgdNeg')'G.EOL||,
+'# define 'cfg||G.EOL||,
+'#endif'G.EOL||G.EOL
+        end
+    end
+
     /* close the file */
     call charout qconfig_h_new
 
-    /* @todo not everything implemented yet, cry loudly... */
-    signal Nonsense
+    /* avoid unecessary rebuilds by copying only if qconfig.h has changed */
+    changed = \FileExists(qconfig_h)
+    if (\changed) then do
+        qconfig_h_str = charin(qconfig_h, 1, chars(qconfig_h))
+        call charout qconfig_h
+        changed = CompareFileToVar(qconfig_h_new, qconfig_h_str) \= 0
+    end
+    if (changed) then
+        call MoveFile qconfig_h_new, qconfig_h
+    else
+        call DeleteFile qconfig_h_new
+
+    /*--------------------------------------------------------------------------
+     save configuration into qconfig.pri
+    --------------------------------------------------------------------------*/
+
+    qconfig_pri = G.OutPath"\mkspecs\qconfig.pri"
+    qconfig_pri_new = qconfig_pri".new"
+
+    call DeleteFile qconfig_pri_new
+
+    G.QTCONFIG_CONFIG = Join(G.QTCONFIG_CONFIG, "no_mocdepend")
+
+    if (G.CFG_DEBUG == "yes") then do
+        G.QTCONFIG_CONFIG = Join(G.QTCONFIG_CONFIG, "debug")
+        if (G.CFG_DEBUG_RELEASE == "yes") then
+            G.QT_CONFIG = Join(G.QT_CONFIG, "release")
+        G.QT_CONFIG = Join(G.QT_CONFIG, "debug")
+    end
+    else if (G.CFG_DEBUG == "no") then do
+        G.QTCONFIG_CONFIG = Join(G.QTCONFIG_CONFIG, "release")
+        if (G.CFG_DEBUG_RELEASE == "yes") then
+            G.QT_CONFIG = Join(G.QT_CONFIG, "debug")
+        G.QT_CONFIG = Join(G.QT_CONFIG, "release")
+    end
+
+    if (G.CFG_STL == "yes") then
+        G.QTCONFIG_CONFIG = Join(G.QTCONFIG_CONFIG, "stl")
+/* @todo do we really need this?
+    if (G.CFG_FRAMEWORK == "no") then
+        G.QTCONFIG_CONFIG = Join(G.QTCONFIG_CONFIG, "qt_no_framework")
+    else do
+        G.QT_CONFIG = Join(G.QT_CONFIG, "qt_framework")
+        G.QTCONFIG_CONFIG = Join(G.QTCONFIG_CONFIG, "qt_framework")
+    end
+*/
+
+    call charout qconfig_pri_new,,
+'#configuration'G.EOL||,
+'CONFIG += 'G.QTCONFIG_CONFIG||G.EOL||,
+'QT_ARCH = 'G.CFG_ARCH||G.EOL||,
+'QT_EDITION = 'G.Edition||G.EOL||,
+'QT_CONFIG += 'G.QT_CONFIG||G.EOL||,
+''G.EOL||,
+'#versioning'G.EOL||,
+'QT_VERSION = 'G.QT_VERSION||G.EOL||,
+'QT_MAJOR_VERSION = 'G.QT_MAJOR_VERSION||G.EOL||,
+'QT_MINOR_VERSION = 'G.QT_MINOR_VERSION||G.EOL||,
+'QT_PATCH_VERSION = 'G.QT_PATCH_VERSION||G.EOL||,
+''G.EOL||,
+'#namespaces'G.EOL||,
+'QT_LIBINFIX = 'G.QT_LIBINFIX||G.EOL||,
+'QT_NAMESPACE = 'G.QT_NAMESPACE||G.EOL||,
+''G.EOL
+
+    /* close the file */
+    call charout qconfig_pri_new
+
+    /* replace qconfig.pri if it differs from the newly created temp file */
+    changed = \FileExists(qconfig_pri)
+    if (\changed) then do
+        qconfig_pri_str = charin(qconfig_pri, 1, chars(qconfig_pri))
+        call charout qconfig_pri
+        changed = CompareFileToVar(qconfig_pri_new, qconfig_pri_str) \= 0
+    end
+    if (changed) then
+        call MoveFile qconfig_pri_new, qconfig_pri
+    else
+        call DeleteFile qconfig_pri_new
+
+    /*--------------------------------------------------------------------------
+     save configuration into .qmake.cache
+    --------------------------------------------------------------------------*/
+
+    qmake_cache = G.OutPath"\.qmake.cache"
+    qmake_cache_new = qmake_cache".new"
+
+    call DeleteFile qmake_cache_new
+
+    call charout qmake_cache_new,,
+'CONFIG         += 'G.QMAKE_CONFIG' create_prl link_prl depend_includepath fix_output_dirs QTDIR_build'G.EOL||,
+'QT_SOURCE_TREE  = 'QuotePath(G.RelPath)||G.EOL||,
+'QT_BUILD_TREE   = 'QuotePath(G.OutPath)||G.EOL||,
+'QT_BUILD_PARTS  = 'G.CFG_BUILD_PARTS||G.EOL||,
+'QMAKE_MOC_SRC   = $$QT_BUILD_TREE\src\moc'G.EOL||,
+''G.EOL||,
+'#local paths that cannot be queried from the QT_INSTALL_* properties while building QTDIR'G.EOL||,
+'QMAKE_MOC       = $$QT_BUILD_TREE\bin\moc.exe'G.EOL||,
+'QMAKE_UIC       = $$QT_BUILD_TREE\bin\uic.exe'G.EOL||,
+'QMAKE_UIC3      = $$QT_BUILD_TREE\bin\uic3.exe'G.EOL||,
+'QMAKE_RCC       = $$QT_BUILD_TREE\bin\rcc.exe'G.EOL||,
+'QMAKE_INCDIR_QT = $$QT_BUILD_TREE\include'G.EOL||,
+'QMAKE_LIBDIR_QT = $$QT_BUILD_TREE\lib'G.EOL||G.EOL
+
+    if (G.QT_CFLAGS_PSQL \== "") then
+        call lineout qmake_cache_new, 'QT_CFLAGS_PSQL  = 'G.QT_CFLAGS_PSQL
+    if (G.QT_LFLAGS_PSQL \== "") then
+        call lineout qmake_cache_new, 'QT_LFLAGS_PSQL  = 'G.QT_LFLAGS_PSQL
+    if (G.QT_CFLAGS_MYSQL \== "") then
+        call lineout qmake_cache_new, 'QT_CFLAGS_MYSQL = 'G.QT_CFLAGS_MYSQL
+    if (G.QT_LFLAGS_MYSQL \== "") then
+        call lineout qmake_cache_new, 'QT_LFLAGS_MYSQL = 'G.QT_LFLAGS_MYSQL
+    if (G.QT_CFLAGS_SQLITE \== "") then
+        call lineout qmake_cache_new, 'QT_CFLAGS_SQLITE = 'G.QT_CFLAGS_SQLITE
+    if (G.QT_LFLAGS_SQLITE \== "") then
+        call lineout qmake_cache_new, 'QT_LFLAGS_SQLITE = 'G.QT_LFLAGS_SQLITE
+
+    if (G.QT_EDITION \== "QT_EDITION_OPENSOURCE") then
+        call charout qmake_cache_new, 'DEFINES *= QT_EDITION=QT_EDITION_DESKTOP'
+
+    /* dump in the OPENSSL_LIBS info */
+    OPENSSL_LIBS = GetEnv("OPENSSL_LIBS")
+    if (OPENSSL_LIBS \== "") then
+        call lineout qmake_cache_new, 'OPENSSL_LIBS = 'OPENSSL_LIBS
+    else if (G.CFG_OPENSSL == "linked") then
+        call lineout qmake_cache_new, 'OPENSSL_LIBS = -lssl -lcrypto'
+
+    /* dump the qmake spec */
+    if (DirExists(G.OutPath"\mkspecs\"G.XPLATFORM)) then
+       call lineout qmake_cache_new, 'QMAKESPEC = $$QT_BUILD_TREE\mkspecs\'G.XPLATFORM
+    else
+       call lineout qmake_cache_new, 'QMAKESPEC = 'G.XPLATFORM
+
+    /* cmdline args */
+    call charout qmake_cache_new, G.EOL||G.QMAKE_VARS
+
+    /* @todo process CFG_INCREMENTAL? */
+
+    /* close the file */
+    call lineout qmake_cache_new
+
+    /* replace .qmake.cache if it differs from the newly created temp file */
+    changed = \FileExists(qmake_cache)
+    if (\changed) then do
+        qmake_cache_str = charin(qmake_cache, 1, chars(qmake_cache))
+        call charout qmake_cache
+        changed = CompareFileToVar(qmake_cache_new, qmake_cache_str) \= 0
+    end
+    if (changed) then
+        call MoveFile qmake_cache_new, qmake_cache
+    else
+        call DeleteFile qmake_cache_new
+
+    /*--------------------------------------------------------------------------
+     give feedback on configuration
+    --------------------------------------------------------------------------*/
+
+    /* G++ is the only supported compiler on OS/2 so far */
+    if (G.CFG_EXCEPTIONS \== "no") then
+        call SaySay,,
+'        This target is using the GNU C++ compiler ('G.PLATFORM').'G.EOL||,
+''G.EOL||,
+'        Recent versions of this compiler automatically include code for'G.EOL||,
+'        exceptions, which increase both the size of the Qt libraries and'G.EOL||,
+'        the amount of memory taken by your applications.'G.EOL||,
+''G.EOL||,
+'        You may choose to re-run `'filespec('N', G.ScriptFile)'` with the -no-exceptions'G.EOL||,
+'        option to compile Qt without exceptions. This is completely binary'G.EOL||,
+'        compatible, and existing applications will continue to work.'G.EOL||G.EOL
+
+    if (G.XPLATFORM == G.PLATFORM) then
+        call SaySay "Build type:    "G.PLATFORM
+    else do
+        call SaySay "Building on:   "G.PLATFORM
+        call SaySay "Building for:  "G.XPLATFORM
+    end
+
+    call SaySay "Architecture:  "G.CFG_ARCH
+
+    if (G.OPT_VERBOSE == "yes") then do
+        call SaySay "qmake vars .......... "replace(G.QMAKE_VARS,G.EOL,' ')
+        call SaySay "qmake switches ...... "G.QMAKE_SWITCHES
+    end
+
+    /* @todo process CFG_INCREMENTAL? */
+
+    call SaySay "Build ............... "G.CFG_BUILD_PARTS
+    call SaySay "Configuration ....... "G.QMAKE_CONFIG G.QT_CONFIG
+    if (G.CFG_DEBUG_RELEASE == "yes") then do
+       call SaySay "Debug ............... yes (combined)"
+       if (G.CFG_DEBUG == "yes") then
+           call SaySay "Default Link ........ debug"
+       else
+           call SaySay "Default Link ........ release"
+    end
+    else
+       call SaySay "Debug ............... "G.CFG_DEBUG
+
+    call SaySay "Qt 3 compatibility .. "G.CFG_QT3SUPPORT
+/* @todo do we really need this?
+    [ "$CFG_DBUS" = "no" ]     && echo "QtDBus module ....... no"
+    [ "$CFG_DBUS" = "yes" ]    && echo "QtDBus module ....... yes (run-time)"
+    [ "$CFG_DBUS" = "linked" ] && echo "QtDBus module ....... yes (linked)"
+*/
+    call SaySay "QtScriptTools module  "G.CFG_SCRIPTTOOLS
+    call SaySay "QtXmlPatterns module  "G.CFG_XMLPATTERNS
+    call SaySay "Phonon module ....... "G.CFG_PHONON
+    call SaySay "SVG module .......... "G.CFG_SVG
+    call SaySay "WebKit module ....... "G.CFG_WEBKIT
+    call SaySay "STL support ......... "G.CFG_STL
+    call SaySay "PCH support ......... "G.CFG_PRECOMPILE
+/* @todo do we really need this?
+    call SaySay "MMX/3DNOW/SSE/SSE2..  "G.CFG_MMX}"/"G.CFG_3DNOW"/"G.CFG_SSE"/"G.CFG_SSE2
+*/
+    call SaySay "Graphics System ..... "G.CFG_GRAPHICS_SYSTEM
+    call SaySay "Accessibility ....... "G.CFG_ACCESSIBILITY
+/* @todo do we really need this?
+    call SaySay "IPv6 support ........ "G.CFG_IPV6
+    call SaySay "IPv6 ifname support . "G.CFG_IPV6IFNAME
+    call SaySay "getifaddrs support .. "G.CFG_GETIFADDRS
+    call SaySay "NIS support ......... "G.CFG_NIS
+    call SaySay "CUPS support ........ "G.CFG_CUPS
+    call SaySay "Iconv support ....... "G.CFG_ICONV
+    call SaySay "Glib support ........ "G.CFG_GLIB
+    call SaySay "GStreamer support ... "G.CFG_GSTREAMER
+*/
+    call SaySay "Large File support .. "G.CFG_LARGEFILE
+    call SaySay "GIF support ......... "G.CFG_GIF
+    if (G.CFG_TIFF == "no") then
+        call SaySay "TIFF support ........ "G.CFG_TIFF
+    else
+        call SaySay "TIFF support ........ "G.CFG_TIFF" ("G.CFG_LIBTIFF")"
+    if (G.CFG_JPEG == "no") then
+        call SaySay "JPEG support ........ "G.CFG_JPEG
+    else
+        call SaySay "JPEG support ........ "G.CFG_JPEG" ("G.CFG_LIBJPEG")"
+    if (G.CFG_PNG == "no") then
+        call SaySay "PNG support ......... "G.CFG_PNG
+    else
+        call SaySay "PNG support ......... "G.CFG_PNG" ("G.CFG_LIBPNG")"
+    if (G.CFG_MNG == "no") then
+        call SaySay "MNG support ......... "G.CFG_MNG
+    else
+        call SaySay "MNG support ......... "G.CFG_MNG" ("G.CFG_LIBMNG")"
+    call SaySay "zlib support ........ "G.CFG_ZLIB
+    call SaySay "Session management .. "G.CFG_SM
+
+    if (G.CFG_OPENGL == "desktop") then
+        call SaySay "OpenGL support ...... yes (Desktop OpenGL)"
+    else if (G.CFG_OPENGL == "es1") then
+        call SaySay "OpenGL support ...... yes (OpenGL ES 1.x Common profile)"
+    else if (G.CFG_OPENGL == "es1cl") then
+        call SaySay "OpenGL support ...... yes (OpenGL ES 1.x Common Lite profile)"
+    else if (G.CFG_OPENGL == "es2") then
+        call SaySay "OpenGL support ...... yes (OpenGL ES 2.x)"
+    else
+        call SaySay "OpenGL support ...... no"
+
+    if (G.CFG_SQL_mysql \== "no") then
+        call SaySay "MySQL support ....... "G.CFG_SQL_mysql
+    if (G.CFG_SQL_psql \== "no") then
+        call SaySay "PostgreSQL support .. "G.CFG_SQL_psql
+    if (G.CFG_SQL_odbc \== "no") then
+        call SaySay "ODBC support ........ "G.CFG_SQL_odbc
+    if (G.CFG_SQL_oci \== "no") then
+        call SaySay "OCI support ......... "G.CFG_SQL_oci
+    if (G.CFG_SQL_tds \== "no") then
+        call SaySay "TDS support ......... "G.CFG_SQL_tds
+    if (G.CFG_SQL_db2 \== "no") then
+        call SaySay "DB2 support ......... "G.CFG_SQL_db2
+    if (G.CFG_SQL_ibase \== "no") then
+        call SaySay "InterBase support ... "G.CFG_SQL_ibase
+    if (G.CFG_SQL_sqlite2 \== "no") then
+        call SaySay "SQLite 2 support .... "G.CFG_SQL_sqlite2
+    if (G.CFG_SQL_sqlite \== "no") then
+        call SaySay "SQLite support ...... "G.CFG_SQL_sqlite" ("G.CFG_SQLITE")"
+
+    OPENSSL_LINKAGE = ""
+    if (G.CFG_OPENSSL == "yes") then
+        OPENSSL_LINKAGE = "(run-time)"
+    else if (G.CFG_OPENSSL == "linked") then
+        OPENSSL_LINKAGE = "(linked)"
+    call SaySay "OpenSSL support ..... "G.CFG_OPENSSL OPENSSL_LINKAGE
+
+    if (G.CFG_PTMALLOC \== "no") then
+        call SaySay "Use ptmalloc ........ "G.CFG_PTMALLOC
+
+    /* complain about not being able to use dynamic plugins if we are using a static build */
+    if (G.CFG_SHARED == "no") then
+        call SaySay,,
+G.EOL||,
+"WARNING: Using static linking will disable the use of dynamically"G.EOL||,
+"loaded plugins. Make sure to import all needed static plugins,"G.EOL||,
+"or compile needed modules into the library."G.EOL||,
+G.EOL
+    if (G.CFG_OPENSSL == "linked" &  OPENSSL_LIBS == "") then
+        call SaySay,,
+G.EOL||,
+"NOTE: When linking against OpenSSL, you can override the default"G.EOL||,
+"library names through OPENSSL_LIBS."G.EOL||,
+"For example:"G.EOL||,
+"    configure -openssl-linked OPENSSL_LIBS='-L/path/to/lib -lssl -lcrypto'"G.EOL||,
+G.EOL
+
+    call SaySay
+
+    /*--------------------------------------------------------------------------
+     build makefiles based on the configuration
+    --------------------------------------------------------------------------*/
+
+    /* @todo walk through the source tree and call qmake on .pro files */
+
+    /*--------------------------------------------------------------------------
+     check for platforms that we don't yet know about
+    --------------------------------------------------------------------------*/
+    if (G.CFG_ARCH == "generic") then
+        call SaySay,,
+G.EOL||,
+'            NOTICE: Atomic operations are not yet supported for this'G.EOL||,
+'            architecture.'G.EOL||,
+G.EOL||,
+'            Qt will use the 'generic' architecture instead, which uses a'G.EOL||,
+'            single pthread_mutex_t to protect all atomic operations. This'G.EOL||,
+'            implementation is the slow (but safe) fallback implementation'G.EOL||,
+'            for architectures Qt does not yet support.'G.EOL||,
+G.EOL
+
+    /*--------------------------------------------------------------------------
+     finally save the executed command to another script
+    --------------------------------------------------------------------------*/
+
+    /* @todo save a call to configure.cmd with all options to a script called
+     * config.staus.cmd */
+
+    G.MAKE = filespec('N', G.MAKE)
+    call SaySay
+    call SaySay "Qt is now configured for building. Just run '"G.MAKE"'."
+    call SaySay
+    call SaySay "To reconfigure, run '"G.MAKE" confclean' and 'configure.cmd'."
+    call SaySay
+
     return
 
@@ -1159,6 +1739,5 @@
     end
 
-    call lineout G.QMAKE_VARS_FILE, aVarname eq aContents
-
+    G.QMAKE_VARS = G.QMAKE_VARS||aVarname eq aContents||G.EOL
     return
 
