Copyright (C) 2009  Mark Brand
                    Volker Grabsch
                    Martin Lambers

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

diff -urN a/configure b/configure
--- a/configure	2009-11-27 02:27:48.000000000 +0100
+++ b/configure	2009-12-04 10:30:44.000000000 +0100
@@ -591,7 +591,7 @@
 rm -f "$outpath/config.tests/.qmake.cache"
 cp "$QMAKE_VARS_FILE" "$outpath/config.tests/.qmake.cache"
 
-QMakeVar add styles "cde mac motif plastique cleanlooks windows"
+QMakeVar add styles "cde mac motif plastique cleanlooks windows windowsxp windowsvista"
 QMakeVar add decorations "default windows styled"
 QMakeVar add mouse-drivers "pc"
 if [ "$UNAME_SYSTEM" = "Linux" ] ; then
@@ -717,6 +717,7 @@
 CFG_3DNOW=auto
 CFG_SSE=auto
 CFG_SSE2=auto
+CFG_RTTI=auto
 CFG_REDUCE_RELOCATIONS=no
 CFG_IPV6=auto
 CFG_NAS=no
@@ -4424,7 +4425,10 @@
 #-------------------------------------------------------------------------------
 
 # detect availability of float math.h functions
-if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/floatmath "floatmath" $L_FLAGS $I_FLAGS $l_FLAGS; then
+if [ "$XPLATFORM" = "win32-g++" ]; then
+    echo "Using FLOATMATH for win32-g++ target"
+    CFG_USE_FLOATMATH=yes
+elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/floatmath "floatmath" $L_FLAGS $I_FLAGS $l_FLAGS; then
     CFG_USE_FLOATMATH=yes
 else
     CFG_USE_FLOATMATH=no
