2011-04-27 10:05:43 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2012-01-05 04:03:39 +00:00
|
|
|
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2012-01-20 03:06:31 +00:00
|
|
|
** Contact: http://www.qt-project.org/
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
|
|
|
** This file is part of the qmake application of the Qt Toolkit.
|
|
|
|
**
|
|
|
|
** $QT_BEGIN_LICENSE:LGPL$
|
|
|
|
** GNU Lesser General Public License Usage
|
2011-05-24 09:34:08 +00:00
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this
|
|
|
|
** file. Please review the following information to ensure the GNU Lesser
|
|
|
|
** General Public License version 2.1 requirements will be met:
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-05-24 09:34:08 +00:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2011-04-27 10:05:43 +00:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
2011-05-24 09:34:08 +00:00
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU General
|
|
|
|
** Public License version 3.0 as published by the Free Software Foundation
|
|
|
|
** and appearing in the file LICENSE.GPL included in the packaging of this
|
|
|
|
** file. Please review the following information to ensure the GNU General
|
|
|
|
** Public License version 3.0 requirements will be met:
|
|
|
|
** http://www.gnu.org/copyleft/gpl.html.
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
2011-05-24 09:34:08 +00:00
|
|
|
** Other Usage
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
|
|
|
**
|
|
|
|
**
|
|
|
|
**
|
|
|
|
**
|
2012-01-24 06:17:24 +00:00
|
|
|
**
|
2011-04-27 10:05:43 +00:00
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "mingw_make.h"
|
|
|
|
#include "option.h"
|
|
|
|
#include "meta.h"
|
2012-09-06 10:21:38 +00:00
|
|
|
|
|
|
|
#include <proitems.h>
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
#include <qregexp.h>
|
|
|
|
#include <qdir.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
|
|
|
MingwMakefileGenerator::MingwMakefileGenerator() : Win32MakefileGenerator(), init_flag(false)
|
|
|
|
{
|
2012-05-03 18:53:10 +00:00
|
|
|
if (isWindowsShell())
|
2011-04-27 10:05:43 +00:00
|
|
|
quote = "\"";
|
|
|
|
else
|
|
|
|
quote = "'";
|
|
|
|
}
|
|
|
|
|
|
|
|
QString MingwMakefileGenerator::escapeDependencyPath(const QString &path) const
|
|
|
|
{
|
|
|
|
QString ret = path;
|
|
|
|
ret.remove('\"');
|
|
|
|
ret.replace('\\', "/");
|
|
|
|
ret.replace(' ', "\\ ");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString MingwMakefileGenerator::getLibTarget()
|
|
|
|
{
|
|
|
|
return QString("lib" + project->first("TARGET") + project->first("TARGET_VERSION_EXT") + ".a");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MingwMakefileGenerator::findLibraries()
|
|
|
|
{
|
|
|
|
QList<QMakeLocalFileName> dirs;
|
2012-08-20 11:04:39 +00:00
|
|
|
static const char * const lflags[] = { "QMAKE_LIBS", "QMAKE_LIBS_PRIVATE", 0 };
|
|
|
|
for (int i = 0; lflags[i]; i++) {
|
2012-09-06 10:21:38 +00:00
|
|
|
ProStringList &l = project->values(lflags[i]);
|
|
|
|
ProStringList::Iterator it = l.begin();
|
2011-04-27 10:05:43 +00:00
|
|
|
while (it != l.end()) {
|
|
|
|
if ((*it).startsWith("-l")) {
|
2012-09-06 10:21:38 +00:00
|
|
|
QString steam = (*it).mid(2).toQString();
|
|
|
|
ProString out;
|
|
|
|
QString suffix = project->first(ProKey("QMAKE_" + steam.toUpper() + "_SUFFIX")).toQString();
|
2011-04-27 10:05:43 +00:00
|
|
|
for (QList<QMakeLocalFileName>::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) {
|
|
|
|
QString extension;
|
|
|
|
int ver = findHighestVersion((*dir_it).local(), steam, "dll.a|a");
|
|
|
|
if (ver != -1)
|
|
|
|
extension += QString::number(ver);
|
|
|
|
extension += suffix;
|
|
|
|
if(QMakeMetaInfo::libExists((*dir_it).local() + Option::dir_sep + steam) ||
|
|
|
|
exists((*dir_it).local() + Option::dir_sep + steam + extension + ".a") ||
|
|
|
|
exists((*dir_it).local() + Option::dir_sep + steam + extension + ".dll.a")) {
|
2012-09-06 10:21:38 +00:00
|
|
|
out = *it + extension;
|
2011-04-27 10:05:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!out.isEmpty()) // We assume if it never finds it that its correct
|
|
|
|
(*it) = out;
|
|
|
|
} else if((*it).startsWith("-L")) {
|
2012-09-06 10:21:38 +00:00
|
|
|
dirs.append(QMakeLocalFileName((*it).mid(2).toQString()));
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
++it;
|
|
|
|
}
|
2012-07-12 19:46:53 +00:00
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MingwMakefileGenerator::writeMakefile(QTextStream &t)
|
|
|
|
{
|
|
|
|
writeHeader(t);
|
|
|
|
if(!project->values("QMAKE_FAILED_REQUIREMENTS").isEmpty()) {
|
|
|
|
t << "all clean:" << "\n\t"
|
|
|
|
<< "@echo \"Some of the required modules ("
|
|
|
|
<< var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t"
|
|
|
|
<< "@echo \"Skipped.\"" << endl << endl;
|
|
|
|
writeMakeQmake(t);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(project->first("TEMPLATE") == "app" ||
|
2011-05-03 13:30:28 +00:00
|
|
|
project->first("TEMPLATE") == "lib" ||
|
|
|
|
project->first("TEMPLATE") == "aux") {
|
2011-04-27 10:05:43 +00:00
|
|
|
if(project->isActiveConfig("create_pc") && project->first("TEMPLATE") == "lib")
|
|
|
|
writePkgConfigFile();
|
|
|
|
|
|
|
|
if(Option::mkfile::do_stub_makefile) {
|
|
|
|
t << "QMAKE = " << var("QMAKE_QMAKE") << endl;
|
2012-09-06 10:21:38 +00:00
|
|
|
const ProStringList &qut = project->values("QMAKE_EXTRA_TARGETS");
|
|
|
|
for (ProStringList::ConstIterator it = qut.begin(); it != qut.end(); ++it)
|
2011-04-27 10:05:43 +00:00
|
|
|
t << *it << " ";
|
|
|
|
t << "first all clean install distclean uninstall: qmake" << endl
|
|
|
|
<< "qmake_all:" << endl;
|
|
|
|
writeMakeQmake(t);
|
2012-04-25 15:12:53 +00:00
|
|
|
t << "FORCE:" << endl << endl;
|
2011-04-27 10:05:43 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
writeMingwParts(t);
|
|
|
|
return MakefileGenerator::writeMakefile(t);
|
|
|
|
}
|
|
|
|
else if(project->first("TEMPLATE") == "subdirs") {
|
|
|
|
writeSubDirs(t);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-09-06 10:21:38 +00:00
|
|
|
void createLdObjectScriptFile(const QString &fileName, const ProStringList &objList)
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
QString filePath = Option::output_dir + QDir::separator() + fileName;
|
|
|
|
QFile file(filePath);
|
|
|
|
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
|
|
|
QTextStream t(&file);
|
|
|
|
t << "INPUT(" << endl;
|
2012-09-06 10:21:38 +00:00
|
|
|
for (ProStringList::ConstIterator it = objList.constBegin(); it != objList.constEnd(); ++it) {
|
|
|
|
QString path = (*it).toQString();
|
|
|
|
if (QDir::isRelativePath(path))
|
|
|
|
t << "./" << path << endl;
|
|
|
|
else
|
|
|
|
t << path << endl;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
t << ");" << endl;
|
|
|
|
t.flush();
|
|
|
|
file.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-06 10:21:38 +00:00
|
|
|
void createArObjectScriptFile(const QString &fileName, const QString &target, const ProStringList &objList)
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
QString filePath = Option::output_dir + QDir::separator() + fileName;
|
|
|
|
QFile file(filePath);
|
|
|
|
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
|
|
|
QTextStream t(&file);
|
|
|
|
t << "CREATE " << target << endl;
|
2012-09-06 10:21:38 +00:00
|
|
|
for (ProStringList::ConstIterator it = objList.constBegin(); it != objList.constEnd(); ++it) {
|
2011-04-27 10:05:43 +00:00
|
|
|
t << "ADDMOD " << *it << endl;
|
|
|
|
}
|
|
|
|
t << "SAVE" << endl;
|
|
|
|
t.flush();
|
|
|
|
file.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-06 10:21:38 +00:00
|
|
|
void createRvctObjectScriptFile(const QString &fileName, const ProStringList &objList)
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
QString filePath = Option::output_dir + QDir::separator() + fileName;
|
|
|
|
QFile file(filePath);
|
|
|
|
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
|
|
|
QTextStream t(&file);
|
2012-09-06 10:21:38 +00:00
|
|
|
for (ProStringList::ConstIterator it = objList.constBegin(); it != objList.constEnd(); ++it) {
|
|
|
|
QString path = (*it).toQString();
|
|
|
|
if (QDir::isRelativePath(path))
|
|
|
|
t << "./" << path << endl;
|
2011-04-27 10:05:43 +00:00
|
|
|
else
|
2012-09-06 10:21:38 +00:00
|
|
|
t << path << endl;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
t.flush();
|
|
|
|
file.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MingwMakefileGenerator::writeMingwParts(QTextStream &t)
|
|
|
|
{
|
|
|
|
writeStandardParts(t);
|
|
|
|
|
|
|
|
if (!preCompHeaderOut.isEmpty()) {
|
2012-09-06 10:21:38 +00:00
|
|
|
QString header = project->first("PRECOMPILED_HEADER").toQString();
|
2011-04-27 10:05:43 +00:00
|
|
|
QString cHeader = preCompHeaderOut + Option::dir_sep + "c";
|
|
|
|
t << escapeDependencyPath(cHeader) << ": " << escapeDependencyPath(header) << " "
|
|
|
|
<< escapeDependencyPaths(findDependencies(header)).join(" \\\n\t\t")
|
|
|
|
<< "\n\t" << mkdir_p_asstring(preCompHeaderOut)
|
|
|
|
<< "\n\t" << "$(CC) -x c-header -c $(CFLAGS) $(INCPATH) -o " << cHeader << " " << header
|
|
|
|
<< endl << endl;
|
|
|
|
QString cppHeader = preCompHeaderOut + Option::dir_sep + "c++";
|
|
|
|
t << escapeDependencyPath(cppHeader) << ": " << escapeDependencyPath(header) << " "
|
|
|
|
<< escapeDependencyPaths(findDependencies(header)).join(" \\\n\t\t")
|
|
|
|
<< "\n\t" << mkdir_p_asstring(preCompHeaderOut)
|
|
|
|
<< "\n\t" << "$(CXX) -x c++-header -c $(CXXFLAGS) $(INCPATH) -o " << cppHeader << " " << header
|
|
|
|
<< endl << endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MingwMakefileGenerator::init()
|
|
|
|
{
|
|
|
|
if(init_flag)
|
|
|
|
return;
|
|
|
|
init_flag = true;
|
|
|
|
|
|
|
|
/* this should probably not be here, but I'm using it to wrap the .t files */
|
|
|
|
if(project->first("TEMPLATE") == "app")
|
|
|
|
project->values("QMAKE_APP_FLAG").append("1");
|
|
|
|
else if(project->first("TEMPLATE") == "lib")
|
|
|
|
project->values("QMAKE_LIB_FLAG").append("1");
|
|
|
|
else if(project->first("TEMPLATE") == "subdirs") {
|
|
|
|
MakefileGenerator::init();
|
|
|
|
if(project->isEmpty("QMAKE_COPY_FILE"))
|
|
|
|
project->values("QMAKE_COPY_FILE").append("$(COPY)");
|
|
|
|
if(project->isEmpty("QMAKE_COPY_DIR"))
|
|
|
|
project->values("QMAKE_COPY_DIR").append("xcopy /s /q /y /i");
|
|
|
|
if(project->isEmpty("QMAKE_INSTALL_FILE"))
|
|
|
|
project->values("QMAKE_INSTALL_FILE").append("$(COPY_FILE)");
|
|
|
|
if(project->isEmpty("QMAKE_INSTALL_PROGRAM"))
|
|
|
|
project->values("QMAKE_INSTALL_PROGRAM").append("$(COPY_FILE)");
|
|
|
|
if(project->isEmpty("QMAKE_INSTALL_DIR"))
|
|
|
|
project->values("QMAKE_INSTALL_DIR").append("$(COPY_DIR)");
|
|
|
|
if(project->values("MAKEFILE").isEmpty())
|
|
|
|
project->values("MAKEFILE").append("Makefile");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
project->values("TARGET_PRL").append(project->first("TARGET"));
|
|
|
|
|
2012-07-16 12:29:48 +00:00
|
|
|
project->values("QMAKE_L_FLAG") << "-L";
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
processVars();
|
|
|
|
|
|
|
|
if (!project->values("RES_FILE").isEmpty()) {
|
|
|
|
project->values("QMAKE_LIBS") += escapeFilePaths(project->values("RES_FILE"));
|
|
|
|
}
|
|
|
|
|
2012-09-06 10:21:38 +00:00
|
|
|
ProStringList &configs = project->values("CONFIG");
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
if(project->isActiveConfig("qt_dll"))
|
|
|
|
if(configs.indexOf("qt") == -1)
|
|
|
|
configs.append("qt");
|
|
|
|
|
2011-11-04 12:51:20 +00:00
|
|
|
if (project->isActiveConfig("dll")) {
|
2011-04-27 10:05:43 +00:00
|
|
|
QString destDir = "";
|
|
|
|
if(!project->first("DESTDIR").isEmpty())
|
|
|
|
destDir = Option::fixPathToTargetOS(project->first("DESTDIR") + Option::dir_sep, false, false);
|
|
|
|
project->values("MINGW_IMPORT_LIB").prepend(destDir + "lib" + project->first("TARGET")
|
|
|
|
+ project->first("TARGET_VERSION_EXT") + ".a");
|
|
|
|
project->values("QMAKE_LFLAGS").append(QString("-Wl,--out-implib,") + project->first("MINGW_IMPORT_LIB"));
|
|
|
|
}
|
|
|
|
|
2011-11-04 12:51:20 +00:00
|
|
|
if (!project->values("DEF_FILE").isEmpty()) {
|
2012-09-06 10:21:38 +00:00
|
|
|
QString defFileName = fileFixify(project->first("DEF_FILE").toQString());
|
2011-04-27 10:05:43 +00:00
|
|
|
project->values("QMAKE_LFLAGS").append(QString("-Wl,") + escapeFilePath(defFileName));
|
|
|
|
}
|
|
|
|
|
2012-07-16 11:02:57 +00:00
|
|
|
if (project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib")
|
|
|
|
project->values("QMAKE_LFLAGS").append("-static");
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
MakefileGenerator::init();
|
|
|
|
|
|
|
|
// precomp
|
|
|
|
if (!project->first("PRECOMPILED_HEADER").isEmpty()
|
|
|
|
&& project->isActiveConfig("precompile_header")) {
|
|
|
|
QString preCompHeader = var("PRECOMPILED_DIR")
|
2012-09-06 10:21:38 +00:00
|
|
|
+ QFileInfo(project->first("PRECOMPILED_HEADER").toQString()).fileName();
|
2011-04-27 10:05:43 +00:00
|
|
|
preCompHeaderOut = preCompHeader + ".gch";
|
|
|
|
project->values("QMAKE_CLEAN").append(preCompHeaderOut + Option::dir_sep + "c");
|
|
|
|
project->values("QMAKE_CLEAN").append(preCompHeaderOut + Option::dir_sep + "c++");
|
|
|
|
|
|
|
|
project->values("QMAKE_RUN_CC").clear();
|
|
|
|
project->values("QMAKE_RUN_CC").append("$(CC) -c -include " + preCompHeader +
|
|
|
|
" $(CFLAGS) $(INCPATH) -o $obj $src");
|
|
|
|
project->values("QMAKE_RUN_CC_IMP").clear();
|
|
|
|
project->values("QMAKE_RUN_CC_IMP").append("$(CC) -c -include " + preCompHeader +
|
|
|
|
" $(CFLAGS) $(INCPATH) -o $@ $<");
|
|
|
|
project->values("QMAKE_RUN_CXX").clear();
|
|
|
|
project->values("QMAKE_RUN_CXX").append("$(CXX) -c -include " + preCompHeader +
|
|
|
|
" $(CXXFLAGS) $(INCPATH) -o $obj $src");
|
|
|
|
project->values("QMAKE_RUN_CXX_IMP").clear();
|
|
|
|
project->values("QMAKE_RUN_CXX_IMP").append("$(CXX) -c -include " + preCompHeader +
|
|
|
|
" $(CXXFLAGS) $(INCPATH) -o $@ $<");
|
|
|
|
}
|
|
|
|
|
|
|
|
if(project->isActiveConfig("dll")) {
|
|
|
|
project->values("QMAKE_CLEAN").append(project->first("MINGW_IMPORT_LIB"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MingwMakefileGenerator::writeIncPart(QTextStream &t)
|
|
|
|
{
|
|
|
|
t << "INCPATH = ";
|
|
|
|
|
2012-09-06 11:51:37 +00:00
|
|
|
if (!project->isActiveConfig("no_include_pwd")) {
|
|
|
|
QString pwd = escapeFilePath(fileFixify(qmake_getpwd()));
|
|
|
|
if (pwd.isEmpty())
|
|
|
|
pwd = ".";
|
|
|
|
t << "-I" << pwd << " ";
|
|
|
|
}
|
|
|
|
|
2012-09-06 10:21:38 +00:00
|
|
|
const ProStringList &incs = project->values("INCLUDEPATH");
|
|
|
|
for (ProStringList::ConstIterator incit = incs.begin(); incit != incs.end(); ++incit) {
|
|
|
|
QString inc = (*incit).toQString();
|
2011-04-27 10:05:43 +00:00
|
|
|
inc.replace(QRegExp("\\\\$"), "");
|
|
|
|
inc.replace(QRegExp("\""), "");
|
|
|
|
t << "-I" << quote << inc << quote << " ";
|
|
|
|
}
|
|
|
|
t << "-I" << quote << specdir() << quote
|
|
|
|
<< endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MingwMakefileGenerator::writeLibsPart(QTextStream &t)
|
|
|
|
{
|
|
|
|
if(project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") {
|
|
|
|
t << "LIB = " << var("QMAKE_LIB") << endl;
|
|
|
|
} else {
|
|
|
|
t << "LINK = " << var("QMAKE_LINK") << endl;
|
|
|
|
t << "LFLAGS = " << var("QMAKE_LFLAGS") << endl;
|
2012-07-16 12:29:48 +00:00
|
|
|
t << "LIBS = "
|
|
|
|
<< var("QMAKE_LIBS").replace(QRegExp("(\\slib|^lib)")," -l") << ' '
|
2012-07-13 10:32:45 +00:00
|
|
|
<< var("QMAKE_LIBS_PRIVATE").replace(QRegExp("(\\slib|^lib)")," -l") << endl;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MingwMakefileGenerator::writeObjectsPart(QTextStream &t)
|
|
|
|
{
|
|
|
|
if (project->values("OBJECTS").count() < var("QMAKE_LINK_OBJECT_MAX").toInt()) {
|
|
|
|
objectsLinkLine = "$(OBJECTS)";
|
|
|
|
} else if (project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") {
|
|
|
|
QString ar_script_file = var("QMAKE_LINK_OBJECT_SCRIPT") + "." + var("TARGET");
|
|
|
|
if (!var("BUILD_NAME").isEmpty()) {
|
|
|
|
ar_script_file += "." + var("BUILD_NAME");
|
|
|
|
}
|
|
|
|
// QMAKE_LIB is used for win32, including mingw, whereas QMAKE_AR is used on Unix.
|
|
|
|
if (project->isActiveConfig("rvct_linker")) {
|
|
|
|
createRvctObjectScriptFile(ar_script_file, project->values("OBJECTS"));
|
|
|
|
QString ar_cmd = project->values("QMAKE_LIB").join(" ");
|
|
|
|
if (ar_cmd.isEmpty())
|
|
|
|
ar_cmd = "armar --create";
|
2012-03-02 11:33:17 +00:00
|
|
|
objectsLinkLine = ar_cmd + " " + var("DEST_TARGET") + " --via " + escapeFilePath(ar_script_file);
|
2011-04-27 10:05:43 +00:00
|
|
|
} else {
|
|
|
|
// Strip off any options since the ar commands will be read from file.
|
|
|
|
QString ar_cmd = var("QMAKE_LIB").section(" ", 0, 0);;
|
|
|
|
if (ar_cmd.isEmpty())
|
|
|
|
ar_cmd = "ar";
|
|
|
|
createArObjectScriptFile(ar_script_file, var("DEST_TARGET"), project->values("OBJECTS"));
|
2012-03-02 11:33:17 +00:00
|
|
|
objectsLinkLine = ar_cmd + " -M < " + escapeFilePath(ar_script_file);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
QString ld_script_file = var("QMAKE_LINK_OBJECT_SCRIPT") + "." + var("TARGET");
|
|
|
|
if (!var("BUILD_NAME").isEmpty()) {
|
|
|
|
ld_script_file += "." + var("BUILD_NAME");
|
|
|
|
}
|
|
|
|
if (project->isActiveConfig("rvct_linker")) {
|
|
|
|
createRvctObjectScriptFile(ld_script_file, project->values("OBJECTS"));
|
2012-03-02 11:33:17 +00:00
|
|
|
objectsLinkLine = QString::fromLatin1("--via ") + escapeFilePath(ld_script_file);
|
2011-04-27 10:05:43 +00:00
|
|
|
} else {
|
|
|
|
createLdObjectScriptFile(ld_script_file, project->values("OBJECTS"));
|
2012-03-02 11:33:17 +00:00
|
|
|
objectsLinkLine = escapeFilePath(ld_script_file);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Win32MakefileGenerator::writeObjectsPart(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MingwMakefileGenerator::writeBuildRulesPart(QTextStream &t)
|
|
|
|
{
|
|
|
|
t << "first: all" << endl;
|
|
|
|
t << "all: " << escapeDependencyPath(fileFixify(Option::output.fileName())) << " " << valGlue(escapeDependencyPaths(project->values("ALL_DEPS"))," "," "," ") << " $(DESTDIR_TARGET)" << endl << endl;
|
|
|
|
t << "$(DESTDIR_TARGET): " << var("PRE_TARGETDEPS") << " $(OBJECTS) " << var("POST_TARGETDEPS");
|
|
|
|
if(!project->isEmpty("QMAKE_PRE_LINK"))
|
|
|
|
t << "\n\t" <<var("QMAKE_PRE_LINK");
|
|
|
|
if(project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") {
|
|
|
|
if (project->values("OBJECTS").count() < var("QMAKE_LINK_OBJECT_MAX").toInt()) {
|
|
|
|
t << "\n\t" << "$(LIB) $(DESTDIR_TARGET) " << objectsLinkLine << " " ;
|
|
|
|
} else {
|
|
|
|
t << "\n\t" << objectsLinkLine << " " ;
|
|
|
|
}
|
2012-08-15 17:42:42 +00:00
|
|
|
} else if (project->first("TEMPLATE") != "aux") {
|
2011-04-27 10:05:43 +00:00
|
|
|
t << "\n\t" << "$(LINK) $(LFLAGS) -o $(DESTDIR_TARGET) " << objectsLinkLine << " " << " $(LIBS)";
|
|
|
|
}
|
|
|
|
if(!project->isEmpty("QMAKE_POST_LINK"))
|
|
|
|
t << "\n\t" <<var("QMAKE_POST_LINK");
|
|
|
|
t << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MingwMakefileGenerator::writeRcFilePart(QTextStream &t)
|
|
|
|
{
|
2012-09-06 10:21:38 +00:00
|
|
|
const QString rc_file = fileFixify(project->first("RC_FILE").toQString());
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
QString incPathStr = fileInfo(rc_file).path();
|
|
|
|
if (incPathStr != "." && QDir::isRelativePath(incPathStr))
|
|
|
|
incPathStr.prepend("./");
|
|
|
|
|
|
|
|
if (!rc_file.isEmpty()) {
|
|
|
|
t << escapeDependencyPath(var("RES_FILE")) << ": " << rc_file << "\n\t"
|
|
|
|
<< var("QMAKE_RC") << " -i " << rc_file << " -o " << var("RES_FILE")
|
|
|
|
<< " --include-dir=" << incPathStr << " $(DEFINES)" << endl << endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList &MingwMakefileGenerator::findDependencies(const QString &file)
|
|
|
|
{
|
|
|
|
QStringList &aList = MakefileGenerator::findDependencies(file);
|
|
|
|
// Note: The QMAKE_IMAGE_COLLECTION file have all images
|
|
|
|
// as dependency, so don't add precompiled header then
|
|
|
|
if (file == project->first("QMAKE_IMAGE_COLLECTION")
|
|
|
|
|| preCompHeaderOut.isEmpty())
|
|
|
|
return aList;
|
|
|
|
for (QStringList::Iterator it = Option::c_ext.begin(); it != Option::c_ext.end(); ++it) {
|
|
|
|
if (file.endsWith(*it)) {
|
|
|
|
QString cHeader = preCompHeaderOut + Option::dir_sep + "c";
|
|
|
|
if (!aList.contains(cHeader))
|
|
|
|
aList += cHeader;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (QStringList::Iterator it = Option::cpp_ext.begin(); it != Option::cpp_ext.end(); ++it) {
|
|
|
|
if (file.endsWith(*it)) {
|
|
|
|
QString cppHeader = preCompHeaderOut + Option::dir_sep + "c++";
|
|
|
|
if (!aList.contains(cppHeader))
|
|
|
|
aList += cppHeader;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return aList;
|
|
|
|
}
|
|
|
|
|
|
|
|
QT_END_NAMESPACE
|