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.
|
2011-04-27 10:05:43 +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 "unixmake.h"
|
|
|
|
#include "option.h"
|
|
|
|
#include <qregexp.h>
|
|
|
|
#include <qfile.h>
|
|
|
|
#include <qhash.h>
|
|
|
|
#include <qdir.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <qdebug.h>
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
|
|
|
void
|
|
|
|
UnixMakefileGenerator::init()
|
|
|
|
{
|
|
|
|
if(project->isEmpty("QMAKE_EXTENSION_SHLIB")) {
|
|
|
|
if(project->isEmpty("QMAKE_CYGWIN_SHLIB")) {
|
|
|
|
project->values("QMAKE_EXTENSION_SHLIB").append("so");
|
|
|
|
} else {
|
|
|
|
project->values("QMAKE_EXTENSION_SHLIB").append("dll");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-06 10:21:38 +00:00
|
|
|
ProStringList &configs = project->values("CONFIG");
|
2011-04-27 10:05:43 +00:00
|
|
|
if(project->isEmpty("ICON") && !project->isEmpty("RC_FILE"))
|
|
|
|
project->values("ICON") = project->values("RC_FILE");
|
|
|
|
if(project->isEmpty("QMAKE_EXTENSION_PLUGIN"))
|
|
|
|
project->values("QMAKE_EXTENSION_PLUGIN").append(project->first("QMAKE_EXTENSION_SHLIB"));
|
|
|
|
if(project->isEmpty("QMAKE_LIBTOOL"))
|
|
|
|
project->values("QMAKE_LIBTOOL").append("libtool --silent");
|
|
|
|
|
2013-12-07 20:34:38 +00:00
|
|
|
project->values("QMAKE_ORIG_TARGET") = project->values("TARGET");
|
|
|
|
|
|
|
|
//version handling
|
|
|
|
if (project->isEmpty("VERSION")) {
|
|
|
|
project->values("VERSION").append(
|
|
|
|
"1.0." + (project->isEmpty("VER_PAT") ? QString("0") : project->first("VER_PAT")));
|
|
|
|
}
|
|
|
|
QStringList l = project->first("VERSION").toQString().split('.');
|
|
|
|
l << "0" << "0"; //make sure there are three
|
|
|
|
project->values("VER_MAJ").append(l[0]);
|
|
|
|
project->values("VER_MIN").append(l[1]);
|
|
|
|
project->values("VER_PAT").append(l[2]);
|
|
|
|
|
2013-12-09 20:46:05 +00:00
|
|
|
QString sroot = project->sourceRoot();
|
|
|
|
foreach (const ProString &iif, project->values("QMAKE_INTERNAL_INCLUDED_FILES")) {
|
2014-07-17 01:43:44 +00:00
|
|
|
if (iif == project->cacheFile())
|
|
|
|
continue;
|
2013-12-09 20:46:05 +00:00
|
|
|
if (iif.startsWith(sroot) && iif.at(sroot.length()) == QLatin1Char('/'))
|
|
|
|
project->values("DISTFILES") += fileFixify(iif.toQString(), FileFixifyRelative);
|
|
|
|
}
|
2013-12-07 20:34:38 +00:00
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
/* 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("MAKEFILE"))
|
|
|
|
project->values("MAKEFILE").append("Makefile");
|
|
|
|
return; /* subdirs is done */
|
|
|
|
}
|
|
|
|
|
|
|
|
project->values("QMAKE_ORIG_DESTDIR") = project->values("DESTDIR");
|
2015-02-06 14:30:02 +00:00
|
|
|
project->values("QMAKE_LIBS") += project->values("LIBS");
|
|
|
|
project->values("QMAKE_LIBS_PRIVATE") += project->values("LIBS_PRIVATE");
|
2011-04-27 10:05:43 +00:00
|
|
|
if((!project->isEmpty("QMAKE_LIB_FLAG") && !project->isActiveConfig("staticlib")) ||
|
|
|
|
(project->isActiveConfig("qt") && project->isActiveConfig("plugin"))) {
|
|
|
|
if(configs.indexOf("dll") == -1) configs.append("dll");
|
|
|
|
} else if(!project->isEmpty("QMAKE_APP_FLAG") || project->isActiveConfig("dll")) {
|
|
|
|
configs.removeAll("staticlib");
|
|
|
|
}
|
|
|
|
if(!project->isEmpty("QMAKE_INCREMENTAL"))
|
|
|
|
project->values("QMAKE_LFLAGS") += project->values("QMAKE_LFLAGS_INCREMENTAL");
|
|
|
|
else if(!project->isEmpty("QMAKE_LFLAGS_PREBIND") &&
|
|
|
|
!project->values("QMAKE_LIB_FLAG").isEmpty() &&
|
|
|
|
project->isActiveConfig("dll"))
|
|
|
|
project->values("QMAKE_LFLAGS") += project->values("QMAKE_LFLAGS_PREBIND");
|
|
|
|
if(!project->isEmpty("QMAKE_INCDIR"))
|
|
|
|
project->values("INCLUDEPATH") += project->values("QMAKE_INCDIR");
|
2012-07-13 11:08:26 +00:00
|
|
|
project->values("QMAKE_L_FLAG")
|
|
|
|
<< (project->isActiveConfig("rvct_linker") ? "--userlibpath "
|
|
|
|
: project->isActiveConfig("armcc_linker") ? "-L--userlibpath="
|
2013-03-18 12:19:34 +00:00
|
|
|
: project->isActiveConfig("ti_linker") ? "--search_path="
|
2012-07-13 11:08:26 +00:00
|
|
|
: "-L");
|
2012-09-06 10:21:38 +00:00
|
|
|
ProStringList ldadd;
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!project->isEmpty("QMAKE_LIBDIR")) {
|
2012-09-06 10:21:38 +00:00
|
|
|
const ProStringList &libdirs = project->values("QMAKE_LIBDIR");
|
2011-04-27 10:05:43 +00:00
|
|
|
for(int i = 0; i < libdirs.size(); ++i) {
|
|
|
|
if(!project->isEmpty("QMAKE_LFLAGS_RPATH") && project->isActiveConfig("rpath_libdirs"))
|
|
|
|
project->values("QMAKE_LFLAGS") += var("QMAKE_LFLAGS_RPATH") + libdirs[i];
|
2012-08-30 14:55:31 +00:00
|
|
|
project->values("QMAKE_LIBDIR_FLAGS") += "-L" + escapeFilePath(libdirs[i]);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
2012-08-30 14:55:31 +00:00
|
|
|
ldadd += project->values("QMAKE_LIBDIR_FLAGS");
|
2013-06-26 10:14:41 +00:00
|
|
|
if (project->isActiveConfig("mac")) {
|
2012-08-30 14:55:31 +00:00
|
|
|
if (!project->isEmpty("QMAKE_FRAMEWORKPATH")) {
|
2012-09-06 10:21:38 +00:00
|
|
|
const ProStringList &fwdirs = project->values("QMAKE_FRAMEWORKPATH");
|
2012-08-30 14:55:31 +00:00
|
|
|
for (int i = 0; i < fwdirs.size(); ++i)
|
|
|
|
project->values("QMAKE_FRAMEWORKPATH_FLAGS") += "-F" + escapeFilePath(fwdirs[i]);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2012-07-13 11:16:39 +00:00
|
|
|
ldadd += project->values("QMAKE_FRAMEWORKPATH_FLAGS");
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2012-09-06 10:21:38 +00:00
|
|
|
ProStringList &qmklibs = project->values("QMAKE_LIBS");
|
2012-07-13 11:16:39 +00:00
|
|
|
qmklibs = ldadd + qmklibs;
|
2014-08-07 11:06:55 +00:00
|
|
|
if (!project->isEmpty("QMAKE_RPATHDIR") && !project->isEmpty("QMAKE_LFLAGS_RPATH")) {
|
2012-09-06 10:21:38 +00:00
|
|
|
const ProStringList &rpathdirs = project->values("QMAKE_RPATHDIR");
|
2014-08-07 11:06:55 +00:00
|
|
|
for (int i = 0; i < rpathdirs.size(); ++i) {
|
|
|
|
QString rpathdir = rpathdirs[i].toQString();
|
|
|
|
if (!rpathdir.startsWith('@') && !rpathdir.startsWith('$'))
|
|
|
|
rpathdir = QFileInfo(rpathdir).absoluteFilePath();
|
|
|
|
project->values("QMAKE_LFLAGS") += var("QMAKE_LFLAGS_RPATH") + escapeFilePath(rpathdir);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
2012-12-03 11:34:37 +00:00
|
|
|
if (!project->isEmpty("QMAKE_RPATHLINKDIR")) {
|
|
|
|
const ProStringList &rpathdirs = project->values("QMAKE_RPATHLINKDIR");
|
|
|
|
for (int i = 0; i < rpathdirs.size(); ++i) {
|
|
|
|
if (!project->isEmpty("QMAKE_LFLAGS_RPATHLINK"))
|
|
|
|
project->values("QMAKE_LFLAGS") += var("QMAKE_LFLAGS_RPATHLINK") + escapeFilePath(QFileInfo(rpathdirs[i].toQString()).absoluteFilePath());
|
|
|
|
}
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
if(project->isActiveConfig("GNUmake") && !project->isEmpty("QMAKE_CFLAGS_DEPS"))
|
|
|
|
include_deps = true; //do not generate deps
|
|
|
|
if(project->isActiveConfig("compile_libtool"))
|
|
|
|
Option::obj_ext = ".lo"; //override the .o
|
|
|
|
|
|
|
|
MakefileGenerator::init();
|
|
|
|
|
|
|
|
QString comps[] = { "C", "CXX", "OBJC", "OBJCXX", QString() };
|
|
|
|
for(int i = 0; !comps[i].isNull(); i++) {
|
|
|
|
QString compile_flag = var("QMAKE_COMPILE_FLAG");
|
|
|
|
if(compile_flag.isEmpty())
|
|
|
|
compile_flag = "-c";
|
|
|
|
|
|
|
|
if(doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER")) {
|
2012-09-06 10:21:38 +00:00
|
|
|
QString pchFlags = var(ProKey("QMAKE_" + comps[i] + "FLAGS_USE_PRECOMPILE"));
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
QString pchBaseName;
|
|
|
|
if(!project->isEmpty("PRECOMPILED_DIR")) {
|
2012-09-06 10:21:38 +00:00
|
|
|
pchBaseName = Option::fixPathToTargetOS(project->first("PRECOMPILED_DIR").toQString());
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!pchBaseName.endsWith(Option::dir_sep))
|
|
|
|
pchBaseName += Option::dir_sep;
|
|
|
|
}
|
2012-09-06 10:21:38 +00:00
|
|
|
pchBaseName += project->first("QMAKE_ORIG_TARGET").toQString();
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
// replace place holders
|
2015-02-06 14:30:02 +00:00
|
|
|
pchFlags.replace("${QMAKE_PCH_INPUT}",
|
|
|
|
escapeFilePath(project->first("PRECOMPILED_HEADER").toQString()));
|
|
|
|
pchFlags.replace("${QMAKE_PCH_OUTPUT_BASE}", escapeFilePath(pchBaseName));
|
2011-04-27 10:05:43 +00:00
|
|
|
if (project->isActiveConfig("icc_pch_style")) {
|
|
|
|
// icc style
|
2015-02-06 14:30:02 +00:00
|
|
|
pchFlags.replace("${QMAKE_PCH_OUTPUT}",
|
|
|
|
escapeFilePath(pchBaseName + project->first("QMAKE_PCH_OUTPUT_EXT")));
|
2011-04-27 10:05:43 +00:00
|
|
|
} else {
|
|
|
|
// gcc style (including clang_pch_style)
|
|
|
|
QString headerSuffix;
|
|
|
|
if (project->isActiveConfig("clang_pch_style"))
|
2012-09-06 10:21:38 +00:00
|
|
|
headerSuffix = project->first("QMAKE_PCH_OUTPUT_EXT").toQString();
|
2011-04-27 10:05:43 +00:00
|
|
|
else
|
2012-09-06 10:21:38 +00:00
|
|
|
pchBaseName += project->first("QMAKE_PCH_OUTPUT_EXT").toQString();
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
pchBaseName += Option::dir_sep;
|
|
|
|
QString pchOutputFile;
|
|
|
|
|
|
|
|
if(comps[i] == "C") {
|
|
|
|
pchOutputFile = "c";
|
|
|
|
} else if(comps[i] == "CXX") {
|
|
|
|
pchOutputFile = "c++";
|
|
|
|
} else if(project->isActiveConfig("objective_c")) {
|
|
|
|
if(comps[i] == "OBJC")
|
|
|
|
pchOutputFile = "objective-c";
|
|
|
|
else if(comps[i] == "OBJCXX")
|
|
|
|
pchOutputFile = "objective-c++";
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!pchOutputFile.isEmpty()) {
|
2015-02-06 14:30:02 +00:00
|
|
|
pchFlags.replace("${QMAKE_PCH_OUTPUT}",
|
|
|
|
escapeFilePath(pchBaseName + pchOutputFile + headerSuffix));
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pchFlags.isEmpty())
|
|
|
|
compile_flag += " " + pchFlags;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString cflags;
|
|
|
|
if(comps[i] == "OBJC" || comps[i] == "OBJCXX")
|
|
|
|
cflags += " $(CFLAGS)";
|
|
|
|
else
|
|
|
|
cflags += " $(" + comps[i] + "FLAGS)";
|
|
|
|
compile_flag += cflags + " $(INCPATH)";
|
|
|
|
|
|
|
|
QString compiler = comps[i];
|
|
|
|
if (compiler == "C")
|
|
|
|
compiler = "CC";
|
|
|
|
|
2012-09-06 10:21:38 +00:00
|
|
|
const ProKey runComp("QMAKE_RUN_" + compiler);
|
2011-04-27 10:05:43 +00:00
|
|
|
if(project->isEmpty(runComp))
|
2013-03-18 11:21:38 +00:00
|
|
|
project->values(runComp).append("$(" + compiler + ") " + compile_flag + " " + var("QMAKE_CC_O_FLAG") + "$obj $src");
|
2012-09-06 10:21:38 +00:00
|
|
|
const ProKey runCompImp("QMAKE_RUN_" + compiler + "_IMP");
|
2011-04-27 10:05:43 +00:00
|
|
|
if(project->isEmpty(runCompImp))
|
2013-03-18 11:21:38 +00:00
|
|
|
project->values(runCompImp).append("$(" + compiler + ") " + compile_flag + " " + var("QMAKE_CC_O_FLAG") + "\"$@\" \"$<\"");
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2013-06-26 10:14:41 +00:00
|
|
|
if (project->isActiveConfig("mac") && !project->isEmpty("TARGET") && !project->isActiveConfig("compile_libtool") &&
|
2011-04-27 10:05:43 +00:00
|
|
|
((project->isActiveConfig("build_pass") || project->isEmpty("BUILDS")))) {
|
2012-09-06 10:21:38 +00:00
|
|
|
ProString bundle;
|
2011-04-27 10:05:43 +00:00
|
|
|
if(project->isActiveConfig("bundle") && !project->isEmpty("QMAKE_BUNDLE_EXTENSION")) {
|
2015-02-06 14:30:02 +00:00
|
|
|
bundle = project->first("TARGET");
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!project->isEmpty("QMAKE_BUNDLE_NAME"))
|
2015-02-06 14:30:02 +00:00
|
|
|
bundle = project->first("QMAKE_BUNDLE_NAME");
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!bundle.endsWith(project->first("QMAKE_BUNDLE_EXTENSION")))
|
|
|
|
bundle += project->first("QMAKE_BUNDLE_EXTENSION");
|
|
|
|
} else if(project->first("TEMPLATE") == "app" && project->isActiveConfig("app_bundle")) {
|
2015-02-06 14:30:02 +00:00
|
|
|
bundle = project->first("TARGET");
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!project->isEmpty("QMAKE_APPLICATION_BUNDLE_NAME"))
|
2015-02-06 14:30:02 +00:00
|
|
|
bundle = project->first("QMAKE_APPLICATION_BUNDLE_NAME");
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!bundle.endsWith(".app"))
|
|
|
|
bundle += ".app";
|
|
|
|
if(project->isEmpty("QMAKE_BUNDLE_LOCATION"))
|
|
|
|
project->values("QMAKE_BUNDLE_LOCATION").append("Contents/MacOS");
|
|
|
|
project->values("QMAKE_PKGINFO").append(project->first("DESTDIR") + bundle + "/Contents/PkgInfo");
|
|
|
|
project->values("QMAKE_BUNDLE_RESOURCE_FILE").append(project->first("DESTDIR") + bundle + "/Contents/Resources/empty.lproj");
|
|
|
|
} else if(project->first("TEMPLATE") == "lib" && !project->isActiveConfig("staticlib") &&
|
|
|
|
((!project->isActiveConfig("plugin") && project->isActiveConfig("lib_bundle")) ||
|
|
|
|
(project->isActiveConfig("plugin") && project->isActiveConfig("plugin_bundle")))) {
|
2015-02-06 14:30:02 +00:00
|
|
|
bundle = project->first("TARGET");
|
2011-04-27 10:05:43 +00:00
|
|
|
if(project->isActiveConfig("plugin")) {
|
|
|
|
if(!project->isEmpty("QMAKE_PLUGIN_BUNDLE_NAME"))
|
2015-02-06 14:30:02 +00:00
|
|
|
bundle = project->first("QMAKE_PLUGIN_BUNDLE_NAME");
|
2014-11-12 09:21:29 +00:00
|
|
|
if (project->isEmpty("QMAKE_BUNDLE_EXTENSION"))
|
|
|
|
project->values("QMAKE_BUNDLE_EXTENSION").append(".plugin");
|
|
|
|
if (!bundle.endsWith(project->first("QMAKE_BUNDLE_EXTENSION")))
|
2011-04-27 10:05:43 +00:00
|
|
|
bundle += project->first("QMAKE_BUNDLE_EXTENSION");
|
|
|
|
if(project->isEmpty("QMAKE_BUNDLE_LOCATION"))
|
|
|
|
project->values("QMAKE_BUNDLE_LOCATION").append("Contents/MacOS");
|
|
|
|
} else {
|
|
|
|
if(!project->isEmpty("QMAKE_FRAMEWORK_BUNDLE_NAME"))
|
2015-02-06 14:30:02 +00:00
|
|
|
bundle = project->first("QMAKE_FRAMEWORK_BUNDLE_NAME");
|
2014-11-12 09:21:29 +00:00
|
|
|
if (project->isEmpty("QMAKE_BUNDLE_EXTENSION"))
|
|
|
|
project->values("QMAKE_BUNDLE_EXTENSION").append(".framework");
|
|
|
|
if (!bundle.endsWith(project->first("QMAKE_BUNDLE_EXTENSION")))
|
2011-04-27 10:05:43 +00:00
|
|
|
bundle += project->first("QMAKE_BUNDLE_EXTENSION");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!bundle.isEmpty()) {
|
2012-09-06 10:21:38 +00:00
|
|
|
project->values("QMAKE_BUNDLE") = ProStringList(bundle);
|
2011-04-27 10:05:43 +00:00
|
|
|
} else {
|
|
|
|
project->values("QMAKE_BUNDLE").clear();
|
|
|
|
project->values("QMAKE_BUNDLE_LOCATION").clear();
|
|
|
|
}
|
|
|
|
} else { //no bundling here
|
|
|
|
project->values("QMAKE_BUNDLE").clear();
|
|
|
|
project->values("QMAKE_BUNDLE_LOCATION").clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
init2();
|
2012-07-13 11:16:39 +00:00
|
|
|
project->values("QMAKE_INTERNAL_PRL_LIBS") << "QMAKE_LIBS";
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!project->isEmpty("QMAKE_MAX_FILES_PER_AR")) {
|
|
|
|
bool ok;
|
|
|
|
int max_files = project->first("QMAKE_MAX_FILES_PER_AR").toInt(&ok);
|
2012-09-06 10:21:38 +00:00
|
|
|
ProStringList ar_sublibs, objs = project->values("OBJECTS");
|
2011-04-27 10:05:43 +00:00
|
|
|
if(ok && max_files > 5 && max_files < (int)objs.count()) {
|
|
|
|
QString lib;
|
|
|
|
for(int i = 0, obj_cnt = 0, lib_cnt = 0; i != objs.size(); ++i) {
|
|
|
|
if((++obj_cnt) >= max_files) {
|
|
|
|
if(lib_cnt) {
|
|
|
|
lib.sprintf("lib%s-tmp%d.a",
|
|
|
|
project->first("QMAKE_ORIG_TARGET").toLatin1().constData(), lib_cnt);
|
|
|
|
ar_sublibs << lib;
|
|
|
|
obj_cnt = 0;
|
|
|
|
}
|
|
|
|
lib_cnt++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!ar_sublibs.isEmpty()) {
|
|
|
|
project->values("QMAKE_AR_SUBLIBS") = ar_sublibs;
|
|
|
|
project->values("QMAKE_INTERNAL_PRL_LIBS") << "QMAKE_AR_SUBLIBS";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(project->isActiveConfig("compile_libtool")) {
|
2012-08-20 11:04:39 +00:00
|
|
|
static const char * const libtoolify[] = {
|
|
|
|
"QMAKE_RUN_CC", "QMAKE_RUN_CC_IMP", "QMAKE_RUN_CXX", "QMAKE_RUN_CXX_IMP",
|
|
|
|
"QMAKE_LINK_THREAD", "QMAKE_LINK", "QMAKE_AR_CMD", "QMAKE_LINK_SHLIB_CMD", 0
|
|
|
|
};
|
|
|
|
for (int i = 0; libtoolify[i]; i++) {
|
2012-09-06 10:21:38 +00:00
|
|
|
ProStringList &l = project->values(libtoolify[i]);
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!l.isEmpty()) {
|
|
|
|
QString libtool_flags, comp_flags;
|
2012-08-20 11:04:39 +00:00
|
|
|
if (!strncmp(libtoolify[i], "QMAKE_LINK", 10) || !strcmp(libtoolify[i], "QMAKE_AR_CMD")) {
|
2011-04-27 10:05:43 +00:00
|
|
|
libtool_flags += " --mode=link";
|
|
|
|
if(project->isActiveConfig("staticlib")) {
|
|
|
|
libtool_flags += " -static";
|
|
|
|
} else {
|
|
|
|
if(!project->isEmpty("QMAKE_LIB_FLAG")) {
|
|
|
|
int maj = project->first("VER_MAJ").toInt();
|
|
|
|
int min = project->first("VER_MIN").toInt();
|
|
|
|
int pat = project->first("VER_PAT").toInt();
|
|
|
|
comp_flags += " -version-info " + QString::number(10*maj + min) +
|
|
|
|
":" + QString::number(pat) + ":0";
|
2012-08-31 14:21:01 +00:00
|
|
|
if (strcmp(libtoolify[i], "QMAKE_AR_CMD")) {
|
2011-04-27 10:05:43 +00:00
|
|
|
QString rpath = Option::output_dir;
|
|
|
|
if(!project->isEmpty("DESTDIR")) {
|
2012-09-06 10:21:38 +00:00
|
|
|
rpath = project->first("DESTDIR").toQString();
|
2011-04-27 10:05:43 +00:00
|
|
|
if(QDir::isRelativePath(rpath))
|
|
|
|
rpath.prepend(Option::output_dir + Option::dir_sep);
|
|
|
|
}
|
2015-02-06 14:30:02 +00:00
|
|
|
comp_flags += " -rpath " + escapeFilePath(Option::fixPathToTargetOS(rpath, false));
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(project->isActiveConfig("plugin"))
|
|
|
|
libtool_flags += " -module";
|
|
|
|
} else {
|
|
|
|
libtool_flags += " --mode=compile";
|
|
|
|
}
|
|
|
|
l.first().prepend("$(LIBTOOL)" + libtool_flags + " ");
|
|
|
|
if(!comp_flags.isEmpty())
|
|
|
|
l.first() += comp_flags;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList
|
|
|
|
&UnixMakefileGenerator::findDependencies(const QString &file)
|
|
|
|
{
|
|
|
|
QStringList &ret = MakefileGenerator::findDependencies(file);
|
2014-11-13 14:37:55 +00:00
|
|
|
if (doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER")) {
|
2011-04-27 10:05:43 +00:00
|
|
|
QString header_prefix;
|
|
|
|
if(!project->isEmpty("PRECOMPILED_DIR"))
|
2012-09-06 10:21:38 +00:00
|
|
|
header_prefix = project->first("PRECOMPILED_DIR").toQString();
|
|
|
|
header_prefix += project->first("QMAKE_ORIG_TARGET").toQString();
|
2011-04-27 10:05:43 +00:00
|
|
|
if (!project->isActiveConfig("clang_pch_style"))
|
2012-09-06 10:21:38 +00:00
|
|
|
header_prefix += project->first("QMAKE_PCH_OUTPUT_EXT").toQString();
|
2011-04-27 10:05:43 +00:00
|
|
|
if (project->isActiveConfig("icc_pch_style")) {
|
|
|
|
// icc style
|
|
|
|
for(QStringList::Iterator it = Option::cpp_ext.begin(); it != Option::cpp_ext.end(); ++it) {
|
|
|
|
if(file.endsWith(*it)) {
|
|
|
|
ret += header_prefix;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// gcc style (including clang_pch_style)
|
|
|
|
QString header_suffix = project->isActiveConfig("clang_pch_style")
|
2012-09-06 10:21:38 +00:00
|
|
|
? project->first("QMAKE_PCH_OUTPUT_EXT").toQString() : "";
|
2011-04-27 10:05:43 +00:00
|
|
|
header_prefix += Option::dir_sep + project->first("QMAKE_PRECOMP_PREFIX");
|
|
|
|
for(QStringList::Iterator it = Option::c_ext.begin(); it != Option::c_ext.end(); ++it) {
|
|
|
|
if(file.endsWith(*it)) {
|
|
|
|
if(!project->isEmpty("QMAKE_CFLAGS_PRECOMPILE")) {
|
|
|
|
QString precomp_c_h = header_prefix + "c" + header_suffix;
|
|
|
|
if(!ret.contains(precomp_c_h))
|
|
|
|
ret += precomp_c_h;
|
|
|
|
}
|
|
|
|
if(project->isActiveConfig("objective_c")) {
|
|
|
|
if(!project->isEmpty("QMAKE_OBJCFLAGS_PRECOMPILE")) {
|
|
|
|
QString precomp_objc_h = header_prefix + "objective-c" + header_suffix;
|
|
|
|
if(!ret.contains(precomp_objc_h))
|
|
|
|
ret += precomp_objc_h;
|
|
|
|
}
|
|
|
|
if(!project->isEmpty("QMAKE_OBJCXXFLAGS_PRECOMPILE")) {
|
|
|
|
QString precomp_objcpp_h = header_prefix + "objective-c++" + header_suffix;
|
|
|
|
if(!ret.contains(precomp_objcpp_h))
|
|
|
|
ret += precomp_objcpp_h;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for(QStringList::Iterator it = Option::cpp_ext.begin(); it != Option::cpp_ext.end(); ++it) {
|
|
|
|
if(file.endsWith(*it)) {
|
|
|
|
if(!project->isEmpty("QMAKE_CXXFLAGS_PRECOMPILE")) {
|
|
|
|
QString precomp_cpp_h = header_prefix + "c++" + header_suffix;
|
|
|
|
if(!ret.contains(precomp_cpp_h))
|
|
|
|
ret += precomp_cpp_h;
|
|
|
|
}
|
|
|
|
if(project->isActiveConfig("objective_c")) {
|
|
|
|
if(!project->isEmpty("QMAKE_OBJCXXFLAGS_PRECOMPILE")) {
|
|
|
|
QString precomp_objcpp_h = header_prefix + "objective-c++" + header_suffix;
|
|
|
|
if(!ret.contains(precomp_objcpp_h))
|
|
|
|
ret += precomp_objcpp_h;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-02-06 14:30:02 +00:00
|
|
|
ProString
|
|
|
|
UnixMakefileGenerator::fixLibFlag(const ProString &lib)
|
|
|
|
{
|
|
|
|
return escapeFilePath(lib);
|
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
bool
|
|
|
|
UnixMakefileGenerator::findLibraries()
|
|
|
|
{
|
2012-09-06 10:21:38 +00:00
|
|
|
ProString libArg = project->first("QMAKE_L_FLAG");
|
2012-07-13 11:08:26 +00:00
|
|
|
if (libArg == "-L")
|
|
|
|
libArg.clear();
|
2012-07-25 11:51:26 +00:00
|
|
|
QList<QMakeLocalFileName> libdirs;
|
2012-07-19 15:50:59 +00:00
|
|
|
int libidx = 0;
|
2012-09-06 10:21:38 +00:00
|
|
|
foreach (const ProString &dlib, project->values("QMAKE_DEFAULT_LIBDIRS"))
|
|
|
|
libdirs.append(QMakeLocalFileName(dlib.toQString()));
|
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]);
|
|
|
|
for (ProStringList::Iterator it = l.begin(); it != l.end(); ) {
|
|
|
|
QString stub, dir, extn, opt = (*it).trimmed().toQString();
|
2011-04-27 10:05:43 +00:00
|
|
|
if(opt.startsWith("-")) {
|
|
|
|
if(opt.startsWith("-L")) {
|
2012-07-13 11:08:26 +00:00
|
|
|
QString lib = opt.mid(2);
|
|
|
|
QMakeLocalFileName f(lib);
|
2012-08-02 10:11:13 +00:00
|
|
|
int idx = libdirs.indexOf(f);
|
|
|
|
if (idx >= 0 && idx < libidx) {
|
2012-07-13 11:09:30 +00:00
|
|
|
it = l.erase(it);
|
|
|
|
continue;
|
|
|
|
}
|
2012-07-19 15:50:59 +00:00
|
|
|
libdirs.insert(libidx++, f);
|
2012-07-13 11:08:26 +00:00
|
|
|
if (!libArg.isEmpty())
|
2015-02-06 14:30:02 +00:00
|
|
|
*it = libArg + f.real();
|
2011-04-27 10:05:43 +00:00
|
|
|
} else if(opt.startsWith("-l")) {
|
2012-07-12 13:44:34 +00:00
|
|
|
if (project->isActiveConfig("rvct_linker") || project->isActiveConfig("armcc_linker")) {
|
2011-04-27 10:05:43 +00:00
|
|
|
(*it) = "lib" + opt.mid(2) + ".so";
|
2013-03-18 12:19:34 +00:00
|
|
|
} else if (project->isActiveConfig("ti_linker")) {
|
|
|
|
(*it) = opt.mid(2);
|
2011-04-27 10:05:43 +00:00
|
|
|
} else {
|
|
|
|
stub = opt.mid(2);
|
|
|
|
}
|
2013-03-06 13:53:36 +00:00
|
|
|
} else if (target_mode == TARG_MAC_MODE && opt.startsWith("-framework")) {
|
2012-07-25 11:51:26 +00:00
|
|
|
if (opt.length() == 10)
|
2011-04-27 10:05:43 +00:00
|
|
|
++it;
|
2012-07-25 11:51:26 +00:00
|
|
|
// Skip
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
extn = dir = "";
|
|
|
|
stub = opt;
|
|
|
|
int slsh = opt.lastIndexOf(Option::dir_sep);
|
|
|
|
if(slsh != -1) {
|
|
|
|
dir = opt.left(slsh);
|
|
|
|
stub = opt.mid(slsh+1);
|
|
|
|
}
|
|
|
|
QRegExp stub_reg("^.*lib(" + stub + "[^./=]*)\\.(.*)$");
|
|
|
|
if(stub_reg.exactMatch(stub)) {
|
|
|
|
stub = stub_reg.cap(1);
|
|
|
|
extn = stub_reg.cap(2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!stub.isEmpty()) {
|
2012-09-06 10:21:38 +00:00
|
|
|
stub += project->first(ProKey("QMAKE_" + stub.toUpper() + "_SUFFIX")).toQString();
|
2011-04-27 10:05:43 +00:00
|
|
|
bool found = false;
|
2012-09-06 10:21:38 +00:00
|
|
|
ProStringList extens;
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!extn.isNull())
|
|
|
|
extens << extn;
|
|
|
|
else
|
2014-11-27 13:49:16 +00:00
|
|
|
extens << project->first("QMAKE_EXTENSION_SHLIB") << "a";
|
2012-09-06 10:21:38 +00:00
|
|
|
for (ProStringList::Iterator extit = extens.begin(); extit != extens.end(); ++extit) {
|
2011-04-27 10:05:43 +00:00
|
|
|
if(dir.isNull()) {
|
|
|
|
for(QList<QMakeLocalFileName>::Iterator dep_it = libdirs.begin(); dep_it != libdirs.end(); ++dep_it) {
|
2014-11-24 15:02:38 +00:00
|
|
|
QString pathToLib = ((*dep_it).local() + '/'
|
2014-11-27 13:49:16 +00:00
|
|
|
+ project->first("QMAKE_PREFIX_SHLIB")
|
2011-04-27 10:05:43 +00:00
|
|
|
+ stub + "." + (*extit));
|
|
|
|
if(exists(pathToLib)) {
|
2012-07-12 13:44:34 +00:00
|
|
|
(*it) = "-l" + stub;
|
2011-04-27 10:05:43 +00:00
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2014-11-27 13:49:16 +00:00
|
|
|
QString lib = dir + project->first("QMAKE_PREFIX_SHLIB") + stub + "." + (*extit);
|
2012-07-19 16:32:16 +00:00
|
|
|
if (exists(lib)) {
|
|
|
|
(*it) = lib;
|
2011-04-27 10:05:43 +00:00
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!found && project->isActiveConfig("compile_libtool")) {
|
|
|
|
for(int dep_i = 0; dep_i < libdirs.size(); ++dep_i) {
|
2014-11-24 15:02:38 +00:00
|
|
|
if (exists(libdirs[dep_i].local() + '/' + project->first("QMAKE_PREFIX_SHLIB") + stub + Option::libtool_ext)) {
|
2014-11-27 13:49:16 +00:00
|
|
|
(*it) = libdirs[dep_i].real() + Option::dir_sep + project->first("QMAKE_PREFIX_SHLIB") + stub + Option::libtool_ext;
|
2011-04-27 10:05:43 +00:00
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-07-13 11:09:30 +00:00
|
|
|
++it;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString linkLib(const QString &file, const QString &libName) {
|
|
|
|
QString ret;
|
|
|
|
QRegExp reg("^.*lib(" + QRegExp::escape(libName) + "[^./=]*).*$");
|
|
|
|
if(reg.exactMatch(file))
|
|
|
|
ret = "-l" + reg.cap(1);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UnixMakefileGenerator::processPrlFiles()
|
|
|
|
{
|
2012-09-06 10:21:38 +00:00
|
|
|
const QString libArg = project->first("QMAKE_L_FLAG").toQString();
|
2011-04-27 10:05:43 +00:00
|
|
|
QList<QMakeLocalFileName> libdirs, frameworkdirs;
|
2012-07-19 15:50:59 +00:00
|
|
|
int libidx = 0, fwidx = 0;
|
2012-09-06 10:21:38 +00:00
|
|
|
foreach (const ProString &dlib, project->values("QMAKE_DEFAULT_LIBDIRS"))
|
|
|
|
libdirs.append(QMakeLocalFileName(dlib.toQString()));
|
2011-04-27 10:05:43 +00:00
|
|
|
frameworkdirs.append(QMakeLocalFileName("/System/Library/Frameworks"));
|
2012-07-19 16:50:05 +00:00
|
|
|
frameworkdirs.append(QMakeLocalFileName("/Library/Frameworks"));
|
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]);
|
2011-04-27 10:05:43 +00:00
|
|
|
for(int lit = 0; lit < l.size(); ++lit) {
|
2012-09-06 10:21:38 +00:00
|
|
|
QString opt = l.at(lit).trimmed().toQString();
|
2011-04-27 10:05:43 +00:00
|
|
|
if(opt.startsWith("-")) {
|
2012-07-13 11:08:26 +00:00
|
|
|
if (opt.startsWith(libArg)) {
|
|
|
|
QMakeLocalFileName l(opt.mid(libArg.length()));
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!libdirs.contains(l))
|
2012-07-19 15:50:59 +00:00
|
|
|
libdirs.insert(libidx++, l);
|
2011-04-27 10:05:43 +00:00
|
|
|
} else if(opt.startsWith("-l")) {
|
|
|
|
QString lib = opt.right(opt.length() - 2);
|
2012-09-06 10:21:38 +00:00
|
|
|
QString prl_ext = project->first(ProKey("QMAKE_" + lib.toUpper() + "_SUFFIX")).toQString();
|
2011-04-27 10:05:43 +00:00
|
|
|
for(int dep_i = 0; dep_i < libdirs.size(); ++dep_i) {
|
|
|
|
const QMakeLocalFileName &lfn = libdirs[dep_i];
|
|
|
|
if(!project->isActiveConfig("compile_libtool")) { //give them the .libs..
|
2014-11-24 15:02:38 +00:00
|
|
|
QString la = lfn.local() + '/' + project->first("QMAKE_PREFIX_SHLIB") + lib + Option::libtool_ext;
|
|
|
|
if (exists(la) && QFile::exists(lfn.local() + "/.libs")) {
|
2011-04-27 10:05:43 +00:00
|
|
|
QString dot_libs = lfn.real() + Option::dir_sep + ".libs";
|
|
|
|
l.append("-L" + dot_libs);
|
2012-07-19 15:50:59 +00:00
|
|
|
libdirs.insert(libidx++, QMakeLocalFileName(dot_libs));
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-24 15:02:38 +00:00
|
|
|
QString prl = lfn.local() + '/' + project->first("QMAKE_PREFIX_SHLIB") + lib + prl_ext;
|
2011-04-27 10:05:43 +00:00
|
|
|
if(processPrlFile(prl)) {
|
|
|
|
if(prl.startsWith(lfn.local()))
|
|
|
|
prl.replace(0, lfn.local().length(), lfn.real());
|
|
|
|
opt = linkLib(prl, lib);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-03-06 13:53:36 +00:00
|
|
|
} else if (target_mode == TARG_MAC_MODE && opt.startsWith("-F")) {
|
2011-04-27 10:05:43 +00:00
|
|
|
QMakeLocalFileName f(opt.right(opt.length()-2));
|
|
|
|
if(!frameworkdirs.contains(f))
|
2012-07-19 15:50:59 +00:00
|
|
|
frameworkdirs.insert(fwidx++, f);
|
2013-03-06 13:53:36 +00:00
|
|
|
} else if (target_mode == TARG_MAC_MODE && opt.startsWith("-framework")) {
|
2011-04-27 10:05:43 +00:00
|
|
|
if(opt.length() > 11)
|
|
|
|
opt = opt.mid(11);
|
|
|
|
else
|
2012-09-06 10:21:38 +00:00
|
|
|
opt = l.at(++lit).toQString();
|
2011-04-27 10:05:43 +00:00
|
|
|
opt = opt.trimmed();
|
2012-07-19 15:52:29 +00:00
|
|
|
foreach (const QMakeLocalFileName &dir, frameworkdirs) {
|
|
|
|
QString prl = dir.local() + "/" + opt + ".framework/" + opt + Option::prl_ext;
|
2011-04-27 10:05:43 +00:00
|
|
|
if(processPrlFile(prl))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if(!opt.isNull()) {
|
|
|
|
QString lib = opt;
|
|
|
|
processPrlFile(lib);
|
|
|
|
#if 0
|
|
|
|
if(ret)
|
|
|
|
opt = linkLib(lib, "");
|
|
|
|
#endif
|
|
|
|
if(!opt.isEmpty())
|
2012-09-06 10:21:38 +00:00
|
|
|
for (int k = 0; k < l.size(); ++k)
|
|
|
|
l[k] = l.at(k).toQString().replace(lib, opt);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2012-09-06 10:21:38 +00:00
|
|
|
ProStringList &prl_libs = project->values("QMAKE_CURRENT_PRL_LIBS");
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!prl_libs.isEmpty()) {
|
|
|
|
for(int prl = 0; prl < prl_libs.size(); ++prl)
|
2015-05-27 18:58:44 +00:00
|
|
|
l.insert(++lit, prl_libs.at(prl));
|
2011-04-27 10:05:43 +00:00
|
|
|
prl_libs.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//merge them into a logical order
|
|
|
|
if(!project->isActiveConfig("no_smart_library_merge") && !project->isActiveConfig("no_lflags_merge")) {
|
2012-09-06 10:21:38 +00:00
|
|
|
QHash<ProKey, ProStringList> lflags;
|
2011-04-27 10:05:43 +00:00
|
|
|
for(int lit = 0; lit < l.size(); ++lit) {
|
2012-09-06 10:21:38 +00:00
|
|
|
ProKey arch("default");
|
|
|
|
ProString opt = l.at(lit).trimmed();
|
2011-04-27 10:05:43 +00:00
|
|
|
if(opt.startsWith("-")) {
|
2013-03-06 13:53:36 +00:00
|
|
|
if (target_mode == TARG_MAC_MODE && opt.startsWith("-Xarch")) {
|
2011-04-27 10:05:43 +00:00
|
|
|
if (opt.length() > 7) {
|
2012-09-06 10:21:38 +00:00
|
|
|
arch = opt.mid(7).toKey();
|
2011-04-27 10:05:43 +00:00
|
|
|
opt = l.at(++lit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-13 11:08:26 +00:00
|
|
|
if (opt.startsWith(libArg) ||
|
2013-03-06 13:53:36 +00:00
|
|
|
(target_mode == TARG_MAC_MODE && opt.startsWith("-F"))) {
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!lflags[arch].contains(opt))
|
|
|
|
lflags[arch].append(opt);
|
|
|
|
} else if(opt.startsWith("-l") || opt == "-pthread") {
|
|
|
|
// Make sure we keep the dependency-order of libraries
|
|
|
|
if (lflags[arch].contains(opt))
|
|
|
|
lflags[arch].removeAll(opt);
|
|
|
|
lflags[arch].append(opt);
|
2013-03-06 13:53:36 +00:00
|
|
|
} else if (target_mode == TARG_MAC_MODE && opt.startsWith("-framework")) {
|
2011-04-27 10:05:43 +00:00
|
|
|
if(opt.length() > 11)
|
|
|
|
opt = opt.mid(11);
|
|
|
|
else {
|
|
|
|
opt = l.at(++lit);
|
2013-03-06 13:53:36 +00:00
|
|
|
if (target_mode == TARG_MAC_MODE && opt.startsWith("-Xarch"))
|
2011-04-27 10:05:43 +00:00
|
|
|
opt = l.at(++lit); // The user has done the right thing and prefixed each part
|
|
|
|
}
|
|
|
|
bool found = false;
|
|
|
|
for(int x = 0; x < lflags[arch].size(); ++x) {
|
2012-09-06 10:21:38 +00:00
|
|
|
ProString xf = lflags[arch].at(x);
|
2011-04-27 10:05:43 +00:00
|
|
|
if(xf.startsWith("-framework")) {
|
2012-09-06 10:21:38 +00:00
|
|
|
ProString framework;
|
2011-04-27 10:05:43 +00:00
|
|
|
if(xf.length() > 11)
|
|
|
|
framework = xf.mid(11);
|
|
|
|
else
|
|
|
|
framework = lflags[arch].at(++x);
|
|
|
|
if(framework == opt) {
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!found) {
|
|
|
|
lflags[arch].append("-framework");
|
|
|
|
lflags[arch].append(opt);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
lflags[arch].append(opt);
|
|
|
|
}
|
|
|
|
} else if(!opt.isNull()) {
|
|
|
|
if(!lflags[arch].contains(opt))
|
|
|
|
lflags[arch].append(opt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
l = lflags.take("default");
|
|
|
|
|
|
|
|
// Process architecture specific options (Xarch)
|
2012-09-06 10:21:38 +00:00
|
|
|
QHash<ProKey, ProStringList>::const_iterator archIterator = lflags.constBegin();
|
2011-04-27 10:05:43 +00:00
|
|
|
while (archIterator != lflags.constEnd()) {
|
2012-09-06 10:21:38 +00:00
|
|
|
const ProStringList &archOptions = archIterator.value();
|
2011-04-27 10:05:43 +00:00
|
|
|
for (int i = 0; i < archOptions.size(); ++i) {
|
|
|
|
l.append(QLatin1String("-Xarch_") + archIterator.key());
|
|
|
|
l.append(archOptions.at(i));
|
|
|
|
}
|
|
|
|
++archIterator;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QString
|
|
|
|
UnixMakefileGenerator::defaultInstall(const QString &t)
|
|
|
|
{
|
|
|
|
if(t != "target" || project->first("TEMPLATE") == "subdirs")
|
|
|
|
return QString();
|
|
|
|
|
2013-07-11 13:43:32 +00:00
|
|
|
enum { NoBundle, SolidBundle, SlicedBundle } bundle = NoBundle;
|
2015-05-05 17:01:14 +00:00
|
|
|
bool isAux = (project->first("TEMPLATE") == "aux");
|
2011-04-27 10:05:43 +00:00
|
|
|
const QString root = "$(INSTALL_ROOT)";
|
2012-09-06 10:21:38 +00:00
|
|
|
ProStringList &uninst = project->values(ProKey(t + ".uninstall"));
|
|
|
|
QString ret, destdir = project->first("DESTDIR").toQString();
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep)
|
|
|
|
destdir += Option::dir_sep;
|
2014-11-24 18:51:32 +00:00
|
|
|
QString targetdir = fileFixify(project->first("target.path").toQString(), FileFixifyAbsolute);
|
2011-04-27 10:05:43 +00:00
|
|
|
if(targetdir.right(1) != Option::dir_sep)
|
|
|
|
targetdir += Option::dir_sep;
|
|
|
|
|
2012-09-06 10:21:38 +00:00
|
|
|
ProStringList links;
|
2011-04-27 10:05:43 +00:00
|
|
|
QString target="$(TARGET)";
|
2012-09-06 10:21:38 +00:00
|
|
|
const ProStringList &targets = project->values(ProKey(t + ".targets"));
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!project->isEmpty("QMAKE_BUNDLE")) {
|
2012-09-06 10:21:38 +00:00
|
|
|
target = project->first("QMAKE_BUNDLE").toQString();
|
2013-07-11 13:43:32 +00:00
|
|
|
bundle = project->isActiveConfig("sliced_bundle") ? SlicedBundle : SolidBundle;
|
2011-04-27 10:05:43 +00:00
|
|
|
} else if(project->first("TEMPLATE") == "app") {
|
|
|
|
target = "$(QMAKE_TARGET)";
|
|
|
|
} else if(project->first("TEMPLATE") == "lib") {
|
|
|
|
if(project->isEmpty("QMAKE_CYGWIN_SHLIB")) {
|
2014-04-23 14:26:26 +00:00
|
|
|
if (!project->isActiveConfig("staticlib")
|
|
|
|
&& !project->isActiveConfig("plugin")
|
|
|
|
&& !project->isActiveConfig("unversioned_libname")) {
|
2011-04-27 10:05:43 +00:00
|
|
|
if(project->isEmpty("QMAKE_HPUX_SHLIB")) {
|
|
|
|
links << "$(TARGET0)" << "$(TARGET1)" << "$(TARGET2)";
|
|
|
|
} else {
|
|
|
|
links << "$(TARGET0)";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for(int i = 0; i < targets.size(); ++i) {
|
2012-09-06 10:21:38 +00:00
|
|
|
QString src = targets.at(i).toQString(),
|
2015-02-06 14:30:02 +00:00
|
|
|
dst = escapeFilePath(filePrefixRoot(root, targetdir + src.section('/', -1)));
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!ret.isEmpty())
|
|
|
|
ret += "\n\t";
|
2015-02-06 14:30:02 +00:00
|
|
|
ret += "-$(INSTALL_FILE) " + escapeFilePath(src) + ' ' + dst;
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!uninst.isEmpty())
|
|
|
|
uninst.append("\n\t");
|
2015-02-06 14:30:02 +00:00
|
|
|
uninst.append("-$(DEL_FILE) " + dst);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2013-07-11 13:43:32 +00:00
|
|
|
if (bundle == NoBundle && project->isActiveConfig("compile_libtool")) {
|
2015-02-06 14:30:02 +00:00
|
|
|
QString src_targ = escapeFilePath(target);
|
2011-04-27 10:05:43 +00:00
|
|
|
if(src_targ == "$(TARGET)")
|
|
|
|
src_targ = "$(TARGETL)";
|
|
|
|
QString dst_dir = fileFixify(targetdir, FileFixifyAbsolute);
|
|
|
|
if(QDir::isRelativePath(dst_dir))
|
|
|
|
dst_dir = Option::fixPathToTargetOS(Option::output_dir + Option::dir_sep + dst_dir);
|
2015-02-06 14:30:02 +00:00
|
|
|
ret = "-$(LIBTOOL) --mode=install cp " + src_targ + ' ' + escapeFilePath(filePrefixRoot(root, dst_dir));
|
|
|
|
uninst.append("-$(LIBTOOL) --mode=uninstall " + src_targ);
|
2011-04-27 10:05:43 +00:00
|
|
|
} else {
|
|
|
|
QString src_targ = target;
|
|
|
|
if(!destdir.isEmpty())
|
|
|
|
src_targ = Option::fixPathToTargetOS(destdir + target, false);
|
2013-07-11 13:43:32 +00:00
|
|
|
QString plain_targ = filePrefixRoot(root, fileFixify(targetdir + target, FileFixifyAbsolute));
|
|
|
|
QString dst_targ = plain_targ;
|
2015-02-06 14:30:02 +00:00
|
|
|
plain_targ = escapeFilePath(plain_targ);
|
2013-07-11 13:43:32 +00:00
|
|
|
if (bundle != NoBundle) {
|
|
|
|
QString suffix;
|
|
|
|
if (project->first("TEMPLATE") == "lib")
|
|
|
|
suffix = "/Versions/" + project->first("QMAKE_FRAMEWORK_VERSION") + "/$(TARGET)";
|
|
|
|
else
|
|
|
|
suffix = "/" + project->first("QMAKE_BUNDLE_LOCATION") + "/$(QMAKE_TARGET)";
|
|
|
|
dst_targ += suffix;
|
|
|
|
if (bundle == SolidBundle) {
|
|
|
|
if (!ret.isEmpty())
|
|
|
|
ret += "\n\t";
|
2015-02-06 14:30:02 +00:00
|
|
|
ret += "$(DEL_FILE) -r " + plain_targ + "\n\t";
|
2013-07-11 13:43:32 +00:00
|
|
|
} else {
|
|
|
|
src_targ += suffix;
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2015-02-06 14:30:02 +00:00
|
|
|
src_targ = escapeFilePath(src_targ);
|
|
|
|
dst_targ = escapeFilePath(dst_targ);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2015-05-05 17:01:14 +00:00
|
|
|
QString copy_cmd;
|
2013-07-11 13:43:32 +00:00
|
|
|
if (bundle == SolidBundle) {
|
2015-05-05 17:01:14 +00:00
|
|
|
copy_cmd += "-$(INSTALL_DIR) " + src_targ + ' ' + plain_targ;
|
2013-07-11 13:43:32 +00:00
|
|
|
} else if (project->first("TEMPLATE") == "lib" && project->isActiveConfig("staticlib")) {
|
2015-05-05 17:01:14 +00:00
|
|
|
copy_cmd += "-$(INSTALL_FILE) " + src_targ + ' ' + dst_targ;
|
|
|
|
} else if (!isAux) {
|
2013-07-11 13:43:32 +00:00
|
|
|
if (bundle == SlicedBundle)
|
2015-02-06 14:30:02 +00:00
|
|
|
ret += mkdir_p_asstring("\"`dirname " + dst_targ + "`\"", false) + "\n\t";
|
2015-05-05 17:01:14 +00:00
|
|
|
copy_cmd += "-$(INSTALL_PROGRAM) " + src_targ + ' ' + dst_targ;
|
2013-07-11 13:43:32 +00:00
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
if(project->first("TEMPLATE") == "lib" && !project->isActiveConfig("staticlib")
|
2012-09-06 10:21:38 +00:00
|
|
|
&& project->values(ProKey(t + ".CONFIG")).indexOf("fix_rpath") != -1) {
|
2015-05-05 17:01:14 +00:00
|
|
|
if (!ret.isEmpty())
|
|
|
|
ret += "\n\t";
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!project->isEmpty("QMAKE_FIX_RPATH")) {
|
|
|
|
ret += copy_cmd;
|
2015-02-06 14:30:02 +00:00
|
|
|
ret += "\n\t-" + var("QMAKE_FIX_RPATH") + ' ' + dst_targ + ' ' + dst_targ;
|
2011-04-27 10:05:43 +00:00
|
|
|
} else if(!project->isEmpty("QMAKE_LFLAGS_RPATH")) {
|
2015-02-06 14:30:02 +00:00
|
|
|
ret += "-$(LINK) $(LFLAGS) " + var("QMAKE_LFLAGS_RPATH") + targetdir + " -o " +
|
|
|
|
dst_targ + " $(OBJECTS) $(LIBS) $(OBJCOMP)";
|
2011-04-27 10:05:43 +00:00
|
|
|
} else {
|
|
|
|
ret += copy_cmd;
|
|
|
|
}
|
2015-05-05 17:01:14 +00:00
|
|
|
} else if (!copy_cmd.isEmpty()) {
|
|
|
|
if (!ret.isEmpty())
|
|
|
|
ret += "\n\t";
|
2011-04-27 10:05:43 +00:00
|
|
|
ret += copy_cmd;
|
|
|
|
}
|
|
|
|
|
2015-05-05 17:01:14 +00:00
|
|
|
if (isAux) {
|
|
|
|
} else if (project->first("TEMPLATE") == "lib" && project->isActiveConfig("staticlib")) {
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!project->isEmpty("QMAKE_RANLIB"))
|
2015-02-06 14:30:02 +00:00
|
|
|
ret += QString("\n\t$(RANLIB) ") + dst_targ;
|
2013-11-18 20:39:08 +00:00
|
|
|
} else if (!project->isActiveConfig("debug_info") && !project->isActiveConfig("nostrip")
|
|
|
|
&& !project->isEmpty("QMAKE_STRIP")) {
|
2011-04-27 10:05:43 +00:00
|
|
|
ret += "\n\t-$(STRIP)";
|
2013-07-04 14:09:05 +00:00
|
|
|
if (project->first("TEMPLATE") == "lib") {
|
|
|
|
if (!project->isEmpty("QMAKE_STRIPFLAGS_LIB"))
|
|
|
|
ret += " " + var("QMAKE_STRIPFLAGS_LIB");
|
|
|
|
} else if (project->first("TEMPLATE") == "app") {
|
|
|
|
if (!project->isEmpty("QMAKE_STRIPFLAGS_APP"))
|
|
|
|
ret += " " + var("QMAKE_STRIPFLAGS_APP");
|
|
|
|
}
|
2015-02-06 14:30:02 +00:00
|
|
|
ret += ' ' + dst_targ;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
if(!uninst.isEmpty())
|
|
|
|
uninst.append("\n\t");
|
2013-07-11 13:43:32 +00:00
|
|
|
if (bundle == SolidBundle)
|
2015-02-06 14:30:02 +00:00
|
|
|
uninst.append("-$(DEL_FILE) -r " + plain_targ);
|
2015-05-05 17:01:14 +00:00
|
|
|
else if (!isAux)
|
2015-02-06 14:30:02 +00:00
|
|
|
uninst.append("-$(DEL_FILE) " + dst_targ);
|
2013-07-11 13:43:32 +00:00
|
|
|
if (bundle == SlicedBundle) {
|
|
|
|
int dstlen = project->first("DESTDIR").length();
|
|
|
|
foreach (const ProString &src, project->values("QMAKE_BUNDLED_FILES")) {
|
2015-02-06 14:30:02 +00:00
|
|
|
ProString file = src.mid(dstlen);
|
|
|
|
QString dst = escapeFilePath(
|
|
|
|
filePrefixRoot(root, fileFixify(targetdir + file, FileFixifyAbsolute)));
|
2013-07-11 13:43:32 +00:00
|
|
|
if (!ret.isEmpty())
|
|
|
|
ret += "\n\t";
|
2015-02-06 14:30:02 +00:00
|
|
|
ret += mkdir_p_asstring("\"`dirname " + dst + "`\"", false) + "\n\t";
|
|
|
|
ret += "-$(DEL_FILE) " + dst + "\n\t"; // Can't overwrite symlinks to directories
|
|
|
|
ret += "-$(INSTALL_DIR) " + escapeFilePath(src) + " " + dst; // Use cp -R to copy symlinks
|
2013-07-11 13:43:32 +00:00
|
|
|
if (!uninst.isEmpty())
|
|
|
|
uninst.append("\n\t");
|
2015-02-06 14:30:02 +00:00
|
|
|
uninst.append("-$(DEL_FILE) " + dst);
|
2013-07-11 13:43:32 +00:00
|
|
|
}
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!links.isEmpty()) {
|
|
|
|
for(int i = 0; i < links.size(); ++i) {
|
2013-03-06 13:53:36 +00:00
|
|
|
if (target_mode == TARG_UNIX_MODE || target_mode == TARG_MAC_MODE) {
|
2011-04-27 10:05:43 +00:00
|
|
|
QString link = Option::fixPathToTargetOS(destdir + links[i], false);
|
|
|
|
int lslash = link.lastIndexOf(Option::dir_sep);
|
|
|
|
if(lslash != -1)
|
|
|
|
link = link.right(link.length() - (lslash + 1));
|
2015-02-06 14:30:02 +00:00
|
|
|
QString dst_link = escapeFilePath(
|
|
|
|
filePrefixRoot(root, fileFixify(targetdir + link, FileFixifyAbsolute)));
|
|
|
|
ret += "\n\t-$(SYMLINK) $(TARGET) " + dst_link;
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!uninst.isEmpty())
|
|
|
|
uninst.append("\n\t");
|
2015-02-06 14:30:02 +00:00
|
|
|
uninst.append("-$(DEL_FILE) " + dst_link);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(project->first("TEMPLATE") == "lib") {
|
|
|
|
QStringList types;
|
|
|
|
types << "prl" << "libtool" << "pkgconfig";
|
|
|
|
for(int i = 0; i < types.size(); ++i) {
|
|
|
|
const QString type = types.at(i);
|
|
|
|
QString meta;
|
|
|
|
if(type == "prl" && project->isActiveConfig("create_prl") && !project->isActiveConfig("no_install_prl") &&
|
|
|
|
!project->isEmpty("QMAKE_INTERNAL_PRL_FILE"))
|
|
|
|
meta = prlFileName(false);
|
|
|
|
if(type == "libtool" && project->isActiveConfig("create_libtool") && !project->isActiveConfig("compile_libtool"))
|
|
|
|
meta = libtoolFileName(false);
|
|
|
|
if(type == "pkgconfig" && project->isActiveConfig("create_pc"))
|
|
|
|
meta = pkgConfigFileName(false);
|
|
|
|
if(!meta.isEmpty()) {
|
|
|
|
QString src_meta = meta;
|
|
|
|
if(!destdir.isEmpty())
|
|
|
|
src_meta = Option::fixPathToTargetOS(destdir + meta, false);
|
|
|
|
QString dst_meta = filePrefixRoot(root, fileFixify(targetdir + meta, FileFixifyAbsolute));
|
|
|
|
if(!uninst.isEmpty())
|
|
|
|
uninst.append("\n\t");
|
2015-02-06 14:30:02 +00:00
|
|
|
uninst.append("-$(DEL_FILE) " + escapeFilePath(dst_meta));
|
2011-04-27 10:05:43 +00:00
|
|
|
const QString dst_meta_dir = fileInfo(dst_meta).path();
|
|
|
|
if(!dst_meta_dir.isEmpty()) {
|
|
|
|
if(!ret.isEmpty())
|
|
|
|
ret += "\n\t";
|
|
|
|
ret += mkdir_p_asstring(dst_meta_dir, true);
|
|
|
|
}
|
2013-01-10 23:30:41 +00:00
|
|
|
if (!ret.isEmpty())
|
|
|
|
ret += "\n\t";
|
|
|
|
ret += installMetaFile(ProKey("QMAKE_" + type.toUpper() + "_INSTALL_REPLACE"), src_meta, dst_meta);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString
|
|
|
|
UnixMakefileGenerator::escapeFilePath(const QString &path) const
|
|
|
|
{
|
|
|
|
QString ret = path;
|
|
|
|
if(!ret.isEmpty()) {
|
2015-02-06 14:30:02 +00:00
|
|
|
ret.replace(QLatin1Char(' '), QLatin1String("\\ "))
|
|
|
|
.replace(QLatin1Char('\t'), QLatin1String("\\\t"));
|
2011-04-27 10:05:43 +00:00
|
|
|
debug_msg(2, "EscapeFilePath: %s -> %s", path.toLatin1().constData(), ret.toLatin1().constData());
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
QT_END_NAMESPACE
|