PageRenderTime 83ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/src/qt/qtbase/tools/configure/configureapp.cpp

https://code.google.com/
C++ | 4512 lines | 3833 code | 465 blank | 214 comment | 2073 complexity | 10eb3a88818ca1a56732242298772915 MD5 | raw file
Possible License(s): LGPL-3.0, CC-BY-SA-4.0, MIT, AGPL-3.0, BSD-3-Clause, LGPL-2.1, CC0-1.0, GPL-2.0, LGPL-2.0, GPL-3.0
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
  4. ** Copyright (C) 2013 Intel Corporation
  5. ** Contact: http://www.qt-project.org/legal
  6. **
  7. ** This file is part of the tools applications of the Qt Toolkit.
  8. **
  9. ** $QT_BEGIN_LICENSE:LGPL$
  10. ** Commercial License Usage
  11. ** Licensees holding valid commercial Qt licenses may use this file in
  12. ** accordance with the commercial license agreement provided with the
  13. ** Software or, alternatively, in accordance with the terms contained in
  14. ** a written agreement between you and Digia. For licensing terms and
  15. ** conditions see http://qt.digia.com/licensing. For further information
  16. ** use the contact form at http://qt.digia.com/contact-us.
  17. **
  18. ** GNU Lesser General Public License Usage
  19. ** Alternatively, this file may be used under the terms of the GNU Lesser
  20. ** General Public License version 2.1 as published by the Free Software
  21. ** Foundation and appearing in the file LICENSE.LGPL included in the
  22. ** packaging of this file. Please review the following information to
  23. ** ensure the GNU Lesser General Public License version 2.1 requirements
  24. ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  25. **
  26. ** In addition, as a special exception, Digia gives you certain additional
  27. ** rights. These rights are described in the Digia Qt LGPL Exception
  28. ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  29. **
  30. ** GNU General Public License Usage
  31. ** Alternatively, this file may be used under the terms of the GNU
  32. ** General Public License version 3.0 as published by the Free Software
  33. ** Foundation and appearing in the file LICENSE.GPL included in the
  34. ** packaging of this file. Please review the following information to
  35. ** ensure the GNU General Public License version 3.0 requirements will be
  36. ** met: http://www.gnu.org/copyleft/gpl.html.
  37. **
  38. **
  39. ** $QT_END_LICENSE$
  40. **
  41. ****************************************************************************/
  42. #include "configureapp.h"
  43. #include "environment.h"
  44. #ifdef COMMERCIAL_VERSION
  45. # include "tools.h"
  46. #endif
  47. #include <qdatetime.h>
  48. #include <qdir.h>
  49. #include <qdiriterator.h>
  50. #include <qtemporaryfile.h>
  51. #include <qstandardpaths.h>
  52. #include <qstack.h>
  53. #include <qdebug.h>
  54. #include <qfileinfo.h>
  55. #include <qtextstream.h>
  56. #include <qregexp.h>
  57. #include <qhash.h>
  58. #include <iostream>
  59. #include <string>
  60. #include <fstream>
  61. #include <windows.h>
  62. #include <conio.h>
  63. QT_BEGIN_NAMESPACE
  64. enum Platforms {
  65. WINDOWS,
  66. WINDOWS_CE,
  67. WINDOWS_RT,
  68. QNX,
  69. BLACKBERRY,
  70. ANDROID
  71. };
  72. std::ostream &operator<<(std::ostream &s, const QString &val) {
  73. s << val.toLocal8Bit().data();
  74. return s;
  75. }
  76. using namespace std;
  77. // Macros to simplify options marking
  78. #define MARK_OPTION(x,y) ( dictionary[ #x ] == #y ? "*" : " " )
  79. static inline void promptKeyPress()
  80. {
  81. cout << "(Press any key to continue...)";
  82. if (_getch() == 3) // _Any_ keypress w/no echo(eat <Enter> for stdout)
  83. exit(0); // Exit cleanly for Ctrl+C
  84. }
  85. Configure::Configure(int& argc, char** argv)
  86. {
  87. // Default values for indentation
  88. optionIndent = 4;
  89. descIndent = 25;
  90. outputWidth = 0;
  91. // Get console buffer output width
  92. CONSOLE_SCREEN_BUFFER_INFO info;
  93. HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  94. if (GetConsoleScreenBufferInfo(hStdout, &info))
  95. outputWidth = info.dwSize.X - 1;
  96. outputWidth = qMin(outputWidth, 79); // Anything wider gets unreadable
  97. if (outputWidth < 35) // Insanely small, just use 79
  98. outputWidth = 79;
  99. int i;
  100. /*
  101. ** Set up the initial state, the default
  102. */
  103. dictionary[ "CONFIGCMD" ] = argv[ 0 ];
  104. for (i = 1; i < argc; i++)
  105. configCmdLine += argv[ i ];
  106. if (configCmdLine.size() >= 2 && configCmdLine.at(0) == "-srcdir") {
  107. sourcePath = QDir::cleanPath(configCmdLine.at(1));
  108. sourceDir = QDir(sourcePath);
  109. configCmdLine.erase(configCmdLine.begin(), configCmdLine.begin() + 2);
  110. } else {
  111. // Get the path to the executable
  112. wchar_t module_name[MAX_PATH];
  113. GetModuleFileName(0, module_name, sizeof(module_name) / sizeof(wchar_t));
  114. QFileInfo sourcePathInfo = QString::fromWCharArray(module_name);
  115. sourcePath = sourcePathInfo.absolutePath();
  116. sourceDir = sourcePathInfo.dir();
  117. }
  118. buildPath = QDir::currentPath();
  119. #if 0
  120. const QString installPath = QString("C:\\Qt\\%1").arg(QT_VERSION_STR);
  121. #else
  122. const QString installPath = buildPath;
  123. #endif
  124. if (sourceDir != buildDir) { //shadow builds!
  125. QDir(buildPath).mkpath("bin");
  126. buildDir.mkpath("mkspecs");
  127. }
  128. defaultBuildParts << QStringLiteral("libs") << QStringLiteral("tools") << QStringLiteral("examples");
  129. allBuildParts = defaultBuildParts;
  130. allBuildParts << QStringLiteral("tests");
  131. dictionary[ "QT_INSTALL_PREFIX" ] = installPath;
  132. dictionary[ "QMAKESPEC" ] = getenv("QMAKESPEC");
  133. if (dictionary[ "QMAKESPEC" ].size() == 0) {
  134. dictionary[ "QMAKESPEC" ] = Environment::detectQMakeSpec();
  135. dictionary[ "QMAKESPEC_FROM" ] = "detected";
  136. } else {
  137. dictionary[ "QMAKESPEC_FROM" ] = "env";
  138. }
  139. dictionary[ "QCONFIG" ] = "full";
  140. dictionary[ "EMBEDDED" ] = "no";
  141. dictionary[ "BUILD_QMAKE" ] = "yes";
  142. dictionary[ "VCPROJFILES" ] = "yes";
  143. dictionary[ "QMAKE_INTERNAL" ] = "no";
  144. dictionary[ "PROCESS" ] = "partial";
  145. dictionary[ "WIDGETS" ] = "yes";
  146. dictionary[ "GUI" ] = "yes";
  147. dictionary[ "RTTI" ] = "yes";
  148. dictionary[ "STRIP" ] = "yes";
  149. dictionary[ "SSE2" ] = "auto";
  150. dictionary[ "SSE3" ] = "auto";
  151. dictionary[ "SSSE3" ] = "auto";
  152. dictionary[ "SSE4_1" ] = "auto";
  153. dictionary[ "SSE4_2" ] = "auto";
  154. dictionary[ "AVX" ] = "auto";
  155. dictionary[ "AVX2" ] = "auto";
  156. dictionary[ "IWMMXT" ] = "auto";
  157. dictionary[ "SYNCQT" ] = "auto";
  158. dictionary[ "CE_CRT" ] = "no";
  159. dictionary[ "CETEST" ] = "auto";
  160. dictionary[ "CE_SIGNATURE" ] = "no";
  161. dictionary[ "AUDIO_BACKEND" ] = "auto";
  162. dictionary[ "WMF_BACKEND" ] = "auto";
  163. dictionary[ "WMSDK" ] = "auto";
  164. dictionary[ "QML_DEBUG" ] = "yes";
  165. dictionary[ "PLUGIN_MANIFESTS" ] = "no";
  166. dictionary[ "DIRECTWRITE" ] = "no";
  167. dictionary[ "DIRECT2D" ] = "no";
  168. dictionary[ "NIS" ] = "no";
  169. dictionary[ "NEON" ] = "auto";
  170. dictionary[ "LARGE_FILE" ] = "yes";
  171. dictionary[ "FONT_CONFIG" ] = "no";
  172. dictionary[ "POSIX_IPC" ] = "no";
  173. dictionary[ "QT_GLIB" ] = "no";
  174. dictionary[ "QT_ICONV" ] = "auto";
  175. dictionary[ "QT_EVDEV" ] = "auto";
  176. dictionary[ "QT_MTDEV" ] = "auto";
  177. dictionary[ "QT_INOTIFY" ] = "auto";
  178. dictionary[ "QT_EVENTFD" ] = "auto";
  179. dictionary[ "QT_CUPS" ] = "auto";
  180. dictionary[ "CFG_GCC_SYSROOT" ] = "yes";
  181. dictionary[ "SLOG2" ] = "no";
  182. dictionary[ "QNX_IMF" ] = "no";
  183. dictionary[ "PPS" ] = "no";
  184. dictionary[ "LGMON" ] = "no";
  185. dictionary[ "SYSTEM_PROXIES" ] = "no";
  186. dictionary[ "WERROR" ] = "auto";
  187. dictionary[ "QREAL" ] = "double";
  188. //Only used when cross compiling.
  189. dictionary[ "QT_INSTALL_SETTINGS" ] = "/etc/xdg";
  190. QString version;
  191. QFile qglobal_h(sourcePath + "/src/corelib/global/qglobal.h");
  192. if (qglobal_h.open(QFile::ReadOnly)) {
  193. QTextStream read(&qglobal_h);
  194. QRegExp version_regexp("^# *define *QT_VERSION_STR *\"([^\"]*)\"");
  195. QString line;
  196. while (!read.atEnd()) {
  197. line = read.readLine();
  198. if (version_regexp.exactMatch(line)) {
  199. version = version_regexp.cap(1).trimmed();
  200. if (!version.isEmpty())
  201. break;
  202. }
  203. }
  204. qglobal_h.close();
  205. }
  206. if (version.isEmpty())
  207. version = QString("%1.%2.%3").arg(QT_VERSION>>16).arg(((QT_VERSION>>8)&0xff)).arg(QT_VERSION&0xff);
  208. dictionary[ "VERSION" ] = version;
  209. {
  210. QRegExp version_re("([0-9]*)\\.([0-9]*)\\.([0-9]*)(|-.*)");
  211. if (version_re.exactMatch(version)) {
  212. dictionary[ "VERSION_MAJOR" ] = version_re.cap(1);
  213. dictionary[ "VERSION_MINOR" ] = version_re.cap(2);
  214. dictionary[ "VERSION_PATCH" ] = version_re.cap(3);
  215. }
  216. }
  217. dictionary[ "REDO" ] = "no";
  218. dictionary[ "DEPENDENCIES" ] = "no";
  219. dictionary[ "BUILD" ] = "debug";
  220. dictionary[ "BUILDALL" ] = "auto"; // Means yes, but not explicitly
  221. dictionary[ "FORCEDEBUGINFO" ] = "no";
  222. dictionary[ "BUILDTYPE" ] = "none";
  223. dictionary[ "BUILDDEV" ] = "no";
  224. dictionary[ "COMPILE_EXAMPLES" ] = "yes";
  225. dictionary[ "C++11" ] = "auto";
  226. dictionary[ "SHARED" ] = "yes";
  227. dictionary[ "ZLIB" ] = "auto";
  228. dictionary[ "PCRE" ] = "auto";
  229. dictionary[ "ICU" ] = "auto";
  230. dictionary[ "ANGLE" ] = "auto";
  231. dictionary[ "DYNAMICGL" ] = "auto";
  232. dictionary[ "GIF" ] = "auto";
  233. dictionary[ "JPEG" ] = "auto";
  234. dictionary[ "PNG" ] = "auto";
  235. dictionary[ "LIBJPEG" ] = "auto";
  236. dictionary[ "LIBPNG" ] = "auto";
  237. dictionary[ "FREETYPE" ] = "yes";
  238. dictionary[ "HARFBUZZ" ] = "no";
  239. dictionary[ "ACCESSIBILITY" ] = "yes";
  240. dictionary[ "OPENGL" ] = "yes";
  241. dictionary[ "OPENGL_ES_2" ] = "yes";
  242. dictionary[ "OPENVG" ] = "no";
  243. dictionary[ "OPENSSL" ] = "auto";
  244. dictionary[ "DBUS" ] = "auto";
  245. dictionary[ "STYLE_WINDOWS" ] = "yes";
  246. dictionary[ "STYLE_WINDOWSXP" ] = "auto";
  247. dictionary[ "STYLE_WINDOWSVISTA" ] = "auto";
  248. dictionary[ "STYLE_FUSION" ] = "yes";
  249. dictionary[ "STYLE_WINDOWSCE" ] = "no";
  250. dictionary[ "STYLE_WINDOWSMOBILE" ] = "no";
  251. dictionary[ "STYLE_GTK" ] = "no";
  252. dictionary[ "SQL_MYSQL" ] = "no";
  253. dictionary[ "SQL_ODBC" ] = "no";
  254. dictionary[ "SQL_OCI" ] = "no";
  255. dictionary[ "SQL_PSQL" ] = "no";
  256. dictionary[ "SQL_TDS" ] = "no";
  257. dictionary[ "SQL_DB2" ] = "no";
  258. dictionary[ "SQL_SQLITE" ] = "auto";
  259. dictionary[ "SQL_SQLITE_LIB" ] = "qt";
  260. dictionary[ "SQL_SQLITE2" ] = "no";
  261. dictionary[ "SQL_IBASE" ] = "no";
  262. QString tmp = dictionary[ "QMAKESPEC" ];
  263. if (tmp.contains("\\")) {
  264. tmp = tmp.mid(tmp.lastIndexOf("\\") + 1);
  265. } else {
  266. tmp = tmp.mid(tmp.lastIndexOf("/") + 1);
  267. }
  268. dictionary[ "QMAKESPEC" ] = tmp;
  269. dictionary[ "INCREDIBUILD_XGE" ] = "auto";
  270. dictionary[ "LTCG" ] = "no";
  271. dictionary[ "NATIVE_GESTURES" ] = "yes";
  272. dictionary[ "MSVC_MP" ] = "no";
  273. }
  274. Configure::~Configure()
  275. {
  276. for (int i=0; i<3; ++i) {
  277. QList<MakeItem*> items = makeList[i];
  278. for (int j=0; j<items.size(); ++j)
  279. delete items[j];
  280. }
  281. }
  282. QString Configure::formatPath(const QString &path)
  283. {
  284. QString ret = QDir::cleanPath(path);
  285. // This amount of quoting is deemed sufficient.
  286. if (ret.contains(QLatin1Char(' '))) {
  287. ret.prepend(QLatin1Char('"'));
  288. ret.append(QLatin1Char('"'));
  289. }
  290. return ret;
  291. }
  292. QString Configure::formatPaths(const QStringList &paths)
  293. {
  294. QString ret;
  295. foreach (const QString &path, paths) {
  296. if (!ret.isEmpty())
  297. ret += QLatin1Char(' ');
  298. ret += formatPath(path);
  299. }
  300. return ret;
  301. }
  302. // We could use QDir::homePath() + "/.qt-license", but
  303. // that will only look in the first of $HOME,$USERPROFILE
  304. // or $HOMEDRIVE$HOMEPATH. So, here we try'em all to be
  305. // more forgiving for the end user..
  306. QString Configure::firstLicensePath()
  307. {
  308. QStringList allPaths;
  309. allPaths << "./.qt-license"
  310. << QString::fromLocal8Bit(getenv("HOME")) + "/.qt-license"
  311. << QString::fromLocal8Bit(getenv("USERPROFILE")) + "/.qt-license"
  312. << QString::fromLocal8Bit(getenv("HOMEDRIVE")) + QString::fromLocal8Bit(getenv("HOMEPATH")) + "/.qt-license";
  313. for (int i = 0; i< allPaths.count(); ++i)
  314. if (QFile::exists(allPaths.at(i)))
  315. return allPaths.at(i);
  316. return QString();
  317. }
  318. // #### somehow I get a compiler error about vc++ reaching the nesting limit without
  319. // undefining the ansi for scoping.
  320. #ifdef for
  321. #undef for
  322. #endif
  323. void Configure::parseCmdLine()
  324. {
  325. if (configCmdLine.size() && configCmdLine.at(0) == "-top-level") {
  326. dictionary[ "TOPLEVEL" ] = "yes";
  327. configCmdLine.removeAt(0);
  328. }
  329. int argCount = configCmdLine.size();
  330. int i = 0;
  331. const QStringList imageFormats = QStringList() << "gif" << "png" << "jpeg";
  332. if (argCount < 1) // skip rest if no arguments
  333. ;
  334. else if (configCmdLine.at(i) == "-redo") {
  335. dictionary[ "REDO" ] = "yes";
  336. configCmdLine.clear();
  337. reloadCmdLine();
  338. }
  339. else if (configCmdLine.at(i) == "-loadconfig") {
  340. ++i;
  341. if (i != argCount) {
  342. dictionary[ "REDO" ] = "yes";
  343. dictionary[ "CUSTOMCONFIG" ] = "_" + configCmdLine.at(i);
  344. configCmdLine.clear();
  345. reloadCmdLine();
  346. } else {
  347. dictionary[ "DONE" ] = "error";
  348. }
  349. i = 0;
  350. }
  351. argCount = configCmdLine.size();
  352. bool isDeviceMkspec = false;
  353. // Look first for XQMAKESPEC
  354. for (int j = 0 ; j < argCount; ++j)
  355. {
  356. if ((configCmdLine.at(j) == "-xplatform") || (configCmdLine.at(j) == "-device")) {
  357. isDeviceMkspec = (configCmdLine.at(j) == "-device");
  358. ++j;
  359. if (j == argCount)
  360. break;
  361. dictionary["XQMAKESPEC"] = configCmdLine.at(j);
  362. applySpecSpecifics();
  363. break;
  364. }
  365. }
  366. for (; i<configCmdLine.size(); ++i) {
  367. bool continueElse[] = {false, false};
  368. if (configCmdLine.at(i) == "-help"
  369. || configCmdLine.at(i) == "-h"
  370. || configCmdLine.at(i) == "-?")
  371. dictionary[ "HELP" ] = "yes";
  372. else if (configCmdLine.at(i) == "-qconfig") {
  373. ++i;
  374. if (i == argCount)
  375. break;
  376. dictionary[ "QCONFIG" ] = configCmdLine.at(i);
  377. }
  378. else if (configCmdLine.at(i) == "-qreal") {
  379. ++i;
  380. if (i == argCount)
  381. break;
  382. dictionary[ "QREAL" ] = configCmdLine.at(i);
  383. }
  384. else if (configCmdLine.at(i) == "-release") {
  385. dictionary[ "BUILD" ] = "release";
  386. if (dictionary[ "BUILDALL" ] == "auto")
  387. dictionary[ "BUILDALL" ] = "no";
  388. } else if (configCmdLine.at(i) == "-debug") {
  389. dictionary[ "BUILD" ] = "debug";
  390. if (dictionary[ "BUILDALL" ] == "auto")
  391. dictionary[ "BUILDALL" ] = "no";
  392. } else if (configCmdLine.at(i) == "-debug-and-release")
  393. dictionary[ "BUILDALL" ] = "yes";
  394. else if (configCmdLine.at(i) == "-force-debug-info")
  395. dictionary[ "FORCEDEBUGINFO" ] = "yes";
  396. else if (configCmdLine.at(i) == "-compile-examples") {
  397. dictionary[ "COMPILE_EXAMPLES" ] = "yes";
  398. } else if (configCmdLine.at(i) == "-no-compile-examples") {
  399. dictionary[ "COMPILE_EXAMPLES" ] = "no";
  400. }
  401. else if (configCmdLine.at(i) == "-c++11")
  402. dictionary[ "C++11" ] = "yes";
  403. else if (configCmdLine.at(i) == "-no-c++11")
  404. dictionary[ "C++11" ] = "no";
  405. else if (configCmdLine.at(i) == "-shared")
  406. dictionary[ "SHARED" ] = "yes";
  407. else if (configCmdLine.at(i) == "-static")
  408. dictionary[ "SHARED" ] = "no";
  409. else if (configCmdLine.at(i) == "-developer-build")
  410. dictionary[ "BUILDDEV" ] = "yes";
  411. else if (configCmdLine.at(i) == "-opensource") {
  412. dictionary[ "BUILDTYPE" ] = "opensource";
  413. }
  414. else if (configCmdLine.at(i) == "-commercial") {
  415. dictionary[ "BUILDTYPE" ] = "commercial";
  416. }
  417. else if (configCmdLine.at(i) == "-ltcg") {
  418. dictionary[ "LTCG" ] = "yes";
  419. }
  420. else if (configCmdLine.at(i) == "-no-ltcg") {
  421. dictionary[ "LTCG" ] = "no";
  422. }
  423. else if (configCmdLine.at(i) == "-mp") {
  424. dictionary[ "MSVC_MP" ] = "yes";
  425. }
  426. else if (configCmdLine.at(i) == "-no-mp") {
  427. dictionary[ "MSVC_MP" ] = "no";
  428. }
  429. else if (configCmdLine.at(i) == "-force-asserts") {
  430. dictionary[ "FORCE_ASSERTS" ] = "yes";
  431. }
  432. else if (configCmdLine.at(i) == "-target") {
  433. ++i;
  434. if (i == argCount)
  435. break;
  436. const QString option = configCmdLine.at(i);
  437. if (option != "xp") {
  438. cout << "ERROR: invalid argument for -target option" << endl;
  439. dictionary["DONE"] = "error";
  440. return;
  441. }
  442. dictionary["TARGET_OS"] = option;
  443. }
  444. else if (configCmdLine.at(i) == "-platform") {
  445. ++i;
  446. if (i == argCount)
  447. break;
  448. dictionary[ "QMAKESPEC" ] = configCmdLine.at(i);
  449. dictionary[ "QMAKESPEC_FROM" ] = "commandline";
  450. } else if (configCmdLine.at(i) == "-arch") {
  451. ++i;
  452. if (i == argCount)
  453. break;
  454. dictionary["OBSOLETE_ARCH_ARG"] = "yes";
  455. } else if (configCmdLine.at(i) == "-embedded") {
  456. dictionary[ "EMBEDDED" ] = "yes";
  457. } else if (configCmdLine.at(i) == "-xplatform"
  458. || configCmdLine.at(i) == "-device") {
  459. ++i;
  460. // do nothing
  461. } else if (configCmdLine.at(i) == "-device-option") {
  462. ++i;
  463. const QString option = configCmdLine.at(i);
  464. QString &devOpt = dictionary["DEVICE_OPTION"];
  465. if (!devOpt.isEmpty())
  466. devOpt.append("\n").append(option);
  467. else
  468. devOpt = option;
  469. }
  470. else if (configCmdLine.at(i) == "-no-zlib") {
  471. // No longer supported since Qt 4.4.0
  472. // But save the information for later so that we can print a warning
  473. //
  474. // If you REALLY really need no zlib support, you can still disable
  475. // it by doing the following:
  476. // add "no-zlib" to mkspecs/qconfig.pri
  477. // #define QT_NO_COMPRESS (probably by adding to src/corelib/global/qconfig.h)
  478. //
  479. // There's no guarantee that Qt will build under those conditions
  480. dictionary[ "ZLIB_FORCED" ] = "yes";
  481. } else if (configCmdLine.at(i) == "-qt-zlib") {
  482. dictionary[ "ZLIB" ] = "qt";
  483. } else if (configCmdLine.at(i) == "-system-zlib") {
  484. dictionary[ "ZLIB" ] = "system";
  485. }
  486. else if (configCmdLine.at(i) == "-qt-pcre") {
  487. dictionary[ "PCRE" ] = "qt";
  488. } else if (configCmdLine.at(i) == "-system-pcre") {
  489. dictionary[ "PCRE" ] = "system";
  490. }
  491. else if (configCmdLine.at(i) == "-icu") {
  492. dictionary[ "ICU" ] = "yes";
  493. } else if (configCmdLine.at(i) == "-no-icu") {
  494. dictionary[ "ICU" ] = "no";
  495. }
  496. else if (configCmdLine.at(i) == "-angle") {
  497. dictionary[ "ANGLE" ] = "yes";
  498. dictionary[ "ANGLE_FROM" ] = "commandline";
  499. } else if (configCmdLine.at(i) == "-angle-d3d11") {
  500. dictionary[ "ANGLE" ] = "d3d11";
  501. dictionary[ "ANGLE_FROM" ] = "commandline";
  502. } else if (configCmdLine.at(i) == "-no-angle") {
  503. dictionary[ "ANGLE" ] = "no";
  504. dictionary[ "ANGLE_FROM" ] = "commandline";
  505. }
  506. // Image formats --------------------------------------------
  507. else if (configCmdLine.at(i) == "-no-gif")
  508. dictionary[ "GIF" ] = "no";
  509. else if (configCmdLine.at(i) == "-no-libjpeg") {
  510. dictionary[ "JPEG" ] = "no";
  511. dictionary[ "LIBJPEG" ] = "no";
  512. } else if (configCmdLine.at(i) == "-qt-libjpeg") {
  513. dictionary[ "LIBJPEG" ] = "qt";
  514. } else if (configCmdLine.at(i) == "-system-libjpeg") {
  515. dictionary[ "LIBJPEG" ] = "system";
  516. }
  517. else if (configCmdLine.at(i) == "-no-libpng") {
  518. dictionary[ "PNG" ] = "no";
  519. dictionary[ "LIBPNG" ] = "no";
  520. } else if (configCmdLine.at(i) == "-qt-libpng") {
  521. dictionary[ "LIBPNG" ] = "qt";
  522. } else if (configCmdLine.at(i) == "-system-libpng") {
  523. dictionary[ "LIBPNG" ] = "system";
  524. }
  525. // Text Rendering --------------------------------------------
  526. else if (configCmdLine.at(i) == "-no-freetype")
  527. dictionary[ "FREETYPE" ] = "no";
  528. else if (configCmdLine.at(i) == "-qt-freetype")
  529. dictionary[ "FREETYPE" ] = "yes";
  530. else if (configCmdLine.at(i) == "-system-freetype")
  531. dictionary[ "FREETYPE" ] = "system";
  532. else if (configCmdLine.at(i) == "-no-harfbuzz")
  533. dictionary[ "HARFBUZZ" ] = "no";
  534. else if (configCmdLine.at(i) == "-qt-harfbuzz")
  535. dictionary[ "HARFBUZZ" ] = "yes";
  536. else if (configCmdLine.at(i) == "-system-harfbuzz")
  537. dictionary[ "HARFBUZZ" ] = "system";
  538. // CE- C runtime --------------------------------------------
  539. else if (configCmdLine.at(i) == "-crt") {
  540. ++i;
  541. if (i == argCount)
  542. break;
  543. QDir cDir(configCmdLine.at(i));
  544. if (!cDir.exists())
  545. cout << "WARNING: Could not find directory (" << qPrintable(configCmdLine.at(i)) << ")for C runtime deployment" << endl;
  546. else
  547. dictionary[ "CE_CRT" ] = QDir::toNativeSeparators(cDir.absolutePath());
  548. } else if (configCmdLine.at(i) == "-qt-crt") {
  549. dictionary[ "CE_CRT" ] = "yes";
  550. } else if (configCmdLine.at(i) == "-no-crt") {
  551. dictionary[ "CE_CRT" ] = "no";
  552. }
  553. // cetest ---------------------------------------------------
  554. else if (configCmdLine.at(i) == "-no-cetest") {
  555. dictionary[ "CETEST" ] = "no";
  556. dictionary[ "CETEST_REQUESTED" ] = "no";
  557. } else if (configCmdLine.at(i) == "-cetest") {
  558. // although specified to use it, we stay at "auto" state
  559. // this is because checkAvailability() adds variables
  560. // we need for crosscompilation; but remember if we asked
  561. // for it.
  562. dictionary[ "CETEST_REQUESTED" ] = "yes";
  563. }
  564. // Qt/CE - signing tool -------------------------------------
  565. else if (configCmdLine.at(i) == "-signature") {
  566. ++i;
  567. if (i == argCount)
  568. break;
  569. QFileInfo info(configCmdLine.at(i));
  570. if (!info.exists())
  571. cout << "WARNING: Could not find signature file (" << qPrintable(configCmdLine.at(i)) << ")" << endl;
  572. else
  573. dictionary[ "CE_SIGNATURE" ] = QDir::toNativeSeparators(info.absoluteFilePath());
  574. }
  575. // Styles ---------------------------------------------------
  576. else if (configCmdLine.at(i) == "-qt-style-windows")
  577. dictionary[ "STYLE_WINDOWS" ] = "yes";
  578. else if (configCmdLine.at(i) == "-no-style-windows")
  579. dictionary[ "STYLE_WINDOWS" ] = "no";
  580. else if (configCmdLine.at(i) == "-qt-style-windowsce")
  581. dictionary[ "STYLE_WINDOWSCE" ] = "yes";
  582. else if (configCmdLine.at(i) == "-no-style-windowsce")
  583. dictionary[ "STYLE_WINDOWSCE" ] = "no";
  584. else if (configCmdLine.at(i) == "-qt-style-windowsmobile")
  585. dictionary[ "STYLE_WINDOWSMOBILE" ] = "yes";
  586. else if (configCmdLine.at(i) == "-no-style-windowsmobile")
  587. dictionary[ "STYLE_WINDOWSMOBILE" ] = "no";
  588. else if (configCmdLine.at(i) == "-qt-style-windowsxp")
  589. dictionary[ "STYLE_WINDOWSXP" ] = "yes";
  590. else if (configCmdLine.at(i) == "-no-style-windowsxp")
  591. dictionary[ "STYLE_WINDOWSXP" ] = "no";
  592. else if (configCmdLine.at(i) == "-qt-style-windowsvista")
  593. dictionary[ "STYLE_WINDOWSVISTA" ] = "yes";
  594. else if (configCmdLine.at(i) == "-no-style-windowsvista")
  595. dictionary[ "STYLE_WINDOWSVISTA" ] = "no";
  596. else if (configCmdLine.at(i) == "-qt-style-fusion")
  597. dictionary[ "STYLE_FUSION" ] = "yes";
  598. else if (configCmdLine.at(i) == "-no-style-fusion")
  599. dictionary[ "STYLE_FUSION" ] = "no";
  600. // Work around compiler nesting limitation
  601. else
  602. continueElse[1] = true;
  603. if (!continueElse[1]) {
  604. }
  605. // OpenGL Support -------------------------------------------
  606. else if (configCmdLine.at(i) == "-no-opengl") {
  607. dictionary[ "OPENGL" ] = "no";
  608. dictionary[ "OPENGL_ES_2" ] = "no";
  609. } else if (configCmdLine.at(i) == "-opengl-es-2") {
  610. dictionary[ "OPENGL" ] = "yes";
  611. dictionary[ "OPENGL_ES_2" ] = "yes";
  612. } else if (configCmdLine.at(i) == "-opengl") {
  613. dictionary[ "OPENGL" ] = "yes";
  614. i++;
  615. if (i == argCount)
  616. break;
  617. dictionary[ "OPENGL_ES_2" ] = "no";
  618. if ( configCmdLine.at(i) == "es2" ) {
  619. dictionary[ "OPENGL_ES_2" ] = "yes";
  620. } else if ( configCmdLine.at(i) == "desktop" ) {
  621. // OPENGL=yes suffices
  622. } else if ( configCmdLine.at(i) == "dynamic" ) {
  623. dictionary[ "DYNAMICGL" ] = "yes";
  624. } else {
  625. cout << "Argument passed to -opengl option is not valid." << endl;
  626. dictionary[ "DONE" ] = "error";
  627. break;
  628. }
  629. }
  630. // OpenVG Support -------------------------------------------
  631. else if (configCmdLine.at(i) == "-openvg") {
  632. dictionary[ "OPENVG" ] = "yes";
  633. } else if (configCmdLine.at(i) == "-no-openvg") {
  634. dictionary[ "OPENVG" ] = "no";
  635. }
  636. // Databases ------------------------------------------------
  637. else if (configCmdLine.at(i) == "-qt-sql-mysql")
  638. dictionary[ "SQL_MYSQL" ] = "yes";
  639. else if (configCmdLine.at(i) == "-plugin-sql-mysql")
  640. dictionary[ "SQL_MYSQL" ] = "plugin";
  641. else if (configCmdLine.at(i) == "-no-sql-mysql")
  642. dictionary[ "SQL_MYSQL" ] = "no";
  643. else if (configCmdLine.at(i) == "-qt-sql-odbc")
  644. dictionary[ "SQL_ODBC" ] = "yes";
  645. else if (configCmdLine.at(i) == "-plugin-sql-odbc")
  646. dictionary[ "SQL_ODBC" ] = "plugin";
  647. else if (configCmdLine.at(i) == "-no-sql-odbc")
  648. dictionary[ "SQL_ODBC" ] = "no";
  649. else if (configCmdLine.at(i) == "-qt-sql-oci")
  650. dictionary[ "SQL_OCI" ] = "yes";
  651. else if (configCmdLine.at(i) == "-plugin-sql-oci")
  652. dictionary[ "SQL_OCI" ] = "plugin";
  653. else if (configCmdLine.at(i) == "-no-sql-oci")
  654. dictionary[ "SQL_OCI" ] = "no";
  655. else if (configCmdLine.at(i) == "-qt-sql-psql")
  656. dictionary[ "SQL_PSQL" ] = "yes";
  657. else if (configCmdLine.at(i) == "-plugin-sql-psql")
  658. dictionary[ "SQL_PSQL" ] = "plugin";
  659. else if (configCmdLine.at(i) == "-no-sql-psql")
  660. dictionary[ "SQL_PSQL" ] = "no";
  661. else if (configCmdLine.at(i) == "-qt-sql-tds")
  662. dictionary[ "SQL_TDS" ] = "yes";
  663. else if (configCmdLine.at(i) == "-plugin-sql-tds")
  664. dictionary[ "SQL_TDS" ] = "plugin";
  665. else if (configCmdLine.at(i) == "-no-sql-tds")
  666. dictionary[ "SQL_TDS" ] = "no";
  667. else if (configCmdLine.at(i) == "-qt-sql-db2")
  668. dictionary[ "SQL_DB2" ] = "yes";
  669. else if (configCmdLine.at(i) == "-plugin-sql-db2")
  670. dictionary[ "SQL_DB2" ] = "plugin";
  671. else if (configCmdLine.at(i) == "-no-sql-db2")
  672. dictionary[ "SQL_DB2" ] = "no";
  673. else if (configCmdLine.at(i) == "-qt-sql-sqlite")
  674. dictionary[ "SQL_SQLITE" ] = "yes";
  675. else if (configCmdLine.at(i) == "-plugin-sql-sqlite")
  676. dictionary[ "SQL_SQLITE" ] = "plugin";
  677. else if (configCmdLine.at(i) == "-no-sql-sqlite")
  678. dictionary[ "SQL_SQLITE" ] = "no";
  679. else if (configCmdLine.at(i) == "-system-sqlite")
  680. dictionary[ "SQL_SQLITE_LIB" ] = "system";
  681. else if (configCmdLine.at(i) == "-qt-sql-sqlite2")
  682. dictionary[ "SQL_SQLITE2" ] = "yes";
  683. else if (configCmdLine.at(i) == "-plugin-sql-sqlite2")
  684. dictionary[ "SQL_SQLITE2" ] = "plugin";
  685. else if (configCmdLine.at(i) == "-no-sql-sqlite2")
  686. dictionary[ "SQL_SQLITE2" ] = "no";
  687. else if (configCmdLine.at(i) == "-qt-sql-ibase")
  688. dictionary[ "SQL_IBASE" ] = "yes";
  689. else if (configCmdLine.at(i) == "-plugin-sql-ibase")
  690. dictionary[ "SQL_IBASE" ] = "plugin";
  691. else if (configCmdLine.at(i) == "-no-sql-ibase")
  692. dictionary[ "SQL_IBASE" ] = "no";
  693. // Image formats --------------------------------------------
  694. else if (configCmdLine.at(i).startsWith("-qt-imageformat-") &&
  695. imageFormats.contains(configCmdLine.at(i).section('-', 3)))
  696. dictionary[ configCmdLine.at(i).section('-', 3).toUpper() ] = "yes";
  697. else if (configCmdLine.at(i).startsWith("-plugin-imageformat-") &&
  698. imageFormats.contains(configCmdLine.at(i).section('-', 3)))
  699. dictionary[ configCmdLine.at(i).section('-', 3).toUpper() ] = "plugin";
  700. else if (configCmdLine.at(i).startsWith("-no-imageformat-") &&
  701. imageFormats.contains(configCmdLine.at(i).section('-', 3)))
  702. dictionary[ configCmdLine.at(i).section('-', 3).toUpper() ] = "no";
  703. // IDE project generation -----------------------------------
  704. else if (configCmdLine.at(i) == "-no-vcproj")
  705. dictionary[ "VCPROJFILES" ] = "no";
  706. else if (configCmdLine.at(i) == "-vcproj")
  707. dictionary[ "VCPROJFILES" ] = "yes";
  708. else if (configCmdLine.at(i) == "-no-incredibuild-xge")
  709. dictionary[ "INCREDIBUILD_XGE" ] = "no";
  710. else if (configCmdLine.at(i) == "-incredibuild-xge")
  711. dictionary[ "INCREDIBUILD_XGE" ] = "yes";
  712. else if (configCmdLine.at(i) == "-native-gestures")
  713. dictionary[ "NATIVE_GESTURES" ] = "yes";
  714. else if (configCmdLine.at(i) == "-no-native-gestures")
  715. dictionary[ "NATIVE_GESTURES" ] = "no";
  716. // Others ---------------------------------------------------
  717. else if (configCmdLine.at(i) == "-widgets")
  718. dictionary[ "WIDGETS" ] = "yes";
  719. else if (configCmdLine.at(i) == "-no-widgets")
  720. dictionary[ "WIDGETS" ] = "no";
  721. else if (configCmdLine.at(i) == "-gui")
  722. dictionary[ "GUI" ] = "yes";
  723. else if (configCmdLine.at(i) == "-no-gui")
  724. dictionary[ "GUI" ] = "no";
  725. else if (configCmdLine.at(i) == "-rtti")
  726. dictionary[ "RTTI" ] = "yes";
  727. else if (configCmdLine.at(i) == "-no-rtti")
  728. dictionary[ "RTTI" ] = "no";
  729. else if (configCmdLine.at(i) == "-strip")
  730. dictionary[ "STRIP" ] = "yes";
  731. else if (configCmdLine.at(i) == "-no-strip")
  732. dictionary[ "STRIP" ] = "no";
  733. else if (configCmdLine.at(i) == "-accessibility")
  734. dictionary[ "ACCESSIBILITY" ] = "yes";
  735. else if (configCmdLine.at(i) == "-no-accessibility") {
  736. dictionary[ "ACCESSIBILITY" ] = "no";
  737. cout << "Setting accessibility to NO" << endl;
  738. }
  739. else if (configCmdLine.at(i) == "-no-sse2")
  740. dictionary[ "SSE2" ] = "no";
  741. else if (configCmdLine.at(i) == "-sse2")
  742. dictionary[ "SSE2" ] = "yes";
  743. else if (configCmdLine.at(i) == "-no-sse3")
  744. dictionary[ "SSE3" ] = "no";
  745. else if (configCmdLine.at(i) == "-sse3")
  746. dictionary[ "SSE3" ] = "yes";
  747. else if (configCmdLine.at(i) == "-no-ssse3")
  748. dictionary[ "SSSE3" ] = "no";
  749. else if (configCmdLine.at(i) == "-ssse3")
  750. dictionary[ "SSSE3" ] = "yes";
  751. else if (configCmdLine.at(i) == "-no-sse4.1")
  752. dictionary[ "SSE4_1" ] = "no";
  753. else if (configCmdLine.at(i) == "-sse4.1")
  754. dictionary[ "SSE4_1" ] = "yes";
  755. else if (configCmdLine.at(i) == "-no-sse4.2")
  756. dictionary[ "SSE4_2" ] = "no";
  757. else if (configCmdLine.at(i) == "-sse4.2")
  758. dictionary[ "SSE4_2" ] = "yes";
  759. else if (configCmdLine.at(i) == "-no-avx")
  760. dictionary[ "AVX" ] = "no";
  761. else if (configCmdLine.at(i) == "-avx")
  762. dictionary[ "AVX" ] = "yes";
  763. else if (configCmdLine.at(i) == "-no-avx2")
  764. dictionary[ "AVX2" ] = "no";
  765. else if (configCmdLine.at(i) == "-avx2")
  766. dictionary[ "AVX2" ] = "yes";
  767. else if (configCmdLine.at(i) == "-no-iwmmxt")
  768. dictionary[ "IWMMXT" ] = "no";
  769. else if (configCmdLine.at(i) == "-iwmmxt")
  770. dictionary[ "IWMMXT" ] = "yes";
  771. else if (configCmdLine.at(i) == "-no-openssl") {
  772. dictionary[ "OPENSSL"] = "no";
  773. } else if (configCmdLine.at(i) == "-openssl") {
  774. dictionary[ "OPENSSL" ] = "yes";
  775. } else if (configCmdLine.at(i) == "-openssl-linked") {
  776. dictionary[ "OPENSSL" ] = "linked";
  777. } else if (configCmdLine.at(i) == "-no-qdbus") {
  778. dictionary[ "DBUS" ] = "no";
  779. } else if (configCmdLine.at(i) == "-qdbus") {
  780. dictionary[ "DBUS" ] = "yes";
  781. } else if (configCmdLine.at(i) == "-no-dbus") {
  782. dictionary[ "DBUS" ] = "no";
  783. } else if (configCmdLine.at(i) == "-dbus") {
  784. dictionary[ "DBUS" ] = "yes";
  785. } else if (configCmdLine.at(i) == "-dbus-linked") {
  786. dictionary[ "DBUS" ] = "linked";
  787. } else if (configCmdLine.at(i) == "-audio-backend") {
  788. dictionary[ "AUDIO_BACKEND" ] = "yes";
  789. } else if (configCmdLine.at(i) == "-no-audio-backend") {
  790. dictionary[ "AUDIO_BACKEND" ] = "no";
  791. } else if (configCmdLine.at(i) == "-wmf-backend") {
  792. dictionary[ "WMF_BACKEND" ] = "yes";
  793. } else if (configCmdLine.at(i) == "-no-wmf-backend") {
  794. dictionary[ "WMF_BACKEND" ] = "no";
  795. } else if (configCmdLine.at(i) == "-no-qml-debug") {
  796. dictionary[ "QML_DEBUG" ] = "no";
  797. } else if (configCmdLine.at(i) == "-qml-debug") {
  798. dictionary[ "QML_DEBUG" ] = "yes";
  799. } else if (configCmdLine.at(i) == "-no-plugin-manifests") {
  800. dictionary[ "PLUGIN_MANIFESTS" ] = "no";
  801. } else if (configCmdLine.at(i) == "-plugin-manifests") {
  802. dictionary[ "PLUGIN_MANIFESTS" ] = "yes";
  803. } else if (configCmdLine.at(i) == "-no-slog2") {
  804. dictionary[ "SLOG2" ] = "no";
  805. } else if (configCmdLine.at(i) == "-slog2") {
  806. dictionary[ "SLOG2" ] = "yes";
  807. } else if (configCmdLine.at(i) == "-no-imf") {
  808. dictionary[ "QNX_IMF" ] = "no";
  809. } else if (configCmdLine.at(i) == "-imf") {
  810. dictionary[ "QNX_IMF" ] = "yes";
  811. } else if (configCmdLine.at(i) == "-no-pps") {
  812. dictionary[ "PPS" ] = "no";
  813. } else if (configCmdLine.at(i) == "-pps") {
  814. dictionary[ "PPS" ] = "yes";
  815. } else if (configCmdLine.at(i) == "-no-lgmon") {
  816. dictionary[ "LGMON" ] = "no";
  817. } else if (configCmdLine.at(i) == "-lgmon") {
  818. dictionary[ "LGMON" ] = "yes";
  819. } else if (configCmdLine.at(i) == "-no-system-proxies") {
  820. dictionary[ "SYSTEM_PROXIES" ] = "no";
  821. } else if (configCmdLine.at(i) == "-system-proxies") {
  822. dictionary[ "SYSTEM_PROXIES" ] = "yes";
  823. } else if (configCmdLine.at(i) == "-warnings-are-errors" ||
  824. configCmdLine.at(i) == "-Werror") {
  825. dictionary[ "WERROR" ] = "yes";
  826. } else if (configCmdLine.at(i) == "-no-warnings-are-errors") {
  827. dictionary[ "WERROR" ] = "no";
  828. } else if (configCmdLine.at(i) == "-no-eventfd") {
  829. dictionary[ "QT_EVENTFD" ] = "no";
  830. } else if (configCmdLine.at(i) == "-eventfd") {
  831. dictionary[ "QT_EVENTFD" ] = "yes";
  832. }
  833. // Work around compiler nesting limitation
  834. else
  835. continueElse[0] = true;
  836. if (!continueElse[0]) {
  837. }
  838. else if (configCmdLine.at(i) == "-internal")
  839. dictionary[ "QMAKE_INTERNAL" ] = "yes";
  840. else if (configCmdLine.at(i) == "-no-syncqt")
  841. dictionary[ "SYNCQT" ] = "no";
  842. else if (configCmdLine.at(i) == "-no-qmake")
  843. dictionary[ "BUILD_QMAKE" ] = "no";
  844. else if (configCmdLine.at(i) == "-qmake")
  845. dictionary[ "BUILD_QMAKE" ] = "yes";
  846. else if (configCmdLine.at(i) == "-dont-process")
  847. dictionary[ "PROCESS" ] = "no";
  848. else if (configCmdLine.at(i) == "-process")
  849. dictionary[ "PROCESS" ] = "partial";
  850. else if (configCmdLine.at(i) == "-fully-process")
  851. dictionary[ "PROCESS" ] = "full";
  852. else if (configCmdLine.at(i) == "-no-qmake-deps")
  853. dictionary[ "DEPENDENCIES" ] = "no";
  854. else if (configCmdLine.at(i) == "-qmake-deps")
  855. dictionary[ "DEPENDENCIES" ] = "yes";
  856. else if (configCmdLine.at(i) == "-qtnamespace") {
  857. ++i;
  858. if (i == argCount)
  859. break;
  860. dictionary[ "QT_NAMESPACE" ] = configCmdLine.at(i);
  861. } else if (configCmdLine.at(i) == "-qtlibinfix") {
  862. ++i;
  863. if (i == argCount)
  864. break;
  865. dictionary[ "QT_LIBINFIX" ] = configCmdLine.at(i);
  866. } else if (configCmdLine.at(i) == "-D") {
  867. ++i;
  868. if (i == argCount)
  869. break;
  870. qmakeDefines += configCmdLine.at(i);
  871. } else if (configCmdLine.at(i) == "-I") {
  872. ++i;
  873. if (i == argCount)
  874. break;
  875. qmakeIncludes += configCmdLine.at(i);
  876. } else if (configCmdLine.at(i) == "-L") {
  877. ++i;
  878. if (i == argCount)
  879. break;
  880. QFileInfo checkDirectory(configCmdLine.at(i));
  881. if (!checkDirectory.isDir()) {
  882. cout << "Argument passed to -L option is not a directory path. Did you mean the -l option?" << endl;
  883. dictionary[ "DONE" ] = "error";
  884. break;
  885. }
  886. qmakeLibs += QString("-L" + configCmdLine.at(i));
  887. } else if (configCmdLine.at(i) == "-l") {
  888. ++i;
  889. if (i == argCount)
  890. break;
  891. qmakeLibs += QString("-l" + configCmdLine.at(i));
  892. } else if (configCmdLine.at(i).startsWith("OPENSSL_LIBS=")) {
  893. opensslLibs = configCmdLine.at(i);
  894. } else if (configCmdLine.at(i).startsWith("OPENSSL_LIBS_DEBUG=")) {
  895. opensslLibsDebug = configCmdLine.at(i);
  896. } else if (configCmdLine.at(i).startsWith("OPENSSL_LIBS_RELEASE=")) {
  897. opensslLibsRelease = configCmdLine.at(i);
  898. } else if (configCmdLine.at(i).startsWith("OPENSSL_PATH=")) {
  899. opensslPath = QDir::fromNativeSeparators(configCmdLine.at(i).section("=", 1));
  900. } else if (configCmdLine.at(i).startsWith("PSQL_LIBS=")) {
  901. psqlLibs = configCmdLine.at(i);
  902. } else if (configCmdLine.at(i).startsWith("SYBASE=")) {
  903. sybase = configCmdLine.at(i);
  904. } else if (configCmdLine.at(i).startsWith("SYBASE_LIBS=")) {
  905. sybaseLibs = configCmdLine.at(i);
  906. } else if (configCmdLine.at(i).startsWith("DBUS_PATH=")) {
  907. dbusPath = QDir::fromNativeSeparators(configCmdLine.at(i).section("=", 1));
  908. } else if (configCmdLine.at(i).startsWith("MYSQL_PATH=")) {
  909. mysqlPath = QDir::fromNativeSeparators(configCmdLine.at(i).section("=", 1));
  910. } else if (configCmdLine.at(i).startsWith("ZLIB_LIBS=")) {
  911. zlibLibs = QDir::fromNativeSeparators(configCmdLine.at(i));
  912. }
  913. else if ((configCmdLine.at(i) == "-override-version") || (configCmdLine.at(i) == "-version-override")){
  914. ++i;
  915. if (i == argCount)
  916. break;
  917. dictionary[ "VERSION" ] = configCmdLine.at(i);
  918. }
  919. else if (configCmdLine.at(i) == "-saveconfig") {
  920. ++i;
  921. if (i == argCount)
  922. break;
  923. dictionary[ "CUSTOMCONFIG" ] = "_" + configCmdLine.at(i);
  924. }
  925. else if (configCmdLine.at(i) == "-confirm-license") {
  926. dictionary["LICENSE_CONFIRMED"] = "yes";
  927. }
  928. else if (configCmdLine.at(i) == "-make") {
  929. ++i;
  930. if (i == argCount)
  931. break;
  932. QString part = configCmdLine.at(i);
  933. if (!allBuildParts.contains(part)) {
  934. cout << "Unknown part " << part << " passed to -make." << endl;
  935. dictionary["DONE"] = "error";
  936. }
  937. buildParts += part;
  938. } else if (configCmdLine.at(i) == "-nomake") {
  939. ++i;
  940. if (i == argCount)
  941. break;
  942. QString part = configCmdLine.at(i);
  943. if (!allBuildParts.contains(part)) {
  944. cout << "Unknown part " << part << " passed to -nomake." << endl;
  945. dictionary["DONE"] = "error";
  946. }
  947. nobuildParts += part;
  948. }
  949. else if (configCmdLine.at(i) == "-skip") {
  950. ++i;
  951. if (i == argCount)
  952. break;
  953. QString mod = configCmdLine.at(i);
  954. if (!mod.startsWith(QStringLiteral("qt")))
  955. mod.insert(0, QStringLiteral("qt"));
  956. if (!QFileInfo(sourcePath + "/../" + mod).isDir()) {
  957. cout << "Attempting to skip non-existent module " << mod << "." << endl;
  958. dictionary["DONE"] = "error";
  959. }
  960. skipModules += mod;
  961. }
  962. // Directories ----------------------------------------------
  963. else if (configCmdLine.at(i) == "-prefix") {
  964. ++i;
  965. if (i == argCount)
  966. break;
  967. dictionary[ "QT_INSTALL_PREFIX" ] = configCmdLine.at(i);
  968. }
  969. else if (configCmdLine.at(i) == "-bindir") {
  970. ++i;
  971. if (i == argCount)
  972. break;
  973. dictionary[ "QT_INSTALL_BINS" ] = configCmdLine.at(i);
  974. }
  975. else if (configCmdLine.at(i) == "-libexecdir") {
  976. ++i;
  977. if (i == argCount)
  978. break;
  979. dictionary[ "QT_INSTALL_LIBEXECS" ] = configCmdLine.at(i);
  980. }
  981. else if (configCmdLine.at(i) == "-libdir") {
  982. ++i;
  983. if (i == argCount)
  984. break;
  985. dictionary[ "QT_INSTALL_LIBS" ] = configCmdLine.at(i);
  986. }
  987. else if (configCmdLine.at(i) == "-docdir") {
  988. ++i;
  989. if (i == argCount)
  990. break;
  991. dictionary[ "QT_INSTALL_DOCS" ] = configCmdLine.at(i);
  992. }
  993. else if (configCmdLine.at(i) == "-headerdir") {
  994. ++i;
  995. if (i == argCount)
  996. break;
  997. dictionary[ "QT_INSTALL_HEADERS" ] = configCmdLine.at(i);
  998. }
  999. else if (configCmdLine.at(i) == "-plugindir") {
  1000. ++i;
  1001. if (i == argCount)
  1002. break;
  1003. dictionary[ "QT_INSTALL_PLUGINS" ] = configCmdLine.at(i);
  1004. }
  1005. else if (configCmdLine.at(i) == "-importdir") {
  1006. ++i;
  1007. if (i == argCount)
  1008. break;
  1009. dictionary[ "QT_INSTALL_IMPORTS" ] = configCmdLine.at(i);
  1010. }
  1011. else if (configCmdLine.at(i) == "-qmldir") {
  1012. ++i;
  1013. if (i == argCount)
  1014. break;
  1015. dictionary[ "QT_INSTALL_QML" ] = configCmdLine.at(i);
  1016. }
  1017. else if (configCmdLine.at(i) == "-archdatadir") {
  1018. ++i;
  1019. if (i == argCount)
  1020. break;
  1021. dictionary[ "QT_INSTALL_ARCHDATA" ] = configCmdLine.at(i);
  1022. }
  1023. else if (configCmdLine.at(i) == "-datadir") {
  1024. ++i;
  1025. if (i == argCount)
  1026. break;
  1027. dictionary[ "QT_INSTALL_DATA" ] = configCmdLine.at(i);
  1028. }
  1029. else if (configCmdLine.at(i) == "-translationdir") {
  1030. ++i;
  1031. if (i == argCount)
  1032. break;
  1033. dictionary[ "QT_INSTALL_TRANSLATIONS" ] = configCmdLine.at(i);
  1034. }
  1035. else if (configCmdLine.at(i) == "-examplesdir") {
  1036. ++i;
  1037. if (i == argCount)
  1038. break;
  1039. dictionary[ "QT_INSTALL_EXAMPLES" ] = configCmdLine.at(i);
  1040. }
  1041. else if (configCmdLine.at(i) == "-testsdir") {
  1042. ++i;
  1043. if (i == argCount)
  1044. break;
  1045. dictionary[ "QT_INSTALL_TESTS" ] = configCmdLine.at(i);
  1046. }
  1047. else if (configCmdLine.at(i) == "-sysroot") {
  1048. ++i;
  1049. if (i == argCount)
  1050. break;
  1051. dictionary[ "CFG_SYSROOT" ] = configCmdLine.at(i);
  1052. }
  1053. else if (configCmdLine.at(i) == "-no-gcc-sysroot") {
  1054. dictionary[ "CFG_GCC_SYSROOT" ] = "no";
  1055. }
  1056. else if (configCmdLine.at(i) == "-hostprefix") {
  1057. ++i;
  1058. if (i == argCount || configCmdLine.at(i).startsWith('-'))
  1059. dictionary[ "QT_HOST_PREFIX" ] = buildPath;
  1060. else
  1061. dictionary[ "QT_HOST_PREFIX" ] = configCmdLine.at(i);
  1062. }
  1063. else if (configCmdLine.at(i) == "-hostbindir") {
  1064. ++i;
  1065. if (i == argCount)
  1066. break;
  1067. dictionary[ "QT_HOST_BINS" ] = configCmdLine.at(i);
  1068. }
  1069. else if (configCmdLine.at(i) == "-hostlibdir") {
  1070. ++i;
  1071. if (i == argCount)
  1072. break;
  1073. dictionary[ "QT_HOST_LIBS" ] = configCmdLine.at(i);
  1074. }
  1075. else if (configCmdLine.at(i) == "-hostdatadir") {
  1076. ++i;
  1077. if (i == argCount)
  1078. break;
  1079. dictionary[ "QT_HOST_DATA" ] = configCmdLine.at(i);
  1080. }
  1081. else if (configCmdLine.at(i) == "-extprefix") {
  1082. ++i;
  1083. if (i == argCount)
  1084. break;
  1085. dictionary[ "QT_EXT_PREFIX" ] = configCmdLine.at(i);
  1086. }
  1087. else if (configCmdLine.at(i) == "-make-tool") {
  1088. ++i;
  1089. if (i == argCount)
  1090. break;
  1091. dictionary[ "MAKE" ] = configCmdLine.at(i);
  1092. }
  1093. else if (configCmdLine.at(i).indexOf(QRegExp("^-(en|dis)able-")) != -1) {
  1094. // Scan to see if any specific modules and drivers are enabled or disabled
  1095. for (QStringList::Iterator module = modules.begin(); module != modules.end(); ++module) {
  1096. if (configCmdLine.at(i) == QString("-enable-") + (*module)) {
  1097. enabledModules += (*module);
  1098. break;
  1099. }
  1100. else if (configCmdLine.at(i) == QString("-disable-") + (*module)) {
  1101. disabledModules += (*module);
  1102. break;
  1103. }
  1104. }
  1105. }
  1106. else if (configCmdLine.at(i) == "-directwrite") {
  1107. dictionary["DIRECTWRITE"] = "yes";
  1108. } else if (configCmdLine.at(i) == "-no-directwrite") {
  1109. dictionary["DIRECTWRITE"] = "no";
  1110. }
  1111. else if (configCmdLine.at(i) == "-direct2d") {
  1112. dictionary["DIRECT2D"] = "yes";
  1113. } else if (configCmdLine.at(i) == "-no-direct2d") {
  1114. dictionary["DIRECT2D"] = "no";
  1115. }
  1116. else if (configCmdLine.at(i) == "-nis") {
  1117. dictionary["NIS"] = "yes";
  1118. } else if (configCmdLine.at(i) == "-no-nis") {
  1119. dictionary["NIS"] = "no";
  1120. }
  1121. else if (configCmdLine.at(i) == "-cups") {
  1122. dictionary["QT_CUPS"] = "yes";
  1123. } else if (configCmdLine.at(i) == "-no-cups") {
  1124. dictionary["QT_CUPS"] = "no";
  1125. }
  1126. else if (configCmdLine.at(i) == "-iconv") {
  1127. dictionary["QT_ICONV"] = "yes";
  1128. } else if (configCmdLine.at(i) == "-no-iconv") {
  1129. dictionary["QT_ICONV"] = "no";
  1130. } else if (configCmdLine.at(i) == "-sun-iconv") {
  1131. dictionary["QT_ICONV"] = "sun";
  1132. } else if (configCmdLine.at(i) == "-gnu-iconv") {
  1133. dictionary["QT_ICONV"] = "gnu";
  1134. }
  1135. else if (configCmdLine.at(i) == "-no-evdev") {
  1136. dictionary[ "QT_EVDEV" ] = "no";
  1137. } else if (configCmdLine.at(i) == "-evdev") {
  1138. dictionary[ "QT_EVDEV" ] = "yes";
  1139. }
  1140. else if (configCmdLine.at(i) == "-no-mtdev") {
  1141. dictionary[ "QT_MTDEV" ] = "no";
  1142. } else if (configCmdLine.at(i) == "-mtdev") {
  1143. dictionary[ "QT_MTDEV" ] = "yes";
  1144. }
  1145. else if (configCmdLine.at(i) == "-inotify") {
  1146. dictionary["QT_INOTIFY"] = "yes";
  1147. } else if (configCmdLine.at(i) == "-no-inotify") {
  1148. dictionary["QT_INOTIFY"] = "no";
  1149. }
  1150. else if (configCmdLine.at(i) == "-neon") {
  1151. dictionary["NEON"] = "yes";
  1152. } else if (configCmdLine.at(i) == "-no-neon") {
  1153. dictionary["NEON"] = "no";
  1154. }
  1155. else if (configCmdLine.at(i) == "-largefile") {
  1156. dictionary["LARGE_FILE"] = "yes";
  1157. }
  1158. else if (configCmdLine.at(i) == "-fontconfig") {
  1159. dictionary["FONT_CONFIG"] = "yes";
  1160. } else if (configCmdLine.at(i) == "-no-fontconfig") {
  1161. dictionary["FONT_CONFIG"] = "no";
  1162. }
  1163. else if (configCmdLine.at(i) == "-posix-ipc") {
  1164. dictionary["POSIX_IPC"] = "yes";
  1165. }
  1166. else if (configCmdLine.at(i) == "-glib") {
  1167. dictionary["QT_GLIB"] = "yes";
  1168. }
  1169. else if (configCmdLine.at(i) == "-sysconfdir") {
  1170. ++i;
  1171. if (i == argCount)
  1172. break;
  1173. dictionary["QT_INSTALL_SETTINGS"] = configCmdLine.at(i);
  1174. }
  1175. else if (configCmdLine.at(i) == "-android-ndk") {
  1176. ++i;
  1177. if (i == argCount)
  1178. break;
  1179. dictionary[ "ANDROID_NDK_ROOT" ] = configCmdLine.at(i);
  1180. }
  1181. else if (configCmdLine.at(i) == "-android-sdk") {
  1182. ++i;
  1183. if (i == argCount)
  1184. break;
  1185. dictionary[ "ANDROID_SDK_ROOT" ] = configCmdLine.at(i);
  1186. }
  1187. else if (configCmdLine.at(i) == "-android-ndk-platform") {
  1188. ++i;
  1189. if (i == argCount)
  1190. break;
  1191. dictionary[ "ANDROID_PLATFORM" ] = configCmdLine.at(i);
  1192. }
  1193. else if (configCmdLine.at(i) == "-android-arch") {
  1194. ++i;
  1195. if (i == argCount)
  1196. break;
  1197. dictionary[ "ANDROID_TARGET_ARCH" ] = configCmdLine.at(i);
  1198. }
  1199. else if (configCmdLine.at(i) == "-android-toolchain-version") {
  1200. ++i;
  1201. if (i == argCount)
  1202. break;
  1203. dictionary[ "ANDROID_NDK_TOOLCHAIN_VERSION" ] = configCmdLine.at(i);
  1204. }
  1205. else {
  1206. dictionary[ "DONE" ] = "error";
  1207. cout << "Unknown option " << configCmdLine.at(i) << endl;
  1208. break;
  1209. }
  1210. }
  1211. // Ensure that QMAKESPEC exists in the mkspecs folder
  1212. const QString mkspecPath(sourcePath + "/mkspecs");
  1213. QDirIterator itMkspecs(mkspecPath, QDir::AllDirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
  1214. QStringList mkspecs;
  1215. while (itMkspecs.hasNext()) {
  1216. QString mkspec = itMkspecs.next();
  1217. // Remove base PATH
  1218. mkspec.remove(0, mkspecPath.length() + 1);
  1219. mkspecs << mkspec;
  1220. }
  1221. if (dictionary["QMAKESPEC"].toLower() == "features"
  1222. || !mkspecs.contains(dictionary["QMAKESPEC"], Qt::CaseInsensitive)) {
  1223. dictionary[ "DONE" ] = "error";
  1224. if (dictionary ["QMAKESPEC_FROM"] == "commandline") {
  1225. cout << "Invalid option \"" << dictionary["QMAKESPEC"] << "\" for -platform." << endl;
  1226. } else if (dictionary ["QMAKESPEC_FROM"] == "env") {
  1227. cout << "QMAKESPEC environment variable is set to \"" << dictionary["QMAKESPEC"]
  1228. << "\" which is not a supported platform" << endl;
  1229. } else { // was autodetected from environment
  1230. cout << "Unable to detect the platform from environment. Use -platform command line"
  1231. "argument or set the QMAKESPEC environment variable and run configure again" << endl;
  1232. }
  1233. cout << "See the README file for a list of supported operating systems and compilers." << endl;
  1234. } else {
  1235. if (dictionary[ "QMAKESPEC" ].endsWith("-icc") ||
  1236. dictionary[ "QMAKESPEC" ].endsWith("-msvc") ||
  1237. dictionary[ "QMAKESPEC" ].endsWith("-msvc.net") ||
  1238. dictionary[ "QMAKESPEC" ].endsWith("-msvc2002") ||
  1239. dictionary[ "QMAKESPEC" ].endsWith("-msvc2003") ||
  1240. dictionary[ "QMAKESPEC" ].endsWith("-msvc2005") ||
  1241. dictionary[ "QMAKESPEC" ].endsWith("-msvc2008") ||
  1242. dictionary[ "QMAKESPEC" ].endsWith("-msvc2010") ||
  1243. dictionary[ "QMAKESPEC" ].endsWith("-msvc2012") ||
  1244. dictionary[ "QMAKESPEC" ].endsWith("-msvc2013")) {
  1245. if (dictionary[ "MAKE" ].isEmpty()) dictionary[ "MAKE" ] = "nmake";
  1246. dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32";
  1247. } else if (dictionary[ "QMAKESPEC" ] == QString("win32-g++")) {
  1248. if (dictionary[ "MAKE" ].isEmpty()) dictionary[ "MAKE" ] = "mingw32-make";
  1249. dictionary[ "QMAKEMAKEFILE" ] = "Makefile.unix";
  1250. } else {
  1251. if (dictionary[ "MAKE" ].isEmpty()) dictionary[ "MAKE" ] = "make";
  1252. dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32";
  1253. }
  1254. }
  1255. if (isDeviceMkspec) {
  1256. const QStringList devices = mkspecs.filter("devices/", Qt::CaseInsensitive);
  1257. const QStringList family = devices.filter(dictionary["XQMAKESPEC"], Qt::CaseInsensitive);
  1258. if (family.isEmpty()) {
  1259. dictionary[ "DONE" ] = "error";
  1260. cout << "Error: No device matching '" << dictionary["XQMAKESPEC"] << "'." << endl;
  1261. } else if (family.size() > 1) {
  1262. dictionary[ "DONE" ] = "error";
  1263. cout << "Error: Multiple matches for device '" << dictionary["XQMAKESPEC"] << "'. Candidates are:" << endl;
  1264. foreach (const QString &device, family)
  1265. cout << "\t* " << device << endl;
  1266. } else {
  1267. Q_ASSERT(family.size() == 1);
  1268. dictionary["XQMAKESPEC"] = family.at(0);
  1269. }
  1270. } else {
  1271. // Ensure that -spec (XQMAKESPEC) exists in the mkspecs folder as well
  1272. if (dictionary.contains("XQMAKESPEC") &&
  1273. !mkspecs.contains(dictionary["XQMAKESPEC"], Qt::CaseInsensitive)) {
  1274. dictionary[ "DONE" ] = "error";
  1275. cout << "Invalid option \"" << dictionary["XQMAKESPEC"] << "\" for -xplatform." << endl;
  1276. }
  1277. }
  1278. // Ensure that the crt to be deployed can be found
  1279. if (dictionary["CE_CRT"] != QLatin1String("yes") && dictionary["CE_CRT"] != QLatin1String("no")) {
  1280. QDir cDir(dictionary["CE_CRT"]);
  1281. QStringList entries = cDir.entryList();
  1282. bool hasDebug = entries.contains("msvcr80.dll");
  1283. bool hasRelease = entries.contains("msvcr80d.dll");
  1284. if ((dictionary["BUILDALL"] == "auto") && (!hasDebug || !hasRelease)) {
  1285. cout << "Could not find debug and release c-runtime." << endl;
  1286. cout << "You need to have msvcr80.dll and msvcr80d.dll in" << endl;
  1287. cout << "the path specified. Setting to -no-crt";
  1288. dictionary[ "CE_CRT" ] = "no";
  1289. } else if ((dictionary["BUILD"] == "debug") && !hasDebug) {
  1290. cout << "Could not find debug c-runtime (msvcr80d.dll) in the directory specified." << endl;
  1291. cout << "Setting c-runtime automatic deployment to -no-crt" << endl;
  1292. dictionary[ "CE_CRT" ] = "no";
  1293. } else if ((dictionary["BUILD"] == "release") && !hasRelease) {
  1294. cout << "Could not find release c-runtime (msvcr80.dll) in the directory specified." << endl;
  1295. cout << "Setting c-runtime automatic deployment to -no-crt" << endl;
  1296. dictionary[ "CE_CRT" ] = "no";
  1297. }
  1298. }
  1299. // Allow tests for private classes to be compiled against internal builds
  1300. if (dictionary["BUILDDEV"] == "yes") {
  1301. qtConfig << "private_tests";
  1302. if (dictionary["WERROR"] != "no")
  1303. qmakeConfig << "warnings_are_errors";
  1304. } else {
  1305. if (dictionary["WERROR"] == "yes")
  1306. qmakeConfig << "warnings_are_errors";
  1307. }
  1308. if (dictionary["FORCE_ASSERTS"] == "yes")
  1309. qtConfig += "force_asserts";
  1310. for (QStringList::Iterator dis = disabledModules.begin(); dis != disabledModules.end(); ++dis) {
  1311. modules.removeAll((*dis));
  1312. }
  1313. for (QStringList::Iterator ena = enabledModules.begin(); ena != enabledModules.end(); ++ena) {
  1314. if (modules.indexOf((*ena)) == -1)
  1315. modules += (*ena);
  1316. }
  1317. qtConfig += modules;
  1318. for (QStringList::Iterator it = disabledModules.begin(); it != disabledModules.end(); ++it)
  1319. qtConfig.removeAll(*it);
  1320. if ((dictionary[ "REDO" ] != "yes") && (dictionary[ "HELP" ] != "yes")
  1321. && (dictionary[ "DONE" ] != "error"))
  1322. saveCmdLine();
  1323. }
  1324. void Configure::validateArgs()
  1325. {
  1326. // Validate the specified config
  1327. QString cfgpath = sourcePath + "/src/corelib/global/qconfig-" + dictionary["QCONFIG"] + ".h";
  1328. // Try internal configurations first.
  1329. QStringList possible_configs = QStringList()
  1330. << "minimal"
  1331. << "small"
  1332. << "medium"
  1333. << "large"
  1334. << "full";
  1335. int index = possible_configs.indexOf(dictionary["QCONFIG"]);
  1336. if (index >= 0) {
  1337. for (int c = 0; c <= index; c++) {
  1338. qtConfig += possible_configs[c] + "-config";
  1339. }
  1340. if (dictionary["QCONFIG"] != "full")
  1341. dictionary["QCONFIG_PATH"] = cfgpath;
  1342. return;
  1343. }
  1344. if (!QFileInfo::exists(cfgpath)) {
  1345. cfgpath = QFileInfo(dictionary["QCONFIG"]).absoluteFilePath();
  1346. if (!QFileInfo::exists(cfgpath)) {
  1347. dictionary[ "DONE" ] = "error";
  1348. cout << "No such configuration \"" << qPrintable(dictionary["QCONFIG"]) << "\"" << endl ;
  1349. return;
  1350. }
  1351. }
  1352. dictionary["QCONFIG_PATH"] = cfgpath;
  1353. }
  1354. // Output helper functions --------------------------------[ Start ]-
  1355. /*!
  1356. Determines the length of a string token.
  1357. */
  1358. static int tokenLength(const char *str)
  1359. {
  1360. if (*str == 0)
  1361. return 0;
  1362. const char *nextToken = strpbrk(str, " _/\n\r");
  1363. if (nextToken == str || !nextToken)
  1364. return 1;
  1365. return int(nextToken - str);
  1366. }
  1367. /*!
  1368. Prints out a string which starts at position \a startingAt, and
  1369. indents each wrapped line with \a wrapIndent characters.
  1370. The wrap point is set to the console width, unless that width
  1371. cannot be determined, or is too small.
  1372. */
  1373. void Configure::desc(const char *description, int startingAt, int wrapIndent)
  1374. {
  1375. int linePos = startingAt;
  1376. bool firstLine = true;
  1377. const char *nextToken = description;
  1378. while (*nextToken) {
  1379. int nextTokenLen = tokenLength(nextToken);
  1380. if (*nextToken == '\n' // Wrap on newline, duh
  1381. || (linePos + nextTokenLen > outputWidth)) // Wrap at outputWidth
  1382. {
  1383. printf("\n");
  1384. linePos = 0;
  1385. firstLine = false;
  1386. if (*nextToken == '\n')
  1387. ++nextToken;
  1388. continue;
  1389. }
  1390. if (!firstLine && linePos < wrapIndent) { // Indent to wrapIndent
  1391. printf("%*s", wrapIndent , "");
  1392. linePos = wrapIndent;
  1393. if (*nextToken == ' ') {
  1394. ++nextToken;
  1395. continue;
  1396. }
  1397. }
  1398. printf("%.*s", nextTokenLen, nextToken);
  1399. linePos += nextTokenLen;
  1400. nextToken += nextTokenLen;
  1401. }
  1402. }
  1403. /*!
  1404. Prints out an option with its description wrapped at the
  1405. description starting point. If \a skipIndent is true, the
  1406. indentation to the option is not outputted (used by marked option
  1407. version of desc()). Extra spaces between option and its
  1408. description is filled with\a fillChar, if there's available
  1409. space.
  1410. */
  1411. void Configure::desc(const char *option, const char *description, bool skipIndent, char fillChar)
  1412. {
  1413. if (!skipIndent)
  1414. printf("%*s", optionIndent, "");
  1415. int remaining = descIndent - optionIndent - int(strlen(option));
  1416. int wrapIndent = descIndent + qMax(0, 1 - remaining);
  1417. printf("%s", option);
  1418. if (remaining > 2) {
  1419. printf(" "); // Space in front
  1420. for (int i = remaining; i > 2; --i)
  1421. printf("%c", fillChar); // Fill, if available space
  1422. }
  1423. printf(" "); // Space between option and description
  1424. desc(description, wrapIndent, wrapIndent);
  1425. printf("\n");
  1426. }
  1427. /*!
  1428. Same as above, except it also marks an option with an '*', if
  1429. the option is default action.
  1430. */
  1431. void Configure::desc(const char *mark_option, const char *mark, const char *option, const char *description, char fillChar)
  1432. {
  1433. const QString markedAs = dictionary.value(mark_option);
  1434. if (markedAs == "auto" && markedAs == mark) // both "auto", always => +
  1435. printf(" + ");
  1436. else if (markedAs == "auto") // setting marked as "auto" and option is default => +
  1437. printf(" %c " , (defaultTo(mark_option) == QLatin1String(mark))? '+' : ' ');
  1438. else if (QLatin1String(mark) == "auto" && markedAs != "no") // description marked as "auto" and option is available => +
  1439. printf(" %c " , checkAvailability(mark_option) ? '+' : ' ');
  1440. else // None are "auto", (markedAs == mark) => *
  1441. printf(" %c " , markedAs == QLatin1String(mark) ? '*' : ' ');
  1442. desc(option, description, true, fillChar);
  1443. }
  1444. /*!
  1445. Modifies the default configuration based on given -platform option.
  1446. Eg. switches to different default styles for Windows CE.
  1447. */
  1448. void Configure::applySpecSpecifics()
  1449. {
  1450. if (dictionary.contains("XQMAKESPEC")) {
  1451. //Disable building tools when cross compiling.
  1452. nobuildParts << "tools";
  1453. }
  1454. if (dictionary.value("XQMAKESPEC").startsWith("winphone") || dictionary.value("XQMAKESPEC").startsWith("winrt")) {
  1455. dictionary[ "STYLE_WINDOWSXP" ] = "no";
  1456. dictionary[ "STYLE_WINDOWSVISTA" ] = "no";
  1457. dictionary[ "GIF" ] = "qt";
  1458. dictionary[ "JPEG" ] = "qt";
  1459. dictionary[ "LIBJPEG" ] = "qt";
  1460. dictionary[ "LIBPNG" ] = "qt";
  1461. dictionary[ "FREETYPE" ] = "yes";
  1462. dictionary[ "OPENGL" ] = "yes";
  1463. dictionary[ "OPENGL_ES_2" ] = "yes";
  1464. dictionary[ "OPENVG" ] = "no";
  1465. dictionary[ "OPENSSL" ] = "no";
  1466. dictionary[ "DBUS" ] = "no";
  1467. dictionary[ "ZLIB" ] = "qt";
  1468. dictionary[ "PCRE" ] = "qt";
  1469. dictionary[ "ICU" ] = "qt";
  1470. dictionary[ "CE_CRT" ] = "yes";
  1471. dictionary[ "LARGE_FILE" ] = "no";
  1472. dictionary[ "ANGLE" ] = "d3d11";
  1473. dictionary[ "DYNAMICGL" ] = "no";
  1474. if (dictionary.value("XQMAKESPEC").startsWith("winphone"))
  1475. dictionary[ "SQL_SQLITE" ] = "no";
  1476. } else if (dictionary.value("XQMAKESPEC").startsWith("wince")) {
  1477. dictionary[ "STYLE_WINDOWSXP" ] = "no";
  1478. dictionary[ "STYLE_WINDOWSVISTA" ] = "no";
  1479. dictionary[ "STYLE_FUSION" ] = "no";
  1480. dictionary[ "STYLE_WINDOWSCE" ] = "yes";
  1481. dictionary[ "STYLE_WINDOWSMOBILE" ] = "yes";
  1482. dictionary[ "OPENGL" ] = "no";
  1483. dictionary[ "OPENSSL" ] = "no";
  1484. dictionary[ "RTTI" ] = "no";
  1485. dictionary[ "SSE2" ] = "no";
  1486. dictionary[ "SSE3" ] = "no";
  1487. dictionary[ "SSSE3" ] = "no";
  1488. dictionary[ "SSE4_1" ] = "no";
  1489. dictionary[ "SSE4_2" ] = "no";
  1490. dictionary[ "AVX" ] = "no";
  1491. dictionary[ "AVX2" ] = "no";
  1492. dictionary[ "IWMMXT" ] = "no";
  1493. dictionary[ "CE_CRT" ] = "yes";
  1494. dictionary[ "LARGE_FILE" ] = "no";
  1495. dictionary[ "ANGLE" ] = "no";
  1496. dictionary[ "DYNAMICGL" ] = "no";
  1497. // We only apply MMX/IWMMXT for mkspecs we know they work
  1498. if (dictionary[ "XQMAKESPEC" ].startsWith("wincewm")) {
  1499. dictionary[ "MMX" ] = "yes";
  1500. dictionary[ "IWMMXT" ] = "yes";
  1501. }
  1502. } else if (dictionary.value("XQMAKESPEC").startsWith("linux")) { //TODO actually wrong.
  1503. //TODO
  1504. dictionary[ "STYLE_WINDOWSXP" ] = "no";
  1505. dictionary[ "STYLE_WINDOWSVISTA" ] = "no";
  1506. dictionary[ "KBD_DRIVERS" ] = "tty";
  1507. dictionary[ "GFX_DRIVERS" ] = "linuxfb";
  1508. dictionary[ "MOUSE_DRIVERS" ] = "pc linuxtp";
  1509. dictionary[ "OPENGL" ] = "no";
  1510. dictionary[ "DBUS"] = "no";
  1511. dictionary[ "QT_INOTIFY" ] = "no";
  1512. dictionary[ "QT_CUPS" ] = "no";
  1513. dictionary[ "QT_GLIB" ] = "no";
  1514. dictionary[ "QT_ICONV" ] = "no";
  1515. dictionary[ "QT_EVDEV" ] = "no";
  1516. dictionary[ "QT_MTDEV" ] = "no";
  1517. dictionary[ "FONT_CONFIG" ] = "auto";
  1518. dictionary["DECORATIONS"] = "default windows styled";
  1519. } else if ((platform() == QNX) || (platform() == BLACKBERRY)) {
  1520. dictionary["STACK_PROTECTOR_STRONG"] = "auto";
  1521. dictionary["SLOG2"] = "auto";
  1522. dictionary["QNX_IMF"] = "auto";
  1523. dictionary["PPS"] = "auto";
  1524. dictionary["LGMON"] = "auto";
  1525. dictionary["QT_XKBCOMMON"] = "no";
  1526. dictionary[ "ANGLE" ] = "no";
  1527. dictionary[ "DYNAMICGL" ] = "no";
  1528. dictionary[ "FONT_CONFIG" ] = "auto";
  1529. } else if (platform() == ANDROID) {
  1530. dictionary[ "REDUCE_EXPORTS" ] = "yes";
  1531. dictionary[ "BUILD" ] = "release";
  1532. dictionary[ "BUILDALL" ] = "no";
  1533. dictionary[ "LARGE_FILE" ] = "no";
  1534. dictionary[ "ANGLE" ] = "no";
  1535. dictionary[ "DYNAMICGL" ] = "no";
  1536. dictionary[ "REDUCE_RELOCATIONS" ] = "yes";
  1537. dictionary[ "QT_GETIFADDRS" ] = "no";
  1538. dictionary[ "QT_XKBCOMMON" ] = "no";
  1539. }
  1540. }
  1541. // Output helper functions ---------------------------------[ Stop ]-
  1542. bool Configure::displayHelp()
  1543. {
  1544. if (dictionary[ "HELP" ] == "yes") {
  1545. desc("Usage: configure [options]\n\n", 0, 7);
  1546. desc("Installation options:\n\n");
  1547. desc("These are optional, but you may specify install directories.\n\n", 0, 1);
  1548. desc( "-prefix <dir>", "This will install everything relative to <dir> (default $QT_INSTALL_PREFIX)\n");
  1549. desc( "-extprefix <dir>", "When -sysroot is used, install everything to <dir>, rather than into SYSROOT/PREFIX.\n");
  1550. desc( "-hostprefix [dir]", "Tools and libraries needed when developing applications are installed in [dir]. "
  1551. "If [dir] is not given, the current build directory will be used. (default EXTPREFIX)\n");
  1552. desc("You may use these to separate different parts of the install:\n\n");
  1553. desc( "-bindir <dir>", "User executables will be installed to <dir>\n(default PREFIX/bin)");
  1554. desc( "-libdir <dir>", "Libraries will be installed to <dir>\n(default PREFIX/lib)");
  1555. desc( "-headerdir <dir>", "Headers will be installed to <dir>\n(default PREFIX/include)");
  1556. desc( "-archdatadir <dir>", "Architecture-dependent data used by Qt will be installed to <dir>\n(default PREFIX)");
  1557. desc( "-libexecdir <dir>", "Program executables will be installed to <dir>\n(default ARCHDATADIR/bin)");
  1558. desc( "-plugindir <dir>", "Plugins will be installed to <dir>\n(default ARCHDATADIR/plugins)");
  1559. desc( "-importdir <dir>", "Imports for QML1 will be installed to <dir>\n(default ARCHDATADIR/imports)");
  1560. desc( "-qmldir <dir>", "Imports for QML2 will be installed to <dir>\n(default ARCHDATADIR/qml)");
  1561. desc( "-datadir <dir>", "Data used by Qt programs will be installed to <dir>\n(default PREFIX)");
  1562. desc( "-docdir <dir>", "Documentation will be installed to <dir>\n(default DATADIR/doc)");
  1563. desc( "-translationdir <dir>", "Translations of Qt programs will be installed to <dir>\n(default DATADIR/translations)");
  1564. desc( "-examplesdir <dir>", "Examples will be installed to <dir>\n(default PREFIX/examples)");
  1565. desc( "-testsdir <dir>", "Tests will be installed to <dir>\n(default PREFIX/tests)\n");
  1566. desc( "-hostbindir <dir>", "Host executables will be installed to <dir>\n(default HOSTPREFIX/bin)");
  1567. desc( "-hostlibdir <dir>", "Host libraries will be installed to <dir>\n(default HOSTPREFIX/lib)");
  1568. desc( "-hostdatadir <dir>", "Data used by qmake will be installed to <dir>\n(default HOSTPREFIX)");
  1569. desc("\nConfigure options:\n\n");
  1570. desc(" The defaults (*) are usually acceptable. A plus (+) denotes a default value"
  1571. " that needs to be evaluated. If the evaluation succeeds, the feature is"
  1572. " included. Here is a short explanation of each option:\n\n", 0, 1);
  1573. desc("BUILD", "release","-release", "Compile and link Qt with debugging turned off.");
  1574. desc("BUILD", "debug", "-debug", "Compile and link Qt with debugging turned on.");
  1575. desc("BUILDALL", "yes", "-debug-and-release", "Compile and link two Qt libraries, with and without debugging turned on.\n");
  1576. desc("FORCEDEBUGINFO", "yes","-force-debug-info", "Create symbol files for release builds.\n");
  1577. desc("BUILDDEV", "yes", "-developer-build", "Compile and link Qt with Qt developer options (including auto-tests exporting)\n");
  1578. desc("OPENSOURCE", "opensource", "-opensource", "Compile and link the Open-Source Edition of Qt.");
  1579. desc("COMMERCIAL", "commercial", "-commercial", "Compile and link the Commercial Edition of Qt.\n");
  1580. desc("C++11", "yes", "-c++11", "Compile Qt with C++11 support enabled.");
  1581. desc("C++11", "no", "-no-c++11", "Do not compile Qt with C++11 support enabled.\n");
  1582. desc("SHARED", "yes", "-shared", "Create and use shared Qt libraries.");
  1583. desc("SHARED", "no", "-static", "Create and use static Qt libraries.\n");
  1584. desc("LTCG", "yes", "-ltcg", "Use Link Time Code Generation. (Release builds only)");
  1585. desc("LTCG", "no", "-no-ltcg", "Do not use Link Time Code Generation.\n");
  1586. desc( "-make <part>", "Add part to the list of parts to be built at make time");
  1587. for (int i=0; i<defaultBuildParts.size(); ++i)
  1588. desc( "", qPrintable(QString(" %1").arg(defaultBuildParts.at(i))), false, ' ');
  1589. desc( "-nomake <part>", "Exclude part from the list of parts to be built.\n");
  1590. desc( "-skip <module>", "Exclude an entire module from the build.\n");
  1591. desc( "-no-compile-examples", "Install only the sources of examples.\n");
  1592. desc("WIDGETS", "no", "-no-widgets", "Disable Qt Widgets module.\n");
  1593. desc("GUI", "no", "-no-gui", "Disable Qt GUI module.\n");
  1594. desc("ACCESSIBILITY", "no", "-no-accessibility", "Disable accessibility support.\n");
  1595. desc( "", "Disabling accessibility is not recommended, as it will break QStyle\n"
  1596. "and may break other internal parts of Qt.\n"
  1597. "With this switch you create a source incompatible version of Qt,\n"
  1598. "which is unsupported.\n");
  1599. desc("ACCESSIBILITY", "yes", "-accessibility", "Enable accessibility support.\n");
  1600. desc( "-no-sql-<driver>", "Disable SQL <driver> entirely, by default none are turned on.");
  1601. desc( "-qt-sql-<driver>", "Enable a SQL <driver> in the Qt Library.");
  1602. desc( "-plugin-sql-<driver>", "Enable SQL <driver> as a plugin to be linked to at run time.\n"
  1603. "Available values for <driver>:");
  1604. desc("SQL_MYSQL", "auto", "", " mysql", ' ');
  1605. desc("SQL_PSQL", "auto", "", " psql", ' ');
  1606. desc("SQL_OCI", "auto", "", " oci", ' ');
  1607. desc("SQL_ODBC", "auto", "", " odbc", ' ');
  1608. desc("SQL_TDS", "auto", "", " tds", ' ');
  1609. desc("SQL_DB2", "auto", "", " db2", ' ');
  1610. desc("SQL_SQLITE", "auto", "", " sqlite", ' ');
  1611. desc("SQL_SQLITE2", "auto", "", " sqlite2", ' ');
  1612. desc("SQL_IBASE", "auto", "", " ibase", ' ');
  1613. desc( "", "(drivers marked with a '+' have been detected as available on this system)\n", false, ' ');
  1614. desc( "-system-sqlite", "Use sqlite from the operating system.\n");
  1615. desc("OPENGL", "no","-no-opengl", "Do not support OpenGL.");
  1616. desc("OPENGL", "no","-opengl <api>", "Enable OpenGL support with specified API version.\n"
  1617. "Available values for <api>:");
  1618. desc("", "no", "", " desktop - Enable support for Desktop OpenGL", ' ');
  1619. desc("", "no", "", " dynamic - Enable support for dynamically loaded OpenGL (either desktop or ES)", ' ');
  1620. desc("OPENGL_ES_2", "yes", "", " es2 - Enable support for OpenGL ES 2.0\n", ' ');
  1621. desc("OPENVG", "no","-no-openvg", "Disables OpenVG functionality.");
  1622. desc("OPENVG", "yes","-openvg", "Enables OpenVG functionality.\n");
  1623. desc( "-force-asserts", "Activate asserts in release mode.\n");
  1624. desc( "-platform <spec>", "The operating system and compiler you are building on.\n(default %QMAKESPEC%)\n");
  1625. desc( "-xplatform <spec>", "The operating system and compiler you are cross compiling to.\n");
  1626. desc( "", "See the README file for a list of supported operating systems and compilers.\n", false, ' ');
  1627. desc("TARGET_OS", "*", "-target", "Set target OS version. Currently the only valid value is 'xp' for targeting Windows XP.\n"
  1628. "MSVC >= 2012 targets Windows Vista by default.\n");
  1629. desc( "-sysroot <dir>", "Sets <dir> as the target compiler's and qmake's sysroot and also sets pkg-config paths.");
  1630. desc( "-no-gcc-sysroot", "When using -sysroot, it disables the passing of --sysroot to the compiler.\n");
  1631. desc( "-qconfig <local>", "Use src/corelib/global/qconfig-<local>.h rather than the\n"
  1632. "default 'full'.\n");
  1633. desc("NIS", "no", "-no-nis", "Do not compile NIS support.");
  1634. desc("NIS", "yes", "-nis", "Compile NIS support.\n");
  1635. desc("NEON", "yes", "-neon", "Enable the use of NEON instructions.");
  1636. desc("NEON", "no", "-no-neon", "Do not enable the use of NEON instructions.\n");
  1637. desc("QT_ICONV", "disable", "-no-iconv", "Do not enable support for iconv(3).");
  1638. desc("QT_ICONV", "yes", "-iconv", "Enable support for iconv(3).");
  1639. desc("QT_ICONV", "yes", "-sun-iconv", "Enable support for iconv(3) using sun-iconv.");
  1640. desc("QT_ICONV", "yes", "-gnu-iconv", "Enable support for iconv(3) using gnu-libiconv.\n");
  1641. desc("QT_EVDEV", "no", "-no-evdev", "Do not enable support for evdev.");
  1642. desc("QT_EVDEV", "yes", "-evdev", "Enable support for evdev.");
  1643. desc("QT_MTDEV", "no", "-no-mtdev", "Do not enable support for mtdev.");
  1644. desc("QT_MTDEV", "yes", "-mtdev", "Enable support for mtdev.");
  1645. desc("QT_INOTIFY", "yes", "-inotify", "Explicitly enable Qt inotify(7) support.");
  1646. desc("QT_INOTIFY", "no", "-no-inotify", "Explicitly disable Qt inotify(7) support.\n");
  1647. desc("QT_EVENTFD", "yes", "-eventfd", "Enable eventfd(7) support in the UNIX event loop.");
  1648. desc("QT_EVENTFD", "no", "-no-eventfd", "Disable eventfd(7) support in the UNIX event loop.\n");
  1649. desc("LARGE_FILE", "yes", "-largefile", "Enables Qt to access files larger than 4 GB.\n");
  1650. desc("FONT_CONFIG", "yes", "-fontconfig", "Build with FontConfig support.");
  1651. desc("FONT_CONFIG", "no", "-no-fontconfig", "Do not build with FontConfig support.\n");
  1652. desc("POSIX_IPC", "yes", "-posix-ipc", "Enable POSIX IPC.\n");
  1653. desc("QT_GLIB", "yes", "-glib", "Compile Glib support.\n");
  1654. desc("QT_INSTALL_SETTINGS", "auto", "-sysconfdir <dir>", "Settings used by Qt programs will be looked for in\n<dir>.\n");
  1655. desc("SYSTEM_PROXIES", "yes", "-system-proxies", "Use system network proxies by default.");
  1656. desc("SYSTEM_PROXIES", "no", "-no-system-proxies", "Do not use system network proxies by default.\n");
  1657. desc("WERROR", "yes", "-warnings-are-errors", "Make warnings be treated as errors.");
  1658. desc("WERROR", "no", "-no-warnings-are-errors","Make warnings be treated normally.");
  1659. desc( "-qtnamespace <name>", "Wraps all Qt library code in 'namespace name {...}'.");
  1660. desc( "-qtlibinfix <infix>", "Renames all Qt* libs to Qt*<infix>.\n");
  1661. desc( "-D <define>", "Add an explicit define to the preprocessor.");
  1662. desc( "-I <includepath>", "Add an explicit include path.");
  1663. desc( "-L <librarypath>", "Add an explicit library path.");
  1664. desc( "-l <libraryname>", "Add an explicit library name, residing in a librarypath.\n");
  1665. desc( "-help, -h, -?", "Display this information.\n");
  1666. // 3rd party stuff options go below here --------------------------------------------------------------------------------
  1667. desc("Third Party Libraries:\n\n");
  1668. desc("ZLIB", "qt", "-qt-zlib", "Use the zlib bundled with Qt.");
  1669. desc("ZLIB", "system", "-system-zlib", "Use zlib from the operating system.\nSee http://www.gzip.org/zlib\n");
  1670. desc("PCRE", "qt", "-qt-pcre", "Use the PCRE library bundled with Qt.");
  1671. desc("PCRE", "system", "-system-pcre", "Use the PCRE library from the operating system.\nSee http://pcre.org/\n");
  1672. desc("ICU", "yes", "-icu", "Use the ICU library.");
  1673. desc("ICU", "no", "-no-icu", "Do not use the ICU library.\nSee http://site.icu-project.org/\n");
  1674. desc("GIF", "no", "-no-gif", "Do not compile GIF reading support.\n");
  1675. desc("LIBPNG", "no", "-no-libpng", "Do not compile PNG support.");
  1676. desc("LIBPNG", "qt", "-qt-libpng", "Use the libpng bundled with Qt.");
  1677. desc("LIBPNG", "system","-system-libpng", "Use libpng from the operating system.\nSee http://www.libpng.org/pub/png\n");
  1678. desc("LIBJPEG", "no", "-no-libjpeg", "Do not compile JPEG support.");
  1679. desc("LIBJPEG", "qt", "-qt-libjpeg", "Use the libjpeg bundled with Qt.");
  1680. desc("LIBJPEG", "system","-system-libjpeg", "Use libjpeg from the operating system.\nSee http://www.ijg.org\n");
  1681. desc("FREETYPE", "no", "-no-freetype", "Do not compile in Freetype2 support.");
  1682. desc("FREETYPE", "yes", "-qt-freetype", "Use the libfreetype bundled with Qt.");
  1683. desc("FREETYPE", "system","-system-freetype", "Use the libfreetype provided by the system.");
  1684. desc("HARFBUZZ", "no", "-no-harfbuzz", "Do not compile in HarfBuzz-NG support.");
  1685. desc("HARFBUZZ", "yes", "-qt-harfbuzz", "(experimental) Use HarfBuzz-NG bundled with Qt\n"
  1686. "to do text shaping. It can still be disabled\n"
  1687. "by setting QT_HARFBUZZ environment variable to \"old\".");
  1688. desc("HARFBUZZ", "system","-system-harfbuzz", "(experimental) Use HarfBuzz-NG from the operating system\n"
  1689. "to do text shaping. It can still be disabled\n"
  1690. "by setting QT_HARFBUZZ environment variable to \"old\".\n");
  1691. if ((platform() == QNX) || (platform() == BLACKBERRY)) {
  1692. desc("SLOG2", "yes", "-slog2", "Compile with slog2 support.");
  1693. desc("SLOG2", "no", "-no-slog2", "Do not compile with slog2 support.");
  1694. desc("QNX_IMF", "yes", "-imf", "Compile with imf support.");
  1695. desc("QNX_IMF", "no", "-no-imf", "Do not compile with imf support.");
  1696. desc("PPS", "yes", "-pps", "Compile with PPS support.");
  1697. desc("PPS", "no", "-no-pps", "Do not compile with PPS support.");
  1698. desc("LGMON", "yes", "-lgmon", "Compile with lgmon support.");
  1699. desc("LGMON", "no", "-no-lgmon", "Do not compile with lgmon support.\n");
  1700. }
  1701. desc("ANGLE", "yes", "-angle", "Use the ANGLE implementation of OpenGL ES 2.0.");
  1702. desc("ANGLE", "d3d11", "-angle-d3d11", "Use the Direct3D 11-based ANGLE implementation of OpenGL ES 2.0.");
  1703. desc("ANGLE", "no", "-no-angle", "Do not use ANGLE.\nSee http://code.google.com/p/angleproject/\n");
  1704. // Qt\Windows only options go below here --------------------------------------------------------------------------------
  1705. desc("\nQt for Windows only:\n\n");
  1706. desc("VCPROJFILES", "no", "-no-vcproj", "Do not generate VC++ .vcproj files.");
  1707. desc("VCPROJFILES", "yes", "-vcproj", "Generate VC++ .vcproj files, only if platform \"win32-msvc.net\".\n");
  1708. desc("INCREDIBUILD_XGE", "no", "-no-incredibuild-xge", "Do not add IncrediBuild XGE distribution commands to custom build steps.");
  1709. 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");
  1710. desc("PLUGIN_MANIFESTS", "no", "-no-plugin-manifests", "Do not embed manifests in plugins.");
  1711. desc("PLUGIN_MANIFESTS", "yes", "-plugin-manifests", "Embed manifests in plugins.\n");
  1712. desc("BUILD_QMAKE", "no", "-no-qmake", "Do not compile qmake.");
  1713. desc("BUILD_QMAKE", "yes", "-qmake", "Compile qmake.\n");
  1714. desc("PROCESS", "partial", "-process", "Generate only top-level Makefile.");
  1715. desc("PROCESS", "full", "-fully-process", "Generate Makefiles/Project files for the entire Qt\ntree.");
  1716. desc("PROCESS", "no", "-dont-process", "Do not generate Makefiles/Project files.\n");
  1717. desc( "-qreal [double|float]", "typedef qreal to the specified type. The default is double.\n"
  1718. "Note that changing this flag affects binary compatibility.\n");
  1719. desc("RTTI", "no", "-no-rtti", "Do not compile runtime type information.");
  1720. desc("RTTI", "yes", "-rtti", "Compile runtime type information.");
  1721. desc("STRIP", "no", "-no-strip", "Do not strip libraries and executables of debug info when installing.");
  1722. desc("STRIP", "yes", "-strip", "Strip libraries and executables of debug info when installing.\n");
  1723. desc("SSE2", "no", "-no-sse2", "Do not compile with use of SSE2 instructions.");
  1724. desc("SSE2", "yes", "-sse2", "Compile with use of SSE2 instructions.");
  1725. desc("SSE3", "no", "-no-sse3", "Do not compile with use of SSE3 instructions.");
  1726. desc("SSE3", "yes", "-sse3", "Compile with use of SSE3 instructions.");
  1727. desc("SSSE3", "no", "-no-ssse3", "Do not compile with use of SSSE3 instructions.");
  1728. desc("SSSE3", "yes", "-ssse3", "Compile with use of SSSE3 instructions.");
  1729. desc("SSE4_1", "no", "-no-sse4.1", "Do not compile with use of SSE4.1 instructions.");
  1730. desc("SSE4_1", "yes", "-sse4.1", "Compile with use of SSE4.1 instructions.");
  1731. desc("SSE4_2", "no", "-no-sse4.2", "Do not compile with use of SSE4.2 instructions.");
  1732. desc("SSE4_2", "yes", "-sse4.2", "Compile with use of SSE4.2 instructions.");
  1733. desc("AVX", "no", "-no-avx", "Do not compile with use of AVX instructions.");
  1734. desc("AVX", "yes", "-avx", "Compile with use of AVX instructions.");
  1735. desc("AVX2", "no", "-no-avx2", "Do not compile with use of AVX2 instructions.");
  1736. desc("AVX2", "yes", "-avx2", "Compile with use of AVX2 instructions.\n");
  1737. desc("OPENSSL", "no", "-no-openssl", "Do not compile support for OpenSSL.");
  1738. desc("OPENSSL", "yes", "-openssl", "Enable run-time OpenSSL support.");
  1739. desc("OPENSSL", "linked","-openssl-linked", "Enable linked OpenSSL support.\n");
  1740. desc("DBUS", "no", "-no-dbus", "Do not compile in D-Bus support.");
  1741. desc("DBUS", "yes", "-dbus", "Compile in D-Bus support and load libdbus-1\ndynamically.");
  1742. desc("DBUS", "linked", "-dbus-linked", "Compile in D-Bus support and link to libdbus-1.\n");
  1743. desc("AUDIO_BACKEND", "no","-no-audio-backend", "Do not compile in the platform audio backend into\nQt Multimedia.");
  1744. desc("AUDIO_BACKEND", "yes","-audio-backend", "Compile in the platform audio backend into Qt Multimedia.\n");
  1745. desc("WMF_BACKEND", "no","-no-wmf-backend", "Do not compile in the windows media foundation backend\ninto Qt Multimedia.");
  1746. desc("WMF_BACKEND", "yes","-wmf-backend", "Compile in the windows media foundation backend into Qt Multimedia.\n");
  1747. desc("QML_DEBUG", "no", "-no-qml-debug", "Do not build the in-process QML debugging support.");
  1748. desc("QML_DEBUG", "yes", "-qml-debug", "Build the in-process QML debugging support.\n");
  1749. desc("DIRECTWRITE", "no", "-no-directwrite", "Do not build support for DirectWrite font rendering.");
  1750. desc("DIRECTWRITE", "yes", "-directwrite", "Build support for DirectWrite font rendering (experimental, requires DirectWrite availability on target systems, e.g. Windows Vista with Platform Update, Windows 7, etc.)\n");
  1751. desc("DIRECT2D", "no", "-no-direct2d", "Do not build the Direct2D platform plugin.");
  1752. desc("DIRECT2D", "yes", "-direct2d", "Build the Direct2D platform plugin (experimental,\n"
  1753. "requires Direct2D availability on target systems,\n"
  1754. "e.g. Windows 7 with Platform Update, Windows 8, etc.)\n");
  1755. desc( "-no-style-<style>", "Disable <style> entirely.");
  1756. desc( "-qt-style-<style>", "Enable <style> in the Qt Library.\nAvailable styles: ");
  1757. desc("STYLE_WINDOWS", "yes", "", " windows", ' ');
  1758. desc("STYLE_WINDOWSXP", "auto", "", " windowsxp", ' ');
  1759. desc("STYLE_WINDOWSVISTA", "auto", "", " windowsvista", ' ');
  1760. desc("STYLE_FUSION", "yes", "", " fusion", ' ');
  1761. desc("STYLE_WINDOWSCE", "yes", "", " windowsce", ' ');
  1762. desc("STYLE_WINDOWSMOBILE" , "yes", "", " windowsmobile\n", ' ');
  1763. desc("NATIVE_GESTURES", "no", "-no-native-gestures", "Do not use native gestures on Windows 7.");
  1764. desc("NATIVE_GESTURES", "yes", "-native-gestures", "Use native gestures on Windows 7.\n");
  1765. desc("MSVC_MP", "no", "-no-mp", "Do not use multiple processors for compiling with MSVC");
  1766. desc("MSVC_MP", "yes", "-mp", "Use multiple processors for compiling with MSVC (-MP).\n");
  1767. desc( "-loadconfig <config>", "Run configure with the parameters from file configure_<config>.cache.");
  1768. desc( "-saveconfig <config>", "Run configure and save the parameters in file configure_<config>.cache.");
  1769. desc( "-redo", "Run configure with the same parameters as last time.\n");
  1770. // Qt\Windows CE only options go below here -----------------------------------------------------------------------------
  1771. desc("Qt for Windows CE only:\n\n");
  1772. desc("IWMMXT", "no", "-no-iwmmxt", "Do not compile with use of IWMMXT instructions.");
  1773. desc("IWMMXT", "yes", "-iwmmxt", "Do compile with use of IWMMXT instructions. (Qt for Windows CE on Arm only)\n");
  1774. desc("CE_CRT", "no", "-no-crt" , "Do not add the C runtime to default deployment rules.");
  1775. desc("CE_CRT", "yes", "-qt-crt", "Qt identifies C runtime during project generation.");
  1776. desc( "-crt <path>", "Specify path to C runtime used for project generation.\n");
  1777. desc("CETEST", "no", "-no-cetest", "Do not compile Windows CE remote test application.");
  1778. desc("CETEST", "yes", "-cetest", "Compile Windows CE remote test application.\n");
  1779. desc( "-signature <file>", "Use <file> for signing the target project.");
  1780. return true;
  1781. }
  1782. return false;
  1783. }
  1784. // Locate a file and return its containing directory.
  1785. QString Configure::locateFile(const QString &fileName) const
  1786. {
  1787. const QString file = fileName.toLower();
  1788. QStringList pathList;
  1789. if (file.endsWith(".h")) {
  1790. static const QStringList headerPaths =
  1791. Environment::headerPaths(Environment::compilerFromQMakeSpec(dictionary[QStringLiteral("QMAKESPEC")]));
  1792. pathList = headerPaths;
  1793. } else if (file.endsWith(".lib") || file.endsWith(".a")) {
  1794. static const QStringList libPaths =
  1795. Environment::libraryPaths(Environment::compilerFromQMakeSpec(dictionary[QStringLiteral("QMAKESPEC")]));
  1796. pathList = libPaths;
  1797. } else {
  1798. // Fallback for .exe and .dll (latter are not covered by QStandardPaths).
  1799. static const QStringList exePaths = Environment::path();
  1800. pathList = exePaths;
  1801. }
  1802. return Environment::findFileInPaths(file, pathList);
  1803. }
  1804. /*!
  1805. Default value for options marked as "auto" if the test passes.
  1806. (Used both by the autoDetection() below, and the desc() function
  1807. to mark (+) the default option of autodetecting options.
  1808. */
  1809. QString Configure::defaultTo(const QString &option)
  1810. {
  1811. // We prefer using the system version of the 3rd party libs
  1812. if (option == "ZLIB"
  1813. || option == "PCRE"
  1814. || option == "LIBJPEG"
  1815. || option == "LIBPNG")
  1816. return "system";
  1817. // PNG is always built-in, never a plugin
  1818. if (option == "PNG")
  1819. return "yes";
  1820. // These database drivers and image formats can be built-in or plugins.
  1821. // Prefer plugins when Qt is shared.
  1822. if (dictionary[ "SHARED" ] == "yes") {
  1823. if (option == "SQL_MYSQL"
  1824. || option == "SQL_MYSQL"
  1825. || option == "SQL_ODBC"
  1826. || option == "SQL_OCI"
  1827. || option == "SQL_PSQL"
  1828. || option == "SQL_TDS"
  1829. || option == "SQL_DB2"
  1830. || option == "SQL_SQLITE"
  1831. || option == "SQL_SQLITE2"
  1832. || option == "SQL_IBASE"
  1833. || option == "JPEG"
  1834. || option == "GIF")
  1835. return "plugin";
  1836. }
  1837. // By default we do not want to compile OCI driver when compiling with
  1838. // MinGW, due to lack of such support from Oracle. It prob. won't work.
  1839. // (Customer may force the use though)
  1840. if (dictionary["QMAKESPEC"].endsWith("-g++")
  1841. && option == "SQL_OCI")
  1842. return "no";
  1843. // keep 'auto' default for msvc, since we can't set the language supported
  1844. if (option == "C++11"
  1845. && dictionary["QMAKESPEC"].contains("msvc"))
  1846. return "auto";
  1847. if (option == "SYNCQT")
  1848. return "yes";
  1849. return "yes";
  1850. }
  1851. bool Configure::checkAngleAvailability(QString *errorMessage /* = 0 */) const
  1852. {
  1853. // Check for Direct X SDK (include lib and direct shader compiler 'fxc').
  1854. // Up to Direct X SDK June 2010 and for MinGW, this is pointed to by the
  1855. // DXSDK_DIR variable. Starting with Windows Kit 8, it is included
  1856. // in the Windows SDK. Checking for the header is not sufficient since
  1857. // it is also present in MinGW.
  1858. const QString directXSdk = Environment::detectDirectXSdk();
  1859. const Compiler compiler = Environment::compilerFromQMakeSpec(dictionary[QStringLiteral("QMAKESPEC")]);
  1860. if (compiler < CC_NET2012 && directXSdk.isEmpty()) {
  1861. if (errorMessage)
  1862. *errorMessage = QStringLiteral("There is no Direct X SDK installed or the environment variable \"DXSDK_DIR\" is not set.");
  1863. return false;
  1864. }
  1865. const QString compilerHeader = QStringLiteral("d3dcompiler.h");
  1866. if (!findFile(compilerHeader)) {
  1867. if (errorMessage)
  1868. *errorMessage = QString::fromLatin1("The header '%1' could not be found.").arg(compilerHeader);
  1869. return false;
  1870. }
  1871. if (dictionary["SSE2"] != "no") {
  1872. const QString intrinHeader = QStringLiteral("intrin.h"); // Not present on MinGW-32
  1873. if (!findFile(intrinHeader)) {
  1874. if (errorMessage)
  1875. *errorMessage = QString::fromLatin1("The header '%1' required for SSE2 could not be found.").arg(intrinHeader);
  1876. return false;
  1877. }
  1878. }
  1879. const QString directXLibrary = dictionary["ANGLE"] == "d3d11" ? QStringLiteral("d3d11.lib") : QStringLiteral("d3d9.lib");
  1880. if (!findFile(directXLibrary)) {
  1881. if (errorMessage)
  1882. *errorMessage = QString::fromLatin1("The library '%1' could not be found.").arg(directXLibrary);
  1883. return false;
  1884. }
  1885. const QString fxcBinary = QStringLiteral("fxc.exe");
  1886. QStringList additionalPaths;
  1887. if (!directXSdk.isEmpty())
  1888. additionalPaths.push_back(directXSdk + QStringLiteral("/Utilities/bin/x86"));
  1889. QString fxcPath = QStandardPaths::findExecutable(fxcBinary, additionalPaths);
  1890. if (fxcPath.isEmpty()) {
  1891. if (errorMessage)
  1892. *errorMessage = QString::fromLatin1("The shader compiler '%1' could not be found.").arg(fxcBinary);
  1893. return false;
  1894. }
  1895. return true;
  1896. }
  1897. /*!
  1898. Checks the system for the availability of a feature.
  1899. Returns true if the feature is available, else false.
  1900. */
  1901. bool Configure::checkAvailability(const QString &part)
  1902. {
  1903. bool available = false;
  1904. if (part == "STYLE_WINDOWSXP")
  1905. available = (platform() == WINDOWS) && findFile("uxtheme.h");
  1906. else if (part == "ZLIB")
  1907. available = findFile("zlib.h");
  1908. else if (part == "PCRE")
  1909. available = findFile("pcre.h");
  1910. else if (part == "ICU")
  1911. available = tryCompileProject("unix/icu");
  1912. else if (part == "ANGLE") {
  1913. available = checkAngleAvailability();
  1914. }
  1915. else if (part == "HARFBUZZ")
  1916. available = tryCompileProject("unix/harfbuzz");
  1917. else if (part == "LIBJPEG")
  1918. available = findFile("jpeglib.h");
  1919. else if (part == "LIBPNG")
  1920. available = findFile("png.h");
  1921. else if (part == "SQL_MYSQL")
  1922. available = findFile("mysql.h") && findFile("libmySQL.lib");
  1923. else if (part == "SQL_ODBC")
  1924. available = findFile("sql.h") && findFile("sqlext.h") && findFile("odbc32.lib");
  1925. else if (part == "SQL_OCI")
  1926. available = findFile("oci.h") && findFile("oci.lib");
  1927. else if (part == "SQL_PSQL")
  1928. available = findFile("libpq-fe.h") && findFile("libpq.lib") && findFile("ws2_32.lib") && findFile("advapi32.lib");
  1929. else if (part == "SQL_TDS")
  1930. available = findFile("sybfront.h") && findFile("sybdb.h") && findFile("ntwdblib.lib");
  1931. else if (part == "SQL_DB2")
  1932. available = findFile("sqlcli.h") && findFile("sqlcli1.h") && findFile("db2cli.lib");
  1933. else if (part == "SQL_SQLITE")
  1934. available = true; // Built in, we have a fork
  1935. else if (part == "SQL_SQLITE_LIB") {
  1936. if (dictionary[ "SQL_SQLITE_LIB" ] == "system") {
  1937. if ((platform() == QNX) || (platform() == BLACKBERRY)) {
  1938. available = true;
  1939. dictionary[ "QT_LFLAGS_SQLITE" ] += "-lsqlite3 -lz";
  1940. } else {
  1941. available = findFile("sqlite3.h") && findFile("sqlite3.lib");
  1942. if (available)
  1943. dictionary[ "QT_LFLAGS_SQLITE" ] += "sqlite3.lib";
  1944. }
  1945. } else {
  1946. available = true;
  1947. }
  1948. } else if (part == "SQL_SQLITE2")
  1949. available = findFile("sqlite.h") && findFile("sqlite.lib");
  1950. else if (part == "SQL_IBASE")
  1951. available = findFile("ibase.h") && (findFile("gds32_ms.lib") || findFile("gds32.lib"));
  1952. else if (part == "IWMMXT")
  1953. available = (dictionary.value("XQMAKESPEC").startsWith("wince"));
  1954. else if (part == "OPENGL_ES_2")
  1955. available = (dictionary.value("XQMAKESPEC").startsWith("wince"));
  1956. else if (part == "SSE2")
  1957. available = tryCompileProject("common/sse2");
  1958. else if (part == "SSE3")
  1959. available = tryCompileProject("common/sse3");
  1960. else if (part == "SSSE3")
  1961. available = tryCompileProject("common/ssse3");
  1962. else if (part == "SSE4_1")
  1963. available = tryCompileProject("common/sse4_1");
  1964. else if (part == "SSE4_2")
  1965. available = tryCompileProject("common/sse4_2");
  1966. else if (part == "AVX")
  1967. available = tryCompileProject("common/avx");
  1968. else if (part == "AVX2")
  1969. available = tryCompileProject("common/avx2");
  1970. else if (part == "OPENSSL")
  1971. available = findFile("openssl\\ssl.h");
  1972. else if (part == "DBUS")
  1973. available = findFile("dbus\\dbus.h");
  1974. else if (part == "CETEST") {
  1975. const QString rapiHeader = QDir::toNativeSeparators(locateFile("rapi.h"));
  1976. const QString rapiLib = QDir::toNativeSeparators(locateFile("rapi.lib"));
  1977. available = (dictionary.value("XQMAKESPEC").startsWith("wince")) && !rapiHeader.isEmpty() && !rapiLib.isEmpty();
  1978. if (available) {
  1979. dictionary[ "QT_CE_RAPI_INC" ] += QLatin1String("\"") + rapiHeader + QLatin1String("\"");
  1980. dictionary[ "QT_CE_RAPI_LIB" ] += QLatin1String("\"") + rapiLib + QLatin1String("\"");
  1981. }
  1982. else if (dictionary[ "CETEST_REQUESTED" ] == "yes") {
  1983. cout << "cetest could not be enabled: rapi.h and rapi.lib could not be found." << endl;
  1984. cout << "Make sure the environment is set up for compiling with ActiveSync." << endl;
  1985. dictionary[ "DONE" ] = "error";
  1986. }
  1987. } else if (part == "INCREDIBUILD_XGE") {
  1988. available = !QStandardPaths::findExecutable(QStringLiteral("BuildConsole.exe")).isEmpty()
  1989. && !QStandardPaths::findExecutable(QStringLiteral("xgConsole.exe")).isEmpty();
  1990. } else if (part == "WMSDK") {
  1991. available = findFile("wmsdk.h");
  1992. } else if (part == "AUDIO_BACKEND") {
  1993. available = true;
  1994. } else if (part == "WMF_BACKEND") {
  1995. available = findFile("mfapi.h") && findFile("mf.lib");
  1996. } else if (part == "DIRECTWRITE") {
  1997. available = findFile("dwrite.h") && findFile("d2d1.h") && findFile("dwrite.lib");
  1998. } else if (part == "DIRECT2D") {
  1999. available = tryCompileProject("qpa/direct2d");
  2000. } else if (part == "ICONV") {
  2001. available = tryCompileProject("unix/iconv") || tryCompileProject("unix/gnu-libiconv");
  2002. } else if (part == "EVDEV") {
  2003. available = tryCompileProject("unix/evdev");
  2004. } else if (part == "MTDEV") {
  2005. available = tryCompileProject("unix/mtdev");
  2006. } else if (part == "INOTIFY") {
  2007. available = tryCompileProject("unix/inotify");
  2008. } else if (part == "QT_EVENTFD") {
  2009. available = tryCompileProject("unix/eventfd");
  2010. } else if (part == "CUPS") {
  2011. available = (platform() != WINDOWS) && (platform() != WINDOWS_CE) && (platform() != WINDOWS_RT) && tryCompileProject("unix/cups");
  2012. } else if (part == "STACK_PROTECTOR_STRONG") {
  2013. available = (platform() == QNX || platform() == BLACKBERRY) && compilerSupportsFlag("qcc -fstack-protector-strong");
  2014. } else if (part == "SLOG2") {
  2015. available = tryCompileProject("unix/slog2");
  2016. } else if (part == "QNX_IMF") {
  2017. available = tryCompileProject("unix/qqnx_imf");
  2018. } else if (part == "PPS") {
  2019. available = (platform() == QNX || platform() == BLACKBERRY) && tryCompileProject("unix/pps");
  2020. } else if (part == "LGMON") {
  2021. available = (platform() == QNX || platform() == BLACKBERRY)
  2022. && tryCompileProject("unix/lgmon");
  2023. } else if (part == "NEON") {
  2024. available = (dictionary["QT_ARCH"] == "arm") && tryCompileProject("unix/neon");
  2025. } else if (part == "FONT_CONFIG") {
  2026. available = tryCompileProject("unix/fontconfig");
  2027. }
  2028. return available;
  2029. }
  2030. /*
  2031. Autodetect options marked as "auto".
  2032. */
  2033. void Configure::autoDetection()
  2034. {
  2035. cout << "Running configuration tests..." << endl;
  2036. // Auto-detect CPU architectures.
  2037. detectArch();
  2038. if (dictionary["C++11"] == "auto") {
  2039. if (!dictionary["QMAKESPEC"].contains("msvc"))
  2040. dictionary["C++11"] = tryCompileProject("common/c++11") ? "yes" : "no";
  2041. }
  2042. // Style detection
  2043. if (dictionary["STYLE_WINDOWSXP"] == "auto")
  2044. dictionary["STYLE_WINDOWSXP"] = checkAvailability("STYLE_WINDOWSXP") ? defaultTo("STYLE_WINDOWSXP") : "no";
  2045. if (dictionary["STYLE_WINDOWSVISTA"] == "auto") // Vista style has the same requirements as XP style
  2046. dictionary["STYLE_WINDOWSVISTA"] = checkAvailability("STYLE_WINDOWSXP") ? defaultTo("STYLE_WINDOWSVISTA") : "no";
  2047. // Compression detection
  2048. if (dictionary["ZLIB"] == "auto")
  2049. dictionary["ZLIB"] = checkAvailability("ZLIB") ? defaultTo("ZLIB") : "qt";
  2050. // PCRE detection
  2051. if (dictionary["PCRE"] == "auto")
  2052. dictionary["PCRE"] = checkAvailability("PCRE") ? defaultTo("PCRE") : "qt";
  2053. // ICU detection
  2054. if (dictionary["ICU"] == "auto")
  2055. dictionary["ICU"] = checkAvailability("ICU") ? "yes" : "no";
  2056. // ANGLE detection
  2057. if (dictionary["ANGLE"] == "auto") {
  2058. if (dictionary["OPENGL_ES_2"] == "yes") {
  2059. dictionary["ANGLE"] = checkAngleAvailability() ? "yes" : "no";
  2060. dictionary["ANGLE_FROM"] = "detected";
  2061. } else {
  2062. dictionary["ANGLE"] = "no";
  2063. }
  2064. }
  2065. // Dynamic GL. This must be explicitly requested, no autodetection.
  2066. if (dictionary["DYNAMICGL"] == "auto")
  2067. dictionary["DYNAMICGL"] = "no";
  2068. // Image format detection
  2069. if (dictionary["GIF"] == "auto")
  2070. dictionary["GIF"] = defaultTo("GIF");
  2071. if (dictionary["JPEG"] == "auto")
  2072. dictionary["JPEG"] = defaultTo("JPEG");
  2073. if (dictionary["PNG"] == "auto")
  2074. dictionary["PNG"] = defaultTo("PNG");
  2075. if (dictionary["LIBJPEG"] == "auto")
  2076. dictionary["LIBJPEG"] = checkAvailability("LIBJPEG") ? defaultTo("LIBJPEG") : "qt";
  2077. if (dictionary["LIBPNG"] == "auto")
  2078. dictionary["LIBPNG"] = checkAvailability("LIBPNG") ? defaultTo("LIBPNG") : "qt";
  2079. // SQL detection (not on by default)
  2080. if (dictionary["SQL_MYSQL"] == "auto")
  2081. dictionary["SQL_MYSQL"] = checkAvailability("SQL_MYSQL") ? defaultTo("SQL_MYSQL") : "no";
  2082. if (dictionary["SQL_ODBC"] == "auto")
  2083. dictionary["SQL_ODBC"] = checkAvailability("SQL_ODBC") ? defaultTo("SQL_ODBC") : "no";
  2084. if (dictionary["SQL_OCI"] == "auto")
  2085. dictionary["SQL_OCI"] = checkAvailability("SQL_OCI") ? defaultTo("SQL_OCI") : "no";
  2086. if (dictionary["SQL_PSQL"] == "auto")
  2087. dictionary["SQL_PSQL"] = checkAvailability("SQL_PSQL") ? defaultTo("SQL_PSQL") : "no";
  2088. if (dictionary["SQL_TDS"] == "auto")
  2089. dictionary["SQL_TDS"] = checkAvailability("SQL_TDS") ? defaultTo("SQL_TDS") : "no";
  2090. if (dictionary["SQL_DB2"] == "auto")
  2091. dictionary["SQL_DB2"] = checkAvailability("SQL_DB2") ? defaultTo("SQL_DB2") : "no";
  2092. if (dictionary["SQL_SQLITE"] == "auto")
  2093. dictionary["SQL_SQLITE"] = checkAvailability("SQL_SQLITE") ? defaultTo("SQL_SQLITE") : "no";
  2094. if (dictionary["SQL_SQLITE_LIB"] == "system")
  2095. if (!checkAvailability("SQL_SQLITE_LIB"))
  2096. dictionary["SQL_SQLITE_LIB"] = "no";
  2097. if (dictionary["SQL_SQLITE2"] == "auto")
  2098. dictionary["SQL_SQLITE2"] = checkAvailability("SQL_SQLITE2") ? defaultTo("SQL_SQLITE2") : "no";
  2099. if (dictionary["SQL_IBASE"] == "auto")
  2100. dictionary["SQL_IBASE"] = checkAvailability("SQL_IBASE") ? defaultTo("SQL_IBASE") : "no";
  2101. if (dictionary["SSE2"] == "auto")
  2102. dictionary["SSE2"] = checkAvailability("SSE2") ? "yes" : "no";
  2103. if (dictionary["SSE3"] == "auto")
  2104. dictionary["SSE3"] = checkAvailability("SSE3") ? "yes" : "no";
  2105. if (dictionary["SSSE3"] == "auto")
  2106. dictionary["SSSE3"] = checkAvailability("SSSE3") ? "yes" : "no";
  2107. if (dictionary["SSE4_1"] == "auto")
  2108. dictionary["SSE4_1"] = checkAvailability("SSE4_1") ? "yes" : "no";
  2109. if (dictionary["SSE4_2"] == "auto")
  2110. dictionary["SSE4_2"] = checkAvailability("SSE4_2") ? "yes" : "no";
  2111. if (dictionary["AVX"] == "auto")
  2112. dictionary["AVX"] = checkAvailability("AVX") ? "yes" : "no";
  2113. if (dictionary["AVX2"] == "auto")
  2114. dictionary["AVX2"] = checkAvailability("AVX2") ? "yes" : "no";
  2115. if (dictionary["IWMMXT"] == "auto")
  2116. dictionary["IWMMXT"] = checkAvailability("IWMMXT") ? "yes" : "no";
  2117. if (dictionary["NEON"] == "auto")
  2118. dictionary["NEON"] = checkAvailability("NEON") ? "yes" : "no";
  2119. if (dictionary["OPENSSL"] == "auto")
  2120. dictionary["OPENSSL"] = checkAvailability("OPENSSL") ? "yes" : "no";
  2121. if (dictionary["DBUS"] == "auto")
  2122. dictionary["DBUS"] = checkAvailability("DBUS") ? "yes" : "no";
  2123. if (dictionary["QML_DEBUG"] == "auto")
  2124. dictionary["QML_DEBUG"] = dictionary["QML"] == "yes" ? "yes" : "no";
  2125. if (dictionary["AUDIO_BACKEND"] == "auto")
  2126. dictionary["AUDIO_BACKEND"] = checkAvailability("AUDIO_BACKEND") ? "yes" : "no";
  2127. if (dictionary["WMF_BACKEND"] == "auto")
  2128. dictionary["WMF_BACKEND"] = checkAvailability("WMF_BACKEND") ? "yes" : "no";
  2129. if (dictionary["WMSDK"] == "auto")
  2130. dictionary["WMSDK"] = checkAvailability("WMSDK") ? "yes" : "no";
  2131. // Qt/WinCE remote test application
  2132. if (dictionary["CETEST"] == "auto")
  2133. dictionary["CETEST"] = checkAvailability("CETEST") ? "yes" : "no";
  2134. // Detection of IncrediBuild buildconsole
  2135. if (dictionary["INCREDIBUILD_XGE"] == "auto")
  2136. dictionary["INCREDIBUILD_XGE"] = checkAvailability("INCREDIBUILD_XGE") ? "yes" : "no";
  2137. // Detection of iconv support
  2138. if (dictionary["QT_ICONV"] == "auto")
  2139. dictionary["QT_ICONV"] = checkAvailability("ICONV") ? "yes" : "no";
  2140. // Detection of evdev support
  2141. if (dictionary["QT_EVDEV"] == "auto")
  2142. dictionary["QT_EVDEV"] = checkAvailability("EVDEV") ? "yes" : "no";
  2143. // Detection of mtdev support
  2144. if (dictionary["QT_MTDEV"] == "auto")
  2145. dictionary["QT_MTDEV"] = checkAvailability("MTDEV") ? "yes" : "no";
  2146. // Detection of inotify
  2147. if (dictionary["QT_INOTIFY"] == "auto")
  2148. dictionary["QT_INOTIFY"] = checkAvailability("INOTIFY") ? "yes" : "no";
  2149. // Detection of cups support
  2150. if (dictionary["QT_CUPS"] == "auto")
  2151. dictionary["QT_CUPS"] = checkAvailability("CUPS") ? "yes" : "no";
  2152. // Detection of -fstack-protector-strong support
  2153. if (dictionary["STACK_PROTECTOR_STRONG"] == "auto")
  2154. dictionary["STACK_PROTECTOR_STRONG"] = checkAvailability("STACK_PROTECTOR_STRONG") ? "yes" : "no";
  2155. if ((platform() == QNX || platform() == BLACKBERRY) && dictionary["SLOG2"] == "auto") {
  2156. dictionary["SLOG2"] = checkAvailability("SLOG2") ? "yes" : "no";
  2157. }
  2158. if ((platform() == QNX || platform() == BLACKBERRY) && dictionary["QNX_IMF"] == "auto") {
  2159. dictionary["QNX_IMF"] = checkAvailability("QNX_IMF") ? "yes" : "no";
  2160. }
  2161. if (dictionary["PPS"] == "auto") {
  2162. dictionary["PPS"] = checkAvailability("PPS") ? "yes" : "no";
  2163. }
  2164. if ((platform() == QNX || platform() == BLACKBERRY) && dictionary["LGMON"] == "auto") {
  2165. dictionary["LGMON"] = checkAvailability("LGMON") ? "yes" : "no";
  2166. }
  2167. if (dictionary["QT_EVENTFD"] == "auto")
  2168. dictionary["QT_EVENTFD"] = checkAvailability("QT_EVENTFD") ? "yes" : "no";
  2169. if (dictionary["FONT_CONFIG"] == "auto")
  2170. dictionary["FONT_CONFIG"] = checkAvailability("FONT_CONFIG") ? "yes" : "no";
  2171. // Mark all unknown "auto" to the default value..
  2172. for (QMap<QString,QString>::iterator i = dictionary.begin(); i != dictionary.end(); ++i) {
  2173. if (i.value() == "auto")
  2174. i.value() = defaultTo(i.key());
  2175. }
  2176. if (tryCompileProject("unix/ptrsize"))
  2177. dictionary["QT_POINTER_SIZE"] = "8";
  2178. else
  2179. dictionary["QT_POINTER_SIZE"] = "4";
  2180. }
  2181. bool Configure::verifyConfiguration()
  2182. {
  2183. bool prompt = false;
  2184. if (dictionary["C++11"] != "auto"
  2185. && dictionary["QMAKESPEC"].contains("msvc")) {
  2186. cout << "WARNING: Qt does not support disabling or enabling any existing C++11 support "
  2187. "with MSVC compilers.";
  2188. if (dictionary["C++11"] == "yes")
  2189. cout << "Therefore -c++11 is ignored." << endl << endl;
  2190. else
  2191. cout << "Therefore -no-c++11 is ignored." << endl << endl;
  2192. dictionary["C++11"] = "auto";
  2193. }
  2194. if (dictionary["SQL_SQLITE_LIB"] == "no" && dictionary["SQL_SQLITE"] != "no") {
  2195. cout << "WARNING: Configure could not detect the presence of a system SQLite3 lib." << endl
  2196. << "Configure will therefore continue with the SQLite3 lib bundled with Qt." << endl;
  2197. dictionary["SQL_SQLITE_LIB"] = "qt"; // Set to Qt's bundled lib an continue
  2198. prompt = true;
  2199. }
  2200. if (dictionary["QMAKESPEC"].endsWith("-g++")
  2201. && dictionary["SQL_OCI"] != "no") {
  2202. cout << "WARNING: Qt does not support compiling the Oracle database driver with" << endl
  2203. << "MinGW, due to lack of such support from Oracle. Consider disabling the" << endl
  2204. << "Oracle driver, as the current build will most likely fail." << endl;
  2205. prompt = true;
  2206. }
  2207. if (dictionary["QMAKESPEC"].endsWith("win32-msvc.net")) {
  2208. cout << "WARNING: The makespec win32-msvc.net is deprecated. Consider using" << endl
  2209. << "win32-msvc2002 or win32-msvc2003 instead." << endl;
  2210. prompt = true;
  2211. }
  2212. if (0 != dictionary["ARM_FPU_TYPE"].size()) {
  2213. QStringList l= QStringList()
  2214. << "softvfp"
  2215. << "softvfp+vfpv2"
  2216. << "vfpv2";
  2217. if (!(l.contains(dictionary["ARM_FPU_TYPE"])))
  2218. cout << QString("WARNING: Using unsupported fpu flag: %1").arg(dictionary["ARM_FPU_TYPE"]) << endl;
  2219. }
  2220. if (dictionary["DIRECTWRITE"] == "yes" && !checkAvailability("DIRECTWRITE")) {
  2221. cout << "WARNING: To be able to compile the DirectWrite font engine you will" << endl
  2222. << "need the Microsoft DirectWrite and Microsoft Direct2D development" << endl
  2223. << "files such as headers and libraries." << endl;
  2224. prompt = true;
  2225. }
  2226. #if WINVER > 0x0601
  2227. if (dictionary["TARGET_OS"] == "xp") {
  2228. cout << "WARNING: Cannot use Windows Kit 8 to build Qt for Windows XP.\n"
  2229. "WARNING: Windows SDK v7.1A is recommended.\n";
  2230. }
  2231. #endif
  2232. if (dictionary["DIRECT2D"] == "yes" && !checkAvailability("DIRECT2D")) {
  2233. cout << "WARNING: To be able to build the Direct2D platform plugin you will" << endl
  2234. << "need the Microsoft DirectWrite and Microsoft Direct2D development" << endl
  2235. << "files such as headers and libraries." << endl;
  2236. prompt = true;
  2237. }
  2238. // -angle given on command line, but Direct X cannot be found.
  2239. if (dictionary["ANGLE"] != "no") {
  2240. QString errorMessage;
  2241. if (!checkAngleAvailability(&errorMessage)) {
  2242. cout << "WARNING: ANGLE specified, but the DirectX SDK could not be detected:" << endl
  2243. << " " << qPrintable(errorMessage) << endl
  2244. << "The build will most likely fail." << endl;
  2245. prompt = true;
  2246. }
  2247. } else if (dictionary["ANGLE"] == "no") {
  2248. if (dictionary["ANGLE_FROM"] == "detected") {
  2249. QString errorMessage;
  2250. checkAngleAvailability(&errorMessage);
  2251. cout << "WARNING: The DirectX SDK could not be detected:" << endl
  2252. << " " << qPrintable(errorMessage) << endl
  2253. << "Disabling the ANGLE backend." << endl;
  2254. prompt = true;
  2255. }
  2256. if ((dictionary["OPENGL_ES_2"] == "yes") && !dictionary.contains("XQMAKESPEC")) {
  2257. cout << endl << "WARNING: Using OpenGL ES 2.0 without ANGLE." << endl
  2258. << "Specify -opengl desktop to use Open GL." << endl
  2259. << "The build will most likely fail." << endl;
  2260. prompt = true;
  2261. }
  2262. }
  2263. if (dictionary["DYNAMICGL"] == "yes") {
  2264. if (dictionary["OPENGL_ES_2"] == "yes" || dictionary["ANGLE"] != "no") {
  2265. cout << "ERROR: Dynamic OpenGL cannot be used together with native Angle (GLES2) builds." << endl;
  2266. dictionary[ "DONE" ] = "error";
  2267. }
  2268. }
  2269. if (prompt)
  2270. promptKeyPress();
  2271. return true;
  2272. }
  2273. void Configure::prepareConfigTests()
  2274. {
  2275. // Generate an empty .qmake.cache file for config.tests
  2276. QDir buildDir(buildPath);
  2277. bool success = true;
  2278. if (!buildDir.exists("config.tests"))
  2279. success = buildDir.mkdir("config.tests");
  2280. QString fileName(buildPath + "/config.tests/.qmake.cache");
  2281. QFile cacheFile(fileName);
  2282. success &= cacheFile.open(QIODevice::WriteOnly);
  2283. cacheFile.close();
  2284. if (!success) {
  2285. cout << "Failed to create file " << qPrintable(QDir::toNativeSeparators(fileName)) << endl;
  2286. dictionary[ "DONE" ] = "error";
  2287. }
  2288. }
  2289. void Configure::generateOutputVars()
  2290. {
  2291. // Generate variables for output
  2292. QString build = dictionary[ "BUILD" ];
  2293. bool buildAll = (dictionary[ "BUILDALL" ] == "yes");
  2294. if (build == "debug") {
  2295. if (buildAll)
  2296. qtConfig += "debug_and_release build_all release";
  2297. qtConfig += "debug";
  2298. } else if (build == "release") {
  2299. if (buildAll)
  2300. qtConfig += "debug_and_release build_all debug";
  2301. qtConfig += "release";
  2302. }
  2303. if (dictionary[ "C++11" ] == "yes")
  2304. qtConfig += "c++11";
  2305. if (dictionary[ "SHARED" ] == "no")
  2306. qtConfig += "static";
  2307. else
  2308. qtConfig += "shared";
  2309. if (dictionary[ "GUI" ] == "no") {
  2310. qtConfig += "no-gui";
  2311. dictionary [ "WIDGETS" ] = "no";
  2312. }
  2313. if (dictionary[ "WIDGETS" ] == "no")
  2314. qtConfig += "no-widgets";
  2315. // Compression --------------------------------------------------
  2316. if (dictionary[ "ZLIB" ] == "qt")
  2317. qtConfig += "zlib";
  2318. else if (dictionary[ "ZLIB" ] == "system")
  2319. qtConfig += "system-zlib";
  2320. // PCRE ---------------------------------------------------------
  2321. if (dictionary[ "PCRE" ] == "qt")
  2322. qmakeConfig += "pcre";
  2323. // ICU ---------------------------------------------------------
  2324. if (dictionary[ "ICU" ] == "yes")
  2325. qtConfig += "icu";
  2326. // ANGLE --------------------------------------------------------
  2327. if (dictionary[ "ANGLE" ] != "no") {
  2328. qtConfig += "angle";
  2329. if (dictionary[ "ANGLE" ] == "d3d11")
  2330. qmakeConfig += "angle_d3d11";
  2331. }
  2332. // Dynamic OpenGL loading ---------------------------------------
  2333. if (dictionary[ "DYNAMICGL" ] != "no")
  2334. qtConfig += "dynamicgl";
  2335. // Image formates -----------------------------------------------
  2336. if (dictionary[ "GIF" ] == "no")
  2337. qtConfig += "no-gif";
  2338. else if (dictionary[ "GIF" ] == "yes")
  2339. qtConfig += "gif";
  2340. if (dictionary[ "JPEG" ] == "no")
  2341. qtConfig += "no-jpeg";
  2342. else if (dictionary[ "JPEG" ] == "yes")
  2343. qtConfig += "jpeg";
  2344. if (dictionary[ "LIBJPEG" ] == "system")
  2345. qtConfig += "system-jpeg";
  2346. if (dictionary[ "PNG" ] == "no")
  2347. qtConfig += "no-png";
  2348. else if (dictionary[ "PNG" ] == "yes")
  2349. qtConfig += "png";
  2350. if (dictionary[ "LIBPNG" ] == "system")
  2351. qtConfig += "system-png";
  2352. // Text rendering --------------------------------------------------
  2353. if (dictionary[ "FREETYPE" ] == "yes")
  2354. qtConfig += "freetype";
  2355. else if (dictionary[ "FREETYPE" ] == "system")
  2356. qtConfig += "system-freetype";
  2357. if (dictionary[ "HARFBUZZ" ] == "yes")
  2358. qtConfig += "harfbuzz";
  2359. else if (dictionary[ "HARFBUZZ" ] == "system")
  2360. qtConfig += "system-harfbuzz";
  2361. // Styles -------------------------------------------------------
  2362. if (dictionary[ "STYLE_WINDOWS" ] == "yes")
  2363. qmakeStyles += "windows";
  2364. if (dictionary[ "STYLE_FUSION" ] == "yes")
  2365. qmakeStyles += "fusion";
  2366. if (dictionary[ "STYLE_WINDOWSXP" ] == "yes")
  2367. qmakeStyles += "windowsxp";
  2368. if (dictionary[ "STYLE_WINDOWSVISTA" ] == "yes")
  2369. qmakeStyles += "windowsvista";
  2370. if (dictionary[ "STYLE_WINDOWSCE" ] == "yes")
  2371. qmakeStyles += "windowsce";
  2372. if (dictionary[ "STYLE_WINDOWSMOBILE" ] == "yes")
  2373. qmakeStyles += "windowsmobile";
  2374. // Databases ----------------------------------------------------
  2375. if (dictionary[ "SQL_MYSQL" ] == "yes")
  2376. qmakeSql += "mysql";
  2377. else if (dictionary[ "SQL_MYSQL" ] == "plugin")
  2378. qmakeSqlPlugins += "mysql";
  2379. if (dictionary[ "SQL_ODBC" ] == "yes")
  2380. qmakeSql += "odbc";
  2381. else if (dictionary[ "SQL_ODBC" ] == "plugin")
  2382. qmakeSqlPlugins += "odbc";
  2383. if (dictionary[ "SQL_OCI" ] == "yes")
  2384. qmakeSql += "oci";
  2385. else if (dictionary[ "SQL_OCI" ] == "plugin")
  2386. qmakeSqlPlugins += "oci";
  2387. if (dictionary[ "SQL_PSQL" ] == "yes")
  2388. qmakeSql += "psql";
  2389. else if (dictionary[ "SQL_PSQL" ] == "plugin")
  2390. qmakeSqlPlugins += "psql";
  2391. if (dictionary[ "SQL_TDS" ] == "yes")
  2392. qmakeSql += "tds";
  2393. else if (dictionary[ "SQL_TDS" ] == "plugin")
  2394. qmakeSqlPlugins += "tds";
  2395. if (dictionary[ "SQL_DB2" ] == "yes")
  2396. qmakeSql += "db2";
  2397. else if (dictionary[ "SQL_DB2" ] == "plugin")
  2398. qmakeSqlPlugins += "db2";
  2399. if (dictionary[ "SQL_SQLITE" ] == "yes")
  2400. qmakeSql += "sqlite";
  2401. else if (dictionary[ "SQL_SQLITE" ] == "plugin")
  2402. qmakeSqlPlugins += "sqlite";
  2403. if (dictionary[ "SQL_SQLITE_LIB" ] == "system")
  2404. qmakeConfig += "system-sqlite";
  2405. if (dictionary[ "SQL_SQLITE2" ] == "yes")
  2406. qmakeSql += "sqlite2";
  2407. else if (dictionary[ "SQL_SQLITE2" ] == "plugin")
  2408. qmakeSqlPlugins += "sqlite2";
  2409. if (dictionary[ "SQL_IBASE" ] == "yes")
  2410. qmakeSql += "ibase";
  2411. else if (dictionary[ "SQL_IBASE" ] == "plugin")
  2412. qmakeSqlPlugins += "ibase";
  2413. // Other options ------------------------------------------------
  2414. if (dictionary[ "BUILDALL" ] == "yes") {
  2415. qtConfig += "build_all";
  2416. }
  2417. if (dictionary[ "FORCEDEBUGINFO" ] == "yes")
  2418. qmakeConfig += "force_debug_info";
  2419. qmakeConfig += dictionary[ "BUILD" ];
  2420. if (buildParts.isEmpty()) {
  2421. buildParts = defaultBuildParts;
  2422. if (dictionary["BUILDDEV"] == "yes")
  2423. buildParts += "tests";
  2424. }
  2425. while (!nobuildParts.isEmpty())
  2426. buildParts.removeAll(nobuildParts.takeFirst());
  2427. if (!buildParts.contains("libs"))
  2428. buildParts += "libs";
  2429. buildParts.removeDuplicates();
  2430. if (dictionary[ "COMPILE_EXAMPLES" ] == "yes")
  2431. qmakeConfig += "compile_examples";
  2432. if (dictionary["MSVC_MP"] == "yes")
  2433. qmakeConfig += "msvc_mp";
  2434. if (dictionary[ "SHARED" ] == "yes") {
  2435. QString version = dictionary[ "VERSION" ];
  2436. if (!version.isEmpty()) {
  2437. qmakeVars += "QMAKE_QT_VERSION_OVERRIDE = " + version.left(version.indexOf('.'));
  2438. version.remove(QLatin1Char('.'));
  2439. }
  2440. }
  2441. if (dictionary[ "ACCESSIBILITY" ] == "yes")
  2442. qtConfig += "accessibility";
  2443. if (!qmakeLibs.isEmpty())
  2444. qmakeVars += "LIBS += " + formatPaths(qmakeLibs);
  2445. if (!dictionary["QT_LFLAGS_SQLITE"].isEmpty())
  2446. qmakeVars += "QT_LFLAGS_SQLITE += " + dictionary["QT_LFLAGS_SQLITE"];
  2447. if (dictionary[ "OPENGL" ] == "yes")
  2448. qtConfig += "opengl";
  2449. if (dictionary["OPENGL_ES_2"] == "yes") {
  2450. qtConfig += "opengles2";
  2451. qtConfig += "egl";
  2452. }
  2453. if (dictionary["OPENVG"] == "yes") {
  2454. qtConfig += "openvg";
  2455. qtConfig += "egl";
  2456. }
  2457. if (dictionary[ "OPENSSL" ] == "yes")
  2458. qtConfig += "openssl";
  2459. else if (dictionary[ "OPENSSL" ] == "linked")
  2460. qtConfig += "openssl-linked";
  2461. if (dictionary[ "DBUS" ] == "yes")
  2462. qtConfig += "dbus";
  2463. else if (dictionary[ "DBUS" ] == "linked")
  2464. qtConfig += "dbus dbus-linked";
  2465. if (dictionary[ "CETEST" ] == "yes")
  2466. qtConfig += "cetest";
  2467. // ### Vestige
  2468. if (dictionary["AUDIO_BACKEND"] == "yes")
  2469. qtConfig += "audio-backend";
  2470. if (dictionary["WMF_BACKEND"] == "yes")
  2471. qtConfig += "wmf-backend";
  2472. if (dictionary["DIRECTWRITE"] == "yes")
  2473. qtConfig += "directwrite";
  2474. if (dictionary["DIRECT2D"] == "yes")
  2475. qtConfig += "direct2d";
  2476. if (dictionary[ "NATIVE_GESTURES" ] == "yes")
  2477. qtConfig += "native-gestures";
  2478. qtConfig += "qpa";
  2479. if (dictionary["NIS"] == "yes")
  2480. qtConfig += "nis";
  2481. if (dictionary["QT_CUPS"] == "yes")
  2482. qtConfig += "cups";
  2483. if (dictionary["QT_ICONV"] == "yes")
  2484. qtConfig += "iconv";
  2485. else if (dictionary["QT_ICONV"] == "sun")
  2486. qtConfig += "sun-libiconv";
  2487. else if (dictionary["QT_ICONV"] == "gnu")
  2488. qtConfig += "gnu-libiconv";
  2489. if (dictionary["QT_EVDEV"] == "yes")
  2490. qtConfig += "evdev";
  2491. if (dictionary["QT_MTDEV"] == "yes")
  2492. qtConfig += "mtdev";
  2493. if (dictionary["QT_INOTIFY"] == "yes")
  2494. qtConfig += "inotify";
  2495. if (dictionary["QT_EVENTFD"] == "yes")
  2496. qtConfig += "eventfd";
  2497. if (dictionary["FONT_CONFIG"] == "yes") {
  2498. qtConfig += "fontconfig";
  2499. qmakeVars += "QMAKE_CFLAGS_FONTCONFIG =";
  2500. qmakeVars += "QMAKE_LIBS_FONTCONFIG = -lfreetype -lfontconfig";
  2501. }
  2502. if (dictionary["QT_GLIB"] == "yes")
  2503. qtConfig += "glib";
  2504. if (dictionary["STACK_PROTECTOR_STRONG"] == "yes")
  2505. qtConfig += "stack-protector-strong";
  2506. if (dictionary["REDUCE_EXPORTS"] == "yes")
  2507. qtConfig += "reduce_exports";
  2508. // We currently have no switch for QtConcurrent, so add it unconditionally.
  2509. qtConfig += "concurrent";
  2510. if (dictionary[ "SYSTEM_PROXIES" ] == "yes")
  2511. qtConfig += "system-proxies";
  2512. if (dictionary.contains("XQMAKESPEC") && (dictionary["QMAKESPEC"] != dictionary["XQMAKESPEC"])) {
  2513. qmakeConfig += "cross_compile";
  2514. dictionary["CROSS_COMPILE"] = "yes";
  2515. }
  2516. // Directories and settings for .qmake.cache --------------------
  2517. if (dictionary.contains("XQMAKESPEC") && dictionary[ "XQMAKESPEC" ].startsWith("linux"))
  2518. qtConfig += "rpath";
  2519. if (!qmakeDefines.isEmpty())
  2520. qmakeVars += QString("DEFINES += ") + qmakeDefines.join(' ');
  2521. if (!qmakeIncludes.isEmpty())
  2522. qmakeVars += QString("INCLUDEPATH += ") + formatPaths(qmakeIncludes);
  2523. if (!opensslLibs.isEmpty())
  2524. qmakeVars += opensslLibs;
  2525. if (dictionary[ "OPENSSL" ] == "linked") {
  2526. if (!opensslLibsDebug.isEmpty() || !opensslLibsRelease.isEmpty()) {
  2527. if (opensslLibsDebug.isEmpty() || opensslLibsRelease.isEmpty()) {
  2528. cout << "Error: either both or none of OPENSSL_LIBS_DEBUG/_RELEASE must be defined." << endl;
  2529. exit(1);
  2530. }
  2531. qmakeVars += opensslLibsDebug;
  2532. qmakeVars += opensslLibsRelease;
  2533. } else if (opensslLibs.isEmpty()) {
  2534. qmakeVars += QString("OPENSSL_LIBS = -lssleay32 -llibeay32");
  2535. }
  2536. if (!opensslPath.isEmpty()) {
  2537. qmakeVars += QString("OPENSSL_CFLAGS += -I%1/include").arg(opensslPath);
  2538. qmakeVars += QString("OPENSSL_LIBS += -L%1/lib").arg(opensslPath);
  2539. }
  2540. }
  2541. if (dictionary[ "DBUS" ] != "no" && !dbusPath.isEmpty()) {
  2542. qmakeVars += QString("QT_CFLAGS_DBUS = -I%1/include").arg(dbusPath);
  2543. qmakeVars += QString("QT_LIBS_DBUS = -L%1/lib").arg(dbusPath);
  2544. }
  2545. if (dictionary[ "SQL_MYSQL" ] != "no" && !mysqlPath.isEmpty()) {
  2546. qmakeVars += QString("QT_CFLAGS_MYSQL = -I%1/include").arg(mysqlPath);
  2547. qmakeVars += QString("QT_LFLAGS_MYSQL = -L%1/lib").arg(mysqlPath);
  2548. }
  2549. if (!psqlLibs.isEmpty())
  2550. qmakeVars += QString("QT_LFLAGS_PSQL=") + psqlLibs.section("=", 1);
  2551. if (!zlibLibs.isEmpty())
  2552. qmakeVars += zlibLibs;
  2553. {
  2554. QStringList lflagsTDS;
  2555. if (!sybase.isEmpty())
  2556. lflagsTDS += QString("-L") + formatPath(sybase.section("=", 1) + "/lib");
  2557. if (!sybaseLibs.isEmpty())
  2558. lflagsTDS += sybaseLibs.section("=", 1);
  2559. if (!lflagsTDS.isEmpty())
  2560. qmakeVars += QString("QT_LFLAGS_TDS=") + lflagsTDS.join(' ');
  2561. }
  2562. if (!qmakeSql.isEmpty())
  2563. qmakeVars += QString("sql-drivers += ") + qmakeSql.join(' ');
  2564. if (!qmakeSqlPlugins.isEmpty())
  2565. qmakeVars += QString("sql-plugins += ") + qmakeSqlPlugins.join(' ');
  2566. if (!qmakeStyles.isEmpty())
  2567. qmakeVars += QString("styles += ") + qmakeStyles.join(' ');
  2568. if (!qmakeStylePlugins.isEmpty())
  2569. qmakeVars += QString("style-plugins += ") + qmakeStylePlugins.join(' ');
  2570. if (dictionary["QMAKESPEC"].endsWith("-g++")) {
  2571. QString includepath = qgetenv("INCLUDE");
  2572. const bool hasSh = !QStandardPaths::findExecutable(QStringLiteral("sh.exe")).isEmpty();
  2573. QChar separator = (!includepath.contains(":\\") && hasSh ? QChar(':') : QChar(';'));
  2574. qmakeVars += QString("TMPPATH = $$quote($$(INCLUDE))");
  2575. qmakeVars += QString("QMAKE_INCDIR_POST += $$split(TMPPATH,\"%1\")").arg(separator);
  2576. qmakeVars += QString("TMPPATH = $$quote($$(LIB))");
  2577. qmakeVars += QString("QMAKE_LIBDIR_POST += $$split(TMPPATH,\"%1\")").arg(separator);
  2578. }
  2579. if (!dictionary[ "QMAKESPEC" ].length()) {
  2580. cout << "Configure could not detect your compiler. QMAKESPEC must either" << endl
  2581. << "be defined as an environment variable, or specified as an" << endl
  2582. << "argument with -platform" << endl;
  2583. QStringList winPlatforms;
  2584. QDir mkspecsDir(sourcePath + "/mkspecs");
  2585. const QFileInfoList &specsList = mkspecsDir.entryInfoList();
  2586. for (int i = 0; i < specsList.size(); ++i) {
  2587. const QFileInfo &fi = specsList.at(i);
  2588. if (fi.fileName().left(5) == "win32") {
  2589. winPlatforms += fi.fileName();
  2590. }
  2591. }
  2592. cout << "Available platforms are: " << qPrintable(winPlatforms.join(", ")) << endl;
  2593. dictionary[ "DONE" ] = "error";
  2594. }
  2595. }
  2596. void Configure::generateCachefile()
  2597. {
  2598. // Generate qmodule.pri
  2599. {
  2600. FileWriter moduleStream(buildPath + "/mkspecs/qmodule.pri");
  2601. moduleStream << "QT_BUILD_PARTS += " << buildParts.join(' ') << endl;
  2602. if (!skipModules.isEmpty())
  2603. moduleStream << "QT_SKIP_MODULES += " << skipModules.join(' ') << endl;
  2604. QString qcpath = dictionary["QCONFIG_PATH"];
  2605. QString qlpath = sourcePath + "/src/corelib/global/";
  2606. if (qcpath.startsWith(qlpath))
  2607. qcpath.remove(0, qlpath.length());
  2608. moduleStream << "QT_QCONFIG_PATH = " << qcpath << endl;
  2609. moduleStream << endl;
  2610. moduleStream << "host_build {" << endl;
  2611. moduleStream << " QT_CPU_FEATURES." << dictionary["QT_HOST_ARCH"] <<
  2612. " = " << dictionary["QT_HOST_CPU_FEATURES"] << endl;
  2613. moduleStream << "} else {" << endl;
  2614. moduleStream << " QT_CPU_FEATURES." << dictionary["QT_ARCH"] <<
  2615. " = " << dictionary["QT_CPU_FEATURES"] << endl;
  2616. moduleStream << "}" << endl;
  2617. moduleStream << "QT_COORD_TYPE += " << dictionary["QREAL"] << endl;
  2618. if (dictionary["QT_XKBCOMMON"] == "no")
  2619. moduleStream << "DEFINES += QT_NO_XKBCOMMON" << endl;
  2620. if (dictionary["CETEST"] == "yes") {
  2621. moduleStream << "QT_CE_RAPI_INC = " << formatPath(dictionary["QT_CE_RAPI_INC"]) << endl;
  2622. moduleStream << "QT_CE_RAPI_LIB = " << formatPath(dictionary["QT_CE_RAPI_LIB"]) << endl;
  2623. }
  2624. moduleStream << "#Qt for Windows CE c-runtime deployment" << endl
  2625. << "QT_CE_C_RUNTIME = " << formatPath(dictionary["CE_CRT"]) << endl;
  2626. if (dictionary["CE_SIGNATURE"] != QLatin1String("no"))
  2627. moduleStream << "DEFAULT_SIGNATURE=" << dictionary["CE_SIGNATURE"] << endl;
  2628. // embedded
  2629. if (!dictionary["KBD_DRIVERS"].isEmpty())
  2630. moduleStream << "kbd-drivers += "<< dictionary["KBD_DRIVERS"]<<endl;
  2631. if (!dictionary["GFX_DRIVERS"].isEmpty())
  2632. moduleStream << "gfx-drivers += "<< dictionary["GFX_DRIVERS"]<<endl;
  2633. if (!dictionary["MOUSE_DRIVERS"].isEmpty())
  2634. moduleStream << "mouse-drivers += "<< dictionary["MOUSE_DRIVERS"]<<endl;
  2635. if (!dictionary["DECORATIONS"].isEmpty())
  2636. moduleStream << "decorations += "<<dictionary["DECORATIONS"]<<endl;
  2637. moduleStream << "CONFIG += " << qmakeConfig.join(' ');
  2638. if (dictionary[ "SSE2" ] == "yes")
  2639. moduleStream << " sse2";
  2640. if (dictionary[ "SSE3" ] == "yes")
  2641. moduleStream << " sse3";
  2642. if (dictionary[ "SSSE3" ] == "yes")
  2643. moduleStream << " ssse3";
  2644. if (dictionary[ "SSE4_1" ] == "yes")
  2645. moduleStream << " sse4_1";
  2646. if (dictionary[ "SSE4_2" ] == "yes")
  2647. moduleStream << " sse4_2";
  2648. if (dictionary[ "AVX" ] == "yes")
  2649. moduleStream << " avx";
  2650. if (dictionary[ "AVX2" ] == "yes")
  2651. moduleStream << " avx2";
  2652. if (dictionary[ "IWMMXT" ] == "yes")
  2653. moduleStream << " iwmmxt";
  2654. if (dictionary[ "NEON" ] == "yes")
  2655. moduleStream << " neon";
  2656. if (dictionary[ "LARGE_FILE" ] == "yes")
  2657. moduleStream << " largefile";
  2658. if (dictionary[ "STRIP" ] == "no")
  2659. moduleStream << " nostrip";
  2660. moduleStream << endl;
  2661. for (QStringList::Iterator var = qmakeVars.begin(); var != qmakeVars.end(); ++var)
  2662. moduleStream << (*var) << endl;
  2663. if (!moduleStream.flush())
  2664. dictionary[ "DONE" ] = "error";
  2665. }
  2666. }
  2667. struct ArchData {
  2668. const char *qmakespec;
  2669. const char *key;
  2670. const char *subarchKey;
  2671. const char *type;
  2672. ArchData() {}
  2673. ArchData(const char *t, const char *qm, const char *k, const char *sak)
  2674. : qmakespec(qm), key(k), subarchKey(sak), type(t)
  2675. {}
  2676. };
  2677. /*
  2678. Runs qmake on config.tests/arch/arch.pro, which will detect the target arch
  2679. for the compiler we are using
  2680. */
  2681. void Configure::detectArch()
  2682. {
  2683. QString oldpwd = QDir::currentPath();
  2684. QString newpwd = QString("%1/config.tests/arch").arg(buildPath);
  2685. if (!QDir().exists(newpwd) && !QDir().mkpath(newpwd)) {
  2686. cout << "Failed to create directory " << qPrintable(QDir::toNativeSeparators(newpwd)) << endl;
  2687. dictionary["DONE"] = "error";
  2688. return;
  2689. }
  2690. if (!QDir::setCurrent(newpwd)) {
  2691. cout << "Failed to change working directory to " << qPrintable(QDir::toNativeSeparators(newpwd)) << endl;
  2692. dictionary["DONE"] = "error";
  2693. return;
  2694. }
  2695. QVector<ArchData> qmakespecs;
  2696. if (dictionary.contains("XQMAKESPEC"))
  2697. qmakespecs << ArchData("target", "XQMAKESPEC", "QT_ARCH", "QT_CPU_FEATURES");
  2698. qmakespecs << ArchData("host", "QMAKESPEC", "QT_HOST_ARCH", "QT_HOST_CPU_FEATURES");
  2699. for (int i = 0; i < qmakespecs.count(); ++i) {
  2700. const ArchData &data = qmakespecs.at(i);
  2701. QString qmakespec = dictionary.value(data.qmakespec);
  2702. QString key = data.key;
  2703. QString subarchKey = data.subarchKey;
  2704. // run qmake
  2705. QString command = QString("%1 -spec %2 %3")
  2706. .arg(QDir::toNativeSeparators(buildPath + "/bin/qmake.exe"),
  2707. QDir::toNativeSeparators(qmakespec),
  2708. QDir::toNativeSeparators(sourcePath + "/config.tests/arch/arch.pro"));
  2709. if (qmakespec.startsWith("winrt") || qmakespec.startsWith("winphone"))
  2710. command.append(" QMAKE_LFLAGS+=/ENTRY:main");
  2711. int returnValue = 0;
  2712. Environment::execute(command, &returnValue);
  2713. if (returnValue != 0) {
  2714. cout << "QMake failed!" << endl;
  2715. dictionary["DONE"] = "error";
  2716. return;
  2717. }
  2718. // compile
  2719. command = dictionary[ "MAKE" ];
  2720. if (command.contains("nmake"))
  2721. command += " /NOLOGO";
  2722. command += " -s";
  2723. Environment::execute(command);
  2724. // find the executable that was generated
  2725. QString arch_exe;
  2726. if (qmakespec.startsWith("android")) {
  2727. arch_exe = "libarch.so";
  2728. } else {
  2729. arch_exe = "arch.exe";
  2730. }
  2731. QFile exe(arch_exe);
  2732. if (!exe.open(QFile::ReadOnly)) { // no Text, this is binary
  2733. exe.setFileName("arch");
  2734. if (!exe.open(QFile::ReadOnly)) {
  2735. cout << "Could not find output file: " << qPrintable(exe.errorString()) << endl;
  2736. dictionary["DONE"] = "error";
  2737. return;
  2738. }
  2739. }
  2740. QByteArray exeContents = exe.readAll();
  2741. exe.close();
  2742. static const char archMagic[] = "==Qt=magic=Qt== Architecture:";
  2743. int magicPos = exeContents.indexOf(archMagic);
  2744. if (magicPos == -1) {
  2745. cout << "Internal error, could not find the architecture of the "
  2746. << data.type << " executable" << endl;
  2747. dictionary["DONE"] = "error";
  2748. return;
  2749. }
  2750. //cout << "Found magic at offset 0x" << hex << magicPos << endl;
  2751. // the conversion from QByteArray will stop at the ending NUL anyway
  2752. QString arch = QString::fromLatin1(exeContents.constData() + magicPos
  2753. + sizeof(archMagic) - 1);
  2754. dictionary[key] = arch;
  2755. static const char subarchMagic[] = "==Qt=magic=Qt== Sub-architecture:";
  2756. magicPos = exeContents.indexOf(subarchMagic);
  2757. if (magicPos == -1) {
  2758. cout << "Internal error, could not find the sub-architecture of the "
  2759. << data.type << " executable" << endl;
  2760. dictionary["DONE"] = "error";
  2761. return;
  2762. }
  2763. QString subarch = QString::fromLatin1(exeContents.constData() + magicPos
  2764. + sizeof(subarchMagic) - 1);
  2765. dictionary[subarchKey] = subarch;
  2766. //cout << "Detected arch '" << qPrintable(arch) << "'\n";
  2767. //cout << "Detected sub-arch '" << qPrintable(subarch) << "'\n";
  2768. // clean up
  2769. Environment::execute(command + " distclean");
  2770. }
  2771. if (!dictionary.contains("QT_HOST_ARCH"))
  2772. dictionary["QT_HOST_ARCH"] = "unknown";
  2773. if (!dictionary.contains("QT_ARCH")) {
  2774. dictionary["QT_ARCH"] = dictionary["QT_HOST_ARCH"];
  2775. dictionary["QT_CPU_FEATURES"] = dictionary["QT_HOST_CPU_FEATURES"];
  2776. }
  2777. QDir::setCurrent(oldpwd);
  2778. }
  2779. bool Configure::tryCompileProject(const QString &projectPath, const QString &extraOptions)
  2780. {
  2781. QString oldpwd = QDir::currentPath();
  2782. QString newpwd = QString("%1/config.tests/%2").arg(buildPath, projectPath);
  2783. if (!QDir().exists(newpwd) && !QDir().mkpath(newpwd)) {
  2784. cout << "Failed to create directory " << qPrintable(QDir::toNativeSeparators(newpwd)) << endl;
  2785. dictionary["DONE"] = "error";
  2786. return false;
  2787. }
  2788. if (!QDir::setCurrent(newpwd)) {
  2789. cout << "Failed to change working directory to " << qPrintable(QDir::toNativeSeparators(newpwd)) << endl;
  2790. dictionary["DONE"] = "error";
  2791. return false;
  2792. }
  2793. // run qmake
  2794. QString command = QString("%1 %2 %3 2>&1")
  2795. .arg(QDir::toNativeSeparators(buildPath + "/bin/qmake.exe"),
  2796. QDir::toNativeSeparators(sourcePath + "/config.tests/" + projectPath),
  2797. extraOptions);
  2798. if (dictionary.contains("XQMAKESPEC")) {
  2799. const QString qmakespec = dictionary["XQMAKESPEC"];
  2800. if (qmakespec.startsWith("winrt") || qmakespec.startsWith("winphone"))
  2801. command.append(" QMAKE_LFLAGS+=/ENTRY:main");
  2802. }
  2803. int code = 0;
  2804. QString output = Environment::execute(command, &code);
  2805. //cout << output << endl;
  2806. if (code == 0) {
  2807. // compile
  2808. command = dictionary[ "MAKE" ];
  2809. if (command.contains("nmake"))
  2810. command += " /NOLOGO";
  2811. command += " -s 2>&1";
  2812. output = Environment::execute(command, &code);
  2813. //cout << output << endl;
  2814. // clean up
  2815. Environment::execute(command + " distclean 2>&1");
  2816. }
  2817. QDir::setCurrent(oldpwd);
  2818. return code == 0;
  2819. }
  2820. bool Configure::compilerSupportsFlag(const QString &compilerAndArgs)
  2821. {
  2822. QFile file("conftest.cpp");
  2823. if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
  2824. cout << "could not open temp file for writing" << endl;
  2825. return false;
  2826. }
  2827. if (!file.write("int main() { return 0; }\r\n")) {
  2828. cout << "could not write to temp file" << endl;
  2829. return false;
  2830. }
  2831. file.close();
  2832. // compilerAndArgs contains compiler because there is no way to query it
  2833. QString command = compilerAndArgs + " -o conftest-out.o conftest.cpp";
  2834. int code = 0;
  2835. QString output = Environment::execute(command, &code);
  2836. file.remove();
  2837. QFile::remove("conftest-out.o");
  2838. return code == 0;
  2839. }
  2840. void Configure::generateQDevicePri()
  2841. {
  2842. FileWriter deviceStream(buildPath + "/mkspecs/qdevice.pri");
  2843. if (dictionary.contains("DEVICE_OPTION")) {
  2844. const QString devoptionlist = dictionary["DEVICE_OPTION"];
  2845. const QStringList optionlist = devoptionlist.split(QStringLiteral("\n"));
  2846. foreach (const QString &entry, optionlist)
  2847. deviceStream << entry << "\n";
  2848. }
  2849. if (dictionary.contains("ANDROID_SDK_ROOT") && dictionary.contains("ANDROID_NDK_ROOT")) {
  2850. QString android_platform(dictionary.contains("ANDROID_PLATFORM")
  2851. ? dictionary["ANDROID_PLATFORM"]
  2852. : QString("android-9"));
  2853. deviceStream << "android_install {" << endl;
  2854. deviceStream << " DEFAULT_ANDROID_SDK_ROOT = " << formatPath(dictionary["ANDROID_SDK_ROOT"]) << endl;
  2855. deviceStream << " DEFAULT_ANDROID_NDK_ROOT = " << formatPath(dictionary["ANDROID_NDK_ROOT"]) << endl;
  2856. deviceStream << " DEFAULT_ANDROID_PLATFORM = " << android_platform << endl;
  2857. if (QSysInfo::WordSize == 64)
  2858. deviceStream << " DEFAULT_ANDROID_NDK_HOST = windows-x86_64" << endl;
  2859. else
  2860. deviceStream << " DEFAULT_ANDROID_NDK_HOST = windows" << endl;
  2861. QString android_arch(dictionary.contains("ANDROID_TARGET_ARCH")
  2862. ? dictionary["ANDROID_TARGET_ARCH"]
  2863. : QString("armeabi-v7a"));
  2864. QString android_tc_vers(dictionary.contains("ANDROID_NDK_TOOLCHAIN_VERSION")
  2865. ? dictionary["ANDROID_NDK_TOOLCHAIN_VERSION"]
  2866. : QString("4.8"));
  2867. deviceStream << " DEFAULT_ANDROID_TARGET_ARCH = " << android_arch << endl;
  2868. deviceStream << " DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION = " << android_tc_vers << endl;
  2869. deviceStream << "}" << endl;
  2870. }
  2871. if (!deviceStream.flush())
  2872. dictionary[ "DONE" ] = "error";
  2873. }
  2874. void Configure::generateQConfigPri()
  2875. {
  2876. // Generate qconfig.pri
  2877. {
  2878. FileWriter configStream(buildPath + "/mkspecs/qconfig.pri");
  2879. configStream << "CONFIG+= ";
  2880. configStream << dictionary[ "BUILD" ];
  2881. configStream << (dictionary[ "SHARED" ] == "no" ? " static" : " shared");
  2882. if (dictionary[ "LTCG" ] == "yes")
  2883. configStream << " ltcg";
  2884. if (dictionary[ "RTTI" ] == "yes")
  2885. configStream << " rtti";
  2886. if (dictionary["INCREDIBUILD_XGE"] == "yes")
  2887. configStream << " incredibuild_xge";
  2888. if (dictionary["PLUGIN_MANIFESTS"] == "no")
  2889. configStream << " no_plugin_manifest";
  2890. if (dictionary["CROSS_COMPILE"] == "yes")
  2891. configStream << " cross_compile";
  2892. if (dictionary[ "SLOG2" ] == "yes")
  2893. configStream << " slog2";
  2894. if (dictionary[ "QNX_IMF" ] == "yes")
  2895. configStream << " qqnx_imf";
  2896. if (dictionary[ "PPS" ] == "yes")
  2897. configStream << " qqnx_pps";
  2898. if (dictionary[ "LGMON" ] == "yes")
  2899. configStream << " lgmon";
  2900. if (dictionary["DIRECTWRITE"] == "yes")
  2901. configStream << " directwrite";
  2902. // ### For compatibility only, should be removed later.
  2903. configStream << " qpa";
  2904. configStream << endl;
  2905. configStream << "host_build {" << endl;
  2906. configStream << " QT_ARCH = " << dictionary["QT_HOST_ARCH"] << endl;
  2907. configStream << " QT_TARGET_ARCH = " << dictionary["QT_ARCH"] << endl;
  2908. configStream << "} else {" << endl;
  2909. configStream << " QT_ARCH = " << dictionary["QT_ARCH"] << endl;
  2910. if (dictionary.contains("XQMAKESPEC") && !dictionary["XQMAKESPEC"].startsWith("wince")) {
  2911. // FIXME: add detection
  2912. configStream << " QMAKE_DEFAULT_LIBDIRS = /lib /usr/lib" << endl;
  2913. configStream << " QMAKE_DEFAULT_INCDIRS = /usr/include /usr/local/include" << endl;
  2914. }
  2915. configStream << "}" << endl;
  2916. configStream << "QT_CONFIG += " << qtConfig.join(' ') << endl;
  2917. configStream << "#versioning " << endl
  2918. << "QT_VERSION = " << dictionary["VERSION"] << endl
  2919. << "QT_MAJOR_VERSION = " << dictionary["VERSION_MAJOR"] << endl
  2920. << "QT_MINOR_VERSION = " << dictionary["VERSION_MINOR"] << endl
  2921. << "QT_PATCH_VERSION = " << dictionary["VERSION_PATCH"] << endl;
  2922. if (!dictionary["CFG_SYSROOT"].isEmpty() && dictionary["CFG_GCC_SYSROOT"] == "yes") {
  2923. configStream << endl
  2924. << "# sysroot" << endl
  2925. << "!host_build {" << endl
  2926. << " QMAKE_CFLAGS += --sysroot=$$[QT_SYSROOT]" << endl
  2927. << " QMAKE_CXXFLAGS += --sysroot=$$[QT_SYSROOT]" << endl
  2928. << " QMAKE_LFLAGS += --sysroot=$$[QT_SYSROOT]" << endl
  2929. << "}" << endl;
  2930. }
  2931. const QString targetOS = dictionary.value("TARGET_OS");
  2932. if (!targetOS.isEmpty())
  2933. configStream << "QMAKE_TARGET_OS = " << targetOS << endl;
  2934. if (!dictionary["QMAKE_RPATHDIR"].isEmpty())
  2935. configStream << "QMAKE_RPATHDIR += " << formatPath(dictionary["QMAKE_RPATHDIR"]) << endl;
  2936. if (!dictionary["QT_LIBINFIX"].isEmpty())
  2937. configStream << "QT_LIBINFIX = " << dictionary["QT_LIBINFIX"] << endl;
  2938. if (!dictionary["QT_NAMESPACE"].isEmpty())
  2939. configStream << "#namespaces" << endl << "QT_NAMESPACE = " << dictionary["QT_NAMESPACE"] << endl;
  2940. if (dictionary[ "SHARED" ] == "no")
  2941. configStream << "QT_DEFAULT_QPA_PLUGIN = q" << qpaPlatformName() << endl;
  2942. if (!configStream.flush())
  2943. dictionary[ "DONE" ] = "error";
  2944. }
  2945. }
  2946. QString Configure::addDefine(QString def)
  2947. {
  2948. QString result, defNeg, defD = def;
  2949. defD.replace(QRegExp("=.*"), "");
  2950. def.replace(QRegExp("="), " ");
  2951. if (def.startsWith("QT_NO_")) {
  2952. defNeg = defD;
  2953. defNeg.replace("QT_NO_", "QT_");
  2954. } else if (def.startsWith("QT_")) {
  2955. defNeg = defD;
  2956. defNeg.replace("QT_", "QT_NO_");
  2957. }
  2958. if (defNeg.isEmpty()) {
  2959. result = "#ifndef $DEFD\n"
  2960. "# define $DEF\n"
  2961. "#endif\n\n";
  2962. } else {
  2963. result = "#if defined($DEFD) && defined($DEFNEG)\n"
  2964. "# undef $DEFD\n"
  2965. "#elif !defined($DEFD)\n"
  2966. "# define $DEF\n"
  2967. "#endif\n\n";
  2968. }
  2969. result.replace("$DEFNEG", defNeg);
  2970. result.replace("$DEFD", defD);
  2971. result.replace("$DEF", def);
  2972. return result;
  2973. }
  2974. void Configure::generateConfigfiles()
  2975. {
  2976. {
  2977. FileWriter tmpStream(buildPath + "/src/corelib/global/qconfig.h");
  2978. if (dictionary[ "QCONFIG" ] == "full") {
  2979. tmpStream << "/* Everything */" << endl;
  2980. } else {
  2981. tmpStream << "#ifndef QT_BOOTSTRAPPED" << endl;
  2982. QFile inFile(dictionary["QCONFIG_PATH"]);
  2983. if (inFile.open(QFile::ReadOnly)) {
  2984. tmpStream << QTextStream(&inFile).readAll();
  2985. inFile.close();
  2986. }
  2987. tmpStream << "#endif // QT_BOOTSTRAPPED" << endl;
  2988. }
  2989. tmpStream << endl;
  2990. if (dictionary[ "SHARED" ] == "no") {
  2991. tmpStream << "/* Qt was configured for a static build */" << endl
  2992. << "#if !defined(QT_SHARED) && !defined(QT_STATIC)" << endl
  2993. << "# define QT_STATIC" << endl
  2994. << "#endif" << endl
  2995. << endl;
  2996. }
  2997. tmpStream << "/* License information */" << endl;
  2998. tmpStream << "#define QT_PRODUCT_LICENSEE \"" << dictionary[ "LICENSEE" ] << "\"" << endl;
  2999. tmpStream << "#define QT_PRODUCT_LICENSE \"" << dictionary[ "EDITION" ] << "\"" << endl;
  3000. tmpStream << endl;
  3001. if (dictionary["BUILDDEV"] == "yes") {
  3002. dictionary["QMAKE_INTERNAL"] = "yes";
  3003. tmpStream << "/* Used for example to export symbols for the certain autotests*/" << endl;
  3004. tmpStream << "#define QT_BUILD_INTERNAL" << endl;
  3005. tmpStream << endl;
  3006. }
  3007. tmpStream << endl << "// Compiler sub-arch support" << endl;
  3008. if (dictionary[ "SSE2" ] == "yes")
  3009. tmpStream << "#define QT_COMPILER_SUPPORTS_SSE2" << endl;
  3010. if (dictionary[ "SSE3" ] == "yes")
  3011. tmpStream << "#define QT_COMPILER_SUPPORTS_SSE3" << endl;
  3012. if (dictionary[ "SSSE3" ] == "yes")
  3013. tmpStream << "#define QT_COMPILER_SUPPORTS_SSSE3" << endl;
  3014. if (dictionary[ "SSE4_1" ] == "yes")
  3015. tmpStream << "#define QT_COMPILER_SUPPORTS_SSE4_1" << endl;
  3016. if (dictionary[ "SSE4_2" ] == "yes")
  3017. tmpStream << "#define QT_COMPILER_SUPPORTS_SSE4_2" << endl;
  3018. if (dictionary[ "AVX" ] == "yes")
  3019. tmpStream << "#define QT_COMPILER_SUPPORTS_AVX" << endl;
  3020. if (dictionary[ "AVX2" ] == "yes")
  3021. tmpStream << "#define QT_COMPILER_SUPPORTS_AVX2" << endl;
  3022. if (dictionary[ "IWMMXT" ] == "yes")
  3023. tmpStream << "#define QT_COMPILER_SUPPORTS_IWMMXT" << endl;
  3024. if (dictionary["QREAL"] != "double")
  3025. tmpStream << "#define QT_COORD_TYPE " << dictionary["QREAL"] << endl;
  3026. tmpStream << endl << "// Compile time features" << endl;
  3027. QStringList qconfigList;
  3028. if (dictionary["STYLE_WINDOWS"] != "yes") qconfigList += "QT_NO_STYLE_WINDOWS";
  3029. if (dictionary["STYLE_FUSION"] != "yes") qconfigList += "QT_NO_STYLE_FUSION";
  3030. if (dictionary["STYLE_WINDOWSXP"] != "yes" && dictionary["STYLE_WINDOWSVISTA"] != "yes")
  3031. qconfigList += "QT_NO_STYLE_WINDOWSXP";
  3032. if (dictionary["STYLE_WINDOWSVISTA"] != "yes") qconfigList += "QT_NO_STYLE_WINDOWSVISTA";
  3033. if (dictionary["STYLE_WINDOWSCE"] != "yes") qconfigList += "QT_NO_STYLE_WINDOWSCE";
  3034. if (dictionary["STYLE_WINDOWSMOBILE"] != "yes") qconfigList += "QT_NO_STYLE_WINDOWSMOBILE";
  3035. if (dictionary["STYLE_GTK"] != "yes") qconfigList += "QT_NO_STYLE_GTK";
  3036. if (dictionary["GIF"] == "yes") qconfigList += "QT_BUILTIN_GIF_READER=1";
  3037. if (dictionary["PNG"] != "yes") qconfigList += "QT_NO_IMAGEFORMAT_PNG";
  3038. if (dictionary["JPEG"] != "yes") qconfigList += "QT_NO_IMAGEFORMAT_JPEG";
  3039. if (dictionary["ZLIB"] == "no") {
  3040. qconfigList += "QT_NO_ZLIB";
  3041. qconfigList += "QT_NO_COMPRESS";
  3042. }
  3043. if (dictionary["ACCESSIBILITY"] == "no") qconfigList += "QT_NO_ACCESSIBILITY";
  3044. if (dictionary["WIDGETS"] == "no") qconfigList += "QT_NO_WIDGETS";
  3045. if (dictionary["GUI"] == "no") qconfigList += "QT_NO_GUI";
  3046. if (dictionary["OPENGL"] == "no") qconfigList += "QT_NO_OPENGL";
  3047. if (dictionary["OPENVG"] == "no") qconfigList += "QT_NO_OPENVG";
  3048. if (dictionary["OPENSSL"] == "no") {
  3049. qconfigList += "QT_NO_OPENSSL";
  3050. qconfigList += "QT_NO_SSL";
  3051. }
  3052. if (dictionary["OPENSSL"] == "linked") qconfigList += "QT_LINKED_OPENSSL";
  3053. if (dictionary["DBUS"] == "no") qconfigList += "QT_NO_DBUS";
  3054. if (dictionary["QML_DEBUG"] == "no") qconfigList += "QT_QML_NO_DEBUGGER";
  3055. if (dictionary["FREETYPE"] == "no") qconfigList += "QT_NO_FREETYPE";
  3056. if (dictionary["HARFBUZZ"] == "no") qconfigList += "QT_NO_HARFBUZZ";
  3057. if (dictionary["NATIVE_GESTURES"] == "no") qconfigList += "QT_NO_NATIVE_GESTURES";
  3058. if (dictionary["OPENGL_ES_2"] == "yes") qconfigList += "QT_OPENGL_ES";
  3059. if (dictionary["OPENGL_ES_2"] == "yes") qconfigList += "QT_OPENGL_ES_2";
  3060. if (dictionary["DYNAMICGL"] == "yes") qconfigList += "QT_OPENGL_DYNAMIC";
  3061. if (dictionary["SQL_MYSQL"] == "yes") qconfigList += "QT_SQL_MYSQL";
  3062. if (dictionary["SQL_ODBC"] == "yes") qconfigList += "QT_SQL_ODBC";
  3063. if (dictionary["SQL_OCI"] == "yes") qconfigList += "QT_SQL_OCI";
  3064. if (dictionary["SQL_PSQL"] == "yes") qconfigList += "QT_SQL_PSQL";
  3065. if (dictionary["SQL_TDS"] == "yes") qconfigList += "QT_SQL_TDS";
  3066. if (dictionary["SQL_DB2"] == "yes") qconfigList += "QT_SQL_DB2";
  3067. if (dictionary["SQL_SQLITE"] == "yes") qconfigList += "QT_SQL_SQLITE";
  3068. if (dictionary["SQL_SQLITE2"] == "yes") qconfigList += "QT_SQL_SQLITE2";
  3069. if (dictionary["SQL_IBASE"] == "yes") qconfigList += "QT_SQL_IBASE";
  3070. if (dictionary["POSIX_IPC"] == "yes") qconfigList += "QT_POSIX_IPC";
  3071. if (dictionary["FONT_CONFIG"] == "no") qconfigList += "QT_NO_FONTCONFIG";
  3072. if (dictionary["NIS"] == "yes")
  3073. qconfigList += "QT_NIS";
  3074. else
  3075. qconfigList += "QT_NO_NIS";
  3076. if (dictionary["LARGE_FILE"] == "yes") qconfigList += "QT_LARGEFILE_SUPPORT=64";
  3077. if (dictionary["QT_CUPS"] == "no") qconfigList += "QT_NO_CUPS";
  3078. if (dictionary["QT_ICONV"] == "no") qconfigList += "QT_NO_ICONV";
  3079. if (dictionary["QT_EVDEV"] == "no") qconfigList += "QT_NO_EVDEV";
  3080. if (dictionary["QT_MTDEV"] == "no") qconfigList += "QT_NO_MTDEV";
  3081. if (dictionary["QT_GLIB"] == "no") qconfigList += "QT_NO_GLIB";
  3082. if (dictionary["QT_INOTIFY"] == "no") qconfigList += "QT_NO_INOTIFY";
  3083. if (dictionary["QT_EVENTFD"] == "no") qconfigList += "QT_NO_EVENTFD";
  3084. if (dictionary["REDUCE_EXPORTS"] == "yes") qconfigList += "QT_VISIBILITY_AVAILABLE";
  3085. if (dictionary["REDUCE_RELOCATIONS"] == "yes") qconfigList += "QT_REDUCE_RELOCATIONS";
  3086. if (dictionary["QT_GETIFADDRS"] == "no") qconfigList += "QT_NO_GETIFADDRS";
  3087. qconfigList += QString("QT_POINTER_SIZE=%1").arg(dictionary["QT_POINTER_SIZE"]);
  3088. qconfigList.sort();
  3089. for (int i = 0; i < qconfigList.count(); ++i)
  3090. tmpStream << addDefine(qconfigList.at(i));
  3091. tmpStream<<"#define QT_QPA_DEFAULT_PLATFORM_NAME \"" << qpaPlatformName() << "\""<<endl;
  3092. if (!tmpStream.flush())
  3093. dictionary[ "DONE" ] = "error";
  3094. }
  3095. }
  3096. void Configure::displayConfig()
  3097. {
  3098. fstream sout;
  3099. sout.open(QString(buildPath + "/config.summary").toLocal8Bit().constData(),
  3100. ios::in | ios::out | ios::trunc);
  3101. // Give some feedback
  3102. sout << "Environment:" << endl;
  3103. QString env = QString::fromLocal8Bit(getenv("INCLUDE")).replace(QRegExp("[;,]"), "\n ");
  3104. if (env.isEmpty())
  3105. env = "Unset";
  3106. sout << " INCLUDE=\n " << env << endl;
  3107. env = QString::fromLocal8Bit(getenv("LIB")).replace(QRegExp("[;,]"), "\n ");
  3108. if (env.isEmpty())
  3109. env = "Unset";
  3110. sout << " LIB=\n " << env << endl;
  3111. env = QString::fromLocal8Bit(getenv("PATH")).replace(QRegExp("[;,]"), "\n ");
  3112. if (env.isEmpty())
  3113. env = "Unset";
  3114. sout << " PATH=\n " << env << endl;
  3115. if (dictionary[QStringLiteral("EDITION")] != QStringLiteral("OpenSource")) {
  3116. QString l1 = dictionary[ "LICENSEE" ];
  3117. QString l2 = dictionary[ "LICENSEID" ];
  3118. QString l3 = dictionary["EDITION"] + ' ' + "Edition";
  3119. QString l4 = dictionary[ "EXPIRYDATE" ];
  3120. sout << "Licensee...................." << (l1.isNull() ? "" : l1) << endl;
  3121. sout << "License ID.................." << (l2.isNull() ? "" : l2) << endl;
  3122. sout << "Product license............." << (l3.isNull() ? "" : l3) << endl;
  3123. sout << "Expiry Date................." << (l4.isNull() ? "" : l4) << endl;
  3124. sout << endl;
  3125. }
  3126. sout << "Configuration:" << endl;
  3127. sout << " " << qmakeConfig.join("\n ") << endl;
  3128. sout << "Qt Configuration:" << endl;
  3129. sout << " " << qtConfig.join("\n ") << endl;
  3130. sout << endl;
  3131. if (dictionary.contains("XQMAKESPEC"))
  3132. sout << "QMAKESPEC..................." << dictionary[ "XQMAKESPEC" ] << " (" << dictionary["QMAKESPEC_FROM"] << ")" << endl;
  3133. else
  3134. sout << "QMAKESPEC..................." << dictionary[ "QMAKESPEC" ] << " (" << dictionary["QMAKESPEC_FROM"] << ")" << endl;
  3135. if (!dictionary["TARGET_OS"].isEmpty())
  3136. sout << "Target OS..................." << dictionary["TARGET_OS"] << endl;
  3137. sout << "Architecture................" << dictionary["QT_ARCH"]
  3138. << ", features:" << dictionary["QT_CPU_FEATURES"] << endl;
  3139. sout << "Host Architecture..........." << dictionary["QT_HOST_ARCH"]
  3140. << ", features:" << dictionary["QT_HOST_CPU_FEATURES"] << endl;
  3141. sout << "Maketool...................." << dictionary[ "MAKE" ] << endl;
  3142. if (dictionary[ "BUILDALL" ] == "yes") {
  3143. sout << "Debug build................." << "yes (combined)" << endl;
  3144. sout << "Default build..............." << dictionary[ "BUILD" ] << endl;
  3145. } else {
  3146. sout << "Debug......................." << (dictionary[ "BUILD" ] == "debug" ? "yes" : "no") << endl;
  3147. }
  3148. if (dictionary[ "BUILD" ] == "release" || dictionary[ "BUILDALL" ] == "yes")
  3149. sout << "Force debug info............" << dictionary[ "FORCEDEBUGINFO" ] << endl;
  3150. sout << "C++11 support..............." << dictionary[ "C++11" ] << endl;
  3151. sout << "Link Time Code Generation..." << dictionary[ "LTCG" ] << endl;
  3152. sout << "Accessibility support......." << dictionary[ "ACCESSIBILITY" ] << endl;
  3153. sout << "RTTI support................" << dictionary[ "RTTI" ] << endl;
  3154. sout << "SSE2 support................" << dictionary[ "SSE2" ] << endl;
  3155. sout << "SSE3 support................" << dictionary[ "SSE3" ] << endl;
  3156. sout << "SSSE3 support..............." << dictionary[ "SSSE3" ] << endl;
  3157. sout << "SSE4.1 support.............." << dictionary[ "SSE4_1" ] << endl;
  3158. sout << "SSE4.2 support.............." << dictionary[ "SSE4_2" ] << endl;
  3159. sout << "AVX support................." << dictionary[ "AVX" ] << endl;
  3160. sout << "AVX2 support................" << dictionary[ "AVX2" ] << endl;
  3161. sout << "NEON support................" << dictionary[ "NEON" ] << endl;
  3162. sout << "IWMMXT support.............." << dictionary[ "IWMMXT" ] << endl;
  3163. sout << "OpenGL support.............." << dictionary[ "OPENGL" ] << endl;
  3164. sout << "Large File support.........." << dictionary[ "LARGE_FILE" ] << endl;
  3165. sout << "NIS support................." << dictionary[ "NIS" ] << endl;
  3166. sout << "Iconv support..............." << dictionary[ "QT_ICONV" ] << endl;
  3167. sout << "Evdev support..............." << dictionary[ "QT_EVDEV" ] << endl;
  3168. sout << "Mtdev support..............." << dictionary[ "QT_MTDEV" ] << endl;
  3169. sout << "Inotify support............." << dictionary[ "QT_INOTIFY" ] << endl;
  3170. sout << "eventfd(7) support.........." << dictionary[ "QT_EVENTFD" ] << endl;
  3171. sout << "Glib support................" << dictionary[ "QT_GLIB" ] << endl;
  3172. sout << "CUPS support................" << dictionary[ "QT_CUPS" ] << endl;
  3173. sout << "OpenVG support.............." << dictionary[ "OPENVG" ] << endl;
  3174. sout << "OpenSSL support............." << dictionary[ "OPENSSL" ] << endl;
  3175. sout << "Qt D-Bus support............" << dictionary[ "DBUS" ] << endl;
  3176. sout << "Qt Widgets module support..." << dictionary[ "WIDGETS" ] << endl;
  3177. sout << "Qt GUI module support......." << dictionary[ "GUI" ] << endl;
  3178. sout << "QML debugging..............." << dictionary[ "QML_DEBUG" ] << endl;
  3179. sout << "DirectWrite support........." << dictionary[ "DIRECTWRITE" ] << endl;
  3180. sout << "Use system proxies.........." << dictionary[ "SYSTEM_PROXIES" ] << endl;
  3181. sout << endl;
  3182. sout << "QPA Backends:" << endl;
  3183. sout << " GDI....................." << "yes" << endl;
  3184. sout << " Direct2D................" << dictionary[ "DIRECT2D" ] << endl;
  3185. sout << endl;
  3186. sout << "Third Party Libraries:" << endl;
  3187. sout << " ZLIB support............" << dictionary[ "ZLIB" ] << endl;
  3188. sout << " GIF support............." << dictionary[ "GIF" ] << endl;
  3189. sout << " JPEG support............" << dictionary[ "JPEG" ] << endl;
  3190. sout << " PNG support............." << dictionary[ "PNG" ] << endl;
  3191. sout << " FreeType support........" << dictionary[ "FREETYPE" ] << endl;
  3192. sout << " Fontconfig support......" << dictionary[ "FONT_CONFIG" ] << endl;
  3193. sout << " HarfBuzz-NG support....." << dictionary[ "HARFBUZZ" ] << endl;
  3194. sout << " PCRE support............" << dictionary[ "PCRE" ] << endl;
  3195. sout << " ICU support............." << dictionary[ "ICU" ] << endl;
  3196. if ((platform() == QNX) || (platform() == BLACKBERRY)) {
  3197. sout << " SLOG2 support..........." << dictionary[ "SLOG2" ] << endl;
  3198. sout << " IMF support............." << dictionary[ "QNX_IMF" ] << endl;
  3199. sout << " PPS support............." << dictionary[ "PPS" ] << endl;
  3200. sout << " LGMON support..........." << dictionary[ "LGMON" ] << endl;
  3201. }
  3202. sout << " ANGLE..................." << dictionary[ "ANGLE" ] << endl;
  3203. sout << " Dynamic OpenGL.........." << dictionary[ "DYNAMICGL" ] << endl;
  3204. sout << endl;
  3205. sout << "Styles:" << endl;
  3206. sout << " Windows................." << dictionary[ "STYLE_WINDOWS" ] << endl;
  3207. sout << " Windows XP.............." << dictionary[ "STYLE_WINDOWSXP" ] << endl;
  3208. sout << " Windows Vista..........." << dictionary[ "STYLE_WINDOWSVISTA" ] << endl;
  3209. sout << " Fusion.................." << dictionary[ "STYLE_FUSION" ] << endl;
  3210. sout << " Windows CE.............." << dictionary[ "STYLE_WINDOWSCE" ] << endl;
  3211. sout << " Windows Mobile.........." << dictionary[ "STYLE_WINDOWSMOBILE" ] << endl;
  3212. sout << endl;
  3213. sout << "Sql Drivers:" << endl;
  3214. sout << " ODBC...................." << dictionary[ "SQL_ODBC" ] << endl;
  3215. sout << " MySQL..................." << dictionary[ "SQL_MYSQL" ] << endl;
  3216. sout << " OCI....................." << dictionary[ "SQL_OCI" ] << endl;
  3217. sout << " PostgreSQL.............." << dictionary[ "SQL_PSQL" ] << endl;
  3218. sout << " TDS....................." << dictionary[ "SQL_TDS" ] << endl;
  3219. sout << " DB2....................." << dictionary[ "SQL_DB2" ] << endl;
  3220. sout << " SQLite.................." << dictionary[ "SQL_SQLITE" ] << " (" << dictionary[ "SQL_SQLITE_LIB" ] << ")" << endl;
  3221. sout << " SQLite2................." << dictionary[ "SQL_SQLITE2" ] << endl;
  3222. sout << " InterBase..............." << dictionary[ "SQL_IBASE" ] << endl;
  3223. sout << endl;
  3224. sout << "Sources are in.............." << QDir::toNativeSeparators(sourcePath) << endl;
  3225. sout << "Build is done in............" << QDir::toNativeSeparators(buildPath) << endl;
  3226. sout << "Install prefix.............." << QDir::toNativeSeparators(dictionary["QT_INSTALL_PREFIX"]) << endl;
  3227. sout << "Headers installed to........" << QDir::toNativeSeparators(dictionary["QT_INSTALL_HEADERS"]) << endl;
  3228. sout << "Libraries installed to......" << QDir::toNativeSeparators(dictionary["QT_INSTALL_LIBS"]) << endl;
  3229. sout << "Arch-dep. data to..........." << QDir::toNativeSeparators(dictionary["QT_INSTALL_ARCHDATA"]) << endl;
  3230. sout << "Plugins installed to........" << QDir::toNativeSeparators(dictionary["QT_INSTALL_PLUGINS"]) << endl;
  3231. sout << "Library execs installed to.." << QDir::toNativeSeparators(dictionary["QT_INSTALL_LIBEXECS"]) << endl;
  3232. sout << "QML1 imports installed to..." << QDir::toNativeSeparators(dictionary["QT_INSTALL_IMPORTS"]) << endl;
  3233. sout << "QML2 imports installed to..." << QDir::toNativeSeparators(dictionary["QT_INSTALL_QML"]) << endl;
  3234. sout << "Binaries installed to......." << QDir::toNativeSeparators(dictionary["QT_INSTALL_BINS"]) << endl;
  3235. sout << "Arch-indep. data to........." << QDir::toNativeSeparators(dictionary["QT_INSTALL_DATA"]) << endl;
  3236. sout << "Docs installed to..........." << QDir::toNativeSeparators(dictionary["QT_INSTALL_DOCS"]) << endl;
  3237. sout << "Translations installed to..." << QDir::toNativeSeparators(dictionary["QT_INSTALL_TRANSLATIONS"]) << endl;
  3238. sout << "Examples installed to......." << QDir::toNativeSeparators(dictionary["QT_INSTALL_EXAMPLES"]) << endl;
  3239. sout << "Tests installed to.........." << QDir::toNativeSeparators(dictionary["QT_INSTALL_TESTS"]) << endl;
  3240. if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith(QLatin1String("wince"))) {
  3241. sout << "Using c runtime detection..." << dictionary[ "CE_CRT" ] << endl;
  3242. sout << "Cetest support.............." << dictionary[ "CETEST" ] << endl;
  3243. sout << "Signature..................." << dictionary[ "CE_SIGNATURE"] << endl;
  3244. sout << endl;
  3245. }
  3246. if (checkAvailability("INCREDIBUILD_XGE"))
  3247. sout << "Using IncrediBuild XGE......" << dictionary["INCREDIBUILD_XGE"] << endl;
  3248. if (!qmakeDefines.isEmpty()) {
  3249. sout << "Defines.....................";
  3250. for (QStringList::Iterator defs = qmakeDefines.begin(); defs != qmakeDefines.end(); ++defs)
  3251. sout << (*defs) << " ";
  3252. sout << endl;
  3253. }
  3254. if (!qmakeIncludes.isEmpty()) {
  3255. sout << "Include paths...............";
  3256. for (QStringList::Iterator incs = qmakeIncludes.begin(); incs != qmakeIncludes.end(); ++incs)
  3257. sout << (*incs) << " ";
  3258. sout << endl;
  3259. }
  3260. if (!qmakeLibs.isEmpty()) {
  3261. sout << "Additional libraries........";
  3262. for (QStringList::Iterator libs = qmakeLibs.begin(); libs != qmakeLibs.end(); ++libs)
  3263. sout << (*libs) << " ";
  3264. sout << endl;
  3265. }
  3266. if (dictionary[ "QMAKE_INTERNAL" ] == "yes") {
  3267. sout << "Using internal configuration." << endl;
  3268. }
  3269. if (dictionary[ "SHARED" ] == "no") {
  3270. sout << "WARNING: Using static linking will disable the use of plugins." << endl;
  3271. sout << " Make sure you compile ALL needed modules into the library." << endl;
  3272. }
  3273. if (dictionary[ "OPENSSL" ] == "linked") {
  3274. if (!opensslLibsDebug.isEmpty() || !opensslLibsRelease.isEmpty()) {
  3275. sout << "Using OpenSSL libraries:" << endl;
  3276. sout << " debug : " << opensslLibsDebug << endl;
  3277. sout << " release: " << opensslLibsRelease << endl;
  3278. sout << " both : " << opensslLibs << endl;
  3279. } else if (opensslLibs.isEmpty()) {
  3280. sout << "NOTE: When linking against OpenSSL, you can override the default" << endl;
  3281. sout << "library names through OPENSSL_LIBS and optionally OPENSSL_LIBS_DEBUG/OPENSSL_LIBS_RELEASE" << endl;
  3282. sout << "For example:" << endl;
  3283. sout << " configure -openssl-linked OPENSSL_LIBS=\"-lssleay32 -llibeay32\"" << endl;
  3284. }
  3285. }
  3286. if (dictionary[ "ZLIB_FORCED" ] == "yes") {
  3287. QString which_zlib = "supplied";
  3288. if (dictionary[ "ZLIB" ] == "system")
  3289. which_zlib = "system";
  3290. sout << "NOTE: The -no-zlib option was supplied but is no longer supported." << endl
  3291. << endl
  3292. << "Qt now requires zlib support in all builds, so the -no-zlib" << endl
  3293. << "option was ignored. Qt will be built using the " << which_zlib
  3294. << "zlib" << endl;
  3295. }
  3296. if (dictionary["OBSOLETE_ARCH_ARG"] == "yes") {
  3297. sout << endl
  3298. << "NOTE: The -arch option is obsolete." << endl
  3299. << endl
  3300. << "Qt now detects the target and host architectures based on compiler" << endl
  3301. << "output. Qt will be built using " << dictionary["QT_ARCH"] << " for the target architecture" << endl
  3302. << "and " << dictionary["QT_HOST_ARCH"] << " for the host architecture (note that these two" << endl
  3303. << "will be the same unless you are cross-compiling)." << endl
  3304. << endl;
  3305. }
  3306. // display config.summary
  3307. sout.seekg(0, ios::beg);
  3308. while (sout.good()) {
  3309. string str;
  3310. getline(sout, str);
  3311. cout << str << endl;
  3312. }
  3313. }
  3314. void Configure::generateHeaders()
  3315. {
  3316. if (dictionary["SYNCQT"] == "auto")
  3317. dictionary["SYNCQT"] = defaultTo("SYNCQT");
  3318. if (dictionary["SYNCQT"] == "yes") {
  3319. if (!QStandardPaths::findExecutable(QStringLiteral("perl.exe")).isEmpty()) {
  3320. cout << "Running syncqt..." << endl;
  3321. QStringList args;
  3322. args << "perl" << "-w";
  3323. args += sourcePath + "/bin/syncqt.pl";
  3324. args << "-minimal" << "-module" << "QtCore";
  3325. args += sourcePath;
  3326. int retc = Environment::execute(args, QStringList(), QStringList());
  3327. if (retc) {
  3328. cout << "syncqt failed, return code " << retc << endl << endl;
  3329. dictionary["DONE"] = "error";
  3330. }
  3331. } else {
  3332. cout << "Perl not found in environment - cannot run syncqt." << endl;
  3333. dictionary["DONE"] = "error";
  3334. }
  3335. }
  3336. }
  3337. static QString stripPrefix(const QString &str, const QString &pfx)
  3338. {
  3339. return str.startsWith(pfx) ? str.mid(pfx.length()) : str;
  3340. }
  3341. void Configure::substPrefix(QString *path)
  3342. {
  3343. QString spfx = dictionary["QT_SYSROOT_PREFIX"];
  3344. if (path->startsWith(spfx))
  3345. path->replace(0, spfx.size(), dictionary["QT_EXT_PREFIX"]);
  3346. }
  3347. void Configure::generateQConfigCpp()
  3348. {
  3349. // if QT_INSTALL_* have not been specified on commandline, define them now from QT_INSTALL_PREFIX
  3350. // if prefix is empty (WINCE), make all of them empty, if they aren't set
  3351. bool qipempty = false;
  3352. if (dictionary["QT_INSTALL_PREFIX"].isEmpty())
  3353. qipempty = true;
  3354. if (!dictionary["QT_INSTALL_HEADERS"].size())
  3355. dictionary["QT_INSTALL_HEADERS"] = qipempty ? "" : dictionary["QT_INSTALL_PREFIX"] + "/include";
  3356. if (!dictionary["QT_INSTALL_LIBS"].size())
  3357. dictionary["QT_INSTALL_LIBS"] = qipempty ? "" : dictionary["QT_INSTALL_PREFIX"] + "/lib";
  3358. if (!dictionary["QT_INSTALL_ARCHDATA"].size())
  3359. dictionary["QT_INSTALL_ARCHDATA"] = qipempty ? "" : dictionary["QT_INSTALL_PREFIX"];
  3360. if (!dictionary["QT_INSTALL_LIBEXECS"].size()) {
  3361. if (dictionary["QT_INSTALL_ARCHDATA"] == dictionary["QT_INSTALL_PREFIX"])
  3362. dictionary["QT_INSTALL_LIBEXECS"] = qipempty ? "" : dictionary["QT_INSTALL_ARCHDATA"] + "/bin";
  3363. else
  3364. dictionary["QT_INSTALL_LIBEXECS"] = qipempty ? "" : dictionary["QT_INSTALL_ARCHDATA"] + "/libexec";
  3365. }
  3366. if (!dictionary["QT_INSTALL_BINS"].size())
  3367. dictionary["QT_INSTALL_BINS"] = qipempty ? "" : dictionary["QT_INSTALL_PREFIX"] + "/bin";
  3368. if (!dictionary["QT_INSTALL_PLUGINS"].size())
  3369. dictionary["QT_INSTALL_PLUGINS"] = qipempty ? "" : dictionary["QT_INSTALL_ARCHDATA"] + "/plugins";
  3370. if (!dictionary["QT_INSTALL_IMPORTS"].size())
  3371. dictionary["QT_INSTALL_IMPORTS"] = qipempty ? "" : dictionary["QT_INSTALL_ARCHDATA"] + "/imports";
  3372. if (!dictionary["QT_INSTALL_QML"].size())
  3373. dictionary["QT_INSTALL_QML"] = qipempty ? "" : dictionary["QT_INSTALL_ARCHDATA"] + "/qml";
  3374. if (!dictionary["QT_INSTALL_DATA"].size())
  3375. dictionary["QT_INSTALL_DATA"] = qipempty ? "" : dictionary["QT_INSTALL_PREFIX"];
  3376. if (!dictionary["QT_INSTALL_DOCS"].size())
  3377. dictionary["QT_INSTALL_DOCS"] = qipempty ? "" : dictionary["QT_INSTALL_DATA"] + "/doc";
  3378. if (!dictionary["QT_INSTALL_TRANSLATIONS"].size())
  3379. dictionary["QT_INSTALL_TRANSLATIONS"] = qipempty ? "" : dictionary["QT_INSTALL_DATA"] + "/translations";
  3380. if (!dictionary["QT_INSTALL_EXAMPLES"].size())
  3381. dictionary["QT_INSTALL_EXAMPLES"] = qipempty ? "" : dictionary["QT_INSTALL_PREFIX"] + "/examples";
  3382. if (!dictionary["QT_INSTALL_TESTS"].size())
  3383. dictionary["QT_INSTALL_TESTS"] = qipempty ? "" : dictionary["QT_INSTALL_PREFIX"] + "/tests";
  3384. QChar sysrootifyPrefix = QLatin1Char('y');
  3385. dictionary["QT_SYSROOT_PREFIX"] = dictionary["QT_INSTALL_PREFIX"];
  3386. dictionary["QT_SYSROOT_HEADERS"] = dictionary["QT_INSTALL_HEADERS"];
  3387. dictionary["QT_SYSROOT_LIBS"] = dictionary["QT_INSTALL_LIBS"];
  3388. dictionary["QT_SYSROOT_ARCHDATA"] = dictionary["QT_INSTALL_ARCHDATA"];
  3389. dictionary["QT_SYSROOT_LIBEXECS"] = dictionary["QT_INSTALL_LIBEXECS"];
  3390. dictionary["QT_SYSROOT_BINS"] = dictionary["QT_INSTALL_BINS"];
  3391. dictionary["QT_SYSROOT_PLUGINS"] = dictionary["QT_INSTALL_PLUGINS"];
  3392. dictionary["QT_SYSROOT_IMPORTS"] = dictionary["QT_INSTALL_IMPORTS"];
  3393. dictionary["QT_SYSROOT_QML"] = dictionary["QT_INSTALL_QML"];
  3394. dictionary["QT_SYSROOT_DATA"] = dictionary["QT_INSTALL_DATA"];
  3395. dictionary["QT_SYSROOT_DOCS"] = dictionary["QT_INSTALL_DOCS"];
  3396. dictionary["QT_SYSROOT_TRANSLATIONS"] = dictionary["QT_INSTALL_TRANSLATIONS"];
  3397. dictionary["QT_SYSROOT_EXAMPLES"] = dictionary["QT_INSTALL_EXAMPLES"];
  3398. dictionary["QT_SYSROOT_TESTS"] = dictionary["QT_INSTALL_TESTS"];
  3399. if (dictionary["QT_EXT_PREFIX"].size()) {
  3400. sysrootifyPrefix = QLatin1Char('n');
  3401. dictionary["QT_INSTALL_PREFIX"] = dictionary["QT_EXT_PREFIX"];
  3402. substPrefix(&dictionary["QT_INSTALL_HEADERS"]);
  3403. substPrefix(&dictionary["QT_INSTALL_LIBS"]);
  3404. substPrefix(&dictionary["QT_INSTALL_ARCHDATA"]);
  3405. substPrefix(&dictionary["QT_INSTALL_LIBEXECS"]);
  3406. substPrefix(&dictionary["QT_INSTALL_BINS"]);
  3407. substPrefix(&dictionary["QT_INSTALL_PLUGINS"]);
  3408. substPrefix(&dictionary["QT_INSTALL_IMPORTS"]);
  3409. substPrefix(&dictionary["QT_INSTALL_QML"]);
  3410. substPrefix(&dictionary["QT_INSTALL_DATA"]);
  3411. substPrefix(&dictionary["QT_INSTALL_DOCS"]);
  3412. substPrefix(&dictionary["QT_INSTALL_TRANSLATIONS"]);
  3413. substPrefix(&dictionary["QT_INSTALL_EXAMPLES"]);
  3414. substPrefix(&dictionary["QT_INSTALL_TESTS"]);
  3415. }
  3416. bool haveHpx = false;
  3417. if (dictionary["QT_HOST_PREFIX"].isEmpty())
  3418. dictionary["QT_HOST_PREFIX"] = dictionary["QT_INSTALL_PREFIX"];
  3419. else
  3420. haveHpx = true;
  3421. if (dictionary["QT_HOST_BINS"].isEmpty())
  3422. dictionary["QT_HOST_BINS"] = haveHpx ? dictionary["QT_HOST_PREFIX"] + "/bin" : dictionary["QT_INSTALL_BINS"];
  3423. if (dictionary["QT_HOST_LIBS"].isEmpty())
  3424. dictionary["QT_HOST_LIBS"] = haveHpx ? dictionary["QT_HOST_PREFIX"] + "/lib" : dictionary["QT_INSTALL_LIBS"];
  3425. if (dictionary["QT_HOST_DATA"].isEmpty())
  3426. dictionary["QT_HOST_DATA"] = haveHpx ? dictionary["QT_HOST_PREFIX"] : dictionary["QT_INSTALL_ARCHDATA"];
  3427. QString specPfx = dictionary["QT_HOST_DATA"] + "/mkspecs/";
  3428. QString hostSpec = stripPrefix(dictionary["QMAKESPEC"], specPfx);
  3429. QString targSpec = dictionary.contains("XQMAKESPEC") ? stripPrefix(dictionary["XQMAKESPEC"], specPfx) : hostSpec;
  3430. // Generate the new qconfig.cpp file
  3431. {
  3432. FileWriter tmpStream(buildPath + "/src/corelib/global/qconfig.cpp");
  3433. tmpStream << "/* Licensed */" << endl
  3434. << "static const char qt_configure_licensee_str [512 + 12] = \"qt_lcnsuser=" << dictionary["LICENSEE"] << "\";" << endl
  3435. << "static const char qt_configure_licensed_products_str [512 + 12] = \"qt_lcnsprod=" << dictionary["EDITION"] << "\";" << endl
  3436. << endl
  3437. << "/* Build date */" << endl
  3438. << "static const char qt_configure_installation [11 + 12] = \"qt_instdate=" << QDate::currentDate().toString(Qt::ISODate) << "\";" << endl
  3439. << endl
  3440. << "static const char qt_configure_prefix_path_strs[][12 + 512] = {" << endl
  3441. << "#ifndef QT_BUILD_QMAKE" << endl
  3442. << " \"qt_prfxpath=" << formatPath(dictionary["QT_SYSROOT_PREFIX"]) << "\"," << endl
  3443. << " \"qt_docspath=" << formatPath(dictionary["QT_SYSROOT_DOCS"]) << "\"," << endl
  3444. << " \"qt_hdrspath=" << formatPath(dictionary["QT_SYSROOT_HEADERS"]) << "\"," << endl
  3445. << " \"qt_libspath=" << formatPath(dictionary["QT_SYSROOT_LIBS"]) << "\"," << endl
  3446. << " \"qt_lbexpath=" << formatPath(dictionary["QT_SYSROOT_LIBEXECS"]) << "\"," << endl
  3447. << " \"qt_binspath=" << formatPath(dictionary["QT_SYSROOT_BINS"]) << "\"," << endl
  3448. << " \"qt_plugpath=" << formatPath(dictionary["QT_SYSROOT_PLUGINS"]) << "\"," << endl
  3449. << " \"qt_impspath=" << formatPath(dictionary["QT_SYSROOT_IMPORTS"]) << "\"," << endl
  3450. << " \"qt_qml2path=" << formatPath(dictionary["QT_SYSROOT_QML"]) << "\"," << endl
  3451. << " \"qt_adatpath=" << formatPath(dictionary["QT_SYSROOT_ARCHDATA"]) << "\"," << endl
  3452. << " \"qt_datapath=" << formatPath(dictionary["QT_SYSROOT_DATA"]) << "\"," << endl
  3453. << " \"qt_trnspath=" << formatPath(dictionary["QT_SYSROOT_TRANSLATIONS"]) << "\"," << endl
  3454. << " \"qt_xmplpath=" << formatPath(dictionary["QT_SYSROOT_EXAMPLES"]) << "\"," << endl
  3455. << " \"qt_tstspath=" << formatPath(dictionary["QT_SYSROOT_TESTS"]) << "\"," << endl
  3456. << "#else" << endl
  3457. << " \"qt_prfxpath=" << formatPath(dictionary["QT_INSTALL_PREFIX"]) << "\"," << endl
  3458. << " \"qt_docspath=" << formatPath(dictionary["QT_INSTALL_DOCS"]) << "\"," << endl
  3459. << " \"qt_hdrspath=" << formatPath(dictionary["QT_INSTALL_HEADERS"]) << "\"," << endl
  3460. << " \"qt_libspath=" << formatPath(dictionary["QT_INSTALL_LIBS"]) << "\"," << endl
  3461. << " \"qt_lbexpath=" << formatPath(dictionary["QT_INSTALL_LIBEXECS"]) << "\"," << endl
  3462. << " \"qt_binspath=" << formatPath(dictionary["QT_INSTALL_BINS"]) << "\"," << endl
  3463. << " \"qt_plugpath=" << formatPath(dictionary["QT_INSTALL_PLUGINS"]) << "\"," << endl
  3464. << " \"qt_impspath=" << formatPath(dictionary["QT_INSTALL_IMPORTS"]) << "\"," << endl
  3465. << " \"qt_qml2path=" << formatPath(dictionary["QT_INSTALL_QML"]) << "\"," << endl
  3466. << " \"qt_adatpath=" << formatPath(dictionary["QT_INSTALL_ARCHDATA"]) << "\"," << endl
  3467. << " \"qt_datapath=" << formatPath(dictionary["QT_INSTALL_DATA"]) << "\"," << endl
  3468. << " \"qt_trnspath=" << formatPath(dictionary["QT_INSTALL_TRANSLATIONS"]) << "\"," << endl
  3469. << " \"qt_xmplpath=" << formatPath(dictionary["QT_INSTALL_EXAMPLES"]) << "\"," << endl
  3470. << " \"qt_tstspath=" << formatPath(dictionary["QT_INSTALL_TESTS"]) << "\"," << endl
  3471. << " \"qt_ssrtpath=" << formatPath(dictionary["CFG_SYSROOT"]) << "\"," << endl
  3472. << " \"qt_hpfxpath=" << formatPath(dictionary["QT_HOST_PREFIX"]) << "\"," << endl
  3473. << " \"qt_hbinpath=" << formatPath(dictionary["QT_HOST_BINS"]) << "\"," << endl
  3474. << " \"qt_hlibpath=" << formatPath(dictionary["QT_HOST_LIBS"]) << "\"," << endl
  3475. << " \"qt_hdatpath=" << formatPath(dictionary["QT_HOST_DATA"]) << "\"," << endl
  3476. << " \"qt_targspec=" << targSpec << "\"," << endl
  3477. << " \"qt_hostspec=" << hostSpec << "\"," << endl
  3478. << "#endif" << endl
  3479. << "};" << endl;
  3480. if ((platform() != WINDOWS) && (platform() != WINDOWS_CE) && (platform() != WINDOWS_RT))
  3481. tmpStream << "static const char qt_configure_settings_path_str [256 + 12] = \"qt_stngpath=" << formatPath(dictionary["QT_INSTALL_SETTINGS"]) << "\";" << endl;
  3482. tmpStream << endl
  3483. << "#ifdef QT_BUILD_QMAKE\n"
  3484. << "static const char qt_sysrootify_prefix[] = \"qt_ssrtfpfx=" << sysrootifyPrefix << "\";\n"
  3485. << "#endif\n\n"
  3486. << "/* strlen( \"qt_lcnsxxxx\") == 12 */" << endl
  3487. << "#define QT_CONFIGURE_LICENSEE qt_configure_licensee_str + 12;" << endl
  3488. << "#define QT_CONFIGURE_LICENSED_PRODUCTS qt_configure_licensed_products_str + 12;" << endl;
  3489. if ((platform() != WINDOWS) && (platform() != WINDOWS_CE) && (platform() != WINDOWS_RT))
  3490. tmpStream << "#define QT_CONFIGURE_SETTINGS_PATH qt_configure_settings_path_str + 12;" << endl;
  3491. if (!tmpStream.flush())
  3492. dictionary[ "DONE" ] = "error";
  3493. }
  3494. }
  3495. void Configure::buildQmake()
  3496. {
  3497. if (dictionary[ "BUILD_QMAKE" ] == "yes") {
  3498. QStringList args;
  3499. // Build qmake
  3500. QString pwd = QDir::currentPath();
  3501. if (!QDir(buildPath).mkpath("qmake")) {
  3502. cout << "Cannot create qmake build dir." << endl;
  3503. dictionary[ "DONE" ] = "error";
  3504. return;
  3505. }
  3506. if (!QDir::setCurrent(buildPath + "/qmake")) {
  3507. cout << "Cannot enter qmake build dir." << endl;
  3508. dictionary[ "DONE" ] = "error";
  3509. return;
  3510. }
  3511. QString makefile = "Makefile";
  3512. {
  3513. QFile out(makefile);
  3514. if (out.open(QFile::WriteOnly | QFile::Text)) {
  3515. QTextStream stream(&out);
  3516. stream << "#AutoGenerated by configure.exe" << endl
  3517. << "BUILD_PATH = " << QDir::toNativeSeparators(buildPath) << endl
  3518. << "SOURCE_PATH = " << QDir::toNativeSeparators(sourcePath) << endl
  3519. << "INC_PATH = " << QDir::toNativeSeparators(buildPath + "/include") << endl;
  3520. stream << "QT_VERSION = " << dictionary["VERSION"] << endl;
  3521. if (dictionary[ "QMAKESPEC" ] == QString("win32-g++")) {
  3522. stream << "QMAKESPEC = $(SOURCE_PATH)\\mkspecs\\win32-g++" << endl
  3523. << "EXTRA_CFLAGS = -DUNICODE" << endl
  3524. << "EXTRA_CXXFLAGS = -DUNICODE" << endl
  3525. << "QTOBJS = qfilesystemengine_win.o \\" << endl
  3526. << " qfilesystemiterator_win.o \\" << endl
  3527. << " qfsfileengine_win.o \\" << endl
  3528. << " qlocale_win.o \\" << endl
  3529. << " qsettings_win.o \\" << endl
  3530. << " qsystemlibrary.o \\" << endl
  3531. << " registry.o" << endl
  3532. << "QTSRCS=\"$(SOURCE_PATH)/src/corelib/io/qfilesystemengine_win.cpp\" \\" << endl
  3533. << " \"$(SOURCE_PATH)/src/corelib/io/qfilesystemiterator_win.cpp\" \\" << endl
  3534. << " \"$(SOURCE_PATH)/src/corelib/io/qfsfileengine_win.cpp\" \\" << endl
  3535. << " \"$(SOURCE_PATH)/src/corelib/io/qsettings_win.cpp\" \\" << endl
  3536. << " \"$(SOURCE_PATH)/src/corelib/tools/qlocale_win.cpp\" \\" << endl\
  3537. << " \"$(SOURCE_PATH)/src/corelib/plugin/qsystemlibrary.cpp\" \\" << endl
  3538. << " \"$(SOURCE_PATH)/tools/shared/windows/registry.cpp\"" << endl
  3539. << "EXEEXT=.exe" << endl
  3540. << "LFLAGS=-static -s -lole32 -luuid -ladvapi32 -lkernel32" << endl;
  3541. /*
  3542. ** SHELL is the full path of sh.exe, unless
  3543. ** 1) it is found in the current directory
  3544. ** 2) it is not found at all
  3545. ** 3) it is overridden on the command line with an existing file
  3546. ** ... otherwise it is always sh.exe. Specifically, SHELL from the
  3547. ** environment has no effect.
  3548. **
  3549. ** This check will fail if SHELL is explicitly set to a not
  3550. ** sh-compatible shell. This is not a problem, because configure.bat
  3551. ** will not do that.
  3552. */
  3553. stream << "ifeq ($(SHELL), sh.exe)" << endl
  3554. << " ifeq ($(wildcard $(CURDIR)/sh.exe), )" << endl
  3555. << " SH = 0" << endl
  3556. << " else" << endl
  3557. << " SH = 1" << endl
  3558. << " endif" << endl
  3559. << "else" << endl
  3560. << " SH = 1" << endl
  3561. << "endif" << endl
  3562. << "\n"
  3563. << "ifeq ($(SH), 1)" << endl
  3564. << " RM_F = rm -f" << endl
  3565. << " RM_RF = rm -rf" << endl
  3566. << "else" << endl
  3567. << " RM_F = del /f" << endl
  3568. << " RM_RF = rmdir /s /q" << endl
  3569. << "endif" << endl;
  3570. stream << "\n\n";
  3571. } else {
  3572. stream << "QMAKESPEC = " << dictionary["QMAKESPEC"] << endl;
  3573. }
  3574. stream << "\n\n";
  3575. QFile in(sourcePath + "/qmake/" + dictionary["QMAKEMAKEFILE"]);
  3576. if (in.open(QFile::ReadOnly | QFile::Text)) {
  3577. QString d = in.readAll();
  3578. //### need replaces (like configure.sh)? --Sam
  3579. stream << d << endl;
  3580. }
  3581. stream.flush();
  3582. out.close();
  3583. }
  3584. }
  3585. args += dictionary[ "MAKE" ];
  3586. args += "-f";
  3587. args += makefile;
  3588. cout << "Creating qmake..." << endl;
  3589. int exitCode = Environment::execute(args, QStringList(), QStringList());
  3590. if (exitCode) {
  3591. args.clear();
  3592. args += dictionary[ "MAKE" ];
  3593. args += "-f";
  3594. args += makefile;
  3595. args += "clean";
  3596. exitCode = Environment::execute(args, QStringList(), QStringList());
  3597. if (exitCode) {
  3598. cout << "Cleaning qmake failed, return code " << exitCode << endl << endl;
  3599. dictionary[ "DONE" ] = "error";
  3600. } else {
  3601. args.clear();
  3602. args += dictionary[ "MAKE" ];
  3603. args += "-f";
  3604. args += makefile;
  3605. exitCode = Environment::execute(args, QStringList(), QStringList());
  3606. if (exitCode) {
  3607. cout << "Building qmake failed, return code " << exitCode << endl << endl;
  3608. dictionary[ "DONE" ] = "error";
  3609. }
  3610. }
  3611. }
  3612. QDir::setCurrent(pwd);
  3613. }
  3614. // Generate qt.conf
  3615. QFile confFile(buildPath + "/bin/qt.conf");
  3616. if (confFile.open(QFile::WriteOnly | QFile::Text)) { // Truncates any existing file.
  3617. QTextStream confStream(&confFile);
  3618. confStream << "[EffectivePaths]" << endl
  3619. << "Prefix=.." << endl;
  3620. if (sourcePath != buildPath)
  3621. confStream << "[EffectiveSourcePaths]" << endl
  3622. << "Prefix=" << sourcePath << endl;
  3623. confStream.flush();
  3624. confFile.close();
  3625. }
  3626. }
  3627. void Configure::appendMakeItem(int inList, const QString &item)
  3628. {
  3629. QString dir;
  3630. if (item != "src")
  3631. dir = "/" + item;
  3632. dir.prepend("/src");
  3633. makeList[inList].append(new MakeItem(sourcePath + dir,
  3634. item + ".pro", buildPath + dir + "/Makefile", Lib));
  3635. if (dictionary[ "VCPROJFILES" ] == "yes") {
  3636. makeList[inList].append(new MakeItem(sourcePath + dir,
  3637. item + ".pro", buildPath + dir + "/" + item + ".vcproj", Lib));
  3638. }
  3639. }
  3640. void Configure::generateMakefiles()
  3641. {
  3642. if (dictionary[ "PROCESS" ] != "no") {
  3643. QString spec = dictionary.contains("XQMAKESPEC") ? dictionary[ "XQMAKESPEC" ] : dictionary[ "QMAKESPEC" ];
  3644. if (spec != "win32-msvc.net" && !spec.startsWith("win32-msvc2") && !spec.startsWith(QLatin1String("wince")) && !spec.startsWith("winphone") && !spec.startsWith("winrt") )
  3645. dictionary[ "VCPROJFILES" ] = "no";
  3646. QString pwd = QDir::currentPath();
  3647. {
  3648. QString sourcePathMangled = sourcePath;
  3649. QString buildPathMangled = buildPath;
  3650. if (dictionary.contains("TOPLEVEL")) {
  3651. sourcePathMangled = QFileInfo(sourcePath).path();
  3652. buildPathMangled = QFileInfo(buildPath).path();
  3653. }
  3654. bool generate = true;
  3655. bool doDsp = (dictionary["VCPROJFILES"] == "yes"
  3656. && dictionary["PROCESS"] == "full");
  3657. while (generate) {
  3658. QStringList args;
  3659. args << buildPath + "/bin/qmake";
  3660. if (doDsp) {
  3661. if (dictionary[ "DEPENDENCIES" ] == "no")
  3662. args << "-nodepend";
  3663. args << "-tp" << "vc";
  3664. doDsp = false; // DSP files will be done
  3665. printf("Generating Visual Studio project files...\n");
  3666. } else {
  3667. printf("Generating Makefiles...\n");
  3668. generate = false; // Now Makefiles will be done
  3669. }
  3670. if (dictionary[ "PROCESS" ] == "full")
  3671. args << "-r";
  3672. args << sourcePathMangled;
  3673. QDir::setCurrent(buildPathMangled);
  3674. if (int exitCode = Environment::execute(args, QStringList(), QStringList())) {
  3675. cout << "Qmake failed, return code " << exitCode << endl << endl;
  3676. dictionary[ "DONE" ] = "error";
  3677. }
  3678. }
  3679. }
  3680. QDir::setCurrent(pwd);
  3681. } else {
  3682. cout << "Processing of project files have been disabled." << endl;
  3683. cout << "Only use this option if you really know what you're doing." << endl << endl;
  3684. return;
  3685. }
  3686. }
  3687. void Configure::showSummary()
  3688. {
  3689. QString make = dictionary[ "MAKE" ];
  3690. cout << endl << endl << "Qt is now configured for building. Just run " << qPrintable(make) << "." << endl;
  3691. cout << "To reconfigure, run " << qPrintable(make) << " confclean and configure." << endl << endl;
  3692. }
  3693. Configure::ProjectType Configure::projectType(const QString& proFileName)
  3694. {
  3695. QFile proFile(proFileName);
  3696. if (proFile.open(QFile::ReadOnly)) {
  3697. QString buffer = proFile.readLine(1024);
  3698. while (!buffer.isEmpty()) {
  3699. QStringList segments = buffer.split(QRegExp("\\s"));
  3700. QStringList::Iterator it = segments.begin();
  3701. if (segments.size() >= 3) {
  3702. QString keyword = (*it++);
  3703. QString operation = (*it++);
  3704. QString value = (*it++);
  3705. if (keyword == "TEMPLATE") {
  3706. if (value == "lib")
  3707. return Lib;
  3708. else if (value == "subdirs")
  3709. return Subdirs;
  3710. }
  3711. }
  3712. // read next line
  3713. buffer = proFile.readLine(1024);
  3714. }
  3715. proFile.close();
  3716. }
  3717. // Default to app handling
  3718. return App;
  3719. }
  3720. bool Configure::showLicense(QString orgLicenseFile)
  3721. {
  3722. if (dictionary["LICENSE_CONFIRMED"] == "yes") {
  3723. cout << "You have already accepted the terms of the license." << endl << endl;
  3724. return true;
  3725. }
  3726. bool haveGpl3 = false;
  3727. QString licenseFile = orgLicenseFile;
  3728. QString theLicense;
  3729. if (dictionary["EDITION"] == "OpenSource" || dictionary["EDITION"] == "Snapshot") {
  3730. haveGpl3 = QFile::exists(orgLicenseFile + "/LICENSE.GPL");
  3731. theLicense = "GNU Lesser General Public License (LGPL) version 2.1";
  3732. if (haveGpl3)
  3733. theLicense += "\nor the GNU General Public License (GPL) version 3";
  3734. } else {
  3735. // the first line of the license file tells us which license it is
  3736. QFile file(licenseFile);
  3737. if (!file.open(QFile::ReadOnly)) {
  3738. cout << "Failed to load LICENSE file" << endl;
  3739. return false;
  3740. }
  3741. theLicense = file.readLine().trimmed();
  3742. }
  3743. forever {
  3744. char accept = '?';
  3745. cout << "You are licensed to use this software under the terms of" << endl
  3746. << "the " << theLicense << "." << endl
  3747. << endl;
  3748. if (dictionary["EDITION"] == "OpenSource" || dictionary["EDITION"] == "Snapshot") {
  3749. if (haveGpl3)
  3750. cout << "Type '3' to view the GNU General Public License version 3 (GPLv3)." << endl;
  3751. cout << "Type 'L' to view the Lesser GNU General Public License version 2.1 (LGPLv2.1)." << endl;
  3752. } else {
  3753. cout << "Type '?' to view the " << theLicense << "." << endl;
  3754. }
  3755. cout << "Type 'y' to accept this license offer." << endl
  3756. << "Type 'n' to decline this license offer." << endl
  3757. << endl
  3758. << "Do you accept the terms of the license?" << endl;
  3759. cin >> accept;
  3760. accept = tolower(accept);
  3761. if (accept == 'y') {
  3762. return true;
  3763. } else if (accept == 'n') {
  3764. return false;
  3765. } else {
  3766. if (dictionary["EDITION"] == "OpenSource" || dictionary["EDITION"] == "Snapshot") {
  3767. if (accept == '3')
  3768. licenseFile = orgLicenseFile + "/LICENSE.GPL";
  3769. else
  3770. licenseFile = orgLicenseFile + "/LICENSE.LGPL";
  3771. }
  3772. // Get console line height, to fill the screen properly
  3773. int i = 0, screenHeight = 25; // default
  3774. CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
  3775. HANDLE stdOut = GetStdHandle(STD_OUTPUT_HANDLE);
  3776. if (GetConsoleScreenBufferInfo(stdOut, &consoleInfo))
  3777. screenHeight = consoleInfo.srWindow.Bottom
  3778. - consoleInfo.srWindow.Top
  3779. - 1; // Some overlap for context
  3780. // Prompt the license content to the user
  3781. QFile file(licenseFile);
  3782. if (!file.open(QFile::ReadOnly)) {
  3783. cout << "Failed to load LICENSE file" << licenseFile << endl;
  3784. return false;
  3785. }
  3786. QStringList licenseContent = QString(file.readAll()).split('\n');
  3787. while (i < licenseContent.size()) {
  3788. cout << licenseContent.at(i) << endl;
  3789. if (++i % screenHeight == 0) {
  3790. promptKeyPress();
  3791. cout << "\r"; // Overwrite text above
  3792. }
  3793. }
  3794. }
  3795. }
  3796. }
  3797. void Configure::readLicense()
  3798. {
  3799. dictionary["PLATFORM NAME"] = platformName();
  3800. dictionary["LICENSE FILE"] = sourcePath;
  3801. bool openSource = false;
  3802. bool hasOpenSource = QFile::exists(dictionary["LICENSE FILE"] + "/LICENSE.GPL") || QFile::exists(dictionary["LICENSE FILE"] + "/LICENSE.LGPL");
  3803. if (dictionary["BUILDTYPE"] == "commercial") {
  3804. openSource = false;
  3805. } else if (dictionary["BUILDTYPE"] == "opensource") {
  3806. openSource = true;
  3807. } else if (hasOpenSource) { // No Open Source? Just display the commercial license right away
  3808. forever {
  3809. char accept = '?';
  3810. cout << "Which edition of Qt do you want to use ?" << endl;
  3811. cout << "Type 'c' if you want to use the Commercial Edition." << endl;
  3812. cout << "Type 'o' if you want to use the Open Source Edition." << endl;
  3813. cin >> accept;
  3814. accept = tolower(accept);
  3815. if (accept == 'c') {
  3816. openSource = false;
  3817. break;
  3818. } else if (accept == 'o') {
  3819. openSource = true;
  3820. break;
  3821. }
  3822. }
  3823. }
  3824. if (hasOpenSource && openSource) {
  3825. cout << endl << "This is the " << dictionary["PLATFORM NAME"] << " Open Source Edition." << endl;
  3826. dictionary["LICENSEE"] = "Open Source";
  3827. dictionary["EDITION"] = "OpenSource";
  3828. cout << endl;
  3829. if (!showLicense(dictionary["LICENSE FILE"])) {
  3830. cout << "Configuration aborted since license was not accepted";
  3831. dictionary["DONE"] = "error";
  3832. return;
  3833. }
  3834. } else if (openSource) {
  3835. cout << endl << "Cannot find the GPL license files! Please download the Open Source version of the library." << endl;
  3836. dictionary["DONE"] = "error";
  3837. }
  3838. #ifdef COMMERCIAL_VERSION
  3839. else {
  3840. Tools::checkLicense(dictionary, sourcePath, buildPath);
  3841. }
  3842. #else // !COMMERCIAL_VERSION
  3843. else {
  3844. cout << endl << "Error: This is the Open Source version of Qt."
  3845. << endl << "If you want to use Enterprise features of Qt,"
  3846. << endl << "use the contact form at http://qt.digia.com/contact-us"
  3847. << endl << "to purchase a license." << endl << endl;
  3848. dictionary["DONE"] = "error";
  3849. }
  3850. #endif
  3851. }
  3852. void Configure::reloadCmdLine()
  3853. {
  3854. if (dictionary[ "REDO" ] == "yes") {
  3855. QFile inFile(buildPath + "/configure" + dictionary[ "CUSTOMCONFIG" ] + ".cache");
  3856. if (inFile.open(QFile::ReadOnly)) {
  3857. QTextStream inStream(&inFile);
  3858. QString buffer;
  3859. inStream >> buffer;
  3860. while (buffer.length()) {
  3861. configCmdLine += buffer;
  3862. inStream >> buffer;
  3863. }
  3864. inFile.close();
  3865. }
  3866. }
  3867. }
  3868. void Configure::saveCmdLine()
  3869. {
  3870. if (dictionary[ "REDO" ] != "yes") {
  3871. QFile outFile(buildPath + "/configure" + dictionary[ "CUSTOMCONFIG" ] + ".cache");
  3872. if (outFile.open(QFile::WriteOnly | QFile::Text)) {
  3873. QTextStream outStream(&outFile);
  3874. for (QStringList::Iterator it = configCmdLine.begin(); it != configCmdLine.end(); ++it) {
  3875. outStream << (*it) << " " << endl;
  3876. }
  3877. outStream.flush();
  3878. outFile.close();
  3879. }
  3880. }
  3881. }
  3882. bool Configure::isDone()
  3883. {
  3884. return !dictionary["DONE"].isEmpty();
  3885. }
  3886. bool Configure::isOk()
  3887. {
  3888. return (dictionary[ "DONE" ] != "error");
  3889. }
  3890. QString Configure::platformName() const
  3891. {
  3892. switch (platform()) {
  3893. default:
  3894. case WINDOWS:
  3895. return QStringLiteral("Qt for Windows");
  3896. case WINDOWS_CE:
  3897. return QStringLiteral("Qt for Windows CE");
  3898. case WINDOWS_RT:
  3899. return QStringLiteral("Qt for Windows Runtime");
  3900. case QNX:
  3901. return QStringLiteral("Qt for QNX");
  3902. case BLACKBERRY:
  3903. return QStringLiteral("Qt for Blackberry");
  3904. case ANDROID:
  3905. return QStringLiteral("Qt for Android");
  3906. }
  3907. }
  3908. QString Configure::qpaPlatformName() const
  3909. {
  3910. switch (platform()) {
  3911. default:
  3912. case WINDOWS:
  3913. case WINDOWS_CE:
  3914. return QStringLiteral("windows");
  3915. case WINDOWS_RT:
  3916. return QStringLiteral("winrt");
  3917. case QNX:
  3918. return QStringLiteral("qnx");
  3919. case BLACKBERRY:
  3920. return QStringLiteral("blackberry");
  3921. case ANDROID:
  3922. return QStringLiteral("android");
  3923. }
  3924. }
  3925. int Configure::platform() const
  3926. {
  3927. const QString qMakeSpec = dictionary.value("QMAKESPEC");
  3928. const QString xQMakeSpec = dictionary.value("XQMAKESPEC");
  3929. if ((xQMakeSpec.startsWith("winphone") || xQMakeSpec.startsWith("winrt")))
  3930. return WINDOWS_RT;
  3931. if ((qMakeSpec.startsWith("wince") || xQMakeSpec.startsWith("wince")))
  3932. return WINDOWS_CE;
  3933. if (xQMakeSpec.contains("qnx"))
  3934. return QNX;
  3935. if (xQMakeSpec.contains("blackberry"))
  3936. return BLACKBERRY;
  3937. if (xQMakeSpec.contains("android"))
  3938. return ANDROID;
  3939. return WINDOWS;
  3940. }
  3941. FileWriter::FileWriter(const QString &name)
  3942. : QTextStream()
  3943. , m_name(name)
  3944. {
  3945. m_buffer.open(QIODevice::WriteOnly);
  3946. setDevice(&m_buffer);
  3947. }
  3948. bool FileWriter::flush()
  3949. {
  3950. QTextStream::flush();
  3951. QFile oldFile(m_name);
  3952. if (oldFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
  3953. if (oldFile.readAll() == m_buffer.data())
  3954. return true;
  3955. oldFile.close();
  3956. }
  3957. QString dir = QFileInfo(m_name).absolutePath();
  3958. if (!QDir().mkpath(dir)) {
  3959. cout << "Cannot create directory " << qPrintable(QDir::toNativeSeparators(dir)) << ".\n";
  3960. return false;
  3961. }
  3962. QFile file(m_name + ".new");
  3963. if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
  3964. if (file.write(m_buffer.data()) == m_buffer.data().size()) {
  3965. file.close();
  3966. if (file.error() == QFile::NoError) {
  3967. ::SetFileAttributes((wchar_t*)m_name.utf16(), FILE_ATTRIBUTE_NORMAL);
  3968. QFile::remove(m_name);
  3969. if (!file.rename(m_name)) {
  3970. cout << "Cannot replace file " << qPrintable(QDir::toNativeSeparators(m_name)) << ".\n";
  3971. return false;
  3972. }
  3973. return true;
  3974. }
  3975. }
  3976. }
  3977. cout << "Cannot create file " << qPrintable(QDir::toNativeSeparators(file.fileName()))
  3978. << ": " << qPrintable(file.errorString()) << ".\n";
  3979. file.remove();
  3980. return false;
  3981. }
  3982. QT_END_NAMESPACE