summaryrefslogtreecommitdiffstats
path: root/qmake/generators/win32/mingw_make.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qmake/generators/win32/mingw_make.cpp')
-rw-r--r--qmake/generators/win32/mingw_make.cpp108
1 files changed, 48 insertions, 60 deletions
diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp
index f2d6678cdf..c19e17bc0e 100644
--- a/qmake/generators/win32/mingw_make.cpp
+++ b/qmake/generators/win32/mingw_make.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the qmake application of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -44,19 +44,14 @@
QT_BEGIN_NAMESPACE
-MingwMakefileGenerator::MingwMakefileGenerator() : Win32MakefileGenerator(), init_flag(false)
+MingwMakefileGenerator::MingwMakefileGenerator() : Win32MakefileGenerator()
{
- if (isWindowsShell())
- quote = "\"";
- else
- quote = "'";
}
QString MingwMakefileGenerator::escapeDependencyPath(const QString &path) const
{
QString ret = path;
- ret.remove('\"');
- ret.replace('\\', "/");
+ ret.replace('\\', "/"); // ### this shouldn't be here
ret.replace(' ', "\\ ");
return ret;
}
@@ -66,6 +61,18 @@ QString MingwMakefileGenerator::getLibTarget()
return QString("lib" + project->first("TARGET") + project->first("TARGET_VERSION_EXT") + ".a");
}
+QString MingwMakefileGenerator::getManifestFileForRcFile() const
+{
+ return project->first("QMAKE_MANIFEST").toQString();
+}
+
+ProString MingwMakefileGenerator::fixLibFlag(const ProString &lib)
+{
+ if (lib.startsWith("lib"))
+ return QStringLiteral("-l") + escapeFilePath(lib.mid(3));
+ return escapeFilePath(lib);
+}
+
bool MingwMakefileGenerator::findLibraries()
{
QList<QMakeLocalFileName> dirs;
@@ -84,9 +91,9 @@ bool MingwMakefileGenerator::findLibraries()
if (ver > 0)
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")) {
+ if (QMakeMetaInfo::libExists((*dir_it).local() + '/' + steam)
+ || exists((*dir_it).local() + '/' + steam + extension + ".a")
+ || exists((*dir_it).local() + '/' + steam + extension + ".dll.a")) {
out = *it + extension;
break;
}
@@ -94,7 +101,9 @@ bool MingwMakefileGenerator::findLibraries()
if (!out.isEmpty()) // We assume if it never finds it that its correct
(*it) = out;
} else if ((*it).startsWith("-L")) {
- dirs.append(QMakeLocalFileName((*it).mid(2).toQString()));
+ QMakeLocalFileName f((*it).mid(2).toQString());
+ dirs.append(f);
+ *it = "-L" + f.real();
}
++it;
@@ -119,7 +128,7 @@ bool MingwMakefileGenerator::writeMakefile(QTextStream &t)
t << "QMAKE = " << var("QMAKE_QMAKE") << endl;
const ProStringList &qut = project->values("QMAKE_EXTRA_TARGETS");
for (ProStringList::ConstIterator it = qut.begin(); it != qut.end(); ++it)
- t << *it << " ";
+ t << escapeDependencyPath(*it) << ' ';
t << "first all clean install distclean uninstall: qmake\n"
<< "qmake_all:\n";
writeMakeQmake(t);
@@ -145,6 +154,7 @@ void createLdObjectScriptFile(const QString &fileName, const ProStringList &objL
t << "INPUT(\n";
for (ProStringList::ConstIterator it = objList.constBegin(); it != objList.constEnd(); ++it) {
QString path = (*it).toQString();
+ // ### quoting?
if (QDir::isRelativePath(path))
t << "./" << path << endl;
else
@@ -162,6 +172,7 @@ void createArObjectScriptFile(const QString &fileName, const QString &target, co
QFile file(filePath);
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
QTextStream t(&file);
+ // ### quoting?
t << "CREATE " << target << endl;
for (ProStringList::ConstIterator it = objList.constBegin(); it != objList.constEnd(); ++it) {
t << "ADDMOD " << *it << endl;
@@ -180,6 +191,7 @@ void createRvctObjectScriptFile(const QString &fileName, const ProStringList &ob
QTextStream t(&file);
for (ProStringList::ConstIterator it = objList.constBegin(); it != objList.constEnd(); ++it) {
QString path = (*it).toQString();
+ // ### quoting?
if (QDir::isRelativePath(path))
t << "./" << path << endl;
else
@@ -200,23 +212,19 @@ void MingwMakefileGenerator::writeMingwParts(QTextStream &t)
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;
+ << "\n\t$(CC) -x c-header -c $(CFLAGS) $(INCPATH) -o " << escapeFilePath(cHeader)
+ << ' ' << escapeFilePath(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;
+ << "\n\t$(CXX) -x c++-header -c $(CXXFLAGS) $(INCPATH) -o " << escapeFilePath(cppHeader)
+ << ' ' << escapeFilePath(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");
@@ -224,16 +232,6 @@ void MingwMakefileGenerator::init()
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;
@@ -245,15 +243,7 @@ void MingwMakefileGenerator::init()
processVars();
- if (!project->values("RES_FILE").isEmpty()) {
- project->values("QMAKE_LIBS") += escapeFilePaths(project->values("RES_FILE"));
- }
-
- ProStringList &configs = project->values("CONFIG");
-
- if(project->isActiveConfig("qt_dll"))
- if(configs.indexOf("qt") == -1)
- configs.append("qt");
+ project->values("QMAKE_LIBS") += project->values("RES_FILE");
if (project->isActiveConfig("dll")) {
QString destDir = "";
@@ -261,7 +251,7 @@ void MingwMakefileGenerator::init()
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"));
+ project->values("QMAKE_LFLAGS").append(QString("-Wl,--out-implib,") + fileVar("MINGW_IMPORT_LIB"));
}
if (!project->values("DEF_FILE").isEmpty()) {
@@ -283,6 +273,7 @@ void MingwMakefileGenerator::init()
project->values("QMAKE_CLEAN").append(preCompHeaderOut + Option::dir_sep + "c");
project->values("QMAKE_CLEAN").append(preCompHeaderOut + Option::dir_sep + "c++");
+ preCompHeader = escapeFilePath(preCompHeader);
project->values("QMAKE_RUN_CC").clear();
project->values("QMAKE_RUN_CC").append("$(CC) -c -include " + preCompHeader +
" $(CFLAGS) $(INCPATH) " + var("QMAKE_CC_O_FLAG") + "$obj $src");
@@ -311,13 +302,12 @@ void MingwMakefileGenerator::writeIncPart(QTextStream &t)
for (ProStringList::ConstIterator incit = incs.begin(); incit != incs.end(); ++incit) {
QString inc = (*incit).toQString();
inc.replace(QRegExp("\\\\$"), "");
- inc.replace(QRegExp("\""), "");
if (!isystem.isEmpty() && isSystemInclude(inc))
t << isystem << ' ';
else
t << "-I";
- t << quote << inc << quote << " ";
+ t << escapeFilePath(inc) << ' ';
}
t << endl;
}
@@ -330,8 +320,8 @@ void MingwMakefileGenerator::writeLibsPart(QTextStream &t)
t << "LINKER = " << var("QMAKE_LINK") << endl;
t << "LFLAGS = " << var("QMAKE_LFLAGS") << endl;
t << "LIBS = "
- << var("QMAKE_LIBS").replace(QRegExp("(\\slib|^lib)")," -l") << ' '
- << var("QMAKE_LIBS_PRIVATE").replace(QRegExp("(\\slib|^lib)")," -l") << endl;
+ << fixLibFlags("QMAKE_LIBS").join(' ') << ' '
+ << fixLibFlags("QMAKE_LIBS_PRIVATE").join(' ') << endl;
}
}
@@ -350,7 +340,7 @@ void MingwMakefileGenerator::writeObjectsPart(QTextStream &t)
QString ar_cmd = project->values("QMAKE_LIB").join(' ');
if (ar_cmd.isEmpty())
ar_cmd = "armar --create";
- objectsLinkLine = ar_cmd + " " + var("DEST_TARGET") + " --via " + escapeFilePath(ar_script_file);
+ objectsLinkLine = ar_cmd + ' ' + fileVar("DEST_TARGET") + " --via " + escapeFilePath(ar_script_file);
} else {
// Strip off any options since the ar commands will be read from file.
QString ar_cmd = var("QMAKE_LIB").section(" ", 0, 0);;
@@ -378,8 +368,9 @@ void MingwMakefileGenerator::writeObjectsPart(QTextStream &t)
void MingwMakefileGenerator::writeBuildRulesPart(QTextStream &t)
{
t << "first: all\n";
- t << "all: " << escapeDependencyPath(fileFixify(Option::output.fileName())) << " " << valGlue(escapeDependencyPaths(project->values("ALL_DEPS"))," "," "," ") << " $(DESTDIR_TARGET)\n\n";
- t << "$(DESTDIR_TARGET): " << var("PRE_TARGETDEPS") << " $(OBJECTS) " << var("POST_TARGETDEPS");
+ t << "all: " << escapeDependencyPath(fileFixify(Option::output.fileName()))
+ << ' ' << depVar("ALL_DEPS") << " $(DESTDIR_TARGET)\n\n";
+ t << "$(DESTDIR_TARGET): " << depVar("PRE_TARGETDEPS") << " $(OBJECTS) " << depVar("POST_TARGETDEPS");
if(!project->isEmpty("QMAKE_PRE_LINK"))
t << "\n\t" <<var("QMAKE_PRE_LINK");
if(project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") {
@@ -414,8 +405,8 @@ void MingwMakefileGenerator::writeRcFilePart(QTextStream &t)
}
if (!rc_file.isEmpty()) {
- t << escapeDependencyPath(var("RES_FILE")) << ": " << rc_file << "\n\t"
- << var("QMAKE_RC") << " -i " << rc_file << " -o " << var("RES_FILE")
+ t << escapeDependencyPath(var("RES_FILE")) << ": " << escapeDependencyPath(rc_file) << "\n\t"
+ << var("QMAKE_RC") << " -i " << escapeFilePath(rc_file) << " -o " << fileVar("RES_FILE")
<< incPathStr << " $(DEFINES)\n\n";
}
}
@@ -423,10 +414,7 @@ void MingwMakefileGenerator::writeRcFilePart(QTextStream &t)
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())
+ if (preCompHeaderOut.isEmpty())
return aList;
for (QStringList::Iterator it = Option::c_ext.begin(); it != Option::c_ext.end(); ++it) {
if (file.endsWith(*it)) {