source: trunk/tools/configure/configureapp.cpp@ 5

Last change on this file since 5 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

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