@@ -4432,7 +4436,10 @@
 
 # detect mmx support
 if [ "${CFG_MMX}" = "auto" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/mmx "mmx" $L_FLAGS $I_FLAGS $l_FLAGS "-mmmx"; then
+    if [ "$XPLATFORM" = "win32-g++" ]; then
+      echo "Using MMX for win32-g++ target"
+      CFG_MMX=yes
+    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/mmx "mmx" $L_FLAGS $I_FLAGS $l_FLAGS "-mmmx"; then
 	CFG_MMX=yes
     else
 	CFG_MMX=no
@@ -4441,7 +4448,10 @@
 
 # detect 3dnow support
 if [ "${CFG_3DNOW}" = "auto" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/3dnow "3dnow" $L_FLAGS $I_FLAGS $l_FLAGS "-m3dnow"; then
+    if [ "$XPLATFORM" = "win32-g++" ]; then
+        echo "Using SSE for win32-g++ target"
+        CFG_3DNOW=yes
+    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/3dnow "3dnow" $L_FLAGS $I_FLAGS $l_FLAGS "-m3dnow"; then
 	CFG_3DNOW=yes
     else
 	CFG_3DNOW=no
@@ -4450,7 +4460,10 @@
 
 # detect sse support
 if [ "${CFG_SSE}" = "auto" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sse "sse" $L_FLAGS $I_FLAGS $l_FLAGS "-msse"; then
+    if [ "$XPLATFORM" = "win32-g++" ]; then
+        echo "Using SSE for win32-g++ target"
+        CFG_SSE=yes
+    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sse "sse" $L_FLAGS $I_FLAGS $l_FLAGS "-msse"; then
 	CFG_SSE=yes
     else
 	CFG_SSE=no
@@ -4459,13 +4472,26 @@
 
 # detect sse2 support
 if [ "${CFG_SSE2}" = "auto" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sse2 "sse2" $L_FLAGS $I_FLAGS $l_FLAGS "-msse2"; then
+    if [ "$XPLATFORM" = "win32-g++" ]; then
+      echo "Using SSE2 for win32-g++ target"
+      CFG_SSE2=yes
+    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sse2 "sse2" $L_FLAGS $I_FLAGS $l_FLAGS "-msse2"; then
        CFG_SSE2=yes
     else
        CFG_SSE2=no
     fi
 fi
 
+# detect rtti support
+if [ "${CFG_RTTI}" = "auto" ]; then
+    if [ "$XPLATFORM" = "win32-g++" ]; then
+      echo "Using RTTI for win32-g++ target"
+      CFG_RTTI=yes
+    else
+      CFG_RTTI=no
+    fi
+fi
+
 # check iWMMXt support
 if [ "$CFG_IWMMXT" = "yes" ]; then
     "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/iwmmxt "iwmmxt" $L_FLAGS $I_FLAGS $l_FLAGS "-mcpu=iwmmxt"
@@ -4491,7 +4517,10 @@
     ZLIB_FORCED=yes
 fi
 if [ "$CFG_ZLIB" = "auto" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/zlib "zlib" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+    if [ "$XPLATFORM" = "win32-g++" ]; then
+       echo "We cannot test for system ZLIB since we are cross building for win32-g++, so we assume it is there."
+       CFG_ZLIB=system
+    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/zlib "zlib" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
        CFG_ZLIB=system
     else
        CFG_ZLIB=yes
@@ -4508,7 +4537,10 @@
 fi
 # detect jpeg
 if [ "$CFG_LIBJPEG" = "auto" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libjpeg "libjpeg" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+    if [ "$XPLATFORM" = "win32-g++" ]; then
+       echo "We cannot test for system LIBJPEG since we are cross building for win32-g++, so we assume it is there."
+       CFG_LIBJPEG=system
+    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libjpeg "libjpeg" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
        CFG_LIBJPEG=system
     else
        CFG_LIBJPEG=qt
@@ -4535,7 +4567,10 @@
 
 # detect tiff
 if [ "$CFG_LIBTIFF" = "auto" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libtiff "libtiff" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+    if [ "$XPLATFORM" = "win32-g++" ]; then
+        echo "We cannot test for system LIBTIFF since we are cross building for win32-g++, so we assume it is there."
+        CFG_LIBTIFF=system
+    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libtiff "libtiff" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
         CFG_LIBTIFF=system
     else
         CFG_LIBTIFF=qt
@@ -4552,7 +4587,10 @@
 fi
 # detect mng
 if [ "$CFG_LIBMNG" = "auto" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libmng "libmng" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+    if [ "$XPLATFORM" = "win32-g++" ]; then
+       echo "We cannot test for system LIBMNG since we are cross building for win32-g++, so we assume it is there."
+       CFG_LIBMNG=system
+    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libmng "libmng" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
        CFG_LIBMNG=system
     else
        CFG_LIBMNG=qt
@@ -4561,7 +4599,10 @@
 
 # detect png
 if [ "$CFG_LIBPNG" = "auto" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libpng "libpng" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+    if [ "$XPLATFORM" = "win32-g++" ]; then
+       echo "We cannot test for system LIBPNG since we are cross building for win32-g++, so we assume it is there."
+       CFG_LIBPNG=system
+    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libpng "libpng" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
        CFG_LIBPNG=system
     else
        CFG_LIBPNG=qt
@@ -4628,7 +4669,10 @@
             fi
             ;;
         psql)
-            if [ "$CFG_SQL_psql" != "no" ]; then
+            if [ "$XPLATFORM" = "win32-g++" ]; then
+                echo "We cannot test for PostgreSQL support since we are cross building for win32-g++, so we assume it is there."
+                CFG_SQL_psql=plugin
+            elif [ "$CFG_SQL_psql" != "no" ]; then
                 if "$WHICH" pg_config >/dev/null 2>&1; then
                     QT_CFLAGS_PSQL=`pg_config --includedir 2>/dev/null`
                     QT_LFLAGS_PSQL=`pg_config --libdir 2>/dev/null`
@@ -4656,7 +4700,10 @@
         ;;
         odbc)
             if [ "$CFG_SQL_odbc" != "no" ]; then
-                if [ "$PLATFORM_MAC" != "yes" ] && "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/odbc "ODBC" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+                if [ "$XPLATFORM" = "win32-g++" ]; then
+                    echo "We cannot test for ODBC support since we are cross building for win32-g++, so we assume it is there."
+                    CFG_SQL_odbc=plugin
+                elif [ "$PLATFORM_MAC" != "yes" ] && "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/odbc "ODBC" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
                     if [ "$CFG_SQL_odbc" = "auto" ]; then
                         CFG_SQL_odbc=plugin
                     fi
@@ -4701,7 +4748,12 @@
             ;;
         tds)
             if [ "$CFG_SQL_tds" != "no" ]; then
-                if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/tds "TDS" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+                if [ "$XPLATFORM" = "win32-g++" ]; then
+                    echo "We cannot test for TDS since we are cross building for win32-g++, so we assume it is there."
+                    if [ "CFG_SQL_tds" = "auto" ]; then
+                        CFG_SQL_tds=plugin
+                    fi
+                elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/tds "TDS" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
                     if [ "$CFG_SQL_tds" = "auto" ]; then
                         CFG_SQL_tds=plugin
                     fi
@@ -4783,7 +4835,13 @@
                         QT_CFLAGS_SQLITE=`$PKG_CONFIG --cflags sqlite3 2>/dev/null`
                         QT_LFLAGS_SQLITE=`$PKG_CONFIG --libs sqlite3 2>/dev/null`
                     fi
-                    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sqlite "SQLite" $QT_LFLAGS_SQLITE $L_FLAGS $QT_CFLAGS_SQLITE $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+                    if [ "$XPLATFORM" = "win32-g++" ]; then
+                        echo "We cannot test for system sqlite since we are cross building for win32-g++, so we assume it is there."
+                        if [ "$CFG_SQL_sqlite" = "auto" ]; then
+                            CFG_SQL_sqlite=plugin
+                        fi
+                        QMAKE_CONFIG="$QMAKE_CONFIG system-sqlite"
+                    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sqlite "SQLite" $QT_LFLAGS_SQLITE $L_FLAGS $QT_CFLAGS_SQLITE $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
                         if [ "$CFG_SQL_sqlite" = "auto" ]; then
                             CFG_SQL_sqlite=plugin
                         fi
@@ -4854,7 +4912,9 @@
 
 # auto-detect iconv(3) support
 if [ "$CFG_ICONV" != "no" ]; then
-    if [ "$PLATFORM_QWS" = "yes" ]; then
+    if [ "$XPLATFORM" = "win32-g++" ]; then
+        CFG_ICONV=no
+    elif [ "$PLATFORM_QWS" = "yes" ]; then
 	CFG_ICONV=no
     elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" "$OPT_VERBOSE" "$relpath" "$outpath" "config.tests/unix/iconv" "POSIX iconv" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
         CFG_ICONV=yes
@@ -5014,7 +5074,9 @@
         echo "Basic XLib functionality test failed!"
         echo " You might need to modify the include and library search paths by editing"
         echo " QMAKE_INCDIR_X11 and QMAKE_LIBDIR_X11 in ${XQMAKESPEC}."
-        exit 1
+echo NOTICE: This is a specially modifed configure script!
+echo For our purposes we do not want X11.
+#        exit 1
     fi
 
     # auto-detect OpenGL support (es1 = OpenGL ES 1.x Common, es1cl = ES 1.x common lite, es2 = OpenGL ES 2.x)
@@ -5088,7 +5150,9 @@
             echo " You might need to modify the include and library search paths by editing"
             echo " QMAKE_INCDIR_OPENGL, QMAKE_LIBDIR_OPENGL and QMAKE_LIBS_OPENGL in"
             echo " ${XQMAKESPEC}."
-            exit 1
+echo NOTICE: This is a specially modifed configure script!
+echo For our purposes we do not want the OpenGL functionality test.
+#            exit 1
         fi
         case "$PLATFORM" in
         hpux*)
@@ -5589,7 +5653,10 @@
 fi
 
 HAVE_STL=no
-if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/stl "STL" $L_FLAGS $I_FLAGS $l_FLAGS; then
+if [ "$XPLATFORM" = "win32-g++" ]; then
+    echo "Using STL for win32-g++ target"
+    HAVE_STL=yes
+elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/stl "STL" $L_FLAGS $I_FLAGS $l_FLAGS; then
     HAVE_STL=yes
 fi
 
@@ -5611,7 +5678,10 @@
 
 # find if the platform supports IPv6
 if [ "$CFG_IPV6" != "no" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/ipv6 "IPv6" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+    if [ "$XPLATFORM" = "win32-g++" ]; then
+        echo "Using IPV6 for win32-g++ target"
+        CFG_IPV6=yes
+    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/ipv6 "IPv6" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
         CFG_IPV6=yes
     else
         if [ "$CFG_IPV6" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
@@ -5725,7 +5795,10 @@
 
 # find if the platform supports X/Open Large File compilation environment
 if [ "$CFG_LARGEFILE" != "no" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/largefile "X/Open Large File" $L_FLAGS $I_FLAGS $l_FLAGS; then
+    if [ "$XPLATFORM" = "win32-g++" ]; then
+        echo "Using LARGEFILE for win32-g++ target"
+        CFG_LARGEFILE=yes
+    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/largefile "X/Open Large File" $L_FLAGS $I_FLAGS $l_FLAGS; then
         CFG_LARGEFILE=yes
     else
         if [ "$CFG_LARGEFILE" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
@@ -5742,7 +5815,9 @@
 
 # detect OpenSSL
 if [ "$CFG_OPENSSL" != "no" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/openssl "OpenSSL" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+    if [ "$XPLATFORM" = "win32-g++" ]; then
+        echo "We cannot test for system CFG_OPENSSL since we are cross building for win32-g++, so we assume it is there."
+    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/openssl "OpenSSL" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
         if [ "$CFG_OPENSSL" = "auto" ]; then
             CFG_OPENSSL=yes
         fi
@@ -6087,6 +6162,7 @@
 [ "$CFG_3DNOW" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG 3dnow"
 [ "$CFG_SSE" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG sse"
 [ "$CFG_SSE2" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG sse2"
+[ "$CFG_RTTI" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG rtti"
 [ "$CFG_IWMMXT" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG iwmmxt"
 [ "$PLATFORM_MAC" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG $CFG_MAC_ARCHS"
 if [ "$CFG_IPV6" = "yes" ]; then
@@ -6167,11 +6243,12 @@
     QT_CONFIG="$QT_CONFIG freetype"
 fi
 
-if [ "x$PLATFORM_MAC" = "xyes" ]; then
-    #On Mac we implicitly link against libz, so we
-    #never use the 3rdparty stuff.
-    [ "$CFG_ZLIB" = "yes" ] && CFG_ZLIB="system"
-fi
+# We're cross compiling, so we respect the user setting.
+#if [ "x$PLATFORM_MAC" = "xyes" ]; then
+#    #On Mac we implicitly link against libz, so we
+#    #never use the 3rdparty stuff.
+#    [ "$CFG_ZLIB" = "yes" ] && CFG_ZLIB="system"
+#fi
 if [ "$CFG_ZLIB" = "yes" ]; then
     QT_CONFIG="$QT_CONFIG zlib"
 elif [ "$CFG_ZLIB" = "system" ]; then
@@ -7102,7 +7179,7 @@
 
 cat >>"$QTCONFIG.tmp" <<EOF
 #configuration
-CONFIG += $QTCONFIG_CONFIG
+CONFIG += $QMAKE_CONFIG $QTCONFIG_CONFIG
 QT_ARCH = $CFG_ARCH
 QT_EDITION = $Edition
 QT_CONFIG += $QT_CONFIG
@@ -7194,7 +7271,7 @@
 if [ '!' -z "$OPENSSL_LIBS" ]; then
     echo "OPENSSL_LIBS = $OPENSSL_LIBS" >> "$CACHEFILE.tmp"
 elif [ "$CFG_OPENSSL" = "linked" ]; then
-    echo "OPENSSL_LIBS = -lssl -lcrypto" >> "$CACHEFILE.tmp"
+    echo "OPENSSL_LIBS = `$PKG_CONFIG --libs openssl`" >> "$CACHEFILE.tmp"
 fi
 
 #dump in the SDK info
@@ -7375,7 +7452,7 @@
 echo "Declarative module .. $CFG_DECLARATIVE"
 echo "STL support ......... $CFG_STL"
 echo "PCH support ......... $CFG_PRECOMPILE"
-echo "MMX/3DNOW/SSE/SSE2..  ${CFG_MMX}/${CFG_3DNOW}/${CFG_SSE}/${CFG_SSE2}"
+echo "MMX/3DNOW/SSE/SSE2/RTTI..  ${CFG_MMX}/${CFG_3DNOW}/${CFG_SSE}/${CFG_SSE2}/${CFG_RTTI}"
 if [ "${CFG_ARCH}" = "arm" ]; then
     echo "iWMMXt support ...... ${CFG_IWMMXT}"
 fi
@@ -7688,7 +7765,11 @@
         [ "$IN_ROOT" = "no" ] && continue
 
         case $a in
-        *winmain/winmain.pro) continue ;;
+        *winmain/winmain.pro)
+            case "$XPLATFORM" in
+            win32*) SPEC=$XQMAKESPEC ;;
+            *) continue ;;
+            esac ;;
         *s60main/s60main.pro) continue ;;
         *examples/activeqt/*) continue ;;
         */qmake/qmake.pro) continue ;;
diff -urN a/demos/spreadsheet/spreadsheet.pro b/demos/spreadsheet/spreadsheet.pro
--- a/demos/spreadsheet/spreadsheet.pro	2009-11-27 02:27:41.000000000 +0100
+++ b/demos/spreadsheet/spreadsheet.pro	2009-12-04 10:30:44.000000000 +0100
@@ -8,7 +8,7 @@
 INCLUDEPATH += .
 
 CONFIG += qt warn_on
-#unix:contains(QT_CONFIG, dbus):QT += dbus
+#unix:!win32:contains(QT_CONFIG, dbus):QT += dbus
 
 # Input
 HEADERS += printview.h spreadsheet.h spreadsheetdelegate.h spreadsheetitem.h
diff -urN a/doc/src/snippets/qmake/scopes.pro b/doc/src/snippets/qmake/scopes.pro
--- a/doc/src/snippets/qmake/scopes.pro	2009-11-27 02:27:44.000000000 +0100
+++ b/doc/src/snippets/qmake/scopes.pro	2009-12-04 10:30:44.000000000 +0100
@@ -17,7 +17,7 @@
 }
 #! [1]
 
-unix {
+unix:!win32 {
     SOURCES += paintwidget_unix.cpp
 }
 
diff -urN a/doc/src/snippets/qmake/spaces.pro b/doc/src/snippets/qmake/spaces.pro
--- a/doc/src/snippets/qmake/spaces.pro	2009-11-27 02:27:44.000000000 +0100
+++ b/doc/src/snippets/qmake/spaces.pro	2009-12-04 10:30:44.000000000 +0100
@@ -1,9 +1,9 @@
 #! [quoting library paths with spaces]
 win32:LIBS += $$quote(C:/mylibs/extra libs/extra.lib)
-unix:LIBS += $$quote(-L/home/user/extra libs) -lextra
+unix:!win32:LIBS += $$quote(-L/home/user/extra libs) -lextra
 #! [quoting library paths with spaces]
 
 #! [quoting include paths with spaces]
 win32:INCLUDEPATH += $$quote(C:/mylibs/extra headers)
-unix:INCLUDEPATH += $$quote(/home/user/extra headers)
+unix:!win32:INCLUDEPATH += $$quote(/home/user/extra headers)
 #! [quoting include paths with spaces]
diff -urN a/examples/itemviews/chart/chart.pro b/examples/itemviews/chart/chart.pro
--- a/examples/itemviews/chart/chart.pro	2009-11-27 02:27:48.000000000 +0100
+++ b/examples/itemviews/chart/chart.pro	2009-12-04 10:30:44.000000000 +0100
@@ -4,7 +4,7 @@
 SOURCES     = main.cpp \
               mainwindow.cpp \
               pieview.cpp
-unix:!mac:!symbian:!vxworks:LIBS+= -lm
+unix:!win32:!mac:!symbian:!vxworks:LIBS+= -lm
 
 TARGET.EPOCHEAPSIZE = 0x200000 0x800000
 
diff -urN a/examples/painting/painterpaths/painterpaths.pro b/examples/painting/painterpaths/painterpaths.pro
--- a/examples/painting/painterpaths/painterpaths.pro	2009-11-27 02:27:48.000000000 +0100
+++ b/examples/painting/painterpaths/painterpaths.pro	2009-12-04 10:30:44.000000000 +0100
@@ -3,7 +3,7 @@
 SOURCES       = main.cpp \
                 renderarea.cpp \
                 window.cpp
-unix:!mac:!symbian:!vxworks:LIBS += -lm
+unix:!win32:!mac:!symbian:!vxworks:LIBS += -lm
 
 # install
 target.path = $$[QT_INSTALL_EXAMPLES]/painting/painterpaths
diff -urN a/examples/threads/mandelbrot/mandelbrot.pro b/examples/threads/mandelbrot/mandelbrot.pro
--- a/examples/threads/mandelbrot/mandelbrot.pro	2009-11-27 02:27:48.000000000 +0100
+++ b/examples/threads/mandelbrot/mandelbrot.pro	2009-12-04 10:30:44.000000000 +0100
@@ -4,7 +4,7 @@
                 mandelbrotwidget.cpp \
                 renderthread.cpp
 
-unix:!mac:!symbian:!vxworks:LIBS += -lm
+unix:!win32:!mac:!symbian:!vxworks:LIBS += -lm
 
 # install
 target.path = $$[QT_INSTALL_EXAMPLES]/threads/mandelbrot
diff -urN a/lib/qjpeg.prl b/lib/qjpeg.prl
--- a/lib/qjpeg.prl	1970-01-01 01:00:00.000000000 +0100
+++ b/lib/qjpeg.prl	2009-12-04 10:30:44.000000000 +0100
@@ -0,0 +1 @@
+QMAKE_PRL_LIBS = -ljpeg
diff -urN a/lib/qmng.prl b/lib/qmng.prl
--- a/lib/qmng.prl	1970-01-01 01:00:00.000000000 +0100
+++ b/lib/qmng.prl	2009-12-04 10:30:44.000000000 +0100
@@ -0,0 +1 @@
+QMAKE_PRL_LIBS = -lmng
diff -urN a/lib/qsqlite.prl b/lib/qsqlite.prl
--- a/lib/qsqlite.prl	1970-01-01 01:00:00.000000000 +0100
+++ b/lib/qsqlite.prl	2009-12-04 10:30:44.000000000 +0100
@@ -0,0 +1 @@
+QMAKE_PRL_LIBS = -lsqlite3
diff -urN a/lib/qsqlodbc.prl b/lib/qsqlodbc.prl
--- a/lib/qsqlodbc.prl	1970-01-01 01:00:00.000000000 +0100
+++ b/lib/qsqlodbc.prl	2009-12-04 10:30:44.000000000 +0100
@@ -0,0 +1 @@
+QMAKE_PRL_LIBS = -lodbc32
diff -urN a/lib/qsqlpsql.prl b/lib/qsqlpsql.prl
--- a/lib/qsqlpsql.prl	1970-01-01 01:00:00.000000000 +0100
+++ b/lib/qsqlpsql.prl	2009-12-04 10:30:44.000000000 +0100
@@ -0,0 +1 @@
+QMAKE_PRL_LIBS = -lpq
diff -urN a/lib/qsqltds.prl b/lib/qsqltds.prl
--- a/lib/qsqltds.prl	1970-01-01 01:00:00.000000000 +0100
+++ b/lib/qsqltds.prl	2009-12-04 10:30:44.000000000 +0100
@@ -0,0 +1 @@
+QMAKE_PRL_LIBS = -lsybdb -liconv
diff -urN a/lib/qtiff.prl b/lib/qtiff.prl
--- a/lib/qtiff.prl	1970-01-01 01:00:00.000000000 +0100
+++ b/lib/qtiff.prl	2009-12-04 10:30:44.000000000 +0100
@@ -0,0 +1 @@
+QMAKE_PRL_LIBS = -ltiff
diff -urN a/mkspecs/win32-g++/qmake.conf b/mkspecs/win32-g++/qmake.conf
--- a/mkspecs/win32-g++/qmake.conf	2009-11-27 02:27:45.000000000 +0100
+++ b/mkspecs/win32-g++/qmake.conf	2009-12-04 10:30:44.000000000 +0100
@@ -3,23 +3,31 @@
 #
 # Written for MinGW
 #
+load(qt_config)
 
 MAKEFILE_GENERATOR	= MINGW
 TEMPLATE		= app
 CONFIG			+= qt warn_on release link_prl copy_dir_files debug_and_release debug_and_release_target precompile_header
+CONFIG			+= windows win32
+CONFIG			-= freetype
+QT_CONFIG		-= freetype
 QT			+= core gui
 DEFINES			+= UNICODE QT_LARGEFILE_SUPPORT
+DEFINES			-= QT_LARGEFILE_SUPPORT
+DEFINES			+= QT_TABLET QT_SESSIONMANAGER QT_NO_DIRECT3D QT_NO_CODECS
 QMAKE_COMPILER_DEFINES  += __GNUC__ WIN32
 
 QMAKE_EXT_OBJ           = .o
 QMAKE_EXT_RES           = _res.o
 
-QMAKE_CC		= gcc
+QMAKE_CC		= HOSTPLATFORMPREFIX-gcc
 QMAKE_LEX		= flex
 QMAKE_LEXFLAGS		=
 QMAKE_YACC		= byacc
 QMAKE_YACCFLAGS		= -d
 QMAKE_CFLAGS		=
+QMAKE_CFLAGS		+= -isystem HOSTPLATFORMINCLUDE
+QMAKE_CFLAGS		+= -pipe
 QMAKE_CFLAGS_DEPS	= -M
 QMAKE_CFLAGS_WARN_ON	= -Wall
 QMAKE_CFLAGS_WARN_OFF	= -w
@@ -27,7 +35,7 @@
 QMAKE_CFLAGS_DEBUG	= -g
 QMAKE_CFLAGS_YACC	= -Wno-unused -Wno-parentheses
 
-QMAKE_CXX		= g++
+QMAKE_CXX		= HOSTPLATFORMPREFIX-g++
 QMAKE_CXXFLAGS		= $$QMAKE_CFLAGS
 QMAKE_CXXFLAGS_DEPS	= $$QMAKE_CFLAGS_DEPS
 QMAKE_CXXFLAGS_WARN_ON	= $$QMAKE_CFLAGS_WARN_ON
@@ -42,6 +50,7 @@
 QMAKE_CXXFLAGS_EXCEPTIONS_OFF = -fno-exceptions
 
 QMAKE_INCDIR		=
+QMAKE_INCDIR		+= .
 QMAKE_INCDIR_QT		= $$[QT_INSTALL_HEADERS]
 QMAKE_LIBDIR_QT		= $$[QT_INSTALL_LIBS]
 
@@ -50,8 +59,8 @@
 QMAKE_RUN_CXX		= $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $obj $src
 QMAKE_RUN_CXX_IMP	= $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
 
-QMAKE_LINK		= g++
-QMAKE_LINK_C		= gcc
+QMAKE_LINK		= HOSTPLATFORMPREFIX-g++
+QMAKE_LINK_C		= HOSTPLATFORMPREFIX-gcc
 QMAKE_LFLAGS		= -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc
 QMAKE_LFLAGS_EXCEPTIONS_ON = -mthreads -Wl
 QMAKE_LFLAGS_EXCEPTIONS_OFF =
@@ -72,15 +81,18 @@
 QMAKE_LIBS_COMPAT       = -ladvapi32 -lshell32 -lcomdlg32 -luser32 -lgdi32 -lws2_32
 QMAKE_LIBS_QT_ENTRY     = -lmingw32 -lqtmain
 
+QMAKE_SH				= bash
+
 !isEmpty(QMAKE_SH) {
     MINGW_IN_SHELL      = 1
 	QMAKE_DIR_SEP		= /
 	QMAKE_COPY		= cp
-	QMAKE_COPY_DIR		= xcopy /s /q /y /i
+	QMAKE_COPY_DIR		= cp -r
 	QMAKE_MOVE		= mv
 	QMAKE_DEL_FILE		= rm
-	QMAKE_MKDIR		= mkdir
+	QMAKE_MKDIR		= mkdir -p
 	QMAKE_DEL_DIR		= rmdir
+	QMAKE_SYMBOLIC_LINK	= ln -s
     QMAKE_CHK_DIR_EXISTS = test -d
 } else {
 	QMAKE_COPY		= copy /y
@@ -92,15 +104,16 @@
     QMAKE_CHK_DIR_EXISTS	= if not exist
 }
 
-QMAKE_MOC		= $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc.exe
-QMAKE_UIC		= $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic.exe
-QMAKE_IDC		= $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc.exe
-
-QMAKE_IDL		= midl
-QMAKE_LIB		= ar -ru
-QMAKE_RC		= windres
+#QMAKE_IDC		= HOSTPLATFORMPREFIX-idc
+QMAKE_MOC		= HOSTPLATFORMPREFIX-moc
+QMAKE_RCC		= HOSTPLATFORMPREFIX-rcc
+QMAKE_UIC		= HOSTPLATFORMPREFIX-uic
+
+#QMAKE_IDL		= midl
+QMAKE_LIB		= HOSTPLATFORMPREFIX-ar -ru
+QMAKE_RC		= HOSTPLATFORMPREFIX-windres
 QMAKE_ZIP		= zip -r -9
 
-QMAKE_STRIP		= strip
+QMAKE_STRIP		= HOSTPLATFORMPREFIX-strip
 QMAKE_STRIPFLAGS_LIB 	+= --strip-unneeded
-load(qt_config)
+PKG_CONFIG		= HOSTPLATFORMPREFIX-pkg-config
diff -urN a/projects.pro b/projects.pro
--- a/projects.pro	2009-11-27 02:27:45.000000000 +0100
+++ b/projects.pro	2009-12-04 10:30:44.000000000 +0100
@@ -55,7 +55,7 @@
 
 !symbian: confclean.depends += clean
 confclean.commands =
-unix:!symbian {
+unix:!win32:!symbian {
   confclean.commands += (cd config.tests/unix/stl && $(MAKE) distclean); \
 			(cd config.tests/unix/endian && $(MAKE) distclean); \
 			(cd config.tests/unix/ipv6 && $(MAKE) distclean); \
diff -urN a/qmake/qmake.pri b/qmake/qmake.pri
--- a/qmake/qmake.pri	2009-11-27 02:27:48.000000000 +0100
+++ b/qmake/qmake.pri	2009-12-04 10:30:44.000000000 +0100
@@ -117,7 +117,7 @@
         qxmlstream.h \
         qxmlutils.h
 
-    unix {
+    unix:!win32 {
         SOURCES += qfsfileengine_unix.cpp qfsfileengine_iterator_unix.cpp
         mac {
           SOURCES += qcore_mac.cpp qsettings_mac.cpp
diff -urN a/src/3rdparty/javascriptcore/WebKit.pri b/src/3rdparty/javascriptcore/WebKit.pri
--- a/src/3rdparty/javascriptcore/WebKit.pri	2009-11-27 02:27:50.000000000 +0100
+++ b/src/3rdparty/javascriptcore/WebKit.pri	2009-12-04 10:30:44.000000000 +0100
@@ -31,7 +31,7 @@
     DEPENDPATH += $$PWD/WebKit/qt/Api
 }
 
-!mac:!unix|symbian {
+!mac:!unix|win32|symbian {
     DEFINES += USE_SYSTEM_MALLOC
 }
 
diff -urN a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro
--- a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro	2009-11-27 02:27:48.000000000 +0100
+++ b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro	2009-12-04 10:30:44.000000000 +0100
@@ -34,7 +34,7 @@
 
 CONFIG(release):!CONFIG(QTDIR_build) {
     contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols
-    unix:contains(QT_CONFIG, reduce_relocations):CONFIG += bsymbolic_functions
+    unix:!win32:contains(QT_CONFIG, reduce_relocations):CONFIG += bsymbolic_functions
 }
 
 linux-*: DEFINES += HAVE_STDINT_H
diff -urN a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro
--- a/src/3rdparty/webkit/WebCore/WebCore.pro	2009-11-27 02:27:50.000000000 +0100
+++ b/src/3rdparty/webkit/WebCore/WebCore.pro	2009-12-04 15:14:47.000000000 +0100
@@ -45,17 +45,17 @@
 
 GENERATED_SOURCES_DIR_SLASH = $$GENERATED_SOURCES_DIR${QMAKE_DIR_SEP}
 
-unix {
+unix:!win32 {
     QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtNetwork
     lessThan(QT_MINOR_VERSION, 4): QMAKE_PKGCONFIG_REQUIRES += QtXml
 }
 
-unix:!mac:*-g++*:QMAKE_CXXFLAGS += -ffunction-sections -fdata-sections 
-unix:!mac:*-g++*:QMAKE_LFLAGS += -Wl,--gc-sections
+unix:!win32:!mac:*-g++*:QMAKE_CXXFLAGS += -ffunction-sections -fdata-sections 
+unix:!win32:!mac:*-g++*:QMAKE_LFLAGS += -Wl,--gc-sections
 
 CONFIG(release):!CONFIG(QTDIR_build) {
     contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols
-    unix:contains(QT_CONFIG, reduce_relocations):CONFIG += bsymbolic_functions
+    unix:!win32:contains(QT_CONFIG, reduce_relocations):CONFIG += bsymbolic_functions
 }
 
 linux-*: DEFINES += HAVE_STDINT_H
@@ -2442,6 +2442,11 @@
         LIBS += -luser32
         LIBS += -lwinmm
     }
+    #I thought qmake would take care of these
+    win32-g++ {
+        LIBS += -lpthread
+        LIBS += -lws2_32
+    }
     wince*: LIBS += -lmmtimer
 
     # Files belonging to the Qt 4.3 build
@@ -2477,7 +2482,7 @@
 
     } else {
 
-        unix {
+        unix:!win32 {
     
             mac {
                 SOURCES += \
@@ -2755,7 +2760,7 @@
         xml/XPathVariableReference.cpp
 }
 
-unix:!mac:CONFIG += link_pkgconfig
+unix:!win32:!mac:CONFIG += link_pkgconfig
 
 contains(DEFINES, ENABLE_XSLT=1) {
     FEATURE_DEFINES_JAVASCRIPT += ENABLE_XSLT=1
@@ -3324,7 +3329,7 @@
 
     INSTALLS += target headers
 
-    unix {
+    unix:!win32 {
         CONFIG += create_pc create_prl
         QMAKE_PKGCONFIG_LIBDIR = $$target.path
         QMAKE_PKGCONFIG_INCDIR = $$headers.path
diff -urN a/src/corelib/arch/generic/arch.pri b/src/corelib/arch/generic/arch.pri
--- a/src/corelib/arch/generic/arch.pri	2009-11-27 02:27:54.000000000 +0100
+++ b/src/corelib/arch/generic/arch.pri	2009-12-04 10:30:44.000000000 +0100
@@ -2,5 +2,5 @@
 # 'generic' architecture
 #
 
-unix:SOURCES += qatomic_generic_unix.cpp
+unix:!win32:SOURCES += qatomic_generic_unix.cpp
 win32:SOURCES += qatomic_generic_windows.cpp
diff -urN a/src/corelib/codecs/codecs.pri b/src/corelib/codecs/codecs.pri
--- a/src/corelib/codecs/codecs.pri	2009-11-27 02:27:53.000000000 +0100
+++ b/src/corelib/codecs/codecs.pri	2009-12-04 10:30:44.000000000 +0100
@@ -19,7 +19,7 @@
 	codecs/qutfcodec.cpp \
 	codecs/qtextcodecplugin.cpp
 
-unix {
+unix:!win32 {
 	SOURCES += codecs/qfontlaocodec.cpp
 
         contains(QT_CONFIG,iconv) {
diff -urN a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri
--- a/src/corelib/kernel/kernel.pri	2009-11-27 02:27:54.000000000 +0100
+++ b/src/corelib/kernel/kernel.pri	2009-12-04 10:30:44.000000000 +0100
@@ -89,7 +89,7 @@
 		kernel/qcore_mac.cpp
 }
 
-unix:!symbian {
+unix:!win32:!symbian {
 	SOURCES += \
                 kernel/qcore_unix.cpp \
                 kernel/qcrashhandler.cpp \
diff -urN a/src/corelib/plugin/plugin.pri b/src/corelib/plugin/plugin.pri
--- a/src/corelib/plugin/plugin.pri	2009-11-27 02:27:54.000000000 +0100
+++ b/src/corelib/plugin/plugin.pri	2009-12-04 10:30:44.000000000 +0100
@@ -19,7 +19,7 @@
 	SOURCES += plugin/qlibrary_win.cpp
 }
 
-unix {
+unix:!win32 {
 	SOURCES += plugin/qlibrary_unix.cpp
 }
 
diff -urN a/src/corelib/thread/thread.pri b/src/corelib/thread/thread.pri
--- a/src/corelib/thread/thread.pri	2009-11-27 02:27:54.000000000 +0100
+++ b/src/corelib/thread/thread.pri	2009-12-04 10:30:44.000000000 +0100
@@ -24,7 +24,7 @@
  	   thread/qthread.cpp \
            thread/qthreadstorage.cpp 
 
-unix:SOURCES += thread/qmutex_unix.cpp \
+unix:!win32:SOURCES += thread/qmutex_unix.cpp \
                 thread/qthread_unix.cpp \
 		thread/qwaitcondition_unix.cpp
 
diff -urN a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri
--- a/src/corelib/tools/tools.pri	2009-11-27 02:27:54.000000000 +0100
+++ b/src/corelib/tools/tools.pri	2009-12-04 10:30:44.000000000 +0100
@@ -96,8 +96,8 @@
         ../3rdparty/zlib/uncompr.c \
         ../3rdparty/zlib/zutil.c
 } else:!contains(QT_CONFIG, no-zlib) {
-   unix:LIBS_PRIVATE += -lz
-#  win32:LIBS += libz.lib
+    unix|win32-g++:LIBS_PRIVATE += -lz
+    win32-msvc*|win32-icc:LIBS += zdll.lib
 }
 
 DEFINES += HB_EXPORT=Q_CORE_EXPORT
@@ -118,5 +118,5 @@
                ../3rdparty/md4
 
 # Note: libm should be present by default becaue this is C++
-!macx-icc:!vxworks:!symbian:unix:LIBS_PRIVATE += -lm
+!macx-icc:!vxworks:!symbian:!win32:unix:LIBS_PRIVATE += -lm
 
diff -urN a/src/gui/dialogs/dialogs.pri b/src/gui/dialogs/dialogs.pri
--- a/src/gui/dialogs/dialogs.pri	2009-11-27 02:27:52.000000000 +0100
+++ b/src/gui/dialogs/dialogs.pri	2009-12-04 10:30:44.000000000 +0100
@@ -46,7 +46,7 @@
     !win32-borland:!wince*: LIBS += -lshell32 	# the filedialog needs this library
 }
 
-!mac:!embedded:!symbian:unix {
+!mac:!embedded:!symbian:!win32:unix {
         HEADERS += dialogs/qpagesetupdialog_unix_p.h
 	SOURCES += dialogs/qprintdialog_unix.cpp \
 		   dialogs/qpagesetupdialog_unix.cpp
diff -urN a/src/gui/egl/egl.pri b/src/gui/egl/egl.pri
--- a/src/gui/egl/egl.pri	2009-11-27 02:27:53.000000000 +0100
+++ b/src/gui/egl/egl.pri	2009-12-04 10:30:44.000000000 +0100
@@ -10,7 +10,7 @@
 
 wince*: SOURCES += egl/qegl_wince.cpp
 
-unix {
+unix:!win32 {
     embedded {
         SOURCES += egl/qegl_qws.cpp
     } else {
diff -urN a/src/gui/gui.pro b/src/gui/gui.pro
--- a/src/gui/gui.pro	2009-11-27 02:27:53.000000000 +0100
+++ b/src/gui/gui.pro	2009-12-04 10:30:44.000000000 +0100
@@ -6,7 +6,7 @@
 
 !win32:!embedded:!mac:!symbian:CONFIG      += x11
 
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore
+unix:!win32:QMAKE_PKGCONFIG_REQUIRES = QtCore
 
 include(../qbase.pri)
 
diff -urN a/src/gui/image/image.pri b/src/gui/image/image.pri
--- a/src/gui/image/image.pri	2009-11-27 02:27:52.000000000 +0100
+++ b/src/gui/image/image.pri	2009-12-04 10:30:44.000000000 +0100
@@ -93,11 +93,11 @@
     SOURCES += image/qpnghandler.cpp
 
     contains(QT_CONFIG, system-png) {
-        unix:LIBS_PRIVATE  += -lpng
-        win32:LIBS += libpng.lib
+        unix|win32-g++:LIBS_PRIVATE  += -lpng
+        win32-msvc*|win32-icc:LIBS += libpng.lib
     } else {
         !isEqual(QT_ARCH, i386):!isEqual(QT_ARCH, x86_64):DEFINES += PNG_NO_ASSEMBLER_CODE
-        INCLUDEPATH  += ../3rdparty/libpng ../3rdparty/zlib
+        INCLUDEPATH += ../3rdparty/libpng
         SOURCES += ../3rdparty/libpng/png.c \
           ../3rdparty/libpng/pngerror.c \
           ../3rdparty/libpng/pngget.c \
@@ -114,6 +114,14 @@
           ../3rdparty/libpng/pngwtran.c \
           ../3rdparty/libpng/pngwutil.c \
           ../3rdparty/libpng/pnggccrd.c
+
+        contains(QT_CONFIG, system-zlib) {
+            unix|win32-g++:LIBS_PRIVATE += -lz
+            win32-msvc*|win32-icc:LIBS += zdll.lib
+        } else {
+            INCLUDEPATH  += ../3rdparty/zlib
+        }
+
     }
 } else {
     DEFINES *= QT_NO_IMAGEFORMAT_PNG
diff -urN a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri
--- a/src/gui/painting/painting.pri	2009-11-27 02:27:53.000000000 +0100
+++ b/src/gui/painting/painting.pri	2009-12-04 10:30:44.000000000 +0100
@@ -153,7 +153,7 @@
                 painting/qprintengine_mac.mm \
 }
 
-unix:!mac:!symbian {
+unix:!win32:!mac:!symbian {
         HEADERS += \
                 painting/qprinterinfo_unix_p.h
         SOURCES += \
@@ -380,9 +380,9 @@
 }
 
 contains(QT_CONFIG, zlib) {
-   INCLUDEPATH += ../3rdparty/zlib
+    INCLUDEPATH += ../3rdparty/zlib
 } else:!contains(QT_CONFIG, no-zlib) {
-   unix:LIBS_PRIVATE += -lz
-#  win32:LIBS += libz.lib
+    unix|win32-g++:LIBS_PRIVATE += -lz
+    win32-msvc*|win32-icc:LIBS += zdll.lib
 }
 
diff -urN a/src/multimedia/multimedia.pro b/src/multimedia/multimedia.pro
--- a/src/multimedia/multimedia.pro	2009-11-27 02:27:54.000000000 +0100
+++ b/src/multimedia/multimedia.pro	2009-12-04 10:30:44.000000000 +0100
@@ -4,7 +4,7 @@
 
 DEFINES += QT_BUILD_MULTIMEDIA_LIB QT_NO_USING_NAMESPACE
 
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui
+unix:!win32:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui
 
 include(../qbase.pri)
 
diff -urN a/src/network/access/access.pri b/src/network/access/access.pri
--- a/src/network/access/access.pri	2009-11-27 02:27:53.000000000 +0100
+++ b/src/network/access/access.pri	2009-12-04 10:30:44.000000000 +0100
@@ -57,8 +57,8 @@
 
 #zlib support
 contains(QT_CONFIG, zlib) {
-   INCLUDEPATH += ../3rdparty/zlib
+    INCLUDEPATH += ../3rdparty/zlib
 } else:!contains(QT_CONFIG, no-zlib) {
-   unix:LIBS_PRIVATE += -lz
-#  win32:LIBS += libz.lib
+    unix|win32-g++:LIBS_PRIVATE += -lz
+    win32-msvc*|win32-icc:LIBS += zdll.lib
 }
diff -urN a/src/network/kernel/kernel.pri b/src/network/kernel/kernel.pri
--- a/src/network/kernel/kernel.pri	2009-11-27 02:27:53.000000000 +0100
+++ b/src/network/kernel/kernel.pri	2009-12-04 10:30:44.000000000 +0100
@@ -21,7 +21,7 @@
 	   kernel/qnetworkinterface.cpp
 
 symbian: SOURCES += kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_symbian.cpp
-unix:!symbian:SOURCES += kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_unix.cpp
+unix:!win32:!symbian:SOURCES += kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_unix.cpp
 win32:SOURCES += kernel/qhostinfo_win.cpp kernel/qnetworkinterface_win.cpp
 
 mac:LIBS_PRIVATE += -framework SystemConfiguration -framework CoreFoundation
diff -urN a/src/network/network.pro b/src/network/network.pro
--- a/src/network/network.pro	2009-11-27 02:27:53.000000000 +0100
+++ b/src/network/network.pro	2009-12-04 10:30:44.000000000 +0100
@@ -13,7 +13,7 @@
 QT = core
 win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x64000000
 
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore
+unix:!win32:QMAKE_PKGCONFIG_REQUIRES = QtCore
 
 include(../qbase.pri)
 include(access/access.pri)
diff -urN a/src/network/socket/socket.pri b/src/network/socket/socket.pri
--- a/src/network/socket/socket.pri	2009-11-27 02:27:53.000000000 +0100
+++ b/src/network/socket/socket.pri	2009-12-04 10:30:44.000000000 +0100
@@ -25,10 +25,10 @@
            socket/qlocalsocket.cpp \
            socket/qlocalserver.cpp
 
-unix:SOURCES += socket/qnativesocketengine_unix.cpp \
+unix:!win32:SOURCES += socket/qnativesocketengine_unix.cpp \
                 socket/qlocalsocket_unix.cpp \
                 socket/qlocalserver_unix.cpp
-unix:HEADERS += \
+unix:!win32:HEADERS += \
                 socket/qnet_unix_p.h
 
 win32:SOURCES += socket/qnativesocketengine_win.cpp \
diff -urN a/src/opengl/opengl.pro b/src/opengl/opengl.pro
--- a/src/opengl/opengl.pro	2009-11-27 02:27:52.000000000 +0100
+++ b/src/opengl/opengl.pro	2009-12-04 12:32:50.000000000 +0100
@@ -6,7 +6,7 @@
 win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x63000000
 solaris-cc*:QMAKE_CXXFLAGS_RELEASE -= -O2
 
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui
+unix:!win32:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui
 
 include(../qbase.pri)
 
@@ -17,6 +17,9 @@
 contains(QT_CONFIG, opengles2):CONFIG += opengles2
 contains(QT_CONFIG, egl):CONFIG += egl
 
+#Thought qmake was supposed to do this.
+LIBS += $$QMAKE_LIBS_OPENGL
+
 HEADERS += qgl.h \
 	   qgl_p.h \
 	   qglcolormap.h \
diff -urN a/src/openvg/openvg.pro b/src/openvg/openvg.pro
--- a/src/openvg/openvg.pro	2009-11-27 02:27:53.000000000 +0100
+++ b/src/openvg/openvg.pro	2009-12-04 10:30:44.000000000 +0100
@@ -33,7 +33,7 @@
 
 include(../qbase.pri)
 
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui
+unix:!win32:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui
 
 !isEmpty(QMAKE_INCDIR_OPENVG): INCLUDEPATH += $$QMAKE_INCDIR_OPENVG
 !isEmpty(QMAKE_LIBDIR_OPENVG): LIBS_PRIVATE += -L$$QMAKE_LIBDIR_OPENVG
diff -urN a/src/phonon/phonon.pro b/src/phonon/phonon.pro
--- a/src/phonon/phonon.pro	2009-11-27 02:27:52.000000000 +0100
+++ b/src/phonon/phonon.pro	2009-12-04 10:30:44.000000000 +0100
@@ -11,7 +11,7 @@
 
 PHONON_DIR = $$QT_SOURCE_TREE/src/3rdparty/phonon/phonon
 
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtNetwork
+unix:!win32:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtNetwork
 
 # Input
 HEADERS += $$PHONON_DIR/abstractaudiooutput.h \
@@ -107,7 +107,7 @@
        QT      += dbus
        HEADERS += $$PHONON_DIR/audiooutputadaptor_p.h
        SOURCES += $$PHONON_DIR/audiooutputadaptor.cpp
-       unix:QMAKE_PKGCONFIG_REQUIRES += QtDBus
+       unix:!win32:QMAKE_PKGCONFIG_REQUIRES += QtDBus
 } else {
        DEFINES += QT_NO_DBUS
 }
diff -urN a/src/plugins/codecs/jp/jp.pro b/src/plugins/codecs/jp/jp.pro
--- a/src/plugins/codecs/jp/jp.pro	2009-11-27 02:27:53.000000000 +0100
+++ b/src/plugins/codecs/jp/jp.pro	2009-12-04 10:30:44.000000000 +0100
@@ -16,7 +16,7 @@
 		  qjpunicode.cpp \
 		  main.cpp
 
-unix {
+unix:!win32 {
 	HEADERS += qfontjpcodec.h
 	SOURCES += qfontjpcodec.cpp
 }
diff -urN a/src/plugins/imageformats/jpeg/jpeg.pro b/src/plugins/imageformats/jpeg/jpeg.pro
--- a/src/plugins/imageformats/jpeg/jpeg.pro	2009-11-27 02:27:53.000000000 +0100
+++ b/src/plugins/imageformats/jpeg/jpeg.pro	2009-12-04 10:30:44.000000000 +0100
@@ -20,8 +20,8 @@
 }
 
 contains(QT_CONFIG, system-jpeg) {
-        unix:LIBS += -ljpeg
-        win32:LIBS += libjpeg.lib
+        unix|win32-g++:LIBS += -ljpeg
+        win32-msvc*|win32-icc:LIBS += libjpeg.lib
 }
 !contains(QT_CONFIG, system-jpeg) {
 	INCLUDEPATH += ../../../3rdparty/libjpeg
diff -urN a/src/plugins/imageformats/mng/mng.pro b/src/plugins/imageformats/mng/mng.pro
--- a/src/plugins/imageformats/mng/mng.pro	2009-11-27 02:27:53.000000000 +0100
+++ b/src/plugins/imageformats/mng/mng.pro	2009-12-04 13:53:53.000000000 +0100
@@ -14,10 +14,9 @@
 }
 
 contains(QT_CONFIG, system-mng) {
-        unix:LIBS += -lmng
-        win32:LIBS += libmng.lib
-}
-!contains(QT_CONFIG, system-mng) {
+        unix|win32-g++:LIBS += -lmng
+        win32-msvc*|win32-icc:LIBS += libmng.lib
+} else {
         DEFINES += MNG_BUILD_SO
         DEFINES += MNG_NO_INCLUDE_JNG
 	INCLUDEPATH += ../../../3rdparty/libmng
@@ -43,11 +42,16 @@
             ../../../3rdparty/libmng/libmng_zlib.c
 }
 
-contains(QT_CONFIG, system-zlib) {
-        LIBS += -lz
+contains(QT_CONFIG, system-jpeg) {
+    unix|win32-g++:LIBS_PRIVATE += -ljpeg
+    win32-msvc*|win32-icc:LIBS += libjpeg.lib
 }
-!contains(QT_CONFIG, system-zlib) {
-        INCLUDEPATH +=  ../../../3rdparty/zlib
+
+contains(QT_CONFIG, system-zlib) {
+    unix|win32-g++:LIBS_PRIVATE += -lz
+    win32-msvc*|win32-icc:LIBS += zdll.lib
+} else {
+    INCLUDEPATH +=  ../../../3rdparty/zlib
 }
 
 QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/imageformats
diff -urN a/src/plugins/imageformats/tiff/tiff.pro b/src/plugins/imageformats/tiff/tiff.pro
--- a/src/plugins/imageformats/tiff/tiff.pro	2009-11-27 02:27:53.000000000 +0100
+++ b/src/plugins/imageformats/tiff/tiff.pro	2009-12-04 15:23:34.000000000 +0100
@@ -8,10 +8,9 @@
            qtiffhandler.cpp
 
 contains(QT_CONFIG, system-tiff) {
-        unix:LIBS += -ltiff
-        win32:LIBS += libtiff.lib
-}
-!contains(QT_CONFIG, system-tiff) {
+        unix|win32-g++:LIBS += -ltiff
+        win32-msvc*|win32-icc:LIBS += libtiff.lib
+} else {
 	INCLUDEPATH += ../../../3rdparty/libtiff/libtiff
 	SOURCES  += \
 	    ../../../3rdparty/libtiff/libtiff/tif_aux.c \
@@ -50,7 +49,7 @@
 	    win32 {
 	       SOURCES += ../../../3rdparty/libtiff/libtiff/tif_win32.c
 	    }
-            unix: {
+            unix:!win32: {
 	       SOURCES += ../../../3rdparty/libtiff/libtiff/tif_unix.c
             }
             wince*: {
@@ -61,11 +60,18 @@
             }
 }
 
-contains(QT_CONFIG, system-zlib) {
-        LIBS += -lz
+contains(QT_CONFIG, system-jpeg) {
+    unix|win32-g++:LIBS_PRIVATE += -ljpeg
+    win32-msvc*|win32-icc:LIBS += libjpeg.lib
+} else {
+    INCLUDEPATH +=  ../../../3rdparty/zlib
 }
-!contains(QT_CONFIG, system-zlib) {
-        INCLUDEPATH +=  ../../../3rdparty/zlib
+
+contains(QT_CONFIG, system-zlib) {
+    unix|win32-g++:LIBS_PRIVATE += -lz
+    win32-msvc*|win32-icc:LIBS += zdll.lib
+} else {
+    INCLUDEPATH +=  ../../../3rdparty/zlib
 }
 
 QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/imageformats
diff -urN a/src/plugins/phonon/phonon.pro b/src/plugins/phonon/phonon.pro
--- a/src/plugins/phonon/phonon.pro	2009-11-27 02:27:53.000000000 +0100
+++ b/src/plugins/phonon/phonon.pro	2009-12-04 10:30:44.000000000 +0100
@@ -2,7 +2,7 @@
 
 SUBDIRS =
 
-unix:contains(QT_CONFIG, gstreamer): SUBDIRS *= gstreamer
+unix:!win32:contains(QT_CONFIG, gstreamer): SUBDIRS *= gstreamer
 mac:contains(QT_CONFIG, phonon-backend): SUBDIRS *= qt7
 win32:!wince*:contains(QT_CONFIG, phonon-backend): SUBDIRS *= ds9
 wince*:contains(QT_CONFIG, phonon-backend): SUBDIRS *= waveout
diff -urN a/src/plugins/plugins.pro b/src/plugins/plugins.pro
--- a/src/plugins/plugins.pro	2009-11-27 02:27:53.000000000 +0100
+++ b/src/plugins/plugins.pro	2009-12-04 10:30:44.000000000 +0100
@@ -1,7 +1,7 @@
 TEMPLATE = subdirs
 
 SUBDIRS	*= accessible imageformats sqldrivers iconengines script
-unix:!symbian {
+unix:!win32:!symbian {
         contains(QT_CONFIG,iconv)|contains(QT_CONFIG,gnu-libiconv):SUBDIRS *= codecs
 } else {
         SUBDIRS *= codecs
diff -urN a/src/plugins/sqldrivers/db2/db2.pro b/src/plugins/sqldrivers/db2/db2.pro
--- a/src/plugins/sqldrivers/db2/db2.pro	2009-11-27 02:27:53.000000000 +0100
+++ b/src/plugins/sqldrivers/db2/db2.pro	2009-12-04 10:30:44.000000000 +0100
@@ -4,7 +4,7 @@
 SOURCES		= main.cpp \
 		  ../../../sql/drivers/db2/qsql_db2.cpp
 
-unix:!contains( LIBS, .*db2.* ):LIBS 	*= -ldb2
+unix:!win32:!contains( LIBS, .*db2.* ):LIBS 	*= -ldb2
 win32:!contains( LIBS, .*db2.* ):LIBS   *= -ldb2cli
 
 include(../qsqldriverbase.pri)
diff -urN a/src/plugins/sqldrivers/ibase/ibase.pro b/src/plugins/sqldrivers/ibase/ibase.pro
--- a/src/plugins/sqldrivers/ibase/ibase.pro	2009-11-27 02:27:53.000000000 +0100
+++ b/src/plugins/sqldrivers/ibase/ibase.pro	2009-12-04 10:30:44.000000000 +0100
@@ -4,9 +4,9 @@
 SOURCES		= main.cpp \
 		  ../../../sql/drivers/ibase/qsql_ibase.cpp
 
-unix:!contains( LIBS, .*gds.* ):!contains( LIBS, .*libfb.* ):LIBS    *= -lgds
+unix:!win32:!contains( LIBS, .*gds.* ):!contains( LIBS, .*libfb.* ):LIBS    *= -lgds
 
-win32:!contains( LIBS, .*gds.* ):!contains( LIBS, .*fbclient.* ) {
+!unix:win32:!contains( LIBS, .*gds.* ):!contains( LIBS, .*fbclient.* ) {
 	!win32-borland:LIBS *= -lgds32_ms
 	win32-borland:LIBS  += gds32.lib
 }
diff -urN a/src/plugins/sqldrivers/mysql/mysql.pro b/src/plugins/sqldrivers/mysql/mysql.pro
--- a/src/plugins/sqldrivers/mysql/mysql.pro	2009-11-27 02:27:53.000000000 +0100
+++ b/src/plugins/sqldrivers/mysql/mysql.pro	2009-12-04 10:30:44.000000000 +0100
@@ -4,7 +4,7 @@
 SOURCES		= main.cpp \
 		  ../../../sql/drivers/mysql/qsql_mysql.cpp
 
-unix: {
+unix:!win32: {
     isEmpty(QT_LFLAGS_MYSQL) {
         !contains(LIBS, .*mysqlclient.*):!contains(LIBS, .*mysqld.*) {
             use_libmysqlclient_r:LIBS *= -lmysqlclient_r
diff -urN a/src/plugins/sqldrivers/oci/oci.pro b/src/plugins/sqldrivers/oci/oci.pro
--- a/src/plugins/sqldrivers/oci/oci.pro	2009-11-27 02:27:53.000000000 +0100
+++ b/src/plugins/sqldrivers/oci/oci.pro	2009-12-04 10:30:44.000000000 +0100
@@ -6,7 +6,7 @@
 
 win32:LIBS	*= -loci
 
-unix:!contains( LIBS, .*clnts.* ):LIBS	*= -lclntsh
+unix:!win32:!contains( LIBS, .*clnts.* ):LIBS	*= -lclntsh
 
 macx:QMAKE_LFLAGS += -Wl,-flat_namespace,-U,_environ
 
diff -urN a/src/plugins/sqldrivers/odbc/odbc.pro b/src/plugins/sqldrivers/odbc/odbc.pro
--- a/src/plugins/sqldrivers/odbc/odbc.pro	2009-11-27 02:27:53.000000000 +0100
+++ b/src/plugins/sqldrivers/odbc/odbc.pro	2009-12-04 10:30:44.000000000 +0100
@@ -4,7 +4,7 @@
 SOURCES		= main.cpp \
 		  ../../../sql/drivers/odbc/qsql_odbc.cpp
 
-unix {
+unix:!win32 {
 	!contains( LIBS, .*odbc.* ) {
 	    LIBS 	*= $$QT_LFLAGS_ODBC
 	}
diff -urN a/src/plugins/sqldrivers/psql/psql.pro b/src/plugins/sqldrivers/psql/psql.pro
--- a/src/plugins/sqldrivers/psql/psql.pro	2009-11-27 02:27:53.000000000 +0100
+++ b/src/plugins/sqldrivers/psql/psql.pro	2009-12-04 10:30:44.000000000 +0100
@@ -4,7 +4,7 @@
 SOURCES		= main.cpp \
 		  ../../../sql/drivers/psql/qsql_psql.cpp
 
-unix: {
+unix:!win32: {
     !isEmpty(QT_LFLAGS_PSQL) {
         LIBS *= $$QT_LFLAGS_PSQL
         QMAKE_CXXFLAGS *= $$QT_CFLAGS_PSQL
diff -urN a/src/plugins/sqldrivers/tds/main.cpp b/src/plugins/sqldrivers/tds/main.cpp
--- a/src/plugins/sqldrivers/tds/main.cpp	2009-11-27 02:27:53.000000000 +0100
+++ b/src/plugins/sqldrivers/tds/main.cpp	2009-12-04 10:30:44.000000000 +0100
@@ -47,6 +47,7 @@
 #define _WINSCARD_H_
 #include <windows.h>
 #endif
+#define Q_USE_SYBASE
 #include "../../../sql/drivers/tds/qsql_tds.h"
 
 QT_BEGIN_NAMESPACE
diff -urN a/src/plugins/sqldrivers/tds/tds.pro b/src/plugins/sqldrivers/tds/tds.pro
--- a/src/plugins/sqldrivers/tds/tds.pro	2009-11-27 02:27:53.000000000 +0100
+++ b/src/plugins/sqldrivers/tds/tds.pro	2009-12-04 10:30:44.000000000 +0100
@@ -5,11 +5,6 @@
 SOURCES		= main.cpp \
 		  ../../../sql/drivers/tds/qsql_tds.cpp
 
-unix:!contains( LIBS, .*sybdb.* ):LIBS 	*= -lsybdb
-
-win32 {
-    !win32-borland:LIBS *= -lNTWDBLIB
-    win32-borland:LIBS 	*= $(BCB)/lib/PSDK/NTWDBLIB.LIB
-}
-
+#Patched to use FreeTDS targetting MinGW
+LIBS *=  -lsybdb -liconv -lws2_32
 include(../qsqldriverbase.pri)
diff -urN a/src/qbase.pri b/src/qbase.pri
--- a/src/qbase.pri	2009-11-27 02:27:54.000000000 +0100
+++ b/src/qbase.pri	2009-12-04 10:30:44.000000000 +0100
@@ -39,7 +39,7 @@
 linux-g++*:QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
 
 contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols
-unix:contains(QT_CONFIG, reduce_relocations):CONFIG += bsymbolic_functions
+unix:!win32:contains(QT_CONFIG, reduce_relocations):CONFIG += bsymbolic_functions
 contains(QT_CONFIG, largefile):CONFIG += largefile
 
 #mac frameworks
@@ -85,7 +85,6 @@
 }
 
 win32 {
-    CONFIG += zlib
     INCLUDEPATH += tmp
     !static: DEFINES+=QT_MAKEDLL
 }
@@ -144,7 +143,7 @@
 #install directives
 include(qt_install.pri)
 
-unix:!symbian {
+unix:!win32:!symbian {
    CONFIG     += create_libtool create_pc explicitlib
    QMAKE_LIBTOOL_LIBDIR = $$[QT_INSTALL_LIBS]
    QMAKE_PRL_LIBDIR = $$[QT_INSTALL_LIBS]
diff -urN a/src/qt3support/network/network.pri b/src/qt3support/network/network.pri
--- a/src/qt3support/network/network.pri	2009-11-27 02:27:54.000000000 +0100
+++ b/src/qt3support/network/network.pri	2009-12-04 10:30:44.000000000 +0100
@@ -25,6 +25,6 @@
 		network/q3urloperator.cpp
 
 win32:SOURCES +=  network/q3socketdevice_win.cpp
-unix:SOURCES += network/q3socketdevice_unix.cpp
+unix:!win32:SOURCES += network/q3socketdevice_unix.cpp
 mac:LIBS_PRIVATE += -lresolv
 
diff -urN a/src/qt3support/other/other.pri b/src/qt3support/other/other.pri
--- a/src/qt3support/other/other.pri	2009-11-27 02:27:54.000000000 +0100
+++ b/src/qt3support/other/other.pri	2009-12-04 10:30:44.000000000 +0100
@@ -18,7 +18,7 @@
 		other/q3process.cpp \
 		other/q3membuf.cpp
 
-unix:SOURCES += other/q3process_unix.cpp
+unix:!win32:SOURCES += other/q3process_unix.cpp
 win32:SOURCES+= other/q3process_win.cpp
 
 
diff -urN a/src/qt3support/qt3support.pro b/src/qt3support/qt3support.pro
--- a/src/qt3support/qt3support.pro	2009-11-27 02:27:54.000000000 +0100
+++ b/src/qt3support/qt3support.pro	2009-12-04 10:30:44.000000000 +0100
@@ -21,7 +21,7 @@
 include(network/network.pri)
 include(painting/painting.pri)
 
-unix {
+unix:!win32 {
    QMAKE_PKGCONFIG_CFLAGS += -DQT3_SUPPORT
    QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtNetwork QtSql
 }
diff -urN a/src/script/script.pro b/src/script/script.pro
--- a/src/script/script.pro	2009-11-27 02:27:52.000000000 +0100
+++ b/src/script/script.pro	2009-12-04 10:30:44.000000000 +0100
@@ -7,7 +7,7 @@
 DEFINES   += QLALR_NO_QSCRIPTGRAMMAR_DEBUG_INFO
 #win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x66000000       ### FIXME
 
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore
+unix:!win32:QMAKE_PKGCONFIG_REQUIRES = QtCore
 
 include(../qbase.pri)
 
diff -urN a/src/scripttools/scripttools.pro b/src/scripttools/scripttools.pro
--- a/src/scripttools/scripttools.pro	2009-11-27 02:27:54.000000000 +0100
+++ b/src/scripttools/scripttools.pro	2009-12-04 10:30:44.000000000 +0100
@@ -5,7 +5,7 @@
 DEFINES   += QT_NO_USING_NAMESPACE
 #win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x66000000
 
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtScript
+unix:!win32:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtScript
 
 include(../qbase.pri)
 
diff -urN a/src/sql/drivers/drivers.pri b/src/sql/drivers/drivers.pri
--- a/src/sql/drivers/drivers.pri	2009-11-27 02:27:52.000000000 +0100
+++ b/src/sql/drivers/drivers.pri	2009-12-04 10:30:44.000000000 +0100
@@ -6,7 +6,7 @@
     HEADERS +=      drivers/psql/qsql_psql.h
     SOURCES +=      drivers/psql/qsql_psql.cpp
 
-    unix {
+    unix:!win32 {
         !isEmpty(QT_LFLAGS_PSQL) {
             LIBS *= $$QT_LFLAGS_PSQL
             QMAKE_CXXFLAGS *= $$QT_CFLAGS_PSQL
@@ -25,7 +25,7 @@
     HEADERS +=      drivers/mysql/qsql_mysql.h
     SOURCES +=      drivers/mysql/qsql_mysql.cpp
 
-    unix {
+    unix:!win32 {
         isEmpty(QT_LFLAGS_MYSQL) {
             !contains(LIBS, .*mysqlclient.*):!contains(LIBS, .*mysqld.*) {
                 use_libmysqlclient_r:LIBS *= -lmysqlclient_r
@@ -48,7 +48,7 @@
      SOURCES += drivers/odbc/qsql_odbc.cpp
 
      mac:!contains( LIBS, .*odbc.* ):LIBS        *= -liodbc
-     unix:!contains( LIBS, .*odbc.* ):LIBS       *= -lodbc
+     unix:!win32:!contains( LIBS, .*odbc.* ):LIBS       *= -lodbc
 
      win32 {
          !win32-borland:LIBS     *= -lodbc32
@@ -60,7 +60,7 @@
     HEADERS += drivers/oci/qsql_oci.h
     SOURCES += drivers/oci/qsql_oci.cpp
 
-    unix:!contains( LIBS, .*clnts.* ):LIBS += -lclntsh
+    unix:!win32:!contains( LIBS, .*clnts.* ):LIBS += -lclntsh
 
     win32:LIBS += -loci
 }
@@ -71,7 +71,7 @@
 
     unix:LIBS += -L$SYBASE/lib -lsybdb
 
-    win32 {
+    win32:!unix {
         !win32-borland:LIBS += -lNTWDBLIB
         win32-borland:LIBS += $(BCB)/lib/PSDK/NTWDBLIB.LIB
     }
@@ -81,7 +81,7 @@
     HEADERS += drivers/db2/qsql_db2.h
     SOURCES += drivers/db2/qsql_db2.cpp
     
-    unix:LIBS += -ldb2
+    unix:!win32:LIBS += -ldb2
     
     win32 {
         !win32-borland:LIBS += -ldb2cli
@@ -93,7 +93,7 @@
     HEADERS += drivers/ibase/qsql_ibase.h
     SOURCES += drivers/ibase/qsql_ibase.cpp
     
-    unix:LIBS *= -lgds  
+    unix:!win32:LIBS *= -lgds  
     
     win32 {
         !win32-borland:LIBS *= -lgds32_ms
diff -urN a/src/sql/drivers/tds/qsql_tds.cpp b/src/sql/drivers/tds/qsql_tds.cpp
--- a/src/sql/drivers/tds/qsql_tds.cpp	2009-11-27 02:27:52.000000000 +0100
+++ b/src/sql/drivers/tds/qsql_tds.cpp	2009-12-04 10:30:44.000000000 +0100
@@ -47,7 +47,8 @@
 #else
 #define Q_USE_SYBASE
 #endif
-
+//Force SYBASE because we use FreeTDS
+#define Q_USE_SYBASE
 #include "qsql_tds.h"
 
 #include <qvariant.h>
diff -urN a/src/sql/drivers/tds/qsql_tds.h b/src/sql/drivers/tds/qsql_tds.h
--- a/src/sql/drivers/tds/qsql_tds.h	2009-11-27 02:27:52.000000000 +0100
+++ b/src/sql/drivers/tds/qsql_tds.h	2009-12-04 10:30:44.000000000 +0100
@@ -48,7 +48,8 @@
 
 #ifdef Q_OS_WIN32
 #define WIN32_LEAN_AND_MEAN
-#define DBNTWIN32 // indicates 32bit windows dblib
+//#define DBNTWIN32 // indicates 32bit windows dblib
+#include <winsock2.h>
 #include <QtCore/qt_windows.h>
 #include <sqlfront.h>
 #include <sqldb.h>
diff -urN a/src/sql/sql.pro b/src/sql/sql.pro
--- a/src/sql/sql.pro	2009-11-27 02:27:52.000000000 +0100
+++ b/src/sql/sql.pro	2009-12-04 10:30:44.000000000 +0100
@@ -5,7 +5,7 @@
 DEFINES += QT_NO_USING_NAMESPACE
 win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x62000000
 
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore
+unix:!win32:QMAKE_PKGCONFIG_REQUIRES = QtCore
 
 include(../qbase.pri)
 
diff -urN a/src/svg/svg.pro b/src/svg/svg.pro
--- a/src/svg/svg.pro	2009-11-27 02:27:53.000000000 +0100
+++ b/src/svg/svg.pro	2009-12-04 10:30:44.000000000 +0100
@@ -6,7 +6,7 @@
 win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x66000000
 solaris-cc*:QMAKE_CXXFLAGS_RELEASE -= -O2
 
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui
+unix:!win32:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui
 
 include(../qbase.pri)
 
@@ -44,7 +44,8 @@
 
 #zlib support
 contains(QT_CONFIG, zlib) {
-   INCLUDEPATH += ../3rdparty/zlib
+    INCLUDEPATH += ../3rdparty/zlib
 } else:!contains(QT_CONFIG, no-zlib) {
-   unix:LIBS_PRIVATE += -lz
+    unix|win32-g++:LIBS_PRIVATE += -lz
+    win32-msvc*|win32-icc:LIBS += zdll.lib
 }
diff -urN a/src/testlib/testlib.pro b/src/testlib/testlib.pro
--- a/src/testlib/testlib.pro	2009-11-27 02:27:52.000000000 +0100
+++ b/src/testlib/testlib.pro	2009-12-04 10:30:44.000000000 +0100
@@ -2,7 +2,7 @@
 QPRO_PWD = $$PWD
 QT = core
 INCLUDEPATH += .
-unix:!embedded:QMAKE_PKGCONFIG_DESCRIPTION = Qt \
+unix:!win32:!embedded:QMAKE_PKGCONFIG_DESCRIPTION = Qt \
     Unit \
     Testing \
     Library
diff -urN a/src/tools/bootstrap/bootstrap.pri b/src/tools/bootstrap/bootstrap.pri
--- a/src/tools/bootstrap/bootstrap.pri	2009-11-27 02:27:53.000000000 +0100
+++ b/src/tools/bootstrap/bootstrap.pri	2009-12-04 10:30:44.000000000 +0100
@@ -52,8 +52,8 @@
     LIBS += -lbootstrap
 }
 !contains(QT_CONFIG, zlib):!contains(QT_CONFIG, no-zlib) {
-   unix:LIBS += -lz
-#  win32:LIBS += libz.lib
+    unix|win32-g++:LIBS_PRIVATE += -lz
+    win32-msvc*|win32-icc:LIBS += zdll.lib
 }
 win32:LIBS += -luser32
 
diff -urN a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro
--- a/src/tools/bootstrap/bootstrap.pro	2009-11-27 02:27:53.000000000 +0100
+++ b/src/tools/bootstrap/bootstrap.pro	2009-12-04 10:30:44.000000000 +0100
@@ -82,7 +82,7 @@
            ../../xml/dom/qdom.cpp \
            ../../xml/sax/qxml.cpp
 
-unix:SOURCES += ../../corelib/io/qfsfileengine_unix.cpp \
+unix:!win32:SOURCES += ../../corelib/io/qfsfileengine_unix.cpp \
                 ../../corelib/io/qfsfileengine_iterator_unix.cpp
 
 win32:SOURCES += ../../corelib/io/qfsfileengine_win.cpp \
@@ -108,6 +108,9 @@
         ../3rdparty/zlib/trees.c \
         ../3rdparty/zlib/uncompr.c \
         ../3rdparty/zlib/zutil.c
+} else:!contains(QT_CONFIG, no-zlib) {
+    unix|win32-g++:LIBS_PRIVATE += -lz
+    win32-msvc*|win32-icc:LIBS += zdll.lib
 }
 
 lib.CONFIG = dummy_install
diff -urN a/src/winmain/winmain.pro b/src/winmain/winmain.pro
--- a/src/winmain/winmain.pro	2009-11-27 02:27:53.000000000 +0100
+++ b/src/winmain/winmain.pro	2009-12-04 10:30:44.000000000 +0100
@@ -11,12 +11,12 @@
 	win32-g++:DEFINES += QT_NEEDS_QMAIN
 	win32-borland:DEFINES += QT_NEEDS_QMAIN
 	SOURCES		= qtmain_win.cpp
-	CONFIG		+= png zlib
+	CONFIG		+= png
 	CONFIG		-= jpeg
 	INCLUDEPATH	+= tmp $$QMAKE_INCDIR_QT/QtCore
 }
 
-!win32:error("$$_FILE_ is intended only for Windows!")
+!win32:warning("$$_FILE_ is intended only for Windows! This warning might be a spurious effect of fromfile function.")
 include(../qbase.pri)
 wince*:QMAKE_POST_LINK =
 
diff -urN a/src/xml/xml.pro b/src/xml/xml.pro
--- a/src/xml/xml.pro	2009-11-27 02:27:48.000000000 +0100
+++ b/src/xml/xml.pro	2009-12-04 10:30:44.000000000 +0100
@@ -4,7 +4,7 @@
 DEFINES   += QT_BUILD_XML_LIB QT_NO_USING_NAMESPACE
 win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x61000000
 
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore
+unix:!win32:QMAKE_PKGCONFIG_REQUIRES = QtCore
 
 include(../qbase.pri)
 
diff -urN a/src/xmlpatterns/xmlpatterns.pro b/src/xmlpatterns/xmlpatterns.pro
--- a/src/xmlpatterns/xmlpatterns.pro	2009-11-27 02:27:53.000000000 +0100
+++ b/src/xmlpatterns/xmlpatterns.pro	2009-12-04 10:30:44.000000000 +0100
@@ -4,7 +4,7 @@
 DEFINES   += QT_BUILD_XMLPATTERNS_LIB QT_NO_USING_NAMESPACE
 win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x61000000
 
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtNetwork
+unix:!win32:QMAKE_PKGCONFIG_REQUIRES = QtCore QtNetwork
 
 include(../qbase.pri)
 
diff -urN a/tools/assistant/compat/assistant.pro b/tools/assistant/compat/assistant.pro
--- a/tools/assistant/compat/assistant.pro	2009-11-27 02:27:46.000000000 +0100
+++ b/tools/assistant/compat/assistant.pro	2009-12-04 10:30:44.000000000 +0100
@@ -6,7 +6,7 @@
 
 CONFIG += qt warn_on
 
-unix:contains(QT_CONFIG, dbus):QT += dbus
+unix:!win32:contains(QT_CONFIG, dbus):QT += dbus
 
 build_all:!build_pass {
     CONFIG -= build_all
@@ -67,7 +67,7 @@
 
 TRANSLATIONS = assistant_de.ts
 
-unix:!contains(QT_CONFIG, zlib):LIBS += -lz
+unix:!win32:!contains(QT_CONFIG, zlib):LIBS += -lz
 
 contains(CONFIG, static): {
     win32 {
diff -urN a/tools/assistant/compat/compat.pro b/tools/assistant/compat/compat.pro
--- a/tools/assistant/compat/compat.pro	2009-11-27 02:27:46.000000000 +0100
+++ b/tools/assistant/compat/compat.pro	2009-12-04 10:30:44.000000000 +0100
@@ -6,7 +6,7 @@
 
 CONFIG += qt warn_on
 
-unix:contains(QT_CONFIG, dbus):QT += dbus
+unix:!win32:contains(QT_CONFIG, dbus):QT += dbus
 
 build_all:!build_pass {
     CONFIG -= build_all
@@ -67,7 +67,7 @@
 
 TRANSLATIONS = assistant_de.ts
 
-unix:!contains(QT_CONFIG, zlib):LIBS += -lz
+unix:!win32:!contains(QT_CONFIG, zlib):LIBS += -lz
 
 contains(CONFIG, static): {
     win32 {
diff -urN a/tools/assistant/compat/lib/lib.pro b/tools/assistant/compat/lib/lib.pro
--- a/tools/assistant/compat/lib/lib.pro	2009-11-27 02:27:46.000000000 +0100
+++ b/tools/assistant/compat/lib/lib.pro	2009-12-04 10:30:44.000000000 +0100
@@ -19,7 +19,7 @@
 DESTDIR                = ../../../../lib
 DLLDESTDIR             = ../../../../bin
 
-unix {
+unix:!win32 {
         QMAKE_CFLAGS += $$QMAKE_CFLAGS_SHLIB
         QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_SHLIB
 }
@@ -67,7 +67,7 @@
     INSTALLS        += assistant_headers
 }
 
-unix {
+unix:!win32 {
    CONFIG     += create_pc
    QMAKE_PKGCONFIG_LIBDIR = $$[QT_INSTALL_LIBS]
    QMAKE_PKGCONFIG_INCDIR = $$[QT_INSTALL_HEADERS]/QtAssistant
diff -urN a/tools/assistant/lib/fulltextsearch/fulltextsearch.pro b/tools/assistant/lib/fulltextsearch/fulltextsearch.pro
--- a/tools/assistant/lib/fulltextsearch/fulltextsearch.pro	2009-11-27 02:27:46.000000000 +0100
+++ b/tools/assistant/lib/fulltextsearch/fulltextsearch.pro	2009-12-04 10:30:44.000000000 +0100
@@ -23,7 +23,7 @@
     linux*-g++*:DEFINES += _GLIBCXX_EXTERN_TEMPLATE=0
 }
 
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore
+unix:!win32:QMAKE_PKGCONFIG_REQUIRES = QtCore
 
 # impossible to disable exceptions in clucene atm
 CONFIG(exceptions_off) {
diff -urN a/tools/assistant/lib/lib.pro b/tools/assistant/lib/lib.pro
--- a/tools/assistant/lib/lib.pro	2009-11-27 02:27:46.000000000 +0100
+++ b/tools/assistant/lib/lib.pro	2009-12-04 10:30:44.000000000 +0100
@@ -19,7 +19,7 @@
     win32:qclucene = $${qclucene}d
 }
 linux-lsb-g++:LIBS_PRIVATE += --lsb-shared-libs=$$qclucene
-unix:QMAKE_PKGCONFIG_REQUIRES += QtNetwork \
+unix:!win32:QMAKE_PKGCONFIG_REQUIRES += QtNetwork \
     QtSql \
     QtXml
 LIBS_PRIVATE += -l$$qclucene
diff -urN a/tools/designer/src/components/lib/lib.pro b/tools/designer/src/components/lib/lib.pro
--- a/tools/designer/src/components/lib/lib.pro	2009-11-27 02:27:46.000000000 +0100
+++ b/tools/designer/src/components/lib/lib.pro	2009-12-04 10:30:44.000000000 +0100
@@ -64,7 +64,7 @@
 include(../../sharedcomponents.pri)
 include(../component.pri)
 
-unix {
+unix:!win32 {
     QMAKE_PKGCONFIG_REQUIRES = QtCore QtDesigner QtGui QtXml
     contains(QT_CONFIG, script): QMAKE_PKGCONFIG_REQUIRES += QtScript
 }
diff -urN a/tools/designer/src/designer/designer.pro b/tools/designer/src/designer/designer.pro
--- a/tools/designer/src/designer/designer.pro	2009-11-27 02:27:46.000000000 +0100
+++ b/tools/designer/src/designer/designer.pro	2009-12-04 10:30:44.000000000 +0100
@@ -89,5 +89,5 @@
 
 include(../sharedcomponents.pri)
 
-unix:!mac:LIBS += -lm
+unix:!win32:!mac:LIBS += -lm
 TRANSLATIONS = designer_de.ts
diff -urN a/tools/designer/src/lib/lib.pro b/tools/designer/src/lib/lib.pro
--- a/tools/designer/src/lib/lib.pro	2009-11-27 02:27:46.000000000 +0100
+++ b/tools/designer/src/lib/lib.pro	2009-12-04 10:30:44.000000000 +0100
@@ -13,7 +13,7 @@
    VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION}
 }
 
-unix:QMAKE_PKGCONFIG_REQUIRES += QtXml
+unix:!win32:QMAKE_PKGCONFIG_REQUIRES += QtXml
 
 include(../../../../src/qt_targets.pri)
 QMAKE_TARGET_PRODUCT = Designer
diff -urN a/tools/designer/src/sharedcomponents.pri b/tools/designer/src/sharedcomponents.pri
--- a/tools/designer/src/sharedcomponents.pri	2009-11-27 02:27:46.000000000 +0100
+++ b/tools/designer/src/sharedcomponents.pri	2009-12-04 10:30:44.000000000 +0100
@@ -21,7 +21,7 @@
     }
 }
 
-unix {
+unix:!win32 {
    CONFIG     += create_pc
    QMAKE_PKGCONFIG_LIBDIR = $$[QT_INSTALL_LIBS]
    QMAKE_PKGCONFIG_INCDIR = $$[QT_INSTALL_HEADERS]/$$TARGET
diff -urN a/tools/designer/src/uitools/uitools.pro b/tools/designer/src/uitools/uitools.pro
--- a/tools/designer/src/uitools/uitools.pro	2009-11-27 02:27:46.000000000 +0100
+++ b/tools/designer/src/uitools/uitools.pro	2009-12-04 10:30:44.000000000 +0100
@@ -35,7 +35,7 @@
 target.path=$$[QT_INSTALL_LIBS]
 INSTALLS        += target
 
-unix {
+unix:!win32 {
    CONFIG     += create_pc
    QMAKE_PKGCONFIG_LIBDIR = $$[QT_INSTALL_LIBS]
    QMAKE_PKGCONFIG_INCDIR = $$[QT_INSTALL_HEADERS]/$$TARGET
diff -urN a/tools/tools.pro b/tools/tools.pro
--- a/tools/tools.pro	2009-11-27 02:27:47.000000000 +0100
+++ b/tools/tools.pro	2009-12-04 10:30:44.000000000 +0100
@@ -16,7 +16,7 @@
      SUBDIRS     += linguist
      symbian: SUBDIRS = designer
      wince*: SUBDIRS = qtestlib designer
-     unix:!mac:!embedded:contains(QT_CONFIG, qt3support):SUBDIRS += qtconfig
+     unix:!win32:!mac:!embedded:contains(QT_CONFIG, qt3support):SUBDIRS += qtconfig
      win32:!wince*:SUBDIRS += activeqt
 }
 
