author | llornkcor <llornkcor> | 2003-07-10 02:40:10 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-07-10 02:40:10 (UTC) |
commit | 155d68c1e7d7dc0fed2534ac43d6d77ce2781f55 (patch) (unidiff) | |
tree | e6edaa5a7040fe6c224c3943d1094dcf02e4f74c /qmake/generators/makefile.cpp | |
parent | 86703e8a5527ef114facd02c005b6b3a7e62e263 (diff) | |
download | opie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.zip opie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.tar.gz opie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.tar.bz2 |
update qmake to 1.05a
Diffstat (limited to 'qmake/generators/makefile.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | qmake/generators/makefile.cpp | 476 |
1 files changed, 327 insertions, 149 deletions
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index f490313..c12375d 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp | |||
@@ -1,16 +1,16 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** $Id$ | 2 | ** $Id$ |
3 | ** | 3 | ** |
4 | ** Definition of ________ class. | 4 | ** Definition of ________ class. |
5 | ** | 5 | ** |
6 | ** Created : 970521 | 6 | ** Created : 970521 |
7 | ** | 7 | ** |
8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. | 8 | ** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. |
9 | ** | 9 | ** |
10 | ** This file is part of the network module of the Qt GUI Toolkit. | 10 | ** This file is part of the network module of the Qt GUI Toolkit. |
11 | ** | 11 | ** |
12 | ** This file may be distributed under the terms of the Q Public License | 12 | ** 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 | 13 | ** as defined by Trolltech AS of Norway and appearing in the file |
14 | ** LICENSE.QPL included in the packaging of this file. | 14 | ** LICENSE.QPL included in the packaging of this file. |
15 | ** | 15 | ** |
16 | ** This file may be distributed and/or modified under the terms of the | 16 | ** This file may be distributed and/or modified under the terms of the |
@@ -54,51 +54,65 @@ | |||
54 | #include <sys/types.h> | 54 | #include <sys/types.h> |
55 | #include <sys/stat.h> | 55 | #include <sys/stat.h> |
56 | 56 | ||
57 | // Well, Windows doesn't have this, so here's the macro | 57 | // Well, Windows doesn't have this, so here's the macro |
58 | #ifndef S_ISDIR | 58 | #ifndef S_ISDIR |
59 | #define S_ISDIR(m)(((m) & S_IFMT) == S_IFDIR) | 59 | #define S_ISDIR(m)(((m) & S_IFMT) == S_IFDIR) |
60 | #endif | 60 | #endif |
61 | 61 | ||
62 | static QString mkdir_p_asstring(const QString &dir) | ||
63 | { | ||
64 | QString ret = "@$(CHK_DIR_EXISTS) \"" + dir + "\" "; | ||
65 | if(Option::target_mode == Option::TARG_WIN_MODE) | ||
66 | ret += "$(MKDIR)"; | ||
67 | else | ||
68 | ret += "|| $(MKDIR)"; | ||
69 | ret += " \"" + dir + "\""; | ||
70 | return ret; | ||
71 | } | ||
72 | |||
62 | static bool createDir(const QString& fullPath) | 73 | static bool createDir(const QString& fullPath) |
63 | { | 74 | { |
75 | if(QFile::exists(fullPath)) | ||
76 | return FALSE; | ||
77 | |||
64 | QDir dirTmp; | 78 | QDir dirTmp; |
65 | bool ret = TRUE; | 79 | bool ret = TRUE; |
66 | QString pathComponent, tmpPath; | 80 | QString pathComponent, tmpPath; |
67 | QStringList hierarchy = QStringList::split(QString(Option::dir_sep), fullPath, TRUE); | 81 | QStringList hierarchy = QStringList::split(QString(Option::dir_sep), fullPath, TRUE); |
68 | for(QStringList::Iterator it = hierarchy.begin(); it != hierarchy.end(); ++it) { | 82 | for(QStringList::Iterator it = hierarchy.begin(); it != hierarchy.end(); ++it) { |
69 | pathComponent = *it + QDir::separator(); | 83 | pathComponent = *it + QDir::separator(); |
70 | tmpPath += pathComponent; | 84 | tmpPath += pathComponent; |
71 | if(!dirTmp.mkdir(tmpPath)) { | 85 | if(!dirTmp.mkdir(tmpPath)) { |
72 | ret = FALSE; | 86 | ret = FALSE; |
73 | // break; | 87 | // break; |
74 | } | 88 | } |
75 | } | 89 | } |
76 | return ret; | 90 | return ret; |
77 | } | 91 | } |
78 | 92 | ||
79 | 93 | ||
80 | MakefileGenerator::MakefileGenerator(QMakeProject *p) : init_opath_already(FALSE), | 94 | MakefileGenerator::MakefileGenerator(QMakeProject *p) : init_opath_already(FALSE), |
81 | init_already(FALSE), moc_aware(FALSE), | 95 | init_already(FALSE), moc_aware(FALSE), |
82 | no_io(FALSE), project(p) | 96 | no_io(FALSE), project(p) |
83 | { | 97 | { |
84 | } | 98 | } |
85 | 99 | ||
86 | static char *gimme_buffer(off_t s) | 100 | static char *gimme_buffer(off_t s) |
87 | { | 101 | { |
88 | static char *big_buffer = NULL; | 102 | static char *big_buffer = NULL; |
89 | static int big_buffer_size = 0; | 103 | static int big_buffer_size = 0; |
90 | if(!big_buffer || big_buffer_size < s) | 104 | if(!big_buffer || big_buffer_size < s) |
91 | big_buffer = (char *)realloc(big_buffer, s); | 105 | big_buffer = (char *)realloc(big_buffer, s); |
92 | return big_buffer; | 106 | return big_buffer; |
93 | } | 107 | } |
94 | 108 | ||
95 | bool | 109 | bool |
96 | MakefileGenerator::generateMocList(QString fn_target) | 110 | MakefileGenerator::generateMocList(const QString &fn_target) |
97 | { | 111 | { |
98 | if(!findMocDestination(fn_target).isEmpty()) | 112 | if(!findMocDestination(fn_target).isEmpty()) |
99 | return TRUE; | 113 | return TRUE; |
100 | 114 | ||
101 | QString fn_local = Option::fixPathToLocalOS(fileFixify(fn_target, QDir::currentDirPath(), Option::output_dir)); | 115 | QString fn_local = Option::fixPathToLocalOS(fileFixify(fn_target, QDir::currentDirPath(), Option::output_dir)); |
102 | 116 | ||
103 | int file = open(fn_local.latin1(), O_RDONLY); | 117 | int file = open(fn_local.latin1(), O_RDONLY); |
104 | if(file == -1) | 118 | if(file == -1) |
@@ -168,38 +182,40 @@ MakefileGenerator::generateMocList(QString fn_target) | |||
168 | len=OBJ_LEN; | 182 | len=OBJ_LEN; |
169 | } else if(!strncmp(big_buffer+x, "Q_DISPATCH", DIS_LEN)) { | 183 | } else if(!strncmp(big_buffer+x, "Q_DISPATCH", DIS_LEN)) { |
170 | len=DIS_LEN; | 184 | len=DIS_LEN; |
171 | } | 185 | } |
172 | if(SYMBOL_CHAR(*(big_buffer+x+len))) | 186 | if(SYMBOL_CHAR(*(big_buffer+x+len))) |
173 | interesting = FALSE; | 187 | interesting = FALSE; |
174 | if(interesting) { | 188 | if(interesting) { |
175 | *(big_buffer+x+len) = '\0'; | 189 | *(big_buffer+x+len) = '\0'; |
176 | debug_msg(2, "Mocgen: %s:%d Found MOC symbol %s", fn_target.latin1(), line_count, big_buffer+x); | 190 | debug_msg(2, "Mocgen: %s:%d Found MOC symbol %s", fn_target.latin1(), |
191 | line_count, big_buffer+x); | ||
177 | 192 | ||
178 | int ext_pos = fn_target.findRev('.'); | 193 | int ext_pos = fn_target.findRev('.'); |
179 | int ext_len = fn_target.length() - ext_pos; | 194 | int ext_len = fn_target.length() - ext_pos; |
180 | int dir_pos = fn_target.findRev(Option::dir_sep, ext_pos); | 195 | int dir_pos = fn_target.findRev(Option::dir_sep, ext_pos); |
181 | QString mocFile; | 196 | QString mocFile; |
182 | if(!project->isEmpty("MOC_DIR")) | 197 | if(!project->isEmpty("MOC_DIR")) |
183 | mocFile = project->first("MOC_DIR"); | 198 | mocFile = project->first("MOC_DIR"); |
184 | else if(dir_pos != -1) | 199 | else if(dir_pos != -1) |
185 | mocFile = fn_target.left(dir_pos+1); | 200 | mocFile = fn_target.left(dir_pos+1); |
186 | 201 | ||
187 | bool cpp_ext = FALSE; | 202 | bool cpp_ext = FALSE; |
188 | for(QStringList::Iterator cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) { | 203 | for(QStringList::Iterator cppit = Option::cpp_ext.begin(); |
204 | cppit != Option::cpp_ext.end(); ++cppit) { | ||
189 | if((cpp_ext = (fn_target.right(ext_len) == (*cppit)))) | 205 | if((cpp_ext = (fn_target.right(ext_len) == (*cppit)))) |
190 | break; | 206 | break; |
191 | } | 207 | } |
192 | if(cpp_ext) { | 208 | if(cpp_ext) { |
193 | mocFile += fn_target.mid(dir_pos+1, ext_pos - dir_pos-1) + Option::moc_ext; | 209 | mocFile += fn_target.mid(dir_pos+1, ext_pos - dir_pos-1) + Option::moc_ext; |
194 | findDependencies(fn_target).append(mocFile); | ||
195 | project->variables()["_SRCMOC"].append(mocFile); | 210 | project->variables()["_SRCMOC"].append(mocFile); |
196 | } else if(project->variables()["HEADERS"].findIndex(fn_target) != -1) { | 211 | } else if(project->variables()["HEADERS"].findIndex(fn_target) != -1) { |
197 | for(QStringList::Iterator hit = Option::h_ext.begin(); hit != Option::h_ext.end(); ++hit) { | 212 | for(QStringList::Iterator hit = Option::h_ext.begin(); |
213 | hit != Option::h_ext.end(); ++hit) { | ||
198 | if((fn_target.right(ext_len) == (*hit))) { | 214 | if((fn_target.right(ext_len) == (*hit))) { |
199 | mocFile += Option::moc_mod + fn_target.mid(dir_pos+1, ext_pos - dir_pos-1) + | 215 | mocFile += Option::moc_mod + fn_target.mid(dir_pos+1, ext_pos - dir_pos-1) + |
200 | Option::cpp_ext.first(); | 216 | Option::cpp_ext.first(); |
201 | logicWarn(mocFile, "SOURCES"); | 217 | logicWarn(mocFile, "SOURCES"); |
202 | project->variables()["_HDRMOC"].append(mocFile); | 218 | project->variables()["_HDRMOC"].append(mocFile); |
203 | break; | 219 | break; |
204 | } | 220 | } |
205 | } | 221 | } |
@@ -220,23 +236,22 @@ MakefileGenerator::generateMocList(QString fn_target) | |||
220 | line_count++; | 236 | line_count++; |
221 | } | 237 | } |
222 | #undef OBJ_LEN | 238 | #undef OBJ_LEN |
223 | #undef DIS_LEN | 239 | #undef DIS_LEN |
224 | return TRUE; | 240 | return TRUE; |
225 | } | 241 | } |
226 | 242 | ||
227 | bool | 243 | bool |
228 | MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QString fn, bool recurse) | 244 | MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const QString &f, bool recurse) |
229 | { | 245 | { |
230 | fn = fileFixify(fn); | 246 | QStringList &fndeps = findDependencies(f); |
231 | QStringList &fndeps = findDependencies(fn); | ||
232 | if(!fndeps.isEmpty()) | 247 | if(!fndeps.isEmpty()) |
233 | return TRUE; | 248 | return TRUE; |
234 | 249 | QString fn = fileFixify(f, QDir::currentDirPath(), Option::output_dir); | |
235 | fn = Option::fixPathToLocalOS(fn, FALSE); | 250 | fn = Option::fixPathToLocalOS(fn, FALSE); |
236 | QString fix_env_fn = Option::fixPathToLocalOS(fn); | 251 | QString fix_env_fn = Option::fixPathToLocalOS(fn); |
237 | int file = open(fix_env_fn.latin1(), O_RDONLY); | 252 | int file = open(fix_env_fn.latin1(), O_RDONLY); |
238 | if(file == -1) | 253 | if(file == -1) |
239 | return FALSE; | 254 | return FALSE; |
240 | struct stat fst; | 255 | struct stat fst; |
241 | if(fstat(file, &fst) || S_ISDIR(fst.st_mode)) | 256 | if(fstat(file, &fst) || S_ISDIR(fst.st_mode)) |
242 | return FALSE; //shouldn't happen | 257 | return FALSE; //shouldn't happen |
@@ -283,18 +298,20 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri | |||
283 | } | 298 | } |
284 | } | 299 | } |
285 | } | 300 | } |
286 | if(*(big_buffer + x) == '#') { | 301 | if(*(big_buffer + x) == '#') { |
287 | x++; | 302 | x++; |
288 | while(x < total_size_read && //Skip spaces after hash | 303 | while(x < total_size_read && //Skip spaces after hash |
289 | (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t')) | 304 | (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t')) |
290 | x++; | 305 | x++; |
291 | if(total_size_read >= x + 8 && !strncmp(big_buffer + x, "include ", 8)) { | 306 | if(total_size_read >= x + 8 && !strncmp(big_buffer + x, "include", 7) && |
292 | for(x+=8; //skip spaces after keyword | 307 | (*(big_buffer + x + 7) == ' ' || *(big_buffer + x + 7) == '\t' || |
308 | *(big_buffer + x + 7) == '<' || *(big_buffer + x + 7) == '"')) { | ||
309 | for(x+=7; //skip spaces after keyword | ||
293 | x < total_size_read && (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t'); | 310 | x < total_size_read && (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t'); |
294 | x++); | 311 | x++); |
295 | char term = *(big_buffer + x); | 312 | char term = *(big_buffer + x); |
296 | if(term == '"'); | 313 | if(term == '"'); |
297 | else if(term == '<') | 314 | else if(term == '<') |
298 | term = '>'; | 315 | term = '>'; |
299 | else | 316 | else |
300 | continue; //wtf? | 317 | continue; //wtf? |
@@ -323,31 +340,31 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri | |||
323 | debug_msg(0, "%s:%d qmake_warning -- %s", fix_env_fn.latin1(), | 340 | debug_msg(0, "%s:%d qmake_warning -- %s", fix_env_fn.latin1(), |
324 | line_count, msg.latin1()); | 341 | line_count, msg.latin1()); |
325 | *(big_buffer + x + msg_len) = term; //put it back | 342 | *(big_buffer + x + msg_len) = term; //put it back |
326 | } | 343 | } |
327 | } | 344 | } |
328 | } else if(ui_file) { | 345 | } else if(ui_file) { |
329 | // skip whitespaces | 346 | // skip whitespaces |
330 | while(x < total_size_read && | 347 | while(x < total_size_read && |
331 | (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t')) | 348 | (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t')) |
332 | x++; | 349 | x++; |
333 | if(*(big_buffer + x) == '<') { | 350 | if(*(big_buffer + x) == '<') { |
334 | x++; | 351 | x++; |
335 | if(total_size_read >= x + 12 && !strncmp(big_buffer + x, "includehint", 11) && | 352 | if(total_size_read >= x + 12 && !strncmp(big_buffer + x, "includehint", 11) && |
336 | (*(big_buffer + x + 11) == ' ' || *(big_buffer + x + 11) == '>')) { | 353 | (*(big_buffer + x + 11) == ' ' || *(big_buffer + x + 11) == '>')) { |
337 | for(x += 12; *(big_buffer + x) != '>'; x++); | 354 | for(x += 12; *(big_buffer + x) != '>'; x++); |
338 | int inc_len = 0; | 355 | int inc_len = 0; |
339 | for(x += 1 ; *(big_buffer + x + inc_len) != '<'; inc_len++); | 356 | for(x += 1 ; *(big_buffer + x + inc_len) != '<'; inc_len++); |
340 | *(big_buffer + x + inc_len) = '\0'; | 357 | *(big_buffer + x + inc_len) = '\0'; |
341 | inc = big_buffer + x; | 358 | inc = big_buffer + x; |
342 | } else if(total_size_read >= x + 8 && !strncmp(big_buffer + x, "include", 7) && | 359 | } else if(total_size_read >= x + 8 && !strncmp(big_buffer + x, "include", 7) && |
343 | (*(big_buffer + x + 7) == ' ' || *(big_buffer + x + 7) == '>')) { | 360 | (*(big_buffer + x + 7) == ' ' || *(big_buffer + x + 7) == '>')) { |
344 | for(x += 8; *(big_buffer + x) != '>'; x++) { | 361 | for(x += 8; *(big_buffer + x) != '>'; x++) { |
345 | if(total_size_read >= x + 9 && *(big_buffer + x) == 'i' && | 362 | if(total_size_read >= x + 9 && *(big_buffer + x) == 'i' && |
346 | !strncmp(big_buffer + x, "impldecl", 8)) { | 363 | !strncmp(big_buffer + x, "impldecl", 8)) { |
347 | for(x += 8; *(big_buffer + x) != '='; x++); | 364 | for(x += 8; *(big_buffer + x) != '='; x++); |
348 | if(*(big_buffer + x) != '=') | 365 | if(*(big_buffer + x) != '=') |
349 | continue; | 366 | continue; |
350 | for(x++; *(big_buffer+x) == '\t' || *(big_buffer+x) == ' '; x++); | 367 | for(x++; *(big_buffer+x) == '\t' || *(big_buffer+x) == ' '; x++); |
351 | char quote = 0; | 368 | char quote = 0; |
352 | if(*(big_buffer+x) == '\'' || *(big_buffer+x) == '"') { | 369 | if(*(big_buffer+x) == '\'' || *(big_buffer+x) == '"') { |
353 | quote = *(big_buffer + x); | 370 | quote = *(big_buffer + x); |
@@ -364,30 +381,31 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri | |||
364 | } | 381 | } |
365 | } | 382 | } |
366 | char saved = *(big_buffer + x + val_len); | 383 | char saved = *(big_buffer + x + val_len); |
367 | *(big_buffer + x + val_len) = '\0'; | 384 | *(big_buffer + x + val_len) = '\0'; |
368 | QString where = big_buffer + x; | 385 | QString where = big_buffer + x; |
369 | *(big_buffer + x + val_len) = saved; | 386 | *(big_buffer + x + val_len) = saved; |
370 | if(where == "in implementation") { | 387 | if(where == "in implementation") { |
371 | QString cpp = fn.left(fn.length() - Option::ui_ext.length()) + | 388 | QString cpp = fn.left(fn.length() - Option::ui_ext.length()) + |
372 | Option::cpp_ext.first(); | 389 | Option::cpp_ext.first(); |
373 | outdeps = &findDependencies(cpp); | 390 | outdeps = &findDependencies(cpp); |
374 | } | 391 | } |
375 | } | 392 | } |
376 | } | 393 | } |
377 | int inc_len = 0; | 394 | int inc_len = 0; |
378 | for(x += 1 ; *(big_buffer + x + inc_len) != '<'; inc_len++); | 395 | for(x += 1 ; *(big_buffer + x + inc_len) != '<'; inc_len++); |
379 | *(big_buffer + x + inc_len) = '\0'; | 396 | *(big_buffer + x + inc_len) = '\0'; |
380 | inc = big_buffer + x; | 397 | inc = big_buffer + x; |
381 | } | 398 | } |
382 | } | 399 | } |
383 | } | 400 | } |
384 | 401 | ||
385 | if(!inc.isEmpty()) { | 402 | if(!inc.isEmpty()) { |
403 | bool from_source_dir = TRUE; | ||
386 | debug_msg(5, "%s:%d Found dependency to %s", fix_env_fn.latin1(), | 404 | debug_msg(5, "%s:%d Found dependency to %s", fix_env_fn.latin1(), |
387 | line_count, inc.latin1()); | 405 | line_count, inc.latin1()); |
388 | if(!project->isEmpty("SKIP_DEPENDS")) { | 406 | if(!project->isEmpty("SKIP_DEPENDS")) { |
389 | bool found = FALSE; | 407 | bool found = FALSE; |
390 | QStringList &nodeplist = project->values("SKIP_DEPENDS"); | 408 | QStringList &nodeplist = project->values("SKIP_DEPENDS"); |
391 | for(QStringList::Iterator it = nodeplist.begin(); | 409 | for(QStringList::Iterator it = nodeplist.begin(); |
392 | it != nodeplist.end(); ++it) { | 410 | it != nodeplist.end(); ++it) { |
393 | QRegExp regx((*it)); | 411 | QRegExp regx((*it)); |
@@ -399,38 +417,39 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri | |||
399 | if(found) | 417 | if(found) |
400 | continue; | 418 | continue; |
401 | } | 419 | } |
402 | 420 | ||
403 | QString fqn; | 421 | QString fqn; |
404 | if(project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH") && | 422 | if(project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH") && |
405 | !stat(fix_env_fndir + inc, &fst) && !S_ISDIR(fst.st_mode)) { | 423 | !stat(fix_env_fndir + inc, &fst) && !S_ISDIR(fst.st_mode)) { |
406 | fqn = fndir + inc; | 424 | fqn = fndir + inc; |
425 | goto handle_fqn; | ||
407 | } else { | 426 | } else { |
408 | if((Option::target_mode == Option::TARG_MAC9_MODE && inc.find(':')) || | 427 | if((Option::target_mode == Option::TARG_MAC9_MODE && inc.find(':')) || |
409 | (Option::target_mode == Option::TARG_WIN_MODE && inc[1] != ':') || | 428 | (Option::target_mode == Option::TARG_WIN_MODE && inc[1] != ':') || |
410 | ((Option::target_mode == Option::TARG_UNIX_MODE || | 429 | ((Option::target_mode == Option::TARG_UNIX_MODE || |
411 | Option::target_mode == Option::TARG_QNX6_MODE || | 430 | Option::target_mode == Option::TARG_QNX6_MODE || |
412 | Option::target_mode == Option::TARG_MACX_MODE) && | 431 | Option::target_mode == Option::TARG_MACX_MODE) && |
413 | inc[0] != '/')) { | 432 | inc[0] != '/')) { |
414 | for(MakefileDependDir *mdd = dirs.first(); mdd; mdd = dirs.next() ) { | 433 | for(MakefileDependDir *mdd = dirs.first(); mdd; mdd = dirs.next() ) { |
415 | if(!stat(mdd->local_dir + QDir::separator() + inc, &fst) && | 434 | if(!stat(mdd->local_dir + QDir::separator() + inc, &fst) && |
416 | !S_ISDIR(fst.st_mode)) { | 435 | !S_ISDIR(fst.st_mode)) { |
417 | fqn = mdd->real_dir + QDir::separator() + inc; | 436 | fqn = mdd->real_dir + QDir::separator() + inc; |
418 | break; | 437 | goto handle_fqn; |
419 | } | 438 | } |
420 | } | 439 | } |
421 | } | 440 | } |
422 | } | 441 | } |
423 | if(fqn.isEmpty()) { | 442 | if(fqn.isEmpty() && Option::mkfile::do_dep_heuristics) { |
424 | //these are some hacky heuristics it will try to do on an include | 443 | //these are some hacky heuristics it will try to do on an include |
425 | //however these can be turned off at runtime, I'm not sure how | 444 | //however these can be turned off at runtime, I'm not sure how |
426 | //reliable these will be, most likely when problems arise turn it off | 445 | //reliable these will be, most likely when problems arise turn it off |
427 | //and see if they go away.. | 446 | //and see if they go away.. |
428 | if(Option::mkfile::do_dep_heuristics && depHeuristics.contains(inc)) { | 447 | if(depHeuristics.contains(inc)) { |
429 | fqn = depHeuristics[inc]; | 448 | fqn = depHeuristics[inc]; |
430 | } else if(Option::mkfile::do_dep_heuristics) { //some heuristics.. | 449 | } else if(Option::mkfile::do_dep_heuristics) { //some heuristics.. |
431 | //is it a file from a .ui? | 450 | //is it a file from a .ui? |
432 | QString inc_file = inc.section(Option::dir_sep, -1); | 451 | QString inc_file = inc.section(Option::dir_sep, -1); |
433 | int extn = inc_file.findRev('.'); | 452 | int extn = inc_file.findRev('.'); |
434 | if(extn != -1 && | 453 | if(extn != -1 && |
435 | (inc_file.right(inc_file.length()-extn) == Option::cpp_ext.first() || | 454 | (inc_file.right(inc_file.length()-extn) == Option::cpp_ext.first() || |
436 | inc_file.right(inc_file.length()-extn) == Option::h_ext.first())) { | 455 | inc_file.right(inc_file.length()-extn) == Option::h_ext.first())) { |
@@ -442,49 +461,101 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri | |||
442 | fqn = project->first("UI_DIR"); | 461 | fqn = project->first("UI_DIR"); |
443 | else if(!project->isEmpty("UI_HEADERS_DIR")) | 462 | else if(!project->isEmpty("UI_HEADERS_DIR")) |
444 | fqn = project->first("UI_HEADERS_DIR"); | 463 | fqn = project->first("UI_HEADERS_DIR"); |
445 | else | 464 | else |
446 | fqn = (*it).section(Option::dir_sep, 0, -2); | 465 | fqn = (*it).section(Option::dir_sep, 0, -2); |
447 | if(!fqn.isEmpty() && !fqn.endsWith(Option::dir_sep)) | 466 | if(!fqn.isEmpty() && !fqn.endsWith(Option::dir_sep)) |
448 | fqn += Option::dir_sep; | 467 | fqn += Option::dir_sep; |
449 | fqn += inc_file; | 468 | fqn += inc_file; |
450 | break; | 469 | from_source_dir = FALSE; //uics go in the output_dir (so don't fix them) |
470 | fqn = fileFixify(fqn, QDir::currentDirPath(), Option::output_dir); | ||
471 | goto handle_fqn; | ||
472 | } | ||
473 | } | ||
474 | } | ||
475 | if(project->isActiveConfig("lex_included")) { //is this the lex file? | ||
476 | QString rhs = Option::lex_mod + Option::cpp_ext.first(); | ||
477 | if(inc.endsWith(rhs)) { | ||
478 | QString lhs = inc.left(inc.length() - rhs.length()) + Option::lex_ext; | ||
479 | QStringList ll = project->variables()["LEXSOURCES"]; | ||
480 | for(QStringList::Iterator it = ll.begin(); it != ll.end(); ++it) { | ||
481 | QString s = (*it), d; | ||
482 | int slsh = s.findRev(Option::dir_sep); | ||
483 | if(slsh != -1) { | ||
484 | d = s.left(slsh + 1); | ||
485 | s = s.right(s.length() - slsh - 1); | ||
486 | } | ||
487 | if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) | ||
488 | d = project->first("QMAKE_ABSOLUTE_SOURCE_PATH"); | ||
489 | if(s == lhs) { | ||
490 | fqn = d + inc; | ||
491 | goto handle_fqn; | ||
492 | } | ||
451 | } | 493 | } |
452 | } | 494 | } |
453 | } | 495 | } |
454 | if(fqn.isEmpty()) { //is it from a .y? | 496 | { //is it from a .y? |
455 | QString rhs = Option::yacc_mod + Option::h_ext.first(); | 497 | QString rhs = Option::yacc_mod + Option::h_ext.first(); |
456 | if(inc.endsWith(rhs)) { | 498 | if(inc.endsWith(rhs)) { |
457 | QString lhs = inc.left(inc.length() - rhs.length()) + Option::yacc_ext; | 499 | QString lhs = inc.left(inc.length() - rhs.length()) + Option::yacc_ext; |
458 | QStringList yl = project->variables()["YACCSOURCES"]; | 500 | QStringList yl = project->variables()["YACCSOURCES"]; |
459 | for(QStringList::Iterator it = yl.begin(); it != yl.end(); ++it) { | 501 | for(QStringList::Iterator it = yl.begin(); it != yl.end(); ++it) { |
460 | QString s = (*it), d; | 502 | QString s = (*it), d; |
461 | int slsh = s.findRev(Option::dir_sep); | 503 | int slsh = s.findRev(Option::dir_sep); |
462 | if(slsh != -1) { | 504 | if(slsh != -1) { |
463 | d = s.left(slsh + 1); | 505 | d = s.left(slsh + 1); |
464 | s = s.right(s.length() - slsh - 1); | 506 | s = s.right(s.length() - slsh - 1); |
465 | } | 507 | } |
466 | if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) | 508 | if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) |
467 | d = project->first("QMAKE_ABSOLUTE_SOURCE_PATH"); | 509 | d = project->first("QMAKE_ABSOLUTE_SOURCE_PATH"); |
468 | if(s == lhs) { | 510 | if(s == lhs) { |
469 | fqn = d + inc; | 511 | fqn = d + inc; |
470 | break; | 512 | goto handle_fqn; |
513 | } | ||
514 | } | ||
515 | } | ||
516 | } | ||
517 | if(mocAware() && //is it a moc file? | ||
518 | (inc.endsWith(Option::cpp_ext.first()) || inc.endsWith(Option::moc_ext))) { | ||
519 | QString mocs[] = { QString("_HDRMOC"), QString("_SRCMOC"), QString::null }; | ||
520 | for(int moc = 0; !mocs[moc].isNull(); moc++) { | ||
521 | QStringList &l = project->variables()[mocs[moc]]; | ||
522 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { | ||
523 | QString file = Option::fixPathToTargetOS((*it)); | ||
524 | if(file.section(Option::dir_sep, -(inc.contains('/')+1)) == inc) { | ||
525 | fqn = (*it); | ||
526 | if(mocs[moc] == "_HDRMOC") { | ||
527 | //Since it is include, no need to link it in as well | ||
528 | project->variables()["_SRCMOC"].append((*it)); | ||
529 | l.remove(it); | ||
530 | } else if(!findMocSource(fqn).endsWith(fn)) { | ||
531 | /* Not really a very good test, but this will at least avoid | ||
532 | confusion if it really does happen (since tmake/qmake | ||
533 | previously didn't even allow this the test is mostly accurate) */ | ||
534 | warn_msg(WarnLogic, | ||
535 | "Found potential multiple MOC include %s (%s) in '%s'", | ||
536 | inc.latin1(), fqn.latin1(), fix_env_fn.latin1()); | ||
537 | } | ||
538 | from_source_dir = FALSE; //mocs go in the output_dir (so don't fix them) | ||
539 | goto handle_fqn; | ||
471 | } | 540 | } |
472 | } | 541 | } |
473 | } | 542 | } |
474 | } | 543 | } |
475 | depHeuristics.insert(inc, fqn); | 544 | depHeuristics.insert(inc, fqn); |
476 | } | 545 | } |
477 | if(!Option::mkfile::do_dep_heuristics || fqn.isEmpty()) //I give up | ||
478 | continue; | ||
479 | } | 546 | } |
480 | 547 | handle_fqn: | |
481 | fqn = fileFixify(Option::fixPathToTargetOS(fqn, FALSE)); | 548 | if(fqn.isEmpty()) //I give up |
482 | debug_msg(4, "Resolved dependancy of %s to %s", inc.latin1(), fqn.latin1()); | 549 | continue; |
550 | fqn = Option::fixPathToTargetOS(fqn, FALSE); | ||
551 | if(from_source_dir) | ||
552 | fqn = fileFixify(fqn); | ||
553 | debug_msg(4, "Resolved dependency of %s to %s", inc.latin1(), fqn.latin1()); | ||
483 | if(outdeps && outdeps->findIndex(fqn) == -1) | 554 | if(outdeps && outdeps->findIndex(fqn) == -1) |
484 | outdeps->append(fqn); | 555 | outdeps->append(fqn); |
485 | } | 556 | } |
486 | //read past new line now.. | 557 | //read past new line now.. |
487 | for( ; x < total_size_read && (*(big_buffer + x) != '\n'); x++); | 558 | for( ; x < total_size_read && (*(big_buffer + x) != '\n'); x++); |
488 | line_count++; | 559 | line_count++; |
489 | } | 560 | } |
490 | 561 | ||
@@ -492,17 +563,17 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri | |||
492 | for(QStringList::Iterator fnit = fndeps.begin(); fnit != fndeps.end(); ++fnit) { | 563 | for(QStringList::Iterator fnit = fndeps.begin(); fnit != fndeps.end(); ++fnit) { |
493 | generateDependencies(dirs, (*fnit), recurse); | 564 | generateDependencies(dirs, (*fnit), recurse); |
494 | QStringList &deplist = findDependencies((*fnit)); | 565 | QStringList &deplist = findDependencies((*fnit)); |
495 | for(QStringList::Iterator it = deplist.begin(); it != deplist.end(); ++it) | 566 | for(QStringList::Iterator it = deplist.begin(); it != deplist.end(); ++it) |
496 | if(fndeps.findIndex((*it)) == -1) | 567 | if(fndeps.findIndex((*it)) == -1) |
497 | fndeps.append((*it)); | 568 | fndeps.append((*it)); |
498 | } | 569 | } |
499 | } | 570 | } |
500 | debug_msg(2, "Dependancies: %s -> %s", fn.latin1(), fndeps.join(" :: ").latin1()); | 571 | debug_msg(2, "Dependencies: %s -> %s", fn.latin1(), fndeps.join(" :: ").latin1()); |
501 | return TRUE; | 572 | return TRUE; |
502 | } | 573 | } |
503 | 574 | ||
504 | void | 575 | void |
505 | MakefileGenerator::initOutPaths() | 576 | MakefileGenerator::initOutPaths() |
506 | { | 577 | { |
507 | if(init_opath_already) | 578 | if(init_opath_already) |
508 | return; | 579 | return; |
@@ -608,32 +679,36 @@ MakefileGenerator::init() | |||
608 | for(int y = 0; paths[y] != QString::null; y++) { | 679 | for(int y = 0; paths[y] != QString::null; y++) { |
609 | QStringList &l = v[paths[y]]; | 680 | QStringList &l = v[paths[y]]; |
610 | if(!l.isEmpty()) | 681 | if(!l.isEmpty()) |
611 | l = fileFixify(l); | 682 | l = fileFixify(l); |
612 | } | 683 | } |
613 | 684 | ||
614 | /* get deps and mocables */ | 685 | /* get deps and mocables */ |
615 | QDict<void> cache_found_files; | 686 | QDict<void> cache_found_files; |
616 | QString cache_file(Option::output_dir + QDir::separator() + ".qmake.internal.cache"); | 687 | QString cache_file(".qmake.internal.cache"); |
688 | if(!project->isEmpty("QMAKE_INTERNAL_CACHE_FILE")) | ||
689 | cache_file = Option::fixPathToLocalOS(project->first("QMAKE_INTERNAL_CACHE_FILE")); | ||
690 | if(cache_file.find(QDir::separator()) == -1) //guess they know what they are doing.. | ||
691 | cache_file.prepend(Option::output_dir + QDir::separator()); | ||
617 | if((Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT || | 692 | if((Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT || |
618 | Option::mkfile::do_deps || Option::mkfile::do_mocs) && !noIO()) { | 693 | Option::mkfile::do_deps || Option::mkfile::do_mocs) && !noIO()) { |
619 | QPtrList<MakefileDependDir> deplist; | 694 | QPtrList<MakefileDependDir> deplist; |
620 | deplist.setAutoDelete(TRUE); | 695 | deplist.setAutoDelete(TRUE); |
621 | if((Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT || Option::mkfile::do_deps) && | 696 | if((Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT || Option::mkfile::do_deps) && |
622 | doDepends()) { | 697 | doDepends()) { |
623 | QStringList incDirs = v["DEPENDPATH"] + v["QMAKE_ABSOLUTE_SOURCE_PATH"]; | 698 | QStringList incDirs = v["DEPENDPATH"] + v["QMAKE_ABSOLUTE_SOURCE_PATH"]; |
624 | if(project->isActiveConfig("depend_includepath")) | 699 | if(project->isActiveConfig("depend_includepath")) |
625 | incDirs += v["INCLUDEPATH"]; | 700 | incDirs += v["INCLUDEPATH"]; |
626 | for(QStringList::Iterator it = incDirs.begin(); it != incDirs.end(); ++it) { | 701 | for(QStringList::Iterator it = incDirs.begin(); it != incDirs.end(); ++it) { |
627 | QString r = (*it), l = Option::fixPathToLocalOS((*it)); | 702 | QString r = (*it), l = Option::fixPathToLocalOS((*it)); |
628 | deplist.append(new MakefileDependDir(r.replace("\"",""), | 703 | deplist.append(new MakefileDependDir(r.replace("\"",""), |
629 | l.replace("\"",""))); | 704 | l.replace("\"",""))); |
630 | } | 705 | } |
631 | debug_msg(1, "Dependancy Directories: %s", incDirs.join(" :: ").latin1()); | 706 | debug_msg(1, "Dependency Directories: %s", incDirs.join(" :: ").latin1()); |
632 | if(Option::output.name() != "-" && project->isActiveConfig("qmake_cache")) { | 707 | if(Option::output.name() != "-" && project->isActiveConfig("qmake_cache")) { |
633 | QFile cachef(cache_file); | 708 | QFile cachef(cache_file); |
634 | if(cachef.open(IO_ReadOnly | IO_Translate)) { | 709 | if(cachef.open(IO_ReadOnly | IO_Translate)) { |
635 | QFileInfo cachefi(cache_file); | 710 | QFileInfo cachefi(cache_file); |
636 | debug_msg(2, "Trying internal cache information: %s", cache_file.latin1()); | 711 | debug_msg(2, "Trying internal cache information: %s", cache_file.latin1()); |
637 | QTextStream cachet(&cachef); | 712 | QTextStream cachet(&cachef); |
638 | QString line, file; | 713 | QString line, file; |
639 | enum { CacheInfo, CacheDepend, CacheMoc } state = CacheInfo; | 714 | enum { CacheInfo, CacheDepend, CacheMoc } state = CacheInfo; |
@@ -678,17 +753,17 @@ MakefileGenerator::init() | |||
678 | cache_found_files.insert((*dep_it), (void *)1); | 753 | cache_found_files.insert((*dep_it), (void *)1); |
679 | } else { | 754 | } else { |
680 | found = FALSE; | 755 | found = FALSE; |
681 | break; | 756 | break; |
682 | } | 757 | } |
683 | } | 758 | } |
684 | } | 759 | } |
685 | if(found) { | 760 | if(found) { |
686 | debug_msg(2, "Dependancies (cached): %s -> %s", file.latin1(), | 761 | debug_msg(2, "Dependencies (cached): %s -> %s", file.latin1(), |
687 | files.join(" :: ").latin1()); | 762 | files.join(" :: ").latin1()); |
688 | findDependencies(file) = files; | 763 | findDependencies(file) = files; |
689 | } | 764 | } |
690 | } | 765 | } |
691 | } else { | 766 | } else { |
692 | void *found = cache_found_files[file]; | 767 | void *found = cache_found_files[file]; |
693 | if(found != (void *)2) { | 768 | if(found != (void *)2) { |
694 | if(found) { | 769 | if(found) { |
@@ -738,16 +813,17 @@ MakefileGenerator::init() | |||
738 | QString::null }; | 813 | QString::null }; |
739 | depHeuristics.clear(); | 814 | depHeuristics.clear(); |
740 | bool write_cache = FALSE, read_cache = QFile::exists(cache_file); | 815 | bool write_cache = FALSE, read_cache = QFile::exists(cache_file); |
741 | for(int x = 0; sources[x] != QString::null; x++) { | 816 | for(int x = 0; sources[x] != QString::null; x++) { |
742 | QStringList vpath, &l = v[sources[x]]; | 817 | QStringList vpath, &l = v[sources[x]]; |
743 | for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { | 818 | for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { |
744 | if(!(*val_it).isEmpty()) { | 819 | if(!(*val_it).isEmpty()) { |
745 | QString file = Option::fixPathToLocalOS((*val_it)); | 820 | QString file = Option::fixPathToLocalOS((*val_it)); |
821 | QStringList file_list(file); | ||
746 | if(!QFile::exists(file)) { | 822 | if(!QFile::exists(file)) { |
747 | bool found = FALSE; | 823 | bool found = FALSE; |
748 | if(QDir::isRelativePath(file)) { | 824 | if(QDir::isRelativePath(file)) { |
749 | if(vpath.isEmpty()) | 825 | if(vpath.isEmpty()) |
750 | vpath = v["VPATH_" + sources[x]] + v["VPATH"] + | 826 | vpath = v["VPATH_" + sources[x]] + v["VPATH"] + |
751 | v["QMAKE_ABSOLUTE_SOURCE_PATH"] + v["DEPENDPATH"]; | 827 | v["QMAKE_ABSOLUTE_SOURCE_PATH"] + v["DEPENDPATH"]; |
752 | 828 | ||
753 | for(QStringList::Iterator vpath_it = vpath.begin(); | 829 | for(QStringList::Iterator vpath_it = vpath.begin(); |
@@ -764,75 +840,84 @@ MakefileGenerator::init() | |||
764 | break; | 840 | break; |
765 | } | 841 | } |
766 | } | 842 | } |
767 | } | 843 | } |
768 | if(!found) { | 844 | if(!found) { |
769 | QString dir, regex = (*val_it), real_dir; | 845 | QString dir, regex = (*val_it), real_dir; |
770 | if(regex.findRev(Option::dir_sep) != -1) { | 846 | if(regex.findRev(Option::dir_sep) != -1) { |
771 | dir = regex.left(regex.findRev(Option::dir_sep) + 1); | 847 | dir = regex.left(regex.findRev(Option::dir_sep) + 1); |
772 | real_dir = fileFixify(Option::fixPathToLocalOS(dir), | 848 | real_dir = fileFixify(Option::fixPathToLocalOS(dir), |
773 | QDir::currentDirPath(), Option::output_dir); | 849 | QDir::currentDirPath(), Option::output_dir); |
774 | regex = regex.right(regex.length() - dir.length()); | 850 | regex = regex.right(regex.length() - dir.length()); |
775 | } | 851 | } |
776 | if(real_dir.isEmpty() || QFile::exists(real_dir)) { | 852 | if(real_dir.isEmpty() || QFile::exists(real_dir)) { |
777 | QDir d(real_dir, regex); | 853 | QDir d(real_dir, regex); |
778 | if(!d.count()) { | 854 | if(!d.count()) { |
779 | debug_msg(1, "%s:%d Failure to find %s in vpath (%s)", | 855 | debug_msg(1, "%s:%d Failure to find %s in vpath (%s)", |
780 | __FILE__, __LINE__, | 856 | __FILE__, __LINE__, |
781 | (*val_it).latin1(), vpath.join("::").latin1()); | 857 | (*val_it).latin1(), vpath.join("::").latin1()); |
782 | warn_msg(WarnLogic, "Failure to find: %s", (*val_it).latin1()); | 858 | warn_msg(WarnLogic, "Failure to find: %s", (*val_it).latin1()); |
783 | continue; | 859 | continue; |
784 | } else { | 860 | } else { |
785 | (*val_it) = dir + d[0]; | 861 | file_list.clear(); |
786 | for(int i = 1; i < (int)d.count(); i++) | 862 | for(int i = 0; i < (int)d.count(); i++) { |
787 | l.insert(val_it, dir + d[i]); | 863 | file_list.append(dir + d[i]); |
864 | if(i == (int)d.count() - 1) | ||
865 | (*val_it) = dir + d[i]; | ||
866 | else | ||
867 | l.insert(val_it, dir + d[i]); | ||
868 | } | ||
788 | } | 869 | } |
789 | } else { | 870 | } else { |
790 | debug_msg(1, "%s:%d Cannot match %s%c%s, as %s does not exist.", | 871 | debug_msg(1, "%s:%d Cannot match %s%c%s, as %s does not exist.", |
791 | __FILE__, __LINE__, | 872 | __FILE__, __LINE__, |
792 | real_dir.latin1(), QDir::separator(), regex.latin1(), | 873 | real_dir.latin1(), QDir::separator(), regex.latin1(), |
793 | real_dir.latin1()); | 874 | real_dir.latin1()); |
794 | warn_msg(WarnLogic, "Failure to find: %s", (*val_it).latin1()); | 875 | warn_msg(WarnLogic, "Failure to find: %s", (*val_it).latin1()); |
795 | } | 876 | } |
796 | } | 877 | } |
797 | } | 878 | } |
798 | 879 | for(QStringList::Iterator file_it = file_list.begin(); | |
799 | QString val_file = fileFixify((*val_it)); | 880 | file_it != file_list.end(); ++file_it) { |
800 | bool found_cache_moc = FALSE, found_cache_dep = FALSE; | 881 | QString file_list_file = fileFixify((*file_it)); |
801 | if(read_cache && Option::output.name() != "-" && | 882 | bool found_cache_moc = FALSE, found_cache_dep = FALSE; |
802 | project->isActiveConfig("qmake_cache")) { | 883 | if(read_cache && Option::output.name() != "-" && |
803 | if(!findDependencies(val_file).isEmpty()) | 884 | project->isActiveConfig("qmake_cache")) { |
804 | found_cache_dep = TRUE; | 885 | if(!findDependencies(file_list_file).isEmpty()) |
805 | if(cache_found_files[(*val_it)] == (void *)2) | 886 | found_cache_dep = TRUE; |
806 | found_cache_moc = TRUE; | 887 | if(cache_found_files[(*file_it)] == (void *)2) |
807 | if(!found_cache_moc || !found_cache_dep) | 888 | found_cache_moc = TRUE; |
808 | write_cache = TRUE; | 889 | if(!found_cache_moc || !found_cache_dep) |
809 | } | 890 | write_cache = TRUE; |
810 | if(!found_cache_dep && sources[x] != "OBJECTS") { | 891 | } |
811 | debug_msg(5, "Looking for dependancies for %s", (*val_it).latin1()); | 892 | /* Do moc before dependency checking since some includes can come from |
812 | generateDependencies(deplist, (*val_it), doDepends()); | 893 | moc_*.cpp files */ |
813 | } | 894 | if(found_cache_moc) { |
814 | if(found_cache_moc) { | 895 | QString moc = findMocDestination(file_list_file); |
815 | QString moc = findMocDestination(val_file); | 896 | if(!moc.isEmpty()) { |
816 | if(!moc.isEmpty()) { | 897 | for(QStringList::Iterator cppit = Option::cpp_ext.begin(); |
817 | for(QStringList::Iterator cppit = Option::cpp_ext.begin(); | 898 | cppit != Option::cpp_ext.end(); ++cppit) { |
818 | cppit != Option::cpp_ext.end(); ++cppit) { | 899 | if(file_list_file.endsWith((*cppit))) { |
819 | if(val_file.endsWith((*cppit))) { | 900 | QStringList &deps = findDependencies(file_list_file); |
820 | QStringList &deps = findDependencies(val_file); | 901 | if(!deps.contains(moc)) |
821 | if(!deps.contains(moc)) | 902 | deps.append(moc); |
822 | deps.append(moc); | 903 | break; |
823 | break; | 904 | } |
824 | } | 905 | } |
825 | } | 906 | } |
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()); | ||
826 | } | 915 | } |
827 | } else if(mocAware() && (sources[x] == "SOURCES" || sources[x] == "HEADERS") && | ||
828 | (Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT || | ||
829 | Option::mkfile::do_mocs)) { | ||
830 | generateMocList((*val_it)); | ||
831 | } | 916 | } |
832 | } | 917 | } |
833 | } | 918 | } |
834 | } | 919 | } |
835 | if(project->isActiveConfig("qmake_cache") && (write_cache || !read_cache)) { | 920 | if(project->isActiveConfig("qmake_cache") && (write_cache || !read_cache)) { |
836 | QFile cachef(cache_file); | 921 | QFile cachef(cache_file); |
837 | if(cachef.open(IO_WriteOnly | IO_Translate)) { | 922 | if(cachef.open(IO_WriteOnly | IO_Translate)) { |
838 | debug_msg(2, "Writing internal cache information: %s", cache_file.latin1()); | 923 | debug_msg(2, "Writing internal cache information: %s", cache_file.latin1()); |
@@ -848,21 +933,22 @@ MakefileGenerator::init() | |||
848 | for(QMap<QString, QStringList>::Iterator it = depends.begin(); | 933 | for(QMap<QString, QStringList>::Iterator it = depends.begin(); |
849 | it != depends.end(); ++it) | 934 | it != depends.end(); ++it) |
850 | cachet << depKeyMap[it.key()] << " = " << it.data().join(" ") << endl; | 935 | cachet << depKeyMap[it.key()] << " = " << it.data().join(" ") << endl; |
851 | cachet << "[mocable]" << endl; | 936 | cachet << "[mocable]" << endl; |
852 | QString mc, moc_sources[] = { QString("HEADERS"), QString("SOURCES"), QString::null }; | 937 | QString mc, moc_sources[] = { QString("HEADERS"), QString("SOURCES"), QString::null }; |
853 | for(int x = 0; moc_sources[x] != QString::null; x++) { | 938 | for(int x = 0; moc_sources[x] != QString::null; x++) { |
854 | QStringList &l = v[moc_sources[x]]; | 939 | QStringList &l = v[moc_sources[x]]; |
855 | for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { | 940 | for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { |
856 | if(!(*val_it).isEmpty()) { | 941 | QString f = fileFixify((*val_it)); |
857 | mc = mocablesToMOC[(*val_it)]; | 942 | if(!f.isEmpty()) { |
943 | mc = mocablesToMOC[f]; | ||
858 | if(mc.isEmpty()) | 944 | if(mc.isEmpty()) |
859 | mc = "*qmake_ignore*"; | 945 | mc = "*qmake_ignore*"; |
860 | cachet << (*val_it) << " = " << mc << endl; | 946 | cachet << f << " = " << mc << endl; |
861 | } | 947 | } |
862 | } | 948 | } |
863 | } | 949 | } |
864 | cachef.close(); | 950 | cachef.close(); |
865 | } | 951 | } |
866 | } | 952 | } |
867 | } | 953 | } |
868 | } | 954 | } |
@@ -941,54 +1027,70 @@ MakefileGenerator::init() | |||
941 | } | 1027 | } |
942 | yaccdeps.clear(); | 1028 | yaccdeps.clear(); |
943 | } | 1029 | } |
944 | v["OBJECTS"] += (v["YACCOBJECTS"] = createObjectList("YACCIMPLS")); | 1030 | v["OBJECTS"] += (v["YACCOBJECTS"] = createObjectList("YACCIMPLS")); |
945 | } | 1031 | } |
946 | 1032 | ||
947 | //UI files | 1033 | //UI files |
948 | { | 1034 | { |
1035 | QStringList &includepath = project->variables()["INCLUDEPATH"]; | ||
949 | if(!project->isEmpty("UI_DIR")) | 1036 | if(!project->isEmpty("UI_DIR")) |
950 | project->variables()["INCLUDEPATH"].append(project->first("UI_DIR")); | 1037 | includepath.append(project->first("UI_DIR")); |
951 | else if(!project->isEmpty("UI_HEADERS_DIR")) | 1038 | else if(!project->isEmpty("UI_HEADERS_DIR")) |
952 | project->variables()["INCLUDEPATH"].append(project->first("UI_HEADERS_DIR")); | 1039 | includepath.append(project->first("UI_HEADERS_DIR")); |
953 | QStringList &decls = v["UICDECLS"], &impls = v["UICIMPLS"]; | 1040 | QStringList &decls = v["UICDECLS"], &impls = v["UICIMPLS"]; |
954 | QStringList &l = v["FORMS"]; | 1041 | QStringList &l = v["FORMS"]; |
955 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { | 1042 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { |
956 | QString impl, decl; | 1043 | QString impl, decl; |
957 | QFileInfo fi(Option::fixPathToLocalOS((*it))); | 1044 | QFileInfo fi(Option::fixPathToLocalOS((*it))); |
958 | if ( !project->isEmpty("UI_DIR") ) { | 1045 | if ( !project->isEmpty("UI_DIR") ) { |
959 | impl = decl = project->first("UI_DIR"); | 1046 | impl = decl = project->first("UI_DIR"); |
960 | QString d = fi.dirPath(); | 1047 | QString d = fi.dirPath(); |
961 | if( d == ".") | 1048 | if( d == ".") |
962 | d = QDir::currentDirPath(); | 1049 | d = QDir::currentDirPath(); |
963 | d = fileFixify(d); | 1050 | d = fileFixify(d, QDir::currentDirPath(), Option::output_dir); |
964 | if( !project->variables()["INCLUDEPATH"].contains(d)) | 1051 | if(!includepath.contains(d)) |
965 | project->variables()["INCLUDEPATH"].append(d); | 1052 | includepath.append(d); |
966 | } else { | 1053 | } else { |
967 | if(decl.isEmpty() && !project->isEmpty("UI_HEADERS_DIR")) | 1054 | if(decl.isEmpty() && !project->isEmpty("UI_HEADERS_DIR")) |
968 | decl = project->first("UI_HEADERS_DIR"); | 1055 | decl = project->first("UI_HEADERS_DIR"); |
969 | if ( !decl.isEmpty() || (project->isEmpty("UI_HEADERS_DIR") && !project->isEmpty("UI_SOURCES_DIR")) ) { | 1056 | if(!decl.isEmpty() || (project->isEmpty("UI_HEADERS_DIR") && |
1057 | !project->isEmpty("UI_SOURCES_DIR")) ) { | ||
970 | QString d = fi.dirPath(); | 1058 | QString d = fi.dirPath(); |
971 | if( d == ".") | 1059 | if( d == ".") |
972 | d = QDir::currentDirPath(); | 1060 | d = QDir::currentDirPath(); |
973 | d = fileFixify(d); | 1061 | d = fileFixify(d, QDir::currentDirPath(), Option::output_dir); |
974 | if( !project->variables()["INCLUDEPATH"].contains(d)) | 1062 | if(includepath.contains(d)) |
975 | project->variables()["INCLUDEPATH"].append(d); | 1063 | includepath.append(d); |
976 | } | 1064 | } |
977 | if(impl.isEmpty() && !project->isEmpty("UI_SOURCES_DIR")) | 1065 | if(impl.isEmpty() && !project->isEmpty("UI_SOURCES_DIR")) |
978 | impl = project->first("UI_SOURCES_DIR"); | 1066 | impl = project->first("UI_SOURCES_DIR"); |
979 | if(fi.dirPath() != ".") { | 1067 | if(fi.dirPath() != ".") { |
980 | if(impl.isEmpty()) | 1068 | if(impl.isEmpty()) |
981 | impl = fi.dirPath() + Option::dir_sep; | 1069 | impl = fi.dirPath() + Option::dir_sep; |
982 | if(decl.isEmpty()) | 1070 | if(decl.isEmpty()) |
983 | decl = fi.dirPath() + Option::dir_sep; | 1071 | decl = fi.dirPath() + Option::dir_sep; |
984 | } | 1072 | } |
985 | } | 1073 | } |
986 | impl += fi.baseName(TRUE) + Option::cpp_ext.first(), | 1074 | impl = fileFixify(impl, QDir::currentDirPath(), Option::output_dir); |
1075 | if(!impl.isEmpty()) | ||
1076 | impl += Option::dir_sep; | ||
1077 | impl += fi.baseName(TRUE) + Option::cpp_ext.first(); | ||
1078 | if(Option::output_dir != QDir::currentDirPath() && | ||
1079 | project->isEmpty("UI_DIR") && project->isEmpty("UI_HEADERS_DIR")) { | ||
1080 | QString decl_fixed = fileFixify(decl, QDir::currentDirPath(), Option::output_dir); | ||
1081 | if(!includepath.contains(decl_fixed)) | ||
1082 | includepath.append(decl_fixed); | ||
1083 | if(!includepath.contains(decl)) | ||
1084 | project->variables()["INCLUDEPATH"].append(decl); | ||
1085 | } | ||
1086 | decl = fileFixify(decl, QDir::currentDirPath(), Option::output_dir); | ||
1087 | if(!decl.isEmpty()) | ||
1088 | decl += Option::dir_sep; | ||
987 | decl += fi.baseName(TRUE) + Option::h_ext.first(); | 1089 | decl += fi.baseName(TRUE) + Option::h_ext.first(); |
988 | logicWarn(impl, "SOURCES"); | 1090 | logicWarn(impl, "SOURCES"); |
989 | logicWarn(decl, "HEADERS"); | 1091 | logicWarn(decl, "HEADERS"); |
990 | decls.append(decl); | 1092 | decls.append(decl); |
991 | impls.append(impl); | 1093 | impls.append(impl); |
992 | findDependencies(impl).append(decl); | 1094 | findDependencies(impl).append(decl); |
993 | 1095 | ||
994 | QString mocable = Option::moc_mod + fi.baseName(TRUE) + Option::cpp_ext.first(); | 1096 | QString mocable = Option::moc_mod + fi.baseName(TRUE) + Option::cpp_ext.first(); |
@@ -1025,19 +1127,19 @@ MakefileGenerator::init() | |||
1025 | warn_msg(WarnLogic, "Failure to open: %s", (*it).latin1()); | 1127 | warn_msg(WarnLogic, "Failure to open: %s", (*it).latin1()); |
1026 | continue; | 1128 | continue; |
1027 | } | 1129 | } |
1028 | findDependencies(imgfile).append(fileFixify((*it))); | 1130 | findDependencies(imgfile).append(fileFixify((*it))); |
1029 | } | 1131 | } |
1030 | } | 1132 | } |
1031 | v["OBJECTS"] += (v["IMAGEOBJECTS"] = createObjectList("QMAKE_IMAGE_COLLECTION")); | 1133 | v["OBJECTS"] += (v["IMAGEOBJECTS"] = createObjectList("QMAKE_IMAGE_COLLECTION")); |
1032 | } | 1134 | } |
1033 | 1135 | if(Option::output_dir != QDir::currentDirPath()) | |
1034 | if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) | 1136 | project->variables()["INCLUDEPATH"].append(fileFixify(Option::output_dir, Option::output_dir, |
1035 | project->variables()["INCLUDEPATH"].append(Option::output_dir); | 1137 | Option::output_dir)); |
1036 | 1138 | ||
1037 | //moc files | 1139 | //moc files |
1038 | if ( mocAware() ) { | 1140 | if ( mocAware() ) { |
1039 | if(!project->isEmpty("MOC_DIR")) | 1141 | if(!project->isEmpty("MOC_DIR")) |
1040 | project->variables()["INCLUDEPATH"].append(project->first("MOC_DIR")); | 1142 | project->variables()["INCLUDEPATH"].append(project->first("MOC_DIR")); |
1041 | v["OBJMOC"] = createObjectList("_HDRMOC") + createObjectList("_UIMOC"); | 1143 | v["OBJMOC"] = createObjectList("_HDRMOC") + createObjectList("_UIMOC"); |
1042 | 1144 | ||
1043 | QStringList &l = v["SRCMOC"]; | 1145 | QStringList &l = v["SRCMOC"]; |
@@ -1061,17 +1163,17 @@ MakefileGenerator::processPrlFile(QString &file) | |||
1061 | } else { | 1163 | } else { |
1062 | QString tmp = file; | 1164 | QString tmp = file; |
1063 | int ext = tmp.findRev('.'); | 1165 | int ext = tmp.findRev('.'); |
1064 | if(ext != -1) | 1166 | if(ext != -1) |
1065 | tmp = tmp.left(ext); | 1167 | tmp = tmp.left(ext); |
1066 | prl_file = tmp + Option::prl_ext; | 1168 | prl_file = tmp + Option::prl_ext; |
1067 | } | 1169 | } |
1068 | prl_file = fileFixify(prl_file); | 1170 | prl_file = fileFixify(prl_file); |
1069 | if(!QFile::exists(fileFixify(prl_file, QDir::currentDirPath(), Option::output_dir)) && | 1171 | if(!QFile::exists(fileFixify(prl_file, QDir::currentDirPath(), Option::output_dir)) && |
1070 | project->isActiveConfig("qt")) { | 1172 | project->isActiveConfig("qt")) { |
1071 | QString stem = prl_file, dir, extn; | 1173 | QString stem = prl_file, dir, extn; |
1072 | int slsh = stem.findRev('/'), hadlib = 0; | 1174 | int slsh = stem.findRev('/'), hadlib = 0; |
1073 | if(slsh != -1) { | 1175 | if(slsh != -1) { |
1074 | dir = stem.left(slsh + 1); | 1176 | dir = stem.left(slsh + 1); |
1075 | stem = stem.right(stem.length() - slsh - 1); | 1177 | stem = stem.right(stem.length() - slsh - 1); |
1076 | } | 1178 | } |
1077 | if(stem.startsWith("lib")) { | 1179 | if(stem.startsWith("lib")) { |
@@ -1099,17 +1201,17 @@ MakefileGenerator::processPrlFile(QString &file) | |||
1099 | if(project->variables()["QMAKE_PRL_INTERNAL_FILES"].findIndex(prl_file) != -1) { | 1201 | if(project->variables()["QMAKE_PRL_INTERNAL_FILES"].findIndex(prl_file) != -1) { |
1100 | ret = TRUE; | 1202 | ret = TRUE; |
1101 | } else if(!real_prl_file.isEmpty() && | 1203 | } else if(!real_prl_file.isEmpty() && |
1102 | QFile::exists(fileFixify(real_prl_file, QDir::currentDirPath(), Option::output_dir))) { | 1204 | QFile::exists(fileFixify(real_prl_file, QDir::currentDirPath(), Option::output_dir))) { |
1103 | project->variables()["QMAKE_PRL_INTERNAL_FILES"].append(prl_file); | 1205 | project->variables()["QMAKE_PRL_INTERNAL_FILES"].append(prl_file); |
1104 | QMakeProject proj; | 1206 | QMakeProject proj; |
1105 | debug_msg(1, "Processing PRL file: %s", real_prl_file.latin1()); | 1207 | debug_msg(1, "Processing PRL file: %s", real_prl_file.latin1()); |
1106 | if(!proj.read(fileFixify(real_prl_file, QDir::currentDirPath(), Option::output_dir), | 1208 | if(!proj.read(fileFixify(real_prl_file, QDir::currentDirPath(), Option::output_dir), |
1107 | QDir::currentDirPath())) { | 1209 | QDir::currentDirPath(), TRUE)) { |
1108 | fprintf(stderr, "Error processing prl file: %s\n", real_prl_file.latin1()); | 1210 | fprintf(stderr, "Error processing prl file: %s\n", real_prl_file.latin1()); |
1109 | } else { | 1211 | } else { |
1110 | ret = TRUE; | 1212 | ret = TRUE; |
1111 | QMap<QString, QStringList> &vars = proj.variables(); | 1213 | QMap<QString, QStringList> &vars = proj.variables(); |
1112 | for( QMap<QString, QStringList>::Iterator it = vars.begin(); it != vars.end(); ++it) | 1214 | for( QMap<QString, QStringList>::Iterator it = vars.begin(); it != vars.end(); ++it) |
1113 | processPrlVariable(it.key(), it.data()); | 1215 | processPrlVariable(it.key(), it.data()); |
1114 | if(try_replace_file && !proj.isEmpty("QMAKE_PRL_TARGET")) { | 1216 | if(try_replace_file && !proj.isEmpty("QMAKE_PRL_TARGET")) { |
1115 | QString dir; | 1217 | QString dir; |
@@ -1191,16 +1293,18 @@ MakefileGenerator::writePrlFile(QTextStream &t) | |||
1191 | 1293 | ||
1192 | if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) | 1294 | if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) |
1193 | t << "QMAKE_PRL_SOURCE_DIR = " << project->first("QMAKE_ABSOLUTE_SOURCE_PATH") << endl; | 1295 | t << "QMAKE_PRL_SOURCE_DIR = " << project->first("QMAKE_ABSOLUTE_SOURCE_PATH") << endl; |
1194 | t << "QMAKE_PRL_TARGET = " << target << endl; | 1296 | t << "QMAKE_PRL_TARGET = " << target << endl; |
1195 | if(!project->isEmpty("PRL_EXPORT_DEFINES")) | 1297 | if(!project->isEmpty("PRL_EXPORT_DEFINES")) |
1196 | t << "QMAKE_PRL_DEFINES = " << project->variables()["PRL_EXPORT_DEFINES"].join(" ") << endl; | 1298 | t << "QMAKE_PRL_DEFINES = " << project->variables()["PRL_EXPORT_DEFINES"].join(" ") << endl; |
1197 | if(!project->isEmpty("CONFIG")) | 1299 | if(!project->isEmpty("CONFIG")) |
1198 | t << "QMAKE_PRL_CONFIG = " << project->variables()["CONFIG"].join(" ") << endl; | 1300 | t << "QMAKE_PRL_CONFIG = " << project->variables()["CONFIG"].join(" ") << endl; |
1301 | if(!project->isEmpty("VERSION")) | ||
1302 | t << "QMAKE_PRL_VERSION = " << project->first("VERSION") << endl; | ||
1199 | if(project->isActiveConfig("staticlib") || project->isActiveConfig("explicitlib")) { | 1303 | if(project->isActiveConfig("staticlib") || project->isActiveConfig("explicitlib")) { |
1200 | QStringList libs; | 1304 | QStringList libs; |
1201 | if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS")) | 1305 | if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS")) |
1202 | libs = project->variables()["QMAKE_INTERNAL_PRL_LIBS"]; | 1306 | libs = project->variables()["QMAKE_INTERNAL_PRL_LIBS"]; |
1203 | else | 1307 | else |
1204 | libs << "QMAKE_LIBS"; //obvious one | 1308 | libs << "QMAKE_LIBS"; //obvious one |
1205 | t << "QMAKE_PRL_LIBS = "; | 1309 | t << "QMAKE_PRL_LIBS = "; |
1206 | for(QStringList::Iterator it = libs.begin(); it != libs.end(); ++it) | 1310 | for(QStringList::Iterator it = libs.begin(); it != libs.end(); ++it) |
@@ -1223,29 +1327,28 @@ MakefileGenerator::write() | |||
1223 | if(slsh != -1) | 1327 | if(slsh != -1) |
1224 | prl = prl.right(prl.length() - slsh); | 1328 | prl = prl.right(prl.length() - slsh); |
1225 | int dot = prl.find('.'); | 1329 | int dot = prl.find('.'); |
1226 | if(dot != -1) | 1330 | if(dot != -1) |
1227 | prl = prl.left(dot); | 1331 | prl = prl.left(dot); |
1228 | prl += Option::prl_ext; | 1332 | prl += Option::prl_ext; |
1229 | if(!project->isEmpty("DESTDIR")) | 1333 | if(!project->isEmpty("DESTDIR")) |
1230 | prl.prepend(var("DESTDIR")); | 1334 | prl.prepend(var("DESTDIR")); |
1231 | QString local_prl = fileFixify(prl, QDir::currentDirPath(), Option::output_dir); | 1335 | QString local_prl = Option::fixPathToLocalOS(fileFixify(prl, QDir::currentDirPath(), Option::output_dir)); |
1232 | fixEnvVariables(local_prl); | ||
1233 | QFile ft(local_prl); | 1336 | QFile ft(local_prl); |
1234 | if(ft.open(IO_WriteOnly)) { | 1337 | if(ft.open(IO_WriteOnly)) { |
1235 | project->variables()["ALL_DEPS"].append(prl); | 1338 | project->variables()["ALL_DEPS"].append(prl); |
1236 | project->variables()["QMAKE_INTERNAL_PRL_FILE"].append(prl); | 1339 | project->variables()["QMAKE_INTERNAL_PRL_FILE"].append(prl); |
1237 | QTextStream t(&ft); | 1340 | QTextStream t(&ft); |
1238 | writePrlFile(t); | 1341 | writePrlFile(t); |
1239 | ft.close(); | 1342 | ft.close(); |
1240 | } | 1343 | } |
1241 | } | 1344 | } |
1242 | if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE && | 1345 | if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE && |
1243 | project->isActiveConfig("link_prl")) //load up prl's | 1346 | project->isActiveConfig("link_prl")) //load up prl's' |
1244 | processPrlFiles(); | 1347 | processPrlFiles(); |
1245 | 1348 | ||
1246 | if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || | 1349 | if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || |
1247 | Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) { | 1350 | Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) { |
1248 | QTextStream t(&Option::output); | 1351 | QTextStream t(&Option::output); |
1249 | writeMakefile(t); | 1352 | writeMakefile(t); |
1250 | } | 1353 | } |
1251 | return TRUE; | 1354 | return TRUE; |
@@ -1297,17 +1400,17 @@ MakefileGenerator::writeObj(QTextStream &t, const QString &obj, const QString &s | |||
1297 | if(!project->isEmpty("OBJECTS_DIR")) { | 1400 | if(!project->isEmpty("OBJECTS_DIR")) { |
1298 | use_implicit_rule = FALSE; | 1401 | use_implicit_rule = FALSE; |
1299 | } else { | 1402 | } else { |
1300 | int dot = (*sit).findRev('.'); | 1403 | int dot = (*sit).findRev('.'); |
1301 | if(dot == -1 || ((*sit).left(dot) + Option::obj_ext != (*oit))) | 1404 | if(dot == -1 || ((*sit).left(dot) + Option::obj_ext != (*oit))) |
1302 | use_implicit_rule = FALSE; | 1405 | use_implicit_rule = FALSE; |
1303 | } | 1406 | } |
1304 | } | 1407 | } |
1305 | if (!use_implicit_rule) { | 1408 | if (!use_implicit_rule && !project->isEmpty(comp)) { |
1306 | QString p = var(comp); | 1409 | QString p = var(comp); |
1307 | p.replace(stringSrc, (*sit)); | 1410 | p.replace(stringSrc, (*sit)); |
1308 | p.replace(stringObj, (*oit)); | 1411 | p.replace(stringObj, (*oit)); |
1309 | t << "\n\t" << p; | 1412 | t << "\n\t" << p; |
1310 | } | 1413 | } |
1311 | t << endl << endl; | 1414 | t << endl << endl; |
1312 | } | 1415 | } |
1313 | } | 1416 | } |
@@ -1315,30 +1418,46 @@ MakefileGenerator::writeObj(QTextStream &t, const QString &obj, const QString &s | |||
1315 | 1418 | ||
1316 | void | 1419 | void |
1317 | MakefileGenerator::writeUicSrc(QTextStream &t, const QString &ui) | 1420 | MakefileGenerator::writeUicSrc(QTextStream &t, const QString &ui) |
1318 | { | 1421 | { |
1319 | QStringList &uil = project->variables()[ui]; | 1422 | QStringList &uil = project->variables()[ui]; |
1320 | for(QStringList::Iterator it = uil.begin(); it != uil.end(); it++) { | 1423 | for(QStringList::Iterator it = uil.begin(); it != uil.end(); it++) { |
1321 | QString deps = findDependencies((*it)).join(" \\\n\t\t"), decl, impl; | 1424 | QString deps = findDependencies((*it)).join(" \\\n\t\t"), decl, impl; |
1322 | { | 1425 | { |
1323 | QString tmp = (*it); | 1426 | QString tmp = (*it), impl_dir, decl_dir; |
1324 | decl = tmp.replace(QRegExp("\\" + Option::ui_ext + "$"), Option::h_ext.first()); | 1427 | decl = tmp.replace(QRegExp("\\" + Option::ui_ext + "$"), Option::h_ext.first()); |
1428 | decl = fileFixify(decl, QDir::currentDirPath(), Option::output_dir); | ||
1429 | int dlen = decl.findRev(Option::dir_sep) + 1; | ||
1325 | tmp = (*it); | 1430 | tmp = (*it); |
1326 | impl = tmp.replace(QRegExp("\\" + Option::ui_ext + "$"), Option::cpp_ext.first()); | 1431 | impl = tmp.replace(QRegExp("\\" + Option::ui_ext + "$"), Option::cpp_ext.first()); |
1327 | int dlen = (*it).findRev(Option::dir_sep) + 1; | 1432 | impl = fileFixify(impl, QDir::currentDirPath(), Option::output_dir); |
1433 | int ilen = decl.findRev(Option::dir_sep) + 1; | ||
1328 | if(!project->isEmpty("UI_DIR")) { | 1434 | if(!project->isEmpty("UI_DIR")) { |
1435 | impl_dir = project->first("UI_DIR"); | ||
1329 | decl = project->first("UI_DIR") + decl.right(decl.length() - dlen); | 1436 | decl = project->first("UI_DIR") + decl.right(decl.length() - dlen); |
1330 | impl = project->first("UI_DIR") + impl.right(impl.length() - dlen); | 1437 | impl = project->first("UI_DIR") + impl.right(impl.length() - ilen); |
1331 | } else { | 1438 | } else { |
1332 | if(!project->isEmpty("UI_HEADERS_DIR")) | 1439 | if(!project->isEmpty("UI_HEADERS_DIR")) { |
1440 | decl_dir = project->first("UI_HEADERS_DIR"); | ||
1333 | decl = project->first("UI_HEADERS_DIR") + decl.right(decl.length() - dlen); | 1441 | decl = project->first("UI_HEADERS_DIR") + decl.right(decl.length() - dlen); |
1334 | if(!project->isEmpty("UI_SOURCES_DIR")) | 1442 | } |
1335 | impl = project->first("UI_SOURCES_DIR") + impl.right(impl.length() - dlen); | 1443 | if(!project->isEmpty("UI_SOURCES_DIR")) { |
1336 | } | 1444 | impl_dir = project->first("UI_SOURCES_DIR"); |
1445 | impl = project->first("UI_SOURCES_DIR") + impl.right(impl.length() - ilen); | ||
1446 | } | ||
1447 | } | ||
1448 | if(decl_dir.isEmpty()) | ||
1449 | decl_dir = decl.left(dlen); | ||
1450 | if(impl_dir.isEmpty()) | ||
1451 | impl_dir = impl.left(ilen); | ||
1452 | if(!impl_dir.isEmpty()) | ||
1453 | createDir(Option::output_dir + Option::dir_sep + impl_dir); | ||
1454 | if(!decl_dir.isEmpty() && decl_dir != impl_dir) | ||
1455 | createDir(Option::output_dir + Option::dir_sep + decl_dir); | ||
1337 | } | 1456 | } |
1338 | t << decl << ": " << (*it) << " " << deps << "\n\t" | 1457 | t << decl << ": " << (*it) << " " << deps << "\n\t" |
1339 | << "$(UIC) " << (*it) << " -o " << decl << endl << endl; | 1458 | << "$(UIC) " << (*it) << " -o " << decl << endl << endl; |
1340 | 1459 | ||
1341 | QString mildDecl = decl; | 1460 | QString mildDecl = decl; |
1342 | int k = mildDecl.findRev( Option::dir_sep ); | 1461 | int k = mildDecl.findRev( Option::dir_sep ); |
1343 | if ( k != -1 ) | 1462 | if ( k != -1 ) |
1344 | mildDecl = mildDecl.mid( k + 1 ); | 1463 | mildDecl = mildDecl.mid( k + 1 ); |
@@ -1365,17 +1484,17 @@ MakefileGenerator::writeMocObj(QTextStream &t, const QString &obj, const QString | |||
1365 | if(!project->isEmpty("OBJECTS_DIR") || !project->isEmpty("MOC_DIR")) { | 1484 | if(!project->isEmpty("OBJECTS_DIR") || !project->isEmpty("MOC_DIR")) { |
1366 | use_implicit_rule = FALSE; | 1485 | use_implicit_rule = FALSE; |
1367 | } else { | 1486 | } else { |
1368 | int dot = (*sit).findRev('.'); | 1487 | int dot = (*sit).findRev('.'); |
1369 | if(dot == -1 || ((*sit).left(dot) + Option::obj_ext != (*oit))) | 1488 | if(dot == -1 || ((*sit).left(dot) + Option::obj_ext != (*oit))) |
1370 | use_implicit_rule = FALSE; | 1489 | use_implicit_rule = FALSE; |
1371 | } | 1490 | } |
1372 | } | 1491 | } |
1373 | if (!use_implicit_rule) { | 1492 | if (!use_implicit_rule && !project->isEmpty("QMAKE_RUN_CXX")) { |
1374 | QString p = var("QMAKE_RUN_CXX"); | 1493 | QString p = var("QMAKE_RUN_CXX"); |
1375 | p.replace(stringSrc, (*sit)); | 1494 | p.replace(stringSrc, (*sit)); |
1376 | p.replace(stringObj, (*oit)); | 1495 | p.replace(stringObj, (*oit)); |
1377 | t << "\n\t" << p; | 1496 | t << "\n\t" << p; |
1378 | } | 1497 | } |
1379 | t << endl << endl; | 1498 | t << endl << endl; |
1380 | } | 1499 | } |
1381 | } | 1500 | } |
@@ -1408,27 +1527,31 @@ MakefileGenerator::writeYaccSrc(QTextStream &t, const QString &src) | |||
1408 | QString default_out_h = "y.tab.h", default_out_c = "y.tab.c"; | 1527 | QString default_out_h = "y.tab.h", default_out_c = "y.tab.c"; |
1409 | if(!project->isEmpty("QMAKE_YACC_HEADER")) | 1528 | if(!project->isEmpty("QMAKE_YACC_HEADER")) |
1410 | default_out_h = project->first("QMAKE_YACC_HEADER"); | 1529 | default_out_h = project->first("QMAKE_YACC_HEADER"); |
1411 | if(!project->isEmpty("QMAKE_YACC_SOURCE")) | 1530 | if(!project->isEmpty("QMAKE_YACC_SOURCE")) |
1412 | default_out_c = project->first("QMAKE_YACC_SOURCE"); | 1531 | default_out_c = project->first("QMAKE_YACC_SOURCE"); |
1413 | QString stringBase("$base"); | 1532 | QString stringBase("$base"); |
1414 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { | 1533 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { |
1415 | QFileInfo fi((*it)); | 1534 | QFileInfo fi((*it)); |
1416 | QString dir = fileFixify(Option::output_dir); | 1535 | QString dir; |
1536 | if(fi.dirPath() != ".") | ||
1537 | dir = fi.dirPath() + Option::dir_sep; | ||
1538 | dir = fileFixify(dir, QDir::currentDirPath(), Option::output_dir); | ||
1417 | if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep) | 1539 | if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep) |
1418 | dir += Option::dir_sep; | 1540 | dir += Option::dir_sep; |
1541 | |||
1419 | QString impl = dir + fi.baseName(TRUE) + Option::yacc_mod + Option::cpp_ext.first(); | 1542 | QString impl = dir + fi.baseName(TRUE) + Option::yacc_mod + Option::cpp_ext.first(); |
1420 | QString decl = dir + fi.baseName(TRUE) + Option::yacc_mod + Option::h_ext.first(); | 1543 | QString decl = dir + fi.baseName(TRUE) + Option::yacc_mod + Option::h_ext.first(); |
1421 | 1544 | ||
1422 | QString yaccflags = "$(YACCFLAGS)", mangle = "y"; | 1545 | QString yaccflags = "$(YACCFLAGS)", mangle = "y"; |
1423 | if(!project->isActiveConfig("yacc_no_name_mangle")) { | 1546 | if(!project->isActiveConfig("yacc_no_name_mangle")) { |
1424 | mangle = fi.baseName(TRUE); | 1547 | mangle = fi.baseName(TRUE); |
1425 | yaccflags += " -p " + mangle; | 1548 | yaccflags += " -p " + mangle; |
1426 | } | 1549 | } |
1427 | QString out_h = default_out_h, out_c = default_out_c; | 1550 | QString out_h = default_out_h, out_c = default_out_c; |
1428 | if(!mangle.isEmpty()) { | 1551 | if(!mangle.isEmpty()) { |
1429 | out_h.replace(stringBase, mangle); | 1552 | out_h.replace(stringBase, mangle); |
1430 | out_c.replace(stringBase, mangle); | 1553 | out_c.replace(stringBase, mangle); |
1431 | } | 1554 | } |
1432 | 1555 | ||
1433 | t << impl << ": " << (*it) << "\n\t" | 1556 | t << impl << ": " << (*it) << "\n\t" |
1434 | << "$(YACC) " << yaccflags << " " << (*it) << "\n\t" | 1557 | << "$(YACC) " << yaccflags << " " << (*it) << "\n\t" |
@@ -1447,28 +1570,31 @@ MakefileGenerator::writeLexSrc(QTextStream &t, const QString &src) | |||
1447 | warn_msg(WarnLogic, "yacc_no_name_mangle specified, but multiple parsers expected.\n" | 1570 | warn_msg(WarnLogic, "yacc_no_name_mangle specified, but multiple parsers expected.\n" |
1448 | "This can lead to link problems.\n"); | 1571 | "This can lead to link problems.\n"); |
1449 | QString default_out_c = "lex.$base.c"; | 1572 | QString default_out_c = "lex.$base.c"; |
1450 | if(!project->isEmpty("QMAKE_LEX_SOURCE")) | 1573 | if(!project->isEmpty("QMAKE_LEX_SOURCE")) |
1451 | default_out_c = project->first("QMAKE_LEX_SOURCE"); | 1574 | default_out_c = project->first("QMAKE_LEX_SOURCE"); |
1452 | QString stringBase("$base"); | 1575 | QString stringBase("$base"); |
1453 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { | 1576 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { |
1454 | QFileInfo fi((*it)); | 1577 | QFileInfo fi((*it)); |
1455 | QString dir = fileFixify(Option::output_dir); | 1578 | QString dir; |
1579 | if(fi.dirPath() != ".") | ||
1580 | dir = fi.dirPath() + Option::dir_sep; | ||
1581 | dir = fileFixify(dir, QDir::currentDirPath(), Option::output_dir); | ||
1456 | if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep) | 1582 | if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep) |
1457 | dir += Option::dir_sep; | 1583 | dir += Option::dir_sep; |
1458 | QString impl = dir + fi.baseName(TRUE) + Option::lex_mod + Option::cpp_ext.first(); | 1584 | QString impl = dir + fi.baseName(TRUE) + Option::lex_mod + Option::cpp_ext.first(); |
1459 | 1585 | ||
1460 | QString lexflags = "$(LEXFLAGS)", stub="yy"; | 1586 | QString lexflags = "$(LEXFLAGS)", stub="yy"; |
1461 | if(!project->isActiveConfig("yacc_no_name_mangle")) { | 1587 | if(!project->isActiveConfig("yacc_no_name_mangle")) { |
1462 | stub = fi.baseName(TRUE); | 1588 | stub = fi.baseName(TRUE); |
1463 | lexflags += " -P" + stub; | 1589 | lexflags += " -P" + stub; |
1464 | } | 1590 | } |
1465 | QString out_c = default_out_c; | 1591 | QString out_c = default_out_c; |
1466 | if(!stub.isEmpty()) | 1592 | if(!stub.isEmpty()) |
1467 | out_c.replace(stringBase, stub); | 1593 | out_c.replace(stringBase, stub); |
1468 | 1594 | ||
1469 | t << impl << ": " << (*it) << " " << findDependencies((*it)).join(" \\\n\t\t") << "\n\t" | 1595 | t << impl << ": " << (*it) << " " << findDependencies((*it)).join(" \\\n\t\t") << "\n\t" |
1470 | << ( "$(LEX) " + lexflags + " " ) << (*it) << "\n\t" | 1596 | << ( "$(LEX) " + lexflags + " " ) << (*it) << "\n\t" |
1471 | << "-$(DEL_FILE) " << impl << " " << "\n\t" | 1597 | << "-$(DEL_FILE) " << impl << " " << "\n\t" |
1472 | << "-$(MOVE) " << out_c << " " << impl << endl << endl; | 1598 | << "-$(MOVE) " << out_c << " " << impl << endl << endl; |
1473 | } | 1599 | } |
1474 | } | 1600 | } |
@@ -1489,17 +1615,17 @@ MakefileGenerator::writeImageObj(QTextStream &t, const QString &obj) | |||
1489 | if(!project->isEmpty("OBJECTS_DIR") || !project->isEmpty("UI_DIR") || !project->isEmpty("UI_SOURCES_DIR")) { | 1615 | if(!project->isEmpty("OBJECTS_DIR") || !project->isEmpty("UI_DIR") || !project->isEmpty("UI_SOURCES_DIR")) { |
1490 | use_implicit_rule = FALSE; | 1616 | use_implicit_rule = FALSE; |
1491 | } else { | 1617 | } else { |
1492 | int dot = src.findRev('.'); | 1618 | int dot = src.findRev('.'); |
1493 | if(dot == -1 || (src.left(dot) + Option::obj_ext != (*oit))) | 1619 | if(dot == -1 || (src.left(dot) + Option::obj_ext != (*oit))) |
1494 | use_implicit_rule = FALSE; | 1620 | use_implicit_rule = FALSE; |
1495 | } | 1621 | } |
1496 | } | 1622 | } |
1497 | if(!use_implicit_rule) { | 1623 | if(!use_implicit_rule && !project->isEmpty("QMAKE_RUN_CXX")) { |
1498 | QString p = var("QMAKE_RUN_CXX"); | 1624 | QString p = var("QMAKE_RUN_CXX"); |
1499 | p.replace( stringSrc, src); | 1625 | p.replace( stringSrc, src); |
1500 | p.replace( stringObj, (*oit)); | 1626 | p.replace( stringObj, (*oit)); |
1501 | t << "\n\t" << p; | 1627 | t << "\n\t" << p; |
1502 | } | 1628 | } |
1503 | t << endl << endl; | 1629 | t << endl << endl; |
1504 | } | 1630 | } |
1505 | } | 1631 | } |
@@ -1536,86 +1662,115 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs) | |||
1536 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { | 1662 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { |
1537 | QString pvar = (*it) + ".path"; | 1663 | QString pvar = (*it) + ".path"; |
1538 | if(project->variables()[pvar].isEmpty()) { | 1664 | if(project->variables()[pvar].isEmpty()) { |
1539 | warn_msg(WarnLogic, "%s is not defined: install target not created\n", pvar.latin1()); | 1665 | warn_msg(WarnLogic, "%s is not defined: install target not created\n", pvar.latin1()); |
1540 | continue; | 1666 | continue; |
1541 | } | 1667 | } |
1542 | 1668 | ||
1543 | bool do_default = TRUE; | 1669 | bool do_default = TRUE; |
1544 | QString target, dst="$(INSTALL_ROOT)" + Option::fixPathToTargetOS(project->variables()[pvar].first(), FALSE); | 1670 | const QString root = "$(INSTALL_ROOT)"; |
1671 | QString target, dst= fileFixify(project->variables()[pvar].first()); | ||
1672 | #ifndef Q_WS_WIN | ||
1545 | if(dst.right(1) != Option::dir_sep) | 1673 | if(dst.right(1) != Option::dir_sep) |
1546 | dst += Option::dir_sep; | 1674 | dst += Option::dir_sep; |
1547 | QStringList tmp, &uninst = project->variables()[(*it) + ".uninstall"]; | 1675 | #endif |
1548 | //other | 1676 | QStringList tmp, &uninst = project->variables()[(*it) + ".uninstall"]; |
1549 | tmp = project->variables()[(*it) + ".extra"]; | 1677 | //other |
1550 | if(!tmp.isEmpty()) { | 1678 | tmp = project->variables()[(*it) + ".extra"]; |
1679 | if(!tmp.isEmpty()) { | ||
1551 | do_default = FALSE; | 1680 | do_default = FALSE; |
1552 | if(!target.isEmpty()) | 1681 | if(!target.isEmpty()) |
1553 | target += "\n\t"; | 1682 | target += "\n\t"; |
1554 | target += tmp.join(" "); | 1683 | target += tmp.join(" "); |
1555 | } | 1684 | } |
1556 | //masks | 1685 | //masks |
1557 | tmp = project->variables()[(*it) + ".files"]; | 1686 | tmp = project->variables()[(*it) + ".files"]; |
1558 | if(!tmp.isEmpty()) { | 1687 | if(!tmp.isEmpty()) { |
1559 | if(!target.isEmpty()) | 1688 | if(!target.isEmpty()) |
1560 | target += "\n"; | 1689 | target += "\n"; |
1561 | do_default = FALSE; | 1690 | do_default = FALSE; |
1562 | for(QStringList::Iterator wild_it = tmp.begin(); wild_it != tmp.end(); ++wild_it) { | 1691 | for(QStringList::Iterator wild_it = tmp.begin(); wild_it != tmp.end(); ++wild_it) { |
1563 | QString wild = Option::fixPathToLocalOS((*wild_it), FALSE), wild_var = fileFixify(wild); | 1692 | QString wild = Option::fixPathToLocalOS((*wild_it), FALSE), wild_var = fileFixify(wild); |
1693 | QString dirstr = QDir::currentDirPath(), filestr = wild; | ||
1694 | int slsh = filestr.findRev(Option::dir_sep); | ||
1695 | if(slsh != -1) { | ||
1696 | dirstr = filestr.left(slsh+1); | ||
1697 | filestr = filestr.right(filestr.length() - slsh - 1); | ||
1698 | } | ||
1699 | if(dirstr.right(Option::dir_sep.length()) != Option::dir_sep) | ||
1700 | dirstr += Option::dir_sep; | ||
1564 | if(QFile::exists(wild)) { //real file | 1701 | if(QFile::exists(wild)) { //real file |
1702 | QString file = wild; | ||
1565 | QFileInfo fi(wild); | 1703 | QFileInfo fi(wild); |
1566 | target += QString("\t-") + (fi.isDir() ? "$(COPY_DIR)" : "$(COPY_FILE)") + | 1704 | if(!target.isEmpty()) |
1567 | " \"" + Option::fixPathToTargetOS(fileFixify(wild), FALSE) + "\" \"" + fileFixify(dst) + "\"\n"; | 1705 | target += "\t"; |
1706 | target += QString(fi.isDir() ? "-$(COPY_DIR)" : "-$(COPY_FILE)") + " \"" + | ||
1707 | Option::fixPathToTargetOS(fileFixify(wild), FALSE) + "\" \"" + root + dst + "\"\n"; | ||
1568 | if(!project->isActiveConfig("debug") && | 1708 | if(!project->isActiveConfig("debug") && |
1569 | !fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP")) | 1709 | !fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP")) |
1570 | target += QString("\t") + var("QMAKE_STRIP") + " \"" + fileFixify(dst + wild) + "\"\n"; | 1710 | target += QString("\t-") + var("QMAKE_STRIP") + " \"" + root + fileFixify(dst + filestr) + "\"\n"; |
1571 | uninst.append(QString("-$(DEL_FILE) -r") + " \"" + fileFixify(dst + wild) + "\""); | 1711 | if(!uninst.isEmpty()) |
1712 | uninst.append("\n\t"); | ||
1713 | uninst.append( | ||
1714 | #ifdef Q_WS_WIN | ||
1715 | QString("-$(DEL_FILE)") | ||
1716 | #else | ||
1717 | QString("-$(DEL_FILE) -r") | ||
1718 | #endif | ||
1719 | + " \"" + root + fileFixify(dst + filestr) + "\""); | ||
1572 | continue; | 1720 | continue; |
1573 | } | 1721 | } |
1574 | QString dirstr = QDir::currentDirPath(), f = wild; //wild | 1722 | QDir dir(dirstr, filestr); //wild |
1575 | int slsh = f.findRev(Option::dir_sep); | ||
1576 | if(slsh != -1) { | ||
1577 | dirstr = f.left(slsh+1); | ||
1578 | f = f.right(f.length() - slsh - 1); | ||
1579 | } | ||
1580 | if(dirstr.right(Option::dir_sep.length()) != Option::dir_sep) | ||
1581 | dirstr += Option::dir_sep; | ||
1582 | if(!uninst.isEmpty()) | ||
1583 | uninst.append("\n\t"); | ||
1584 | uninst.append(QString("-$(DEL_FILE) -r") + " " + fileFixify(dst + f) + ""); | ||
1585 | |||
1586 | QDir dir(dirstr, f); | ||
1587 | for(uint x = 0; x < dir.count(); x++) { | 1723 | for(uint x = 0; x < dir.count(); x++) { |
1588 | QString file = dir[x]; | 1724 | QString file = dir[x]; |
1589 | if(file == "." || file == "..") //blah | 1725 | if(file == "." || file == "..") //blah |
1590 | continue; | 1726 | continue; |
1727 | if(!uninst.isEmpty()) | ||
1728 | uninst.append("\n\t"); | ||
1729 | uninst.append( | ||
1730 | #ifdef Q_WS_WIN | ||
1731 | QString("-$(DEL_FILE)") | ||
1732 | #else | ||
1733 | QString("-$(DEL_FILE) -r") | ||
1734 | #endif | ||
1735 | + " \"" + root + fileFixify(dst + file) + "\""); | ||
1591 | QFileInfo fi(file); | 1736 | QFileInfo fi(file); |
1592 | target += QString("\t-") + (fi.isDir() ? "$(COPY_DIR)" : "$(COPY_FILE)") + | 1737 | if(!target.isEmpty()) |
1593 | " \"" + Option::fixPathToTargetOS(fileFixify(dirstr + file), FALSE) + | 1738 | target += "\t"; |
1594 | "\" \"" + fileFixify(dst) + "\"\n"; | 1739 | target += QString(fi.isDir() ? "-$(COPY_DIR)" : "-$(COPY_FILE)") + " \"" + |
1740 | Option::fixPathToTargetOS(fileFixify(dirstr + file), FALSE) + | ||
1741 | "\" \"" + root + fileFixify(dst) + "\"\n"; | ||
1595 | if(!project->isActiveConfig("debug") && | 1742 | if(!project->isActiveConfig("debug") && |
1596 | !fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP")) | 1743 | !fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP")) |
1597 | target += QString("\t") + var("QMAKE_STRIP") + " \"" + fileFixify(dst + file) + "\"\n"; | 1744 | target += QString("\t-") + var("QMAKE_STRIP") + " \"" + root + fileFixify(dst + file) + "\"\n"; |
1598 | } | 1745 | } |
1599 | } | 1746 | } |
1600 | } | 1747 | } |
1601 | //default? | 1748 | //default? |
1602 | if(do_default) | 1749 | if(do_default) |
1603 | target = defaultInstall((*it)); | 1750 | target = defaultInstall((*it)); |
1604 | 1751 | ||
1605 | if(!target.isEmpty()) { | 1752 | if(!target.isEmpty()) { |
1606 | t << "install_" << (*it) << ": " << "\n\t" | 1753 | t << "install_" << (*it) << ": " << "\n\t"; |
1607 | << "@test -d " << dst << " || mkdir -p " << dst << "\n\t" | 1754 | const QStringList &dirs = project->variables()[pvar]; |
1608 | << target << endl << endl; | 1755 | for(QStringList::ConstIterator pit = dirs.begin(); pit != dirs.end(); ++pit) { |
1756 | QString tmp_dst = fileFixify((*pit)); | ||
1757 | #ifndef Q_WS_WIN | ||
1758 | if(tmp_dst.right(1) != Option::dir_sep) | ||
1759 | tmp_dst += Option::dir_sep; | ||
1760 | #endif | ||
1761 | t << mkdir_p_asstring(root+tmp_dst) << "\n\t"; | ||
1762 | } | ||
1763 | t << target << endl << endl; | ||
1609 | all_installs += QString("install_") + (*it) + " "; | 1764 | all_installs += QString("install_") + (*it) + " "; |
1610 | if(!uninst.isEmpty()) { | 1765 | if(!uninst.isEmpty()) { |
1611 | t << "uninstall_" << (*it) << ": " << "\n\t" | 1766 | t << "uninstall_" << (*it) << ": " << "\n\t" |
1612 | << uninst.join(" ") << "\n\t" | 1767 | << uninst.join("") << "\n\t" |
1613 | << "-$(DEL_DIR) \"" << dst << "\"" << endl << endl; | 1768 | << "-$(DEL_DIR) \"" << ( root + dst ) << "\"" << endl << endl; |
1614 | all_uninstalls += "uninstall_" + (*it) + " "; | 1769 | all_uninstalls += "uninstall_" + (*it) + " "; |
1615 | } | 1770 | } |
1616 | t << endl; | 1771 | t << endl; |
1617 | } else { | 1772 | } else { |
1618 | debug_msg(1, "no definition for install %s: install target not created",(*it).latin1()); | 1773 | debug_msg(1, "no definition for install %s: install target not created",(*it).latin1()); |
1619 | } | 1774 | } |
1620 | } | 1775 | } |
1621 | t << "install: all " << all_installs << "\n\n"; | 1776 | t << "install: all " << all_installs << "\n\n"; |
@@ -1782,32 +1937,32 @@ QString MakefileGenerator::build_args() | |||
1782 | } | 1937 | } |
1783 | 1938 | ||
1784 | bool | 1939 | bool |
1785 | MakefileGenerator::writeHeader(QTextStream &t) | 1940 | MakefileGenerator::writeHeader(QTextStream &t) |
1786 | { | 1941 | { |
1787 | time_t foo = time(NULL); | 1942 | time_t foo = time(NULL); |
1788 | t << "#############################################################################" << endl; | 1943 | t << "#############################################################################" << endl; |
1789 | t << "# Makefile for building: " << var("TARGET") << endl; | 1944 | t << "# Makefile for building: " << var("TARGET") << endl; |
1790 | t << "# Generated by qmake (" << qmake_version() << ") on: " << ctime(&foo); | 1945 | t << "# Generated by qmake (" << qmake_version() << ") (Qt " << QT_VERSION_STR << ") on: " << ctime(&foo); |
1791 | t << "# Project: " << fileFixify(project->projectFile()) << endl; | 1946 | t << "# Project: " << fileFixify(project->projectFile()) << endl; |
1792 | t << "# Template: " << var("TEMPLATE") << endl; | 1947 | t << "# Template: " << var("TEMPLATE") << endl; |
1793 | t << "# Command: " << build_args() << endl; | 1948 | t << "# Command: " << build_args() << endl; |
1794 | t << "#############################################################################" << endl; | 1949 | t << "#############################################################################" << endl; |
1795 | t << endl; | 1950 | t << endl; |
1796 | return TRUE; | 1951 | return TRUE; |
1797 | } | 1952 | } |
1798 | 1953 | ||
1799 | 1954 | ||
1800 | //makes my life easier.. | 1955 | //makes my life easier.. |
1801 | bool | 1956 | bool |
1802 | MakefileGenerator::writeMakeQmake(QTextStream &t) | 1957 | MakefileGenerator::writeMakeQmake(QTextStream &t) |
1803 | { | 1958 | { |
1804 | QString ofile = Option::fixPathToTargetOS(fileFixify(Option::output.name())); | 1959 | QString ofile = Option::fixPathToTargetOS(fileFixify(Option::output.name())); |
1805 | if(project->isEmpty("QMAKE_FAILED_REQUIREMENTS") && | 1960 | if(project->isEmpty("QMAKE_FAILED_REQUIREMENTS") && !project->isActiveConfig("no_autoqmake") && |
1806 | !project->isEmpty("QMAKE_INTERNAL_PRL_FILE")) { | 1961 | !project->isEmpty("QMAKE_INTERNAL_PRL_FILE")) { |
1807 | QStringList files = fileFixify(Option::mkfile::project_files); | 1962 | QStringList files = fileFixify(Option::mkfile::project_files); |
1808 | t << project->first("QMAKE_INTERNAL_PRL_FILE") << ": " << "\n\t" | 1963 | t << project->first("QMAKE_INTERNAL_PRL_FILE") << ": " << "\n\t" |
1809 | << "@$(QMAKE) -prl " << buildArgs() << " " << files.join(" ") << endl; | 1964 | << "@$(QMAKE) -prl " << buildArgs() << " " << files.join(" ") << endl; |
1810 | } | 1965 | } |
1811 | 1966 | ||
1812 | QString pfile = project->projectFile(); | 1967 | QString pfile = project->projectFile(); |
1813 | if(pfile != "(stdin)") { | 1968 | if(pfile != "(stdin)") { |
@@ -1841,19 +1996,25 @@ MakefileGenerator::fileFixify(const QStringList& files, const QString &out_dir, | |||
1841 | ret << fileFixify((*it), out_dir, in_dir, force_fix); | 1996 | ret << fileFixify((*it), out_dir, in_dir, force_fix); |
1842 | } | 1997 | } |
1843 | return ret; | 1998 | return ret; |
1844 | } | 1999 | } |
1845 | 2000 | ||
1846 | QString | 2001 | QString |
1847 | MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const QString &in_d, bool force_fix) const | 2002 | MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const QString &in_d, bool force_fix) const |
1848 | { | 2003 | { |
2004 | if(file0.isEmpty()) | ||
2005 | return file0; | ||
2006 | QString key = file0; | ||
2007 | if(!in_d.isEmpty() || !out_d.isEmpty() || force_fix) | ||
2008 | key.prepend(in_d + "--" + out_d + "--" + QString::number((int)force_fix) + "-"); | ||
2009 | if(fileFixed.contains(key)) | ||
2010 | return fileFixed[key]; | ||
2011 | |||
1849 | QString file = file0; | 2012 | QString file = file0; |
1850 | if(file.isEmpty()) | ||
1851 | return file; | ||
1852 | int depth = 4; | 2013 | int depth = 4; |
1853 | if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || | 2014 | if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || |
1854 | Option::qmake_mode == Option::QMAKE_GENERATE_PRL) { | 2015 | Option::qmake_mode == Option::QMAKE_GENERATE_PRL) { |
1855 | if(project && !project->isEmpty("QMAKE_PROJECT_DEPTH")) | 2016 | if(project && !project->isEmpty("QMAKE_PROJECT_DEPTH")) |
1856 | depth = project->first("QMAKE_PROJECT_DEPTH").toInt(); | 2017 | depth = project->first("QMAKE_PROJECT_DEPTH").toInt(); |
1857 | else if(Option::mkfile::cachefile_depth != -1) | 2018 | else if(Option::mkfile::cachefile_depth != -1) |
1858 | depth = Option::mkfile::cachefile_depth; | 2019 | depth = Option::mkfile::cachefile_depth; |
1859 | } | 2020 | } |
@@ -1885,25 +2046,36 @@ MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const | |||
1885 | if(!QDir::isRelativePath(in_dir) || !QDir::isRelativePath(out_dir)) { | 2046 | if(!QDir::isRelativePath(in_dir) || !QDir::isRelativePath(out_dir)) { |
1886 | QFileInfo in_fi(in_dir); | 2047 | QFileInfo in_fi(in_dir); |
1887 | if(!in_fi.convertToAbs()) | 2048 | if(!in_fi.convertToAbs()) |
1888 | in_dir = in_fi.filePath(); | 2049 | in_dir = in_fi.filePath(); |
1889 | QFileInfo out_fi(out_dir); | 2050 | QFileInfo out_fi(out_dir); |
1890 | if(!out_fi.convertToAbs()) | 2051 | if(!out_fi.convertToAbs()) |
1891 | out_dir = out_fi.filePath(); | 2052 | out_dir = out_fi.filePath(); |
1892 | } | 2053 | } |
2054 | QString in_canonical_dir = QDir(in_dir).canonicalPath(), | ||
2055 | out_canonical_dir = QDir(out_dir).canonicalPath(); | ||
2056 | if(!in_canonical_dir.isEmpty()) | ||
2057 | in_dir = in_canonical_dir; | ||
2058 | if(!out_canonical_dir.isEmpty()) | ||
2059 | out_dir = out_canonical_dir; | ||
1893 | } | 2060 | } |
1894 | if(out_dir != in_dir || !QDir::isRelativePath(qfile)) { | 2061 | if(out_dir != in_dir || !QDir::isRelativePath(qfile)) { |
1895 | if(QDir::isRelativePath(qfile)) { | 2062 | if(QDir::isRelativePath(qfile)) { |
1896 | if(file.left(Option::dir_sep.length()) != Option::dir_sep && | 2063 | if(file.left(Option::dir_sep.length()) != Option::dir_sep && |
1897 | in_dir.right(Option::dir_sep.length()) != Option::dir_sep) | 2064 | in_dir.right(Option::dir_sep.length()) != Option::dir_sep) |
1898 | file.prepend(Option::dir_sep); | 2065 | file.prepend(Option::dir_sep); |
1899 | file.prepend(in_dir); | 2066 | file.prepend(in_dir); |
1900 | } | 2067 | } |
1901 | file = Option::fixPathToTargetOS(file, FALSE); | 2068 | file = Option::fixPathToTargetOS(file, FALSE); |
2069 | if(QFile::exists(file) && file == Option::fixPathToTargetOS(file, TRUE)) { | ||
2070 | QString real_file = QDir(file).canonicalPath(); | ||
2071 | if(!real_file.isEmpty()) | ||
2072 | file = real_file; | ||
2073 | } | ||
1902 | QString match_dir = Option::fixPathToTargetOS(out_dir, FALSE); | 2074 | QString match_dir = Option::fixPathToTargetOS(out_dir, FALSE); |
1903 | if(file == match_dir) { | 2075 | if(file == match_dir) { |
1904 | file = ""; | 2076 | file = ""; |
1905 | } else if(file.startsWith(match_dir) && | 2077 | } else if(file.startsWith(match_dir) && |
1906 | file.mid(match_dir.length(), Option::dir_sep.length()) == Option::dir_sep) { | 2078 | file.mid(match_dir.length(), Option::dir_sep.length()) == Option::dir_sep) { |
1907 | file = file.right(file.length() - (match_dir.length() + 1)); | 2079 | file = file.right(file.length() - (match_dir.length() + 1)); |
1908 | } else { | 2080 | } else { |
1909 | for(int i = 1; i <= depth; i++) { | 2081 | for(int i = 1; i <= depth; i++) { |
@@ -1924,19 +2096,22 @@ MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const | |||
1924 | for(int o = 0; o < i; o++) | 2096 | for(int o = 0; o < i; o++) |
1925 | file.prepend(".." + Option::dir_sep); | 2097 | file.prepend(".." + Option::dir_sep); |
1926 | } | 2098 | } |
1927 | } | 2099 | } |
1928 | } | 2100 | } |
1929 | } | 2101 | } |
1930 | } | 2102 | } |
1931 | file = Option::fixPathToTargetOS(file, FALSE); | 2103 | file = Option::fixPathToTargetOS(file, FALSE); |
2104 | if(file.isEmpty()) | ||
2105 | file = "."; | ||
1932 | if(!quote.isNull()) | 2106 | if(!quote.isNull()) |
1933 | file = quote + file + quote; | 2107 | file = quote + file + quote; |
1934 | debug_msg(3, "Fixed %s :: to :: %s (%d)", orig_file.latin1(), file.latin1(), depth); | 2108 | debug_msg(3, "Fixed %s :: to :: %s (%d)", orig_file.latin1(), file.latin1(), depth); |
2109 | ((MakefileGenerator*)this)->fileFixed.insert(key, file); | ||
1935 | return file; | 2110 | return file; |
1936 | } | 2111 | } |
1937 | 2112 | ||
1938 | QString | 2113 | QString |
1939 | MakefileGenerator::cleanFilePath(const QString &file) const | 2114 | MakefileGenerator::cleanFilePath(const QString &file) const |
1940 | { | 2115 | { |
1941 | return fileFixify(Option::fixPathToTargetOS(file)); | 2116 | return fileFixify(Option::fixPathToTargetOS(file)); |
1942 | } | 2117 | } |
@@ -2034,18 +2209,19 @@ MakefileGenerator::openOutput(QFile &file) const | |||
2034 | } | 2209 | } |
2035 | return FALSE; | 2210 | return FALSE; |
2036 | } | 2211 | } |
2037 | 2212 | ||
2038 | 2213 | ||
2039 | 2214 | ||
2040 | //Factory thing | 2215 | //Factory thing |
2041 | #include "unixmake.h" | 2216 | #include "unixmake.h" |
2042 | #include "borland_bmake.h" | ||
2043 | #include "msvc_nmake.h" | 2217 | #include "msvc_nmake.h" |
2218 | #include "borland_bmake.h" | ||
2219 | #include "mingw_make.h" | ||
2044 | #include "msvc_dsp.h" | 2220 | #include "msvc_dsp.h" |
2045 | #include "msvc_vcproj.h" | 2221 | #include "msvc_vcproj.h" |
2046 | #include "metrowerks_xml.h" | 2222 | #include "metrowerks_xml.h" |
2047 | #include "pbuilder_pbx.h" | 2223 | #include "pbuilder_pbx.h" |
2048 | #include "projectgenerator.h" | 2224 | #include "projectgenerator.h" |
2049 | 2225 | ||
2050 | MakefileGenerator * | 2226 | MakefileGenerator * |
2051 | MakefileGenerator::create(QMakeProject *proj) | 2227 | MakefileGenerator::create(QMakeProject *proj) |
@@ -2056,29 +2232,31 @@ MakefileGenerator::create(QMakeProject *proj) | |||
2056 | MakefileGenerator *mkfile = NULL; | 2232 | MakefileGenerator *mkfile = NULL; |
2057 | QString gen = proj->first("MAKEFILE_GENERATOR"); | 2233 | QString gen = proj->first("MAKEFILE_GENERATOR"); |
2058 | if(gen.isEmpty()) { | 2234 | if(gen.isEmpty()) { |
2059 | fprintf(stderr, "No generator specified in config file: %s\n", | 2235 | fprintf(stderr, "No generator specified in config file: %s\n", |
2060 | proj->projectFile().latin1()); | 2236 | proj->projectFile().latin1()); |
2061 | } else if(gen == "UNIX") { | 2237 | } else if(gen == "UNIX") { |
2062 | mkfile = new UnixMakefileGenerator(proj); | 2238 | mkfile = new UnixMakefileGenerator(proj); |
2063 | } else if(gen == "MSVC") { | 2239 | } else if(gen == "MSVC") { |
2064 | // Visual Studio =< v6.0 | 2240 | // Visual Studio =< v6.0 |
2065 | if(proj->first("TEMPLATE").find(QRegExp("^vc.*")) != -1) | 2241 | if(proj->first("TEMPLATE").find(QRegExp("^vc.*")) != -1) |
2066 | mkfile = new DspMakefileGenerator(proj); | 2242 | mkfile = new DspMakefileGenerator(proj); |
2067 | else | 2243 | else |
2068 | mkfile = new NmakeMakefileGenerator(proj); | 2244 | mkfile = new NmakeMakefileGenerator(proj); |
2069 | } else if(gen == "MSVC.NET") { | 2245 | } else if(gen == "MSVC.NET") { |
2070 | // Visual Studio >= v7.0 | 2246 | // Visual Studio >= v7.0 |
2071 | if(proj->first("TEMPLATE").find(QRegExp("^vc.*")) != -1) | 2247 | if(proj->first("TEMPLATE").find(QRegExp("^vc.*")) != -1) |
2072 | mkfile = new VcprojGenerator(proj); | 2248 | mkfile = new VcprojGenerator(proj); |
2073 | else | 2249 | else |
2074 | mkfile = new NmakeMakefileGenerator(proj); | 2250 | mkfile = new NmakeMakefileGenerator(proj); |
2075 | } else if(gen == "BMAKE") { | 2251 | } else if(gen == "BMAKE") { |
2076 | mkfile = new BorlandMakefileGenerator(proj); | 2252 | mkfile = new BorlandMakefileGenerator(proj); |
2253 | } else if(gen == "MINGW") { | ||
2254 | mkfile = new MingwMakefileGenerator(proj); | ||
2077 | } else if(gen == "METROWERKS") { | 2255 | } else if(gen == "METROWERKS") { |
2078 | mkfile = new MetrowerksMakefileGenerator(proj); | 2256 | mkfile = new MetrowerksMakefileGenerator(proj); |
2079 | } else if(gen == "PROJECTBUILDER") { | 2257 | } else if(gen == "PROJECTBUILDER") { |
2080 | mkfile = new ProjectBuilderMakefileGenerator(proj); | 2258 | mkfile = new ProjectBuilderMakefileGenerator(proj); |
2081 | } else { | 2259 | } else { |
2082 | fprintf(stderr, "Unknown generator specified: %s\n", gen.latin1()); | 2260 | fprintf(stderr, "Unknown generator specified: %s\n", gen.latin1()); |
2083 | } | 2261 | } |
2084 | return mkfile; | 2262 | return mkfile; |