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