diff options
Diffstat (limited to 'qmake/generators/unix/unixmake2.cpp')
-rw-r--r-- | qmake/generators/unix/unixmake2.cpp | 343 |
1 files changed, 189 insertions, 154 deletions
diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp index 05b96f3ec6..c14395ae27 100644 --- a/qmake/generators/unix/unixmake2.cpp +++ b/qmake/generators/unix/unixmake2.cpp @@ -101,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"); @@ -127,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) { @@ -148,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)); @@ -157,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; } @@ -166,7 +167,6 @@ UnixMakefileGenerator::writeSubTargets(QTextStream &t, QList<MakefileGenerator:: void UnixMakefileGenerator::writeMakeParts(QTextStream &t) { - QString deps = fileFixify(Option::output.fileName()), target_deps; bool do_incremental = (project->isActiveConfig("incremental") && !project->values("QMAKE_INCREMENTAL").isEmpty() && (!project->values("QMAKE_APP_FLAG").isEmpty() || @@ -188,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")) @@ -207,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; @@ -220,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"); @@ -258,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; } } } @@ -300,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"; @@ -321,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" @@ -374,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; } } @@ -395,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"); @@ -411,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(); @@ -443,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->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"); @@ -463,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")) @@ -497,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"; @@ -512,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"); @@ -530,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") + " "; @@ -556,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")) @@ -598,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" @@ -608,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; @@ -667,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) @@ -680,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")) @@ -709,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.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; @@ -746,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")) { @@ -754,47 +774,53 @@ 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 = escapeFilePath(fileFixify(project->first("QMAKE_INFO_PLIST").toQString())); + QString info_plist = fileFixify(project->first("QMAKE_INFO_PLIST").toQString()); if (info_plist.isEmpty()) info_plist = specdir() + QDir::separator() + "Info.plist." + project->first("TEMPLATE"); - if (!exists(Option::fixPathToLocalOS(info_plist))) { + 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; } + info_plist = escapeFilePath(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; @@ -834,13 +860,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"; @@ -871,23 +898,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" @@ -898,18 +926,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; @@ -930,15 +959,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) @@ -993,26 +1023,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(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) " @@ -1023,11 +1054,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; @@ -1038,8 +1069,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; } @@ -1069,13 +1100,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.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"); @@ -1098,12 +1131,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.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") @@ -1166,11 +1200,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")) @@ -1363,7 +1397,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; } @@ -1388,22 +1422,23 @@ UnixMakefileGenerator::writeLibtoolFile() 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; @@ -1413,7 +1448,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"; |