summaryrefslogtreecommitdiff
path: root/qmake/generators/makefile.cpp
Unidiff
Diffstat (limited to 'qmake/generators/makefile.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/generators/makefile.cpp656
1 files changed, 445 insertions, 211 deletions
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
index c12375d..5ce387f 100644
--- a/qmake/generators/makefile.cpp
+++ b/qmake/generators/makefile.cpp
@@ -1,13 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2**
3** 3**
4** Definition of ________ class. 4** Implementation of MakefileGenerator class.
5** 5**
6** Created : 970521 6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
7** 7**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. 8** This file is part of qmake.
9**
10** This file is part of the network module of the Qt GUI Toolkit.
11** 9**
12** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
@@ -37,6 +35,7 @@
37 35
38#include "makefile.h" 36#include "makefile.h"
39#include "option.h" 37#include "option.h"
38#include "meta.h"
40#include <qdir.h> 39#include <qdir.h>
41#include <qfile.h> 40#include <qfile.h>
42#include <qtextstream.h> 41#include <qtextstream.h>
@@ -58,8 +57,9 @@
58#ifndef S_ISDIR 57#ifndef S_ISDIR
59 #define S_ISDIR(m)(((m) & S_IFMT) == S_IFDIR) 58 #define S_ISDIR(m)(((m) & S_IFMT) == S_IFDIR)
60#endif 59#endif
60#define QMAKE_EOL(x) (x == '\r' || x == '\n')
61 61
62static QString mkdir_p_asstring(const QString &dir) 62QString mkdir_p_asstring(const QString &dir)
63{ 63{
64 QString ret = "@$(CHK_DIR_EXISTS) \"" + dir + "\" "; 64 QString ret = "@$(CHK_DIR_EXISTS) \"" + dir + "\" ";
65 if(Option::target_mode == Option::TARG_WIN_MODE) 65 if(Option::target_mode == Option::TARG_WIN_MODE)
@@ -74,7 +74,6 @@ static bool createDir(const QString& fullPath)
74{ 74{
75 if(QFile::exists(fullPath)) 75 if(QFile::exists(fullPath))
76 return FALSE; 76 return FALSE;
77
78 QDir dirTmp; 77 QDir dirTmp;
79 bool ret = TRUE; 78 bool ret = TRUE;
80 QString pathComponent, tmpPath; 79 QString pathComponent, tmpPath;
@@ -142,7 +141,7 @@ MakefileGenerator::generateMocList(const QString &fn_target)
142 x++; 141 x++;
143 if(total_size_read >= x) { 142 if(total_size_read >= x) {
144 if(*(big_buffer + x) == '/') { //c++ style comment 143 if(*(big_buffer + x) == '/') { //c++ style comment
145 for( ;x < total_size_read && *(big_buffer + x) != '\n'; x++); 144 for( ;x < total_size_read && !QMAKE_EOL(*(big_buffer + x)); x++);
146 line_count++; 145 line_count++;
147 } else if(*(big_buffer + x) == '*') { //c style comment 146 } else if(*(big_buffer + x) == '*') { //c style comment
148 for( ;x < total_size_read; x++) { 147 for( ;x < total_size_read; x++) {
@@ -160,7 +159,7 @@ MakefileGenerator::generateMocList(const QString &fn_target)
160 x += 2; 159 x += 2;
161 break; 160 break;
162 } 161 }
163 } else if(*(big_buffer + x) == '\n') { 162 } else if(QMAKE_EOL(*(big_buffer + x))) {
164 line_count++; 163 line_count++;
165 } 164 }
166 } 165 }
@@ -187,7 +186,7 @@ MakefileGenerator::generateMocList(const QString &fn_target)
187 interesting = FALSE; 186 interesting = FALSE;
188 if(interesting) { 187 if(interesting) {
189 *(big_buffer+x+len) = '\0'; 188 *(big_buffer+x+len) = '\0';
190 debug_msg(2, "Mocgen: %s:%d Found MOC symbol %s", fn_target.latin1(), 189 debug_msg(2, "Mocgen: %s:%d Found MOC symbol %s", fn_target.latin1(),
191 line_count, big_buffer+x); 190 line_count, big_buffer+x);
192 191
193 int ext_pos = fn_target.findRev('.'); 192 int ext_pos = fn_target.findRev('.');
@@ -200,20 +199,20 @@ MakefileGenerator::generateMocList(const QString &fn_target)
200 mocFile = fn_target.left(dir_pos+1); 199 mocFile = fn_target.left(dir_pos+1);
201 200
202 bool cpp_ext = FALSE; 201 bool cpp_ext = FALSE;
203 for(QStringList::Iterator cppit = Option::cpp_ext.begin(); 202 for(QStringList::Iterator cppit = Option::cpp_ext.begin();
204 cppit != Option::cpp_ext.end(); ++cppit) { 203 cppit != Option::cpp_ext.end(); ++cppit) {
205 if((cpp_ext = (fn_target.right(ext_len) == (*cppit)))) 204 if((cpp_ext = (fn_target.right(ext_len) == (*cppit))))
206 break; 205 break;
207 } 206 }
208 if(cpp_ext) { 207 if(cpp_ext) {
209 mocFile += fn_target.mid(dir_pos+1, ext_pos - dir_pos-1) + Option::moc_ext; 208 mocFile += Option::cpp_moc_mod + fn_target.mid(dir_pos+1, ext_pos - dir_pos-1) + Option::cpp_moc_ext;
210 project->variables()["_SRCMOC"].append(mocFile); 209 project->variables()["_SRCMOC"].append(mocFile);
211 } else if(project->variables()["HEADERS"].findIndex(fn_target) != -1) { 210 } else if(project->variables()["HEADERS"].findIndex(fn_target) != -1) {
212 for(QStringList::Iterator hit = Option::h_ext.begin(); 211 for(QStringList::Iterator hit = Option::h_ext.begin();
213 hit != Option::h_ext.end(); ++hit) { 212 hit != Option::h_ext.end(); ++hit) {
214 if((fn_target.right(ext_len) == (*hit))) { 213 if((fn_target.right(ext_len) == (*hit))) {
215 mocFile += Option::moc_mod + fn_target.mid(dir_pos+1, ext_pos - dir_pos-1) + 214 mocFile += Option::h_moc_mod + fn_target.mid(dir_pos+1, ext_pos - dir_pos-1) +
216 Option::cpp_ext.first(); 215 Option::h_moc_ext;
217 logicWarn(mocFile, "SOURCES"); 216 logicWarn(mocFile, "SOURCES");
218 project->variables()["_HDRMOC"].append(mocFile); 217 project->variables()["_HDRMOC"].append(mocFile);
219 break; 218 break;
@@ -232,7 +231,7 @@ MakefileGenerator::generateMocList(const QString &fn_target)
232 231
233 while(x < total_size_read && SYMBOL_CHAR(*(big_buffer+x))) 232 while(x < total_size_read && SYMBOL_CHAR(*(big_buffer+x)))
234 x++; 233 x++;
235 if(*(big_buffer+x) == '\n') 234 if(QMAKE_EOL(*(big_buffer+x)))
236 line_count++; 235 line_count++;
237 } 236 }
238#undef OBJ_LEN 237#undef OBJ_LEN
@@ -243,9 +242,11 @@ MakefileGenerator::generateMocList(const QString &fn_target)
243bool 242bool
244MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const QString &f, bool recurse) 243MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const QString &f, bool recurse)
245{ 244{
246 QStringList &fndeps = findDependencies(f); 245 if(processedDependencies(f))
247 if(!fndeps.isEmpty())
248 return TRUE; 246 return TRUE;
247 setProcessedDependencies(f, TRUE);
248
249 QStringList &fndeps = findDependencies(f);
249 QString fn = fileFixify(f, QDir::currentDirPath(), Option::output_dir); 250 QString fn = fileFixify(f, QDir::currentDirPath(), Option::output_dir);
250 fn = Option::fixPathToLocalOS(fn, FALSE); 251 fn = Option::fixPathToLocalOS(fn, FALSE);
251 QString fix_env_fn = Option::fixPathToLocalOS(fn); 252 QString fix_env_fn = Option::fixPathToLocalOS(fn);
@@ -283,7 +284,7 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const
283 x++; 284 x++;
284 if(total_size_read >= x) { 285 if(total_size_read >= x) {
285 if(*(big_buffer + x) == '/') { //c++ style comment 286 if(*(big_buffer + x) == '/') { //c++ style comment
286 for( ; x < total_size_read && *(big_buffer + x) != '\n'; x++); 287 for( ; x < total_size_read && !QMAKE_EOL(*(big_buffer + x)); x++);
287 } else if(*(big_buffer + x) == '*') { //c style comment 288 } else if(*(big_buffer + x) == '*') { //c style comment
288 for( ; x < total_size_read; x++) { 289 for( ; x < total_size_read; x++) {
289 if(*(big_buffer + x) == '*') { 290 if(*(big_buffer + x) == '*') {
@@ -291,13 +292,16 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const
291 x += 2; 292 x += 2;
292 break; 293 break;
293 } 294 }
294 } else if(*(big_buffer + x) == '\n') { 295 } else if(QMAKE_EOL(*(big_buffer + x))) {
295 line_count++; 296 line_count++;
296 } 297 }
297 } 298 }
298 } 299 }
299 } 300 }
300 } 301 }
302 while(x < total_size_read && //Skip spaces
303 (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t'))
304 x++;
301 if(*(big_buffer + x) == '#') { 305 if(*(big_buffer + x) == '#') {
302 x++; 306 x++;
303 while(x < total_size_read && //Skip spaces after hash 307 while(x < total_size_read && //Skip spaces after hash
@@ -318,28 +322,31 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const
318 x++; 322 x++;
319 323
320 int inc_len; 324 int inc_len;
321 for(inc_len = 0; *(big_buffer + x + inc_len) != term; inc_len++); 325 for(inc_len = 0; *(big_buffer + x + inc_len) != term &&
326 !QMAKE_EOL(*(big_buffer + x + inc_len)); inc_len++);
322 *(big_buffer + x + inc_len) = '\0'; 327 *(big_buffer + x + inc_len) = '\0';
323 inc = big_buffer + x; 328 inc = big_buffer + x;
324 } else if(total_size_read >= x + 14 && !strncmp(big_buffer + x, "qmake_warning ", 14)) { 329 } else if(total_size_read >= x + 14 && !strncmp(big_buffer + x, "qmake_warning ", 14)) {
325 for(x+=14; //skip spaces after keyword 330 for(x+=14; //skip spaces after keyword
326 x < total_size_read && (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t'); 331 x < total_size_read && (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t');
327 x++); 332 x++);
328 char term = '\n'; 333 char term = 0;
329 if(*(big_buffer + x) == '"') 334 if(*(big_buffer + x) == '"')
330 term = '"'; 335 term = '"';
331 if(*(big_buffer + x) == '\'') 336 if(*(big_buffer + x) == '\'')
332 term = '\''; 337 term = '\'';
333 if(term != '\n') 338 if(term)
334 x++; 339 x++;
335 340
336 int msg_len; 341 int msg_len;
337 for(msg_len = 0; *(big_buffer + x + msg_len) != term; msg_len++); 342 for(msg_len = 0; (term && *(big_buffer + x + msg_len) != term) &&
343 !QMAKE_EOL(*(big_buffer + x + msg_len)); msg_len++);
344 const char saved_term = *(big_buffer + x + msg_len);
338 *(big_buffer + x + msg_len) = '\0'; 345 *(big_buffer + x + msg_len) = '\0';
339 QString msg = big_buffer + x; 346 QString msg = big_buffer + x;
340 debug_msg(0, "%s:%d qmake_warning -- %s", fix_env_fn.latin1(), 347 debug_msg(0, "%s:%d qmake_warning -- %s", fix_env_fn.latin1(),
341 line_count, msg.latin1()); 348 line_count, msg.latin1());
342 *(big_buffer + x + msg_len) = term; //put it back 349 *(big_buffer + x + msg_len) = saved_term; //put it back
343 } 350 }
344 } 351 }
345 } else if(ui_file) { 352 } else if(ui_file) {
@@ -351,11 +358,31 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const
351 x++; 358 x++;
352 if(total_size_read >= x + 12 && !strncmp(big_buffer + x, "includehint", 11) && 359 if(total_size_read >= x + 12 && !strncmp(big_buffer + x, "includehint", 11) &&
353 (*(big_buffer + x + 11) == ' ' || *(big_buffer + x + 11) == '>')) { 360 (*(big_buffer + x + 11) == ' ' || *(big_buffer + x + 11) == '>')) {
354 for(x += 12; *(big_buffer + x) != '>'; x++); 361 for(x += 11; *(big_buffer + x) != '>'; x++);
355 int inc_len = 0; 362 int inc_len = 0;
356 for(x += 1 ; *(big_buffer + x + inc_len) != '<'; inc_len++); 363 for(x += 1 ; *(big_buffer + x + inc_len) != '<'; inc_len++);
357 *(big_buffer + x + inc_len) = '\0'; 364 *(big_buffer + x + inc_len) = '\0';
358 inc = big_buffer + x; 365 inc = big_buffer + x;
366 } else if(total_size_read >= x + 13 && !strncmp(big_buffer + x, "customwidget", 12) &&
367 (*(big_buffer + x + 12) == ' ' || *(big_buffer + x + 12) == '>')) {
368 for(x += 13; *(big_buffer + x) != '>'; x++); //skip up to >
369 while(x < total_size_read) {
370 for(x++; *(big_buffer + x) != '<'; x++); //skip up to <
371 x++;
372 if(total_size_read >= x + 7 && !strncmp(big_buffer+x, "header", 6) &&
373 (*(big_buffer + x + 6) == ' ' || *(big_buffer + x + 6) == '>')) {
374 for(x += 7; *(big_buffer + x) != '>'; x++); //skip up to >
375 int inc_len = 0;
376 for(x += 1 ; *(big_buffer + x + inc_len) != '<'; inc_len++);
377 *(big_buffer + x + inc_len) = '\0';
378 inc = big_buffer + x;
379 break;
380 } else if(total_size_read >= x + 14 && !strncmp(big_buffer+x, "/customwidget", 13) &&
381 (*(big_buffer + x + 13) == ' ' || *(big_buffer + x + 13) == '>')) {
382 x += 14;
383 break;
384 }
385 }
359 } else if(total_size_read >= x + 8 && !strncmp(big_buffer + x, "include", 7) && 386 } else if(total_size_read >= x + 8 && !strncmp(big_buffer + x, "include", 7) &&
360 (*(big_buffer + x + 7) == ' ' || *(big_buffer + x + 7) == '>')) { 387 (*(big_buffer + x + 7) == ' ' || *(big_buffer + x + 7) == '>')) {
361 for(x += 8; *(big_buffer + x) != '>'; x++) { 388 for(x += 8; *(big_buffer + x) != '>'; x++) {
@@ -417,12 +444,15 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const
417 if(found) 444 if(found)
418 continue; 445 continue;
419 } 446 }
420
421 QString fqn; 447 QString fqn;
422 if(project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH") && 448 if(project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH") &&
423 !stat(fix_env_fndir + inc, &fst) && !S_ISDIR(fst.st_mode)) { 449 !stat(fix_env_fndir + inc, &fst) && !S_ISDIR(fst.st_mode)) {
424 fqn = fndir + inc; 450 fqn = fndir + inc;
425 goto handle_fqn; 451 goto handle_fqn;
452 } else if(project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH") &&
453 !stat(inc, &fst) && !S_ISDIR(fst.st_mode)) {
454 fqn = inc;
455 goto handle_fqn;
426 } else { 456 } else {
427 if((Option::target_mode == Option::TARG_MAC9_MODE && inc.find(':')) || 457 if((Option::target_mode == Option::TARG_MAC9_MODE && inc.find(':')) ||
428 (Option::target_mode == Option::TARG_WIN_MODE && inc[1] != ':') || 458 (Option::target_mode == Option::TARG_WIN_MODE && inc[1] != ':') ||
@@ -446,6 +476,7 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const
446 //and see if they go away.. 476 //and see if they go away..
447 if(depHeuristics.contains(inc)) { 477 if(depHeuristics.contains(inc)) {
448 fqn = depHeuristics[inc]; 478 fqn = depHeuristics[inc];
479 from_source_dir = FALSE;
449 } else if(Option::mkfile::do_dep_heuristics) { //some heuristics.. 480 } else if(Option::mkfile::do_dep_heuristics) { //some heuristics..
450 //is it a file from a .ui? 481 //is it a file from a .ui?
451 QString inc_file = inc.section(Option::dir_sep, -1); 482 QString inc_file = inc.section(Option::dir_sep, -1);
@@ -466,9 +497,9 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const
466 if(!fqn.isEmpty() && !fqn.endsWith(Option::dir_sep)) 497 if(!fqn.isEmpty() && !fqn.endsWith(Option::dir_sep))
467 fqn += Option::dir_sep; 498 fqn += Option::dir_sep;
468 fqn += inc_file; 499 fqn += inc_file;
469 from_source_dir = FALSE; //uics go in the output_dir (so don't fix them) 500 from_source_dir = FALSE; //uics go in the output_dir (so don't fix them)
470 fqn = fileFixify(fqn, QDir::currentDirPath(), Option::output_dir); 501 fqn = fileFixify(fqn, QDir::currentDirPath(), Option::output_dir);
471 goto handle_fqn; 502 goto cache_fqn;
472 } 503 }
473 } 504 }
474 } 505 }
@@ -488,7 +519,9 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const
488 d = project->first("QMAKE_ABSOLUTE_SOURCE_PATH"); 519 d = project->first("QMAKE_ABSOLUTE_SOURCE_PATH");
489 if(s == lhs) { 520 if(s == lhs) {
490 fqn = d + inc; 521 fqn = d + inc;
491 goto handle_fqn; 522 from_source_dir = FALSE; //uics go in the output_dir (so don't fix them)
523 fqn = fileFixify(fqn, QDir::currentDirPath(), Option::output_dir);
524 goto cache_fqn;
492 } 525 }
493 } 526 }
494 } 527 }
@@ -509,13 +542,16 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const
509 d = project->first("QMAKE_ABSOLUTE_SOURCE_PATH"); 542 d = project->first("QMAKE_ABSOLUTE_SOURCE_PATH");
510 if(s == lhs) { 543 if(s == lhs) {
511 fqn = d + inc; 544 fqn = d + inc;
512 goto handle_fqn; 545 from_source_dir = FALSE; //uics go in the output_dir (so don't fix them)
546 fqn = fileFixify(fqn, QDir::currentDirPath(), Option::output_dir);
547 goto cache_fqn;
513 } 548 }
514 } 549 }
515 } 550 }
516 } 551 }
517 if(mocAware() && //is it a moc file? 552 if( mocAware() && //is it a moc file?
518 (inc.endsWith(Option::cpp_ext.first()) || inc.endsWith(Option::moc_ext))) { 553 ( inc.endsWith(Option::cpp_ext.first()) || inc.endsWith(Option::cpp_moc_ext) )
554 || ( (Option::cpp_ext.first() != Option::h_moc_ext) && inc.endsWith(Option::h_moc_ext) )) {
519 QString mocs[] = { QString("_HDRMOC"), QString("_SRCMOC"), QString::null }; 555 QString mocs[] = { QString("_HDRMOC"), QString("_SRCMOC"), QString::null };
520 for(int moc = 0; !mocs[moc].isNull(); moc++) { 556 for(int moc = 0; !mocs[moc].isNull(); moc++) {
521 QStringList &l = project->variables()[mocs[moc]]; 557 QStringList &l = project->variables()[mocs[moc]];
@@ -527,8 +563,8 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const
527 //Since it is include, no need to link it in as well 563 //Since it is include, no need to link it in as well
528 project->variables()["_SRCMOC"].append((*it)); 564 project->variables()["_SRCMOC"].append((*it));
529 l.remove(it); 565 l.remove(it);
530 } else if(!findMocSource(fqn).endsWith(fn)) { 566 } else if(!findMocSource(fqn).endsWith(fileFixify(fn))) {
531 /* Not really a very good test, but this will at least avoid 567 /* Not really a very good test, but this will at least avoid
532 confusion if it really does happen (since tmake/qmake 568 confusion if it really does happen (since tmake/qmake
533 previously didn't even allow this the test is mostly accurate) */ 569 previously didn't even allow this the test is mostly accurate) */
534 warn_msg(WarnLogic, 570 warn_msg(WarnLogic,
@@ -536,11 +572,17 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const
536 inc.latin1(), fqn.latin1(), fix_env_fn.latin1()); 572 inc.latin1(), fqn.latin1(), fix_env_fn.latin1());
537 } 573 }
538 from_source_dir = FALSE; //mocs go in the output_dir (so don't fix them) 574 from_source_dir = FALSE; //mocs go in the output_dir (so don't fix them)
539 goto handle_fqn; 575 goto cache_fqn;
540 } 576 }
541 } 577 }
542 } 578 }
543 } 579 }
580 fqn = findDependency(inc); //all else fails..
581 cache_fqn:
582 if(from_source_dir) {
583 fqn = fileFixify(fqn);
584 from_source_dir = FALSE;
585 }
544 depHeuristics.insert(inc, fqn); 586 depHeuristics.insert(inc, fqn);
545 } 587 }
546 } 588 }
@@ -555,7 +597,7 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const
555 outdeps->append(fqn); 597 outdeps->append(fqn);
556 } 598 }
557 //read past new line now.. 599 //read past new line now..
558 for( ; x < total_size_read && (*(big_buffer + x) != '\n'); x++); 600 for( ; x < total_size_read && !QMAKE_EOL(*(big_buffer + x)); x++);
559 line_count++; 601 line_count++;
560 } 602 }
561 603
@@ -563,8 +605,8 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const
563 for(QStringList::Iterator fnit = fndeps.begin(); fnit != fndeps.end(); ++fnit) { 605 for(QStringList::Iterator fnit = fndeps.begin(); fnit != fndeps.end(); ++fnit) {
564 generateDependencies(dirs, (*fnit), recurse); 606 generateDependencies(dirs, (*fnit), recurse);
565 QStringList &deplist = findDependencies((*fnit)); 607 QStringList &deplist = findDependencies((*fnit));
566 for(QStringList::Iterator it = deplist.begin(); it != deplist.end(); ++it) 608 for(QStringList::Iterator it = deplist.begin(); it != deplist.end(); ++it)
567 if(fndeps.findIndex((*it)) == -1) 609 if(fndeps.findIndex((*it)) == -1 && (*it) != fn)
568 fndeps.append((*it)); 610 fndeps.append((*it));
569 } 611 }
570 } 612 }
@@ -606,10 +648,14 @@ MakefileGenerator::initOutPaths()
606 QString currentDir = QDir::currentDirPath(); 648 QString currentDir = QDir::currentDirPath();
607 QString dirs[] = { QString("OBJECTS_DIR"), QString("MOC_DIR"), QString("UI_HEADERS_DIR"), 649 QString dirs[] = { QString("OBJECTS_DIR"), QString("MOC_DIR"), QString("UI_HEADERS_DIR"),
608 QString("UI_SOURCES_DIR"), QString("UI_DIR"), QString("DESTDIR"), 650 QString("UI_SOURCES_DIR"), QString("UI_DIR"), QString("DESTDIR"),
609 QString("SUBLIBS_DIR"), QString::null }; 651 QString("SUBLIBS_DIR"), QString("DLLDESTDIR"), QString::null };
610 for(int x = 0; dirs[x] != QString::null; x++) { 652 for(int x = 0; dirs[x] != QString::null; x++) {
611 if ( !v[dirs[x]].isEmpty() ) { 653 if ( !v[dirs[x]].isEmpty() ) {
612 QString orig_path = v[dirs[x]].first(); 654 QString orig_path = v[dirs[x]].first();
655#ifdef Q_WS_WIN
656 // We don't want to add a separator for DLLDESTDIR on Windows
657 if (!(dirs[x] == "DLLDESTDIR"))
658#endif
613 { 659 {
614 QString &path = v[dirs[x]].first(); 660 QString &path = v[dirs[x]].first();
615 path = fileFixify(path, Option::output_dir, Option::output_dir); 661 path = fileFixify(path, Option::output_dir, Option::output_dir);
@@ -661,6 +707,11 @@ MakefileGenerator::initOutPaths()
661#endif 707#endif
662 } 708 }
663 } 709 }
710 if ( !v["DESTDIR"].isEmpty() ) {
711 QDir d(v["DESTDIR"].first());
712 if(Option::fixPathToLocalOS(d.absPath()) == Option::fixPathToLocalOS(Option::output_dir))
713 v.remove("DESTDIR");
714 }
664 QDir::current().cd( currentDir ); 715 QDir::current().cd( currentDir );
665} 716}
666 717
@@ -674,12 +725,17 @@ MakefileGenerator::init()
674 725
675 QMap<QString, QStringList> &v = project->variables(); 726 QMap<QString, QStringList> &v = project->variables();
676 QString paths[] = { QString("SOURCES"), QString("FORMS"), QString("YACCSOURCES"), QString("INCLUDEPATH"), 727 QString paths[] = { QString("SOURCES"), QString("FORMS"), QString("YACCSOURCES"), QString("INCLUDEPATH"),
677 QString("HEADERS"), QString("HEADERS_ORIG"), 728 QString("HEADERS"), QString("HEADERS_ORIG"), QString("LEXSOURCES"),
678 QString("LEXSOURCES"), QString("QMAKE_INTERNAL_INCLUDED_FILES"), QString::null }; 729 QString("QMAKE_INTERNAL_INCLUDED_FILES"),
730 QString("PRECOMPILED_HEADER"), QString::null };
679 for(int y = 0; paths[y] != QString::null; y++) { 731 for(int y = 0; paths[y] != QString::null; y++) {
680 QStringList &l = v[paths[y]]; 732 QStringList &l = v[paths[y]];
681 if(!l.isEmpty()) 733 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
682 l = fileFixify(l); 734 if ((*it).isEmpty())
735 continue;
736 if(QFile::exists((*it)))
737 (*it) = fileFixify((*it));
738 }
683 } 739 }
684 740
685 /* get deps and mocables */ 741 /* get deps and mocables */
@@ -761,6 +817,7 @@ MakefileGenerator::init()
761 debug_msg(2, "Dependencies (cached): %s -> %s", file.latin1(), 817 debug_msg(2, "Dependencies (cached): %s -> %s", file.latin1(),
762 files.join(" :: ").latin1()); 818 files.join(" :: ").latin1());
763 findDependencies(file) = files; 819 findDependencies(file) = files;
820 setProcessedDependencies(file, TRUE);
764 } 821 }
765 } 822 }
766 } else { 823 } else {
@@ -809,19 +866,19 @@ MakefileGenerator::init()
809 } 866 }
810 if(!noIO()) { 867 if(!noIO()) {
811 QString sources[] = { QString("OBJECTS"), QString("LEXSOURCES"), QString("YACCSOURCES"), 868 QString sources[] = { QString("OBJECTS"), QString("LEXSOURCES"), QString("YACCSOURCES"),
812 QString("HEADERS"), QString("SOURCES"), QString("FORMS"), 869 QString("HEADERS"), QString("SOURCES"), QString("FORMS"),
813 QString::null }; 870 QString("PRECOMPILED_HEADER"), QString::null };
814 depHeuristics.clear(); 871 depHeuristics.clear();
815 bool write_cache = FALSE, read_cache = QFile::exists(cache_file); 872 bool write_cache = FALSE, read_cache = QFile::exists(cache_file);
816 for(int x = 0; sources[x] != QString::null; x++) { 873 int x;
874 for(x = 0; sources[x] != QString::null; x++) {
817 QStringList vpath, &l = v[sources[x]]; 875 QStringList vpath, &l = v[sources[x]];
818 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { 876 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) {
819 if(!(*val_it).isEmpty()) { 877 if(!(*val_it).isEmpty()) {
820 QString file = Option::fixPathToLocalOS((*val_it)); 878 QString file = fileFixify((*val_it), QDir::currentDirPath(), Option::output_dir);
821 QStringList file_list(file);
822 if(!QFile::exists(file)) { 879 if(!QFile::exists(file)) {
823 bool found = FALSE; 880 bool found = FALSE;
824 if(QDir::isRelativePath(file)) { 881 if(QDir::isRelativePath((*val_it))) {
825 if(vpath.isEmpty()) 882 if(vpath.isEmpty())
826 vpath = v["VPATH_" + sources[x]] + v["VPATH"] + 883 vpath = v["VPATH_" + sources[x]] + v["VPATH"] +
827 v["QMAKE_ABSOLUTE_SOURCE_PATH"] + v["DEPENDPATH"]; 884 v["QMAKE_ABSOLUTE_SOURCE_PATH"] + v["DEPENDPATH"];
@@ -858,13 +915,12 @@ MakefileGenerator::init()
858 warn_msg(WarnLogic, "Failure to find: %s", (*val_it).latin1()); 915 warn_msg(WarnLogic, "Failure to find: %s", (*val_it).latin1());
859 continue; 916 continue;
860 } else { 917 } else {
861 file_list.clear();
862 for(int i = 0; i < (int)d.count(); i++) { 918 for(int i = 0; i < (int)d.count(); i++) {
863 file_list.append(dir + d[i]); 919 QString file = fileFixify(dir + d[i]);
864 if(i == (int)d.count() - 1) 920 if(i == (int)d.count() - 1)
865 (*val_it) = dir + d[i]; 921 (*val_it) = file;
866 else 922 else
867 l.insert(val_it, dir + d[i]); 923 l.insert(val_it, file);
868 } 924 }
869 } 925 }
870 } else { 926 } else {
@@ -876,44 +932,46 @@ MakefileGenerator::init()
876 } 932 }
877 } 933 }
878 } 934 }
879 for(QStringList::Iterator file_it = file_list.begin(); 935 }
880 file_it != file_list.end(); ++file_it) { 936 }
881 QString file_list_file = fileFixify((*file_it)); 937 }
882 bool found_cache_moc = FALSE, found_cache_dep = FALSE; 938 for(x = 0; sources[x] != QString::null; x++) {
883 if(read_cache && Option::output.name() != "-" && 939 QStringList &l = v[sources[x]];
884 project->isActiveConfig("qmake_cache")) { 940 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) {
885 if(!findDependencies(file_list_file).isEmpty()) 941 bool found_cache_moc = FALSE, found_cache_dep = FALSE;
886 found_cache_dep = TRUE; 942 if(read_cache && Option::output.name() != "-" &&
887 if(cache_found_files[(*file_it)] == (void *)2) 943 project->isActiveConfig("qmake_cache")) {
888 found_cache_moc = TRUE; 944 if(processedDependencies((*val_it)))
889 if(!found_cache_moc || !found_cache_dep) 945 found_cache_dep = TRUE;
890 write_cache = TRUE; 946 if(cache_found_files[(*val_it)] == (void *)2)
891 } 947 found_cache_moc = TRUE;
892 /* Do moc before dependency checking since some includes can come from 948 if(!found_cache_moc || !found_cache_dep)
893 moc_*.cpp files */ 949 write_cache = TRUE;
894 if(found_cache_moc) { 950 }
895 QString moc = findMocDestination(file_list_file); 951 /* Do moc before dependency checking since some includes can come from
896 if(!moc.isEmpty()) { 952 moc_*.cpp files */
897 for(QStringList::Iterator cppit = Option::cpp_ext.begin(); 953 if(found_cache_moc) {
898 cppit != Option::cpp_ext.end(); ++cppit) { 954 QString fixed_file(fileFixify((*val_it), QDir::currentDirPath(), Option::output_dir));
899 if(file_list_file.endsWith((*cppit))) { 955 QString moc = findMocDestination(fixed_file);
900 QStringList &deps = findDependencies(file_list_file); 956 if(!moc.isEmpty()) {
901 if(!deps.contains(moc)) 957 for(QStringList::Iterator cppit = Option::cpp_ext.begin();
902 deps.append(moc); 958 cppit != Option::cpp_ext.end(); ++cppit) {
903 break; 959 if(fixed_file.endsWith((*cppit))) {
904 } 960 QStringList &deps = findDependencies(fixed_file);
905 } 961 if(!deps.contains(moc))
962 deps.append(moc);
963 break;
906 } 964 }
907 } else if(mocAware() && (sources[x] == "SOURCES" || sources[x] == "HEADERS") &&
908 (Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT ||
909 Option::mkfile::do_mocs)) {
910 generateMocList((*file_it));
911 }
912 if(!found_cache_dep && sources[x] != "OBJECTS") {
913 debug_msg(5, "Looking for dependencies for %s", (*file_it).latin1());
914 generateDependencies(deplist, (*file_it), doDepends());
915 } 965 }
916 } 966 }
967 } else if(mocAware() && (sources[x] == "SOURCES" || sources[x] == "HEADERS") &&
968 (Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT ||
969 Option::mkfile::do_mocs)) {
970 generateMocList((*val_it));
971 }
972 if(!found_cache_dep && sources[x] != "OBJECTS") {
973 debug_msg(5, "Looking for dependencies for %s", (*val_it).latin1());
974 generateDependencies(deplist, (*val_it), doDepends());
917 } 975 }
918 } 976 }
919 } 977 }
@@ -932,7 +990,7 @@ MakefileGenerator::init()
932 cachet << "[depend]" << endl; 990 cachet << "[depend]" << endl;
933 for(QMap<QString, QStringList>::Iterator it = depends.begin(); 991 for(QMap<QString, QStringList>::Iterator it = depends.begin();
934 it != depends.end(); ++it) 992 it != depends.end(); ++it)
935 cachet << depKeyMap[it.key()] << " = " << it.data().join(" ") << endl; 993 cachet << dependencyKey(it.key()) << " = " << it.data().join(" ") << endl;
936 cachet << "[mocable]" << endl; 994 cachet << "[mocable]" << endl;
937 QString mc, moc_sources[] = { QString("HEADERS"), QString("SOURCES"), QString::null }; 995 QString mc, moc_sources[] = { QString("HEADERS"), QString("SOURCES"), QString::null };
938 for(int x = 0; moc_sources[x] != QString::null; x++) { 996 for(int x = 0; moc_sources[x] != QString::null; x++) {
@@ -1053,7 +1111,7 @@ MakefileGenerator::init()
1053 } else { 1111 } else {
1054 if(decl.isEmpty() && !project->isEmpty("UI_HEADERS_DIR")) 1112 if(decl.isEmpty() && !project->isEmpty("UI_HEADERS_DIR"))
1055 decl = project->first("UI_HEADERS_DIR"); 1113 decl = project->first("UI_HEADERS_DIR");
1056 if(!decl.isEmpty() || (project->isEmpty("UI_HEADERS_DIR") && 1114 if(!decl.isEmpty() || (project->isEmpty("UI_HEADERS_DIR") &&
1057 !project->isEmpty("UI_SOURCES_DIR")) ) { 1115 !project->isEmpty("UI_SOURCES_DIR")) ) {
1058 QString d = fi.dirPath(); 1116 QString d = fi.dirPath();
1059 if( d == ".") 1117 if( d == ".")
@@ -1072,10 +1130,10 @@ MakefileGenerator::init()
1072 } 1130 }
1073 } 1131 }
1074 impl = fileFixify(impl, QDir::currentDirPath(), Option::output_dir); 1132 impl = fileFixify(impl, QDir::currentDirPath(), Option::output_dir);
1075 if(!impl.isEmpty()) 1133 if(!impl.isEmpty() && !impl.endsWith(Option::dir_sep))
1076 impl += Option::dir_sep; 1134 impl += Option::dir_sep;
1077 impl += fi.baseName(TRUE) + Option::cpp_ext.first(); 1135 impl += fi.baseName(TRUE) + Option::cpp_ext.first();
1078 if(Option::output_dir != QDir::currentDirPath() && 1136 if(Option::output_dir != QDir::currentDirPath() &&
1079 project->isEmpty("UI_DIR") && project->isEmpty("UI_HEADERS_DIR")) { 1137 project->isEmpty("UI_DIR") && project->isEmpty("UI_HEADERS_DIR")) {
1080 QString decl_fixed = fileFixify(decl, QDir::currentDirPath(), Option::output_dir); 1138 QString decl_fixed = fileFixify(decl, QDir::currentDirPath(), Option::output_dir);
1081 if(!includepath.contains(decl_fixed)) 1139 if(!includepath.contains(decl_fixed))
@@ -1084,7 +1142,7 @@ MakefileGenerator::init()
1084 project->variables()["INCLUDEPATH"].append(decl); 1142 project->variables()["INCLUDEPATH"].append(decl);
1085 } 1143 }
1086 decl = fileFixify(decl, QDir::currentDirPath(), Option::output_dir); 1144 decl = fileFixify(decl, QDir::currentDirPath(), Option::output_dir);
1087 if(!decl.isEmpty()) 1145 if(!decl.isEmpty() && !decl.endsWith(Option::dir_sep))
1088 decl += Option::dir_sep; 1146 decl += Option::dir_sep;
1089 decl += fi.baseName(TRUE) + Option::h_ext.first(); 1147 decl += fi.baseName(TRUE) + Option::h_ext.first();
1090 logicWarn(impl, "SOURCES"); 1148 logicWarn(impl, "SOURCES");
@@ -1093,7 +1151,7 @@ MakefileGenerator::init()
1093 impls.append(impl); 1151 impls.append(impl);
1094 findDependencies(impl).append(decl); 1152 findDependencies(impl).append(decl);
1095 1153
1096 QString mocable = Option::moc_mod + fi.baseName(TRUE) + Option::cpp_ext.first(); 1154 QString mocable = Option::h_moc_mod + fi.baseName(TRUE) + Option::h_moc_ext;
1097 if(!v["MOC_DIR"].isEmpty()) 1155 if(!v["MOC_DIR"].isEmpty())
1098 mocable.prepend(v["MOC_DIR"].first()); 1156 mocable.prepend(v["MOC_DIR"].first());
1099 else if(fi.dirPath() != ".") 1157 else if(fi.dirPath() != ".")
@@ -1106,6 +1164,14 @@ MakefileGenerator::init()
1106 v["OBJECTS"] += (v["UICOBJECTS"] = createObjectList("UICDECLS")); 1164 v["OBJECTS"] += (v["UICOBJECTS"] = createObjectList("UICDECLS"));
1107 } 1165 }
1108 1166
1167 //Translation files
1168 if(!project->isEmpty("TRANSLATIONS")) {
1169 QStringList &trf = project->variables()["TRANSLATIONS"];
1170 for(QStringList::Iterator it = trf.begin(); it != trf.end(); ++it) {
1171 (*it) = Option::fixPathToLocalOS((*it));
1172 }
1173 }
1174
1109 //Image files 1175 //Image files
1110 if(!project->isEmpty("IMAGES")) { 1176 if(!project->isEmpty("IMAGES")) {
1111 if(project->isEmpty("QMAKE_IMAGE_COLLECTION")) 1177 if(project->isEmpty("QMAKE_IMAGE_COLLECTION"))
@@ -1132,7 +1198,7 @@ MakefileGenerator::init()
1132 } 1198 }
1133 v["OBJECTS"] += (v["IMAGEOBJECTS"] = createObjectList("QMAKE_IMAGE_COLLECTION")); 1199 v["OBJECTS"] += (v["IMAGEOBJECTS"] = createObjectList("QMAKE_IMAGE_COLLECTION"));
1134 } 1200 }
1135 if(Option::output_dir != QDir::currentDirPath()) 1201 if(Option::output_dir != QDir::currentDirPath())
1136 project->variables()["INCLUDEPATH"].append(fileFixify(Option::output_dir, Option::output_dir, 1202 project->variables()["INCLUDEPATH"].append(fileFixify(Option::output_dir, Option::output_dir,
1137 Option::output_dir)); 1203 Option::output_dir));
1138 1204
@@ -1140,7 +1206,8 @@ MakefileGenerator::init()
1140 if ( mocAware() ) { 1206 if ( mocAware() ) {
1141 if(!project->isEmpty("MOC_DIR")) 1207 if(!project->isEmpty("MOC_DIR"))
1142 project->variables()["INCLUDEPATH"].append(project->first("MOC_DIR")); 1208 project->variables()["INCLUDEPATH"].append(project->first("MOC_DIR"));
1143 v["OBJMOC"] = createObjectList("_HDRMOC") + createObjectList("_UIMOC"); 1209 if ( Option::h_moc_ext == Option::cpp_ext.first() )
1210 v["OBJMOC"] = createObjectList("_HDRMOC") + createObjectList("_UIMOC");
1144 1211
1145 QStringList &l = v["SRCMOC"]; 1212 QStringList &l = v["SRCMOC"];
1146 l = v["_HDRMOC"] + v["_UIMOC"] + v["_SRCMOC"]; 1213 l = v["_HDRMOC"] + v["_UIMOC"] + v["_SRCMOC"];
@@ -1149,28 +1216,46 @@ MakefileGenerator::init()
1149 (*val_it) = Option::fixPathToTargetOS((*val_it), FALSE); 1216 (*val_it) = Option::fixPathToTargetOS((*val_it), FALSE);
1150 } 1217 }
1151 } 1218 }
1219
1220 QString fixpaths[] = { QString("PRE_TARGETDEPS"), QString("POST_TARGETDEPS"), QString::null };
1221 for(int path = 0; !fixpaths[path].isNull(); path++) {
1222 QStringList &l = v[fixpaths[path]];
1223 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) {
1224 if(!(*val_it).isEmpty())
1225 (*val_it) = Option::fixPathToTargetOS((*val_it), FALSE);
1226 }
1227 }
1228
1229 // Make sure the INCLUDEPATH doesn't contain any empty(/null) entries
1230 QStringList &ipl = project->variables()["INCLUDEPATH"];
1231 for(QStringList::Iterator ipl_it = ipl.begin(); ipl_it != ipl.end();) {
1232 if ((*ipl_it).isEmpty())
1233 ipl_it = ipl.remove(ipl_it);
1234 else
1235 ++ipl_it;
1236 }
1152} 1237}
1153 1238
1154bool 1239bool
1155MakefileGenerator::processPrlFile(QString &file) 1240MakefileGenerator::processPrlFile(QString &file)
1156{ 1241{
1157 bool ret = FALSE, try_replace_file=FALSE; 1242 bool ret = FALSE, try_replace_file=FALSE;
1158 QString prl_file; 1243 QString meta_file, orig_file = file;
1159 if(file.endsWith(Option::prl_ext)) { 1244 if(QMakeMetaInfo::libExists(file)) {
1160 try_replace_file = TRUE; 1245 try_replace_file = TRUE;
1161 prl_file = file; 1246 meta_file = file;
1162 file = ""; 1247 file = "";
1163 } else { 1248 } else {
1164 QString tmp = file; 1249 QString tmp = file;
1165 int ext = tmp.findRev('.'); 1250 int ext = tmp.findRev('.');
1166 if(ext != -1) 1251 if(ext != -1)
1167 tmp = tmp.left(ext); 1252 tmp = tmp.left(ext);
1168 prl_file = tmp + Option::prl_ext; 1253 meta_file = tmp;
1169 } 1254 }
1170 prl_file = fileFixify(prl_file); 1255 meta_file = fileFixify(meta_file);
1171 if(!QFile::exists(fileFixify(prl_file, QDir::currentDirPath(), Option::output_dir)) && 1256 if(!QMakeMetaInfo::libExists(fileFixify(meta_file, QDir::currentDirPath(), Option::output_dir)) &&
1172 project->isActiveConfig("qt")) { 1257 project->isActiveConfig("qt")) {
1173 QString stem = prl_file, dir, extn; 1258 QString stem = meta_file, dir, extn;
1174 int slsh = stem.findRev('/'), hadlib = 0; 1259 int slsh = stem.findRev('/'), hadlib = 0;
1175 if(slsh != -1) { 1260 if(slsh != -1) {
1176 dir = stem.left(slsh + 1); 1261 dir = stem.left(slsh + 1);
@@ -1190,39 +1275,53 @@ MakefileGenerator::processPrlFile(QString &file)
1190 stem = stem.left(stem.length() - 3); //lose the -mt 1275 stem = stem.left(stem.length() - 3); //lose the -mt
1191 else 1276 else
1192 stem += "-mt"; //try the thread case 1277 stem += "-mt"; //try the thread case
1193 prl_file = dir; 1278 meta_file = dir;
1194 if(hadlib) 1279 if(hadlib)
1195 prl_file += "lib"; 1280 meta_file += "lib";
1196 prl_file += stem + extn; 1281 meta_file += stem + extn;
1197 try_replace_file = TRUE; 1282 try_replace_file = TRUE;
1198 } 1283 }
1199 } 1284 }
1200 QString real_prl_file = Option::fixPathToLocalOS(prl_file); 1285 QString real_meta_file = Option::fixPathToLocalOS(meta_file);
1201 if(project->variables()["QMAKE_PRL_INTERNAL_FILES"].findIndex(prl_file) != -1) { 1286 if(project->variables()["QMAKE_PRL_INTERNAL_FILES"].findIndex(QMakeMetaInfo::findLib(meta_file)) != -1) {
1202 ret = TRUE; 1287 ret = TRUE;
1203 } else if(!real_prl_file.isEmpty() && 1288 } else if(!meta_file.isEmpty()) {
1204 QFile::exists(fileFixify(real_prl_file, QDir::currentDirPath(), Option::output_dir))) { 1289 QString f = fileFixify(real_meta_file, QDir::currentDirPath(), Option::output_dir);
1205 project->variables()["QMAKE_PRL_INTERNAL_FILES"].append(prl_file); 1290 if(QMakeMetaInfo::libExists(f)) {
1206 QMakeProject proj; 1291 QMakeMetaInfo libinfo;
1207 debug_msg(1, "Processing PRL file: %s", real_prl_file.latin1()); 1292 debug_msg(1, "Processing PRL file: %s", real_meta_file.latin1());
1208 if(!proj.read(fileFixify(real_prl_file, QDir::currentDirPath(), Option::output_dir), 1293 if(!libinfo.readLib(f)) {
1209 QDir::currentDirPath(), TRUE)) { 1294 fprintf(stderr, "Error processing meta file: %s\n", real_meta_file.latin1());
1210 fprintf(stderr, "Error processing prl file: %s\n", real_prl_file.latin1()); 1295 } else if(project->isActiveConfig("no_read_prl_" + libinfo.type().lower())) {
1211 } else { 1296 debug_msg(2, "Ignored meta file %s [%s]", real_meta_file.latin1(), libinfo.type().latin1());
1212 ret = TRUE; 1297 } else {
1213 QMap<QString, QStringList> &vars = proj.variables(); 1298 ret = TRUE;
1214 for( QMap<QString, QStringList>::Iterator it = vars.begin(); it != vars.end(); ++it) 1299 QMap<QString, QStringList> &vars = libinfo.variables();
1215 processPrlVariable(it.key(), it.data()); 1300 for( QMap<QString, QStringList>::Iterator it = vars.begin(); it != vars.end(); ++it)
1216 if(try_replace_file && !proj.isEmpty("QMAKE_PRL_TARGET")) { 1301 processPrlVariable(it.key(), it.data());
1217 QString dir; 1302 if(try_replace_file && !libinfo.isEmpty("QMAKE_PRL_TARGET")) {
1218 int slsh = real_prl_file.findRev(Option::dir_sep); 1303 QString dir;
1219 if(slsh != -1) 1304 int slsh = real_meta_file.findRev(Option::dir_sep);
1220 dir = real_prl_file.left(slsh+1); 1305 if(slsh != -1)
1221 file = dir + proj.first("QMAKE_PRL_TARGET"); 1306 dir = real_meta_file.left(slsh+1);
1307 file = libinfo.first("QMAKE_PRL_TARGET");
1308 if(QDir::isRelativePath(file))
1309 file.prepend(dir);
1310 }
1222 } 1311 }
1223 } 1312 }
1224 if(ret) 1313 if(ret) {
1225 project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"].append(prl_file); 1314 QString mf = QMakeMetaInfo::findLib(meta_file);
1315 project->variables()["QMAKE_PRL_INTERNAL_FILES"].append(mf);
1316 project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"].append(mf);
1317 }
1318 }
1319 if(try_replace_file && file.isEmpty()) {
1320#if 0
1321 warn_msg(WarnLogic, "Found prl [%s] file with no target [%s]!", meta_file.latin1(),
1322 orig_file.latin1());
1323#endif
1324 file = orig_file;
1226 } 1325 }
1227 return ret; 1326 return ret;
1228} 1327}
@@ -1296,6 +1395,10 @@ MakefileGenerator::writePrlFile(QTextStream &t)
1296 t << "QMAKE_PRL_TARGET = " << target << endl; 1395 t << "QMAKE_PRL_TARGET = " << target << endl;
1297 if(!project->isEmpty("PRL_EXPORT_DEFINES")) 1396 if(!project->isEmpty("PRL_EXPORT_DEFINES"))
1298 t << "QMAKE_PRL_DEFINES = " << project->variables()["PRL_EXPORT_DEFINES"].join(" ") << endl; 1397 t << "QMAKE_PRL_DEFINES = " << project->variables()["PRL_EXPORT_DEFINES"].join(" ") << endl;
1398 if(!project->isEmpty("PRL_EXPORT_CFLAGS"))
1399 t << "QMAKE_PRL_CFLAGS = " << project->variables()["PRL_EXPORT_CFLAGS"].join(" ") << endl;
1400 if(!project->isEmpty("PRL_EXPORT_CXXFLAGS"))
1401 t << "QMAKE_PRL_CXXFLAGS = " << project->variables()["PRL_EXPORT_CXXFLAGS"].join(" ") << endl;
1299 if(!project->isEmpty("CONFIG")) 1402 if(!project->isEmpty("CONFIG"))
1300 t << "QMAKE_PRL_CONFIG = " << project->variables()["CONFIG"].join(" ") << endl; 1403 t << "QMAKE_PRL_CONFIG = " << project->variables()["CONFIG"].join(" ") << endl;
1301 if(!project->isEmpty("VERSION")) 1404 if(!project->isEmpty("VERSION"))
@@ -1316,10 +1419,12 @@ MakefileGenerator::writePrlFile(QTextStream &t)
1316bool 1419bool
1317MakefileGenerator::write() 1420MakefileGenerator::write()
1318{ 1421{
1422 usePlatformDir();
1319 init(); 1423 init();
1320 findLibraries(); 1424 findLibraries();
1321 if((Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || //write prl 1425 if((Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || //write prl
1322 Option::qmake_mode == Option::QMAKE_GENERATE_PRL) && 1426 Option::qmake_mode == Option::QMAKE_GENERATE_PRL) &&
1427 project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty() &&
1323 project->isActiveConfig("create_prl") && project->first("TEMPLATE") == "lib" && 1428 project->isActiveConfig("create_prl") && project->first("TEMPLATE") == "lib" &&
1324 !project->isActiveConfig("plugin")) { 1429 !project->isActiveConfig("plugin")) {
1325 QString prl = var("TARGET"); 1430 QString prl = var("TARGET");
@@ -1346,7 +1451,7 @@ MakefileGenerator::write()
1346 project->isActiveConfig("link_prl")) //load up prl's' 1451 project->isActiveConfig("link_prl")) //load up prl's'
1347 processPrlFiles(); 1452 processPrlFiles();
1348 1453
1349 if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || 1454 if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || //write prl file
1350 Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) { 1455 Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) {
1351 QTextStream t(&Option::output); 1456 QTextStream t(&Option::output);
1352 writeMakefile(t); 1457 writeMakefile(t);
@@ -1354,6 +1459,61 @@ MakefileGenerator::write()
1354 return TRUE; 1459 return TRUE;
1355} 1460}
1356 1461
1462// Manipulate directories, so it's possible to build
1463// several cross-platform targets concurrently
1464void
1465MakefileGenerator::usePlatformDir()
1466{
1467 QString pltDir(project->first("QMAKE_PLATFORM_DIR"));
1468 if(pltDir.isEmpty())
1469 return;
1470 char sep = QDir::separator();
1471 QString slashPltDir = sep + pltDir;
1472
1473 QString filePath = project->first("DESTDIR");
1474 project->variables()["DESTDIR"] = filePath
1475 + (filePath.isEmpty() ? pltDir : slashPltDir);
1476
1477 filePath = project->first("DLLDESTDIR");
1478 project->variables()["DLLDESTDIR"] = filePath
1479 + (filePath.isEmpty() ? pltDir : slashPltDir);
1480
1481 filePath = project->first("OBJECTS_DIR");
1482 project->variables()["OBJECTS_DIR"] = filePath
1483 + (filePath.isEmpty() ? pltDir : slashPltDir);
1484
1485 filePath = project->first("QMAKE_LIBDIR_QT");
1486 project->variables()["QMAKE_LIBDIR_QT"] = filePath
1487 + (filePath.isEmpty() ? pltDir : slashPltDir);
1488
1489 filePath = project->first("QMAKE_LIBS_QT");
1490 int fpi = filePath.findRev(sep);
1491 if (fpi == -1)
1492 project->variables()["QMAKE_LIBS_QT"].prepend(pltDir + sep);
1493 else
1494 project->variables()["QMAKE_LIBS_QT"] = filePath.left(fpi)
1495 + slashPltDir
1496 + filePath.mid(fpi);
1497
1498 filePath = project->first("QMAKE_LIBS_QT_THREAD");
1499 fpi = filePath.findRev(sep);
1500 if (fpi == -1)
1501 project->variables()["QMAKE_LIBS_QT_THREAD"].prepend(pltDir + sep);
1502 else
1503 project->variables()["QMAKE_LIBS_QT_THREAD"] = filePath.left(fpi)
1504 + slashPltDir
1505 + filePath.mid(fpi);
1506
1507 filePath = project->first("QMAKE_LIBS_QT_ENTRY");
1508 fpi = filePath.findRev(sep);
1509 if (fpi == -1)
1510 project->variables()["QMAKE_LIBS_QT_ENTRY"].prepend(pltDir + sep);
1511 else
1512 project->variables()["QMAKE_LIBS_QT_ENTRY"] = filePath.left(fpi)
1513 + slashPltDir
1514 + filePath.mid(fpi);
1515}
1516
1357void 1517void
1358MakefileGenerator::writeObj(QTextStream &t, const QString &obj, const QString &src) 1518MakefileGenerator::writeObj(QTextStream &t, const QString &obj, const QString &src)
1359{ 1519{
@@ -1372,7 +1532,7 @@ MakefileGenerator::writeObj(QTextStream &t, const QString &obj, const QString &s
1372 QString sdep, odep = (*sit) + " "; 1532 QString sdep, odep = (*sit) + " ";
1373 QStringList deps = findDependencies((*sit)); 1533 QStringList deps = findDependencies((*sit));
1374 for(QStringList::Iterator dit = deps.begin(); dit != deps.end(); dit++) { 1534 for(QStringList::Iterator dit = deps.begin(); dit != deps.end(); dit++) {
1375 if((*dit).endsWith(Option::moc_ext)) 1535 if((*dit).endsWith(Option::cpp_moc_ext))
1376 odep += (*dit) + " "; 1536 odep += (*dit) + " ";
1377 else 1537 else
1378 sdep += (*dit) + " "; 1538 sdep += (*dit) + " ";
@@ -1406,8 +1566,8 @@ MakefileGenerator::writeObj(QTextStream &t, const QString &obj, const QString &s
1406 } 1566 }
1407 } 1567 }
1408 if (!use_implicit_rule && !project->isEmpty(comp)) { 1568 if (!use_implicit_rule && !project->isEmpty(comp)) {
1409 QString p = var(comp); 1569 QString p = var(comp), srcf(*sit);
1410 p.replace(stringSrc, (*sit)); 1570 p.replace(stringSrc, srcf);
1411 p.replace(stringObj, (*oit)); 1571 p.replace(stringObj, (*oit));
1412 t << "\n\t" << p; 1572 t << "\n\t" << p;
1413 } 1573 }
@@ -1421,16 +1581,14 @@ MakefileGenerator::writeUicSrc(QTextStream &t, const QString &ui)
1421{ 1581{
1422 QStringList &uil = project->variables()[ui]; 1582 QStringList &uil = project->variables()[ui];
1423 for(QStringList::Iterator it = uil.begin(); it != uil.end(); it++) { 1583 for(QStringList::Iterator it = uil.begin(); it != uil.end(); it++) {
1424 QString deps = findDependencies((*it)).join(" \\\n\t\t"), decl, impl; 1584 QString decl, impl;
1425 { 1585 {
1426 QString tmp = (*it), impl_dir, decl_dir; 1586 QString tmp = (*it), impl_dir, decl_dir;
1427 decl = tmp.replace(QRegExp("\\" + Option::ui_ext + "$"), Option::h_ext.first()); 1587 decl = tmp.replace(QRegExp("\\" + Option::ui_ext + "$"), Option::h_ext.first());
1428 decl = fileFixify(decl, QDir::currentDirPath(), Option::output_dir); 1588 int dlen = decl.findRev(Option::dir_sep) + 1;
1429 int dlen = decl.findRev(Option::dir_sep) + 1;
1430 tmp = (*it); 1589 tmp = (*it);
1431 impl = tmp.replace(QRegExp("\\" + Option::ui_ext + "$"), Option::cpp_ext.first()); 1590 impl = tmp.replace(QRegExp("\\" + Option::ui_ext + "$"), Option::cpp_ext.first());
1432 impl = fileFixify(impl, QDir::currentDirPath(), Option::output_dir); 1591 int ilen = decl.findRev(Option::dir_sep) + 1;
1433 int ilen = decl.findRev(Option::dir_sep) + 1;
1434 if(!project->isEmpty("UI_DIR")) { 1592 if(!project->isEmpty("UI_DIR")) {
1435 impl_dir = project->first("UI_DIR"); 1593 impl_dir = project->first("UI_DIR");
1436 decl = project->first("UI_DIR") + decl.right(decl.length() - dlen); 1594 decl = project->first("UI_DIR") + decl.right(decl.length() - dlen);
@@ -1444,26 +1602,32 @@ MakefileGenerator::writeUicSrc(QTextStream &t, const QString &ui)
1444 impl_dir = project->first("UI_SOURCES_DIR"); 1602 impl_dir = project->first("UI_SOURCES_DIR");
1445 impl = project->first("UI_SOURCES_DIR") + impl.right(impl.length() - ilen); 1603 impl = project->first("UI_SOURCES_DIR") + impl.right(impl.length() - ilen);
1446 } 1604 }
1447 } 1605 }
1448 if(decl_dir.isEmpty()) 1606 impl = fileFixify(impl, QDir::currentDirPath(), Option::output_dir);
1449 decl_dir = decl.left(dlen); 1607 decl = fileFixify(decl, QDir::currentDirPath(), Option::output_dir);
1450 if(impl_dir.isEmpty()) 1608 if(decl_dir.isEmpty())
1451 impl_dir = impl.left(ilen); 1609 decl_dir = decl.section(Option::dir_sep,0,-2);
1452 if(!impl_dir.isEmpty()) 1610 if(impl_dir.isEmpty())
1453 createDir(Option::output_dir + Option::dir_sep + impl_dir); 1611 impl_dir = impl.section(Option::dir_sep,0,-2);
1454 if(!decl_dir.isEmpty() && decl_dir != impl_dir) 1612 if (QDir::isRelativePath(impl_dir))
1455 createDir(Option::output_dir + Option::dir_sep + decl_dir); 1613 impl_dir.prepend(Option::output_dir + Option::dir_sep);
1456 } 1614 if (QDir::isRelativePath(decl_dir))
1457 t << decl << ": " << (*it) << " " << deps << "\n\t" 1615 decl_dir.prepend(Option::output_dir + Option::dir_sep);
1616 createDir(impl_dir);
1617 createDir(decl_dir);
1618 }
1619 QStringList deps = findDependencies((*it));
1620 deps.remove(decl); //avoid circular dependencies..
1621 t << decl << ": " << (*it) << " " << deps.join(" \\\n\t\t") << "\n\t"
1458 << "$(UIC) " << (*it) << " -o " << decl << endl << endl; 1622 << "$(UIC) " << (*it) << " -o " << decl << endl << endl;
1459 1623
1460 QString mildDecl = decl; 1624 QString mildDecl = decl;
1461 int k = mildDecl.findRev( Option::dir_sep ); 1625 int k = mildDecl.findRev(Option::dir_sep);
1462 if ( k != -1 ) 1626 if ( k != -1 )
1463 mildDecl = mildDecl.mid( k + 1 ); 1627 mildDecl = mildDecl.mid( k + 1 );
1464 1628 t << impl << ": " << decl << " " << (*it) << " " << deps.join(" \\\n\t\t") << "\n\t"
1465 t << impl << ": " << decl << " " << (*it) << " " << deps << "\n\t" 1629 << "$(UIC)";
1466 << "$(UIC) " << (*it) << " -i " << mildDecl << " -o " << impl << endl << endl; 1630 t << " " << (*it) << " -i " << mildDecl << " -o " << impl << endl << endl;
1467 } 1631 }
1468} 1632}
1469 1633
@@ -1477,7 +1641,8 @@ MakefileGenerator::writeMocObj(QTextStream &t, const QString &obj, const QString
1477 QString stringSrc("$src"), stringObj("$obj"); 1641 QString stringSrc("$src"), stringObj("$obj");
1478 for( ;sit != srcl.end() && oit != objl.end(); oit++, sit++) { 1642 for( ;sit != srcl.end() && oit != objl.end(); oit++, sit++) {
1479 QString hdr = findMocSource((*sit)); 1643 QString hdr = findMocSource((*sit));
1480 t << (*oit) << ": " << (*sit) << " " 1644 t << (*oit) << ": "
1645 << (*sit) << " " << findDependencies((*sit)).join(" \\\n\t\t") << " "
1481 << hdr << " " << findDependencies(hdr).join(" \\\n\t\t"); 1646 << hdr << " " << findDependencies(hdr).join(" \\\n\t\t");
1482 bool use_implicit_rule = !project->isEmpty("QMAKE_RUN_CXX_IMP"); 1647 bool use_implicit_rule = !project->isEmpty("QMAKE_RUN_CXX_IMP");
1483 if(use_implicit_rule) { 1648 if(use_implicit_rule) {
@@ -1490,8 +1655,8 @@ MakefileGenerator::writeMocObj(QTextStream &t, const QString &obj, const QString
1490 } 1655 }
1491 } 1656 }
1492 if (!use_implicit_rule && !project->isEmpty("QMAKE_RUN_CXX")) { 1657 if (!use_implicit_rule && !project->isEmpty("QMAKE_RUN_CXX")) {
1493 QString p = var("QMAKE_RUN_CXX"); 1658 QString p = var("QMAKE_RUN_CXX"), srcf(*sit);
1494 p.replace(stringSrc, (*sit)); 1659 p.replace(stringSrc, srcf);
1495 p.replace(stringObj, (*oit)); 1660 p.replace(stringObj, (*oit));
1496 t << "\n\t" << p; 1661 t << "\n\t" << p;
1497 } 1662 }
@@ -1512,7 +1677,8 @@ MakefileGenerator::writeMocSrc(QTextStream &t, const QString &src)
1512 deps += "$(MOC) "; 1677 deps += "$(MOC) ";
1513 deps += (*it); 1678 deps += (*it);
1514 t << m << ": " << deps << "\n\t" 1679 t << m << ": " << deps << "\n\t"
1515 << "$(MOC) " << (*it) << " -o " << m << endl << endl; 1680 << "$(MOC)";
1681 t << " " << (*it) << " -o " << m << endl << endl;
1516 } 1682 }
1517 } 1683 }
1518} 1684}
@@ -1545,7 +1711,10 @@ MakefileGenerator::writeYaccSrc(QTextStream &t, const QString &src)
1545 QString yaccflags = "$(YACCFLAGS)", mangle = "y"; 1711 QString yaccflags = "$(YACCFLAGS)", mangle = "y";
1546 if(!project->isActiveConfig("yacc_no_name_mangle")) { 1712 if(!project->isActiveConfig("yacc_no_name_mangle")) {
1547 mangle = fi.baseName(TRUE); 1713 mangle = fi.baseName(TRUE);
1548 yaccflags += " -p " + mangle; 1714 if(!project->isEmpty("QMAKE_YACCFLAGS_MANGLE"))
1715 yaccflags += " " + var("QMAKE_YACCFLAGS_MANGLE").replace(stringBase, mangle);
1716 else
1717 yaccflags += " -p " + mangle;
1549 } 1718 }
1550 QString out_h = default_out_h, out_c = default_out_c; 1719 QString out_h = default_out_h, out_c = default_out_c;
1551 if(!mangle.isEmpty()) { 1720 if(!mangle.isEmpty()) {
@@ -1621,9 +1790,9 @@ MakefileGenerator::writeImageObj(QTextStream &t, const QString &obj)
1621 } 1790 }
1622 } 1791 }
1623 if(!use_implicit_rule && !project->isEmpty("QMAKE_RUN_CXX")) { 1792 if(!use_implicit_rule && !project->isEmpty("QMAKE_RUN_CXX")) {
1624 QString p = var("QMAKE_RUN_CXX"); 1793 QString p = var("QMAKE_RUN_CXX"), srcf(src);
1625 p.replace( stringSrc, src); 1794 p.replace(stringSrc, srcf);
1626 p.replace( stringObj, (*oit)); 1795 p.replace(stringObj, (*oit));
1627 t << "\n\t" << p; 1796 t << "\n\t" << p;
1628 } 1797 }
1629 t << endl << endl; 1798 t << endl << endl;
@@ -1661,7 +1830,8 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs)
1661 QStringList &l = project->variables()[installs]; 1830 QStringList &l = project->variables()[installs];
1662 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 1831 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
1663 QString pvar = (*it) + ".path"; 1832 QString pvar = (*it) + ".path";
1664 if(project->variables()[pvar].isEmpty()) { 1833 if(project->variables()[(*it) + ".CONFIG"].findIndex("no_path") == -1 &&
1834 project->variables()[pvar].isEmpty()) {
1665 warn_msg(WarnLogic, "%s is not defined: install target not created\n", pvar.latin1()); 1835 warn_msg(WarnLogic, "%s is not defined: install target not created\n", pvar.latin1());
1666 continue; 1836 continue;
1667 } 1837 }
@@ -1669,13 +1839,13 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs)
1669 bool do_default = TRUE; 1839 bool do_default = TRUE;
1670 const QString root = "$(INSTALL_ROOT)"; 1840 const QString root = "$(INSTALL_ROOT)";
1671 QString target, dst= fileFixify(project->variables()[pvar].first()); 1841 QString target, dst= fileFixify(project->variables()[pvar].first());
1672#ifndef Q_WS_WIN
1673 if(dst.right(1) != Option::dir_sep) 1842 if(dst.right(1) != Option::dir_sep)
1674 dst += Option::dir_sep; 1843 dst += Option::dir_sep;
1675#endif 1844 QStringList tmp, uninst = project->variables()[(*it) + ".uninstall"];
1676 QStringList tmp, &uninst = project->variables()[(*it) + ".uninstall"];
1677 //other 1845 //other
1678 tmp = project->variables()[(*it) + ".extra"]; 1846 tmp = project->variables()[(*it) + ".extra"];
1847 if(tmp.isEmpty())
1848 tmp = project->variables()[(*it) + ".commands"]; //to allow compatible name
1679 if(!tmp.isEmpty()) { 1849 if(!tmp.isEmpty()) {
1680 do_default = FALSE; 1850 do_default = FALSE;
1681 if(!target.isEmpty()) 1851 if(!target.isEmpty())
@@ -1703,11 +1873,16 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs)
1703 QFileInfo fi(wild); 1873 QFileInfo fi(wild);
1704 if(!target.isEmpty()) 1874 if(!target.isEmpty())
1705 target += "\t"; 1875 target += "\t";
1706 target += QString(fi.isDir() ? "-$(COPY_DIR)" : "-$(COPY_FILE)") + " \"" + 1876 QString cmd = QString(fi.isDir() ? "-$(INSTALL_DIR)" : "-$(INSTALL_FILE)") + " \"" +
1707 Option::fixPathToTargetOS(fileFixify(wild), FALSE) + "\" \"" + root + dst + "\"\n"; 1877 Option::fixPathToTargetOS(fileFixify(wild, QString::null,
1878 QString::null, FALSE, FALSE), FALSE) +
1879 "\" \"" + root + dst + "\"\n";
1880 target += cmd;
1708 if(!project->isActiveConfig("debug") && 1881 if(!project->isActiveConfig("debug") &&
1709 !fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP")) 1882 !fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP"))
1710 target += QString("\t-") + var("QMAKE_STRIP") + " \"" + root + fileFixify(dst + filestr) + "\"\n"; 1883 target += QString("\t-") + var("QMAKE_STRIP") + " \"" +
1884 root + fileFixify(dst + filestr, QString::null, QString::null, FALSE, FALSE) +
1885 "\"\n";
1711 if(!uninst.isEmpty()) 1886 if(!uninst.isEmpty())
1712 uninst.append("\n\t"); 1887 uninst.append("\n\t");
1713 uninst.append( 1888 uninst.append(
@@ -1716,9 +1891,10 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs)
1716#else 1891#else
1717 QString("-$(DEL_FILE) -r") 1892 QString("-$(DEL_FILE) -r")
1718#endif 1893#endif
1719 + " \"" + root + fileFixify(dst + filestr) + "\""); 1894 + " \"" + root + fileFixify(dst + filestr, QString::null, QString::null, FALSE, FALSE) + "\"");
1720 continue; 1895 continue;
1721 } 1896 }
1897 fixEnvVariables(dirstr);
1722 QDir dir(dirstr, filestr); //wild 1898 QDir dir(dirstr, filestr); //wild
1723 for(uint x = 0; x < dir.count(); x++) { 1899 for(uint x = 0; x < dir.count(); x++) {
1724 QString file = dir[x]; 1900 QString file = dir[x];
@@ -1732,25 +1908,42 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs)
1732#else 1908#else
1733 QString("-$(DEL_FILE) -r") 1909 QString("-$(DEL_FILE) -r")
1734#endif 1910#endif
1735 + " \"" + root + fileFixify(dst + file) + "\""); 1911 + " \"" + root + fileFixify(dst + file, QString::null, QString::null, FALSE, FALSE) +
1736 QFileInfo fi(file); 1912 "\"");
1913 QFileInfo fi(Option::fixPathToTargetOS(fileFixify(dirstr + file), TRUE));
1737 if(!target.isEmpty()) 1914 if(!target.isEmpty())
1738 target += "\t"; 1915 target += "\t";
1739 target += QString(fi.isDir() ? "-$(COPY_DIR)" : "-$(COPY_FILE)") + " \"" + 1916 QString cmd = QString(fi.isDir() ? "-$(INSTALL_DIR)" : "-$(INSTALL_FILE)") + " \"" +
1740 Option::fixPathToTargetOS(fileFixify(dirstr + file), FALSE) + 1917 Option::fixPathToTargetOS(fileFixify(dirstr + file, QString::null,
1741 "\" \"" + root + fileFixify(dst) + "\"\n"; 1918 QString::null, FALSE, FALSE), FALSE) +
1919 "\" \"" + root + dst + "\"\n";
1920 target += cmd;
1742 if(!project->isActiveConfig("debug") && 1921 if(!project->isActiveConfig("debug") &&
1743 !fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP")) 1922 !fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP"))
1744 target += QString("\t-") + var("QMAKE_STRIP") + " \"" + root + fileFixify(dst + file) + "\"\n"; 1923 target += QString("\t-") + var("QMAKE_STRIP") + " \"" +
1924 root + fileFixify(dst + file, QString::null, QString::null, FALSE, FALSE) +
1925 "\"\n";
1745 } 1926 }
1746 } 1927 }
1747 } 1928 }
1748 //default? 1929 //default?
1749 if(do_default) 1930 if(do_default) {
1750 target = defaultInstall((*it)); 1931 target = defaultInstall((*it));
1932 uninst = project->variables()[(*it) + ".uninstall"];
1933 }
1751 1934
1752 if(!target.isEmpty()) { 1935 if(!target.isEmpty()) {
1753 t << "install_" << (*it) << ": " << "\n\t"; 1936 t << "install_" << (*it) << ": all ";
1937 const QStringList &deps = project->variables()[(*it) + ".depends"];
1938 if(!deps.isEmpty()) {
1939 for(QStringList::ConstIterator dep_it = deps.begin(); dep_it != deps.end(); ++dep_it) {
1940 QString targ = var((*dep_it) + ".target");
1941 if(targ.isEmpty())
1942 targ = (*dep_it);
1943 t << targ;
1944 }
1945 }
1946 t << "\n\t";
1754 const QStringList &dirs = project->variables()[pvar]; 1947 const QStringList &dirs = project->variables()[pvar];
1755 for(QStringList::ConstIterator pit = dirs.begin(); pit != dirs.end(); ++pit) { 1948 for(QStringList::ConstIterator pit = dirs.begin(); pit != dirs.end(); ++pit) {
1756 QString tmp_dst = fileFixify((*pit)); 1949 QString tmp_dst = fileFixify((*pit));
@@ -1761,20 +1954,24 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs)
1761 t << mkdir_p_asstring(root+tmp_dst) << "\n\t"; 1954 t << mkdir_p_asstring(root+tmp_dst) << "\n\t";
1762 } 1955 }
1763 t << target << endl << endl; 1956 t << target << endl << endl;
1764 all_installs += QString("install_") + (*it) + " ";
1765 if(!uninst.isEmpty()) { 1957 if(!uninst.isEmpty()) {
1766 t << "uninstall_" << (*it) << ": " << "\n\t" 1958 t << "uninstall_" << (*it) << ": " << "\n\t"
1767 << uninst.join("") << "\n\t" 1959 << uninst.join("") << "\n\t"
1768 << "-$(DEL_DIR) \"" << ( root + dst ) << "\"" << endl << endl; 1960 << "-$(DEL_DIR) \"" << ( root + dst ) << "\"" << endl << endl;
1769 all_uninstalls += "uninstall_" + (*it) + " ";
1770 } 1961 }
1771 t << endl; 1962 t << endl;
1963
1964 if(project->variables()[(*it) + ".CONFIG"].findIndex("no_default_install") == -1) {
1965 all_installs += QString("install_") + (*it) + " ";
1966 if(!uninst.isEmpty())
1967 all_uninstalls += "uninstall_" + (*it) + " ";
1968 }
1772 } else { 1969 } else {
1773 debug_msg(1, "no definition for install %s: install target not created",(*it).latin1()); 1970 debug_msg(1, "no definition for install %s: install target not created",(*it).latin1());
1774 } 1971 }
1775 } 1972 }
1776 t << "install: all " << all_installs << "\n\n"; 1973 t << "install: " << all_installs << " " << var("INSTALLDEPS") << "\n\n";
1777 t << "uninstall: " << all_uninstalls << "\n\n"; 1974 t << "uninstall: " << all_uninstalls << " " << var("UNINSTALLDEPS") << "\n\n";
1778} 1975}
1779 1976
1780QString 1977QString
@@ -1971,8 +2168,12 @@ MakefileGenerator::writeMakeQmake(QTextStream &t)
1971 t << ofile << ": " << fileFixify(pfile) << " "; 2168 t << ofile << ": " << fileFixify(pfile) << " ";
1972 if(Option::mkfile::do_cache) 2169 if(Option::mkfile::do_cache)
1973 t << fileFixify(Option::mkfile::cachefile) << " "; 2170 t << fileFixify(Option::mkfile::cachefile) << " ";
1974 if(!specdir().isEmpty()) 2171 if(!specdir().isEmpty()) {
1975 t << specdir() << Option::dir_sep << "qmake.conf" << " "; 2172 if (QFile::exists(Option::fixPathToLocalOS(specdir()+QDir::separator()+"qmake.conf")))
2173 t << specdir() << Option::dir_sep << "qmake.conf" << " ";
2174 else if (QFile::exists(Option::fixPathToLocalOS(specdir()+QDir::separator()+"tmake.conf")))
2175 t << specdir() << Option::dir_sep << "tmake.conf" << " ";
2176 }
1976 t << project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"].join(" \\\n\t\t") << "\n\t" 2177 t << project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"].join(" \\\n\t\t") << "\n\t"
1977 << qmake <<endl; 2178 << qmake <<endl;
1978 } 2179 }
@@ -1986,27 +2187,32 @@ MakefileGenerator::writeMakeQmake(QTextStream &t)
1986} 2187}
1987 2188
1988QStringList 2189QStringList
1989MakefileGenerator::fileFixify(const QStringList& files, const QString &out_dir, const QString &in_dir, bool force_fix) const 2190MakefileGenerator::fileFixify(const QStringList& files, const QString &out_dir, const QString &in_dir,
2191 bool force_fix, bool canon) const
1990{ 2192{
1991 if(files.isEmpty()) 2193 if(files.isEmpty())
1992 return files; 2194 return files;
1993 QStringList ret; 2195 QStringList ret;
1994 for(QStringList::ConstIterator it = files.begin(); it != files.end(); ++it) { 2196 for(QStringList::ConstIterator it = files.begin(); it != files.end(); ++it) {
1995 if(!(*it).isEmpty()) 2197 if(!(*it).isEmpty())
1996 ret << fileFixify((*it), out_dir, in_dir, force_fix); 2198 ret << fileFixify((*it), out_dir, in_dir, force_fix, canon);
1997 } 2199 }
1998 return ret; 2200 return ret;
1999} 2201}
2000 2202
2001QString 2203QString
2002MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const QString &in_d, bool force_fix) const 2204MakefileGenerator::fileFixify(const QString& file0, const QString &out_d,
2205 const QString &in_d, bool force_fix, bool canon) const
2003{ 2206{
2004 if(file0.isEmpty()) 2207 if(file0.isEmpty())
2005 return file0; 2208 return file0;
2006 QString key = file0; 2209 QString key = file0;
2007 if(!in_d.isEmpty() || !out_d.isEmpty() || force_fix) 2210 if(QDir::isRelativePath(file0))
2008 key.prepend(in_d + "--" + out_d + "--" + QString::number((int)force_fix) + "-"); 2211 key.prepend(QDir::currentDirPath() + "--");
2009 if(fileFixed.contains(key)) 2212 if(!in_d.isEmpty() || !out_d.isEmpty() || force_fix || !canon)
2213 key.prepend(in_d + "--" + out_d + "--" + QString::number((int)force_fix) + "--" +
2214 QString::number((int)canon) + "-");
2215 if(fileFixed.contains(key))
2010 return fileFixed[key]; 2216 return fileFixed[key];
2011 2217
2012 QString file = file0; 2218 QString file = file0;
@@ -2027,7 +2233,7 @@ MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const
2027 QString orig_file = file; 2233 QString orig_file = file;
2028 if(!force_fix && project->isActiveConfig("no_fixpath")) { 2234 if(!force_fix && project->isActiveConfig("no_fixpath")) {
2029 if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) { //absoluteify it 2235 if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) { //absoluteify it
2030 QString qfile = Option::fixPathToLocalOS(file); 2236 QString qfile = Option::fixPathToLocalOS(file, TRUE, canon);
2031 if(QDir::isRelativePath(file)) { //already absolute 2237 if(QDir::isRelativePath(file)) { //already absolute
2032 QFileInfo fi(qfile); 2238 QFileInfo fi(qfile);
2033 if(!fi.convertToAbs()) //strange 2239 if(!fi.convertToAbs()) //strange
@@ -2035,14 +2241,17 @@ MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const
2035 } 2241 }
2036 } 2242 }
2037 } else { //fix it.. 2243 } else { //fix it..
2038 QString qfile(Option::fixPathToLocalOS(file, TRUE)), in_dir(in_d), out_dir(out_d); 2244 QString qfile(Option::fixPathToLocalOS(file, TRUE, canon)), in_dir(in_d), out_dir(out_d);
2039 { 2245 {
2040 if(out_dir.isNull()) 2246 if(out_dir.isNull() || QDir::isRelativePath(out_dir))
2041 out_dir = Option::output_dir; 2247 out_dir.prepend(Option::output_dir + QDir::separator());
2042 if(out_dir == ".") 2248 if(out_dir == ".")
2043 out_dir = QDir::currentDirPath(); 2249 out_dir = QDir::currentDirPath();
2044 if(in_dir.isEmpty() || in_dir == ".") 2250 if(in_dir.isEmpty() || QDir::isRelativePath(in_dir))
2251 in_dir.prepend(QDir::currentDirPath() + QDir::separator());
2252 if(in_dir == ".")
2045 in_dir = QDir::currentDirPath(); 2253 in_dir = QDir::currentDirPath();
2254
2046 if(!QDir::isRelativePath(in_dir) || !QDir::isRelativePath(out_dir)) { 2255 if(!QDir::isRelativePath(in_dir) || !QDir::isRelativePath(out_dir)) {
2047 QFileInfo in_fi(in_dir); 2256 QFileInfo in_fi(in_dir);
2048 if(!in_fi.convertToAbs()) 2257 if(!in_fi.convertToAbs())
@@ -2065,13 +2274,13 @@ MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const
2065 file.prepend(Option::dir_sep); 2274 file.prepend(Option::dir_sep);
2066 file.prepend(in_dir); 2275 file.prepend(in_dir);
2067 } 2276 }
2068 file = Option::fixPathToTargetOS(file, FALSE); 2277 file = Option::fixPathToTargetOS(file, FALSE, canon);
2069 if(QFile::exists(file) && file == Option::fixPathToTargetOS(file, TRUE)) { 2278 if(canon && QFile::exists(file) && file == Option::fixPathToTargetOS(file, TRUE, canon)) {
2070 QString real_file = QDir(file).canonicalPath(); 2279 QString real_file = QDir(file).canonicalPath();
2071 if(!real_file.isEmpty()) 2280 if(!real_file.isEmpty())
2072 file = real_file; 2281 file = real_file;
2073 } 2282 }
2074 QString match_dir = Option::fixPathToTargetOS(out_dir, FALSE); 2283 QString match_dir = Option::fixPathToTargetOS(out_dir, FALSE, canon);
2075 if(file == match_dir) { 2284 if(file == match_dir) {
2076 file = ""; 2285 file = "";
2077 } else if(file.startsWith(match_dir) && 2286 } else if(file.startsWith(match_dir) &&
@@ -2100,12 +2309,13 @@ MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const
2100 } 2309 }
2101 } 2310 }
2102 } 2311 }
2103 file = Option::fixPathToTargetOS(file, FALSE); 2312 file = Option::fixPathToTargetOS(file, FALSE, canon);
2104 if(file.isEmpty()) 2313 if(file.isEmpty())
2105 file = "."; 2314 file = ".";
2106 if(!quote.isNull()) 2315 if(!quote.isNull())
2107 file = quote + file + quote; 2316 file = quote + file + quote;
2108 debug_msg(3, "Fixed %s :: to :: %s (%d)", orig_file.latin1(), file.latin1(), depth); 2317 debug_msg(3, "Fixed %s :: to :: %s (%d) [%s::%s]", orig_file.latin1(), file.latin1(), depth,
2318 in_d.latin1(), out_d.latin1());
2109 ((MakefileGenerator*)this)->fileFixed.insert(key, file); 2319 ((MakefileGenerator*)this)->fileFixed.insert(key, file);
2110 return file; 2320 return file;
2111} 2321}
@@ -2138,16 +2348,35 @@ void MakefileGenerator::logicWarn(const QString &f, const QString &w)
2138 } 2348 }
2139} 2349}
2140 2350
2351QString
2352MakefileGenerator::dependencyKey(const QString &file) const
2353{
2354 QString key = file;
2355 Option::fixPathToTargetOS(key);
2356 if(key.find(Option::dir_sep))
2357 key = key.right(key.length() - key.findRev(Option::dir_sep) - 1);
2358 return key;
2359}
2360
2361void
2362MakefileGenerator::setProcessedDependencies(const QString &file, bool b)
2363{
2364 depProcessed[dependencyKey(file)] = b;
2365}
2366
2367bool
2368MakefileGenerator::processedDependencies(const QString &file)
2369{
2370 QString key = dependencyKey(file);
2371 if(!depProcessed.contains(key))
2372 return FALSE;
2373 return depProcessed[key];
2374}
2375
2141QStringList 2376QStringList
2142&MakefileGenerator::findDependencies(const QString &file) 2377&MakefileGenerator::findDependencies(const QString &file)
2143{ 2378{
2144 QString key = file; 2379 return depends[dependencyKey(file)];
2145 Option::fixPathToTargetOS(key);
2146 if(key.find(Option::dir_sep))
2147 key = key.right(key.length() - key.findRev(Option::dir_sep) - 1);
2148 if(!depKeyMap.contains(key))
2149 depKeyMap.insert(key, file);
2150 return depends[key];
2151} 2380}
2152 2381
2153 2382
@@ -2157,8 +2386,8 @@ MakefileGenerator::specdir()
2157 if(!spec.isEmpty()) 2386 if(!spec.isEmpty())
2158 return spec; 2387 return spec;
2159 spec = Option::mkfile::qmakespec; 2388 spec = Option::mkfile::qmakespec;
2160 const char *d = getenv("QTDIR"); 2389#if 0
2161 if(d) { 2390 if(const char *d = getenv("QTDIR")) {
2162 QString qdir = Option::fixPathToTargetOS(QString(d)); 2391 QString qdir = Option::fixPathToTargetOS(QString(d));
2163 if(qdir.endsWith(QString(QChar(QDir::separator())))) 2392 if(qdir.endsWith(QString(QChar(QDir::separator()))))
2164 qdir.truncate(qdir.length()-1); 2393 qdir.truncate(qdir.length()-1);
@@ -2172,6 +2401,9 @@ MakefileGenerator::specdir()
2172 spec = absSpec; 2401 spec = absSpec;
2173 } 2402 }
2174 } 2403 }
2404#else
2405 spec = Option::fixPathToTargetOS(spec);
2406#endif
2175 return spec; 2407 return spec;
2176} 2408}
2177 2409
@@ -2181,6 +2413,8 @@ MakefileGenerator::openOutput(QFile &file) const
2181 { 2413 {
2182 QString outdir; 2414 QString outdir;
2183 if(!file.name().isEmpty()) { 2415 if(!file.name().isEmpty()) {
2416 if(QDir::isRelativePath(file.name()))
2417 file.setName(Option::output_dir + file.name()); //pwd when qmake was run
2184 QFileInfo fi(file); 2418 QFileInfo fi(file);
2185 if(fi.isDir()) 2419 if(fi.isDir())
2186 outdir = file.name() + QDir::separator(); 2420 outdir = file.name() + QDir::separator();