bool QMakeMetaInfo::readLibtoolFile(const QString &f) { /* I can just run the .la through the .pro parser since they are compatible.. */ QMakeProject proj; QString nf = Option::normalizePath(f); if (!proj.read(nf, QMakeEvaluator::LoadProOnly)) return false; QString dirf = nf.section(QLatin1Char('/'), 0, -2); if(dirf == nf) dirf = ""; else if(!dirf.isEmpty() && !dirf.endsWith(Option::output_dir)) dirf += QLatin1Char('/'); const ProValueMap &v = proj.variables(); for (ProValueMap::ConstIterator it = v.begin(); it != v.end(); ++it) { ProStringList lst = it.value(); if(lst.count() == 1 && (lst.first().startsWith("'") || lst.first().startsWith("\"")) && lst.first().endsWith(QString(lst.first().at(0)))) lst = ProStringList(lst.first().mid(1, lst.first().length() - 2)); if(!vars.contains("QMAKE_PRL_TARGET") && (it.key() == "dlname" || it.key() == "library_names" || it.key() == "old_library")) { ProString dir = v["libdir"].first(); if ((dir.startsWith('\'') || dir.startsWith('"')) && dir.endsWith(dir.at(0))) dir = dir.mid(1, dir.length() - 2); dir = dir.trimmed(); if(!dir.isEmpty() && !dir.endsWith(QLatin1Char('/'))) dir += QLatin1Char('/'); if(lst.count() == 1) lst = ProStringList(lst.first().toQString().split(" ")); for (ProStringList::Iterator lst_it = lst.begin(); lst_it != lst.end(); ++lst_it) { bool found = false; QString dirs[] = { "", dir.toQString(), dirf, dirf + ".libs/", "(term)" }; for(int i = 0; !found && dirs[i] != "(term)"; i++) { if(QFile::exists(dirs[i] + (*lst_it))) { QString targ = dirs[i] + (*lst_it); if(QDir::isRelativePath(targ)) targ.prepend(qmake_getpwd() + QLatin1Char('/')); vars["QMAKE_PRL_TARGET"] << targ; found = true; } } if(found) break; } } else if(it.key() == "dependency_libs") { if(lst.count() == 1) { ProString dep = lst.first(); if ((dep.startsWith('\'') || dep.startsWith('"')) && dep.endsWith(dep.at(0))) dep = dep.mid(1, dep.length() - 2); lst = ProStringList(dep.trimmed().toQString().split(" ")); } for (ProStringList::Iterator lit = lst.begin(); lit != lst.end(); ++lit) { if((*lit).startsWith("-R")) { if(!conf->isEmpty("QMAKE_LFLAGS_RPATH")) (*lit) = conf->first("QMAKE_LFLAGS_RPATH") + (*lit).mid(2); } } vars["QMAKE_PRL_LIBS"] += lst; } } return true; }
bool UnixMakefileGenerator::findLibraries() { ProString libArg = project->first("QMAKE_L_FLAG"); if (libArg == "-L") libArg.clear(); QList<QMakeLocalFileName> libdirs; int libidx = 0; foreach (const ProString &dlib, project->values("QMAKE_DEFAULT_LIBDIRS")) libdirs.append(QMakeLocalFileName(dlib.toQString())); static const char * const lflags[] = { "QMAKE_LIBS", "QMAKE_LIBS_PRIVATE", 0 }; for (int i = 0; lflags[i]; i++) { ProStringList &l = project->values(lflags[i]); for (ProStringList::Iterator it = l.begin(); it != l.end(); ) { QString stub, dir, extn, opt = (*it).trimmed().toQString(); if(opt.startsWith("-")) { if(opt.startsWith("-L")) { QString lib = opt.mid(2); QMakeLocalFileName f(lib); int idx = libdirs.indexOf(f); if (idx >= 0 && idx < libidx) { it = l.erase(it); continue; } libdirs.insert(libidx++, f); if (!libArg.isEmpty()) *it = libArg + lib; } else if(opt.startsWith("-l")) { if (project->isActiveConfig("rvct_linker") || project->isActiveConfig("armcc_linker")) { (*it) = "lib" + opt.mid(2) + ".so"; } else if (project->isActiveConfig("ti_linker")) { (*it) = opt.mid(2); } else { stub = opt.mid(2); } } else if (target_mode == TARG_MAC_MODE && opt.startsWith("-framework")) { if (opt.length() == 10) ++it; // Skip } } else { extn = dir = ""; stub = opt; int slsh = opt.lastIndexOf(Option::dir_sep); if(slsh != -1) { dir = opt.left(slsh); stub = opt.mid(slsh+1); } QRegExp stub_reg("^.*lib(" + stub + "[^./=]*)\\.(.*)$"); if(stub_reg.exactMatch(stub)) { stub = stub_reg.cap(1); extn = stub_reg.cap(2); } } if(!stub.isEmpty()) { stub += project->first(ProKey("QMAKE_" + stub.toUpper() + "_SUFFIX")).toQString(); bool found = false; ProStringList extens; if(!extn.isNull()) extens << extn; else extens << project->values("QMAKE_EXTENSION_SHLIB").first() << "a"; for (ProStringList::Iterator extit = extens.begin(); extit != extens.end(); ++extit) { if(dir.isNull()) { for(QList<QMakeLocalFileName>::Iterator dep_it = libdirs.begin(); dep_it != libdirs.end(); ++dep_it) { QString pathToLib = ((*dep_it).local() + Option::dir_sep + project->values("QMAKE_PREFIX_SHLIB").first() + stub + "." + (*extit)); if(exists(pathToLib)) { (*it) = "-l" + stub; found = true; break; } } } else { QString lib = dir + project->values("QMAKE_PREFIX_SHLIB").first() + stub + "." + (*extit); if (exists(lib)) { (*it) = lib; found = true; break; } } } if(!found && project->isActiveConfig("compile_libtool")) { for(int dep_i = 0; dep_i < libdirs.size(); ++dep_i) { if(exists(libdirs[dep_i].local() + Option::dir_sep + project->values("QMAKE_PREFIX_SHLIB").first() + stub + Option::libtool_ext)) { (*it) = libdirs[dep_i].real() + Option::dir_sep + project->values("QMAKE_PREFIX_SHLIB").first() + stub + Option::libtool_ext; found = true; break; } } } } ++it; } } return false; }