| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Copyright (C) 2016 Intel Corporation. |
| 5 | ** Contact: https://www.qt.io/licensing/ |
| 6 | ** |
| 7 | ** This file is part of the qmake application of the Qt Toolkit. |
| 8 | ** |
| 9 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
| 10 | ** Commercial License Usage |
| 11 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 12 | ** accordance with the commercial license agreement provided with the |
| 13 | ** Software or, alternatively, in accordance with the terms contained in |
| 14 | ** a written agreement between you and The Qt Company. For licensing terms |
| 15 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 16 | ** information use the contact form at https://www.qt.io/contact-us. |
| 17 | ** |
| 18 | ** GNU General Public License Usage |
| 19 | ** Alternatively, this file may be used under the terms of the GNU |
| 20 | ** General Public License version 3 as published by the Free Software |
| 21 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
| 22 | ** included in the packaging of this file. Please review the following |
| 23 | ** information to ensure the GNU General Public License requirements will |
| 24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
| 25 | ** |
| 26 | ** $QT_END_LICENSE$ |
| 27 | ** |
| 28 | ****************************************************************************/ |
| 29 | |
| 30 | #include "unixmake.h" |
| 31 | #include "option.h" |
| 32 | #include "meta.h" |
| 33 | #include <qregularexpression.h> |
| 34 | #include <qbytearray.h> |
| 35 | #include <qfile.h> |
| 36 | #include <qdir.h> |
| 37 | #include <qdebug.h> |
| 38 | #include <time.h> |
| 39 | |
| 40 | QT_BEGIN_NAMESPACE |
| 41 | |
| 42 | void |
| 43 | UnixMakefileGenerator::writePrlFile(QTextStream &t) |
| 44 | { |
| 45 | MakefileGenerator::writePrlFile(t); |
| 46 | const ProString tmplt = project->first("TEMPLATE" ); |
| 47 | if (tmplt != "lib" && tmplt != "aux" ) |
| 48 | return; |
| 49 | // libtool support |
| 50 | if (project->isActiveConfig("create_libtool" )) { |
| 51 | writeLibtoolFile(); |
| 52 | } |
| 53 | // pkg-config support |
| 54 | if (project->isActiveConfig("create_pc" )) |
| 55 | writePkgConfigFile(); |
| 56 | } |
| 57 | |
| 58 | bool |
| 59 | UnixMakefileGenerator::writeMakefile(QTextStream &t) |
| 60 | { |
| 61 | |
| 62 | writeHeader(t); |
| 63 | if (writeDummyMakefile(t)) |
| 64 | return true; |
| 65 | |
| 66 | if (project->first("TEMPLATE" ) == "app" || |
| 67 | project->first("TEMPLATE" ) == "lib" || |
| 68 | project->first("TEMPLATE" ) == "aux" ) { |
| 69 | writeMakeParts(t); |
| 70 | return MakefileGenerator::writeMakefile(t); |
| 71 | } else if (project->first("TEMPLATE" ) == "subdirs" ) { |
| 72 | MakefileGenerator::writeSubDirs(t); |
| 73 | return true; |
| 74 | } |
| 75 | return false; |
| 76 | } |
| 77 | |
| 78 | void |
| 79 | UnixMakefileGenerator::writeDefaultVariables(QTextStream &t) |
| 80 | { |
| 81 | MakefileGenerator::writeDefaultVariables(t); |
| 82 | t << "TAR = " << var("QMAKE_TAR" ) << Qt::endl; |
| 83 | t << "COMPRESS = " << var("QMAKE_GZIP" ) << Qt::endl; |
| 84 | |
| 85 | if (project->isEmpty("QMAKE_DISTNAME" )) { |
| 86 | ProString distname = project->first("QMAKE_ORIG_TARGET" ); |
| 87 | if (!project->isActiveConfig("no_dist_version" )) |
| 88 | distname += project->first("VERSION" ); |
| 89 | project->values("QMAKE_DISTNAME" ) = distname; |
| 90 | } |
| 91 | t << "DISTNAME = " << fileVar("QMAKE_DISTNAME" ) << Qt::endl; |
| 92 | |
| 93 | if (project->isEmpty("QMAKE_DISTDIR" )) |
| 94 | project->values("QMAKE_DISTDIR" ) = project->first("QMAKE_DISTNAME" ); |
| 95 | t << "DISTDIR = " << escapeFilePath(fileFixify( |
| 96 | (project->isEmpty("OBJECTS_DIR" ) ? ProString(".tmp/" ) : project->first("OBJECTS_DIR" )) + project->first("QMAKE_DISTDIR" ), |
| 97 | FileFixifyFromOutdir | FileFixifyAbsolute)) << Qt::endl; |
| 98 | } |
| 99 | |
| 100 | void |
| 101 | UnixMakefileGenerator::writeSubTargets(QTextStream &t, QList<MakefileGenerator::SubTarget*> targets, int flags) |
| 102 | { |
| 103 | MakefileGenerator::writeSubTargets(t, targets, flags); |
| 104 | |
| 105 | t << "dist: distdir FORCE" << Qt::endl; |
| 106 | t << "\t(cd `dirname $(DISTDIR)` && $(TAR) $(DISTNAME).tar $(DISTNAME) && $(COMPRESS) $(DISTNAME).tar)" |
| 107 | " && $(MOVE) `dirname $(DISTDIR)`/$(DISTNAME).tar.gz . && $(DEL_FILE) -r $(DISTDIR)" ; |
| 108 | t << Qt::endl << Qt::endl; |
| 109 | |
| 110 | t << "distdir:" ; |
| 111 | for (int target = 0; target < targets.size(); ++target) { |
| 112 | SubTarget *subtarget = targets.at(target); |
| 113 | t << " " << subtarget->target << "-distdir" ; |
| 114 | } |
| 115 | t << " FORCE\n\t" |
| 116 | << mkdir_p_asstring("$(DISTDIR)" , false) << "\n\t" |
| 117 | << "$(COPY_FILE) --parents " << fileVar("DISTFILES" ) << " $(DISTDIR)" << Option::dir_sep << Qt::endl << Qt::endl; |
| 118 | |
| 119 | const QString abs_source_path = project->first("QMAKE_ABSOLUTE_SOURCE_PATH" ).toQString(); |
| 120 | for (int target = 0; target < targets.size(); ++target) { |
| 121 | SubTarget *subtarget = targets.at(target); |
| 122 | QString in_directory = subtarget->in_directory; |
| 123 | if (!in_directory.isEmpty() && !in_directory.endsWith(Option::dir_sep)) |
| 124 | in_directory += Option::dir_sep; |
| 125 | QString out_directory = subtarget->out_directory; |
| 126 | if (!out_directory.isEmpty() && !out_directory.endsWith(Option::dir_sep)) |
| 127 | out_directory += Option::dir_sep; |
| 128 | if (!abs_source_path.isEmpty() && out_directory.startsWith(abs_source_path)) |
| 129 | out_directory = Option::output_dir + out_directory.mid(abs_source_path.length()); |
| 130 | |
| 131 | QString dist_directory = out_directory; |
| 132 | if (dist_directory.endsWith(Option::dir_sep)) |
| 133 | dist_directory.chop(Option::dir_sep.length()); |
| 134 | if (!dist_directory.startsWith(Option::dir_sep)) |
| 135 | dist_directory.prepend(Option::dir_sep); |
| 136 | |
| 137 | QString out_directory_cdin = out_directory.isEmpty() ? QString("\n\t" ) |
| 138 | : "\n\tcd " + escapeFilePath(out_directory) + " && " ; |
| 139 | QString makefilein = " -e -f " + escapeFilePath(subtarget->makefile) |
| 140 | + " distdir DISTDIR=$(DISTDIR)" + escapeFilePath(dist_directory); |
| 141 | |
| 142 | QString out = subtarget->makefile; |
| 143 | QString in = escapeFilePath(fileFixify(in_directory + subtarget->profile, FileFixifyAbsolute)); |
| 144 | if (out.startsWith(in_directory)) |
| 145 | out.remove(0, in_directory.length()); |
| 146 | |
| 147 | t << subtarget->target << "-distdir: FORCE" ; |
| 148 | writeSubTargetCall(t, in_directory, in, out_directory, escapeFilePath(out), |
| 149 | out_directory_cdin, makefilein); |
| 150 | t << Qt::endl; |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | static QString rfc1034Identifier(const QString &str) |
| 155 | { |
| 156 | QString s = str; |
| 157 | for (QChar &ch : s) { |
| 158 | const char c = ch.toLatin1(); |
| 159 | |
| 160 | const bool okChar = (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') |
| 161 | || (c >= 'a' && c <= 'z') || c == '-' || c == '.'; |
| 162 | if (!okChar) |
| 163 | ch = QChar::fromLatin1('-'); |
| 164 | } |
| 165 | return s; |
| 166 | } |
| 167 | |
| 168 | static QString escapeDir(const QString &dir) |
| 169 | { |
| 170 | // When building on non-MSys MinGW, the path ends with a backslash, which |
| 171 | // GNU make will interpret that as a line continuation. Doubling the backslash |
| 172 | // avoids the problem, at the cost of the variable containing *both* backslashes. |
| 173 | if (dir.endsWith('\\')) |
| 174 | return dir + '\\'; |
| 175 | return dir; |
| 176 | } |
| 177 | |
| 178 | void |
| 179 | UnixMakefileGenerator::writeMakeParts(QTextStream &t) |
| 180 | { |
| 181 | bool do_incremental = (project->isActiveConfig("incremental" ) && |
| 182 | !project->values("QMAKE_INCREMENTAL" ).isEmpty() && |
| 183 | (!project->values("QMAKE_APP_FLAG" ).isEmpty() || |
| 184 | (!project->isActiveConfig("staticlib" )))), |
| 185 | src_incremental=false; |
| 186 | |
| 187 | ProStringList &bundledFiles = project->values("QMAKE_BUNDLED_FILES" ); |
| 188 | |
| 189 | writeExportedVariables(t); |
| 190 | |
| 191 | t << "####### Compiler, tools and options\n\n" ; |
| 192 | t << "CC = " << var("QMAKE_CC" ) << Qt::endl; |
| 193 | t << "CXX = " << var("QMAKE_CXX" ) << Qt::endl; |
| 194 | t << "DEFINES = " |
| 195 | << varGlue("PRL_EXPORT_DEFINES" ,"-D" ," -D" ," " ) |
| 196 | << varGlue("DEFINES" ,"-D" ," -D" ,"" ) << Qt::endl; |
| 197 | t << "CFLAGS = " << var("QMAKE_CFLAGS" ) << " $(DEFINES)\n" ; |
| 198 | t << "CXXFLAGS = " << var("QMAKE_CXXFLAGS" ) << " $(DEFINES)\n" ; |
| 199 | t << "INCPATH =" ; |
| 200 | { |
| 201 | const ProStringList &incs = project->values("INCLUDEPATH" ); |
| 202 | for(int i = 0; i < incs.size(); ++i) { |
| 203 | const ProString &inc = incs.at(i); |
| 204 | if (inc.isEmpty()) |
| 205 | continue; |
| 206 | |
| 207 | t << " -I" << escapeFilePath(inc); |
| 208 | } |
| 209 | } |
| 210 | if(!project->isEmpty("QMAKE_FRAMEWORKPATH_FLAGS" )) |
| 211 | t << " " << var("QMAKE_FRAMEWORKPATH_FLAGS" ); |
| 212 | t << Qt::endl; |
| 213 | |
| 214 | writeDefaultVariables(t); |
| 215 | |
| 216 | if(!project->isActiveConfig("staticlib" )) { |
| 217 | t << "LINK = " << var("QMAKE_LINK" ) << Qt::endl; |
| 218 | t << "LFLAGS = " << var("QMAKE_LFLAGS" ) << Qt::endl; |
| 219 | t << "LIBS = $(SUBLIBS) " << fixLibFlags("LIBS" ).join(' ') << ' ' |
| 220 | << fixLibFlags("LIBS_PRIVATE" ).join(' ') << ' ' |
| 221 | << fixLibFlags("QMAKE_LIBS" ).join(' ') << ' ' |
| 222 | << fixLibFlags("QMAKE_LIBS_PRIVATE" ).join(' ') << Qt::endl; |
| 223 | } |
| 224 | |
| 225 | t << "AR = " << var("QMAKE_AR" ) << Qt::endl; |
| 226 | t << "RANLIB = " << var("QMAKE_RANLIB" ) << Qt::endl; |
| 227 | t << "SED = " << var("QMAKE_STREAM_EDITOR" ) << Qt::endl; |
| 228 | t << "STRIP = " << var("QMAKE_STRIP" ) << Qt::endl; |
| 229 | |
| 230 | t << Qt::endl; |
| 231 | |
| 232 | t << "####### Output directory\n\n" ; |
| 233 | // This is used in commands by some .prf files. |
| 234 | if (! project->values("OBJECTS_DIR" ).isEmpty()) |
| 235 | t << "OBJECTS_DIR = " << escapeDir(fileVar("OBJECTS_DIR" )) << Qt::endl; |
| 236 | else |
| 237 | t << "OBJECTS_DIR = ./\n" ; |
| 238 | t << Qt::endl; |
| 239 | |
| 240 | /* files */ |
| 241 | t << "####### Files\n\n" ; |
| 242 | // This is used by the dist target. |
| 243 | t << "SOURCES = " << fileVarList("SOURCES" ) << ' ' << fileVarList("GENERATED_SOURCES" ) << Qt::endl; |
| 244 | auto objectParts = writeObjectsPart(t, do_incremental); |
| 245 | src_incremental = objectParts.first; |
| 246 | if(do_incremental && !src_incremental) |
| 247 | do_incremental = false; |
| 248 | t << "DIST = " << valList(fileFixify(project->values("DISTFILES" ).toQStringList())) << " " |
| 249 | << fileVarList("HEADERS" ) << ' ' << fileVarList("SOURCES" ) << Qt::endl; |
| 250 | t << "QMAKE_TARGET = " << fileVar("QMAKE_ORIG_TARGET" ) << Qt::endl; |
| 251 | t << "DESTDIR = " << escapeDir(fileVar("DESTDIR" )) << Qt::endl; |
| 252 | t << "TARGET = " << fileVar("TARGET" ) << Qt::endl; |
| 253 | if(project->isActiveConfig("plugin" )) { |
| 254 | t << "TARGETD = " << fileVar("TARGET" ) << Qt::endl; |
| 255 | } else if(!project->isActiveConfig("staticlib" ) && project->values("QMAKE_APP_FLAG" ).isEmpty()) { |
| 256 | t << "TARGETA = " << fileVar("TARGETA" ) << Qt::endl; |
| 257 | if(!project->isEmpty("QMAKE_BUNDLE" )) { |
| 258 | t << "TARGETD = " << fileVar("TARGET_x.y" ) << Qt::endl; |
| 259 | t << "TARGET0 = " << fileVar("TARGET_" ) << Qt::endl; |
| 260 | } else if (!project->isActiveConfig("unversioned_libname" )) { |
| 261 | t << "TARGET0 = " << fileVar("TARGET_" ) << Qt::endl; |
| 262 | if (project->isEmpty("QMAKE_HPUX_SHLIB" )) { |
| 263 | t << "TARGETD = " << fileVar("TARGET_x.y.z" ) << Qt::endl; |
| 264 | t << "TARGET1 = " << fileVar("TARGET_x" ) << Qt::endl; |
| 265 | t << "TARGET2 = " << fileVar("TARGET_x.y" ) << Qt::endl; |
| 266 | } else { |
| 267 | t << "TARGETD = " << fileVar("TARGET_x" ) << Qt::endl; |
| 268 | } |
| 269 | } |
| 270 | } |
| 271 | writeExtraCompilerVariables(t); |
| 272 | writeExtraVariables(t); |
| 273 | t << Qt::endl; |
| 274 | |
| 275 | // blasted includes |
| 276 | const ProStringList &qeui = project->values("QMAKE_EXTRA_INCLUDES" ); |
| 277 | ProStringList::ConstIterator it; |
| 278 | for(it = qeui.begin(); it != qeui.end(); ++it) |
| 279 | t << "include " << escapeDependencyPath(*it) << Qt::endl; |
| 280 | |
| 281 | /* rules */ |
| 282 | t << "first:" << (!project->isActiveConfig("no_default_goal_deps" ) ? " all" : "" ) << "\n" ; |
| 283 | |
| 284 | if(include_deps) { |
| 285 | if (project->isActiveConfig("gcc_MD_depends" )) { |
| 286 | ProStringList objects = project->values("OBJECTS" ); |
| 287 | for (ProStringList::Iterator it = objects.begin(); it != objects.end(); ++it) { |
| 288 | QString d_file = (*it).toQString().replace(QRegularExpression(Option::obj_ext + "$" ), ".d" ); |
| 289 | t << "-include " << escapeDependencyPath(d_file) << Qt::endl; |
| 290 | project->values("QMAKE_DISTCLEAN" ) << d_file; |
| 291 | } |
| 292 | } else { |
| 293 | QString cmd=var("QMAKE_CFLAGS_DEPS" ) + " " ; |
| 294 | cmd += varGlue("DEFINES" ,"-D" ," -D" ,"" ) + varGlue("PRL_EXPORT_DEFINES" ," -D" ," -D" ,"" ); |
| 295 | if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH" )) |
| 296 | cmd += " -I" + fileVar("QMAKE_ABSOLUTE_SOURCE_PATH" ) + ' '; |
| 297 | cmd += " $(INCPATH) " + fileVarGlue("DEPENDPATH" , "-I" , " -I" , "" ); |
| 298 | ProString odir; |
| 299 | if(!project->values("OBJECTS_DIR" ).isEmpty()) |
| 300 | odir = project->first("OBJECTS_DIR" ); |
| 301 | QString odird = escapeDependencyPath(odir.toQString()); |
| 302 | |
| 303 | QString pwd = escapeFilePath(fileFixify(qmake_getpwd())); |
| 304 | |
| 305 | t << "###### Dependencies\n\n" ; |
| 306 | t << odird << ".deps/%.d: " << pwd << "/%.cpp\n\t" ; |
| 307 | if(project->isActiveConfig("echo_depend_creation" )) |
| 308 | t << "@echo Creating depend for $<\n\t" ; |
| 309 | t << mkdir_p_asstring("$(@D)" , false) << "\n\t" |
| 310 | << "@$(CXX) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@\n\n" ; |
| 311 | |
| 312 | t << odird << ".deps/%.d: " << pwd << "/%.c\n\t" ; |
| 313 | if(project->isActiveConfig("echo_depend_creation" )) |
| 314 | t << "@echo Creating depend for $<\n\t" ; |
| 315 | t << mkdir_p_asstring("$(@D)" , false) << "\n\t" |
| 316 | << "@$(CC) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@\n\n" ; |
| 317 | |
| 318 | static const char * const src[] = { "SOURCES" , "GENERATED_SOURCES" , nullptr }; |
| 319 | for (int x = 0; src[x]; x++) { |
| 320 | const ProStringList &l = project->values(src[x]); |
| 321 | for (ProStringList::ConstIterator it = l.begin(); it != l.end(); ++it) { |
| 322 | if(!(*it).isEmpty()) { |
| 323 | QString d_file; |
| 324 | for(QStringList::Iterator cit = Option::c_ext.begin(); |
| 325 | cit != Option::c_ext.end(); ++cit) { |
| 326 | if((*it).endsWith((*cit))) { |
| 327 | d_file = (*it).left((*it).length() - (*cit).length()).toQString(); |
| 328 | break; |
| 329 | } |
| 330 | } |
| 331 | if(d_file.isEmpty()) { |
| 332 | for(QStringList::Iterator cppit = Option::cpp_ext.begin(); |
| 333 | cppit != Option::cpp_ext.end(); ++cppit) { |
| 334 | if((*it).endsWith((*cppit))) { |
| 335 | d_file = (*it).left((*it).length() - (*cppit).length()).toQString(); |
| 336 | break; |
| 337 | } |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | if(!d_file.isEmpty()) { |
| 342 | d_file = odir + ".deps/" + fileFixify(d_file, FileFixifyBackwards) + ".d" ; |
| 343 | QString d_file_d = escapeDependencyPath(d_file); |
| 344 | QStringList deps = findDependencies((*it).toQString()).filter(QRegularExpression( |
| 345 | "((^|/)" + Option::h_moc_mod + "|" + Option::cpp_moc_ext + "$)" )); |
| 346 | if(!deps.isEmpty()) |
| 347 | t << d_file_d << ": " << finalizeDependencyPaths(deps).join(' ') << Qt::endl; |
| 348 | t << "-include " << d_file_d << Qt::endl; |
| 349 | project->values("QMAKE_DISTCLEAN" ) += d_file; |
| 350 | } |
| 351 | } |
| 352 | } |
| 353 | } |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | t << "####### Build rules\n\n" ; |
| 358 | if(!project->values("SUBLIBS" ).isEmpty()) { |
| 359 | ProString libdir = "tmp/" ; |
| 360 | if(!project->isEmpty("SUBLIBS_DIR" )) |
| 361 | libdir = project->first("SUBLIBS_DIR" ); |
| 362 | t << "SUBLIBS = " ; |
| 363 | const ProStringList &l = project->values("SUBLIBS" ); |
| 364 | for (ProStringList::ConstIterator it = l.begin(); it != l.end(); ++it) |
| 365 | t << escapeFilePath(libdir + project->first("QMAKE_PREFIX_STATICLIB" ) + (*it) + '.' |
| 366 | + project->first("QMAKE_EXTENSION_STATICLIB" )) << ' '; |
| 367 | t << Qt::endl << Qt::endl; |
| 368 | } |
| 369 | QString target_deps; |
| 370 | if ((project->isActiveConfig("depend_prl" ) || project->isActiveConfig("fast_depend_prl" )) |
| 371 | && !project->isEmpty("QMAKE_PRL_INTERNAL_FILES" )) { |
| 372 | const ProStringList &l = project->values("QMAKE_PRL_INTERNAL_FILES" ); |
| 373 | ProStringList::ConstIterator it; |
| 374 | for(it = l.begin(); it != l.end(); ++it) { |
| 375 | QMakeMetaInfo libinfo; |
| 376 | if (libinfo.readLib((*it).toQString()) && !libinfo.isEmpty("QMAKE_PRL_BUILD_DIR" )) { |
| 377 | ProString dir; |
| 378 | int slsh = (*it).lastIndexOf(Option::dir_sep); |
| 379 | if(slsh != -1) |
| 380 | dir = (*it).left(slsh + 1); |
| 381 | QString targ = dir + libinfo.first("QMAKE_PRL_TARGET" ); |
| 382 | QString targ_d = escapeDependencyPath(targ); |
| 383 | target_deps += ' ' + targ_d; |
| 384 | t << targ_d; |
| 385 | if (project->isActiveConfig("fast_depend_prl" )) |
| 386 | t << ":\n\t@echo \"Creating '" ; |
| 387 | else |
| 388 | t << ": FORCE\n\t@echo \"Creating/updating '" ; |
| 389 | t << targ << "'\"\n\t" |
| 390 | << "(cd " << escapeFilePath(libinfo.first("QMAKE_PRL_BUILD_DIR" )) << ';' |
| 391 | << "$(MAKE))\n" ; |
| 392 | } |
| 393 | } |
| 394 | } |
| 395 | QString deps = escapeDependencyPath(fileFixify(Option::output.fileName())); |
| 396 | QString allDeps; |
| 397 | if (!project->values("QMAKE_APP_FLAG" ).isEmpty() || project->first("TEMPLATE" ) == "aux" ) { |
| 398 | QString destdir = project->first("DESTDIR" ).toQString(); |
| 399 | if(!project->isEmpty("QMAKE_BUNDLE" )) { |
| 400 | QString bundle_loc = project->first("QMAKE_BUNDLE_LOCATION" ).toQString(); |
| 401 | if(!bundle_loc.isEmpty() && !bundle_loc.startsWith("/" )) |
| 402 | bundle_loc.prepend("/" ); |
| 403 | if(!bundle_loc.endsWith("/" )) |
| 404 | bundle_loc += "/" ; |
| 405 | destdir += project->first("QMAKE_BUNDLE" ) + bundle_loc; |
| 406 | } |
| 407 | if(do_incremental) { |
| 408 | //incremental target |
| 409 | QString incr_target = var("TARGET" ) + "_incremental" ; |
| 410 | if(incr_target.indexOf(Option::dir_sep) != -1) |
| 411 | incr_target = incr_target.right(incr_target.length() - |
| 412 | (incr_target.lastIndexOf(Option::dir_sep) + 1)); |
| 413 | QString incr_deps, incr_objs; |
| 414 | if(project->first("QMAKE_INCREMENTAL_STYLE" ) == "ld" ) { |
| 415 | QString incr_target_dir = var("OBJECTS_DIR" ) + incr_target + Option::obj_ext; |
| 416 | QString incr_target_dir_d = escapeDependencyPath(incr_target_dir); |
| 417 | QString incr_target_dir_f = escapeFilePath(incr_target_dir); |
| 418 | //actual target |
| 419 | t << incr_target_dir_d << ": $(OBJECTS)\n\t" |
| 420 | << "ld -r -o " << incr_target_dir_f << " $(OBJECTS)\n" ; |
| 421 | //communicated below |
| 422 | deps.prepend(incr_target_dir_d + ' '); |
| 423 | incr_deps = "$(INCREMENTAL_OBJECTS)" ; |
| 424 | if(!incr_objs.isEmpty()) |
| 425 | incr_objs += " " ; |
| 426 | incr_objs += incr_target_dir_f; |
| 427 | } else { |
| 428 | //actual target |
| 429 | QString incr_target_dir = var("DESTDIR" ) + "lib" + incr_target + "." + |
| 430 | project->first("QMAKE_EXTENSION_SHLIB" ); |
| 431 | QString incr_target_dir_d = escapeDependencyPath(incr_target_dir); |
| 432 | QString incr_target_dir_f = escapeFilePath(incr_target_dir); |
| 433 | QString incr_lflags = var("QMAKE_LFLAGS_SHLIB" ) + " " ; |
| 434 | if(project->isActiveConfig("debug" )) |
| 435 | incr_lflags += var("QMAKE_LFLAGS_DEBUG" ); |
| 436 | else if (project->isActiveConfig("debug_info" )) |
| 437 | incr_lflags += var("QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO" ); |
| 438 | else |
| 439 | incr_lflags += var("QMAKE_LFLAGS_RELEASE" ); |
| 440 | t << incr_target_dir_d << ": $(INCREMENTAL_OBJECTS)\n\t" ; |
| 441 | if(!destdir.isEmpty()) |
| 442 | t << "\n\t" << mkdir_p_asstring(destdir) << "\n\t" ; |
| 443 | t << "$(LINK) " << incr_lflags << " -o " << incr_target_dir_f << |
| 444 | " $(INCREMENTAL_OBJECTS)\n" ; |
| 445 | //communicated below |
| 446 | if(!destdir.isEmpty()) { |
| 447 | if(!incr_objs.isEmpty()) |
| 448 | incr_objs += " " ; |
| 449 | incr_objs += "-L" + escapeFilePath(destdir); |
| 450 | } else { |
| 451 | if(!incr_objs.isEmpty()) |
| 452 | incr_objs += " " ; |
| 453 | incr_objs += "-L" + escapeFilePath(qmake_getpwd()); |
| 454 | } |
| 455 | if(!incr_objs.isEmpty()) |
| 456 | incr_objs += " " ; |
| 457 | incr_objs += " -l" + escapeFilePath(incr_target); |
| 458 | deps.prepend(incr_target_dir_d + ' '); |
| 459 | incr_deps = "$(OBJECTS)" ; |
| 460 | } |
| 461 | |
| 462 | //real target |
| 463 | t << var("TARGET" ) << ": " << depVar("PRE_TARGETDEPS" ) << ' ' << incr_deps << ' ' << target_deps |
| 464 | << ' ' << depVar("POST_TARGETDEPS" ) << "\n\t" ; |
| 465 | if(!destdir.isEmpty()) |
| 466 | t << "\n\t" << mkdir_p_asstring(destdir) << "\n\t" ; |
| 467 | if(!project->isEmpty("QMAKE_PRE_LINK" )) |
| 468 | t << var("QMAKE_PRE_LINK" ) << "\n\t" ; |
| 469 | t << "$(LINK) $(LFLAGS) " << var("QMAKE_LINK_O_FLAG" ) << "$(TARGET) " << incr_deps << " " << incr_objs << " $(OBJCOMP) $(LIBS)" ; |
| 470 | if(!project->isEmpty("QMAKE_POST_LINK" )) |
| 471 | t << "\n\t" << var("QMAKE_POST_LINK" ); |
| 472 | t << Qt::endl << Qt::endl; |
| 473 | } else { |
| 474 | t << depVar("TARGET" ) << ": " << depVar("PRE_TARGETDEPS" ) << " $(OBJECTS) " |
| 475 | << target_deps << ' ' << depVar("POST_TARGETDEPS" ) << "\n\t" ; |
| 476 | if (project->first("TEMPLATE" ) != "aux" ) { |
| 477 | if (!destdir.isEmpty()) |
| 478 | t << mkdir_p_asstring(destdir) << "\n\t" ; |
| 479 | if (!project->isEmpty("QMAKE_PRE_LINK" )) |
| 480 | t << var("QMAKE_PRE_LINK" ) << "\n\t" ; |
| 481 | t << "$(LINK) $(LFLAGS) " << var("QMAKE_LINK_O_FLAG" ) << "$(TARGET) " |
| 482 | << objectParts.second << " $(OBJCOMP) $(LIBS)" ; |
| 483 | if (!project->isEmpty("QMAKE_POST_LINK" )) |
| 484 | t << "\n\t" << var("QMAKE_POST_LINK" ); |
| 485 | } |
| 486 | t << Qt::endl << Qt::endl; |
| 487 | } |
| 488 | allDeps = ' ' + depVar("TARGET" ); |
| 489 | } else if(!project->isActiveConfig("staticlib" )) { |
| 490 | QString destdir_r = project->first("DESTDIR" ).toQString(), incr_deps; |
| 491 | if(!project->isEmpty("QMAKE_BUNDLE" )) { |
| 492 | QString bundle_loc = project->first("QMAKE_BUNDLE_LOCATION" ).toQString(); |
| 493 | if(!bundle_loc.isEmpty() && !bundle_loc.startsWith("/" )) |
| 494 | bundle_loc.prepend("/" ); |
| 495 | if(!bundle_loc.endsWith("/" )) |
| 496 | bundle_loc += "/" ; |
| 497 | destdir_r += project->first("QMAKE_BUNDLE" ) + bundle_loc; |
| 498 | } |
| 499 | QString destdir_d = escapeDependencyPath(destdir_r); |
| 500 | QString destdir = escapeFilePath(destdir_r); |
| 501 | |
| 502 | if(do_incremental) { |
| 503 | ProString s_ext = project->first("QMAKE_EXTENSION_SHLIB" ); |
| 504 | QString incr_target = var("QMAKE_ORIG_TARGET" ).replace( |
| 505 | QRegularExpression("\\." + s_ext), "" ).replace(QRegularExpression("^lib" ), "" ) + "_incremental" ; |
| 506 | if(incr_target.indexOf(Option::dir_sep) != -1) |
| 507 | incr_target = incr_target.right(incr_target.length() - |
| 508 | (incr_target.lastIndexOf(Option::dir_sep) + 1)); |
| 509 | |
| 510 | if(project->first("QMAKE_INCREMENTAL_STYLE" ) == "ld" ) { |
| 511 | QString incr_target_dir = var("OBJECTS_DIR" ) + incr_target + Option::obj_ext; |
| 512 | QString incr_target_dir_d = escapeDependencyPath(incr_target_dir); |
| 513 | QString incr_target_dir_f = escapeFilePath(incr_target_dir); |
| 514 | //actual target |
| 515 | const QString link_deps = "$(OBJECTS) " ; |
| 516 | t << incr_target_dir_d << ": " << link_deps << "\n\t" |
| 517 | << "ld -r -o " << incr_target_dir_f << ' ' << link_deps << Qt::endl; |
| 518 | //communicated below |
| 519 | ProStringList &cmd = project->values("QMAKE_LINK_SHLIB_CMD" ); |
| 520 | cmd[0] = cmd.at(0).toQString().replace(QLatin1String("$(OBJECTS) " ), QLatin1String("$(INCREMENTAL_OBJECTS)" )); //ick |
| 521 | cmd.append(incr_target_dir_f); |
| 522 | deps.prepend(incr_target_dir_d + ' '); |
| 523 | incr_deps = "$(INCREMENTAL_OBJECTS)" ; |
| 524 | } else { |
| 525 | //actual target |
| 526 | QString incr_target_dir = destdir_r + "lib" + incr_target + '.' + s_ext; |
| 527 | QString incr_target_dir_d = escapeDependencyPath(incr_target_dir); |
| 528 | QString incr_target_dir_f = escapeFilePath(incr_target_dir); |
| 529 | QString incr_lflags = var("QMAKE_LFLAGS_SHLIB" ) + " " ; |
| 530 | if(!project->isEmpty("QMAKE_LFLAGS_INCREMENTAL" )) |
| 531 | incr_lflags += var("QMAKE_LFLAGS_INCREMENTAL" ) + " " ; |
| 532 | if(project->isActiveConfig("debug" )) |
| 533 | incr_lflags += var("QMAKE_LFLAGS_DEBUG" ); |
| 534 | else if (project->isActiveConfig("debug_info" )) |
| 535 | incr_lflags += var("QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO" ); |
| 536 | else |
| 537 | incr_lflags += var("QMAKE_LFLAGS_RELEASE" ); |
| 538 | t << incr_target_dir_d << ": $(INCREMENTAL_OBJECTS)\n\t" ; |
| 539 | if(!destdir.isEmpty()) |
| 540 | t << mkdir_p_asstring(destdir, false) << "\n\t" ; |
| 541 | t << "$(LINK) " << incr_lflags << ' ' << var("QMAKE_LINK_O_FLAG" ) << incr_target_dir_f << |
| 542 | " $(INCREMENTAL_OBJECTS)\n" ; |
| 543 | //communicated below |
| 544 | ProStringList &cmd = project->values("QMAKE_LINK_SHLIB_CMD" ); |
| 545 | if(!destdir.isEmpty()) |
| 546 | cmd.append(" -L" + destdir); |
| 547 | cmd.append(" -l" + escapeFilePath(incr_target)); |
| 548 | deps.prepend(incr_target_dir_d + ' '); |
| 549 | incr_deps = "$(OBJECTS)" ; |
| 550 | } |
| 551 | |
| 552 | //real target |
| 553 | t << destdir_d << depVar("TARGET" ) << ": " << depVar("PRE_TARGETDEPS" ) << ' ' |
| 554 | << incr_deps << " $(SUBLIBS) " << target_deps << ' ' << depVar("POST_TARGETDEPS" ); |
| 555 | } else { |
| 556 | ProStringList &cmd = project->values("QMAKE_LINK_SHLIB_CMD" ); |
| 557 | cmd[0] = cmd.at(0).toQString().replace(QLatin1String("$(OBJECTS)" ), objectParts.second); |
| 558 | t << destdir_d << depVar("TARGET" ) << ": " << depVar("PRE_TARGETDEPS" ) |
| 559 | << " $(OBJECTS) $(SUBLIBS) $(OBJCOMP) " << target_deps |
| 560 | << ' ' << depVar("POST_TARGETDEPS" ); |
| 561 | } |
| 562 | allDeps = ' ' + destdir_d + depVar("TARGET" ); |
| 563 | if(!destdir.isEmpty()) |
| 564 | t << "\n\t" << mkdir_p_asstring(destdir, false); |
| 565 | if(!project->isEmpty("QMAKE_PRE_LINK" )) |
| 566 | t << "\n\t" << var("QMAKE_PRE_LINK" ); |
| 567 | |
| 568 | if (project->isActiveConfig("plugin" )) { |
| 569 | t << "\n\t" |
| 570 | << "-$(DEL_FILE) $(TARGET)\n\t" |
| 571 | << var("QMAKE_LINK_SHLIB_CMD" ); |
| 572 | if(!destdir.isEmpty()) |
| 573 | t << "\n\t" |
| 574 | << "-$(MOVE) $(TARGET) " << destdir << "$(TARGET)" ; |
| 575 | if(!project->isEmpty("QMAKE_POST_LINK" )) |
| 576 | t << "\n\t" << var("QMAKE_POST_LINK" ); |
| 577 | t << Qt::endl << Qt::endl; |
| 578 | } else if(!project->isEmpty("QMAKE_BUNDLE" )) { |
| 579 | bundledFiles << destdir_r + var("TARGET" ); |
| 580 | t << "\n\t" |
| 581 | << "-$(DEL_FILE) $(TARGET) $(TARGET0) $(DESTDIR)$(TARGET0)\n\t" |
| 582 | << var("QMAKE_LINK_SHLIB_CMD" ) << "\n\t" |
| 583 | << mkdir_p_asstring("\"`dirname $(DESTDIR)$(TARGETD)`\"" , false) << "\n\t" |
| 584 | << "-$(MOVE) $(TARGET) $(DESTDIR)$(TARGETD)\n\t" |
| 585 | << mkdir_p_asstring("\"`dirname $(DESTDIR)$(TARGET0)`\"" , false) << "\n\t" ; |
| 586 | if (!project->isActiveConfig("shallow_bundle" )) |
| 587 | t << varGlue("QMAKE_LN_SHLIB" , "-" , " " , |
| 588 | " Versions/Current/$(TARGET) $(DESTDIR)$(TARGET0)" ) << "\n\t" ; |
| 589 | if(!project->isEmpty("QMAKE_POST_LINK" )) |
| 590 | t << "\n\t" << var("QMAKE_POST_LINK" ); |
| 591 | t << Qt::endl << Qt::endl; |
| 592 | } else if(project->isEmpty("QMAKE_HPUX_SHLIB" )) { |
| 593 | t << "\n\t" ; |
| 594 | |
| 595 | if (!project->isActiveConfig("unversioned_libname" )) |
| 596 | t << "-$(DEL_FILE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2)" ; |
| 597 | else |
| 598 | t << "-$(DEL_FILE) $(TARGET)" ; |
| 599 | |
| 600 | t << "\n\t" << var("QMAKE_LINK_SHLIB_CMD" ); |
| 601 | |
| 602 | if (!project->isActiveConfig("unversioned_libname" )) { |
| 603 | t << "\n\t" |
| 604 | << varGlue("QMAKE_LN_SHLIB" ,"-" ," " ," $(TARGET) $(TARGET0)" ) << "\n\t" |
| 605 | << varGlue("QMAKE_LN_SHLIB" ,"-" ," " ," $(TARGET) $(TARGET1)" ) << "\n\t" |
| 606 | << varGlue("QMAKE_LN_SHLIB" ,"-" ," " ," $(TARGET) $(TARGET2)" ); |
| 607 | } |
| 608 | if (!destdir.isEmpty()) { |
| 609 | t << "\n\t" |
| 610 | << "-$(DEL_FILE) " << destdir << "$(TARGET)\n\t" |
| 611 | << "-$(MOVE) $(TARGET) " << destdir << "$(TARGET)" ; |
| 612 | |
| 613 | if (!project->isActiveConfig("unversioned_libname" )) { |
| 614 | t << "\n\t" |
| 615 | << "-$(DEL_FILE) " << destdir << "$(TARGET0)\n\t" |
| 616 | << "-$(DEL_FILE) " << destdir << "$(TARGET1)\n\t" |
| 617 | << "-$(DEL_FILE) " << destdir << "$(TARGET2)\n\t" |
| 618 | << "-$(MOVE) $(TARGET0) " << destdir << "$(TARGET0)\n\t" |
| 619 | << "-$(MOVE) $(TARGET1) " << destdir << "$(TARGET1)\n\t" |
| 620 | << "-$(MOVE) $(TARGET2) " << destdir << "$(TARGET2)" ; |
| 621 | } |
| 622 | } |
| 623 | if(!project->isEmpty("QMAKE_POST_LINK" )) |
| 624 | t << "\n\t" << var("QMAKE_POST_LINK" ); |
| 625 | t << Qt::endl << Qt::endl; |
| 626 | } else { |
| 627 | t << "\n\t" |
| 628 | << "-$(DEL_FILE) $(TARGET) $(TARGET0)\n\t" |
| 629 | << var("QMAKE_LINK_SHLIB_CMD" ) << "\n\t" ; |
| 630 | t << varGlue("QMAKE_LN_SHLIB" ,"" ," " ," $(TARGET) $(TARGET0)" ); |
| 631 | if(!destdir.isEmpty()) |
| 632 | t << "\n\t" |
| 633 | << "-$(DEL_FILE) " << destdir << "$(TARGET)\n\t" |
| 634 | << "-$(DEL_FILE) " << destdir << "$(TARGET0)\n\t" |
| 635 | << "-$(MOVE) $(TARGET) " << destdir << "$(TARGET)\n\t" |
| 636 | << "-$(MOVE) $(TARGET0) " << destdir << "$(TARGET0)\n\t" ; |
| 637 | if(!project->isEmpty("QMAKE_POST_LINK" )) |
| 638 | t << "\n\t" << var("QMAKE_POST_LINK" ); |
| 639 | t << Qt::endl << Qt::endl; |
| 640 | } |
| 641 | t << Qt::endl << Qt::endl; |
| 642 | |
| 643 | if (! project->isActiveConfig("plugin" )) { |
| 644 | t << "staticlib: " << depVar("TARGETA" ) << "\n\n" ; |
| 645 | t << depVar("TARGETA" ) << ": " << depVar("PRE_TARGETDEPS" ) << " $(OBJECTS) $(OBJCOMP)" ; |
| 646 | if(do_incremental) |
| 647 | t << " $(INCREMENTAL_OBJECTS)" ; |
| 648 | t << ' ' << depVar("POST_TARGETDEPS" ) << "\n\t" ; |
| 649 | if (!project->isEmpty("QMAKE_PRE_LINK" )) |
| 650 | t << var("QMAKE_PRE_LINK" ) << "\n\t" ; |
| 651 | t << "-$(DEL_FILE) $(TARGETA) \n\t" |
| 652 | << var("QMAKE_AR_CMD" ); |
| 653 | if(do_incremental) |
| 654 | t << " $(INCREMENTAL_OBJECTS)" ; |
| 655 | if (!project->isEmpty("QMAKE_POST_LINK" )) |
| 656 | t << "\n\t" << var("QMAKE_POST_LINK" ); |
| 657 | if(!project->isEmpty("QMAKE_RANLIB" )) |
| 658 | t << "\n\t$(RANLIB) $(TARGETA)" ; |
| 659 | t << Qt::endl << Qt::endl; |
| 660 | } |
| 661 | } else { |
| 662 | QString destdir_r = project->first("DESTDIR" ).toQString(); |
| 663 | QString destdir_d = escapeDependencyPath(destdir_r); |
| 664 | QString destdir = escapeFilePath(destdir_r); |
| 665 | allDeps = ' ' + destdir_d + depVar("TARGET" ); |
| 666 | t << "staticlib: " << destdir_d << "$(TARGET)\n\n" |
| 667 | << destdir_d << depVar("TARGET" ) << ": " << depVar("PRE_TARGETDEPS" ) |
| 668 | << " $(OBJECTS) $(OBJCOMP) " << depVar("POST_TARGETDEPS" ) << "\n\t" ; |
| 669 | if (!destdir.isEmpty()) |
| 670 | t << mkdir_p_asstring(destdir, false) << "\n\t" ; |
| 671 | if (!project->isEmpty("QMAKE_PRE_LINK" )) |
| 672 | t << var("QMAKE_PRE_LINK" ) << "\n\t" ; |
| 673 | t << "-$(DEL_FILE) " << destdir << "$(TARGET)\n\t" |
| 674 | << var("QMAKE_AR_CMD" ) << "\n" ; |
| 675 | if (!project->isEmpty("QMAKE_POST_LINK" )) |
| 676 | t << "\t" << var("QMAKE_POST_LINK" ) << "\n" ; |
| 677 | if (!project->isEmpty("QMAKE_RANLIB" )) |
| 678 | t << "\t$(RANLIB) " << destdir << "$(TARGET)\n" ; |
| 679 | t << Qt::endl << Qt::endl; |
| 680 | } |
| 681 | |
| 682 | writeMakeQmake(t); |
| 683 | if(project->isEmpty("QMAKE_FAILED_REQUIREMENTS" ) && !project->isActiveConfig("no_autoqmake" )) { |
| 684 | QStringList meta_files; |
| 685 | if (project->isActiveConfig("create_libtool" ) && project->first("TEMPLATE" ) == "lib" ) { //libtool |
| 686 | meta_files += libtoolFileName(); |
| 687 | } |
| 688 | if(project->isActiveConfig("create_pc" ) && project->first("TEMPLATE" ) == "lib" ) { //pkg-config |
| 689 | meta_files += pkgConfigFileName(); |
| 690 | } |
| 691 | if(!meta_files.isEmpty()) |
| 692 | t << escapeDependencyPaths(meta_files).join(" " ) << ": \n\t" |
| 693 | << "@$(QMAKE) -prl " << escapeFilePath(project->projectFile()) << ' ' << buildArgs(true) << Qt::endl; |
| 694 | } |
| 695 | |
| 696 | if (!project->isEmpty("QMAKE_BUNDLE" )) { |
| 697 | QHash<QString, QString> symlinks; |
| 698 | ProStringList &alldeps = project->values("ALL_DEPS" ); |
| 699 | QString bundle_dir = project->first("DESTDIR" ) + project->first("QMAKE_BUNDLE" ) + "/" ; |
| 700 | if (!project->first("QMAKE_PKGINFO" ).isEmpty()) { |
| 701 | ProString pkginfo = project->first("QMAKE_PKGINFO" ); |
| 702 | ProString pkginfo_f = escapeFilePath(pkginfo); |
| 703 | ProString pkginfo_d = escapeDependencyPath(pkginfo); |
| 704 | bundledFiles << pkginfo; |
| 705 | alldeps << pkginfo; |
| 706 | QString destdir = bundle_dir + "Contents" ; |
| 707 | t << pkginfo_d << ": \n\t" ; |
| 708 | if (!destdir.isEmpty()) |
| 709 | t << mkdir_p_asstring(destdir) << "\n\t" ; |
| 710 | t << "@$(DEL_FILE) " << pkginfo_f << "\n\t" |
| 711 | << "@echo \"APPL" |
| 712 | << (project->isEmpty("QMAKE_PKGINFO_TYPEINFO" ) |
| 713 | ? QString::fromLatin1("????" ) : project->first("QMAKE_PKGINFO_TYPEINFO" ).left(4)) |
| 714 | << "\" > " << pkginfo_f << Qt::endl; |
| 715 | } |
| 716 | if (!project->first("QMAKE_BUNDLE_RESOURCE_FILE" ).isEmpty()) { |
| 717 | ProString resources = project->first("QMAKE_BUNDLE_RESOURCE_FILE" ); |
| 718 | ProString resources_f = escapeFilePath(resources); |
| 719 | ProString resources_d = escapeDependencyPath(resources); |
| 720 | bundledFiles << resources; |
| 721 | alldeps << resources; |
| 722 | QString destdir = bundle_dir + "Contents/Resources" ; |
| 723 | t << resources_d << ": \n\t" ; |
| 724 | t << mkdir_p_asstring(destdir) << "\n\t" ; |
| 725 | t << "@touch " << resources_f << "\n\t\n" ; |
| 726 | } |
| 727 | //copy the plist |
| 728 | while (!project->isActiveConfig("no_plist" )) { // 'while' just to be able to 'break' |
| 729 | QString info_plist = project->first("QMAKE_INFO_PLIST" ).toQString(); |
| 730 | if (info_plist.isEmpty()) { |
| 731 | info_plist = escapeFilePath(specdir() + QDir::separator() + "Info.plist." + project->first("TEMPLATE" )); |
| 732 | } else if (!exists(Option::normalizePath(info_plist))) { |
| 733 | warn_msg(WarnLogic, "Could not resolve Info.plist: '%s'. Check if QMAKE_INFO_PLIST points to a valid file." , |
| 734 | info_plist.toLatin1().constData()); |
| 735 | break; |
| 736 | } else { |
| 737 | info_plist = escapeFilePath(fileFixify(info_plist)); |
| 738 | } |
| 739 | bool isFramework = project->first("TEMPLATE" ) == "lib" |
| 740 | && !project->isActiveConfig("plugin" ) |
| 741 | && project->isActiveConfig("lib_bundle" ); |
| 742 | bool isShallowBundle = project->isActiveConfig("shallow_bundle" ); |
| 743 | QString info_plist_out = bundle_dir + |
| 744 | (!isShallowBundle |
| 745 | ? (isFramework |
| 746 | ? ("Versions/" + project->first("QMAKE_FRAMEWORK_VERSION" ) + "/Resources/" ) |
| 747 | : QString("Contents/" )) |
| 748 | : QString()) |
| 749 | + "Info.plist" ; |
| 750 | bundledFiles << info_plist_out; |
| 751 | alldeps << info_plist_out; |
| 752 | QString destdir = info_plist_out.section(Option::dir_sep, 0, -2); |
| 753 | t << escapeDependencyPath(info_plist_out) << ": \n\t" ; |
| 754 | info_plist_out = escapeFilePath(info_plist_out); |
| 755 | if (!destdir.isEmpty()) |
| 756 | t << mkdir_p_asstring(destdir) << "\n\t" ; |
| 757 | ProStringList commonSedArgs; |
| 758 | if (!project->values("VERSION" ).isEmpty()) { |
| 759 | const ProString shortVersion = |
| 760 | project->first("VER_MAJ" ) + "." + |
| 761 | project->first("VER_MIN" ); |
| 762 | commonSedArgs << "-e \"s,@SHORT_VERSION@," << shortVersion << ",g\" " ; |
| 763 | commonSedArgs << "-e \"s,\\$${QMAKE_SHORT_VERSION}," << shortVersion << ",g\" " ; |
| 764 | const ProString fullVersion = |
| 765 | project->first("VER_MAJ" ) + "." + |
| 766 | project->first("VER_MIN" ) + "." + |
| 767 | project->first("VER_PAT" ); |
| 768 | commonSedArgs << "-e \"s,@FULL_VERSION@," << fullVersion << ",g\" " ; |
| 769 | commonSedArgs << "-e \"s,\\$${QMAKE_FULL_VERSION}," << fullVersion << ",g\" " ; |
| 770 | } |
| 771 | const ProString typeInfo = project->isEmpty("QMAKE_PKGINFO_TYPEINFO" ) |
| 772 | ? QString::fromLatin1("????" ) |
| 773 | : project->first("QMAKE_PKGINFO_TYPEINFO" ).left(4); |
| 774 | commonSedArgs << "-e \"s,@TYPEINFO@," << typeInfo << ",g\" " ; |
| 775 | commonSedArgs << "-e \"s,\\$${QMAKE_PKGINFO_TYPEINFO}," << typeInfo << ",g\" " ; |
| 776 | |
| 777 | QString bundlePrefix = project->first("QMAKE_TARGET_BUNDLE_PREFIX" ).toQString(); |
| 778 | if (bundlePrefix.isEmpty()) |
| 779 | bundlePrefix = "com.yourcompany" ; |
| 780 | if (bundlePrefix.endsWith("." )) |
| 781 | bundlePrefix.chop(1); |
| 782 | QString bundleIdentifier = bundlePrefix + "." + var("QMAKE_BUNDLE" ); |
| 783 | if (bundleIdentifier.endsWith(".app" )) |
| 784 | bundleIdentifier.chop(4); |
| 785 | if (bundleIdentifier.endsWith(".framework" )) |
| 786 | bundleIdentifier.chop(10); |
| 787 | // replace invalid bundle id characters |
| 788 | bundleIdentifier = rfc1034Identifier(bundleIdentifier); |
| 789 | commonSedArgs << "-e \"s,@BUNDLEIDENTIFIER@," << bundleIdentifier << ",g\" " ; |
| 790 | commonSedArgs << "-e \"s,\\$${PRODUCT_BUNDLE_IDENTIFIER}," << bundleIdentifier << ",g\" " ; |
| 791 | |
| 792 | commonSedArgs << "-e \"s,\\$${MACOSX_DEPLOYMENT_TARGET}," |
| 793 | << project->first("QMAKE_MACOSX_DEPLOYMENT_TARGET" ).toQString() << ",g\" " ; |
| 794 | commonSedArgs << "-e \"s,\\$${IPHONEOS_DEPLOYMENT_TARGET}," |
| 795 | << project->first("QMAKE_IPHONEOS_DEPLOYMENT_TARGET" ).toQString() << ",g\" " ; |
| 796 | commonSedArgs << "-e \"s,\\$${TVOS_DEPLOYMENT_TARGET}," |
| 797 | << project->first("QMAKE_TVOS_DEPLOYMENT_TARGET" ).toQString() << ",g\" " ; |
| 798 | commonSedArgs << "-e \"s,\\$${WATCHOS_DEPLOYMENT_TARGET}," |
| 799 | << project->first("QMAKE_WATCHOS_DEPLOYMENT_TARGET" ).toQString() << ",g\" " ; |
| 800 | |
| 801 | QString launchScreen = var("QMAKE_IOS_LAUNCH_SCREEN" ); |
| 802 | if (launchScreen.isEmpty()) |
| 803 | launchScreen = QLatin1String("LaunchScreen" ); |
| 804 | else |
| 805 | launchScreen = QFileInfo(launchScreen).baseName(); |
| 806 | commonSedArgs << "-e \"s,\\$${IOS_LAUNCH_SCREEN}," << launchScreen << ",g\" " ; |
| 807 | |
| 808 | if (!isFramework) { |
| 809 | ProString app_bundle_name = var("QMAKE_APPLICATION_BUNDLE_NAME" ); |
| 810 | if (app_bundle_name.isEmpty()) |
| 811 | app_bundle_name = var("QMAKE_ORIG_TARGET" ); |
| 812 | |
| 813 | ProString plugin_bundle_name = var("QMAKE_PLUGIN_BUNDLE_NAME" ); |
| 814 | if (plugin_bundle_name.isEmpty()) |
| 815 | plugin_bundle_name = var("QMAKE_ORIG_TARGET" ); |
| 816 | |
| 817 | QString icon = fileFixify(var("ICON" )); |
| 818 | t << "@$(DEL_FILE) " << info_plist_out << "\n\t" |
| 819 | << "@sed " ; |
| 820 | for (const ProString &arg : qAsConst(commonSedArgs)) |
| 821 | t << arg; |
| 822 | const QString iconName = icon.section(Option::dir_sep, -1); |
| 823 | t << "-e \"s,@ICON@," << iconName << ",g\" " |
| 824 | << "-e \"s,\\$${ASSETCATALOG_COMPILER_APPICON_NAME}," << iconName << ",g\" " |
| 825 | << "-e \"s,@EXECUTABLE@," << app_bundle_name << ",g\" " |
| 826 | << "-e \"s,@LIBRARY@," << plugin_bundle_name << ",g\" " |
| 827 | << "-e \"s,\\$${EXECUTABLE_NAME}," << (app_bundle_name.isEmpty() ? app_bundle_name : plugin_bundle_name) << ",g\" " |
| 828 | << "-e \"s,@TYPEINFO@," << typeInfo << ",g\" " |
| 829 | << "-e \"s,\\$${QMAKE_PKGINFO_TYPEINFO}," << typeInfo << ",g\" " |
| 830 | << "" << info_plist << " >" << info_plist_out << Qt::endl; |
| 831 | //copy the icon |
| 832 | if (!project->isEmpty("ICON" )) { |
| 833 | QString dir = bundle_dir + "Contents/Resources/" ; |
| 834 | const QString icon_path = dir + icon.section(Option::dir_sep, -1); |
| 835 | QString icon_path_f = escapeFilePath(icon_path); |
| 836 | bundledFiles << icon_path; |
| 837 | alldeps << icon_path; |
| 838 | t << escapeDependencyPath(icon_path) << ": " << escapeDependencyPath(icon) << "\n\t" |
| 839 | << mkdir_p_asstring(dir) << "\n\t" |
| 840 | << "@$(DEL_FILE) " << icon_path_f << "\n\t" |
| 841 | << "@$(COPY_FILE) " << escapeFilePath(icon) << ' ' << icon_path_f << Qt::endl; |
| 842 | } |
| 843 | } else { |
| 844 | ProString lib_bundle_name = var("QMAKE_FRAMEWORK_BUNDLE_NAME" ); |
| 845 | if (lib_bundle_name.isEmpty()) |
| 846 | lib_bundle_name = var("QMAKE_ORIG_TARGET" ); |
| 847 | |
| 848 | if (!isShallowBundle) |
| 849 | symlinks[bundle_dir + "Resources" ] = "Versions/Current/Resources" ; |
| 850 | t << "@$(DEL_FILE) " << info_plist_out << "\n\t" |
| 851 | << "@sed " ; |
| 852 | for (const ProString &arg : qAsConst(commonSedArgs)) |
| 853 | t << arg; |
| 854 | t << "-e \"s,@LIBRARY@," << lib_bundle_name << ",g\" " |
| 855 | << "-e \"s,\\$${EXECUTABLE_NAME}," << lib_bundle_name << ",g\" " |
| 856 | << "-e \"s,@TYPEINFO@," << typeInfo << ",g\" " |
| 857 | << "-e \"s,\\$${QMAKE_PKGINFO_TYPEINFO}," << typeInfo << ",g\" " |
| 858 | << "" << info_plist << " >" << info_plist_out << Qt::endl; |
| 859 | } |
| 860 | break; |
| 861 | } // project->isActiveConfig("no_plist") |
| 862 | //copy other data |
| 863 | if(!project->isEmpty("QMAKE_BUNDLE_DATA" )) { |
| 864 | const ProStringList &bundle_data = project->values("QMAKE_BUNDLE_DATA" ); |
| 865 | for(int i = 0; i < bundle_data.count(); i++) { |
| 866 | const ProStringList &files = project->values(ProKey(bundle_data[i] + ".files" )); |
| 867 | QString path = bundle_dir; |
| 868 | const ProKey pkey(bundle_data[i] + ".path" ); |
| 869 | if (!project->isActiveConfig("shallow_bundle" )) { |
| 870 | const ProKey vkey(bundle_data[i] + ".version" ); |
| 871 | if (!project->isEmpty(vkey)) { |
| 872 | QString version = project->first(vkey) + "/" + |
| 873 | project->first("QMAKE_FRAMEWORK_VERSION" ) + "/" ; |
| 874 | ProString name = project->first(pkey); |
| 875 | int pos = name.indexOf('/'); |
| 876 | if (pos > 0) |
| 877 | name = name.mid(0, pos); |
| 878 | symlinks[Option::fixPathToTargetOS(path + name)] = |
| 879 | project->first(vkey) + "/Current/" + name; |
| 880 | path += version; |
| 881 | } |
| 882 | } |
| 883 | path += project->first(pkey).toQString(); |
| 884 | path = Option::fixPathToTargetOS(path); |
| 885 | for(int file = 0; file < files.count(); file++) { |
| 886 | QString fn = files.at(file).toQString(); |
| 887 | QString src = fileFixify(fn, FileFixifyAbsolute); |
| 888 | if (!QFile::exists(src)) |
| 889 | src = fileFixify(fn, FileFixifyFromOutdir); |
| 890 | else |
| 891 | src = fileFixify(fn); |
| 892 | QString dst = path + Option::dir_sep + fileInfo(fn).fileName(); |
| 893 | bundledFiles << dst; |
| 894 | alldeps << dst; |
| 895 | t << escapeDependencyPath(dst) << ": " << escapeDependencyPath(src) << "\n\t" |
| 896 | << mkdir_p_asstring(path) << "\n\t" ; |
| 897 | src = escapeFilePath(src); |
| 898 | dst = escapeFilePath(dst); |
| 899 | QFileInfo fi(fileInfo(fn)); |
| 900 | if(fi.isDir()) |
| 901 | t << "@$(DEL_FILE) -r " << dst << "\n\t" |
| 902 | << "@$(COPY_DIR) " << src << " " << dst << Qt::endl; |
| 903 | else |
| 904 | t << "@$(DEL_FILE) " << dst << "\n\t" |
| 905 | << "@$(COPY_FILE) " << src << " " << dst << Qt::endl; |
| 906 | } |
| 907 | } |
| 908 | } |
| 909 | if (!symlinks.isEmpty()) { |
| 910 | QString bundle_dir_f = escapeFilePath(bundle_dir); |
| 911 | QHash<QString, QString>::ConstIterator symIt = symlinks.constBegin(), |
| 912 | symEnd = symlinks.constEnd(); |
| 913 | for (; symIt != symEnd; ++symIt) { |
| 914 | bundledFiles << symIt.key(); |
| 915 | alldeps << symIt.key(); |
| 916 | t << escapeDependencyPath(symIt.key()) << ":\n\t" |
| 917 | << mkdir_p_asstring(bundle_dir) << "\n\t" |
| 918 | << "@$(SYMLINK) " << escapeFilePath(symIt.value()) << ' ' << bundle_dir_f << Qt::endl; |
| 919 | } |
| 920 | |
| 921 | if (!project->isActiveConfig("shallow_bundle" )) { |
| 922 | QString currentLink = bundle_dir + "Versions/Current" ; |
| 923 | QString currentLink_f = escapeDependencyPath(currentLink); |
| 924 | bundledFiles << currentLink; |
| 925 | alldeps << currentLink; |
| 926 | t << currentLink_f << ": $(MAKEFILE)\n\t" |
| 927 | << mkdir_p_asstring(bundle_dir + "Versions" ) << "\n\t" |
| 928 | << "@-$(DEL_FILE) " << currentLink_f << "\n\t" |
| 929 | << "@$(SYMLINK) " << project->first("QMAKE_FRAMEWORK_VERSION" ) |
| 930 | << ' ' << currentLink_f << Qt::endl; |
| 931 | } |
| 932 | } |
| 933 | } |
| 934 | |
| 935 | t << Qt::endl << "all: " << deps |
| 936 | << valGlue(escapeDependencyPaths(project->values("ALL_DEPS" )), " \\\n\t\t" , " \\\n\t\t" , "" ) |
| 937 | << allDeps << Qt::endl << Qt::endl; |
| 938 | |
| 939 | t << "dist: distdir FORCE\n\t" ; |
| 940 | t << "(cd `dirname $(DISTDIR)` && $(TAR) $(DISTNAME).tar $(DISTNAME) && $(COMPRESS) $(DISTNAME).tar)" |
| 941 | " && $(MOVE) `dirname $(DISTDIR)`" << Option::dir_sep << "$(DISTNAME).tar.gz ." |
| 942 | " && $(DEL_FILE) -r $(DISTDIR)" ; |
| 943 | t << Qt::endl << Qt::endl; |
| 944 | |
| 945 | t << "distdir: FORCE\n\t" |
| 946 | << mkdir_p_asstring("$(DISTDIR)" , false) << "\n\t" |
| 947 | << "$(COPY_FILE) --parents $(DIST) $(DISTDIR)" << Option::dir_sep << Qt::endl; |
| 948 | if(!project->isEmpty("QMAKE_EXTRA_COMPILERS" )) { |
| 949 | const ProStringList &quc = project->values("QMAKE_EXTRA_COMPILERS" ); |
| 950 | for (ProStringList::ConstIterator it = quc.begin(); it != quc.end(); ++it) { |
| 951 | const ProStringList &var = project->values(ProKey(*it + ".input" )); |
| 952 | for (ProStringList::ConstIterator var_it = var.begin(); var_it != var.end(); ++var_it) { |
| 953 | const ProStringList &val = project->values((*var_it).toKey()); |
| 954 | if(val.isEmpty()) |
| 955 | continue; |
| 956 | t << "\t$(COPY_FILE) --parents " << escapeFilePaths(val).join(' ') |
| 957 | << " $(DISTDIR)" << Option::dir_sep << Qt::endl; |
| 958 | } |
| 959 | } |
| 960 | } |
| 961 | if(!project->isEmpty("TRANSLATIONS" )) |
| 962 | t << "\t$(COPY_FILE) --parents " << fileVar("TRANSLATIONS" ) << " $(DISTDIR)" << Option::dir_sep << Qt::endl; |
| 963 | t << Qt::endl << Qt::endl; |
| 964 | |
| 965 | QString clean_targets = " compiler_clean " + depVar("CLEAN_DEPS" ); |
| 966 | if(do_incremental) { |
| 967 | t << "incrclean:\n" ; |
| 968 | if(src_incremental) |
| 969 | t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJECTS)\n" ; |
| 970 | t << Qt::endl; |
| 971 | } |
| 972 | |
| 973 | t << "clean:" << clean_targets << "\n\t" ; |
| 974 | if(!project->isEmpty("OBJECTS" )) { |
| 975 | t << "-$(DEL_FILE) $(OBJECTS)\n\t" ; |
| 976 | } |
| 977 | if(doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER" )) { |
| 978 | ProStringList precomp_files; |
| 979 | ProString precomph_out_dir; |
| 980 | |
| 981 | if(!project->isEmpty("PRECOMPILED_DIR" )) |
| 982 | precomph_out_dir = project->first("PRECOMPILED_DIR" ); |
| 983 | precomph_out_dir += project->first("QMAKE_ORIG_TARGET" ); |
| 984 | precomph_out_dir += project->first("QMAKE_PCH_OUTPUT_EXT" ); |
| 985 | |
| 986 | if (project->isActiveConfig("icc_pch_style" )) { |
| 987 | // icc style |
| 988 | ProString pchBaseName = project->first("QMAKE_ORIG_TARGET" ); |
| 989 | ProStringList pchArchs = project->values("QMAKE_PCH_ARCHS" ); |
| 990 | if (pchArchs.isEmpty()) |
| 991 | pchArchs << ProString(); // normal single-arch PCH |
| 992 | for (const ProString &arch : qAsConst(pchArchs)) { |
| 993 | ProString pchOutput; |
| 994 | if (!project->isEmpty("PRECOMPILED_DIR" )) |
| 995 | pchOutput = project->first("PRECOMPILED_DIR" ); |
| 996 | pchOutput += pchBaseName + project->first("QMAKE_PCH_OUTPUT_EXT" ); |
| 997 | if (!arch.isEmpty()) |
| 998 | pchOutput = ProString(pchOutput.toQString().replace( |
| 999 | QStringLiteral("${QMAKE_PCH_ARCH}" ), arch.toQString())); |
| 1000 | |
| 1001 | ProString sourceFile = pchOutput + Option::cpp_ext.first(); |
| 1002 | ProString objectFile = createObjectList(ProStringList(sourceFile)).first(); |
| 1003 | precomp_files << precomph_out_dir << sourceFile << objectFile; |
| 1004 | } |
| 1005 | } else { |
| 1006 | // gcc style (including clang_pch_style) |
| 1007 | precomph_out_dir += Option::dir_sep; |
| 1008 | |
| 1009 | ProString = project->first("QMAKE_PRECOMP_PREFIX" ); |
| 1010 | ProString = project->isActiveConfig("clang_pch_style" ) |
| 1011 | ? project->first("QMAKE_PCH_OUTPUT_EXT" ) : "" ; |
| 1012 | |
| 1013 | for (const ProString &compiler : project->values("QMAKE_BUILTIN_COMPILERS" )) { |
| 1014 | if (project->isEmpty(ProKey("QMAKE_" + compiler + "FLAGS_PRECOMPILE" ))) |
| 1015 | continue; |
| 1016 | ProString language = project->first(ProKey("QMAKE_LANGUAGE_" + compiler)); |
| 1017 | if (language.isEmpty()) |
| 1018 | continue; |
| 1019 | |
| 1020 | ProStringList pchArchs = project->values("QMAKE_PCH_ARCHS" ); |
| 1021 | if (pchArchs.isEmpty()) |
| 1022 | pchArchs << ProString(); // normal single-arch PCH |
| 1023 | for (const ProString &arch : qAsConst(pchArchs)) { |
| 1024 | QString file = precomph_out_dir + header_prefix + language + header_suffix; |
| 1025 | if (!arch.isEmpty()) |
| 1026 | file.replace(QStringLiteral("${QMAKE_PCH_ARCH}" ), arch.toQString()); |
| 1027 | precomp_files += file; |
| 1028 | } |
| 1029 | } |
| 1030 | } |
| 1031 | t << "-$(DEL_FILE) " << escapeFilePaths(precomp_files).join(' ') << "\n\t" ; |
| 1032 | } |
| 1033 | if(src_incremental) |
| 1034 | t << "-$(DEL_FILE) $(INCREMENTAL_OBJECTS)\n\t" ; |
| 1035 | t << fileVarGlue("QMAKE_CLEAN" ,"-$(DEL_FILE) " ," " ,"\n\t" ) |
| 1036 | << "-$(DEL_FILE) *~ core *.core\n" |
| 1037 | << fileVarGlue("CLEAN_FILES" ,"\t-$(DEL_FILE) " ," " ,"" ) << Qt::endl << Qt::endl; |
| 1038 | |
| 1039 | ProString destdir = project->first("DESTDIR" ); |
| 1040 | if (!destdir.isEmpty() && !destdir.endsWith(Option::dir_sep)) |
| 1041 | destdir += Option::dir_sep; |
| 1042 | t << "distclean: clean " << depVar("DISTCLEAN_DEPS" ) << '\n'; |
| 1043 | if(!project->isEmpty("QMAKE_BUNDLE" )) { |
| 1044 | QString bundlePath = escapeFilePath(destdir + project->first("QMAKE_BUNDLE" )); |
| 1045 | t << "\t-$(DEL_FILE) -r " << bundlePath << Qt::endl; |
| 1046 | } else if (project->isActiveConfig("staticlib" ) || project->isActiveConfig("plugin" )) { |
| 1047 | t << "\t-$(DEL_FILE) " << escapeFilePath(destdir) << "$(TARGET) \n" ; |
| 1048 | } else if (project->values("QMAKE_APP_FLAG" ).isEmpty()) { |
| 1049 | destdir = escapeFilePath(destdir); |
| 1050 | t << "\t-$(DEL_FILE) " << destdir << "$(TARGET) \n" ; |
| 1051 | if (!project->isActiveConfig("unversioned_libname" )) { |
| 1052 | t << "\t-$(DEL_FILE) " << destdir << "$(TARGET0) " << destdir << "$(TARGET1) " |
| 1053 | << destdir << "$(TARGET2) $(TARGETA)\n" ; |
| 1054 | } else { |
| 1055 | t << "\t-$(DEL_FILE) $(TARGETA)\n" ; |
| 1056 | } |
| 1057 | } else { |
| 1058 | t << "\t-$(DEL_FILE) $(TARGET) \n" ; |
| 1059 | } |
| 1060 | t << fileVarGlue("QMAKE_DISTCLEAN" ,"\t-$(DEL_FILE) " ," " ,"\n" ); |
| 1061 | { |
| 1062 | QString ofile = fileFixify(Option::output.fileName()); |
| 1063 | if(!ofile.isEmpty()) |
| 1064 | t << "\t-$(DEL_FILE) " << escapeFilePath(ofile) << Qt::endl; |
| 1065 | } |
| 1066 | t << Qt::endl << Qt::endl; |
| 1067 | |
| 1068 | t << "####### Sub-libraries\n\n" ; |
| 1069 | if (!project->values("SUBLIBS" ).isEmpty()) { |
| 1070 | ProString libdir = "tmp/" ; |
| 1071 | if (!project->isEmpty("SUBLIBS_DIR" )) |
| 1072 | libdir = project->first("SUBLIBS_DIR" ); |
| 1073 | const ProStringList &l = project->values("SUBLIBS" ); |
| 1074 | for (it = l.begin(); it != l.end(); ++it) |
| 1075 | t << escapeDependencyPath(libdir + project->first("QMAKE_PREFIX_STATICLIB" ) + (*it) + '.' |
| 1076 | + project->first("QMAKE_EXTENSION_STATICLIB" )) << ":\n\t" |
| 1077 | << var(ProKey("MAKELIB" + *it)) << Qt::endl << Qt::endl; |
| 1078 | } |
| 1079 | |
| 1080 | if(doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER" )) { |
| 1081 | QString pchInput = project->first("PRECOMPILED_HEADER" ).toQString(); |
| 1082 | t << "###### Precompiled headers\n" ; |
| 1083 | for (const ProString &compiler : project->values("QMAKE_BUILTIN_COMPILERS" )) { |
| 1084 | QString pchOutputDir; |
| 1085 | QString pchFlags = var(ProKey("QMAKE_" + compiler + "FLAGS_PRECOMPILE" )); |
| 1086 | if(pchFlags.isEmpty()) |
| 1087 | continue; |
| 1088 | |
| 1089 | QString cflags; |
| 1090 | if (compiler == "C" || compiler == "OBJC" ) |
| 1091 | cflags += " $(CFLAGS)" ; |
| 1092 | else |
| 1093 | cflags += " $(CXXFLAGS)" ; |
| 1094 | |
| 1095 | ProStringList pchArchs = project->values("QMAKE_PCH_ARCHS" ); |
| 1096 | if (pchArchs.isEmpty()) |
| 1097 | pchArchs << ProString(); // normal single-arch PCH |
| 1098 | ProString pchBaseName = project->first("QMAKE_ORIG_TARGET" ); |
| 1099 | ProString pchOutput; |
| 1100 | if(!project->isEmpty("PRECOMPILED_DIR" )) |
| 1101 | pchOutput = project->first("PRECOMPILED_DIR" ); |
| 1102 | pchOutput += pchBaseName; |
| 1103 | pchOutput += project->first("QMAKE_PCH_OUTPUT_EXT" ); |
| 1104 | |
| 1105 | if (!project->isActiveConfig("icc_pch_style" )) { |
| 1106 | // gcc style (including clang_pch_style) |
| 1107 | ProString = project->first("QMAKE_PRECOMP_PREFIX" ); |
| 1108 | ProString = project->isActiveConfig("clang_pch_style" ) |
| 1109 | ? project->first("QMAKE_PCH_OUTPUT_EXT" ) : "" ; |
| 1110 | pchOutput += Option::dir_sep; |
| 1111 | pchOutputDir = pchOutput.toQString(); |
| 1112 | |
| 1113 | QString language = project->first(ProKey("QMAKE_LANGUAGE_" + compiler)).toQString(); |
| 1114 | if (language.isEmpty()) |
| 1115 | continue; |
| 1116 | |
| 1117 | pchOutput += header_prefix + language + header_suffix; |
| 1118 | } |
| 1119 | pchFlags.replace(QLatin1String("${QMAKE_PCH_INPUT}" ), escapeFilePath(pchInput)) |
| 1120 | .replace(QLatin1String("${QMAKE_PCH_OUTPUT_BASE}" ), escapeFilePath(pchBaseName.toQString())); |
| 1121 | for (const ProString &arch : qAsConst(pchArchs)) { |
| 1122 | auto pchArchOutput = pchOutput.toQString(); |
| 1123 | if (!arch.isEmpty()) |
| 1124 | pchArchOutput.replace(QStringLiteral("${QMAKE_PCH_ARCH}" ), arch.toQString()); |
| 1125 | |
| 1126 | const auto pchFilePath_d = escapeDependencyPath(pchArchOutput); |
| 1127 | if (!arch.isEmpty()) { |
| 1128 | t << pchFilePath_d << ": " << "EXPORT_ARCH_ARGS = -arch " << arch << "\n\n" ; |
| 1129 | t << pchFilePath_d << ": " |
| 1130 | << "EXPORT_QMAKE_XARCH_CFLAGS = $(EXPORT_QMAKE_XARCH_CFLAGS_" << arch << ")" << "\n\n" ; |
| 1131 | t << pchFilePath_d << ": " |
| 1132 | << "EXPORT_QMAKE_XARCH_LFLAGS = $(EXPORT_QMAKE_XARCH_LFLAGS_" << arch << ")" << "\n\n" ; |
| 1133 | } |
| 1134 | t << pchFilePath_d << ": " << escapeDependencyPath(pchInput) << ' ' |
| 1135 | << finalizeDependencyPaths(findDependencies(pchInput)).join(" \\\n\t\t" ); |
| 1136 | if (project->isActiveConfig("icc_pch_style" )) { |
| 1137 | QString sourceFile = pchArchOutput + Option::cpp_ext.first(); |
| 1138 | QString sourceFile_f = escapeFilePath(sourceFile); |
| 1139 | QString objectFile = createObjectList(ProStringList(sourceFile)).first().toQString(); |
| 1140 | |
| 1141 | pchFlags.replace(QLatin1String("${QMAKE_PCH_TEMP_SOURCE}" ), sourceFile_f) |
| 1142 | .replace(QLatin1String("${QMAKE_PCH_TEMP_OBJECT}" ), escapeFilePath(objectFile)); |
| 1143 | |
| 1144 | t << "\n\techo \"// Automatically generated, do not modify\" > " << sourceFile_f |
| 1145 | << "\n\trm -f " << escapeFilePath(pchArchOutput); |
| 1146 | } else { |
| 1147 | QString outDir = pchOutputDir; |
| 1148 | if (!arch.isEmpty()) |
| 1149 | outDir.replace(QStringLiteral("${QMAKE_PCH_ARCH}" ), arch.toQString()); |
| 1150 | t << "\n\t" << mkdir_p_asstring(outDir); |
| 1151 | } |
| 1152 | |
| 1153 | auto pchArchFlags = pchFlags; |
| 1154 | pchArchFlags.replace(QLatin1String("${QMAKE_PCH_OUTPUT}" ), escapeFilePath(pchArchOutput)); |
| 1155 | |
| 1156 | QString compilerExecutable; |
| 1157 | if (compiler == "C" || compiler == "OBJC" ) |
| 1158 | compilerExecutable = "$(CC)" ; |
| 1159 | else |
| 1160 | compilerExecutable = "$(CXX)" ; |
| 1161 | |
| 1162 | // compile command |
| 1163 | t << "\n\t" << compilerExecutable << cflags << " $(INCPATH) " << pchArchFlags << Qt::endl << Qt::endl; |
| 1164 | } |
| 1165 | } |
| 1166 | } |
| 1167 | |
| 1168 | writeExtraTargets(t); |
| 1169 | writeExtraCompilerTargets(t); |
| 1170 | } |
| 1171 | |
| 1172 | void UnixMakefileGenerator::init2() |
| 1173 | { |
| 1174 | if(project->isEmpty("QMAKE_FRAMEWORK_VERSION" )) |
| 1175 | project->values("QMAKE_FRAMEWORK_VERSION" ).append(project->first("VER_MAJ" )); |
| 1176 | |
| 1177 | if (project->first("TEMPLATE" ) == "aux" ) { |
| 1178 | project->values("PRL_TARGET" ) = { |
| 1179 | project->first("QMAKE_PREFIX_STATICLIB" ) + |
| 1180 | project->first("TARGET" ) |
| 1181 | }; |
| 1182 | } else if (!project->values("QMAKE_APP_FLAG" ).isEmpty()) { |
| 1183 | if(!project->isEmpty("QMAKE_BUNDLE" )) { |
| 1184 | ProString bundle_loc = project->first("QMAKE_BUNDLE_LOCATION" ); |
| 1185 | if(!bundle_loc.isEmpty() && !bundle_loc.startsWith("/" )) |
| 1186 | bundle_loc.prepend("/" ); |
| 1187 | if(!bundle_loc.endsWith("/" )) |
| 1188 | bundle_loc += "/" ; |
| 1189 | project->values("TARGET" ).first().prepend(project->first("QMAKE_BUNDLE" ) + bundle_loc); |
| 1190 | } |
| 1191 | if(!project->isEmpty("TARGET" )) |
| 1192 | project->values("TARGET" ).first().prepend(project->first("DESTDIR" )); |
| 1193 | } else if (project->isActiveConfig("staticlib" )) { |
| 1194 | project->values("PRL_TARGET" ) = |
| 1195 | project->values("TARGET" ).first().prepend(project->first("QMAKE_PREFIX_STATICLIB" )); |
| 1196 | project->values("TARGET" ).first() += "." + project->first("QMAKE_EXTENSION_STATICLIB" ); |
| 1197 | if(project->values("QMAKE_AR_CMD" ).isEmpty()) |
| 1198 | project->values("QMAKE_AR_CMD" ).append("$(AR) $(DESTDIR)$(TARGET) $(OBJECTS)" ); |
| 1199 | } else { |
| 1200 | project->values("TARGETA" ).append(project->first("DESTDIR" ) + project->first("QMAKE_PREFIX_STATICLIB" ) |
| 1201 | + project->first("TARGET" ) + "." + project->first("QMAKE_EXTENSION_STATICLIB" )); |
| 1202 | |
| 1203 | ProStringList &ar_cmd = project->values("QMAKE_AR_CMD" ); |
| 1204 | if (!ar_cmd.isEmpty()) |
| 1205 | ar_cmd[0] = ar_cmd.at(0).toQString().replace(QLatin1String("(TARGET)" ), QLatin1String("(TARGETA)" )); |
| 1206 | else |
| 1207 | ar_cmd.append("$(AR) $(TARGETA) $(OBJECTS)" ); |
| 1208 | if (!project->isEmpty("QMAKE_BUNDLE" )) { |
| 1209 | project->values("PRL_TARGET" ).prepend(project->first("QMAKE_BUNDLE" ) + |
| 1210 | "/Versions/" + project->first("QMAKE_FRAMEWORK_VERSION" ) + |
| 1211 | "/Resources/" + project->first("TARGET" )); |
| 1212 | ProString bundle_loc = project->first("QMAKE_BUNDLE_LOCATION" ); |
| 1213 | if(!bundle_loc.isEmpty() && !bundle_loc.startsWith("/" )) |
| 1214 | bundle_loc.prepend("/" ); |
| 1215 | if(!bundle_loc.endsWith("/" )) |
| 1216 | bundle_loc += "/" ; |
| 1217 | const QString target = project->first("QMAKE_BUNDLE" ) + |
| 1218 | bundle_loc + project->first("TARGET" ); |
| 1219 | project->values("TARGET_" ).append(target); |
| 1220 | if (!project->isActiveConfig("shallow_bundle" )) { |
| 1221 | project->values("TARGET_x.y" ).append(project->first("QMAKE_BUNDLE" ) + |
| 1222 | "/Versions/" + |
| 1223 | project->first("QMAKE_FRAMEWORK_VERSION" ) + |
| 1224 | bundle_loc + project->first("TARGET" )); |
| 1225 | } else { |
| 1226 | project->values("TARGET_x.y" ).append(target); |
| 1227 | } |
| 1228 | } else if(project->isActiveConfig("plugin" )) { |
| 1229 | QString prefix; |
| 1230 | if(!project->isActiveConfig("no_plugin_name_prefix" )) |
| 1231 | prefix = "lib" ; |
| 1232 | project->values("PRL_TARGET" ).prepend(prefix + project->first("TARGET" )); |
| 1233 | project->values("TARGET_x.y.z" ).append(prefix + |
| 1234 | project->first("TARGET" ) + "." + |
| 1235 | project->first("QMAKE_EXTENSION_PLUGIN" )); |
| 1236 | if(project->isActiveConfig("lib_version_first" )) |
| 1237 | project->values("TARGET_x" ).append(prefix + project->first("TARGET" ) + "." + |
| 1238 | project->first("VER_MAJ" ) + "." + |
| 1239 | project->first("QMAKE_EXTENSION_PLUGIN" )); |
| 1240 | else |
| 1241 | project->values("TARGET_x" ).append(prefix + project->first("TARGET" ) + "." + |
| 1242 | project->first("QMAKE_EXTENSION_PLUGIN" ) + |
| 1243 | "." + project->first("VER_MAJ" )); |
| 1244 | project->values("TARGET" ) = project->values("TARGET_x.y.z" ); |
| 1245 | } else if (!project->isEmpty("QMAKE_HPUX_SHLIB" )) { |
| 1246 | project->values("PRL_TARGET" ).prepend("lib" + project->first("TARGET" )); |
| 1247 | project->values("TARGET_" ).append("lib" + project->first("TARGET" ) + ".sl" ); |
| 1248 | if(project->isActiveConfig("lib_version_first" )) |
| 1249 | project->values("TARGET_x" ).append("lib" + project->first("VER_MAJ" ) + "." + |
| 1250 | project->first("TARGET" )); |
| 1251 | else |
| 1252 | project->values("TARGET_x" ).append("lib" + project->first("TARGET" ) + "." + |
| 1253 | project->first("VER_MAJ" )); |
| 1254 | project->values("TARGET" ) = project->values("TARGET_x" ); |
| 1255 | } else if (!project->isEmpty("QMAKE_AIX_SHLIB" )) { |
| 1256 | project->values("PRL_TARGET" ).prepend("lib" + project->first("TARGET" )); |
| 1257 | project->values("TARGET_" ).append(project->first("QMAKE_PREFIX_STATICLIB" ) + project->first("TARGET" ) |
| 1258 | + "." + project->first("QMAKE_EXTENSION_STATICLIB" )); |
| 1259 | if(project->isActiveConfig("lib_version_first" )) { |
| 1260 | project->values("TARGET_x" ).append("lib" + project->first("TARGET" ) + "." + |
| 1261 | project->first("VER_MAJ" ) + "." + |
| 1262 | project->first("QMAKE_EXTENSION_SHLIB" )); |
| 1263 | project->values("TARGET_x.y" ).append("lib" + project->first("TARGET" ) + "." + |
| 1264 | project->first("VER_MAJ" ) + |
| 1265 | "." + project->first("VER_MIN" ) + "." + |
| 1266 | project->first("QMAKE_EXTENSION_SHLIB" )); |
| 1267 | project->values("TARGET_x.y.z" ).append("lib" + project->first("TARGET" ) + "." + |
| 1268 | project->first("VER_MAJ" ) + "." + |
| 1269 | project->first("VER_MIN" ) + "." + |
| 1270 | project->first("VER_PAT" ) + "." + |
| 1271 | project->first("QMAKE_EXTENSION_SHLIB" )); |
| 1272 | } else { |
| 1273 | project->values("TARGET_x" ).append("lib" + project->first("TARGET" ) + "." + |
| 1274 | project->first("QMAKE_EXTENSION_SHLIB" ) + |
| 1275 | "." + project->first("VER_MAJ" )); |
| 1276 | project->values("TARGET_x.y" ).append("lib" + project->first("TARGET" ) + "." + |
| 1277 | project->first("QMAKE_EXTENSION_SHLIB" ) + |
| 1278 | "." + project->first("VER_MAJ" ) + |
| 1279 | "." + project->first("VER_MIN" )); |
| 1280 | project->values("TARGET_x.y.z" ).append("lib" + project->first("TARGET" ) + "." + |
| 1281 | project->first("QMAKE_EXTENSION_SHLIB" ) + "." + |
| 1282 | project->first("VER_MAJ" ) + "." + |
| 1283 | project->first("VER_MIN" ) + "." + |
| 1284 | project->first("VER_PAT" )); |
| 1285 | } |
| 1286 | project->values("TARGET" ) = project->values("TARGET_x.y.z" ); |
| 1287 | } else { |
| 1288 | project->values("PRL_TARGET" ).prepend("lib" + project->first("TARGET" )); |
| 1289 | project->values("TARGET_" ).append("lib" + project->first("TARGET" ) + "." + |
| 1290 | project->first("QMAKE_EXTENSION_SHLIB" )); |
| 1291 | if(project->isActiveConfig("lib_version_first" )) { |
| 1292 | project->values("TARGET_x" ).append("lib" + project->first("TARGET" ) + "." + |
| 1293 | project->first("VER_MAJ" ) + "." + |
| 1294 | project->first("QMAKE_EXTENSION_SHLIB" )); |
| 1295 | project->values("TARGET_x.y" ).append("lib" + project->first("TARGET" ) + "." + |
| 1296 | project->first("VER_MAJ" ) + |
| 1297 | "." + project->first("VER_MIN" ) + "." + |
| 1298 | project->first("QMAKE_EXTENSION_SHLIB" )); |
| 1299 | project->values("TARGET_x.y.z" ).append("lib" + project->first("TARGET" ) + "." + |
| 1300 | project->first("VER_MAJ" ) + "." + |
| 1301 | project->first("VER_MIN" ) + "." + |
| 1302 | project->first("VER_PAT" ) + "." + |
| 1303 | project->first("QMAKE_EXTENSION_SHLIB" )); |
| 1304 | } else { |
| 1305 | project->values("TARGET_x" ).append("lib" + project->first("TARGET" ) + "." + |
| 1306 | project->first("QMAKE_EXTENSION_SHLIB" ) + |
| 1307 | "." + project->first("VER_MAJ" )); |
| 1308 | project->values("TARGET_x.y" ).append("lib" + project->first("TARGET" ) + "." + |
| 1309 | project->first("QMAKE_EXTENSION_SHLIB" ) |
| 1310 | + "." + project->first("VER_MAJ" ) + |
| 1311 | "." + project->first("VER_MIN" )); |
| 1312 | project->values("TARGET_x.y.z" ).append("lib" + project->first("TARGET" ) + |
| 1313 | "." + |
| 1314 | project->first( |
| 1315 | "QMAKE_EXTENSION_SHLIB" ) + "." + |
| 1316 | project->first("VER_MAJ" ) + "." + |
| 1317 | project->first("VER_MIN" ) + "." + |
| 1318 | project->first("VER_PAT" )); |
| 1319 | } |
| 1320 | if (project->isActiveConfig("unversioned_libname" )) |
| 1321 | project->values("TARGET" ) = project->values("TARGET_" ); |
| 1322 | else |
| 1323 | project->values("TARGET" ) = project->values("TARGET_x.y.z" ); |
| 1324 | } |
| 1325 | if (!project->values("QMAKE_LFLAGS_SONAME" ).isEmpty()) { |
| 1326 | ProString soname; |
| 1327 | if(project->isActiveConfig("plugin" )) { |
| 1328 | if(!project->values("TARGET" ).isEmpty()) |
| 1329 | soname += project->first("TARGET" ); |
| 1330 | } else if(!project->isEmpty("QMAKE_BUNDLE" )) { |
| 1331 | soname += project->first("TARGET_x.y" ); |
| 1332 | } else if(project->isActiveConfig("unversioned_soname" )) { |
| 1333 | soname = "lib" + project->first("QMAKE_ORIG_TARGET" ) |
| 1334 | + "." + project->first("QMAKE_EXTENSION_SHLIB" ); |
| 1335 | } else if(!project->values("TARGET_x" ).isEmpty()) { |
| 1336 | soname += project->first("TARGET_x" ); |
| 1337 | } |
| 1338 | if(!soname.isEmpty()) { |
| 1339 | if(project->isActiveConfig("absolute_library_soname" ) && |
| 1340 | project->values("INSTALLS" ).indexOf("target" ) != -1 && |
| 1341 | !project->isEmpty("target.path" )) { |
| 1342 | QString instpath = Option::fixPathToTargetOS(project->first("target.path" ).toQString()); |
| 1343 | if(!instpath.endsWith(Option::dir_sep)) |
| 1344 | instpath += Option::dir_sep; |
| 1345 | soname.prepend(instpath); |
| 1346 | } else if (!project->isEmpty("QMAKE_SONAME_PREFIX" )) { |
| 1347 | QString sonameprefix = project->first("QMAKE_SONAME_PREFIX" ).toQString(); |
| 1348 | if (!sonameprefix.startsWith('@')) |
| 1349 | sonameprefix = Option::fixPathToTargetOS(sonameprefix, false); |
| 1350 | if (!sonameprefix.endsWith(Option::dir_sep)) |
| 1351 | sonameprefix += Option::dir_sep; |
| 1352 | soname.prepend(sonameprefix); |
| 1353 | } |
| 1354 | project->values("QMAKE_LFLAGS_SONAME" ).first() += escapeFilePath(soname); |
| 1355 | } |
| 1356 | } |
| 1357 | if (project->values("QMAKE_LINK_SHLIB_CMD" ).isEmpty()) |
| 1358 | project->values("QMAKE_LINK_SHLIB_CMD" ).append( |
| 1359 | "$(LINK) $(LFLAGS) " + project->first("QMAKE_LINK_O_FLAG" ) + "$(TARGET) $(OBJECTS) $(LIBS) $(OBJCOMP)" ); |
| 1360 | } |
| 1361 | if (!project->values("QMAKE_APP_FLAG" ).isEmpty() || project->first("TEMPLATE" ) == "aux" ) { |
| 1362 | project->values("QMAKE_CFLAGS" ) += project->values("QMAKE_CFLAGS_APP" ); |
| 1363 | project->values("QMAKE_CXXFLAGS" ) += project->values("QMAKE_CXXFLAGS_APP" ); |
| 1364 | project->values("QMAKE_LFLAGS" ) += project->values("QMAKE_LFLAGS_APP" ); |
| 1365 | } else if (project->isActiveConfig("dll" )) { |
| 1366 | if(!project->isActiveConfig("plugin" ) || !project->isActiveConfig("plugin_no_share_shlib_cflags" )) { |
| 1367 | project->values("QMAKE_CFLAGS" ) += project->values("QMAKE_CFLAGS_SHLIB" ); |
| 1368 | project->values("QMAKE_CXXFLAGS" ) += project->values("QMAKE_CXXFLAGS_SHLIB" ); |
| 1369 | } |
| 1370 | if (project->isActiveConfig("plugin" )) { |
| 1371 | project->values("QMAKE_CFLAGS" ) += project->values("QMAKE_CFLAGS_PLUGIN" ); |
| 1372 | project->values("QMAKE_CXXFLAGS" ) += project->values("QMAKE_CXXFLAGS_PLUGIN" ); |
| 1373 | project->values("QMAKE_LFLAGS" ) += project->values("QMAKE_LFLAGS_PLUGIN" ); |
| 1374 | if (project->isActiveConfig("plugin_with_soname" )) |
| 1375 | project->values("QMAKE_LFLAGS" ) += project->values("QMAKE_LFLAGS_SONAME" ); |
| 1376 | } else { |
| 1377 | project->values("QMAKE_LFLAGS" ) += project->values("QMAKE_LFLAGS_SHLIB" ); |
| 1378 | if(!project->isEmpty("QMAKE_LFLAGS_COMPAT_VERSION" )) { |
| 1379 | if(project->isEmpty("COMPAT_VERSION" )) |
| 1380 | project->values("QMAKE_LFLAGS" ) += QString(project->first("QMAKE_LFLAGS_COMPAT_VERSION" ) + |
| 1381 | project->first("VER_MAJ" ) + "." + |
| 1382 | project->first("VER_MIN" )); |
| 1383 | else |
| 1384 | project->values("QMAKE_LFLAGS" ) += QString(project->first("QMAKE_LFLAGS_COMPAT_VERSION" ) + |
| 1385 | project->first("COMPATIBILITY_VERSION" )); |
| 1386 | } |
| 1387 | if(!project->isEmpty("QMAKE_LFLAGS_VERSION" )) { |
| 1388 | project->values("QMAKE_LFLAGS" ) += QString(project->first("QMAKE_LFLAGS_VERSION" ) + |
| 1389 | project->first("VER_MAJ" ) + "." + |
| 1390 | project->first("VER_MIN" ) + "." + |
| 1391 | project->first("VER_PAT" )); |
| 1392 | } |
| 1393 | project->values("QMAKE_LFLAGS" ) += project->values("QMAKE_LFLAGS_SONAME" ); |
| 1394 | } |
| 1395 | } |
| 1396 | |
| 1397 | if (include_deps && project->isActiveConfig("gcc_MD_depends" )) { |
| 1398 | ProString MD_flag("-MD" ); |
| 1399 | project->values("QMAKE_CFLAGS" ) += MD_flag; |
| 1400 | project->values("QMAKE_CXXFLAGS" ) += MD_flag; |
| 1401 | } |
| 1402 | } |
| 1403 | |
| 1404 | QString |
| 1405 | UnixMakefileGenerator::libtoolFileName(bool fixify) |
| 1406 | { |
| 1407 | QString ret = var("TARGET" ); |
| 1408 | int slsh = ret.lastIndexOf(Option::dir_sep); |
| 1409 | if(slsh != -1) |
| 1410 | ret = ret.right(ret.length() - slsh - 1); |
| 1411 | int dot = ret.indexOf('.'); |
| 1412 | if(dot != -1) |
| 1413 | ret = ret.left(dot); |
| 1414 | ret += Option::libtool_ext; |
| 1415 | if(!project->isEmpty("QMAKE_LIBTOOL_DESTDIR" )) |
| 1416 | ret.prepend(project->first("QMAKE_LIBTOOL_DESTDIR" ) + Option::dir_sep); |
| 1417 | if(fixify) { |
| 1418 | if(QDir::isRelativePath(ret) && !project->isEmpty("DESTDIR" )) |
| 1419 | ret.prepend(project->first("DESTDIR" ).toQString()); |
| 1420 | ret = fileFixify(ret, FileFixifyBackwards); |
| 1421 | } |
| 1422 | return ret; |
| 1423 | } |
| 1424 | |
| 1425 | void |
| 1426 | UnixMakefileGenerator::writeLibtoolFile() |
| 1427 | { |
| 1428 | auto fixDependencyLibs |
| 1429 | = [this](const ProStringList &libs) |
| 1430 | { |
| 1431 | ProStringList result; |
| 1432 | for (auto lib : libs) { |
| 1433 | auto fi = fileInfo(lib.toQString()); |
| 1434 | if (fi.isAbsolute()) { |
| 1435 | const QString libDirArg = "-L" + fi.path(); |
| 1436 | if (!result.contains(libDirArg)) |
| 1437 | result += libDirArg; |
| 1438 | QString namespec = fi.fileName(); |
| 1439 | int dotPos = namespec.lastIndexOf('.'); |
| 1440 | if (dotPos != -1 && namespec.startsWith("lib" )) { |
| 1441 | namespec.truncate(dotPos); |
| 1442 | namespec.remove(0, 3); |
| 1443 | } else { |
| 1444 | debug_msg(1, "Ignoring dependency library %s" , |
| 1445 | lib.toLatin1().constData()); |
| 1446 | continue; |
| 1447 | } |
| 1448 | result += "-l" + namespec; |
| 1449 | } else { |
| 1450 | result += lib; |
| 1451 | } |
| 1452 | } |
| 1453 | return result; |
| 1454 | }; |
| 1455 | |
| 1456 | QString fname = libtoolFileName(), lname = fname; |
| 1457 | debug_msg(1, "Writing libtool file %s" , fname.toLatin1().constData()); |
| 1458 | mkdir(fileInfo(fname).path()); |
| 1459 | int slsh = lname.lastIndexOf(Option::dir_sep); |
| 1460 | if(slsh != -1) |
| 1461 | lname = lname.right(lname.length() - slsh - 1); |
| 1462 | QFile ft(fname); |
| 1463 | if(!ft.open(QIODevice::WriteOnly)) |
| 1464 | return; |
| 1465 | QString ffname(fileFixify(fname)); |
| 1466 | project->values("ALL_DEPS" ).append(ffname); |
| 1467 | project->values("QMAKE_DISTCLEAN" ).append(ffname); |
| 1468 | |
| 1469 | QTextStream t(&ft); |
| 1470 | t << "# " << lname << " - a libtool library file\n" ; |
| 1471 | t << "# Generated by qmake/libtool (" QMAKE_VERSION_STR ") (Qt " |
| 1472 | << QT_VERSION_STR << ")" ; |
| 1473 | t << "\n" ; |
| 1474 | |
| 1475 | t << "# The name that we can dlopen(3).\n" |
| 1476 | << "dlname='" << fileVar(project->isActiveConfig("plugin" ) ? "TARGET" : "TARGET_x" ) |
| 1477 | << "'\n\n" ; |
| 1478 | |
| 1479 | t << "# Names of this library.\n" ; |
| 1480 | t << "library_names='" ; |
| 1481 | if(project->isActiveConfig("plugin" )) { |
| 1482 | t << fileVar("TARGET" ); |
| 1483 | } else { |
| 1484 | if (project->isEmpty("QMAKE_HPUX_SHLIB" )) |
| 1485 | t << fileVar("TARGET_x.y.z" ) << ' '; |
| 1486 | t << fileVar("TARGET_x" ) << ' ' << fileVar("TARGET_" ); |
| 1487 | } |
| 1488 | t << "'\n\n" ; |
| 1489 | |
| 1490 | t << "# The name of the static archive.\n" |
| 1491 | << "old_library='" << escapeFilePath(lname.left(lname.length()-Option::libtool_ext.length())) |
| 1492 | << ".a'\n\n" ; |
| 1493 | |
| 1494 | t << "# Libraries that this one depends upon.\n" ; |
| 1495 | static const ProKey libVars[] = { "LIBS" , "QMAKE_LIBS" }; |
| 1496 | ProStringList libs; |
| 1497 | for (auto var : libVars) |
| 1498 | libs += fixLibFlags(var); |
| 1499 | t << "dependency_libs='" << fixDependencyLibs(libs).join(' ') << "'\n\n" ; |
| 1500 | |
| 1501 | t << "# Version information for " << lname << "\n" ; |
| 1502 | int maj = project->first("VER_MAJ" ).toInt(); |
| 1503 | int min = project->first("VER_MIN" ).toInt(); |
| 1504 | int pat = project->first("VER_PAT" ).toInt(); |
| 1505 | t << "current=" << (10*maj + min) << "\n" // best I can think of |
| 1506 | << "age=0\n" |
| 1507 | << "revision=" << pat << "\n\n" ; |
| 1508 | |
| 1509 | t << "# Is this an already installed library.\n" |
| 1510 | "installed=yes\n\n" ; // ### |
| 1511 | |
| 1512 | t << "# Files to dlopen/dlpreopen.\n" |
| 1513 | "dlopen=''\n" |
| 1514 | "dlpreopen=''\n\n" ; |
| 1515 | |
| 1516 | ProString install_dir = project->first("QMAKE_LIBTOOL_LIBDIR" ); |
| 1517 | if(install_dir.isEmpty()) |
| 1518 | install_dir = project->first("target.path" ); |
| 1519 | if(install_dir.isEmpty()) |
| 1520 | install_dir = project->first("DESTDIR" ); |
| 1521 | t << "# Directory that this library needs to be installed in:\n" |
| 1522 | "libdir='" << Option::fixPathToTargetOS(install_dir.toQString(), false) << "'\n" ; |
| 1523 | } |
| 1524 | |
| 1525 | std::pair<bool, QString> UnixMakefileGenerator::writeObjectsPart(QTextStream &t, bool do_incremental) |
| 1526 | { |
| 1527 | bool src_incremental = false; |
| 1528 | QString objectsLinkLine; |
| 1529 | const ProStringList &objs = project->values("OBJECTS" ); |
| 1530 | if (do_incremental) { |
| 1531 | const ProStringList &incrs = project->values("QMAKE_INCREMENTAL" ); |
| 1532 | ProStringList incrs_out; |
| 1533 | t << "OBJECTS = " ; |
| 1534 | for (ProStringList::ConstIterator objit = objs.begin(); objit != objs.end(); ++objit) { |
| 1535 | bool increment = false; |
| 1536 | for (ProStringList::ConstIterator incrit = incrs.begin(); incrit != incrs.end(); ++incrit) { |
| 1537 | auto regexp = QRegularExpression::fromWildcard((*incrit).toQString(), Qt::CaseSensitive, |
| 1538 | QRegularExpression::UnanchoredWildcardConversion); |
| 1539 | if ((*objit).toQString().contains(regexp)) { |
| 1540 | increment = true; |
| 1541 | incrs_out.append((*objit)); |
| 1542 | break; |
| 1543 | } |
| 1544 | } |
| 1545 | if (!increment) |
| 1546 | t << "\\\n\t\t" << (*objit); |
| 1547 | } |
| 1548 | if (incrs_out.count() == objs.count()) { //we just switched places, no real incrementals to be done! |
| 1549 | t << escapeFilePaths(incrs_out).join(QString(" \\\n\t\t" )) << Qt::endl; |
| 1550 | } else if (!incrs_out.count()) { |
| 1551 | t << Qt::endl; |
| 1552 | } else { |
| 1553 | src_incremental = true; |
| 1554 | t << Qt::endl; |
| 1555 | t << "INCREMENTAL_OBJECTS = " |
| 1556 | << escapeFilePaths(incrs_out).join(QString(" \\\n\t\t" )) << Qt::endl; |
| 1557 | } |
| 1558 | } else { |
| 1559 | const ProString &objMax = project->first("QMAKE_LINK_OBJECT_MAX" ); |
| 1560 | // Used all over the place in both deps and commands. |
| 1561 | if (objMax.isEmpty() || project->values("OBJECTS" ).count() < objMax.toInt()) { |
| 1562 | objectsLinkLine = "$(OBJECTS)" ; |
| 1563 | } else { |
| 1564 | const QString ld_response_file = createResponseFile( |
| 1565 | fileVar("OBJECTS_DIR" ) + var("QMAKE_LINK_OBJECT_SCRIPT" ), objs); |
| 1566 | objectsLinkLine = "@" + escapeFilePath(ld_response_file); |
| 1567 | } |
| 1568 | t << "OBJECTS = " << valList(escapeDependencyPaths(objs)) << Qt::endl; |
| 1569 | } |
| 1570 | return std::make_pair(src_incremental, objectsLinkLine); |
| 1571 | } |
| 1572 | |
| 1573 | QT_END_NAMESPACE |
| 1574 | |