void Win32MakefileGenerator::processPrlFiles() { const QString libArg = project->first("QMAKE_L_FLAG").toQString(); QList<QMakeLocalFileName> libdirs; static const char * const lflags[] = { "QMAKE_LIBS", "QMAKE_LIBS_PRIVATE", 0 }; for (int i = 0; lflags[i]; i++) { ProStringList &l = project->values(lflags[i]); for (int lit = 0; lit < l.size(); ++lit) { QString opt = l.at(lit).trimmed().toQString(); if((opt[0] == '\'' || opt[0] == '"') && opt[(int)opt.length()-1] == opt[0]) opt = opt.mid(1, opt.length()-2); if (opt.startsWith(libArg)) { QMakeLocalFileName l(opt.mid(libArg.length())); if (!libdirs.contains(l)) libdirs.append(l); } else if (!opt.startsWith("/")) { if (!processPrlFile(opt) && (QDir::isRelativePath(opt) || opt.startsWith("-l"))) { QString tmp; if (opt.startsWith("-l")) tmp = opt.mid(2); else tmp = opt; for(QList<QMakeLocalFileName>::Iterator it = libdirs.begin(); it != libdirs.end(); ++it) { QString prl = (*it).local() + Option::dir_sep + tmp; if (processPrlFile(prl)) break; } } } ProStringList &prl_libs = project->values("QMAKE_CURRENT_PRL_LIBS"); for (int prl = 0; prl < prl_libs.size(); ++prl) { ProString arg = prl_libs.at(prl); if (arg.startsWith(libArg)) arg = arg.left(libArg.length()) + escapeFilePath(arg.mid(libArg.length()).toQString()); else if (!arg.startsWith('/')) arg = escapeFilePath(arg.toQString()); l.insert(lit + prl + 1, arg); } prl_libs.clear(); } // Merge them into a logical order if (!project->isActiveConfig("no_smart_library_merge") && !project->isActiveConfig("no_lflags_merge")) { ProStringList lflags; for (int lit = 0; lit < l.size(); ++lit) { ProString opt = l.at(lit).trimmed(); if (opt.startsWith(libArg)) { if (!lflags.contains(opt)) lflags.append(opt); } else { // Make sure we keep the dependency-order of libraries lflags.removeAll(opt); lflags.append(opt); } } l = lflags; } } }
bool NmakeMakefileGenerator::writeMakefile(QTextStream &t) { writeHeader(t); if (writeDummyMakefile(t)) return true; if(project->first("TEMPLATE") == "app" || project->first("TEMPLATE") == "lib" || project->first("TEMPLATE") == "aux") { #if 0 if(Option::mkfile::do_stub_makefile) return MakefileGenerator::writeStubMakefile(t); #endif if (!project->isHostBuild()) { const ProValueMap &variables = project->variables(); if (project->isActiveConfig("wince")) { CeSdkHandler sdkhandler; sdkhandler.parse(); const QString sdkName = variables["CE_SDK"].join(' ') + " (" + variables["CE_ARCH"].join(' ') + ")"; const QList<CeSdkInfo> sdkList = sdkhandler.listAll(); CeSdkInfo sdk; foreach (const CeSdkInfo &info, sdkList) { if (info.name().compare(sdkName, Qt::CaseInsensitive ) == 0) { sdk = info; break; } } if (sdk.isValid()) { t << "\nINCLUDE = " << sdk.includePath(); t << "\nLIB = " << sdk.libPath(); t << "\nPATH = " << sdk.binPath() << "\n"; } else { QStringList sdkStringList; foreach (const CeSdkInfo &info, sdkList) sdkStringList << info.name(); fprintf(stderr, "Failed to find Windows CE SDK matching %s, found: %s\n" "SDK needs to be specified in mkspec (using: %s/qmake.conf)\n" "SDK name needs to match the following format: CE_SDK (CE_ARCH)\n", qPrintable(sdkName), qPrintable(sdkStringList.join(", ")), qPrintable(variables["QMAKESPEC"].first().toQString())); return false; } } else if (project->isActiveConfig(QStringLiteral("winrt"))) { QString arch = project->first("VCPROJ_ARCH").toQString().toLower(); QString compiler; QString compilerArch; if (arch == QStringLiteral("arm")) { compiler = QStringLiteral("x86_arm"); compilerArch = QStringLiteral("arm"); } else if (arch == QStringLiteral("x64")) { const ProStringList hostArch = project->values("QMAKE_TARGET.arch"); if (hostArch.contains("x86_64")) compiler = QStringLiteral("amd64"); else compiler = QStringLiteral("x86_amd64"); compilerArch = QStringLiteral("amd64"); } else { arch = QStringLiteral("x86"); } const QString msvcVer = project->first("MSVC_VER").toQString(); if (msvcVer.isEmpty()) { fprintf(stderr, "Mkspec does not specify MSVC_VER. Cannot continue.\n"); return false; } const QString winsdkVer = project->first("WINSDK_VER").toQString(); if (winsdkVer.isEmpty()) { fprintf(stderr, "Mkspec does not specify WINSDK_VER. Cannot continue.\n"); return false; } const QString targetVer = project->first("WINTARGET_VER").toQString(); if (targetVer.isEmpty()) { fprintf(stderr, "Mkspec does not specify WINTARGET_VER. Cannot continue.\n"); return false; } const bool isPhone = project->isActiveConfig(QStringLiteral("winphone")); #ifdef Q_OS_WIN QString regKeyPrefix; #if !defined(Q_OS_WIN64) && _WIN32_WINNT >= 0x0501 BOOL isWow64; IsWow64Process(GetCurrentProcess(), &isWow64); if (!isWow64) regKeyPrefix = QStringLiteral("Software\\"); else #endif regKeyPrefix = QStringLiteral("Software\\Wow6432Node\\"); QString regKey = regKeyPrefix + QStringLiteral("Microsoft\\VisualStudio\\") + msvcVer + ("\\Setup\\VC\\ProductDir"); const QString vcInstallDir = qt_readRegistryKey(HKEY_LOCAL_MACHINE, regKey); if (vcInstallDir.isEmpty()) { fprintf(stderr, "Failed to find the Visual Studio installation directory.\n"); return false; } regKey = regKeyPrefix + (isPhone ? QStringLiteral("Microsoft\\Microsoft SDKs\\WindowsPhone\\v") : QStringLiteral("Microsoft\\Microsoft SDKs\\Windows\\v")) + winsdkVer + QStringLiteral("\\InstallationFolder"); const QString kitDir = qt_readRegistryKey(HKEY_LOCAL_MACHINE, regKey); if (kitDir.isEmpty()) { fprintf(stderr, "Failed to find the Windows Kit installation directory.\n"); return false; } #else const QString vcInstallDir = "/fake/vc_install_dir"; const QString kitDir = "/fake/sdk_install_dir"; #endif // Q_OS_WIN QStringList incDirs; QStringList libDirs; QStringList binDirs; if (isPhone) { QString sdkDir = vcInstallDir + QStringLiteral("/WPSDK/") + targetVer; if (!QDir(sdkDir).exists()) { fprintf(stderr, "Failed to find the Windows Phone SDK in %s.\n" "Check that it is properly installed.\n", qPrintable(QDir::toNativeSeparators(sdkDir))); return false; } incDirs << sdkDir + QStringLiteral("/include"); libDirs << sdkDir + QStringLiteral("/lib/") + compilerArch; binDirs << sdkDir + QStringLiteral("/bin/") + compiler; libDirs << kitDir + QStringLiteral("/lib/") + arch; incDirs << kitDir + QStringLiteral("/include") << kitDir + QStringLiteral("/include/abi") << kitDir + QStringLiteral("/include/mincore") << kitDir + QStringLiteral("/include/minwin"); } else { incDirs << vcInstallDir + QStringLiteral("/include"); libDirs << vcInstallDir + QStringLiteral("/lib/store/") + compilerArch << vcInstallDir + QStringLiteral("/lib/") + compilerArch; binDirs << vcInstallDir + QStringLiteral("/bin/") + compiler << vcInstallDir + QStringLiteral("/../Common7/IDE"); libDirs << kitDir + QStringLiteral("/Lib/") + targetVer + ("/um/") + arch; incDirs << kitDir + QStringLiteral("/include/um") << kitDir + QStringLiteral("/include/shared") << kitDir + QStringLiteral("/include/winrt"); } // Inherit PATH binDirs << QString::fromLocal8Bit(qgetenv("PATH")).split(QLatin1Char(';')); t << "\nINCLUDE = " << nmakePathList(incDirs); t << "\nLIB = " << nmakePathList(libDirs); t << "\nPATH = " << nmakePathList(binDirs) << '\n'; } }