qmake/generators/unix/unixmake.cpp
branchGCC_SURGE
changeset 31 5daf16870df6
parent 30 5dc02b23752f
equal deleted inserted replaced
27:93b982ccede2 31:5daf16870df6
    62             project->values("QMAKE_EXTENSION_SHLIB").append("so");
    62             project->values("QMAKE_EXTENSION_SHLIB").append("so");
    63         } else {
    63         } else {
    64             project->values("QMAKE_EXTENSION_SHLIB").append("dll");
    64             project->values("QMAKE_EXTENSION_SHLIB").append("dll");
    65         }
    65         }
    66     }
    66     }
       
    67 
       
    68     if (project->isEmpty("QMAKE_PREFIX_SHLIB"))
       
    69         // Prevent crash when using the empty variable.
       
    70         project->values("QMAKE_PREFIX_SHLIB").append("");
    67 
    71 
    68     if(!project->isEmpty("QMAKE_FAILED_REQUIREMENTS")) /* no point */
    72     if(!project->isEmpty("QMAKE_FAILED_REQUIREMENTS")) /* no point */
    69         return;
    73         return;
    70 
    74 
    71     QStringList &configs = project->values("CONFIG");
    75     QStringList &configs = project->values("CONFIG");
    97         project->values("QMAKE_LIB_FLAG").append("1");
   101         project->values("QMAKE_LIB_FLAG").append("1");
    98     else if(project->first("TEMPLATE") == "subdirs") {
   102     else if(project->first("TEMPLATE") == "subdirs") {
    99         MakefileGenerator::init();
   103         MakefileGenerator::init();
   100         if(project->isEmpty("MAKEFILE"))
   104         if(project->isEmpty("MAKEFILE"))
   101             project->values("MAKEFILE").append("Makefile");
   105             project->values("MAKEFILE").append("Makefile");
   102         if(project->isEmpty("QMAKE_QMAKE"))
       
   103             project->values("QMAKE_QMAKE").append("qmake");
       
   104         if(project->values("QMAKE_INTERNAL_QMAKE_DEPS").indexOf("qmake_all") == -1)
   106         if(project->values("QMAKE_INTERNAL_QMAKE_DEPS").indexOf("qmake_all") == -1)
   105             project->values("QMAKE_INTERNAL_QMAKE_DEPS").append("qmake_all");
   107             project->values("QMAKE_INTERNAL_QMAKE_DEPS").append("qmake_all");
   106         return; /* subdirs is done */
   108         return; /* subdirs is done */
   107     }
   109     }
   108 
   110 
   449                 if(opt.startsWith("-L")) {
   451                 if(opt.startsWith("-L")) {
   450                     QMakeLocalFileName f(opt.right(opt.length()-2));
   452                     QMakeLocalFileName f(opt.right(opt.length()-2));
   451                     if(!libdirs.contains(f))
   453                     if(!libdirs.contains(f))
   452                         libdirs.append(f);
   454                         libdirs.append(f);
   453                 } else if(opt.startsWith("-l")) {
   455                 } else if(opt.startsWith("-l")) {
   454                     if (project->isActiveConfig("rvct_linker")) {
   456                     if (!project->isEmpty("QMAKE_RVCT_LINKSTYLE")) {
       
   457                         (*it) = opt.mid(2);
       
   458                     } else if (project->isActiveConfig("rvct_linker")) {
   455                         (*it) = "lib" + opt.mid(2) + ".so";
   459                         (*it) = "lib" + opt.mid(2) + ".so";
   456                     } else {
   460                     } else {
   457                         stub = opt.mid(2);
   461                         stub = opt.mid(2);
   458                     }
   462                     }
   459                 } else if(Option::target_mode == Option::TARG_MACX_MODE && opt.startsWith("-F")) {
   463                 } else if(Option::target_mode == Option::TARG_MACX_MODE && opt.startsWith("-F")) {
   489                     stub += project->first("QMAKE_" + stub.toUpper() + "_SUFFIX");
   493                     stub += project->first("QMAKE_" + stub.toUpper() + "_SUFFIX");
   490                 bool found = false;
   494                 bool found = false;
   491                 QStringList extens;
   495                 QStringList extens;
   492                 if(!extn.isNull())
   496                 if(!extn.isNull())
   493                     extens << extn;
   497                     extens << extn;
       
   498                 else if (!project->isEmpty("QMAKE_SYMBIAN_SHLIB"))
       
   499                     // In Symbian you link to the stub .lib file, but run with the .dll file.
       
   500                     extens << "lib";
   494                 else
   501                 else
   495                     extens << project->values("QMAKE_EXTENSION_SHLIB").first() << "a";
   502                     extens << project->values("QMAKE_EXTENSION_SHLIB").first() << "a";
   496                 for(QStringList::Iterator extit = extens.begin(); extit != extens.end(); ++extit) {
   503                 for(QStringList::Iterator extit = extens.begin(); extit != extens.end(); ++extit) {
   497                     if(dir.isNull()) {
   504                     if(dir.isNull()) {
   498                         QString lib_stub;
       
   499                         for(QList<QMakeLocalFileName>::Iterator dep_it = libdirs.begin(); dep_it != libdirs.end(); ++dep_it) {
   505                         for(QList<QMakeLocalFileName>::Iterator dep_it = libdirs.begin(); dep_it != libdirs.end(); ++dep_it) {
   500                             if(exists((*dep_it).local() + Option::dir_sep + "lib" + stub +
   506                             QString pathToLib = ((*dep_it).local() + Option::dir_sep
   501                                       "." + (*extit))) {
   507                                     + project->values("QMAKE_PREFIX_SHLIB").first()
   502                                 lib_stub = stub;
   508                                     + stub + "." + (*extit));
       
   509                             if(exists(pathToLib)) {
       
   510                                 if (!project->isEmpty("QMAKE_RVCT_LINKSTYLE"))
       
   511                                     (*it) = pathToLib;
       
   512                                 else
       
   513                                     (*it) = "-l" + stub;
       
   514                                 found = true;
   503                                 break;
   515                                 break;
   504                             }
   516                             }
   505                         }
   517                         }
   506                         if(!lib_stub.isNull()) {
   518                     } else {
   507                             (*it) = "-l" + lib_stub;
   519                         if(exists(project->values("QMAKE_PREFIX_SHLIB").first() + stub + "." + (*extit))) {
       
   520                             (*it) = project->values("QMAKE_PREFIX_SHLIB").first() + stub + "." + (*extit);
   508                             found = true;
   521                             found = true;
   509                             break;
   522                             break;
   510                         }
   523                         }
   511                     } else {
       
   512                         if(exists("lib" + stub + "." + (*extit))) {
       
   513                             (*it) = "lib" + stub + "." + (*extit);
       
   514                             found = true;
       
   515                             break;
       
   516                         }
       
   517                     }
   524                     }
   518                 }
   525                 }
   519                 if(!found && project->isActiveConfig("compile_libtool")) {
   526                 if(!found && project->isActiveConfig("compile_libtool")) {
   520                     for(int dep_i = 0; dep_i < libdirs.size(); ++dep_i) {
   527                     for(int dep_i = 0; dep_i < libdirs.size(); ++dep_i) {
   521                         if(exists(libdirs[dep_i].local() + Option::dir_sep + "lib" + stub + Option::libtool_ext)) {
   528                         if(exists(libdirs[dep_i].local() + Option::dir_sep + project->values("QMAKE_PREFIX_SHLIB").first() + stub + Option::libtool_ext)) {
   522                             (*it) = libdirs[dep_i].real() + Option::dir_sep + "lib" + stub + Option::libtool_ext;
   529                             (*it) = libdirs[dep_i].real() + Option::dir_sep + project->values("QMAKE_PREFIX_SHLIB").first() + stub + Option::libtool_ext;
   523                             found = true;
   530                             found = true;
   524                             break;
   531                             break;
   525                         }
   532                         }
   526                     }
   533                     }
   527                 }
   534                 }
   542 void
   549 void
   543 UnixMakefileGenerator::processPrlFiles()
   550 UnixMakefileGenerator::processPrlFiles()
   544 {
   551 {
   545     QList<QMakeLocalFileName> libdirs, frameworkdirs;
   552     QList<QMakeLocalFileName> libdirs, frameworkdirs;
   546     frameworkdirs.append(QMakeLocalFileName("/System/Library/Frameworks"));
   553     frameworkdirs.append(QMakeLocalFileName("/System/Library/Frameworks"));
   547     frameworkdirs.append(QMakeLocalFileName("/Library/Frameworks"));
       
   548     const QString lflags[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_FRAMEWORKPATH_FLAGS", "QMAKE_LFLAGS", "QMAKE_LIBS", QString() };
   554     const QString lflags[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_FRAMEWORKPATH_FLAGS", "QMAKE_LFLAGS", "QMAKE_LIBS", QString() };
   549     for(int i = 0; !lflags[i].isNull(); i++) {
   555     for(int i = 0; !lflags[i].isNull(); i++) {
   550         QStringList &l = project->values(lflags[i]);
   556         QStringList &l = project->values(lflags[i]);
   551         for(int lit = 0; lit < l.size(); ++lit) {
   557         for(int lit = 0; lit < l.size(); ++lit) {
   552             QString opt = l.at(lit).trimmed();
   558             QString opt = l.at(lit).trimmed();
   558                 } else if(opt.startsWith("-l")) {
   564                 } else if(opt.startsWith("-l")) {
   559                     QString lib = opt.right(opt.length() - 2);
   565                     QString lib = opt.right(opt.length() - 2);
   560                     for(int dep_i = 0; dep_i < libdirs.size(); ++dep_i) {
   566                     for(int dep_i = 0; dep_i < libdirs.size(); ++dep_i) {
   561                         const QMakeLocalFileName &lfn = libdirs[dep_i];
   567                         const QMakeLocalFileName &lfn = libdirs[dep_i];
   562                         if(!project->isActiveConfig("compile_libtool")) { //give them the .libs..
   568                         if(!project->isActiveConfig("compile_libtool")) { //give them the .libs..
   563                             QString la = lfn.local() + Option::dir_sep + "lib" + lib + Option::libtool_ext;
   569                             QString la = lfn.local() + Option::dir_sep + project->values("QMAKE_PREFIX_SHLIB").first() + lib + Option::libtool_ext;
   564                             if(exists(la) && QFile::exists(lfn.local() + Option::dir_sep + ".libs")) {
   570                             if(exists(la) && QFile::exists(lfn.local() + Option::dir_sep + ".libs")) {
   565                                 QString dot_libs = lfn.real() + Option::dir_sep + ".libs";
   571                                 QString dot_libs = lfn.real() + Option::dir_sep + ".libs";
   566                                 l.append("-L" + dot_libs);
   572                                 l.append("-L" + dot_libs);
   567                                 libdirs.append(QMakeLocalFileName(dot_libs));
   573                                 libdirs.append(QMakeLocalFileName(dot_libs));
   568                             }
   574                             }
   569                         }
   575                         }
   570 
   576 
   571                         QString prl = lfn.local() + Option::dir_sep + "lib" + lib;
   577                         QString prl = lfn.local() + Option::dir_sep + project->values("QMAKE_PREFIX_SHLIB").first() + lib;
   572                         if(!project->isEmpty("QMAKE_" + lib.toUpper() + "_SUFFIX"))
   578                         if(!project->isEmpty("QMAKE_" + lib.toUpper() + "_SUFFIX"))
   573                             prl += project->first("QMAKE_" + lib.toUpper() + "_SUFFIX");
   579                             prl += project->first("QMAKE_" + lib.toUpper() + "_SUFFIX");
   574                         if(processPrlFile(prl)) {
   580                         if(processPrlFile(prl)) {
   575                             if(prl.startsWith(lfn.local()))
   581                             if(prl.startsWith(lfn.local()))
   576                                 prl.replace(0, lfn.local().length(), lfn.real());
   582                                 prl.replace(0, lfn.local().length(), lfn.real());
   777             uninst.append("-$(DEL_FILE) -r \"" + dst_targ + "\"");
   783             uninst.append("-$(DEL_FILE) -r \"" + dst_targ + "\"");
   778         else
   784         else
   779             uninst.append("-$(DEL_FILE) \"" + dst_targ + "\"");
   785             uninst.append("-$(DEL_FILE) \"" + dst_targ + "\"");
   780         if(!links.isEmpty()) {
   786         if(!links.isEmpty()) {
   781             for(int i = 0; i < links.size(); ++i) {
   787             for(int i = 0; i < links.size(); ++i) {
   782                 if(Option::target_mode == Option::TARG_WIN_MODE ||
   788                 if(Option::target_mode == Option::TARG_UNIX_MODE ||
   783                    Option::target_mode == Option::TARG_MAC9_MODE) {
   789                    Option::target_mode == Option::TARG_MACX_MODE) {
   784                 } else if(Option::target_mode == Option::TARG_UNIX_MODE ||
       
   785                           Option::target_mode == Option::TARG_MACX_MODE) {
       
   786                     QString link = Option::fixPathToTargetOS(destdir + links[i], false);
   790                     QString link = Option::fixPathToTargetOS(destdir + links[i], false);
   787                     int lslash = link.lastIndexOf(Option::dir_sep);
   791                     int lslash = link.lastIndexOf(Option::dir_sep);
   788                     if(lslash != -1)
   792                     if(lslash != -1)
   789                         link = link.right(link.length() - (lslash + 1));
   793                         link = link.right(link.length() - (lslash + 1));
   790                     QString dst_link = filePrefixRoot(root, fileFixify(targetdir + link, FileFixifyAbsolute));
   794                     QString dst_link = filePrefixRoot(root, fileFixify(targetdir + link, FileFixifyAbsolute));