changeset 2103:855b32e713a2

package qt: use new mkspec for gcc 4.6
author Mark Brand <mabrand@mabrand.nl>
date Thu, 17 Nov 2011 07:40:02 +0100
parents 57ec66c86927
children 95202d76a33d
files src/qt-1-cherrypicks.patch src/qt.mk
diffstat 2 files changed, 552 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/src/qt-1-cherrypicks.patch	Wed Nov 16 23:19:43 2011 +0100
+++ b/src/qt-1-cherrypicks.patch	Thu Nov 17 07:40:02 2011 +0100
@@ -8,7 +8,7 @@
 From 9ae9b4c7f69482cfb67594044da8444bc70c6f97 Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Thu, 30 Jun 2011 10:22:33 +0200
-Subject: [PATCH 01/10] do not detect or configure iconv for Windows
+Subject: [PATCH 01/12] do not detect or configure iconv for Windows
 
 Qt doesn't use iconv on Windows, but configuring it will appear to
 work and the build will complete. The result is that character
@@ -33,13 +33,13 @@
      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
 -- 
-1.7.7
+1.7.7.3
 
 
 From 5146d425f67575913f4d988da5cf1daff722e9e7 Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Sun, 3 Jul 2011 22:45:15 +0200
-Subject: [PATCH 02/10] add missing multiple inclusion guard
+Subject: [PATCH 02/12] add missing multiple inclusion guard
 
 ---
  src/plugins/codecs/kr/cp949codetbl.h |    5 +++++
@@ -66,13 +66,13 @@
 +
 +#endif // CP494CODETBL_H
 -- 
-1.7.7
+1.7.7.3
 
 
 From d19058417259a1f18c0f0ddcc7c7fad120a88f12 Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Mon, 4 Jul 2011 00:42:24 +0200
-Subject: [PATCH 03/10] load plugin codecs regardless of iconv
+Subject: [PATCH 03/12] load plugin codecs regardless of iconv
 
 Otherwise Windows applications linking to static Qt will have to
 import the static plugins to avoid linking failure even if they
@@ -140,13 +140,13 @@
  #endif // QT_NO_CODECS
  
 -- 
-1.7.7
+1.7.7.3
 
 
 From 1572988d2a3728505d9bacd204a1e7132d5f7a7d Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Sun, 3 Jul 2011 21:40:11 +0200
-Subject: [PATCH 04/10] move plugin text codecs to QtCore
+Subject: [PATCH 04/12] move plugin text codecs to QtCore
 
 Having plugin text codecs adds considerable complexity to
 configuring Qt. The plugin interface is designed for optional
@@ -79778,13 +79778,13 @@
  !embedded:!qpa:!contains(QT_CONFIG, no-gui):SUBDIRS *= graphicssystems
  embedded:SUBDIRS *=  gfxdrivers decorations mousedrivers kbddrivers
 -- 
-1.7.7
+1.7.7.3
 
 
-From 91577ea4e4c338e24c67c611a4ddefddbfd3ccdc Mon Sep 17 00:00:00 2001
+From 72750d704101c1f3a97d1efa2135ea0ac76a9924 Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Thu, 3 Nov 2011 15:10:26 +0100
-Subject: [PATCH 05/10] use pkg-config for libmng
+Subject: [PATCH 05/12] use pkg-config for libmng (mingw-cross-env specific)
 
 ---
  src/gui/image/qmnghandler.pri |    4 +++-
