| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** Contact: Qt Software Information ([email protected])
|
|---|
| 5 | **
|
|---|
| 6 | ** This file is part of the qmake application of the Qt Toolkit.
|
|---|
| 7 | **
|
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 9 | ** Commercial Usage
|
|---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 13 | ** a written agreement between you and Nokia.
|
|---|
| 14 | **
|
|---|
| 15 | ** GNU Lesser General Public License Usage
|
|---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 17 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 19 | ** packaging of this file. Please review the following information to
|
|---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 22 | **
|
|---|
| 23 | ** In addition, as a special exception, Nokia gives you certain
|
|---|
| 24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
|---|
| 25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
|---|
| 26 | ** package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you are unsure which license is appropriate for your use, please
|
|---|
| 37 | ** contact the sales department at [email protected].
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | #include "mingw_make.h"
|
|---|
| 43 | #include "option.h"
|
|---|
| 44 | #include "meta.h"
|
|---|
| 45 | #include <qregexp.h>
|
|---|
| 46 | #include <qdir.h>
|
|---|
| 47 | #include <stdlib.h>
|
|---|
| 48 | #include <time.h>
|
|---|
| 49 |
|
|---|
| 50 | QT_BEGIN_NAMESPACE
|
|---|
| 51 |
|
|---|
| 52 | MingwMakefileGenerator::MingwMakefileGenerator() : Win32MakefileGenerator(), init_flag(false)
|
|---|
| 53 | {
|
|---|
| 54 | if (Option::shellPath.isEmpty())
|
|---|
| 55 | quote = "\"";
|
|---|
| 56 | else
|
|---|
| 57 | quote = "'";
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | bool MingwMakefileGenerator::isDosLikeShell() const
|
|---|
| 61 | {
|
|---|
| 62 | #ifdef Q_OS_WIN
|
|---|
| 63 | return Option::shellPath.isEmpty();
|
|---|
| 64 | #else
|
|---|
| 65 | return Win32MakefileGenerator::isDosLikeShell();
|
|---|
| 66 | #endif
|
|---|
| 67 | }
|
|---|
| 68 |
|
|---|
| 69 | QString MingwMakefileGenerator::escapeDependencyPath(const QString &path) const
|
|---|
| 70 | {
|
|---|
| 71 | QString ret = path;
|
|---|
| 72 | ret.remove('\"');
|
|---|
| 73 | ret.replace('\\', "/");
|
|---|
| 74 | ret.replace(' ', "\\ ");
|
|---|
| 75 | return ret;
|
|---|
| 76 | }
|
|---|
| 77 |
|
|---|
| 78 | QString MingwMakefileGenerator::getLibTarget()
|
|---|
| 79 | {
|
|---|
| 80 | return QString("lib" + project->first("TARGET") + project->first("TARGET_VERSION_EXT") + ".a");
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | bool MingwMakefileGenerator::findLibraries()
|
|---|
| 84 | {
|
|---|
| 85 | QStringList &l = project->values("QMAKE_LIBS");
|
|---|
| 86 |
|
|---|
| 87 | QList<QMakeLocalFileName> dirs;
|
|---|
| 88 | {
|
|---|
| 89 | QStringList &libpaths = project->values("QMAKE_LIBDIR");
|
|---|
| 90 | for(QStringList::Iterator libpathit = libpaths.begin();
|
|---|
| 91 | libpathit != libpaths.end(); ++libpathit)
|
|---|
| 92 | dirs.append(QMakeLocalFileName((*libpathit)));
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | QStringList::Iterator it = l.begin();
|
|---|
| 96 | while (it != l.end()) {
|
|---|
| 97 | if ((*it).startsWith("-l")) {
|
|---|
| 98 | QString steam = (*it).mid(2), out;
|
|---|
| 99 | QString suffix;
|
|---|
| 100 | if (!project->isEmpty("QMAKE_" + steam.toUpper() + "_SUFFIX"))
|
|---|
| 101 | suffix = project->first("QMAKE_" + steam.toUpper() + "_SUFFIX");
|
|---|
| 102 | for (QList<QMakeLocalFileName>::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) {
|
|---|
| 103 | QString extension;
|
|---|
| 104 | int ver = findHighestVersion((*dir_it).local(), steam, "dll.a|a");
|
|---|
| 105 | if (ver != -1)
|
|---|
| 106 | extension += QString::number(ver);
|
|---|
| 107 | extension += suffix;
|
|---|
| 108 | if(QMakeMetaInfo::libExists((*dir_it).local() + Option::dir_sep + steam) ||
|
|---|
| 109 | exists((*dir_it).local() + Option::dir_sep + steam + extension + ".a") ||
|
|---|
| 110 | exists((*dir_it).local() + Option::dir_sep + steam + extension + ".dll.a")) {
|
|---|
| 111 | out = (*it) + extension;
|
|---|
| 112 | break;
|
|---|
| 113 | }
|
|---|
| 114 | }
|
|---|
| 115 | if (!out.isEmpty()) // We assume if it never finds it that its correct
|
|---|
| 116 | (*it) = out;
|
|---|
| 117 | } else if((*it).startsWith("-L")) {
|
|---|
| 118 | dirs.append(QMakeLocalFileName((*it).mid(2)));
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | ++it;
|
|---|
| 122 | }
|
|---|
| 123 | return true;
|
|---|
| 124 | }
|
|---|
| 125 |
|
|---|
| 126 | bool MingwMakefileGenerator::writeMakefile(QTextStream &t)
|
|---|
| 127 | {
|
|---|
| 128 | writeHeader(t);
|
|---|
| 129 | if(!project->values("QMAKE_FAILED_REQUIREMENTS").isEmpty()) {
|
|---|
| 130 | t << "all clean:" << "\n\t"
|
|---|
| 131 | << "@echo \"Some of the required modules ("
|
|---|
| 132 | << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t"
|
|---|
| 133 | << "@echo \"Skipped.\"" << endl << endl;
|
|---|
| 134 | writeMakeQmake(t);
|
|---|
| 135 | return true;
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 | if(project->first("TEMPLATE") == "app" ||
|
|---|
| 139 | project->first("TEMPLATE") == "lib") {
|
|---|
| 140 | if(Option::mkfile::do_stub_makefile) {
|
|---|
| 141 | t << "QMAKE = " << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl;
|
|---|
| 142 | QStringList &qut = project->values("QMAKE_EXTRA_TARGETS");
|
|---|
| 143 | for(QStringList::ConstIterator it = qut.begin(); it != qut.end(); ++it)
|
|---|
| 144 | t << *it << " ";
|
|---|
| 145 | t << "first all clean install distclean uninstall: qmake" << endl
|
|---|
| 146 | << "qmake_all:" << endl;
|
|---|
| 147 | writeMakeQmake(t);
|
|---|
| 148 | if(project->isEmpty("QMAKE_NOFORCE"))
|
|---|
| 149 | t << "FORCE:" << endl << endl;
|
|---|
| 150 | return true;
|
|---|
| 151 | }
|
|---|
| 152 | writeMingwParts(t);
|
|---|
| 153 | return MakefileGenerator::writeMakefile(t);
|
|---|
| 154 | }
|
|---|
| 155 | else if(project->first("TEMPLATE") == "subdirs") {
|
|---|
| 156 | writeSubDirs(t);
|
|---|
| 157 | return true;
|
|---|
| 158 | }
|
|---|
| 159 | return false;
|
|---|
| 160 | }
|
|---|
| 161 |
|
|---|
| 162 | void createLdObjectScriptFile(const QString &fileName, const QStringList &objList)
|
|---|
| 163 | {
|
|---|
| 164 | QString filePath = Option::output_dir + QDir::separator() + fileName;
|
|---|
| 165 | QFile file(filePath);
|
|---|
| 166 | if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
|---|
| 167 | QTextStream t(&file);
|
|---|
| 168 | t << "INPUT(" << endl;
|
|---|
| 169 | for (QStringList::ConstIterator it = objList.constBegin(); it != objList.constEnd(); ++it) {
|
|---|
| 170 | if (QDir::isRelativePath(*it))
|
|---|
| 171 | t << "./" << *it << endl;
|
|---|
| 172 | else
|
|---|
| 173 | t << *it << endl;
|
|---|
| 174 | }
|
|---|
| 175 | t << ");" << endl;
|
|---|
| 176 | t.flush();
|
|---|
| 177 | file.close();
|
|---|
| 178 | }
|
|---|
| 179 | }
|
|---|
| 180 |
|
|---|
| 181 | void createArObjectScriptFile(const QString &fileName, const QString &target, const QStringList &objList)
|
|---|
| 182 | {
|
|---|
| 183 | QString filePath = Option::output_dir + QDir::separator() + fileName;
|
|---|
| 184 | QFile file(filePath);
|
|---|
| 185 | if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
|---|
| 186 | QTextStream t(&file);
|
|---|
| 187 | t << "CREATE " << target << endl;
|
|---|
| 188 | for (QStringList::ConstIterator it = objList.constBegin(); it != objList.constEnd(); ++it) {
|
|---|
| 189 | if (QDir::isRelativePath(*it))
|
|---|
| 190 | t << "ADDMOD " << *it << endl;
|
|---|
| 191 | else
|
|---|
| 192 | t << *it << endl;
|
|---|
| 193 | }
|
|---|
| 194 | t << "SAVE" << endl;
|
|---|
| 195 | t.flush();
|
|---|
| 196 | file.close();
|
|---|
| 197 | }
|
|---|
| 198 | }
|
|---|
| 199 |
|
|---|
| 200 | void MingwMakefileGenerator::writeMingwParts(QTextStream &t)
|
|---|
| 201 | {
|
|---|
| 202 | writeStandardParts(t);
|
|---|
| 203 |
|
|---|
| 204 | if (!preCompHeaderOut.isEmpty()) {
|
|---|
| 205 | QString header = project->first("PRECOMPILED_HEADER");
|
|---|
| 206 | QString cHeader = preCompHeaderOut + Option::dir_sep + "c";
|
|---|
| 207 | t << escapeDependencyPath(cHeader) << ": " << escapeDependencyPath(header) << " "
|
|---|
| 208 | << escapeDependencyPaths(findDependencies(header)).join(" \\\n\t\t")
|
|---|
| 209 | << "\n\t" << mkdir_p_asstring(preCompHeaderOut)
|
|---|
| 210 | << "\n\t" << "$(CC) -x c-header -c $(CFLAGS) $(INCPATH) -o " << cHeader << " " << header
|
|---|
| 211 | << endl << endl;
|
|---|
| 212 | QString cppHeader = preCompHeaderOut + Option::dir_sep + "c++";
|
|---|
| 213 | t << escapeDependencyPath(cppHeader) << ": " << escapeDependencyPath(header) << " "
|
|---|
| 214 | << escapeDependencyPaths(findDependencies(header)).join(" \\\n\t\t")
|
|---|
| 215 | << "\n\t" << mkdir_p_asstring(preCompHeaderOut)
|
|---|
| 216 | << "\n\t" << "$(CXX) -x c++-header -c $(CXXFLAGS) $(INCPATH) -o " << cppHeader << " " << header
|
|---|
| 217 | << endl << endl;
|
|---|
| 218 | }
|
|---|
| 219 | }
|
|---|
| 220 |
|
|---|
| 221 | void MingwMakefileGenerator::init()
|
|---|
| 222 | {
|
|---|
| 223 | if(init_flag)
|
|---|
| 224 | return;
|
|---|
| 225 | init_flag = true;
|
|---|
| 226 |
|
|---|
| 227 | /* this should probably not be here, but I'm using it to wrap the .t files */
|
|---|
| 228 | if(project->first("TEMPLATE") == "app")
|
|---|
| 229 | project->values("QMAKE_APP_FLAG").append("1");
|
|---|
| 230 | else if(project->first("TEMPLATE") == "lib")
|
|---|
| 231 | project->values("QMAKE_LIB_FLAG").append("1");
|
|---|
| 232 | else if(project->first("TEMPLATE") == "subdirs") {
|
|---|
| 233 | MakefileGenerator::init();
|
|---|
| 234 | if(project->isEmpty("QMAKE_COPY_FILE"))
|
|---|
| 235 | project->values("QMAKE_COPY_FILE").append("$(COPY)");
|
|---|
| 236 | if(project->isEmpty("QMAKE_COPY_DIR"))
|
|---|
| 237 | project->values("QMAKE_COPY_DIR").append("xcopy /s /q /y /i");
|
|---|
| 238 | if(project->isEmpty("QMAKE_INSTALL_FILE"))
|
|---|
| 239 | project->values("QMAKE_INSTALL_FILE").append("$(COPY_FILE)");
|
|---|
| 240 | if(project->isEmpty("QMAKE_INSTALL_PROGRAM"))
|
|---|
| 241 | project->values("QMAKE_INSTALL_PROGRAM").append("$(COPY_FILE)");
|
|---|
| 242 | if(project->isEmpty("QMAKE_INSTALL_DIR"))
|
|---|
| 243 | project->values("QMAKE_INSTALL_DIR").append("$(COPY_DIR)");
|
|---|
| 244 | if(project->values("MAKEFILE").isEmpty())
|
|---|
| 245 | project->values("MAKEFILE").append("Makefile");
|
|---|
| 246 | if(project->values("QMAKE_QMAKE").isEmpty())
|
|---|
| 247 | project->values("QMAKE_QMAKE").append("qmake");
|
|---|
| 248 | return;
|
|---|
| 249 | }
|
|---|
| 250 |
|
|---|
| 251 | project->values("TARGET_PRL").append(project->first("TARGET"));
|
|---|
| 252 |
|
|---|
| 253 | processVars();
|
|---|
| 254 |
|
|---|
| 255 | if (!project->values("RES_FILE").isEmpty()) {
|
|---|
| 256 | project->values("QMAKE_LIBS") += escapeFilePaths(project->values("RES_FILE"));
|
|---|
| 257 | }
|
|---|
| 258 |
|
|---|
| 259 | // LIBS defined in Profile comes first for gcc
|
|---|
| 260 | project->values("QMAKE_LIBS") += escapeFilePaths(project->values("LIBS"));
|
|---|
| 261 |
|
|---|
| 262 | QString targetfilename = project->values("TARGET").first();
|
|---|
| 263 | QStringList &configs = project->values("CONFIG");
|
|---|
| 264 |
|
|---|
| 265 | if(project->isActiveConfig("qt_dll"))
|
|---|
| 266 | if(configs.indexOf("qt") == -1)
|
|---|
| 267 | configs.append("qt");
|
|---|
| 268 |
|
|---|
| 269 | if(project->isActiveConfig("dll")) {
|
|---|
| 270 | QString destDir = "";
|
|---|
| 271 | if(!project->first("DESTDIR").isEmpty())
|
|---|
| 272 | destDir = Option::fixPathToTargetOS(project->first("DESTDIR") + Option::dir_sep, false, false);
|
|---|
| 273 | project->values("MINGW_IMPORT_LIB").prepend(destDir + "lib" + project->first("TARGET")
|
|---|
| 274 | + project->first("TARGET_VERSION_EXT") + ".a");
|
|---|
| 275 | project->values("QMAKE_LFLAGS").append(QString("-Wl,--out-implib,") + project->first("MINGW_IMPORT_LIB"));
|
|---|
| 276 | }
|
|---|
| 277 |
|
|---|
| 278 | if(!project->values("DEF_FILE").isEmpty())
|
|---|
| 279 | project->values("QMAKE_LFLAGS").append(QString("-Wl,") + project->first("DEF_FILE"));
|
|---|
| 280 |
|
|---|
| 281 | MakefileGenerator::init();
|
|---|
| 282 |
|
|---|
| 283 | // precomp
|
|---|
| 284 | if (!project->first("PRECOMPILED_HEADER").isEmpty()
|
|---|
| 285 | && project->isActiveConfig("precompile_header")) {
|
|---|
| 286 | QString preCompHeader = var("PRECOMPILED_DIR")
|
|---|
| 287 | + QFileInfo(project->first("PRECOMPILED_HEADER")).fileName();
|
|---|
| 288 | preCompHeaderOut = preCompHeader + ".gch";
|
|---|
| 289 | project->values("QMAKE_CLEAN").append(preCompHeaderOut + Option::dir_sep + "c");
|
|---|
| 290 | project->values("QMAKE_CLEAN").append(preCompHeaderOut + Option::dir_sep + "c++");
|
|---|
| 291 |
|
|---|
| 292 | project->values("QMAKE_RUN_CC").clear();
|
|---|
| 293 | project->values("QMAKE_RUN_CC").append("$(CC) -c -include " + preCompHeader +
|
|---|
| 294 | " $(CFLAGS) $(INCPATH) -o $obj $src");
|
|---|
| 295 | project->values("QMAKE_RUN_CC_IMP").clear();
|
|---|
| 296 | project->values("QMAKE_RUN_CC_IMP").append("$(CC) -c -include " + preCompHeader +
|
|---|
| 297 | " $(CFLAGS) $(INCPATH) -o $@ $<");
|
|---|
| 298 | project->values("QMAKE_RUN_CXX").clear();
|
|---|
| 299 | project->values("QMAKE_RUN_CXX").append("$(CXX) -c -include " + preCompHeader +
|
|---|
| 300 | " $(CXXFLAGS) $(INCPATH) -o $obj $src");
|
|---|
| 301 | project->values("QMAKE_RUN_CXX_IMP").clear();
|
|---|
| 302 | project->values("QMAKE_RUN_CXX_IMP").append("$(CXX) -c -include " + preCompHeader +
|
|---|
| 303 | " $(CXXFLAGS) $(INCPATH) -o $@ $<");
|
|---|
| 304 | }
|
|---|
| 305 |
|
|---|
| 306 | if(project->isActiveConfig("dll")) {
|
|---|
| 307 | project->values("QMAKE_CLEAN").append(project->first("MINGW_IMPORT_LIB"));
|
|---|
| 308 | }
|
|---|
| 309 | }
|
|---|
| 310 |
|
|---|
| 311 | void MingwMakefileGenerator::fixTargetExt()
|
|---|
| 312 | {
|
|---|
| 313 | if (project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") {
|
|---|
| 314 | project->values("TARGET_EXT").append(".a");
|
|---|
| 315 | project->values("QMAKE_LFLAGS").append("-static");
|
|---|
| 316 | project->values("TARGET").first() = "lib" + project->first("TARGET");
|
|---|
| 317 | } else {
|
|---|
| 318 | Win32MakefileGenerator::fixTargetExt();
|
|---|
| 319 | }
|
|---|
| 320 | }
|
|---|
| 321 |
|
|---|
| 322 | void MingwMakefileGenerator::writeIncPart(QTextStream &t)
|
|---|
| 323 | {
|
|---|
| 324 | t << "INCPATH = ";
|
|---|
| 325 |
|
|---|
| 326 | QStringList &incs = project->values("INCLUDEPATH");
|
|---|
| 327 | for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) {
|
|---|
| 328 | QString inc = (*incit);
|
|---|
| 329 | inc.replace(QRegExp("\\\\$"), "");
|
|---|
| 330 | inc.replace(QRegExp("\""), "");
|
|---|
| 331 | t << "-I" << quote << inc << quote << " ";
|
|---|
| 332 | }
|
|---|
| 333 | t << "-I" << quote << specdir() << quote
|
|---|
| 334 | << endl;
|
|---|
| 335 | }
|
|---|
| 336 |
|
|---|
| 337 | void MingwMakefileGenerator::writeLibsPart(QTextStream &t)
|
|---|
| 338 | {
|
|---|
| 339 | if(project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") {
|
|---|
| 340 | t << "LIB = " << var("QMAKE_LIB") << endl;
|
|---|
| 341 | } else {
|
|---|
| 342 | t << "LINK = " << var("QMAKE_LINK") << endl;
|
|---|
| 343 | t << "LFLAGS = " << var("QMAKE_LFLAGS") << endl;
|
|---|
| 344 | t << "LIBS = ";
|
|---|
| 345 | if(!project->values("QMAKE_LIBDIR").isEmpty())
|
|---|
| 346 | writeLibDirPart(t);
|
|---|
| 347 | t << var("QMAKE_LIBS").replace(QRegExp("(\\slib|^lib)")," -l") << endl;
|
|---|
| 348 | }
|
|---|
| 349 | }
|
|---|
| 350 |
|
|---|
| 351 | void MingwMakefileGenerator::writeLibDirPart(QTextStream &t)
|
|---|
| 352 | {
|
|---|
| 353 | QStringList libDirs = project->values("QMAKE_LIBDIR");
|
|---|
| 354 | for (int i = 0; i < libDirs.size(); ++i)
|
|---|
| 355 | libDirs[i].remove("\"");
|
|---|
| 356 | t << valGlue(libDirs,"-L"+quote,quote+" -L" +quote,quote) << " ";
|
|---|
| 357 | }
|
|---|
| 358 |
|
|---|
| 359 | void MingwMakefileGenerator::writeObjectsPart(QTextStream &t)
|
|---|
| 360 | {
|
|---|
| 361 | if (project->values("OBJECTS").count() < var("QMAKE_LINK_OBJECT_MAX").toInt()) {
|
|---|
| 362 | objectsLinkLine = "$(OBJECTS)";
|
|---|
| 363 | } else if (project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") {
|
|---|
| 364 | QString ar_script_file = var("QMAKE_LINK_OBJECT_SCRIPT") + "." + var("TARGET");
|
|---|
| 365 | if (!var("BUILD_NAME").isEmpty()) {
|
|---|
| 366 | ar_script_file += "." + var("BUILD_NAME");
|
|---|
| 367 | }
|
|---|
| 368 | createArObjectScriptFile(ar_script_file, var("DEST_TARGET"), project->values("OBJECTS"));
|
|---|
| 369 | objectsLinkLine = "ar -M < " + ar_script_file;
|
|---|
| 370 | } else {
|
|---|
| 371 | QString ld_script_file = var("QMAKE_LINK_OBJECT_SCRIPT") + "." + var("TARGET");
|
|---|
| 372 | if (!var("BUILD_NAME").isEmpty()) {
|
|---|
| 373 | ld_script_file += "." + var("BUILD_NAME");
|
|---|
| 374 | }
|
|---|
| 375 | createLdObjectScriptFile(ld_script_file, project->values("OBJECTS"));
|
|---|
| 376 | objectsLinkLine = ld_script_file;
|
|---|
| 377 | }
|
|---|
| 378 | Win32MakefileGenerator::writeObjectsPart(t);
|
|---|
| 379 | }
|
|---|
| 380 |
|
|---|
| 381 | void MingwMakefileGenerator::writeBuildRulesPart(QTextStream &t)
|
|---|
| 382 | {
|
|---|
| 383 | t << "first: all" << endl;
|
|---|
| 384 | t << "all: " << escapeDependencyPath(fileFixify(Option::output.fileName())) << " " << valGlue(escapeDependencyPaths(project->values("ALL_DEPS"))," "," "," ") << " $(DESTDIR_TARGET)" << endl << endl;
|
|---|
| 385 | t << "$(DESTDIR_TARGET): " << var("PRE_TARGETDEPS") << " $(OBJECTS) " << var("POST_TARGETDEPS");
|
|---|
| 386 | if(!project->isEmpty("QMAKE_PRE_LINK"))
|
|---|
| 387 | t << "\n\t" <<var("QMAKE_PRE_LINK");
|
|---|
| 388 | if(project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") {
|
|---|
| 389 | if (project->values("OBJECTS").count() < var("QMAKE_LINK_OBJECT_MAX").toInt()) {
|
|---|
| 390 | t << "\n\t" << "$(LIB) $(DESTDIR_TARGET) " << objectsLinkLine << " " ;
|
|---|
| 391 | } else {
|
|---|
| 392 | t << "\n\t" << objectsLinkLine << " " ;
|
|---|
| 393 | }
|
|---|
| 394 | } else {
|
|---|
| 395 | t << "\n\t" << "$(LINK) $(LFLAGS) -o $(DESTDIR_TARGET) " << objectsLinkLine << " " << " $(LIBS)";
|
|---|
| 396 | }
|
|---|
| 397 | if(!project->isEmpty("QMAKE_POST_LINK"))
|
|---|
| 398 | t << "\n\t" <<var("QMAKE_POST_LINK");
|
|---|
| 399 | t << endl;
|
|---|
| 400 | }
|
|---|
| 401 |
|
|---|
| 402 | void MingwMakefileGenerator::writeRcFilePart(QTextStream &t)
|
|---|
| 403 | {
|
|---|
| 404 | const QString rc_file = fileFixify(project->first("RC_FILE"));
|
|---|
| 405 |
|
|---|
| 406 | QString incPathStr = fileInfo(rc_file).path();
|
|---|
| 407 | if (incPathStr != "." && QDir::isRelativePath(incPathStr))
|
|---|
| 408 | incPathStr.prepend("./");
|
|---|
| 409 |
|
|---|
| 410 | if (!rc_file.isEmpty()) {
|
|---|
| 411 | t << escapeDependencyPath(var("RES_FILE")) << ": " << rc_file << "\n\t"
|
|---|
| 412 | << var("QMAKE_RC") << " -i " << rc_file << " -o " << var("RES_FILE")
|
|---|
| 413 | << " --include-dir=" << incPathStr << endl << endl;
|
|---|
| 414 | }
|
|---|
| 415 | }
|
|---|
| 416 |
|
|---|
| 417 | void MingwMakefileGenerator::processPrlVariable(const QString &var, const QStringList &l)
|
|---|
| 418 | {
|
|---|
| 419 | if (var == "QMAKE_PRL_LIBS") {
|
|---|
| 420 | QString where = "QMAKE_LIBS";
|
|---|
| 421 | if (!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS"))
|
|---|
| 422 | where = project->first("QMAKE_INTERNAL_PRL_LIBS");
|
|---|
| 423 | QStringList &out = project->values(where);
|
|---|
| 424 | for (QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
|
|---|
| 425 | out.removeAll((*it));
|
|---|
| 426 | out.append((*it));
|
|---|
| 427 | }
|
|---|
| 428 | } else {
|
|---|
| 429 | Win32MakefileGenerator::processPrlVariable(var, l);
|
|---|
| 430 | }
|
|---|
| 431 | }
|
|---|
| 432 |
|
|---|
| 433 | QStringList &MingwMakefileGenerator::findDependencies(const QString &file)
|
|---|
| 434 | {
|
|---|
| 435 | QStringList &aList = MakefileGenerator::findDependencies(file);
|
|---|
| 436 | // Note: The QMAKE_IMAGE_COLLECTION file have all images
|
|---|
| 437 | // as dependency, so don't add precompiled header then
|
|---|
| 438 | if (file == project->first("QMAKE_IMAGE_COLLECTION")
|
|---|
| 439 | || preCompHeaderOut.isEmpty())
|
|---|
| 440 | return aList;
|
|---|
| 441 | for (QStringList::Iterator it = Option::c_ext.begin(); it != Option::c_ext.end(); ++it) {
|
|---|
| 442 | if (file.endsWith(*it)) {
|
|---|
| 443 | QString cHeader = preCompHeaderOut + Option::dir_sep + "c";
|
|---|
| 444 | if (!aList.contains(cHeader))
|
|---|
| 445 | aList += cHeader;
|
|---|
| 446 | break;
|
|---|
| 447 | }
|
|---|
| 448 | }
|
|---|
| 449 | for (QStringList::Iterator it = Option::cpp_ext.begin(); it != Option::cpp_ext.end(); ++it) {
|
|---|
| 450 | if (file.endsWith(*it)) {
|
|---|
| 451 | QString cppHeader = preCompHeaderOut + Option::dir_sep + "c++";
|
|---|
| 452 | if (!aList.contains(cppHeader))
|
|---|
| 453 | aList += cppHeader;
|
|---|
| 454 | break;
|
|---|
| 455 | }
|
|---|
| 456 | }
|
|---|
| 457 | return aList;
|
|---|
| 458 | }
|
|---|
| 459 |
|
|---|
| 460 | QT_END_NAMESPACE
|
|---|