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