1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the tools applications of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #include "configureapp.h"
43 #include "environment.h"
44 #ifdef COMMERCIAL_VERSION
50 #include <qtemporaryfile.h>
53 #include <qfileinfo.h>
54 #include <qtextstream.h>
64 std::ostream &operator<<(std::ostream &s, const QString &val) {
65 s << val.toLocal8Bit().data();
72 // Macros to simplify options marking
73 #define MARK_OPTION(x,y) ( dictionary[ #x ] == #y ? "*" : " " )
76 bool writeToFile(const char* text, const QString &filename)
78 QByteArray symFile(text);
80 QDir dir(QFileInfo(file).absoluteDir());
82 dir.mkpath(dir.absolutePath());
83 if (!file.open(QFile::WriteOnly)) {
84 cout << "Couldn't write to " << qPrintable(filename) << ": " << qPrintable(file.errorString())
92 Configure::Configure(int& argc, char** argv)
94 useUnixSeparators = false;
95 // Default values for indentation
99 // Get console buffer output width
100 CONSOLE_SCREEN_BUFFER_INFO info;
101 HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
102 if (GetConsoleScreenBufferInfo(hStdout, &info))
103 outputWidth = info.dwSize.X - 1;
104 outputWidth = qMin(outputWidth, 79); // Anything wider gets unreadable
105 if (outputWidth < 35) // Insanely small, just use 79
110 ** Set up the initial state, the default
112 dictionary[ "CONFIGCMD" ] = argv[ 0 ];
114 for (i = 1; i < argc; i++)
115 configCmdLine += argv[ i ];
117 if (configCmdLine.size() >= 2 && configCmdLine.at(0) == "-srcdir") {
118 sourcePath = QDir::cleanPath(configCmdLine.at(1));
119 sourceDir = QDir(sourcePath);
120 configCmdLine.erase(configCmdLine.begin(), configCmdLine.begin() + 2);
122 // Get the path to the executable
123 wchar_t module_name[MAX_PATH];
124 GetModuleFileName(0, module_name, sizeof(module_name) / sizeof(wchar_t));
125 QFileInfo sourcePathInfo = QString::fromWCharArray(module_name);
126 sourcePath = sourcePathInfo.absolutePath();
127 sourceDir = sourcePathInfo.dir();
129 buildPath = QDir::currentPath();
131 const QString installPath = QString("C:\\Qt\\%1").arg(QT_VERSION_STR);
133 const QString installPath = buildPath;
135 if (sourceDir != buildDir) { //shadow builds!
136 if (!findFile("perl") && !findFile("perl.exe")) {
137 cout << "Error: Creating a shadow build of Qt requires" << endl
138 << "perl to be in the PATH environment";
139 exit(0); // Exit cleanly for Ctrl+C
142 cout << "Preparing build tree..." << endl;
143 QDir(buildPath).mkpath("bin");
145 { //make a syncqt script(s) that can be used in the shadow
146 QFile syncqt(buildPath + "/bin/syncqt");
147 if (syncqt.open(QFile::WriteOnly)) {
148 QTextStream stream(&syncqt);
149 stream << "#!/usr/bin/perl -w" << endl
150 << "require \"" << sourcePath + "/bin/syncqt\";" << endl;
152 QFile syncqt_bat(buildPath + "/bin/syncqt.bat");
153 if (syncqt_bat.open(QFile::WriteOnly)) {
154 QTextStream stream(&syncqt_bat);
155 stream << "@echo off" << endl
156 << "call " << fixSeparators(sourcePath) << fixSeparators("/bin/syncqt.bat -qtdir \"") << fixSeparators(buildPath) << "\" %*" << endl;
161 QFile configtests(buildPath + "/bin/qtmodule-configtests");
162 if (configtests.open(QFile::WriteOnly)) {
163 QTextStream stream(&configtests);
164 stream << "#!/usr/bin/perl -w" << endl
165 << "require \"" << sourcePath + "/bin/qtmodule-configtests\";" << endl;
167 // For Windows CE and shadow builds we need to copy these to the
169 QFile::copy(sourcePath + "/bin/setcepaths.bat" , buildPath + "/bin/setcepaths.bat");
171 buildDir.mkpath("mkspecs");
172 if (!Environment::cpdir(sourcePath + "/mkspecs", buildPath + "/mkspecs")){
173 cout << "Couldn't copy mkspecs!" << sourcePath << " " << buildPath << endl;
174 dictionary["DONE"] = "error";
179 dictionary[ "QT_SOURCE_TREE" ] = fixSeparators(sourcePath);
180 dictionary[ "QT_BUILD_TREE" ] = fixSeparators(buildPath);
181 dictionary[ "QT_INSTALL_PREFIX" ] = fixSeparators(installPath);
183 dictionary[ "QMAKESPEC" ] = getenv("QMAKESPEC");
184 if (dictionary[ "QMAKESPEC" ].size() == 0) {
185 dictionary[ "QMAKESPEC" ] = Environment::detectQMakeSpec();
186 dictionary[ "QMAKESPEC_FROM" ] = "detected";
188 dictionary[ "QMAKESPEC_FROM" ] = "env";
191 dictionary[ "QCONFIG" ] = "full";
192 dictionary[ "EMBEDDED" ] = "no";
193 dictionary[ "BUILD_QMAKE" ] = "yes";
194 dictionary[ "DSPFILES" ] = "yes";
195 dictionary[ "VCPROJFILES" ] = "yes";
196 dictionary[ "QMAKE_INTERNAL" ] = "no";
197 dictionary[ "FAST" ] = "no";
198 dictionary[ "NOPROCESS" ] = "no";
199 dictionary[ "STL" ] = "yes";
200 dictionary[ "EXCEPTIONS" ] = "yes";
201 dictionary[ "WIDGETS" ] = "yes";
202 dictionary[ "RTTI" ] = "yes";
203 dictionary[ "SSE2" ] = "auto";
204 dictionary[ "IWMMXT" ] = "auto";
205 dictionary[ "SYNCQT" ] = "auto";
206 dictionary[ "CE_CRT" ] = "no";
207 dictionary[ "CETEST" ] = "auto";
208 dictionary[ "CE_SIGNATURE" ] = "no";
209 dictionary[ "PHONON_BACKEND" ] = "yes";
210 dictionary[ "AUDIO_BACKEND" ] = "auto";
211 dictionary[ "WMSDK" ] = "auto";
212 dictionary[ "DIRECTSHOW" ] = "no";
213 dictionary[ "V8SNAPSHOT" ] = "auto";
214 dictionary[ "DECLARATIVE_DEBUG" ]= "yes";
215 dictionary[ "PLUGIN_MANIFESTS" ] = "yes";
216 dictionary[ "DIRECTWRITE" ] = "no";
219 QFile qglobal_h(sourcePath + "/src/corelib/global/qglobal.h");
220 if (qglobal_h.open(QFile::ReadOnly)) {
221 QTextStream read(&qglobal_h);
222 QRegExp version_regexp("^# *define *QT_VERSION_STR *\"([^\"]*)\"");
224 while (!read.atEnd()) {
225 line = read.readLine();
226 if (version_regexp.exactMatch(line)) {
227 version = version_regexp.cap(1).trimmed();
228 if (!version.isEmpty())
235 if (version.isEmpty())
236 version = QString("%1.%2.%3").arg(QT_VERSION>>16).arg(((QT_VERSION>>8)&0xff)).arg(QT_VERSION&0xff);
238 dictionary[ "VERSION" ] = version;
240 QRegExp version_re("([0-9]*)\\.([0-9]*)\\.([0-9]*)(|-.*)");
241 if (version_re.exactMatch(version)) {
242 dictionary[ "VERSION_MAJOR" ] = version_re.cap(1);
243 dictionary[ "VERSION_MINOR" ] = version_re.cap(2);
244 dictionary[ "VERSION_PATCH" ] = version_re.cap(3);
248 dictionary[ "REDO" ] = "no";
249 dictionary[ "DEPENDENCIES" ] = "no";
251 dictionary[ "BUILD" ] = "debug";
252 dictionary[ "BUILDALL" ] = "auto"; // Means yes, but not explicitly
254 dictionary[ "BUILDTYPE" ] = "none";
256 dictionary[ "BUILDDEV" ] = "no";
258 dictionary[ "SHARED" ] = "yes";
260 dictionary[ "ZLIB" ] = "auto";
262 dictionary[ "PCRE" ] = "auto";
264 dictionary[ "ICU" ] = "auto";
266 dictionary[ "GIF" ] = "auto";
267 dictionary[ "JPEG" ] = "auto";
268 dictionary[ "PNG" ] = "auto";
269 dictionary[ "LIBJPEG" ] = "auto";
270 dictionary[ "LIBPNG" ] = "auto";
271 dictionary[ "FREETYPE" ] = "yes";
273 dictionary[ "ACCESSIBILITY" ] = "yes";
274 dictionary[ "OPENGL" ] = "yes";
275 dictionary[ "OPENVG" ] = "no";
276 dictionary[ "OPENSSL" ] = "auto";
277 dictionary[ "DBUS" ] = "auto";
279 dictionary[ "STYLE_WINDOWS" ] = "yes";
280 dictionary[ "STYLE_WINDOWSXP" ] = "auto";
281 dictionary[ "STYLE_WINDOWSVISTA" ] = "auto";
282 dictionary[ "STYLE_PLASTIQUE" ] = "yes";
283 dictionary[ "STYLE_CLEANLOOKS" ]= "yes";
284 dictionary[ "STYLE_WINDOWSCE" ] = "no";
285 dictionary[ "STYLE_WINDOWSMOBILE" ] = "no";
286 dictionary[ "STYLE_MOTIF" ] = "yes";
287 dictionary[ "STYLE_CDE" ] = "yes";
288 dictionary[ "STYLE_GTK" ] = "no";
290 dictionary[ "SQL_MYSQL" ] = "no";
291 dictionary[ "SQL_ODBC" ] = "no";
292 dictionary[ "SQL_OCI" ] = "no";
293 dictionary[ "SQL_PSQL" ] = "no";
294 dictionary[ "SQL_TDS" ] = "no";
295 dictionary[ "SQL_DB2" ] = "no";
296 dictionary[ "SQL_SQLITE" ] = "auto";
297 dictionary[ "SQL_SQLITE_LIB" ] = "qt";
298 dictionary[ "SQL_SQLITE2" ] = "no";
299 dictionary[ "SQL_IBASE" ] = "no";
301 QString tmp = dictionary[ "QMAKESPEC" ];
302 if (tmp.contains("\\")) {
303 tmp = tmp.mid(tmp.lastIndexOf("\\") + 1);
305 tmp = tmp.mid(tmp.lastIndexOf("/") + 1);
307 dictionary[ "QMAKESPEC" ] = tmp;
309 dictionary[ "INCREDIBUILD_XGE" ] = "auto";
310 dictionary[ "LTCG" ] = "no";
311 dictionary[ "NATIVE_GESTURES" ] = "yes";
312 dictionary[ "MSVC_MP" ] = "no";
315 Configure::~Configure()
317 for (int i=0; i<3; ++i) {
318 QList<MakeItem*> items = makeList[i];
319 for (int j=0; j<items.size(); ++j)
324 QString Configure::fixSeparators(const QString &somePath, bool escape)
326 if (useUnixSeparators)
327 return QDir::fromNativeSeparators(somePath);
328 QString ret = QDir::toNativeSeparators(somePath);
329 return escape ? escapeSeparators(ret) : ret;
332 QString Configure::escapeSeparators(const QString &somePath)
334 QString out = somePath;
335 out.replace(QLatin1Char('\\'), QLatin1String("\\\\"));
339 // We could use QDir::homePath() + "/.qt-license", but
340 // that will only look in the first of $HOME,$USERPROFILE
341 // or $HOMEDRIVE$HOMEPATH. So, here we try'em all to be
342 // more forgiving for the end user..
343 QString Configure::firstLicensePath()
345 QStringList allPaths;
346 allPaths << "./.qt-license"
347 << QString::fromLocal8Bit(getenv("HOME")) + "/.qt-license"
348 << QString::fromLocal8Bit(getenv("USERPROFILE")) + "/.qt-license"
349 << QString::fromLocal8Bit(getenv("HOMEDRIVE")) + QString::fromLocal8Bit(getenv("HOMEPATH")) + "/.qt-license";
350 for (int i = 0; i< allPaths.count(); ++i)
351 if (QFile::exists(allPaths.at(i)))
352 return allPaths.at(i);
357 // #### somehow I get a compiler error about vc++ reaching the nesting limit without
358 // undefining the ansi for scoping.
363 void Configure::parseCmdLine()
365 int argCount = configCmdLine.size();
367 const QStringList imageFormats = QStringList() << "gif" << "png" << "jpeg";
370 if (argCount < 1) // skip rest if no arguments
372 else if (configCmdLine.at(i) == "-redo") {
373 dictionary[ "REDO" ] = "yes";
374 configCmdLine.clear();
377 else if (configCmdLine.at(i) == "-loadconfig") {
380 dictionary[ "REDO" ] = "yes";
381 dictionary[ "CUSTOMCONFIG" ] = "_" + configCmdLine.at(i);
382 configCmdLine.clear();
385 dictionary[ "HELP" ] = "yes";
389 argCount = configCmdLine.size();
392 // Look first for XQMAKESPEC
393 for (int j = 0 ; j < argCount; ++j)
395 if (configCmdLine.at(j) == "-xplatform") {
399 dictionary["XQMAKESPEC"] = configCmdLine.at(j);
400 if (!dictionary[ "XQMAKESPEC" ].isEmpty())
401 applySpecSpecifics();
405 for (; i<configCmdLine.size(); ++i) {
406 bool continueElse[] = {false, false};
407 if (configCmdLine.at(i) == "-help"
408 || configCmdLine.at(i) == "-h"
409 || configCmdLine.at(i) == "-?")
410 dictionary[ "HELP" ] = "yes";
413 else if (configCmdLine.at(i) == "-qconfig") {
417 dictionary[ "QCONFIG" ] = configCmdLine.at(i);
420 else if (configCmdLine.at(i) == "-release") {
421 dictionary[ "BUILD" ] = "release";
422 if (dictionary[ "BUILDALL" ] == "auto")
423 dictionary[ "BUILDALL" ] = "no";
424 } else if (configCmdLine.at(i) == "-debug") {
425 dictionary[ "BUILD" ] = "debug";
426 if (dictionary[ "BUILDALL" ] == "auto")
427 dictionary[ "BUILDALL" ] = "no";
428 } else if (configCmdLine.at(i) == "-debug-and-release")
429 dictionary[ "BUILDALL" ] = "yes";
431 else if (configCmdLine.at(i) == "-shared")
432 dictionary[ "SHARED" ] = "yes";
433 else if (configCmdLine.at(i) == "-static")
434 dictionary[ "SHARED" ] = "no";
435 else if (configCmdLine.at(i) == "-developer-build")
436 dictionary[ "BUILDDEV" ] = "yes";
437 else if (configCmdLine.at(i) == "-opensource") {
438 dictionary[ "BUILDTYPE" ] = "opensource";
440 else if (configCmdLine.at(i) == "-commercial") {
441 dictionary[ "BUILDTYPE" ] = "commercial";
443 else if (configCmdLine.at(i) == "-ltcg") {
444 dictionary[ "LTCG" ] = "yes";
446 else if (configCmdLine.at(i) == "-no-ltcg") {
447 dictionary[ "LTCG" ] = "no";
449 else if (configCmdLine.at(i) == "-mp") {
450 dictionary[ "MSVC_MP" ] = "yes";
452 else if (configCmdLine.at(i) == "-no-mp") {
453 dictionary[ "MSVC_MP" ] = "no";
455 else if (configCmdLine.at(i) == "-force-asserts") {
456 dictionary[ "FORCE_ASSERTS" ] = "yes";
462 else if (configCmdLine.at(i) == "-platform") {
466 dictionary[ "QMAKESPEC" ] = configCmdLine.at(i);
467 dictionary[ "QMAKESPEC_FROM" ] = "commandline";
468 } else if (configCmdLine.at(i) == "-arch") {
472 dictionary["OBSOLETE_ARCH_ARG"] = "yes";
473 } else if (configCmdLine.at(i) == "-embedded") {
474 dictionary[ "EMBEDDED" ] = "yes";
475 } else if (configCmdLine.at(i) == "-xplatform") {
482 else if (configCmdLine.at(i) == "-no-zlib") {
483 // No longer supported since Qt 4.4.0
484 // But save the information for later so that we can print a warning
486 // If you REALLY really need no zlib support, you can still disable
487 // it by doing the following:
488 // add "no-zlib" to mkspecs/qconfig.pri
489 // #define QT_NO_COMPRESS (probably by adding to src/corelib/global/qconfig.h)
491 // There's no guarantee that Qt will build under those conditions
493 dictionary[ "ZLIB_FORCED" ] = "yes";
494 } else if (configCmdLine.at(i) == "-qt-zlib") {
495 dictionary[ "ZLIB" ] = "qt";
496 } else if (configCmdLine.at(i) == "-system-zlib") {
497 dictionary[ "ZLIB" ] = "system";
500 else if (configCmdLine.at(i) == "-qt-pcre") {
501 dictionary[ "PCRE" ] = "qt";
502 } else if (configCmdLine.at(i) == "-system-pcre") {
503 dictionary[ "PCRE" ] = "system";
506 else if (configCmdLine.at(i) == "-icu") {
507 dictionary[ "ICU" ] = "yes";
508 } else if (configCmdLine.at(i) == "-no-icu") {
509 dictionary[ "ICU" ] = "no";
512 // Image formats --------------------------------------------
513 else if (configCmdLine.at(i) == "-no-gif")
514 dictionary[ "GIF" ] = "no";
516 else if (configCmdLine.at(i) == "-no-libjpeg") {
517 dictionary[ "JPEG" ] = "no";
518 dictionary[ "LIBJPEG" ] = "no";
519 } else if (configCmdLine.at(i) == "-qt-libjpeg") {
520 dictionary[ "LIBJPEG" ] = "qt";
521 } else if (configCmdLine.at(i) == "-system-libjpeg") {
522 dictionary[ "LIBJPEG" ] = "system";
525 else if (configCmdLine.at(i) == "-no-libpng") {
526 dictionary[ "PNG" ] = "no";
527 dictionary[ "LIBPNG" ] = "no";
528 } else if (configCmdLine.at(i) == "-qt-libpng") {
529 dictionary[ "LIBPNG" ] = "qt";
530 } else if (configCmdLine.at(i) == "-system-libpng") {
531 dictionary[ "LIBPNG" ] = "system";
534 // Text Rendering --------------------------------------------
535 else if (configCmdLine.at(i) == "-no-freetype")
536 dictionary[ "FREETYPE" ] = "no";
537 else if (configCmdLine.at(i) == "-qt-freetype")
538 dictionary[ "FREETYPE" ] = "yes";
540 // CE- C runtime --------------------------------------------
541 else if (configCmdLine.at(i) == "-crt") {
545 QDir cDir(configCmdLine.at(i));
547 cout << "WARNING: Could not find directory (" << qPrintable(configCmdLine.at(i)) << ")for C runtime deployment" << endl;
549 dictionary[ "CE_CRT" ] = QDir::toNativeSeparators(cDir.absolutePath());
550 } else if (configCmdLine.at(i) == "-qt-crt") {
551 dictionary[ "CE_CRT" ] = "yes";
552 } else if (configCmdLine.at(i) == "-no-crt") {
553 dictionary[ "CE_CRT" ] = "no";
555 // cetest ---------------------------------------------------
556 else if (configCmdLine.at(i) == "-no-cetest") {
557 dictionary[ "CETEST" ] = "no";
558 dictionary[ "CETEST_REQUESTED" ] = "no";
559 } else if (configCmdLine.at(i) == "-cetest") {
560 // although specified to use it, we stay at "auto" state
561 // this is because checkAvailability() adds variables
562 // we need for crosscompilation; but remember if we asked
564 dictionary[ "CETEST_REQUESTED" ] = "yes";
566 // Qt/CE - signing tool -------------------------------------
567 else if (configCmdLine.at(i) == "-signature") {
571 QFileInfo info(configCmdLine.at(i));
573 cout << "WARNING: Could not find signature file (" << qPrintable(configCmdLine.at(i)) << ")" << endl;
575 dictionary[ "CE_SIGNATURE" ] = QDir::toNativeSeparators(info.absoluteFilePath());
577 // Styles ---------------------------------------------------
578 else if (configCmdLine.at(i) == "-qt-style-windows")
579 dictionary[ "STYLE_WINDOWS" ] = "yes";
580 else if (configCmdLine.at(i) == "-no-style-windows")
581 dictionary[ "STYLE_WINDOWS" ] = "no";
583 else if (configCmdLine.at(i) == "-qt-style-windowsce")
584 dictionary[ "STYLE_WINDOWSCE" ] = "yes";
585 else if (configCmdLine.at(i) == "-no-style-windowsce")
586 dictionary[ "STYLE_WINDOWSCE" ] = "no";
587 else if (configCmdLine.at(i) == "-qt-style-windowsmobile")
588 dictionary[ "STYLE_WINDOWSMOBILE" ] = "yes";
589 else if (configCmdLine.at(i) == "-no-style-windowsmobile")
590 dictionary[ "STYLE_WINDOWSMOBILE" ] = "no";
592 else if (configCmdLine.at(i) == "-qt-style-windowsxp")
593 dictionary[ "STYLE_WINDOWSXP" ] = "yes";
594 else if (configCmdLine.at(i) == "-no-style-windowsxp")
595 dictionary[ "STYLE_WINDOWSXP" ] = "no";
597 else if (configCmdLine.at(i) == "-qt-style-windowsvista")
598 dictionary[ "STYLE_WINDOWSVISTA" ] = "yes";
599 else if (configCmdLine.at(i) == "-no-style-windowsvista")
600 dictionary[ "STYLE_WINDOWSVISTA" ] = "no";
602 else if (configCmdLine.at(i) == "-qt-style-plastique")
603 dictionary[ "STYLE_PLASTIQUE" ] = "yes";
604 else if (configCmdLine.at(i) == "-no-style-plastique")
605 dictionary[ "STYLE_PLASTIQUE" ] = "no";
607 else if (configCmdLine.at(i) == "-qt-style-cleanlooks")
608 dictionary[ "STYLE_CLEANLOOKS" ] = "yes";
609 else if (configCmdLine.at(i) == "-no-style-cleanlooks")
610 dictionary[ "STYLE_CLEANLOOKS" ] = "no";
612 else if (configCmdLine.at(i) == "-qt-style-motif")
613 dictionary[ "STYLE_MOTIF" ] = "yes";
614 else if (configCmdLine.at(i) == "-no-style-motif")
615 dictionary[ "STYLE_MOTIF" ] = "no";
617 else if (configCmdLine.at(i) == "-qt-style-cde")
618 dictionary[ "STYLE_CDE" ] = "yes";
619 else if (configCmdLine.at(i) == "-no-style-cde")
620 dictionary[ "STYLE_CDE" ] = "no";
622 // Work around compiler nesting limitation
624 continueElse[1] = true;
625 if (!continueElse[1]) {
628 // OpenGL Support -------------------------------------------
629 else if (configCmdLine.at(i) == "-no-opengl") {
630 dictionary[ "OPENGL" ] = "no";
631 } else if (configCmdLine.at(i) == "-opengl-es-cm") {
632 dictionary[ "OPENGL" ] = "yes";
633 dictionary[ "OPENGL_ES_CM" ] = "yes";
634 } else if (configCmdLine.at(i) == "-opengl-es-2") {
635 dictionary[ "OPENGL" ] = "yes";
636 dictionary[ "OPENGL_ES_2" ] = "yes";
637 } else if (configCmdLine.at(i) == "-opengl") {
638 dictionary[ "OPENGL" ] = "yes";
643 if (configCmdLine.at(i) == "es1") {
644 dictionary[ "OPENGL_ES_CM" ] = "yes";
645 } else if ( configCmdLine.at(i) == "es2" ) {
646 dictionary[ "OPENGL_ES_2" ] = "yes";
647 } else if ( configCmdLine.at(i) == "desktop" ) {
648 // OPENGL=yes suffices
650 cout << "Argument passed to -opengl option is not valid." << endl;
651 dictionary[ "DONE" ] = "error";
656 // OpenVG Support -------------------------------------------
657 else if (configCmdLine.at(i) == "-openvg") {
658 dictionary[ "OPENVG" ] = "yes";
659 } else if (configCmdLine.at(i) == "-no-openvg") {
660 dictionary[ "OPENVG" ] = "no";
663 // Databases ------------------------------------------------
664 else if (configCmdLine.at(i) == "-qt-sql-mysql")
665 dictionary[ "SQL_MYSQL" ] = "yes";
666 else if (configCmdLine.at(i) == "-plugin-sql-mysql")
667 dictionary[ "SQL_MYSQL" ] = "plugin";
668 else if (configCmdLine.at(i) == "-no-sql-mysql")
669 dictionary[ "SQL_MYSQL" ] = "no";
671 else if (configCmdLine.at(i) == "-qt-sql-odbc")
672 dictionary[ "SQL_ODBC" ] = "yes";
673 else if (configCmdLine.at(i) == "-plugin-sql-odbc")
674 dictionary[ "SQL_ODBC" ] = "plugin";
675 else if (configCmdLine.at(i) == "-no-sql-odbc")
676 dictionary[ "SQL_ODBC" ] = "no";
678 else if (configCmdLine.at(i) == "-qt-sql-oci")
679 dictionary[ "SQL_OCI" ] = "yes";
680 else if (configCmdLine.at(i) == "-plugin-sql-oci")
681 dictionary[ "SQL_OCI" ] = "plugin";
682 else if (configCmdLine.at(i) == "-no-sql-oci")
683 dictionary[ "SQL_OCI" ] = "no";
685 else if (configCmdLine.at(i) == "-qt-sql-psql")
686 dictionary[ "SQL_PSQL" ] = "yes";
687 else if (configCmdLine.at(i) == "-plugin-sql-psql")
688 dictionary[ "SQL_PSQL" ] = "plugin";
689 else if (configCmdLine.at(i) == "-no-sql-psql")
690 dictionary[ "SQL_PSQL" ] = "no";
692 else if (configCmdLine.at(i) == "-qt-sql-tds")
693 dictionary[ "SQL_TDS" ] = "yes";
694 else if (configCmdLine.at(i) == "-plugin-sql-tds")
695 dictionary[ "SQL_TDS" ] = "plugin";
696 else if (configCmdLine.at(i) == "-no-sql-tds")
697 dictionary[ "SQL_TDS" ] = "no";
699 else if (configCmdLine.at(i) == "-qt-sql-db2")
700 dictionary[ "SQL_DB2" ] = "yes";
701 else if (configCmdLine.at(i) == "-plugin-sql-db2")
702 dictionary[ "SQL_DB2" ] = "plugin";
703 else if (configCmdLine.at(i) == "-no-sql-db2")
704 dictionary[ "SQL_DB2" ] = "no";
706 else if (configCmdLine.at(i) == "-qt-sql-sqlite")
707 dictionary[ "SQL_SQLITE" ] = "yes";
708 else if (configCmdLine.at(i) == "-plugin-sql-sqlite")
709 dictionary[ "SQL_SQLITE" ] = "plugin";
710 else if (configCmdLine.at(i) == "-no-sql-sqlite")
711 dictionary[ "SQL_SQLITE" ] = "no";
712 else if (configCmdLine.at(i) == "-system-sqlite")
713 dictionary[ "SQL_SQLITE_LIB" ] = "system";
714 else if (configCmdLine.at(i) == "-qt-sql-sqlite2")
715 dictionary[ "SQL_SQLITE2" ] = "yes";
716 else if (configCmdLine.at(i) == "-plugin-sql-sqlite2")
717 dictionary[ "SQL_SQLITE2" ] = "plugin";
718 else if (configCmdLine.at(i) == "-no-sql-sqlite2")
719 dictionary[ "SQL_SQLITE2" ] = "no";
721 else if (configCmdLine.at(i) == "-qt-sql-ibase")
722 dictionary[ "SQL_IBASE" ] = "yes";
723 else if (configCmdLine.at(i) == "-plugin-sql-ibase")
724 dictionary[ "SQL_IBASE" ] = "plugin";
725 else if (configCmdLine.at(i) == "-no-sql-ibase")
726 dictionary[ "SQL_IBASE" ] = "no";
728 // Image formats --------------------------------------------
729 else if (configCmdLine.at(i).startsWith("-qt-imageformat-") &&
730 imageFormats.contains(configCmdLine.at(i).section('-', 3)))
731 dictionary[ configCmdLine.at(i).section('-', 3).toUpper() ] = "yes";
732 else if (configCmdLine.at(i).startsWith("-plugin-imageformat-") &&
733 imageFormats.contains(configCmdLine.at(i).section('-', 3)))
734 dictionary[ configCmdLine.at(i).section('-', 3).toUpper() ] = "plugin";
735 else if (configCmdLine.at(i).startsWith("-no-imageformat-") &&
736 imageFormats.contains(configCmdLine.at(i).section('-', 3)))
737 dictionary[ configCmdLine.at(i).section('-', 3).toUpper() ] = "no";
739 // IDE project generation -----------------------------------
740 else if (configCmdLine.at(i) == "-no-dsp")
741 dictionary[ "DSPFILES" ] = "no";
742 else if (configCmdLine.at(i) == "-dsp")
743 dictionary[ "DSPFILES" ] = "yes";
745 else if (configCmdLine.at(i) == "-no-vcp")
746 dictionary[ "VCPFILES" ] = "no";
747 else if (configCmdLine.at(i) == "-vcp")
748 dictionary[ "VCPFILES" ] = "yes";
750 else if (configCmdLine.at(i) == "-no-vcproj")
751 dictionary[ "VCPROJFILES" ] = "no";
752 else if (configCmdLine.at(i) == "-vcproj")
753 dictionary[ "VCPROJFILES" ] = "yes";
755 else if (configCmdLine.at(i) == "-no-incredibuild-xge")
756 dictionary[ "INCREDIBUILD_XGE" ] = "no";
757 else if (configCmdLine.at(i) == "-incredibuild-xge")
758 dictionary[ "INCREDIBUILD_XGE" ] = "yes";
759 else if (configCmdLine.at(i) == "-native-gestures")
760 dictionary[ "NATIVE_GESTURES" ] = "yes";
761 else if (configCmdLine.at(i) == "-no-native-gestures")
762 dictionary[ "NATIVE_GESTURES" ] = "no";
764 // Others ---------------------------------------------------
765 else if (configCmdLine.at(i) == "-fast")
766 dictionary[ "FAST" ] = "yes";
767 else if (configCmdLine.at(i) == "-no-fast")
768 dictionary[ "FAST" ] = "no";
770 else if (configCmdLine.at(i) == "-stl")
771 dictionary[ "STL" ] = "yes";
772 else if (configCmdLine.at(i) == "-no-stl")
773 dictionary[ "STL" ] = "no";
775 else if (configCmdLine.at(i) == "-exceptions")
776 dictionary[ "EXCEPTIONS" ] = "yes";
777 else if (configCmdLine.at(i) == "-no-exceptions")
778 dictionary[ "EXCEPTIONS" ] = "no";
780 else if (configCmdLine.at(i) == "-widgets")
781 dictionary[ "WIDGETS" ] = "yes";
782 else if (configCmdLine.at(i) == "-no-widgets")
783 dictionary[ "WIDGETS" ] = "no";
785 else if (configCmdLine.at(i) == "-rtti")
786 dictionary[ "RTTI" ] = "yes";
787 else if (configCmdLine.at(i) == "-no-rtti")
788 dictionary[ "RTTI" ] = "no";
790 else if (configCmdLine.at(i) == "-accessibility")
791 dictionary[ "ACCESSIBILITY" ] = "yes";
792 else if (configCmdLine.at(i) == "-no-accessibility") {
793 dictionary[ "ACCESSIBILITY" ] = "no";
794 cout << "Setting accessibility to NO" << endl;
797 else if (configCmdLine.at(i) == "-no-sse2")
798 dictionary[ "SSE2" ] = "no";
799 else if (configCmdLine.at(i) == "-sse2")
800 dictionary[ "SSE2" ] = "yes";
801 else if (configCmdLine.at(i) == "-no-iwmmxt")
802 dictionary[ "IWMMXT" ] = "no";
803 else if (configCmdLine.at(i) == "-iwmmxt")
804 dictionary[ "IWMMXT" ] = "yes";
806 else if (configCmdLine.at(i) == "-no-openssl") {
807 dictionary[ "OPENSSL"] = "no";
808 } else if (configCmdLine.at(i) == "-openssl") {
809 dictionary[ "OPENSSL" ] = "yes";
810 } else if (configCmdLine.at(i) == "-openssl-linked") {
811 dictionary[ "OPENSSL" ] = "linked";
812 } else if (configCmdLine.at(i) == "-no-qdbus") {
813 dictionary[ "DBUS" ] = "no";
814 } else if (configCmdLine.at(i) == "-qdbus") {
815 dictionary[ "DBUS" ] = "yes";
816 } else if (configCmdLine.at(i) == "-no-dbus") {
817 dictionary[ "DBUS" ] = "no";
818 } else if (configCmdLine.at(i) == "-dbus") {
819 dictionary[ "DBUS" ] = "yes";
820 } else if (configCmdLine.at(i) == "-dbus-linked") {
821 dictionary[ "DBUS" ] = "linked";
822 } else if (configCmdLine.at(i) == "-audio-backend") {
823 dictionary[ "AUDIO_BACKEND" ] = "yes";
824 } else if (configCmdLine.at(i) == "-no-audio-backend") {
825 dictionary[ "AUDIO_BACKEND" ] = "no";
826 } else if (configCmdLine.at(i) == "-no-phonon-backend") {
827 dictionary[ "PHONON_BACKEND" ] = "no";
828 } else if (configCmdLine.at(i) == "-phonon-backend") {
829 dictionary[ "PHONON_BACKEND" ] = "yes";
830 } else if (configCmdLine.at(i) == "-phonon-wince-ds9") {
831 dictionary[ "DIRECTSHOW" ] = "yes";
832 } else if (configCmdLine.at(i) == "-no-declarative-debug") {
833 dictionary[ "DECLARATIVE_DEBUG" ] = "no";
834 } else if (configCmdLine.at(i) == "-declarative-debug") {
835 dictionary[ "DECLARATIVE_DEBUG" ] = "yes";
836 } else if (configCmdLine.at(i) == "-no-plugin-manifests") {
837 dictionary[ "PLUGIN_MANIFESTS" ] = "no";
838 } else if (configCmdLine.at(i) == "-plugin-manifests") {
839 dictionary[ "PLUGIN_MANIFESTS" ] = "yes";
842 // Work around compiler nesting limitation
844 continueElse[0] = true;
845 if (!continueElse[0]) {
848 else if (configCmdLine.at(i) == "-internal")
849 dictionary[ "QMAKE_INTERNAL" ] = "yes";
851 else if (configCmdLine.at(i) == "-no-syncqt")
852 dictionary[ "SYNCQT" ] = "no";
854 else if (configCmdLine.at(i) == "-no-qmake")
855 dictionary[ "BUILD_QMAKE" ] = "no";
856 else if (configCmdLine.at(i) == "-qmake")
857 dictionary[ "BUILD_QMAKE" ] = "yes";
859 else if (configCmdLine.at(i) == "-dont-process")
860 dictionary[ "NOPROCESS" ] = "yes";
861 else if (configCmdLine.at(i) == "-process")
862 dictionary[ "NOPROCESS" ] = "no";
864 else if (configCmdLine.at(i) == "-no-qmake-deps")
865 dictionary[ "DEPENDENCIES" ] = "no";
866 else if (configCmdLine.at(i) == "-qmake-deps")
867 dictionary[ "DEPENDENCIES" ] = "yes";
870 else if (configCmdLine.at(i) == "-qtnamespace") {
874 dictionary[ "QT_NAMESPACE" ] = configCmdLine.at(i);
875 } else if (configCmdLine.at(i) == "-qtlibinfix") {
879 dictionary[ "QT_LIBINFIX" ] = configCmdLine.at(i);
880 } else if (configCmdLine.at(i) == "-D") {
884 qmakeDefines += configCmdLine.at(i);
885 } else if (configCmdLine.at(i) == "-I") {
889 qmakeIncludes += configCmdLine.at(i);
890 } else if (configCmdLine.at(i) == "-L") {
894 QFileInfo checkDirectory(configCmdLine.at(i));
895 if (!checkDirectory.isDir()) {
896 cout << "Argument passed to -L option is not a directory path. Did you mean the -l option?" << endl;
897 dictionary[ "DONE" ] = "error";
900 qmakeLibs += QString("-L" + configCmdLine.at(i));
901 } else if (configCmdLine.at(i) == "-l") {
905 qmakeLibs += QString("-l" + configCmdLine.at(i));
906 } else if (configCmdLine.at(i).startsWith("OPENSSL_LIBS=")) {
907 opensslLibs = configCmdLine.at(i);
908 } else if (configCmdLine.at(i).startsWith("PSQL_LIBS=")) {
909 psqlLibs = configCmdLine.at(i);
910 } else if (configCmdLine.at(i).startsWith("SYBASE=")) {
911 sybase = configCmdLine.at(i);
912 } else if (configCmdLine.at(i).startsWith("SYBASE_LIBS=")) {
913 sybaseLibs = configCmdLine.at(i);
914 } else if (configCmdLine.at(i) == "-qpa") {
915 dictionary["QPA"] = "yes";
918 else if ((configCmdLine.at(i) == "-override-version") || (configCmdLine.at(i) == "-version-override")){
922 dictionary[ "VERSION" ] = configCmdLine.at(i);
925 else if (configCmdLine.at(i) == "-saveconfig") {
929 dictionary[ "CUSTOMCONFIG" ] = "_" + configCmdLine.at(i);
932 else if (configCmdLine.at(i) == "-confirm-license") {
933 dictionary["LICENSE_CONFIRMED"] = "yes";
936 else if (configCmdLine.at(i) == "-nomake") {
940 disabledBuildParts += configCmdLine.at(i);
943 // Directories ----------------------------------------------
944 else if (configCmdLine.at(i) == "-prefix") {
948 dictionary[ "QT_INSTALL_PREFIX" ] = configCmdLine.at(i);
951 else if (configCmdLine.at(i) == "-bindir") {
955 dictionary[ "QT_INSTALL_BINS" ] = configCmdLine.at(i);
958 else if (configCmdLine.at(i) == "-libdir") {
962 dictionary[ "QT_INSTALL_LIBS" ] = configCmdLine.at(i);
965 else if (configCmdLine.at(i) == "-docdir") {
969 dictionary[ "QT_INSTALL_DOCS" ] = configCmdLine.at(i);
972 else if (configCmdLine.at(i) == "-headerdir") {
976 dictionary[ "QT_INSTALL_HEADERS" ] = configCmdLine.at(i);
979 else if (configCmdLine.at(i) == "-plugindir") {
983 dictionary[ "QT_INSTALL_PLUGINS" ] = configCmdLine.at(i);
986 else if (configCmdLine.at(i) == "-importdir") {
990 dictionary[ "QT_INSTALL_IMPORTS" ] = configCmdLine.at(i);
992 else if (configCmdLine.at(i) == "-datadir") {
996 dictionary[ "QT_INSTALL_DATA" ] = configCmdLine.at(i);
999 else if (configCmdLine.at(i) == "-translationdir") {
1003 dictionary[ "QT_INSTALL_TRANSLATIONS" ] = configCmdLine.at(i);
1006 else if (configCmdLine.at(i) == "-examplesdir") {
1010 dictionary[ "QT_INSTALL_EXAMPLES" ] = configCmdLine.at(i);
1013 else if (configCmdLine.at(i) == "-testsdir") {
1017 dictionary[ "QT_INSTALL_TESTS" ] = configCmdLine.at(i);
1020 else if (configCmdLine.at(i) == "-sysroot") {
1024 dictionary[ "CFG_SYSROOT" ] = configCmdLine.at(i);
1027 else if (configCmdLine.at(i) == "-hostprefix") {
1029 if (i == argCount || configCmdLine.at(i).startsWith('-'))
1030 dictionary[ "QT_HOST_PREFIX" ] = dictionary[ "QT_BUILD_TREE" ];
1032 dictionary[ "QT_HOST_PREFIX" ] = configCmdLine.at(i);
1035 else if (configCmdLine.at(i) == "-hostbindir") {
1039 dictionary[ "QT_HOST_BINS" ] = configCmdLine.at(i);
1042 else if (configCmdLine.at(i) == "-hostdatadir") {
1046 dictionary[ "QT_HOST_DATA" ] = configCmdLine.at(i);
1049 else if (configCmdLine.at(i) == "-make") {
1053 dictionary[ "MAKE" ] = configCmdLine.at(i);
1056 else if (configCmdLine.at(i).indexOf(QRegExp("^-(en|dis)able-")) != -1) {
1057 // Scan to see if any specific modules and drivers are enabled or disabled
1058 for (QStringList::Iterator module = modules.begin(); module != modules.end(); ++module) {
1059 if (configCmdLine.at(i) == QString("-enable-") + (*module)) {
1060 enabledModules += (*module);
1063 else if (configCmdLine.at(i) == QString("-disable-") + (*module)) {
1064 disabledModules += (*module);
1070 else if (configCmdLine.at(i) == "-directwrite") {
1071 dictionary["DIRECTWRITE"] = "yes";
1072 } else if (configCmdLine.at(i) == "-no-directwrite") {
1073 dictionary["DIRECTWRITE"] = "no";
1077 dictionary[ "HELP" ] = "yes";
1078 cout << "Unknown option " << configCmdLine.at(i) << endl;
1085 // Ensure that QMAKESPEC exists in the mkspecs folder
1086 QDir mkspec_dir = fixSeparators(sourcePath + "/mkspecs");
1087 QStringList mkspecs = mkspec_dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
1089 if (dictionary["QMAKESPEC"].toLower() == "features"
1090 || !mkspecs.contains(dictionary["QMAKESPEC"], Qt::CaseInsensitive)) {
1091 dictionary[ "HELP" ] = "yes";
1092 if (dictionary ["QMAKESPEC_FROM"] == "commandline") {
1093 cout << "Invalid option \"" << dictionary["QMAKESPEC"] << "\" for -platform." << endl;
1094 } else if (dictionary ["QMAKESPEC_FROM"] == "env") {
1095 cout << "QMAKESPEC environment variable is set to \"" << dictionary["QMAKESPEC"]
1096 << "\" which is not a supported platform" << endl;
1097 } else { // was autodetected from environment
1098 cout << "Unable to detect the platform from environment. Use -platform command line"
1099 "argument or set the QMAKESPEC environment variable and run configure again" << endl;
1101 cout << "See the README file for a list of supported operating systems and compilers." << endl;
1103 if (dictionary[ "QMAKESPEC" ].endsWith("-icc") ||
1104 dictionary[ "QMAKESPEC" ].endsWith("-msvc") ||
1105 dictionary[ "QMAKESPEC" ].endsWith("-msvc.net") ||
1106 dictionary[ "QMAKESPEC" ].endsWith("-msvc2002") ||
1107 dictionary[ "QMAKESPEC" ].endsWith("-msvc2003") ||
1108 dictionary[ "QMAKESPEC" ].endsWith("-msvc2005") ||
1109 dictionary[ "QMAKESPEC" ].endsWith("-msvc2008") ||
1110 dictionary[ "QMAKESPEC" ].endsWith("-msvc2010")) {
1111 if (dictionary[ "MAKE" ].isEmpty()) dictionary[ "MAKE" ] = "nmake";
1112 dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32";
1113 } else if (dictionary[ "QMAKESPEC" ] == QString("win32-g++")) {
1114 if (dictionary[ "MAKE" ].isEmpty()) dictionary[ "MAKE" ] = "mingw32-make";
1115 dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32-g++";
1117 if (dictionary[ "MAKE" ].isEmpty()) dictionary[ "MAKE" ] = "make";
1118 dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32";
1122 // Tell the user how to proceed building Qt after configure finished its job
1123 dictionary["QTBUILDINSTRUCTION"] = dictionary["MAKE"];
1124 if (dictionary.contains("XQMAKESPEC")) {
1125 if (dictionary["XQMAKESPEC"].startsWith("wince")) {
1126 dictionary["QTBUILDINSTRUCTION"] =
1127 QString("setcepaths.bat ") + dictionary["XQMAKESPEC"] + QString(" && ") + dictionary["MAKE"];
1131 // Tell the user how to confclean before the next configure
1132 dictionary["CONFCLEANINSTRUCTION"] = dictionary["MAKE"] + QString(" confclean");
1134 // Ensure that -spec (XQMAKESPEC) exists in the mkspecs folder as well
1135 if (dictionary.contains("XQMAKESPEC") &&
1136 !mkspecs.contains(dictionary["XQMAKESPEC"], Qt::CaseInsensitive)) {
1137 dictionary["HELP"] = "yes";
1138 cout << "Invalid option \"" << dictionary["XQMAKESPEC"] << "\" for -xplatform." << endl;
1141 // Ensure that the crt to be deployed can be found
1142 if (dictionary["CE_CRT"] != QLatin1String("yes") && dictionary["CE_CRT"] != QLatin1String("no")) {
1143 QDir cDir(dictionary["CE_CRT"]);
1144 QStringList entries = cDir.entryList();
1145 bool hasDebug = entries.contains("msvcr80.dll");
1146 bool hasRelease = entries.contains("msvcr80d.dll");
1147 if ((dictionary["BUILDALL"] == "auto") && (!hasDebug || !hasRelease)) {
1148 cout << "Could not find debug and release c-runtime." << endl;
1149 cout << "You need to have msvcr80.dll and msvcr80d.dll in" << endl;
1150 cout << "the path specified. Setting to -no-crt";
1151 dictionary[ "CE_CRT" ] = "no";
1152 } else if ((dictionary["BUILD"] == "debug") && !hasDebug) {
1153 cout << "Could not find debug c-runtime (msvcr80d.dll) in the directory specified." << endl;
1154 cout << "Setting c-runtime automatic deployment to -no-crt" << endl;
1155 dictionary[ "CE_CRT" ] = "no";
1156 } else if ((dictionary["BUILD"] == "release") && !hasRelease) {
1157 cout << "Could not find release c-runtime (msvcr80.dll) in the directory specified." << endl;
1158 cout << "Setting c-runtime automatic deployment to -no-crt" << endl;
1159 dictionary[ "CE_CRT" ] = "no";
1163 useUnixSeparators = (dictionary["QMAKESPEC"] == "win32-g++");
1165 // Allow tests for private classes to be compiled against internal builds
1166 if (dictionary["BUILDDEV"] == "yes")
1167 qtConfig += "private_tests";
1169 if (dictionary["FORCE_ASSERTS"] == "yes")
1170 qtConfig += "force_asserts";
1173 for (QStringList::Iterator dis = disabledModules.begin(); dis != disabledModules.end(); ++dis) {
1174 modules.removeAll((*dis));
1176 for (QStringList::Iterator ena = enabledModules.begin(); ena != enabledModules.end(); ++ena) {
1177 if (modules.indexOf((*ena)) == -1)
1180 qtConfig += modules;
1182 for (QStringList::Iterator it = disabledModules.begin(); it != disabledModules.end(); ++it)
1183 qtConfig.removeAll(*it);
1185 if ((dictionary[ "REDO" ] != "yes") && (dictionary[ "HELP" ] != "yes"))
1191 void Configure::validateArgs()
1193 // Validate the specified config
1195 // Get all possible configurations from the file system.
1197 QStringList filters;
1198 filters << "qconfig-*.h";
1199 dir.setNameFilters(filters);
1200 dir.setPath(sourcePath + "/src/corelib/global/");
1202 QStringList stringList = dir.entryList();
1204 QStringList::Iterator it;
1205 for (it = stringList.begin(); it != stringList.end(); ++it)
1206 allConfigs << it->remove("qconfig-").remove(".h");
1207 allConfigs << "full";
1209 // Try internal configurations first.
1210 QStringList possible_configs = QStringList()
1216 int index = possible_configs.indexOf(dictionary["QCONFIG"]);
1218 for (int c = 0; c <= index; c++) {
1219 qmakeConfig += possible_configs[c] + "-config";
1224 // If the internal configurations failed, try others.
1225 QStringList::Iterator config;
1226 for (config = allConfigs.begin(); config != allConfigs.end(); ++config) {
1227 if ((*config) == dictionary[ "QCONFIG" ])
1230 if (config == allConfigs.end()) {
1231 dictionary[ "HELP" ] = "yes";
1232 cout << "No such configuration \"" << qPrintable(dictionary[ "QCONFIG" ]) << "\"" << endl ;
1235 qmakeConfig += (*config) + "-config";
1240 // Output helper functions --------------------------------[ Start ]-
1242 Determines the length of a string token.
1244 static int tokenLength(const char *str)
1249 const char *nextToken = strpbrk(str, " _/\n\r");
1250 if (nextToken == str || !nextToken)
1253 return int(nextToken - str);
1257 Prints out a string which starts at position \a startingAt, and
1258 indents each wrapped line with \a wrapIndent characters.
1259 The wrap point is set to the console width, unless that width
1260 cannot be determined, or is too small.
1262 void Configure::desc(const char *description, int startingAt, int wrapIndent)
1264 int linePos = startingAt;
1266 bool firstLine = true;
1267 const char *nextToken = description;
1268 while (*nextToken) {
1269 int nextTokenLen = tokenLength(nextToken);
1270 if (*nextToken == '\n' // Wrap on newline, duh
1271 || (linePos + nextTokenLen > outputWidth)) // Wrap at outputWidth
1276 if (*nextToken == '\n')
1280 if (!firstLine && linePos < wrapIndent) { // Indent to wrapIndent
1281 printf("%*s", wrapIndent , "");
1282 linePos = wrapIndent;
1283 if (*nextToken == ' ') {
1288 printf("%.*s", nextTokenLen, nextToken);
1289 linePos += nextTokenLen;
1290 nextToken += nextTokenLen;
1295 Prints out an option with its description wrapped at the
1296 description starting point. If \a skipIndent is true, the
1297 indentation to the option is not outputted (used by marked option
1298 version of desc()). Extra spaces between option and its
1299 description is filled with\a fillChar, if there's available
1302 void Configure::desc(const char *option, const char *description, bool skipIndent, char fillChar)
1305 printf("%*s", optionIndent, "");
1307 int remaining = descIndent - optionIndent - strlen(option);
1308 int wrapIndent = descIndent + qMax(0, 1 - remaining);
1309 printf("%s", option);
1311 if (remaining > 2) {
1312 printf(" "); // Space in front
1313 for (int i = remaining; i > 2; --i)
1314 printf("%c", fillChar); // Fill, if available space
1316 printf(" "); // Space between option and description
1318 desc(description, wrapIndent, wrapIndent);
1323 Same as above, except it also marks an option with an '*', if
1324 the option is default action.
1326 void Configure::desc(const char *mark_option, const char *mark, const char *option, const char *description, char fillChar)
1328 const QString markedAs = dictionary.value(mark_option);
1329 if (markedAs == "auto" && markedAs == mark) // both "auto", always => +
1331 else if (markedAs == "auto") // setting marked as "auto" and option is default => +
1332 printf(" %c " , (defaultTo(mark_option) == QLatin1String(mark))? '+' : ' ');
1333 else if (QLatin1String(mark) == "auto" && markedAs != "no") // description marked as "auto" and option is available => +
1334 printf(" %c " , checkAvailability(mark_option) ? '+' : ' ');
1335 else // None are "auto", (markedAs == mark) => *
1336 printf(" %c " , markedAs == QLatin1String(mark) ? '*' : ' ');
1338 desc(option, description, true, fillChar);
1342 Modifies the default configuration based on given -platform option.
1343 Eg. switches to different default styles for Windows CE.
1345 void Configure::applySpecSpecifics()
1347 if (dictionary[ "XQMAKESPEC" ].startsWith("wince")) {
1348 dictionary[ "STYLE_WINDOWSXP" ] = "no";
1349 dictionary[ "STYLE_WINDOWSVISTA" ] = "no";
1350 dictionary[ "STYLE_PLASTIQUE" ] = "no";
1351 dictionary[ "STYLE_CLEANLOOKS" ] = "no";
1352 dictionary[ "STYLE_WINDOWSCE" ] = "yes";
1353 dictionary[ "STYLE_WINDOWSMOBILE" ] = "yes";
1354 dictionary[ "STYLE_MOTIF" ] = "no";
1355 dictionary[ "STYLE_CDE" ] = "no";
1356 dictionary[ "FREETYPE" ] = "no";
1357 dictionary[ "OPENGL" ] = "no";
1358 dictionary[ "OPENSSL" ] = "no";
1359 dictionary[ "STL" ] = "no";
1360 dictionary[ "EXCEPTIONS" ] = "no";
1361 dictionary[ "RTTI" ] = "no";
1362 dictionary[ "SSE2" ] = "no";
1363 dictionary[ "IWMMXT" ] = "no";
1364 dictionary[ "CE_CRT" ] = "yes";
1365 dictionary[ "DIRECTSHOW" ] = "no";
1366 // We only apply MMX/IWMMXT for mkspecs we know they work
1367 if (dictionary[ "XQMAKESPEC" ].startsWith("wincewm")) {
1368 dictionary[ "MMX" ] = "yes";
1369 dictionary[ "IWMMXT" ] = "yes";
1370 dictionary[ "DIRECTSHOW" ] = "yes";
1372 dictionary[ "QT_HOST_PREFIX" ] = dictionary[ "QT_INSTALL_PREFIX" ];
1373 dictionary[ "QT_INSTALL_PREFIX" ] = "";
1375 } else if (dictionary[ "XQMAKESPEC" ].startsWith("linux")) { //TODO actually wrong.
1377 dictionary[ "STYLE_WINDOWSXP" ] = "no";
1378 dictionary[ "STYLE_WINDOWSVISTA" ] = "no";
1379 dictionary[ "KBD_DRIVERS" ] = "tty";
1380 dictionary[ "GFX_DRIVERS" ] = "linuxfb";
1381 dictionary[ "MOUSE_DRIVERS" ] = "pc linuxtp";
1382 dictionary[ "OPENGL" ] = "no";
1383 dictionary[ "EXCEPTIONS" ] = "no";
1384 dictionary[ "DBUS"] = "no";
1385 dictionary[ "QT_QWS_DEPTH" ] = "4 8 16 24 32";
1386 dictionary[ "QT_SXE" ] = "no";
1387 dictionary[ "QT_INOTIFY" ] = "no";
1388 dictionary[ "QT_LPR" ] = "no";
1389 dictionary[ "QT_CUPS" ] = "no";
1390 dictionary[ "QT_GLIB" ] = "no";
1391 dictionary[ "QT_ICONV" ] = "no";
1393 dictionary["DECORATIONS"] = "default windows styled";
1397 QString Configure::locateFileInPaths(const QString &fileName, const QStringList &paths)
1400 for (QStringList::ConstIterator it = paths.begin(); it != paths.end(); ++it) {
1401 // Remove any leading or trailing ", this is commonly used in the environment
1403 QString path = (*it);
1404 if (path.startsWith("\""))
1405 path = path.right(path.length() - 1);
1406 if (path.endsWith("\""))
1407 path = path.left(path.length() - 1);
1408 if (d.exists(path + QDir::separator() + fileName)) {
1415 QString Configure::locateFile(const QString &fileName)
1417 QString file = fileName.toLower();
1419 #if defined(Q_OS_WIN32)
1420 QRegExp splitReg("[;,]");
1422 QRegExp splitReg("[:]");
1424 if (file.endsWith(".h"))
1425 paths = QString::fromLocal8Bit(getenv("INCLUDE")).split(splitReg, QString::SkipEmptyParts);
1426 else if (file.endsWith(".lib"))
1427 paths = QString::fromLocal8Bit(getenv("LIB")).split(splitReg, QString::SkipEmptyParts);
1429 paths = QString::fromLocal8Bit(getenv("PATH")).split(splitReg, QString::SkipEmptyParts);
1430 return locateFileInPaths(file, paths);
1433 // Output helper functions ---------------------------------[ Stop ]-
1436 bool Configure::displayHelp()
1438 if (dictionary[ "HELP" ] == "yes") {
1439 desc("Usage: configure\n"
1440 "[-release] [-debug] [-debug-and-release] [-shared] [-static]\n"
1441 "[-no-fast] [-fast] [-no-exceptions] [-exceptions]\n"
1442 "[-no-accessibility] [-accessibility] [-no-rtti] [-rtti]\n"
1443 "[-no-stl] [-stl] [-no-sql-<driver>] [-qt-sql-<driver>]\n"
1444 "[-plugin-sql-<driver>] [-system-sqlite]\n"
1445 "[-D <define>] [-I <includepath>] [-L <librarypath>]\n"
1446 "[-help] [-no-dsp] [-dsp] [-no-vcproj] [-vcproj]\n"
1447 "[-no-qmake] [-qmake] [-dont-process] [-process]\n"
1448 "[-no-style-<style>] [-qt-style-<style>] [-redo]\n"
1449 "[-saveconfig <config>] [-loadconfig <config>]\n"
1450 "[-qt-zlib] [-system-zlib] [-qt-pcre] [-system-pcre] [-no-gif]\n"
1451 "[-no-libpng] [-qt-libpng] [-system-libpng]\n"
1452 "[-no-libjpeg] [-qt-libjpeg] [-system-libjpeg]\n"
1453 "[-sse2] [-no-sse2]\n"
1454 "[-no-iwmmxt] [-iwmmxt] [-openssl] [-openssl-linked]\n"
1455 "[-no-openssl] [-no-dbus] [-dbus] [-dbus-linked] [-platform <spec>]\n"
1456 "[-qtnamespace <namespace>] [-qtlibinfix <infix>] [-no-phonon]\n"
1457 "[-phonon] [-no-phonon-backend] [-phonon-backend]\n"
1458 "[-no-multimedia] [-multimedia] [-no-audio-backend] [-audio-backend]\n"
1459 "[-no-script] [-script] [-no-scripttools] [-scripttools]\n"
1460 "[-no-webkit] [-webkit] [-webkit-debug]\n"
1461 "[-no-directwrite] [-directwrite] [-qpa] [-no-widgets] [-icu]\n\n", 0, 7);
1463 desc("Installation options:\n\n");
1466 desc("Configure options:\n\n");
1468 desc(" The defaults (*) are usually acceptable. A plus (+) denotes a default value"
1469 " that needs to be evaluated. If the evaluation succeeds, the feature is"
1470 " included. Here is a short explanation of each option:\n\n", 0, 1);
1472 desc("BUILD", "release","-release", "Compile and link Qt with debugging turned off.");
1473 desc("BUILD", "debug", "-debug", "Compile and link Qt with debugging turned on.");
1474 desc("BUILDALL", "yes", "-debug-and-release", "Compile and link two Qt libraries, with and without debugging turned on.\n");
1476 desc("OPENSOURCE", "opensource", "-opensource", "Compile and link the Open-Source Edition of Qt.");
1477 desc("COMMERCIAL", "commercial", "-commercial", "Compile and link the Commercial Edition of Qt.\n");
1479 desc("BUILDDEV", "yes", "-developer-build", "Compile and link Qt with Qt developer options (including auto-tests exporting)\n");
1481 desc("SHARED", "yes", "-shared", "Create and use shared Qt libraries.");
1482 desc("SHARED", "no", "-static", "Create and use static Qt libraries.\n");
1484 desc("LTCG", "yes", "-ltcg", "Use Link Time Code Generation. (Release builds only)");
1485 desc("LTCG", "no", "-no-ltcg", "Do not use Link Time Code Generation.\n");
1487 desc("FAST", "no", "-no-fast", "Configure Qt normally by generating Makefiles for all project files.");
1488 desc("FAST", "yes", "-fast", "Configure Qt quickly by generating Makefiles only for library and "
1489 "subdirectory targets. All other Makefiles are created as wrappers "
1490 "which will in turn run qmake\n");
1492 desc("EXCEPTIONS", "no", "-no-exceptions", "Disable exceptions on platforms that support it.");
1493 desc("EXCEPTIONS", "yes","-exceptions", "Enable exceptions on platforms that support it.\n");
1495 desc("WIDGETS", "no", "-no-widgets", "Disable QtWidgets module\n");
1497 desc("ACCESSIBILITY", "no", "-no-accessibility", "Do not compile Windows Active Accessibility support.");
1498 desc("ACCESSIBILITY", "yes", "-accessibility", "Compile Windows Active Accessibility support.\n");
1500 desc("STL", "no", "-no-stl", "Do not compile STL support.");
1501 desc("STL", "yes", "-stl", "Compile STL support.\n");
1503 desc( "-no-sql-<driver>", "Disable SQL <driver> entirely, by default none are turned on.");
1504 desc( "-qt-sql-<driver>", "Enable a SQL <driver> in the Qt Library.");
1505 desc( "-plugin-sql-<driver>", "Enable SQL <driver> as a plugin to be linked to at run time.\n"
1506 "Available values for <driver>:");
1507 desc("SQL_MYSQL", "auto", "", " mysql", ' ');
1508 desc("SQL_PSQL", "auto", "", " psql", ' ');
1509 desc("SQL_OCI", "auto", "", " oci", ' ');
1510 desc("SQL_ODBC", "auto", "", " odbc", ' ');
1511 desc("SQL_TDS", "auto", "", " tds", ' ');
1512 desc("SQL_DB2", "auto", "", " db2", ' ');
1513 desc("SQL_SQLITE", "auto", "", " sqlite", ' ');
1514 desc("SQL_SQLITE2", "auto", "", " sqlite2", ' ');
1515 desc("SQL_IBASE", "auto", "", " ibase", ' ');
1516 desc( "", "(drivers marked with a '+' have been detected as available on this system)\n", false, ' ');
1518 desc( "-system-sqlite", "Use sqlite from the operating system.\n");
1520 desc("OPENGL", "no","-no-opengl", "Disables OpenGL functionality\n");
1521 desc("OPENGL", "no","-opengl <api>", "Enable OpenGL support with specified API version.\n"
1522 "Available values for <api>:");
1523 desc("", "", "", " desktop - Enable support for Desktop OpenGL", ' ');
1524 desc("OPENGL_ES_CM", "no", "", " es1 - Enable support for OpenGL ES Common Profile", ' ');
1525 desc("OPENGL_ES_2", "no", "", " es2 - Enable support for OpenGL ES 2.0", ' ');
1527 desc("OPENVG", "no","-no-openvg", "Disables OpenVG functionality\n");
1528 desc("OPENVG", "yes","-openvg", "Enables OpenVG functionality");
1529 desc( "-force-asserts", "Activate asserts in release mode.\n");
1531 desc( "-platform <spec>", "The operating system and compiler you are building on.\n(default %QMAKESPEC%)\n");
1532 desc( "-xplatform <spec>", "The operating system and compiler you are cross compiling to.\n");
1533 desc( "", "See the README file for a list of supported operating systems and compilers.\n", false, ' ');
1536 desc( "-qtnamespace <namespace>", "Wraps all Qt library code in 'namespace name {...}");
1537 desc( "-qtlibinfix <infix>", "Renames all Qt* libs to Qt*<infix>\n");
1538 desc( "-D <define>", "Add an explicit define to the preprocessor.");
1539 desc( "-I <includepath>", "Add an explicit include path.");
1540 desc( "-L <librarypath>", "Add an explicit library path.");
1541 desc( "-l <libraryname>", "Add an explicit library name, residing in a librarypath.\n");
1544 desc( "-help, -h, -?", "Display this information.\n");
1547 // 3rd party stuff options go below here --------------------------------------------------------------------------------
1548 desc("Third Party Libraries:\n\n");
1550 desc("ZLIB", "qt", "-qt-zlib", "Use the zlib bundled with Qt.");
1551 desc("ZLIB", "system", "-system-zlib", "Use zlib from the operating system.\nSee http://www.gzip.org/zlib\n");
1553 desc("PCRE", "qt", "-qt-pcre", "Use the PCRE library bundled with Qt.");
1554 desc("PCRE", "qt", "-system-pcre", "Use the PCRE library from the operating system.\nSee http://pcre.org/\n");
1556 desc("ICU", "yes", "-icu", "Use the ICU library.");
1557 desc("ICU", "no", "-no-icu", "Do not use the ICU library.\nSee http://site.icu-project.org/\n");
1559 desc("GIF", "no", "-no-gif", "Do not compile GIF reading support.");
1561 desc("LIBPNG", "no", "-no-libpng", "Do not compile PNG support.");
1562 desc("LIBPNG", "qt", "-qt-libpng", "Use the libpng bundled with Qt.");
1563 desc("LIBPNG", "system","-system-libpng", "Use libpng from the operating system.\nSee http://www.libpng.org/pub/png\n");
1565 desc("LIBJPEG", "no", "-no-libjpeg", "Do not compile JPEG support.");
1566 desc("LIBJPEG", "qt", "-qt-libjpeg", "Use the libjpeg bundled with Qt.");
1567 desc("LIBJPEG", "system","-system-libjpeg", "Use libjpeg from the operating system.\nSee http://www.ijg.org\n");
1569 desc("FREETYPE", "no", "-no-freetype", "Do not compile in Freetype2 support.");
1570 desc("FREETYPE", "yes", "-qt-freetype", "Use the libfreetype bundled with Qt.");
1572 // Qt\Windows only options go below here --------------------------------------------------------------------------------
1573 desc("Qt for Windows only:\n\n");
1575 desc("DSPFILES", "no", "-no-dsp", "Do not generate VC++ .dsp files.");
1576 desc("DSPFILES", "yes", "-dsp", "Generate VC++ .dsp files, only if spec \"win32-msvc\".\n");
1578 desc("VCPROJFILES", "no", "-no-vcproj", "Do not generate VC++ .vcproj files.");
1579 desc("VCPROJFILES", "yes", "-vcproj", "Generate VC++ .vcproj files, only if platform \"win32-msvc.net\".\n");
1581 desc("INCREDIBUILD_XGE", "no", "-no-incredibuild-xge", "Do not add IncrediBuild XGE distribution commands to custom build steps.");
1582 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");
1584 desc("PLUGIN_MANIFESTS", "no", "-no-plugin-manifests", "Do not embed manifests in plugins.");
1585 desc("PLUGIN_MANIFESTS", "yes", "-plugin-manifests", "Embed manifests in plugins.\n");
1588 desc("BUILD_QMAKE", "no", "-no-qmake", "Do not compile qmake.");
1589 desc("BUILD_QMAKE", "yes", "-qmake", "Compile qmake.\n");
1591 desc("NOPROCESS", "yes", "-dont-process", "Do not generate Makefiles/Project files. This will override -no-fast if specified.");
1592 desc("NOPROCESS", "no", "-process", "Generate Makefiles/Project files.\n");
1594 desc("RTTI", "no", "-no-rtti", "Do not compile runtime type information.");
1595 desc("RTTI", "yes", "-rtti", "Compile runtime type information.\n");
1596 desc("SSE2", "no", "-no-sse2", "Do not compile with use of SSE2 instructions");
1597 desc("SSE2", "yes", "-sse2", "Compile with use of SSE2 instructions");
1598 desc("OPENSSL", "no", "-no-openssl", "Do not compile in OpenSSL support");
1599 desc("OPENSSL", "yes", "-openssl", "Compile in run-time OpenSSL support");
1600 desc("OPENSSL", "linked","-openssl-linked", "Compile in linked OpenSSL support");
1601 desc("DBUS", "no", "-no-dbus", "Do not compile in D-Bus support");
1602 desc("DBUS", "yes", "-dbus", "Compile in D-Bus support and load libdbus-1 dynamically");
1603 desc("DBUS", "linked", "-dbus-linked", "Compile in D-Bus support and link to libdbus-1");
1604 desc("PHONON_BACKEND","no", "-no-phonon-backend","Do not compile the platform-specific Phonon backend-plugin");
1605 desc("PHONON_BACKEND","yes","-phonon-backend", "Compile in the platform-specific Phonon backend-plugin");
1606 desc("AUDIO_BACKEND", "no","-no-audio-backend", "Do not compile in the platform audio backend into QtMultimedia");
1607 desc("AUDIO_BACKEND", "yes","-audio-backend", "Compile in the platform audio backend into QtMultimedia");
1608 desc("DECLARATIVE_DEBUG", "no", "-no-declarative-debug", "Do not build the declarative debugging support");
1609 desc("DECLARATIVE_DEBUG", "yes", "-declarative-debug", "Build the declarative debugging support");
1610 desc("DIRECTWRITE", "no", "-no-directwrite", "Do not build support for DirectWrite font rendering");
1611 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.)");
1613 desc( "-no-style-<style>", "Disable <style> entirely.");
1614 desc( "-qt-style-<style>", "Enable <style> in the Qt Library.\nAvailable styles: ");
1616 desc("STYLE_WINDOWS", "yes", "", " windows", ' ');
1617 desc("STYLE_WINDOWSXP", "auto", "", " windowsxp", ' ');
1618 desc("STYLE_WINDOWSVISTA", "auto", "", " windowsvista", ' ');
1619 desc("STYLE_PLASTIQUE", "yes", "", " plastique", ' ');
1620 desc("STYLE_CLEANLOOKS", "yes", "", " cleanlooks", ' ');
1621 desc("STYLE_MOTIF", "yes", "", " motif", ' ');
1622 desc("STYLE_CDE", "yes", "", " cde", ' ');
1623 desc("STYLE_WINDOWSCE", "yes", "", " windowsce", ' ');
1624 desc("STYLE_WINDOWSMOBILE" , "yes", "", " windowsmobile", ' ');
1625 desc("NATIVE_GESTURES", "no", "-no-native-gestures", "Do not use native gestures on Windows 7.");
1626 desc("NATIVE_GESTURES", "yes", "-native-gestures", "Use native gestures on Windows 7.");
1627 desc("MSVC_MP", "no", "-no-mp", "Do not use multiple processors for compiling with MSVC");
1628 desc("MSVC_MP", "yes", "-mp", "Use multiple processors for compiling with MSVC (-MP)");
1630 /* We do not support -qconfig on Windows yet
1632 desc( "-qconfig <local>", "Use src/tools/qconfig-local.h rather than the default.\nPossible values for local:");
1633 for (int i=0; i<allConfigs.size(); ++i)
1634 desc( "", qPrintable(QString(" %1").arg(allConfigs.at(i))), false, ' ');
1638 desc( "-loadconfig <config>", "Run configure with the parameters from file configure_<config>.cache.");
1639 desc( "-saveconfig <config>", "Run configure and save the parameters in file configure_<config>.cache.");
1640 desc( "-redo", "Run configure with the same parameters as last time.\n");
1642 // Qt\Windows CE only options go below here -----------------------------------------------------------------------------
1643 desc("Qt for Windows CE only:\n\n");
1644 desc("IWMMXT", "no", "-no-iwmmxt", "Do not compile with use of IWMMXT instructions");
1645 desc("IWMMXT", "yes", "-iwmmxt", "Do compile with use of IWMMXT instructions (Qt for Windows CE on Arm only)");
1646 desc("CE_CRT", "no", "-no-crt" , "Do not add the C runtime to default deployment rules");
1647 desc("CE_CRT", "yes", "-qt-crt", "Qt identifies C runtime during project generation");
1648 desc( "-crt <path>", "Specify path to C runtime used for project generation.");
1649 desc("CETEST", "no", "-no-cetest", "Do not compile Windows CE remote test application");
1650 desc("CETEST", "yes", "-cetest", "Compile Windows CE remote test application");
1651 desc( "-signature <file>", "Use file for signing the target project");
1653 desc("DIRECTSHOW", "no", "-phonon-wince-ds9", "Enable Phonon Direct Show 9 backend for Windows CE");
1659 QString Configure::findFileInPaths(const QString &fileName, const QString &paths)
1661 #if defined(Q_OS_WIN32)
1662 QRegExp splitReg("[;,]");
1664 QRegExp splitReg("[:]");
1666 QStringList pathList = paths.split(splitReg, QString::SkipEmptyParts);
1668 for (QStringList::ConstIterator it = pathList.begin(); it != pathList.end(); ++it) {
1669 // Remove any leading or trailing ", this is commonly used in the environment
1671 QString path = (*it);
1672 if (path.startsWith('\"'))
1673 path = path.right(path.length() - 1);
1674 if (path.endsWith('\"'))
1675 path = path.left(path.length() - 1);
1676 if (d.exists(path + QDir::separator() + fileName))
1682 static QString mingwPaths(const QString &mingwPath, const QString &pathName)
1685 QDir mingwDir = QFileInfo(mingwPath).dir();
1686 const QFileInfoList subdirs = mingwDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
1687 for (int i = 0 ;i < subdirs.length(); ++i) {
1688 const QFileInfo &fi = subdirs.at(i);
1689 const QString name = fi.fileName();
1690 if (name == pathName)
1691 ret += fi.absoluteFilePath() + ';';
1692 else if (name.contains("mingw"))
1693 ret += fi.absoluteFilePath() + QDir::separator() + pathName + ';';
1698 bool Configure::findFile(const QString &fileName)
1700 const QString file = fileName.toLower();
1701 const QString pathEnvVar = QString::fromLocal8Bit(getenv("PATH"));
1702 const QString mingwPath = dictionary["QMAKESPEC"].endsWith("-g++") ?
1703 findFileInPaths("g++.exe", pathEnvVar) : QString();
1706 if (file.endsWith(".h")) {
1707 if (!mingwPath.isNull()) {
1708 if (!findFileInPaths(file, mingwPaths(mingwPath, "include")).isNull())
1710 //now let's try the additional compiler path
1712 const QFileInfoList mingwConfigs = QDir(mingwPath + QLatin1String("/../lib/gcc")).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
1713 for (int i = 0; i < mingwConfigs.length(); ++i) {
1714 const QDir mingwLibDir = mingwConfigs.at(i).absoluteFilePath();
1715 foreach(const QFileInfo &version, mingwLibDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) {
1716 if (!findFileInPaths(file, version.absoluteFilePath() + QLatin1String("/include")).isNull())
1721 paths = QString::fromLocal8Bit(getenv("INCLUDE"));
1722 } else if (file.endsWith(".lib") || file.endsWith(".a")) {
1723 if (!mingwPath.isNull() && !findFileInPaths(file, mingwPaths(mingwPath, "lib")).isNull())
1725 paths = QString::fromLocal8Bit(getenv("LIB"));
1729 return !findFileInPaths(file, paths).isNull();
1733 Default value for options marked as "auto" if the test passes.
1734 (Used both by the autoDetection() below, and the desc() function
1735 to mark (+) the default option of autodetecting options.
1737 QString Configure::defaultTo(const QString &option)
1739 // We prefer using the system version of the 3rd party libs
1740 if (option == "ZLIB"
1742 || option == "LIBJPEG"
1743 || option == "LIBPNG")
1746 // PNG is always built-in, never a plugin
1747 if (option == "PNG")
1750 // These database drivers and image formats can be built-in or plugins.
1751 // Prefer plugins when Qt is shared.
1752 if (dictionary[ "SHARED" ] == "yes") {
1753 if (option == "SQL_MYSQL"
1754 || option == "SQL_MYSQL"
1755 || option == "SQL_ODBC"
1756 || option == "SQL_OCI"
1757 || option == "SQL_PSQL"
1758 || option == "SQL_TDS"
1759 || option == "SQL_DB2"
1760 || option == "SQL_SQLITE"
1761 || option == "SQL_SQLITE2"
1762 || option == "SQL_IBASE"
1768 // By default we do not want to compile OCI driver when compiling with
1769 // MinGW, due to lack of such support from Oracle. It prob. wont work.
1770 // (Customer may force the use though)
1771 if (dictionary["QMAKESPEC"].endsWith("-g++")
1772 && option == "SQL_OCI")
1775 if (option == "SYNCQT"
1776 && (!QFile::exists(sourcePath + "/bin/syncqt") ||
1777 !QFile::exists(sourcePath + "/bin/syncqt.bat")))
1784 Checks the system for the availability of a feature.
1785 Returns true if the feature is available, else false.
1787 bool Configure::checkAvailability(const QString &part)
1789 bool available = false;
1790 if (part == "STYLE_WINDOWSXP")
1791 available = findFile("uxtheme.h");
1793 else if (part == "ZLIB")
1794 available = findFile("zlib.h");
1796 else if (part == "PCRE")
1797 available = findFile("pcre.h");
1799 else if (part == "ICU")
1800 available = findFile("unicode/utypes.h") && findFile("unicode/ucol.h") && findFile("unicode/ustring.h") && findFile("icuin.lib");
1802 else if (part == "LIBJPEG")
1803 available = findFile("jpeglib.h");
1804 else if (part == "LIBPNG")
1805 available = findFile("png.h");
1806 else if (part == "SQL_MYSQL")
1807 available = findFile("mysql.h") && findFile("libmySQL.lib");
1808 else if (part == "SQL_ODBC")
1809 available = findFile("sql.h") && findFile("sqlext.h") && findFile("odbc32.lib");
1810 else if (part == "SQL_OCI")
1811 available = findFile("oci.h") && findFile("oci.lib");
1812 else if (part == "SQL_PSQL")
1813 available = findFile("libpq-fe.h") && findFile("libpq.lib") && findFile("ws2_32.lib") && findFile("advapi32.lib");
1814 else if (part == "SQL_TDS")
1815 available = findFile("sybfront.h") && findFile("sybdb.h") && findFile("ntwdblib.lib");
1816 else if (part == "SQL_DB2")
1817 available = findFile("sqlcli.h") && findFile("sqlcli1.h") && findFile("db2cli.lib");
1818 else if (part == "SQL_SQLITE")
1819 available = true; // Built in, we have a fork
1820 else if (part == "SQL_SQLITE_LIB") {
1821 if (dictionary[ "SQL_SQLITE_LIB" ] == "system") {
1822 available = findFile("sqlite3.h") && findFile("sqlite3.lib");
1824 dictionary[ "QT_LFLAGS_SQLITE" ] += "sqlite3.lib";
1827 } else if (part == "SQL_SQLITE2")
1828 available = findFile("sqlite.h") && findFile("sqlite.lib");
1829 else if (part == "SQL_IBASE")
1830 available = findFile("ibase.h") && (findFile("gds32_ms.lib") || findFile("gds32.lib"));
1831 else if (part == "IWMMXT")
1832 available = (dictionary.value("XQMAKESPEC").startsWith("wince"));
1833 else if (part == "OPENGL_ES_CM")
1834 available = (dictionary.value("XQMAKESPEC").startsWith("wince"));
1835 else if (part == "OPENGL_ES_2")
1836 available = (dictionary.value("XQMAKESPEC").startsWith("wince"));
1837 else if (part == "DIRECTSHOW")
1838 available = (dictionary.value("XQMAKESPEC").startsWith("wince"));
1839 else if (part == "SSE2")
1840 available = (dictionary.value("QMAKESPEC") != "win32-msvc");
1841 else if (part == "OPENSSL")
1842 available = findFile("openssl\\ssl.h");
1843 else if (part == "DBUS")
1844 available = findFile("dbus\\dbus.h");
1845 else if (part == "CETEST") {
1846 QString rapiHeader = locateFile("rapi.h");
1847 QString rapiLib = locateFile("rapi.lib");
1848 available = (dictionary.value("XQMAKESPEC").startsWith("wince")) && !rapiHeader.isEmpty() && !rapiLib.isEmpty();
1850 dictionary[ "QT_CE_RAPI_INC" ] += QLatin1String("\"") + rapiHeader + QLatin1String("\"");
1851 dictionary[ "QT_CE_RAPI_LIB" ] += QLatin1String("\"") + rapiLib + QLatin1String("\"");
1853 else if (dictionary[ "CETEST_REQUESTED" ] == "yes") {
1854 cout << "cetest could not be enabled: rapi.h and rapi.lib could not be found." << endl;
1855 cout << "Make sure the environment is set up for compiling with ActiveSync." << endl;
1856 dictionary[ "DONE" ] = "error";
1859 else if (part == "INCREDIBUILD_XGE")
1860 available = findFile("BuildConsole.exe") && findFile("xgConsole.exe");
1861 else if (part == "PHONON") {
1862 available = findFile("vmr9.h") && findFile("dshow.h") && findFile("dmo.h") && findFile("dmodshow.h")
1863 && (findFile("strmiids.lib") || findFile("libstrmiids.a"))
1864 && (findFile("dmoguids.lib") || findFile("libdmoguids.a"))
1865 && (findFile("msdmo.lib") || findFile("libmsdmo.a"))
1866 && findFile("d3d9.h");
1869 cout << "All the required DirectShow/Direct3D files couldn't be found." << endl
1870 << "Make sure you have either the platform SDK AND the DirectShow SDK or the Windows SDK installed." << endl
1871 << "If you have the DirectShow SDK installed, please make sure that you have run the <path to SDK>\\SetEnv.Cmd script." << endl;
1872 if (!findFile("vmr9.h")) cout << "vmr9.h not found" << endl;
1873 if (!findFile("dshow.h")) cout << "dshow.h not found" << endl;
1874 if (!findFile("strmiids.lib")) cout << "strmiids.lib not found" << endl;
1875 if (!findFile("dmoguids.lib")) cout << "dmoguids.lib not found" << endl;
1876 if (!findFile("msdmo.lib")) cout << "msdmo.lib not found" << endl;
1877 if (!findFile("d3d9.h")) cout << "d3d9.h not found" << endl;
1879 } else if (part == "WMSDK") {
1880 available = findFile("wmsdk.h");
1881 } else if (part == "V8SNAPSHOT") {
1883 } else if (part == "AUDIO_BACKEND") {
1885 } else if (part == "DIRECTWRITE") {
1886 available = findFile("dwrite.h") && findFile("d2d1.h") && findFile("dwrite.lib");
1893 Autodetect options marked as "auto".
1895 void Configure::autoDetection()
1898 if (dictionary["STYLE_WINDOWSXP"] == "auto")
1899 dictionary["STYLE_WINDOWSXP"] = checkAvailability("STYLE_WINDOWSXP") ? defaultTo("STYLE_WINDOWSXP") : "no";
1900 if (dictionary["STYLE_WINDOWSVISTA"] == "auto") // Vista style has the same requirements as XP style
1901 dictionary["STYLE_WINDOWSVISTA"] = checkAvailability("STYLE_WINDOWSXP") ? defaultTo("STYLE_WINDOWSVISTA") : "no";
1903 // Compression detection
1904 if (dictionary["ZLIB"] == "auto")
1905 dictionary["ZLIB"] = checkAvailability("ZLIB") ? defaultTo("ZLIB") : "qt";
1908 if (dictionary["PCRE"] == "auto")
1909 dictionary["PCRE"] = checkAvailability("PCRE") ? defaultTo("PCRE") : "qt";
1912 if (dictionary["ICU"] == "auto")
1913 dictionary["ICU"] = checkAvailability("ICU") ? "yes" : "no";
1915 // Image format detection
1916 if (dictionary["GIF"] == "auto")
1917 dictionary["GIF"] = defaultTo("GIF");
1918 if (dictionary["JPEG"] == "auto")
1919 dictionary["JPEG"] = defaultTo("JPEG");
1920 if (dictionary["PNG"] == "auto")
1921 dictionary["PNG"] = defaultTo("PNG");
1922 if (dictionary["LIBJPEG"] == "auto")
1923 dictionary["LIBJPEG"] = checkAvailability("LIBJPEG") ? defaultTo("LIBJPEG") : "qt";
1924 if (dictionary["LIBPNG"] == "auto")
1925 dictionary["LIBPNG"] = checkAvailability("LIBPNG") ? defaultTo("LIBPNG") : "qt";
1927 // SQL detection (not on by default)
1928 if (dictionary["SQL_MYSQL"] == "auto")
1929 dictionary["SQL_MYSQL"] = checkAvailability("SQL_MYSQL") ? defaultTo("SQL_MYSQL") : "no";
1930 if (dictionary["SQL_ODBC"] == "auto")
1931 dictionary["SQL_ODBC"] = checkAvailability("SQL_ODBC") ? defaultTo("SQL_ODBC") : "no";
1932 if (dictionary["SQL_OCI"] == "auto")
1933 dictionary["SQL_OCI"] = checkAvailability("SQL_OCI") ? defaultTo("SQL_OCI") : "no";
1934 if (dictionary["SQL_PSQL"] == "auto")
1935 dictionary["SQL_PSQL"] = checkAvailability("SQL_PSQL") ? defaultTo("SQL_PSQL") : "no";
1936 if (dictionary["SQL_TDS"] == "auto")
1937 dictionary["SQL_TDS"] = checkAvailability("SQL_TDS") ? defaultTo("SQL_TDS") : "no";
1938 if (dictionary["SQL_DB2"] == "auto")
1939 dictionary["SQL_DB2"] = checkAvailability("SQL_DB2") ? defaultTo("SQL_DB2") : "no";
1940 if (dictionary["SQL_SQLITE"] == "auto")
1941 dictionary["SQL_SQLITE"] = checkAvailability("SQL_SQLITE") ? defaultTo("SQL_SQLITE") : "no";
1942 if (dictionary["SQL_SQLITE_LIB"] == "system")
1943 if (!checkAvailability("SQL_SQLITE_LIB"))
1944 dictionary["SQL_SQLITE_LIB"] = "no";
1945 if (dictionary["SQL_SQLITE2"] == "auto")
1946 dictionary["SQL_SQLITE2"] = checkAvailability("SQL_SQLITE2") ? defaultTo("SQL_SQLITE2") : "no";
1947 if (dictionary["SQL_IBASE"] == "auto")
1948 dictionary["SQL_IBASE"] = checkAvailability("SQL_IBASE") ? defaultTo("SQL_IBASE") : "no";
1949 if (dictionary["SSE2"] == "auto")
1950 dictionary["SSE2"] = checkAvailability("SSE2") ? "yes" : "no";
1951 if (dictionary["IWMMXT"] == "auto")
1952 dictionary["IWMMXT"] = checkAvailability("IWMMXT") ? "yes" : "no";
1953 if (dictionary["OPENSSL"] == "auto")
1954 dictionary["OPENSSL"] = checkAvailability("OPENSSL") ? "yes" : "no";
1955 if (dictionary["DBUS"] == "auto")
1956 dictionary["DBUS"] = checkAvailability("DBUS") ? "yes" : "no";
1957 if (dictionary["V8SNAPSHOT"] == "auto")
1958 dictionary["V8SNAPSHOT"] = (dictionary["V8"] == "yes") && checkAvailability("V8SNAPSHOT") ? "yes" : "no";
1959 if (dictionary["DECLARATIVE_DEBUG"] == "auto")
1960 dictionary["DECLARATIVE_DEBUG"] = dictionary["DECLARATIVE"] == "yes" ? "yes" : "no";
1961 if (dictionary["AUDIO_BACKEND"] == "auto")
1962 dictionary["AUDIO_BACKEND"] = checkAvailability("AUDIO_BACKEND") ? "yes" : "no";
1963 if (dictionary["WMSDK"] == "auto")
1964 dictionary["WMSDK"] = checkAvailability("WMSDK") ? "yes" : "no";
1966 // Qt/WinCE remote test application
1967 if (dictionary["CETEST"] == "auto")
1968 dictionary["CETEST"] = checkAvailability("CETEST") ? "yes" : "no";
1970 // Detection of IncrediBuild buildconsole
1971 if (dictionary["INCREDIBUILD_XGE"] == "auto")
1972 dictionary["INCREDIBUILD_XGE"] = checkAvailability("INCREDIBUILD_XGE") ? "yes" : "no";
1974 // Mark all unknown "auto" to the default value..
1975 for (QMap<QString,QString>::iterator i = dictionary.begin(); i != dictionary.end(); ++i) {
1976 if (i.value() == "auto")
1977 i.value() = defaultTo(i.key());
1981 bool Configure::verifyConfiguration()
1983 if (dictionary["SQL_SQLITE_LIB"] == "no" && dictionary["SQL_SQLITE"] != "no") {
1984 cout << "WARNING: Configure could not detect the presence of a system SQLite3 lib." << endl
1985 << "Configure will therefore continue with the SQLite3 lib bundled with Qt." << endl
1986 << "(Press any key to continue..)";
1987 if (_getch() == 3) // _Any_ keypress w/no echo(eat <Enter> for stdout)
1988 exit(0); // Exit cleanly for Ctrl+C
1990 dictionary["SQL_SQLITE_LIB"] = "qt"; // Set to Qt's bundled lib an continue
1992 if (dictionary["QMAKESPEC"].endsWith("-g++")
1993 && dictionary["SQL_OCI"] != "no") {
1994 cout << "WARNING: Qt does not support compiling the Oracle database driver with" << endl
1995 << "MinGW, due to lack of such support from Oracle. Consider disabling the" << endl
1996 << "Oracle driver, as the current build will most likely fail." << endl;
1997 cout << "(Press any key to continue..)";
1998 if (_getch() == 3) // _Any_ keypress w/no echo(eat <Enter> for stdout)
1999 exit(0); // Exit cleanly for Ctrl+C
2001 if (dictionary["QMAKESPEC"].endsWith("win32-msvc.net")) {
2002 cout << "WARNING: The makespec win32-msvc.net is deprecated. Consider using" << endl
2003 << "win32-msvc2002 or win32-msvc2003 instead." << endl;
2004 cout << "(Press any key to continue..)";
2005 if (_getch() == 3) // _Any_ keypress w/no echo(eat <Enter> for stdout)
2006 exit(0); // Exit cleanly for Ctrl+C
2008 if (0 != dictionary["ARM_FPU_TYPE"].size()) {
2009 QStringList l= QStringList()
2013 if (!(l.contains(dictionary["ARM_FPU_TYPE"])))
2014 cout << QString("WARNING: Using unsupported fpu flag: %1").arg(dictionary["ARM_FPU_TYPE"]) << endl;
2016 if (dictionary["DIRECTWRITE"] == "yes" && !checkAvailability("DIRECTWRITE")) {
2017 cout << "WARNING: To be able to compile the DirectWrite font engine you will" << endl
2018 << "need the Microsoft DirectWrite and Microsoft Direct2D development" << endl
2019 << "files such as headers and libraries." << endl
2020 << "(Press any key to continue..)";
2021 if (_getch() == 3) // _Any_ keypress w/no echo(eat <Enter> for stdout)
2022 exit(0); // Exit cleanly for Ctrl+C
2029 Things that affect the Qt API/ABI:
2031 minimal-config small-config medium-config large-config full-config
2037 Things that do not affect the Qt API/ABI:
2038 system-jpeg no-jpeg jpeg
2039 system-png no-png png
2040 system-zlib no-zlib zlib
2051 X11 : x11sm xinerama xcursor xfixes xrandr xrender fontconfig xkb
2052 Embedded: embedded freetype
2054 void Configure::generateBuildKey()
2056 QString spec = dictionary["QMAKESPEC"];
2058 QString compiler = "msvc"; // ICC is compatible
2059 if (spec.endsWith("-g++"))
2061 else if (spec.endsWith("-borland"))
2062 compiler = "borland";
2064 // Build options which changes the Qt API/ABI
2065 QStringList build_options;
2066 if (!dictionary["QCONFIG"].isEmpty())
2067 build_options += dictionary["QCONFIG"] + "-config ";
2068 build_options.sort();
2070 // Sorted defines that start with QT_NO_
2071 QStringList build_defines = qmakeDefines.filter(QRegExp("^QT_NO_"));
2072 build_defines.sort();
2075 void Configure::generateOutputVars()
2077 // Generate variables for output
2078 QString build = dictionary[ "BUILD" ];
2079 bool buildAll = (dictionary[ "BUILDALL" ] == "yes");
2080 if (build == "debug") {
2082 qtConfig += "release";
2083 qtConfig += "debug";
2084 } else if (build == "release") {
2086 qtConfig += "debug";
2087 qtConfig += "release";
2090 if (dictionary[ "WIDGETS" ] == "no")
2091 qtConfig += "no-widgets";
2093 // Compression --------------------------------------------------
2094 if (dictionary[ "ZLIB" ] == "qt")
2096 else if (dictionary[ "ZLIB" ] == "system")
2097 qtConfig += "system-zlib";
2099 // PCRE ---------------------------------------------------------
2100 if (dictionary[ "PCRE" ] == "qt")
2101 qmakeConfig += "pcre";
2103 // ICU ---------------------------------------------------------
2104 if (dictionary[ "ICU" ] == "yes")
2107 // Image formates -----------------------------------------------
2108 if (dictionary[ "GIF" ] == "no")
2109 qtConfig += "no-gif";
2110 else if (dictionary[ "GIF" ] == "yes")
2113 if (dictionary[ "JPEG" ] == "no")
2114 qtConfig += "no-jpeg";
2115 else if (dictionary[ "JPEG" ] == "yes")
2117 if (dictionary[ "LIBJPEG" ] == "system")
2118 qtConfig += "system-jpeg";
2120 if (dictionary[ "PNG" ] == "no")
2121 qtConfig += "no-png";
2122 else if (dictionary[ "PNG" ] == "yes")
2124 if (dictionary[ "LIBPNG" ] == "system")
2125 qtConfig += "system-png";
2127 // Text rendering --------------------------------------------------
2128 if (dictionary[ "FREETYPE" ] == "yes")
2129 qtConfig += "freetype";
2131 // Styles -------------------------------------------------------
2132 if (dictionary[ "STYLE_WINDOWS" ] == "yes")
2133 qmakeStyles += "windows";
2135 if (dictionary[ "STYLE_PLASTIQUE" ] == "yes")
2136 qmakeStyles += "plastique";
2138 if (dictionary[ "STYLE_CLEANLOOKS" ] == "yes")
2139 qmakeStyles += "cleanlooks";
2141 if (dictionary[ "STYLE_WINDOWSXP" ] == "yes")
2142 qmakeStyles += "windowsxp";
2144 if (dictionary[ "STYLE_WINDOWSVISTA" ] == "yes")
2145 qmakeStyles += "windowsvista";
2147 if (dictionary[ "STYLE_MOTIF" ] == "yes")
2148 qmakeStyles += "motif";
2150 if (dictionary[ "STYLE_SGI" ] == "yes")
2151 qmakeStyles += "sgi";
2153 if (dictionary[ "STYLE_WINDOWSCE" ] == "yes")
2154 qmakeStyles += "windowsce";
2156 if (dictionary[ "STYLE_WINDOWSMOBILE" ] == "yes")
2157 qmakeStyles += "windowsmobile";
2159 if (dictionary[ "STYLE_CDE" ] == "yes")
2160 qmakeStyles += "cde";
2162 // Databases ----------------------------------------------------
2163 if (dictionary[ "SQL_MYSQL" ] == "yes")
2164 qmakeSql += "mysql";
2165 else if (dictionary[ "SQL_MYSQL" ] == "plugin")
2166 qmakeSqlPlugins += "mysql";
2168 if (dictionary[ "SQL_ODBC" ] == "yes")
2170 else if (dictionary[ "SQL_ODBC" ] == "plugin")
2171 qmakeSqlPlugins += "odbc";
2173 if (dictionary[ "SQL_OCI" ] == "yes")
2175 else if (dictionary[ "SQL_OCI" ] == "plugin")
2176 qmakeSqlPlugins += "oci";
2178 if (dictionary[ "SQL_PSQL" ] == "yes")
2180 else if (dictionary[ "SQL_PSQL" ] == "plugin")
2181 qmakeSqlPlugins += "psql";
2183 if (dictionary[ "SQL_TDS" ] == "yes")
2185 else if (dictionary[ "SQL_TDS" ] == "plugin")
2186 qmakeSqlPlugins += "tds";
2188 if (dictionary[ "SQL_DB2" ] == "yes")
2190 else if (dictionary[ "SQL_DB2" ] == "plugin")
2191 qmakeSqlPlugins += "db2";
2193 if (dictionary[ "SQL_SQLITE" ] == "yes")
2194 qmakeSql += "sqlite";
2195 else if (dictionary[ "SQL_SQLITE" ] == "plugin")
2196 qmakeSqlPlugins += "sqlite";
2198 if (dictionary[ "SQL_SQLITE_LIB" ] == "system")
2199 qmakeConfig += "system-sqlite";
2201 if (dictionary[ "SQL_SQLITE2" ] == "yes")
2202 qmakeSql += "sqlite2";
2203 else if (dictionary[ "SQL_SQLITE2" ] == "plugin")
2204 qmakeSqlPlugins += "sqlite2";
2206 if (dictionary[ "SQL_IBASE" ] == "yes")
2207 qmakeSql += "ibase";
2208 else if (dictionary[ "SQL_IBASE" ] == "plugin")
2209 qmakeSqlPlugins += "ibase";
2211 // Other options ------------------------------------------------
2212 if (dictionary[ "BUILDALL" ] == "yes") {
2213 qtConfig += "build_all";
2215 qmakeConfig += dictionary[ "BUILD" ];
2216 dictionary[ "QMAKE_OUTDIR" ] = dictionary[ "BUILD" ];
2218 if (dictionary["MSVC_MP"] == "yes")
2219 qmakeConfig += "msvc_mp";
2221 if (dictionary[ "SHARED" ] == "yes") {
2222 QString version = dictionary[ "VERSION" ];
2223 if (!version.isEmpty()) {
2224 qmakeVars += "QMAKE_QT_VERSION_OVERRIDE = " + version.left(version.indexOf("."));
2225 version.remove(QLatin1Char('.'));
2227 dictionary[ "QMAKE_OUTDIR" ] += "_shared";
2229 dictionary[ "QMAKE_OUTDIR" ] += "_static";
2232 if (dictionary[ "ACCESSIBILITY" ] == "yes")
2233 qtConfig += "accessibility";
2235 if (!qmakeLibs.isEmpty())
2236 qmakeVars += "LIBS += " + escapeSeparators(qmakeLibs.join(" "));
2238 if (!dictionary["QT_LFLAGS_SQLITE"].isEmpty())
2239 qmakeVars += "QT_LFLAGS_SQLITE += " + escapeSeparators(dictionary["QT_LFLAGS_SQLITE"]);
2241 if (dictionary[ "OPENGL" ] == "yes")
2242 qtConfig += "opengl";
2244 if (dictionary["OPENGL_ES_CM"] == "yes") {
2245 qtConfig += "opengles1";
2249 if (dictionary["OPENGL_ES_2"] == "yes") {
2250 qtConfig += "opengles2";
2254 if (dictionary["OPENVG"] == "yes") {
2255 qtConfig += "openvg";
2260 if (dictionary["DIRECTSHOW"] == "yes")
2261 qtConfig += "directshow";
2263 if (dictionary[ "OPENSSL" ] == "yes")
2264 qtConfig += "openssl";
2265 else if (dictionary[ "OPENSSL" ] == "linked")
2266 qtConfig += "openssl-linked";
2268 if (dictionary[ "DBUS" ] == "yes")
2270 else if (dictionary[ "DBUS" ] == "linked")
2271 qtConfig += "dbus dbus-linked";
2273 if (dictionary[ "CETEST" ] == "yes")
2274 qtConfig += "cetest";
2277 if (dictionary["PHONON_BACKEND"] == "yes")
2278 qtConfig += "phonon-backend";
2281 if (dictionary["AUDIO_BACKEND"] == "yes")
2282 qtConfig += "audio-backend";
2284 if (dictionary["DIRECTWRITE"] == "yes")
2285 qtConfig += "directwrite";
2287 if (dictionary[ "NATIVE_GESTURES" ] == "yes")
2288 qtConfig += "native-gestures";
2290 // We currently have no switch for QtConcurrent, so add it unconditionally.
2291 qtConfig += "concurrent";
2294 if (dictionary[ "V8SNAPSHOT" ] == "yes")
2295 qtConfig += "v8snapshot";
2297 // Add config levels --------------------------------------------
2298 QStringList possible_configs = QStringList()
2305 QString set_config = dictionary["QCONFIG"];
2306 if (possible_configs.contains(set_config)) {
2307 foreach (const QString &cfg, possible_configs) {
2308 qtConfig += (cfg + "-config");
2309 if (cfg == set_config)
2314 if (dictionary.contains("XQMAKESPEC") && (dictionary["QMAKESPEC"] != dictionary["XQMAKESPEC"])) {
2315 qmakeConfig += "cross_compile";
2316 dictionary["CROSS_COMPILE"] = "yes";
2319 // Directories and settings for .qmake.cache --------------------
2321 // if QT_INSTALL_* have not been specified on commandline, define them now from QT_INSTALL_PREFIX
2322 // if prefix is empty (WINCE), make all of them empty, if they aren't set
2323 bool qipempty = false;
2324 if (dictionary[ "QT_INSTALL_PREFIX" ].isEmpty())
2327 if (!dictionary[ "QT_INSTALL_DOCS" ].size())
2328 dictionary[ "QT_INSTALL_DOCS" ] = qipempty ? "" : fixSeparators(dictionary[ "QT_INSTALL_PREFIX" ] + "/doc");
2329 if (!dictionary[ "QT_INSTALL_HEADERS" ].size())
2330 dictionary[ "QT_INSTALL_HEADERS" ] = qipempty ? "" : fixSeparators(dictionary[ "QT_INSTALL_PREFIX" ] + "/include");
2331 if (!dictionary[ "QT_INSTALL_LIBS" ].size())
2332 dictionary[ "QT_INSTALL_LIBS" ] = qipempty ? "" : fixSeparators(dictionary[ "QT_INSTALL_PREFIX" ] + "/lib");
2333 if (!dictionary[ "QT_INSTALL_BINS" ].size())
2334 dictionary[ "QT_INSTALL_BINS" ] = qipempty ? "" : fixSeparators(dictionary[ "QT_INSTALL_PREFIX" ] + "/bin");
2335 if (!dictionary[ "QT_INSTALL_PLUGINS" ].size())
2336 dictionary[ "QT_INSTALL_PLUGINS" ] = qipempty ? "" : fixSeparators(dictionary[ "QT_INSTALL_PREFIX" ] + "/plugins");
2337 if (!dictionary[ "QT_INSTALL_IMPORTS" ].size())
2338 dictionary[ "QT_INSTALL_IMPORTS" ] = qipempty ? "" : fixSeparators(dictionary[ "QT_INSTALL_PREFIX" ] + "/imports");
2339 if (!dictionary[ "QT_INSTALL_DATA" ].size())
2340 dictionary[ "QT_INSTALL_DATA" ] = qipempty ? "" : fixSeparators(dictionary[ "QT_INSTALL_PREFIX" ]);
2341 if (!dictionary[ "QT_INSTALL_TRANSLATIONS" ].size())
2342 dictionary[ "QT_INSTALL_TRANSLATIONS" ] = qipempty ? "" : fixSeparators(dictionary[ "QT_INSTALL_PREFIX" ] + "/translations");
2343 if (!dictionary[ "QT_INSTALL_EXAMPLES" ].size())
2344 dictionary[ "QT_INSTALL_EXAMPLES" ] = qipempty ? "" : fixSeparators(dictionary[ "QT_INSTALL_PREFIX" ] + "/examples");
2345 if (!dictionary[ "QT_INSTALL_TESTS" ].size())
2346 dictionary[ "QT_INSTALL_TESTS" ] = qipempty ? "" : fixSeparators(dictionary[ "QT_INSTALL_PREFIX" ] + "/tests");
2348 bool haveHpx = false;
2349 if (dictionary[ "QT_HOST_PREFIX" ].isEmpty())
2350 dictionary[ "QT_HOST_PREFIX" ] = dictionary[ "QT_INSTALL_PREFIX" ];
2353 if (dictionary[ "QT_HOST_BINS" ].isEmpty())
2354 dictionary[ "QT_HOST_BINS" ] = haveHpx ? fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/bin") : dictionary[ "QT_INSTALL_BINS" ];
2355 if (dictionary[ "QT_HOST_DATA" ].isEmpty())
2356 dictionary[ "QT_HOST_DATA" ] = haveHpx ? dictionary[ "QT_HOST_PREFIX" ] : dictionary[ "QT_INSTALL_DATA" ];
2358 if (dictionary.contains("XQMAKESPEC") && dictionary[ "XQMAKESPEC" ].startsWith("linux"))
2359 dictionary[ "QMAKE_RPATHDIR" ] = dictionary[ "QT_INSTALL_LIBS" ];
2361 qmakeVars += QString("OBJECTS_DIR = ") + fixSeparators("tmp/obj/" + dictionary[ "QMAKE_OUTDIR" ], true);
2362 qmakeVars += QString("MOC_DIR = ") + fixSeparators("tmp/moc/" + dictionary[ "QMAKE_OUTDIR" ], true);
2363 qmakeVars += QString("RCC_DIR = ") + fixSeparators("tmp/rcc/" + dictionary["QMAKE_OUTDIR"], true);
2365 if (!qmakeDefines.isEmpty())
2366 qmakeVars += QString("DEFINES += ") + qmakeDefines.join(" ");
2367 if (!qmakeIncludes.isEmpty())
2368 qmakeVars += QString("INCLUDEPATH += ") + escapeSeparators(qmakeIncludes.join(" "));
2369 if (!opensslLibs.isEmpty())
2370 qmakeVars += opensslLibs;
2371 else if (dictionary[ "OPENSSL" ] == "linked")
2372 qmakeVars += QString("OPENSSL_LIBS = -lssleay32 -llibeay32");
2373 if (!psqlLibs.isEmpty())
2374 qmakeVars += QString("QT_LFLAGS_PSQL=") + psqlLibs.section("=", 1);
2377 QStringList lflagsTDS;
2378 if (!sybase.isEmpty())
2379 lflagsTDS += QString("-L") + fixSeparators(sybase.section("=", 1) + "/lib");
2380 if (!sybaseLibs.isEmpty())
2381 lflagsTDS += sybaseLibs.section("=", 1);
2382 if (!lflagsTDS.isEmpty())
2383 qmakeVars += QString("QT_LFLAGS_TDS=") + lflagsTDS.join(" ");
2386 if (!qmakeSql.isEmpty())
2387 qmakeVars += QString("sql-drivers += ") + qmakeSql.join(" ");
2388 if (!qmakeSqlPlugins.isEmpty())
2389 qmakeVars += QString("sql-plugins += ") + qmakeSqlPlugins.join(" ");
2390 if (!qmakeStyles.isEmpty())
2391 qmakeVars += QString("styles += ") + qmakeStyles.join(" ");
2392 if (!qmakeStylePlugins.isEmpty())
2393 qmakeVars += QString("style-plugins += ") + qmakeStylePlugins.join(" ");
2395 if (dictionary["QMAKESPEC"].endsWith("-g++")) {
2396 QString includepath = qgetenv("INCLUDE");
2397 bool hasSh = Environment::detectExecutable("sh.exe");
2398 QChar separator = (!includepath.contains(":\\") && hasSh ? QChar(':') : QChar(';'));
2399 qmakeVars += QString("TMPPATH = $$quote($$(INCLUDE))");
2400 qmakeVars += QString("QMAKE_INCDIR_POST += $$split(TMPPATH,\"%1\")").arg(separator);
2401 qmakeVars += QString("TMPPATH = $$quote($$(LIB))");
2402 qmakeVars += QString("QMAKE_LIBDIR_POST += $$split(TMPPATH,\"%1\")").arg(separator);
2405 if (!dictionary[ "QMAKESPEC" ].length()) {
2406 cout << "Configure could not detect your compiler. QMAKESPEC must either" << endl
2407 << "be defined as an environment variable, or specified as an" << endl
2408 << "argument with -platform" << endl;
2409 dictionary[ "HELP" ] = "yes";
2411 QStringList winPlatforms;
2412 QDir mkspecsDir(sourcePath + "/mkspecs");
2413 const QFileInfoList &specsList = mkspecsDir.entryInfoList();
2414 for (int i = 0; i < specsList.size(); ++i) {
2415 const QFileInfo &fi = specsList.at(i);
2416 if (fi.fileName().left(5) == "win32") {
2417 winPlatforms += fi.fileName();
2420 cout << "Available platforms are: " << qPrintable(winPlatforms.join(", ")) << endl;
2421 dictionary[ "DONE" ] = "error";
2426 void Configure::generateCachefile()
2428 // Generate .qmake.cache
2429 QFile cacheFile(buildPath + "/.qmake.cache");
2430 if (cacheFile.open(QFile::WriteOnly | QFile::Text)) { // Truncates any existing file.
2431 QTextStream cacheStream(&cacheFile);
2433 cacheStream << "include($$PWD/mkspecs/qmodule.pri)" << endl;
2435 for (QStringList::Iterator var = qmakeVars.begin(); var != qmakeVars.end(); ++var) {
2436 cacheStream << (*var) << endl;
2438 cacheStream << "CONFIG += " << qmakeConfig.join(" ") << "depend_includepath no_private_qt_headers_warning QTDIR_build" << endl;
2440 cacheStream.flush();
2444 // Generate qmodule.pri
2445 QFile moduleFile(dictionary[ "QT_BUILD_TREE" ] + "/mkspecs/qmodule.pri");
2446 if (moduleFile.open(QFile::WriteOnly | QFile::Text)) { // Truncates any existing file.
2447 QTextStream moduleStream(&moduleFile);
2449 moduleStream << "#paths" << endl;
2450 moduleStream << "QT_BUILD_TREE = " << fixSeparators(dictionary[ "QT_BUILD_TREE" ], true) << endl;
2451 moduleStream << "QT_SOURCE_TREE = " << fixSeparators(dictionary[ "QT_SOURCE_TREE" ], true) << endl;
2452 QStringList buildParts;
2453 buildParts << QStringLiteral("libs") << QStringLiteral("examples") << QStringLiteral("tests");
2454 foreach (const QString &item, disabledBuildParts) {
2455 buildParts.removeAll(item);
2457 moduleStream << "QT_BUILD_PARTS = " << buildParts.join(" ") << endl << endl;
2459 //so that we can build without an install first (which would be impossible)
2460 moduleStream << "#local paths that cannot be queried from the QT_INSTALL_* properties while building QTDIR" << endl;
2461 moduleStream << "QMAKE_INCDIR_QT = $$QT_BUILD_TREE" << fixSeparators("/include", true) << endl;
2462 moduleStream << "QMAKE_LIBDIR_QT = $$QT_BUILD_TREE" << fixSeparators("/lib", true) << endl;
2465 QString targetSpec = dictionary.contains("XQMAKESPEC") ? dictionary[ "XQMAKESPEC" ] : dictionary[ "QMAKESPEC" ];
2466 QString mkspec_path = fixSeparators(sourcePath + "/mkspecs/" + targetSpec);
2467 if (QFile::exists(mkspec_path))
2468 moduleStream << "QMAKESPEC = " << escapeSeparators(mkspec_path) << endl;
2470 moduleStream << "QMAKESPEC = " << fixSeparators(targetSpec, true) << endl;
2472 if (dictionary["QT_EDITION"] != "QT_EDITION_OPENSOURCE")
2473 moduleStream << "DEFINES *= QT_EDITION=QT_EDITION_DESKTOP" << endl;
2475 if (dictionary["CETEST"] == "yes") {
2476 moduleStream << "QT_CE_RAPI_INC = " << fixSeparators(dictionary[ "QT_CE_RAPI_INC" ], true) << endl;
2477 moduleStream << "QT_CE_RAPI_LIB = " << fixSeparators(dictionary[ "QT_CE_RAPI_LIB" ], true) << endl;
2480 moduleStream << "#Qt for Windows CE c-runtime deployment" << endl
2481 << "QT_CE_C_RUNTIME = " << fixSeparators(dictionary[ "CE_CRT" ], true) << endl;
2483 if (dictionary["CE_SIGNATURE"] != QLatin1String("no"))
2484 moduleStream << "DEFAULT_SIGNATURE=" << dictionary["CE_SIGNATURE"] << endl;
2486 if (!dictionary["QMAKE_RPATHDIR"].isEmpty())
2487 moduleStream << "QMAKE_RPATHDIR += " << dictionary["QMAKE_RPATHDIR"] << endl;
2489 if (!dictionary["QT_LIBINFIX"].isEmpty())
2490 moduleStream << "QT_LIBINFIX = " << dictionary["QT_LIBINFIX"] << endl;
2492 if (!dictionary["QT_NAMESPACE"].isEmpty()) {
2493 moduleStream << "#namespaces" << endl << "QT_NAMESPACE = " << dictionary["QT_NAMESPACE"] << endl;
2497 if (!dictionary["KBD_DRIVERS"].isEmpty())
2498 moduleStream << "kbd-drivers += "<< dictionary["KBD_DRIVERS"]<<endl;
2499 if (!dictionary["GFX_DRIVERS"].isEmpty())
2500 moduleStream << "gfx-drivers += "<< dictionary["GFX_DRIVERS"]<<endl;
2501 if (!dictionary["MOUSE_DRIVERS"].isEmpty())
2502 moduleStream << "mouse-drivers += "<< dictionary["MOUSE_DRIVERS"]<<endl;
2503 if (!dictionary["DECORATIONS"].isEmpty())
2504 moduleStream << "decorations += "<<dictionary["DECORATIONS"]<<endl;
2506 if (!dictionary["QMAKE_RPATHDIR"].isEmpty())
2507 moduleStream << "QMAKE_RPATHDIR += "<<dictionary["QMAKE_RPATHDIR"]<<endl;
2509 moduleStream << "CONFIG += create_prl link_prl" << endl;
2511 moduleStream.flush();
2517 Runs qmake on config.tests/arch/arch.pro, which will detect the target arch
2518 for the compiler we are using
2520 void Configure::detectArch()
2522 QString oldpwd = QDir::currentPath();
2524 QString newpwd = fixSeparators(QString("%1/config.tests/arch").arg(buildPath));
2525 if (!QDir().exists(newpwd) && !QDir().mkpath(newpwd)) {
2526 cout << "Failed to create directory " << qPrintable(newpwd) << endl;
2527 dictionary["DONE"] = "error";
2530 if (!QDir::setCurrent(newpwd)) {
2531 cout << "Failed to change working directory to " << qPrintable(newpwd) << endl;
2532 dictionary["DONE"] = "error";
2536 QList<QPair<QString, QString> > qmakespecs;
2537 if (dictionary.contains("XQMAKESPEC"))
2538 qmakespecs << qMakePair(QString("XQMAKESPEC"), QString("QT_ARCH"));
2539 qmakespecs << qMakePair(QString("QMAKESPEC"), QString("QT_HOST_ARCH"));
2541 for (int i = 0; i < qmakespecs.count(); ++i) {
2542 const QPair<QString, QString> &pair = qmakespecs.at(i);
2543 QString qmakespec = dictionary.value(pair.first);
2544 QString key = pair.second;
2547 fixSeparators(QString("%1/bin/qmake.exe -spec %2 %3/config.tests/arch/arch.pro -o %4/Makefile.unused 2>&1")
2548 .arg(buildPath, qmakespec, sourcePath, newpwd));
2549 QString output = Environment::execute(command);
2550 if (output.isEmpty())
2553 QRegExp re("Project MESSAGE:.*Architecture: ([a-zA-Z0-9_]*)");
2554 if (re.indexIn(output) != -1)
2555 dictionary[key] = re.cap(1);
2558 if (!dictionary.contains("QT_HOST_ARCH"))
2559 dictionary["QT_HOST_ARCH"] = "unknown";
2560 if (!dictionary.contains("QT_ARCH"))
2561 dictionary["QT_ARCH"] = dictionary["QT_HOST_ARCH"];
2563 QDir::setCurrent(oldpwd);
2566 void Configure::generateQConfigPri()
2568 // Generate qconfig.pri
2569 QFile configFile(dictionary[ "QT_BUILD_TREE" ] + "/mkspecs/qconfig.pri");
2570 if (configFile.open(QFile::WriteOnly | QFile::Text)) { // Truncates any existing file.
2571 QTextStream configStream(&configFile);
2573 configStream << "CONFIG+= ";
2574 configStream << dictionary[ "BUILD" ];
2575 if (dictionary[ "SHARED" ] == "yes")
2576 configStream << " shared";
2578 configStream << " static";
2580 if (dictionary[ "LTCG" ] == "yes")
2581 configStream << " ltcg";
2582 if (dictionary[ "STL" ] == "yes")
2583 configStream << " stl";
2584 if (dictionary[ "EXCEPTIONS" ] == "yes")
2585 configStream << " exceptions";
2586 if (dictionary[ "EXCEPTIONS" ] == "no")
2587 configStream << " exceptions_off";
2588 if (dictionary[ "RTTI" ] == "yes")
2589 configStream << " rtti";
2590 if (dictionary[ "SSE2" ] == "yes")
2591 configStream << " sse2";
2592 if (dictionary[ "IWMMXT" ] == "yes")
2593 configStream << " iwmmxt";
2594 if (dictionary["INCREDIBUILD_XGE"] == "yes")
2595 configStream << " incredibuild_xge";
2596 if (dictionary["PLUGIN_MANIFESTS"] == "no")
2597 configStream << " no_plugin_manifest";
2598 if (dictionary["QPA"] == "yes")
2599 configStream << " qpa";
2600 if (dictionary["CROSS_COMPILE"] == "yes")
2601 configStream << " cross_compile";
2603 if (dictionary["DIRECTWRITE"] == "yes")
2604 configStream << "directwrite";
2606 configStream << endl;
2607 configStream << "QT_ARCH = " << dictionary["QT_ARCH"] << endl;
2608 configStream << "QT_HOST_ARCH = " << dictionary["QT_HOST_ARCH"] << endl;
2609 if (dictionary["QT_EDITION"].contains("OPENSOURCE"))
2610 configStream << "QT_EDITION = " << QLatin1String("OpenSource") << endl;
2612 configStream << "QT_EDITION = " << dictionary["EDITION"] << endl;
2613 configStream << "QT_CONFIG += " << qtConfig.join(" ") << endl;
2615 configStream << "#versioning " << endl
2616 << "QT_VERSION = " << dictionary["VERSION"] << endl
2617 << "QT_MAJOR_VERSION = " << dictionary["VERSION_MAJOR"] << endl
2618 << "QT_MINOR_VERSION = " << dictionary["VERSION_MINOR"] << endl
2619 << "QT_PATCH_VERSION = " << dictionary["VERSION_PATCH"] << endl;
2621 if (!dictionary["CFG_SYSROOT"].isEmpty()) {
2622 QString targetSpec = dictionary.contains("XQMAKESPEC") ? dictionary[ "XQMAKESPEC" ] : dictionary[ "QMAKESPEC" ];
2623 configStream << endl
2624 << "# sysroot" << endl
2625 << targetSpec << " {" << endl
2626 << " QMAKE_CFLAGS += --sysroot=$$[QT_SYSROOT]" << endl
2627 << " QMAKE_CXXFLAGS += --sysroot=$$[QT_SYSROOT]" << endl
2628 << " QMAKE_LFLAGS += --sysroot=$$[QT_SYSROOT]" << endl
2632 configStream.flush();
2638 QString Configure::addDefine(QString def)
2640 QString result, defNeg, defD = def;
2642 defD.replace(QRegExp("=.*"), "");
2643 def.replace(QRegExp("="), " ");
2645 if (def.startsWith("QT_NO_")) {
2647 defNeg.replace("QT_NO_", "QT_");
2648 } else if (def.startsWith("QT_")) {
2650 defNeg.replace("QT_", "QT_NO_");
2653 if (defNeg.isEmpty()) {
2654 result = "#ifndef $DEFD\n"
2658 result = "#if defined($DEFD) && defined($DEFNEG)\n"
2660 "#elif !defined($DEFD)\n"
2664 result.replace("$DEFNEG", defNeg);
2665 result.replace("$DEFD", defD);
2666 result.replace("$DEF", def);
2671 bool Configure::copySpec(const char *name, const char *pfx, const QString &spec)
2673 // Copy configured mkspec to default directory, but remove the old one first, if there is any
2674 QString defSpec = buildPath + "/mkspecs/" + name;
2675 QFileInfo defSpecInfo(defSpec);
2676 if (defSpecInfo.exists()) {
2677 if (!Environment::rmdir(defSpec)) {
2678 cout << "Couldn't update default " << pfx << "mkspec! Are files in " << qPrintable(defSpec) << " read-only?" << endl;
2679 dictionary["DONE"] = "error";
2684 QString pltSpec = sourcePath + "/mkspecs/" + spec;
2685 QString includeSpec = buildPath + "/mkspecs/" + spec;
2686 if (!Environment::cpdir(pltSpec, defSpec, includeSpec)) {
2687 cout << "Couldn't update default " << pfx << "mkspec! Does " << qPrintable(pltSpec) << " exist?" << endl;
2688 dictionary["DONE"] = "error";
2694 void Configure::generateConfigfiles()
2696 QDir(buildPath).mkpath("src/corelib/global");
2697 QString outName(buildPath + "/src/corelib/global/qconfig.h");
2698 QTemporaryFile tmpFile;
2699 QTextStream tmpStream;
2701 if (tmpFile.open()) {
2702 tmpStream.setDevice(&tmpFile);
2704 if (dictionary[ "QCONFIG" ] == "full") {
2705 tmpStream << "/* Everything */" << endl;
2707 QString configName("qconfig-" + dictionary[ "QCONFIG" ] + ".h");
2708 tmpStream << "/* Copied from " << configName << "*/" << endl;
2709 tmpStream << "#ifndef QT_BOOTSTRAPPED" << endl;
2710 QFile inFile(sourcePath + "/src/corelib/global/" + configName);
2711 if (inFile.open(QFile::ReadOnly)) {
2712 QByteArray buffer = inFile.readAll();
2713 tmpFile.write(buffer.constData(), buffer.size());
2716 tmpStream << "#endif // QT_BOOTSTRAPPED" << endl;
2720 if (dictionary[ "SHARED" ] == "yes") {
2721 tmpStream << "#ifndef QT_DLL" << endl;
2722 tmpStream << "#define QT_DLL" << endl;
2723 tmpStream << "#endif" << endl;
2726 tmpStream << "/* License information */" << endl;
2727 tmpStream << "#define QT_PRODUCT_LICENSEE \"" << licenseInfo[ "LICENSEE" ] << "\"" << endl;
2728 tmpStream << "#define QT_PRODUCT_LICENSE \"" << dictionary[ "EDITION" ] << "\"" << endl;
2730 tmpStream << "// Qt Edition" << endl;
2731 tmpStream << "#ifndef QT_EDITION" << endl;
2732 tmpStream << "# define QT_EDITION " << dictionary["QT_EDITION"] << endl;
2733 tmpStream << "#endif" << endl;
2735 if (dictionary["BUILDDEV"] == "yes") {
2736 dictionary["QMAKE_INTERNAL"] = "yes";
2737 tmpStream << "/* Used for example to export symbols for the certain autotests*/" << endl;
2738 tmpStream << "#define QT_BUILD_INTERNAL" << endl;
2742 if (dictionary[ "QPA" ] == "yes")
2743 tmpStream << endl << "#define Q_WS_QPA" << endl;
2745 tmpStream << endl << "// Compile time features" << endl;
2747 QStringList qconfigList;
2748 if (dictionary["STL"] == "no") qconfigList += "QT_NO_STL";
2749 if (dictionary["STYLE_WINDOWS"] != "yes") qconfigList += "QT_NO_STYLE_WINDOWS";
2750 if (dictionary["STYLE_PLASTIQUE"] != "yes") qconfigList += "QT_NO_STYLE_PLASTIQUE";
2751 if (dictionary["STYLE_CLEANLOOKS"] != "yes") qconfigList += "QT_NO_STYLE_CLEANLOOKS";
2752 if (dictionary["STYLE_WINDOWSXP"] != "yes" && dictionary["STYLE_WINDOWSVISTA"] != "yes")
2753 qconfigList += "QT_NO_STYLE_WINDOWSXP";
2754 if (dictionary["STYLE_WINDOWSVISTA"] != "yes") qconfigList += "QT_NO_STYLE_WINDOWSVISTA";
2755 if (dictionary["STYLE_MOTIF"] != "yes") qconfigList += "QT_NO_STYLE_MOTIF";
2756 if (dictionary["STYLE_CDE"] != "yes") qconfigList += "QT_NO_STYLE_CDE";
2758 // ### We still need the QT_NO_STYLE_S60 define for compiling Qt. Remove later!
2759 qconfigList += "QT_NO_STYLE_S60";
2761 if (dictionary["STYLE_WINDOWSCE"] != "yes") qconfigList += "QT_NO_STYLE_WINDOWSCE";
2762 if (dictionary["STYLE_WINDOWSMOBILE"] != "yes") qconfigList += "QT_NO_STYLE_WINDOWSMOBILE";
2763 if (dictionary["STYLE_GTK"] != "yes") qconfigList += "QT_NO_STYLE_GTK";
2765 if (dictionary["GIF"] == "yes") qconfigList += "QT_BUILTIN_GIF_READER=1";
2766 if (dictionary["PNG"] != "yes") qconfigList += "QT_NO_IMAGEFORMAT_PNG";
2767 if (dictionary["JPEG"] != "yes") qconfigList += "QT_NO_IMAGEFORMAT_JPEG";
2768 if (dictionary["ZLIB"] == "no") {
2769 qconfigList += "QT_NO_ZLIB";
2770 qconfigList += "QT_NO_COMPRESS";
2773 if (dictionary["ACCESSIBILITY"] == "no") qconfigList += "QT_NO_ACCESSIBILITY";
2774 if (dictionary["EXCEPTIONS"] == "no") qconfigList += "QT_NO_EXCEPTIONS";
2775 if (dictionary["WIDGETS"] == "no") qconfigList += "QT_NO_WIDGETS";
2776 if (dictionary["OPENGL"] == "no") qconfigList += "QT_NO_OPENGL";
2777 if (dictionary["OPENVG"] == "no") qconfigList += "QT_NO_OPENVG";
2778 if (dictionary["OPENSSL"] == "no") {
2779 qconfigList += "QT_NO_OPENSSL";
2780 qconfigList += "QT_NO_SSL";
2782 if (dictionary["OPENSSL"] == "linked") qconfigList += "QT_LINKED_OPENSSL";
2783 if (dictionary["DBUS"] == "no") qconfigList += "QT_NO_DBUS";
2784 if (dictionary["DECLARATIVE_DEBUG"] == "no") qconfigList += "QDECLARATIVE_NO_DEBUG_PROTOCOL";
2785 if (dictionary["FREETYPE"] == "no") qconfigList += "QT_NO_FREETYPE";
2786 if (dictionary["NATIVE_GESTURES"] == "no") qconfigList += "QT_NO_NATIVE_GESTURES";
2788 if (dictionary["OPENGL_ES_CM"] == "yes" ||
2789 dictionary["OPENGL_ES_2"] == "yes") qconfigList += "QT_OPENGL_ES";
2791 if (dictionary["OPENGL_ES_CM"] == "yes") qconfigList += "QT_OPENGL_ES_1";
2792 if (dictionary["OPENGL_ES_2"] == "yes") qconfigList += "QT_OPENGL_ES_2";
2793 if (dictionary["SQL_MYSQL"] == "yes") qconfigList += "QT_SQL_MYSQL";
2794 if (dictionary["SQL_ODBC"] == "yes") qconfigList += "QT_SQL_ODBC";
2795 if (dictionary["SQL_OCI"] == "yes") qconfigList += "QT_SQL_OCI";
2796 if (dictionary["SQL_PSQL"] == "yes") qconfigList += "QT_SQL_PSQL";
2797 if (dictionary["SQL_TDS"] == "yes") qconfigList += "QT_SQL_TDS";
2798 if (dictionary["SQL_DB2"] == "yes") qconfigList += "QT_SQL_DB2";
2799 if (dictionary["SQL_SQLITE"] == "yes") qconfigList += "QT_SQL_SQLITE";
2800 if (dictionary["SQL_SQLITE2"] == "yes") qconfigList += "QT_SQL_SQLITE2";
2801 if (dictionary["SQL_IBASE"] == "yes") qconfigList += "QT_SQL_IBASE";
2804 for (int i = 0; i < qconfigList.count(); ++i)
2805 tmpStream << addDefine(qconfigList.at(i));
2807 if (dictionary["EMBEDDED"] == "yes")
2809 // Check for keyboard, mouse, gfx.
2810 QStringList kbdDrivers = dictionary["KBD_DRIVERS"].split(" ");;
2811 QStringList allKbdDrivers;
2812 allKbdDrivers<<"tty"<<"usb"<<"sl5000"<<"yopy"<<"vr41xx"<<"qvfb"<<"um";
2813 foreach (const QString &kbd, allKbdDrivers) {
2814 if (!kbdDrivers.contains(kbd))
2815 tmpStream<<"#define QT_NO_QWS_KBD_"<<kbd.toUpper()<<endl;
2818 QStringList mouseDrivers = dictionary["MOUSE_DRIVERS"].split(" ");
2819 QStringList allMouseDrivers;
2820 allMouseDrivers << "pc"<<"bus"<<"linuxtp"<<"yopy"<<"vr41xx"<<"tslib"<<"qvfb";
2821 foreach (const QString &mouse, allMouseDrivers) {
2822 if (!mouseDrivers.contains(mouse))
2823 tmpStream<<"#define QT_NO_QWS_MOUSE_"<<mouse.toUpper()<<endl;
2826 QStringList gfxDrivers = dictionary["GFX_DRIVERS"].split(" ");
2827 QStringList allGfxDrivers;
2828 allGfxDrivers<<"linuxfb"<<"transformed"<<"qvfb"<<"multiscreen"<<"ahi";
2829 foreach (const QString &gfx, allGfxDrivers) {
2830 if (!gfxDrivers.contains(gfx))
2831 tmpStream<<"#define QT_NO_QWS_"<<gfx.toUpper()<<endl;
2834 tmpStream<<"#define Q_WS_QWS"<<endl;
2836 QStringList depths = dictionary[ "QT_QWS_DEPTH" ].split(" ");
2837 foreach (const QString &depth, depths)
2838 tmpStream<<"#define QT_QWS_DEPTH_"+depth<<endl;
2841 if (dictionary[ "QT_CUPS" ] == "no")
2842 tmpStream<<"#define QT_NO_CUPS"<<endl;
2844 if (dictionary[ "QT_ICONV" ] == "no")
2845 tmpStream<<"#define QT_NO_ICONV"<<endl;
2847 if (dictionary[ "QT_GLIB" ] == "no")
2848 tmpStream<<"#define QT_NO_GLIB"<<endl;
2850 if (dictionary[ "QT_LPR" ] == "no")
2851 tmpStream<<"#define QT_NO_LPR"<<endl;
2853 if (dictionary[ "QT_INOTIFY" ] == "no")
2854 tmpStream<<"#define QT_NO_INOTIFY"<<endl;
2856 if (dictionary[ "QT_SXE" ] == "no")
2857 tmpStream<<"#define QT_NO_SXE"<<endl;
2862 // Replace old qconfig.h with new one
2863 ::SetFileAttributes((wchar_t*)outName.utf16(), FILE_ATTRIBUTE_NORMAL);
2864 QFile::remove(outName);
2865 tmpFile.copy(outName);
2869 QString spec = dictionary.contains("XQMAKESPEC") ? dictionary["XQMAKESPEC"] : dictionary["QMAKESPEC"];
2870 if (!copySpec("default", "", spec))
2873 // Generate the new qconfig.cpp file
2874 QDir(buildPath).mkpath("src/corelib/global");
2875 outName = buildPath + "/src/corelib/global/qconfig.cpp";
2877 QTemporaryFile tmpFile2;
2878 if (tmpFile2.open()) {
2879 tmpStream.setDevice(&tmpFile2);
2880 tmpStream << "/* Licensed */" << endl
2881 << "static const char qt_configure_licensee_str [512 + 12] = \"qt_lcnsuser=" << licenseInfo["LICENSEE"] << "\";" << endl
2882 << "static const char qt_configure_licensed_products_str [512 + 12] = \"qt_lcnsprod=" << dictionary["EDITION"] << "\";" << endl
2884 << "/* Build date */" << endl
2885 << "static const char qt_configure_installation [11 + 12] = \"qt_instdate=" << QDate::currentDate().toString(Qt::ISODate) << "\";" << endl
2887 << "static const char qt_configure_prefix_path_strs[][12 + 512] = {" << endl
2888 << " \"qt_prfxpath=" << escapeSeparators(dictionary["QT_INSTALL_PREFIX"]) << "\"," << endl
2889 << " \"qt_docspath=" << escapeSeparators(dictionary["QT_INSTALL_DOCS"]) << "\"," << endl
2890 << " \"qt_hdrspath=" << escapeSeparators(dictionary["QT_INSTALL_HEADERS"]) << "\"," << endl
2891 << " \"qt_libspath=" << escapeSeparators(dictionary["QT_INSTALL_LIBS"]) << "\"," << endl
2892 << " \"qt_binspath=" << escapeSeparators(dictionary["QT_INSTALL_BINS"]) << "\"," << endl
2893 << " \"qt_plugpath=" << escapeSeparators(dictionary["QT_INSTALL_PLUGINS"]) << "\"," << endl
2894 << " \"qt_impspath=" << escapeSeparators(dictionary["QT_INSTALL_IMPORTS"]) << "\"," << endl
2895 << " \"qt_datapath=" << escapeSeparators(dictionary["QT_INSTALL_DATA"]) << "\"," << endl
2896 << " \"qt_trnspath=" << escapeSeparators(dictionary["QT_INSTALL_TRANSLATIONS"]) << "\"," << endl
2897 << " \"qt_xmplpath=" << escapeSeparators(dictionary["QT_INSTALL_EXAMPLES"]) << "\"," << endl
2898 << " \"qt_tstspath=" << escapeSeparators(dictionary["QT_INSTALL_TESTS"]) << "\"," << endl
2899 << "#ifdef QT_BUILD_QMAKE" << endl
2900 << " \"qt_ssrtpath=" << escapeSeparators(dictionary["CFG_SYSROOT"]) << "\"," << endl
2901 << " \"qt_hpfxpath=" << escapeSeparators(dictionary["QT_HOST_PREFIX"]) << "\"," << endl
2902 << " \"qt_hbinpath=" << escapeSeparators(dictionary["QT_HOST_BINS"]) << "\"," << endl
2903 << " \"qt_hdatpath=" << escapeSeparators(dictionary["QT_HOST_DATA"]) << "\"," << endl
2906 //<< "static const char qt_configure_settings_path_str [256] = \"qt_stngpath=" << escapeSeparators(dictionary["QT_INSTALL_SETTINGS"]) << "\";" << endl
2908 << "/* strlen( \"qt_lcnsxxxx\") == 12 */" << endl
2909 << "#define QT_CONFIGURE_LICENSEE qt_configure_licensee_str + 12;" << endl
2910 << "#define QT_CONFIGURE_LICENSED_PRODUCTS qt_configure_licensed_products_str + 12;" << endl
2911 //<< "#define QT_CONFIGURE_SETTINGS_PATH qt_configure_settings_path_str + 12;" << endl
2917 // Replace old qconfig.cpp with new one
2918 ::SetFileAttributes((wchar_t*)outName.utf16(), FILE_ATTRIBUTE_NORMAL);
2919 QFile::remove(outName);
2920 tmpFile2.copy(outName);
2924 QTemporaryFile tmpFile3;
2925 if (tmpFile3.open()) {
2926 tmpStream.setDevice(&tmpFile3);
2927 tmpStream << "/* Evaluation license key */" << endl
2928 << "static const volatile char qt_eval_key_data [512 + 12] = \"qt_qevalkey=" << licenseInfo["LICENSEKEYEXT"] << "\";" << endl;
2933 outName = buildPath + "/src/corelib/global/qconfig_eval.cpp";
2934 ::SetFileAttributes((wchar_t*)outName.utf16(), FILE_ATTRIBUTE_NORMAL);
2935 QFile::remove(outName);
2937 if (dictionary["EDITION"] == "Evaluation" || qmakeDefines.contains("QT_EVAL"))
2938 tmpFile3.copy(outName);
2945 void Configure::displayConfig()
2947 // Give some feedback
2948 cout << "Environment:" << endl;
2949 QString env = QString::fromLocal8Bit(getenv("INCLUDE")).replace(QRegExp("[;,]"), "\r\n ");
2952 cout << " INCLUDE=\r\n " << env << endl;
2953 env = QString::fromLocal8Bit(getenv("LIB")).replace(QRegExp("[;,]"), "\r\n ");
2956 cout << " LIB=\r\n " << env << endl;
2957 env = QString::fromLocal8Bit(getenv("PATH")).replace(QRegExp("[;,]"), "\r\n ");
2960 cout << " PATH=\r\n " << env << endl;
2962 if (dictionary["EDITION"] == "OpenSource") {
2963 cout << "You are licensed to use this software under the terms of the GNU GPL version 3.";
2964 cout << "You are licensed to use this software under the terms of the Lesser GNU LGPL version 2.1." << endl;
2965 cout << "See " << dictionary["LICENSE FILE"] << "3" << endl << endl
2966 << " or " << dictionary["LICENSE FILE"] << "L" << endl << endl;
2968 QString l1 = licenseInfo[ "LICENSEE" ];
2969 QString l2 = licenseInfo[ "LICENSEID" ];
2970 QString l3 = dictionary["EDITION"] + ' ' + "Edition";
2971 QString l4 = licenseInfo[ "EXPIRYDATE" ];
2972 cout << "Licensee...................." << (l1.isNull() ? "" : l1) << endl;
2973 cout << "License ID.................." << (l2.isNull() ? "" : l2) << endl;
2974 cout << "Product license............." << (l3.isNull() ? "" : l3) << endl;
2975 cout << "Expiry Date................." << (l4.isNull() ? "" : l4) << endl << endl;
2978 cout << "Configuration:" << endl;
2979 cout << " " << qmakeConfig.join("\r\n ") << endl;
2980 cout << "Qt Configuration:" << endl;
2981 cout << " " << qtConfig.join("\r\n ") << endl;
2984 if (dictionary.contains("XQMAKESPEC"))
2985 cout << "QMAKESPEC..................." << dictionary[ "XQMAKESPEC" ] << " (" << dictionary["QMAKESPEC_FROM"] << ")" << endl;
2987 cout << "QMAKESPEC..................." << dictionary[ "QMAKESPEC" ] << " (" << dictionary["QMAKESPEC_FROM"] << ")" << endl;
2988 cout << "Architecture................" << dictionary["QT_ARCH"] << endl;
2989 cout << "Host Architecture..........." << dictionary["QT_HOST_ARCH"] << endl;
2990 cout << "Maketool...................." << dictionary[ "MAKE" ] << endl;
2991 cout << "Debug symbols..............." << (dictionary[ "BUILD" ] == "debug" ? "yes" : "no") << endl;
2992 cout << "Link Time Code Generation..." << dictionary[ "LTCG" ] << endl;
2993 cout << "Accessibility support......." << dictionary[ "ACCESSIBILITY" ] << endl;
2994 cout << "STL support................." << dictionary[ "STL" ] << endl;
2995 cout << "Exception support..........." << dictionary[ "EXCEPTIONS" ] << endl;
2996 cout << "RTTI support................" << dictionary[ "RTTI" ] << endl;
2997 cout << "SSE2 support................" << dictionary[ "SSE2" ] << endl;
2998 cout << "IWMMXT support.............." << dictionary[ "IWMMXT" ] << endl;
2999 cout << "OpenGL support.............." << dictionary[ "OPENGL" ] << endl;
3000 cout << "OpenVG support.............." << dictionary[ "OPENVG" ] << endl;
3001 cout << "OpenSSL support............." << dictionary[ "OPENSSL" ] << endl;
3002 cout << "QtDBus support.............." << dictionary[ "DBUS" ] << endl;
3003 cout << "QtWidgets module support...." << dictionary[ "WIDGETS" ] << endl;
3004 cout << "Declarative debugging......." << dictionary[ "DECLARATIVE_DEBUG" ] << endl;
3005 cout << "DirectWrite support........." << dictionary[ "DIRECTWRITE" ] << endl << endl;
3007 cout << "Third Party Libraries:" << endl;
3008 cout << " ZLIB support............" << dictionary[ "ZLIB" ] << endl;
3009 cout << " GIF support............." << dictionary[ "GIF" ] << endl;
3010 cout << " JPEG support............" << dictionary[ "JPEG" ] << endl;
3011 cout << " PNG support............." << dictionary[ "PNG" ] << endl;
3012 cout << " FreeType support........" << dictionary[ "FREETYPE" ] << endl << endl;
3013 cout << " PCRE support............" << dictionary[ "PCRE" ] << endl;
3014 cout << " ICU support............." << dictionary[ "ICU" ] << endl;
3016 cout << "Styles:" << endl;
3017 cout << " Windows................." << dictionary[ "STYLE_WINDOWS" ] << endl;
3018 cout << " Windows XP.............." << dictionary[ "STYLE_WINDOWSXP" ] << endl;
3019 cout << " Windows Vista..........." << dictionary[ "STYLE_WINDOWSVISTA" ] << endl;
3020 cout << " Plastique..............." << dictionary[ "STYLE_PLASTIQUE" ] << endl;
3021 cout << " Cleanlooks.............." << dictionary[ "STYLE_CLEANLOOKS" ] << endl;
3022 cout << " Motif..................." << dictionary[ "STYLE_MOTIF" ] << endl;
3023 cout << " CDE....................." << dictionary[ "STYLE_CDE" ] << endl;
3024 cout << " Windows CE.............." << dictionary[ "STYLE_WINDOWSCE" ] << endl;
3025 cout << " Windows Mobile.........." << dictionary[ "STYLE_WINDOWSMOBILE" ] << endl << endl;
3027 cout << "Sql Drivers:" << endl;
3028 cout << " ODBC...................." << dictionary[ "SQL_ODBC" ] << endl;
3029 cout << " MySQL..................." << dictionary[ "SQL_MYSQL" ] << endl;
3030 cout << " OCI....................." << dictionary[ "SQL_OCI" ] << endl;
3031 cout << " PostgreSQL.............." << dictionary[ "SQL_PSQL" ] << endl;
3032 cout << " TDS....................." << dictionary[ "SQL_TDS" ] << endl;
3033 cout << " DB2....................." << dictionary[ "SQL_DB2" ] << endl;
3034 cout << " SQLite.................." << dictionary[ "SQL_SQLITE" ] << " (" << dictionary[ "SQL_SQLITE_LIB" ] << ")" << endl;
3035 cout << " SQLite2................." << dictionary[ "SQL_SQLITE2" ] << endl;
3036 cout << " InterBase..............." << dictionary[ "SQL_IBASE" ] << endl << endl;
3038 cout << "Sources are in.............." << dictionary[ "QT_SOURCE_TREE" ] << endl;
3039 cout << "Build is done in............" << dictionary[ "QT_BUILD_TREE" ] << endl;
3040 cout << "Install prefix.............." << dictionary[ "QT_INSTALL_PREFIX" ] << endl;
3041 cout << "Headers installed to........" << dictionary[ "QT_INSTALL_HEADERS" ] << endl;
3042 cout << "Libraries installed to......" << dictionary[ "QT_INSTALL_LIBS" ] << endl;
3043 cout << "Plugins installed to........" << dictionary[ "QT_INSTALL_PLUGINS" ] << endl;
3044 cout << "Imports installed to........" << dictionary[ "QT_INSTALL_IMPORTS" ] << endl;
3045 cout << "Binaries installed to......." << dictionary[ "QT_INSTALL_BINS" ] << endl;
3046 cout << "Docs installed to..........." << dictionary[ "QT_INSTALL_DOCS" ] << endl;
3047 cout << "Data installed to..........." << dictionary[ "QT_INSTALL_DATA" ] << endl;
3048 cout << "Translations installed to..." << dictionary[ "QT_INSTALL_TRANSLATIONS" ] << endl;
3049 cout << "Examples installed to......." << dictionary[ "QT_INSTALL_EXAMPLES" ] << endl;
3050 cout << "Tests installed to.........." << dictionary[ "QT_INSTALL_TESTS" ] << endl;
3052 if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith(QLatin1String("wince"))) {
3053 cout << "Using c runtime detection..." << dictionary[ "CE_CRT" ] << endl;
3054 cout << "Cetest support.............." << dictionary[ "CETEST" ] << endl;
3055 cout << "Signature..................." << dictionary[ "CE_SIGNATURE"] << endl << endl;
3058 if (checkAvailability("INCREDIBUILD_XGE"))
3059 cout << "Using IncrediBuild XGE......" << dictionary["INCREDIBUILD_XGE"] << endl;
3060 if (!qmakeDefines.isEmpty()) {
3061 cout << "Defines.....................";
3062 for (QStringList::Iterator defs = qmakeDefines.begin(); defs != qmakeDefines.end(); ++defs)
3063 cout << (*defs) << " ";
3066 if (!qmakeIncludes.isEmpty()) {
3067 cout << "Include paths...............";
3068 for (QStringList::Iterator incs = qmakeIncludes.begin(); incs != qmakeIncludes.end(); ++incs)
3069 cout << (*incs) << " ";
3072 if (!qmakeLibs.isEmpty()) {
3073 cout << "Additional libraries........";
3074 for (QStringList::Iterator libs = qmakeLibs.begin(); libs != qmakeLibs.end(); ++libs)
3075 cout << (*libs) << " ";
3078 if (dictionary[ "QMAKE_INTERNAL" ] == "yes") {
3079 cout << "Using internal configuration." << endl;
3081 if (dictionary[ "SHARED" ] == "no") {
3082 cout << "WARNING: Using static linking will disable the use of plugins." << endl;
3083 cout << " Make sure you compile ALL needed modules into the library." << endl;
3085 if (dictionary[ "OPENSSL" ] == "linked" && opensslLibs.isEmpty()) {
3086 cout << "NOTE: When linking against OpenSSL, you can override the default" << endl;
3087 cout << "library names through OPENSSL_LIBS." << endl;
3088 cout << "For example:" << endl;
3089 cout << " configure -openssl-linked OPENSSL_LIBS=\"-lssleay32 -llibeay32\"" << endl;
3091 if (dictionary[ "ZLIB_FORCED" ] == "yes") {
3092 QString which_zlib = "supplied";
3093 if (dictionary[ "ZLIB" ] == "system")
3094 which_zlib = "system";
3096 cout << "NOTE: The -no-zlib option was supplied but is no longer supported." << endl
3098 << "Qt now requires zlib support in all builds, so the -no-zlib" << endl
3099 << "option was ignored. Qt will be built using the " << which_zlib
3102 if (dictionary["OBSOLETE_ARCH_ARG"] == "yes") {
3104 << "NOTE: The -arch option is obsolete." << endl
3106 << "Qt now detects the target and host architectures based on compiler" << endl
3107 << "output. Qt will be built using " << dictionary["QT_ARCH"] << " for the target architecture" << endl
3108 << "and " << dictionary["QT_HOST_ARCH"] << " for the host architecture (note that these two" << endl
3109 << "will be the same unless you are cross-compiling)." << endl
3116 void Configure::generateHeaders()
3118 if (dictionary["SYNCQT"] == "yes") {
3119 if (findFile("perl.exe")) {
3120 cout << "Running syncqt..." << endl;
3122 args += buildPath + "/bin/syncqt.bat";
3125 env += QString("QTDIR=" + sourcePath);
3126 env += QString("PATH=" + buildPath + "/bin/;" + qgetenv("PATH"));
3127 int retc = Environment::execute(args, env, QStringList());
3129 cout << "syncqt failed, return code " << retc << endl << endl;
3130 dictionary["DONE"] = "error";
3133 cout << "Perl not found in environment - cannot run syncqt." << endl;
3134 dictionary["DONE"] = "error";
3139 void Configure::buildQmake()
3141 if (dictionary[ "BUILD_QMAKE" ] == "yes") {
3145 QString pwd = QDir::currentPath();
3146 if (!QDir(buildPath).mkpath("qmake")) {
3147 cout << "Cannot create qmake build dir." << endl;
3148 dictionary[ "DONE" ] = "error";
3151 if (!QDir::setCurrent(buildPath + "/qmake")) {
3152 cout << "Cannot enter qmake build dir." << endl;
3153 dictionary[ "DONE" ] = "error";
3157 QString makefile = "Makefile";
3159 QFile out(makefile);
3160 if (out.open(QFile::WriteOnly | QFile::Text)) {
3161 QTextStream stream(&out);
3162 stream << "#AutoGenerated by configure.exe" << endl
3163 << "BUILD_PATH = " << QDir::toNativeSeparators(buildPath) << endl
3164 << "SOURCE_PATH = " << QDir::toNativeSeparators(sourcePath) << endl;
3165 stream << "QMAKESPEC = " << dictionary["QMAKESPEC"] << endl
3166 << "QT_VERSION = " << dictionary["VERSION"] << endl;
3168 if (dictionary["EDITION"] == "OpenSource" ||
3169 dictionary["QT_EDITION"].contains("OPENSOURCE"))
3170 stream << "QMAKE_OPENSOURCE_EDITION = yes" << endl;
3173 QFile in(sourcePath + "/qmake/" + dictionary["QMAKEMAKEFILE"]);
3174 if (in.open(QFile::ReadOnly | QFile::Text)) {
3175 QString d = in.readAll();
3176 //### need replaces (like configure.sh)? --Sam
3177 stream << d << endl;
3184 args += dictionary[ "MAKE" ];
3188 cout << "Creating qmake..." << endl;
3189 int exitCode = Environment::execute(args, QStringList(), QStringList());
3192 args += dictionary[ "MAKE" ];
3196 exitCode = Environment::execute(args, QStringList(), QStringList());
3198 cout << "Cleaning qmake failed, return code " << exitCode << endl << endl;
3199 dictionary[ "DONE" ] = "error";
3202 args += dictionary[ "MAKE" ];
3205 exitCode = Environment::execute(args, QStringList(), QStringList());
3207 cout << "Building qmake failed, return code " << exitCode << endl << endl;
3208 dictionary[ "DONE" ] = "error";
3212 QDir::setCurrent(pwd);
3217 void Configure::buildHostTools()
3219 if (dictionary[ "NOPROCESS" ] == "yes")
3220 dictionary[ "DONE" ] = "yes";
3222 if (!dictionary.contains("XQMAKESPEC"))
3225 QString pwd = QDir::currentPath();
3226 QStringList hostToolsDirs;
3230 for (int i = 0; i < hostToolsDirs.count(); ++i) {
3231 cout << "Creating " << hostToolsDirs.at(i) << " ..." << endl;
3232 QString toolBuildPath = buildPath + "/" + hostToolsDirs.at(i);
3233 QString toolSourcePath = sourcePath + "/" + hostToolsDirs.at(i);
3235 // generate Makefile
3237 args << QDir::toNativeSeparators(buildPath + "/bin/qmake");
3238 // override .qmake.cache because we are not cross-building these.
3239 // we need a full path so that a build with -prefix will still find it.
3240 args << "-spec" << QDir::toNativeSeparators(buildPath + "/mkspecs/" + dictionary["QMAKESPEC"]);
3242 args << "-o" << QDir::toNativeSeparators(toolBuildPath + "/Makefile");
3244 QDir().mkpath(toolBuildPath);
3245 QDir::setCurrent(toolSourcePath);
3246 int exitCode = Environment::execute(args, QStringList(), QStringList());
3248 cout << "qmake failed, return code " << exitCode << endl << endl;
3249 dictionary["DONE"] = "error";
3255 args += dictionary["MAKE"];
3256 QDir::setCurrent(toolBuildPath);
3257 exitCode = Environment::execute(args, QStringList(), QStringList());
3260 args += dictionary["MAKE"];
3262 exitCode = Environment::execute(args, QStringList(), QStringList());
3264 cout << "Cleaning " << hostToolsDirs.at(i) << " failed, return code " << exitCode << endl << endl;
3265 dictionary["DONE"] = "error";
3269 args += dictionary["MAKE"];
3270 exitCode = Environment::execute(args, QStringList(), QStringList());
3272 cout << "Building " << hostToolsDirs.at(i) << " failed, return code " << exitCode << endl << endl;
3273 dictionary["DONE"] = "error";
3279 QDir::setCurrent(pwd);
3282 void Configure::findProjects(const QString& dirName)
3284 if (dictionary[ "NOPROCESS" ] == "no") {
3288 ProjectType qmakeTemplate;
3289 const QFileInfoList &list = dir.entryInfoList(QStringList(QLatin1String("*.pro")),
3290 QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot);
3291 for (int i = 0; i < list.size(); ++i) {
3292 const QFileInfo &fi = list.at(i);
3293 if (fi.fileName() != "qmake.pro") {
3294 entryName = dirName + "/" + fi.fileName();
3296 findProjects(entryName);
3298 qmakeTemplate = projectType(fi.absoluteFilePath());
3299 switch (qmakeTemplate) {
3308 makeList[makeListNumber].append(new MakeItem(sourceDir.relativeFilePath(fi.absolutePath()),
3319 void Configure::appendMakeItem(int inList, const QString &item)
3324 dir.prepend("/src");
3325 makeList[inList].append(new MakeItem(sourcePath + dir,
3326 item + ".pro", buildPath + dir + "/Makefile", Lib));
3327 if (dictionary[ "DSPFILES" ] == "yes") {
3328 makeList[inList].append(new MakeItem(sourcePath + dir,
3329 item + ".pro", buildPath + dir + "/" + item + ".dsp", Lib));
3331 if (dictionary[ "VCPFILES" ] == "yes") {
3332 makeList[inList].append(new MakeItem(sourcePath + dir,
3333 item + ".pro", buildPath + dir + "/" + item + ".vcp", Lib));
3335 if (dictionary[ "VCPROJFILES" ] == "yes") {
3336 makeList[inList].append(new MakeItem(sourcePath + dir,
3337 item + ".pro", buildPath + dir + "/" + item + ".vcproj", Lib));
3341 void Configure::generateMakefiles()
3343 if (dictionary[ "NOPROCESS" ] == "no") {
3345 cout << "Creating makefiles in src..." << endl;
3348 QString spec = dictionary.contains("XQMAKESPEC") ? dictionary[ "XQMAKESPEC" ] : dictionary[ "QMAKESPEC" ];
3349 if (spec != "win32-msvc")
3350 dictionary[ "DSPFILES" ] = "no";
3352 if (spec != "win32-msvc.net" && !spec.startsWith("win32-msvc2") && !spec.startsWith(QLatin1String("wince")))
3353 dictionary[ "VCPROJFILES" ] = "no";
3356 QString pwd = QDir::currentPath();
3357 if (dictionary["FAST"] != "yes") {
3359 bool generate = true;
3360 bool doDsp = (dictionary["DSPFILES"] == "yes" || dictionary["VCPFILES"] == "yes"
3361 || dictionary["VCPROJFILES"] == "yes");
3363 QString pwd = QDir::currentPath();
3364 QString dirPath = fixSeparators(buildPath + dirName);
3367 args << fixSeparators(buildPath + "/bin/qmake");
3370 if (dictionary[ "DEPENDENCIES" ] == "no")
3371 args << "-nodepend";
3372 args << "-tp" << "vc";
3373 doDsp = false; // DSP files will be done
3374 printf("Generating Visual Studio project files...\n");
3376 printf("Generating Makefiles...\n");
3377 generate = false; // Now Makefiles will be done
3379 // don't pass -spec - .qmake.cache has it already
3381 args << (sourcePath + "/qtbase.pro");
3384 if (!dictionary[ "QMAKEADDITIONALARGS" ].isEmpty())
3385 args << dictionary[ "QMAKEADDITIONALARGS" ];
3387 QDir::setCurrent(fixSeparators(dirPath));
3388 if (int exitCode = Environment::execute(args, QStringList(), QStringList())) {
3389 cout << "Qmake failed, return code " << exitCode << endl << endl;
3390 dictionary[ "DONE" ] = "error";
3394 findProjects(sourcePath);
3395 for (i=0; i<3; i++) {
3396 for (int j=0; j<makeList[i].size(); ++j) {
3397 MakeItem *it=makeList[i][j];
3398 QString dirPath = fixSeparators(it->directory + "/");
3399 QString projectName = it->proFile;
3400 QString makefileName = buildPath + "/" + dirPath + it->target;
3402 // For shadowbuilds, we need to create the path first
3403 QDir buildPathDir(buildPath);
3404 if (sourcePath != buildPath && !buildPathDir.exists(dirPath))
3405 buildPathDir.mkpath(dirPath);
3409 args << fixSeparators(buildPath + "/bin/qmake");
3410 args << sourcePath + "/" + dirPath + projectName;
3411 args << dictionary[ "QMAKE_ALL_ARGS" ];
3413 cout << "For " << qPrintable(dirPath + projectName) << endl;
3418 if (!dictionary[ "QMAKEADDITIONALARGS" ].isEmpty())
3419 args << dictionary[ "QMAKEADDITIONALARGS" ];
3421 QDir::setCurrent(fixSeparators(dirPath));
3423 QFile file(makefileName);
3424 if (!file.open(QFile::WriteOnly)) {
3425 printf("failed on dirPath=%s, makefile=%s\n",
3426 qPrintable(dirPath), qPrintable(makefileName));
3429 QTextStream txt(&file);
3431 txt << "\t" << args.join(" ") << "\n";
3432 txt << "\t\"$(MAKE)\" -$(MAKEFLAGS) -f " << it->target << "\n";
3433 txt << "first: all\n";
3435 txt << "\t" << args.join(" ") << "\n";
3439 QDir::setCurrent(pwd);
3441 cout << "Processing of project files have been disabled." << endl;
3442 cout << "Only use this option if you really know what you're doing." << endl << endl;
3447 void Configure::showSummary()
3449 QString make = dictionary[ "MAKE" ];
3450 if (!dictionary.contains("XQMAKESPEC")) {
3451 cout << endl << endl << "Qt is now configured for building. Just run " << qPrintable(make) << "." << endl;
3452 cout << "To reconfigure, run " << qPrintable(make) << " confclean and configure." << endl << endl;
3453 } else if (dictionary.value("QMAKESPEC").startsWith("wince")) {
3454 // we are cross compiling for Windows CE
3455 cout << endl << endl << "Qt is now configured for building. To start the build run:" << endl
3456 << "\tsetcepaths " << dictionary.value("XQMAKESPEC") << endl
3457 << "\t" << qPrintable(make) << endl
3458 << "To reconfigure, run " << qPrintable(make) << " confclean and configure." << endl << endl;
3462 Configure::ProjectType Configure::projectType(const QString& proFileName)
3464 QFile proFile(proFileName);
3465 if (proFile.open(QFile::ReadOnly)) {
3466 QString buffer = proFile.readLine(1024);
3467 while (!buffer.isEmpty()) {
3468 QStringList segments = buffer.split(QRegExp("\\s"));
3469 QStringList::Iterator it = segments.begin();
3471 if (segments.size() >= 3) {
3472 QString keyword = (*it++);
3473 QString operation = (*it++);
3474 QString value = (*it++);
3476 if (keyword == "TEMPLATE") {
3479 else if (value == "subdirs")
3484 buffer = proFile.readLine(1024);
3488 // Default to app handling
3494 bool Configure::showLicense(QString orgLicenseFile)
3496 if (dictionary["LICENSE_CONFIRMED"] == "yes") {
3497 cout << "You have already accepted the terms of the license." << endl << endl;
3501 bool haveGpl3 = false;
3502 QString licenseFile = orgLicenseFile;
3504 if (dictionary["EDITION"] == "OpenSource" || dictionary["EDITION"] == "Snapshot") {
3505 haveGpl3 = QFile::exists(orgLicenseFile + "/LICENSE.GPL3");
3506 theLicense = "GNU Lesser General Public License (LGPL) version 2.1";
3508 theLicense += "\nor the GNU General Public License (GPL) version 3";
3510 // the first line of the license file tells us which license it is
3511 QFile file(licenseFile);
3512 if (!file.open(QFile::ReadOnly)) {
3513 cout << "Failed to load LICENSE file" << endl;
3516 theLicense = file.readLine().trimmed();
3521 cout << "You are licensed to use this software under the terms of" << endl
3522 << "the " << theLicense << "." << endl
3524 if (dictionary["EDITION"] == "OpenSource" || dictionary["EDITION"] == "Snapshot") {
3526 cout << "Type '3' to view the GNU General Public License version 3 (GPLv3)." << endl;
3527 cout << "Type 'L' to view the Lesser GNU General Public License version 2.1 (LGPLv2.1)." << endl;
3529 cout << "Type '?' to view the " << theLicense << "." << endl;
3531 cout << "Type 'y' to accept this license offer." << endl
3532 << "Type 'n' to decline this license offer." << endl
3534 << "Do you accept the terms of the license?" << endl;
3536 accept = tolower(accept);
3538 if (accept == 'y') {
3540 } else if (accept == 'n') {
3543 if (dictionary["EDITION"] == "OpenSource" || dictionary["EDITION"] == "Snapshot") {
3545 licenseFile = orgLicenseFile + "/LICENSE.GPL3";
3547 licenseFile = orgLicenseFile + "/LICENSE.LGPL";
3549 // Get console line height, to fill the screen properly
3550 int i = 0, screenHeight = 25; // default
3551 CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
3552 HANDLE stdOut = GetStdHandle(STD_OUTPUT_HANDLE);
3553 if (GetConsoleScreenBufferInfo(stdOut, &consoleInfo))
3554 screenHeight = consoleInfo.srWindow.Bottom
3555 - consoleInfo.srWindow.Top
3556 - 1; // Some overlap for context
3558 // Prompt the license content to the user
3559 QFile file(licenseFile);
3560 if (!file.open(QFile::ReadOnly)) {
3561 cout << "Failed to load LICENSE file" << licenseFile << endl;
3564 QStringList licenseContent = QString(file.readAll()).split('\n');
3565 while (i < licenseContent.size()) {
3566 cout << licenseContent.at(i) << endl;
3567 if (++i % screenHeight == 0) {
3568 cout << "(Press any key for more..)";
3569 if (_getch() == 3) // _Any_ keypress w/no echo(eat <Enter> for stdout)
3570 exit(0); // Exit cleanly for Ctrl+C
3571 cout << "\r"; // Overwrite text above
3578 void Configure::readLicense()
3580 if (QFile::exists(dictionary["QT_SOURCE_TREE"] + "/src/corelib/kernel/qfunctions_wince.h") &&
3581 (dictionary.value("QMAKESPEC").startsWith("wince") || dictionary.value("XQMAKESPEC").startsWith("wince")))
3582 dictionary["PLATFORM NAME"] = "Qt for Windows CE";
3584 dictionary["PLATFORM NAME"] = "Qt for Windows";
3585 dictionary["LICENSE FILE"] = sourcePath;
3587 bool openSource = false;
3588 bool hasOpenSource = QFile::exists(dictionary["LICENSE FILE"] + "/LICENSE.GPL3") || QFile::exists(dictionary["LICENSE FILE"] + "/LICENSE.LGPL");
3589 if (dictionary["BUILDTYPE"] == "commercial") {
3591 } else if (dictionary["BUILDTYPE"] == "opensource") {
3593 } else if (hasOpenSource) { // No Open Source? Just display the commercial license right away
3596 cout << "Which edition of Qt do you want to use ?" << endl;
3597 cout << "Type 'c' if you want to use the Commercial Edition." << endl;
3598 cout << "Type 'o' if you want to use the Open Source Edition." << endl;
3600 accept = tolower(accept);
3602 if (accept == 'c') {
3605 } else if (accept == 'o') {
3611 if (hasOpenSource && openSource) {
3612 cout << endl << "This is the " << dictionary["PLATFORM NAME"] << " Open Source Edition." << endl;
3613 licenseInfo["LICENSEE"] = "Open Source";
3614 dictionary["EDITION"] = "OpenSource";
3615 dictionary["QT_EDITION"] = "QT_EDITION_OPENSOURCE";
3617 if (!showLicense(dictionary["LICENSE FILE"])) {
3618 cout << "Configuration aborted since license was not accepted";
3619 dictionary["DONE"] = "error";
3622 } else if (openSource) {
3623 cout << endl << "Cannot find the GPL license files! Please download the Open Source version of the library." << endl;
3624 dictionary["DONE"] = "error";
3626 #ifdef COMMERCIAL_VERSION
3628 Tools::checkLicense(dictionary, licenseInfo, firstLicensePath());
3629 if (dictionary["DONE"] != "error") {
3630 // give the user some feedback, and prompt for license acceptance
3631 cout << endl << "This is the " << dictionary["PLATFORM NAME"] << " " << dictionary["EDITION"] << " Edition."<< endl << endl;
3632 if (!showLicense(dictionary["LICENSE FILE"])) {
3633 cout << "Configuration aborted since license was not accepted";
3634 dictionary["DONE"] = "error";
3639 #else // !COMMERCIAL_VERSION
3641 cout << endl << "Cannot build commercial edition from the open source version of the library." << endl;
3642 dictionary["DONE"] = "error";
3647 void Configure::reloadCmdLine()
3649 if (dictionary[ "REDO" ] == "yes") {
3650 QFile inFile(buildPath + "/configure" + dictionary[ "CUSTOMCONFIG" ] + ".cache");
3651 if (inFile.open(QFile::ReadOnly)) {
3652 QTextStream inStream(&inFile);
3655 while (buffer.length()) {
3656 configCmdLine += buffer;
3664 void Configure::saveCmdLine()
3666 if (dictionary[ "REDO" ] != "yes") {
3667 QFile outFile(buildPath + "/configure" + dictionary[ "CUSTOMCONFIG" ] + ".cache");
3668 if (outFile.open(QFile::WriteOnly | QFile::Text)) {
3669 QTextStream outStream(&outFile);
3670 for (QStringList::Iterator it = configCmdLine.begin(); it != configCmdLine.end(); ++it) {
3671 outStream << (*it) << " " << endl;
3680 bool Configure::isDone()
3682 return !dictionary["DONE"].isEmpty();
3685 bool Configure::isOk()
3687 return (dictionary[ "DONE" ] != "error");
3691 Configure::filesDiffer(const QString &fn1, const QString &fn2)
3693 QFile file1(fn1), file2(fn2);
3694 if (!file1.open(QFile::ReadOnly) || !file2.open(QFile::ReadOnly))
3696 const int chunk = 2048;
3697 int used1 = 0, used2 = 0;
3698 char b1[chunk], b2[chunk];
3699 while (!file1.atEnd() && !file2.atEnd()) {
3701 used1 = file1.read(b1, chunk);
3703 used2 = file2.read(b2, chunk);
3704 if (used1 > 0 && used2 > 0) {
3705 const int cmp = qMin(used1, used2);
3706 if (memcmp(b1, b2, cmp))
3709 memcpy(b1, b1+cmp, used1);
3711 memcpy(b2, b2+cmp, used2);
3714 return !file1.atEnd() || !file2.atEnd();