diff options
Diffstat (limited to 'qmake/generators/unix')
-rw-r--r-- | qmake/generators/unix/unixmake.cpp | 189 | ||||
-rw-r--r-- | qmake/generators/unix/unixmake.h | 17 | ||||
-rw-r--r-- | qmake/generators/unix/unixmake2.cpp | 384 |
3 files changed, 299 insertions, 291 deletions
diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp index e54ddf8ad7..efea807209 100644 --- a/qmake/generators/unix/unixmake.cpp +++ b/qmake/generators/unix/unixmake.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$ @@ -45,10 +45,6 @@ QT_BEGIN_NAMESPACE void UnixMakefileGenerator::init() { - if(init_flag) - return; - init_flag = true; - if(project->isEmpty("QMAKE_EXTENSION_SHLIB")) { if(project->isEmpty("QMAKE_CYGWIN_SHLIB")) { project->values("QMAKE_EXTENSION_SHLIB").append("so"); @@ -57,37 +53,14 @@ UnixMakefileGenerator::init() } } - if (project->isEmpty("QMAKE_PREFIX_SHLIB")) - // Prevent crash when using the empty variable. - project->values("QMAKE_PREFIX_SHLIB").append(""); - - if(!project->isEmpty("QMAKE_FAILED_REQUIREMENTS")) /* no point */ - return; - ProStringList &configs = project->values("CONFIG"); 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_COPY_FILE")) - project->values("QMAKE_COPY_FILE").append("$(COPY)"); - if(project->isEmpty("QMAKE_STREAM_EDITOR")) - project->values("QMAKE_STREAM_EDITOR").append("sed"); - if(project->isEmpty("QMAKE_COPY_DIR")) - project->values("QMAKE_COPY_DIR").append("$(COPY) -R"); - if(project->isEmpty("QMAKE_INSTALL_FILE")) - project->values("QMAKE_INSTALL_FILE").append("$(COPY_FILE)"); - if(project->isEmpty("QMAKE_INSTALL_DIR")) - project->values("QMAKE_INSTALL_DIR").append("$(COPY_DIR)"); - if(project->isEmpty("QMAKE_INSTALL_PROGRAM")) - project->values("QMAKE_INSTALL_PROGRAM").append("$(COPY_FILE)"); if(project->isEmpty("QMAKE_LIBTOOL")) project->values("QMAKE_LIBTOOL").append("libtool --silent"); - if(project->isEmpty("QMAKE_SYMBOLIC_LINK")) - project->values("QMAKE_SYMBOLIC_LINK").append("ln -f -s"); - if (!project->isEmpty("TARGET")) - project->values("TARGET") = escapeFilePaths(project->values("TARGET")); project->values("QMAKE_ORIG_TARGET") = project->values("TARGET"); //version handling @@ -122,8 +95,8 @@ UnixMakefileGenerator::init() } project->values("QMAKE_ORIG_DESTDIR") = project->values("DESTDIR"); - project->values("QMAKE_LIBS") += escapeFilePaths(project->values("LIBS")); - project->values("QMAKE_LIBS_PRIVATE") += escapeFilePaths(project->values("LIBS_PRIVATE")); + project->values("QMAKE_LIBS") += project->values("LIBS"); + project->values("QMAKE_LIBS_PRIVATE") += project->values("LIBS_PRIVATE"); if((!project->isEmpty("QMAKE_LIB_FLAG") && !project->isActiveConfig("staticlib")) || (project->isActiveConfig("qt") && project->isActiveConfig("plugin"))) { if(configs.indexOf("dll") == -1) configs.append("dll"); @@ -205,13 +178,13 @@ UnixMakefileGenerator::init() pchBaseName += project->first("QMAKE_ORIG_TARGET").toQString(); // replace place holders - pchFlags = pchFlags.replace("${QMAKE_PCH_INPUT}", - project->first("PRECOMPILED_HEADER").toQString()); - pchFlags = pchFlags.replace("${QMAKE_PCH_OUTPUT_BASE}", pchBaseName); + pchFlags.replace("${QMAKE_PCH_INPUT}", + escapeFilePath(project->first("PRECOMPILED_HEADER").toQString())); + pchFlags.replace("${QMAKE_PCH_OUTPUT_BASE}", escapeFilePath(pchBaseName)); if (project->isActiveConfig("icc_pch_style")) { // icc style - pchFlags = pchFlags.replace("${QMAKE_PCH_OUTPUT}", - pchBaseName + project->first("QMAKE_PCH_OUTPUT_EXT")); + pchFlags.replace("${QMAKE_PCH_OUTPUT}", + escapeFilePath(pchBaseName + project->first("QMAKE_PCH_OUTPUT_EXT"))); } else { // gcc style (including clang_pch_style) QString headerSuffix; @@ -235,8 +208,8 @@ UnixMakefileGenerator::init() } if(!pchOutputFile.isEmpty()) { - pchFlags = pchFlags.replace("${QMAKE_PCH_OUTPUT}", - pchBaseName + pchOutputFile + headerSuffix); + pchFlags.replace("${QMAKE_PCH_OUTPUT}", + escapeFilePath(pchBaseName + pchOutputFile + headerSuffix)); } } @@ -267,15 +240,15 @@ UnixMakefileGenerator::init() ((project->isActiveConfig("build_pass") || project->isEmpty("BUILDS")))) { ProString bundle; if(project->isActiveConfig("bundle") && !project->isEmpty("QMAKE_BUNDLE_EXTENSION")) { - bundle = unescapeFilePath(project->first("TARGET")); + bundle = project->first("TARGET"); if(!project->isEmpty("QMAKE_BUNDLE_NAME")) - bundle = unescapeFilePath(project->first("QMAKE_BUNDLE_NAME")); + bundle = project->first("QMAKE_BUNDLE_NAME"); if(!bundle.endsWith(project->first("QMAKE_BUNDLE_EXTENSION"))) bundle += project->first("QMAKE_BUNDLE_EXTENSION"); } else if(project->first("TEMPLATE") == "app" && project->isActiveConfig("app_bundle")) { - bundle = unescapeFilePath(project->first("TARGET")); + bundle = project->first("TARGET"); if(!project->isEmpty("QMAKE_APPLICATION_BUNDLE_NAME")) - bundle = unescapeFilePath(project->first("QMAKE_APPLICATION_BUNDLE_NAME")); + bundle = project->first("QMAKE_APPLICATION_BUNDLE_NAME"); if(!bundle.endsWith(".app")) bundle += ".app"; if(project->isEmpty("QMAKE_BUNDLE_LOCATION")) @@ -285,23 +258,23 @@ UnixMakefileGenerator::init() } else if(project->first("TEMPLATE") == "lib" && !project->isActiveConfig("staticlib") && ((!project->isActiveConfig("plugin") && project->isActiveConfig("lib_bundle")) || (project->isActiveConfig("plugin") && project->isActiveConfig("plugin_bundle")))) { - bundle = unescapeFilePath(project->first("TARGET")); + bundle = project->first("TARGET"); if(project->isActiveConfig("plugin")) { if(!project->isEmpty("QMAKE_PLUGIN_BUNDLE_NAME")) - bundle = unescapeFilePath(project->first("QMAKE_PLUGIN_BUNDLE_NAME")); - if(!project->isEmpty("QMAKE_BUNDLE_EXTENSION") && !bundle.endsWith(project->first("QMAKE_BUNDLE_EXTENSION"))) + bundle = project->first("QMAKE_PLUGIN_BUNDLE_NAME"); + if (project->isEmpty("QMAKE_BUNDLE_EXTENSION")) + project->values("QMAKE_BUNDLE_EXTENSION").append(".plugin"); + if (!bundle.endsWith(project->first("QMAKE_BUNDLE_EXTENSION"))) bundle += project->first("QMAKE_BUNDLE_EXTENSION"); - else if(!bundle.endsWith(".plugin")) - bundle += ".plugin"; if(project->isEmpty("QMAKE_BUNDLE_LOCATION")) project->values("QMAKE_BUNDLE_LOCATION").append("Contents/MacOS"); } else { if(!project->isEmpty("QMAKE_FRAMEWORK_BUNDLE_NAME")) - bundle = unescapeFilePath(project->first("QMAKE_FRAMEWORK_BUNDLE_NAME")); - if(!project->isEmpty("QMAKE_BUNDLE_EXTENSION") && !bundle.endsWith(project->first("QMAKE_BUNDLE_EXTENSION"))) + bundle = project->first("QMAKE_FRAMEWORK_BUNDLE_NAME"); + if (project->isEmpty("QMAKE_BUNDLE_EXTENSION")) + project->values("QMAKE_BUNDLE_EXTENSION").append(".framework"); + if (!bundle.endsWith(project->first("QMAKE_BUNDLE_EXTENSION"))) bundle += project->first("QMAKE_BUNDLE_EXTENSION"); - else if(!bundle.endsWith(".framework")) - bundle += ".framework"; } } if(!bundle.isEmpty()) { @@ -368,7 +341,7 @@ UnixMakefileGenerator::init() if(QDir::isRelativePath(rpath)) rpath.prepend(Option::output_dir + Option::dir_sep); } - comp_flags += " -rpath " + Option::fixPathToTargetOS(rpath, false); + comp_flags += " -rpath " + escapeFilePath(Option::fixPathToTargetOS(rpath, false)); } } } @@ -389,10 +362,7 @@ QStringList &UnixMakefileGenerator::findDependencies(const QString &file) { QStringList &ret = MakefileGenerator::findDependencies(file); - // Note: The QMAKE_IMAGE_COLLECTION file have all images - // as dependency, so don't add precompiled header then - if(doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER") - && file != project->first("QMAKE_IMAGE_COLLECTION")) { + if (doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER")) { QString header_prefix; if(!project->isEmpty("PRECOMPILED_DIR")) header_prefix = project->first("PRECOMPILED_DIR").toQString(); @@ -456,6 +426,12 @@ QStringList return ret; } +ProString +UnixMakefileGenerator::fixLibFlag(const ProString &lib) +{ + return escapeFilePath(lib); +} + bool UnixMakefileGenerator::findLibraries() { @@ -482,7 +458,7 @@ UnixMakefileGenerator::findLibraries() } libdirs.insert(libidx++, f); if (!libArg.isEmpty()) - *it = libArg + lib; + *it = libArg + f.real(); } else if(opt.startsWith("-l")) { if (project->isActiveConfig("rvct_linker") || project->isActiveConfig("armcc_linker")) { (*it) = "lib" + opt.mid(2) + ".so"; @@ -517,12 +493,12 @@ UnixMakefileGenerator::findLibraries() if(!extn.isNull()) extens << extn; else - extens << project->values("QMAKE_EXTENSION_SHLIB").first() << "a"; + extens << project->first("QMAKE_EXTENSION_SHLIB") << "a"; for (ProStringList::Iterator extit = extens.begin(); extit != extens.end(); ++extit) { if(dir.isNull()) { for(QList<QMakeLocalFileName>::Iterator dep_it = libdirs.begin(); dep_it != libdirs.end(); ++dep_it) { - QString pathToLib = ((*dep_it).local() + Option::dir_sep - + project->values("QMAKE_PREFIX_SHLIB").first() + QString pathToLib = ((*dep_it).local() + '/' + + project->first("QMAKE_PREFIX_SHLIB") + stub + "." + (*extit)); if(exists(pathToLib)) { (*it) = "-l" + stub; @@ -531,7 +507,7 @@ UnixMakefileGenerator::findLibraries() } } } else { - QString lib = dir + project->values("QMAKE_PREFIX_SHLIB").first() + stub + "." + (*extit); + QString lib = dir + project->first("QMAKE_PREFIX_SHLIB") + stub + "." + (*extit); if (exists(lib)) { (*it) = lib; found = true; @@ -541,8 +517,8 @@ UnixMakefileGenerator::findLibraries() } if(!found && project->isActiveConfig("compile_libtool")) { for(int dep_i = 0; dep_i < libdirs.size(); ++dep_i) { - if(exists(libdirs[dep_i].local() + Option::dir_sep + project->values("QMAKE_PREFIX_SHLIB").first() + stub + Option::libtool_ext)) { - (*it) = libdirs[dep_i].real() + Option::dir_sep + project->values("QMAKE_PREFIX_SHLIB").first() + stub + Option::libtool_ext; + if (exists(libdirs[dep_i].local() + '/' + project->first("QMAKE_PREFIX_SHLIB") + stub + Option::libtool_ext)) { + (*it) = libdirs[dep_i].real() + Option::dir_sep + project->first("QMAKE_PREFIX_SHLIB") + stub + Option::libtool_ext; found = true; break; } @@ -589,15 +565,15 @@ UnixMakefileGenerator::processPrlFiles() 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.. - QString la = lfn.local() + Option::dir_sep + project->values("QMAKE_PREFIX_SHLIB").first() + lib + Option::libtool_ext; - if(exists(la) && QFile::exists(lfn.local() + Option::dir_sep + ".libs")) { + QString la = lfn.local() + '/' + project->first("QMAKE_PREFIX_SHLIB") + lib + Option::libtool_ext; + if (exists(la) && QFile::exists(lfn.local() + "/.libs")) { QString dot_libs = lfn.real() + Option::dir_sep + ".libs"; l.append("-L" + dot_libs); libdirs.insert(libidx++, QMakeLocalFileName(dot_libs)); } } - QString prl = lfn.local() + Option::dir_sep + project->values("QMAKE_PREFIX_SHLIB").first() + lib + prl_ext; + QString prl = lfn.local() + '/' + project->first("QMAKE_PREFIX_SHLIB") + lib + prl_ext; if(processPrlFile(prl)) { if(prl.startsWith(lfn.local())) prl.replace(0, lfn.local().length(), lfn.real()); @@ -636,7 +612,7 @@ UnixMakefileGenerator::processPrlFiles() ProStringList &prl_libs = project->values("QMAKE_CURRENT_PRL_LIBS"); if(!prl_libs.isEmpty()) { for(int prl = 0; prl < prl_libs.size(); ++prl) - l.insert(lit+prl+1, escapeFilePath(prl_libs.at(prl).toQString())); + l.insert(lit+prl+1, prl_libs.at(prl).toQString()); prl_libs.clear(); } } @@ -726,10 +702,9 @@ UnixMakefileGenerator::defaultInstall(const QString &t) const QString root = "$(INSTALL_ROOT)"; ProStringList &uninst = project->values(ProKey(t + ".uninstall")); QString ret, destdir = project->first("DESTDIR").toQString(); - QString targetdir = Option::fixPathToTargetOS(project->first("target.path").toQString(), false); if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep) destdir += Option::dir_sep; - targetdir = fileFixify(targetdir, FileFixifyAbsolute); + QString targetdir = fileFixify(project->first("target.path").toQString(), FileFixifyAbsolute); if(targetdir.right(1) != Option::dir_sep) targetdir += Option::dir_sep; @@ -756,30 +731,31 @@ UnixMakefileGenerator::defaultInstall(const QString &t) } for(int i = 0; i < targets.size(); ++i) { QString src = targets.at(i).toQString(), - dst = filePrefixRoot(root, targetdir + src.section('/', -1)); + dst = escapeFilePath(filePrefixRoot(root, targetdir + src.section('/', -1))); if(!ret.isEmpty()) ret += "\n\t"; - ret += "-$(INSTALL_FILE) \"" + src + "\" \"" + dst + "\""; + ret += "-$(INSTALL_FILE) " + escapeFilePath(src) + ' ' + dst; if(!uninst.isEmpty()) uninst.append("\n\t"); - uninst.append("-$(DEL_FILE) \"" + dst + "\""); + uninst.append("-$(DEL_FILE) " + dst); } if (bundle == NoBundle && project->isActiveConfig("compile_libtool")) { - QString src_targ = target; + QString src_targ = escapeFilePath(target); 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); - ret = "-$(LIBTOOL) --mode=install cp \"" + src_targ + "\" \"" + filePrefixRoot(root, dst_dir) + "\""; - uninst.append("-$(LIBTOOL) --mode=uninstall \"" + src_targ + "\""); + ret = "-$(LIBTOOL) --mode=install cp " + src_targ + ' ' + escapeFilePath(filePrefixRoot(root, dst_dir)); + uninst.append("-$(LIBTOOL) --mode=uninstall " + src_targ); } else { QString src_targ = target; if(!destdir.isEmpty()) src_targ = Option::fixPathToTargetOS(destdir + target, false); QString plain_targ = filePrefixRoot(root, fileFixify(targetdir + target, FileFixifyAbsolute)); QString dst_targ = plain_targ; + plain_targ = escapeFilePath(plain_targ); if (bundle != NoBundle) { QString suffix; if (project->first("TEMPLATE") == "lib") @@ -790,33 +766,34 @@ UnixMakefileGenerator::defaultInstall(const QString &t) if (bundle == SolidBundle) { if (!ret.isEmpty()) ret += "\n\t"; - ret += "$(DEL_FILE) -r \"" + plain_targ + "\"\n\t"; + ret += "$(DEL_FILE) -r " + plain_targ + "\n\t"; } else { src_targ += suffix; } } + src_targ = escapeFilePath(src_targ); + dst_targ = escapeFilePath(dst_targ); if(!ret.isEmpty()) ret += "\n\t"; QString copy_cmd("-"); if (bundle == SolidBundle) { - copy_cmd += "$(INSTALL_DIR) \"" + src_targ + "\" \"" + plain_targ + "\""; + copy_cmd += "$(INSTALL_DIR) " + src_targ + ' ' + plain_targ; } else if (project->first("TEMPLATE") == "lib" && project->isActiveConfig("staticlib")) { - copy_cmd += "$(INSTALL_FILE) \"" + src_targ + "\" \"" + dst_targ + "\""; + copy_cmd += "$(INSTALL_FILE) " + src_targ + ' ' + dst_targ; } else { if (bundle == SlicedBundle) - ret += mkdir_p_asstring("\"`dirname \"" + dst_targ + "\"`\"", false) + "\n\t"; - copy_cmd += "$(INSTALL_PROGRAM) \"" + src_targ + "\" \"" + dst_targ + "\""; + ret += mkdir_p_asstring("\"`dirname " + dst_targ + "`\"", false) + "\n\t"; + copy_cmd += "$(INSTALL_PROGRAM) " + src_targ + ' ' + dst_targ; } if(project->first("TEMPLATE") == "lib" && !project->isActiveConfig("staticlib") && project->values(ProKey(t + ".CONFIG")).indexOf("fix_rpath") != -1) { if(!project->isEmpty("QMAKE_FIX_RPATH")) { ret += copy_cmd; - ret += "\n\t-" + var("QMAKE_FIX_RPATH") + " \"" + - dst_targ + "\" \"" + dst_targ + "\""; + ret += "\n\t-" + var("QMAKE_FIX_RPATH") + ' ' + dst_targ + ' ' + dst_targ; } else if(!project->isEmpty("QMAKE_LFLAGS_RPATH")) { - ret += "-$(LINK) $(LFLAGS) " + var("QMAKE_LFLAGS_RPATH") + targetdir + " -o \"" + - dst_targ + "\" $(OBJECTS) $(LIBS) $(OBJCOMP)"; + ret += "-$(LINK) $(LFLAGS) " + var("QMAKE_LFLAGS_RPATH") + targetdir + " -o " + + dst_targ + " $(OBJECTS) $(LIBS) $(OBJCOMP)"; } else { ret += copy_cmd; } @@ -826,7 +803,7 @@ UnixMakefileGenerator::defaultInstall(const QString &t) if(project->first("TEMPLATE") == "lib" && project->isActiveConfig("staticlib")) { if(!project->isEmpty("QMAKE_RANLIB")) - ret += QString("\n\t$(RANLIB) \"") + dst_targ + "\""; + ret += QString("\n\t$(RANLIB) ") + dst_targ; } else if (!project->isActiveConfig("debug_info") && !project->isActiveConfig("nostrip") && !project->isEmpty("QMAKE_STRIP")) { ret += "\n\t-$(STRIP)"; @@ -837,27 +814,28 @@ UnixMakefileGenerator::defaultInstall(const QString &t) if (!project->isEmpty("QMAKE_STRIPFLAGS_APP")) ret += " " + var("QMAKE_STRIPFLAGS_APP"); } - ret += " \"" + dst_targ + "\""; + ret += ' ' + dst_targ; } if(!uninst.isEmpty()) uninst.append("\n\t"); if (bundle == SolidBundle) - uninst.append("-$(DEL_FILE) -r \"" + plain_targ + "\""); + uninst.append("-$(DEL_FILE) -r " + plain_targ); else - uninst.append("-$(DEL_FILE) \"" + dst_targ + "\""); + uninst.append("-$(DEL_FILE) " + dst_targ); if (bundle == SlicedBundle) { int dstlen = project->first("DESTDIR").length(); foreach (const ProString &src, project->values("QMAKE_BUNDLED_FILES")) { - QString file = unescapeFilePath(src.toQString()).mid(dstlen); - QString dst = filePrefixRoot(root, fileFixify(targetdir + file, FileFixifyAbsolute)); + ProString file = src.mid(dstlen); + QString dst = escapeFilePath( + filePrefixRoot(root, fileFixify(targetdir + file, FileFixifyAbsolute))); if (!ret.isEmpty()) ret += "\n\t"; - ret += mkdir_p_asstring("\"`dirname \"" + dst + "\"`\"", false) + "\n\t"; - ret += "-$(DEL_FILE) \"" + dst + "\"\n\t"; // Can't overwrite symlinks to directories - ret += "-$(INSTALL_DIR) " + src + " \"" + dst + "\""; // Use cp -R to copy symlinks + 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 if (!uninst.isEmpty()) uninst.append("\n\t"); - uninst.append("-$(DEL_FILE) \"" + dst + "\""); + uninst.append("-$(DEL_FILE) " + dst); } } if(!links.isEmpty()) { @@ -867,11 +845,12 @@ UnixMakefileGenerator::defaultInstall(const QString &t) int lslash = link.lastIndexOf(Option::dir_sep); if(lslash != -1) link = link.right(link.length() - (lslash + 1)); - QString dst_link = filePrefixRoot(root, fileFixify(targetdir + link, FileFixifyAbsolute)); - ret += "\n\t-$(SYMLINK) \"$(TARGET)\" \"" + dst_link + "\""; + QString dst_link = escapeFilePath( + filePrefixRoot(root, fileFixify(targetdir + link, FileFixifyAbsolute))); + ret += "\n\t-$(SYMLINK) $(TARGET) " + dst_link; if(!uninst.isEmpty()) uninst.append("\n\t"); - uninst.append("-$(DEL_FILE) \"" + dst_link + "\""); + uninst.append("-$(DEL_FILE) " + dst_link); } } } @@ -896,7 +875,7 @@ UnixMakefileGenerator::defaultInstall(const QString &t) QString dst_meta = filePrefixRoot(root, fileFixify(targetdir + meta, FileFixifyAbsolute)); if(!uninst.isEmpty()) uninst.append("\n\t"); - uninst.append("-$(DEL_FILE) \"" + dst_meta + "\""); + uninst.append("-$(DEL_FILE) " + escapeFilePath(dst_meta)); const QString dst_meta_dir = fileInfo(dst_meta).path(); if(!dst_meta_dir.isEmpty()) { if(!ret.isEmpty()) @@ -917,8 +896,8 @@ UnixMakefileGenerator::escapeFilePath(const QString &path) const { QString ret = path; if(!ret.isEmpty()) { - ret = unescapeFilePath(ret).replace(QLatin1Char(' '), QLatin1String("\\ ")) - .replace(QLatin1Char('\t'), QLatin1String("\\\t")); + ret.replace(QLatin1Char(' '), QLatin1String("\\ ")) + .replace(QLatin1Char('\t'), QLatin1String("\\\t")); debug_msg(2, "EscapeFilePath: %s -> %s", path.toLatin1().constData(), ret.toLatin1().constData()); } return ret; diff --git a/qmake/generators/unix/unixmake.h b/qmake/generators/unix/unixmake.h index e90933649a..b136ea04d0 100644 --- a/qmake/generators/unix/unixmake.h +++ b/qmake/generators/unix/unixmake.h @@ -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$ @@ -40,7 +40,7 @@ QT_BEGIN_NAMESPACE class UnixMakefileGenerator : public MakefileGenerator { - bool init_flag, include_deps; + bool include_deps; QString libtoolFileName(bool fixify=true); void writeLibtoolFile(); // for libtool void writePrlFile(QTextStream &); @@ -53,6 +53,7 @@ protected: virtual bool doPrecompiledHeaders() const { return project->isActiveConfig("precompile_header"); } virtual bool doDepends() const { return !Option::mkfile::do_stub_makefile && MakefileGenerator::doDepends(); } virtual QString defaultInstall(const QString &); + virtual ProString fixLibFlag(const ProString &lib); virtual void processPrlFiles(); virtual bool findLibraries(); diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp index f3a24a8681..7822107a37 100644 --- a/qmake/generators/unix/unixmake2.cpp +++ b/qmake/generators/unix/unixmake2.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$ @@ -38,13 +38,12 @@ #include <qbytearray.h> #include <qfile.h> #include <qdir.h> -#include <qdatetime.h> #include <qdebug.h> #include <time.h> QT_BEGIN_NAMESPACE -UnixMakefileGenerator::UnixMakefileGenerator() : MakefileGenerator(), init_flag(false), include_deps(false) +UnixMakefileGenerator::UnixMakefileGenerator() : MakefileGenerator(), include_deps(false) { } @@ -75,14 +74,14 @@ UnixMakefileGenerator::writeMakefile(QTextStream &t) if (writeDummyMakefile(t)) return true; - if (project->values("TEMPLATE").first() == "app" || - project->values("TEMPLATE").first() == "lib" || - project->values("TEMPLATE").first() == "aux") { + if (project->first("TEMPLATE") == "app" || + project->first("TEMPLATE") == "lib" || + project->first("TEMPLATE") == "aux") { if(Option::mkfile::do_stub_makefile && MakefileGenerator::writeStubMakefile(t)) return true; writeMakeParts(t); return MakefileGenerator::writeMakefile(t); - } else if(project->values("TEMPLATE").first() == "subdirs") { + } else if (project->first("TEMPLATE") == "subdirs") { MakefileGenerator::writeSubDirs(t); return true; } @@ -102,7 +101,7 @@ UnixMakefileGenerator::writeDefaultVariables(QTextStream &t) distname += project->first("VERSION"); project->values("QMAKE_DISTNAME") = distname; } - t << "DISTNAME = " << var("QMAKE_DISTNAME") << endl; + t << "DISTNAME = " << fileVar("QMAKE_DISTNAME") << endl; if (project->isEmpty("QMAKE_DISTDIR")) project->values("QMAKE_DISTDIR") = project->first("QMAKE_DISTNAME"); @@ -128,7 +127,7 @@ UnixMakefileGenerator::writeSubTargets(QTextStream &t, QList<MakefileGenerator:: } t << " FORCE\n\t" << mkdir_p_asstring("$(DISTDIR)", false) << "\n\t" - << "$(COPY_FILE) --parents " << var("DISTFILES") << " $(DISTDIR)" << Option::dir_sep << endl << endl; + << "$(COPY_FILE) --parents " << fileVar("DISTFILES") << " $(DISTDIR)" << Option::dir_sep << endl << endl; const QString abs_source_path = project->first("QMAKE_ABSOLUTE_SOURCE_PATH").toQString(); for (int target = 0; target < targets.size(); ++target) { @@ -149,8 +148,9 @@ UnixMakefileGenerator::writeSubTargets(QTextStream &t, QList<MakefileGenerator:: dist_directory.prepend(Option::dir_sep); QString out_directory_cdin = out_directory.isEmpty() ? "\n\t" - : "\n\tcd " + out_directory + " && "; - QString makefilein = " -e -f " + subtarget->makefile + " distdir DISTDIR=$(DISTDIR)" + dist_directory; + : "\n\tcd " + escapeFilePath(out_directory) + " && "; + QString makefilein = " -e -f " + escapeFilePath(subtarget->makefile) + + " distdir DISTDIR=$(DISTDIR)" + escapeFilePath(dist_directory); QString out = subtarget->makefile; QString in = escapeFilePath(fileFixify(in_directory + subtarget->profile, FileFixifyAbsolute)); @@ -158,7 +158,7 @@ UnixMakefileGenerator::writeSubTargets(QTextStream &t, QList<MakefileGenerator:: out.remove(0, in_directory.length()); t << subtarget->target << "-distdir: FORCE"; - writeSubTargetCall(t, in_directory, in, out_directory, out, + writeSubTargetCall(t, in_directory, in, out_directory, escapeFilePath(out), out_directory_cdin, makefilein); t << endl; } @@ -167,7 +167,6 @@ UnixMakefileGenerator::writeSubTargets(QTextStream &t, QList<MakefileGenerator:: void UnixMakefileGenerator::writeMakeParts(QTextStream &t) { - QString deps = fileFixify(Option::output.fileName()), target_deps, prl; bool do_incremental = (project->isActiveConfig("incremental") && !project->values("QMAKE_INCREMENTAL").isEmpty() && (!project->values("QMAKE_APP_FLAG").isEmpty() || @@ -189,14 +188,15 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) QString isystem = var("QMAKE_CFLAGS_ISYSTEM"); const ProStringList &incs = project->values("INCLUDEPATH"); for(int i = 0; i < incs.size(); ++i) { - ProString inc = escapeFilePath(incs.at(i)); + const ProString &inc = incs.at(i); if (inc.isEmpty()) continue; if (!isystem.isEmpty() && isSystemInclude(inc.toQString())) - t << ' ' << isystem << ' ' << inc; + t << ' ' << isystem << ' '; else - t << " -I" << inc; + t << " -I"; + t << escapeFilePath(inc); } } if(!project->isEmpty("QMAKE_FRAMEWORKPATH_FLAGS")) @@ -208,7 +208,8 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) if(!project->isActiveConfig("staticlib")) { t << "LINK = " << var("QMAKE_LINK") << endl; t << "LFLAGS = " << var("QMAKE_LFLAGS") << endl; - t << "LIBS = $(SUBLIBS) " << var("QMAKE_LIBS") << " " << var("QMAKE_LIBS_PRIVATE") << endl; + t << "LIBS = $(SUBLIBS) " << fixLibFlags("QMAKE_LIBS").join(' ') << ' ' + << fixLibFlags("QMAKE_LIBS_PRIVATE").join(' ') << endl; } t << "AR = " << var("QMAKE_AR") << endl; @@ -221,16 +222,17 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) t << endl; t << "####### Output directory\n\n"; + // This is used in commands by some .prf files. if (! project->values("OBJECTS_DIR").isEmpty()) - t << "OBJECTS_DIR = " << var("OBJECTS_DIR") << endl; + t << "OBJECTS_DIR = " << fileVar("OBJECTS_DIR") << endl; else t << "OBJECTS_DIR = ./\n"; t << endl; /* files */ t << "####### Files\n\n"; - t << "SOURCES = " << valList(escapeFilePaths(project->values("SOURCES"))) << " " - << valList(escapeFilePaths(project->values("GENERATED_SOURCES"))) << endl; + // This is used by the dist target. + t << "SOURCES = " << fileVarList("SOURCES") << ' ' << fileVarList("GENERATED_SOURCES") << endl; if(do_incremental) { const ProStringList &objs = project->values("OBJECTS"); const ProStringList &incrs = project->values("QMAKE_INCREMENTAL"); @@ -259,37 +261,37 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) t << "INCREMENTAL_OBJECTS = " << escapeFilePaths(incrs_out).join(" \\\n\t\t") << endl; } } else { - t << "OBJECTS = " << valList(escapeFilePaths(project->values("OBJECTS"))) << endl; + // Used all over the place in both deps and commands. + t << "OBJECTS = " << valList(escapeDependencyPaths(project->values("OBJECTS"))) << endl; } if(do_incremental && !src_incremental) do_incremental = false; t << "DIST = " << valList(fileFixify(project->values("DISTFILES").toQStringList())) << " " - << valList(escapeFilePaths(project->values("HEADERS"))) << " " - << valList(escapeFilePaths(project->values("SOURCES"))) << endl; - t << "QMAKE_TARGET = " << var("QMAKE_ORIG_TARGET") << endl; + << fileVarList("HEADERS") << ' ' << fileVarList("SOURCES") << endl; + t << "QMAKE_TARGET = " << fileVar("QMAKE_ORIG_TARGET") << endl; // The comment is important for mingw32-make.exe on Windows as otherwise trailing slashes // would be interpreted as line continuation. The lack of spacing between the value and the // comment is also important as otherwise quoted use of "$(DESTDIR)" would include this // spacing. - t << "DESTDIR = " << var("DESTDIR") << "#avoid trailing-slash linebreak\n"; + t << "DESTDIR = " << fileVar("DESTDIR") << "#avoid trailing-slash linebreak\n"; if(project->isActiveConfig("compile_libtool")) - t << "TARGETL = " << var("TARGET_la") << endl; - t << "TARGET = " << escapeFilePath(var("TARGET")) << endl; + t << "TARGETL = " << fileVar("TARGET_la") << endl; + t << "TARGET = " << fileVar("TARGET") << endl; // ### mixed use! if(project->isActiveConfig("plugin")) { - t << "TARGETD = " << escapeFilePath(var("TARGET")) << endl; + t << "TARGETD = " << fileVar("TARGET") << endl; } else if(!project->isActiveConfig("staticlib") && project->values("QMAKE_APP_FLAG").isEmpty()) { - t << "TARGETA = " << escapeFilePath(var("TARGETA")) << endl; + t << "TARGETA = " << fileVar("TARGETA") << endl; // ### mixed use! if(!project->isEmpty("QMAKE_BUNDLE")) { - t << "TARGETD = " << escapeFilePath(var("TARGET_x.y")) << endl; - t << "TARGET0 = " << escapeFilePath(var("TARGET_")) << endl; + t << "TARGETD = " << fileVar("TARGET_x.y") << endl; + t << "TARGET0 = " << fileVar("TARGET_") << endl; } else if (!project->isActiveConfig("unversioned_libname")) { - t << "TARGET0 = " << escapeFilePath(var("TARGET_")) << endl; + t << "TARGET0 = " << fileVar("TARGET_") << endl; if (project->isEmpty("QMAKE_HPUX_SHLIB")) { - t << "TARGETD = " << escapeFilePath(var("TARGET_x.y.z")) << endl; - t << "TARGET1 = " << escapeFilePath(var("TARGET_x")) << endl; - t << "TARGET2 = " << escapeFilePath(var("TARGET_x.y")) << endl; + t << "TARGETD = " << fileVar("TARGET_x.y.z") << endl; + t << "TARGET1 = " << fileVar("TARGET_x") << endl; + t << "TARGET2 = " << fileVar("TARGET_x.y") << endl; } else { - t << "TARGETD = " << escapeFilePath(var("TARGET_x")) << endl; + t << "TARGETD = " << fileVar("TARGET_x") << endl; } } } @@ -301,7 +303,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) const ProStringList &qeui = project->values("QMAKE_EXTRA_INCLUDES"); ProStringList::ConstIterator it; for(it = qeui.begin(); it != qeui.end(); ++it) - t << "include " << (*it) << endl; + t << "include " << escapeDependencyPath(*it) << endl; /* rules */ t << "first: all\n"; @@ -322,29 +324,30 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) ProStringList objects = project->values("OBJECTS"); for (ProStringList::Iterator it = objects.begin(); it != objects.end(); ++it) { QString d_file = (*it).toQString().replace(QRegExp(Option::obj_ext + "$"), ".d"); - t << "-include " << d_file << endl; + t << "-include " << escapeDependencyPath(d_file) << endl; project->values("QMAKE_DISTCLEAN") << d_file; } } else { QString cmd=var("QMAKE_CFLAGS_DEPS") + " "; cmd += varGlue("DEFINES","-D"," -D","") + varGlue("PRL_EXPORT_DEFINES"," -D"," -D",""); if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) - cmd += " -I" + project->first("QMAKE_ABSOLUTE_SOURCE_PATH") + " "; - cmd += " $(INCPATH) " + varGlue("DEPENDPATH", "-I", " -I", ""); + cmd += " -I" + fileVar("QMAKE_ABSOLUTE_SOURCE_PATH") + ' '; + cmd += " $(INCPATH) " + fileVarGlue("DEPENDPATH", "-I", " -I", ""); ProString odir; if(!project->values("OBJECTS_DIR").isEmpty()) odir = project->first("OBJECTS_DIR"); + QString odird = escapeDependencyPath(odir.toQString()); QString pwd = escapeFilePath(fileFixify(qmake_getpwd())); t << "###### Dependencies\n\n"; - t << odir << ".deps/%.d: " << pwd << "/%.cpp\n\t"; + t << odird << ".deps/%.d: " << pwd << "/%.cpp\n\t"; if(project->isActiveConfig("echo_depend_creation")) t << "@echo Creating depend for $<\n\t"; t << mkdir_p_asstring("$(@D)", false) << "\n\t" << "@$(CXX) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@\n\n"; - t << odir << ".deps/%.d: " << pwd << "/%.c\n\t"; + t << odird << ".deps/%.d: " << pwd << "/%.c\n\t"; if(project->isActiveConfig("echo_depend_creation")) t << "@echo Creating depend for $<\n\t"; t << mkdir_p_asstring("$(@D)", false) << "\n\t" @@ -375,11 +378,12 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) if(!d_file.isEmpty()) { d_file = odir + ".deps/" + fileFixify(d_file, pwd, Option::output_dir) + ".d"; + QString d_file_d = escapeDependencyPath(d_file); QStringList deps = findDependencies((*it).toQString()).filter(QRegExp( "((^|/)" + Option::h_moc_mod + "|" + Option::cpp_moc_ext + "$)")); if(!deps.isEmpty()) - t << d_file << ": " << deps.join(' ') << endl; - t << "-include " << d_file << endl; + t << d_file_d << ": " << escapeDependencyPaths(deps).join(' ') << endl; + t << "-include " << d_file_d << endl; project->values("QMAKE_DISTCLEAN") += d_file; } } @@ -396,10 +400,11 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) t << "SUBLIBS = "; const ProStringList &l = project->values("SUBLIBS"); for (ProStringList::ConstIterator it = l.begin(); it != l.end(); ++it) - t << libdir << project->first("QMAKE_PREFIX_STATICLIB") << (*it) << "." - << project->first("QMAKE_EXTENSION_STATICLIB") << " "; + t << escapeFilePath(libdir + project->first("QMAKE_PREFIX_STATICLIB") + (*it) + '.' + + project->first("QMAKE_EXTENSION_STATICLIB")) << ' '; t << endl << endl; } + QString target_deps; if ((project->isActiveConfig("depend_prl") || project->isActiveConfig("fast_depend_prl")) && !project->isEmpty("QMAKE_PRL_INTERNAL_FILES")) { const ProStringList &l = project->values("QMAKE_PRL_INTERNAL_FILES"); @@ -412,18 +417,20 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) if(slsh != -1) dir = (*it).left(slsh + 1); QString targ = dir + libinfo.first("QMAKE_PRL_TARGET"); - target_deps += " " + targ; - t << targ; + QString targ_d = escapeDependencyPath(targ); + target_deps += ' ' + targ_d; + t << targ_d; if (project->isActiveConfig("fast_depend_prl")) t << ":\n\t@echo \"Creating '"; else t << ": FORCE\n\t@echo \"Creating/updating '"; t << targ << "'\"\n\t" - << "(cd " << libinfo.first("QMAKE_PRL_BUILD_DIR") << ";" + << "(cd " << escapeFilePath(libinfo.first("QMAKE_PRL_BUILD_DIR")) << ';' << "$(MAKE))\n"; } } } + QString deps = escapeDependencyPath(fileFixify(Option::output.fileName())); QString allDeps; if (!project->values("QMAKE_APP_FLAG").isEmpty() || project->first("TEMPLATE") == "aux") { QString destdir = project->first("DESTDIR").toQString(); @@ -444,19 +451,23 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) QString incr_deps, incr_objs; if(project->first("QMAKE_INCREMENTAL_STYLE") == "ld") { QString incr_target_dir = var("OBJECTS_DIR") + incr_target + Option::obj_ext; + QString incr_target_dir_d = escapeDependencyPath(incr_target_dir); + QString incr_target_dir_f = escapeFilePath(incr_target_dir); //actual target - t << incr_target_dir << ": $(OBJECTS)\n\t" - << "ld -r -o "<< incr_target_dir << " $(OBJECTS)\n"; + t << incr_target_dir_d << ": $(OBJECTS)\n\t" + << "ld -r -o " << incr_target_dir_f << " $(OBJECTS)\n"; //communicated below - deps.prepend(incr_target_dir + " "); + deps.prepend(incr_target_dir_d + ' '); incr_deps = "$(INCREMENTAL_OBJECTS)"; if(!incr_objs.isEmpty()) incr_objs += " "; - incr_objs += incr_target_dir; + incr_objs += incr_target_dir_f; } else { //actual target QString incr_target_dir = var("DESTDIR") + "lib" + incr_target + "." + - project->values("QMAKE_EXTENSION_SHLIB").first(); + project->first("QMAKE_EXTENSION_SHLIB"); + QString incr_target_dir_d = escapeDependencyPath(incr_target_dir); + QString incr_target_dir_f = escapeFilePath(incr_target_dir); QString incr_lflags = var("QMAKE_LFLAGS_SHLIB") + " "; if(project->isActiveConfig("debug")) incr_lflags += var("QMAKE_LFLAGS_DEBUG"); @@ -464,31 +475,31 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) incr_lflags += var("QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO"); else incr_lflags += var("QMAKE_LFLAGS_RELEASE"); - t << incr_target_dir << ": $(INCREMENTAL_OBJECTS)\n\t"; + t << incr_target_dir_d << ": $(INCREMENTAL_OBJECTS)\n\t"; if(!destdir.isEmpty()) t << "\n\t" << mkdir_p_asstring(destdir) << "\n\t"; - t << "$(LINK) " << incr_lflags << " -o "<< incr_target_dir << + t << "$(LINK) " << incr_lflags << " -o "<< incr_target_dir_f << " $(INCREMENTAL_OBJECTS)\n"; //communicated below if(!destdir.isEmpty()) { if(!incr_objs.isEmpty()) incr_objs += " "; - incr_objs += "-L" + destdir; + incr_objs += "-L" + escapeFilePath(destdir); } else { if(!incr_objs.isEmpty()) incr_objs += " "; - incr_objs += "-L" + qmake_getpwd(); + incr_objs += "-L" + escapeFilePath(qmake_getpwd()); } if(!incr_objs.isEmpty()) incr_objs += " "; - incr_objs += " -l" + incr_target; - deps.prepend(incr_target_dir + " "); + incr_objs += " -l" + escapeFilePath(incr_target); + deps.prepend(incr_target_dir_d + ' '); incr_deps = "$(OBJECTS)"; } //real target - t << var("TARGET") << ": " << var("PRE_TARGETDEPS") << " " << incr_deps << " " << target_deps - << " " << var("POST_TARGETDEPS") << "\n\t"; + t << var("TARGET") << ": " << depVar("PRE_TARGETDEPS") << ' ' << incr_deps << ' ' << target_deps + << ' ' << depVar("POST_TARGETDEPS") << "\n\t"; if(!destdir.isEmpty()) t << "\n\t" << mkdir_p_asstring(destdir) << "\n\t"; if(!project->isEmpty("QMAKE_PRE_LINK")) @@ -498,8 +509,8 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) t << "\n\t" << var("QMAKE_POST_LINK"); t << endl << endl; } else { - t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(OBJECTS) " - << target_deps << " " << var("POST_TARGETDEPS") << "\n\t"; + t << "$(TARGET): " << depVar("PRE_TARGETDEPS") << " $(OBJECTS) " + << target_deps << ' ' << depVar("POST_TARGETDEPS") << "\n\t"; if (project->first("TEMPLATE") != "aux") { if (!destdir.isEmpty()) t << mkdir_p_asstring(destdir) << "\n\t"; @@ -513,16 +524,17 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) } allDeps = " $(TARGET)"; } else if(!project->isActiveConfig("staticlib")) { - QString destdir = unescapeFilePath(project->first("DESTDIR").toQString()), incr_deps; + QString destdir_r = project->first("DESTDIR").toQString(), incr_deps; if(!project->isEmpty("QMAKE_BUNDLE")) { QString bundle_loc = project->first("QMAKE_BUNDLE_LOCATION").toQString(); if(!bundle_loc.isEmpty() && !bundle_loc.startsWith("/")) bundle_loc.prepend("/"); if(!bundle_loc.endsWith("/")) bundle_loc += "/"; - destdir += project->first("QMAKE_BUNDLE") + bundle_loc; + destdir_r += project->first("QMAKE_BUNDLE") + bundle_loc; } - destdir = escapeFilePath(destdir); + QString destdir_d = escapeDependencyPath(destdir_r); + QString destdir = escapeFilePath(destdir_r); if(do_incremental) { ProString s_ext = project->first("QMAKE_EXTENSION_SHLIB"); @@ -531,23 +543,26 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) if(incr_target.indexOf(Option::dir_sep) != -1) incr_target = incr_target.right(incr_target.length() - (incr_target.lastIndexOf(Option::dir_sep) + 1)); - incr_target = escapeFilePath(incr_target); if(project->first("QMAKE_INCREMENTAL_STYLE") == "ld") { - QString incr_target_dir = escapeFilePath(var("OBJECTS_DIR") + incr_target + Option::obj_ext); + QString incr_target_dir = var("OBJECTS_DIR") + incr_target + Option::obj_ext; + QString incr_target_dir_d = escapeDependencyPath(incr_target_dir); + QString incr_target_dir_f = escapeFilePath(incr_target_dir); //actual target const QString link_deps = "$(OBJECTS) "; - t << incr_target_dir << ": " << link_deps << "\n\t" - << "ld -r -o " << incr_target_dir << " " << link_deps << endl; + t << incr_target_dir_d << ": " << link_deps << "\n\t" + << "ld -r -o " << incr_target_dir_f << ' ' << link_deps << endl; //communicated below ProStringList &cmd = project->values("QMAKE_LINK_SHLIB_CMD"); cmd[0] = cmd.at(0).toQString().replace("$(OBJECTS) ", "$(INCREMENTAL_OBJECTS)"); //ick - cmd.append(incr_target_dir); - deps.prepend(incr_target_dir + " "); + cmd.append(incr_target_dir_f); + deps.prepend(incr_target_dir_d + ' '); incr_deps = "$(INCREMENTAL_OBJECTS)"; } else { //actual target - QString incr_target_dir = escapeFilePath(destdir + "lib" + incr_target + "." + s_ext); + QString incr_target_dir = destdir_r + "lib" + incr_target + '.' + s_ext; + QString incr_target_dir_d = escapeDependencyPath(incr_target_dir); + QString incr_target_dir_f = escapeFilePath(incr_target_dir); QString incr_lflags = var("QMAKE_LFLAGS_SHLIB") + " "; if(!project->isEmpty("QMAKE_LFLAGS_INCREMENTAL")) incr_lflags += var("QMAKE_LFLAGS_INCREMENTAL") + " "; @@ -557,29 +572,29 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) incr_lflags += var("QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO"); else incr_lflags += var("QMAKE_LFLAGS_RELEASE"); - t << incr_target_dir << ": $(INCREMENTAL_OBJECTS)\n\t"; + t << incr_target_dir_d << ": $(INCREMENTAL_OBJECTS)\n\t"; if(!destdir.isEmpty()) t << mkdir_p_asstring(destdir, false) << "\n\t"; - t << "$(LINK) " << incr_lflags << " " << var("QMAKE_LINK_O_FLAG") << incr_target_dir << + t << "$(LINK) " << incr_lflags << ' ' << var("QMAKE_LINK_O_FLAG") << incr_target_dir_f << " $(INCREMENTAL_OBJECTS)\n"; //communicated below ProStringList &cmd = project->values("QMAKE_LINK_SHLIB_CMD"); if(!destdir.isEmpty()) cmd.append(" -L" + destdir); - cmd.append(" -l" + incr_target); - deps.prepend(incr_target_dir + " "); + cmd.append(" -l" + escapeFilePath(incr_target)); + deps.prepend(incr_target_dir_d + ' '); incr_deps = "$(OBJECTS)"; } //real target - t << destdir << "$(TARGET): " << var("PRE_TARGETDEPS") << " " - << incr_deps << " $(SUBLIBS) " << target_deps << " " << var("POST_TARGETDEPS"); + t << destdir_d << "$(TARGET): " << depVar("PRE_TARGETDEPS") << ' ' + << incr_deps << " $(SUBLIBS) " << target_deps << ' ' << depVar("POST_TARGETDEPS"); } else { - t << destdir << "$(TARGET): " << var("PRE_TARGETDEPS") + t << destdir_d << "$(TARGET): " << depVar("PRE_TARGETDEPS") << " $(OBJECTS) $(SUBLIBS) $(OBJCOMP) " << target_deps - << " " << var("POST_TARGETDEPS"); + << ' ' << depVar("POST_TARGETDEPS"); } - allDeps = ' ' + destdir + "$(TARGET)"; + allDeps = ' ' + destdir_d + "$(TARGET)"; if(!destdir.isEmpty()) t << "\n\t" << mkdir_p_asstring(destdir, false); if(!project->isEmpty("QMAKE_PRE_LINK")) @@ -599,8 +614,9 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) t << "\n\t" << var("QMAKE_POST_LINK"); t << endl << endl; } else if(!project->isEmpty("QMAKE_BUNDLE")) { - QString currentLink = destdir + "Versions/Current"; - bundledFiles << currentLink << destdir + "$(TARGET)"; + QString currentLink = destdir_r + "Versions/Current"; + QString currentLink_f = escapeDependencyPath(currentLink); + bundledFiles << currentLink << destdir_r + "$(TARGET)"; t << "\n\t" << "-$(DEL_FILE) $(TARGET) $(TARGET0) $(DESTDIR)$(TARGET0)\n\t" << var("QMAKE_LINK_SHLIB_CMD") << "\n\t" @@ -609,9 +625,9 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) << mkdir_p_asstring("\"`dirname $(DESTDIR)$(TARGET0)`\"", false) << "\n\t" << varGlue("QMAKE_LN_SHLIB", "-", " ", " Versions/Current/$(TARGET) $(DESTDIR)$(TARGET0)") << "\n\t" - << "-$(DEL_FILE) " << currentLink << "\n\t" + << "-$(DEL_FILE) " << currentLink_f << "\n\t" << varGlue("QMAKE_LN_SHLIB","-"," ", " " + project->first("QMAKE_FRAMEWORK_VERSION") + - " " + currentLink) << "\n\t"; + ' ' + currentLink_f) << "\n\t"; if(!project->isEmpty("QMAKE_POST_LINK")) t << "\n\t" << var("QMAKE_POST_LINK"); t << endl << endl; @@ -668,10 +684,10 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) if (! project->isActiveConfig("plugin")) { t << "staticlib: $(TARGETA)\n\n"; - t << "$(TARGETA): " << var("PRE_TARGETDEPS") << " $(OBJECTS) $(OBJCOMP)"; + t << "$(TARGETA): " << depVar("PRE_TARGETDEPS") << " $(OBJECTS) $(OBJCOMP)"; if(do_incremental) t << " $(INCREMENTAL_OBJECTS)"; - t << " " << var("POST_TARGETDEPS") << "\n\t" + t << ' ' << depVar("POST_TARGETDEPS") << "\n\t" << "-$(DEL_FILE) $(TARGETA) \n\t" << var("QMAKE_AR_CMD"); if(do_incremental) @@ -681,15 +697,17 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) t << endl << endl; } } else { - QString destdir = project->first("DESTDIR").toQString(); - allDeps = ' ' + destdir + "$(TARGET)" - + varGlue("QMAKE_AR_SUBLIBS", ' ' + destdir, ' ' + destdir, ""); - t << "staticlib: " << destdir << "$(TARGET)\n\n"; + QString destdir_r = project->first("DESTDIR").toQString(); + QString destdir_d = escapeDependencyPath(destdir_r); + QString destdir = escapeFilePath(destdir_r); + allDeps = ' ' + destdir_d + "$(TARGET)" + + varGlue("QMAKE_AR_SUBLIBS", ' ' + destdir_d, ' ' + destdir_d, ""); + t << "staticlib: " << destdir_d << "$(TARGET)\n\n"; if(project->isEmpty("QMAKE_AR_SUBLIBS")) { - t << destdir << "$(TARGET): " << var("PRE_TARGETDEPS") - << " $(OBJECTS) $(OBJCOMP) " << var("POST_TARGETDEPS") << "\n\t"; + t << destdir_d << "$(TARGET): " << depVar("PRE_TARGETDEPS") + << " $(OBJECTS) $(OBJCOMP) " << depVar("POST_TARGETDEPS") << "\n\t"; if(!destdir.isEmpty()) - t << mkdir_p_asstring(destdir) << "\n\t"; + t << mkdir_p_asstring(destdir, false) << "\n\t"; t << "-$(DEL_FILE) $(TARGET)\n\t" << var("QMAKE_AR_CMD") << "\n"; if(!project->isEmpty("QMAKE_POST_LINK")) @@ -710,26 +728,27 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) for(int cnt = 0; cnt < max_files && objit != objs.end(); ++objit, cnt++) build << (*objit); QString ar; + ProString lib = escapeFilePath(*libit); if((*libit) == "$(TARGET)") { - t << destdir << "$(TARGET): " << var("PRE_TARGETDEPS") - << " " << var("POST_TARGETDEPS") << valList(build) << "\n\t"; + t << destdir_d << "$(TARGET): " << depVar("PRE_TARGETDEPS") + << ' ' << depVar("POST_TARGETDEPS") << valList(escapeDependencyPaths(build)) << "\n\t"; ar = project->first("QMAKE_AR_CMD").toQString(); - ar = ar.replace("$(OBJECTS)", build.join(' ')); + ar.replace("$(OBJECTS)", escapeFilePaths(build).join(' ')); } else { - t << (*libit) << ": " << valList(build) << "\n\t"; - ar = "$(AR) " + (*libit) + " " + build.join(' '); + t << escapeDependencyPath(*libit) << ": " << valList(escapeDependencyPaths(build)) << "\n\t"; + ar = "$(AR) " + lib + ' ' + escapeFilePaths(build).join(' '); } if(!destdir.isEmpty()) - t << mkdir_p_asstring(destdir) << "\n\t"; - t << "-$(DEL_FILE) " << (*libit) << "\n\t" + t << mkdir_p_asstring(destdir, false) << "\n\t"; + t << "-$(DEL_FILE) " << lib << "\n\t" << ar << "\n"; if(!project->isEmpty("QMAKE_POST_LINK")) t << "\t" << var("QMAKE_POST_LINK") << "\n"; if(!project->isEmpty("QMAKE_RANLIB")) - t << "\t$(RANLIB) " << (*libit) << "\n"; + t << "\t$(RANLIB) " << lib << "\n"; if(!destdir.isEmpty()) - t << "\t-$(DEL_FILE) " << destdir << (*libit) << "\n" - << "\t-$(MOVE) " << (*libit) << " " << destdir << " \n"; + t << "\t-$(DEL_FILE) " << destdir << lib << "\n" + << "\t-$(MOVE) " << lib << ' ' << destdir << " \n"; } } t << endl << endl; @@ -747,7 +766,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) } if(!meta_files.isEmpty()) t << escapeDependencyPaths(meta_files).join(" ") << ": \n\t" - << "@$(QMAKE) -prl " << buildArgs() << " " << project->projectFile() << endl; + << "@$(QMAKE) -prl " << buildArgs() << ' ' << escapeFilePath(project->projectFile()) << endl; } if (!project->isEmpty("QMAKE_BUNDLE")) { @@ -755,50 +774,54 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) ProStringList &alldeps = project->values("ALL_DEPS"); QString bundle_dir = project->first("DESTDIR") + project->first("QMAKE_BUNDLE") + "/"; if (!project->first("QMAKE_PKGINFO").isEmpty()) { - ProString pkginfo = escapeFilePath(project->first("QMAKE_PKGINFO")); + ProString pkginfo = project->first("QMAKE_PKGINFO"); + ProString pkginfo_f = escapeFilePath(pkginfo); + ProString pkginfo_d = escapeDependencyPath(pkginfo); bundledFiles << pkginfo; alldeps << pkginfo; QString destdir = bundle_dir + "Contents"; - t << pkginfo << ": \n\t"; + t << pkginfo_d << ": \n\t"; if (!destdir.isEmpty()) t << mkdir_p_asstring(destdir) << "\n\t"; - t << "@$(DEL_FILE) " << pkginfo << "\n\t" + t << "@$(DEL_FILE) " << pkginfo_f << "\n\t" << "@echo \"APPL" << (project->isEmpty("QMAKE_PKGINFO_TYPEINFO") ? QString::fromLatin1("????") : project->first("QMAKE_PKGINFO_TYPEINFO").left(4)) - << "\" >" << pkginfo << endl; + << "\" > " << pkginfo_f << endl; } if (!project->first("QMAKE_BUNDLE_RESOURCE_FILE").isEmpty()) { - ProString resources = escapeFilePath(project->first("QMAKE_BUNDLE_RESOURCE_FILE")); + ProString resources = project->first("QMAKE_BUNDLE_RESOURCE_FILE"); + ProString resources_f = escapeFilePath(resources); + ProString resources_d = escapeDependencyPath(resources); bundledFiles << resources; alldeps << resources; QString destdir = bundle_dir + "Contents/Resources"; - t << resources << ": \n\t"; + t << resources_d << ": \n\t"; t << mkdir_p_asstring(destdir) << "\n\t"; - t << "@touch " << resources << "\n\t\n"; + t << "@touch " << resources_f << "\n\t\n"; } //copy the plist while (!project->isActiveConfig("no_plist")) { // 'while' just to be able to 'break' QString info_plist = project->first("QMAKE_INFO_PLIST").toQString(); if (info_plist.isEmpty()) { info_plist = escapeFilePath(specdir() + QDir::separator() + "Info.plist." + project->first("TEMPLATE")); - } else if (!exists(Option::fixPathToLocalOS(info_plist))) { + } else if (!exists(Option::normalizePath(info_plist))) { warn_msg(WarnLogic, "Could not resolve Info.plist: '%s'. Check if QMAKE_INFO_PLIST points to a valid file.", info_plist.toLatin1().constData()); break; } else { info_plist = escapeFilePath(fileFixify(info_plist)); } - bool isApp = (project->first("TEMPLATE") == "app"); - QString info_plist_out = escapeFilePath( + QString info_plist_out = bundle_dir + (isApp ? "Contents/Info.plist" : "Versions/" + project->first("QMAKE_FRAMEWORK_VERSION") - + "/Resources/Info.plist")); + + "/Resources/Info.plist"); bundledFiles << info_plist_out; alldeps << info_plist_out; QString destdir = info_plist_out.section(Option::dir_sep, 0, -2); - t << info_plist_out << ": \n\t"; + t << escapeDependencyPath(info_plist_out) << ": \n\t"; + info_plist_out = escapeFilePath(info_plist_out); if (!destdir.isEmpty()) t << mkdir_p_asstring(destdir, false) << "\n\t"; ProStringList commonSedArgs; @@ -838,13 +861,14 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) //copy the icon if (!project->isEmpty("ICON")) { QString dir = bundle_dir + "Contents/Resources/"; - const QString icon_path = escapeFilePath(dir + icon.section(Option::dir_sep, -1)); + const QString icon_path = dir + icon.section(Option::dir_sep, -1); + QString icon_path_f = escapeFilePath(icon_path); bundledFiles << icon_path; alldeps << icon_path; - t << icon_path << ": " << icon << "\n\t" + t << escapeDependencyPath(icon_path) << ": " << escapeDependencyPath(icon) << "\n\t" << mkdir_p_asstring(dir) << "\n\t" - << "@$(DEL_FILE) " << icon_path << "\n\t" - << "@$(COPY_FILE) " << escapeFilePath(icon) << " " << icon_path << endl; + << "@$(DEL_FILE) " << icon_path_f << "\n\t" + << "@$(COPY_FILE) " << escapeFilePath(icon) << ' ' << icon_path_f << endl; } } else { symlinks[bundle_dir + "Resources"] = "Versions/Current/Resources"; @@ -875,23 +899,24 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) int pos = name.indexOf('/'); if (pos > 0) name = name.mid(0, pos); - symlinks[Option::fixPathToLocalOS(path + name)] = + symlinks[Option::fixPathToTargetOS(path + name)] = project->first(vkey) + "/Current/" + name; path += version; } path += project->first(pkey).toQString(); - path = Option::fixPathToLocalOS(path); + path = Option::fixPathToTargetOS(path); for(int file = 0; file < files.count(); file++) { QString fn = files.at(file).toQString(); QString src = fileFixify(fn, FileFixifyAbsolute); if (!QFile::exists(src)) src = fn; - src = escapeFilePath(src); - const QString dst = escapeFilePath(path + Option::dir_sep + fileInfo(fn).fileName()); + QString dst = path + Option::dir_sep + fileInfo(fn).fileName(); bundledFiles << dst; alldeps << dst; - t << dst << ": " << src << "\n\t" + t << escapeDependencyPath(dst) << ": " << escapeDependencyPath(src) << "\n\t" << mkdir_p_asstring(path) << "\n\t"; + src = escapeFilePath(src); + dst = escapeFilePath(dst); QFileInfo fi(fileInfo(fn)); if(fi.isDir()) t << "@$(DEL_FILE) -r " << dst << "\n\t" @@ -902,18 +927,19 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) } } } + QString bundle_dir_f = escapeFilePath(bundle_dir); QHash<QString, QString>::ConstIterator symIt = symlinks.constBegin(), symEnd = symlinks.constEnd(); for (; symIt != symEnd; ++symIt) { bundledFiles << symIt.key(); alldeps << symIt.key(); - t << symIt.key() << ":\n\t" + t << escapeDependencyPath(symIt.key()) << ":\n\t" << mkdir_p_asstring(bundle_dir) << "\n\t" - << "@$(SYMLINK) " << symIt.value() << " " << bundle_dir << endl; + << "@$(SYMLINK) " << escapeFilePath(symIt.value()) << ' ' << bundle_dir_f << endl; } } - t << endl << "all: " << escapeDependencyPath(deps) + t << endl << "all: " << deps << valGlue(escapeDependencyPaths(project->values("ALL_DEPS")), " \\\n\t\t", " \\\n\t\t", "") << allDeps << endl << endl; @@ -934,15 +960,16 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) const ProStringList &val = project->values((*var_it).toKey()); if(val.isEmpty()) continue; - t << "\t$(COPY_FILE) --parents " << val.join(' ') << " $(DISTDIR)" << Option::dir_sep << endl; + t << "\t$(COPY_FILE) --parents " << escapeFilePaths(val).join(' ') + << " $(DISTDIR)" << Option::dir_sep << endl; } } } if(!project->isEmpty("TRANSLATIONS")) - t << "\t$(COPY_FILE) --parents " << var("TRANSLATIONS") << " $(DISTDIR)" << Option::dir_sep << endl; + t << "\t$(COPY_FILE) --parents " << fileVar("TRANSLATIONS") << " $(DISTDIR)" << Option::dir_sep << endl; t << endl << endl; - QString clean_targets = "compiler_clean " + var("CLEAN_DEPS"); + QString clean_targets = " compiler_clean " + depVar("CLEAN_DEPS"); if(do_incremental) { t << "incrclean:\n"; if(src_incremental) @@ -997,28 +1024,27 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) precomp_files += precomph_out_dir + header_prefix + "objective-c++" + header_suffix; } } - t << "-$(DEL_FILE) " << precomp_files.join(' ') << "\n\t"; + t << "-$(DEL_FILE) " << escapeFilePaths(precomp_files).join(' ') << "\n\t"; } - if(!project->isEmpty("IMAGES")) - t << varGlue("QMAKE_IMAGE_COLLECTION", "\t-$(DEL_FILE) ", " ", "") << "\n\t"; if(src_incremental) t << "-$(DEL_FILE) $(INCREMENTAL_OBJECTS)\n\t"; - t << varGlue("QMAKE_CLEAN","-$(DEL_FILE) "," ","\n\t") + t << fileVarGlue("QMAKE_CLEAN","-$(DEL_FILE) "," ","\n\t") << "-$(DEL_FILE) *~ core *.core\n" - << varGlue("CLEAN_FILES","\t-$(DEL_FILE) "," ","") << endl << endl; + << fileVarGlue("CLEAN_FILES","\t-$(DEL_FILE) "," ","") << endl << endl; ProString destdir = project->first("DESTDIR"); if (!destdir.isEmpty() && !destdir.endsWith(Option::dir_sep)) destdir += Option::dir_sep; - t << "distclean: clean " << var("DISTCLEAN_DEPS") << '\n'; + t << "distclean: clean " << depVar("DISTCLEAN_DEPS") << '\n'; if(!project->isEmpty("QMAKE_BUNDLE")) { QString bundlePath = escapeFilePath(destdir + project->first("QMAKE_BUNDLE")); t << "\t-$(DEL_FILE) -r " << bundlePath << endl; } else if(project->isActiveConfig("compile_libtool")) { t << "\t-$(LIBTOOL) --mode=clean $(DEL_FILE) $(TARGET)\n"; } else if (project->isActiveConfig("staticlib")) { - t << "\t-$(DEL_FILE) " << destdir << "$(TARGET) \n"; + t << "\t-$(DEL_FILE) " << escapeFilePath(destdir) << "$(TARGET) \n"; } else if (project->values("QMAKE_APP_FLAG").isEmpty() && !project->isActiveConfig("plugin")) { + destdir = escapeFilePath(destdir); t << "\t-$(DEL_FILE) " << destdir << "$(TARGET) \n"; if (!project->isActiveConfig("unversioned_libname")) { t << "\t-$(DEL_FILE) " << destdir << "$(TARGET0) " << destdir << "$(TARGET1) " @@ -1029,11 +1055,11 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) } else { t << "\t-$(DEL_FILE) $(TARGET) \n"; } - t << varGlue("QMAKE_DISTCLEAN","\t-$(DEL_FILE) "," ","\n"); + t << fileVarGlue("QMAKE_DISTCLEAN","\t-$(DEL_FILE) "," ","\n"); { - QString ofile = Option::fixPathToTargetOS(fileFixify(Option::output.fileName())); + QString ofile = fileFixify(Option::output.fileName()); if(!ofile.isEmpty()) - t << "\t-$(DEL_FILE) " << ofile << endl; + t << "\t-$(DEL_FILE) " << escapeFilePath(ofile) << endl; } t << endl << endl; @@ -1044,8 +1070,8 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) libdir = project->first("SUBLIBS_DIR"); const ProStringList &l = project->values("SUBLIBS"); for (it = l.begin(); it != l.end(); ++it) - t << libdir << project->first("QMAKE_PREFIX_STATICLIB") << (*it) << "." - << project->first("QMAKE_EXTENSION_STATICLIB") << ":\n\t" + t << escapeDependencyPath(libdir + project->first("QMAKE_PREFIX_STATICLIB") + (*it) + '.' + + project->first("QMAKE_EXTENSION_STATICLIB")) << ":\n\t" << var(ProKey("MAKELIB" + *it)) << endl << endl; } @@ -1075,13 +1101,15 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) if (project->isActiveConfig("icc_pch_style")) { // icc style QString sourceFile = pchOutput + Option::cpp_ext.first(); + QString sourceFile_f = escapeFilePath(sourceFile); QString objectFile = createObjectList(ProStringList(sourceFile)).first().toQString(); - t << pchOutput << ": " << pchInput << " " << findDependencies(pchInput).join(" \\\n\t\t") - << "\n\techo \"// Automatically generated, do not modify\" > " << sourceFile - << "\n\trm -f " << pchOutput; + t << escapeDependencyPath(pchOutput) << ": " << escapeDependencyPath(pchInput) << ' ' + << escapeDependencyPaths(findDependencies(pchInput)).join(" \\\n\t\t") + << "\n\techo \"// Automatically generated, do not modify\" > " << sourceFile_f + << "\n\trm -f " << escapeFilePath(pchOutput); - pchFlags = pchFlags.replace("${QMAKE_PCH_TEMP_SOURCE}", sourceFile) - .replace("${QMAKE_PCH_TEMP_OBJECT}", objectFile); + pchFlags.replace("${QMAKE_PCH_TEMP_SOURCE}", sourceFile_f) + .replace("${QMAKE_PCH_TEMP_OBJECT}", escapeFilePath(objectFile)); } else { // gcc style (including clang_pch_style) ProString header_prefix = project->first("QMAKE_PRECOMP_PREFIX"); @@ -1104,12 +1132,13 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) continue; pchOutput += header_prefix + pchOutputFile + header_suffix; - t << pchOutput << ": " << pchInput << " " << findDependencies(pchInput).join(" \\\n\t\t") + t << escapeDependencyPath(pchOutput) << ": " << escapeDependencyPath(pchInput) << ' ' + << escapeDependencyPaths(findDependencies(pchInput)).join(" \\\n\t\t") << "\n\t" << mkdir_p_asstring(pchOutputDir); } - pchFlags = pchFlags.replace("${QMAKE_PCH_INPUT}", pchInput) - .replace("${QMAKE_PCH_OUTPUT_BASE}", pchBaseName.toQString()) - .replace("${QMAKE_PCH_OUTPUT}", pchOutput.toQString()); + pchFlags.replace("${QMAKE_PCH_INPUT}", escapeFilePath(pchInput)) + .replace("${QMAKE_PCH_OUTPUT_BASE}", escapeFilePath(pchBaseName.toQString())) + .replace("${QMAKE_PCH_OUTPUT}", escapeFilePath(pchOutput.toQString())); QString compiler; if(comps[i] == "C" || comps[i] == "OBJC" || comps[i] == "OBJCXX") @@ -1129,9 +1158,9 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) void UnixMakefileGenerator::init2() { if(project->isEmpty("QMAKE_FRAMEWORK_VERSION")) - project->values("QMAKE_FRAMEWORK_VERSION").append(project->values("VER_MAJ").first()); + project->values("QMAKE_FRAMEWORK_VERSION").append(project->first("VER_MAJ")); - if (project->values("TEMPLATE").first() == "aux") + if (project->first("TEMPLATE") == "aux") return; if (!project->values("QMAKE_APP_FLAG").isEmpty()) { @@ -1172,11 +1201,11 @@ void UnixMakefileGenerator::init2() if(!bundle_loc.endsWith("/")) bundle_loc += "/"; project->values("TARGET_").append(project->first("QMAKE_BUNDLE") + - bundle_loc + unescapeFilePath(project->first("TARGET"))); + bundle_loc + project->first("TARGET")); project->values("TARGET_x.y").append(project->first("QMAKE_BUNDLE") + "/Versions/" + project->first("QMAKE_FRAMEWORK_VERSION") + - bundle_loc + unescapeFilePath(project->first("TARGET"))); + bundle_loc + project->first("TARGET")); } else if(project->isActiveConfig("plugin")) { QString prefix; if(!project->isActiveConfig("no_plugin_name_prefix")) @@ -1248,7 +1277,7 @@ void UnixMakefileGenerator::init2() project->first("VER_MAJ") + "." + project->first("VER_MIN") + "." + project->first("VER_PAT") + "." + - project->values("QMAKE_EXTENSION_SHLIB").first()); + project->first("QMAKE_EXTENSION_SHLIB")); } else { project->values("TARGET_x").append("lib" + project->first("TARGET") + "." + project->first("QMAKE_EXTENSION_SHLIB") + @@ -1259,8 +1288,8 @@ void UnixMakefileGenerator::init2() "." + project->first("VER_MIN")); project->values("TARGET_x.y.z").append("lib" + project->first("TARGET") + "." + - project->values( - "QMAKE_EXTENSION_SHLIB").first() + "." + + project->first( + "QMAKE_EXTENSION_SHLIB") + "." + project->first("VER_MAJ") + "." + project->first("VER_MIN") + "." + project->first("VER_PAT")); @@ -1270,8 +1299,6 @@ void UnixMakefileGenerator::init2() else project->values("TARGET") = project->values("TARGET_x.y.z"); } - if(project->isEmpty("QMAKE_LN_SHLIB")) - project->values("QMAKE_LN_SHLIB").append("ln -s"); if (!project->values("QMAKE_LFLAGS_SONAME").isEmpty()) { ProString soname; if(project->isActiveConfig("plugin")) { @@ -1369,7 +1396,7 @@ UnixMakefileGenerator::libtoolFileName(bool fixify) if(fixify) { if(QDir::isRelativePath(ret) && !project->isEmpty("DESTDIR")) ret.prepend(project->first("DESTDIR").toQString()); - ret = Option::fixPathToLocalOS(fileFixify(ret, qmake_getpwd(), Option::output_dir)); + ret = fileFixify(ret, qmake_getpwd(), Option::output_dir); } return ret; } @@ -1390,26 +1417,27 @@ UnixMakefileGenerator::writeLibtoolFile() QTextStream t(&ft); t << "# " << lname << " - a libtool library file\n"; t << "# Generated by qmake/libtool (" QMAKE_VERSION_STR ") (Qt " - << QT_VERSION_STR << ") on: " << QDateTime::currentDateTime().toString(); + << QT_VERSION_STR << ")"; t << "\n"; t << "# The name that we can dlopen(3).\n" - << "dlname='" << var(project->isActiveConfig("plugin") ? "TARGET" : "TARGET_x") + << "dlname='" << fileVar(project->isActiveConfig("plugin") ? "TARGET" : "TARGET_x") << "'\n\n"; t << "# Names of this library.\n"; t << "library_names='"; if(project->isActiveConfig("plugin")) { - t << var("TARGET"); + t << fileVar("TARGET"); } else { if (project->isEmpty("QMAKE_HPUX_SHLIB")) - t << var("TARGET_x.y.z") << " "; - t << var("TARGET_x") << " " << var("TARGET_"); + t << fileVar("TARGET_x.y.z") << ' '; + t << fileVar("TARGET_x") << ' ' << fileVar("TARGET_"); } t << "'\n\n"; t << "# The name of the static archive.\n" - << "old_library='" << lname.left(lname.length()-Option::libtool_ext.length()) << ".a'\n\n"; + << "old_library='" << escapeFilePath(lname.left(lname.length()-Option::libtool_ext.length())) + << ".a'\n\n"; t << "# Libraries that this one depends upon.\n"; ProStringList libs; @@ -1419,7 +1447,7 @@ UnixMakefileGenerator::writeLibtoolFile() libs << "QMAKE_LIBS"; //obvious one t << "dependency_libs='"; for (ProStringList::ConstIterator it = libs.begin(); it != libs.end(); ++it) - t << project->values((*it).toKey()).join(' ') << " "; + t << fixLibFlags((*it).toKey()).join(' ') << ' '; t << "'\n\n"; t << "# Version information for " << lname << "\n"; |