2011-04-27 10:05:43 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2015-01-28 08:44:43 +00:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
** Contact: http://www.qt.io/licensing/
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
|
|
|
** This file is part of the qmake application of the Qt Toolkit.
|
|
|
|
**
|
2014-08-21 13:51:22 +00:00
|
|
|
** $QT_BEGIN_LICENSE:LGPL21$
|
2012-09-19 12:28:29 +00:00
|
|
|
** Commercial License Usage
|
|
|
|
** 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
|
2015-01-28 08:44:43 +00:00
|
|
|
** 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.
|
2012-09-19 12:28:29 +00:00
|
|
|
**
|
2011-04-27 10:05:43 +00:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-09-19 12:28:29 +00:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-08-21 13:51:22 +00:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-09-19 12:28:29 +00:00
|
|
|
**
|
2015-01-28 08:44:43 +00:00
|
|
|
** As a special exception, The Qt Company gives you certain additional
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2011-04-27 10:05:43 +00:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "mingw_make.h"
|
|
|
|
#include "option.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
|
|
|
|
|
2014-11-11 18:04:42 +00:00
|
|
|
MingwMakefileGenerator::MingwMakefileGenerator() : Win32MakefileGenerator()
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
QString MingwMakefileGenerator::escapeDependencyPath(const QString &path) const
|
|
|
|
{
|
|
|
|
QString ret = path;
|
2015-02-06 14:30:02 +00:00
|
|
|
ret.replace('\\', "/"); // ### this shouldn't be here
|
2011-04-27 10:05:43 +00:00
|
|
|
ret.replace(' ', "\\ ");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-10-29 14:11:57 +00:00
|
|
|
QString MingwMakefileGenerator::getManifestFileForRcFile() const
|
|
|
|
{
|
|
|
|
return project->first("QMAKE_MANIFEST").toQString();
|
|
|
|
}
|
|
|
|
|
2015-02-06 14:30:02 +00:00
|
|
|
ProString MingwMakefileGenerator::fixLibFlag(const ProString &lib)
|
|
|
|
{
|
|
|
|
if (lib.startsWith("lib"))
|
|
|
|
return QStringLiteral("-l") + escapeFilePath(lib.mid(3));
|
|
|
|
return escapeFilePath(lib);
|
|
|
|
}
|
|
|
|
|
2015-08-17 17:33:52 +00:00
|
|
|
bool MingwMakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
QList<QMakeLocalFileName> dirs;
|
2012-08-20 11:04:39 +00:00
|
|
|
static const char * const lflags[] = { "QMAKE_LIBS", "QMAKE_LIBS_PRIVATE", 0 };
|
rewrite windows library handling
first, store the library's full name in the .prl file, like we do on
unix. this is not expected to have any side effects, as QMAKE_PRL_TARGET
was entirely unused under windows so far.
then, rewrite the mingw library handling: instead of letting the linker
resolve the actual libraries, do it ourselves like we do for msvc. we
could not do that before due to the partial file names in the .prl
files: if the library didn't exist at qmake execution time, we'd have to
guess the file extension (the msvc generators never had that problem, as
they know about only one possible extension for libraries anyway).
make use of processPrlFile()'s ability to replace the reference to
the .prl file with the actual library. that way we don't need to
re-assemble the file name from pieces, which was fragile and
inefficient.
QMAKE_*_VERSION_OVERRIDE does not affect libraries coming with .prl
files any more. additionally, it is now used literally (not
numerically), and values less or equal to zero lost their special
meaning as "none" - this isn't a problem, because that's the default
anyway, and there is no need to override bogus versions from .prl files
any more.
no changelog for that, as i found no public traces of that feature
outside qtbase.
[ChangeLog][qmake][Windows] Libraries coming with .prl files can now
have non-standard file extensions and a major version of zero.
[ChangeLog][qmake][Windows][Important Behavior Changes] The .prl files
written by earlier versions of Qt cannot be used any more. This will
affect you if you depend on 3rd party libraries which come with .prl
files. Patch up QMAKE_PRL_TARGET to contain the complete file name of
the library, and replace any /LIBPATH: in QMAKE_PRL_LIBS with -L.
(the part about /LIBPATH: actually refers to the next commit.)
Change-Id: I07399341bff0609cb6db9660cbc62b141fb2ad96
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2015-09-25 12:21:44 +00:00
|
|
|
static const QLatin1String extens[] =
|
|
|
|
{ QLatin1String(".dll.a"), QLatin1String(".a"), QLatin1String(0) };
|
2012-08-20 11:04:39 +00:00
|
|
|
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();
|
rewrite windows library handling
first, store the library's full name in the .prl file, like we do on
unix. this is not expected to have any side effects, as QMAKE_PRL_TARGET
was entirely unused under windows so far.
then, rewrite the mingw library handling: instead of letting the linker
resolve the actual libraries, do it ourselves like we do for msvc. we
could not do that before due to the partial file names in the .prl
files: if the library didn't exist at qmake execution time, we'd have to
guess the file extension (the msvc generators never had that problem, as
they know about only one possible extension for libraries anyway).
make use of processPrlFile()'s ability to replace the reference to
the .prl file with the actual library. that way we don't need to
re-assemble the file name from pieces, which was fragile and
inefficient.
QMAKE_*_VERSION_OVERRIDE does not affect libraries coming with .prl
files any more. additionally, it is now used literally (not
numerically), and values less or equal to zero lost their special
meaning as "none" - this isn't a problem, because that's the default
anyway, and there is no need to override bogus versions from .prl files
any more.
no changelog for that, as i found no public traces of that feature
outside qtbase.
[ChangeLog][qmake][Windows] Libraries coming with .prl files can now
have non-standard file extensions and a major version of zero.
[ChangeLog][qmake][Windows][Important Behavior Changes] The .prl files
written by earlier versions of Qt cannot be used any more. This will
affect you if you depend on 3rd party libraries which come with .prl
files. Patch up QMAKE_PRL_TARGET to contain the complete file name of
the library, and replace any /LIBPATH: in QMAKE_PRL_LIBS with -L.
(the part about /LIBPATH: actually refers to the next commit.)
Change-Id: I07399341bff0609cb6db9660cbc62b141fb2ad96
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2015-09-25 12:21:44 +00:00
|
|
|
ProString verovr =
|
|
|
|
project->first(ProKey("QMAKE_" + steam.toUpper() + "_VERSION_OVERRIDE"));
|
2011-04-27 10:05:43 +00:00
|
|
|
for (QList<QMakeLocalFileName>::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) {
|
rewrite windows library handling
first, store the library's full name in the .prl file, like we do on
unix. this is not expected to have any side effects, as QMAKE_PRL_TARGET
was entirely unused under windows so far.
then, rewrite the mingw library handling: instead of letting the linker
resolve the actual libraries, do it ourselves like we do for msvc. we
could not do that before due to the partial file names in the .prl
files: if the library didn't exist at qmake execution time, we'd have to
guess the file extension (the msvc generators never had that problem, as
they know about only one possible extension for libraries anyway).
make use of processPrlFile()'s ability to replace the reference to
the .prl file with the actual library. that way we don't need to
re-assemble the file name from pieces, which was fragile and
inefficient.
QMAKE_*_VERSION_OVERRIDE does not affect libraries coming with .prl
files any more. additionally, it is now used literally (not
numerically), and values less or equal to zero lost their special
meaning as "none" - this isn't a problem, because that's the default
anyway, and there is no need to override bogus versions from .prl files
any more.
no changelog for that, as i found no public traces of that feature
outside qtbase.
[ChangeLog][qmake][Windows] Libraries coming with .prl files can now
have non-standard file extensions and a major version of zero.
[ChangeLog][qmake][Windows][Important Behavior Changes] The .prl files
written by earlier versions of Qt cannot be used any more. This will
affect you if you depend on 3rd party libraries which come with .prl
files. Patch up QMAKE_PRL_TARGET to contain the complete file name of
the library, and replace any /LIBPATH: in QMAKE_PRL_LIBS with -L.
(the part about /LIBPATH: actually refers to the next commit.)
Change-Id: I07399341bff0609cb6db9660cbc62b141fb2ad96
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2015-09-25 12:21:44 +00:00
|
|
|
QString cand = (*dir_it).real() + Option::dir_sep + steam;
|
|
|
|
if (linkPrl && processPrlFile(cand)) {
|
|
|
|
(*it) = cand;
|
|
|
|
goto found;
|
|
|
|
}
|
|
|
|
QString libBase = (*dir_it).local() + '/' + steam + verovr;
|
|
|
|
for (int e = 0; extens[e].data(); e++) {
|
|
|
|
if (exists(libBase + extens[e])) {
|
|
|
|
(*it) = cand + verovr + extens[e];
|
|
|
|
goto found;
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
rewrite windows library handling
first, store the library's full name in the .prl file, like we do on
unix. this is not expected to have any side effects, as QMAKE_PRL_TARGET
was entirely unused under windows so far.
then, rewrite the mingw library handling: instead of letting the linker
resolve the actual libraries, do it ourselves like we do for msvc. we
could not do that before due to the partial file names in the .prl
files: if the library didn't exist at qmake execution time, we'd have to
guess the file extension (the msvc generators never had that problem, as
they know about only one possible extension for libraries anyway).
make use of processPrlFile()'s ability to replace the reference to
the .prl file with the actual library. that way we don't need to
re-assemble the file name from pieces, which was fragile and
inefficient.
QMAKE_*_VERSION_OVERRIDE does not affect libraries coming with .prl
files any more. additionally, it is now used literally (not
numerically), and values less or equal to zero lost their special
meaning as "none" - this isn't a problem, because that's the default
anyway, and there is no need to override bogus versions from .prl files
any more.
no changelog for that, as i found no public traces of that feature
outside qtbase.
[ChangeLog][qmake][Windows] Libraries coming with .prl files can now
have non-standard file extensions and a major version of zero.
[ChangeLog][qmake][Windows][Important Behavior Changes] The .prl files
written by earlier versions of Qt cannot be used any more. This will
affect you if you depend on 3rd party libraries which come with .prl
files. Patch up QMAKE_PRL_TARGET to contain the complete file name of
the library, and replace any /LIBPATH: in QMAKE_PRL_LIBS with -L.
(the part about /LIBPATH: actually refers to the next commit.)
Change-Id: I07399341bff0609cb6db9660cbc62b141fb2ad96
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2015-09-25 12:21:44 +00:00
|
|
|
// We assume if it never finds it that its correct
|
|
|
|
found: ;
|
2014-01-13 14:48:44 +00:00
|
|
|
} else if ((*it).startsWith("-L")) {
|
2015-02-06 14:30:02 +00:00
|
|
|
QMakeLocalFileName f((*it).mid(2).toQString());
|
|
|
|
dirs.append(f);
|
|
|
|
*it = "-L" + f.real();
|
2015-08-17 17:33:52 +00:00
|
|
|
} else if (linkPrl && !(*it).startsWith('-')) {
|
|
|
|
QString prl = (*it).toQString();
|
rewrite windows library handling
first, store the library's full name in the .prl file, like we do on
unix. this is not expected to have any side effects, as QMAKE_PRL_TARGET
was entirely unused under windows so far.
then, rewrite the mingw library handling: instead of letting the linker
resolve the actual libraries, do it ourselves like we do for msvc. we
could not do that before due to the partial file names in the .prl
files: if the library didn't exist at qmake execution time, we'd have to
guess the file extension (the msvc generators never had that problem, as
they know about only one possible extension for libraries anyway).
make use of processPrlFile()'s ability to replace the reference to
the .prl file with the actual library. that way we don't need to
re-assemble the file name from pieces, which was fragile and
inefficient.
QMAKE_*_VERSION_OVERRIDE does not affect libraries coming with .prl
files any more. additionally, it is now used literally (not
numerically), and values less or equal to zero lost their special
meaning as "none" - this isn't a problem, because that's the default
anyway, and there is no need to override bogus versions from .prl files
any more.
no changelog for that, as i found no public traces of that feature
outside qtbase.
[ChangeLog][qmake][Windows] Libraries coming with .prl files can now
have non-standard file extensions and a major version of zero.
[ChangeLog][qmake][Windows][Important Behavior Changes] The .prl files
written by earlier versions of Qt cannot be used any more. This will
affect you if you depend on 3rd party libraries which come with .prl
files. Patch up QMAKE_PRL_TARGET to contain the complete file name of
the library, and replace any /LIBPATH: in QMAKE_PRL_LIBS with -L.
(the part about /LIBPATH: actually refers to the next commit.)
Change-Id: I07399341bff0609cb6db9660cbc62b141fb2ad96
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2015-09-25 12:21:44 +00:00
|
|
|
if (fileInfo(prl).isAbsolute()) {
|
|
|
|
if (processPrlFile(prl))
|
|
|
|
(*it) = prl;
|
|
|
|
} else {
|
2015-08-17 17:33:52 +00:00
|
|
|
for (QList<QMakeLocalFileName>::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) {
|
rewrite windows library handling
first, store the library's full name in the .prl file, like we do on
unix. this is not expected to have any side effects, as QMAKE_PRL_TARGET
was entirely unused under windows so far.
then, rewrite the mingw library handling: instead of letting the linker
resolve the actual libraries, do it ourselves like we do for msvc. we
could not do that before due to the partial file names in the .prl
files: if the library didn't exist at qmake execution time, we'd have to
guess the file extension (the msvc generators never had that problem, as
they know about only one possible extension for libraries anyway).
make use of processPrlFile()'s ability to replace the reference to
the .prl file with the actual library. that way we don't need to
re-assemble the file name from pieces, which was fragile and
inefficient.
QMAKE_*_VERSION_OVERRIDE does not affect libraries coming with .prl
files any more. additionally, it is now used literally (not
numerically), and values less or equal to zero lost their special
meaning as "none" - this isn't a problem, because that's the default
anyway, and there is no need to override bogus versions from .prl files
any more.
no changelog for that, as i found no public traces of that feature
outside qtbase.
[ChangeLog][qmake][Windows] Libraries coming with .prl files can now
have non-standard file extensions and a major version of zero.
[ChangeLog][qmake][Windows][Important Behavior Changes] The .prl files
written by earlier versions of Qt cannot be used any more. This will
affect you if you depend on 3rd party libraries which come with .prl
files. Patch up QMAKE_PRL_TARGET to contain the complete file name of
the library, and replace any /LIBPATH: in QMAKE_PRL_LIBS with -L.
(the part about /LIBPATH: actually refers to the next commit.)
Change-Id: I07399341bff0609cb6db9660cbc62b141fb2ad96
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2015-09-25 12:21:44 +00:00
|
|
|
QString cand = (*dir_it).real() + Option::dir_sep + prl;
|
|
|
|
if (processPrlFile(cand)) {
|
|
|
|
(*it) = cand;
|
2015-08-17 17:33:52 +00:00
|
|
|
break;
|
rewrite windows library handling
first, store the library's full name in the .prl file, like we do on
unix. this is not expected to have any side effects, as QMAKE_PRL_TARGET
was entirely unused under windows so far.
then, rewrite the mingw library handling: instead of letting the linker
resolve the actual libraries, do it ourselves like we do for msvc. we
could not do that before due to the partial file names in the .prl
files: if the library didn't exist at qmake execution time, we'd have to
guess the file extension (the msvc generators never had that problem, as
they know about only one possible extension for libraries anyway).
make use of processPrlFile()'s ability to replace the reference to
the .prl file with the actual library. that way we don't need to
re-assemble the file name from pieces, which was fragile and
inefficient.
QMAKE_*_VERSION_OVERRIDE does not affect libraries coming with .prl
files any more. additionally, it is now used literally (not
numerically), and values less or equal to zero lost their special
meaning as "none" - this isn't a problem, because that's the default
anyway, and there is no need to override bogus versions from .prl files
any more.
no changelog for that, as i found no public traces of that feature
outside qtbase.
[ChangeLog][qmake][Windows] Libraries coming with .prl files can now
have non-standard file extensions and a major version of zero.
[ChangeLog][qmake][Windows][Important Behavior Changes] The .prl files
written by earlier versions of Qt cannot be used any more. This will
affect you if you depend on 3rd party libraries which come with .prl
files. Patch up QMAKE_PRL_TARGET to contain the complete file name of
the library, and replace any /LIBPATH: in QMAKE_PRL_LIBS with -L.
(the part about /LIBPATH: actually refers to the next commit.)
Change-Id: I07399341bff0609cb6db9660cbc62b141fb2ad96
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2015-09-25 12:21:44 +00:00
|
|
|
}
|
2015-08-17 17:33:52 +00:00
|
|
|
}
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2015-08-17 17:33:52 +00:00
|
|
|
ProStringList &prl_libs = project->values("QMAKE_CURRENT_PRL_LIBS");
|
|
|
|
for (int prl = 0; prl < prl_libs.size(); ++prl)
|
|
|
|
it = l.insert(++it, prl_libs.at(prl));
|
|
|
|
prl_libs.clear();
|
2011-04-27 10:05:43 +00:00
|
|
|
++it;
|
|
|
|
}
|
2015-08-17 17:33:52 +00:00
|
|
|
if (mergeLflags) {
|
|
|
|
ProStringList lopts;
|
|
|
|
for (int lit = 0; lit < l.size(); ++lit) {
|
|
|
|
ProString opt = l.at(lit);
|
|
|
|
if (opt.startsWith("-L")) {
|
|
|
|
if (!lopts.contains(opt))
|
|
|
|
lopts.append(opt);
|
|
|
|
} else {
|
|
|
|
// Make sure we keep the dependency order of libraries
|
|
|
|
lopts.removeAll(opt);
|
|
|
|
lopts.append(opt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
l = lopts;
|
|
|
|
}
|
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);
|
2013-08-26 17:51:57 +00:00
|
|
|
if (writeDummyMakefile(t))
|
2011-04-27 10:05:43 +00:00
|
|
|
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)
|
2015-02-06 14:30:02 +00:00
|
|
|
t << escapeDependencyPath(*it) << ' ';
|
2013-07-04 09:25:16 +00:00
|
|
|
t << "first all clean install distclean uninstall: qmake\n"
|
|
|
|
<< "qmake_all:\n";
|
2011-04-27 10:05:43 +00:00
|
|
|
writeMakeQmake(t);
|
2013-07-04 09:25:16 +00:00
|
|
|
t << "FORCE:\n\n";
|
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);
|
2013-07-04 09:25:16 +00:00
|
|
|
t << "INPUT(\n";
|
2012-09-06 10:21:38 +00:00
|
|
|
for (ProStringList::ConstIterator it = objList.constBegin(); it != objList.constEnd(); ++it) {
|
|
|
|
QString path = (*it).toQString();
|
2015-02-06 14:30:02 +00:00
|
|
|
// ### quoting?
|
2012-09-06 10:21:38 +00:00
|
|
|
if (QDir::isRelativePath(path))
|
|
|
|
t << "./" << path << endl;
|
|
|
|
else
|
|
|
|
t << path << endl;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2013-07-04 09:25:16 +00:00
|
|
|
t << ");\n";
|
2014-01-13 14:48:44 +00:00
|
|
|
t.flush();
|
2011-04-27 10:05:43 +00:00
|
|
|
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);
|
2015-02-06 14:30:02 +00:00
|
|
|
// ### quoting?
|
2011-04-27 10:05:43 +00:00
|
|
|
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;
|
|
|
|
}
|
2013-07-04 09:25:16 +00:00
|
|
|
t << "SAVE\n";
|
2014-01-13 14:48:44 +00:00
|
|
|
t.flush();
|
2011-04-27 10:05:43 +00:00
|
|
|
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();
|
2014-01-13 14:48:44 +00:00
|
|
|
QString cHeader = preCompHeaderOut + Option::dir_sep + "c";
|
|
|
|
t << escapeDependencyPath(cHeader) << ": " << escapeDependencyPath(header) << " "
|
2011-04-27 10:05:43 +00:00
|
|
|
<< escapeDependencyPaths(findDependencies(header)).join(" \\\n\t\t")
|
2014-01-13 14:48:44 +00:00
|
|
|
<< "\n\t" << mkdir_p_asstring(preCompHeaderOut)
|
2015-02-06 14:30:02 +00:00
|
|
|
<< "\n\t$(CC) -x c-header -c $(CFLAGS) $(INCPATH) -o " << escapeFilePath(cHeader)
|
|
|
|
<< ' ' << escapeFilePath(header) << endl << endl;
|
2014-01-13 14:48:44 +00:00
|
|
|
QString cppHeader = preCompHeaderOut + Option::dir_sep + "c++";
|
|
|
|
t << escapeDependencyPath(cppHeader) << ": " << escapeDependencyPath(header) << " "
|
2011-04-27 10:05:43 +00:00
|
|
|
<< escapeDependencyPaths(findDependencies(header)).join(" \\\n\t\t")
|
2014-01-13 14:48:44 +00:00
|
|
|
<< "\n\t" << mkdir_p_asstring(preCompHeaderOut)
|
2015-02-06 14:30:02 +00:00
|
|
|
<< "\n\t$(CXX) -x c++-header -c $(CXXFLAGS) $(INCPATH) -o " << escapeFilePath(cppHeader)
|
|
|
|
<< ' ' << escapeFilePath(header) << endl << endl;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MingwMakefileGenerator::init()
|
|
|
|
{
|
|
|
|
/* 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->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();
|
|
|
|
|
2015-02-06 14:30:02 +00:00
|
|
|
project->values("QMAKE_LIBS") += project->values("RES_FILE");
|
2011-04-27 10:05:43 +00:00
|
|
|
|
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);
|
2015-09-29 10:44:30 +00:00
|
|
|
project->values("MINGW_IMPORT_LIB").prepend(destDir + project->first("LIB_TARGET"));
|
2015-02-06 14:30:02 +00:00
|
|
|
project->values("QMAKE_LFLAGS").append(QString("-Wl,--out-implib,") + fileVar("MINGW_IMPORT_LIB"));
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
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();
|
2014-01-13 14:48:44 +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++");
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2015-02-06 14:30:02 +00:00
|
|
|
preCompHeader = escapeFilePath(preCompHeader);
|
2014-01-13 14:48:44 +00:00
|
|
|
project->values("QMAKE_RUN_CC").clear();
|
|
|
|
project->values("QMAKE_RUN_CC").append("$(CC) -c -include " + preCompHeader +
|
2013-03-18 11:21:38 +00:00
|
|
|
" $(CFLAGS) $(INCPATH) " + var("QMAKE_CC_O_FLAG") + "$obj $src");
|
2011-04-27 10:05:43 +00:00
|
|
|
project->values("QMAKE_RUN_CC_IMP").clear();
|
2014-01-13 14:48:44 +00:00
|
|
|
project->values("QMAKE_RUN_CC_IMP").append("$(CC) -c -include " + preCompHeader +
|
2013-03-18 11:21:38 +00:00
|
|
|
" $(CFLAGS) $(INCPATH) " + var("QMAKE_CC_O_FLAG") + "$@ $<");
|
2011-04-27 10:05:43 +00:00
|
|
|
project->values("QMAKE_RUN_CXX").clear();
|
2014-01-13 14:48:44 +00:00
|
|
|
project->values("QMAKE_RUN_CXX").append("$(CXX) -c -include " + preCompHeader +
|
2013-03-18 11:21:38 +00:00
|
|
|
" $(CXXFLAGS) $(INCPATH) " + var("QMAKE_CC_O_FLAG") + "$obj $src");
|
2011-04-27 10:05:43 +00:00
|
|
|
project->values("QMAKE_RUN_CXX_IMP").clear();
|
2014-01-13 14:48:44 +00:00
|
|
|
project->values("QMAKE_RUN_CXX_IMP").append("$(CXX) -c -include " + preCompHeader +
|
2013-03-18 11:21:38 +00:00
|
|
|
" $(CXXFLAGS) $(INCPATH) " + var("QMAKE_CC_O_FLAG") + "$@ $<");
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(project->isActiveConfig("dll")) {
|
|
|
|
project->values("QMAKE_CLEAN").append(project->first("MINGW_IMPORT_LIB"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MingwMakefileGenerator::writeIncPart(QTextStream &t)
|
|
|
|
{
|
|
|
|
t << "INCPATH = ";
|
|
|
|
|
2013-12-09 18:56:31 +00:00
|
|
|
QString isystem = var("QMAKE_CFLAGS_ISYSTEM");
|
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("\\\\$"), "");
|
2013-12-09 18:56:31 +00:00
|
|
|
|
|
|
|
if (!isystem.isEmpty() && isSystemInclude(inc))
|
|
|
|
t << isystem << ' ';
|
|
|
|
else
|
|
|
|
t << "-I";
|
2015-02-06 14:30:02 +00:00
|
|
|
t << escapeFilePath(inc) << ' ';
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2015-01-09 12:42:57 +00:00
|
|
|
t << endl;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MingwMakefileGenerator::writeLibsPart(QTextStream &t)
|
|
|
|
{
|
|
|
|
if(project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") {
|
|
|
|
t << "LIB = " << var("QMAKE_LIB") << endl;
|
|
|
|
} else {
|
2012-12-04 11:36:56 +00:00
|
|
|
t << "LINKER = " << var("QMAKE_LINK") << endl;
|
2011-04-27 10:05:43 +00:00
|
|
|
t << "LFLAGS = " << var("QMAKE_LFLAGS") << endl;
|
2012-07-16 12:29:48 +00:00
|
|
|
t << "LIBS = "
|
2015-02-06 14:30:02 +00:00
|
|
|
<< fixLibFlags("QMAKE_LIBS").join(' ') << ' '
|
|
|
|
<< fixLibFlags("QMAKE_LIBS_PRIVATE").join(' ') << 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") {
|
2014-01-13 14:48:44 +00:00
|
|
|
QString ar_script_file = var("QMAKE_LINK_OBJECT_SCRIPT") + "." + var("TARGET");
|
|
|
|
if (!var("BUILD_NAME").isEmpty()) {
|
|
|
|
ar_script_file += "." + var("BUILD_NAME");
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
// QMAKE_LIB is used for win32, including mingw, whereas QMAKE_AR is used on Unix.
|
2015-06-01 13:02:25 +00:00
|
|
|
// 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"));
|
|
|
|
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");
|
2014-01-13 14:48:44 +00:00
|
|
|
if (!var("BUILD_NAME").isEmpty()) {
|
|
|
|
ld_script_file += "." + var("BUILD_NAME");
|
|
|
|
}
|
2015-06-01 13:02:25 +00:00
|
|
|
createLdObjectScriptFile(ld_script_file, project->values("OBJECTS"));
|
|
|
|
objectsLinkLine = escapeFilePath(ld_script_file);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
Win32MakefileGenerator::writeObjectsPart(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MingwMakefileGenerator::writeBuildRulesPart(QTextStream &t)
|
|
|
|
{
|
2013-07-04 09:25:16 +00:00
|
|
|
t << "first: all\n";
|
2015-02-06 14:30:02 +00:00
|
|
|
t << "all: " << escapeDependencyPath(fileFixify(Option::output.fileName()))
|
|
|
|
<< ' ' << depVar("ALL_DEPS") << " $(DESTDIR_TARGET)\n\n";
|
|
|
|
t << "$(DESTDIR_TARGET): " << depVar("PRE_TARGETDEPS") << " $(OBJECTS) " << depVar("POST_TARGETDEPS");
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!project->isEmpty("QMAKE_PRE_LINK"))
|
|
|
|
t << "\n\t" <<var("QMAKE_PRE_LINK");
|
|
|
|
if(project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") {
|
2014-01-13 14:48:44 +00:00
|
|
|
if (project->values("OBJECTS").count() < var("QMAKE_LINK_OBJECT_MAX").toInt()) {
|
2013-07-04 09:25:16 +00:00
|
|
|
t << "\n\t$(LIB) $(DESTDIR_TARGET) " << objectsLinkLine << " " ;
|
2011-04-27 10:05:43 +00:00
|
|
|
} else {
|
|
|
|
t << "\n\t" << objectsLinkLine << " " ;
|
|
|
|
}
|
2012-08-15 17:42:42 +00:00
|
|
|
} else if (project->first("TEMPLATE") != "aux") {
|
2013-07-04 09:25:16 +00:00
|
|
|
t << "\n\t$(LINKER) $(LFLAGS) " << var("QMAKE_LINK_O_FLAG") << "$(DESTDIR_TARGET) " << objectsLinkLine << " $(LIBS)";
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
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
|
|
|
|
2012-12-06 15:29:30 +00:00
|
|
|
ProStringList rcIncPaths = project->values("RC_INCLUDEPATH");
|
|
|
|
rcIncPaths.prepend(fileInfo(rc_file).path());
|
|
|
|
QString incPathStr;
|
|
|
|
for (int i = 0; i < rcIncPaths.count(); ++i) {
|
|
|
|
const ProString &path = rcIncPaths.at(i);
|
|
|
|
if (path.isEmpty())
|
|
|
|
continue;
|
|
|
|
incPathStr += QStringLiteral(" --include-dir=");
|
|
|
|
if (path != "." && QDir::isRelativePath(path.toQString()))
|
|
|
|
incPathStr += "./";
|
|
|
|
incPathStr += escapeFilePath(path);
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
if (!rc_file.isEmpty()) {
|
2015-05-27 20:31:21 +00:00
|
|
|
|
|
|
|
ProString defines = varGlue("RC_DEFINES", " -D", " -D", "");
|
|
|
|
if (defines.isEmpty())
|
|
|
|
defines = ProString(" $(DEFINES)");
|
|
|
|
|
2015-02-06 14:30:02 +00:00
|
|
|
t << escapeDependencyPath(var("RES_FILE")) << ": " << escapeDependencyPath(rc_file) << "\n\t"
|
|
|
|
<< var("QMAKE_RC") << " -i " << escapeFilePath(rc_file) << " -o " << fileVar("RES_FILE")
|
2015-05-27 20:31:21 +00:00
|
|
|
<< incPathStr << defines << "\n\n";
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList &MingwMakefileGenerator::findDependencies(const QString &file)
|
|
|
|
{
|
|
|
|
QStringList &aList = MakefileGenerator::findDependencies(file);
|
2014-11-13 14:37:55 +00:00
|
|
|
if (preCompHeaderOut.isEmpty())
|
2011-04-27 10:05:43 +00:00
|
|
|
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
|