util/tools/configure/configureapp.cpp
changeset 7 f7bc934e204c
equal deleted inserted replaced
3:41300fa6a67c 7:f7bc934e204c
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the tools applications of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #include "configureapp.h"
       
    43 #include "environment.h"
       
    44 #ifdef COMMERCIAL_VERSION
       
    45 #  include "tools.h"
       
    46 #endif
       
    47 
       
    48 #include <QDate>
       
    49 #include <qdir.h>
       
    50 #include <qtemporaryfile.h>
       
    51 #include <qstack.h>
       
    52 #include <qdebug.h>
       
    53 #include <qfileinfo.h>
       
    54 #include <qtextstream.h>
       
    55 #include <qregexp.h>
       
    56 #include <qhash.h>
       
    57 
       
    58 #include <iostream>
       
    59 #include <windows.h>
       
    60 #include <conio.h>
       
    61 
       
    62 QT_BEGIN_NAMESPACE
       
    63 
       
    64 std::ostream &operator<<( std::ostream &s, const QString &val ) {
       
    65     s << val.toLocal8Bit().data();
       
    66     return s;
       
    67 }
       
    68 
       
    69 
       
    70 using namespace std;
       
    71 
       
    72 // Macros to simplify options marking
       
    73 #define MARK_OPTION(x,y) ( dictionary[ #x ] == #y ? "*" : " " )
       
    74 
       
    75 
       
    76 bool writeToFile(const char* text, const QString &filename)
       
    77 {
       
    78     QByteArray symFile(text);
       
    79     QFile file(filename);
       
    80     QDir dir(QFileInfo(file).absoluteDir());
       
    81     if (!dir.exists())
       
    82         dir.mkpath(dir.absolutePath());
       
    83     if (!file.open(QFile::WriteOnly)) {
       
    84         cout << "Couldn't write to " << qPrintable(filename) << ": " << qPrintable(file.errorString())
       
    85              << endl;
       
    86         return false;
       
    87     }
       
    88     file.write(symFile);
       
    89     return true;
       
    90 }
       
    91 
       
    92 Configure::Configure( int& argc, char** argv )
       
    93 {
       
    94     useUnixSeparators = false;
       
    95     // Default values for indentation
       
    96     optionIndent = 4;
       
    97     descIndent   = 25;
       
    98     outputWidth  = 0;
       
    99     // Get console buffer output width
       
   100     CONSOLE_SCREEN_BUFFER_INFO info;
       
   101     HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
       
   102     if (GetConsoleScreenBufferInfo(hStdout, &info))
       
   103         outputWidth = info.dwSize.X - 1;
       
   104     outputWidth = qMin(outputWidth, 79); // Anything wider gets unreadable
       
   105     if (outputWidth < 35) // Insanely small, just use 79
       
   106         outputWidth = 79;
       
   107     int i;
       
   108 
       
   109     /*
       
   110     ** Set up the initial state, the default
       
   111     */
       
   112     dictionary[ "CONFIGCMD" ] = argv[ 0 ];
       
   113 
       
   114     for ( i = 1; i < argc; i++ )
       
   115         configCmdLine += argv[ i ];
       
   116 
       
   117 
       
   118     // Get the path to the executable
       
   119     wchar_t module_name[MAX_PATH];
       
   120     GetModuleFileName(0, module_name, sizeof(module_name) / sizeof(wchar_t));
       
   121     QFileInfo sourcePathInfo = QString::fromWCharArray(module_name);
       
   122     sourcePath = sourcePathInfo.absolutePath();
       
   123     sourceDir = sourcePathInfo.dir();
       
   124     buildPath = QDir::currentPath();
       
   125 #if 0
       
   126     const QString installPath = QString("C:\\Qt\\%1").arg(QT_VERSION_STR);
       
   127 #else
       
   128     const QString installPath = buildPath;
       
   129 #endif
       
   130     if(sourceDir != buildDir) { //shadow builds!
       
   131         if (!findFile("perl") && !findFile("perl.exe")) {
       
   132             cout << "Error: Creating a shadow build of Qt requires" << endl
       
   133                  << "perl to be in the PATH environment";
       
   134             exit(0); // Exit cleanly for Ctrl+C
       
   135         }
       
   136 
       
   137         cout << "Preparing build tree..." << endl;
       
   138         QDir(buildPath).mkpath("bin");
       
   139 
       
   140         { //duplicate qmake
       
   141             QStack<QString> qmake_dirs;
       
   142             qmake_dirs.push("qmake");
       
   143             while(!qmake_dirs.isEmpty()) {
       
   144                 QString dir = qmake_dirs.pop();
       
   145                 QString od(buildPath + "/" + dir);
       
   146                 QString id(sourcePath + "/" + dir);
       
   147                 QFileInfoList entries = QDir(id).entryInfoList(QDir::NoDotAndDotDot|QDir::AllEntries);
       
   148                 for(int i = 0; i < entries.size(); ++i) {
       
   149                     QFileInfo fi(entries.at(i));
       
   150                     if(fi.isDir()) {
       
   151                         qmake_dirs.push(dir + "/" + fi.fileName());
       
   152                         QDir().mkpath(od + "/" + fi.fileName());
       
   153                     } else {
       
   154                         QDir().mkpath(od );
       
   155                         bool justCopy = true;
       
   156                         const QString fname = fi.fileName();
       
   157                         const QString outFile(od + "/" + fname), inFile(id + "/" + fname);
       
   158                         if(fi.fileName() == "Makefile") { //ignore
       
   159                         } else if(fi.suffix() == "h" || fi.suffix() == "cpp") {
       
   160                             QTemporaryFile tmpFile;
       
   161                             if(tmpFile.open()) {
       
   162                                 QTextStream stream(&tmpFile);
       
   163                                 stream << "#include \"" << inFile << "\"" << endl;
       
   164                                 justCopy = false;
       
   165                                 stream.flush();
       
   166                                 tmpFile.flush();
       
   167                                 if(filesDiffer(tmpFile.fileName(), outFile)) {
       
   168                                     QFile::remove(outFile);
       
   169                                     tmpFile.copy(outFile);
       
   170                                 }
       
   171                             }
       
   172                         }
       
   173                         if(justCopy && filesDiffer(inFile, outFile))
       
   174                             QFile::copy(inFile, outFile);
       
   175                     }
       
   176                 }
       
   177             }
       
   178         }
       
   179 
       
   180         { //make a syncqt script(s) that can be used in the shadow
       
   181             QFile syncqt(buildPath + "/bin/syncqt");
       
   182             if(syncqt.open(QFile::WriteOnly)) {
       
   183                 QTextStream stream(&syncqt);
       
   184                 stream << "#!/usr/bin/perl -w" << endl
       
   185                        << "require \"" << sourcePath + "/bin/syncqt\";" << endl;
       
   186             }
       
   187             QFile syncqt_bat(buildPath + "/bin/syncqt.bat");
       
   188             if(syncqt_bat.open(QFile::WriteOnly)) {
       
   189                 QTextStream stream(&syncqt_bat);
       
   190                 stream << "@echo off" << endl
       
   191                        << "set QTDIR=" << QDir::toNativeSeparators(sourcePath) << endl
       
   192                        << "call " << fixSeparators(sourcePath) << fixSeparators("/bin/syncqt.bat -outdir \"") << fixSeparators(buildPath) << "\"" << endl
       
   193                        << "set QTDIR=" << QDir::toNativeSeparators(buildPath) << endl;
       
   194                 syncqt_bat.close();
       
   195             }
       
   196         }
       
   197 
       
   198         // For Windows CE and shadow builds we need to copy these to the
       
   199         // build directory.
       
   200         QFile::copy(sourcePath + "/bin/setcepaths.bat" , buildPath + "/bin/setcepaths.bat");
       
   201 
       
   202         //copy the mkspecs
       
   203         buildDir.mkpath("mkspecs");
       
   204         if(!Environment::cpdir(sourcePath + "/mkspecs", buildPath + "/mkspecs")){
       
   205             cout << "Couldn't copy mkspecs!" << sourcePath << " " << buildPath << endl;
       
   206             dictionary["DONE"] = "error";
       
   207             return;
       
   208         }
       
   209     }
       
   210 
       
   211     dictionary[ "QT_SOURCE_TREE" ]    = fixSeparators(sourcePath);
       
   212     dictionary[ "QT_BUILD_TREE" ]     = fixSeparators(buildPath);
       
   213     dictionary[ "QT_INSTALL_PREFIX" ] = fixSeparators(installPath);
       
   214 
       
   215     dictionary[ "QMAKESPEC" ] = getenv("QMAKESPEC");
       
   216     if (dictionary[ "QMAKESPEC" ].size() == 0) {
       
   217         dictionary[ "QMAKESPEC" ] = Environment::detectQMakeSpec();
       
   218         dictionary[ "QMAKESPEC_FROM" ] = "detected";
       
   219     } else {
       
   220         dictionary[ "QMAKESPEC_FROM" ] = "env";
       
   221     }
       
   222 
       
   223     dictionary[ "ARCHITECTURE" ]    = "windows";
       
   224     dictionary[ "QCONFIG" ]         = "full";
       
   225     dictionary[ "EMBEDDED" ]        = "no";
       
   226     dictionary[ "BUILD_QMAKE" ]     = "yes";
       
   227     dictionary[ "DSPFILES" ]        = "yes";
       
   228     dictionary[ "VCPROJFILES" ]     = "yes";
       
   229     dictionary[ "QMAKE_INTERNAL" ]  = "no";
       
   230     dictionary[ "FAST" ]            = "no";
       
   231     dictionary[ "NOPROCESS" ]       = "no";
       
   232     dictionary[ "STL" ]             = "yes";
       
   233     dictionary[ "EXCEPTIONS" ]      = "yes";
       
   234     dictionary[ "RTTI" ]            = "yes";
       
   235     dictionary[ "MMX" ]             = "auto";
       
   236     dictionary[ "3DNOW" ]           = "auto";
       
   237     dictionary[ "SSE" ]             = "auto";
       
   238     dictionary[ "SSE2" ]            = "auto";
       
   239     dictionary[ "IWMMXT" ]          = "auto";
       
   240     dictionary[ "SYNCQT" ]          = "auto";
       
   241     dictionary[ "CE_CRT" ]          = "no";
       
   242     dictionary[ "CETEST" ]          = "auto";
       
   243     dictionary[ "CE_SIGNATURE" ]    = "no";
       
   244     dictionary[ "SCRIPT" ]          = "auto";
       
   245     dictionary[ "SCRIPTTOOLS" ]     = "auto";
       
   246     dictionary[ "XMLPATTERNS" ]     = "auto";
       
   247     dictionary[ "PHONON" ]          = "auto";
       
   248     dictionary[ "PHONON_BACKEND" ]  = "yes";
       
   249     dictionary[ "MULTIMEDIA" ]      = "yes";
       
   250     dictionary[ "AUDIO_BACKEND" ]   = "auto";
       
   251     dictionary[ "DIRECTSHOW" ]      = "no";
       
   252     dictionary[ "WEBKIT" ]          = "auto";
       
   253     dictionary[ "DECLARATIVE" ]     = "auto";
       
   254     dictionary[ "PLUGIN_MANIFESTS" ] = "yes";
       
   255 
       
   256     QString version;
       
   257     QFile qglobal_h(sourcePath + "/src/corelib/global/qglobal.h");
       
   258     if (qglobal_h.open(QFile::ReadOnly)) {
       
   259         QTextStream read(&qglobal_h);
       
   260         QRegExp version_regexp("^# *define *QT_VERSION_STR *\"([^\"]*)\"");
       
   261         QString line;
       
   262         while (!read.atEnd()) {
       
   263             line = read.readLine();
       
   264             if (version_regexp.exactMatch(line)) {
       
   265                 version = version_regexp.cap(1).trimmed();
       
   266                 if (!version.isEmpty())
       
   267                     break;
       
   268             }
       
   269         }
       
   270         qglobal_h.close();
       
   271     }
       
   272 
       
   273     if (version.isEmpty())
       
   274         version = QString("%1.%2.%3").arg(QT_VERSION>>16).arg(((QT_VERSION>>8)&0xff)).arg(QT_VERSION&0xff);
       
   275 
       
   276     dictionary[ "VERSION" ]         = version;
       
   277     {
       
   278         QRegExp version_re("([0-9]*)\\.([0-9]*)\\.([0-9]*)(|-.*)");
       
   279         if(version_re.exactMatch(version)) {
       
   280             dictionary[ "VERSION_MAJOR" ] = version_re.cap(1);
       
   281             dictionary[ "VERSION_MINOR" ] = version_re.cap(2);
       
   282             dictionary[ "VERSION_PATCH" ] = version_re.cap(3);
       
   283         }
       
   284     }
       
   285 
       
   286     dictionary[ "REDO" ]            = "no";
       
   287     dictionary[ "DEPENDENCIES" ]    = "no";
       
   288 
       
   289     dictionary[ "BUILD" ]           = "debug";
       
   290     dictionary[ "BUILDALL" ]        = "auto"; // Means yes, but not explicitly
       
   291 
       
   292     dictionary[ "BUILDTYPE" ]      = "none";
       
   293 
       
   294     dictionary[ "BUILDDEV" ]        = "no";
       
   295     dictionary[ "BUILDNOKIA" ]      = "no";
       
   296 
       
   297     dictionary[ "SHARED" ]          = "yes";
       
   298 
       
   299     dictionary[ "ZLIB" ]            = "auto";
       
   300 
       
   301     dictionary[ "GIF" ]             = "auto";
       
   302     dictionary[ "TIFF" ]            = "auto";
       
   303     dictionary[ "JPEG" ]            = "auto";
       
   304     dictionary[ "PNG" ]             = "auto";
       
   305     dictionary[ "MNG" ]             = "auto";
       
   306     dictionary[ "LIBTIFF" ]         = "auto";
       
   307     dictionary[ "LIBJPEG" ]         = "auto";
       
   308     dictionary[ "LIBPNG" ]          = "auto";
       
   309     dictionary[ "LIBMNG" ]          = "auto";
       
   310     dictionary[ "FREETYPE" ]        = "no";
       
   311 
       
   312     dictionary[ "QT3SUPPORT" ]      = "yes";
       
   313     dictionary[ "ACCESSIBILITY" ]   = "yes";
       
   314     dictionary[ "OPENGL" ]          = "yes";
       
   315     dictionary[ "OPENVG" ]          = "no";
       
   316     dictionary[ "IPV6" ]            = "yes"; // Always, dynamicly loaded
       
   317     dictionary[ "OPENSSL" ]         = "auto";
       
   318     dictionary[ "DBUS" ]            = "auto";
       
   319     dictionary[ "S60" ]             = "yes";
       
   320 
       
   321     dictionary[ "STYLE_WINDOWS" ]   = "yes";
       
   322     dictionary[ "STYLE_WINDOWSXP" ] = "auto";
       
   323     dictionary[ "STYLE_WINDOWSVISTA" ] = "auto";
       
   324     dictionary[ "STYLE_PLASTIQUE" ] = "yes";
       
   325     dictionary[ "STYLE_CLEANLOOKS" ]= "yes";
       
   326     dictionary[ "STYLE_WINDOWSCE" ] = "no";
       
   327     dictionary[ "STYLE_WINDOWSMOBILE" ] = "no";
       
   328     dictionary[ "STYLE_MOTIF" ]     = "yes";
       
   329     dictionary[ "STYLE_CDE" ]       = "yes";
       
   330     dictionary[ "STYLE_S60" ]       = "no";
       
   331     dictionary[ "STYLE_GTK" ]       = "no";
       
   332 
       
   333     dictionary[ "SQL_MYSQL" ]       = "no";
       
   334     dictionary[ "SQL_ODBC" ]        = "no";
       
   335     dictionary[ "SQL_OCI" ]         = "no";
       
   336     dictionary[ "SQL_PSQL" ]        = "no";
       
   337     dictionary[ "SQL_TDS" ]         = "no";
       
   338     dictionary[ "SQL_DB2" ]         = "no";
       
   339     dictionary[ "SQL_SQLITE" ]      = "auto";
       
   340     dictionary[ "SQL_SQLITE_LIB" ]  = "qt";
       
   341     dictionary[ "SQL_SQLITE2" ]     = "no";
       
   342     dictionary[ "SQL_IBASE" ]       = "no";
       
   343     dictionary[ "GRAPHICS_SYSTEM" ] = "raster";
       
   344 
       
   345     QString tmp = dictionary[ "QMAKESPEC" ];
       
   346     if (tmp.contains("\\")) {
       
   347         tmp = tmp.mid( tmp.lastIndexOf( "\\" ) + 1 );
       
   348     } else {
       
   349         tmp = tmp.mid( tmp.lastIndexOf("/") + 1 );
       
   350     }
       
   351     dictionary[ "QMAKESPEC" ] = tmp;
       
   352 
       
   353     dictionary[ "INCREDIBUILD_XGE" ] = "auto";
       
   354     dictionary[ "LTCG" ]            = "no";
       
   355     dictionary[ "NATIVE_GESTURES" ] = "yes";
       
   356 }
       
   357 
       
   358 Configure::~Configure()
       
   359 {
       
   360     for (int i=0; i<3; ++i) {
       
   361         QList<MakeItem*> items = makeList[i];
       
   362         for (int j=0; j<items.size(); ++j)
       
   363             delete items[j];
       
   364     }
       
   365 }
       
   366 
       
   367 QString Configure::fixSeparators(QString somePath)
       
   368 {
       
   369     return useUnixSeparators ?
       
   370            QDir::fromNativeSeparators(somePath) :
       
   371            QDir::toNativeSeparators(somePath);
       
   372 }
       
   373 
       
   374 // We could use QDir::homePath() + "/.qt-license", but
       
   375 // that will only look in the first of $HOME,$USERPROFILE
       
   376 // or $HOMEDRIVE$HOMEPATH. So, here we try'em all to be
       
   377 // more forgiving for the end user..
       
   378 QString Configure::firstLicensePath()
       
   379 {
       
   380     QStringList allPaths;
       
   381     allPaths << "./.qt-license"
       
   382              << QString::fromLocal8Bit(getenv("HOME")) + "/.qt-license"
       
   383              << QString::fromLocal8Bit(getenv("USERPROFILE")) + "/.qt-license"
       
   384              << QString::fromLocal8Bit(getenv("HOMEDRIVE")) + QString::fromLocal8Bit(getenv("HOMEPATH")) + "/.qt-license";
       
   385     for (int i = 0; i< allPaths.count(); ++i)
       
   386         if (QFile::exists(allPaths.at(i)))
       
   387             return allPaths.at(i);
       
   388     return QString();
       
   389 }
       
   390 
       
   391 
       
   392 // #### somehow I get a compiler error about vc++ reaching the nesting limit without
       
   393 // undefining the ansi for scoping.
       
   394 #ifdef for
       
   395 #undef for
       
   396 #endif
       
   397 
       
   398 void Configure::parseCmdLine()
       
   399 {
       
   400     int argCount = configCmdLine.size();
       
   401     int i = 0;
       
   402 
       
   403 #if !defined(EVAL)
       
   404     if (argCount < 1) // skip rest if no arguments
       
   405         ;
       
   406     else if( configCmdLine.at(i) == "-redo" ) {
       
   407         dictionary[ "REDO" ] = "yes";
       
   408         configCmdLine.clear();
       
   409         reloadCmdLine();
       
   410     }
       
   411     else if( configCmdLine.at(i) == "-loadconfig" ) {
       
   412         ++i;
       
   413         if (i != argCount) {
       
   414             dictionary[ "REDO" ] = "yes";
       
   415             dictionary[ "CUSTOMCONFIG" ] = "_" + configCmdLine.at(i);
       
   416             configCmdLine.clear();
       
   417             reloadCmdLine();
       
   418         } else {
       
   419             dictionary[ "HELP" ] = "yes";
       
   420         }
       
   421         i = 0;
       
   422     }
       
   423     argCount = configCmdLine.size();
       
   424 #endif
       
   425 
       
   426     // Look first for XQMAKESPEC
       
   427     for(int j = 0 ; j < argCount; ++j)
       
   428     {
       
   429         if( configCmdLine.at(j) == "-xplatform") {
       
   430             ++j;
       
   431             if (j == argCount)
       
   432                 break;
       
   433             dictionary["XQMAKESPEC"] = configCmdLine.at(j);
       
   434             if (!dictionary[ "XQMAKESPEC" ].isEmpty())
       
   435                 applySpecSpecifics();
       
   436         }
       
   437     }
       
   438 
       
   439     for( ; i<configCmdLine.size(); ++i ) {
       
   440         bool continueElse[] = {false, false};
       
   441         if( configCmdLine.at(i) == "-help"
       
   442             || configCmdLine.at(i) == "-h"
       
   443             || configCmdLine.at(i) == "-?" )
       
   444             dictionary[ "HELP" ] = "yes";
       
   445 
       
   446 #if !defined(EVAL)
       
   447         else if( configCmdLine.at(i) == "-qconfig" ) {
       
   448             ++i;
       
   449             if (i==argCount)
       
   450                 break;
       
   451             dictionary[ "QCONFIG" ] = configCmdLine.at(i);
       
   452         }
       
   453 
       
   454         else if ( configCmdLine.at(i) == "-buildkey" ) {
       
   455             ++i;
       
   456             if (i==argCount)
       
   457                 break;
       
   458             dictionary[ "USER_BUILD_KEY" ] = configCmdLine.at(i);
       
   459         }
       
   460 
       
   461         else if( configCmdLine.at(i) == "-release" ) {
       
   462             dictionary[ "BUILD" ] = "release";
       
   463             if (dictionary[ "BUILDALL" ] == "auto")
       
   464                 dictionary[ "BUILDALL" ] = "no";
       
   465         } else if( configCmdLine.at(i) == "-debug" ) {
       
   466             dictionary[ "BUILD" ] = "debug";
       
   467             if (dictionary[ "BUILDALL" ] == "auto")
       
   468                 dictionary[ "BUILDALL" ] = "no";
       
   469         } else if( configCmdLine.at(i) == "-debug-and-release" )
       
   470             dictionary[ "BUILDALL" ] = "yes";
       
   471 
       
   472         else if( configCmdLine.at(i) == "-shared" )
       
   473             dictionary[ "SHARED" ] = "yes";
       
   474         else if( configCmdLine.at(i) == "-static" )
       
   475             dictionary[ "SHARED" ] = "no";
       
   476         else if( configCmdLine.at(i) == "-developer-build" )
       
   477             dictionary[ "BUILDDEV" ] = "yes";
       
   478         else if( configCmdLine.at(i) == "-nokia-developer" ) {
       
   479             cout << "Detected -nokia-developer option" << endl;
       
   480             cout << "Nokia employees and agents are allowed to use this software under" << endl;
       
   481             cout << "the authority of Nokia Corporation and/or its subsidiary(-ies)" << endl;
       
   482             dictionary[ "BUILDNOKIA" ] = "yes";
       
   483             dictionary[ "BUILDDEV" ] = "yes";
       
   484             dictionary["LICENSE_CONFIRMED"] = "yes";
       
   485             if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith("symbian")) {
       
   486                 dictionary[ "SYMBIAN_DEFFILES" ] = "no";
       
   487             }
       
   488         }
       
   489         else if( configCmdLine.at(i) == "-opensource" ) {
       
   490             dictionary[ "BUILDTYPE" ] = "opensource";
       
   491         }
       
   492         else if( configCmdLine.at(i) == "-commercial" ) {
       
   493             dictionary[ "BUILDTYPE" ] = "commercial";
       
   494         }
       
   495         else if( configCmdLine.at(i) == "-ltcg" ) {
       
   496             dictionary[ "LTCG" ] = "yes";
       
   497         }
       
   498         else if( configCmdLine.at(i) == "-no-ltcg" ) {
       
   499             dictionary[ "LTCG" ] = "no";
       
   500         }
       
   501 #endif
       
   502 
       
   503         else if( configCmdLine.at(i) == "-platform" ) {
       
   504             ++i;
       
   505             if (i==argCount)
       
   506                 break;
       
   507             dictionary[ "QMAKESPEC" ] = configCmdLine.at(i);
       
   508         dictionary[ "QMAKESPEC_FROM" ] = "commandline";
       
   509         } else if( configCmdLine.at(i) == "-arch" ) {
       
   510             ++i;
       
   511             if (i==argCount)
       
   512                 break;
       
   513             dictionary[ "ARCHITECTURE" ] = configCmdLine.at(i);
       
   514             if (configCmdLine.at(i) == "boundschecker") {
       
   515                 dictionary[ "ARCHITECTURE" ] = "generic";   // Boundschecker uses the generic arch,
       
   516                 qtConfig += "boundschecker";                // but also needs this CONFIG option
       
   517             }
       
   518         } else if( configCmdLine.at(i) == "-embedded" ) {
       
   519             dictionary[ "EMBEDDED" ] = "yes";
       
   520         } else if( configCmdLine.at(i) == "-xplatform") {
       
   521             ++i;
       
   522             // do nothing
       
   523         }
       
   524 
       
   525 
       
   526 #if !defined(EVAL)
       
   527         else if( configCmdLine.at(i) == "-no-zlib" ) {
       
   528             // No longer supported since Qt 4.4.0
       
   529             // But save the information for later so that we can print a warning
       
   530             //
       
   531             // If you REALLY really need no zlib support, you can still disable
       
   532             // it by doing the following:
       
   533             //   add "no-zlib" to mkspecs/qconfig.pri
       
   534             //   #define QT_NO_COMPRESS (probably by adding to src/corelib/global/qconfig.h)
       
   535             //
       
   536             // There's no guarantee that Qt will build under those conditions
       
   537 
       
   538             dictionary[ "ZLIB_FORCED" ] = "yes";
       
   539         } else if( configCmdLine.at(i) == "-qt-zlib" ) {
       
   540             dictionary[ "ZLIB" ] = "qt";
       
   541         } else if( configCmdLine.at(i) == "-system-zlib" ) {
       
   542             dictionary[ "ZLIB" ] = "system";
       
   543         }
       
   544 
       
   545         // Image formats --------------------------------------------
       
   546         else if( configCmdLine.at(i) == "-no-gif" )
       
   547             dictionary[ "GIF" ] = "no";
       
   548         else if( configCmdLine.at(i) == "-qt-gif" )
       
   549             dictionary[ "GIF" ] = "auto";
       
   550 
       
   551         else if( configCmdLine.at(i) == "-no-libtiff" ) {
       
   552               dictionary[ "TIFF"] = "no";
       
   553               dictionary[ "LIBTIFF" ] = "no";
       
   554         } else if( configCmdLine.at(i) == "-qt-libtiff" ) {
       
   555             dictionary[ "TIFF" ] = "plugin";
       
   556             dictionary[ "LIBTIFF" ] = "qt";
       
   557         } else if( configCmdLine.at(i) == "-system-libtiff" ) {
       
   558               dictionary[ "TIFF" ] = "plugin";
       
   559               dictionary[ "LIBTIFF" ] = "system";
       
   560         }
       
   561 
       
   562         else if( configCmdLine.at(i) == "-no-libjpeg" ) {
       
   563             dictionary[ "JPEG" ] = "no";
       
   564             dictionary[ "LIBJPEG" ] = "no";
       
   565         } else if( configCmdLine.at(i) == "-qt-libjpeg" ) {
       
   566             dictionary[ "JPEG" ] = "plugin";
       
   567             dictionary[ "LIBJPEG" ] = "qt";
       
   568         } else if( configCmdLine.at(i) == "-system-libjpeg" ) {
       
   569             dictionary[ "JPEG" ] = "plugin";
       
   570             dictionary[ "LIBJPEG" ] = "system";
       
   571         }
       
   572 
       
   573         else if( configCmdLine.at(i) == "-no-libpng" ) {
       
   574             dictionary[ "PNG" ] = "no";
       
   575             dictionary[ "LIBPNG" ] = "no";
       
   576         } else if( configCmdLine.at(i) == "-qt-libpng" ) {
       
   577             dictionary[ "PNG" ] = "qt";
       
   578             dictionary[ "LIBPNG" ] = "qt";
       
   579         } else if( configCmdLine.at(i) == "-system-libpng" ) {
       
   580             dictionary[ "PNG" ] = "qt";
       
   581             dictionary[ "LIBPNG" ] = "system";
       
   582         }
       
   583 
       
   584         else if( configCmdLine.at(i) == "-no-libmng" ) {
       
   585             dictionary[ "MNG" ] = "no";
       
   586             dictionary[ "LIBMNG" ] = "no";
       
   587         } else if( configCmdLine.at(i) == "-qt-libmng" ) {
       
   588             dictionary[ "MNG" ] = "qt";
       
   589             dictionary[ "LIBMNG" ] = "qt";
       
   590         } else if( configCmdLine.at(i) == "-system-libmng" ) {
       
   591             dictionary[ "MNG" ] = "qt";
       
   592             dictionary[ "LIBMNG" ] = "system";
       
   593         }
       
   594 
       
   595         // Text Rendering --------------------------------------------
       
   596         else if( configCmdLine.at(i) == "-no-freetype" )
       
   597             dictionary[ "FREETYPE" ] = "no";
       
   598         else if( configCmdLine.at(i) == "-qt-freetype" )
       
   599             dictionary[ "FREETYPE" ] = "yes";
       
   600 
       
   601         // CE- C runtime --------------------------------------------
       
   602         else if( configCmdLine.at(i) == "-crt" ) {
       
   603             ++i;
       
   604             if (i==argCount)
       
   605                 break;
       
   606             QDir cDir(configCmdLine.at(i));
       
   607             if (!cDir.exists())
       
   608                 cout << "WARNING: Could not find directory (" << qPrintable(configCmdLine.at(i)) << ")for C runtime deployment" << endl;
       
   609             else
       
   610                 dictionary[ "CE_CRT" ] = QDir::toNativeSeparators(cDir.absolutePath());
       
   611         } else if (configCmdLine.at(i) == "-qt-crt") {
       
   612             dictionary[ "CE_CRT" ] = "yes";
       
   613         } else if (configCmdLine.at(i) == "-no-crt") {
       
   614             dictionary[ "CE_CRT" ] = "no";
       
   615         }
       
   616         // cetest ---------------------------------------------------
       
   617         else if (configCmdLine.at(i) == "-no-cetest") {
       
   618             dictionary[ "CETEST" ] = "no";
       
   619             dictionary[ "CETEST_REQUESTED" ] = "no";
       
   620         } else if (configCmdLine.at(i) == "-cetest") {
       
   621             // although specified to use it, we stay at "auto" state
       
   622             // this is because checkAvailability() adds variables
       
   623             // we need for crosscompilation; but remember if we asked
       
   624             // for it.
       
   625             dictionary[ "CETEST_REQUESTED" ] = "yes";
       
   626         }
       
   627         // Qt/CE - signing tool -------------------------------------
       
   628         else if( configCmdLine.at(i) == "-signature") {
       
   629             ++i;
       
   630             if (i==argCount)
       
   631                 break;
       
   632             QFileInfo info(configCmdLine.at(i));
       
   633             if (!info.exists())
       
   634                 cout << "WARNING: Could not find signature file (" << qPrintable(configCmdLine.at(i)) << ")" << endl;
       
   635             else
       
   636                 dictionary[ "CE_SIGNATURE" ] = QDir::toNativeSeparators(info.absoluteFilePath());
       
   637         }
       
   638         // Styles ---------------------------------------------------
       
   639         else if( configCmdLine.at(i) == "-qt-style-windows" )
       
   640             dictionary[ "STYLE_WINDOWS" ] = "yes";
       
   641         else if( configCmdLine.at(i) == "-no-style-windows" )
       
   642             dictionary[ "STYLE_WINDOWS" ] = "no";
       
   643 
       
   644         else if( configCmdLine.at(i) == "-qt-style-windowsce" )
       
   645             dictionary[ "STYLE_WINDOWSCE" ] = "yes";
       
   646         else if( configCmdLine.at(i) == "-no-style-windowsce" )
       
   647             dictionary[ "STYLE_WINDOWSCE" ] = "no";
       
   648         else if( configCmdLine.at(i) == "-qt-style-windowsmobile" )
       
   649             dictionary[ "STYLE_WINDOWSMOBILE" ] = "yes";
       
   650         else if( configCmdLine.at(i) == "-no-style-windowsmobile" )
       
   651             dictionary[ "STYLE_WINDOWSMOBILE" ] = "no";
       
   652 
       
   653         else if( configCmdLine.at(i) == "-qt-style-windowsxp" )
       
   654             dictionary[ "STYLE_WINDOWSXP" ] = "yes";
       
   655         else if( configCmdLine.at(i) == "-no-style-windowsxp" )
       
   656             dictionary[ "STYLE_WINDOWSXP" ] = "no";
       
   657 
       
   658         else if( configCmdLine.at(i) == "-qt-style-windowsvista" )
       
   659             dictionary[ "STYLE_WINDOWSVISTA" ] = "yes";
       
   660         else if( configCmdLine.at(i) == "-no-style-windowsvista" )
       
   661             dictionary[ "STYLE_WINDOWSVISTA" ] = "no";
       
   662 
       
   663         else if( configCmdLine.at(i) == "-qt-style-plastique" )
       
   664             dictionary[ "STYLE_PLASTIQUE" ] = "yes";
       
   665         else if( configCmdLine.at(i) == "-no-style-plastique" )
       
   666             dictionary[ "STYLE_PLASTIQUE" ] = "no";
       
   667 
       
   668         else if( configCmdLine.at(i) == "-qt-style-cleanlooks" )
       
   669             dictionary[ "STYLE_CLEANLOOKS" ] = "yes";
       
   670         else if( configCmdLine.at(i) == "-no-style-cleanlooks" )
       
   671             dictionary[ "STYLE_CLEANLOOKS" ] = "no";
       
   672 
       
   673         else if( configCmdLine.at(i) == "-qt-style-motif" )
       
   674             dictionary[ "STYLE_MOTIF" ] = "yes";
       
   675         else if( configCmdLine.at(i) == "-no-style-motif" )
       
   676             dictionary[ "STYLE_MOTIF" ] = "no";
       
   677 
       
   678         else if( configCmdLine.at(i) == "-qt-style-cde" )
       
   679             dictionary[ "STYLE_CDE" ] = "yes";
       
   680         else if( configCmdLine.at(i) == "-no-style-cde" )
       
   681             dictionary[ "STYLE_CDE" ] = "no";
       
   682 
       
   683         else if( configCmdLine.at(i) == "-qt-style-s60" )
       
   684             dictionary[ "STYLE_S60" ] = "yes";
       
   685         else if( configCmdLine.at(i) == "-no-style-s60" )
       
   686             dictionary[ "STYLE_S60" ] = "no";
       
   687 
       
   688         // Qt 3 Support ---------------------------------------------
       
   689         else if( configCmdLine.at(i) == "-no-qt3support" )
       
   690             dictionary[ "QT3SUPPORT" ] = "no";
       
   691 
       
   692         // Work around compiler nesting limitation
       
   693         else
       
   694             continueElse[1] = true;
       
   695         if (!continueElse[1]) {
       
   696         }
       
   697 
       
   698         // OpenGL Support -------------------------------------------
       
   699         else if( configCmdLine.at(i) == "-no-opengl" ) {
       
   700             dictionary[ "OPENGL" ]    = "no";
       
   701         } else if ( configCmdLine.at(i) == "-opengl-es-cm" ) {
       
   702             dictionary[ "OPENGL" ]          = "yes";
       
   703             dictionary[ "OPENGL_ES_CM" ]    = "yes";
       
   704         } else if ( configCmdLine.at(i) == "-opengl-es-cl" ) {
       
   705             dictionary[ "OPENGL" ]          = "yes";
       
   706             dictionary[ "OPENGL_ES_CL" ]    = "yes";
       
   707         } else if ( configCmdLine.at(i) == "-opengl-es-2" ) {
       
   708             dictionary[ "OPENGL" ]          = "yes";
       
   709             dictionary[ "OPENGL_ES_2" ]     = "yes";
       
   710         }
       
   711 
       
   712         // OpenVG Support -------------------------------------------
       
   713         else if( configCmdLine.at(i) == "-openvg" ) {
       
   714             dictionary[ "OPENVG" ]    = "yes";
       
   715         } else if( configCmdLine.at(i) == "-no-openvg" ) {
       
   716             dictionary[ "OPENVG" ]    = "no";
       
   717         }
       
   718 
       
   719         // Databases ------------------------------------------------
       
   720         else if( configCmdLine.at(i) == "-qt-sql-mysql" )
       
   721             dictionary[ "SQL_MYSQL" ] = "yes";
       
   722         else if( configCmdLine.at(i) == "-plugin-sql-mysql" )
       
   723             dictionary[ "SQL_MYSQL" ] = "plugin";
       
   724         else if( configCmdLine.at(i) == "-no-sql-mysql" )
       
   725             dictionary[ "SQL_MYSQL" ] = "no";
       
   726 
       
   727         else if( configCmdLine.at(i) == "-qt-sql-odbc" )
       
   728             dictionary[ "SQL_ODBC" ] = "yes";
       
   729         else if( configCmdLine.at(i) == "-plugin-sql-odbc" )
       
   730             dictionary[ "SQL_ODBC" ] = "plugin";
       
   731         else if( configCmdLine.at(i) == "-no-sql-odbc" )
       
   732             dictionary[ "SQL_ODBC" ] = "no";
       
   733 
       
   734         else if( configCmdLine.at(i) == "-qt-sql-oci" )
       
   735             dictionary[ "SQL_OCI" ] = "yes";
       
   736         else if( configCmdLine.at(i) == "-plugin-sql-oci" )
       
   737             dictionary[ "SQL_OCI" ] = "plugin";
       
   738         else if( configCmdLine.at(i) == "-no-sql-oci" )
       
   739             dictionary[ "SQL_OCI" ] = "no";
       
   740 
       
   741         else if( configCmdLine.at(i) == "-qt-sql-psql" )
       
   742             dictionary[ "SQL_PSQL" ] = "yes";
       
   743         else if( configCmdLine.at(i) == "-plugin-sql-psql" )
       
   744             dictionary[ "SQL_PSQL" ] = "plugin";
       
   745         else if( configCmdLine.at(i) == "-no-sql-psql" )
       
   746             dictionary[ "SQL_PSQL" ] = "no";
       
   747 
       
   748         else if( configCmdLine.at(i) == "-qt-sql-tds" )
       
   749             dictionary[ "SQL_TDS" ] = "yes";
       
   750         else if( configCmdLine.at(i) == "-plugin-sql-tds" )
       
   751             dictionary[ "SQL_TDS" ] = "plugin";
       
   752         else if( configCmdLine.at(i) == "-no-sql-tds" )
       
   753             dictionary[ "SQL_TDS" ] = "no";
       
   754 
       
   755         else if( configCmdLine.at(i) == "-qt-sql-db2" )
       
   756             dictionary[ "SQL_DB2" ] = "yes";
       
   757         else if( configCmdLine.at(i) == "-plugin-sql-db2" )
       
   758             dictionary[ "SQL_DB2" ] = "plugin";
       
   759         else if( configCmdLine.at(i) == "-no-sql-db2" )
       
   760             dictionary[ "SQL_DB2" ] = "no";
       
   761 
       
   762         else if( configCmdLine.at(i) == "-qt-sql-sqlite" )
       
   763             dictionary[ "SQL_SQLITE" ] = "yes";
       
   764         else if( configCmdLine.at(i) == "-plugin-sql-sqlite" )
       
   765             dictionary[ "SQL_SQLITE" ] = "plugin";
       
   766         else if( configCmdLine.at(i) == "-no-sql-sqlite" )
       
   767             dictionary[ "SQL_SQLITE" ] = "no";
       
   768         else if( configCmdLine.at(i) == "-system-sqlite" )
       
   769             dictionary[ "SQL_SQLITE_LIB" ] = "system";
       
   770         else if( configCmdLine.at(i) == "-qt-sql-sqlite2" )
       
   771             dictionary[ "SQL_SQLITE2" ] = "yes";
       
   772         else if( configCmdLine.at(i) == "-plugin-sql-sqlite2" )
       
   773             dictionary[ "SQL_SQLITE2" ] = "plugin";
       
   774         else if( configCmdLine.at(i) == "-no-sql-sqlite2" )
       
   775             dictionary[ "SQL_SQLITE2" ] = "no";
       
   776 
       
   777         else if( configCmdLine.at(i) == "-qt-sql-ibase" )
       
   778             dictionary[ "SQL_IBASE" ] = "yes";
       
   779         else if( configCmdLine.at(i) == "-plugin-sql-ibase" )
       
   780             dictionary[ "SQL_IBASE" ] = "plugin";
       
   781         else if( configCmdLine.at(i) == "-no-sql-ibase" )
       
   782             dictionary[ "SQL_IBASE" ] = "no";
       
   783 #endif
       
   784         // IDE project generation -----------------------------------
       
   785         else if( configCmdLine.at(i) == "-no-dsp" )
       
   786             dictionary[ "DSPFILES" ] = "no";
       
   787         else if( configCmdLine.at(i) == "-dsp" )
       
   788             dictionary[ "DSPFILES" ] = "yes";
       
   789 
       
   790         else if( configCmdLine.at(i) == "-no-vcp" )
       
   791             dictionary[ "VCPFILES" ] = "no";
       
   792         else if( configCmdLine.at(i) == "-vcp" )
       
   793             dictionary[ "VCPFILES" ] = "yes";
       
   794 
       
   795         else if( configCmdLine.at(i) == "-no-vcproj" )
       
   796             dictionary[ "VCPROJFILES" ] = "no";
       
   797         else if( configCmdLine.at(i) == "-vcproj" )
       
   798             dictionary[ "VCPROJFILES" ] = "yes";
       
   799 
       
   800         else if( configCmdLine.at(i) == "-no-incredibuild-xge" )
       
   801             dictionary[ "INCREDIBUILD_XGE" ] = "no";
       
   802         else if( configCmdLine.at(i) == "-incredibuild-xge" )
       
   803             dictionary[ "INCREDIBUILD_XGE" ] = "yes";
       
   804         else if( configCmdLine.at(i) == "-native-gestures" )
       
   805             dictionary[ "NATIVE_GESTURES" ] = "yes";
       
   806         else if( configCmdLine.at(i) == "-no-native-gestures" )
       
   807             dictionary[ "NATIVE_GESTURES" ] = "no";
       
   808 #if !defined(EVAL)
       
   809         // Symbian Support -------------------------------------------
       
   810         else if (configCmdLine.at(i) == "-fpu" )
       
   811         {
       
   812             ++i;
       
   813             if(i==argCount)
       
   814                 break;
       
   815             dictionary[ "ARM_FPU_TYPE" ] = configCmdLine.at(i);
       
   816         }
       
   817 
       
   818         else if( configCmdLine.at(i) == "-s60" )
       
   819             dictionary[ "S60" ]    = "yes";
       
   820         else if( configCmdLine.at(i) == "-no-s60" )
       
   821             dictionary[ "S60" ]    = "no";
       
   822 
       
   823         else if( configCmdLine.at(i) == "-usedeffiles" )
       
   824             dictionary[ "SYMBIAN_DEFFILES" ] = "yes";
       
   825         else if( configCmdLine.at(i) == "-no-usedeffiles" )
       
   826             dictionary[ "SYMBIAN_DEFFILES" ] = "no";
       
   827 
       
   828         // Others ---------------------------------------------------
       
   829         else if (configCmdLine.at(i) == "-fast" )
       
   830             dictionary[ "FAST" ] = "yes";
       
   831         else if (configCmdLine.at(i) == "-no-fast" )
       
   832             dictionary[ "FAST" ] = "no";
       
   833 
       
   834         else if( configCmdLine.at(i) == "-stl" )
       
   835             dictionary[ "STL" ] = "yes";
       
   836         else if( configCmdLine.at(i) == "-no-stl" )
       
   837             dictionary[ "STL" ] = "no";
       
   838 
       
   839         else if ( configCmdLine.at(i) == "-exceptions" )
       
   840             dictionary[ "EXCEPTIONS" ] = "yes";
       
   841         else if ( configCmdLine.at(i) == "-no-exceptions" )
       
   842             dictionary[ "EXCEPTIONS" ] = "no";
       
   843 
       
   844         else if ( configCmdLine.at(i) == "-rtti" )
       
   845             dictionary[ "RTTI" ] = "yes";
       
   846         else if ( configCmdLine.at(i) == "-no-rtti" )
       
   847             dictionary[ "RTTI" ] = "no";
       
   848 
       
   849         else if( configCmdLine.at(i) == "-accessibility" )
       
   850             dictionary[ "ACCESSIBILITY" ] = "yes";
       
   851         else if( configCmdLine.at(i) == "-no-accessibility" ) {
       
   852             dictionary[ "ACCESSIBILITY" ] = "no";
       
   853             cout << "Setting accessibility to NO" << endl;
       
   854         }
       
   855 
       
   856         else if (configCmdLine.at(i) == "-no-mmx")
       
   857             dictionary[ "MMX" ] = "no";
       
   858         else if (configCmdLine.at(i) == "-mmx")
       
   859             dictionary[ "MMX" ] = "yes";
       
   860         else if (configCmdLine.at(i) == "-no-3dnow")
       
   861             dictionary[ "3DNOW" ] = "no";
       
   862         else if (configCmdLine.at(i) == "-3dnow")
       
   863             dictionary[ "3DNOW" ] = "yes";
       
   864         else if (configCmdLine.at(i) == "-no-sse")
       
   865             dictionary[ "SSE" ] = "no";
       
   866         else if (configCmdLine.at(i) == "-sse")
       
   867             dictionary[ "SSE" ] = "yes";
       
   868         else if (configCmdLine.at(i) == "-no-sse2")
       
   869             dictionary[ "SSE2" ] = "no";
       
   870         else if (configCmdLine.at(i) == "-sse2")
       
   871             dictionary[ "SSE2" ] = "yes";
       
   872         else if (configCmdLine.at(i) == "-no-iwmmxt")
       
   873             dictionary[ "IWMMXT" ] = "no";
       
   874         else if (configCmdLine.at(i) == "-iwmmxt")
       
   875             dictionary[ "IWMMXT" ] = "yes";
       
   876 
       
   877         else if( configCmdLine.at(i) == "-no-openssl" ) {
       
   878               dictionary[ "OPENSSL"] = "no";
       
   879         } else if( configCmdLine.at(i) == "-openssl" ) {
       
   880               dictionary[ "OPENSSL" ] = "yes";
       
   881         } else if( configCmdLine.at(i) == "-openssl-linked" ) {
       
   882               dictionary[ "OPENSSL" ] = "linked";
       
   883         } else if( configCmdLine.at(i) == "-no-qdbus" ) {
       
   884             dictionary[ "DBUS" ] = "no";
       
   885         } else if( configCmdLine.at(i) == "-qdbus" ) {
       
   886             dictionary[ "DBUS" ] = "yes";
       
   887         } else if( configCmdLine.at(i) == "-no-dbus" ) {
       
   888             dictionary[ "DBUS" ] = "no";
       
   889         } else if( configCmdLine.at(i) == "-dbus" ) {
       
   890             dictionary[ "DBUS" ] = "yes";
       
   891         } else if( configCmdLine.at(i) == "-dbus-linked" ) {
       
   892             dictionary[ "DBUS" ] = "linked";
       
   893         } else if( configCmdLine.at(i) == "-no-script" ) {
       
   894             dictionary[ "SCRIPT" ] = "no";
       
   895         } else if( configCmdLine.at(i) == "-script" ) {
       
   896             dictionary[ "SCRIPT" ] = "yes";
       
   897         } else if( configCmdLine.at(i) == "-no-scripttools" ) {
       
   898             dictionary[ "SCRIPTTOOLS" ] = "no";
       
   899         } else if( configCmdLine.at(i) == "-scripttools" ) {
       
   900             dictionary[ "SCRIPTTOOLS" ] = "yes";
       
   901         } else if( configCmdLine.at(i) == "-no-xmlpatterns" ) {
       
   902             dictionary[ "XMLPATTERNS" ] = "no";
       
   903         } else if( configCmdLine.at(i) == "-xmlpatterns" ) {
       
   904             dictionary[ "XMLPATTERNS" ] = "yes";
       
   905         } else if( configCmdLine.at(i) == "-no-multimedia" ) {
       
   906             dictionary[ "MULTIMEDIA" ] = "no";
       
   907         } else if( configCmdLine.at(i) == "-multimedia" ) {
       
   908             dictionary[ "MULTIMEDIA" ] = "yes";
       
   909         } else if( configCmdLine.at(i) == "-audio-backend" ) {
       
   910             dictionary[ "AUDIO_BACKEND" ] = "yes";
       
   911         } else if( configCmdLine.at(i) == "-no-audio-backend" ) {
       
   912             dictionary[ "AUDIO_BACKEND" ] = "no";
       
   913         } else if( configCmdLine.at(i) == "-no-phonon" ) {
       
   914             dictionary[ "PHONON" ] = "no";
       
   915         } else if( configCmdLine.at(i) == "-phonon" ) {
       
   916             dictionary[ "PHONON" ] = "yes";
       
   917         } else if( configCmdLine.at(i) == "-no-phonon-backend" ) {
       
   918             dictionary[ "PHONON_BACKEND" ] = "no";
       
   919         } else if( configCmdLine.at(i) == "-phonon-backend" ) {
       
   920             dictionary[ "PHONON_BACKEND" ] = "yes";
       
   921         } else if( configCmdLine.at(i) == "-phonon-wince-ds9" ) {
       
   922             dictionary[ "DIRECTSHOW" ] = "yes";
       
   923         } else if( configCmdLine.at(i) == "-no-webkit" ) {
       
   924             dictionary[ "WEBKIT" ] = "no";
       
   925         } else if( configCmdLine.at(i) == "-webkit" ) {
       
   926             dictionary[ "WEBKIT" ] = "yes";
       
   927         } else if( configCmdLine.at(i) == "-no-declarative" ) {
       
   928             dictionary[ "DECLARATIVE" ] = "no";
       
   929         } else if( configCmdLine.at(i) == "-declarative" ) {
       
   930             dictionary[ "DECLARATIVE" ] = "yes";
       
   931         } else if( configCmdLine.at(i) == "-no-plugin-manifests" ) {
       
   932             dictionary[ "PLUGIN_MANIFESTS" ] = "no";
       
   933         } else if( configCmdLine.at(i) == "-plugin-manifests" ) {
       
   934             dictionary[ "PLUGIN_MANIFESTS" ] = "yes";
       
   935         }
       
   936 
       
   937         // Work around compiler nesting limitation
       
   938         else
       
   939             continueElse[0] = true;
       
   940         if (!continueElse[0]) {
       
   941         }
       
   942 
       
   943         else if( configCmdLine.at(i) == "-internal" )
       
   944             dictionary[ "QMAKE_INTERNAL" ] = "yes";
       
   945 
       
   946         else if( configCmdLine.at(i) == "-no-qmake" )
       
   947             dictionary[ "BUILD_QMAKE" ] = "no";
       
   948         else if( configCmdLine.at(i) == "-qmake" )
       
   949             dictionary[ "BUILD_QMAKE" ] = "yes";
       
   950 
       
   951         else if( configCmdLine.at(i) == "-dont-process" )
       
   952             dictionary[ "NOPROCESS" ] = "yes";
       
   953         else if( configCmdLine.at(i) == "-process" )
       
   954             dictionary[ "NOPROCESS" ] = "no";
       
   955 
       
   956         else if( configCmdLine.at(i) == "-no-qmake-deps" )
       
   957             dictionary[ "DEPENDENCIES" ] = "no";
       
   958         else if( configCmdLine.at(i) == "-qmake-deps" )
       
   959             dictionary[ "DEPENDENCIES" ] = "yes";
       
   960 
       
   961 
       
   962         else if( configCmdLine.at(i) == "-qtnamespace" ) {
       
   963             ++i;
       
   964             if(i==argCount)
       
   965                 break;
       
   966             qmakeDefines += "QT_NAMESPACE="+configCmdLine.at(i);
       
   967         } else if( configCmdLine.at(i) == "-qtlibinfix" ) {
       
   968             ++i;
       
   969             if(i==argCount)
       
   970                 break;
       
   971             dictionary[ "QT_LIBINFIX" ] = configCmdLine.at(i);
       
   972             if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith("symbian")) {
       
   973                 dictionary[ "QT_INSTALL_PLUGINS" ] =
       
   974                     QString("\\resource\\qt%1\\plugins").arg(dictionary[ "QT_LIBINFIX" ]);
       
   975             }
       
   976         } else if( configCmdLine.at(i) == "-D" ) {
       
   977             ++i;
       
   978             if (i==argCount)
       
   979                 break;
       
   980             qmakeDefines += configCmdLine.at(i);
       
   981         } else if( configCmdLine.at(i) == "-I" ) {
       
   982             ++i;
       
   983             if (i==argCount)
       
   984                 break;
       
   985             qmakeIncludes += configCmdLine.at(i);
       
   986         } else if( configCmdLine.at(i) == "-L" ) {
       
   987             ++i;
       
   988             if (i==argCount)
       
   989                 break;
       
   990             QFileInfo check(configCmdLine.at(i));
       
   991             if (!check.isDir()) {
       
   992                 cout << "Argument passed to -L option is not a directory path. Did you mean the -l option?" << endl;
       
   993                 dictionary[ "DONE" ] = "error";
       
   994                 break;
       
   995             }
       
   996             qmakeLibs += QString("-L" + configCmdLine.at(i));
       
   997         } else if( configCmdLine.at(i) == "-l" ) {
       
   998             ++i;
       
   999             if (i==argCount)
       
  1000                 break;
       
  1001             qmakeLibs += QString("-l" + configCmdLine.at(i));
       
  1002         } else if (configCmdLine.at(i).startsWith("OPENSSL_LIBS=")) {
       
  1003             opensslLibs = configCmdLine.at(i);
       
  1004         }
       
  1005 
       
  1006         else if( ( configCmdLine.at(i) == "-override-version" ) || ( configCmdLine.at(i) == "-version-override" ) ){
       
  1007             ++i;
       
  1008             if (i==argCount)
       
  1009                 break;
       
  1010             dictionary[ "VERSION" ] = configCmdLine.at(i);
       
  1011         }
       
  1012 
       
  1013         else if( configCmdLine.at(i) == "-saveconfig" ) {
       
  1014             ++i;
       
  1015             if (i==argCount)
       
  1016                 break;
       
  1017             dictionary[ "CUSTOMCONFIG" ] = "_" + configCmdLine.at(i);
       
  1018         }
       
  1019 
       
  1020         else if (configCmdLine.at(i) == "-confirm-license") {
       
  1021             dictionary["LICENSE_CONFIRMED"] = "yes";
       
  1022         }
       
  1023 
       
  1024         else if (configCmdLine.at(i) == "-nomake") {
       
  1025             ++i;
       
  1026             if (i==argCount)
       
  1027                 break;
       
  1028             disabledBuildParts += configCmdLine.at(i);
       
  1029         }
       
  1030 
       
  1031         // Directories ----------------------------------------------
       
  1032         else if( configCmdLine.at(i) == "-prefix" ) {
       
  1033             ++i;
       
  1034             if(i==argCount)
       
  1035                 break;
       
  1036             dictionary[ "QT_INSTALL_PREFIX" ] = configCmdLine.at(i);
       
  1037         }
       
  1038 
       
  1039         else if( configCmdLine.at(i) == "-bindir" ) {
       
  1040             ++i;
       
  1041             if(i==argCount)
       
  1042                 break;
       
  1043             dictionary[ "QT_INSTALL_BINS" ] = configCmdLine.at(i);
       
  1044         }
       
  1045 
       
  1046         else if( configCmdLine.at(i) == "-libdir" ) {
       
  1047             ++i;
       
  1048             if(i==argCount)
       
  1049                 break;
       
  1050             dictionary[ "QT_INSTALL_LIBS" ] = configCmdLine.at(i);
       
  1051         }
       
  1052 
       
  1053         else if( configCmdLine.at(i) == "-docdir" ) {
       
  1054             ++i;
       
  1055             if(i==argCount)
       
  1056                 break;
       
  1057             dictionary[ "QT_INSTALL_DOCS" ] = configCmdLine.at(i);
       
  1058         }
       
  1059 
       
  1060         else if( configCmdLine.at(i) == "-headerdir" ) {
       
  1061             ++i;
       
  1062             if(i==argCount)
       
  1063                 break;
       
  1064             dictionary[ "QT_INSTALL_HEADERS" ] = configCmdLine.at(i);
       
  1065         }
       
  1066 
       
  1067         else if( configCmdLine.at(i) == "-plugindir" ) {
       
  1068             ++i;
       
  1069             if(i==argCount)
       
  1070                 break;
       
  1071             dictionary[ "QT_INSTALL_PLUGINS" ] = configCmdLine.at(i);
       
  1072         }
       
  1073 
       
  1074         else if( configCmdLine.at(i) == "-datadir" ) {
       
  1075             ++i;
       
  1076             if(i==argCount)
       
  1077                 break;
       
  1078             dictionary[ "QT_INSTALL_DATA" ] = configCmdLine.at(i);
       
  1079         }
       
  1080 
       
  1081         else if( configCmdLine.at(i) == "-translationdir" ) {
       
  1082             ++i;
       
  1083             if(i==argCount)
       
  1084                 break;
       
  1085             dictionary[ "QT_INSTALL_TRANSLATIONS" ] = configCmdLine.at(i);
       
  1086         }
       
  1087 
       
  1088         else if( configCmdLine.at(i) == "-examplesdir" ) {
       
  1089             ++i;
       
  1090             if(i==argCount)
       
  1091                 break;
       
  1092             dictionary[ "QT_INSTALL_EXAMPLES" ] = configCmdLine.at(i);
       
  1093         }
       
  1094 
       
  1095         else if( configCmdLine.at(i) == "-demosdir" ) {
       
  1096             ++i;
       
  1097             if(i==argCount)
       
  1098                 break;
       
  1099             dictionary[ "QT_INSTALL_DEMOS" ] = configCmdLine.at(i);
       
  1100         }
       
  1101 
       
  1102         else if( configCmdLine.at(i) == "-hostprefix" ) {
       
  1103             ++i;
       
  1104             if(i==argCount)
       
  1105                 break;
       
  1106             dictionary[ "QT_HOST_PREFIX" ] = configCmdLine.at(i);
       
  1107         }
       
  1108 
       
  1109         else if( configCmdLine.at(i) == "-make" ) {
       
  1110             ++i;
       
  1111             if(i==argCount)
       
  1112                 break;
       
  1113             dictionary[ "MAKE" ] = configCmdLine.at(i);
       
  1114         }
       
  1115 
       
  1116         else if (configCmdLine.at(i) == "-graphicssystem") {
       
  1117             ++i;
       
  1118             if (i == argCount)
       
  1119                 break;
       
  1120             QString system = configCmdLine.at(i);
       
  1121             if (system == QLatin1String("raster")
       
  1122                 || system == QLatin1String("opengl")
       
  1123                 || system == QLatin1String("openvg"))
       
  1124                 dictionary["GRAPHICS_SYSTEM"] = configCmdLine.at(i);
       
  1125         }
       
  1126 
       
  1127         else if( configCmdLine.at(i).indexOf( QRegExp( "^-(en|dis)able-" ) ) != -1 ) {
       
  1128             // Scan to see if any specific modules and drivers are enabled or disabled
       
  1129             for( QStringList::Iterator module = modules.begin(); module != modules.end(); ++module ) {
       
  1130                 if( configCmdLine.at(i) == QString( "-enable-" ) + (*module) ) {
       
  1131                     enabledModules += (*module);
       
  1132                     break;
       
  1133                 }
       
  1134                 else if( configCmdLine.at(i) == QString( "-disable-" ) + (*module) ) {
       
  1135                     disabledModules += (*module);
       
  1136                     break;
       
  1137                 }
       
  1138             }
       
  1139         }
       
  1140 
       
  1141         else {
       
  1142             dictionary[ "HELP" ] = "yes";
       
  1143             cout << "Unknown option " << configCmdLine.at(i) << endl;
       
  1144             break;
       
  1145         }
       
  1146 
       
  1147 #endif
       
  1148     }
       
  1149 
       
  1150     // Ensure that QMAKESPEC exists in the mkspecs folder
       
  1151     QDir mkspec_dir = fixSeparators(sourcePath + "/mkspecs");
       
  1152     QStringList mkspecs = mkspec_dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
       
  1153 
       
  1154     if (dictionary["QMAKESPEC"].toLower() == "features"
       
  1155         || !mkspecs.contains(dictionary["QMAKESPEC"], Qt::CaseInsensitive)) {
       
  1156         dictionary[ "HELP" ] = "yes";
       
  1157         if (dictionary ["QMAKESPEC_FROM"] == "commandline") {
       
  1158             cout << "Invalid option \"" << dictionary["QMAKESPEC"] << "\" for -platform." << endl;
       
  1159         } else if (dictionary ["QMAKESPEC_FROM"] == "env") {
       
  1160             cout << "QMAKESPEC environment variable is set to \"" << dictionary["QMAKESPEC"]
       
  1161                  << "\" which is not a supported platform" << endl;
       
  1162         } else { // was autodetected from environment
       
  1163             cout << "Unable to detect the platform from environment. Use -platform command line"
       
  1164                     "argument or set the QMAKESPEC environment variable and run configure again" << endl;
       
  1165         }
       
  1166         cout << "See the README file for a list of supported operating systems and compilers." << endl;
       
  1167     } else {
       
  1168         if( dictionary[ "QMAKESPEC" ].endsWith( "-icc" ) ||
       
  1169             dictionary[ "QMAKESPEC" ].endsWith( "-msvc" ) ||
       
  1170             dictionary[ "QMAKESPEC" ].endsWith( "-msvc.net" ) ||
       
  1171             dictionary[ "QMAKESPEC" ].endsWith( "-msvc2002" ) ||
       
  1172             dictionary[ "QMAKESPEC" ].endsWith( "-msvc2003" ) ||
       
  1173             dictionary[ "QMAKESPEC" ].endsWith( "-msvc2005" ) ||
       
  1174             dictionary[ "QMAKESPEC" ].endsWith( "-msvc2008" )) {
       
  1175             if ( dictionary[ "MAKE" ].isEmpty() ) dictionary[ "MAKE" ] = "nmake";
       
  1176             dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32";
       
  1177         } else if ( dictionary[ "QMAKESPEC" ] == QString( "win32-g++" ) ) {
       
  1178             if ( dictionary[ "MAKE" ].isEmpty() ) dictionary[ "MAKE" ] = "mingw32-make";
       
  1179             if (Environment::detectExecutable("sh.exe")) {
       
  1180                 dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32-g++-sh";
       
  1181             } else {
       
  1182                 dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32-g++";
       
  1183             }
       
  1184         } else if ( dictionary[ "QMAKESPEC" ] == QString( "win32-g++-symbian" ) ) {
       
  1185                 dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32-g++-symbian";
       
  1186                 dictionary[ "MAKE" ] = "make";
       
  1187         } else {
       
  1188             if ( dictionary[ "MAKE" ].isEmpty() ) dictionary[ "MAKE" ] = "make";
       
  1189             dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32";
       
  1190         }
       
  1191     }
       
  1192 
       
  1193     // Tell the user how to proceed building Qt after configure finished its job
       
  1194     dictionary["QTBUILDINSTRUCTION"] = dictionary["MAKE"];
       
  1195     if (dictionary.contains("XQMAKESPEC")) {
       
  1196         if (dictionary["XQMAKESPEC"].startsWith("symbian")) {
       
  1197             dictionary["QTBUILDINSTRUCTION"] = QString("make debug-winscw|debug-armv5|release-armv5");
       
  1198         } else if (dictionary["XQMAKESPEC"].startsWith("wince")) {
       
  1199             dictionary["QTBUILDINSTRUCTION"] =
       
  1200                 QString("setcepaths.bat ") + dictionary["XQMAKESPEC"] + QString(" && ") + dictionary["MAKE"];
       
  1201         }
       
  1202     }
       
  1203 
       
  1204     // Tell the user how to confclean before the next configure
       
  1205     dictionary["CONFCLEANINSTRUCTION"] = dictionary["MAKE"] + QString(" confclean");
       
  1206 
       
  1207     // Ensure that -spec (XQMAKESPEC) exists in the mkspecs folder as well
       
  1208     if (dictionary.contains("XQMAKESPEC") &&
       
  1209         !mkspecs.contains(dictionary["XQMAKESPEC"], Qt::CaseInsensitive)) {
       
  1210             dictionary["HELP"] = "yes";
       
  1211             cout << "Invalid option \"" << dictionary["XQMAKESPEC"] << "\" for -xplatform." << endl;
       
  1212     }
       
  1213 
       
  1214     // Ensure that the crt to be deployed can be found
       
  1215     if (dictionary["CE_CRT"] != QLatin1String("yes") && dictionary["CE_CRT"] != QLatin1String("no")) {
       
  1216         QDir cDir(dictionary["CE_CRT"]);
       
  1217         QStringList entries = cDir.entryList();
       
  1218         bool hasDebug = entries.contains("msvcr80.dll");
       
  1219         bool hasRelease = entries.contains("msvcr80d.dll");
       
  1220         if ((dictionary["BUILDALL"] == "auto") && (!hasDebug || !hasRelease)) {
       
  1221             cout << "Could not find debug and release c-runtime." << endl;
       
  1222             cout << "You need to have msvcr80.dll and msvcr80d.dll in" << endl;
       
  1223             cout << "the path specified. Setting to -no-crt";
       
  1224             dictionary[ "CE_CRT" ] = "no";
       
  1225         } else if ((dictionary["BUILD"] == "debug") && !hasDebug) {
       
  1226             cout << "Could not find debug c-runtime (msvcr80d.dll) in the directory specified." << endl;
       
  1227             cout << "Setting c-runtime automatic deployment to -no-crt" << endl;
       
  1228             dictionary[ "CE_CRT" ] = "no";
       
  1229         } else if ((dictionary["BUILD"] == "release") && !hasRelease) {
       
  1230             cout << "Could not find release c-runtime (msvcr80.dll) in the directory specified." << endl;
       
  1231             cout << "Setting c-runtime automatic deployment to -no-crt" << endl;
       
  1232             dictionary[ "CE_CRT" ] = "no";
       
  1233         }
       
  1234     }
       
  1235 
       
  1236     useUnixSeparators = (dictionary["QMAKESPEC"] == "win32-g++");
       
  1237 
       
  1238     // Allow tests for private classes to be compiled against internal builds
       
  1239     if (dictionary["BUILDDEV"] == "yes")
       
  1240         qtConfig += "private_tests";
       
  1241 
       
  1242 
       
  1243 #if !defined(EVAL)
       
  1244     for( QStringList::Iterator dis = disabledModules.begin(); dis != disabledModules.end(); ++dis ) {
       
  1245         modules.removeAll( (*dis) );
       
  1246     }
       
  1247     for( QStringList::Iterator ena = enabledModules.begin(); ena != enabledModules.end(); ++ena ) {
       
  1248         if( modules.indexOf( (*ena) ) == -1 )
       
  1249             modules += (*ena);
       
  1250     }
       
  1251     qtConfig += modules;
       
  1252 
       
  1253     for( QStringList::Iterator it = disabledModules.begin(); it != disabledModules.end(); ++it )
       
  1254         qtConfig.removeAll(*it);
       
  1255 
       
  1256     if( ( dictionary[ "REDO" ] != "yes" ) && ( dictionary[ "HELP" ] != "yes" ) )
       
  1257         saveCmdLine();
       
  1258 #endif
       
  1259 }
       
  1260 
       
  1261 #if !defined(EVAL)
       
  1262 void Configure::validateArgs()
       
  1263 {
       
  1264     // Validate the specified config
       
  1265 
       
  1266     // Get all possible configurations from the file system.
       
  1267     QDir dir;
       
  1268     QStringList filters;
       
  1269     filters << "qconfig-*.h";
       
  1270     dir.setNameFilters(filters);
       
  1271     dir.setPath(sourcePath + "/src/corelib/global/");
       
  1272 
       
  1273     QStringList stringList =  dir.entryList();
       
  1274 
       
  1275     QStringList::Iterator it;
       
  1276     for( it = stringList.begin(); it != stringList.end(); ++it )
       
  1277         allConfigs << it->remove("qconfig-").remove(".h");
       
  1278     allConfigs << "full";
       
  1279 
       
  1280     // Try internal configurations first.
       
  1281     QStringList possible_configs = QStringList()
       
  1282         << "minimal"
       
  1283         << "small"
       
  1284         << "medium"
       
  1285         << "large"
       
  1286         << "full";
       
  1287     int index = possible_configs.indexOf(dictionary["QCONFIG"]);
       
  1288     if (index >= 0) {
       
  1289         for (int c = 0; c <= index; c++) {
       
  1290             qmakeConfig += possible_configs[c] + "-config";
       
  1291         }
       
  1292         return;
       
  1293     }
       
  1294 
       
  1295     // If the internal configurations failed, try others.
       
  1296     QStringList::Iterator config;
       
  1297     for( config = allConfigs.begin(); config != allConfigs.end(); ++config ) {
       
  1298         if( (*config) == dictionary[ "QCONFIG" ] )
       
  1299             break;
       
  1300     }
       
  1301     if( config == allConfigs.end() ) {
       
  1302         dictionary[ "HELP" ] = "yes";
       
  1303         cout << "No such configuration \"" << qPrintable(dictionary[ "QCONFIG" ]) << "\"" << endl ;
       
  1304     }
       
  1305     else
       
  1306         qmakeConfig += (*config) + "-config";
       
  1307 }
       
  1308 #endif
       
  1309 
       
  1310 
       
  1311 // Output helper functions --------------------------------[ Start ]-
       
  1312 /*!
       
  1313     Determines the length of a string token.
       
  1314 */
       
  1315 static int tokenLength(const char *str)
       
  1316 {
       
  1317     if (*str == 0)
       
  1318         return 0;
       
  1319 
       
  1320     const char *nextToken = strpbrk(str, " _/\n\r");
       
  1321     if (nextToken == str || !nextToken)
       
  1322         return 1;
       
  1323 
       
  1324     return int(nextToken - str);
       
  1325 }
       
  1326 
       
  1327 /*!
       
  1328     Prints out a string which starts at position \a startingAt, and
       
  1329     indents each wrapped line with \a wrapIndent characters.
       
  1330     The wrap point is set to the console width, unless that width
       
  1331     cannot be determined, or is too small.
       
  1332 */
       
  1333 void Configure::desc(const char *description, int startingAt, int wrapIndent)
       
  1334 {
       
  1335     int linePos = startingAt;
       
  1336 
       
  1337     bool firstLine = true;
       
  1338     const char *nextToken = description;
       
  1339     while (*nextToken) {
       
  1340         int nextTokenLen = tokenLength(nextToken);
       
  1341         if (*nextToken == '\n'                         // Wrap on newline, duh
       
  1342             || (linePos + nextTokenLen > outputWidth)) // Wrap at outputWidth
       
  1343         {
       
  1344             printf("\n");
       
  1345             linePos = 0;
       
  1346             firstLine = false;
       
  1347             if (*nextToken == '\n')
       
  1348                 ++nextToken;
       
  1349             continue;
       
  1350         }
       
  1351         if (!firstLine && linePos < wrapIndent) {  // Indent to wrapIndent
       
  1352             printf("%*s", wrapIndent , "");
       
  1353             linePos = wrapIndent;
       
  1354             if (*nextToken == ' ') {
       
  1355                 ++nextToken;
       
  1356                 continue;
       
  1357             }
       
  1358         }
       
  1359         printf("%.*s", nextTokenLen, nextToken);
       
  1360         linePos += nextTokenLen;
       
  1361         nextToken += nextTokenLen;
       
  1362     }
       
  1363 }
       
  1364 
       
  1365 /*!
       
  1366     Prints out an option with its description wrapped at the
       
  1367     description starting point. If \a skipIndent is true, the
       
  1368     indentation to the option is not outputted (used by marked option
       
  1369     version of desc()). Extra spaces between option and its
       
  1370     description is filled with\a fillChar, if there's available
       
  1371     space.
       
  1372 */
       
  1373 void Configure::desc(const char *option, const char *description, bool skipIndent, char fillChar)
       
  1374 {
       
  1375     if (!skipIndent)
       
  1376         printf("%*s", optionIndent, "");
       
  1377 
       
  1378     int remaining  = descIndent - optionIndent - strlen(option);
       
  1379     int wrapIndent = descIndent + qMax(0, 1 - remaining);
       
  1380     printf("%s", option);
       
  1381 
       
  1382     if (remaining > 2) {
       
  1383         printf(" "); // Space in front
       
  1384         for (int i = remaining; i > 2; --i)
       
  1385             printf("%c", fillChar); // Fill, if available space
       
  1386     }
       
  1387     printf(" "); // Space between option and description
       
  1388 
       
  1389     desc(description, wrapIndent, wrapIndent);
       
  1390     printf("\n");
       
  1391 }
       
  1392 
       
  1393 /*!
       
  1394     Same as above, except it also marks an option with an '*', if
       
  1395     the option is default action.
       
  1396 */
       
  1397 void Configure::desc(const char *mark_option, const char *mark, const char *option, const char *description, char fillChar)
       
  1398 {
       
  1399     const QString markedAs = dictionary.value(mark_option);
       
  1400     if (markedAs == "auto" && markedAs == mark) // both "auto", always => +
       
  1401         printf(" +  ");
       
  1402     else if (markedAs == "auto")                // setting marked as "auto" and option is default => +
       
  1403         printf(" %c  " , (defaultTo(mark_option) == QLatin1String(mark))? '+' : ' ');
       
  1404     else if (QLatin1String(mark) == "auto" && markedAs != "no")     // description marked as "auto" and option is available => +
       
  1405         printf(" %c  " , checkAvailability(mark_option) ? '+' : ' ');
       
  1406     else                                        // None are "auto", (markedAs == mark) => *
       
  1407         printf(" %c  " , markedAs == QLatin1String(mark) ? '*' : ' ');
       
  1408 
       
  1409     desc(option, description, true, fillChar);
       
  1410 }
       
  1411 
       
  1412 /*!
       
  1413     Modifies the default configuration based on given -platform option.
       
  1414     Eg. switches to different default styles for Windows CE.
       
  1415 */
       
  1416 void Configure::applySpecSpecifics()
       
  1417 {
       
  1418     if (dictionary[ "XQMAKESPEC" ].startsWith("wince")) {
       
  1419         dictionary[ "STYLE_WINDOWSXP" ]     = "no";
       
  1420         dictionary[ "STYLE_WINDOWSVISTA" ]  = "no";
       
  1421         dictionary[ "STYLE_PLASTIQUE" ]     = "no";
       
  1422         dictionary[ "STYLE_CLEANLOOKS" ]    = "no";
       
  1423         dictionary[ "STYLE_WINDOWSCE" ]     = "yes";
       
  1424         dictionary[ "STYLE_WINDOWSMOBILE" ] = "yes";
       
  1425         dictionary[ "STYLE_MOTIF" ]         = "no";
       
  1426         dictionary[ "STYLE_CDE" ]           = "no";
       
  1427         dictionary[ "STYLE_S60" ]           = "no";
       
  1428         dictionary[ "FREETYPE" ]            = "no";
       
  1429         dictionary[ "QT3SUPPORT" ]          = "no";
       
  1430         dictionary[ "OPENGL" ]              = "no";
       
  1431         dictionary[ "OPENSSL" ]             = "no";
       
  1432         dictionary[ "STL" ]                 = "no";
       
  1433         dictionary[ "EXCEPTIONS" ]          = "no";
       
  1434         dictionary[ "RTTI" ]                = "no";
       
  1435         dictionary[ "ARCHITECTURE" ]        = "windowsce";
       
  1436         dictionary[ "3DNOW" ]               = "no";
       
  1437         dictionary[ "SSE" ]                 = "no";
       
  1438         dictionary[ "SSE2" ]                = "no";
       
  1439         dictionary[ "MMX" ]                 = "no";
       
  1440         dictionary[ "IWMMXT" ]              = "no";
       
  1441         dictionary[ "CE_CRT" ]              = "yes";
       
  1442         dictionary[ "WEBKIT" ]              = "no";
       
  1443         dictionary[ "PHONON" ]              = "yes";
       
  1444         dictionary[ "DIRECTSHOW" ]          = "no";
       
  1445         // We only apply MMX/IWMMXT for mkspecs we know they work
       
  1446         if (dictionary[ "XQMAKESPEC" ].startsWith("wincewm")) {
       
  1447             dictionary[ "MMX" ]    = "yes";
       
  1448             dictionary[ "IWMMXT" ] = "yes";
       
  1449             dictionary[ "DIRECTSHOW" ] = "yes";
       
  1450         }
       
  1451         dictionary[ "QT_HOST_PREFIX" ]      = dictionary[ "QT_INSTALL_PREFIX" ];
       
  1452         dictionary[ "QT_INSTALL_PREFIX" ]   = "";
       
  1453 
       
  1454     } else if(dictionary[ "XQMAKESPEC" ].startsWith("symbian")) {
       
  1455         dictionary[ "ACCESSIBILITY" ]       = "no";
       
  1456         dictionary[ "STYLE_WINDOWSXP" ]     = "no";
       
  1457         dictionary[ "STYLE_WINDOWSVISTA" ]  = "no";
       
  1458         dictionary[ "STYLE_PLASTIQUE" ]     = "no";
       
  1459         dictionary[ "STYLE_CLEANLOOKS" ]    = "no";
       
  1460         dictionary[ "STYLE_WINDOWSCE" ]     = "no";
       
  1461         dictionary[ "STYLE_WINDOWSMOBILE" ] = "no";
       
  1462         dictionary[ "STYLE_MOTIF" ]         = "no";
       
  1463         dictionary[ "STYLE_CDE" ]           = "no";
       
  1464         dictionary[ "STYLE_S60" ]           = "yes";
       
  1465         dictionary[ "FREETYPE" ]            = "no";
       
  1466         dictionary[ "QT3SUPPORT" ]          = "no";
       
  1467         dictionary[ "OPENGL" ]              = "no";
       
  1468         dictionary[ "OPENSSL" ]             = "yes";
       
  1469         dictionary[ "STL" ]                 = "yes";
       
  1470         dictionary[ "EXCEPTIONS" ]          = "yes";
       
  1471         dictionary[ "RTTI" ]                = "yes";
       
  1472         dictionary[ "ARCHITECTURE" ]        = "symbian";
       
  1473         dictionary[ "3DNOW" ]               = "no";
       
  1474         dictionary[ "SSE" ]                 = "no";
       
  1475         dictionary[ "SSE2" ]                = "no";
       
  1476         dictionary[ "MMX" ]                 = "no";
       
  1477         dictionary[ "IWMMXT" ]              = "no";
       
  1478         dictionary[ "CE_CRT" ]              = "no";
       
  1479         dictionary[ "DIRECT3D" ]            = "no";
       
  1480         dictionary[ "WEBKIT" ]              = "yes";
       
  1481         dictionary[ "ASSISTANT_WEBKIT" ]    = "no";
       
  1482         dictionary[ "PHONON" ]              = "yes";
       
  1483         dictionary[ "XMLPATTERNS" ]         = "yes";
       
  1484         dictionary[ "QT_GLIB" ]             = "no";
       
  1485         dictionary[ "S60" ]                 = "yes";
       
  1486         dictionary[ "SYMBIAN_DEFFILES" ]    = "yes";
       
  1487         // iconv makes makes apps start and run ridiculously slowly in symbian emulator (HW not tested)
       
  1488         // iconv_open seems to return -1 always, so something is probably missing from the platform.
       
  1489         dictionary[ "QT_ICONV" ]            = "no";
       
  1490         dictionary[ "SCRIPTTOOLS" ]         = "no";
       
  1491         dictionary[ "QT_HOST_PREFIX" ]      = dictionary[ "QT_INSTALL_PREFIX" ];
       
  1492         dictionary[ "QT_INSTALL_PREFIX" ]   = "";
       
  1493         dictionary[ "QT_INSTALL_PLUGINS" ]  = "\\resource\\qt\\plugins";
       
  1494         dictionary[ "QT_INSTALL_TRANSLATIONS" ]  = "\\resource\\qt\\translations";
       
  1495         dictionary[ "ARM_FPU_TYPE" ]        = "softvfp";
       
  1496         dictionary[ "SQL_SQLITE" ]          = "yes";
       
  1497         dictionary[ "SQL_SQLITE_LIB" ]      = "system";
       
  1498 
       
  1499         // Disable building docs and translations for now
       
  1500         disabledBuildParts << "docs" << "translations";
       
  1501 
       
  1502     } else if(dictionary[ "XQMAKESPEC" ].startsWith("linux")) { //TODO actually wrong.
       
  1503       //TODO
       
  1504         dictionary[ "STYLE_WINDOWSXP" ]     = "no";
       
  1505         dictionary[ "STYLE_WINDOWSVISTA" ]  = "no";
       
  1506         dictionary[ "KBD_DRIVERS" ]         = "tty";
       
  1507         dictionary[ "GFX_DRIVERS" ]         = "linuxfb vnc";
       
  1508         dictionary[ "MOUSE_DRIVERS" ]       = "pc linuxtp";
       
  1509         dictionary[ "QT3SUPPORT" ]          = "no";
       
  1510         dictionary[ "OPENGL" ]              = "no";
       
  1511         dictionary[ "EXCEPTIONS" ]          = "no";
       
  1512         dictionary[ "DBUS"]                 = "no";
       
  1513         dictionary[ "QT_QWS_DEPTH" ]        = "4 8 16 24 32";
       
  1514         dictionary[ "QT_SXE" ]              = "no";
       
  1515         dictionary[ "QT_INOTIFY" ]          = "no";
       
  1516         dictionary[ "QT_LPR" ]              = "no";
       
  1517         dictionary[ "QT_CUPS" ]             = "no";
       
  1518         dictionary[ "QT_GLIB" ]             = "no";
       
  1519         dictionary[ "QT_ICONV" ]            = "no";
       
  1520 
       
  1521         dictionary["DECORATIONS"]           = "default windows styled";
       
  1522         dictionary[ "QMAKEADDITIONALARGS" ] = "-unix";
       
  1523     }
       
  1524 }
       
  1525 
       
  1526 QString Configure::locateFileInPaths(const QString &fileName, const QStringList &paths)
       
  1527 {
       
  1528     QDir d;
       
  1529     for( QStringList::ConstIterator it = paths.begin(); it != paths.end(); ++it ) {
       
  1530         // Remove any leading or trailing ", this is commonly used in the environment
       
  1531         // variables
       
  1532         QString path = (*it);
       
  1533         if ( path.startsWith( "\"" ) )
       
  1534             path = path.right( path.length() - 1 );
       
  1535         if ( path.endsWith( "\"" ) )
       
  1536             path = path.left( path.length() - 1 );
       
  1537         if( d.exists(path + QDir::separator() + fileName) ) {
       
  1538             return (path);
       
  1539         }
       
  1540     }
       
  1541     return QString();
       
  1542 }
       
  1543 
       
  1544 QString Configure::locateFile( const QString &fileName )
       
  1545 {
       
  1546     QString file = fileName.toLower();
       
  1547     QStringList paths;
       
  1548 #if defined(Q_OS_WIN32)
       
  1549     QRegExp splitReg("[;,]");
       
  1550 #else
       
  1551     QRegExp splitReg("[:]");
       
  1552 #endif
       
  1553     if (file.endsWith(".h"))
       
  1554         paths = QString::fromLocal8Bit(getenv("INCLUDE")).split(splitReg, QString::SkipEmptyParts);
       
  1555     else if ( file.endsWith( ".lib" ) )
       
  1556         paths = QString::fromLocal8Bit(getenv("LIB")).split(splitReg, QString::SkipEmptyParts);
       
  1557     else
       
  1558         paths = QString::fromLocal8Bit(getenv("PATH")).split(splitReg, QString::SkipEmptyParts);
       
  1559     return locateFileInPaths(file, paths);
       
  1560 }
       
  1561 
       
  1562 // Output helper functions ---------------------------------[ Stop ]-
       
  1563 
       
  1564 
       
  1565 bool Configure::displayHelp()
       
  1566 {
       
  1567     if( dictionary[ "HELP" ] == "yes" ) {
       
  1568         desc("Usage: configure [-buildkey <key>]\n"
       
  1569 //      desc("Usage: configure [-prefix dir] [-bindir <dir>] [-libdir <dir>]\n"
       
  1570 //                  "[-docdir <dir>] [-headerdir <dir>] [-plugindir <dir>]\n"
       
  1571 //                  "[-datadir <dir>] [-translationdir <dir>]\n"
       
  1572 //                  "[-examplesdir <dir>] [-demosdir <dir>][-buildkey <key>]\n"
       
  1573                     "[-release] [-debug] [-debug-and-release] [-shared] [-static]\n"
       
  1574                     "[-no-fast] [-fast] [-no-exceptions] [-exceptions]\n"
       
  1575                     "[-no-accessibility] [-accessibility] [-no-rtti] [-rtti]\n"
       
  1576                     "[-no-stl] [-stl] [-no-sql-<driver>] [-qt-sql-<driver>]\n"
       
  1577                     "[-plugin-sql-<driver>] [-system-sqlite] [-arch <arch>]\n"
       
  1578                     "[-D <define>] [-I <includepath>] [-L <librarypath>]\n"
       
  1579                     "[-help] [-no-dsp] [-dsp] [-no-vcproj] [-vcproj]\n"
       
  1580                     "[-no-qmake] [-qmake] [-dont-process] [-process]\n"
       
  1581                     "[-no-style-<style>] [-qt-style-<style>] [-redo]\n"
       
  1582                     "[-saveconfig <config>] [-loadconfig <config>]\n"
       
  1583                     "[-qt-zlib] [-system-zlib] [-no-gif] [-qt-gif] [-no-libpng]\n"
       
  1584                     "[-qt-libpng] [-system-libpng] [-no-libtiff] [-qt-libtiff]\n"
       
  1585                     "[-system-libtiff] [-no-libjpeg] [-qt-libjpeg] [-system-libjpeg]\n"
       
  1586                     "[-no-libmng] [-qt-libmng] [-system-libmng] [-no-qt3support] [-mmx]\n"
       
  1587                     "[-no-mmx] [-3dnow] [-no-3dnow] [-sse] [-no-sse] [-sse2] [-no-sse2]\n"
       
  1588                     "[-no-iwmmxt] [-iwmmxt] [-openssl] [-openssl-linked]\n"
       
  1589                     "[-no-openssl] [-no-dbus] [-dbus] [-dbus-linked] [-platform <spec>]\n"
       
  1590                     "[-qtnamespace <namespace>] [-qtlibinfix <infix>] [-no-phonon]\n"
       
  1591                     "[-phonon] [-no-phonon-backend] [-phonon-backend]\n"
       
  1592                     "[-no-multimedia] [-multimedia] [-no-audio-backend] [-audio-backend]\n"
       
  1593                     "[-no-script] [-script] [-no-scripttools] [-scripttools]\n"
       
  1594                     "[-no-webkit] [-webkit] [-graphicssystem raster|opengl|openvg]\n\n", 0, 7);
       
  1595 
       
  1596         desc("Installation options:\n\n");
       
  1597 
       
  1598 #if !defined(EVAL)
       
  1599 /*
       
  1600         desc(" These are optional, but you may specify install directories.\n\n", 0, 1);
       
  1601 
       
  1602         desc(                   "-prefix dir",          "This will install everything relative to dir\n(default $QT_INSTALL_PREFIX)\n");
       
  1603 
       
  1604         desc(" You may use these to separate different parts of the install:\n\n", 0, 1);
       
  1605 
       
  1606         desc(                   "-bindir <dir>",        "Executables will be installed to dir\n(default PREFIX/bin)");
       
  1607         desc(                   "-libdir <dir>",        "Libraries will be installed to dir\n(default PREFIX/lib)");
       
  1608         desc(                   "-docdir <dir>",        "Documentation will be installed to dir\n(default PREFIX/doc)");
       
  1609         desc(                   "-headerdir <dir>",     "Headers will be installed to dir\n(default PREFIX/include)");
       
  1610         desc(                   "-plugindir <dir>",     "Plugins will be installed to dir\n(default PREFIX/plugins)");
       
  1611         desc(                   "-datadir <dir>",       "Data used by Qt programs will be installed to dir\n(default PREFIX)");
       
  1612         desc(                   "-translationdir <dir>","Translations of Qt programs will be installed to dir\n(default PREFIX/translations)\n");
       
  1613         desc(                   "-examplesdir <dir>",   "Examples will be installed to dir\n(default PREFIX/examples)");
       
  1614         desc(                   "-demosdir <dir>",      "Demos will be installed to dir\n(default PREFIX/demos)");
       
  1615 */
       
  1616         desc(" You may use these options to turn on strict plugin loading:\n\n", 0, 1);
       
  1617 
       
  1618         desc(                   "-buildkey <key>",      "Build the Qt library and plugins using the specified <key>.  "
       
  1619                                                         "When the library loads plugins, it will only load those that have a matching <key>.\n");
       
  1620 
       
  1621         desc("Configure options:\n\n");
       
  1622 
       
  1623         desc(" The defaults (*) are usually acceptable. A plus (+) denotes a default value"
       
  1624              " that needs to be evaluated. If the evaluation succeeds, the feature is"
       
  1625              " included. Here is a short explanation of each option:\n\n", 0, 1);
       
  1626 
       
  1627         desc("BUILD", "release","-release",             "Compile and link Qt with debugging turned off.");
       
  1628         desc("BUILD", "debug",  "-debug",               "Compile and link Qt with debugging turned on.");
       
  1629         desc("BUILDALL", "yes", "-debug-and-release",   "Compile and link two Qt libraries, with and without debugging turned on.\n");
       
  1630 
       
  1631         desc("OPENSOURCE", "opensource", "-opensource",   "Compile and link the Open-Source Edition of Qt.");
       
  1632         desc("COMMERCIAL", "commercial", "-commercial",   "Compile and link the Commercial Edition of Qt.\n");
       
  1633 
       
  1634         desc("BUILDDEV", "yes", "-developer-build",      "Compile and link Qt with Qt developer options (including auto-tests exporting)\n");
       
  1635 
       
  1636         desc("SHARED", "yes",   "-shared",              "Create and use shared Qt libraries.");
       
  1637         desc("SHARED", "no",    "-static",              "Create and use static Qt libraries.\n");
       
  1638 
       
  1639         desc("LTCG", "yes",   "-ltcg",                  "Use Link Time Code Generation. (Release builds only)");
       
  1640         desc("LTCG", "no",    "-no-ltcg",               "Do not use Link Time Code Generation.\n");
       
  1641 
       
  1642         desc("FAST", "no",      "-no-fast",             "Configure Qt normally by generating Makefiles for all project files.");
       
  1643         desc("FAST", "yes",     "-fast",                "Configure Qt quickly by generating Makefiles only for library and "
       
  1644                                                         "subdirectory targets.  All other Makefiles are created as wrappers "
       
  1645                                                         "which will in turn run qmake\n");
       
  1646 
       
  1647         desc("EXCEPTIONS", "no", "-no-exceptions",      "Disable exceptions on platforms that support it.");
       
  1648         desc("EXCEPTIONS", "yes","-exceptions",         "Enable exceptions on platforms that support it.\n");
       
  1649 
       
  1650         desc("ACCESSIBILITY", "no",  "-no-accessibility", "Do not compile Windows Active Accessibility support.");
       
  1651         desc("ACCESSIBILITY", "yes", "-accessibility",    "Compile Windows Active Accessibility support.\n");
       
  1652 
       
  1653         desc("STL", "no",       "-no-stl",              "Do not compile STL support.");
       
  1654         desc("STL", "yes",      "-stl",                 "Compile STL support.\n");
       
  1655 
       
  1656         desc(                   "-no-sql-<driver>",     "Disable SQL <driver> entirely, by default none are turned on.");
       
  1657         desc(                   "-qt-sql-<driver>",     "Enable a SQL <driver> in the Qt Library.");
       
  1658         desc(                   "-plugin-sql-<driver>", "Enable SQL <driver> as a plugin to be linked to at run time.\n"
       
  1659                                                         "Available values for <driver>:");
       
  1660         desc("SQL_MYSQL", "auto", "",                   "  mysql", ' ');
       
  1661         desc("SQL_PSQL", "auto", "",                    "  psql", ' ');
       
  1662         desc("SQL_OCI", "auto", "",                     "  oci", ' ');
       
  1663         desc("SQL_ODBC", "auto", "",                    "  odbc", ' ');
       
  1664         desc("SQL_TDS", "auto", "",                     "  tds", ' ');
       
  1665         desc("SQL_DB2", "auto", "",                     "  db2", ' ');
       
  1666         desc("SQL_SQLITE", "auto", "",                  "  sqlite", ' ');
       
  1667         desc("SQL_SQLITE2", "auto", "",                 "  sqlite2", ' ');
       
  1668         desc("SQL_IBASE", "auto", "",                   "  ibase", ' ');
       
  1669         desc(                   "",                     "(drivers marked with a '+' have been detected as available on this system)\n", false, ' ');
       
  1670 
       
  1671         desc(                   "-system-sqlite",       "Use sqlite from the operating system.\n");
       
  1672 
       
  1673         desc("QT3SUPPORT", "no","-no-qt3support",       "Disables the Qt 3 support functionality.\n");
       
  1674         desc("OPENGL", "no","-no-opengl",               "Disables OpenGL functionality\n");
       
  1675 
       
  1676         desc("OPENVG", "no","-no-openvg",               "Disables OpenVG functionality\n");
       
  1677         desc("OPENVG", "yes","-openvg",                 "Enables OpenVG functionality");
       
  1678         desc(                   "",                     "Requires EGL support, typically supplied by an OpenGL", false, ' ');
       
  1679         desc(                   "",                     "or other graphics implementation\n", false, ' ');
       
  1680 
       
  1681 #endif
       
  1682         desc(                   "-platform <spec>",     "The operating system and compiler you are building on.\n(default %QMAKESPEC%)\n");
       
  1683         desc(                   "-xplatform <spec>",    "The operating system and compiler you are cross compiling to.\n");
       
  1684         desc(                   "",                     "See the README file for a list of supported operating systems and compilers.\n", false, ' ');
       
  1685 
       
  1686 #if !defined(EVAL)
       
  1687         desc(                   "-qtnamespace <namespace>", "Wraps all Qt library code in 'namespace name {...}");
       
  1688         desc(                   "-qtlibinfix <infix>",  "Renames all Qt* libs to Qt*<infix>\n");
       
  1689         desc(                   "-D <define>",          "Add an explicit define to the preprocessor.");
       
  1690         desc(                   "-I <includepath>",     "Add an explicit include path.");
       
  1691         desc(                   "-L <librarypath>",     "Add an explicit library path.");
       
  1692         desc(                   "-l <libraryname>",     "Add an explicit library name, residing in a librarypath.\n");
       
  1693 #endif
       
  1694         desc(                   "-graphicssystem <sys>",   "Specify which graphicssystem should be used.\n"
       
  1695                                 "Available values for <sys>:");
       
  1696         desc("GRAPHICS_SYSTEM", "raster", "", "  raster - Software rasterizer", ' ');
       
  1697         desc("GRAPHICS_SYSTEM", "opengl", "", "  opengl - Using OpenGL acceleration, experimental!", ' ');
       
  1698         desc("GRAPHICS_SYSTEM", "openvg", "", "  openvg - Using OpenVG acceleration, experimental!", ' ');
       
  1699 
       
  1700 
       
  1701         desc(                   "-help, -h, -?",        "Display this information.\n");
       
  1702 
       
  1703 #if !defined(EVAL)
       
  1704         // 3rd party stuff options go below here --------------------------------------------------------------------------------
       
  1705         desc("Third Party Libraries:\n\n");
       
  1706 
       
  1707         desc("ZLIB", "qt",      "-qt-zlib",             "Use the zlib bundled with Qt.");
       
  1708         desc("ZLIB", "system",  "-system-zlib",         "Use zlib from the operating system.\nSee http://www.gzip.org/zlib\n");
       
  1709 
       
  1710         desc("GIF", "no",       "-no-gif",              "Do not compile the plugin for GIF reading support.");
       
  1711         desc("GIF", "auto",     "-qt-gif",              "Compile the plugin for GIF reading support.\nSee also src/plugins/imageformats/gif/qgifhandler.h\n");
       
  1712 
       
  1713         desc("LIBPNG", "no",    "-no-libpng",           "Do not compile in PNG support.");
       
  1714         desc("LIBPNG", "qt",    "-qt-libpng",           "Use the libpng bundled with Qt.");
       
  1715         desc("LIBPNG", "system","-system-libpng",       "Use libpng from the operating system.\nSee http://www.libpng.org/pub/png\n");
       
  1716 
       
  1717         desc("LIBMNG", "no",    "-no-libmng",           "Do not compile in MNG support.");
       
  1718         desc("LIBMNG", "qt",    "-qt-libmng",           "Use the libmng bundled with Qt.");
       
  1719         desc("LIBMNG", "system","-system-libmng",       "Use libmng from the operating system.\nSee See http://www.libmng.com\n");
       
  1720 
       
  1721         desc("LIBTIFF", "no",    "-no-libtiff",         "Do not compile the plugin for TIFF support.");
       
  1722         desc("LIBTIFF", "qt",    "-qt-libtiff",         "Use the libtiff bundled with Qt.");
       
  1723         desc("LIBTIFF", "system","-system-libtiff",     "Use libtiff from the operating system.\nSee http://www.libtiff.org\n");
       
  1724 
       
  1725         desc("LIBJPEG", "no",    "-no-libjpeg",         "Do not compile the plugin for JPEG support.");
       
  1726         desc("LIBJPEG", "qt",    "-qt-libjpeg",         "Use the libjpeg bundled with Qt.");
       
  1727         desc("LIBJPEG", "system","-system-libjpeg",     "Use libjpeg from the operating system.\nSee http://www.ijg.org\n");
       
  1728 
       
  1729 #endif
       
  1730         // Qt\Windows only options go below here --------------------------------------------------------------------------------
       
  1731         desc("Qt for Windows only:\n\n");
       
  1732 
       
  1733         desc("DSPFILES", "no",  "-no-dsp",              "Do not generate VC++ .dsp files.");
       
  1734         desc("DSPFILES", "yes", "-dsp",                 "Generate VC++ .dsp files, only if spec \"win32-msvc\".\n");
       
  1735 
       
  1736         desc("VCPROJFILES", "no", "-no-vcproj",         "Do not generate VC++ .vcproj files.");
       
  1737         desc("VCPROJFILES", "yes", "-vcproj",           "Generate VC++ .vcproj files, only if platform \"win32-msvc.net\".\n");
       
  1738 
       
  1739         desc("INCREDIBUILD_XGE", "no", "-no-incredibuild-xge", "Do not add IncrediBuild XGE distribution commands to custom build steps.");
       
  1740         desc("INCREDIBUILD_XGE", "yes", "-incredibuild-xge",   "Add IncrediBuild XGE distribution commands to custom build steps. This will distribute MOC and UIC steps, and other custom buildsteps which are added to the INCREDIBUILD_XGE variable.\n(The IncrediBuild distribution commands are only added to Visual Studio projects)\n");
       
  1741 
       
  1742         desc("PLUGIN_MANIFESTS", "no", "-no-plugin-manifests", "Do not embed manifests in plugins.");
       
  1743         desc("PLUGIN_MANIFESTS", "yes", "-plugin-manifests",   "Embed manifests in plugins.\n");
       
  1744 
       
  1745 #if !defined(EVAL)
       
  1746         desc("BUILD_QMAKE", "no", "-no-qmake",          "Do not compile qmake.");
       
  1747         desc("BUILD_QMAKE", "yes", "-qmake",            "Compile qmake.\n");
       
  1748 
       
  1749         desc("NOPROCESS", "yes", "-dont-process",       "Do not generate Makefiles/Project files. This will override -no-fast if specified.");
       
  1750         desc("NOPROCESS", "no",  "-process",            "Generate Makefiles/Project files.\n");
       
  1751 
       
  1752         desc("RTTI", "no",      "-no-rtti",             "Do not compile runtime type information.");
       
  1753         desc("RTTI", "yes",     "-rtti",                "Compile runtime type information.\n");
       
  1754         desc("MMX", "no",       "-no-mmx",              "Do not compile with use of MMX instructions");
       
  1755         desc("MMX", "yes",      "-mmx",                 "Compile with use of MMX instructions");
       
  1756         desc("3DNOW", "no",     "-no-3dnow",            "Do not compile with use of 3DNOW instructions");
       
  1757         desc("3DNOW", "yes",    "-3dnow",               "Compile with use of 3DNOW instructions");
       
  1758         desc("SSE", "no",       "-no-sse",              "Do not compile with use of SSE instructions");
       
  1759         desc("SSE", "yes",      "-sse",                 "Compile with use of SSE instructions");
       
  1760         desc("SSE2", "no",      "-no-sse2",             "Do not compile with use of SSE2 instructions");
       
  1761         desc("SSE2", "yes",      "-sse2",               "Compile with use of SSE2 instructions");
       
  1762         desc("OPENSSL", "no",    "-no-openssl",         "Do not compile in OpenSSL support");
       
  1763         desc("OPENSSL", "yes",   "-openssl",            "Compile in run-time OpenSSL support");
       
  1764         desc("OPENSSL", "linked","-openssl-linked",     "Compile in linked OpenSSL support");
       
  1765         desc("DBUS", "no",       "-no-dbus",            "Do not compile in D-Bus support");
       
  1766         desc("DBUS", "yes",      "-dbus",               "Compile in D-Bus support and load libdbus-1 dynamically");
       
  1767         desc("DBUS", "linked",   "-dbus-linked",        "Compile in D-Bus support and link to libdbus-1");
       
  1768         desc("PHONON", "no",    "-no-phonon",           "Do not compile in the Phonon module");
       
  1769         desc("PHONON", "yes",   "-phonon",              "Compile the Phonon module (Phonon is built if a decent C++ compiler is used.)");
       
  1770         desc("PHONON_BACKEND","no", "-no-phonon-backend","Do not compile the platform-specific Phonon backend-plugin");
       
  1771         desc("PHONON_BACKEND","yes","-phonon-backend",  "Compile in the platform-specific Phonon backend-plugin");
       
  1772         desc("MULTIMEDIA", "no", "-no-multimedia",      "Do not compile the multimedia module");
       
  1773         desc("MULTIMEDIA", "yes","-multimedia",         "Compile in multimedia module");
       
  1774         desc("AUDIO_BACKEND", "no","-no-audio-backend", "Do not compile in the platform audio backend into QtMultimedia");
       
  1775         desc("AUDIO_BACKEND", "yes","-audio-backend",   "Compile in the platform audio backend into QtMultimedia");
       
  1776         desc("WEBKIT", "no",    "-no-webkit",           "Do not compile in the WebKit module");
       
  1777         desc("WEBKIT", "yes",   "-webkit",              "Compile in the WebKit module (WebKit is built if a decent C++ compiler is used.)");
       
  1778         desc("SCRIPT", "no",    "-no-script",           "Do not build the QtScript module.");
       
  1779         desc("SCRIPT", "yes",   "-script",              "Build the QtScript module.");
       
  1780         desc("SCRIPTTOOLS", "no", "-no-scripttools",    "Do not build the QtScriptTools module.");
       
  1781         desc("SCRIPTTOOLS", "yes", "-scripttools",      "Build the QtScriptTools module.");
       
  1782         desc("DECLARATIVE", "no",    "-no-declarative", "Do not build the declarative module");
       
  1783         desc("DECLARATIVE", "yes",   "-declarative",    "Build the declarative module");
       
  1784 
       
  1785         desc(                   "-arch <arch>",         "Specify an architecture.\n"
       
  1786                                                         "Available values for <arch>:");
       
  1787         desc("ARCHITECTURE","windows",       "",        "  windows", ' ');
       
  1788         desc("ARCHITECTURE","windowsce",     "",        "  windowsce", ' ');
       
  1789         desc("ARCHITECTURE","symbian",     "",          "  symbian", ' ');
       
  1790         desc("ARCHITECTURE","boundschecker",     "",    "  boundschecker", ' ');
       
  1791         desc("ARCHITECTURE","generic", "",              "  generic\n", ' ');
       
  1792 
       
  1793         desc(                   "-no-style-<style>",    "Disable <style> entirely.");
       
  1794         desc(                   "-qt-style-<style>",    "Enable <style> in the Qt Library.\nAvailable styles: ");
       
  1795 
       
  1796         desc("STYLE_WINDOWS", "yes", "",                "  windows", ' ');
       
  1797         desc("STYLE_WINDOWSXP", "auto", "",             "  windowsxp", ' ');
       
  1798         desc("STYLE_WINDOWSVISTA", "auto", "",          "  windowsvista", ' ');
       
  1799         desc("STYLE_PLASTIQUE", "yes", "",              "  plastique", ' ');
       
  1800         desc("STYLE_CLEANLOOKS", "yes", "",             "  cleanlooks", ' ');
       
  1801         desc("STYLE_MOTIF", "yes", "",                  "  motif", ' ');
       
  1802         desc("STYLE_CDE", "yes", "",                    "  cde", ' ');
       
  1803         desc("STYLE_WINDOWSCE", "yes", "",              "  windowsce", ' ');
       
  1804         desc("STYLE_WINDOWSMOBILE" , "yes", "",         "  windowsmobile", ' ');
       
  1805         desc("STYLE_S60" , "yes", "",                   "  s60\n", ' ');
       
  1806         desc("NATIVE_GESTURES", "no", "-no-native-gestures", "Do not use native gestures on Windows 7.");
       
  1807         desc("NATIVE_GESTURES", "yes", "-native-gestures", "Use native gestures on Windows 7.");
       
  1808 
       
  1809 /*      We do not support -qconfig on Windows yet
       
  1810 
       
  1811         desc(                   "-qconfig <local>",     "Use src/tools/qconfig-local.h rather than the default.\nPossible values for local:");
       
  1812         for (int i=0; i<allConfigs.size(); ++i)
       
  1813             desc(               "",                     qPrintable(QString("  %1").arg(allConfigs.at(i))), false, ' ');
       
  1814         printf("\n");
       
  1815 */
       
  1816 #endif
       
  1817         desc(                   "-loadconfig <config>", "Run configure with the parameters from file configure_<config>.cache.");
       
  1818         desc(                   "-saveconfig <config>", "Run configure and save the parameters in file configure_<config>.cache.");
       
  1819         desc(                   "-redo",                "Run configure with the same parameters as last time.\n");
       
  1820 
       
  1821         // Qt\Windows CE only options go below here -----------------------------------------------------------------------------
       
  1822         desc("Qt for Windows CE only:\n\n");
       
  1823         desc("IWMMXT", "no",       "-no-iwmmxt",           "Do not compile with use of IWMMXT instructions");
       
  1824         desc("IWMMXT", "yes",      "-iwmmxt",              "Do compile with use of IWMMXT instructions (Qt for Windows CE on Arm only)");
       
  1825         desc("CE_CRT", "no",       "-no-crt" ,             "Do not add the C runtime to default deployment rules");
       
  1826         desc("CE_CRT", "yes",      "-qt-crt",              "Qt identifies C runtime during project generation");
       
  1827         desc(                      "-crt <path>",          "Specify path to C runtime used for project generation.");
       
  1828         desc("CETEST", "no",       "-no-cetest",           "Do not compile Windows CE remote test application");
       
  1829         desc("CETEST", "yes",      "-cetest",              "Compile Windows CE remote test application");
       
  1830         desc(                      "-signature <file>",    "Use file for signing the target project");
       
  1831         desc("OPENGL_ES_CM", "no", "-opengl-es-cm",        "Enable support for OpenGL ES Common");
       
  1832         desc("OPENGL_ES_CL", "no", "-opengl-es-cl",        "Enable support for OpenGL ES Common Lite");
       
  1833         desc("OPENGL_ES_2",  "no", "-opengl-es-2",         "Enable support for OpenGL ES 2.0");
       
  1834         desc("DIRECTSHOW", "no",   "-phonon-wince-ds9",    "Enable Phonon Direct Show 9 backend for Windows CE");
       
  1835 
       
  1836         // Qt\Symbian only options go below here -----------------------------------------------------------------------------
       
  1837         desc("Qt for Symbian OS only:\n\n");
       
  1838         desc("FREETYPE", "no",     "-no-freetype",         "Do not compile in Freetype2 support.");
       
  1839         desc("FREETYPE", "yes",    "-qt-freetype",         "Use the libfreetype bundled with Qt.");
       
  1840         desc(                      "-fpu <flags>",         "VFP type on ARM, supported options: softvfp(default) | vfpv2 | softvfp+vfpv2");
       
  1841         desc("S60", "no",          "-no-s60",              "Do not compile in S60 support.");
       
  1842         desc("S60", "yes",         "-s60",                 "Compile with support for the S60 UI Framework");
       
  1843         desc("SYMBIAN_DEFFILES", "no",  "-no-usedeffiles",  "Disable the usage of DEF files.");
       
  1844         desc("SYMBIAN_DEFFILES", "yes", "-usedeffiles",     "Enable the usage of DEF files.\n");
       
  1845         return true;
       
  1846     }
       
  1847     return false;
       
  1848 }
       
  1849 
       
  1850 QString Configure::findFileInPaths(const QString &fileName, const QString &paths)
       
  1851 {
       
  1852 #if defined(Q_OS_WIN32)
       
  1853     QRegExp splitReg("[;,]");
       
  1854 #else
       
  1855     QRegExp splitReg("[:]");
       
  1856 #endif
       
  1857     QStringList pathList = paths.split(splitReg, QString::SkipEmptyParts);
       
  1858     QDir d;
       
  1859     for( QStringList::ConstIterator it = pathList.begin(); it != pathList.end(); ++it ) {
       
  1860         // Remove any leading or trailing ", this is commonly used in the environment
       
  1861         // variables
       
  1862         QString path = (*it);
       
  1863         if ( path.startsWith( '\"' ) )
       
  1864             path = path.right( path.length() - 1 );
       
  1865         if ( path.endsWith( '\"' ) )
       
  1866             path = path.left( path.length() - 1 );
       
  1867         if( d.exists( path + QDir::separator() + fileName ) )
       
  1868             return path;
       
  1869     }
       
  1870     return QString();
       
  1871 }
       
  1872 
       
  1873 bool Configure::findFile( const QString &fileName )
       
  1874 {
       
  1875     const QString file = fileName.toLower();
       
  1876     const QString pathEnvVar = QString::fromLocal8Bit(getenv("PATH"));
       
  1877     const QString mingwPath = dictionary["QMAKESPEC"].endsWith("-g++") ?
       
  1878         findFileInPaths("mingw32-g++.exe", pathEnvVar) : QString();
       
  1879 
       
  1880     QString paths;
       
  1881     if (file.endsWith(".h")) {
       
  1882         if (!mingwPath.isNull() && !findFileInPaths(file, mingwPath + QLatin1String("/../include")).isNull())
       
  1883 		    return true;
       
  1884         paths = QString::fromLocal8Bit(getenv("INCLUDE"));
       
  1885     } else if ( file.endsWith( ".lib" ) ||  file.endsWith( ".a" ) ) {
       
  1886         if (!mingwPath.isNull() && !findFileInPaths(file, mingwPath + QLatin1String("/../lib")).isNull())
       
  1887 		    return true;
       
  1888         paths = QString::fromLocal8Bit(getenv("LIB"));
       
  1889     } else {
       
  1890         paths = pathEnvVar;
       
  1891     }
       
  1892     return !findFileInPaths(file, paths).isNull();
       
  1893 }
       
  1894 
       
  1895 /*!
       
  1896     Default value for options marked as "auto" if the test passes.
       
  1897     (Used both by the autoDetection() below, and the desc() function
       
  1898     to mark (+) the default option of autodetecting options.
       
  1899 */
       
  1900 QString Configure::defaultTo(const QString &option)
       
  1901 {
       
  1902     // We prefer using the system version of the 3rd party libs
       
  1903     if (option == "ZLIB"
       
  1904         || option == "LIBJPEG"
       
  1905         || option == "LIBPNG"
       
  1906         || option == "LIBMNG"
       
  1907         || option == "LIBTIFF")
       
  1908         return "system";
       
  1909 
       
  1910     // We want PNG built-in
       
  1911     if (option == "PNG")
       
  1912         return "qt";
       
  1913 
       
  1914     // The JPEG image library can only be a plugin
       
  1915     if (option == "JPEG"
       
  1916         || option == "MNG" || option == "TIFF")
       
  1917         return "plugin";
       
  1918 
       
  1919     // GIF off by default
       
  1920     if (option == "GIF") {
       
  1921         if (dictionary["SHARED"] == "yes")
       
  1922             return "plugin";
       
  1923         else
       
  1924             return "yes";
       
  1925     }
       
  1926 
       
  1927     // By default we do not want to compile OCI driver when compiling with
       
  1928     // MinGW, due to lack of such support from Oracle. It prob. wont work.
       
  1929     // (Customer may force the use though)
       
  1930     if (dictionary["QMAKESPEC"].endsWith("-g++")
       
  1931         && option == "SQL_OCI")
       
  1932         return "no";
       
  1933 
       
  1934     if (option == "SQL_MYSQL"
       
  1935         || option == "SQL_MYSQL"
       
  1936         || option == "SQL_ODBC"
       
  1937         || option == "SQL_OCI"
       
  1938         || option == "SQL_PSQL"
       
  1939         || option == "SQL_TDS"
       
  1940         || option == "SQL_DB2"
       
  1941         || option == "SQL_SQLITE"
       
  1942         || option == "SQL_SQLITE2"
       
  1943         || option == "SQL_IBASE")
       
  1944         return "plugin";
       
  1945 
       
  1946     if (option == "SYNCQT"
       
  1947         && (!QFile::exists(sourcePath + "/bin/syncqt") ||
       
  1948             !QFile::exists(sourcePath + "/bin/syncqt.bat")))
       
  1949         return "no";
       
  1950 
       
  1951     return "yes";
       
  1952 }
       
  1953 
       
  1954 /*!
       
  1955     Checks the system for the availability of a feature.
       
  1956     Returns true if the feature is available, else false.
       
  1957 */
       
  1958 bool Configure::checkAvailability(const QString &part)
       
  1959 {
       
  1960     bool available = false;
       
  1961     if (part == "STYLE_WINDOWSXP")
       
  1962         available = (findFile("uxtheme.h"));
       
  1963 
       
  1964     else if (part == "ZLIB")
       
  1965         available = findFile("zlib.h");
       
  1966 
       
  1967     else if (part == "LIBJPEG")
       
  1968         available = findFile("jpeglib.h");
       
  1969     else if (part == "LIBPNG")
       
  1970         available = findFile("png.h");
       
  1971     else if (part == "LIBMNG")
       
  1972         available = findFile("libmng.h");
       
  1973     else if (part == "LIBTIFF")
       
  1974         available = findFile("tiffio.h");
       
  1975     else if (part == "SQL_MYSQL")
       
  1976         available = findFile("mysql.h") && findFile("libmySQL.lib");
       
  1977     else if (part == "SQL_ODBC")
       
  1978         available = findFile("sql.h") && findFile("sqlext.h") && findFile("odbc32.lib");
       
  1979     else if (part == "SQL_OCI")
       
  1980         available = findFile("oci.h") && findFile("oci.lib");
       
  1981     else if (part == "SQL_PSQL")
       
  1982         available = findFile("libpq-fe.h") && findFile("libpq.lib") && findFile("ws2_32.lib") && findFile("advapi32.lib");
       
  1983     else if (part == "SQL_TDS")
       
  1984         available = findFile("sybfront.h") && findFile("sybdb.h") && findFile("ntwdblib.lib");
       
  1985     else if (part == "SQL_DB2")
       
  1986         available = findFile("sqlcli.h") && findFile("sqlcli1.h") && findFile("db2cli.lib");
       
  1987     else if (part == "SQL_SQLITE")
       
  1988         if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith("symbian"))
       
  1989             available = false; // In Symbian we only support system sqlite option
       
  1990         else
       
  1991             available = true; // Built in, we have a fork
       
  1992     else if (part == "SQL_SQLITE_LIB") {
       
  1993         if (dictionary[ "SQL_SQLITE_LIB" ] == "system") {
       
  1994 		    // Symbian has multiple .lib/.dll files we need to find
       
  1995             if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith("symbian")) {
       
  1996 			    available = true; // There is sqlite_symbian plugin which exports the necessary stuff
       
  1997 			    dictionary[ "QT_LFLAGS_SQLITE" ] += "-lsqlite3";
       
  1998 		    } else {
       
  1999 			    available = findFile("sqlite3.h") && findFile("sqlite3.lib");
       
  2000 			    if (available)
       
  2001 				    dictionary[ "QT_LFLAGS_SQLITE" ] += "sqlite3.lib";
       
  2002 		    }
       
  2003         } else
       
  2004             available = true;
       
  2005     } else if (part == "SQL_SQLITE2")
       
  2006         available = findFile("sqlite.h") && findFile("sqlite.lib");
       
  2007     else if (part == "SQL_IBASE")
       
  2008         available = findFile("ibase.h") && (findFile("gds32_ms.lib") || findFile("gds32.lib"));
       
  2009     else if (part == "IWMMXT")
       
  2010         available = (dictionary[ "ARCHITECTURE" ]  == "windowsce");
       
  2011     else if (part == "OPENGL_ES_CM")
       
  2012         available = (dictionary[ "ARCHITECTURE" ]  == "windowsce");
       
  2013     else if (part == "OPENGL_ES_CL")
       
  2014         available = (dictionary[ "ARCHITECTURE" ]  == "windowsce");
       
  2015     else if (part == "OPENGL_ES_2")
       
  2016         available = (dictionary[ "ARCHITECTURE" ]  == "windowsce");
       
  2017     else if (part == "DIRECTSHOW")
       
  2018         available = (dictionary[ "ARCHITECTURE" ]  == "windowsce");
       
  2019     else if (part == "SSE2")
       
  2020         available = (dictionary.value("QMAKESPEC") != "win32-msvc") && (dictionary.value("QMAKESPEC") != "win32-g++");
       
  2021     else if (part == "3DNOW" )
       
  2022         available = (dictionary.value("QMAKESPEC") != "win32-msvc") && (dictionary.value("QMAKESPEC") != "win32-icc") && findFile("mm3dnow.h") && (dictionary.value("QMAKESPEC") != "win32-g++");
       
  2023     else if (part == "MMX" || part == "SSE")
       
  2024         available = (dictionary.value("QMAKESPEC") != "win32-msvc") && (dictionary.value("QMAKESPEC") != "win32-g++");
       
  2025     else if (part == "OPENSSL")
       
  2026         available = findFile("openssl\\ssl.h");
       
  2027     else if (part == "DBUS")
       
  2028         available = findFile("dbus\\dbus.h");
       
  2029     else if (part == "CETEST") {
       
  2030         QString rapiHeader = locateFile("rapi.h");
       
  2031         QString rapiLib = locateFile("rapi.lib");
       
  2032         available = (dictionary[ "ARCHITECTURE" ]  == "windowsce") && !rapiHeader.isEmpty() && !rapiLib.isEmpty();
       
  2033         if (available) {
       
  2034             dictionary[ "QT_CE_RAPI_INC" ] += QLatin1String("\"") + rapiHeader + QLatin1String("\"");
       
  2035             dictionary[ "QT_CE_RAPI_LIB" ] += QLatin1String("\"") + rapiLib + QLatin1String("\"");
       
  2036         }
       
  2037         else if (dictionary[ "CETEST_REQUESTED" ] == "yes") {
       
  2038             cout << "cetest could not be enabled: rapi.h and rapi.lib could not be found." << endl;
       
  2039             cout << "Make sure the environment is set up for compiling with ActiveSync." << endl;
       
  2040             dictionary[ "DONE" ] = "error";
       
  2041         }
       
  2042     }
       
  2043     else if (part == "INCREDIBUILD_XGE")
       
  2044         available = findFile("BuildConsole.exe") && findFile("xgConsole.exe");
       
  2045     else if (part == "XMLPATTERNS")
       
  2046     {
       
  2047         /* MSVC 6.0 and MSVC 2002/7.0 has too poor C++ support for QtXmlPatterns. */
       
  2048         return dictionary.value("QMAKESPEC") != "win32-msvc"
       
  2049                && dictionary.value("QMAKESPEC") != "win32-msvc.net" // Leave for now, since we can't be sure if they are using 2002 or 2003 with this spec
       
  2050                && dictionary.value("QMAKESPEC") != "win32-msvc2002"
       
  2051                && dictionary.value("EXCEPTIONS") == "yes";
       
  2052     } else if (part == "PHONON") {
       
  2053         available = findFile("vmr9.h") && findFile("dshow.h") && findFile("dmo.h") && findFile("dmodshow.h")
       
  2054             && (findFile("strmiids.lib") || findFile("libstrmiids.a"))
       
  2055             && (findFile("dmoguids.lib") || findFile("libdmoguids.a"))
       
  2056             && (findFile("msdmo.lib") || findFile("libmsdmo.a"))
       
  2057             && findFile("d3d9.h");
       
  2058 
       
  2059         if (!available) {
       
  2060             cout << "All the required DirectShow/Direct3D files couldn't be found." << endl
       
  2061                  << "Make sure you have either the platform SDK AND the DirectShow SDK or the Windows SDK installed." << endl
       
  2062                  << "If you have the DirectShow SDK installed, please make sure that you have run the <path to SDK>\\SetEnv.Cmd script." << endl;
       
  2063             if (!findFile("vmr9.h"))  cout << "vmr9.h not found" << endl;
       
  2064             if (!findFile("dshow.h")) cout << "dshow.h not found" << endl;
       
  2065             if (!findFile("strmiids.lib")) cout << "strmiids.lib not found" << endl;
       
  2066             if (!findFile("dmoguids.lib")) cout << "dmoguids.lib not found" << endl;
       
  2067             if (!findFile("msdmo.lib")) cout << "msdmo.lib not found" << endl;
       
  2068             if (!findFile("d3d9.h")) cout << "d3d9.h not found" << endl;
       
  2069         }
       
  2070     } else if (part == "MULTIMEDIA" || part == "SCRIPT" || part == "SCRIPTTOOLS") {
       
  2071         available = true;
       
  2072     } else if (part == "WEBKIT") {
       
  2073         available = (dictionary.value("QMAKESPEC") == "win32-msvc2005") || (dictionary.value("QMAKESPEC") == "win32-msvc2008") || (dictionary.value("QMAKESPEC") == "win32-g++");
       
  2074     } else if (part == "DECLARATIVE") {
       
  2075         available = QFile::exists(sourcePath + "/src/declarative/qml/qmlcomponent.h");
       
  2076     } else if (part == "AUDIO_BACKEND") {
       
  2077         available = true;
       
  2078         if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith("symbian")) {
       
  2079             QString epocRoot = Environment::symbianEpocRoot();
       
  2080             const QDir epocRootDir(epocRoot);
       
  2081             if (epocRootDir.exists()) {
       
  2082                 QStringList paths;
       
  2083                 paths << "epoc32/release/armv5/lib/mmfdevsound.dso"
       
  2084                       << "epoc32/release/armv5/lib/mmfdevsound.lib"
       
  2085                       << "epoc32/release/winscw/udeb/mmfdevsound.dll"
       
  2086                       << "epoc32/release/winscw/udeb/mmfdevsound.lib"
       
  2087                       << "epoc32/include/mmf/server/sounddevice.h";
       
  2088 
       
  2089                 QStringList::iterator i = paths.begin();
       
  2090                 while (i != paths.end()) {
       
  2091                     const QString &path = epocRoot + *i;
       
  2092                     if (QFile::exists(path))
       
  2093                         i = paths.erase(i);
       
  2094                     else
       
  2095                         ++i;
       
  2096                 }
       
  2097 
       
  2098                 available = (paths.size() == 0);
       
  2099                 if (!available) {
       
  2100                     if (epocRoot.isNull() || epocRoot == "")
       
  2101                         epocRoot = "<empty string>";
       
  2102                     cout << endl
       
  2103                          << "The QtMultimedia audio backend will not be built because required" << endl
       
  2104                          << "support for CMMFDevSound was not found in the SDK." << endl
       
  2105                          << "The SDK which was examined was located at the following path:" << endl
       
  2106                          << "    " << epocRoot << endl
       
  2107                          << "The following required files were missing from the SDK:" << endl;
       
  2108                     QString path;
       
  2109                     foreach (path, paths)
       
  2110                         cout << "    " << path << endl;
       
  2111                     cout << endl;
       
  2112                 }
       
  2113             } else {
       
  2114                 cout << endl
       
  2115                      << "The SDK root was determined to be '" << epocRoot << "'." << endl
       
  2116                      << "This directory was not found, so the SDK could not be checked for" << endl
       
  2117                      << "CMMFDevSound support.  The QtMultimedia audio backend will therefore" << endl
       
  2118                      << "not be built." << endl << endl;
       
  2119                 available = false;
       
  2120             }
       
  2121         }
       
  2122     }
       
  2123 
       
  2124     return available;
       
  2125 }
       
  2126 
       
  2127 /*
       
  2128     Autodetect options marked as "auto".
       
  2129 */
       
  2130 void Configure::autoDetection()
       
  2131 {
       
  2132     // Style detection
       
  2133     if (dictionary["STYLE_WINDOWSXP"] == "auto")
       
  2134         dictionary["STYLE_WINDOWSXP"] = checkAvailability("STYLE_WINDOWSXP") ? defaultTo("STYLE_WINDOWSXP") : "no";
       
  2135     if (dictionary["STYLE_WINDOWSVISTA"] == "auto") // Vista style has the same requirements as XP style
       
  2136         dictionary["STYLE_WINDOWSVISTA"] = checkAvailability("STYLE_WINDOWSXP") ? defaultTo("STYLE_WINDOWSVISTA") : "no";
       
  2137 
       
  2138     // Compression detection
       
  2139     if (dictionary["ZLIB"] == "auto")
       
  2140         dictionary["ZLIB"] =  checkAvailability("ZLIB") ? defaultTo("ZLIB") : "qt";
       
  2141 
       
  2142     // Image format detection
       
  2143     if (dictionary["GIF"] == "auto")
       
  2144         dictionary["GIF"] = defaultTo("GIF");
       
  2145     if (dictionary["JPEG"] == "auto")
       
  2146         dictionary["JPEG"] = defaultTo("JPEG");
       
  2147     if (dictionary["PNG"] == "auto")
       
  2148         dictionary["PNG"] = defaultTo("PNG");
       
  2149     if (dictionary["MNG"] == "auto")
       
  2150         dictionary["MNG"] = defaultTo("MNG");
       
  2151     if (dictionary["TIFF"] == "auto")
       
  2152         dictionary["TIFF"] = dictionary["ZLIB"] == "no" ? "no" : defaultTo("TIFF");
       
  2153     if (dictionary["LIBJPEG"] == "auto")
       
  2154         dictionary["LIBJPEG"] = checkAvailability("LIBJPEG") ? defaultTo("LIBJPEG") : "qt";
       
  2155     if (dictionary["LIBPNG"] == "auto")
       
  2156         dictionary["LIBPNG"] = checkAvailability("LIBPNG") ? defaultTo("LIBPNG") : "qt";
       
  2157     if (dictionary["LIBMNG"] == "auto")
       
  2158         dictionary["LIBMNG"] = checkAvailability("LIBMNG") ? defaultTo("LIBMNG") : "qt";
       
  2159     if (dictionary["LIBTIFF"] == "auto")
       
  2160         dictionary["LIBTIFF"] = checkAvailability("LIBTIFF") ? defaultTo("LIBTIFF") : "qt";
       
  2161 
       
  2162     // SQL detection (not on by default)
       
  2163     if (dictionary["SQL_MYSQL"] == "auto")
       
  2164         dictionary["SQL_MYSQL"] = checkAvailability("SQL_MYSQL") ? defaultTo("SQL_MYSQL") : "no";
       
  2165     if (dictionary["SQL_ODBC"] == "auto")
       
  2166         dictionary["SQL_ODBC"] = checkAvailability("SQL_ODBC") ? defaultTo("SQL_ODBC") : "no";
       
  2167     if (dictionary["SQL_OCI"] == "auto")
       
  2168         dictionary["SQL_OCI"] = checkAvailability("SQL_OCI") ? defaultTo("SQL_OCI") : "no";
       
  2169     if (dictionary["SQL_PSQL"] == "auto")
       
  2170         dictionary["SQL_PSQL"] = checkAvailability("SQL_PSQL") ? defaultTo("SQL_PSQL") : "no";
       
  2171     if (dictionary["SQL_TDS"] == "auto")
       
  2172         dictionary["SQL_TDS"] = checkAvailability("SQL_TDS") ? defaultTo("SQL_TDS") : "no";
       
  2173     if (dictionary["SQL_DB2"] == "auto")
       
  2174         dictionary["SQL_DB2"] = checkAvailability("SQL_DB2") ? defaultTo("SQL_DB2") : "no";
       
  2175     if (dictionary["SQL_SQLITE"] == "auto")
       
  2176         dictionary["SQL_SQLITE"] = checkAvailability("SQL_SQLITE") ? defaultTo("SQL_SQLITE") : "no";
       
  2177     if (dictionary["SQL_SQLITE_LIB"] == "system")
       
  2178         if (!checkAvailability("SQL_SQLITE_LIB"))
       
  2179             dictionary["SQL_SQLITE_LIB"] = "no";
       
  2180     if (dictionary["SQL_SQLITE2"] == "auto")
       
  2181         dictionary["SQL_SQLITE2"] = checkAvailability("SQL_SQLITE2") ? defaultTo("SQL_SQLITE2") : "no";
       
  2182     if (dictionary["SQL_IBASE"] == "auto")
       
  2183         dictionary["SQL_IBASE"] = checkAvailability("SQL_IBASE") ? defaultTo("SQL_IBASE") : "no";
       
  2184     if (dictionary["MMX"] == "auto")
       
  2185         dictionary["MMX"] = checkAvailability("MMX") ? "yes" : "no";
       
  2186     if (dictionary["3DNOW"] == "auto")
       
  2187         dictionary["3DNOW"] = checkAvailability("3DNOW") ? "yes" : "no";
       
  2188     if (dictionary["SSE"] == "auto")
       
  2189         dictionary["SSE"] = checkAvailability("SSE") ? "yes" : "no";
       
  2190     if (dictionary["SSE2"] == "auto")
       
  2191         dictionary["SSE2"] = checkAvailability("SSE2") ? "yes" : "no";
       
  2192     if (dictionary["IWMMXT"] == "auto")
       
  2193         dictionary["IWMMXT"] = checkAvailability("IWMMXT") ? "yes" : "no";
       
  2194     if (dictionary["OPENSSL"] == "auto")
       
  2195         dictionary["OPENSSL"] = checkAvailability("OPENSSL") ? "yes" : "no";
       
  2196     if (dictionary["DBUS"] == "auto")
       
  2197         dictionary["DBUS"] = checkAvailability("DBUS") ? "yes" : "no";
       
  2198     if (dictionary["SCRIPT"] == "auto")
       
  2199         dictionary["SCRIPT"] = checkAvailability("SCRIPT") ? "yes" : "no";
       
  2200     if (dictionary["SCRIPTTOOLS"] == "auto")
       
  2201         dictionary["SCRIPTTOOLS"] = checkAvailability("SCRIPTTOOLS") ? "yes" : "no";
       
  2202     if (dictionary["XMLPATTERNS"] == "auto")
       
  2203         dictionary["XMLPATTERNS"] = checkAvailability("XMLPATTERNS") ? "yes" : "no";
       
  2204     if (dictionary["PHONON"] == "auto")
       
  2205         dictionary["PHONON"] = checkAvailability("PHONON") ? "yes" : "no";
       
  2206     if (dictionary["WEBKIT"] == "auto")
       
  2207         dictionary["WEBKIT"] = checkAvailability("WEBKIT") ? "yes" : "no";
       
  2208     if (dictionary["DECLARATIVE"] == "auto")
       
  2209         dictionary["DECLARATIVE"] = checkAvailability("DECLARATIVE") ? "yes" : "no";
       
  2210     if (dictionary["AUDIO_BACKEND"] == "auto")
       
  2211         dictionary["AUDIO_BACKEND"] = checkAvailability("AUDIO_BACKEND") ? "yes" : "no";
       
  2212 
       
  2213     // Qt/WinCE remote test application
       
  2214     if (dictionary["CETEST"] == "auto")
       
  2215         dictionary["CETEST"] = checkAvailability("CETEST") ? "yes" : "no";
       
  2216 
       
  2217     // Detection of IncrediBuild buildconsole
       
  2218     if (dictionary["INCREDIBUILD_XGE"] == "auto")
       
  2219         dictionary["INCREDIBUILD_XGE"] = checkAvailability("INCREDIBUILD_XGE") ? "yes" : "no";
       
  2220 
       
  2221     // Mark all unknown "auto" to the default value..
       
  2222     for (QMap<QString,QString>::iterator i = dictionary.begin(); i != dictionary.end(); ++i) {
       
  2223         if (i.value() == "auto")
       
  2224             i.value() = defaultTo(i.key());
       
  2225     }
       
  2226 }
       
  2227 
       
  2228 bool Configure::verifyConfiguration()
       
  2229 {
       
  2230     if (dictionary["SQL_SQLITE_LIB"] == "no" && dictionary["SQL_SQLITE"] != "no") {
       
  2231         cout << "WARNING: Configure could not detect the presence of a system SQLite3 lib." << endl
       
  2232              << "Configure will therefore continue with the SQLite3 lib bundled with Qt." << endl
       
  2233              << "(Press any key to continue..)";
       
  2234         if(_getch() == 3) // _Any_ keypress w/no echo(eat <Enter> for stdout)
       
  2235             exit(0);      // Exit cleanly for Ctrl+C
       
  2236 
       
  2237         dictionary["SQL_SQLITE_LIB"] = "qt"; // Set to Qt's bundled lib an continue
       
  2238     }
       
  2239     if (dictionary["QMAKESPEC"].endsWith("-g++")
       
  2240         && dictionary["SQL_OCI"] != "no") {
       
  2241         cout << "WARNING: Qt does not support compiling the Oracle database driver with" << endl
       
  2242              << "MinGW, due to lack of such support from Oracle. Consider disabling the" << endl
       
  2243              << "Oracle driver, as the current build will most likely fail." << endl;
       
  2244         cout << "(Press any key to continue..)";
       
  2245         if(_getch() == 3) // _Any_ keypress w/no echo(eat <Enter> for stdout)
       
  2246             exit(0);      // Exit cleanly for Ctrl+C
       
  2247     }
       
  2248     if (dictionary["QMAKESPEC"].endsWith("win32-msvc.net")) {
       
  2249         cout << "WARNING: The makespec win32-msvc.net is deprecated. Consider using" << endl
       
  2250              << "win32-msvc2002 or win32-msvc2003 instead." << endl;
       
  2251         cout << "(Press any key to continue..)";
       
  2252         if(_getch() == 3) // _Any_ keypress w/no echo(eat <Enter> for stdout)
       
  2253             exit(0);      // Exit cleanly for Ctrl+C
       
  2254     }
       
  2255 	if (0 != dictionary["ARM_FPU_TYPE"].size())
       
  2256 	{
       
  2257 		QStringList l= QStringList()
       
  2258 			<< "softvfp"
       
  2259 			<< "softvfp+vfpv2"
       
  2260 			<< "vfpv2";
       
  2261 		if (!(l.contains(dictionary["ARM_FPU_TYPE"])))
       
  2262 			cout << QString("WARNING: Using unsupported fpu flag: %1").arg(dictionary["ARM_FPU_TYPE"]) << endl;
       
  2263 	}
       
  2264 
       
  2265     return true;
       
  2266 }
       
  2267 
       
  2268 /*
       
  2269  Things that affect the Qt API/ABI:
       
  2270    Options:
       
  2271      minimal-config small-config medium-config large-config full-config
       
  2272 
       
  2273    Options:
       
  2274      debug release
       
  2275      stl
       
  2276 
       
  2277  Things that do not affect the Qt API/ABI:
       
  2278      system-jpeg no-jpeg jpeg
       
  2279      system-mng no-mng mng
       
  2280      system-png no-png png
       
  2281      system-zlib no-zlib zlib
       
  2282      system-tiff no-tiff tiff
       
  2283      no-gif gif
       
  2284      dll staticlib
       
  2285 
       
  2286      nocrosscompiler
       
  2287      GNUmake
       
  2288      largefile
       
  2289      nis
       
  2290      nas
       
  2291      tablet
       
  2292      ipv6
       
  2293 
       
  2294      X11     : x11sm xinerama xcursor xfixes xrandr xrender fontconfig xkb
       
  2295      Embedded: embedded freetype
       
  2296 */
       
  2297 void Configure::generateBuildKey()
       
  2298 {
       
  2299     QString spec = dictionary["QMAKESPEC"];
       
  2300 
       
  2301     QString compiler = "msvc"; // ICC is compatible
       
  2302     if (spec.endsWith("-g++"))
       
  2303         compiler = "mingw";
       
  2304     else if (spec.endsWith("-borland"))
       
  2305         compiler = "borland";
       
  2306 
       
  2307     // Build options which changes the Qt API/ABI
       
  2308     QStringList build_options;
       
  2309     if (!dictionary["QCONFIG"].isEmpty())
       
  2310         build_options += dictionary["QCONFIG"] + "-config ";
       
  2311     build_options.sort();
       
  2312 
       
  2313     // Sorted defines that start with QT_NO_
       
  2314     QStringList build_defines = qmakeDefines.filter(QRegExp("^QT_NO_"));
       
  2315     build_defines.sort();
       
  2316 
       
  2317     // Build up the QT_BUILD_KEY ifdef
       
  2318     QString buildKey = "QT_BUILD_KEY \"";
       
  2319     if (!dictionary["USER_BUILD_KEY"].isEmpty())
       
  2320         buildKey += dictionary["USER_BUILD_KEY"] + " ";
       
  2321 
       
  2322     QString build32Key = buildKey + "Windows " + compiler + " %1 " + build_options.join(" ") + " " + build_defines.join(" ");
       
  2323     QString build64Key = buildKey + "Windows x64 " + compiler + " %1 " + build_options.join(" ") + " " + build_defines.join(" ");
       
  2324     QString buildSymbianKey = buildKey + "Symbian " + build_options.join(" ") + " " + build_defines.join(" ");
       
  2325     build32Key = build32Key.simplified();
       
  2326     build64Key = build64Key.simplified();
       
  2327     buildSymbianKey = buildSymbianKey.simplified();
       
  2328     build32Key.prepend("#   define ");
       
  2329     build64Key.prepend("#   define ");
       
  2330     buildSymbianKey.prepend("# define ");
       
  2331 
       
  2332     QString buildkey = "#if defined(__SYMBIAN32__)\n"
       
  2333                        + buildSymbianKey + "\"\n"
       
  2334                        "#else\n"
       
  2335                        // Debug builds
       
  2336                        "# if (defined(_DEBUG) || defined(DEBUG))\n"
       
  2337                        "#  if (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))\n"
       
  2338                        + build64Key.arg("debug") + "\"\n"
       
  2339                        "#  else\n"
       
  2340                        + build32Key.arg("debug") + "\"\n"
       
  2341                        "#  endif\n"
       
  2342                        "# else\n"
       
  2343                        // Release builds
       
  2344                        "#  if (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))\n"
       
  2345                        + build64Key.arg("release") + "\"\n"
       
  2346                        "#  else\n"
       
  2347                        + build32Key.arg("release") + "\"\n"
       
  2348                        "#  endif\n"
       
  2349                        "# endif\n"
       
  2350                        "#endif\n";
       
  2351 
       
  2352     dictionary["BUILD_KEY"] = buildkey;
       
  2353 }
       
  2354 
       
  2355 void Configure::generateOutputVars()
       
  2356 {
       
  2357     // Generate variables for output
       
  2358     // Build key ----------------------------------------------------
       
  2359     if ( dictionary.contains("BUILD_KEY") ) {
       
  2360         qmakeVars += dictionary.value("BUILD_KEY");
       
  2361     }
       
  2362 
       
  2363     QString build = dictionary[ "BUILD" ];
       
  2364     bool buildAll = (dictionary[ "BUILDALL" ] == "yes");
       
  2365     if ( build == "debug") {
       
  2366         if (buildAll)
       
  2367             qtConfig += "release";
       
  2368         qtConfig += "debug";
       
  2369     } else if (build == "release") {
       
  2370         if (buildAll)
       
  2371             qtConfig += "debug";
       
  2372         qtConfig += "release";
       
  2373     }
       
  2374 
       
  2375     // Compression --------------------------------------------------
       
  2376     if( dictionary[ "ZLIB" ] == "qt" )
       
  2377         qtConfig += "zlib";
       
  2378     else if( dictionary[ "ZLIB" ] == "system" )
       
  2379         qtConfig += "system-zlib";
       
  2380 
       
  2381     // Image formates -----------------------------------------------
       
  2382     if( dictionary[ "GIF" ] == "no" )
       
  2383         qtConfig += "no-gif";
       
  2384     else if( dictionary[ "GIF" ] == "yes" )
       
  2385         qtConfig += "gif";
       
  2386     else if( dictionary[ "GIF" ] == "plugin" )
       
  2387         qmakeFormatPlugins += "gif";
       
  2388 
       
  2389     if( dictionary[ "TIFF" ] == "no" )
       
  2390           qtConfig += "no-tiff";
       
  2391     else if( dictionary[ "TIFF" ] == "plugin" )
       
  2392         qmakeFormatPlugins += "tiff";
       
  2393     if( dictionary[ "LIBTIFF" ] == "system" )
       
  2394         qtConfig += "system-tiff";
       
  2395 
       
  2396     if( dictionary[ "JPEG" ] == "no" )
       
  2397         qtConfig += "no-jpeg";
       
  2398     else if( dictionary[ "JPEG" ] == "plugin" )
       
  2399         qmakeFormatPlugins += "jpeg";
       
  2400     if( dictionary[ "LIBJPEG" ] == "system" )
       
  2401         qtConfig += "system-jpeg";
       
  2402 
       
  2403     if( dictionary[ "PNG" ] == "no" )
       
  2404         qtConfig += "no-png";
       
  2405     else if( dictionary[ "PNG" ] == "qt" )
       
  2406         qtConfig += "png";
       
  2407     if( dictionary[ "LIBPNG" ] == "system" )
       
  2408         qtConfig += "system-png";
       
  2409 
       
  2410     if( dictionary[ "MNG" ] == "no" )
       
  2411         qtConfig += "no-mng";
       
  2412     else if( dictionary[ "MNG" ] == "qt" )
       
  2413         qtConfig += "mng";
       
  2414     if( dictionary[ "LIBMNG" ] == "system" )
       
  2415         qtConfig += "system-mng";
       
  2416 
       
  2417     // Text rendering --------------------------------------------------
       
  2418     if( dictionary[ "FREETYPE" ] == "yes" )
       
  2419         qtConfig += "freetype";
       
  2420 
       
  2421     // Styles -------------------------------------------------------
       
  2422     if ( dictionary[ "STYLE_WINDOWS" ] == "yes" )
       
  2423         qmakeStyles += "windows";
       
  2424 
       
  2425     if ( dictionary[ "STYLE_PLASTIQUE" ] == "yes" )
       
  2426         qmakeStyles += "plastique";
       
  2427 
       
  2428     if ( dictionary[ "STYLE_CLEANLOOKS" ] == "yes" )
       
  2429         qmakeStyles += "cleanlooks";
       
  2430 
       
  2431     if ( dictionary[ "STYLE_WINDOWSXP" ] == "yes" )
       
  2432         qmakeStyles += "windowsxp";
       
  2433 
       
  2434     if ( dictionary[ "STYLE_WINDOWSVISTA" ] == "yes" )
       
  2435         qmakeStyles += "windowsvista";
       
  2436 
       
  2437     if ( dictionary[ "STYLE_MOTIF" ] == "yes" )
       
  2438         qmakeStyles += "motif";
       
  2439 
       
  2440     if ( dictionary[ "STYLE_SGI" ] == "yes" )
       
  2441         qmakeStyles += "sgi";
       
  2442 
       
  2443     if ( dictionary[ "STYLE_WINDOWSCE" ] == "yes" )
       
  2444     qmakeStyles += "windowsce";
       
  2445 
       
  2446     if ( dictionary[ "STYLE_WINDOWSMOBILE" ] == "yes" )
       
  2447     qmakeStyles += "windowsmobile";
       
  2448 
       
  2449     if ( dictionary[ "STYLE_CDE" ] == "yes" )
       
  2450         qmakeStyles += "cde";
       
  2451 
       
  2452     if ( dictionary[ "STYLE_S60" ] == "yes" )
       
  2453         qmakeStyles += "s60";
       
  2454 
       
  2455     // Databases ----------------------------------------------------
       
  2456     if ( dictionary[ "SQL_MYSQL" ] == "yes" )
       
  2457         qmakeSql += "mysql";
       
  2458     else if ( dictionary[ "SQL_MYSQL" ] == "plugin" )
       
  2459         qmakeSqlPlugins += "mysql";
       
  2460 
       
  2461     if ( dictionary[ "SQL_ODBC" ] == "yes" )
       
  2462         qmakeSql += "odbc";
       
  2463     else if ( dictionary[ "SQL_ODBC" ] == "plugin" )
       
  2464         qmakeSqlPlugins += "odbc";
       
  2465 
       
  2466     if ( dictionary[ "SQL_OCI" ] == "yes" )
       
  2467         qmakeSql += "oci";
       
  2468     else if ( dictionary[ "SQL_OCI" ] == "plugin" )
       
  2469         qmakeSqlPlugins += "oci";
       
  2470 
       
  2471     if ( dictionary[ "SQL_PSQL" ] == "yes" )
       
  2472         qmakeSql += "psql";
       
  2473     else if ( dictionary[ "SQL_PSQL" ] == "plugin" )
       
  2474         qmakeSqlPlugins += "psql";
       
  2475 
       
  2476     if ( dictionary[ "SQL_TDS" ] == "yes" )
       
  2477         qmakeSql += "tds";
       
  2478     else if ( dictionary[ "SQL_TDS" ] == "plugin" )
       
  2479         qmakeSqlPlugins += "tds";
       
  2480 
       
  2481     if ( dictionary[ "SQL_DB2" ] == "yes" )
       
  2482         qmakeSql += "db2";
       
  2483     else if ( dictionary[ "SQL_DB2" ] == "plugin" )
       
  2484         qmakeSqlPlugins += "db2";
       
  2485 
       
  2486     if ( dictionary[ "SQL_SQLITE" ] == "yes" )
       
  2487         qmakeSql += "sqlite";
       
  2488     else if ( dictionary[ "SQL_SQLITE" ] == "plugin" )
       
  2489         qmakeSqlPlugins += "sqlite";
       
  2490 
       
  2491     if ( dictionary[ "SQL_SQLITE_LIB" ] == "system" )
       
  2492         qmakeConfig += "system-sqlite";
       
  2493 
       
  2494     if ( dictionary[ "SQL_SQLITE2" ] == "yes" )
       
  2495         qmakeSql += "sqlite2";
       
  2496     else if ( dictionary[ "SQL_SQLITE2" ] == "plugin" )
       
  2497         qmakeSqlPlugins += "sqlite2";
       
  2498 
       
  2499     if ( dictionary[ "SQL_IBASE" ] == "yes" )
       
  2500         qmakeSql += "ibase";
       
  2501     else if ( dictionary[ "SQL_IBASE" ] == "plugin" )
       
  2502         qmakeSqlPlugins += "ibase";
       
  2503 
       
  2504     // Other options ------------------------------------------------
       
  2505     if( dictionary[ "BUILDALL" ] == "yes" ) {
       
  2506         qmakeConfig += "build_all";
       
  2507     }
       
  2508     qmakeConfig += dictionary[ "BUILD" ];
       
  2509     dictionary[ "QMAKE_OUTDIR" ] = dictionary[ "BUILD" ];
       
  2510 
       
  2511     if ( dictionary[ "SHARED" ] == "yes" ) {
       
  2512         QString version = dictionary[ "VERSION" ];
       
  2513         if (!version.isEmpty()) {
       
  2514             qmakeVars += "QMAKE_QT_VERSION_OVERRIDE = " + version.left(version.indexOf("."));
       
  2515             version.remove(QLatin1Char('.'));
       
  2516         }
       
  2517         dictionary[ "QMAKE_OUTDIR" ] += "_shared";
       
  2518     } else {
       
  2519         dictionary[ "QMAKE_OUTDIR" ] += "_static";
       
  2520     }
       
  2521 
       
  2522     if( dictionary[ "ACCESSIBILITY" ] == "yes" )
       
  2523         qtConfig += "accessibility";
       
  2524 
       
  2525     if( !qmakeLibs.isEmpty() )
       
  2526         qmakeVars += "LIBS           += " + qmakeLibs.join( " " );
       
  2527 
       
  2528     if( !dictionary["QT_LFLAGS_SQLITE"].isEmpty() )
       
  2529         qmakeVars += "QT_LFLAGS_SQLITE += " + dictionary["QT_LFLAGS_SQLITE"];
       
  2530 
       
  2531     if (dictionary[ "QT3SUPPORT" ] == "yes")
       
  2532         qtConfig += "qt3support";
       
  2533 
       
  2534     if (dictionary[ "OPENGL" ] == "yes")
       
  2535         qtConfig += "opengl";
       
  2536 
       
  2537     if ( dictionary["OPENGL_ES_CM"] == "yes" ) {
       
  2538         qtConfig += "opengles1";
       
  2539         qtConfig += "egl";
       
  2540     }
       
  2541 
       
  2542     if ( dictionary["OPENGL_ES_2"] == "yes" ) {
       
  2543         qtConfig += "opengles2";
       
  2544         qtConfig += "egl";
       
  2545     }
       
  2546 
       
  2547     if ( dictionary["OPENGL_ES_CL"] == "yes" ) {
       
  2548         qtConfig += "opengles1cl";
       
  2549         qtConfig += "egl";
       
  2550     }
       
  2551 
       
  2552     if ( dictionary["OPENVG"] == "yes" ) {
       
  2553         qtConfig += "openvg";
       
  2554         qtConfig += "egl";
       
  2555     }
       
  2556 
       
  2557     if ( dictionary["S60"] == "yes" ) {
       
  2558         qtConfig += "s60";
       
  2559     }
       
  2560 
       
  2561      if ( dictionary["DIRECTSHOW"] == "yes" )
       
  2562         qtConfig += "directshow";
       
  2563 
       
  2564     if (dictionary[ "OPENSSL" ] == "yes")
       
  2565         qtConfig += "openssl";
       
  2566     else if (dictionary[ "OPENSSL" ] == "linked")
       
  2567         qtConfig += "openssl-linked";
       
  2568 
       
  2569     if (dictionary[ "DBUS" ] == "yes")
       
  2570         qtConfig += "dbus";
       
  2571     else if (dictionary[ "DBUS" ] == "linked")
       
  2572         qtConfig += "dbus dbus-linked";
       
  2573 
       
  2574     if (dictionary["IPV6"] == "yes")
       
  2575         qtConfig += "ipv6";
       
  2576     else if (dictionary["IPV6"] == "no")
       
  2577         qtConfig += "no-ipv6";
       
  2578 
       
  2579     if (dictionary[ "CETEST" ] == "yes")
       
  2580         qtConfig += "cetest";
       
  2581 
       
  2582     if (dictionary[ "SCRIPT" ] == "yes")
       
  2583         qtConfig += "script";
       
  2584 
       
  2585     if (dictionary[ "SCRIPTTOOLS" ] == "yes") {
       
  2586         if (dictionary[ "SCRIPT" ] == "no") {
       
  2587             cout << "QtScriptTools was requested, but it can't be built due to QtScript being "
       
  2588                     "disabled." << endl;
       
  2589             dictionary[ "DONE" ] = "error";
       
  2590         }
       
  2591         qtConfig += "scripttools";
       
  2592     }
       
  2593 
       
  2594     if (dictionary[ "XMLPATTERNS" ] == "yes")
       
  2595         qtConfig += "xmlpatterns";
       
  2596 
       
  2597     if (dictionary["PHONON"] == "yes") {
       
  2598         qtConfig += "phonon";
       
  2599         if (dictionary["PHONON_BACKEND"] == "yes")
       
  2600             qtConfig += "phonon-backend";
       
  2601     }
       
  2602 
       
  2603     if (dictionary["MULTIMEDIA"] == "yes") {
       
  2604         qtConfig += "multimedia";
       
  2605         if (dictionary["AUDIO_BACKEND"] == "yes")
       
  2606             qtConfig += "audio-backend";
       
  2607     }
       
  2608 
       
  2609     if (dictionary["WEBKIT"] == "yes")
       
  2610         qtConfig += "webkit";
       
  2611 
       
  2612     if (dictionary["DECLARATIVE"] == "yes")
       
  2613         qtConfig += "declarative";
       
  2614 
       
  2615     if( dictionary[ "NATIVE_GESTURES" ] == "yes" )
       
  2616         qtConfig += "native-gestures";
       
  2617 
       
  2618     // We currently have no switch for QtSvg, so add it unconditionally.
       
  2619     qtConfig += "svg";
       
  2620 
       
  2621     // Add config levels --------------------------------------------
       
  2622     QStringList possible_configs = QStringList()
       
  2623         << "minimal"
       
  2624         << "small"
       
  2625         << "medium"
       
  2626         << "large"
       
  2627         << "full";
       
  2628 
       
  2629     QString set_config = dictionary["QCONFIG"];
       
  2630     if (possible_configs.contains(set_config)) {
       
  2631         foreach(QString cfg, possible_configs) {
       
  2632             qtConfig += (cfg + "-config");
       
  2633             if (cfg == set_config)
       
  2634                 break;
       
  2635         }
       
  2636     }
       
  2637 
       
  2638     if (dictionary.contains("XQMAKESPEC") && ( dictionary["QMAKESPEC"] != dictionary["XQMAKESPEC"] ) )
       
  2639             qmakeConfig += "cross_compile";
       
  2640 
       
  2641     // Directories and settings for .qmake.cache --------------------
       
  2642 
       
  2643     // if QT_INSTALL_* have not been specified on commandline, define them now from QT_INSTALL_PREFIX
       
  2644     // if prefix is empty (WINCE), make all of them empty, if they aren't set
       
  2645     bool qipempty = false;
       
  2646     if(dictionary[ "QT_INSTALL_PREFIX" ].isEmpty())
       
  2647         qipempty = true;
       
  2648 
       
  2649     if( !dictionary[ "QT_INSTALL_DOCS" ].size() )
       
  2650         dictionary[ "QT_INSTALL_DOCS" ] = qipempty ? "" : fixSeparators( dictionary[ "QT_INSTALL_PREFIX" ] + "/doc" );
       
  2651     if( !dictionary[ "QT_INSTALL_HEADERS" ].size() )
       
  2652         dictionary[ "QT_INSTALL_HEADERS" ] = qipempty ? "" : fixSeparators( dictionary[ "QT_INSTALL_PREFIX" ] + "/include" );
       
  2653     if( !dictionary[ "QT_INSTALL_LIBS" ].size() )
       
  2654         dictionary[ "QT_INSTALL_LIBS" ] = qipempty ? "" : fixSeparators( dictionary[ "QT_INSTALL_PREFIX" ] + "/lib" );
       
  2655     if( !dictionary[ "QT_INSTALL_BINS" ].size() )
       
  2656         dictionary[ "QT_INSTALL_BINS" ] = qipempty ? "" : fixSeparators( dictionary[ "QT_INSTALL_PREFIX" ] + "/bin" );
       
  2657     if( !dictionary[ "QT_INSTALL_PLUGINS" ].size() )
       
  2658         dictionary[ "QT_INSTALL_PLUGINS" ] = qipempty ? "" : fixSeparators( dictionary[ "QT_INSTALL_PREFIX" ] + "/plugins" );
       
  2659     if( !dictionary[ "QT_INSTALL_DATA" ].size() )
       
  2660         dictionary[ "QT_INSTALL_DATA" ] = qipempty ? "" : fixSeparators( dictionary[ "QT_INSTALL_PREFIX" ] );
       
  2661     if( !dictionary[ "QT_INSTALL_TRANSLATIONS" ].size() )
       
  2662         dictionary[ "QT_INSTALL_TRANSLATIONS" ] = qipempty ? "" : fixSeparators( dictionary[ "QT_INSTALL_PREFIX" ] + "/translations" );
       
  2663     if( !dictionary[ "QT_INSTALL_EXAMPLES" ].size() )
       
  2664         dictionary[ "QT_INSTALL_EXAMPLES" ] = qipempty ? "" : fixSeparators( dictionary[ "QT_INSTALL_PREFIX" ] + "/examples");
       
  2665     if( !dictionary[ "QT_INSTALL_DEMOS" ].size() )
       
  2666         dictionary[ "QT_INSTALL_DEMOS" ] = qipempty ? "" : fixSeparators( dictionary[ "QT_INSTALL_PREFIX" ] + "/demos" );
       
  2667 
       
  2668     if(dictionary.contains("XQMAKESPEC") && dictionary[ "XQMAKESPEC" ].startsWith("linux"))
       
  2669         dictionary[ "QMAKE_RPATHDIR" ] = dictionary[ "QT_INSTALL_LIBS" ];
       
  2670 
       
  2671     qmakeVars += QString("OBJECTS_DIR     = ") + fixSeparators( "tmp/obj/" + dictionary[ "QMAKE_OUTDIR" ] );
       
  2672     qmakeVars += QString("MOC_DIR         = ") + fixSeparators( "tmp/moc/" + dictionary[ "QMAKE_OUTDIR" ] );
       
  2673     qmakeVars += QString("RCC_DIR         = ") + fixSeparators("tmp/rcc/" + dictionary["QMAKE_OUTDIR"]);
       
  2674 
       
  2675     if (!qmakeDefines.isEmpty())
       
  2676         qmakeVars += QString("DEFINES        += ") + qmakeDefines.join( " " );
       
  2677     if (!qmakeIncludes.isEmpty())
       
  2678         qmakeVars += QString("INCLUDEPATH    += ") + qmakeIncludes.join( " " );
       
  2679     if (!opensslLibs.isEmpty())
       
  2680         qmakeVars += opensslLibs;
       
  2681     else if (dictionary[ "OPENSSL" ] == "linked") {
       
  2682     	if(dictionary.contains("XQMAKESPEC") && dictionary[ "XQMAKESPEC" ].startsWith("symbian") )
       
  2683             qmakeVars += QString("OPENSSL_LIBS    = -llibssl -llibcrypto");
       
  2684         else
       
  2685             qmakeVars += QString("OPENSSL_LIBS    = -lssleay32 -llibeay32");
       
  2686         }
       
  2687     if (!qmakeSql.isEmpty())
       
  2688         qmakeVars += QString("sql-drivers    += ") + qmakeSql.join( " " );
       
  2689     if (!qmakeSqlPlugins.isEmpty())
       
  2690         qmakeVars += QString("sql-plugins    += ") + qmakeSqlPlugins.join( " " );
       
  2691     if (!qmakeStyles.isEmpty())
       
  2692         qmakeVars += QString("styles         += ") + qmakeStyles.join( " " );
       
  2693     if (!qmakeStylePlugins.isEmpty())
       
  2694         qmakeVars += QString("style-plugins  += ") + qmakeStylePlugins.join( " " );
       
  2695     if (!qmakeFormatPlugins.isEmpty())
       
  2696         qmakeVars += QString("imageformat-plugins += ") + qmakeFormatPlugins.join( " " );
       
  2697 
       
  2698     if (dictionary["QMAKESPEC"].endsWith("-g++")) {
       
  2699         QString includepath = qgetenv("INCLUDE");
       
  2700         bool hasSh = Environment::detectExecutable("sh.exe");
       
  2701         QChar separator = (!includepath.contains(":\\") && hasSh ? QChar(':') : QChar(';'));
       
  2702         qmakeVars += QString("TMPPATH            = $$quote($$(INCLUDE))");
       
  2703         qmakeVars += QString("QMAKE_INCDIR_POST += $$split(TMPPATH,\"%1\")").arg(separator);
       
  2704         qmakeVars += QString("TMPPATH            = $$quote($$(LIB))");
       
  2705         qmakeVars += QString("QMAKE_LIBDIR_POST += $$split(TMPPATH,\"%1\")").arg(separator);
       
  2706     }
       
  2707 
       
  2708     if( !dictionary[ "QMAKESPEC" ].length() ) {
       
  2709         cout << "Configure could not detect your compiler. QMAKESPEC must either" << endl
       
  2710              << "be defined as an environment variable, or specified as an" << endl
       
  2711              << "argument with -platform" << endl;
       
  2712         dictionary[ "HELP" ] = "yes";
       
  2713 
       
  2714         QStringList winPlatforms;
       
  2715         QDir mkspecsDir( sourcePath + "/mkspecs" );
       
  2716         const QFileInfoList &specsList = mkspecsDir.entryInfoList();
       
  2717         for(int i = 0; i < specsList.size(); ++i) {
       
  2718             const QFileInfo &fi = specsList.at(i);
       
  2719             if( fi.fileName().left( 5 ) == "win32" ) {
       
  2720                 winPlatforms += fi.fileName();
       
  2721             }
       
  2722         }
       
  2723         cout << "Available platforms are: " << qPrintable(winPlatforms.join( ", " )) << endl;
       
  2724         dictionary[ "DONE" ] = "error";
       
  2725     }
       
  2726 }
       
  2727 
       
  2728 #if !defined(EVAL)
       
  2729 void Configure::generateCachefile()
       
  2730 {
       
  2731     // Generate .qmake.cache
       
  2732     QFile cacheFile( buildPath + "/.qmake.cache" );
       
  2733     if( cacheFile.open( QFile::WriteOnly | QFile::Text ) ) { // Truncates any existing file.
       
  2734         QTextStream cacheStream( &cacheFile );
       
  2735         for( QStringList::Iterator var = qmakeVars.begin(); var != qmakeVars.end(); ++var ) {
       
  2736             cacheStream << (*var) << endl;
       
  2737         }
       
  2738         cacheStream << "CONFIG         += " << qmakeConfig.join( " " ) << " incremental create_prl link_prl depend_includepath QTDIR_build" << endl;
       
  2739 
       
  2740         QStringList buildParts;
       
  2741         buildParts << "libs" << "tools" << "examples" << "demos" << "docs" << "translations";
       
  2742         foreach(QString item, disabledBuildParts) {
       
  2743             buildParts.removeAll(item);
       
  2744         }
       
  2745         cacheStream << "QT_BUILD_PARTS  = " << buildParts.join( " " ) << endl;
       
  2746 
       
  2747         QString targetSpec = dictionary.contains("XQMAKESPEC") ? dictionary[ "XQMAKESPEC" ] : dictionary[ "QMAKESPEC" ];
       
  2748         QString mkspec_path = fixSeparators(sourcePath + "/mkspecs/" + targetSpec);
       
  2749         if(QFile::exists(mkspec_path))
       
  2750             cacheStream << "QMAKESPEC       = " << mkspec_path << endl;
       
  2751         else
       
  2752             cacheStream << "QMAKESPEC       = " << fixSeparators(targetSpec) << endl;
       
  2753         cacheStream << "ARCH            = " << fixSeparators(dictionary[ "ARCHITECTURE" ]) << endl;
       
  2754         cacheStream << "QT_BUILD_TREE   = " << fixSeparators(dictionary[ "QT_BUILD_TREE" ]) << endl;
       
  2755         cacheStream << "QT_SOURCE_TREE  = " << fixSeparators(dictionary[ "QT_SOURCE_TREE" ]) << endl;
       
  2756 
       
  2757         if (dictionary["QT_EDITION"] != "QT_EDITION_OPENSOURCE")
       
  2758             cacheStream << "DEFINES        *= QT_EDITION=QT_EDITION_DESKTOP" << endl;
       
  2759 
       
  2760         //so that we can build without an install first (which would be impossible)
       
  2761         cacheStream << "QMAKE_MOC       = $$QT_BUILD_TREE" << fixSeparators("/bin/moc.exe") << endl;
       
  2762         cacheStream << "QMAKE_UIC       = $$QT_BUILD_TREE" << fixSeparators("/bin/uic.exe") << endl;
       
  2763         cacheStream << "QMAKE_UIC3      = $$QT_BUILD_TREE" << fixSeparators("/bin/uic3.exe") << endl;
       
  2764         cacheStream << "QMAKE_RCC       = $$QT_BUILD_TREE" << fixSeparators("/bin/rcc.exe") << endl;
       
  2765         cacheStream << "QMAKE_DUMPCPP   = $$QT_BUILD_TREE" << fixSeparators("/bin/dumpcpp.exe") << endl;
       
  2766         cacheStream << "QMAKE_INCDIR_QT = $$QT_BUILD_TREE" << fixSeparators("/include") << endl;
       
  2767         cacheStream << "QMAKE_LIBDIR_QT = $$QT_BUILD_TREE" << fixSeparators("/lib") << endl;
       
  2768         if (dictionary["CETEST"] == "yes") {
       
  2769             cacheStream << "QT_CE_RAPI_INC  = " << fixSeparators(dictionary[ "QT_CE_RAPI_INC" ]) << endl;
       
  2770             cacheStream << "QT_CE_RAPI_LIB  = " << fixSeparators(dictionary[ "QT_CE_RAPI_LIB" ]) << endl;
       
  2771         }
       
  2772 
       
  2773         // embedded
       
  2774         if( !dictionary["KBD_DRIVERS"].isEmpty())
       
  2775             cacheStream << "kbd-drivers += "<< dictionary["KBD_DRIVERS"]<<endl;
       
  2776         if( !dictionary["GFX_DRIVERS"].isEmpty())
       
  2777             cacheStream << "gfx-drivers += "<< dictionary["GFX_DRIVERS"]<<endl;
       
  2778         if( !dictionary["MOUSE_DRIVERS"].isEmpty())
       
  2779             cacheStream << "mouse-drivers += "<< dictionary["MOUSE_DRIVERS"]<<endl;
       
  2780         if( !dictionary["DECORATIONS"].isEmpty())
       
  2781             cacheStream << "decorations += "<<dictionary["DECORATIONS"]<<endl;
       
  2782 
       
  2783         if( !dictionary["QMAKE_RPATHDIR"].isEmpty() )
       
  2784             cacheStream << "QMAKE_RPATHDIR += "<<dictionary["QMAKE_RPATHDIR"];
       
  2785 
       
  2786         cacheStream.flush();
       
  2787         cacheFile.close();
       
  2788     }
       
  2789     QFile configFile( dictionary[ "QT_BUILD_TREE" ] + "/mkspecs/qconfig.pri" );
       
  2790     if( configFile.open( QFile::WriteOnly | QFile::Text ) ) { // Truncates any existing file.
       
  2791         QTextStream configStream( &configFile );
       
  2792         configStream << "CONFIG+= ";
       
  2793         configStream << dictionary[ "BUILD" ];
       
  2794         if( dictionary[ "SHARED" ] == "yes" )
       
  2795             configStream << " shared";
       
  2796         else
       
  2797             configStream << " static";
       
  2798 
       
  2799         if( dictionary[ "LTCG" ] == "yes" )
       
  2800             configStream << " ltcg";
       
  2801         if( dictionary[ "STL" ] == "yes" )
       
  2802             configStream << " stl";
       
  2803         if ( dictionary[ "EXCEPTIONS" ] == "yes" )
       
  2804             configStream << " exceptions";
       
  2805         if ( dictionary[ "EXCEPTIONS" ] == "no" )
       
  2806             configStream << " exceptions_off";
       
  2807         if ( dictionary[ "RTTI" ] == "yes" )
       
  2808             configStream << " rtti";
       
  2809         if ( dictionary[ "MMX" ] == "yes" )
       
  2810             configStream << " mmx";
       
  2811         if ( dictionary[ "3DNOW" ] == "yes" )
       
  2812             configStream << " 3dnow";
       
  2813         if ( dictionary[ "SSE" ] == "yes" )
       
  2814             configStream << " sse";
       
  2815         if ( dictionary[ "SSE2" ] == "yes" )
       
  2816             configStream << " sse2";
       
  2817         if ( dictionary[ "IWMMXT" ] == "yes" )
       
  2818             configStream << " iwmmxt";
       
  2819         if ( dictionary["INCREDIBUILD_XGE"] == "yes" )
       
  2820             configStream << " incredibuild_xge";
       
  2821         if ( dictionary["PLUGIN_MANIFESTS"] == "no" )
       
  2822             configStream << " no_plugin_manifest";
       
  2823 
       
  2824         if ( dictionary.contains("SYMBIAN_DEFFILES") ) {
       
  2825             if(dictionary["SYMBIAN_DEFFILES"] == "yes" ) {
       
  2826                 configStream << " def_files";
       
  2827             } else if ( dictionary["SYMBIAN_DEFFILES"] == "no" ) {
       
  2828                 configStream << " def_files_disabled";
       
  2829             }
       
  2830         }
       
  2831         configStream << endl;
       
  2832         configStream << "QT_ARCH = " << dictionary[ "ARCHITECTURE" ] << endl;
       
  2833         if (dictionary["QT_EDITION"].contains("OPENSOURCE"))
       
  2834             configStream << "QT_EDITION = " << QLatin1String("OpenSource") << endl;
       
  2835         else
       
  2836             configStream << "QT_EDITION = " << dictionary["EDITION"] << endl;
       
  2837         configStream << "QT_CONFIG += " << qtConfig.join(" ") << endl;
       
  2838 
       
  2839         configStream << "#versioning " << endl
       
  2840                      << "QT_VERSION = " << dictionary["VERSION"] << endl
       
  2841                      << "QT_MAJOR_VERSION = " << dictionary["VERSION_MAJOR"] << endl
       
  2842                      << "QT_MINOR_VERSION = " << dictionary["VERSION_MINOR"] << endl
       
  2843                      << "QT_PATCH_VERSION = " << dictionary["VERSION_PATCH"] << endl;
       
  2844 
       
  2845         configStream << "#Qt for Windows CE c-runtime deployment" << endl
       
  2846                      << "QT_CE_C_RUNTIME = " << fixSeparators(dictionary[ "CE_CRT" ]) << endl;
       
  2847 
       
  2848         if(dictionary["CE_SIGNATURE"] != QLatin1String("no"))
       
  2849             configStream << "DEFAULT_SIGNATURE=" << dictionary["CE_SIGNATURE"] << endl;
       
  2850 
       
  2851         if(!dictionary["QMAKE_RPATHDIR"].isEmpty())
       
  2852             configStream << "QMAKE_RPATHDIR += " << dictionary["QMAKE_RPATHDIR"] << endl;
       
  2853 
       
  2854         if (!dictionary["QT_LIBINFIX"].isEmpty())
       
  2855             configStream << "QT_LIBINFIX = " << dictionary["QT_LIBINFIX"] << endl;
       
  2856 
       
  2857         configStream << "#Qt for Symbian FPU settings" << endl;
       
  2858         if(!dictionary["ARM_FPU_TYPE"].isEmpty()) {
       
  2859             configStream<<"MMP_RULES += \"ARMFPU "<< dictionary["ARM_FPU_TYPE"]<< "\"";
       
  2860         }
       
  2861 
       
  2862         configStream.flush();
       
  2863         configFile.close();
       
  2864     }
       
  2865 }
       
  2866 #endif
       
  2867 
       
  2868 QString Configure::addDefine(QString def)
       
  2869 {
       
  2870     QString result, defNeg, defD = def;
       
  2871 
       
  2872     defD.replace(QRegExp("=.*"), "");
       
  2873     def.replace(QRegExp("="), " ");
       
  2874 
       
  2875     if(def.startsWith("QT_NO_")) {
       
  2876         defNeg = defD;
       
  2877         defNeg.replace("QT_NO_", "QT_");
       
  2878     } else if(def.startsWith("QT_")) {
       
  2879         defNeg = defD;
       
  2880         defNeg.replace("QT_", "QT_NO_");
       
  2881     }
       
  2882 
       
  2883     if (defNeg.isEmpty()) {
       
  2884         result = "#ifndef $DEFD\n"
       
  2885                  "# define $DEF\n"
       
  2886                  "#endif\n\n";
       
  2887     } else {
       
  2888         result = "#if defined($DEFD) && defined($DEFNEG)\n"
       
  2889                  "# undef $DEFD\n"
       
  2890                  "#elif !defined($DEFD)\n"
       
  2891                  "# define $DEF\n"
       
  2892                  "#endif\n\n";
       
  2893     }
       
  2894     result.replace("$DEFNEG", defNeg);
       
  2895     result.replace("$DEFD", defD);
       
  2896     result.replace("$DEF", def);
       
  2897     return result;
       
  2898 }
       
  2899 
       
  2900 #if !defined(EVAL)
       
  2901 void Configure::generateConfigfiles()
       
  2902 {
       
  2903     QDir(buildPath).mkpath("src/corelib/global");
       
  2904     QString outName( buildPath + "/src/corelib/global/qconfig.h" );
       
  2905     QTemporaryFile tmpFile;
       
  2906     QTextStream tmpStream;
       
  2907 
       
  2908     if(tmpFile.open()) {
       
  2909         tmpStream.setDevice(&tmpFile);
       
  2910 
       
  2911         if( dictionary[ "QCONFIG" ] == "full" ) {
       
  2912             tmpStream << "/* Everything */" << endl;
       
  2913         } else {
       
  2914             QString configName( "qconfig-" + dictionary[ "QCONFIG" ] + ".h" );
       
  2915             tmpStream << "/* Copied from " << configName << "*/" << endl;
       
  2916             tmpStream << "#ifndef QT_BOOTSTRAPPED" << endl;
       
  2917             QFile inFile( sourcePath + "/src/corelib/global/" + configName );
       
  2918             if( inFile.open( QFile::ReadOnly ) ) {
       
  2919                 QByteArray buffer = inFile.readAll();
       
  2920                 tmpFile.write( buffer.constData(), buffer.size() );
       
  2921                 inFile.close();
       
  2922             }
       
  2923             tmpStream << "#endif // QT_BOOTSTRAPPED" << endl;
       
  2924         }
       
  2925         tmpStream << endl;
       
  2926 
       
  2927         if( dictionary[ "SHARED" ] == "yes" ) {
       
  2928             tmpStream << "#ifndef QT_DLL" << endl;
       
  2929             tmpStream << "#define QT_DLL" << endl;
       
  2930             tmpStream << "#endif" << endl;
       
  2931         }
       
  2932         tmpStream << endl;
       
  2933         tmpStream << "/* License information */" << endl;
       
  2934         tmpStream << "#define QT_PRODUCT_LICENSEE \"" << licenseInfo[ "LICENSEE" ] << "\"" << endl;
       
  2935         tmpStream << "#define QT_PRODUCT_LICENSE \"" << dictionary[ "EDITION" ] << "\"" << endl;
       
  2936         tmpStream << endl;
       
  2937         tmpStream << "// Qt Edition" << endl;
       
  2938         tmpStream << "#ifndef QT_EDITION" << endl;
       
  2939         tmpStream << "#  define QT_EDITION " << dictionary["QT_EDITION"] << endl;
       
  2940         tmpStream << "#endif" << endl;
       
  2941         tmpStream << endl;
       
  2942         tmpStream << dictionary["BUILD_KEY"];
       
  2943         tmpStream << endl;
       
  2944         if (dictionary["BUILDDEV"] == "yes") {
       
  2945             dictionary["QMAKE_INTERNAL"] = "yes";
       
  2946             tmpStream << "/* Used for example to export symbols for the certain autotests*/" << endl;
       
  2947             tmpStream << "#define QT_BUILD_INTERNAL" << endl;
       
  2948             tmpStream << endl;
       
  2949         }
       
  2950         tmpStream << "/* Machine byte-order */" << endl;
       
  2951         tmpStream << "#define Q_BIG_ENDIAN 4321" << endl;
       
  2952         tmpStream << "#define Q_LITTLE_ENDIAN 1234" << endl;
       
  2953         if ( QSysInfo::ByteOrder == QSysInfo::BigEndian )
       
  2954             tmpStream << "#define Q_BYTE_ORDER Q_BIG_ENDIAN" << endl;
       
  2955         else
       
  2956             tmpStream << "#define Q_BYTE_ORDER Q_LITTLE_ENDIAN" << endl;
       
  2957 
       
  2958         tmpStream << endl << "// Compile time features" << endl;
       
  2959         tmpStream << "#define QT_ARCH_" << dictionary["ARCHITECTURE"].toUpper() << endl;
       
  2960         QStringList qconfigList;
       
  2961         if(dictionary["STL"] == "no")                qconfigList += "QT_NO_STL";
       
  2962         if(dictionary["STYLE_WINDOWS"] != "yes")     qconfigList += "QT_NO_STYLE_WINDOWS";
       
  2963         if(dictionary["STYLE_PLASTIQUE"] != "yes")   qconfigList += "QT_NO_STYLE_PLASTIQUE";
       
  2964         if(dictionary["STYLE_CLEANLOOKS"] != "yes")   qconfigList += "QT_NO_STYLE_CLEANLOOKS";
       
  2965         if(dictionary["STYLE_WINDOWSXP"] != "yes" && dictionary["STYLE_WINDOWSVISTA"] != "yes")
       
  2966             qconfigList += "QT_NO_STYLE_WINDOWSXP";
       
  2967         if(dictionary["STYLE_WINDOWSVISTA"] != "yes")   qconfigList += "QT_NO_STYLE_WINDOWSVISTA";
       
  2968         if(dictionary["STYLE_MOTIF"] != "yes")       qconfigList += "QT_NO_STYLE_MOTIF";
       
  2969         if(dictionary["STYLE_CDE"] != "yes")         qconfigList += "QT_NO_STYLE_CDE";
       
  2970         if(dictionary["STYLE_S60"] != "yes")         qconfigList += "QT_NO_STYLE_S60";
       
  2971         if(dictionary["STYLE_WINDOWSCE"] != "yes")   qconfigList += "QT_NO_STYLE_WINDOWSCE";
       
  2972         if(dictionary["STYLE_WINDOWSMOBILE"] != "yes")   qconfigList += "QT_NO_STYLE_WINDOWSMOBILE";
       
  2973         if(dictionary["STYLE_GTK"] != "yes")         qconfigList += "QT_NO_STYLE_GTK";
       
  2974 
       
  2975         if(dictionary["GIF"] == "yes")              qconfigList += "QT_BUILTIN_GIF_READER=1";
       
  2976         if(dictionary["PNG"] == "no")               qconfigList += "QT_NO_IMAGEFORMAT_PNG";
       
  2977         if(dictionary["MNG"] == "no")               qconfigList += "QT_NO_IMAGEFORMAT_MNG";
       
  2978         if(dictionary["JPEG"] == "no")              qconfigList += "QT_NO_IMAGEFORMAT_JPEG";
       
  2979         if(dictionary["TIFF"] == "no")              qconfigList += "QT_NO_IMAGEFORMAT_TIFF";
       
  2980         if(dictionary["ZLIB"] == "no") {
       
  2981             qconfigList += "QT_NO_ZLIB";
       
  2982             qconfigList += "QT_NO_COMPRESS";
       
  2983         }
       
  2984 
       
  2985         if(dictionary["ACCESSIBILITY"] == "no")     qconfigList += "QT_NO_ACCESSIBILITY";
       
  2986         if(dictionary["EXCEPTIONS"] == "no")        qconfigList += "QT_NO_EXCEPTIONS";
       
  2987         if(dictionary["OPENGL"] == "no")            qconfigList += "QT_NO_OPENGL";
       
  2988         if(dictionary["OPENVG"] == "no")            qconfigList += "QT_NO_OPENVG";
       
  2989         if(dictionary["OPENSSL"] == "no")           qconfigList += "QT_NO_OPENSSL";
       
  2990         if(dictionary["OPENSSL"] == "linked")       qconfigList += "QT_LINKED_OPENSSL";
       
  2991         if(dictionary["DBUS"] == "no")              qconfigList += "QT_NO_DBUS";
       
  2992         if(dictionary["IPV6"] == "no")              qconfigList += "QT_NO_IPV6";
       
  2993         if(dictionary["WEBKIT"] == "no")            qconfigList += "QT_NO_WEBKIT";
       
  2994         if(dictionary["DECLARATIVE"] == "no")       qconfigList += "QT_NO_DECLARATIVE";
       
  2995         if(dictionary["PHONON"] == "no")            qconfigList += "QT_NO_PHONON";
       
  2996         if(dictionary["MULTIMEDIA"] == "no")        qconfigList += "QT_NO_MULTIMEDIA";
       
  2997         if(dictionary["XMLPATTERNS"] == "no")       qconfigList += "QT_NO_XMLPATTERNS";
       
  2998         if(dictionary["SCRIPT"] == "no")            qconfigList += "QT_NO_SCRIPT";
       
  2999         if(dictionary["SCRIPTTOOLS"] == "no")       qconfigList += "QT_NO_SCRIPTTOOLS";
       
  3000         if(dictionary["FREETYPE"] == "no")          qconfigList += "QT_NO_FREETYPE";
       
  3001         if(dictionary["S60"] == "no")               qconfigList += "QT_NO_S60";
       
  3002         if(dictionary["NATIVE_GESTURES"] == "no")   qconfigList += "QT_NO_NATIVE_GESTURES";
       
  3003 
       
  3004         if(dictionary["OPENGL_ES_CM"] == "yes" ||
       
  3005            dictionary["OPENGL_ES_CL"] == "yes" ||
       
  3006            dictionary["OPENGL_ES_2"]  == "yes")     qconfigList += "QT_OPENGL_ES";
       
  3007 
       
  3008         if(dictionary["OPENGL_ES_CM"] == "yes")     qconfigList += "QT_OPENGL_ES_1";
       
  3009         if(dictionary["OPENGL_ES_2"]  == "yes")     qconfigList += "QT_OPENGL_ES_2";
       
  3010         if(dictionary["OPENGL_ES_CL"] == "yes")     qconfigList += "QT_OPENGL_ES_1_CL";
       
  3011 
       
  3012         if(dictionary["SQL_MYSQL"] == "yes")        qconfigList += "QT_SQL_MYSQL";
       
  3013         if(dictionary["SQL_ODBC"] == "yes")         qconfigList += "QT_SQL_ODBC";
       
  3014         if(dictionary["SQL_OCI"] == "yes")          qconfigList += "QT_SQL_OCI";
       
  3015         if(dictionary["SQL_PSQL"] == "yes")         qconfigList += "QT_SQL_PSQL";
       
  3016         if(dictionary["SQL_TDS"] == "yes")          qconfigList += "QT_SQL_TDS";
       
  3017         if(dictionary["SQL_DB2"] == "yes")          qconfigList += "QT_SQL_DB2";
       
  3018         if(dictionary["SQL_SQLITE"] == "yes")       qconfigList += "QT_SQL_SQLITE";
       
  3019         if(dictionary["SQL_SQLITE2"] == "yes")      qconfigList += "QT_SQL_SQLITE2";
       
  3020         if(dictionary["SQL_IBASE"] == "yes")        qconfigList += "QT_SQL_IBASE";
       
  3021 
       
  3022         if (dictionary["GRAPHICS_SYSTEM"] == "openvg") qconfigList += "QT_GRAPHICSSYSTEM_OPENVG";
       
  3023         if (dictionary["GRAPHICS_SYSTEM"] == "opengl") qconfigList += "QT_GRAPHICSSYSTEM_OPENGL";
       
  3024         if (dictionary["GRAPHICS_SYSTEM"] == "raster") qconfigList += "QT_GRAPHICSSYSTEM_RASTER";
       
  3025 
       
  3026         if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith("symbian")) {
       
  3027             // These features are not ported to Symbian (yet)
       
  3028             qconfigList += "QT_NO_CONCURRENT";
       
  3029             qconfigList += "QT_NO_QFUTURE";
       
  3030             qconfigList += "QT_NO_CRASHHANDLER";
       
  3031             qconfigList += "QT_NO_PRINTER";
       
  3032             qconfigList += "QT_NO_SYSTEMTRAYICON";
       
  3033             if (dictionary.contains("QT_LIBINFIX"))
       
  3034                 tmpStream << QString("#define QT_LIBINFIX \"%1\"").arg(dictionary["QT_LIBINFIX"]) << endl;
       
  3035         }
       
  3036 
       
  3037         qconfigList.sort();
       
  3038         for (int i = 0; i < qconfigList.count(); ++i)
       
  3039             tmpStream << addDefine(qconfigList.at(i));
       
  3040 
       
  3041         if(dictionary["EMBEDDED"] == "yes")
       
  3042         {
       
  3043             // Check for keyboard, mouse, gfx.
       
  3044             QStringList kbdDrivers = dictionary["KBD_DRIVERS"].split(" ");;
       
  3045             QStringList allKbdDrivers;
       
  3046             allKbdDrivers<<"tty"<<"usb"<<"sl5000"<<"yopy"<<"vr41xx"<<"qvfb"<<"um";
       
  3047             foreach(QString kbd, allKbdDrivers) {
       
  3048                 if( !kbdDrivers.contains(kbd))
       
  3049                     tmpStream<<"#define QT_NO_QWS_KBD_"<<kbd.toUpper()<<endl;
       
  3050             }
       
  3051 
       
  3052             QStringList mouseDrivers = dictionary["MOUSE_DRIVERS"].split(" ");
       
  3053             QStringList allMouseDrivers;
       
  3054             allMouseDrivers << "pc"<<"bus"<<"linuxtp"<<"yopy"<<"vr41xx"<<"tslib"<<"qvfb";
       
  3055             foreach(QString mouse, allMouseDrivers) {
       
  3056                 if( !mouseDrivers.contains(mouse) )
       
  3057                     tmpStream<<"#define QT_NO_QWS_MOUSE_"<<mouse.toUpper()<<endl;
       
  3058             }
       
  3059 
       
  3060             QStringList gfxDrivers = dictionary["GFX_DRIVERS"].split(" ");
       
  3061             QStringList allGfxDrivers;
       
  3062             allGfxDrivers<<"linuxfb"<<"transformed"<<"qvfb"<<"vnc"<<"multiscreen"<<"ahi";
       
  3063             foreach(QString gfx, allGfxDrivers) {
       
  3064                 if( !gfxDrivers.contains(gfx))
       
  3065                     tmpStream<<"#define QT_NO_QWS_"<<gfx.toUpper()<<endl;
       
  3066             }
       
  3067 
       
  3068             tmpStream<<"#define Q_WS_QWS"<<endl;
       
  3069 
       
  3070             QStringList depths = dictionary[ "QT_QWS_DEPTH" ].split(" ");
       
  3071             foreach(QString depth, depths)
       
  3072               tmpStream<<"#define QT_QWS_DEPTH_"+depth<<endl;
       
  3073         }
       
  3074 
       
  3075         if( dictionary[ "QT_CUPS" ] == "no")
       
  3076           tmpStream<<"#define QT_NO_CUPS"<<endl;
       
  3077 
       
  3078         if( dictionary[ "QT_ICONV" ]  == "no")
       
  3079           tmpStream<<"#define QT_NO_ICONV"<<endl;
       
  3080 
       
  3081         if(dictionary[ "QT_GLIB" ] == "no")
       
  3082           tmpStream<<"#define QT_NO_GLIB"<<endl;
       
  3083 
       
  3084         if(dictionary[ "QT_LPR" ] == "no")
       
  3085           tmpStream<<"#define QT_NO_LPR"<<endl;
       
  3086 
       
  3087         if(dictionary[ "QT_INOTIFY" ] == "no" )
       
  3088           tmpStream<<"#define QT_NO_INOTIFY"<<endl;
       
  3089 
       
  3090         if(dictionary[ "QT_SXE" ] == "no")
       
  3091           tmpStream<<"#define QT_NO_SXE"<<endl;
       
  3092 
       
  3093         tmpStream.flush();
       
  3094         tmpFile.flush();
       
  3095 
       
  3096         // Replace old qconfig.h with new one
       
  3097         ::SetFileAttributes((wchar_t*)outName.utf16(), FILE_ATTRIBUTE_NORMAL);
       
  3098         QFile::remove(outName);
       
  3099         tmpFile.copy(outName);
       
  3100         tmpFile.close();
       
  3101 
       
  3102         if(!QFile::exists(buildPath + "/include/QtCore/qconfig.h")) {
       
  3103             if (!writeToFile("#include \"../../src/corelib/global/qconfig.h\"\n",
       
  3104                              buildPath + "/include/QtCore/qconfig.h")
       
  3105             || !writeToFile("#include \"../../src/corelib/global/qconfig.h\"\n",
       
  3106                             buildPath + "/include/Qt/qconfig.h")) {
       
  3107                 dictionary["DONE"] = "error";
       
  3108                 return;
       
  3109             }
       
  3110         }
       
  3111     }
       
  3112 
       
  3113     // Copy configured mkspec to default directory, but remove the old one first, if there is any
       
  3114     QString defSpec = buildPath + "/mkspecs/default";
       
  3115     QFileInfo defSpecInfo(defSpec);
       
  3116     if (defSpecInfo.exists()) {
       
  3117         if (!Environment::rmdir(defSpec)) {
       
  3118             cout << "Couldn't update default mkspec! Are files in " << qPrintable(defSpec) << " read-only?" << endl;
       
  3119             dictionary["DONE"] = "error";
       
  3120             return;
       
  3121         }
       
  3122     }
       
  3123 
       
  3124     QString spec = dictionary.contains("XQMAKESPEC") ? dictionary["XQMAKESPEC"] : dictionary["QMAKESPEC"];
       
  3125     QString pltSpec = sourcePath + "/mkspecs/" + spec;
       
  3126     if (!Environment::cpdir(pltSpec, defSpec)) {
       
  3127         cout << "Couldn't update default mkspec! Does " << qPrintable(pltSpec) << " exist?" << endl;
       
  3128         dictionary["DONE"] = "error";
       
  3129         return;
       
  3130     }
       
  3131 
       
  3132     outName = defSpec + "/qmake.conf";
       
  3133     ::SetFileAttributes((wchar_t*)outName.utf16(), FILE_ATTRIBUTE_NORMAL );
       
  3134     QFile qmakeConfFile(outName);
       
  3135     if (qmakeConfFile.open(QFile::Append | QFile::WriteOnly | QFile::Text)) {
       
  3136         QTextStream qmakeConfStream;
       
  3137         qmakeConfStream.setDevice(&qmakeConfFile);
       
  3138         qmakeConfStream << endl << "QMAKESPEC_ORIGINAL=" << pltSpec << endl;
       
  3139         qmakeConfStream.flush();
       
  3140         qmakeConfFile.close();
       
  3141     }
       
  3142 
       
  3143     // Generate the new qconfig.cpp file
       
  3144     QDir(buildPath).mkpath("src/corelib/global");
       
  3145     outName = buildPath + "/src/corelib/global/qconfig.cpp";
       
  3146 
       
  3147     QTemporaryFile tmpFile2;
       
  3148     if (tmpFile2.open()) {
       
  3149         tmpStream.setDevice(&tmpFile2);
       
  3150         tmpStream << "/* Licensed */" << endl
       
  3151                   << "static const char qt_configure_licensee_str          [512 + 12] = \"qt_lcnsuser=" << licenseInfo["LICENSEE"] << "\";" << endl
       
  3152                   << "static const char qt_configure_licensed_products_str [512 + 12] = \"qt_lcnsprod=" << dictionary["EDITION"] << "\";" << endl
       
  3153                   << endl
       
  3154                   << "/* Build date */" << endl
       
  3155                   << "static const char qt_configure_installation          [11  + 12] = \"qt_instdate=" << QDate::currentDate().toString(Qt::ISODate) << "\";" << endl
       
  3156                   << endl;
       
  3157         if(!dictionary[ "QT_HOST_PREFIX" ].isNull())
       
  3158             tmpStream << "#if !defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE)" << endl;
       
  3159         tmpStream << "static const char qt_configure_prefix_path_str       [512 + 12] = \"qt_prfxpath=" << QString(dictionary["QT_INSTALL_PREFIX"]).replace( "\\", "\\\\" ) << "\";" << endl
       
  3160                   << "static const char qt_configure_documentation_path_str[512 + 12] = \"qt_docspath=" << QString(dictionary["QT_INSTALL_DOCS"]).replace( "\\", "\\\\" ) << "\";"  << endl
       
  3161                   << "static const char qt_configure_headers_path_str      [512 + 12] = \"qt_hdrspath=" << QString(dictionary["QT_INSTALL_HEADERS"]).replace( "\\", "\\\\" ) << "\";"  << endl
       
  3162                   << "static const char qt_configure_libraries_path_str    [512 + 12] = \"qt_libspath=" << QString(dictionary["QT_INSTALL_LIBS"]).replace( "\\", "\\\\" ) << "\";"  << endl
       
  3163                   << "static const char qt_configure_binaries_path_str     [512 + 12] = \"qt_binspath=" << QString(dictionary["QT_INSTALL_BINS"]).replace( "\\", "\\\\" ) << "\";"  << endl
       
  3164                   << "static const char qt_configure_plugins_path_str      [512 + 12] = \"qt_plugpath=" << QString(dictionary["QT_INSTALL_PLUGINS"]).replace( "\\", "\\\\" ) << "\";"  << endl
       
  3165                   << "static const char qt_configure_data_path_str         [512 + 12] = \"qt_datapath=" << QString(dictionary["QT_INSTALL_DATA"]).replace( "\\", "\\\\" ) << "\";"  << endl
       
  3166                   << "static const char qt_configure_translations_path_str [512 + 12] = \"qt_trnspath=" << QString(dictionary["QT_INSTALL_TRANSLATIONS"]).replace( "\\", "\\\\" ) << "\";" << endl
       
  3167                   << "static const char qt_configure_examples_path_str     [512 + 12] = \"qt_xmplpath=" << QString(dictionary["QT_INSTALL_EXAMPLES"]).replace( "\\", "\\\\" ) << "\";"  << endl
       
  3168                   << "static const char qt_configure_demos_path_str        [512 + 12] = \"qt_demopath=" << QString(dictionary["QT_INSTALL_DEMOS"]).replace( "\\", "\\\\" ) << "\";"  << endl
       
  3169                   //<< "static const char qt_configure_settings_path_str [256] = \"qt_stngpath=" << QString(dictionary["QT_INSTALL_SETTINGS"]).replace( "\\", "\\\\" ) << "\";" << endl
       
  3170                   ;
       
  3171         if(!dictionary[ "QT_HOST_PREFIX" ].isNull()) {
       
  3172              tmpStream << "#else" << endl
       
  3173                        << "static const char qt_configure_prefix_path_str       [512 + 12] = \"qt_prfxpath=" << QString(dictionary[ "QT_HOST_PREFIX" ]).replace( "\\", "\\\\" ) << "\";" << endl
       
  3174                        << "static const char qt_configure_documentation_path_str[512 + 12] = \"qt_docspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/doc").replace( "\\", "\\\\" ) <<"\";"  << endl
       
  3175                        << "static const char qt_configure_headers_path_str      [512 + 12] = \"qt_hdrspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/include").replace( "\\", "\\\\" ) <<"\";"  << endl
       
  3176                        << "static const char qt_configure_libraries_path_str    [512 + 12] = \"qt_libspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/lib").replace( "\\", "\\\\" ) <<"\";"  << endl
       
  3177                        << "static const char qt_configure_binaries_path_str     [512 + 12] = \"qt_binspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/bin").replace( "\\", "\\\\" ) <<"\";"  << endl
       
  3178                        << "static const char qt_configure_plugins_path_str      [512 + 12] = \"qt_plugpath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/plugins").replace( "\\", "\\\\" ) <<"\";"  << endl
       
  3179                        << "static const char qt_configure_data_path_str         [512 + 12] = \"qt_datapath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ]).replace( "\\", "\\\\" ) <<"\";"  << endl
       
  3180                        << "static const char qt_configure_translations_path_str [512 + 12] = \"qt_trnspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/translations").replace( "\\", "\\\\" ) <<"\";" << endl
       
  3181                        << "static const char qt_configure_examples_path_str     [512 + 12] = \"qt_xmplpath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/example").replace( "\\", "\\\\" ) <<"\";"  << endl
       
  3182                        << "static const char qt_configure_demos_path_str        [512 + 12] = \"qt_demopath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/demos").replace( "\\", "\\\\" ) <<"\";"  << endl
       
  3183                        << "#endif //QT_BOOTSTRAPPED" << endl;
       
  3184         }
       
  3185         tmpStream << "/* strlen( \"qt_lcnsxxxx\" ) == 12 */" << endl
       
  3186                   << "#define QT_CONFIGURE_LICENSEE qt_configure_licensee_str + 12;" << endl
       
  3187                   << "#define QT_CONFIGURE_LICENSED_PRODUCTS qt_configure_licensed_products_str + 12;" << endl
       
  3188                   << "#define QT_CONFIGURE_PREFIX_PATH qt_configure_prefix_path_str + 12;" << endl
       
  3189                   << "#define QT_CONFIGURE_DOCUMENTATION_PATH qt_configure_documentation_path_str + 12;" << endl
       
  3190                   << "#define QT_CONFIGURE_HEADERS_PATH qt_configure_headers_path_str + 12;" << endl
       
  3191                   << "#define QT_CONFIGURE_LIBRARIES_PATH qt_configure_libraries_path_str + 12;" << endl
       
  3192                   << "#define QT_CONFIGURE_BINARIES_PATH qt_configure_binaries_path_str + 12;" << endl
       
  3193                   << "#define QT_CONFIGURE_PLUGINS_PATH qt_configure_plugins_path_str + 12;" << endl
       
  3194                   << "#define QT_CONFIGURE_DATA_PATH qt_configure_data_path_str + 12;" << endl
       
  3195                   << "#define QT_CONFIGURE_TRANSLATIONS_PATH qt_configure_translations_path_str + 12;" << endl
       
  3196                   << "#define QT_CONFIGURE_EXAMPLES_PATH qt_configure_examples_path_str + 12;" << endl
       
  3197                   << "#define QT_CONFIGURE_DEMOS_PATH qt_configure_demos_path_str + 12;" << endl
       
  3198                   //<< "#define QT_CONFIGURE_SETTINGS_PATH qt_configure_settings_path_str + 12;" << endl
       
  3199                   << endl;
       
  3200 
       
  3201         tmpStream.flush();
       
  3202         tmpFile2.flush();
       
  3203 
       
  3204         // Replace old qconfig.cpp with new one
       
  3205         ::SetFileAttributes((wchar_t*)outName.utf16(), FILE_ATTRIBUTE_NORMAL );
       
  3206         QFile::remove( outName );
       
  3207         tmpFile2.copy(outName);
       
  3208         tmpFile2.close();
       
  3209     }
       
  3210 
       
  3211     QTemporaryFile tmpFile3;
       
  3212     if (tmpFile3.open()) {
       
  3213         tmpStream.setDevice(&tmpFile3);
       
  3214         tmpStream << "/* Evaluation license key */" << endl
       
  3215                   << "static const char qt_eval_key_data              [512 + 12] = \"qt_qevalkey=" << licenseInfo["LICENSEKEYEXT"] << "\";" << endl;
       
  3216 
       
  3217         tmpStream.flush();
       
  3218         tmpFile3.flush();
       
  3219 
       
  3220         outName = buildPath + "/src/corelib/global/qconfig_eval.cpp";
       
  3221         ::SetFileAttributes((wchar_t*)outName.utf16(), FILE_ATTRIBUTE_NORMAL );
       
  3222         QFile::remove( outName );
       
  3223 
       
  3224         if (dictionary["EDITION"] == "Evaluation" || qmakeDefines.contains("QT_EVAL"))
       
  3225             tmpFile3.copy(outName);
       
  3226         tmpFile3.close();
       
  3227     }
       
  3228 }
       
  3229 #endif
       
  3230 
       
  3231 #if !defined(EVAL)
       
  3232 void Configure::displayConfig()
       
  3233 {
       
  3234     // Give some feedback
       
  3235     cout << "Environment:" << endl;
       
  3236     QString env = QString::fromLocal8Bit(getenv("INCLUDE")).replace(QRegExp("[;,]"), "\r\n      ");
       
  3237     if (env.isEmpty())
       
  3238         env = "Unset";
       
  3239     cout << "    INCLUDE=\r\n      " << env << endl;
       
  3240     env = QString::fromLocal8Bit(getenv("LIB")).replace(QRegExp("[;,]"), "\r\n      ");
       
  3241     if (env.isEmpty())
       
  3242         env = "Unset";
       
  3243     cout << "    LIB=\r\n      " << env << endl;
       
  3244     env = QString::fromLocal8Bit(getenv("PATH")).replace(QRegExp("[;,]"), "\r\n      ");
       
  3245     if (env.isEmpty())
       
  3246         env = "Unset";
       
  3247     cout << "    PATH=\r\n      " << env << endl;
       
  3248 
       
  3249     if (dictionary["EDITION"] == "OpenSource") {
       
  3250         cout << "You are licensed to use this software under the terms of the GNU GPL version 3.";
       
  3251         cout << "You are licensed to use this software under the terms of the Lesser GNU LGPL version 2.1." << endl;
       
  3252         cout << "See " << dictionary["LICENSE FILE"] << "3" << endl << endl
       
  3253              << " or " << dictionary["LICENSE FILE"] << "L" << endl << endl;
       
  3254     } else {
       
  3255         QString l1 = licenseInfo[ "LICENSEE" ];
       
  3256         QString l2 = licenseInfo[ "LICENSEID" ];
       
  3257         QString l3 = dictionary["EDITION"] + ' ' + "Edition";
       
  3258         QString l4 = licenseInfo[ "EXPIRYDATE" ];
       
  3259         cout << "Licensee...................." << (l1.isNull() ? "" : l1) << endl;
       
  3260         cout << "License ID.................." << (l2.isNull() ? "" : l2) << endl;
       
  3261         cout << "Product license............." << (l3.isNull() ? "" : l3) << endl;
       
  3262         cout << "Expiry Date................." << (l4.isNull() ? "" : l4) << endl << endl;
       
  3263     }
       
  3264 
       
  3265     cout << "Configuration:" << endl;
       
  3266     cout << "    " << qmakeConfig.join( "\r\n    " ) << endl;
       
  3267     cout << "Qt Configuration:" << endl;
       
  3268     cout << "    " << qtConfig.join( "\r\n    " ) << endl;
       
  3269     cout << endl;
       
  3270 
       
  3271     if (dictionary.contains("XQMAKESPEC"))
       
  3272         cout << "QMAKESPEC..................." << dictionary[ "XQMAKESPEC" ] << " (" << dictionary["QMAKESPEC_FROM"] << ")" << endl;
       
  3273     else
       
  3274         cout << "QMAKESPEC..................." << dictionary[ "QMAKESPEC" ] << " (" << dictionary["QMAKESPEC_FROM"] << ")" << endl;
       
  3275     cout << "Architecture................" << dictionary[ "ARCHITECTURE" ] << endl;
       
  3276     cout << "Maketool...................." << dictionary[ "MAKE" ] << endl;
       
  3277     cout << "Debug symbols..............." << (dictionary[ "BUILD" ] == "debug" ? "yes" : "no") << endl;
       
  3278     cout << "Link Time Code Generation..." << dictionary[ "LTCG" ] << endl;
       
  3279     cout << "Accessibility support......." << dictionary[ "ACCESSIBILITY" ] << endl;
       
  3280     cout << "STL support................." << dictionary[ "STL" ] << endl;
       
  3281     cout << "Exception support..........." << dictionary[ "EXCEPTIONS" ] << endl;
       
  3282     cout << "RTTI support................" << dictionary[ "RTTI" ] << endl;
       
  3283     cout << "MMX support................." << dictionary[ "MMX" ] << endl;
       
  3284     cout << "3DNOW support..............." << dictionary[ "3DNOW" ] << endl;
       
  3285     cout << "SSE support................." << dictionary[ "SSE" ] << endl;
       
  3286     cout << "SSE2 support................" << dictionary[ "SSE2" ] << endl;
       
  3287     cout << "IWMMXT support.............." << dictionary[ "IWMMXT" ] << endl;
       
  3288     cout << "OpenGL support.............." << dictionary[ "OPENGL" ] << endl;
       
  3289     cout << "OpenVG support.............." << dictionary[ "OPENVG" ] << endl;
       
  3290     cout << "OpenSSL support............." << dictionary[ "OPENSSL" ] << endl;
       
  3291     cout << "QtDBus support.............." << dictionary[ "DBUS" ] << endl;
       
  3292     cout << "QtXmlPatterns support......." << dictionary[ "XMLPATTERNS" ] << endl;
       
  3293     cout << "Phonon support.............." << dictionary[ "PHONON" ] << endl;
       
  3294     cout << "QtMultimedia support........" << dictionary[ "MULTIMEDIA" ] << endl;
       
  3295     cout << "WebKit support.............." << dictionary[ "WEBKIT" ] << endl;
       
  3296     cout << "Declarative support........." << dictionary[ "DECLARATIVE" ] << endl;
       
  3297     cout << "QtScript support............" << dictionary[ "SCRIPT" ] << endl;
       
  3298     cout << "QtScriptTools support......." << dictionary[ "SCRIPTTOOLS" ] << endl;
       
  3299     cout << "Graphics System............." << dictionary[ "GRAPHICS_SYSTEM" ] << endl;
       
  3300     cout << "Qt3 compatibility..........." << dictionary[ "QT3SUPPORT" ] << endl << endl;
       
  3301 
       
  3302     cout << "Third Party Libraries:" << endl;
       
  3303     cout << "    ZLIB support............" << dictionary[ "ZLIB" ] << endl;
       
  3304     cout << "    GIF support............." << dictionary[ "GIF" ] << endl;
       
  3305     cout << "    TIFF support............" << dictionary[ "TIFF" ] << endl;
       
  3306     cout << "    JPEG support............" << dictionary[ "JPEG" ] << endl;
       
  3307     cout << "    PNG support............." << dictionary[ "PNG" ] << endl;
       
  3308     cout << "    MNG support............." << dictionary[ "MNG" ] << endl;
       
  3309     cout << "    FreeType support........" << dictionary[ "FREETYPE" ] << endl << endl;
       
  3310 
       
  3311     cout << "Styles:" << endl;
       
  3312     cout << "    Windows................." << dictionary[ "STYLE_WINDOWS" ] << endl;
       
  3313     cout << "    Windows XP.............." << dictionary[ "STYLE_WINDOWSXP" ] << endl;
       
  3314     cout << "    Windows Vista..........." << dictionary[ "STYLE_WINDOWSVISTA" ] << endl;
       
  3315     cout << "    Plastique..............." << dictionary[ "STYLE_PLASTIQUE" ] << endl;
       
  3316     cout << "    Cleanlooks.............." << dictionary[ "STYLE_CLEANLOOKS" ] << endl;
       
  3317     cout << "    Motif..................." << dictionary[ "STYLE_MOTIF" ] << endl;
       
  3318     cout << "    CDE....................." << dictionary[ "STYLE_CDE" ] << endl;
       
  3319     cout << "    Windows CE.............." << dictionary[ "STYLE_WINDOWSCE" ] << endl;
       
  3320     cout << "    Windows Mobile.........." << dictionary[ "STYLE_WINDOWSMOBILE" ] << endl;
       
  3321     cout << "    S60....................." << dictionary[ "STYLE_S60" ] << endl << endl;
       
  3322 
       
  3323     cout << "Sql Drivers:" << endl;
       
  3324     cout << "    ODBC...................." << dictionary[ "SQL_ODBC" ] << endl;
       
  3325     cout << "    MySQL..................." << dictionary[ "SQL_MYSQL" ] << endl;
       
  3326     cout << "    OCI....................." << dictionary[ "SQL_OCI" ] << endl;
       
  3327     cout << "    PostgreSQL.............." << dictionary[ "SQL_PSQL" ] << endl;
       
  3328     cout << "    TDS....................." << dictionary[ "SQL_TDS" ] << endl;
       
  3329     cout << "    DB2....................." << dictionary[ "SQL_DB2" ] << endl;
       
  3330     cout << "    SQLite.................." << dictionary[ "SQL_SQLITE" ] << " (" << dictionary[ "SQL_SQLITE_LIB" ] << ")" << endl;
       
  3331     cout << "    SQLite2................." << dictionary[ "SQL_SQLITE2" ] << endl;
       
  3332     cout << "    InterBase..............." << dictionary[ "SQL_IBASE" ] << endl << endl;
       
  3333 
       
  3334     cout << "Sources are in.............." << dictionary[ "QT_SOURCE_TREE" ] << endl;
       
  3335     cout << "Build is done in............" << dictionary[ "QT_BUILD_TREE" ] << endl;
       
  3336     cout << "Install prefix.............." << dictionary[ "QT_INSTALL_PREFIX" ] << endl;
       
  3337     cout << "Headers installed to........" << dictionary[ "QT_INSTALL_HEADERS" ] << endl;
       
  3338     cout << "Libraries installed to......" << dictionary[ "QT_INSTALL_LIBS" ] << endl;
       
  3339     cout << "Plugins installed to........" << dictionary[ "QT_INSTALL_PLUGINS" ] << endl;
       
  3340     cout << "Binaries installed to......." << dictionary[ "QT_INSTALL_BINS" ] << endl;
       
  3341     cout << "Docs installed to..........." << dictionary[ "QT_INSTALL_DOCS" ] << endl;
       
  3342     cout << "Data installed to..........." << dictionary[ "QT_INSTALL_DATA" ] << endl;
       
  3343     cout << "Translations installed to..." << dictionary[ "QT_INSTALL_TRANSLATIONS" ] << endl;
       
  3344     cout << "Examples installed to......." << dictionary[ "QT_INSTALL_EXAMPLES" ] << endl;
       
  3345     cout << "Demos installed to.........." << dictionary[ "QT_INSTALL_DEMOS" ] << endl << endl;
       
  3346 
       
  3347     if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith(QLatin1String("wince"))) {
       
  3348         cout << "Using c runtime detection..." << dictionary[ "CE_CRT" ] << endl;
       
  3349         cout << "Cetest support.............." << dictionary[ "CETEST" ] << endl;
       
  3350         cout << "Signature..................." << dictionary[ "CE_SIGNATURE"] << endl << endl;
       
  3351     }
       
  3352 
       
  3353     if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith(QLatin1String("symbian"))) {
       
  3354         cout << "Support for S60............." << dictionary[ "S60" ] << endl;
       
  3355     }
       
  3356 
       
  3357     if (dictionary.contains("SYMBIAN_DEFFILES")) {
       
  3358         cout << "Symbian DEF files enabled..." << dictionary[ "SYMBIAN_DEFFILES" ] << endl;
       
  3359         if(dictionary["SYMBIAN_DEFFILES"] == "no") {
       
  3360             cout << "WARNING: Disabling DEF files will mean that Qt is NOT binary compatible with previous versions." << endl;
       
  3361             cout << "         This feature is only intended for use during development, NEVER for release builds." << endl;
       
  3362         }
       
  3363     }
       
  3364 
       
  3365     if(dictionary["ASSISTANT_WEBKIT"] == "yes")
       
  3366         cout << "Using WebKit as html rendering engine in Qt Assistant." << endl;
       
  3367 
       
  3368     if(checkAvailability("INCREDIBUILD_XGE"))
       
  3369         cout << "Using IncrediBuild XGE......" << dictionary["INCREDIBUILD_XGE"] << endl;
       
  3370     if( !qmakeDefines.isEmpty() ) {
       
  3371         cout << "Defines.....................";
       
  3372         for( QStringList::Iterator defs = qmakeDefines.begin(); defs != qmakeDefines.end(); ++defs )
       
  3373             cout << (*defs) << " ";
       
  3374         cout << endl;
       
  3375     }
       
  3376     if( !qmakeIncludes.isEmpty() ) {
       
  3377         cout << "Include paths...............";
       
  3378         for( QStringList::Iterator incs = qmakeIncludes.begin(); incs != qmakeIncludes.end(); ++incs )
       
  3379             cout << (*incs) << " ";
       
  3380         cout << endl;
       
  3381     }
       
  3382     if( !qmakeLibs.isEmpty() ) {
       
  3383         cout << "Additional libraries........";
       
  3384         for( QStringList::Iterator libs = qmakeLibs.begin(); libs != qmakeLibs.end(); ++libs )
       
  3385             cout << (*libs) << " ";
       
  3386         cout << endl;
       
  3387     }
       
  3388     if( dictionary[ "QMAKE_INTERNAL" ] == "yes" ) {
       
  3389         cout << "Using internal configuration." << endl;
       
  3390     }
       
  3391     if( dictionary[ "SHARED" ] == "no" ) {
       
  3392         cout << "WARNING: Using static linking will disable the use of plugins." << endl;
       
  3393         cout << "         Make sure you compile ALL needed modules into the library." << endl;
       
  3394     }
       
  3395     if( dictionary[ "OPENSSL" ] == "linked" && opensslLibs.isEmpty() ) {
       
  3396         cout << "NOTE: When linking against OpenSSL, you can override the default" << endl;
       
  3397         cout << "library names through OPENSSL_LIBS." << endl;
       
  3398         cout << "For example:" << endl;
       
  3399         cout << "    configure -openssl-linked OPENSSL_LIBS='-lssleay32 -llibeay32'" << endl;
       
  3400     }
       
  3401     if( dictionary[ "ZLIB_FORCED" ] == "yes" ) {
       
  3402         QString which_zlib = "supplied";
       
  3403         if( dictionary[ "ZLIB" ] == "system")
       
  3404             which_zlib = "system";
       
  3405 
       
  3406         cout << "NOTE: The -no-zlib option was supplied but is no longer supported." << endl
       
  3407              << endl
       
  3408              << "Qt now requires zlib support in all builds, so the -no-zlib" << endl
       
  3409              << "option was ignored. Qt will be built using the " << which_zlib
       
  3410              << "zlib" << endl;
       
  3411     }
       
  3412 }
       
  3413 #endif
       
  3414 
       
  3415 #if !defined(EVAL)
       
  3416 void Configure::generateHeaders()
       
  3417 {
       
  3418     if (dictionary["SYNCQT"] == "yes"
       
  3419         && findFile("perl.exe")) {
       
  3420         cout << "Running syncqt..." << endl;
       
  3421         QStringList args;
       
  3422         args += buildPath + "/bin/syncqt.bat";
       
  3423         QStringList env;
       
  3424         env += QString("QTDIR=" + sourcePath);
       
  3425         env += QString("PATH=" + buildPath + "/bin/;" + qgetenv("PATH"));
       
  3426         Environment::execute(args, env, QStringList());
       
  3427     }
       
  3428 }
       
  3429 
       
  3430 void Configure::buildQmake()
       
  3431 {
       
  3432     if( dictionary[ "BUILD_QMAKE" ] == "yes" ) {
       
  3433         QStringList args;
       
  3434 
       
  3435         // Build qmake
       
  3436         QString pwd = QDir::currentPath();
       
  3437         QDir::setCurrent(buildPath + "/qmake" );
       
  3438 
       
  3439         QString makefile = "Makefile";
       
  3440         {
       
  3441             QFile out(makefile);
       
  3442             if(out.open(QFile::WriteOnly | QFile::Text)) {
       
  3443                 QTextStream stream(&out);
       
  3444                 stream << "#AutoGenerated by configure.exe" << endl
       
  3445                     << "BUILD_PATH = " << QDir::convertSeparators(buildPath) << endl
       
  3446                     << "SOURCE_PATH = " << QDir::convertSeparators(sourcePath) << endl;
       
  3447                 stream << "QMAKESPEC = " << dictionary["QMAKESPEC"] << endl;
       
  3448 
       
  3449                 if (dictionary["EDITION"] == "OpenSource" ||
       
  3450                     dictionary["QT_EDITION"].contains("OPENSOURCE"))
       
  3451                     stream << "QMAKE_OPENSOURCE_EDITION = yes" << endl;
       
  3452                 stream << "\n\n";
       
  3453 
       
  3454                 QFile in(sourcePath + "/qmake/" + dictionary["QMAKEMAKEFILE"]);
       
  3455                 if(in.open(QFile::ReadOnly | QFile::Text)) {
       
  3456                     QString d = in.readAll();
       
  3457                     //### need replaces (like configure.sh)? --Sam
       
  3458                     stream << d << endl;
       
  3459                 }
       
  3460                 stream.flush();
       
  3461                 out.close();
       
  3462             }
       
  3463         }
       
  3464 
       
  3465         args += dictionary[ "MAKE" ];
       
  3466         args += "-f";
       
  3467         args += makefile;
       
  3468 
       
  3469         cout << "Creating qmake..." << endl;
       
  3470         int exitCode = 0;
       
  3471         if( exitCode = Environment::execute(args, QStringList(), QStringList()) ) {
       
  3472             args.clear();
       
  3473             args += dictionary[ "MAKE" ];
       
  3474             args += "-f";
       
  3475             args += makefile;
       
  3476             args += "clean";
       
  3477             if( exitCode = Environment::execute(args, QStringList(), QStringList())) {
       
  3478                 cout << "Cleaning qmake failed, return code " << exitCode << endl << endl;
       
  3479                 dictionary[ "DONE" ] = "error";
       
  3480             } else {
       
  3481                 args.clear();
       
  3482                 args += dictionary[ "MAKE" ];
       
  3483                 args += "-f";
       
  3484                 args += makefile;
       
  3485                 if (exitCode = Environment::execute(args, QStringList(), QStringList())) {
       
  3486                     cout << "Building qmake failed, return code " << exitCode << endl << endl;
       
  3487                     dictionary[ "DONE" ] = "error";
       
  3488                 }
       
  3489             }
       
  3490         }
       
  3491         QDir::setCurrent( pwd );
       
  3492     }
       
  3493 }
       
  3494 #endif
       
  3495 
       
  3496 void Configure::buildHostTools()
       
  3497 {
       
  3498     if (dictionary[ "NOPROCESS" ] == "yes")
       
  3499         dictionary[ "DONE" ] = "yes";
       
  3500 
       
  3501     if (!dictionary.contains("XQMAKESPEC"))
       
  3502         return;
       
  3503 
       
  3504     QString pwd = QDir::currentPath();
       
  3505     QStringList hostToolsDirs;
       
  3506     hostToolsDirs
       
  3507         << "src/tools"
       
  3508         << "tools/linguist/lrelease";
       
  3509 
       
  3510     if(dictionary["XQMAKESPEC"].startsWith("wince"))
       
  3511         hostToolsDirs << "tools/checksdk";
       
  3512 
       
  3513     if (dictionary[ "CETEST" ] == "yes")
       
  3514         hostToolsDirs << "tools/qtestlib/wince/cetest";
       
  3515 
       
  3516     for (int i = 0; i < hostToolsDirs.count(); ++i) {
       
  3517         cout << "Creating " << hostToolsDirs.at(i) << " ..." << endl;
       
  3518         QString toolBuildPath = buildPath + "/" + hostToolsDirs.at(i);
       
  3519         QString toolSourcePath = sourcePath + "/" + hostToolsDirs.at(i);
       
  3520 
       
  3521         // generate Makefile
       
  3522         QStringList args;
       
  3523         args << QDir::toNativeSeparators(buildPath + "/bin/qmake");
       
  3524         args << "-spec" << dictionary["QMAKESPEC"] << "-r";
       
  3525         args << "-o" << QDir::toNativeSeparators(toolBuildPath + "/Makefile");
       
  3526 
       
  3527         QDir().mkpath(toolBuildPath);
       
  3528         QDir::setCurrent(toolSourcePath);
       
  3529         int exitCode = 0;
       
  3530         if (exitCode = Environment::execute(args, QStringList(), QStringList())) {
       
  3531             cout << "qmake failed, return code " << exitCode << endl << endl;
       
  3532             dictionary["DONE"] = "error";
       
  3533             break;
       
  3534         }
       
  3535 
       
  3536         // build app
       
  3537         args.clear();
       
  3538         args += dictionary["MAKE"];
       
  3539         QDir::setCurrent(toolBuildPath);
       
  3540         if (exitCode = Environment::execute(args, QStringList(), QStringList())) {
       
  3541             args.clear();
       
  3542             args += dictionary["MAKE"];
       
  3543             args += "clean";
       
  3544             if(exitCode = Environment::execute(args, QStringList(), QStringList())) {
       
  3545                 cout << "Cleaning " << hostToolsDirs.at(i) << " failed, return code " << exitCode << endl << endl;
       
  3546                 dictionary["DONE"] = "error";
       
  3547                 break;
       
  3548             } else {
       
  3549                 args.clear();
       
  3550                 args += dictionary["MAKE"];
       
  3551                 if (exitCode = Environment::execute(args, QStringList(), QStringList())) {
       
  3552                     cout << "Building " << hostToolsDirs.at(i) << " failed, return code " << exitCode << endl << endl;
       
  3553                     dictionary["DONE"] = "error";
       
  3554                     break;
       
  3555                 }
       
  3556             }
       
  3557         }
       
  3558     }
       
  3559     QDir::setCurrent(pwd);
       
  3560 }
       
  3561 
       
  3562 void Configure::findProjects( const QString& dirName )
       
  3563 {
       
  3564     if( dictionary[ "NOPROCESS" ] == "no" ) {
       
  3565         QDir dir( dirName );
       
  3566         QString entryName;
       
  3567         int makeListNumber;
       
  3568         ProjectType qmakeTemplate;
       
  3569         const QFileInfoList &list = dir.entryInfoList(QStringList(QLatin1String("*.pro")),
       
  3570                                                       QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot);
       
  3571         for(int i = 0; i < list.size(); ++i) {
       
  3572             const QFileInfo &fi = list.at(i);
       
  3573             if(fi.fileName() != "qmake.pro") {
       
  3574                 entryName = dirName + "/" + fi.fileName();
       
  3575                 if(fi.isDir()) {
       
  3576                     findProjects( entryName );
       
  3577                 } else {
       
  3578                     qmakeTemplate = projectType( fi.absoluteFilePath() );
       
  3579                     switch ( qmakeTemplate ) {
       
  3580                     case Lib:
       
  3581                     case Subdirs:
       
  3582                         makeListNumber = 1;
       
  3583                         break;
       
  3584                     default:
       
  3585                         makeListNumber = 2;
       
  3586                         break;
       
  3587                     }
       
  3588                     makeList[makeListNumber].append(new MakeItem(sourceDir.relativeFilePath(fi.absolutePath()),
       
  3589                                                     fi.fileName(),
       
  3590                                                     "Makefile",
       
  3591                                                     qmakeTemplate));
       
  3592                 }
       
  3593             }
       
  3594 
       
  3595         }
       
  3596     }
       
  3597 }
       
  3598 
       
  3599 void Configure::appendMakeItem(int inList, const QString &item)
       
  3600 {
       
  3601     QString dir;
       
  3602     if (item != "src")
       
  3603         dir = "/" + item;
       
  3604     dir.prepend("/src");
       
  3605     makeList[inList].append(new MakeItem(sourcePath + dir,
       
  3606         item + ".pro", buildPath + dir + "/Makefile", Lib ) );
       
  3607     if( dictionary[ "DSPFILES" ] == "yes" ) {
       
  3608         makeList[inList].append( new MakeItem(sourcePath + dir,
       
  3609             item + ".pro", buildPath + dir + "/" + item + ".dsp", Lib ) );
       
  3610     }
       
  3611     if( dictionary[ "VCPFILES" ] == "yes" ) {
       
  3612         makeList[inList].append( new MakeItem(sourcePath + dir,
       
  3613             item + ".pro", buildPath + dir + "/" + item + ".vcp", Lib ) );
       
  3614     }
       
  3615     if( dictionary[ "VCPROJFILES" ] == "yes" ) {
       
  3616         makeList[inList].append( new MakeItem(sourcePath + dir,
       
  3617             item + ".pro", buildPath + dir + "/" + item + ".vcproj", Lib ) );
       
  3618     }
       
  3619 }
       
  3620 
       
  3621 void Configure::generateMakefiles()
       
  3622 {
       
  3623     if( dictionary[ "NOPROCESS" ] == "no" ) {
       
  3624 #if !defined(EVAL)
       
  3625         cout << "Creating makefiles in src..." << endl;
       
  3626 #endif
       
  3627 
       
  3628         QString spec = dictionary.contains("XQMAKESPEC") ? dictionary[ "XQMAKESPEC" ] : dictionary[ "QMAKESPEC" ];
       
  3629         if( spec != "win32-msvc" )
       
  3630             dictionary[ "DSPFILES" ] = "no";
       
  3631 
       
  3632         if( spec != "win32-msvc.net" && !spec.startsWith("win32-msvc2") && !spec.startsWith(QLatin1String("wince")))
       
  3633             dictionary[ "VCPROJFILES" ] = "no";
       
  3634 
       
  3635         int i = 0;
       
  3636         QString pwd = QDir::currentPath();
       
  3637         if (dictionary["FAST"] != "yes") {
       
  3638             QString dirName;
       
  3639             bool generate = true;
       
  3640             bool doDsp = (dictionary["DSPFILES"] == "yes" || dictionary["VCPFILES"] == "yes"
       
  3641                           || dictionary["VCPROJFILES"] == "yes");
       
  3642             while (generate) {
       
  3643                 QString pwd = QDir::currentPath();
       
  3644                 QString dirPath = fixSeparators(buildPath + dirName);
       
  3645                 QStringList args;
       
  3646 
       
  3647                 args << fixSeparators( buildPath + "/bin/qmake" );
       
  3648 
       
  3649                 if (doDsp) {
       
  3650                     if( dictionary[ "DEPENDENCIES" ] == "no" )
       
  3651                         args << "-nodepend";
       
  3652                     args << "-tp" <<  "vc";
       
  3653                     doDsp = false; // DSP files will be done
       
  3654                     printf("Generating Visual Studio project files...\n");
       
  3655                 } else {
       
  3656                     printf("Generating Makefiles...\n");
       
  3657                     generate = false; // Now Makefiles will be done
       
  3658                 }
       
  3659                 args << "-spec";
       
  3660                 args << spec;
       
  3661                 args << "-r";
       
  3662                 args << (sourcePath + "/projects.pro");
       
  3663                 args << "-o";
       
  3664                 args << buildPath;
       
  3665                 if(!dictionary[ "QMAKEADDITIONALARGS" ].isEmpty())
       
  3666                     args << dictionary[ "QMAKEADDITIONALARGS" ];
       
  3667 
       
  3668                 QDir::setCurrent( fixSeparators( dirPath ) );
       
  3669                 if( int exitCode = Environment::execute(args, QStringList(), QStringList()) ) {
       
  3670                     cout << "Qmake failed, return code " << exitCode  << endl << endl;
       
  3671                     dictionary[ "DONE" ] = "error";
       
  3672                 }
       
  3673             }
       
  3674         } else {
       
  3675             findProjects(sourcePath);
       
  3676             for ( i=0; i<3; i++ ) {
       
  3677                 for ( int j=0; j<makeList[i].size(); ++j) {
       
  3678                     MakeItem *it=makeList[i][j];
       
  3679                     QString dirPath = fixSeparators( it->directory + "/" );
       
  3680                     QString projectName = it->proFile;
       
  3681                     QString makefileName = buildPath + "/" + dirPath + it->target;
       
  3682 
       
  3683                     // For shadowbuilds, we need to create the path first
       
  3684                     QDir buildPathDir(buildPath);
       
  3685                     if (sourcePath != buildPath && !buildPathDir.exists(dirPath))
       
  3686                         buildPathDir.mkpath(dirPath);
       
  3687 
       
  3688                     QStringList args;
       
  3689 
       
  3690                     args << fixSeparators( buildPath + "/bin/qmake" );
       
  3691                     args << sourcePath + "/" + dirPath + projectName;
       
  3692                     args << dictionary[ "QMAKE_ALL_ARGS" ];
       
  3693 
       
  3694                     cout << "For " << qPrintable(dirPath + projectName) << endl;
       
  3695                     args << "-o";
       
  3696                     args << it->target;
       
  3697                     args << "-spec";
       
  3698                     args << spec;
       
  3699                     if(!dictionary[ "QMAKEADDITIONALARGS" ].isEmpty())
       
  3700                         args << dictionary[ "QMAKEADDITIONALARGS" ];
       
  3701 
       
  3702                     QDir::setCurrent( fixSeparators( dirPath ) );
       
  3703 
       
  3704                     QFile file(makefileName);
       
  3705                     if (!file.open(QFile::WriteOnly)) {
       
  3706                         printf("failed on dirPath=%s, makefile=%s\n",
       
  3707                             qPrintable(dirPath), qPrintable(makefileName));
       
  3708                         continue;
       
  3709                     }
       
  3710                     QTextStream txt(&file);
       
  3711                     txt << "all:\n";
       
  3712                     txt << "\t" << args.join(" ") << "\n";
       
  3713                     txt << "\t\"$(MAKE)\" -$(MAKEFLAGS) -f " << it->target << "\n";
       
  3714                     txt << "first: all\n";
       
  3715                     txt << "qmake:\n";
       
  3716                     txt << "\t" << args.join(" ") << "\n";
       
  3717                 }
       
  3718             }
       
  3719         }
       
  3720         QDir::setCurrent( pwd );
       
  3721     } else {
       
  3722         cout << "Processing of project files have been disabled." << endl;
       
  3723         cout << "Only use this option if you really know what you're doing." << endl << endl;
       
  3724         return;
       
  3725     }
       
  3726 }
       
  3727 
       
  3728 void Configure::showSummary()
       
  3729 {
       
  3730     QString make = dictionary[ "MAKE" ];
       
  3731     if (!dictionary.contains("XQMAKESPEC")) {
       
  3732         cout << endl << endl << "Qt is now configured for building. Just run " << qPrintable(make) << "." << endl;
       
  3733         cout << "To reconfigure, run " << qPrintable(make) << " confclean and configure." << endl << endl;
       
  3734     } else if(dictionary.value("QMAKESPEC").startsWith("wince")) {
       
  3735         // we are cross compiling for Windows CE
       
  3736         cout << endl << endl << "Qt is now configured for building. To start the build run:" << endl
       
  3737              << "\tsetcepaths " << dictionary.value("XQMAKESPEC") << endl
       
  3738              << "\t" << qPrintable(make) << endl
       
  3739              << "To reconfigure, run " << qPrintable(make) << " confclean and configure." << endl << endl;
       
  3740     } else { // Compiling for Symbian OS
       
  3741         cout << endl << endl << "Qt is now configured for building. To start the build run:" << qPrintable(dictionary["QTBUILDINSTRUCTION"]) << "." << endl
       
  3742         << "To reconfigure, run '" << qPrintable(dictionary["CONFCLEANINSTRUCTION"]) << "' and configure." << endl;
       
  3743     }
       
  3744 }
       
  3745 
       
  3746 Configure::ProjectType Configure::projectType( const QString& proFileName )
       
  3747 {
       
  3748     QFile proFile( proFileName );
       
  3749     if( proFile.open( QFile::ReadOnly ) ) {
       
  3750         QString buffer = proFile.readLine(1024);
       
  3751         while (!buffer.isEmpty()) {
       
  3752             QStringList segments = buffer.split(QRegExp( "\\s" ));
       
  3753             QStringList::Iterator it = segments.begin();
       
  3754 
       
  3755             if(segments.size() >= 3) {
       
  3756                 QString keyword = (*it++);
       
  3757                 QString operation = (*it++);
       
  3758                 QString value = (*it++);
       
  3759 
       
  3760                 if( keyword == "TEMPLATE" ) {
       
  3761                     if( value == "lib" )
       
  3762                         return Lib;
       
  3763                     else if( value == "subdirs" )
       
  3764                         return Subdirs;
       
  3765                 }
       
  3766             }
       
  3767             // read next line
       
  3768             buffer = proFile.readLine(1024);
       
  3769         }
       
  3770         proFile.close();
       
  3771     }
       
  3772     // Default to app handling
       
  3773     return App;
       
  3774 }
       
  3775 
       
  3776 #if !defined(EVAL)
       
  3777 
       
  3778 bool Configure::showLicense(QString orgLicenseFile)
       
  3779 {
       
  3780     if (dictionary["LICENSE_CONFIRMED"] == "yes") {
       
  3781         cout << "You have already accepted the terms of the license." << endl << endl;
       
  3782         return true;
       
  3783     }
       
  3784 
       
  3785     bool haveGpl3 = false;
       
  3786     QString licenseFile = orgLicenseFile;
       
  3787     QString theLicense;
       
  3788     if (dictionary["EDITION"] == "OpenSource" || dictionary["EDITION"] == "Snapshot") {
       
  3789         haveGpl3 = QFile::exists(orgLicenseFile + "/LICENSE.GPL3");
       
  3790         theLicense = "GNU Lesser General Public License (LGPL) version 2.1";
       
  3791         if (haveGpl3)
       
  3792             theLicense += "\nor the GNU General Public License (GPL) version 3";
       
  3793     } else {
       
  3794         // the first line of the license file tells us which license it is
       
  3795         QFile file(licenseFile);
       
  3796         if (!file.open(QFile::ReadOnly)) {
       
  3797             cout << "Failed to load LICENSE file" << endl;
       
  3798             return false;
       
  3799         }
       
  3800         theLicense = file.readLine().trimmed();
       
  3801     }
       
  3802 
       
  3803     forever {
       
  3804         char accept = '?';
       
  3805         cout << "You are licensed to use this software under the terms of" << endl
       
  3806              << "the " << theLicense << "." << endl
       
  3807              << endl;
       
  3808         if (dictionary["EDITION"] == "OpenSource" || dictionary["EDITION"] == "Snapshot") {
       
  3809             if (haveGpl3)
       
  3810                 cout << "Type '3' to view the GNU General Public License version 3 (GPLv3)." << endl;
       
  3811             cout << "Type 'L' to view the Lesser GNU General Public License version 2.1 (LGPLv2.1)." << endl;
       
  3812         } else {
       
  3813             cout << "Type '?' to view the " << theLicense << "." << endl;
       
  3814         }
       
  3815         cout << "Type 'y' to accept this license offer." << endl
       
  3816              << "Type 'n' to decline this license offer." << endl
       
  3817              << endl
       
  3818              << "Do you accept the terms of the license?" << endl;
       
  3819         cin >> accept;
       
  3820         accept = tolower(accept);
       
  3821 
       
  3822         if (accept == 'y') {
       
  3823             return true;
       
  3824         } else if (accept == 'n') {
       
  3825             return false;
       
  3826         } else {
       
  3827             if (dictionary["EDITION"] == "OpenSource" || dictionary["EDITION"] == "Snapshot") {
       
  3828                 if (accept == '3')
       
  3829                     licenseFile = orgLicenseFile + "/LICENSE.GPL3";
       
  3830                 else
       
  3831                     licenseFile = orgLicenseFile + "/LICENSE.LGPL";
       
  3832             }
       
  3833             // Get console line height, to fill the screen properly
       
  3834             int i = 0, screenHeight = 25; // default
       
  3835             CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
       
  3836             HANDLE stdOut = GetStdHandle(STD_OUTPUT_HANDLE);
       
  3837             if (GetConsoleScreenBufferInfo(stdOut, &consoleInfo))
       
  3838                 screenHeight = consoleInfo.srWindow.Bottom
       
  3839                              - consoleInfo.srWindow.Top
       
  3840                              - 1; // Some overlap for context
       
  3841 
       
  3842             // Prompt the license content to the user
       
  3843             QFile file(licenseFile);
       
  3844             if (!file.open(QFile::ReadOnly)) {
       
  3845                 cout << "Failed to load LICENSE file" << licenseFile << endl;
       
  3846                 return false;
       
  3847             }
       
  3848             QStringList licenseContent = QString(file.readAll()).split('\n');
       
  3849             while(i < licenseContent.size()) {
       
  3850                 cout << licenseContent.at(i) << endl;
       
  3851                 if (++i % screenHeight == 0) {
       
  3852                     cout << "(Press any key for more..)";
       
  3853                     if(_getch() == 3) // _Any_ keypress w/no echo(eat <Enter> for stdout)
       
  3854                         exit(0);      // Exit cleanly for Ctrl+C
       
  3855                     cout << "\r";     // Overwrite text above
       
  3856                 }
       
  3857             }
       
  3858         }
       
  3859     }
       
  3860 }
       
  3861 
       
  3862 void Configure::readLicense()
       
  3863 {
       
  3864    if (QFile::exists(dictionary["QT_SOURCE_TREE"] + "/src/corelib/kernel/qfunctions_wince.h") &&
       
  3865        (dictionary.value("QMAKESPEC").startsWith("wince") || dictionary.value("XQMAKESPEC").startsWith("wince")))
       
  3866         dictionary["PLATFORM NAME"] = "Qt for Windows CE";
       
  3867     else if (dictionary.value("XQMAKESPEC").startsWith("symbian"))
       
  3868         dictionary["PLATFORM NAME"] = "Qt for Symbian";
       
  3869     else
       
  3870         dictionary["PLATFORM NAME"] = "Qt for Windows";
       
  3871     dictionary["LICENSE FILE"] = sourcePath;
       
  3872 
       
  3873     bool openSource = false;
       
  3874     bool hasOpenSource = QFile::exists(dictionary["LICENSE FILE"] + "/LICENSE.GPL3") || QFile::exists(dictionary["LICENSE FILE"] + "/LICENSE.LGPL");
       
  3875     if (dictionary["BUILDNOKIA"] == "yes" || dictionary["BUILDTYPE"] == "commercial") {
       
  3876         openSource = false;
       
  3877     } else if (dictionary["BUILDTYPE"] == "opensource") {
       
  3878         openSource = true;
       
  3879     } else if (hasOpenSource) { // No Open Source? Just display the commercial license right away
       
  3880         forever {
       
  3881             char accept = '?';
       
  3882             cout << "Which edition of Qt do you want to use ?" << endl;
       
  3883             cout << "Type 'c' if you want to use the Commercial Edition." << endl;
       
  3884             cout << "Type 'o' if you want to use the Open Source Edition." << endl;
       
  3885             cin >> accept;
       
  3886             accept = tolower(accept);
       
  3887 
       
  3888             if (accept == 'c') {
       
  3889                 openSource = false;
       
  3890                 break;
       
  3891             } else if (accept == 'o') {
       
  3892                 openSource = true;
       
  3893                 break;
       
  3894             }
       
  3895         }
       
  3896     }
       
  3897     if (hasOpenSource && openSource) {
       
  3898         cout << endl << "This is the " << dictionary["PLATFORM NAME"] << " Open Source Edition." << endl;
       
  3899         licenseInfo["LICENSEE"] = "Open Source";
       
  3900         dictionary["EDITION"] = "OpenSource";
       
  3901         dictionary["QT_EDITION"] = "QT_EDITION_OPENSOURCE";
       
  3902         cout << endl;
       
  3903         if (!showLicense(dictionary["LICENSE FILE"])) {
       
  3904             cout << "Configuration aborted since license was not accepted";
       
  3905             dictionary["DONE"] = "error";
       
  3906             return;
       
  3907         }
       
  3908     } else if (openSource) {
       
  3909         cout << endl << "Cannot find the GPL license files! Please download the Open Source version of the library." << endl;
       
  3910         dictionary["DONE"] = "error";
       
  3911     }
       
  3912 #ifdef COMMERCIAL_VERSION
       
  3913     else {
       
  3914         Tools::checkLicense(dictionary, licenseInfo, firstLicensePath());
       
  3915         if (dictionary["DONE"] != "error" && dictionary["BUILDNOKIA"] != "yes") {
       
  3916             // give the user some feedback, and prompt for license acceptance
       
  3917             cout << endl << "This is the " << dictionary["PLATFORM NAME"] << " " << dictionary["EDITION"] << " Edition."<< endl << endl;
       
  3918             if (!showLicense(dictionary["LICENSE FILE"])) {
       
  3919                 cout << "Configuration aborted since license was not accepted";
       
  3920                 dictionary["DONE"] = "error";
       
  3921                 return;
       
  3922             }
       
  3923         }
       
  3924     }
       
  3925 #else // !COMMERCIAL_VERSION
       
  3926     else {
       
  3927         cout << endl << "Cannot build commercial edition from the open source version of the library." << endl;
       
  3928         dictionary["DONE"] = "error";
       
  3929     }
       
  3930 #endif
       
  3931 }
       
  3932 
       
  3933 void Configure::reloadCmdLine()
       
  3934 {
       
  3935     if( dictionary[ "REDO" ] == "yes" ) {
       
  3936         QFile inFile( buildPath + "/configure" + dictionary[ "CUSTOMCONFIG" ] + ".cache" );
       
  3937         if( inFile.open( QFile::ReadOnly ) ) {
       
  3938             QTextStream inStream( &inFile );
       
  3939             QString buffer;
       
  3940             inStream >> buffer;
       
  3941             while( buffer.length() ) {
       
  3942                 configCmdLine += buffer;
       
  3943                 inStream >> buffer;
       
  3944             }
       
  3945             inFile.close();
       
  3946         }
       
  3947     }
       
  3948 }
       
  3949 
       
  3950 void Configure::saveCmdLine()
       
  3951 {
       
  3952     if( dictionary[ "REDO" ] != "yes" ) {
       
  3953         QFile outFile( buildPath + "/configure" + dictionary[ "CUSTOMCONFIG" ] + ".cache" );
       
  3954         if( outFile.open( QFile::WriteOnly | QFile::Text ) ) {
       
  3955             QTextStream outStream( &outFile );
       
  3956             for( QStringList::Iterator it = configCmdLine.begin(); it != configCmdLine.end(); ++it ) {
       
  3957                 outStream << (*it) << " " << endl;
       
  3958             }
       
  3959             outStream.flush();
       
  3960             outFile.close();
       
  3961         }
       
  3962     }
       
  3963 }
       
  3964 #endif // !EVAL
       
  3965 
       
  3966 bool Configure::isDone()
       
  3967 {
       
  3968     return !dictionary["DONE"].isEmpty();
       
  3969 }
       
  3970 
       
  3971 bool Configure::isOk()
       
  3972 {
       
  3973     return (dictionary[ "DONE" ] != "error");
       
  3974 }
       
  3975 
       
  3976 bool
       
  3977 Configure::filesDiffer(const QString &fn1, const QString &fn2)
       
  3978 {
       
  3979     QFile file1(fn1), file2(fn2);
       
  3980     if(!file1.open(QFile::ReadOnly) || !file2.open(QFile::ReadOnly))
       
  3981         return true;
       
  3982     const int chunk = 2048;
       
  3983     int used1 = 0, used2 = 0;
       
  3984     char b1[chunk], b2[chunk];
       
  3985     while(!file1.atEnd() && !file2.atEnd()) {
       
  3986         if(!used1)
       
  3987             used1 = file1.read(b1, chunk);
       
  3988         if(!used2)
       
  3989             used2 = file2.read(b2, chunk);
       
  3990         if(used1 > 0 && used2 > 0) {
       
  3991             const int cmp = qMin(used1, used2);
       
  3992             if(memcmp(b1, b2, cmp))
       
  3993                 return true;
       
  3994             if((used1 -= cmp))
       
  3995                 memcpy(b1, b1+cmp, used1);
       
  3996             if((used2 -= cmp))
       
  3997                 memcpy(b2, b2+cmp, used2);
       
  3998         }
       
  3999     }
       
  4000     return !file1.atEnd() || !file2.atEnd();
       
  4001 }
       
  4002 
       
  4003 QT_END_NAMESPACE