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