Index: trunk/tools/configure/environment.cpp
===================================================================
--- trunk/tools/configure/environment.cpp	(revision 769)
+++ trunk/tools/configure/environment.cpp	(revision 846)
@@ -1,5 +1,5 @@
 /****************************************************************************
 **
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
 ** All rights reserved.
 ** Contact: Nokia Corporation (qt-info@nokia.com)
@@ -61,6 +61,6 @@
 #endif
 
-#include <symbian/epocroot.h> // from tools/shared
-#include <windows/registry.h> // from tools/shared
+#include <symbian/epocroot_p.h> // from tools/shared
+#include <windows/registry_p.h> // from tools/shared
 
 QT_BEGIN_NAMESPACE
@@ -74,5 +74,5 @@
     // The compilers here are sorted in a reversed-preferred order
     {CC_BORLAND, "Borland C++",                                                    0, "bcc32.exe"},
-    {CC_MINGW,   "MinGW (Minimalist GNU for Windows)",                             0, "mingw32-gcc.exe"},
+    {CC_MINGW,   "MinGW (Minimalist GNU for Windows)",                             0, "g++.exe"},
     {CC_INTEL,   "Intel(R) C++ Compiler for 32-bit applications",                  0, "icl.exe"}, // xilink.exe, xilink5.exe, xilink6.exe, xilib.exe
     {CC_MSVC6,   "Microsoft (R) 32-bit C/C++ Optimizing Compiler (6.x)",           "Software\\Microsoft\\VisualStudio\\6.0\\Setup\\Microsoft Visual C++\\ProductDir", "cl.exe"}, // link.exe, lib.exe
@@ -81,4 +81,5 @@
     {CC_NET2005, "Microsoft (R) 32-bit C/C++ Optimizing Compiler.NET 2005 (8.0)",  "Software\\Microsoft\\VisualStudio\\SxS\\VC7\\8.0", "cl.exe"}, // link.exe, lib.exe
     {CC_NET2008, "Microsoft (R) 32-bit C/C++ Optimizing Compiler.NET 2008 (9.0)",  "Software\\Microsoft\\VisualStudio\\SxS\\VC7\\9.0", "cl.exe"}, // link.exe, lib.exe
+    {CC_NET2010, "Microsoft (R) 32-bit C/C++ Optimizing Compiler.NET 2010 (10.0)", "Software\\Microsoft\\VisualStudio\\SxS\\VC7\\10.0", "cl.exe"}, // link.exe, lib.exe
     {CC_UNKNOWN, "Unknown", 0, 0},
 };
@@ -106,4 +107,7 @@
     QString spec;
     switch (detectCompiler()) {
+    case CC_NET2010:
+        spec = "win32-msvc2010";
+        break;
     case CC_NET2008:
         spec = "win32-msvc2008";
@@ -160,5 +164,5 @@
     QStringList pathlist = paths.toLower().split(";");
     for(int i = 0; compiler_info[i].compiler; ++i) {
-        QString productPath = readRegistryKey(HKEY_LOCAL_MACHINE, compiler_info[i].regKey).toLower();
+        QString productPath = qt_readRegistryKey(HKEY_LOCAL_MACHINE, compiler_info[i].regKey).toLower();
         if (productPath.length()) {
             QStringList::iterator it;
@@ -278,6 +282,5 @@
     }
     // add the user environment
-    for (QStringList::ConstIterator it = environment.begin(); it != environment.end(); it++ ) {
-            QString tmp = *it;
+    foreach (const QString &tmp, environment) {
             uint tmpSize = sizeof(wchar_t) * (tmp.length() + 1);
             envlist.resize(envlist.size() + tmpSize);
@@ -358,5 +361,5 @@
     QByteArray envlist = qt_create_environment(fullEnv);
 
-    DWORD exitCode = -1;
+    DWORD exitCode = DWORD(-1);
     PROCESS_INFORMATION procInfo;
     memset(&procInfo, 0, sizeof(procInfo));
@@ -379,9 +382,9 @@
 
 
-    if (exitCode == -1) {
+    if (exitCode == DWORD(-1)) {
         switch(GetLastError()) {
         case E2BIG:
             cerr << "execute: Argument list exceeds 1024 bytes" << endl;
-            foreach(QString arg, arguments)
+            foreach (const QString &arg, arguments)
                 cerr << "   (" << arg.toLocal8Bit().constData() << ")" << endl;
             break;
@@ -397,5 +400,5 @@
         default:
             cerr << "execute: Unknown error" << endl;
-            foreach(QString arg, arguments)
+            foreach (const QString &arg, arguments)
                 cerr << "   (" << arg.toLocal8Bit().constData() << ")" << endl;
             break;
@@ -405,8 +408,23 @@
 }
 
-bool Environment::cpdir(const QString &srcDir, const QString &destDir)
+/*!
+    Copies the \a srcDir contents into \a destDir.
+
+    If \a includeSrcDir is not empty, any files with 'h', 'prf', or 'conf' suffixes
+    will not be copied over from \a srcDir. Instead a new file will be created
+    in \a destDir with the same name and that file will include a file with the
+    same name from the \a includeSrcDir using relative path and appropriate
+    syntax for the file type.
+
+    Returns true if copying was successful.
+*/
+bool Environment::cpdir(const QString &srcDir,
+                        const QString &destDir,
+                        const QString &includeSrcDir)
 {
     QString cleanSrcName = QDir::cleanPath(srcDir);
     QString cleanDstName = QDir::cleanPath(destDir);
+    QString cleanIncludeName = QDir::cleanPath(includeSrcDir);
+
 #ifdef CONFIGURE_DEBUG_CP_DIR
     qDebug() << "Attempt to cpdir " << cleanSrcName << "->" << cleanDstName;
@@ -419,4 +437,5 @@
     bool result = true;
     QDir dir = QDir(cleanSrcName);
+    QDir destinationDir = QDir(cleanDstName);
     QFileInfoList allEntries = dir.entryInfoList(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot);
     for (int i = 0; result && (i < allEntries.count()); ++i) {
@@ -424,6 +443,11 @@
 	bool intermediate = true;
         if (entry.isDir()) {
+            QString newIncSrcDir;
+            if (!includeSrcDir.isEmpty())
+                newIncSrcDir = QString("%1/%2").arg(cleanIncludeName).arg(entry.fileName());
+
             intermediate = cpdir(QString("%1/%2").arg(cleanSrcName).arg(entry.fileName()),
-                            QString("%1/%2").arg(cleanDstName).arg(entry.fileName()));
+                                 QString("%1/%2").arg(cleanDstName).arg(entry.fileName()),
+                                 newIncSrcDir);
         } else {
             QString destFile = QString("%1/%2").arg(cleanDstName).arg(entry.fileName());
@@ -432,6 +456,38 @@
 #endif
 	    QFile::remove(destFile);
-            intermediate = QFile::copy(entry.absoluteFilePath(), destFile);
-            SetFileAttributes((wchar_t*)destFile.utf16(), FILE_ATTRIBUTE_NORMAL);
+            QString suffix = entry.suffix();
+            if (!includeSrcDir.isEmpty() && (suffix == "prf" || suffix == "conf" || suffix == "h")) {
+                QString relativeIncludeFilePath = QString("%1/%2").arg(cleanIncludeName).arg(entry.fileName());
+                relativeIncludeFilePath = destinationDir.relativeFilePath(relativeIncludeFilePath);
+#ifdef CONFIGURE_DEBUG_CP_DIR
+                qDebug() << "...instead generate relative include to" << relativeIncludeFilePath;
+#endif
+                QFile currentFile(destFile);
+                if (currentFile.open(QFile::WriteOnly | QFile::Text)) {
+                    QTextStream fileStream;
+                    fileStream.setDevice(&currentFile);
+
+                    if (suffix == "prf" || suffix == "conf") {
+                        if (entry.fileName() == "qmake.conf") {
+                            // While QMAKESPEC_ORIGINAL being relative or absolute doesn't matter for the
+                            // primary use of this variable by qmake to identify the original mkspec, the
+                            // variable is also used for few special cases where the absolute path is required.
+                            // Conversely, the include of the original qmake.conf must be done using relative path,
+                            // as some Qt binary deployments are done in a manner that doesn't allow for patching
+                            // the paths at the installation time.
+                            fileStream << "QMAKESPEC_ORIGINAL=" << cleanSrcName << endl << endl;
+                        }
+                        fileStream << "include(" << relativeIncludeFilePath << ")" << endl << endl;
+                    } else if (suffix == "h") {
+                        fileStream << "#include \"" << relativeIncludeFilePath << "\"" << endl << endl;
+                    }
+
+                    fileStream.flush();
+                    currentFile.close();
+                }
+            } else {
+                intermediate = QFile::copy(entry.absoluteFilePath(), destFile);
+                SetFileAttributes((wchar_t*)destFile.utf16(), FILE_ATTRIBUTE_NORMAL);
+            }
         }
 	if(!intermediate) {
@@ -464,6 +520,6 @@
 QString Environment::symbianEpocRoot()
 {
-    // Call function defined in tools/shared/symbian/epocroot.h
-    return ::epocRoot();
+    // Call function defined in tools/shared/symbian/epocroot_p.h
+    return ::qt_epocRoot();
 }
 
