summaryrefslogtreecommitdiff
path: root/qmake/generators/win32/winmakefile.cpp
Unidiff
Diffstat (limited to 'qmake/generators/win32/winmakefile.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/generators/win32/winmakefile.cpp148
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
@@ -101,7 +101,7 @@ Win32MakefileGenerator::writeSubDirs(QTextStream &t)
101 t << "MAKEFILE=" << var("MAKEFILE") << endl; 101 t << "MAKEFILE=" << var("MAKEFILE") << endl;
102 t << "QMAKE =" << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl; 102 t << "QMAKE =" << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl;
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;
106 t << endl << endl; 106 t << endl << endl;
107 t << "all: qmake_all $(SUBTARGETS)" << endl << endl; 107 t << "all: qmake_all $(SUBTARGETS)" << endl << endl;
@@ -116,11 +116,10 @@ Win32MakefileGenerator::writeSubDirs(QTextStream &t)
116 t << mkfile << ":"; 116 t << mkfile << ":";
117 if(project->variables()["QMAKE_NOFORCE"].isEmpty()) 117 if(project->variables()["QMAKE_NOFORCE"].isEmpty())
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) {
125 int subLevels = it.current()->directory.contains(Option::dir_sep) + 1; 124 int subLevels = it.current()->directory.contains(Option::dir_sep) + 1;
126 t << "\n\t" << "@cd .."; 125 t << "\n\t" << "@cd ..";
@@ -133,11 +132,10 @@ Win32MakefileGenerator::writeSubDirs(QTextStream &t)
133 t << (*it)->target << ": " << mkfile; 132 t << (*it)->target << ": " << mkfile;
134 if(project->variables()["QMAKE_NOFORCE"].isEmpty()) 133 if(project->variables()["QMAKE_NOFORCE"].isEmpty())
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) {
142 int subLevels = it.current()->directory.contains(Option::dir_sep) + 1; 140 int subLevels = it.current()->directory.contains(Option::dir_sep) + 1;
143 t << "\n\t" << "@cd .."; 141 t << "\n\t" << "@cd ..";
@@ -155,14 +153,16 @@ Win32MakefileGenerator::writeSubDirs(QTextStream &t)
155 if ( !subdirs.isEmpty() ) { 153 if ( !subdirs.isEmpty() ) {
156 for( it.toFirst(); it.current(); ++it) { 154 for( it.toFirst(); it.current(); ++it) {
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;
159 t << "\n\t" 158 t << "\n\t"
160 << "cd " << subdir << "\n\t"; 159 << "cd " << subdir << "\n\t";
161 int lastSlash = subdir.findRev(Option::dir_sep); 160 int lastSlash = subdir.findRev(Option::dir_sep);
162 if(lastSlash != -1) 161 if(lastSlash != -1)
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"
167 << "@cd .."; 167 << "@cd ..";
168 for(int i = 1; i < subLevels; i++ ) 168 for(int i = 1; i < subLevels; i++ )
@@ -186,13 +186,11 @@ Win32MakefileGenerator::writeSubDirs(QTextStream &t)
186 bool have_dir = !(*it)->directory.isEmpty(); 186 bool have_dir = !(*it)->directory.isEmpty();
187 if(have_dir) 187 if(have_dir)
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];
193 if(have_dir) { 191 if(have_dir) {
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 << "..";
197 } 195 }
198 } 196 }
@@ -210,26 +208,30 @@ Win32MakefileGenerator::writeSubDirs(QTextStream &t)
210 208
211 209
212int 210int
213Win32MakefileGenerator::findHighestVersion(const QString &d, const 211Win32MakefileGenerator::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);
225 int biggest=-1; 220 int biggest=-1;
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 }
234 return biggest; 236 return biggest;
235} 237}
@@ -241,60 +243,98 @@ Win32MakefileGenerator::findLibraries(const QString &where)
241 243
242 QStringList &l = project->variables()[where]; 244 QStringList &l = project->variables()[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")) {
254 QString lib = opt.right(opt.length() - 2), out; 273 QString lib = opt.right(opt.length() - 2), out;
255 if(!lib.isEmpty()) { 274 if(!lib.isEmpty()) {
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;
264 } 285 }
265 } 286 }
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 }
290 } 327 }
291 } 328 }
292 } 329 }
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 }
299 return TRUE; 339 return TRUE;
300} 340}
@@ -323,8 +363,8 @@ Win32MakefileGenerator::processPrlFiles()
323 QStringList &l = project->variables()[where]; 363 QStringList &l = project->variables()[where];
324 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 364 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
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;
329 fixEnvVariables(l); 369 fixEnvVariables(l);
330 libdirs.append(new MakefileDependDir(r.replace("\"",""), 370 libdirs.append(new MakefileDependDir(r.replace("\"",""),