@@ -79806,13 +79806,13 @@
  } else {
      include($$PWD/../../3rdparty/libmng.pri)
 -- 
-1.7.7
+1.7.7.3
 
 
-From 430bcd7435a32b1058e0a387ba0295c1e0389766 Mon Sep 17 00:00:00 2001
+From 9fa7811cb907435a72b0f0719ca585e36e19dec0 Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Thu, 3 Nov 2011 14:11:02 +0100
-Subject: [PATCH 06/10] use pkg-config for libtiff
+Subject: [PATCH 06/12] use pkg-config for libtiff (mingw-cross-env specific)
 
 ---
  src/gui/image/qtiffhandler.pri |    4 +++-
@@ -79834,13 +79834,13 @@
  } else {
      include($$PWD/../../3rdparty/libtiff.pri)
 -- 
-1.7.7
+1.7.7.3
 
 
-From 606cc859a6df8e57006f1a51b3bc67ec75e3eb26 Mon Sep 17 00:00:00 2001
+From f2b7061ab718faa8a7178536443e0224af101296 Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Sat, 5 Jun 2010 23:41:04 +0200
-Subject: [PATCH 07/10] restore support for static linking of QtWebKit
+Subject: [PATCH 07/12] restore support for static linking of QtWebKit
  (mingw-cross-env specific)
 
 Support was removed by 4221d629e2cf37ee8c5ba7cb595b05ab8c82f113.
@@ -79931,13 +79931,13 @@
  build-qtscript {
      SUBDIRS += \
 -- 
-1.7.7
+1.7.7.3
 
 
-From 6459ac61c72e148a768b5785b4bf297b982b98ad Mon Sep 17 00:00:00 2001
+From 1ccb57fd77c555afe5a3da5da12e345923e284e0 Mon Sep 17 00:00:00 2001
 From: Tony Theodore <tonyt@logyst.com>
 Date: Thu, 1 Sep 2011 13:47:10 +0200
-Subject: [PATCH 08/10] fix building on GNU/kFreeBSD (mingw-cross-specific)
+Subject: [PATCH 08/12] fix building on GNU/kFreeBSD (mingw-cross-specific)
 
 This patch has been taken from:
 
@@ -79964,13 +79964,13 @@
  #  define Q_OS_NETBSD
  #  define Q_OS_BSD4
 -- 
-1.7.7
+1.7.7.3
 
 
-From 9ed796a8de712249a2967eb543dec9abdef6bf68 Mon Sep 17 00:00:00 2001
+From 65b8403ce58f8324517915717cfdaf700ab739cb Mon Sep 17 00:00:00 2001
 From: Tony Theodore <tonyt@logyst.com>
 Date: Thu, 1 Sep 2011 13:49:47 +0200
-Subject: [PATCH 09/10] fix missing platform when building on GNU/kFreeBSD
+Subject: [PATCH 09/12] fix missing platform when building on GNU/kFreeBSD
  (mingw-cross-env specific)
 
 This patch is inspired by:
@@ -79996,13 +79996,13 @@
          PLATFORM=dgux-g++
          ;;
 -- 
-1.7.7
+1.7.7.3
 
 
-From 8cc359a585438d16e1ba6199baadf0e16dc1716f Mon Sep 17 00:00:00 2001
+From ab430c7079d00e65b6aadd20704d0e39c1c2ad9c Mon Sep 17 00:00:00 2001
 From: Tony Theodore <tonyt@logyst.com>
 Date: Thu, 1 Sep 2011 13:51:50 +0200
-Subject: [PATCH 10/10] fix building on dragonfly (mingw-cross-env specific)
+Subject: [PATCH 10/12] fix building on dragonfly (mingw-cross-env specific)
 
 This patch is inspired by:
 http://cvsweb.NetBSD.org/bsdweb.cgi/pkgsrc/x11/qt4-libs/Makefile.common?rev=1.27&content-type=text/x-cvsweb-markup
@@ -80024,5 +80024,530 @@
          PLATFORM_NOTES="
              - Also available for FreeBSD: freebsd-icc
 -- 
-1.7.7
+1.7.7.3
+
+
+From 1f2598b07cd835b75c824e111d0fceaff7cbb7a3 Mon Sep 17 00:00:00 2001
+From: Friedemann Kleint <Friedemann.Kleint@nokia.com>
+Date: Wed, 16 Nov 2011 09:53:38 +0100
+Subject: [PATCH 11/12] Windows: Add gcc 4.6.
+
+- Add gcc 4.6 mkspec for > 4.4 (win32-g++-4.6)
+- Add detection of g++ version and 64bit to configure.
+
+Reviewed-by: mariusSO
+(cherry picked from commit d4150975af620e2889cc58bd476bac6b4d101db3)
+---
+ mkspecs/win32-g++-4.6/qmake.conf      |    3 +
+ mkspecs/win32-g++-4.6/qplatformdefs.h |  159 +++++++++++++++++++++++++++++++++
+ qmake/Makefile.win32-g++              |    2 +-
+ src/corelib/tools/qlocale_tools.cpp   |    7 ++
+ tools/configure/configureapp.cpp      |   31 ++++---
+ tools/configure/environment.cpp       |   86 ++++++++++++++++++-
+ tools/configure/environment.h         |    3 +
+ 7 files changed, 275 insertions(+), 16 deletions(-)
+ create mode 100644 mkspecs/win32-g++-4.6/qmake.conf
+ create mode 100644 mkspecs/win32-g++-4.6/qplatformdefs.h
 
+diff --git a/mkspecs/win32-g++-4.6/qmake.conf b/mkspecs/win32-g++-4.6/qmake.conf
+new file mode 100644
+index 0000000..2c94587
+--- /dev/null
++++ b/mkspecs/win32-g++-4.6/qmake.conf
+@@ -0,0 +1,3 @@
++include(../win32-g++/qmake.conf)
++QMAKE_CFLAGS *= -fno-keep-inline-dllexport
++QMAKE_CXXFLAGS *= -fno-keep-inline-dllexport
+diff --git a/mkspecs/win32-g++-4.6/qplatformdefs.h b/mkspecs/win32-g++-4.6/qplatformdefs.h
+new file mode 100644
+index 0000000..630a6a4
+--- /dev/null
++++ b/mkspecs/win32-g++-4.6/qplatformdefs.h
+@@ -0,0 +1,159 @@
++/****************************************************************************
++**
++** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
++** All rights reserved.
++** Contact: Nokia Corporation (qt-info@nokia.com)
++**
++** This file is part of the qmake spec of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:LGPL$
++** GNU Lesser General Public License Usage
++** This file may be used under the terms of the GNU Lesser General Public
++** License version 2.1 as published by the Free Software Foundation and
++** appearing in the file LICENSE.LGPL included in the packaging of this
++** file. Please review the following information to ensure the GNU Lesser
++** General Public License version 2.1 requirements will be met:
++** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
++**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** GNU General Public License Usage
++** Alternatively, this file may be used under the terms of the GNU General
++** Public License version 3.0 as published by the Free Software Foundation
++** and appearing in the file LICENSE.GPL included in the packaging of this
++** file. Please review the following information to ensure the GNU General
++** Public License version 3.0 requirements will be met:
++** http://www.gnu.org/copyleft/gpl.html.
++**
++** Other Usage
++** Alternatively, this file may be used in accordance with the terms and
++** conditions contained in a signed written agreement between you and Nokia.
++**
++**
++**
++**
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++#ifndef QPLATFORMDEFS_H
++#define QPLATFORMDEFS_H
++
++#ifdef UNICODE
++#ifndef _UNICODE
++#define _UNICODE
++#endif
++#endif
++
++// Get Qt defines/settings
++
++#include "qglobal.h"
++
++#include <tchar.h>
++#include <io.h>
++#include <direct.h>
++#include <stdio.h>
++#include <fcntl.h>
++#include <errno.h>
++#include <sys/stat.h>
++#include <stdlib.h>
++#include <qt_windows.h>
++#include <limits.h>
++
++#if !defined(_WIN32_WINNT) || (_WIN32_WINNT-0 < 0x0500)
++typedef enum {
++    NameUnknown		  = 0,
++    NameFullyQualifiedDN  = 1,
++    NameSamCompatible	  = 2,
++    NameDisplay		  = 3,
++    NameUniqueId	  = 6,
++    NameCanonical	  = 7,
++    NameUserPrincipal	  = 8,
++    NameCanonicalEx	  = 9,
++    NameServicePrincipal  = 10,
++    NameDnsDomain	  = 12
++} EXTENDED_NAME_FORMAT, *PEXTENDED_NAME_FORMAT;
++#endif
++
++#define Q_FS_FAT
++#ifdef QT_LARGEFILE_SUPPORT
++#define QT_STATBUF		struct _stati64		// non-ANSI defs
++#define QT_STATBUF4TSTAT	struct _stati64		// non-ANSI defs
++#define QT_STAT			::_stati64
++#define QT_FSTAT		::_fstati64
++#else
++#define QT_STATBUF		struct _stat		// non-ANSI defs
++#define QT_STATBUF4TSTAT	struct _stat		// non-ANSI defs
++#define QT_STAT			::_stat
++#define QT_FSTAT		::_fstat
++#endif
++#define QT_STAT_REG		_S_IFREG
++#define QT_STAT_DIR		_S_IFDIR
++#define QT_STAT_MASK		_S_IFMT
++#if defined(_S_IFLNK)
++#  define QT_STAT_LNK		_S_IFLNK
++#endif
++#define QT_FILENO		_fileno
++#define QT_OPEN			::_open
++#define QT_CLOSE		::_close
++#ifdef QT_LARGEFILE_SUPPORT
++#define QT_LSEEK		::_lseeki64
++#ifndef UNICODE
++#define QT_TSTAT		::_stati64
++#else
++#define QT_TSTAT		::_wstati64
++#endif
++#else
++#define QT_LSEEK		::_lseek
++#ifndef UNICODE
++#define QT_TSTAT		::_stat
++#else
++#define QT_TSTAT		::_wstat
++#endif
++#endif
++#define QT_READ			::_read
++#define QT_WRITE		::_write
++#define QT_ACCESS		::_access
++#define QT_GETCWD		::_getcwd
++#define QT_CHDIR		::_chdir
++#define QT_MKDIR		::_mkdir
++#define QT_RMDIR		::_rmdir
++#define QT_OPEN_LARGEFILE       0
++#define QT_OPEN_RDONLY		_O_RDONLY
++#define QT_OPEN_WRONLY		_O_WRONLY
++#define QT_OPEN_RDWR		_O_RDWR
++#define QT_OPEN_CREAT		_O_CREAT
++#define QT_OPEN_TRUNC		_O_TRUNC
++#define QT_OPEN_APPEND		_O_APPEND
++#if defined(O_TEXT)
++# define QT_OPEN_TEXT		_O_TEXT
++# define QT_OPEN_BINARY		_O_BINARY
++#endif
++
++#include "../common/c89/qplatformdefs.h"
++
++#ifdef QT_LARGEFILE_SUPPORT
++#undef QT_FSEEK
++#undef QT_FTELL
++#undef QT_OFF_T
++
++#define QT_FSEEK                ::fseeko64
++#define QT_FTELL                ::ftello64
++#define QT_OFF_T                off64_t
++#endif
++
++#define QT_SIGNAL_ARGS		int
++
++#define QT_VSNPRINTF		::_vsnprintf
++#define QT_SNPRINTF		::_snprintf
++
++# define F_OK	0
++# define X_OK	1
++# define W_OK	2
++# define R_OK	4
++
++
++#endif // QPLATFORMDEFS_H
+diff --git a/qmake/Makefile.win32-g++ b/qmake/Makefile.win32-g++
+index d40dc29..5fa1e5e 100644
+--- a/qmake/Makefile.win32-g++
++++ b/qmake/Makefile.win32-g++
+@@ -27,7 +27,7 @@ CFLAGS	    =	-c -o$@ -O \
+ 		-DQT_BUILD_QMAKE -DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM \
+ 		-DQT_BOOTSTRAPPED -DQLIBRARYINFO_EPOCROOT
+ CXXFLAGS    =   $(CFLAGS)
+-LFLAGS	    = -static-libgcc -static-libstdc++ -s
++LFLAGS      = -static-libgcc -s
+ LIBS	    = -lole32 -luuid -ladvapi32 -lkernel32
+ LINKQMAKE   =	g++ $(LFLAGS) -o qmake.exe $(OBJS) $(QTOBJS) $(LIBS)
+ ADDCLEAN    =
+diff --git a/src/corelib/tools/qlocale_tools.cpp b/src/corelib/tools/qlocale_tools.cpp
+index df31bf9..750379c 100644
+--- a/src/corelib/tools/qlocale_tools.cpp
++++ b/src/corelib/tools/qlocale_tools.cpp
+@@ -2253,6 +2253,13 @@ static int quorem(Bigint *b, Bigint *S)
+  *           calculation.
+  */
+ 
++#if defined(Q_OS_WIN) && defined (Q_CC_GNU) && !defined(_clear87) // See QTBUG-7576
++extern "C" {
++__attribute__ ((dllimport)) unsigned int __cdecl __MINGW_NOTHROW _control87 (unsigned int unNew, unsigned int unMask);
++__attribute__ ((dllimport)) unsigned int __cdecl __MINGW_NOTHROW _clearfp (void); /* Clear the FPU status word */
++}
++#  define _clear87 _clearfp
++#endif
+ 
+ /* This actually sometimes returns a pointer to a string literal
+    cast to a char*. Do NOT try to modify the return value. */
+diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp
+index e6d8526..60996e3 100644
+--- a/tools/configure/configureapp.cpp
++++ b/tools/configure/configureapp.cpp
+@@ -1263,17 +1263,18 @@ void Configure::parseCmdLine()
+         }
+         cout << "See the README file for a list of supported operating systems and compilers." << endl;
+     } else {
+-        if (dictionary[ "QMAKESPEC" ].endsWith("-icc") ||
+-            dictionary[ "QMAKESPEC" ].endsWith("-msvc") ||
+-            dictionary[ "QMAKESPEC" ].endsWith("-msvc.net") ||
+-            dictionary[ "QMAKESPEC" ].endsWith("-msvc2002") ||
+-            dictionary[ "QMAKESPEC" ].endsWith("-msvc2003") ||
+-            dictionary[ "QMAKESPEC" ].endsWith("-msvc2005") ||
+-            dictionary[ "QMAKESPEC" ].endsWith("-msvc2008") ||
+-            dictionary[ "QMAKESPEC" ].endsWith("-msvc2010")) {
++        const QString qmakeSpec = dictionary[ "QMAKESPEC" ];
++        if (qmakeSpec.endsWith("-icc") ||
++            qmakeSpec.endsWith("-msvc") ||
++            qmakeSpec.endsWith("-msvc.net") ||
++            qmakeSpec.endsWith("-msvc2002") ||
++            qmakeSpec.endsWith("-msvc2003") ||
++            qmakeSpec.endsWith("-msvc2005") ||
++            qmakeSpec.endsWith("-msvc2008") ||
++            qmakeSpec.endsWith("-msvc2010")) {
+             if (dictionary[ "MAKE" ].isEmpty()) dictionary[ "MAKE" ] = "nmake";
+             dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32";
+-        } else if (dictionary[ "QMAKESPEC" ] == QString("win32-g++")) {
++        } else if (qmakeSpec.contains("win32-g++")) {
+             if (dictionary[ "MAKE" ].isEmpty()) dictionary[ "MAKE" ] = "mingw32-make";
+             if (Environment::detectExecutable("sh.exe")) {
+                 dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32-g++-sh";
+@@ -1329,7 +1330,7 @@ void Configure::parseCmdLine()
+         }
+     }
+ 
+-    useUnixSeparators = (dictionary["QMAKESPEC"] == "win32-g++");
++    useUnixSeparators = dictionary["QMAKESPEC"].contains("win32-g++");
+ 
+     // Allow tests for private classes to be compiled against internal builds
+     if (dictionary["BUILDDEV"] == "yes")
+@@ -2201,7 +2202,9 @@ bool Configure::checkAvailability(const QString &part)
+     } else if (part == "MULTIMEDIA" || part == "SCRIPT" || part == "SCRIPTTOOLS" || part == "DECLARATIVE") {
+         available = true;
+     } else if (part == "WEBKIT") {
+-        available = (dictionary.value("QMAKESPEC") == "win32-msvc2005") || (dictionary.value("QMAKESPEC") == "win32-msvc2008") || (dictionary.value("QMAKESPEC") == "win32-msvc2010") || (dictionary.value("QMAKESPEC") == "win32-g++");
++        const QString qmakeSpec = dictionary.value("QMAKESPEC");
++        available = qmakeSpec == "win32-msvc2005" || qmakeSpec == "win32-msvc2008" ||
++                qmakeSpec == "win32-msvc2010" || qmakeSpec.startsWith("win32-g++");
+         if (dictionary[ "SHARED" ] == "no") {
+             cout << endl << "WARNING: Using static linking will disable the WebKit module." << endl
+                  << endl;
+@@ -2376,7 +2379,7 @@ bool Configure::verifyConfiguration()
+ 
+         dictionary["SQL_SQLITE_LIB"] = "qt"; // Set to Qt's bundled lib an continue
+     }
+-    if (dictionary["QMAKESPEC"].endsWith("-g++")
++    if (dictionary["QMAKESPEC"].contains("-g++")
+         && dictionary["SQL_OCI"] != "no") {
+         cout << "WARNING: Qt does not support compiling the Oracle database driver with" << endl
+              << "MinGW, due to lack of such support from Oracle. Consider disabling the" << endl
+@@ -2456,7 +2459,7 @@ void Configure::generateBuildKey()
+     QString spec = dictionary["QMAKESPEC"];
+ 
+     QString compiler = "msvc"; // ICC is compatible
+-    if (spec.endsWith("-g++"))
++    if (spec.contains("-g++"))
+         compiler = "mingw";
+     else if (spec.endsWith("-borland"))
+         compiler = "borland";
+@@ -2874,7 +2877,7 @@ void Configure::generateOutputVars()
+     if (!qmakeStylePlugins.isEmpty())
+         qmakeVars += QString("style-plugins  += ") + qmakeStylePlugins.join(" ");
+ 
+-    if (dictionary["QMAKESPEC"].endsWith("-g++")) {
++    if (dictionary["QMAKESPEC"].contains("-g++")) {
+         QString includepath = qgetenv("INCLUDE");
+         bool hasSh = Environment::detectExecutable("sh.exe");
+         QChar separator = (!includepath.contains(":\\") && hasSh ? QChar(':') : QChar(';'));
+diff --git a/tools/configure/environment.cpp b/tools/configure/environment.cpp
+index f9b3e85..78e1d87 100644
+--- a/tools/configure/environment.cpp
++++ b/tools/configure/environment.cpp
+@@ -120,6 +120,9 @@ QString Environment::detectQMakeSpec()
+         spec = "win32-icc";
+         break;
+     case CC_MINGW:
++        spec = "win32-g++-4.6";
++        break;
++    case CC_MINGW_44:
+         spec = "win32-g++";
+         break;
+     case CC_BORLAND:
+@@ -173,6 +176,12 @@ Compiler Environment::detectCompiler()
+             if (executable.length() && Environment::detectExecutable(executable)) {
+                 ++installed;
+                 detectedCompiler = compiler_info[i].compiler;
++                if (detectedCompiler == CC_MINGW) {
++                    bool is64bit;
++                    const int version = detectGPlusPlusVersion(executable, &is64bit);
++                    if (version < 0x040600)
++                        detectedCompiler = CC_MINGW_44;
++                }
+                 break;
+             }
+         }
+@@ -184,7 +193,7 @@ Compiler Environment::detectCompiler()
+     }
+     return detectedCompiler;
+ #endif
+-};
++}
+ 
+ /*!
+     Returns true if the \a executable could be loaded, else false.
+@@ -214,6 +223,81 @@ bool Environment::detectExecutable(const QString &executable)
+ }
+ 
+ /*!
++  Determine the g++ version.
++*/
++
++int Environment::detectGPlusPlusVersion(const QString &executable,
++                                        bool *is64bit)
++{
++    QRegExp regexp(QLatin1String("[gG]\\+\\+[\\.exEX]{0,4} ([^\\s]+) (\\d+)\\.(\\d+)\\.(\\d+)"));
++    QString stdOut = readProcessStandardOutput(executable + QLatin1String(" --version"));
++    if (regexp.indexIn(stdOut) != -1) {
++        const QString compiler = regexp.cap(1);
++        // Check for "tdm64-1"
++        *is64bit = compiler.contains(QLatin1String("64"));
++        const int major = regexp.cap(2).toInt();
++        const int minor = regexp.cap(3).toInt();
++        const int patch = regexp.cap(4).toInt();
++        return (major << 16) + (minor << 8) + patch;
++    }
++    *is64bit = false;
++    return 0;
++}
++
++/*!
++    Run a process and return its standard output.
++*/
++
++QString Environment::readProcessStandardOutput(const QString &commandLine)
++{
++    QString stdOut;
++    TCHAR tempFileName[MAX_PATH];
++    TCHAR tempPathBuffer[MAX_PATH];
++    if (!GetTempPath(MAX_PATH, tempPathBuffer)
++        || !GetTempFileName(tempPathBuffer, TEXT("qtconfigure"), 0, tempFileName))
++        return stdOut;
++
++    STARTUPINFO startInfo;
++    memset(&startInfo, 0, sizeof(startInfo));
++    startInfo.cb = sizeof(startInfo);
++    startInfo.dwFlags |= STARTF_USESTDHANDLES;
++
++    SECURITY_ATTRIBUTES securityAttributes;
++    securityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
++    securityAttributes.bInheritHandle = TRUE;
++    securityAttributes.lpSecurityDescriptor = NULL;
++
++    startInfo.hStdOutput = CreateFile(tempFileName, GENERIC_WRITE, 0, &securityAttributes, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
++    if (startInfo.hStdOutput == INVALID_HANDLE_VALUE)
++        return stdOut;
++
++    PROCESS_INFORMATION procInfo;
++    memset(&procInfo, 0, sizeof(procInfo));
++
++    if (!CreateProcess(0, (wchar_t*)commandLine.utf16(),
++                       0, 0, TRUE,
++                       0,
++                       0, 0, &startInfo, &procInfo)) {
++        CloseHandle(startInfo.hStdOutput);
++        DeleteFile(tempFileName);
++        return stdOut;
++    }
++
++    WaitForSingleObject(procInfo.hProcess, INFINITE);
++    CloseHandle(procInfo.hThread);
++    CloseHandle(procInfo.hProcess);
++    CloseHandle(startInfo.hStdOutput);
++    QFile file(QString::fromWCharArray(tempFileName));
++
++    if (file.open(QIODevice::Text| QIODevice::ReadOnly)) {
++        stdOut = QString::fromLocal8Bit(file.readAll());
++        file.close();
++    }
++    DeleteFile(tempFileName);
++    return stdOut;
++}
++
++/*!
+     Creates a commandling from \a program and it \a arguments,
+     escaping characters that needs it.
+ */
+diff --git a/tools/configure/environment.h b/tools/configure/environment.h
+index 9bbd096..81c232a 100644
+--- a/tools/configure/environment.h
++++ b/tools/configure/environment.h
+@@ -49,6 +49,7 @@ enum Compiler {
+     CC_UNKNOWN = 0,
+     CC_BORLAND = 0x01,
+     CC_MINGW   = 0x02,
++    CC_MINGW_44 = 0x21,
+     CC_INTEL   = 0x03,
+     CC_NET2003 = 0x71,
+     CC_NET2005 = 0x80,
+@@ -63,6 +64,8 @@ public:
+     static Compiler detectCompiler();
+     static QString detectQMakeSpec();
+     static bool detectExecutable(const QString &executable);
++    static int detectGPlusPlusVersion(const QString &executable, bool *is64bit);
++    static QString readProcessStandardOutput(const QString &commandLine);
+ 
+     static int execute(QStringList arguments, const QStringList &additionalEnv, const QStringList &removeEnv);
+     static bool cpdir(const QString &srcDir,
+-- 
+1.7.7.3
+
+
+From f36985c6115866b8e12e405e19a547f79adecd71 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Thu, 17 Nov 2011 00:57:12 +0100
+Subject: [PATCH 12/12] Windows: Add gcc 4.6 for cross building
+
+    - Add gcc 4.6 cross mkspec for > 4.4 (win32-g++-4.6-cross)
+
+Based on commit 1f2598b which did this for win32-g++-4.6
+---
+ mkspecs/unsupported/win32-g++-4.6-cross/qmake.conf |    3 +
+ .../win32-g++-4.6-cross/qplatformdefs.h            |   42 ++++++++++++++++++++
+ 2 files changed, 45 insertions(+), 0 deletions(-)
+ create mode 100644 mkspecs/unsupported/win32-g++-4.6-cross/qmake.conf
+ create mode 100644 mkspecs/unsupported/win32-g++-4.6-cross/qplatformdefs.h
+
+diff --git a/mkspecs/unsupported/win32-g++-4.6-cross/qmake.conf b/mkspecs/unsupported/win32-g++-4.6-cross/qmake.conf
+new file mode 100644
+index 0000000..b2a1bb7
+--- /dev/null
++++ b/mkspecs/unsupported/win32-g++-4.6-cross/qmake.conf
+@@ -0,0 +1,3 @@
++include(../win32-g++-cross/qmake.conf)
++QMAKE_CFLAGS *= -fno-keep-inline-dllexport
++QMAKE_CXXFLAGS *= -fno-keep-inline-dllexport
+diff --git a/mkspecs/unsupported/win32-g++-4.6-cross/qplatformdefs.h b/mkspecs/unsupported/win32-g++-4.6-cross/qplatformdefs.h
+new file mode 100644
+index 0000000..f91d92d
+--- /dev/null
++++ b/mkspecs/unsupported/win32-g++-4.6-cross/qplatformdefs.h
+@@ -0,0 +1,42 @@
++/****************************************************************************
++**
++** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
++** All rights reserved.
++** Contact: Nokia Corporation (qt-info@nokia.com)
++**
++** This file is part of the qmake spec of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:LGPL$
++** GNU Lesser General Public License Usage
++** This file may be used under the terms of the GNU Lesser General Public
++** License version 2.1 as published by the Free Software Foundation and
++** appearing in the file LICENSE.LGPL included in the packaging of this
++** file. Please review the following information to ensure the GNU Lesser
++** General Public License version 2.1 requirements will be met:
++** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
++**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights. These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** GNU General Public License Usage
++** Alternatively, this file may be used under the terms of the GNU General
++** Public License version 3.0 as published by the Free Software Foundation
++** and appearing in the file LICENSE.GPL included in the packaging of this
++** file. Please review the following information to ensure the GNU General
++** Public License version 3.0 requirements will be met:
++** http://www.gnu.org/copyleft/gpl.html.
++**
++** Other Usage
++** Alternatively, this file may be used in accordance with the terms and
++** conditions contained in a signed written agreement between you and Nokia.
++**
++**
++**
++**
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++#include "../../win32-g++-4.6/qplatformdefs.h"
+-- 
+1.7.7.3
+
--- a/src/qt.mk	Wed Nov 16 23:19:43 2011 +0100
+++ b/src/qt.mk	Thu Nov 17 07:40:02 2011 +0100
@@ -30,7 +30,7 @@
         -opensource \
         -confirm-license \
         -fast \
-        -xplatform unsupported/win32-g++-cross \
+        -xplatform unsupported/win32-g++-4.6-cross \
         -force-pkg-config \
         -release \
         -exceptions \