Diffstat (limited to 'qmake/generators/win32/winmakefile.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | qmake/generators/win32/winmakefile.cpp | 148 |
1 files changed, 94 insertions, 54 deletions
diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp index a07c921..bc3fed9 100644 --- a/qmake/generators/win32/winmakefile.cpp +++ b/qmake/generators/win32/winmakefile.cpp | |||
@@ -103,3 +103,3 @@ Win32MakefileGenerator::writeSubDirs(QTextStream &t) | |||
103 | t << "SUBTARGETS= "; | 103 | t << "SUBTARGETS= "; |
104 | for( it.toFirst(); it.current(); ++it) | 104 | for( it.toFirst(); it.current(); ++it) |
105 | t << " \\\n\t\t" << it.current()->target; | 105 | t << " \\\n\t\t" << it.current()->target; |
@@ -118,7 +118,6 @@ Win32MakefileGenerator::writeSubDirs(QTextStream &t) | |||
118 | t << " FORCE"; | 118 | t << " FORCE"; |
119 | if(have_dir) | 119 | if(have_dir) |
120 | t << "\n\t" << "cd " << (*it)->directory; | 120 | t << "\n\t" << "cd " << (*it)->directory; |
121 | t << "\n\t" << "$(QMAKE) " << (*it)->profile << " " << buildArgs(); | 121 | t << "\n\t" << "$(QMAKE) " << (*it)->profile << " " << buildArgs(); |
122 | if((*it)->makefile != "$(MAKEFILE)") | 122 | t << " -o " << (*it)->makefile; |
123 | t << " -o " << (*it)->makefile; | ||
124 | if(have_dir) { | 123 | if(have_dir) { |
@@ -135,7 +134,6 @@ Win32MakefileGenerator::writeSubDirs(QTextStream &t) | |||
135 | t << " FORCE"; | 134 | t << " FORCE"; |
136 | if(have_dir) | 135 | if(have_dir) |
137 | t << "\n\t" << "cd " << (*it)->directory; | 136 | t << "\n\t" << "cd " << (*it)->directory; |
138 | t << "\n\t" << "$(MAKE)"; | 137 | t << "\n\t" << "$(MAKE)"; |
139 | if((*it)->makefile != "$(MAKEFILE)") | 138 | t << " -f " << (*it)->makefile; |
140 | t << " -f " << (*it)->makefile; | ||
141 | if(have_dir) { | 139 | if(have_dir) { |
@@ -157,2 +155,3 @@ Win32MakefileGenerator::writeSubDirs(QTextStream &t) | |||
157 | QString subdir = (*it)->directory; | 155 | QString subdir = (*it)->directory; |
156 | QString profile = (*it)->profile; | ||
158 | int subLevels = subdir.contains(Option::dir_sep) + 1; | 157 | int subLevels = subdir.contains(Option::dir_sep) + 1; |
@@ -163,4 +162,5 @@ Win32MakefileGenerator::writeSubDirs(QTextStream &t) | |||
163 | subdir = subdir.mid( lastSlash + 1 ); | 162 | subdir = subdir.mid( lastSlash + 1 ); |
164 | t << "$(QMAKE) " << subdir << ".pro" | 163 | t << "$(QMAKE) " |
165 | << (!project->isEmpty("MAKEFILE") ? QString(" -o ") + var("MAKEFILE") : QString("")) | 164 | << ( !profile.isEmpty() ? profile : subdir + ".pro" ) |
165 | << " -o " << (*it)->makefile | ||
166 | << " " << buildArgs() << "\n\t" | 166 | << " " << buildArgs() << "\n\t" |
@@ -188,5 +188,3 @@ Win32MakefileGenerator::writeSubDirs(QTextStream &t) | |||
188 | t << "\n\t" << "cd " << (*it)->directory; | 188 | t << "\n\t" << "cd " << (*it)->directory; |
189 | QString in_file; | 189 | QString in_file = " -f " + (*it)->makefile; |
190 | if((*it)->makefile != "$(MAKEFILE)") | ||
191 | in_file = " -f " + (*it)->makefile; | ||
192 | t << "\n\t" << "$(MAKE) " << in_file << " " << targs[x]; | 190 | t << "\n\t" << "$(MAKE) " << in_file << " " << targs[x]; |
@@ -194,3 +192,3 @@ Win32MakefileGenerator::writeSubDirs(QTextStream &t) | |||
194 | t << "\n\t" << "@cd .."; | 192 | t << "\n\t" << "@cd .."; |
195 | for(int i = 1; i < subLevels; i++ ) | 193 | for(int i = 1; i < subLevels; i++ ) |
196 | t << Option::dir_sep << ".."; | 194 | t << Option::dir_sep << ".."; |
@@ -212,13 +210,10 @@ Win32MakefileGenerator::writeSubDirs(QTextStream &t) | |||
212 | int | 210 | int |
213 | Win32MakefileGenerator::findHighestVersion(const QString &d, const | 211 | Win32MakefileGenerator::findHighestVersion(const QString &d, const QString &stem) |
214 | QString &stem) | ||
215 | { | 212 | { |
216 | if(!QFile::exists(Option::fixPathToLocalOS(d))) | 213 | QString bd = Option::fixPathToLocalOS(d, TRUE); |
214 | if(!QFile::exists(bd)) | ||
217 | return -1; | 215 | return -1; |
218 | if(!project->variables()["QMAKE_" + stem.upper() + | 216 | if(!project->variables()["QMAKE_" + stem.upper() + "_VERSION_OVERRIDE"].isEmpty()) |
219 | "_VERSION_OVERRIDE"].isEmpty()) | 217 | return project->variables()["QMAKE_" + stem.upper() + "_VERSION_OVERRIDE"].first().toInt(); |
220 | return project->variables()["QMAKE_" + stem.upper() + | 218 | |
221 | "_VERSION_OVERRIDE"].first().toInt(); | ||
222 | QString bd = d; | ||
223 | fixEnvVariables(bd); | ||
224 | QDir dir(bd); | 219 | QDir dir(bd); |
@@ -226,8 +221,15 @@ Win32MakefileGenerator::findHighestVersion(const QString &d, const | |||
226 | QStringList entries = dir.entryList(); | 221 | QStringList entries = dir.entryList(); |
227 | QRegExp regx( "(" + stem + "([0-9]*)).lib", FALSE ); | 222 | QString dllStem = stem + QTDLL_POSTFIX; |
228 | for(QStringList::Iterator it = entries.begin(); it != entries.end(); | 223 | QRegExp regx( "(" + dllStem + "([0-9]*)).lib", FALSE ); |
229 | ++it) { | 224 | for(QStringList::Iterator it = entries.begin(); it != entries.end(); ++it) { |
230 | if(regx.exactMatch((*it))) | 225 | if(regx.exactMatch((*it))) |
231 | biggest = QMAX(biggest, (regx.cap(1) == stem || | 226 | biggest = QMAX(biggest, (regx.cap(1) == dllStem || |
232 | regx.cap(2).isEmpty()) ? -1 : regx.cap(2).toInt()); | 227 | regx.cap(2).isEmpty()) ? -1 : regx.cap(2).toInt()); |
228 | } | ||
229 | if(dir.exists(dllStem + Option::prl_ext)) { | ||
230 | QMakeProject proj; | ||
231 | if(proj.read(bd + dllStem + Option::prl_ext, QDir::currentDirPath(), TRUE)) { | ||
232 | if(!proj.isEmpty("QMAKE_PRL_VERSION")) | ||
233 | biggest = QMAX(biggest, proj.first("QMAKE_PRL_VERSION").replace(".", "").toInt()); | ||
234 | } | ||
233 | } | 235 | } |
@@ -243,11 +245,28 @@ Win32MakefileGenerator::findLibraries(const QString &where) | |||
243 | QPtrList<MakefileDependDir> dirs; | 245 | QPtrList<MakefileDependDir> dirs; |
246 | { | ||
247 | QStringList &libpaths = project->variables()["QMAKE_LIBDIR"]; | ||
248 | for(QStringList::Iterator libpathit = libpaths.begin(); libpathit != libpaths.end(); ++libpathit) { | ||
249 | QString r = (*libpathit), l = r; | ||
250 | fixEnvVariables(l); | ||
251 | dirs.append(new MakefileDependDir(r.replace("\"",""), l.replace("\"",""))); | ||
252 | } | ||
253 | } | ||
244 | dirs.setAutoDelete(TRUE); | 254 | dirs.setAutoDelete(TRUE); |
245 | for(QStringList::Iterator it = l.begin(); it != l.end(); ) { | 255 | for(QStringList::Iterator it = l.begin(); it != l.end(); ) { |
246 | QString opt = (*it); | 256 | QChar quote; |
247 | bool remove = FALSE; | 257 | bool modified_opt = FALSE, remove = FALSE; |
248 | if(opt.startsWith("-L") || opt.startsWith("/L")) { | 258 | QString opt = (*it).stripWhiteSpace(); |
249 | QString r = opt.right(opt.length() - 2), l = Option::fixPathToLocalOS(r); | 259 | if((opt[0] == '\'' || opt[0] == '"') && opt[(int)opt.length()-1] == opt[0]) { |
260 | quote = opt[0]; | ||
261 | opt = opt.mid(1, opt.length()-2); | ||
262 | } | ||
263 | if(opt.startsWith("/LIBPATH:")) { | ||
264 | QString r = opt.mid(9), l = Option::fixPathToLocalOS(r); | ||
265 | dirs.append(new MakefileDependDir(r.replace("\"",""), | ||
266 | l.replace("\"",""))); | ||
267 | } else if(opt.startsWith("-L") || opt.startsWith("/L")) { | ||
268 | QString r = opt.mid(2), l = Option::fixPathToLocalOS(r); | ||
250 | dirs.append(new MakefileDependDir(r.replace("\"",""), | 269 | dirs.append(new MakefileDependDir(r.replace("\"",""), |
251 | l.replace("\"",""))); | 270 | l.replace("\"",""))); |
252 | remove = TRUE; | 271 | remove = TRUE; //we eat this switch |
253 | } else if(opt.startsWith("-l") || opt.startsWith("/l")) { | 272 | } else if(opt.startsWith("-l") || opt.startsWith("/l")) { |
@@ -256,8 +275,10 @@ Win32MakefileGenerator::findLibraries(const QString &where) | |||
256 | for(MakefileDependDir *mdd = dirs.first(); mdd; mdd = dirs.next() ) { | 275 | for(MakefileDependDir *mdd = dirs.first(); mdd; mdd = dirs.next() ) { |
276 | QString extension; | ||
257 | int ver = findHighestVersion(mdd->local_dir, lib); | 277 | int ver = findHighestVersion(mdd->local_dir, lib); |
258 | if(ver > 0) | 278 | if(ver > 0) |
259 | lib += QString::number(ver); | 279 | extension += QString::number(ver); |
260 | lib += ".lib"; | 280 | extension += ".lib"; |
261 | if(QFile::exists(mdd->local_dir + Option::dir_sep + lib)) { | 281 | if(QFile::exists(mdd->local_dir + Option::dir_sep + lib + Option::prl_ext) || |
262 | out = mdd->real_dir + Option::dir_sep + lib; | 282 | QFile::exists(mdd->local_dir + Option::dir_sep + lib + extension)) { |
283 | out = mdd->real_dir + Option::dir_sep + lib + extension; | ||
263 | break; | 284 | break; |
@@ -266,24 +287,40 @@ Win32MakefileGenerator::findLibraries(const QString &where) | |||
266 | } | 287 | } |
267 | if(out.isEmpty()) | 288 | if(out.isEmpty()) { |
268 | remove = TRUE; | 289 | remove = TRUE; //just eat it since we cannot find one.. |
269 | else | 290 | } else { |
291 | modified_opt = TRUE; | ||
270 | (*it) = out; | 292 | (*it) = out; |
293 | } | ||
271 | } else if(!QFile::exists(Option::fixPathToLocalOS(opt))) { | 294 | } else if(!QFile::exists(Option::fixPathToLocalOS(opt))) { |
272 | QString dir, file = opt; | 295 | QPtrList<MakefileDependDir> lib_dirs; |
296 | QString file = opt; | ||
273 | int slsh = file.findRev(Option::dir_sep); | 297 | int slsh = file.findRev(Option::dir_sep); |
274 | if(slsh != -1) { | 298 | if(slsh != -1) { |
275 | dir = file.left(slsh+1); | 299 | QString r = file.left(slsh+1), l = r; |
300 | fixEnvVariables(l); | ||
301 | lib_dirs.append(new MakefileDependDir(r.replace("\"",""), l.replace("\"",""))); | ||
276 | file = file.right(file.length() - slsh - 1); | 302 | file = file.right(file.length() - slsh - 1); |
277 | } | 303 | } else { |
278 | if ( !(project->variables()["QMAKE_QT_DLL"].isEmpty() && (file == "qt.lib" || file == "qt-mt.lib")) ) { | 304 | lib_dirs = dirs; |
279 | if(file.endsWith(".lib")) { | 305 | } |
280 | file = file.left(file.length() - 4); | 306 | if(file.endsWith(".lib")) { |
281 | if(!file.at(file.length()-1).isNumber()) { | 307 | file = file.left(file.length() - 4); |
282 | int ver = findHighestVersion(dir, file); | 308 | if(!file.at(file.length()-1).isNumber()) { |
309 | for(MakefileDependDir *mdd = lib_dirs.first(); mdd; mdd = lib_dirs.next() ) { | ||
310 | QString lib_tmpl(file + "%1" + ".lib"); | ||
311 | int ver = findHighestVersion(mdd->local_dir, file); | ||
283 | if(ver != -1) { | 312 | if(ver != -1) { |
284 | file = QString(dir + file + "%1" + ".lib"); | ||
285 | if(ver) | 313 | if(ver) |
286 | (*it) = file.arg(ver); | 314 | lib_tmpl = lib_tmpl.arg(ver); |
287 | else | 315 | else |
288 | (*it) = file.arg(""); | 316 | lib_tmpl = lib_tmpl.arg(""); |
317 | if(slsh != -1) { | ||
318 | QString dir = mdd->real_dir; | ||
319 | if(!dir.endsWith(Option::dir_sep)) | ||
320 | dir += Option::dir_sep; | ||
321 | lib_tmpl.prepend(dir); | ||
322 | } | ||
323 | modified_opt = TRUE; | ||
324 | (*it) = lib_tmpl; | ||
325 | break; | ||
289 | } | 326 | } |
@@ -293,6 +330,9 @@ Win32MakefileGenerator::findLibraries(const QString &where) | |||
293 | } | 330 | } |
294 | if(remove) | 331 | if(remove) { |
295 | it = l.remove(it); | 332 | it = l.remove(it); |
296 | else | 333 | } else { |
334 | if(!quote.isNull() && modified_opt) | ||
335 | (*it) = quote + (*it) + quote; | ||
297 | ++it; | 336 | ++it; |
337 | } | ||
298 | } | 338 | } |
@@ -325,4 +365,4 @@ Win32MakefileGenerator::processPrlFiles() | |||
325 | QString opt = (*it); | 365 | QString opt = (*it); |
326 | if(opt.left(1) == "/") { | 366 | if(opt.startsWith("/")) { |
327 | if(opt.left(9) == "/LIBPATH:") { | 367 | if(opt.startsWith("/LIBPATH:")) { |
328 | QString r = opt.mid(9), l = r; | 368 | QString r = opt.mid(9), l = r; |