summaryrefslogtreecommitdiff
path: root/qmake/generators
Unidiff
Diffstat (limited to 'qmake/generators') (more/less context) (show whitespace changes)
-rw-r--r--qmake/generators/makefile.cpp384
-rw-r--r--qmake/generators/makefile.h10
-rw-r--r--qmake/generators/projectgenerator.cpp64
-rw-r--r--qmake/generators/unix/unixmake.cpp154
-rw-r--r--qmake/generators/unix/unixmake.h1
-rw-r--r--qmake/generators/unix/unixmake2.cpp149
-rw-r--r--qmake/generators/win32/borland_bmake.cpp56
-rw-r--r--qmake/generators/win32/borland_bmake.h9
-rw-r--r--qmake/generators/win32/mingw_make.cpp524
-rw-r--r--qmake/generators/win32/mingw_make.h58
-rw-r--r--qmake/generators/win32/msvc_dsp.cpp163
-rw-r--r--qmake/generators/win32/msvc_dsp.h14
-rw-r--r--qmake/generators/win32/msvc_nmake.cpp98
-rw-r--r--qmake/generators/win32/msvc_nmake.h8
-rw-r--r--qmake/generators/win32/msvc_objectmodel.cpp155
-rw-r--r--qmake/generators/win32/msvc_objectmodel.h50
-rw-r--r--qmake/generators/win32/msvc_vcproj.cpp316
-rw-r--r--qmake/generators/win32/msvc_vcproj.h30
-rw-r--r--qmake/generators/win32/winmakefile.cpp126
19 files changed, 1833 insertions, 536 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,32 +1,32 @@
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
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this 21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software. 23** with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
@@ -38,83 +38,97 @@
38#include "makefile.h" 38#include "makefile.h"
39#include "option.h" 39#include "option.h"
40#include <qdir.h> 40#include <qdir.h>
41#include <qfile.h> 41#include <qfile.h>
42#include <qtextstream.h> 42#include <qtextstream.h>
43#include <qregexp.h> 43#include <qregexp.h>
44#include <qdict.h> 44#include <qdict.h>
45#if defined(Q_OS_UNIX) 45#if defined(Q_OS_UNIX)
46#include <unistd.h> 46#include <unistd.h>
47#else 47#else
48#include <io.h> 48#include <io.h>
49#endif 49#endif
50#include <stdio.h> 50#include <stdio.h>
51#include <stdlib.h> 51#include <stdlib.h>
52#include <time.h> 52#include <time.h>
53#include <fcntl.h> 53#include <fcntl.h>
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
62static 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
62static bool createDir(const QString& fullPath) 73static 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
80MakefileGenerator::MakefileGenerator(QMakeProject *p) : init_opath_already(FALSE), 94MakefileGenerator::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
86static char *gimme_buffer(off_t s) 100static 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
95bool 109bool
96MakefileGenerator::generateMocList(QString fn_target) 110MakefileGenerator::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)
105 return FALSE; 119 return FALSE;
106 120
107 struct stat fst; 121 struct stat fst;
108 if(fstat(file, &fst) || S_ISDIR(fst.st_mode)) 122 if(fstat(file, &fst) || S_ISDIR(fst.st_mode))
109 return FALSE; //shouldn't happen 123 return FALSE; //shouldn't happen
110 char *big_buffer = gimme_buffer(fst.st_size); 124 char *big_buffer = gimme_buffer(fst.st_size);
111 125
112 int total_size_read; 126 int total_size_read;
113 for(int have_read = total_size_read = 0; 127 for(int have_read = total_size_read = 0;
114 (have_read = read(file, big_buffer + total_size_read, 128 (have_read = read(file, big_buffer + total_size_read,
115 fst.st_size - total_size_read)); 129 fst.st_size - total_size_read));
116 total_size_read += have_read); 130 total_size_read += have_read);
117 close(file); 131 close(file);
118 132
119 bool ignore_qobject = FALSE; 133 bool ignore_qobject = FALSE;
120 int line_count = 1; 134 int line_count = 1;
@@ -152,107 +166,108 @@ MakefileGenerator::generateMocList(QString fn_target)
152 } 166 }
153 } 167 }
154 } 168 }
155 } 169 }
156#define SYMBOL_CHAR(x) ((x >= 'a' && x <= 'z') || (x >= 'A' && x <= 'Z') || \ 170#define SYMBOL_CHAR(x) ((x >= 'a' && x <= 'z') || (x >= 'A' && x <= 'Z') || \
157 (x <= '0' && x >= '9') || x == '_') 171 (x <= '0' && x >= '9') || x == '_')
158 172
159 bool interesting = *(big_buffer+x) == 'Q' && (!strncmp(big_buffer+x, "Q_OBJECT", OBJ_LEN) || 173 bool interesting = *(big_buffer+x) == 'Q' && (!strncmp(big_buffer+x, "Q_OBJECT", OBJ_LEN) ||
160 !strncmp(big_buffer+x, "Q_DISPATCH", DIS_LEN)); 174 !strncmp(big_buffer+x, "Q_DISPATCH", DIS_LEN));
161 if(interesting) { 175 if(interesting) {
162 int len = 0; 176 int len = 0;
163 if(!strncmp(big_buffer+x, "Q_OBJECT", OBJ_LEN)) { 177 if(!strncmp(big_buffer+x, "Q_OBJECT", OBJ_LEN)) {
164 if(ignore_qobject) { 178 if(ignore_qobject) {
165 debug_msg(2, "Mocgen: %s:%d Ignoring Q_OBJECT", fn_target.latin1(), line_count); 179 debug_msg(2, "Mocgen: %s:%d Ignoring Q_OBJECT", fn_target.latin1(), line_count);
166 interesting = FALSE; 180 interesting = FALSE;
167 } 181 }
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 }
206 } 222 }
207 223
208 if(!mocFile.isEmpty()) { 224 if(!mocFile.isEmpty()) {
209 mocFile = Option::fixPathToTargetOS(mocFile); 225 mocFile = Option::fixPathToTargetOS(mocFile);
210 mocablesToMOC[cleanFilePath(fn_target)] = mocFile; 226 mocablesToMOC[cleanFilePath(fn_target)] = mocFile;
211 mocablesFromMOC[cleanFilePath(mocFile)] = fn_target; 227 mocablesFromMOC[cleanFilePath(mocFile)] = fn_target;
212 } 228 }
213 break; 229 break;
214 } 230 }
215 } 231 }
216 232
217 while(x < total_size_read && SYMBOL_CHAR(*(big_buffer+x))) 233 while(x < total_size_read && SYMBOL_CHAR(*(big_buffer+x)))
218 x++; 234 x++;
219 if(*(big_buffer+x) == '\n') 235 if(*(big_buffer+x) == '\n')
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
227bool 243bool
228MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QString fn, bool recurse) 244MakefileGenerator::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
243 258
244 QString fndir, fix_env_fndir; 259 QString fndir, fix_env_fndir;
245 int dl = fn.findRev(Option::dir_sep); 260 int dl = fn.findRev(Option::dir_sep);
246 if(dl != -1) 261 if(dl != -1)
247 fndir = fn.left(dl+1); 262 fndir = fn.left(dl+1);
248 dl = fix_env_fn.findRev(Option::dir_sep); 263 dl = fix_env_fn.findRev(Option::dir_sep);
249 if(dl != -1) 264 if(dl != -1)
250 fix_env_fndir = fix_env_fn.left(dl + 1); 265 fix_env_fndir = fix_env_fn.left(dl + 1);
251 266
252 int line_count = 1; 267 int line_count = 1;
253 char *big_buffer = gimme_buffer(fst.st_size); 268 char *big_buffer = gimme_buffer(fst.st_size);
254 269
255 int total_size_read; 270 int total_size_read;
256 for(int have_read = total_size_read = 0; 271 for(int have_read = total_size_read = 0;
257 (have_read = read(file, big_buffer + total_size_read, 272 (have_read = read(file, big_buffer + total_size_read,
258 fst.st_size - total_size_read)); 273 fst.st_size - total_size_read));
@@ -267,50 +282,52 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri
267 if(*(big_buffer + x) == '/') { 282 if(*(big_buffer + x) == '/') {
268 x++; 283 x++;
269 if(total_size_read >= x) { 284 if(total_size_read >= x) {
270 if(*(big_buffer + x) == '/') { //c++ style comment 285 if(*(big_buffer + x) == '/') { //c++ style comment
271 for( ; x < total_size_read && *(big_buffer + x) != '\n'; x++); 286 for( ; x < total_size_read && *(big_buffer + x) != '\n'; x++);
272 } else if(*(big_buffer + x) == '*') { //c style comment 287 } else if(*(big_buffer + x) == '*') { //c style comment
273 for( ; x < total_size_read; x++) { 288 for( ; x < total_size_read; x++) {
274 if(*(big_buffer + x) == '*') { 289 if(*(big_buffer + x) == '*') {
275 if(total_size_read >= (x+1) && *(big_buffer + (x+1)) == '/') { 290 if(total_size_read >= (x+1) && *(big_buffer + (x+1)) == '/') {
276 x += 2; 291 x += 2;
277 break; 292 break;
278 } 293 }
279 } else if(*(big_buffer + x) == '\n') { 294 } else if(*(big_buffer + x) == '\n') {
280 line_count++; 295 line_count++;
281 } 296 }
282 } 297 }
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?
301 x++; 318 x++;
302 319
303 int inc_len; 320 int inc_len;
304 for(inc_len = 0; *(big_buffer + x + inc_len) != term; inc_len++); 321 for(inc_len = 0; *(big_buffer + x + inc_len) != term; inc_len++);
305 *(big_buffer + x + inc_len) = '\0'; 322 *(big_buffer + x + inc_len) = '\0';
306 inc = big_buffer + x; 323 inc = big_buffer + x;
307 } else if(total_size_read >= x + 14 && !strncmp(big_buffer + x, "qmake_warning ", 14)) { 324 } else if(total_size_read >= x + 14 && !strncmp(big_buffer + x, "qmake_warning ", 14)) {
308 for(x+=14; //skip spaces after keyword 325 for(x+=14; //skip spaces after keyword
309 x < total_size_read && (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t'); 326 x < total_size_read && (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t');
310 x++); 327 x++);
311 char term = '\n'; 328 char term = '\n';
312 if(*(big_buffer + x) == '"') 329 if(*(big_buffer + x) == '"')
313 term = '"'; 330 term = '"';
314 if(*(big_buffer + x) == '\'') 331 if(*(big_buffer + x) == '\'')
315 term = '\''; 332 term = '\'';
316 if(term != '\n') 333 if(term != '\n')
@@ -362,163 +379,217 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri
362 *(big_buffer + x + val_len) == ' ') { 379 *(big_buffer + x + val_len) == ' ') {
363 break; 380 break;
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));
394 if(regx.search(inc) != -1) { 412 if(regx.search(inc) != -1) {
395 found = TRUE; 413 found = TRUE;
396 break; 414 break;
397 } 415 }
398 } 416 }
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())) {
437 QString uip = inc_file.left(extn) + Option::ui_ext; 456 QString uip = inc_file.left(extn) + Option::ui_ext;
438 QStringList uil = project->variables()["FORMS"]; 457 QStringList uil = project->variables()["FORMS"];
439 for(QStringList::Iterator it = uil.begin(); it != uil.end(); ++it) { 458 for(QStringList::Iterator it = uil.begin(); it != uil.end(); ++it) {
440 if((*it).section(Option::dir_sep, -1) == uip) { 459 if((*it).section(Option::dir_sep, -1) == uip) {
441 if(!project->isEmpty("UI_DIR")) 460 if(!project->isEmpty("UI_DIR"))
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
491 if(recurse) { 562 if(recurse) {
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
504void 575void
505MakefileGenerator::initOutPaths() 576MakefileGenerator::initOutPaths()
506{ 577{
507 if(init_opath_already) 578 if(init_opath_already)
508 return; 579 return;
509 init_opath_already = TRUE; 580 init_opath_already = TRUE;
510 QMap<QString, QStringList> &v = project->variables(); 581 QMap<QString, QStringList> &v = project->variables();
511 if(!v.contains("QMAKE_ABSOLUTE_SOURCE_PATH")) { 582 if(!v.contains("QMAKE_ABSOLUTE_SOURCE_PATH")) {
512 if(Option::mkfile::do_cache && !Option::mkfile::cachefile.isEmpty() && 583 if(Option::mkfile::do_cache && !Option::mkfile::cachefile.isEmpty() &&
513 v.contains("QMAKE_ABSOLUTE_SOURCE_ROOT")) { 584 v.contains("QMAKE_ABSOLUTE_SOURCE_ROOT")) {
514 QString root = v["QMAKE_ABSOLUTE_SOURCE_ROOT"].first(); 585 QString root = v["QMAKE_ABSOLUTE_SOURCE_ROOT"].first();
515 root = Option::fixPathToTargetOS( root ); 586 root = Option::fixPathToTargetOS( root );
516 if(!root.isEmpty()) { 587 if(!root.isEmpty()) {
517 QFileInfo fi(Option::mkfile::cachefile); 588 QFileInfo fi(Option::mkfile::cachefile);
518 if(!fi.convertToAbs()) { 589 if(!fi.convertToAbs()) {
519 QString cache_r = fi.dirPath(), pwd = Option::output_dir; 590 QString cache_r = fi.dirPath(), pwd = Option::output_dir;
520 if ( pwd.startsWith(cache_r) && !pwd.startsWith(root) ) { 591 if ( pwd.startsWith(cache_r) && !pwd.startsWith(root) ) {
521 pwd = Option::fixPathToTargetOS(root + pwd.mid(cache_r.length())); 592 pwd = Option::fixPathToTargetOS(root + pwd.mid(cache_r.length()));
522 if(QFile::exists(pwd)) 593 if(QFile::exists(pwd))
523 v.insert("QMAKE_ABSOLUTE_SOURCE_PATH", pwd); 594 v.insert("QMAKE_ABSOLUTE_SOURCE_PATH", pwd);
524 } 595 }
@@ -592,64 +663,68 @@ MakefileGenerator::initOutPaths()
592 } 663 }
593 QDir::current().cd( currentDir ); 664 QDir::current().cd( currentDir );
594} 665}
595 666
596void 667void
597MakefileGenerator::init() 668MakefileGenerator::init()
598{ 669{
599 initOutPaths(); 670 initOutPaths();
600 if(init_already) 671 if(init_already)
601 return; 672 return;
602 init_already = TRUE; 673 init_already = TRUE;
603 674
604 QMap<QString, QStringList> &v = project->variables(); 675 QMap<QString, QStringList> &v = project->variables();
605 QString paths[] = { QString("SOURCES"), QString("FORMS"), QString("YACCSOURCES"), QString("INCLUDEPATH"), 676 QString paths[] = { QString("SOURCES"), QString("FORMS"), QString("YACCSOURCES"), QString("INCLUDEPATH"),
606 QString("HEADERS"), QString("HEADERS_ORIG"), 677 QString("HEADERS"), QString("HEADERS_ORIG"),
607 QString("LEXSOURCES"), QString("QMAKE_INTERNAL_INCLUDED_FILES"), QString::null }; 678 QString("LEXSOURCES"), QString("QMAKE_INTERNAL_INCLUDED_FILES"), QString::null };
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;
640 while (!cachet.eof()) { 715 while (!cachet.eof()) {
641 line = cachet.readLine().stripWhiteSpace(); 716 line = cachet.readLine().stripWhiteSpace();
642 int sep = line.find('='); 717 int sep = line.find('=');
643 if(line == "[depend]") { 718 if(line == "[depend]") {
644 state = CacheDepend; 719 state = CacheDepend;
645 } else if(line == "[mocable]") { 720 } else if(line == "[mocable]") {
646 state = CacheMoc; 721 state = CacheMoc;
647 } else if(line == "[check]") { 722 } else if(line == "[check]") {
648 state = CacheInfo; 723 state = CacheInfo;
649 } else if(!line.isEmpty() && sep != -1) { 724 } else if(!line.isEmpty() && sep != -1) {
650 file = line.left(sep).stripWhiteSpace(); 725 file = line.left(sep).stripWhiteSpace();
651 line = line.right(line.length() - sep - 1).stripWhiteSpace(); 726 line = line.right(line.length() - sep - 1).stripWhiteSpace();
652 if(state == CacheInfo) { 727 if(state == CacheInfo) {
653 if(file == "QMAKE_CACHE_VERSION") { 728 if(file == "QMAKE_CACHE_VERSION") {
654 if(line != qmake_version()) 729 if(line != qmake_version())
655 break; 730 break;
@@ -662,49 +737,49 @@ MakefileGenerator::init()
662 bool found = (bool)cache_found_files[file]; 737 bool found = (bool)cache_found_files[file];
663 QStringList files = QStringList::split(" ", line); 738 QStringList files = QStringList::split(" ", line);
664 if(!found) { 739 if(!found) {
665 QFileInfo fi(fileFixify(file, QDir::currentDirPath(), Option::output_dir)); 740 QFileInfo fi(fileFixify(file, QDir::currentDirPath(), Option::output_dir));
666 if(fi.exists() && fi.lastModified() < cachefi.lastModified()) { 741 if(fi.exists() && fi.lastModified() < cachefi.lastModified()) {
667 cache_found_files.insert(file, (void *)1); 742 cache_found_files.insert(file, (void *)1);
668 found = TRUE; 743 found = TRUE;
669 } 744 }
670 } 745 }
671 if(found) { 746 if(found) {
672 for(QStringList::Iterator dep_it = files.begin(); 747 for(QStringList::Iterator dep_it = files.begin();
673 dep_it != files.end(); ++dep_it) { 748 dep_it != files.end(); ++dep_it) {
674 if(!cache_found_files[(*dep_it)]) { 749 if(!cache_found_files[(*dep_it)]) {
675 QFileInfo fi(fileFixify((*dep_it), QDir::currentDirPath(), Option::output_dir)); 750 QFileInfo fi(fileFixify((*dep_it), QDir::currentDirPath(), Option::output_dir));
676 if(fi.exists() && 751 if(fi.exists() &&
677 fi.lastModified() < cachefi.lastModified()) { 752 fi.lastModified() < cachefi.lastModified()) {
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) {
695 cache_found_files.replace(file, (void *)2); 770 cache_found_files.replace(file, (void *)2);
696 } else { 771 } else {
697 QFileInfo fi(fileFixify(file, QDir::currentDirPath(), Option::output_dir)); 772 QFileInfo fi(fileFixify(file, QDir::currentDirPath(), Option::output_dir));
698 if(fi.exists() && fi.lastModified() < cachefi.lastModified()) { 773 if(fi.exists() && fi.lastModified() < cachefi.lastModified()) {
699 cache_found_files.insert(file, (void *)2); 774 cache_found_files.insert(file, (void *)2);
700 found = (void*)1; 775 found = (void*)1;
701 } 776 }
702 } 777 }
703 } 778 }
704 if(found && line != "*qmake_ignore*") { 779 if(found && line != "*qmake_ignore*") {
705 int ext_len = file.length() - file.findRev('.'); 780 int ext_len = file.length() - file.findRev('.');
706 bool cpp_ext = FALSE; 781 bool cpp_ext = FALSE;
707 for(QStringList::Iterator cppit = Option::cpp_ext.begin(); 782 for(QStringList::Iterator cppit = Option::cpp_ext.begin();
708 cppit != Option::cpp_ext.end(); ++cppit) { 783 cppit != Option::cpp_ext.end(); ++cppit) {
709 if((cpp_ext = (file.right(ext_len) == (*cppit)))) 784 if((cpp_ext = (file.right(ext_len) == (*cppit))))
710 break; 785 break;
@@ -722,163 +797,174 @@ MakefileGenerator::init()
722 } 797 }
723 debug_msg(2, "Mocgen (cached): %s -> %s", file.latin1(), 798 debug_msg(2, "Mocgen (cached): %s -> %s", file.latin1(),
724 line.latin1()); 799 line.latin1());
725 mocablesToMOC[file] = line; 800 mocablesToMOC[file] = line;
726 mocablesFromMOC[line] = file; 801 mocablesFromMOC[line] = file;
727 } 802 }
728 } 803 }
729 } 804 }
730 } 805 }
731 cachef.close(); 806 cachef.close();
732 } 807 }
733 } 808 }
734 } 809 }
735 if(!noIO()) { 810 if(!noIO()) {
736 QString sources[] = { QString("OBJECTS"), QString("LEXSOURCES"), QString("YACCSOURCES"), 811 QString sources[] = { QString("OBJECTS"), QString("LEXSOURCES"), QString("YACCSOURCES"),
737 QString("HEADERS"), QString("SOURCES"), QString("FORMS"), 812 QString("HEADERS"), QString("SOURCES"), QString("FORMS"),
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();
754 vpath_it != vpath.end(); ++vpath_it) { 830 vpath_it != vpath.end(); ++vpath_it) {
755 QString real_dir = Option::fixPathToLocalOS((*vpath_it)); 831 QString real_dir = Option::fixPathToLocalOS((*vpath_it));
756 if(QFile::exists(real_dir + QDir::separator() + (*val_it))) { 832 if(QFile::exists(real_dir + QDir::separator() + (*val_it))) {
757 QString dir = (*vpath_it); 833 QString dir = (*vpath_it);
758 if(dir.right(Option::dir_sep.length()) != Option::dir_sep) 834 if(dir.right(Option::dir_sep.length()) != Option::dir_sep)
759 dir += Option::dir_sep; 835 dir += Option::dir_sep;
760 (*val_it) = fileFixify(dir + (*val_it)); 836 (*val_it) = fileFixify(dir + (*val_it));
761 found = TRUE; 837 found = TRUE;
762 debug_msg(1, "Found file through vpath %s -> %s", 838 debug_msg(1, "Found file through vpath %s -> %s",
763 file.latin1(), (*val_it).latin1()); 839 file.latin1(), (*val_it).latin1());
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++) {
863 file_list.append(dir + d[i]);
864 if(i == (int)d.count() - 1)
865 (*val_it) = dir + d[i];
866 else
787 l.insert(val_it, dir + d[i]); 867 l.insert(val_it, dir + d[i]);
788 } 868 }
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) {
881 QString file_list_file = fileFixify((*file_it));
800 bool found_cache_moc = FALSE, found_cache_dep = FALSE; 882 bool found_cache_moc = FALSE, found_cache_dep = FALSE;
801 if(read_cache && Option::output.name() != "-" && 883 if(read_cache && Option::output.name() != "-" &&
802 project->isActiveConfig("qmake_cache")) { 884 project->isActiveConfig("qmake_cache")) {
803 if(!findDependencies(val_file).isEmpty()) 885 if(!findDependencies(file_list_file).isEmpty())
804 found_cache_dep = TRUE; 886 found_cache_dep = TRUE;
805 if(cache_found_files[(*val_it)] == (void *)2) 887 if(cache_found_files[(*file_it)] == (void *)2)
806 found_cache_moc = TRUE; 888 found_cache_moc = TRUE;
807 if(!found_cache_moc || !found_cache_dep) 889 if(!found_cache_moc || !found_cache_dep)
808 write_cache = TRUE; 890 write_cache = TRUE;
809 } 891 }
810 if(!found_cache_dep && sources[x] != "OBJECTS") { 892 /* Do moc before dependency checking since some includes can come from
811 debug_msg(5, "Looking for dependancies for %s", (*val_it).latin1()); 893 moc_*.cpp files */
812 generateDependencies(deplist, (*val_it), doDepends());
813 }
814 if(found_cache_moc) { 894 if(found_cache_moc) {
815 QString moc = findMocDestination(val_file); 895 QString moc = findMocDestination(file_list_file);
816 if(!moc.isEmpty()) { 896 if(!moc.isEmpty()) {
817 for(QStringList::Iterator cppit = Option::cpp_ext.begin(); 897 for(QStringList::Iterator cppit = Option::cpp_ext.begin();
818 cppit != Option::cpp_ext.end(); ++cppit) { 898 cppit != Option::cpp_ext.end(); ++cppit) {
819 if(val_file.endsWith((*cppit))) { 899 if(file_list_file.endsWith((*cppit))) {
820 QStringList &deps = findDependencies(val_file); 900 QStringList &deps = findDependencies(file_list_file);
821 if(!deps.contains(moc)) 901 if(!deps.contains(moc))
822 deps.append(moc); 902 deps.append(moc);
823 break; 903 break;
824 } 904 }
825 } 905 }
826 } 906 }
827 } else if(mocAware() && (sources[x] == "SOURCES" || sources[x] == "HEADERS") && 907 } else if(mocAware() && (sources[x] == "SOURCES" || sources[x] == "HEADERS") &&
828 (Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT || 908 (Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT ||
829 Option::mkfile::do_mocs)) { 909 Option::mkfile::do_mocs)) {
830 generateMocList((*val_it)); 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 }
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());
839 QTextStream cachet(&cachef); 924 QTextStream cachet(&cachef);
840 cachet << "[check]" << "\n" 925 cachet << "[check]" << "\n"
841 << "QMAKE_CACHE_VERSION = " << qmake_version() << "\n" 926 << "QMAKE_CACHE_VERSION = " << qmake_version() << "\n"
842 << "QMAKE_ABSOLUTE_SOURCE_PATH = " << var("QMAKE_ABSOLUTE_SOURCE_PATH") << "\n" 927 << "QMAKE_ABSOLUTE_SOURCE_PATH = " << var("QMAKE_ABSOLUTE_SOURCE_PATH") << "\n"
843 << "MOC_DIR = " << var("MOC_DIR") << "\n" 928 << "MOC_DIR = " << var("MOC_DIR") << "\n"
844 << "UI_DIR = " << var("UI_DIR") << "\n" 929 << "UI_DIR = " << var("UI_DIR") << "\n"
845 << "UI_HEADERS_DIR = " << var("UI_HEADERS_DIR") << "\n" 930 << "UI_HEADERS_DIR = " << var("UI_HEADERS_DIR") << "\n"
846 << "UI_SOURCES_DIR = " << var("UI_SOURCES_DIR") << "\n"; 931 << "UI_SOURCES_DIR = " << var("UI_SOURCES_DIR") << "\n";
847 cachet << "[depend]" << endl; 932 cachet << "[depend]" << endl;
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 }
869 v["OBJECTS"] = createObjectList("SOURCES") + v["OBJECTS"]; // init variables 955 v["OBJECTS"] = createObjectList("SOURCES") + v["OBJECTS"]; // init variables
870 956
871 //lex files 957 //lex files
872 { 958 {
873 QStringList &impls = v["LEXIMPLS"]; 959 QStringList &impls = v["LEXIMPLS"];
874 QStringList &l = v["LEXSOURCES"]; 960 QStringList &l = v["LEXSOURCES"];
875 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 961 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
876 QString dir; 962 QString dir;
877 QFileInfo fi((*it)); 963 QFileInfo fi((*it));
878 if(fi.dirPath() != ".") 964 if(fi.dirPath() != ".")
879 dir = fi.dirPath() + Option::dir_sep; 965 dir = fi.dirPath() + Option::dir_sep;
880 dir = fileFixify(dir, QDir::currentDirPath(), Option::output_dir); 966 dir = fileFixify(dir, QDir::currentDirPath(), Option::output_dir);
881 if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep) 967 if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep)
882 dir += Option::dir_sep; 968 dir += Option::dir_sep;
883 QString impl = dir + fi.baseName(TRUE) + Option::lex_mod + Option::cpp_ext.first(); 969 QString impl = dir + fi.baseName(TRUE) + Option::lex_mod + Option::cpp_ext.first();
884 logicWarn(impl, "SOURCES"); 970 logicWarn(impl, "SOURCES");
@@ -925,135 +1011,151 @@ MakefileGenerator::init()
925 QStringList &yaccdeps = findDependencies((*it)); 1011 QStringList &yaccdeps = findDependencies((*it));
926 for(QStringList::ConstIterator d = yaccdeps.begin(); d != yaccdeps.end(); ++d) { 1012 for(QStringList::ConstIterator d = yaccdeps.begin(); d != yaccdeps.end(); ++d) {
927 if(!impldeps.contains(*d)) 1013 if(!impldeps.contains(*d))
928 impldeps.append(*d); 1014 impldeps.append(*d);
929 } 1015 }
930 if( project->isActiveConfig("lex_included")) { 1016 if( project->isActiveConfig("lex_included")) {
931 // is there a matching lex file ? Transfer its dependencies. 1017 // is there a matching lex file ? Transfer its dependencies.
932 QString lexsrc = fi.baseName(TRUE) + Option::lex_ext; 1018 QString lexsrc = fi.baseName(TRUE) + Option::lex_ext;
933 if(fi.dirPath() != ".") 1019 if(fi.dirPath() != ".")
934 lexsrc.prepend(fi.dirPath() + Option::dir_sep); 1020 lexsrc.prepend(fi.dirPath() + Option::dir_sep);
935 if(v["LEXSOURCES"].findIndex(lexsrc) != -1) { 1021 if(v["LEXSOURCES"].findIndex(lexsrc) != -1) {
936 QString trg = dir + fi.baseName(TRUE) + Option::lex_mod + Option::cpp_ext.first(); 1022 QString trg = dir + fi.baseName(TRUE) + Option::lex_mod + Option::cpp_ext.first();
937 impldeps.append(trg); 1023 impldeps.append(trg);
938 impldeps += findDependencies(lexsrc); 1024 impldeps += findDependencies(lexsrc);
939 depends[lexsrc].clear(); 1025 depends[lexsrc].clear();
940 } 1026 }
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();
995 if(!v["MOC_DIR"].isEmpty()) 1097 if(!v["MOC_DIR"].isEmpty())
996 mocable.prepend(v["MOC_DIR"].first()); 1098 mocable.prepend(v["MOC_DIR"].first());
997 else if(fi.dirPath() != ".") 1099 else if(fi.dirPath() != ".")
998 mocable.prepend(fi.dirPath() + Option::dir_sep); 1100 mocable.prepend(fi.dirPath() + Option::dir_sep);
999 logicWarn(mocable, "SOURCES"); 1101 logicWarn(mocable, "SOURCES");
1000 mocablesToMOC[cleanFilePath(decl)] = mocable; 1102 mocablesToMOC[cleanFilePath(decl)] = mocable;
1001 mocablesFromMOC[cleanFilePath(mocable)] = decl; 1103 mocablesFromMOC[cleanFilePath(mocable)] = decl;
1002 v["_UIMOC"].append(mocable); 1104 v["_UIMOC"].append(mocable);
1003 } 1105 }
1004 v["OBJECTS"] += (v["UICOBJECTS"] = createObjectList("UICDECLS")); 1106 v["OBJECTS"] += (v["UICOBJECTS"] = createObjectList("UICDECLS"));
1005 } 1107 }
1006 1108
1007 //Image files 1109 //Image files
1008 if(!project->isEmpty("IMAGES")) { 1110 if(!project->isEmpty("IMAGES")) {
1009 if(project->isEmpty("QMAKE_IMAGE_COLLECTION")) 1111 if(project->isEmpty("QMAKE_IMAGE_COLLECTION"))
1010 v["QMAKE_IMAGE_COLLECTION"].append("qmake_image_collection" + Option::cpp_ext.first()); 1112 v["QMAKE_IMAGE_COLLECTION"].append("qmake_image_collection" + Option::cpp_ext.first());
1011 QString imgfile = project->first("QMAKE_IMAGE_COLLECTION"); 1113 QString imgfile = project->first("QMAKE_IMAGE_COLLECTION");
1012 Option::fixPathToTargetOS(imgfile); 1114 Option::fixPathToTargetOS(imgfile);
1013 if(!project->isEmpty("UI_DIR") || !project->isEmpty("UI_SOURCES_DIR")) { 1115 if(!project->isEmpty("UI_DIR") || !project->isEmpty("UI_SOURCES_DIR")) {
1014 if(imgfile.find(Option::dir_sep) != -1) 1116 if(imgfile.find(Option::dir_sep) != -1)
1015 imgfile = imgfile.right(imgfile.findRev(Option::dir_sep) + 1); 1117 imgfile = imgfile.right(imgfile.findRev(Option::dir_sep) + 1);
1016 imgfile.prepend( (project->isEmpty("UI_DIR") ? project->first("UI_SOURCES_DIR") : 1118 imgfile.prepend( (project->isEmpty("UI_DIR") ? project->first("UI_SOURCES_DIR") :
1017 project->first("UI_DIR")) ); 1119 project->first("UI_DIR")) );
1018 v["QMAKE_IMAGE_COLLECTION"] = QStringList(imgfile); 1120 v["QMAKE_IMAGE_COLLECTION"] = QStringList(imgfile);
1019 } 1121 }
1020 logicWarn(imgfile, "SOURCES"); 1122 logicWarn(imgfile, "SOURCES");
1021 if(!noIO()) { 1123 if(!noIO()) {
1022 QStringList &l = v["IMAGES"]; 1124 QStringList &l = v["IMAGES"];
1023 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 1125 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
1024 if(!QFile::exists((*it))) { 1126 if(!QFile::exists((*it))) {
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"];
1044 l = v["_HDRMOC"] + v["_UIMOC"] + v["_SRCMOC"]; 1146 l = v["_HDRMOC"] + v["_UIMOC"] + v["_SRCMOC"];
1045 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { 1147 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) {
1046 if(!(*val_it).isEmpty()) 1148 if(!(*val_it).isEmpty())
1047 (*val_it) = Option::fixPathToTargetOS((*val_it), FALSE); 1149 (*val_it) = Option::fixPathToTargetOS((*val_it), FALSE);
1048 } 1150 }
1049 } 1151 }
1050} 1152}
1051 1153
1052bool 1154bool
1053MakefileGenerator::processPrlFile(QString &file) 1155MakefileGenerator::processPrlFile(QString &file)
1054{ 1156{
1055 bool ret = FALSE, try_replace_file=FALSE; 1157 bool ret = FALSE, try_replace_file=FALSE;
1056 QString prl_file; 1158 QString prl_file;
1057 if(file.endsWith(Option::prl_ext)) { 1159 if(file.endsWith(Option::prl_ext)) {
1058 try_replace_file = TRUE; 1160 try_replace_file = TRUE;
1059 prl_file = file; 1161 prl_file = file;
@@ -1083,49 +1185,49 @@ MakefileGenerator::processPrlFile(QString &file)
1083 extn = stem.right(stem.length() - dot); 1185 extn = stem.right(stem.length() - dot);
1084 stem = stem.left(dot); 1186 stem = stem.left(dot);
1085 } 1187 }
1086 if(stem == "qt" || stem == "qte" || stem == "qte-mt" || stem == "qt-mt") { 1188 if(stem == "qt" || stem == "qte" || stem == "qte-mt" || stem == "qt-mt") {
1087 if(stem.endsWith("-mt")) 1189 if(stem.endsWith("-mt"))
1088 stem = stem.left(stem.length() - 3); //lose the -mt 1190 stem = stem.left(stem.length() - 3); //lose the -mt
1089 else 1191 else
1090 stem += "-mt"; //try the thread case 1192 stem += "-mt"; //try the thread case
1091 prl_file = dir; 1193 prl_file = dir;
1092 if(hadlib) 1194 if(hadlib)
1093 prl_file += "lib"; 1195 prl_file += "lib";
1094 prl_file += stem + extn; 1196 prl_file += stem + extn;
1095 try_replace_file = TRUE; 1197 try_replace_file = TRUE;
1096 } 1198 }
1097 } 1199 }
1098 QString real_prl_file = Option::fixPathToLocalOS(prl_file); 1200 QString real_prl_file = Option::fixPathToLocalOS(prl_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;
1116 int slsh = real_prl_file.findRev(Option::dir_sep); 1218 int slsh = real_prl_file.findRev(Option::dir_sep);
1117 if(slsh != -1) 1219 if(slsh != -1)
1118 dir = real_prl_file.left(slsh+1); 1220 dir = real_prl_file.left(slsh+1);
1119 file = dir + proj.first("QMAKE_PRL_TARGET"); 1221 file = dir + proj.first("QMAKE_PRL_TARGET");
1120 } 1222 }
1121 } 1223 }
1122 if(ret) 1224 if(ret)
1123 project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"].append(prl_file); 1225 project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"].append(prl_file);
1124 } 1226 }
1125 return ret; 1227 return ret;
1126} 1228}
1127 1229
1128void 1230void
1129MakefileGenerator::processPrlVariable(const QString &var, const QStringList &l) 1231MakefileGenerator::processPrlVariable(const QString &var, const QStringList &l)
1130{ 1232{
1131 if(var == "QMAKE_PRL_LIBS") { 1233 if(var == "QMAKE_PRL_LIBS") {
@@ -1175,93 +1277,94 @@ MakefileGenerator::processPrlFiles()
1175} 1277}
1176 1278
1177void 1279void
1178MakefileGenerator::writePrlFile(QTextStream &t) 1280MakefileGenerator::writePrlFile(QTextStream &t)
1179{ 1281{
1180 QString target = project->first("TARGET"); 1282 QString target = project->first("TARGET");
1181 int slsh = target.findRev(Option::dir_sep); 1283 int slsh = target.findRev(Option::dir_sep);
1182 if(slsh != -1) 1284 if(slsh != -1)
1183 target = target.right(target.length() - slsh - 1); 1285 target = target.right(target.length() - slsh - 1);
1184 QString bdir = Option::output_dir; 1286 QString bdir = Option::output_dir;
1185 if(bdir.isEmpty()) 1287 if(bdir.isEmpty())
1186 bdir = QDir::currentDirPath(); 1288 bdir = QDir::currentDirPath();
1187 t << "QMAKE_PRL_BUILD_DIR = " << bdir << endl; 1289 t << "QMAKE_PRL_BUILD_DIR = " << bdir << endl;
1188 1290
1189 if(!project->projectFile().isEmpty() && project->projectFile() != "-") 1291 if(!project->projectFile().isEmpty() && project->projectFile() != "-")
1190 t << "QMAKE_PRO_INPUT = " << project->projectFile().section('/', -1) << endl; 1292 t << "QMAKE_PRO_INPUT = " << project->projectFile().section('/', -1) << endl;
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)
1207 t << project->variables()[(*it)].join(" ") << " "; 1311 t << project->variables()[(*it)].join(" ") << " ";
1208 t << endl; 1312 t << endl;
1209 } 1313 }
1210} 1314}
1211 1315
1212bool 1316bool
1213MakefileGenerator::write() 1317MakefileGenerator::write()
1214{ 1318{
1215 init(); 1319 init();
1216 findLibraries(); 1320 findLibraries();
1217 if((Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || //write prl 1321 if((Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || //write prl
1218 Option::qmake_mode == Option::QMAKE_GENERATE_PRL) && 1322 Option::qmake_mode == Option::QMAKE_GENERATE_PRL) &&
1219 project->isActiveConfig("create_prl") && project->first("TEMPLATE") == "lib" && 1323 project->isActiveConfig("create_prl") && project->first("TEMPLATE") == "lib" &&
1220 !project->isActiveConfig("plugin")) { 1324 !project->isActiveConfig("plugin")) {
1221 QString prl = var("TARGET"); 1325 QString prl = var("TARGET");
1222 int slsh = prl.findRev(Option::dir_sep); 1326 int slsh = prl.findRev(Option::dir_sep);
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;
1252} 1355}
1253 1356
1254void 1357void
1255MakefileGenerator::writeObj(QTextStream &t, const QString &obj, const QString &src) 1358MakefileGenerator::writeObj(QTextStream &t, const QString &obj, const QString &src)
1256{ 1359{
1257 QStringList &objl = project->variables()[obj]; 1360 QStringList &objl = project->variables()[obj];
1258 QStringList &srcl = project->variables()[src]; 1361 QStringList &srcl = project->variables()[src];
1259 1362
1260 QStringList::Iterator oit = objl.begin(); 1363 QStringList::Iterator oit = objl.begin();
1261 QStringList::Iterator sit = srcl.begin(); 1364 QStringList::Iterator sit = srcl.begin();
1262 QString stringSrc("$src"); 1365 QString stringSrc("$src");
1263 QString stringObj("$obj"); 1366 QString stringObj("$obj");
1264 for( ;sit != srcl.end() && oit != objl.end(); oit++, sit++) { 1367 for( ;sit != srcl.end() && oit != objl.end(); oit++, sit++) {
1265 if((*sit).isEmpty()) 1368 if((*sit).isEmpty())
1266 continue; 1369 continue;
1267 1370
@@ -1281,357 +1384,409 @@ MakefileGenerator::writeObj(QTextStream &t, const QString &obj, const QString &s
1281 } 1384 }
1282 1385
1283 QString comp, cimp; 1386 QString comp, cimp;
1284 for(QStringList::Iterator cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) { 1387 for(QStringList::Iterator cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) {
1285 if((*sit).endsWith((*cppit))) { 1388 if((*sit).endsWith((*cppit))) {
1286 comp = "QMAKE_RUN_CXX"; 1389 comp = "QMAKE_RUN_CXX";
1287 cimp = "QMAKE_RUN_CXX_IMP"; 1390 cimp = "QMAKE_RUN_CXX_IMP";
1288 break; 1391 break;
1289 } 1392 }
1290 } 1393 }
1291 if(comp.isEmpty()) { 1394 if(comp.isEmpty()) {
1292 comp = "QMAKE_RUN_CC"; 1395 comp = "QMAKE_RUN_CC";
1293 cimp = "QMAKE_RUN_CC_IMP"; 1396 cimp = "QMAKE_RUN_CC_IMP";
1294 } 1397 }
1295 bool use_implicit_rule = !project->isEmpty(cimp); 1398 bool use_implicit_rule = !project->isEmpty(cimp);
1296 if(use_implicit_rule) { 1399 if(use_implicit_rule) {
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}
1314 1417
1315 1418
1316void 1419void
1317MakefileGenerator::writeUicSrc(QTextStream &t, const QString &ui) 1420MakefileGenerator::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"))
1335 impl = project->first("UI_SOURCES_DIR") + impl.right(impl.length() - dlen);
1336 } 1442 }
1443 if(!project->isEmpty("UI_SOURCES_DIR")) {
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 );
1345 1464
1346 t << impl << ": " << decl << " " << (*it) << " " << deps << "\n\t" 1465 t << impl << ": " << decl << " " << (*it) << " " << deps << "\n\t"
1347 << "$(UIC) " << (*it) << " -i " << mildDecl << " -o " << impl << endl << endl; 1466 << "$(UIC) " << (*it) << " -i " << mildDecl << " -o " << impl << endl << endl;
1348 } 1467 }
1349} 1468}
1350 1469
1351 1470
1352void 1471void
1353MakefileGenerator::writeMocObj(QTextStream &t, const QString &obj, const QString &src) 1472MakefileGenerator::writeMocObj(QTextStream &t, const QString &obj, const QString &src)
1354{ 1473{
1355 QStringList &objl = project->variables()[obj], 1474 QStringList &objl = project->variables()[obj],
1356 &srcl = project->variables()[src]; 1475 &srcl = project->variables()[src];
1357 QStringList::Iterator oit = objl.begin(), sit = srcl.begin(); 1476 QStringList::Iterator oit = objl.begin(), sit = srcl.begin();
1358 QString stringSrc("$src"), stringObj("$obj"); 1477 QString stringSrc("$src"), stringObj("$obj");
1359 for( ;sit != srcl.end() && oit != objl.end(); oit++, sit++) { 1478 for( ;sit != srcl.end() && oit != objl.end(); oit++, sit++) {
1360 QString hdr = findMocSource((*sit)); 1479 QString hdr = findMocSource((*sit));
1361 t << (*oit) << ": " << (*sit) << " " 1480 t << (*oit) << ": " << (*sit) << " "
1362 << hdr << " " << findDependencies(hdr).join(" \\\n\t\t"); 1481 << hdr << " " << findDependencies(hdr).join(" \\\n\t\t");
1363 bool use_implicit_rule = !project->isEmpty("QMAKE_RUN_CXX_IMP"); 1482 bool use_implicit_rule = !project->isEmpty("QMAKE_RUN_CXX_IMP");
1364 if(use_implicit_rule) { 1483 if(use_implicit_rule) {
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}
1382 1501
1383 1502
1384void 1503void
1385MakefileGenerator::writeMocSrc(QTextStream &t, const QString &src) 1504MakefileGenerator::writeMocSrc(QTextStream &t, const QString &src)
1386{ 1505{
1387 QStringList &l = project->variables()[src]; 1506 QStringList &l = project->variables()[src];
1388 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 1507 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
1389 QString m = Option::fixPathToTargetOS(findMocDestination(*it)); 1508 QString m = Option::fixPathToTargetOS(findMocDestination(*it));
1390 if ( !m.isEmpty()) { 1509 if ( !m.isEmpty()) {
1391 QString deps; 1510 QString deps;
1392 if(!project->isActiveConfig("no_mocdepend")) 1511 if(!project->isActiveConfig("no_mocdepend"))
1393 deps += "$(MOC) "; 1512 deps += "$(MOC) ";
1394 deps += (*it); 1513 deps += (*it);
1395 t << m << ": " << deps << "\n\t" 1514 t << m << ": " << deps << "\n\t"
1396 << "$(MOC) " << (*it) << " -o " << m << endl << endl; 1515 << "$(MOC) " << (*it) << " -o " << m << endl << endl;
1397 } 1516 }
1398 } 1517 }
1399} 1518}
1400 1519
1401void 1520void
1402MakefileGenerator::writeYaccSrc(QTextStream &t, const QString &src) 1521MakefileGenerator::writeYaccSrc(QTextStream &t, const QString &src)
1403{ 1522{
1404 QStringList &l = project->variables()[src]; 1523 QStringList &l = project->variables()[src];
1405 if(project->isActiveConfig("yacc_no_name_mangle") && l.count() > 1) 1524 if(project->isActiveConfig("yacc_no_name_mangle") && l.count() > 1)
1406 warn_msg(WarnLogic, "yacc_no_name_mangle specified, but multiple parsers expected." 1525 warn_msg(WarnLogic, "yacc_no_name_mangle specified, but multiple parsers expected."
1407 "This can lead to link problems.\n"); 1526 "This can lead to link problems.\n");
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"
1435 << "-$(DEL_FILE) " << impl << " " << decl << "\n\t" 1558 << "-$(DEL_FILE) " << impl << " " << decl << "\n\t"
1436 << "-$(MOVE) " << out_h << " " << decl << "\n\t" 1559 << "-$(MOVE) " << out_h << " " << decl << "\n\t"
1437 << "-$(MOVE) " << out_c << " " << impl << endl << endl; 1560 << "-$(MOVE) " << out_c << " " << impl << endl << endl;
1438 t << decl << ": " << impl << endl << endl; 1561 t << decl << ": " << impl << endl << endl;
1439 } 1562 }
1440} 1563}
1441 1564
1442void 1565void
1443MakefileGenerator::writeLexSrc(QTextStream &t, const QString &src) 1566MakefileGenerator::writeLexSrc(QTextStream &t, const QString &src)
1444{ 1567{
1445 QStringList &l = project->variables()[src]; 1568 QStringList &l = project->variables()[src];
1446 if(project->isActiveConfig("yacc_no_name_mangle") && l.count() > 1) 1569 if(project->isActiveConfig("yacc_no_name_mangle") && l.count() > 1)
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}
1475 1601
1476void 1602void
1477MakefileGenerator::writeImageObj(QTextStream &t, const QString &obj) 1603MakefileGenerator::writeImageObj(QTextStream &t, const QString &obj)
1478{ 1604{
1479 QStringList &objl = project->variables()[obj]; 1605 QStringList &objl = project->variables()[obj];
1480 QString stringSrc("$src"); 1606 QString stringSrc("$src");
1481 QString stringObj("$obj"); 1607 QString stringObj("$obj");
1482 1608
1483 QString uidir; 1609 QString uidir;
1484 for(QStringList::Iterator oit = objl.begin(); oit != objl.end(); oit++) { 1610 for(QStringList::Iterator oit = objl.begin(); oit != objl.end(); oit++) {
1485 QString src(project->first("QMAKE_IMAGE_COLLECTION")); 1611 QString src(project->first("QMAKE_IMAGE_COLLECTION"));
1486 t << (*oit) << ": " << src; 1612 t << (*oit) << ": " << src;
1487 bool use_implicit_rule = !project->isEmpty("QMAKE_RUN_CXX_IMP"); 1613 bool use_implicit_rule = !project->isEmpty("QMAKE_RUN_CXX_IMP");
1488 if(use_implicit_rule) { 1614 if(use_implicit_rule) {
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}
1506 1632
1507 1633
1508void 1634void
1509MakefileGenerator::writeImageSrc(QTextStream &t, const QString &src) 1635MakefileGenerator::writeImageSrc(QTextStream &t, const QString &src)
1510{ 1636{
1511 QStringList &l = project->variables()[src]; 1637 QStringList &l = project->variables()[src];
1512 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 1638 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
1513 QString gen = project->first("MAKEFILE_GENERATOR"); 1639 QString gen = project->first("MAKEFILE_GENERATOR");
1514 if ( gen == "MSVC" ) { 1640 if ( gen == "MSVC" ) {
1515 t << (*it) << ": " << findDependencies((*it)).join(" \\\n\t\t") << "\n\t" 1641 t << (*it) << ": " << findDependencies((*it)).join(" \\\n\t\t") << "\n\t"
1516 << "$(UIC) -o " << (*it) << " -embed " << project->first("QMAKE_ORIG_TARGET") 1642 << "$(UIC) -o " << (*it) << " -embed " << project->first("QMAKE_ORIG_TARGET")
1517 << " -f <<\n" << findDependencies((*it)).join(" ") << "\n<<" << endl << endl; 1643 << " -f <<\n" << findDependencies((*it)).join(" ") << "\n<<" << endl << endl;
1518 } else if ( gen == "BMAKE" ) { 1644 } else if ( gen == "BMAKE" ) {
1519 t << (*it) << ": " << findDependencies((*it)).join(" \\\n\t\t") << "\n\t" 1645 t << (*it) << ": " << findDependencies((*it)).join(" \\\n\t\t") << "\n\t"
1520 << "$(UIC) " << " -embed " << project->first("QMAKE_ORIG_TARGET") 1646 << "$(UIC) " << " -embed " << project->first("QMAKE_ORIG_TARGET")
1521 << " -f &&|\n" << findDependencies((*it)).join(" ") << "\n| -o " << (*it) << endl << endl; 1647 << " -f &&|\n" << findDependencies((*it)).join(" ") << "\n| -o " << (*it) << endl << endl;
1522 } else { 1648 } else {
1523 t << (*it) << ": " << findDependencies((*it)).join(" \\\n\t\t") << "\n\t" 1649 t << (*it) << ": " << findDependencies((*it)).join(" \\\n\t\t") << "\n\t"
1524 << "$(UIC) " << " -embed " << project->first("QMAKE_ORIG_TARGET") 1650 << "$(UIC) " << " -embed " << project->first("QMAKE_ORIG_TARGET")
1525 << " " << findDependencies((*it)).join(" ") << " -o " << (*it) << endl << endl; 1651 << " " << findDependencies((*it)).join(" ") << " -o " << (*it) << endl << endl;
1526 } 1652 }
1527 } 1653 }
1528} 1654}
1529 1655
1530 1656
1531void 1657void
1532MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs) 1658MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs)
1533{ 1659{
1534 QString all_installs, all_uninstalls; 1660 QString all_installs, all_uninstalls;
1535 QStringList &l = project->variables()[installs]; 1661 QStringList &l = project->variables()[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;
1675#endif
1547 QStringList tmp, &uninst = project->variables()[(*it) + ".uninstall"]; 1676 QStringList tmp, &uninst = project->variables()[(*it) + ".uninstall"];
1548 //other 1677 //other
1549 tmp = project->variables()[(*it) + ".extra"]; 1678 tmp = project->variables()[(*it) + ".extra"];
1550 if(!tmp.isEmpty()) { 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);
1564 if(QFile::exists(wild)) { //real file 1693 QString dirstr = QDir::currentDirPath(), filestr = wild;
1565 QFileInfo fi(wild); 1694 int slsh = filestr.findRev(Option::dir_sep);
1566 target += QString("\t-") + (fi.isDir() ? "$(COPY_DIR)" : "$(COPY_FILE)") +
1567 " \"" + Option::fixPathToTargetOS(fileFixify(wild), FALSE) + "\" \"" + fileFixify(dst) + "\"\n";
1568 if(!project->isActiveConfig("debug") &&
1569 !fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP"))
1570 target += QString("\t") + var("QMAKE_STRIP") + " \"" + fileFixify(dst + wild) + "\"\n";
1571 uninst.append(QString("-$(DEL_FILE) -r") + " \"" + fileFixify(dst + wild) + "\"");
1572 continue;
1573 }
1574 QString dirstr = QDir::currentDirPath(), f = wild; //wild
1575 int slsh = f.findRev(Option::dir_sep);
1576 if(slsh != -1) { 1695 if(slsh != -1) {
1577 dirstr = f.left(slsh+1); 1696 dirstr = filestr.left(slsh+1);
1578 f = f.right(f.length() - slsh - 1); 1697 filestr = filestr.right(filestr.length() - slsh - 1);
1579 } 1698 }
1580 if(dirstr.right(Option::dir_sep.length()) != Option::dir_sep) 1699 if(dirstr.right(Option::dir_sep.length()) != Option::dir_sep)
1581 dirstr += Option::dir_sep; 1700 dirstr += Option::dir_sep;
1701 if(QFile::exists(wild)) { //real file
1702 QString file = wild;
1703 QFileInfo fi(wild);
1704 if(!target.isEmpty())
1705 target += "\t";
1706 target += QString(fi.isDir() ? "-$(COPY_DIR)" : "-$(COPY_FILE)") + " \"" +
1707 Option::fixPathToTargetOS(fileFixify(wild), FALSE) + "\" \"" + root + dst + "\"\n";
1708 if(!project->isActiveConfig("debug") &&
1709 !fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP"))
1710 target += QString("\t-") + var("QMAKE_STRIP") + " \"" + root + fileFixify(dst + filestr) + "\"\n";
1582 if(!uninst.isEmpty()) 1711 if(!uninst.isEmpty())
1583 uninst.append("\n\t"); 1712 uninst.append("\n\t");
1584 uninst.append(QString("-$(DEL_FILE) -r") + " " + fileFixify(dst + f) + ""); 1713 uninst.append(
1585 1714#ifdef Q_WS_WIN
1586 QDir dir(dirstr, f); 1715 QString("-$(DEL_FILE)")
1716#else
1717 QString("-$(DEL_FILE) -r")
1718#endif
1719 + " \"" + root + fileFixify(dst + filestr) + "\"");
1720 continue;
1721 }
1722 QDir dir(dirstr, filestr); //wild
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";
1622 t << "uninstall: " << all_uninstalls << "\n\n"; 1777 t << "uninstall: " << all_uninstalls << "\n\n";
1623} 1778}
1624 1779
1625QString 1780QString
1626MakefileGenerator::var(const QString &var) 1781MakefileGenerator::var(const QString &var)
1627{ 1782{
1628 return val(project->variables()[var]); 1783 return val(project->variables()[var]);
1629} 1784}
1630 1785
1631QString 1786QString
1632MakefileGenerator::val(const QStringList &varList) 1787MakefileGenerator::val(const QStringList &varList)
1633{ 1788{
1634 return valGlue(varList, "", " ", ""); 1789 return valGlue(varList, "", " ", "");
1635} 1790}
1636 1791
1637QString 1792QString
@@ -1766,193 +1921,213 @@ QString MakefileGenerator::build_args()
1766 if(ret.isEmpty()) { 1921 if(ret.isEmpty()) {
1767 ret = "$(QMAKE)"; 1922 ret = "$(QMAKE)";
1768 1923
1769 // general options and arguments 1924 // general options and arguments
1770 ret += buildArgs(); 1925 ret += buildArgs();
1771 1926
1772 //output 1927 //output
1773 QString ofile = Option::fixPathToTargetOS(fileFixify(Option::output.name())); 1928 QString ofile = Option::fixPathToTargetOS(fileFixify(Option::output.name()));
1774 if (!ofile.isEmpty() && ofile != project->first("QMAKE_MAKEFILE")) 1929 if (!ofile.isEmpty() && ofile != project->first("QMAKE_MAKEFILE"))
1775 ret += " -o " + ofile; 1930 ret += " -o " + ofile;
1776 1931
1777 //inputs 1932 //inputs
1778 QStringList files = fileFixify(Option::mkfile::project_files); 1933 QStringList files = fileFixify(Option::mkfile::project_files);
1779 ret += " " + files.join(" "); 1934 ret += " " + files.join(" ");
1780 } 1935 }
1781 return ret; 1936 return ret;
1782} 1937}
1783 1938
1784bool 1939bool
1785MakefileGenerator::writeHeader(QTextStream &t) 1940MakefileGenerator::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..
1801bool 1956bool
1802MakefileGenerator::writeMakeQmake(QTextStream &t) 1957MakefileGenerator::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)") {
1814 QString qmake = build_args(); 1969 QString qmake = build_args();
1815 if(!ofile.isEmpty() && !project->isActiveConfig("no_autoqmake")) { 1970 if(!ofile.isEmpty() && !project->isActiveConfig("no_autoqmake")) {
1816 t << ofile << ": " << fileFixify(pfile) << " "; 1971 t << ofile << ": " << fileFixify(pfile) << " ";
1817 if(Option::mkfile::do_cache) 1972 if(Option::mkfile::do_cache)
1818 t << fileFixify(Option::mkfile::cachefile) << " "; 1973 t << fileFixify(Option::mkfile::cachefile) << " ";
1819 if(!specdir().isEmpty()) 1974 if(!specdir().isEmpty())
1820 t << specdir() << Option::dir_sep << "qmake.conf" << " "; 1975 t << specdir() << Option::dir_sep << "qmake.conf" << " ";
1821 t << project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"].join(" \\\n\t\t") << "\n\t" 1976 t << project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"].join(" \\\n\t\t") << "\n\t"
1822 << qmake <<endl; 1977 << qmake <<endl;
1823 } 1978 }
1824 if(project->first("QMAKE_ORIG_TARGET") != "qmake") { 1979 if(project->first("QMAKE_ORIG_TARGET") != "qmake") {
1825 t << "qmake: " << 1980 t << "qmake: " <<
1826 project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].join(" \\\n\t\t") << "\n\t" 1981 project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].join(" \\\n\t\t") << "\n\t"
1827 << "@" << qmake << endl << endl; 1982 << "@" << qmake << endl << endl;
1828 } 1983 }
1829 } 1984 }
1830 return TRUE; 1985 return TRUE;
1831} 1986}
1832 1987
1833QStringList 1988QStringList
1834MakefileGenerator::fileFixify(const QStringList& files, const QString &out_dir, const QString &in_dir, bool force_fix) const 1989MakefileGenerator::fileFixify(const QStringList& files, const QString &out_dir, const QString &in_dir, bool force_fix) const
1835{ 1990{
1836 if(files.isEmpty()) 1991 if(files.isEmpty())
1837 return files; 1992 return files;
1838 QStringList ret; 1993 QStringList ret;
1839 for(QStringList::ConstIterator it = files.begin(); it != files.end(); ++it) { 1994 for(QStringList::ConstIterator it = files.begin(); it != files.end(); ++it) {
1840 if(!(*it).isEmpty()) 1995 if(!(*it).isEmpty())
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
1846QString 2001QString
1847MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const QString &in_d, bool force_fix) const 2002MakefileGenerator::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 }
1860 2021
1861 QChar quote; 2022 QChar quote;
1862 if((file.startsWith("'") || file.startsWith("\"")) && file.startsWith(file.right(1))) { 2023 if((file.startsWith("'") || file.startsWith("\"")) && file.startsWith(file.right(1))) {
1863 quote = file.at(0); 2024 quote = file.at(0);
1864 file = file.mid(1, file.length() - 2); 2025 file = file.mid(1, file.length() - 2);
1865 } 2026 }
1866 QString orig_file = file; 2027 QString orig_file = file;
1867 if(!force_fix && project->isActiveConfig("no_fixpath")) { 2028 if(!force_fix && project->isActiveConfig("no_fixpath")) {
1868 if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) { //absoluteify it 2029 if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) { //absoluteify it
1869 QString qfile = Option::fixPathToLocalOS(file); 2030 QString qfile = Option::fixPathToLocalOS(file);
1870 if(QDir::isRelativePath(file)) { //already absolute 2031 if(QDir::isRelativePath(file)) { //already absolute
1871 QFileInfo fi(qfile); 2032 QFileInfo fi(qfile);
1872 if(!fi.convertToAbs()) //strange 2033 if(!fi.convertToAbs()) //strange
1873 file = fi.filePath(); 2034 file = fi.filePath();
1874 } 2035 }
1875 } 2036 }
1876 } else { //fix it.. 2037 } else { //fix it..
1877 QString qfile(Option::fixPathToLocalOS(file, TRUE)), in_dir(in_d), out_dir(out_d); 2038 QString qfile(Option::fixPathToLocalOS(file, TRUE)), in_dir(in_d), out_dir(out_d);
1878 { 2039 {
1879 if(out_dir.isNull()) 2040 if(out_dir.isNull())
1880 out_dir = Option::output_dir; 2041 out_dir = Option::output_dir;
1881 if(out_dir == ".") 2042 if(out_dir == ".")
1882 out_dir = QDir::currentDirPath(); 2043 out_dir = QDir::currentDirPath();
1883 if(in_dir.isEmpty() || in_dir == ".") 2044 if(in_dir.isEmpty() || in_dir == ".")
1884 in_dir = QDir::currentDirPath(); 2045 in_dir = QDir::currentDirPath();
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++) {
1910 int sl = match_dir.findRev(Option::dir_sep); 2082 int sl = match_dir.findRev(Option::dir_sep);
1911 if(sl == -1) 2083 if(sl == -1)
1912 break; 2084 break;
1913 match_dir = match_dir.left(sl); 2085 match_dir = match_dir.left(sl);
1914 if(match_dir.isEmpty()) 2086 if(match_dir.isEmpty())
1915 break; 2087 break;
1916 if(file.startsWith(match_dir) && 2088 if(file.startsWith(match_dir) &&
1917 file.mid(match_dir.length(), Option::dir_sep.length()) == Option::dir_sep) { 2089 file.mid(match_dir.length(), Option::dir_sep.length()) == Option::dir_sep) {
1918 //concat 2090 //concat
1919 int remlen = file.length() - (match_dir.length() + 1); 2091 int remlen = file.length() - (match_dir.length() + 1);
1920 if (remlen < 0) 2092 if (remlen < 0)
1921 remlen = 0; 2093 remlen = 0;
1922 file = file.right(remlen); 2094 file = file.right(remlen);
1923 //prepend 2095 //prepend
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
1938QString 2113QString
1939MakefileGenerator::cleanFilePath(const QString &file) const 2114MakefileGenerator::cleanFilePath(const QString &file) const
1940{ 2115{
1941 return fileFixify(Option::fixPathToTargetOS(file)); 2116 return fileFixify(Option::fixPathToTargetOS(file));
1942} 2117}
1943 2118
1944void MakefileGenerator::logicWarn(const QString &f, const QString &w) 2119void MakefileGenerator::logicWarn(const QString &f, const QString &w)
1945{ 2120{
1946 if(!(Option::warn_level & WarnLogic)) 2121 if(!(Option::warn_level & WarnLogic))
1947 return; 2122 return;
1948 QString file = f; 2123 QString file = f;
1949 int slsh = f.findRev(Option::dir_sep); 2124 int slsh = f.findRev(Option::dir_sep);
1950 if(slsh != -1) 2125 if(slsh != -1)
1951 file = file.right(file.length() - slsh - 1); 2126 file = file.right(file.length() - slsh - 1);
1952 QStringList &l = project->variables()[w]; 2127 QStringList &l = project->variables()[w];
1953 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { 2128 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) {
1954 QString file2((*val_it)); 2129 QString file2((*val_it));
1955 slsh = file2.findRev(Option::dir_sep); 2130 slsh = file2.findRev(Option::dir_sep);
1956 if(slsh != -1) 2131 if(slsh != -1)
1957 file2 = file2.right(file2.length() - slsh - 1); 2132 file2 = file2.right(file2.length() - slsh - 1);
1958 if(file2 == file) { 2133 if(file2 == file) {
@@ -2018,68 +2193,71 @@ MakefileGenerator::openOutput(QFile &file) const
2018 } 2193 }
2019 } 2194 }
2020 if(QDir::isRelativePath(file.name())) 2195 if(QDir::isRelativePath(file.name()))
2021 file.setName(Option::output_dir + file.name()); //pwd when qmake was run 2196 file.setName(Option::output_dir + file.name()); //pwd when qmake was run
2022 if(project->isEmpty("QMAKE_MAKEFILE")) 2197 if(project->isEmpty("QMAKE_MAKEFILE"))
2023 project->variables()["QMAKE_MAKEFILE"].append(file.name()); 2198 project->variables()["QMAKE_MAKEFILE"].append(file.name());
2024 int slsh = file.name().findRev(Option::dir_sep); 2199 int slsh = file.name().findRev(Option::dir_sep);
2025 if(slsh != -1) 2200 if(slsh != -1)
2026 createDir(file.name().left(slsh)); 2201 createDir(file.name().left(slsh));
2027 if(file.open(IO_WriteOnly | IO_Translate)) { 2202 if(file.open(IO_WriteOnly | IO_Translate)) {
2028 QFileInfo fi(Option::output); 2203 QFileInfo fi(Option::output);
2029 QString od = Option::fixPathToTargetOS((fi.isSymLink() ? fi.readLink() : fi.dirPath()) ); 2204 QString od = Option::fixPathToTargetOS((fi.isSymLink() ? fi.readLink() : fi.dirPath()) );
2030 if(QDir::isRelativePath(od)) 2205 if(QDir::isRelativePath(od))
2031 od.prepend(Option::output_dir); 2206 od.prepend(Option::output_dir);
2032 Option::output_dir = od; 2207 Option::output_dir = od;
2033 return TRUE; 2208 return TRUE;
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
2050MakefileGenerator * 2226MakefileGenerator *
2051MakefileGenerator::create(QMakeProject *proj) 2227MakefileGenerator::create(QMakeProject *proj)
2052{ 2228{
2053 if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) 2229 if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT)
2054 return new ProjectGenerator(proj); 2230 return new ProjectGenerator(proj);
2055 2231
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;
2085} 2263}
diff --git a/qmake/generators/makefile.h b/qmake/generators/makefile.h
index 1d19d98..4fdabe8 100644
--- a/qmake/generators/makefile.h
+++ b/qmake/generators/makefile.h
@@ -1,104 +1,104 @@
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
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this 21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software. 23** with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37#ifndef __MAKEFILE_H__ 37#ifndef __MAKEFILE_H__
38#define __MAKEFILE_H__ 38#define __MAKEFILE_H__
39 39
40#include "option.h" 40#include "option.h"
41#include "project.h" 41#include "project.h"
42#include <qtextstream.h> 42#include <qtextstream.h>
43 43
44class MakefileGenerator 44class MakefileGenerator
45{ 45{
46 QString spec; 46 QString spec;
47 bool init_opath_already, init_already, moc_aware, no_io; 47 bool init_opath_already, init_already, moc_aware, no_io;
48 QStringList createObjectList(const QString &var); 48 QStringList createObjectList(const QString &var);
49 QString build_args(); 49 QString build_args();
50 QMap<QString, QString> depHeuristics, depKeyMap; 50 QMap<QString, QString> depHeuristics, depKeyMap, fileFixed;
51 QMap<QString, QString> mocablesToMOC, mocablesFromMOC; 51 QMap<QString, QString> mocablesToMOC, mocablesFromMOC;
52 QMap<QString, QStringList> depends; 52 QMap<QString, QStringList> depends;
53 53
54protected: 54protected:
55 void writeObj(QTextStream &, const QString &obj, const QString &src); 55 void writeObj(QTextStream &, const QString &obj, const QString &src);
56 void writeUicSrc(QTextStream &, const QString &ui); 56 void writeUicSrc(QTextStream &, const QString &ui);
57 void writeMocObj(QTextStream &, const QString &obj, const QString &src); 57 void writeMocObj(QTextStream &, const QString &obj, const QString &src);
58 void writeMocSrc(QTextStream &, const QString &src); 58 void writeMocSrc(QTextStream &, const QString &src);
59 void writeLexSrc(QTextStream &, const QString &lex); 59 void writeLexSrc(QTextStream &, const QString &lex);
60 void writeYaccSrc(QTextStream &, const QString &yac); 60 void writeYaccSrc(QTextStream &, const QString &yac);
61 void writeInstalls(QTextStream &t, const QString &installs); 61 void writeInstalls(QTextStream &t, const QString &installs);
62 void writeImageObj(QTextStream &t, const QString &obj); 62 void writeImageObj(QTextStream &t, const QString &obj);
63 void writeImageSrc(QTextStream &t, const QString &images); 63 void writeImageSrc(QTextStream &t, const QString &images);
64 64
65protected: 65protected:
66 66
67 QMakeProject *project; 67 QMakeProject *project;
68 68
69 class MakefileDependDir { 69 class MakefileDependDir {
70 public: 70 public:
71 MakefileDependDir(QString r, QString l) : real_dir(r), local_dir(l) { } 71 MakefileDependDir(const QString &r, const QString &l) : real_dir(r), local_dir(l) { }
72 QString real_dir, local_dir; 72 QString real_dir, local_dir;
73 }; 73 };
74 bool generateDependencies(QPtrList<MakefileDependDir> &dirs, QString x, bool recurse); 74 bool generateDependencies(QPtrList<MakefileDependDir> &dirs, const QString &x, bool recurse);
75 75
76 QString buildArgs(); 76 QString buildArgs();
77 77
78 QString specdir(); 78 QString specdir();
79 QString cleanFilePath(const QString &file) const; 79 QString cleanFilePath(const QString &file) const;
80 bool generateMocList(QString fn); 80 bool generateMocList(const QString &fn);
81 81
82 QString findMocSource(const QString &moc_file) const; 82 QString findMocSource(const QString &moc_file) const;
83 QString findMocDestination(const QString &src_file) const; 83 QString findMocDestination(const QString &src_file) const;
84 QStringList &findDependencies(const QString &file); 84 QStringList &findDependencies(const QString &file);
85 85
86 void setNoIO(bool o); 86 void setNoIO(bool o);
87 bool noIO() const; 87 bool noIO() const;
88 88
89 void setMocAware(bool o); 89 void setMocAware(bool o);
90 bool mocAware() const; 90 bool mocAware() const;
91 void logicWarn(const QString &, const QString &); 91 void logicWarn(const QString &, const QString &);
92 92
93 virtual bool doDepends() const { return Option::mkfile::do_deps; } 93 virtual bool doDepends() const { return Option::mkfile::do_deps; }
94 bool writeHeader(QTextStream &); 94 bool writeHeader(QTextStream &);
95 virtual bool writeMakefile(QTextStream &); 95 virtual bool writeMakefile(QTextStream &);
96 virtual bool writeMakeQmake(QTextStream &); 96 virtual bool writeMakeQmake(QTextStream &);
97 void initOutPaths(); 97 void initOutPaths();
98 virtual void init(); 98 virtual void init();
99 99
100 //for installs 100 //for installs
101 virtual QString defaultInstall(const QString &); 101 virtual QString defaultInstall(const QString &);
102 102
103 //for prl 103 //for prl
104 bool processPrlFile(QString &); 104 bool processPrlFile(QString &);
diff --git a/qmake/generators/projectgenerator.cpp b/qmake/generators/projectgenerator.cpp
index 5ff6250..1515216 100644
--- a/qmake/generators/projectgenerator.cpp
+++ b/qmake/generators/projectgenerator.cpp
@@ -21,88 +21,96 @@
21** Licensees holding valid Qt Enterprise Edition licenses may use this 21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software. 23** with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#include "projectgenerator.h" 38#include "projectgenerator.h"
39#include "option.h" 39#include "option.h"
40#include <qdir.h> 40#include <qdir.h>
41#include <qfile.h> 41#include <qfile.h>
42#include <qfileinfo.h> 42#include <qfileinfo.h>
43#include <qregexp.h> 43#include <qregexp.h>
44 44
45QString project_builtin_regx() //calculate the builtin regular expression..
46{
47 QString ret;
48 QStringList builtin_exts(".c");
49 builtin_exts << Option::ui_ext << Option::yacc_ext << Option::lex_ext << ".ts";
50 builtin_exts += Option::h_ext + Option::cpp_ext;
51 for(QStringList::Iterator ext_it = builtin_exts.begin();
52 ext_it != builtin_exts.end(); ++ext_it) {
53 if(!ret.isEmpty())
54 ret += "; ";
55 ret += QString("*") + (*ext_it);
56 }
57 return ret;
58}
59
60
45 61
46ProjectGenerator::ProjectGenerator(QMakeProject *p) : MakefileGenerator(p), init_flag(FALSE) 62ProjectGenerator::ProjectGenerator(QMakeProject *p) : MakefileGenerator(p), init_flag(FALSE)
47{ 63{
48} 64}
49 65
50void 66void
51ProjectGenerator::init() 67ProjectGenerator::init()
52{ 68{
53 if(init_flag) 69 if(init_flag)
54 return; 70 return;
55 int file_count = 0; 71 int file_count = 0;
56 init_flag = TRUE; 72 init_flag = TRUE;
57 73
58 QMap<QString, QStringList> &v = project->variables(); 74 QMap<QString, QStringList> &v = project->variables();
59 QString templ = Option::user_template.isEmpty() ? QString("app") : Option::user_template; 75 QString templ = Option::user_template.isEmpty() ? QString("app") : Option::user_template;
60 if(!Option::user_template_prefix.isEmpty()) 76 if(!Option::user_template_prefix.isEmpty())
61 templ.prepend(Option::user_template_prefix); 77 templ.prepend(Option::user_template_prefix);
62 v["TEMPLATE_ASSIGN"] += templ; 78 v["TEMPLATE_ASSIGN"] += templ;
63 79
64 //figure out target 80 //figure out target
65 if(Option::output.name() == "-" || Option::output.name().isEmpty()) 81 if(Option::output.name() == "-" || Option::output.name().isEmpty())
66 v["TARGET"] = QStringList("unknown"); 82 v["TARGET"] = QStringList("unknown");
67 83
68 //the scary stuff 84 //the scary stuff
69 if(project->first("TEMPLATE_ASSIGN") != "subdirs") { 85 if(project->first("TEMPLATE_ASSIGN") != "subdirs") {
70 QString builtin_regex; 86 QString builtin_regex = project_builtin_regx();
71 { //calculate the builtin regular expression..
72 QStringList builtin_exts(".c");
73 builtin_exts << Option::ui_ext << Option::yacc_ext << Option::lex_ext;
74 builtin_exts += Option::h_ext + Option::cpp_ext;
75 for(QStringList::Iterator ext_it = builtin_exts.begin();
76 ext_it != builtin_exts.end(); ++ext_it) {
77 if(!builtin_regex.isEmpty())
78 builtin_regex += "; ";
79 builtin_regex += QString("*") + (*ext_it);
80 }
81 }
82 QStringList dirs = Option::projfile::project_dirs; 87 QStringList dirs = Option::projfile::project_dirs;
83 if(Option::projfile::do_pwd) 88 if(Option::projfile::do_pwd) {
89 if(!v["INCLUDEPATH"].contains("."))
90 v["INCLUDEPATH"] += ".";
84 dirs.prepend(QDir::currentDirPath()); 91 dirs.prepend(QDir::currentDirPath());
92 }
85 93
86 for(QStringList::Iterator pd = dirs.begin(); pd != dirs.end(); pd++) { 94 for(QStringList::Iterator pd = dirs.begin(); pd != dirs.end(); pd++) {
87 QString dir, regex; 95 QString dir, regex;
88 bool add_depend = FALSE; 96 bool add_depend = FALSE;
89 if(QFile::exists((*pd))) { 97 if(QFile::exists((*pd))) {
90 QFileInfo fi((*pd)); 98 QFileInfo fi((*pd));
91 if(fi.isDir()) { 99 if(fi.isDir()) {
92 dir = (*pd); 100 dir = (*pd);
93 add_depend = TRUE; 101 add_depend = TRUE;
94 if(dir.right(1) != Option::dir_sep) 102 if(dir.right(1) != Option::dir_sep)
95 dir += Option::dir_sep; 103 dir += Option::dir_sep;
96 if(Option::projfile::do_recursive) { 104 if(Option::projfile::do_recursive) {
97 QDir d(dir); 105 QDir d(dir);
98 d.setFilter(QDir::Dirs); 106 d.setFilter(QDir::Dirs);
99 for(int i = 0; i < (int)d.count(); i++) { 107 for(int i = 0; i < (int)d.count(); i++) {
100 if(d[i] != "." && d[i] != "..") 108 if(d[i] != "." && d[i] != "..")
101 dirs.append(dir + d[i] + QDir::separator() + builtin_regex); 109 dirs.append(dir + d[i] + QDir::separator() + builtin_regex);
102 } 110 }
103 } 111 }
104 regex = builtin_regex; 112 regex = builtin_regex;
105 } else { 113 } else {
106 QString file = (*pd); 114 QString file = (*pd);
107 int s = file.findRev(Option::dir_sep); 115 int s = file.findRev(Option::dir_sep);
108 if(s != -1) 116 if(s != -1)
@@ -119,54 +127,53 @@ ProjectGenerator::init()
119 int s = regex.findRev(Option::dir_sep); 127 int s = regex.findRev(Option::dir_sep);
120 if(s != -1) { 128 if(s != -1) {
121 dir = regex.left(s+1); 129 dir = regex.left(s+1);
122 regex = regex.right(regex.length() - (s+1)); 130 regex = regex.right(regex.length() - (s+1));
123 } 131 }
124 if(Option::projfile::do_recursive) { 132 if(Option::projfile::do_recursive) {
125 QDir d(dir); 133 QDir d(dir);
126 d.setFilter(QDir::Dirs); 134 d.setFilter(QDir::Dirs);
127 for(int i = 0; i < (int)d.count(); i++) { 135 for(int i = 0; i < (int)d.count(); i++) {
128 if(d[i] != "." && d[i] != "..") 136 if(d[i] != "." && d[i] != "..")
129 dirs.append(dir + d[i] + QDir::separator() + regex); 137 dirs.append(dir + d[i] + QDir::separator() + regex);
130 } 138 }
131 } 139 }
132 QDir d(dir, regex); 140 QDir d(dir, regex);
133 for(int i = 0; i < (int)d.count(); i++) { 141 for(int i = 0; i < (int)d.count(); i++) {
134 QString file = dir + d[i]; 142 QString file = dir + d[i];
135 if (addFile(file)) { 143 if (addFile(file)) {
136 add_depend = TRUE; 144 add_depend = TRUE;
137 file_count++; 145 file_count++;
138 } 146 }
139 } 147 }
140 } 148 }
141 if(add_depend && !dir.isEmpty() && !v["DEPENDPATH"].contains(dir)) { 149 if(add_depend && !dir.isEmpty() && !v["DEPENDPATH"].contains(dir)) {
142 QFileInfo fi(dir); 150 QFileInfo fi(dir);
143 if(fi.absFilePath() != QDir::currentDirPath()) { 151 if(fi.absFilePath() != QDir::currentDirPath())
144 v["DEPENDPATH"] += fileFixify(dir); 152 v["DEPENDPATH"] += fileFixify(dir);
145 } 153 }
146 } 154 }
147 } 155 }
148 }
149 if(!file_count) { //shall we try a subdir? 156 if(!file_count) { //shall we try a subdir?
150 QStringList dirs = Option::projfile::project_dirs; 157 QStringList dirs = Option::projfile::project_dirs;
151 if(Option::projfile::do_pwd) 158 if(Option::projfile::do_pwd)
152 dirs.prepend("."); 159 dirs.prepend(".");
153 for(QStringList::Iterator pd = dirs.begin(); pd != dirs.end(); pd++) { 160 for(QStringList::Iterator pd = dirs.begin(); pd != dirs.end(); pd++) {
154 if(QFile::exists((*pd))) { 161 if(QFile::exists((*pd))) {
155 QString newdir = (*pd); 162 QString newdir = (*pd);
156 QFileInfo fi(newdir); 163 QFileInfo fi(newdir);
157 if(fi.isDir()) { 164 if(fi.isDir()) {
158 newdir = fileFixify(newdir); 165 newdir = fileFixify(newdir);
159 QStringList &subdirs = v["SUBDIRS"]; 166 QStringList &subdirs = v["SUBDIRS"];
160 if(QFile::exists(fi.filePath() + QDir::separator() + fi.fileName() + ".pro") && 167 if(QFile::exists(fi.filePath() + QDir::separator() + fi.fileName() + ".pro") &&
161 !subdirs.contains(newdir)) { 168 !subdirs.contains(newdir)) {
162 subdirs.append(newdir); 169 subdirs.append(newdir);
163 } else { 170 } else {
164 QDir d(newdir, "*.pro"); 171 QDir d(newdir, "*.pro");
165 d.setFilter(QDir::Files); 172 d.setFilter(QDir::Files);
166 for(int i = 0; i < (int)d.count(); i++) { 173 for(int i = 0; i < (int)d.count(); i++) {
167 QString nd = newdir + QDir::separator() + d[i]; 174 QString nd = newdir + QDir::separator() + d[i];
168 fileFixify(nd); 175 fileFixify(nd);
169 if(d[i] != "." && d[i] != ".." && !subdirs.contains(nd)) { 176 if(d[i] != "." && d[i] != ".." && !subdirs.contains(nd)) {
170 if(newdir + d[i] != Option::output_dir + Option::output.name()) 177 if(newdir + d[i] != Option::output_dir + Option::output.name())
171 subdirs.append(nd); 178 subdirs.append(nd);
172 } 179 }
@@ -220,72 +227,81 @@ ProjectGenerator::init()
220 } 227 }
221 v["TEMPLATE_ASSIGN"] = "subdirs"; 228 v["TEMPLATE_ASSIGN"] = "subdirs";
222 return; 229 return;
223 } 230 }
224 231
225 QPtrList<MakefileDependDir> deplist; 232 QPtrList<MakefileDependDir> deplist;
226 deplist.setAutoDelete(TRUE); 233 deplist.setAutoDelete(TRUE);
227 { 234 {
228 QStringList &d = v["DEPENDPATH"]; 235 QStringList &d = v["DEPENDPATH"];
229 for(QStringList::Iterator it = d.begin(); it != d.end(); ++it) { 236 for(QStringList::Iterator it = d.begin(); it != d.end(); ++it) {
230 QString r = (*it), l = Option::fixPathToLocalOS((*it)); 237 QString r = (*it), l = Option::fixPathToLocalOS((*it));
231 deplist.append(new MakefileDependDir(r, l)); 238 deplist.append(new MakefileDependDir(r, l));
232 } 239 }
233 } 240 }
234 QStringList &h = v["HEADERS"]; 241 QStringList &h = v["HEADERS"];
235 bool no_qt_files = TRUE; 242 bool no_qt_files = TRUE;
236 QString srcs[] = { "SOURCES", "YACCSOURCES", "LEXSOURCES", "INTERFACES", QString::null }; 243 QString srcs[] = { "SOURCES", "YACCSOURCES", "LEXSOURCES", "INTERFACES", QString::null };
237 for(int i = 0; !srcs[i].isNull(); i++) { 244 for(int i = 0; !srcs[i].isNull(); i++) {
238 QStringList &l = v[srcs[i]]; 245 QStringList &l = v[srcs[i]];
239 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { 246 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) {
240 if(generateDependencies(deplist, (*val_it), TRUE)) { 247 if(generateDependencies(deplist, (*val_it), TRUE)) {
241 QStringList &tmp = findDependencies((*val_it)); 248 QStringList &tmp = findDependencies((*val_it));
242 if(!tmp.isEmpty()) { 249 if(!tmp.isEmpty()) {
243 for(QStringList::Iterator dep_it = tmp.begin(); dep_it != tmp.end(); ++dep_it) { 250 for(QStringList::Iterator dep_it = tmp.begin(); dep_it != tmp.end(); ++dep_it) {
244 QString file_no_path = (*dep_it).right( 251 QString file_dir = (*dep_it).section(Option::dir_sep, 0, -2),
245 (*dep_it).length() - ((*dep_it).findRev(Option::dir_sep)+1)); 252 file_no_path = (*dep_it).section(Option::dir_sep, -1);
253 if(!file_dir.isEmpty()) {
254 for(MakefileDependDir *mdd = deplist.first(); mdd; mdd = deplist.next()) {
255 if(mdd->local_dir == file_dir && !v["INCLUDEPATH"].contains(mdd->real_dir))
256 v["INCLUDEPATH"] += mdd->real_dir;
257 }
258 }
246 if(no_qt_files && file_no_path.find(QRegExp("^q[a-z_0-9].h$")) != -1) 259 if(no_qt_files && file_no_path.find(QRegExp("^q[a-z_0-9].h$")) != -1)
247 no_qt_files = FALSE; 260 no_qt_files = FALSE;
248 QString h_ext; 261 QString h_ext;
249 for(QStringList::Iterator hit = Option::h_ext.begin(); hit != Option::h_ext.end(); ++hit) { 262 for(QStringList::Iterator hit = Option::h_ext.begin();
263 hit != Option::h_ext.end(); ++hit) {
250 if((*dep_it).endsWith((*hit))) { 264 if((*dep_it).endsWith((*hit))) {
251 h_ext = (*hit); 265 h_ext = (*hit);
252 break; 266 break;
253 } 267 }
254 } 268 }
255 if(!h_ext.isEmpty()) { 269 if(!h_ext.isEmpty()) {
256 if((*dep_it).left(1).lower() == "q") { 270 if((*dep_it).left(1).lower() == "q") {
257 QString qhdr = (*dep_it).lower(); 271 QString qhdr = (*dep_it).lower();
258 if(file_no_path == "qthread.h") 272 if(file_no_path == "qthread.h")
259 addConfig("thread"); 273 addConfig("thread");
260 } 274 }
261 for(QStringList::Iterator cppit = Option::cpp_ext.begin(); 275 for(QStringList::Iterator cppit = Option::cpp_ext.begin();
262 cppit != Option::cpp_ext.end(); ++cppit) { 276 cppit != Option::cpp_ext.end(); ++cppit) {
263 QString src((*dep_it).left((*dep_it).length() - h_ext.length()) + (*cppit)); 277 QString src((*dep_it).left((*dep_it).length() - h_ext.length()) +
278 (*cppit));
264 if(QFile::exists(src)) { 279 if(QFile::exists(src)) {
265 bool exists = FALSE; 280 bool exists = FALSE;
266 QStringList &srcl = v["SOURCES"]; 281 QStringList &srcl = v["SOURCES"];
267 for(QStringList::Iterator src_it = srcl.begin(); src_it != srcl.end(); ++src_it) { 282 for(QStringList::Iterator src_it = srcl.begin();
283 src_it != srcl.end(); ++src_it) {
268 if((*src_it).lower() == src.lower()) { 284 if((*src_it).lower() == src.lower()) {
269 exists = TRUE; 285 exists = TRUE;
270 break; 286 break;
271 } 287 }
272 } 288 }
273 if(!exists) 289 if(!exists)
274 srcl.append(src); 290 srcl.append(src);
275 } 291 }
276 } 292 }
277 } else if((*dep_it).endsWith(Option::lex_ext) && 293 } else if((*dep_it).endsWith(Option::lex_ext) &&
278 file_no_path.startsWith(Option::lex_mod)) { 294 file_no_path.startsWith(Option::lex_mod)) {
279 addConfig("lex_included"); 295 addConfig("lex_included");
280 } 296 }
281 if(!h.contains((*dep_it))) { 297 if(!h.contains((*dep_it))) {
282 if(generateMocList((*dep_it)) && !findMocDestination((*dep_it)).isEmpty()) 298 if(generateMocList((*dep_it)) && !findMocDestination((*dep_it)).isEmpty())
283 h += (*dep_it); 299 h += (*dep_it);
284 } 300 }
285 } 301 }
286 } 302 }
287 } 303 }
288 } 304 }
289 } 305 }
290 if(h.isEmpty()) 306 if(h.isEmpty())
291 addConfig("moc", FALSE); 307 addConfig("moc", FALSE);
@@ -316,56 +332,58 @@ ProjectGenerator::init()
316 ++val_it; 332 ++val_it;
317 } 333 }
318 } 334 }
319 } 335 }
320} 336}
321 337
322 338
323bool 339bool
324ProjectGenerator::writeMakefile(QTextStream &t) 340ProjectGenerator::writeMakefile(QTextStream &t)
325{ 341{
326 t << "######################################################################" << endl; 342 t << "######################################################################" << endl;
327 t << "# Automatically generated by qmake (" << qmake_version() << ") " << QDateTime::currentDateTime().toString() << endl; 343 t << "# Automatically generated by qmake (" << qmake_version() << ") " << QDateTime::currentDateTime().toString() << endl;
328 t << "######################################################################" << endl << endl; 344 t << "######################################################################" << endl << endl;
329 QStringList::Iterator it; 345 QStringList::Iterator it;
330 for(it = Option::before_user_vars.begin(); it != Option::before_user_vars.end(); ++it) 346 for(it = Option::before_user_vars.begin(); it != Option::before_user_vars.end(); ++it)
331 t << (*it) << endl; 347 t << (*it) << endl;
332 t << getWritableVar("TEMPLATE_ASSIGN", FALSE); 348 t << getWritableVar("TEMPLATE_ASSIGN", FALSE);
333 if(project->first("TEMPLATE_ASSIGN") == "subdirs") { 349 if(project->first("TEMPLATE_ASSIGN") == "subdirs") {
334 t << endl << "# Directories" << "\n" 350 t << endl << "# Directories" << "\n"
335 << getWritableVar("SUBDIRS"); 351 << getWritableVar("SUBDIRS");
336 } else { 352 } else {
337 t << getWritableVar("TARGET") 353 t << getWritableVar("TARGET")
338 << getWritableVar("CONFIG", FALSE) 354 << getWritableVar("CONFIG", FALSE)
339 << getWritableVar("CONFIG_REMOVE", FALSE) 355 << getWritableVar("CONFIG_REMOVE", FALSE)
340 << getWritableVar("DEPENDPATH") << endl; 356 << getWritableVar("DEPENDPATH")
357 << getWritableVar("INCLUDEPATH") << endl;
341 358
342 t << "# Input" << "\n"; 359 t << "# Input" << "\n";
343 t << getWritableVar("HEADERS") 360 t << getWritableVar("HEADERS")
344 << getWritableVar("INTERFACES") 361 << getWritableVar("INTERFACES")
345 << getWritableVar("LEXSOURCES") 362 << getWritableVar("LEXSOURCES")
346 << getWritableVar("YACCSOURCES") 363 << getWritableVar("YACCSOURCES")
347 << getWritableVar("SOURCES"); 364 << getWritableVar("SOURCES")
365 << getWritableVar("TRANSLATIONS");
348 } 366 }
349 for(it = Option::after_user_vars.begin(); it != Option::after_user_vars.end(); ++it) 367 for(it = Option::after_user_vars.begin(); it != Option::after_user_vars.end(); ++it)
350 t << (*it) << endl; 368 t << (*it) << endl;
351 return TRUE; 369 return TRUE;
352} 370}
353 371
354bool 372bool
355ProjectGenerator::addConfig(const QString &cfg, bool add) 373ProjectGenerator::addConfig(const QString &cfg, bool add)
356{ 374{
357 QString where = "CONFIG"; 375 QString where = "CONFIG";
358 if(!add) 376 if(!add)
359 where = "CONFIG_REMOVE"; 377 where = "CONFIG_REMOVE";
360 if(!project->variables()[where].contains(cfg)) { 378 if(!project->variables()[where].contains(cfg)) {
361 project->variables()[where] += cfg; 379 project->variables()[where] += cfg;
362 return TRUE; 380 return TRUE;
363 } 381 }
364 return FALSE; 382 return FALSE;
365} 383}
366 384
367 385
368bool 386bool
369ProjectGenerator::addFile(QString file) 387ProjectGenerator::addFile(QString file)
370{ 388{
371 file = fileFixify(file, QDir::currentDirPath()); 389 file = fileFixify(file, QDir::currentDirPath());
@@ -382,48 +400,50 @@ ProjectGenerator::addFile(QString file)
382 if(QFile::exists(file.left(file.length() - (*cppit).length()) + Option::ui_ext)) 400 if(QFile::exists(file.left(file.length() - (*cppit).length()) + Option::ui_ext))
383 return FALSE; 401 return FALSE;
384 else 402 else
385 where = "SOURCES"; 403 where = "SOURCES";
386 break; 404 break;
387 } 405 }
388 } 406 }
389 if(where.isEmpty()) { 407 if(where.isEmpty()) {
390 for(QStringList::Iterator hit = Option::h_ext.begin(); hit != Option::h_ext.end(); ++hit) { 408 for(QStringList::Iterator hit = Option::h_ext.begin(); hit != Option::h_ext.end(); ++hit) {
391 if(file.endsWith((*hit))) { 409 if(file.endsWith((*hit))) {
392 where = "HEADERS"; 410 where = "HEADERS";
393 break; 411 break;
394 } 412 }
395 } 413 }
396 } 414 }
397 if(where.isEmpty()) { 415 if(where.isEmpty()) {
398 if(file.endsWith(Option::ui_ext)) 416 if(file.endsWith(Option::ui_ext))
399 where = "INTERFACES"; 417 where = "INTERFACES";
400 else if(file.endsWith(".c")) 418 else if(file.endsWith(".c"))
401 where = "SOURCES"; 419 where = "SOURCES";
402 else if(file.endsWith(Option::lex_ext)) 420 else if(file.endsWith(Option::lex_ext))
403 where = "LEXSOURCES"; 421 where = "LEXSOURCES";
404 else if(file.endsWith(Option::yacc_ext)) 422 else if(file.endsWith(Option::yacc_ext))
405 where = "YACCSOURCES"; 423 where = "YACCSOURCES";
424 else if(file.endsWith(".ts"))
425 where = "TRANSLATIONS";
406 } 426 }
407 427
408 QString newfile = fileFixify(file); 428 QString newfile = fileFixify(file);
409 if(!where.isEmpty() && !project->variables()[where].contains(file)) { 429 if(!where.isEmpty() && !project->variables()[where].contains(file)) {
410 project->variables()[where] += newfile; 430 project->variables()[where] += newfile;
411 return TRUE; 431 return TRUE;
412 } 432 }
413 return FALSE; 433 return FALSE;
414} 434}
415 435
416 436
417QString 437QString
418ProjectGenerator::getWritableVar(const QString &v, bool /*fixPath*/) 438ProjectGenerator::getWritableVar(const QString &v, bool /*fixPath*/)
419{ 439{
420 QStringList &vals = project->variables()[v]; 440 QStringList &vals = project->variables()[v];
421 if(vals.isEmpty()) 441 if(vals.isEmpty())
422 return ""; 442 return "";
423 443
424 QString ret; 444 QString ret;
425 if(v.endsWith("_REMOVE")) 445 if(v.endsWith("_REMOVE"))
426 ret = v.left(v.length() - 7) + " -= "; 446 ret = v.left(v.length() - 7) + " -= ";
427 else if(v.endsWith("_ASSIGN")) 447 else if(v.endsWith("_ASSIGN"))
428 ret = v.left(v.length() - 7) + " = "; 448 ret = v.left(v.length() - 7) + " = ";
429 else 449 else
diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp
index 7df95b2..e274481 100644
--- a/qmake/generators/unix/unixmake.cpp
+++ b/qmake/generators/unix/unixmake.cpp
@@ -1,32 +1,32 @@
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-2002 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2003 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
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this 21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software. 23** with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
@@ -51,53 +51,52 @@ UnixMakefileGenerator::init()
51 return; 51 return;
52 init_flag = TRUE; 52 init_flag = TRUE;
53 53
54 if(!project->isEmpty("QMAKE_FAILED_REQUIREMENTS")) /* no point */ 54 if(!project->isEmpty("QMAKE_FAILED_REQUIREMENTS")) /* no point */
55 return; 55 return;
56 56
57 QStringList &configs = project->variables()["CONFIG"]; 57 QStringList &configs = project->variables()["CONFIG"];
58 /* this should probably not be here, but I'm using it to wrap the .t files */ 58 /* this should probably not be here, but I'm using it to wrap the .t files */
59 if(project->first("TEMPLATE") == "app") 59 if(project->first("TEMPLATE") == "app")
60 project->variables()["QMAKE_APP_FLAG"].append("1"); 60 project->variables()["QMAKE_APP_FLAG"].append("1");
61 else if(project->first("TEMPLATE") == "lib") 61 else if(project->first("TEMPLATE") == "lib")
62 project->variables()["QMAKE_LIB_FLAG"].append("1"); 62 project->variables()["QMAKE_LIB_FLAG"].append("1");
63 else if(project->first("TEMPLATE") == "subdirs") { 63 else if(project->first("TEMPLATE") == "subdirs") {
64 MakefileGenerator::init(); 64 MakefileGenerator::init();
65 if(project->isEmpty("MAKEFILE")) 65 if(project->isEmpty("MAKEFILE"))
66 project->variables()["MAKEFILE"].append("Makefile"); 66 project->variables()["MAKEFILE"].append("Makefile");
67 if(project->isEmpty("QMAKE")) 67 if(project->isEmpty("QMAKE"))
68 project->variables()["QMAKE"].append("qmake"); 68 project->variables()["QMAKE"].append("qmake");
69 if(project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].findIndex("qmake_all") == -1) 69 if(project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].findIndex("qmake_all") == -1)
70 project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].append("qmake_all"); 70 project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].append("qmake_all");
71 return; /* subdirs is done */ 71 return; /* subdirs is done */
72 } 72 }
73 73
74 if( project->isEmpty("QMAKE_EXTENSION_SHLIB") ) { 74 if( project->isEmpty("QMAKE_EXTENSION_SHLIB") ) {
75 QString os = project->variables()["QMAKESPEC"].first().section( '-', 0, 0 ); 75 if ( project->isEmpty("QMAKE_CYGWIN_SHLIB") ) {
76 if ( os == "cygwin" ) {
77 project->variables()["QMAKE_EXTENSION_SHLIB"].append( "dll" );
78 } else {
79 project->variables()["QMAKE_EXTENSION_SHLIB"].append( "so" ); 76 project->variables()["QMAKE_EXTENSION_SHLIB"].append( "so" );
77 } else {
78 project->variables()["QMAKE_EXTENSION_SHLIB"].append( "dll" );
80 } 79 }
81 } 80 }
82 if( project->isEmpty("QMAKE_COPY_FILE") ) 81 if( project->isEmpty("QMAKE_COPY_FILE") )
83 project->variables()["QMAKE_COPY_FILE"].append( "$(COPY) -p" ); 82 project->variables()["QMAKE_COPY_FILE"].append( "$(COPY) -p" );
84 if( project->isEmpty("QMAKE_COPY_DIR") ) 83 if( project->isEmpty("QMAKE_COPY_DIR") )
85 project->variables()["QMAKE_COPY_DIR"].append( "$(COPY) -pR" ); 84 project->variables()["QMAKE_COPY_DIR"].append( "$(COPY) -pR" );
86 //If the TARGET looks like a path split it into DESTDIR and the resulting TARGET 85 //If the TARGET looks like a path split it into DESTDIR and the resulting TARGET
87 if(!project->isEmpty("TARGET")) { 86 if(!project->isEmpty("TARGET")) {
88 QString targ = project->first("TARGET"); 87 QString targ = project->first("TARGET");
89 int slsh = QMAX(targ.findRev('/'), targ.findRev(Option::dir_sep)); 88 int slsh = QMAX(targ.findRev('/'), targ.findRev(Option::dir_sep));
90 if(slsh != -1) { 89 if(slsh != -1) {
91 if(project->isEmpty("DESTDIR")) 90 if(project->isEmpty("DESTDIR"))
92 project->values("DESTDIR").append(""); 91 project->values("DESTDIR").append("");
93 else if(project->first("DESTDIR").right(1) != Option::dir_sep) 92 else if(project->first("DESTDIR").right(1) != Option::dir_sep)
94 project->variables()["DESTDIR"] = project->first("DESTDIR") + Option::dir_sep; 93 project->variables()["DESTDIR"] = project->first("DESTDIR") + Option::dir_sep;
95 project->variables()["DESTDIR"] = project->first("DESTDIR") + targ.left(slsh+1); 94 project->variables()["DESTDIR"] = project->first("DESTDIR") + targ.left(slsh+1);
96 project->variables()["TARGET"] = targ.mid(slsh+1); 95 project->variables()["TARGET"] = targ.mid(slsh+1);
97 } 96 }
98 } 97 }
99 98
100 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"]; 99 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"];
101 100
102 bool is_qt = (project->first("TARGET") == "qt" || project->first("TARGET") == "qte" || 101 bool is_qt = (project->first("TARGET") == "qt" || project->first("TARGET") == "qte" ||
103 project->first("TARGET") == "qt-mt" || project->first("TARGET") == "qte-mt"); 102 project->first("TARGET") == "qt-mt" || project->first("TARGET") == "qte-mt");
@@ -155,82 +154,82 @@ UnixMakefileGenerator::init()
155 configs.append("x11inc"); 154 configs.append("x11inc");
156 } 155 }
157 if ( project->isActiveConfig("qt") ) { 156 if ( project->isActiveConfig("qt") ) {
158 if ( project->isActiveConfig("accessibility" ) ) 157 if ( project->isActiveConfig("accessibility" ) )
159 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT"); 158 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT");
160 if ( project->isActiveConfig("tablet") ) 159 if ( project->isActiveConfig("tablet") )
161 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT"); 160 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT");
162 if(configs.findIndex("moc")) configs.append("moc"); 161 if(configs.findIndex("moc")) configs.append("moc");
163 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QT"]; 162 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QT"];
164 if ( !project->isActiveConfig("debug") ) 163 if ( !project->isActiveConfig("debug") )
165 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG"); 164 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG");
166 if ( !is_qt ) { 165 if ( !is_qt ) {
167 if ( !project->isEmpty("QMAKE_LIBDIR_QT") ) { 166 if ( !project->isEmpty("QMAKE_LIBDIR_QT") ) {
168 if ( !project->isEmpty("QMAKE_RPATH") ) 167 if ( !project->isEmpty("QMAKE_RPATH") )
169 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_QT", " " + var("QMAKE_RPATH"), 168 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_QT", " " + var("QMAKE_RPATH"),
170 " " + var("QMAKE_RPATH"), ""); 169 " " + var("QMAKE_RPATH"), "");
171 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_QT", "-L", " -L", ""); 170 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_QT", "-L", " -L", "");
172 } 171 }
173 if (project->isActiveConfig("thread") && !project->isEmpty("QMAKE_LIBS_QT_THREAD")) 172 if (project->isActiveConfig("thread") && !project->isEmpty("QMAKE_LIBS_QT_THREAD"))
174 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; 173 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"];
175 else 174 else
176 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; 175 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"];
177 } 176 }
178 } 177 }
179 if ( project->isActiveConfig("thread") ) {
180 if(project->isActiveConfig("qt"))
181 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT");
182 if ( !project->isEmpty("QMAKE_CFLAGS_THREAD"))
183 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_THREAD"];
184 if( !project->isEmpty("QMAKE_CXXFLAGS_THREAD"))
185 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_THREAD"];
186 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_THREAD"];
187 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_THREAD"];
188 if(!project->isEmpty("QMAKE_LFLAGS_THREAD"))
189 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_THREAD"];
190 }
191 if ( project->isActiveConfig("opengl") ) { 178 if ( project->isActiveConfig("opengl") ) {
192 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_OPENGL"]; 179 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_OPENGL"];
193 if(!project->isEmpty("QMAKE_LIBDIR_OPENGL")) 180 if(!project->isEmpty("QMAKE_LIBDIR_OPENGL"))
194 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_OPENGL", "-L", " -L", ""); 181 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_OPENGL", "-L", " -L", "");
195 if ( is_qt ) 182 if ( is_qt )
196 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL_QT"]; 183 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL_QT"];
197 else 184 else
198 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; 185 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"];
199 } 186 }
200 if(project->isActiveConfig("global_init_link_order")) 187 if(project->isActiveConfig("global_init_link_order"))
201 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; 188 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
202 if ( project->isActiveConfig("x11sm") )
203 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_X11SM"];
204 if ( project->isActiveConfig("dylib") )
205 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_DYNLOAD"];
206 if ( project->isActiveConfig("x11inc") ) 189 if ( project->isActiveConfig("x11inc") )
207 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_X11"]; 190 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_X11"];
208 if ( project->isActiveConfig("x11lib") ) { 191 if ( project->isActiveConfig("x11lib") ) {
209 if(!project->isEmpty("QMAKE_LIBDIR_X11")) 192 if(!project->isEmpty("QMAKE_LIBDIR_X11"))
210 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_X11", "-L", " -L", ""); 193 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_X11", "-L", " -L", "");
211 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_X11"]; 194 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_X11"];
212 } 195 }
196 if ( project->isActiveConfig("x11sm") )
197 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_X11SM"];
198 if ( project->isActiveConfig("dylib") )
199 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_DYNLOAD"];
200 if ( project->isActiveConfig("thread") ) {
201 if(project->isActiveConfig("qt"))
202 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT");
203 if ( !project->isEmpty("QMAKE_CFLAGS_THREAD"))
204 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_THREAD"];
205 if( !project->isEmpty("QMAKE_CXXFLAGS_THREAD"))
206 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_THREAD"];
207 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_THREAD"];
208 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_THREAD"];
209 if(!project->isEmpty("QMAKE_LFLAGS_THREAD"))
210 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_THREAD"];
211 }
213 if ( project->isActiveConfig("moc") ) 212 if ( project->isActiveConfig("moc") )
214 setMocAware(TRUE); 213 setMocAware(TRUE);
215 if ( project->isEmpty("QMAKE_RUN_CC") ) 214 if ( project->isEmpty("QMAKE_RUN_CC") )
216 project->variables()["QMAKE_RUN_CC"].append("$(CC) -c $(CFLAGS) $(INCPATH) -o $obj $src"); 215 project->variables()["QMAKE_RUN_CC"].append("$(CC) -c $(CFLAGS) $(INCPATH) -o $obj $src");
217 if ( project->isEmpty("QMAKE_RUN_CC_IMP") ) 216 if ( project->isEmpty("QMAKE_RUN_CC_IMP") )
218 project->variables()["QMAKE_RUN_CC_IMP"].append("$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<"); 217 project->variables()["QMAKE_RUN_CC_IMP"].append("$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<");
219 if ( project->isEmpty("QMAKE_RUN_CXX") ) 218 if ( project->isEmpty("QMAKE_RUN_CXX") )
220 project->variables()["QMAKE_RUN_CXX"].append("$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $obj $src"); 219 project->variables()["QMAKE_RUN_CXX"].append("$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $obj $src");
221 if ( project->isEmpty("QMAKE_RUN_CXX_IMP") ) 220 if ( project->isEmpty("QMAKE_RUN_CXX_IMP") )
222 project->variables()["QMAKE_RUN_CXX_IMP"].append("$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<"); 221 project->variables()["QMAKE_RUN_CXX_IMP"].append("$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<");
223 project->variables()["QMAKE_FILETAGS"] += QStringList::split("HEADERS SOURCES TARGET DESTDIR", " "); 222 project->variables()["QMAKE_FILETAGS"] += QStringList::split("HEADERS SOURCES TARGET DESTDIR", " ");
224 if ( !project->isEmpty("PRECOMPH") ) { 223 if ( !project->isEmpty("PRECOMPH") ) {
225 initOutPaths(); // Need to fix MOC_DIR since we do this before init() 224 initOutPaths(); // Need to fix MOC_DIR since we do this before init()
226 QString allmoc = fileFixify(project->first("MOC_DIR") + "/allmoc.cpp", QDir::currentDirPath(), Option::output_dir); 225 QString allmoc = fileFixify(project->first("MOC_DIR") + "/allmoc.cpp", QDir::currentDirPath(), Option::output_dir);
227 project->variables()["SOURCES"].prepend(allmoc); 226 project->variables()["SOURCES"].prepend(allmoc);
228 project->variables()["HEADERS_ORIG"] = project->variables()["HEADERS"]; 227 project->variables()["HEADERS_ORIG"] = project->variables()["HEADERS"];
229 project->variables()["HEADERS"].clear(); 228 project->variables()["HEADERS"].clear();
230 } 229 }
231 if( project->isActiveConfig("GNUmake") && !project->isEmpty("QMAKE_CFLAGS_DEPS")) 230 if( project->isActiveConfig("GNUmake") && !project->isEmpty("QMAKE_CFLAGS_DEPS"))
232 include_deps = TRUE; //do not generate deps 231 include_deps = TRUE; //do not generate deps
233 232
234 MakefileGenerator::init(); 233 MakefileGenerator::init();
235 if ( project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) { 234 if ( project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) {
236 if(!project->isEmpty("QMAKE_APP_FLAG")) { 235 if(!project->isEmpty("QMAKE_APP_FLAG")) {
@@ -336,48 +335,132 @@ UnixMakefileGenerator::uniqueSetLFlags(const QStringList &list1, QStringList &li
336 } 335 }
337 } 336 }
338 } else { 337 } else {
339 unique = (list2.findIndex((*it)) == -1); 338 unique = (list2.findIndex((*it)) == -1);
340 } 339 }
341 } else if(QFile::exists((*it))) { 340 } else if(QFile::exists((*it))) {
342 unique = (list2.findIndex((*it)) == -1); 341 unique = (list2.findIndex((*it)) == -1);
343 } 342 }
344 if(unique) 343 if(unique)
345 ret.append((*it)); 344 ret.append((*it));
346 } 345 }
347 return ret; 346 return ret;
348} 347}
349 348
350 349
351void 350void
352UnixMakefileGenerator::processPrlVariable(const QString &var, const QStringList &l) 351UnixMakefileGenerator::processPrlVariable(const QString &var, const QStringList &l)
353{ 352{
354 if(var == "QMAKE_PRL_LIBS") 353 if(var == "QMAKE_PRL_LIBS")
355 project->variables()["QMAKE_CURRENT_PRL_LIBS"] += uniqueSetLFlags(l, project->variables()["QMAKE_LIBS"]); 354 project->variables()["QMAKE_CURRENT_PRL_LIBS"] += uniqueSetLFlags(l, project->variables()["QMAKE_LIBS"]);
356 else 355 else
357 MakefileGenerator::processPrlVariable(var, l); 356 MakefileGenerator::processPrlVariable(var, l);
358} 357}
359 358
359bool
360UnixMakefileGenerator::findLibraries()
361{
362 QPtrList<MakefileDependDir> libdirs;
363 libdirs.setAutoDelete(TRUE);
364 const QString lflags[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_LIBS", QString::null };
365 for(int i = 0; !lflags[i].isNull(); i++) {
366 QStringList &l = project->variables()[lflags[i]];
367 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
368 QString stub, dir, extn, opt = (*it).stripWhiteSpace();
369 if(opt.startsWith("-")) {
370 if(opt.startsWith("-L")) {
371 QString r = opt.right(opt.length() - 2), l = r;
372 fixEnvVariables(l);
373 libdirs.append(new MakefileDependDir(r.replace("\"",""),
374 l.replace("\"","")));
375 } else if(opt.startsWith("-l")) {
376 stub = opt.mid(2);
377 } else if(project->isActiveConfig("macx") && opt.startsWith("-framework")) {
378 if(opt.length() > 11) {
379 opt = opt.mid(11);
380 } else {
381 ++it;
382 opt = (*it);
383 }
384 extn = "";
385 dir = "/System/Library/Frameworks/" + opt + ".framework/";
386 stub = opt;
387 }
388 } else {
389 extn = dir = "";
390 stub = opt;
391 int slsh = opt.findRev(Option::dir_sep);
392 if(slsh != -1) {
393 dir = opt.left(slsh);
394 stub = opt.mid(slsh+1);
395 }
396 QRegExp stub_reg("^.*lib(" + stub + "[^./=]*)\\.(.*)$");
397 if(stub_reg.exactMatch(stub)) {
398 stub = stub_reg.cap(1);
399 extn = stub_reg.cap(2);
400 }
401 }
402 if(!stub.isEmpty()) {
403 const QString modifs[] = { "-mt", QString::null };
404 for(int modif = 0; !modifs[modif].isNull(); modif++) {
405 bool found = FALSE;
406 QStringList extens;
407 if(!extn.isNull())
408 extens << extn;
409 else
410 extens << project->variables()["QMAKE_EXTENSION_SHLIB"].first() << "a";
411 for(QStringList::Iterator extit = extens.begin(); extit != extens.end(); ++extit) {
412 if(dir.isNull()) {
413 QString lib_stub;
414 for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) {
415 if(QFile::exists(mdd->local_dir + Option::dir_sep + "lib" + stub +
416 modifs[modif] + "." + (*extit))) {
417 lib_stub = stub + modifs[modif];
418 break;
419 }
420 }
421 if(!lib_stub.isNull()) {
422 (*it) = "-l" + lib_stub;
423 found = TRUE;
424 break;
425 }
426 } else {
427 if(QFile::exists("lib" + stub + modifs[modif] + "." + (*extit))) {
428 (*it) = "lib" + stub + modifs[modif] + "." + (*extit);
429 found = TRUE;
430 break;
431 }
432 }
433 }
434 if(found)
435 break;
436 }
437 }
438 }
439 }
440 return FALSE;
441}
442
360void 443void
361UnixMakefileGenerator::processPrlFiles() 444UnixMakefileGenerator::processPrlFiles()
362{ 445{
363 QDict<void> processed; 446 QDict<void> processed;
364 QPtrList<MakefileDependDir> libdirs; 447 QPtrList<MakefileDependDir> libdirs;
365 libdirs.setAutoDelete(TRUE); 448 libdirs.setAutoDelete(TRUE);
366 const QString lflags[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_LIBS", QString::null }; 449 const QString lflags[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_LIBS", QString::null };
367 for(int i = 0; !lflags[i].isNull(); i++) { 450 for(int i = 0; !lflags[i].isNull(); i++) {
368 for(bool ret = FALSE; TRUE; ret = FALSE) { 451 for(bool ret = FALSE; TRUE; ret = FALSE) {
369 QStringList l_out; 452 QStringList l_out;
370 QStringList &l = project->variables()[lflags[i]]; 453 QStringList &l = project->variables()[lflags[i]];
371 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 454 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
372 project->variables()["QMAKE_CURRENT_PRL_LIBS"].clear(); 455 project->variables()["QMAKE_CURRENT_PRL_LIBS"].clear();
373 QString opt = (*it).stripWhiteSpace();; 456 QString opt = (*it).stripWhiteSpace();;
374 if(opt.startsWith("-")) { 457 if(opt.startsWith("-")) {
375 if(opt.startsWith("-L")) { 458 if(opt.startsWith("-L")) {
376 QString r = opt.right(opt.length() - 2), l = r; 459 QString r = opt.right(opt.length() - 2), l = r;
377 fixEnvVariables(l); 460 fixEnvVariables(l);
378 libdirs.append(new MakefileDependDir(r.replace("\"",""), 461 libdirs.append(new MakefileDependDir(r.replace("\"",""),
379 l.replace("\"",""))); 462 l.replace("\"","")));
380 } else if(opt.startsWith("-l") && !processed[opt]) { 463 } else if(opt.startsWith("-l") && !processed[opt]) {
381 QString lib = opt.right(opt.length() - 2), prl; 464 QString lib = opt.right(opt.length() - 2), prl;
382 for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) { 465 for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) {
383 prl = mdd->local_dir + Option::dir_sep + "lib" + lib + Option::prl_ext; 466 prl = mdd->local_dir + Option::dir_sep + "lib" + lib + Option::prl_ext;
@@ -413,108 +496,109 @@ UnixMakefileGenerator::processPrlFiles()
413 if(!processed[opt] && processPrlFile(opt)) { 496 if(!processed[opt] && processPrlFile(opt)) {
414 processed.insert(opt, (void*)1); 497 processed.insert(opt, (void*)1);
415 ret = TRUE; 498 ret = TRUE;
416 } 499 }
417 if(!opt.isEmpty()) 500 if(!opt.isEmpty())
418 l_out.append(opt); 501 l_out.append(opt);
419 l_out += uniqueSetLFlags(project->variables()["QMAKE_CURRENT_PRL_LIBS"], l_out); 502 l_out += uniqueSetLFlags(project->variables()["QMAKE_CURRENT_PRL_LIBS"], l_out);
420 } 503 }
421 } 504 }
422 if(ret && l != l_out) 505 if(ret && l != l_out)
423 l = l_out; 506 l = l_out;
424 else 507 else
425 break; 508 break;
426 } 509 }
427 } 510 }
428} 511}
429 512
430QString 513QString
431UnixMakefileGenerator::defaultInstall(const QString &t) 514UnixMakefileGenerator::defaultInstall(const QString &t)
432{ 515{
433 if(t != "target" || project->first("TEMPLATE") == "subdirs") 516 if(t != "target" || project->first("TEMPLATE") == "subdirs")
434 return QString(); 517 return QString();
435 518
436 bool resource = FALSE; 519 bool resource = FALSE;
520 const QString root = "$(INSTALL_ROOT)";
437 QStringList &uninst = project->variables()[t + ".uninstall"]; 521 QStringList &uninst = project->variables()[t + ".uninstall"];
438 QString ret, destdir=fileFixify(project->first("DESTDIR")); 522 QString ret, destdir=project->first("DESTDIR");
439 QString targetdir = Option::fixPathToTargetOS(project->first("target.path"), FALSE); 523 QString targetdir = Option::fixPathToTargetOS(project->first("target.path"), FALSE);
440 if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep) 524 if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep)
441 destdir += Option::dir_sep; 525 destdir += Option::dir_sep;
442 targetdir = "$(INSTALL_ROOT)" + Option::fixPathToTargetOS(targetdir, FALSE); 526 targetdir = fileFixify(targetdir);
443 if(targetdir.right(1) != Option::dir_sep) 527 if(targetdir.right(1) != Option::dir_sep)
444 targetdir += Option::dir_sep; 528 targetdir += Option::dir_sep;
445 529
446 QStringList links; 530 QStringList links;
447 QString target="$(TARGET)"; 531 QString target="$(TARGET)";
448 if(project->first("TEMPLATE") == "app") { 532 if(project->first("TEMPLATE") == "app") {
449 target = "$(QMAKE_TARGET)"; 533 target = "$(QMAKE_TARGET)";
450 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) { 534 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) {
451 destdir += "../../../"; 535 destdir += "../../../";
452 target += ".app"; 536 target += ".app";
453 resource = TRUE; 537 resource = TRUE;
454 } 538 }
455 } else if(project->first("TEMPLATE") == "lib") { 539 } else if(project->first("TEMPLATE") == "lib") {
456 if(project->isActiveConfig("create_prl") && !project->isEmpty("QMAKE_INTERNAL_PRL_FILE")) { 540 if(project->isActiveConfig("create_prl") && !project->isEmpty("QMAKE_INTERNAL_PRL_FILE")) {
457 QString dst_prl = project->first("QMAKE_INTERNAL_PRL_FILE"); 541 QString dst_prl = project->first("QMAKE_INTERNAL_PRL_FILE");
458 int slsh = dst_prl.findRev('/'); 542 int slsh = dst_prl.findRev('/');
459 if(slsh != -1) 543 if(slsh != -1)
460 dst_prl = dst_prl.right(dst_prl.length() - slsh - 1); 544 dst_prl = dst_prl.right(dst_prl.length() - slsh - 1);
461 dst_prl = targetdir + dst_prl; 545 dst_prl = root + targetdir + dst_prl;
462 ret += "-$(COPY) " + project->first("QMAKE_INTERNAL_PRL_FILE") + " " + dst_prl; 546 ret += "-$(COPY) \"" + project->first("QMAKE_INTERNAL_PRL_FILE") + "\" \"" + dst_prl + "\"";
463 if(!uninst.isEmpty()) 547 if(!uninst.isEmpty())
464 uninst.append("\n\t"); 548 uninst.append("\n\t");
465 uninst.append("-$(DEL_FILE) \"" + dst_prl + "\""); 549 uninst.append("-$(DEL_FILE) \"" + dst_prl + "\"");
466 } 550 }
467 QString os = project->variables()["QMAKESPEC"].first().section( '-', 0, 0 ); 551 if ( project->isEmpty("QMAKE_CYGWIN_SHLIB") ) {
468 if ( os != "cygwin" ) {
469 if ( !project->isActiveConfig("staticlib") && !project->isActiveConfig("plugin") ) { 552 if ( !project->isActiveConfig("staticlib") && !project->isActiveConfig("plugin") ) {
470 if ( os == "hpux" ) { 553 if ( project->isEmpty("QMAKE_HPUX_SHLIB") ) {
471 links << "$(TARGET0)";
472 } else {
473 links << "$(TARGET0)" << "$(TARGET1)" << "$(TARGET2)"; 554 links << "$(TARGET0)" << "$(TARGET1)" << "$(TARGET2)";
555 } else {
556 links << "$(TARGET0)";
474 } 557 }
475 } 558 }
476 } 559 }
477 } 560 }
478 QString src_targ = target; 561 QString src_targ = target;
479 if(!destdir.isEmpty()) 562 if(!destdir.isEmpty())
480 src_targ = Option::fixPathToTargetOS(destdir + target, FALSE); 563 src_targ = Option::fixPathToTargetOS(destdir + target, FALSE);
481 QString dst_targ = fileFixify(targetdir + target); 564 QString dst_targ = root + fileFixify(targetdir + target);
482 if(!ret.isEmpty()) 565 if(!ret.isEmpty())
483 ret += "\n\t"; 566 ret += "\n\t";
484 ret += QString(resource ? "-$(COPY_DIR)" : "-$(COPY)") + " \"" + 567 ret += QString(resource ? "-$(COPY_DIR)" : "-$(COPY)") + " \"" +
485 src_targ + "\" \"" + dst_targ + "\""; 568 src_targ + "\" \"" + dst_targ + "\"";
486 if(!project->isEmpty("QMAKE_STRIP")) { 569 if(!project->isActiveConfig("debug") && !project->isEmpty("QMAKE_STRIP")) {
487 ret += "\n\t-" + var("QMAKE_STRIP"); 570 ret += "\n\t-" + var("QMAKE_STRIP");
571 if(!project->isEmpty("QMAKE_STRIPFLAGS_LIB") && project->first("TEMPLATE") == "lib")
572 ret += " " + var("QMAKE_STRIPFLAGS_LIB");
488 if(resource) 573 if(resource)
489 ret = " \"" + dst_targ + "/Contents/MacOS/$(QMAKE_TARGET)"; 574 ret = " \"" + dst_targ + "/Contents/MacOS/$(QMAKE_TARGET)\"";
490 else 575 else
491 ret += " \"" + dst_targ + "\""; 576 ret += " \"" + dst_targ + "\"";
492 } 577 }
493 if(!uninst.isEmpty()) 578 if(!uninst.isEmpty())
494 uninst.append("\n\t"); 579 uninst.append("\n\t");
495 if(resource) 580 if(resource)
496 uninst.append("-$(DEL_FILE) -r \"" + dst_targ + "\""); 581 uninst.append("-$(DEL_FILE) -r \"" + dst_targ + "\"");
497 else 582 else
498 uninst.append("-$(DEL_FILE) \"" + dst_targ + "\""); 583 uninst.append("-$(DEL_FILE) \"" + dst_targ + "\"");
499 if(!links.isEmpty()) { 584 if(!links.isEmpty()) {
500 for(QStringList::Iterator it = links.begin(); it != links.end(); it++) { 585 for(QStringList::Iterator it = links.begin(); it != links.end(); it++) {
501 if(Option::target_mode == Option::TARG_WIN_MODE || 586 if(Option::target_mode == Option::TARG_WIN_MODE ||
502 Option::target_mode == Option::TARG_MAC9_MODE) { 587 Option::target_mode == Option::TARG_MAC9_MODE) {
503 } else if(Option::target_mode == Option::TARG_UNIX_MODE || 588 } else if(Option::target_mode == Option::TARG_UNIX_MODE ||
504 Option::target_mode == Option::TARG_MACX_MODE) { 589 Option::target_mode == Option::TARG_MACX_MODE) {
505 QString link = Option::fixPathToTargetOS(destdir + (*it), FALSE); 590 QString link = Option::fixPathToTargetOS(destdir + (*it), FALSE);
506 int lslash = link.findRev(Option::dir_sep); 591 int lslash = link.findRev(Option::dir_sep);
507 if(lslash != -1) 592 if(lslash != -1)
508 link = link.right(link.length() - (lslash + 1)); 593 link = link.right(link.length() - (lslash + 1));
509 QString dst_link = fileFixify(targetdir + link); 594 QString dst_link = root + fileFixify(targetdir + link);
510 ret += "\n\t-$(SYMLINK) \"$(TARGET)\" \"" + dst_link + "\""; 595 ret += "\n\t-$(SYMLINK) \"$(TARGET)\" \"" + dst_link + "\"";
511 if(!uninst.isEmpty()) 596 if(!uninst.isEmpty())
512 uninst.append("\n\t"); 597 uninst.append("\n\t");
513 uninst.append("-$(DEL_FILE) \"" + dst_link + "\""); 598 uninst.append("-$(DEL_FILE) \"" + dst_link + "\"");
514 } 599 }
515 } 600 }
516 } 601 }
517 return ret; 602 return ret;
518} 603}
519 604
520
diff --git a/qmake/generators/unix/unixmake.h b/qmake/generators/unix/unixmake.h
index e889dcc..3d00214 100644
--- a/qmake/generators/unix/unixmake.h
+++ b/qmake/generators/unix/unixmake.h
@@ -34,38 +34,39 @@
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37#ifndef __UNIXMAKE_H__ 37#ifndef __UNIXMAKE_H__
38#define __UNIXMAKE_H__ 38#define __UNIXMAKE_H__
39 39
40#include "makefile.h" 40#include "makefile.h"
41 41
42class UnixMakefileGenerator : public MakefileGenerator 42class UnixMakefileGenerator : public MakefileGenerator
43{ 43{
44 bool init_flag, include_deps; 44 bool init_flag, include_deps;
45 bool writeMakefile(QTextStream &); 45 bool writeMakefile(QTextStream &);
46 QStringList uniqueSetLFlags(const QStringList &list1, QStringList &list2); 46 QStringList uniqueSetLFlags(const QStringList &list1, QStringList &list2);
47 47
48public: 48public:
49 UnixMakefileGenerator(QMakeProject *p); 49 UnixMakefileGenerator(QMakeProject *p);
50 ~UnixMakefileGenerator(); 50 ~UnixMakefileGenerator();
51 51
52protected: 52protected:
53 virtual bool doDepends() const { return !include_deps && MakefileGenerator::doDepends(); } 53 virtual bool doDepends() const { return !include_deps && MakefileGenerator::doDepends(); }
54 virtual QString defaultInstall(const QString &); 54 virtual QString defaultInstall(const QString &);
55 virtual void processPrlVariable(const QString &, const QStringList &); 55 virtual void processPrlVariable(const QString &, const QStringList &);
56 virtual void processPrlFiles(); 56 virtual void processPrlFiles();
57 57
58 virtual bool findLibraries();
58 virtual void init(); 59 virtual void init();
59 60
60 void writeMakeParts(QTextStream &); 61 void writeMakeParts(QTextStream &);
61 void writeSubdirs(QTextStream &, bool=TRUE); 62 void writeSubdirs(QTextStream &, bool=TRUE);
62 63
63private: 64private:
64 void init2(); 65 void init2();
65}; 66};
66 67
67inline UnixMakefileGenerator::~UnixMakefileGenerator() 68inline UnixMakefileGenerator::~UnixMakefileGenerator()
68{ } 69{ }
69 70
70 71
71#endif /* __UNIXMAKE_H__ */ 72#endif /* __UNIXMAKE_H__ */
diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp
index 9bb6f6b..7fbb9f4 100644
--- a/qmake/generators/unix/unixmake2.cpp
+++ b/qmake/generators/unix/unixmake2.cpp
@@ -60,104 +60,111 @@ UnixMakefileGenerator::writeMakefile(QTextStream &t)
60 writeMakeQmake(t); 60 writeMakeQmake(t);
61 return TRUE; 61 return TRUE;
62 } 62 }
63 63
64 if (project->variables()["TEMPLATE"].first() == "app" || 64 if (project->variables()["TEMPLATE"].first() == "app" ||
65 project->variables()["TEMPLATE"].first() == "lib") { 65 project->variables()["TEMPLATE"].first() == "lib") {
66 writeMakeParts(t); 66 writeMakeParts(t);
67 return MakefileGenerator::writeMakefile(t); 67 return MakefileGenerator::writeMakefile(t);
68 } else if(project->variables()["TEMPLATE"].first() == "subdirs") { 68 } else if(project->variables()["TEMPLATE"].first() == "subdirs") {
69 writeSubdirs(t); 69 writeSubdirs(t);
70 return TRUE; 70 return TRUE;
71 } 71 }
72 return FALSE; 72 return FALSE;
73} 73}
74 74
75void 75void
76UnixMakefileGenerator::writeMakeParts(QTextStream &t) 76UnixMakefileGenerator::writeMakeParts(QTextStream &t)
77{ 77{
78 QString deps = fileFixify(Option::output.name()), prl; 78 QString deps = fileFixify(Option::output.name()), prl;
79 bool do_incremental = (project->isActiveConfig("incremental") && 79 bool do_incremental = (project->isActiveConfig("incremental") &&
80 !project->variables()["QMAKE_INCREMENTAL"].isEmpty() && 80 !project->variables()["QMAKE_INCREMENTAL"].isEmpty() &&
81 (!project->variables()["QMAKE_APP_FLAG"].isEmpty() || 81 (!project->variables()["QMAKE_APP_FLAG"].isEmpty() ||
82 !project->isActiveConfig("staticlib"))), 82 !project->isActiveConfig("staticlib"))),
83 src_incremental=FALSE, moc_incremental=FALSE; 83 src_incremental=FALSE, moc_incremental=FALSE;
84 QString os = project->variables()["QMAKESPEC"].first().section( '-', 0, 0 );
85 84
86 t << "####### Compiler, tools and options" << endl << endl; 85 t << "####### Compiler, tools and options" << endl << endl;
87 t << "CC = "; 86 t << "CC = ";
88 if (project->isActiveConfig("thread") && 87 if (project->isActiveConfig("thread") &&
89 ! project->variables()["QMAKE_CC_THREAD"].isEmpty()) 88 ! project->variables()["QMAKE_CC_THREAD"].isEmpty())
90 t << var("QMAKE_CC_THREAD") << endl; 89 t << var("QMAKE_CC_THREAD") << endl;
91 else 90 else
92 t << var("QMAKE_CC") << endl; 91 t << var("QMAKE_CC") << endl;
93 92
94 t << "CXX = "; 93 t << "CXX = ";
95 if (project->isActiveConfig("thread") && 94 if (project->isActiveConfig("thread") &&
96 ! project->variables()["QMAKE_CXX_THREAD"].isEmpty()) 95 ! project->variables()["QMAKE_CXX_THREAD"].isEmpty())
97 t << var("QMAKE_CXX_THREAD") << endl; 96 t << var("QMAKE_CXX_THREAD") << endl;
98 else 97 else
99 t << var("QMAKE_CXX") << endl; 98 t << var("QMAKE_CXX") << endl;
100 99
101 t << "LEX = " << var("QMAKE_LEX") << endl; 100 t << "LEX = " << var("QMAKE_LEX") << endl;
102 t << "YACC = " << var("QMAKE_YACC") << endl; 101 t << "YACC = " << var("QMAKE_YACC") << endl;
103 t << "CFLAGS = " << var("QMAKE_CFLAGS") << " " 102 t << "CFLAGS = " << var("QMAKE_CFLAGS") << " "
104 << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " " 103 << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "
105 << varGlue("DEFINES","-D"," -D","") << endl; 104 << varGlue("DEFINES","-D"," -D","") << endl;
106 t << "CXXFLAGS = " << var("QMAKE_CXXFLAGS") << " " 105 t << "CXXFLAGS = " << var("QMAKE_CXXFLAGS") << " "
107 << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " " 106 << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "
108 << varGlue("DEFINES","-D"," -D","") << endl; 107 << varGlue("DEFINES","-D"," -D","") << endl;
109 t << "LEXFLAGS = " << var("QMAKE_LEXFLAGS") << endl; 108 t << "LEXFLAGS = " << var("QMAKE_LEXFLAGS") << endl;
110 t << "YACCFLAGS= " << var("QMAKE_YACCFLAGS") << endl; 109 t << "YACCFLAGS= " << var("QMAKE_YACCFLAGS") << endl;
111 t << "INCPATH = " << varGlue("INCLUDEPATH","-I", " -I", "") << " -I" << specdir() << endl; 110 t << "INCPATH = " << "-I" << specdir();
111 if(!project->isActiveConfig("no_include_pwd")) {
112 QString pwd = fileFixify(QDir::currentDirPath());
113 if(pwd.isEmpty())
114 pwd = ".";
115 t << " -I" << pwd;
116 }
117 t << varGlue("INCLUDEPATH"," -I", " -I", "") << endl;
112 118
113 if(!project->isActiveConfig("staticlib")) { 119 if(!project->isActiveConfig("staticlib")) {
114 t << "LINK = "; 120 t << "LINK = ";
115 if (project->isActiveConfig("thread") && 121 if (project->isActiveConfig("thread") &&
116 ! project->variables()["QMAKE_LINK_THREAD"].isEmpty()) 122 ! project->variables()["QMAKE_LINK_THREAD"].isEmpty())
117 t << var("QMAKE_LINK_THREAD") << endl; 123 t << var("QMAKE_LINK_THREAD") << endl;
118 else 124 else
119 t << var("QMAKE_LINK") << endl; 125 t << var("QMAKE_LINK") << endl;
120 126
121 t << "LFLAGS = " << var("QMAKE_LFLAGS") << endl; 127 t << "LFLAGS = " << var("QMAKE_LFLAGS") << endl;
122 t << "LIBS = " << "$(SUBLIBS) " << var("QMAKE_LIBDIR_FLAGS") << " " << var("QMAKE_LIBS") << endl; 128 t << "LIBS = " << "$(SUBLIBS) " << var("QMAKE_LIBDIR_FLAGS") << " " << var("QMAKE_LIBS") << endl;
123 } 129 }
124 130
125 t << "AR = " << var("QMAKE_AR") << endl; 131 t << "AR = " << var("QMAKE_AR") << endl;
126 t << "RANLIB = " << var("QMAKE_RANLIB") << endl; 132 t << "RANLIB = " << var("QMAKE_RANLIB") << endl;
127 t << "MOC = " << var("QMAKE_MOC") << endl; 133 t << "MOC = " << var("QMAKE_MOC") << endl;
128 t << "UIC = "<< var("QMAKE_UIC") << endl; 134 t << "UIC = "<< var("QMAKE_UIC") << endl;
129 t << "QMAKE = "<< (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl; 135 t << "QMAKE = "<< (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl;
130 t << "TAR = "<< var("QMAKE_TAR") << endl; 136 t << "TAR = "<< var("QMAKE_TAR") << endl;
131 t << "GZIP = " << var("QMAKE_GZIP") << endl; 137 t << "GZIP = " << var("QMAKE_GZIP") << endl;
132 t << "COPY = " << var("QMAKE_COPY") << endl; 138 t << "COPY = " << var("QMAKE_COPY") << endl;
133 t << "COPY_FILE= " << var("QMAKE_COPY_FILE") << endl; 139 t << "COPY_FILE= " << var("QMAKE_COPY_FILE") << endl;
134 t << "COPY_DIR = " << var("QMAKE_COPY_DIR") << endl; 140 t << "COPY_DIR = " << var("QMAKE_COPY_DIR") << endl;
135 t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; 141 t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl;
136 t << "SYMLINK = " << var("QMAKE_SYMBOLIC_LINK") << endl; 142 t << "SYMLINK = " << var("QMAKE_SYMBOLIC_LINK") << endl;
137 t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl; 143 t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl;
138 t << "MOVE = " << var("QMAKE_MOVE") << endl; 144 t << "MOVE = " << var("QMAKE_MOVE") << endl;
139 t << "PRO = " << fileFixify(project->projectFile() )<< endl; 145 t << "CHK_DIR_EXISTS= " << var("QMAKE_CHK_DIR_EXISTS") << endl;
146 t << "MKDIR = " << var("QMAKE_MKDIR") << endl;
140 t << endl; 147 t << endl;
141 148
142 t << "####### Output directory" << endl << endl; 149 t << "####### Output directory" << endl << endl;
143 if (! project->variables()["OBJECTS_DIR"].isEmpty()) 150 if (! project->variables()["OBJECTS_DIR"].isEmpty())
144 t << "OBJECTS_DIR = " << var("OBJECTS_DIR") << endl; 151 t << "OBJECTS_DIR = " << var("OBJECTS_DIR") << endl;
145 else 152 else
146 t << "OBJECTS_DIR = ./" << endl; 153 t << "OBJECTS_DIR = ./" << endl;
147 t << endl; 154 t << endl;
148 155
149 /* files */ 156 /* files */
150 t << "####### Files" << endl << endl; 157 t << "####### Files" << endl << endl;
151 t << "HEADERS = " << varList("HEADERS") << endl; 158 t << "HEADERS = " << varList("HEADERS") << endl;
152 t << "SOURCES = " << varList("SOURCES") << endl; 159 t << "SOURCES = " << varList("SOURCES") << endl;
153 if(do_incremental) { 160 if(do_incremental) {
154 QStringList &objs = project->variables()["OBJECTS"], &incrs = project->variables()["QMAKE_INCREMENTAL"], incrs_out; 161 QStringList &objs = project->variables()["OBJECTS"], &incrs = project->variables()["QMAKE_INCREMENTAL"], incrs_out;
155 t << "OBJECTS = "; 162 t << "OBJECTS = ";
156 for(QStringList::Iterator objit = objs.begin(); objit != objs.end(); ++objit) { 163 for(QStringList::Iterator objit = objs.begin(); objit != objs.end(); ++objit) {
157 bool increment = FALSE; 164 bool increment = FALSE;
158 for(QStringList::Iterator incrit = incrs.begin(); incrit != incrs.end(); ++incrit) { 165 for(QStringList::Iterator incrit = incrs.begin(); incrit != incrs.end(); ++incrit) {
159 if((*objit).find(QRegExp((*incrit), TRUE, TRUE)) != -1) { 166 if((*objit).find(QRegExp((*incrit), TRUE, TRUE)) != -1) {
160 increment = TRUE; 167 increment = TRUE;
161 incrs_out.append((*objit)); 168 incrs_out.append((*objit));
162 break; 169 break;
163 } 170 }
@@ -191,98 +198,96 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
191 for(QStringList::Iterator incrit = incrs.begin(); incrit != incrs.end(); ++incrit) { 198 for(QStringList::Iterator incrit = incrs.begin(); incrit != incrs.end(); ++incrit) {
192 if((*objit).find(QRegExp((*incrit), TRUE, TRUE)) != -1) { 199 if((*objit).find(QRegExp((*incrit), TRUE, TRUE)) != -1) {
193 increment = TRUE; 200 increment = TRUE;
194 incrs_out.append((*objit)); 201 incrs_out.append((*objit));
195 break; 202 break;
196 } 203 }
197 } 204 }
198 if(!increment) 205 if(!increment)
199 t << "\\\n\t\t" << (*objit); 206 t << "\\\n\t\t" << (*objit);
200 } 207 }
201 if(incrs_out.count() == objs.count()) { //we just switched places, no real incrementals to be done! 208 if(incrs_out.count() == objs.count()) { //we just switched places, no real incrementals to be done!
202 t << incrs_out.join(" \\\n\t\t") << endl; 209 t << incrs_out.join(" \\\n\t\t") << endl;
203 } else if(!incrs_out.count()) { 210 } else if(!incrs_out.count()) {
204 t << endl; 211 t << endl;
205 } else { 212 } else {
206 moc_incremental = TRUE; 213 moc_incremental = TRUE;
207 t << endl; 214 t << endl;
208 t << "INCREMENTAL_OBJMOC = " << incrs_out.join(" \\\n\t\t") << endl; 215 t << "INCREMENTAL_OBJMOC = " << incrs_out.join(" \\\n\t\t") << endl;
209 } 216 }
210 } else { 217 } else {
211 t << "OBJMOC = " << objMoc << endl; 218 t << "OBJMOC = " << objMoc << endl;
212 } 219 }
213 if(do_incremental && !moc_incremental && !src_incremental) 220 if(do_incremental && !moc_incremental && !src_incremental)
214 do_incremental = FALSE; 221 do_incremental = FALSE;
215 t << "DIST = " << varList("DISTFILES") << endl; 222 t << "DIST = " << valList(fileFixify(project->variables()["DISTFILES"])) << endl;
216 t << "PRO = " << fileFixify(project->projectFile()) << endl;
217 t << "QMAKE_TARGET = " << var("QMAKE_ORIG_TARGET") << endl; 223 t << "QMAKE_TARGET = " << var("QMAKE_ORIG_TARGET") << endl;
218 t << "DESTDIR = " << var("DESTDIR") << endl; 224 t << "DESTDIR = " << var("DESTDIR") << endl;
219 t << "TARGET = " << var("TARGET") << endl; 225 t << "TARGET = " << var("TARGET") << endl;
220 if(project->isActiveConfig("plugin") ) { 226 if(project->isActiveConfig("plugin") ) {
221 t << "TARGETD = " << var("TARGET") << endl; 227 t << "TARGETD = " << var("TARGET") << endl;
222 } else if (!project->isActiveConfig("staticlib") && project->variables()["QMAKE_APP_FLAG"].isEmpty()) { 228 } else if (!project->isActiveConfig("staticlib") && project->variables()["QMAKE_APP_FLAG"].isEmpty()) {
223 t << "TARGETA= " << var("TARGETA") << endl; 229 t << "TARGETA= " << var("TARGETA") << endl;
224 if (os == "hpux") { 230 if (project->isEmpty("QMAKE_HPUX_SHLIB")) {
225 t << "TARGETD= " << var("TARGET_x") << endl;
226 t << "TARGET0= " << var("TARGET_") << endl;
227 }
228 else {
229 t << "TARGETD= " << var("TARGET_x.y.z") << endl; 231 t << "TARGETD= " << var("TARGET_x.y.z") << endl;
230 t << "TARGET0= " << var("TARGET_") << endl; 232 t << "TARGET0= " << var("TARGET_") << endl;
231 t << "TARGET1= " << var("TARGET_x") << endl; 233 t << "TARGET1= " << var("TARGET_x") << endl;
232 t << "TARGET2= " << var("TARGET_x.y") << endl; 234 t << "TARGET2= " << var("TARGET_x.y") << endl;
235 } else {
236 t << "TARGETD= " << var("TARGET_x") << endl;
237 t << "TARGET0= " << var("TARGET_") << endl;
233 } 238 }
234 } 239 }
235 t << endl; 240 t << endl;
236 241
237 // blasted incldues 242 // blasted incldues
238 QStringList &qeui = project->variables()["QMAKE_EXTRA_UNIX_INCLUDES"]; 243 QStringList &qeui = project->variables()["QMAKE_EXTRA_UNIX_INCLUDES"];
239 QStringList::Iterator it; 244 QStringList::Iterator it;
240 for( it = qeui.begin(); it != qeui.end(); ++it) 245 for( it = qeui.begin(); it != qeui.end(); ++it)
241 t << "include " << (*it) << endl; 246 t << "include " << (*it) << endl;
242 247
243 /* rules */ 248 /* rules */
244 t << "first: all" << endl; 249 t << "first: all" << endl;
245 t << "####### Implicit rules" << endl << endl; 250 t << "####### Implicit rules" << endl << endl;
246 t << ".SUFFIXES: .c"; 251 t << ".SUFFIXES: .c";
247 QStringList::Iterator cppit; 252 QStringList::Iterator cppit;
248 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) 253 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
249 t << " " << (*cppit); 254 t << " " << (*cppit);
250 t << endl << endl; 255 t << endl << endl;
251 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) 256 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
252 t << (*cppit) << ".o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; 257 t << (*cppit) << ".o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
253 t << ".c.o:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl; 258 t << ".c.o:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;
254 259
255 if(include_deps) { 260 if(include_deps) {
256 QString cmd=var("QMAKE_CFLAGS_DEPS") + " "; 261 QString cmd=var("QMAKE_CFLAGS_DEPS") + " ";
257 cmd += varGlue("DEFINES","-D"," -D","") + varGlue("PRL_EXPORT_DEFINES"," -D"," -D",""); 262 cmd += varGlue("DEFINES","-D"," -D","") + varGlue("PRL_EXPORT_DEFINES"," -D"," -D","");
258 if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) 263 if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH"))
259 cmd += " -I" + project->first("QMAKE_ABSOLUTE_SOURCE_PATH") + " "; 264 cmd += " -I" + project->first("QMAKE_ABSOLUTE_SOURCE_PATH") + " ";
260 cmd += " $(INCPATH) " + varGlue("DEPENDPATH", "-I", " -I", ""); 265 cmd += " $(INCPATH) " + varGlue("DEPENDPATH", "-I", " -I", "");
261 QString odir; 266 QString odir;
262 if(!project->variables()["OBJECTS_DIR"].isEmpty()) 267 if(!project->variables()["OBJECTS_DIR"].isEmpty())
263 odir = project->first("OBJECTS_DIR"); 268 odir = project->first("OBJECTS_DIR");
264 t << "###### Dependancies" << endl << endl; 269 t << "###### Dependencies" << endl << endl;
265 t << odir << ".deps/%.d: %.cpp\n\t" 270 t << odir << ".deps/%.d: %.cpp\n\t"
266 << "@echo Creating depend for $<" << "\n\t" 271 << "@echo Creating depend for $<" << "\n\t"
267 << "@test -d $(@D) || mkdir -p $(@D)" << "\n\t" 272 << "@test -d $(@D) || mkdir -p $(@D)" << "\n\t"
268 << "@$(CXX) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl; 273 << "@$(CXX) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl;
269 274
270 t << odir << ".deps/%.d: %.c\n\t" 275 t << odir << ".deps/%.d: %.c\n\t"
271 << "@echo Creating depend for $<" << "\n\t" 276 << "@echo Creating depend for $<" << "\n\t"
272 << "@test -d $(@D) || mkdir -p $(@D)" << "\n\t" 277 << "@test -d $(@D) || mkdir -p $(@D)" << "\n\t"
273 << "@$(CC) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl; 278 << "@$(CC) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl;
274 279
275 280
276 QString src[] = { "SOURCES", "UICIMPLS", "SRCMOC", QString::null }; 281 QString src[] = { "SOURCES", "UICIMPLS", "SRCMOC", QString::null };
277 for(int x = 0; !src[x].isNull(); x++) { 282 for(int x = 0; !src[x].isNull(); x++) {
278 QStringList &l = project->variables()[src[x]]; 283 QStringList &l = project->variables()[src[x]];
279 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 284 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
280 if(!(*it).isEmpty()) { 285 if(!(*it).isEmpty()) {
281 QString d_file; 286 QString d_file;
282 if((*it).endsWith(".c")) { 287 if((*it).endsWith(".c")) {
283 d_file = (*it).left((*it).length() - 2); 288 d_file = (*it).left((*it).length() - 2);
284 } else { 289 } else {
285 for(QStringList::Iterator cppit = Option::cpp_ext.begin(); 290 for(QStringList::Iterator cppit = Option::cpp_ext.begin();
286 cppit != Option::cpp_ext.end(); ++cppit) { 291 cppit != Option::cpp_ext.end(); ++cppit) {
287 if((*it).endsWith((*cppit))) { 292 if((*it).endsWith((*cppit))) {
288 d_file = (*it).left((*it).length() - (*cppit).length()); 293 d_file = (*it).left((*it).length() - (*cppit).length());
@@ -365,62 +370,64 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
365 if(!destdir.isEmpty()) 370 if(!destdir.isEmpty())
366 t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; 371 t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
367 t << "$(LINK) " << incr_lflags << " -o "<< incr_target_dir << 372 t << "$(LINK) " << incr_lflags << " -o "<< incr_target_dir <<
368 " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << endl; 373 " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << endl;
369 //communicated below 374 //communicated below
370 if(!destdir.isEmpty()) { 375 if(!destdir.isEmpty()) {
371 if(!incr_objs.isEmpty()) 376 if(!incr_objs.isEmpty())
372 incr_objs += " "; 377 incr_objs += " ";
373 incr_objs += "-L" + destdir; 378 incr_objs += "-L" + destdir;
374 } else { 379 } else {
375 if(!incr_objs.isEmpty()) 380 if(!incr_objs.isEmpty())
376 incr_objs += " "; 381 incr_objs += " ";
377 incr_objs += "-L" + QDir::currentDirPath(); 382 incr_objs += "-L" + QDir::currentDirPath();
378 } 383 }
379 if(!incr_objs.isEmpty()) 384 if(!incr_objs.isEmpty())
380 incr_objs += " "; 385 incr_objs += " ";
381 incr_objs += " -l" + incr_target; 386 incr_objs += " -l" + incr_target;
382 deps.prepend(incr_target_dir + " "); 387 deps.prepend(incr_target_dir + " ");
383 incr_deps = "$(UICDECLS) $(OBJECTS) $(OBJMOC)"; 388 incr_deps = "$(UICDECLS) $(OBJECTS) $(OBJMOC)";
384 } 389 }
385 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" 390 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)"
386 << endl << endl; 391 << endl << endl;
387 392
388 //real target 393 //real target
389 t << var("TARGET") << ": " << " " << incr_deps << " " << var("TARGETDEPS") << "\n\t"; 394 t << var("TARGET") << ": " << var("PRE_TARGETDEPS") << " " << incr_deps
395 << " " << var("POST_TARGETDEPS") << "\n\t";
390 if(!destdir.isEmpty()) 396 if(!destdir.isEmpty())
391 t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; 397 t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
392 if(!project->isEmpty("QMAKE_PRE_LINK")) 398 if(!project->isEmpty("QMAKE_PRE_LINK"))
393 t << var("QMAKE_PRE_LINK") << "\n\t"; 399 t << var("QMAKE_PRE_LINK") << "\n\t";
394 t << "$(LINK) $(LFLAGS) -o $(TARGET) " << incr_deps << " " << incr_objs << " $(LIBS)"; 400 t << "$(LINK) $(LFLAGS) -o $(TARGET) " << incr_deps << " " << incr_objs << " $(LIBS)";
395 if(!project->isEmpty("QMAKE_POST_LINK")) 401 if(!project->isEmpty("QMAKE_POST_LINK"))
396 t << "\n\t" << var("QMAKE_POST_LINK"); 402 t << "\n\t" << var("QMAKE_POST_LINK");
397 t << endl << endl; 403 t << endl << endl;
398 } else { 404 } else {
399 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" 405 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)"
400 << endl << endl; 406 << endl << endl;
401 407
402 t << "$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) " << var("TARGETDEPS") << "\n\t"; 408 t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) "
409 << var("POST_TARGETDEPS") << "\n\t";
403 if(!destdir.isEmpty()) 410 if(!destdir.isEmpty())
404 t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; 411 t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
405 if(!project->isEmpty("QMAKE_PRE_LINK")) 412 if(!project->isEmpty("QMAKE_PRE_LINK"))
406 t << var("QMAKE_PRE_LINK") << "\n\t"; 413 t << var("QMAKE_PRE_LINK") << "\n\t";
407 t << "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)"; 414 t << "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)";
408 if(!project->isEmpty("QMAKE_POST_LINK")) 415 if(!project->isEmpty("QMAKE_POST_LINK"))
409 t << "\n\t" << var("QMAKE_POST_LINK"); 416 t << "\n\t" << var("QMAKE_POST_LINK");
410 t << endl << endl; 417 t << endl << endl;
411 } 418 }
412 } else if(!project->isActiveConfig("staticlib")) { 419 } else if(!project->isActiveConfig("staticlib")) {
413 QString destdir = project->first("DESTDIR"), incr_deps; 420 QString destdir = project->first("DESTDIR"), incr_deps;
414 if(do_incremental) { 421 if(do_incremental) {
415 QString s_ext = project->variables()["QMAKE_EXTENSION_SHLIB"].first(); 422 QString s_ext = project->variables()["QMAKE_EXTENSION_SHLIB"].first();
416 QString incr_target = var("QMAKE_ORIG_TARGET").replace( 423 QString incr_target = var("QMAKE_ORIG_TARGET").replace(
417 QRegExp("\\." + s_ext), "").replace(QRegExp("^lib"), "") + "_incremental"; 424 QRegExp("\\." + s_ext), "").replace(QRegExp("^lib"), "") + "_incremental";
418 if(incr_target.find(Option::dir_sep) != -1) 425 if(incr_target.find(Option::dir_sep) != -1)
419 incr_target = incr_target.right(incr_target.length() - 426 incr_target = incr_target.right(incr_target.length() -
420 (incr_target.findRev(Option::dir_sep) + 1)); 427 (incr_target.findRev(Option::dir_sep) + 1));
421 428
422 if(project->first("QMAKE_INCREMENTAL_STYLE") == "ld") { 429 if(project->first("QMAKE_INCREMENTAL_STYLE") == "ld") {
423 QString incr_target_dir = var("OBJECTS_DIR") + incr_target + Option::obj_ext; 430 QString incr_target_dir = var("OBJECTS_DIR") + incr_target + Option::obj_ext;
424 //actual target 431 //actual target
425 const QString link_deps = "$(UICDECLS) $(OBJECTS) $(OBJMOC)"; 432 const QString link_deps = "$(UICDECLS) $(OBJECTS) $(OBJMOC)";
426 t << incr_target_dir << ": " << link_deps << "\n\t" 433 t << incr_target_dir << ": " << link_deps << "\n\t"
@@ -439,181 +446,182 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
439 if(!project->isEmpty("QMAKE_LFLAGS_INCREMENTAL")) 446 if(!project->isEmpty("QMAKE_LFLAGS_INCREMENTAL"))
440 incr_lflags += var("QMAKE_LFLAGS_INCREMENTAL") + " "; 447 incr_lflags += var("QMAKE_LFLAGS_INCREMENTAL") + " ";
441 if(project->isActiveConfig("debug")) 448 if(project->isActiveConfig("debug"))
442 incr_lflags += var("QMAKE_LFLAGS_DEBUG"); 449 incr_lflags += var("QMAKE_LFLAGS_DEBUG");
443 else 450 else
444 incr_lflags += var("QMAKE_LFLAGS_RELEASE"); 451 incr_lflags += var("QMAKE_LFLAGS_RELEASE");
445 t << incr_target_dir << ": $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << "\n\t"; 452 t << incr_target_dir << ": $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << "\n\t";
446 if(!destdir.isEmpty()) 453 if(!destdir.isEmpty())
447 t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; 454 t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
448 t << "$(LINK) " << incr_lflags << " -o "<< incr_target_dir << 455 t << "$(LINK) " << incr_lflags << " -o "<< incr_target_dir <<
449 " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << endl; 456 " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << endl;
450 //communicated below 457 //communicated below
451 QStringList &cmd = project->variables()["QMAKE_LINK_SHLIB_CMD"]; 458 QStringList &cmd = project->variables()["QMAKE_LINK_SHLIB_CMD"];
452 if(!destdir.isEmpty()) 459 if(!destdir.isEmpty())
453 cmd.append(" -L" + destdir); 460 cmd.append(" -L" + destdir);
454 cmd.append(" -l" + incr_target); 461 cmd.append(" -l" + incr_target);
455 deps.prepend(incr_target_dir + " "); 462 deps.prepend(incr_target_dir + " ");
456 incr_deps = "$(UICDECLS) $(OBJECTS) $(OBJMOC)"; 463 incr_deps = "$(UICDECLS) $(OBJECTS) $(OBJMOC)";
457 } 464 }
458 465
459 t << "all: " << " " << deps << " " << varGlue("ALL_DEPS",""," ","") 466 t << "all: " << " " << deps << " " << varGlue("ALL_DEPS",""," ","")
460 << " " << var("DESTDIR_TARGET") << endl << endl; 467 << " " << var("DESTDIR_TARGET") << endl << endl;
461 468
462 //real target 469 //real target
463 t << var("DESTDIR_TARGET") << ": " << incr_deps << " $(SUBLIBS) " << 470 t << var("DESTDIR_TARGET") << ": " << var("PRE_TARGETDEPS") << " "
464 var("TARGETDEPS"); 471 << incr_deps << " $(SUBLIBS) " << var("POST_TARGETDEPS");
465 } else { 472 } else {
466 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," ","") << " " << 473 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," ","") << " " <<
467 var("DESTDIR_TARGET") << endl << endl; 474 var("DESTDIR_TARGET") << endl << endl;
468 t << var("DESTDIR_TARGET") << ": $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) " << 475 t << var("DESTDIR_TARGET") << ": " << var("PRE_TARGETDEPS")
469 var("TARGETDEPS"); 476 << " $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) " << var("POST_TARGETDEPS");
470 } 477 }
471 if(!destdir.isEmpty()) 478 if(!destdir.isEmpty())
472 t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir; 479 t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir;
473 if(!project->isEmpty("QMAKE_PRE_LINK")) 480 if(!project->isEmpty("QMAKE_PRE_LINK"))
474 t << "\n\t" << var("QMAKE_PRE_LINK"); 481 t << "\n\t" << var("QMAKE_PRE_LINK");
475 482
476 if(project->isActiveConfig("plugin")) { 483 if(project->isActiveConfig("plugin")) {
477 t << "\n\t" 484 t << "\n\t"
478 << "-$(DEL_FILE) $(TARGET)" << "\n\t" 485 << "-$(DEL_FILE) $(TARGET)" << "\n\t"
479 << var("QMAKE_LINK_SHLIB_CMD"); 486 << var("QMAKE_LINK_SHLIB_CMD");
480 if(!destdir.isEmpty()) 487 if(!destdir.isEmpty())
481 t << "\n\t" 488 t << "\n\t"
482 << "-$(MOVE) $(TARGET) " << var("DESTDIR"); 489 << "-$(MOVE) $(TARGET) " << var("DESTDIR");
483 if(!project->isEmpty("QMAKE_POST_LINK")) 490 if(!project->isEmpty("QMAKE_POST_LINK"))
484 t << "\n\t" << var("QMAKE_POST_LINK") << "\n\t"; 491 t << "\n\t" << var("QMAKE_POST_LINK") << "\n\t";
485 t << endl << endl; 492 t << endl << endl;
486 } else if ( os == "hpux" ) { 493 } else if(project->isEmpty("QMAKE_HPUX_SHLIB")) {
487 t << "\n\t" 494 t << "\n\t"
488 << "-$(DEL_FILE) $(TARGET) $(TARGET0)" << "\n\t" 495 << "-$(DEL_FILE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2)" << "\n\t"
489 << var("QMAKE_LINK_SHLIB_CMD") << "\n\t"; 496 << var("QMAKE_LINK_SHLIB_CMD") << "\n\t";
490 t << varGlue("QMAKE_LN_SHLIB",""," "," $(TARGET) $(TARGET0)"); 497 t << varGlue("QMAKE_LN_SHLIB","-"," "," $(TARGET) $(TARGET0)") << "\n\t"
498 << varGlue("QMAKE_LN_SHLIB","-"," "," $(TARGET) $(TARGET1)") << "\n\t"
499 << varGlue("QMAKE_LN_SHLIB","-"," "," $(TARGET) $(TARGET2)");
491 if(!destdir.isEmpty()) 500 if(!destdir.isEmpty())
492 t << "\n\t" 501 t << "\n\t"
493 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET)\n\t" 502 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET)\n\t"
494 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET0)\n\t" 503 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET0)\n\t"
495 << "-$(MOVE) $(TARGET) $(TARGET0) " << var("DESTDIR"); 504 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET1)\n\t"
505 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET2)\n\t"
506 << "-$(MOVE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) " << var("DESTDIR");
496 if(!project->isEmpty("QMAKE_POST_LINK")) 507 if(!project->isEmpty("QMAKE_POST_LINK"))
497 t << "\n\t" << var("QMAKE_POST_LINK"); 508 t << "\n\t" << var("QMAKE_POST_LINK");
498 t << endl << endl; 509 t << endl << endl;
499 } else { 510 } else {
500 t << "\n\t" 511 t << "\n\t"
501 << "-$(DEL_FILE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2)" << "\n\t" 512 << "-$(DEL_FILE) $(TARGET) $(TARGET0)" << "\n\t"
502 << var("QMAKE_LINK_SHLIB_CMD") << "\n\t"; 513 << var("QMAKE_LINK_SHLIB_CMD") << "\n\t";
503 t << varGlue("QMAKE_LN_SHLIB","-"," "," $(TARGET) $(TARGET0)") << "\n\t" 514 t << varGlue("QMAKE_LN_SHLIB",""," "," $(TARGET) $(TARGET0)");
504 << varGlue("QMAKE_LN_SHLIB","-"," "," $(TARGET) $(TARGET1)") << "\n\t"
505 << varGlue("QMAKE_LN_SHLIB","-"," "," $(TARGET) $(TARGET2)");
506 if(!destdir.isEmpty()) 515 if(!destdir.isEmpty())
507 t << "\n\t" 516 t << "\n\t"
508 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET)\n\t" 517 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET)\n\t"
509 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET0)\n\t" 518 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET0)\n\t"
510 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET1)\n\t" 519 << "-$(MOVE) $(TARGET) $(TARGET0) " << var("DESTDIR");
511 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET2)\n\t"
512 << "-$(MOVE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) " << var("DESTDIR");
513 if(!project->isEmpty("QMAKE_POST_LINK")) 520 if(!project->isEmpty("QMAKE_POST_LINK"))
514 t << "\n\t" << var("QMAKE_POST_LINK"); 521 t << "\n\t" << var("QMAKE_POST_LINK");
515 t << endl << endl; 522 t << endl << endl;
516 } 523 }
517 t << endl << endl; 524 t << endl << endl;
518 525
519 if (! project->isActiveConfig("plugin")) { 526 if (! project->isActiveConfig("plugin")) {
520 t << "staticlib: $(TARGETA)" << endl << endl; 527 t << "staticlib: $(TARGETA)" << endl << endl;
521 t << "$(TARGETA): $(UICDECLS) $(OBJECTS) $(OBJMOC)"; 528 t << "$(TARGETA): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC)";
522 if(do_incremental) 529 if(do_incremental)
523 t << " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)"; 530 t << " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)";
524 t << var("TARGETDEPS") << "\n\t" 531 t << var("POST_TARGETDEPS") << "\n\t"
525 << "-$(DEL_FILE) $(TARGETA) " << "\n\t" 532 << "-$(DEL_FILE) $(TARGETA) " << "\n\t"
526 << var("QMAKE_AR_CMD"); 533 << var("QMAKE_AR_CMD");
527 if(do_incremental) 534 if(do_incremental)
528 t << " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)"; 535 t << " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)";
529 if(!project->isEmpty("QMAKE_RANLIB")) 536 if(!project->isEmpty("QMAKE_RANLIB"))
530 t << "\n\t" << "$(RANLIB) $(TARGETA)"; 537 t << "\n\t" << "$(RANLIB) $(TARGETA)";
531 t << endl << endl; 538 t << endl << endl;
532 } 539 }
533 } else { 540 } else {
534 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << var("DESTDIR") << "$(TARGET) " 541 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << var("DESTDIR") << "$(TARGET) "
535 << varGlue("QMAKE_AR_SUBLIBS", var("DESTDIR"), " " + var("DESTDIR"), "") << "\n\n" 542 << varGlue("QMAKE_AR_SUBLIBS", var("DESTDIR"), " " + var("DESTDIR"), "") << "\n\n"
536 << "staticlib: " << var("DESTDIR") << "$(TARGET)" << "\n\n"; 543 << "staticlib: " << var("DESTDIR") << "$(TARGET)" << "\n\n";
537 if(project->isEmpty("QMAKE_AR_SUBLIBS")) { 544 if(project->isEmpty("QMAKE_AR_SUBLIBS")) {
538 t << var("DESTDIR") << "$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(TARGETDEPS) " << "\n\t"; 545 t << var("DESTDIR") << "$(TARGET): " << var("PRE_TARGETDEPS")
546 << " $(UICDECLS) $(OBJECTS) $(OBJMOC) " << var("POST_TARGETDEPS") << "\n\t";
539 if(!project->isEmpty("DESTDIR")) { 547 if(!project->isEmpty("DESTDIR")) {
540 QString destdir = project->first("DESTDIR"); 548 QString destdir = project->first("DESTDIR");
541 t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; 549 t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
542 } 550 }
543 t << "-$(DEL_FILE) $(TARGET)" << "\n\t" 551 t << "-$(DEL_FILE) $(TARGET)" << "\n\t"
544 << var("QMAKE_AR_CMD") << "\n"; 552 << var("QMAKE_AR_CMD") << "\n";
545 if(!project->isEmpty("QMAKE_POST_LINK")) 553 if(!project->isEmpty("QMAKE_POST_LINK"))
546 t << "\t" << var("QMAKE_POST_LINK") << "\n"; 554 t << "\t" << var("QMAKE_POST_LINK") << "\n";
547 if(!project->isEmpty("QMAKE_RANLIB")) 555 if(!project->isEmpty("QMAKE_RANLIB"))
548 t << "\t" << "$(RANLIB) $(TARGET)" << "\n"; 556 t << "\t" << "$(RANLIB) $(TARGET)" << "\n";
549 if(!project->isEmpty("DESTDIR")) 557 if(!project->isEmpty("DESTDIR"))
550 t << "\t" << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET)" << "\n" 558 t << "\t" << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET)" << "\n"
551 << "\t" << "-$(MOVE) $(TARGET) " << var("DESTDIR") << "\n"; 559 << "\t" << "-$(MOVE) $(TARGET) " << var("DESTDIR") << "\n";
552 } else { 560 } else {
553 int cnt = 0, max_files = project->first("QMAKE_MAX_FILES_PER_AR").toInt(); 561 int max_files = project->first("QMAKE_MAX_FILES_PER_AR").toInt();
554 QStringList objs = project->variables()["OBJECTS"] + project->variables()["OBJMOC"], 562 QStringList objs = project->variables()["OBJECTS"] + project->variables()["OBJMOC"],
555 libs = project->variables()["QMAKE_AR_SUBLIBS"]; 563 libs = project->variables()["QMAKE_AR_SUBLIBS"];
556 libs.prepend("$(TARGET)"); 564 libs.prepend("$(TARGET)");
557 for(QStringList::Iterator libit = libs.begin(), objit = objs.begin(); 565 for(QStringList::Iterator libit = libs.begin(), objit = objs.begin();
558 libit != libs.end(); ++libit) { 566 libit != libs.end(); ++libit) {
559 QStringList build; 567 QStringList build;
560 for(cnt = 0; cnt < max_files && objit != objs.end(); ++objit, cnt++) 568 for(int cnt = 0; cnt < max_files && objit != objs.end(); ++objit, cnt++)
561 build << (*objit); 569 build << (*objit);
562 QString ar; 570 QString ar;
563 if((*libit) == "$(TARGET)") { 571 if((*libit) == "$(TARGET)") {
564 t << var("DESTDIR") << "$(TARGET): $(UICDECLS) " << " $(TARGETDEPS) " 572 t << var("DESTDIR") << "$(TARGET): " << var("PRE_TARGETDEPS")
565 << valList(build) << "\n\t"; 573 << " $(UICDECLS) " << var("POST_TARGETDEPS") << valList(build) << "\n\t";
566 ar = project->variables()["QMAKE_AR_CMD"].first(); 574 ar = project->variables()["QMAKE_AR_CMD"].first();
567 ar = ar.replace("$(OBJMOC)", "").replace("$(OBJECTS)", 575 ar = ar.replace("$(OBJMOC)", "").replace("$(OBJECTS)",
568 build.join(" ")); 576 build.join(" "));
569 } else { 577 } else {
570 t << (*libit) << ": " << valList(build) << "\n\t"; 578 t << (*libit) << ": " << valList(build) << "\n\t";
571 ar = "$(AR) " + (*libit) + " " + build.join(" "); 579 ar = "$(AR) " + (*libit) + " " + build.join(" ");
572 } 580 }
573 if(!project->isEmpty("DESTDIR")) { 581 if(!project->isEmpty("DESTDIR")) {
574 QString destdir = project->first("DESTDIR"); 582 QString destdir = project->first("DESTDIR");
575 t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; 583 t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
576 } 584 }
577 t << "-$(DEL_FILE) " << (*libit) << "\n\t" 585 t << "-$(DEL_FILE) " << (*libit) << "\n\t"
578 << ar << "\n"; 586 << ar << "\n";
579 if(!project->isEmpty("QMAKE_POST_LINK")) 587 if(!project->isEmpty("QMAKE_POST_LINK"))
580 t << "\t" << var("QMAKE_POST_LINK") << "\n"; 588 t << "\t" << var("QMAKE_POST_LINK") << "\n";
581 if(!project->isEmpty("QMAKE_RANLIB")) 589 if(!project->isEmpty("QMAKE_RANLIB"))
582 t << "\t" << "$(RANLIB) " << (*libit) << "\n"; 590 t << "\t" << "$(RANLIB) " << (*libit) << "\n";
583 if(!project->isEmpty("DESTDIR")) 591 if(!project->isEmpty("DESTDIR"))
584 t << "\t" << "-$(DEL_FILE) " << var("DESTDIR") << (*libit) << "\n" 592 t << "\t" << "-$(DEL_FILE) " << var("DESTDIR") << (*libit) << "\n"
585 << "\t" << "-$(MOVE) " << (*libit) << " " << var("DESTDIR") << "\n"; 593 << "\t" << "-$(MOVE) " << (*libit) << " " << var("DESTDIR") << "\n";
586 } 594 }
587 } 595 }
588 t << endl << endl; 596 t << endl << endl;
589 } 597 }
590 598
591 t << "mocables: $(SRCMOC)" << endl << endl; 599 t << "mocables: $(SRCMOC)" << endl << endl;
592 600
593 if(!project->isActiveConfig("no_mocdepend")) { 601 if(!project->isActiveConfig("no_mocdepend")) {
594 //this is an implicity depend on moc, so it will be built if necesary, however 602 //this is an implicity depend on moc, so it will be built if necesary, however
595 //moc itself shouldn't have this dependancy - this is a little kludgy but it is 603 //moc itself shouldn't have this dependency - this is a little kludgy but it is
596 //better than the alternative for now. 604 //better than the alternative for now.
597 QString moc = project->first("QMAKE_MOC"), target = project->first("TARGET"); 605 QString moc = project->first("QMAKE_MOC"), target = project->first("TARGET");
598 fixEnvVariables(target); 606 fixEnvVariables(target);
599 fixEnvVariables(moc); 607 fixEnvVariables(moc);
600 if(target != moc) 608 if(target != moc)
601 t << "$(MOC): \n\t" 609 t << "$(MOC): \n\t"
602 << "( cd $(QTDIR)/src/moc ; $(MAKE) )" << endl << endl; 610 << "( cd $(QTDIR)/src/moc ; $(MAKE) )" << endl << endl;
603 } 611 }
604 612
605 writeMakeQmake(t); 613 writeMakeQmake(t);
606 614
607 if(!project->first("QMAKE_PKGINFO").isEmpty()) { 615 if(!project->first("QMAKE_PKGINFO").isEmpty()) {
608 QString pkginfo = project->first("QMAKE_PKGINFO"); 616 QString pkginfo = project->first("QMAKE_PKGINFO");
609 QString destdir = project->first("DESTDIR"); 617 QString destdir = project->first("DESTDIR");
610 t << pkginfo << ": " << "\n\t"; 618 t << pkginfo << ": " << "\n\t";
611 if(!destdir.isEmpty()) 619 if(!destdir.isEmpty())
612 t << "@test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; 620 t << "@test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
613 t << "@$(DEL_FILE) " << pkginfo << "\n\t" 621 t << "@$(DEL_FILE) " << pkginfo << "\n\t"
614 << "@echo \"APPL????\" >" << pkginfo << endl; 622 << "@echo \"APPL????\" >" << pkginfo << endl;
615 } 623 }
616 if(!project->first("QMAKE_INFO_PLIST").isEmpty()) { 624 if(!project->first("QMAKE_INFO_PLIST").isEmpty()) {
617 QString info_plist = project->first("QMAKE_INFO_PLIST"), 625 QString info_plist = project->first("QMAKE_INFO_PLIST"),
618 info_plist_out = project->first("QMAKE_INFO_PLIST_OUT"); 626 info_plist_out = project->first("QMAKE_INFO_PLIST_OUT");
619 QString destdir = project->first("DESTDIR"); 627 QString destdir = project->first("DESTDIR");
@@ -632,107 +640,150 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
632 640
633 QString ddir = project->isEmpty("QMAKE_DISTDIR") ? project->first("QMAKE_ORIG_TARGET") : 641 QString ddir = project->isEmpty("QMAKE_DISTDIR") ? project->first("QMAKE_ORIG_TARGET") :
634 project->first("QMAKE_DISTDIR"); 642 project->first("QMAKE_DISTDIR");
635 QString ddir_c = fileFixify((project->isEmpty("OBJECTS_DIR") ? QString(".tmp/") : 643 QString ddir_c = fileFixify((project->isEmpty("OBJECTS_DIR") ? QString(".tmp/") :
636 project->first("OBJECTS_DIR")) + ddir); 644 project->first("OBJECTS_DIR")) + ddir);
637 t << "dist: " << "\n\t" 645 t << "dist: " << "\n\t"
638 << "@mkdir -p " << ddir_c << " && " 646 << "@mkdir -p " << ddir_c << " && "
639 << "$(COPY_FILE) --parents $(SOURCES) $(HEADERS) $(FORMS) $(DIST) " << ddir_c << Option::dir_sep << " && "; 647 << "$(COPY_FILE) --parents $(SOURCES) $(HEADERS) $(FORMS) $(DIST) " << ddir_c << Option::dir_sep << " && ";
640 if(!project->isEmpty("TRANSLATIONS")) 648 if(!project->isEmpty("TRANSLATIONS"))
641 t << "$(COPY_FILE) --parents " << var("TRANSLATIONS") << " " << ddir_c << Option::dir_sep << " && "; 649 t << "$(COPY_FILE) --parents " << var("TRANSLATIONS") << " " << ddir_c << Option::dir_sep << " && ";
642 if(!project->isEmpty("FORMS")) { 650 if(!project->isEmpty("FORMS")) {
643 QStringList &forms = project->variables()["FORMS"], ui_headers; 651 QStringList &forms = project->variables()["FORMS"], ui_headers;
644 for(QStringList::Iterator formit = forms.begin(); formit != forms.end(); ++formit) { 652 for(QStringList::Iterator formit = forms.begin(); formit != forms.end(); ++formit) {
645 QString ui_h = fileFixify((*formit) + Option::h_ext.first()); 653 QString ui_h = fileFixify((*formit) + Option::h_ext.first());
646 if(QFile::exists(ui_h) ) 654 if(QFile::exists(ui_h) )
647 ui_headers << ui_h; 655 ui_headers << ui_h;
648 } 656 }
649 if(!ui_headers.isEmpty()) 657 if(!ui_headers.isEmpty())
650 t << "$(COPY_FILE) --parents " << val(ui_headers) << " " << ddir_c << Option::dir_sep << " && "; 658 t << "$(COPY_FILE) --parents " << val(ui_headers) << " " << ddir_c << Option::dir_sep << " && ";
651 } 659 }
652 t << "( cd `dirname " << ddir_c << "` && " 660 t << "( cd `dirname " << ddir_c << "` && "
653 << "$(TAR) " << var("QMAKE_ORIG_TARGET") << ".tar " << ddir << " && " 661 << "$(TAR) " << var("QMAKE_ORIG_TARGET") << ".tar " << ddir << " && "
654 << "$(GZIP) " << var("QMAKE_ORIG_TARGET") << ".tar ) && " 662 << "$(GZIP) " << var("QMAKE_ORIG_TARGET") << ".tar ) && "
655 << "$(MOVE) `dirname " << ddir_c << "`" << Option::dir_sep << var("QMAKE_ORIG_TARGET") << ".tar.gz . && " 663 << "$(MOVE) `dirname " << ddir_c << "`" << Option::dir_sep << var("QMAKE_ORIG_TARGET") << ".tar.gz . && "
656 << "$(DEL_DIR) " << ddir_c 664 << "$(DEL_FILE) -r " << ddir_c
657 << endl << endl; 665 << endl << endl;
658 666
659 QString clean_targets; 667 QString clean_targets;
660 if(mocAware()) { 668 if(mocAware()) {
661 t << "mocclean:" << "\n"; 669 t << "mocclean:" << "\n";
662 if(!objMoc.isEmpty() || !srcMoc.isEmpty() || moc_incremental) { 670 if(!objMoc.isEmpty() || !srcMoc.isEmpty() || moc_incremental) {
663 if(!objMoc.isEmpty()) 671 if(!objMoc.isEmpty())
664 t << "\t-$(DEL_FILE) $(OBJMOC)" << '\n'; 672 t << "\t-$(DEL_FILE) $(OBJMOC)" << '\n';
665 if(!srcMoc.isEmpty()) 673 if(!srcMoc.isEmpty())
666 t << "\t-$(DEL_FILE) $(SRCMOC)" << '\n'; 674 t << "\t-$(DEL_FILE) $(SRCMOC)" << '\n';
667 if(moc_incremental) 675 if(moc_incremental)
668 t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJMOC)" << '\n'; 676 t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJMOC)" << '\n';
669 clean_targets += " mocclean"; 677 clean_targets += " mocclean";
670 } 678 }
671 t << endl; 679 t << endl;
672 } 680 }
673 t << "uiclean:" << "\n"; 681 t << "uiclean:" << "\n";
674 if (!var("UICIMPLS").isEmpty() || !var("UICDECLS").isEmpty()) { 682 if (!var("UICIMPLS").isEmpty() || !var("UICDECLS").isEmpty()) {
675 t << "\t-$(DEL_FILE) $(UICIMPLS) $(UICDECLS)" << "\n"; 683 t << "\t-$(DEL_FILE) $(UICIMPLS) $(UICDECLS)" << "\n";
676 clean_targets += " uiclean"; 684 clean_targets += " uiclean";
677 } 685 }
678 t << endl; 686 t << endl;
679 687
688 t << "yaccclean:" << "\n";
689 if(!var("YACCSOURCES").isEmpty()) {
690 QStringList clean, &l = project->variables()["YACCSOURCES"];
691 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
692 QFileInfo fi((*it));
693 QString dir;
694 if(fi.dirPath() != ".")
695 dir = fi.dirPath() + Option::dir_sep;
696 dir = fileFixify(dir, QDir::currentDirPath(), Option::output_dir);
697 if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep)
698 dir += Option::dir_sep;
699 clean << dir + fi.baseName(TRUE) + Option::yacc_mod + Option::cpp_ext.first();
700 clean << dir + fi.baseName(TRUE) + Option::yacc_mod + Option::h_ext.first();
701 }
702 if(!clean.isEmpty()) {
703 t << "\t-$(DEL_FILE) " << clean.join(" ") << "\n";
704 clean_targets += " yaccclean";
705 }
706 }
707
708 t << "lexclean:" << "\n";
709 if(!var("LEXSOURCES").isEmpty()) {
710 QStringList clean, &l = project->variables()["LEXSOURCES"];
711 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
712 QFileInfo fi((*it));
713 QString dir;
714 if(fi.dirPath() != ".")
715 dir = fi.dirPath() + Option::dir_sep;
716 dir = fileFixify(dir, QDir::currentDirPath(), Option::output_dir);
717 if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep)
718 dir += Option::dir_sep;
719 clean << dir + fi.baseName(TRUE) + Option::lex_mod + Option::cpp_ext.first();
720 }
721 if(!clean.isEmpty()) {
722 t << "\t-$(DEL_FILE) " << clean.join(" ") << "\n";
723 clean_targets += " lexclean";
724 }
725 }
726
680 if(do_incremental) { 727 if(do_incremental) {
681 t << "incrclean:" << "\n"; 728 t << "incrclean:" << "\n";
682 if(src_incremental) 729 if(src_incremental)
683 t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJECTS)" << "\n"; 730 t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJECTS)" << "\n";
684 if(moc_incremental) 731 if(moc_incremental)
685 t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJMOC)" << '\n'; 732 t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJMOC)" << '\n';
686 t << endl; 733 t << endl;
687 } 734 }
688 735
689 t << "clean:" << clean_targets << "\n\t"; 736 t << "clean:" << clean_targets << "\n\t";
690 if(!project->isEmpty("OBJECTS")) 737 if(!project->isEmpty("OBJECTS"))
691 t << "-$(DEL_FILE) $(OBJECTS) " << "\n\t"; 738 t << "-$(DEL_FILE) $(OBJECTS) " << "\n\t";
692 if(!project->isEmpty("IMAGES")) 739 if(!project->isEmpty("IMAGES"))
693 t << varGlue("QMAKE_IMAGE_COLLECTION", "\t-$(DEL_FILE) ", " ", "") << "\n\t"; 740 t << varGlue("QMAKE_IMAGE_COLLECTION", "\t-$(DEL_FILE) ", " ", "") << "\n\t";
694 if(src_incremental) 741 if(src_incremental)
695 t << "-$(DEL_FILE) $(INCREMENTAL_OBJECTS)" << "\n\t"; 742 t << "-$(DEL_FILE) $(INCREMENTAL_OBJECTS)" << "\n\t";
696 t << varGlue("QMAKE_CLEAN","-$(DEL_FILE) "," ","\n\t") 743 t << varGlue("QMAKE_CLEAN","-$(DEL_FILE) "," ","\n\t")
697 << "-$(DEL_FILE) *~ core *.core" << "\n" 744 << "-$(DEL_FILE) *~ core *.core" << "\n"
698 << varGlue("CLEAN_FILES","\t-$(DEL_FILE) "," ","") << endl << endl; 745 << varGlue("CLEAN_FILES","\t-$(DEL_FILE) "," ","") << endl << endl;
699 t << "####### Sub-libraries" << endl << endl; 746 t << "####### Sub-libraries" << endl << endl;
700 if ( !project->variables()["SUBLIBS"].isEmpty() ) { 747 if ( !project->variables()["SUBLIBS"].isEmpty() ) {
701 QString libdir = "tmp/"; 748 QString libdir = "tmp/";
702 if(!project->isEmpty("SUBLIBS_DIR")) 749 if(!project->isEmpty("SUBLIBS_DIR"))
703 libdir = project->first("SUBLIBS_DIR"); 750 libdir = project->first("SUBLIBS_DIR");
704 QStringList &l = project->variables()["SUBLIBS"]; 751 QStringList &l = project->variables()["SUBLIBS"];
705 for(it = l.begin(); it != l.end(); ++it) 752 for(it = l.begin(); it != l.end(); ++it)
706 t << libdir << "lib" << (*it) << ".a" << ":\n\t" 753 t << libdir << "lib" << (*it) << ".a" << ":\n\t"
707 << var(QString("MAKELIB") + (*it)) << endl << endl; 754 << var(QString("MAKELIB") + (*it)) << endl << endl;
708 } 755 }
709 756
710 QString destdir = project->first("DESTDIR"); 757 QString destdir = project->first("DESTDIR");
711 if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep) 758 if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep)
712 destdir += Option::dir_sep; 759 destdir += Option::dir_sep;
713 t << "distclean: " << "clean\n\t" 760 t << "distclean: " << "clean\n";
714 << "-$(DEL_FILE) " << destdir << "$(TARGET)" << " " << "$(TARGET)" << "\n"; 761 if(project->first("TEMPLATE") == "app" &&
762 project->isActiveConfig("resource_fork") && !project->isActiveConfig("console"))
763 t << "\t-$(DEL_FILE) -r " << destdir.section(Option::dir_sep, 0, -4) << "\n";
764 else
765 t << "\t-$(DEL_FILE) " << destdir << "$(TARGET)" << " " << "$(TARGET)" << "\n";
715 if(!project->isActiveConfig("staticlib") && project->variables()["QMAKE_APP_FLAG"].isEmpty() && 766 if(!project->isActiveConfig("staticlib") && project->variables()["QMAKE_APP_FLAG"].isEmpty() &&
716 !project->isActiveConfig("plugin")) 767 !project->isActiveConfig("plugin"))
717 t << "\t-$(DEL_FILE) " << destdir << "$(TARGET0) " << destdir << "$(TARGET1) " 768 t << "\t-$(DEL_FILE) " << destdir << "$(TARGET0) " << destdir << "$(TARGET1) "
718 << destdir << "$(TARGET2) $(TARGETA)" << "\n"; 769 << destdir << "$(TARGET2) $(TARGETA)" << "\n";
719 t << endl << endl; 770 t << endl << endl;
720 771
721 if ( !project->isEmpty("PRECOMPH") ) { 772 if ( !project->isEmpty("PRECOMPH") ) {
722 QString outdir = project->first("MOC_DIR"); 773 QString outdir = project->first("MOC_DIR");
723 QString qt_dot_h = Option::fixPathToLocalOS(project->first("PRECOMPH")); 774 QString qt_dot_h = Option::fixPathToLocalOS(project->first("PRECOMPH"));
724 t << "###### Combined headers" << endl << endl; 775 t << "###### Combined headers" << endl << endl;
725 //XXX 776 //XXX
726 t << outdir << "allmoc.cpp: " << qt_dot_h << " " 777 t << outdir << "allmoc.cpp: " << qt_dot_h << " "
727 << varList("HEADERS_ORIG") << "\n\t" 778 << varList("HEADERS_ORIG") << "\n\t"
728 << "echo '#include \"" << qt_dot_h << "\"' >" << outdir << "allmoc.cpp" << "\n\t" 779 << "echo '#include \"" << qt_dot_h << "\"' >" << outdir << "allmoc.cpp" << "\n\t"
729 << "$(CXX) -E -DQT_MOC_CPP -DQT_NO_STL $(CXXFLAGS) $(INCPATH) >" << outdir << "allmoc.h " 780 << "$(CXX) -E -DQT_MOC_CPP -DQT_NO_STL $(CXXFLAGS) $(INCPATH) >" << outdir << "allmoc.h "
730 << outdir << "allmoc.cpp" << "\n\t" 781 << outdir << "allmoc.cpp" << "\n\t"
731 << "$(MOC) -o " << outdir << "allmoc.cpp " << outdir << "allmoc.h" << "\n\t" 782 << "$(MOC) -o " << outdir << "allmoc.cpp " << outdir << "allmoc.h" << "\n\t"
732 << "perl -pi -e 's{#include \"allmoc.h\"}{#define QT_H_CPP\\n#include \"" 783 << "perl -pi -e 's{#include \"allmoc.h\"}{#define QT_H_CPP\\n#include \""
733 << qt_dot_h << "\"}' " << outdir << "allmoc.cpp" << "\n\t" 784 << qt_dot_h << "\"}' " << outdir << "allmoc.cpp" << "\n\t"
734 << "$(DEL_FILE) " << outdir << "allmoc.h" << endl << endl; 785 << "$(DEL_FILE) " << outdir << "allmoc.h" << endl << endl;
735 } 786 }
736 787
737 // blasted user defined targets 788 // blasted user defined targets
738 QStringList &qut = project->variables()["QMAKE_EXTRA_UNIX_TARGETS"]; 789 QStringList &qut = project->variables()["QMAKE_EXTRA_UNIX_TARGETS"];
@@ -823,147 +874,148 @@ UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
823 t << mkfile << ": " << "\n\t"; 874 t << mkfile << ": " << "\n\t";
824 if(have_dir) 875 if(have_dir)
825 t << "cd " << (*it)->directory << " && "; 876 t << "cd " << (*it)->directory << " && ";
826 t << "$(QMAKE) " << (*it)->profile << buildArgs() << out << endl; 877 t << "$(QMAKE) " << (*it)->profile << buildArgs() << out << endl;
827 //actually compile 878 //actually compile
828 t << (*it)->target << ": " << mkfile << " FORCE" << "\n\t"; 879 t << (*it)->target << ": " << mkfile << " FORCE" << "\n\t";
829 if(have_dir) 880 if(have_dir)
830 t << "cd " << (*it)->directory << " && "; 881 t << "cd " << (*it)->directory << " && ";
831 t << "$(MAKE) -f " << (*it)->makefile << endl << endl; 882 t << "$(MAKE) -f " << (*it)->makefile << endl << endl;
832 } 883 }
833 884
834 if (project->isActiveConfig("ordered")) { // generate dependencies 885 if (project->isActiveConfig("ordered")) { // generate dependencies
835 for( it.toFirst(); it.current(); ) { 886 for( it.toFirst(); it.current(); ) {
836 QString tar = it.current()->target; 887 QString tar = it.current()->target;
837 ++it; 888 ++it;
838 if (it.current()) 889 if (it.current())
839 t << it.current()->target << ": " << tar << endl; 890 t << it.current()->target << ": " << tar << endl;
840 } 891 }
841 t << endl; 892 t << endl;
842 } 893 }
843 894
844 writeMakeQmake(t); 895 writeMakeQmake(t);
845 896
846 if(project->isEmpty("SUBDIRS")) { 897 if(project->isEmpty("SUBDIRS")) {
847 t << "all qmake_all distclean install uiclean mocclean clean: FORCE" << endl; 898 t << "all qmake_all distclean install uiclean mocclean lexclean yaccclean clean: FORCE" << endl;
848 } else { 899 } else {
849 t << "all: $(SUBTARGETS)" << endl; 900 t << "all: $(SUBTARGETS)" << endl;
850 t << "qmake_all:"; 901 t << "qmake_all:";
851 for( it.toFirst(); it.current(); ++it) { 902 for( it.toFirst(); it.current(); ++it) {
852 t << " "; 903 t << " ";
853 if(!(*it)->directory.isEmpty()) 904 if(!(*it)->directory.isEmpty())
854 t << (*it)->directory << Option::dir_sep; 905 t << (*it)->directory << Option::dir_sep;
855 t << (*it)->makefile; 906 t << (*it)->makefile;
856 } 907 }
857 for( it.toFirst(); it.current(); ++it) { 908 for( it.toFirst(); it.current(); ++it) {
858 t << "\n\t ( "; 909 t << "\n\t ( ";
859 if(!(*it)->directory.isEmpty()) 910 if(!(*it)->directory.isEmpty())
860 t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; "; 911 t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; ";
861 t << "grep \"^qmake_all:\" " << (*it)->makefile 912 t << "grep \"^qmake_all:\" " << (*it)->makefile
862 << " && $(MAKE) -f " << (*it)->makefile << " qmake_all" << "; ) || true"; 913 << " && $(MAKE) -f " << (*it)->makefile << " qmake_all" << "; ) || true";
863 } 914 }
864 t << endl; 915 t << endl;
865 t << "clean uninstall install uiclean mocclean: qmake_all FORCE"; 916 t << "clean uninstall install uiclean mocclean lexclean yaccclean: qmake_all FORCE";
866 for( it.toFirst(); it.current(); ++it) { 917 for( it.toFirst(); it.current(); ++it) {
867 t << "\n\t ( "; 918 t << "\n\t ( ";
868 if(!(*it)->directory.isEmpty()) 919 if(!(*it)->directory.isEmpty())
869 t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; "; 920 t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; ";
870 t << "$(MAKE) -f " << (*it)->makefile << " $@" << "; ) || true"; 921 t << "$(MAKE) -f " << (*it)->makefile << " $@" << "; ) || true";
871 } 922 }
872 t << endl; 923 t << endl;
873 t << "distclean: qmake_all FORCE"; 924 t << "distclean: qmake_all FORCE";
874 for( it.toFirst(); it.current(); ++it) { 925 for( it.toFirst(); it.current(); ++it) {
875 t << "\n\t ( "; 926 t << "\n\t ( ";
876 if(!(*it)->directory.isEmpty()) 927 if(!(*it)->directory.isEmpty())
877 t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; "; 928 t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; ";
878 t << "$(MAKE) -f " << (*it)->makefile << " $@; $(DEL_FILE) " << (*it)->makefile << "; ) || true"; 929 t << "$(MAKE) -f " << (*it)->makefile << " $@; $(DEL_FILE) " << (*it)->makefile << "; ) || true";
879 } 930 }
880 t << endl << endl; 931 t << endl << endl;
881 } 932 }
882 t <<"FORCE:" << endl << endl; 933 t <<"FORCE:" << endl << endl;
883} 934}
884 935
885void UnixMakefileGenerator::init2() 936void UnixMakefileGenerator::init2()
886{ 937{
887 //version handling 938 //version handling
888 if(project->variables()["VERSION"].isEmpty()) 939 if(project->variables()["VERSION"].isEmpty())
889 project->variables()["VERSION"].append("1.0." + 940 project->variables()["VERSION"].append("1.0." +
890 (project->isEmpty("VER_PAT") ? QString("0") : 941 (project->isEmpty("VER_PAT") ? QString("0") :
891 project->first("VER_PAT")) ); 942 project->first("VER_PAT")) );
892 QStringList l = QStringList::split('.', project->first("VERSION")); 943 QStringList l = QStringList::split('.', project->first("VERSION"));
893 l << "0" << "0"; //make sure there are three 944 l << "0" << "0"; //make sure there are three
894 project->variables()["VER_MAJ"].append(l[0]); 945 project->variables()["VER_MAJ"].append(l[0]);
895 project->variables()["VER_MIN"].append(l[1]); 946 project->variables()["VER_MIN"].append(l[1]);
896 project->variables()["VER_PAT"].append(l[2]); 947 project->variables()["VER_PAT"].append(l[2]);
897 948
898 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { 949 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
899#if 0 950#if 0
900 if ( project->isActiveConfig("dll") ) { 951 if ( project->isActiveConfig("dll") ) {
901 project->variables()["TARGET"] += project->variables()["TARGET.so"]; 952 project->variables()["TARGET"] += project->variables()["TARGET.so"];
902 if(project->variables()["QMAKE_LFLAGS_SHAPP"].isEmpty()) 953 if(project->variables()["QMAKE_LFLAGS_SHAPP"].isEmpty())
903 project->variables()["QMAKE_LFLAGS_SHAPP"] += project->variables()["QMAKE_LFLAGS_SHLIB"]; 954 project->variables()["QMAKE_LFLAGS_SHAPP"] += project->variables()["QMAKE_LFLAGS_SHLIB"];
904 if(!project->variables()["QMAKE_LFLAGS_SONAME"].isEmpty()) 955 if(!project->variables()["QMAKE_LFLAGS_SONAME"].isEmpty())
905 project->variables()["QMAKE_LFLAGS_SONAME"].first() += project->first("TARGET"); 956 project->variables()["QMAKE_LFLAGS_SONAME"].first() += project->first("TARGET");
906 } 957 }
907#endif 958#endif
908 project->variables()["TARGET"].first().prepend(project->first("DESTDIR")); 959 project->variables()["TARGET"].first().prepend(project->first("DESTDIR"));
960 if ( !project->variables()["QMAKE_CYGWIN_EXE"].isEmpty() )
961 project->variables()["TARGET_EXT"].append(".exe");
909 } else if ( project->isActiveConfig("staticlib") ) { 962 } else if ( project->isActiveConfig("staticlib") ) {
910 project->variables()["TARGET"].first().prepend("lib"); 963 project->variables()["TARGET"].first().prepend("lib");
911 project->variables()["TARGET"].first() += ".a"; 964 project->variables()["TARGET"].first() += ".a";
912 if(project->variables()["QMAKE_AR_CMD"].isEmpty()) 965 if(project->variables()["QMAKE_AR_CMD"].isEmpty())
913 project->variables()["QMAKE_AR_CMD"].append("$(AR) $(TARGET) $(OBJECTS) $(OBJMOC)"); 966 project->variables()["QMAKE_AR_CMD"].append("$(AR) $(TARGET) $(OBJECTS) $(OBJMOC)");
914 } else { 967 } else {
915 project->variables()["TARGETA"].append(project->first("DESTDIR") + "lib" + project->first("TARGET") + ".a"); 968 project->variables()["TARGETA"].append(project->first("DESTDIR") + "lib" + project->first("TARGET") + ".a");
916 if ( !project->variables()["QMAKE_AR_CMD"].isEmpty() ) 969 if ( !project->variables()["QMAKE_AR_CMD"].isEmpty() )
917 project->variables()["QMAKE_AR_CMD"].first().replace("(TARGET)","(TARGETA)"); 970 project->variables()["QMAKE_AR_CMD"].first().replace("(TARGET)","(TARGETA)");
918 else 971 else
919 project->variables()["QMAKE_AR_CMD"].append("$(AR) $(TARGETA) $(OBJECTS) $(OBJMOC)"); 972 project->variables()["QMAKE_AR_CMD"].append("$(AR) $(TARGETA) $(OBJECTS) $(OBJMOC)");
920 QString os = project->variables()["QMAKESPEC"].first().section( '-', 0, 0 );
921 if( project->isActiveConfig("plugin") ) { 973 if( project->isActiveConfig("plugin") ) {
922 project->variables()["TARGET_x.y.z"].append("lib" + 974 project->variables()["TARGET_x.y.z"].append("lib" +
923 project->first("TARGET") + "." + project->first("QMAKE_EXTENSION_SHLIB")); 975 project->first("TARGET") + "." + project->first("QMAKE_EXTENSION_SHLIB"));
924 if(project->isActiveConfig("lib_version_first")) 976 if(project->isActiveConfig("lib_version_first"))
925 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + 977 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
926 project->first("VER_MAJ") + "." + 978 project->first("VER_MAJ") + "." +
927 project->first("QMAKE_EXTENSION_SHLIB")); 979 project->first("QMAKE_EXTENSION_SHLIB"));
928 else 980 else
929 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + 981 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
930 project->first("QMAKE_EXTENSION_SHLIB") + 982 project->first("QMAKE_EXTENSION_SHLIB") +
931 "." + project->first("VER_MAJ")); 983 "." + project->first("VER_MAJ"));
932 984
933 project->variables()["TARGET"] = project->variables()["TARGET_x.y.z"]; 985 project->variables()["TARGET"] = project->variables()["TARGET_x.y.z"];
934 if(project->isActiveConfig("qt")) 986 if(project->isActiveConfig("qt"))
935 project->variables()["DEFINES"].append("QT_PLUGIN"); 987 project->variables()["DEFINES"].append("QT_PLUGIN");
936 } else if ( os == "hpux" ) { 988 } else if ( !project->isEmpty("QMAKE_HPUX_SHLIB") ) {
937 project->variables()["TARGET_"].append("lib" + project->first("TARGET") + ".sl"); 989 project->variables()["TARGET_"].append("lib" + project->first("TARGET") + ".sl");
938 if(project->isActiveConfig("lib_version_first")) 990 if(project->isActiveConfig("lib_version_first"))
939 project->variables()["TARGET_x"].append("lib" + project->first("VER_MAJ") + "." + 991 project->variables()["TARGET_x"].append("lib" + project->first("VER_MAJ") + "." +
940 project->first("TARGET")); 992 project->first("TARGET"));
941 else 993 else
942 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + 994 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
943 project->first("VER_MAJ")); 995 project->first("VER_MAJ"));
944 project->variables()["TARGET"] = project->variables()["TARGET_x"]; 996 project->variables()["TARGET"] = project->variables()["TARGET_x"];
945 } else if ( os == "aix" ) { 997 } else if ( !project->isEmpty("QMAKE_AIX_SHLIB") ) {
946 project->variables()["TARGET_"].append("lib" + project->first("TARGET") + ".a"); 998 project->variables()["TARGET_"].append("lib" + project->first("TARGET") + ".a");
947 if(project->isActiveConfig("lib_version_first")) { 999 if(project->isActiveConfig("lib_version_first")) {
948 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + 1000 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
949 project->first("VER_MAJ") + "." + 1001 project->first("VER_MAJ") + "." +
950 project->first("QMAKE_EXTENSION_SHLIB")); 1002 project->first("QMAKE_EXTENSION_SHLIB"));
951 project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." + 1003 project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." +
952 project->first("VER_MAJ") + 1004 project->first("VER_MAJ") +
953 "." + project->first("VER_MIN") + "." + 1005 "." + project->first("VER_MIN") + "." +
954 project->first("QMAKE_EXTENSION_SHLIB")); 1006 project->first("QMAKE_EXTENSION_SHLIB"));
955 project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") + "." + 1007 project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") + "." +
956 project->first("VER_MAJ") + "." + 1008 project->first("VER_MAJ") + "." +
957 project->first("VER_MIN") + "." + 1009 project->first("VER_MIN") + "." +
958 project->first("VER_PAT") + "." + 1010 project->first("VER_PAT") + "." +
959 project->first("QMAKE_EXTENSION_SHLIB")); 1011 project->first("QMAKE_EXTENSION_SHLIB"));
960 } else { 1012 } else {
961 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + 1013 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
962 project->first("QMAKE_EXTENSION_SHLIB") + 1014 project->first("QMAKE_EXTENSION_SHLIB") +
963 "." + project->first("VER_MAJ")); 1015 "." + project->first("VER_MAJ"));
964 project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." + 1016 project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." +
965 project->first("QMAKE_EXTENSION_SHLIB") + 1017 project->first("QMAKE_EXTENSION_SHLIB") +
966 "." + project->first("VER_MAJ") + 1018 "." + project->first("VER_MAJ") +
967 "." + project->first("VER_MIN")); 1019 "." + project->first("VER_MIN"));
968 project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") + "." + 1020 project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") + "." +
969 project->first("QMAKE_EXTENSION_SHLIB") + "." + 1021 project->first("QMAKE_EXTENSION_SHLIB") + "." +
@@ -990,50 +1042,57 @@ void UnixMakefileGenerator::init2()
990 project->variables()["QMAKE_EXTENSION_SHLIB"].first()); 1042 project->variables()["QMAKE_EXTENSION_SHLIB"].first());
991 } else { 1043 } else {
992 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + 1044 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
993 project->first("QMAKE_EXTENSION_SHLIB") + 1045 project->first("QMAKE_EXTENSION_SHLIB") +
994 "." + project->first("VER_MAJ")); 1046 "." + project->first("VER_MAJ"));
995 project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." + 1047 project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." +
996 project->first("QMAKE_EXTENSION_SHLIB") 1048 project->first("QMAKE_EXTENSION_SHLIB")
997 + "." + project->first("VER_MAJ") + 1049 + "." + project->first("VER_MAJ") +
998 "." + project->first("VER_MIN")); 1050 "." + project->first("VER_MIN"));
999 project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") + 1051 project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") +
1000 "." + 1052 "." +
1001 project->variables()[ 1053 project->variables()[
1002 "QMAKE_EXTENSION_SHLIB"].first() + "." + 1054 "QMAKE_EXTENSION_SHLIB"].first() + "." +
1003 project->first("VER_MAJ") + "." + 1055 project->first("VER_MAJ") + "." +
1004 project->first("VER_MIN") + "." + 1056 project->first("VER_MIN") + "." +
1005 project->first("VER_PAT")); 1057 project->first("VER_PAT"));
1006 } 1058 }
1007 project->variables()["TARGET"] = project->variables()["TARGET_x.y.z"]; 1059 project->variables()["TARGET"] = project->variables()["TARGET_x.y.z"];
1008 } 1060 }
1009 if(project->isEmpty("QMAKE_LN_SHLIB")) 1061 if(project->isEmpty("QMAKE_LN_SHLIB"))
1010 project->variables()["QMAKE_LN_SHLIB"].append("ln -s"); 1062 project->variables()["QMAKE_LN_SHLIB"].append("ln -s");
1011 project->variables()["DESTDIR_TARGET"].append("$(TARGET)"); 1063 project->variables()["DESTDIR_TARGET"].append("$(TARGET)");
1012 if ( !project->variables()["DESTDIR"].isEmpty() ) 1064 if ( !project->variables()["DESTDIR"].isEmpty() )
1013 project->variables()["DESTDIR_TARGET"].first().prepend(project->first("DESTDIR")); 1065 project->variables()["DESTDIR_TARGET"].first().prepend(project->first("DESTDIR"));
1014 if ( !project->variables()["QMAKE_LFLAGS_SONAME"].isEmpty() && !project->variables()["TARGET_x"].isEmpty() ) 1066 if ( !project->variables()["QMAKE_LFLAGS_SONAME"].isEmpty()) {
1067 if(project->isActiveConfig("plugin")) {
1068 if(!project->variables()["TARGET"].isEmpty() )
1069 project->variables()["QMAKE_LFLAGS_SONAME"].first() += project->first("TARGET");
1070 } else {
1071 if(!project->variables()["TARGET_x"].isEmpty() )
1015 project->variables()["QMAKE_LFLAGS_SONAME"].first() += project->first("TARGET_x"); 1072 project->variables()["QMAKE_LFLAGS_SONAME"].first() += project->first("TARGET_x");
1073 }
1074 }
1016 if ( project->variables()["QMAKE_LINK_SHLIB_CMD"].isEmpty() ) 1075 if ( project->variables()["QMAKE_LINK_SHLIB_CMD"].isEmpty() )
1017 project->variables()["QMAKE_LINK_SHLIB_CMD"].append( 1076 project->variables()["QMAKE_LINK_SHLIB_CMD"].append(
1018 "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)"); 1077 "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)");
1019 } 1078 }
1020 if(project->isEmpty("QMAKE_SYMBOLIC_LINK")) 1079 if(project->isEmpty("QMAKE_SYMBOLIC_LINK"))
1021 project->variables()["QMAKE_SYMBOLIC_LINK"].append("ln -sf"); 1080 project->variables()["QMAKE_SYMBOLIC_LINK"].append("ln -sf");
1022 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { 1081 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
1023 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SHAPP"]; 1082 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SHAPP"];
1024 } else if ( project->isActiveConfig("dll") ) { 1083 } else if ( project->isActiveConfig("dll") ) {
1025 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_SHLIB"]; 1084 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_SHLIB"];
1026 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_SHLIB"]; 1085 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_SHLIB"];
1027 if ( project->isActiveConfig("plugin") ) { 1086 if ( project->isActiveConfig("plugin") ) {
1028 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_PLUGIN"]; 1087 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_PLUGIN"];
1029 if( !project->isActiveConfig("plugin_no_soname") ) 1088 if( !project->isActiveConfig("plugin_no_soname") )
1030 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SONAME"]; 1089 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SONAME"];
1031 } else { 1090 } else {
1032 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SHLIB"]; 1091 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SHLIB"];
1033 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SONAME"]; 1092 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SONAME"];
1034 } 1093 }
1035 QString destdir = project->first("DESTDIR"); 1094 QString destdir = project->first("DESTDIR");
1036 if ( !destdir.isEmpty() && !project->variables()["QMAKE_RPATH"].isEmpty() ) { 1095 if ( !destdir.isEmpty() && !project->variables()["QMAKE_RPATH"].isEmpty() ) {
1037 QString rpath_destdir = destdir; 1096 QString rpath_destdir = destdir;
1038 if(QDir::isRelativePath(rpath_destdir)) { 1097 if(QDir::isRelativePath(rpath_destdir)) {
1039 QFileInfo fi(Option::fixPathToLocalOS(rpath_destdir)); 1098 QFileInfo fi(Option::fixPathToLocalOS(rpath_destdir));
diff --git a/qmake/generators/win32/borland_bmake.cpp b/qmake/generators/win32/borland_bmake.cpp
index ae7b47b..26eea88 100644
--- a/qmake/generators/win32/borland_bmake.cpp
+++ b/qmake/generators/win32/borland_bmake.cpp
@@ -111,160 +111,171 @@ BorlandMakefileGenerator::writeBorlandParts(QTextStream &t)
111 t << var("QMAKE_LFLAGS") << endl; 111 t << var("QMAKE_LFLAGS") << endl;
112 t << "LIBS =" << var("QMAKE_LIBS") << endl; 112 t << "LIBS =" << var("QMAKE_LIBS") << endl;
113 } 113 }
114 else { 114 else {
115 t << "LIB =" << var("QMAKE_LIB") << endl; 115 t << "LIB =" << var("QMAKE_LIB") << endl;
116 } 116 }
117 t << "MOC =" << (project->isEmpty("QMAKE_MOC") ? QString("moc") : 117 t << "MOC =" << (project->isEmpty("QMAKE_MOC") ? QString("moc") :
118 Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl; 118 Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl;
119 t << "UIC =" << (project->isEmpty("QMAKE_UIC") ? QString("uic") : 119 t << "UIC =" << (project->isEmpty("QMAKE_UIC") ? QString("uic") :
120 Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl; 120 Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl;
121 t << "QMAKE = " << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : 121 t << "QMAKE = " << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") :
122 Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl; 122 Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl;
123 t << "IDC =" << (project->isEmpty("QMAKE_IDC") ? QString("idc") : 123 t << "IDC =" << (project->isEmpty("QMAKE_IDC") ? QString("idc") :
124 Option::fixPathToTargetOS(var("QMAKE_IDC"), FALSE)) << endl; 124 Option::fixPathToTargetOS(var("QMAKE_IDC"), FALSE)) << endl;
125 t << "IDL =" << (project->isEmpty("QMAKE_IDL") ? QString("midl") : 125 t << "IDL =" << (project->isEmpty("QMAKE_IDL") ? QString("midl") :
126 Option::fixPathToTargetOS(var("QMAKE_IDL"), FALSE)) << endl; 126 Option::fixPathToTargetOS(var("QMAKE_IDL"), FALSE)) << endl;
127 t << "ZIP =" << var("QMAKE_ZIP") << endl; 127 t << "ZIP =" << var("QMAKE_ZIP") << endl;
128 t << "DEF_FILE =" << varList("DEF_FILE") << endl; 128 t << "DEF_FILE =" << varList("DEF_FILE") << endl;
129 t << "RES_FILE =" << varList("RES_FILE") << endl; 129 t << "RES_FILE =" << varList("RES_FILE") << endl;
130 t << "COPY_FILE = " << var("QMAKE_COPY") << endl; 130 t << "COPY_FILE = " << var("QMAKE_COPY") << endl;
131 t << "COPY_DIR = " << var("QMAKE_COPY") << endl; 131 t << "COPY_DIR = " << var("QMAKE_COPY") << endl;
132 t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; 132 t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl;
133 t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl; 133 t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl;
134 t << "MOVE = " << var("QMAKE_MOVE") << endl; 134 t << "MOVE = " << var("QMAKE_MOVE") << endl;
135 t << "CHK_DIR_EXISTS =" << var("QMAKE_CHK_DIR_EXISTS") << endl;
136 t << "MKDIR =" << var("QMAKE_MKDIR") << endl;
135 t << endl; 137 t << endl;
136 138
137 t << "####### Files" << endl << endl; 139 t << "####### Files" << endl << endl;
138 t << "HEADERS =" << varList("HEADERS") << endl; 140 t << "HEADERS =" << varList("HEADERS") << endl;
139 t << "SOURCES =" << varList("SOURCES") << endl; 141 t << "SOURCES =" << varList("SOURCES") << endl;
140 t << "OBJECTS =" << varList("OBJECTS") << endl; 142 t << "OBJECTS =" << varList("OBJECTS") << endl;
141 t << "FORMS =" << varList("FORMS") << endl; 143 t << "FORMS =" << varList("FORMS") << endl;
142 t << "UICDECLS =" << varList("UICDECLS") << endl; 144 t << "UICDECLS =" << varList("UICDECLS") << endl;
143 t << "UICIMPLS =" << varList("UICIMPLS") << endl; 145 t << "UICIMPLS =" << varList("UICIMPLS") << endl;
144 t << "SRCMOC =" << varList("SRCMOC") << endl; 146 t << "SRCMOC =" << varList("SRCMOC") << endl;
145 t << "OBJMOC =" << varList("OBJMOC") << endl; 147 t << "OBJMOC =" << varList("OBJMOC") << endl;
146 t << "DIST =" << varList("DISTFILES") << endl; 148 t << "DIST =" << varList("DISTFILES") << endl;
147 t << "TARGET =" 149 t << "TARGET ="
148 << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT")) 150 << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT"))
149 << endl; 151 << endl;
150 t << endl; 152 t << endl;
151 153
152 t << "####### Implicit rules" << endl << endl; 154 t << "####### Implicit rules" << endl << endl;
153 t << ".SUFFIXES: .cpp .cxx .cc .c" << endl << endl; 155 t << ".SUFFIXES: .c";
154 t << ".cpp.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; 156 QStringList::Iterator cppit;
155 t << ".cxx.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; 157 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
156 t << ".cc.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; 158 t << " " << (*cppit);
157 t << ".c.obj:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl; 159 t << endl << endl;
160 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
161 t << (*cppit) << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
162 t << ".c" << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;
158 163
159 t << "####### Build rules" << endl << endl; 164 t << "####### Build rules" << endl << endl;
160 t << "all: " << varGlue("ALL_DEPS",""," "," ") << " $(TARGET)" << endl << endl; 165 t << "all: " << varGlue("ALL_DEPS",""," "," ") << " $(TARGET)" << endl << endl;
161 t << "$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) " << var("TARGETDEPS"); 166 t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) "
167 << var("POST_TARGETDEPS");
162 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) { 168 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
163 t << "\n\t" << "$(LINK) @&&|" << "\n\t" 169 t << "\n\t" << "$(LINK) @&&|" << "\n\t"
164 << "$(LFLAGS) $(OBJECTS) $(OBJMOC),$(TARGET),,$(LIBS),$(DEF_FILE),$(RES_FILE)"; 170 << "$(LFLAGS) $(OBJECTS) $(OBJMOC),$(TARGET),,$(LIBS),$(DEF_FILE),$(RES_FILE)";
165 } else { 171 } else {
166 t << "\n\t-del $(TARGET)" 172 t << "\n\t-del $(TARGET)"
167 << "\n\t" << "$(LIB) $(TARGET) @&&|" << " \n+" 173 << "\n\t" << "$(LIB) $(TARGET) @&&|" << " \n+"
168 << project->variables()["OBJECTS"].join(" \\\n+") << " \\\n+" 174 << project->variables()["OBJECTS"].join(" \\\n+") << " \\\n+"
169 << project->variables()["OBJMOC"].join(" \\\n+"); 175 << project->variables()["OBJMOC"].join(" \\\n+");
170 } 176 }
171 t << endl << "|" << endl; 177 t << endl << "|" << endl;
178
179 if ( !project->variables()["QMAKE_POST_LINK"].isEmpty() )
180 t << "\t" <<var("QMAKE_POST_LINK") << endl;
181
172 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) { 182 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) {
173 QStringList dlldirs = project->variables()["DLLDESTDIR"]; 183 QStringList dlldirs = project->variables()["DLLDESTDIR"];
174 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) { 184 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) {
175 t << "\n\t" << "-copy $(TARGET) " << *dlldir; 185 t << "\n\t" << "-copy $(TARGET) " << *dlldir;
176 } 186 }
177 } 187 }
178 QString targetfilename = project->variables()["TARGET"].first(); 188 QString targetfilename = project->variables()["TARGET"].first();
179 if(project->isActiveConfig("activeqt")) { 189 if(project->isActiveConfig("activeqt")) {
180 QString version = project->variables()["VERSION"].first(); 190 QString version = project->variables()["VERSION"].first();
181 if ( version.isEmpty() ) 191 if ( version.isEmpty() )
182 version = "1.0"; 192 version = "1.0";
183 193
184 if ( project->isActiveConfig("dll")) { 194 if ( project->isActiveConfig("dll")) {
185 t << "\n\t" << ("-$(IDC) $(TARGET) /idl tmp\\" + targetfilename + ".idl -version " + version); 195 t << "\n\t" << ("-$(IDC) $(TARGET) /idl tmp\\" + targetfilename + ".idl -version " + version);
186 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl"); 196 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl");
187 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb"); 197 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb");
188 t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" ); 198 t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" );
189 } else { 199 } else {
190 t << "\n\t" << ("-$(TARGET) -dumpidl tmp\\" + targetfilename + ".idl -version " + version); 200 t << "\n\t" << ("-$(TARGET) -dumpidl tmp\\" + targetfilename + ".idl -version " + version);
191 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl"); 201 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl");
192 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb"); 202 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb");
193 t << "\n\t" << ("-$(TARGET) -regserver"); 203 t << "\n\t" << ("-$(TARGET) -regserver");
194 } 204 }
195 } 205 }
196 t << endl << endl; 206 t << endl << endl;
197 207
198 if(!project->variables()["RC_FILE"].isEmpty()) { 208 if(!project->variables()["RC_FILE"].isEmpty()) {
199 t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t" 209 t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t"
200 << var("QMAKE_RC") << " " << var("RC_FILE") << endl << endl; 210 << var("QMAKE_RC") << " " << var("RC_FILE") << endl << endl;
201 } 211 }
202 t << "mocables: $(SRCMOC)" << endl << endl; 212 t << "mocables: $(SRCMOC)" << endl << endl;
203 213
204 writeMakeQmake(t); 214 writeMakeQmake(t);
205 215
206 t << "dist:" << "\n\t" 216 t << "dist:" << "\n\t"
207 << "$(ZIP) " << var("PROJECT") << ".zip " << var("PROJECT") << ".pro $(SOURCES) $(HEADERS) $(DIST) $(FORMS)" 217 << "$(ZIP) " << var("PROJECT") << ".zip " << var("PROJECT") << ".pro $(SOURCES) $(HEADERS) $(DIST) $(FORMS)"
208 << endl << endl; 218 << endl << endl;
209 219
210 t << "clean:\n" 220 t << "clean:\n"
211 << varGlue("OBJECTS","\t-del ","\n\t-del ","") 221 << varGlue("OBJECTS","\t-del ","\n\t-del ","")
212 << varGlue("SRCMOC" ,"\n\t-del ","\n\t-del ","") 222 << varGlue("SRCMOC" ,"\n\t-del ","\n\t-del ","")
213 << varGlue("OBJMOC" ,"\n\t-del ","\n\t-del ","") 223 << varGlue("OBJMOC" ,"\n\t-del ","\n\t-del ","")
214 << varGlue("UICDECLS" ,"\n\t-del ","\n\t-del ","") 224 << varGlue("UICDECLS" ,"\n\t-del ","\n\t-del ","")
215 << varGlue("UICIMPLS" ,"\n\t-del ","\n\t-del ","") 225 << varGlue("UICIMPLS" ,"\n\t-del ","\n\t-del ","")
216 << "\n\t-del $(TARGET)"
217 << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ","") 226 << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ","")
218 << varGlue("CLEAN_FILES","\n\t-del ","\n\t-del ",""); 227 << varGlue("CLEAN_FILES","\n\t-del ","\n\t-del ","");
219 if ( project->isActiveConfig("activeqt")) { 228 if ( project->isActiveConfig("activeqt")) {
220 t << ("\n\t-del tmp\\" + targetfilename + ".*"); 229 t << ("\n\t-del tmp\\" + targetfilename + ".*");
221 t << "\n\t-del tmp\\dump.*"; 230 t << "\n\t-del tmp\\dump.*";
222 } 231 }
223 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty())
224 t << "\n\t-del " << var("DLLDESTDIR") << "\\" << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first();
225 if(!project->isEmpty("IMAGES")) 232 if(!project->isEmpty("IMAGES"))
226 t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-del ", "\n\t-del ", ""); 233 t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-del ", "\n\t-del ", "");
227 234
228 // blasted user defined targets 235 // blasted user defined targets
229 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"]; 236 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"];
230 for(QStringList::Iterator it = qut.begin(); it != qut.end(); ++it) { 237 for(QStringList::Iterator it = qut.begin(); it != qut.end(); ++it) {
231 QString targ = var((*it) + ".target"), 238 QString targ = var((*it) + ".target"),
232 cmd = var((*it) + ".commands"), deps; 239 cmd = var((*it) + ".commands"), deps;
233 if(targ.isEmpty()) 240 if(targ.isEmpty())
234 targ = (*it); 241 targ = (*it);
235 QStringList &deplist = project->variables()[(*it) + ".depends"]; 242 QStringList &deplist = project->variables()[(*it) + ".depends"];
236 for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) { 243 for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) {
237 QString dep = var((*dep_it) + ".target"); 244 QString dep = var((*dep_it) + ".target");
238 if(dep.isEmpty()) 245 if(dep.isEmpty())
239 dep = (*dep_it); 246 dep = (*dep_it);
240 deps += " " + dep; 247 deps += " " + dep;
241 } 248 }
242 t << "\n\n" << targ << ":" << deps << "\n\t" 249 t << "\n\n" << targ << ":" << deps << "\n\t"
243 << cmd; 250 << cmd;
244 } 251 }
245 252
246 t << endl << endl; 253 t << endl << endl;
254
255 t << "distclean: clean"
256 << "\n\t-del $(TARGET)"
257 << endl << endl;
247} 258}
248 259
249void 260void
250BorlandMakefileGenerator::init() 261BorlandMakefileGenerator::init()
251{ 262{
252 if(init_flag) 263 if(init_flag)
253 return; 264 return;
254 init_flag = TRUE; 265 init_flag = TRUE;
255 266
256 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"]; 267 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"];
257 268
258 /* this should probably not be here, but I'm using it to wrap the .t files */ 269 /* this should probably not be here, but I'm using it to wrap the .t files */
259 if(project->first("TEMPLATE") == "app") 270 if(project->first("TEMPLATE") == "app")
260 project->variables()["QMAKE_APP_FLAG"].append("1"); 271 project->variables()["QMAKE_APP_FLAG"].append("1");
261 else if(project->first("TEMPLATE") == "lib") 272 else if(project->first("TEMPLATE") == "lib")
262 project->variables()["QMAKE_LIB_FLAG"].append("1"); 273 project->variables()["QMAKE_LIB_FLAG"].append("1");
263 else if(project->first("TEMPLATE") == "subdirs") { 274 else if(project->first("TEMPLATE") == "subdirs") {
264 MakefileGenerator::init(); 275 MakefileGenerator::init();
265 if(project->variables()["MAKEFILE"].isEmpty()) 276 if(project->variables()["MAKEFILE"].isEmpty())
266 project->variables()["MAKEFILE"].append("Makefile"); 277 project->variables()["MAKEFILE"].append("Makefile");
267 if(project->variables()["QMAKE"].isEmpty()) 278 if(project->variables()["QMAKE"].isEmpty())
268 project->variables()["QMAKE"].append("qmake"); 279 project->variables()["QMAKE"].append("qmake");
269 return; 280 return;
270 } 281 }
@@ -343,49 +354,49 @@ BorlandMakefileGenerator::init()
343 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"]; 354 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"];
344 } 355 }
345 if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") ) { 356 if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") ) {
346 project->variables()["CONFIG"].append("windows"); 357 project->variables()["CONFIG"].append("windows");
347 } 358 }
348 if ( project->isActiveConfig("qt") ) { 359 if ( project->isActiveConfig("qt") ) {
349 project->variables()["CONFIG"].append("moc"); 360 project->variables()["CONFIG"].append("moc");
350 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"]; 361 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"];
351 project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"]; 362 project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"];
352 if ( !project->isActiveConfig("debug") ) 363 if ( !project->isActiveConfig("debug") )
353 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG"); 364 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG");
354 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { 365 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) {
355 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty()) { 366 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty()) {
356 project->variables()["DEFINES"].append("QT_MAKEDLL"); 367 project->variables()["DEFINES"].append("QT_MAKEDLL");
357 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_QT_DLL"]; 368 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_QT_DLL"];
358 } 369 }
359 } else { 370 } else {
360 if(project->isActiveConfig("thread")) 371 if(project->isActiveConfig("thread"))
361 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; 372 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"];
362 else 373 else
363 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; 374 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"];
364 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { 375 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) {
365 int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt"); 376 int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt");
366 if ( hver == -1 ) 377 if ( hver == -1 )
367 hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt-mt"); 378 hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qtmt");
368 if(hver != -1) { 379 if(hver != -1) {
369 QString ver; 380 QString ver;
370 ver.sprintf("qt%s" QTDLL_POSTFIX "%d.lib", (project->isActiveConfig("thread") ? "mt" : ""), hver); 381 ver.sprintf("qt%s" QTDLL_POSTFIX "%d.lib", (project->isActiveConfig("thread") ? "mt" : ""), hver);
371 QStringList &libs = project->variables()["QMAKE_LIBS"]; 382 QStringList &libs = project->variables()["QMAKE_LIBS"];
372 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) 383 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit)
373 (*libit).replace(QRegExp("qt(mt)?\\.lib"), ver); 384 (*libit).replace(QRegExp("qt(mt)?\\.lib"), ver);
374 } 385 }
375 } 386 }
376 if ( project->isActiveConfig( "activeqt" ) ) { 387 if ( project->isActiveConfig( "activeqt" ) ) {
377 project->variables().remove("QMAKE_LIBS_QT_ENTRY"); 388 project->variables().remove("QMAKE_LIBS_QT_ENTRY");
378 project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib"; 389 project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib";
379 if ( project->isActiveConfig( "dll" ) ) 390 if ( project->isActiveConfig( "dll" ) )
380 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"]; 391 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"];
381 } 392 }
382 if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) { 393 if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) {
383 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"]; 394 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"];
384 } 395 }
385 } 396 }
386 } 397 }
387 if ( project->isActiveConfig("opengl") ) { 398 if ( project->isActiveConfig("opengl") ) {
388 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; 399 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"];
389 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"]; 400 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"];
390 } 401 }
391 if ( project->isActiveConfig("dll") ) { 402 if ( project->isActiveConfig("dll") ) {
@@ -405,73 +416,94 @@ BorlandMakefileGenerator::init()
405 project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE"]; 416 project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE"];
406 project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS"]; 417 project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS"];
407 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty()) { 418 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty()) {
408 project->variables()["TARGET_EXT"].append(".exe"); 419 project->variables()["TARGET_EXT"].append(".exe");
409 } else { 420 } else {
410 project->variables()["TARGET_EXT"].append(".lib"); 421 project->variables()["TARGET_EXT"].append(".lib");
411 } 422 }
412 } 423 }
413 if ( project->isActiveConfig("windows") ) { 424 if ( project->isActiveConfig("windows") ) {
414 if ( project->isActiveConfig("console") ) { 425 if ( project->isActiveConfig("console") ) {
415 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"]; 426 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
416 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"]; 427 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
417 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"]; 428 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
418 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"]; 429 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
419 } else { 430 } else {
420 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"]; 431 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"];
421 } 432 }
422 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"]; 433 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"];
423 } else { 434 } else {
424 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"]; 435 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
425 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"]; 436 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
426 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"]; 437 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
427 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"]; 438 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
428 } 439 }
440 if ( project->isActiveConfig("stl") ) {
441 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_ON"];
442 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_ON"];
443 } else {
444 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_OFF"];
445 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_OFF"];
446 }
447 if ( project->isActiveConfig("exceptions") ) {
448 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_ON"];
449 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_ON"];
450 } else {
451 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_OFF"];
452 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_OFF"];
453 }
454 if ( project->isActiveConfig("rtti") ) {
455 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_ON"];
456 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_ON"];
457 } else {
458 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_OFF"];
459 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_OFF"];
460 }
461
429 if ( project->isActiveConfig("thread") ) { 462 if ( project->isActiveConfig("thread") ) {
430 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_RTMT"]; 463 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_RTMT"];
431 } else { 464 } else {
432 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_RT"]; 465 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_RT"];
433 } 466 }
434 if ( project->isActiveConfig("moc") ) { 467 if ( project->isActiveConfig("moc") ) {
435 setMocAware(TRUE); 468 setMocAware(TRUE);
436 } 469 }
437 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; 470 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
438 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ', 471 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ',
439 "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH"); 472 "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH");
440 QStringList &l = project->variables()["QMAKE_FILETAGS"]; 473 QStringList &l = project->variables()["QMAKE_FILETAGS"];
441 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 474 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
442 QStringList &gdmf = project->variables()[(*it)]; 475 QStringList &gdmf = project->variables()[(*it)];
443 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner) 476 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner)
444 (*inner) = Option::fixPathToTargetOS((*inner), FALSE); 477 (*inner) = Option::fixPathToTargetOS((*inner), FALSE);
445 } 478 }
446 479
447 if ( !project->variables()["RC_FILE"].isEmpty()) { 480 if ( !project->variables()["RC_FILE"].isEmpty()) {
448 if ( !project->variables()["RES_FILE"].isEmpty()) { 481 if ( !project->variables()["RES_FILE"].isEmpty()) {
449 fprintf(stderr, "Both .rc and .res file specified.\n"); 482 fprintf(stderr, "Both .rc and .res file specified.\n");
450 fprintf(stderr, "Please specify one of them, not both."); 483 fprintf(stderr, "Please specify one of them, not both.");
451 exit(666); 484 exit(666);
452 } 485 }
453 project->variables()["RES_FILE"] = project->variables()["RC_FILE"]; 486 project->variables()["RES_FILE"] = project->variables()["RC_FILE"];
454 project->variables()["RES_FILE"].first().replace(".rc",".res"); 487 project->variables()["RES_FILE"].first().replace(".rc",".res");
455 project->variables()["TARGETDEPS"] += project->variables()["RES_FILE"]; 488 project->variables()["POST_TARGETDEPS"] += project->variables()["RES_FILE"];
456 } 489 }
457 MakefileGenerator::init(); 490 MakefileGenerator::init();
458 if ( !project->variables()["VERSION"].isEmpty()) { 491 if ( !project->variables()["VERSION"].isEmpty()) {
459 QStringList l = QStringList::split('.', project->first("VERSION")); 492 QStringList l = QStringList::split('.', project->first("VERSION"));
460 project->variables()["VER_MAJ"].append(l[0]); 493 project->variables()["VER_MAJ"].append(l[0]);
461 project->variables()["VER_MIN"].append(l[1]); 494 project->variables()["VER_MIN"].append(l[1]);
462 } 495 }
463 496
464 if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { 497 if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
465 // bcc does not generate a .tds file for static libs 498 // bcc does not generate a .tds file for static libs
466 QString tdsPostfix; 499 QString tdsPostfix;
467 if ( !project->variables()["VERSION"].isEmpty() ) { 500 if ( !project->variables()["VERSION"].isEmpty() ) {
468 tdsPostfix = QStringList::split( '.', project->first("VERSION") ).join("") 501 tdsPostfix = QStringList::split( '.', project->first("VERSION") ).join("")
469 + ".tds"; 502 + ".tds";
470 } else { 503 } else {
471 tdsPostfix = ".tds"; 504 tdsPostfix = ".tds";
472 } 505 }
473 project->variables()["QMAKE_CLEAN"].append( 506 project->variables()["QMAKE_CLEAN"].append(
474 project->first("DESTDIR") + project->first("TARGET") + tdsPostfix ); 507 project->first("DESTDIR") + project->first("TARGET") + tdsPostfix );
475 } 508 }
476} 509}
477
diff --git a/qmake/generators/win32/borland_bmake.h b/qmake/generators/win32/borland_bmake.h
index 90f8229..5ffed58 100644
--- a/qmake/generators/win32/borland_bmake.h
+++ b/qmake/generators/win32/borland_bmake.h
@@ -1,59 +1,58 @@
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
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this 21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software. 23** with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37#ifndef __BORLANDMAKE_H__ 37#ifndef __BORLAND_BMAKE_H__
38#define __BORLANDMAKE_H__ 38#define __BORLAND_BMAKE_H__
39 39
40#include "winmakefile.h" 40#include "winmakefile.h"
41 41
42class BorlandMakefileGenerator : public Win32MakefileGenerator 42class BorlandMakefileGenerator : public Win32MakefileGenerator
43{ 43{
44 bool init_flag; 44 bool init_flag;
45 void writeBorlandParts(QTextStream &); 45 void writeBorlandParts(QTextStream &);
46 46
47 bool writeMakefile(QTextStream &); 47 bool writeMakefile(QTextStream &);
48 void init(); 48 void init();
49 49
50public: 50public:
51 BorlandMakefileGenerator(QMakeProject *p); 51 BorlandMakefileGenerator(QMakeProject *p);
52 ~BorlandMakefileGenerator(); 52 ~BorlandMakefileGenerator();
53}; 53};
54 54
55inline BorlandMakefileGenerator::~BorlandMakefileGenerator() 55inline BorlandMakefileGenerator::~BorlandMakefileGenerator()
56{ } 56{ }
57 57
58 58#endif /* __BORLAND_BMAKE_H__ */
59#endif /* __BORLANDMAKE_H__ */
diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp
new file mode 100644
index 0000000..7f58a55
--- a/dev/null
+++ b/qmake/generators/win32/mingw_make.cpp
@@ -0,0 +1,524 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
7**
8** This file is part of the network module of the Qt GUI Toolkit.
9**
10** This file may be distributed under the terms of the Q Public License
11** as defined by Trolltech AS of Norway and appearing in the file
12** LICENSE.QPL included in the packaging of this file.
13**
14** This file may be distributed and/or modified under the terms of the
15** GNU General Public License version 2 as published by the Free Software
16** Foundation and appearing in the file LICENSE.GPL included in the
17** packaging of this file.
18**
19** Licensees holding valid Qt Enterprise Edition licenses may use this
20** file in accordance with the Qt Commercial License Agreement provided
21** with the Software.
22**
23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25**
26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
27** information about Qt Commercial License Agreements.
28** See http://www.trolltech.com/qpl/ for QPL licensing information.
29** See http://www.trolltech.com/gpl/ for GPL licensing information.
30**
31** Contact info@trolltech.com if any conditions of this licensing are
32** not clear to you.
33**
34**********************************************************************/
35
36#include "mingw_make.h"
37#include "option.h"
38#include <qregexp.h>
39#include <qdir.h>
40#include <stdlib.h>
41#include <time.h>
42
43
44MingwMakefileGenerator::MingwMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE)
45{
46 Option::obj_ext = ".o";
47}
48
49bool
50MingwMakefileGenerator::writeMakefile(QTextStream &t)
51{
52 writeHeader(t);
53 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {
54 t << "all clean:" << "\n\t"
55 << "@echo \"Some of the required modules ("
56 << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t"
57 << "@echo \"Skipped.\"" << endl << endl;
58 writeMakeQmake(t);
59 return TRUE;
60 }
61
62 if(project->first("TEMPLATE") == "app" ||
63 project->first("TEMPLATE") == "lib") {
64 writeMingwParts(t);
65 return MakefileGenerator::writeMakefile(t);
66 }
67 else if(project->first("TEMPLATE") == "subdirs") {
68 writeSubDirs(t);
69 return TRUE;
70 }
71 return FALSE;
72}
73
74void
75MingwMakefileGenerator::writeMingwParts(QTextStream &t)
76{
77 t << "####### Compiler, tools and options" << endl << endl;
78 t << "CC =" << var("QMAKE_CC") << endl;
79 t << "CXX =" << var("QMAKE_CXX") << endl;
80 t << "LEX = " << var("QMAKE_LEX") << endl;
81 t << "YACC = " << var("QMAKE_YACC") << endl;
82 t << "CFLAGS =" << var("QMAKE_CFLAGS") << " "
83 << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "
84 << varGlue("DEFINES","-D"," -D","") << endl;
85 t << "CXXFLAGS =" << var("QMAKE_CXXFLAGS") << " "
86 << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "
87 << varGlue("DEFINES","-D"," -D","") << endl;
88 t << "LEXFLAGS=" << var("QMAKE_LEXFLAGS") << endl;
89 t << "YACCFLAGS=" << var("QMAKE_YACCFLAGS") << endl;
90
91 t << "INCPATH =";
92 QStringList &incs = project->variables()["INCLUDEPATH"];
93 for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) {
94 QString inc = (*incit);
95 inc.replace(QRegExp("\\\\$"), "\\\\");
96 inc.replace(QRegExp("\""), "");
97 t << " -I" << inc ;
98 }
99 t << " -I" << specdir()
100 << endl;
101 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
102 t << "LINK =" << var("QMAKE_LINK") << endl;
103 t << "LFLAGS =";
104 if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() )
105 t << varGlue("QMAKE_LIBDIR","-L",";","") << " ";
106 t << var("QMAKE_LFLAGS") << endl;
107 t << "LIBS =" << var("QMAKE_LIBS").replace(QRegExp("(\\slib|^lib)")," -l") << endl;
108 }
109 else {
110 t << "LIB =" << var("QMAKE_LIB") << endl;
111 }
112 t << "MOC =" << (project->isEmpty("QMAKE_MOC") ? QString("moc") :
113 Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl;
114 t << "UIC =" << (project->isEmpty("QMAKE_UIC") ? QString("uic") :
115 Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl;
116 t << "QMAKE =" << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") :
117 Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl;
118 t << "IDC =" << (project->isEmpty("QMAKE_IDC") ? QString("idc") :
119 Option::fixPathToTargetOS(var("QMAKE_IDC"), FALSE)) << endl;
120 t << "IDL =" << (project->isEmpty("QMAKE_IDL") ? QString("midl") :
121 Option::fixPathToTargetOS(var("QMAKE_IDL"), FALSE)) << endl;
122 t << "ZIP =" << var("QMAKE_ZIP") << endl;
123 t << "DEF_FILE =" << varList("DEF_FILE") << endl;
124 t << "COPY_FILE= " << var("QMAKE_COPY") << endl;
125 t << "COPY_DIR= " << var("QMAKE_COPY") << endl;
126 t << "DEL_FILE= " << var("QMAKE_DEL_FILE") << endl;
127 t << "DEL_DIR= " << var("QMAKE_DEL_DIR") << endl;
128 t << "MOVE = " << var("QMAKE_MOVE") << endl;
129 t << "CHK_DIR_EXISTS =" << var("QMAKE_CHK_DIR_EXISTS") << endl;
130 t << "MKDIR =" << var("QMAKE_MKDIR") << endl;
131 t << endl;
132
133 t << "####### Output directory" << endl << endl;
134 if (! project->variables()["OBJECTS_DIR"].isEmpty())
135 t << "OBJECTS_DIR = " << var("OBJECTS_DIR").replace(QRegExp("\\\\$"),"") << endl;
136 else
137 t << "OBJECTS_DIR = . " << endl;
138 if (! project->variables()["MOC_DIR"].isEmpty())
139 t << "MOC_DIR = " << var("MOC_DIR").replace(QRegExp("\\\\$"),"") << endl;
140 else
141 t << "MOC_DIR = . " << endl;
142 t << endl;
143
144 t << "####### Files" << endl << endl;
145 t << "HEADERS =" << varList("HEADERS") << endl;
146 t << "SOURCES =" << varList("SOURCES") << endl;
147 // t << "OBJECTS =" << varList("OBJECTS").replace(QRegExp("\\.obj"),".o") << endl;
148 t << "OBJECTS =" << varList("OBJECTS") << endl;
149 t << "FORMS =" << varList("FORMS") << endl;
150 t << "UICDECLS =" << varList("UICDECLS") << endl;
151 t << "UICIMPLS =" << varList("UICIMPLS") << endl;
152 t << "SRCMOC =" << varList("SRCMOC") << endl;
153 t << "OBJMOC =" << varList("OBJMOC") << endl;
154 // t << "OBJMOC =" << varList("OBJMOC").replace(QRegExp("\\.obj"),".o") << endl;
155 t << "DIST =" << varList("DISTFILES") << endl;
156 t << "TARGET =";
157 if( !project->variables()[ "DESTDIR" ].isEmpty() )
158 t << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT"));
159 else
160 t << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first();
161 t << endl;
162 t << endl;
163
164 t << "####### Implicit rules" << endl << endl;
165 t << ".SUFFIXES: .cpp .cxx .cc .C .c" << endl << endl;
166 t << ".cpp.o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
167 t << ".cxx.o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
168 t << ".cc.o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
169 t << ".C.o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
170 t << ".c.o:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;
171
172 t << "####### Build rules" << endl << endl;
173 t << "all: " << "$(OBJECTS_DIR) " << "$(MOC_DIR) " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" << endl << endl;
174 t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) "
175 << var("POST_TARGETDEPS");
176 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
177 t << "\n\t" << "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)";
178 } else {
179 t << "\n\t" << "$(LIB) $(TARGET) $(OBJECTS) $(OBJMOC)";
180 }
181
182 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) {
183 QStringList dlldirs = project->variables()["DLLDESTDIR"];
184 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) {
185 t << "\n\t" << "copy $(TARGET) " << *dlldir;
186 }
187 }
188 QString targetfilename = project->variables()["TARGET"].first();
189 if(project->isActiveConfig("activeqt")) {
190 QString version = project->variables()["VERSION"].first();
191 if ( version.isEmpty() )
192 version = "1.0";
193
194 if ( project->isActiveConfig("dll")) {
195 t << "\n\t" << ("-$(IDC) $(TARGET) /idl tmp\\" + targetfilename + ".idl -version " + version);
196 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl");
197 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb");
198 t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" );
199 } else {
200 t << "\n\t" << ("-$(TARGET) -dumpidl tmp\\" + targetfilename + ".idl -version " + version);
201 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl");
202 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb");
203 t << "\n\t" << "-$(TARGET) -regserver";
204 }
205 }
206 t << endl << endl;
207
208 if(!project->variables()["RC_FILE"].isEmpty()) {
209 t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t"
210 << var("QMAKE_RC") << " -i " << var("RC_FILE") << " -o " << var("RC_FILE").replace(QRegExp("\\.rc"),".o") << endl << endl;
211 }
212 project->variables()["RES_FILE"].first().replace(QRegExp("\\.rc"),".o");
213
214 t << "mocables: $(SRCMOC)" << endl << endl;
215
216 t << "$(OBJECTS_DIR):" << "\n\t"
217 << "@if not exist $(OBJECTS_DIR) mkdir $(OBJECTS_DIR)" << endl << endl;
218
219 t << "$(MOC_DIR):" << "\n\t"
220 << "@if not exist $(MOC_DIR) mkdir $(MOC_DIR)" << endl << endl;
221
222 writeMakeQmake(t);
223
224 t << "dist:" << "\n\t"
225 << "$(ZIP) " << var("PROJECT") << ".zip "
226 << var("PROJECT") << ".pro $(SOURCES) $(HEADERS) $(DIST) $(FORMS)" << endl << endl;
227
228 t << "clean:"
229 << varGlue("OBJECTS","\n\t-del ","\n\t-del ","").replace(QRegExp("\\.obj"),".o")
230 << varGlue("SRCMOC" ,"\n\t-del ","\n\t-del ","")
231 << varGlue("OBJMOC" ,"\n\t-del ","\n\t-del ","").replace(QRegExp("\\.obj"),".o")
232 << varGlue("UICDECLS" ,"\n\t-del ","\n\t-del ","")
233 << varGlue("UICIMPLS" ,"\n\t-del ","\n\t-del ","")
234 << "\n\t-del $(TARGET)"
235 << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ","")
236 << varGlue("CLEAN_FILES","\n\t-del ","\n\t-del ","");
237 if ( project->isActiveConfig("activeqt")) {
238 t << ("\n\t-del tmp\\" + targetfilename + ".*");
239 t << "\n\t-del tmp\\dump.*";
240 }
241 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty())
242 t << "\n\t-del " << var("DLLDESTDIR") << "\\" << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first();
243 if(!project->isEmpty("IMAGES"))
244 t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-del ", "\n\t-del ", "");
245
246 // blasted user defined targets
247 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"];
248 for(QStringList::Iterator it = qut.begin(); it != qut.end(); ++it) {
249 QString targ = var((*it) + ".target"),
250 cmd = var((*it) + ".commands"), deps;
251 if(targ.isEmpty())
252 targ = (*it);
253 QStringList &deplist = project->variables()[(*it) + ".depends"];
254 for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) {
255 QString dep = var((*dep_it) + ".target");
256 if(dep.isEmpty())
257 dep = (*dep_it);
258 deps += " " + dep;
259 }
260 t << "\n\n" << targ << ":" << deps << "\n\t"
261 << cmd;
262 }
263
264 t << endl << endl;
265}
266
267
268void
269MingwMakefileGenerator::init()
270{
271 if(init_flag)
272 return;
273 init_flag = TRUE;
274
275 /* this should probably not be here, but I'm using it to wrap the .t files */
276 if(project->first("TEMPLATE") == "app")
277 project->variables()["QMAKE_APP_FLAG"].append("1");
278 else if(project->first("TEMPLATE") == "lib")
279 project->variables()["QMAKE_LIB_FLAG"].append("1");
280 else if(project->first("TEMPLATE") == "subdirs") {
281 MakefileGenerator::init();
282 if(project->variables()["MAKEFILE"].isEmpty())
283 project->variables()["MAKEFILE"].append("Makefile");
284 if(project->variables()["QMAKE"].isEmpty())
285 project->variables()["QMAKE"].append("qmake");
286 return;
287 }
288
289 bool is_qt = (project->first("TARGET") == "qt"QTDLL_POSTFIX || project->first("TARGET") == "qt-mt"QTDLL_POSTFIX);
290 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"];
291
292 // LIBS defined in Profile comes first for gcc
293 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
294
295 QString targetfilename = project->variables()["TARGET"].first();
296 QStringList &configs = project->variables()["CONFIG"];
297 if (project->isActiveConfig("qt") && project->isActiveConfig("shared"))
298 project->variables()["DEFINES"].append("QT_DLL");
299 if (project->isActiveConfig("qt_dll"))
300 if(configs.findIndex("qt") == -1) configs.append("qt");
301 if ( project->isActiveConfig("qt") ) {
302 if ( project->isActiveConfig( "plugin" ) ) {
303 project->variables()["CONFIG"].append("dll");
304 if(project->isActiveConfig("qt"))
305 project->variables()["DEFINES"].append("QT_PLUGIN");
306 }
307 if ( (project->variables()["DEFINES"].findIndex("QT_NODLL") == -1) &&
308 ((project->variables()["DEFINES"].findIndex("QT_MAKEDLL") != -1 ||
309 project->variables()["DEFINES"].findIndex("QT_DLL") != -1) ||
310 (getenv("QT_DLL") && !getenv("QT_NODLL"))) ) {
311 project->variables()["QMAKE_QT_DLL"].append("1");
312 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() )
313 project->variables()["CONFIG"].append("dll");
314 }
315 if ( project->isActiveConfig("thread") )
316 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT");
317 if ( project->isActiveConfig("accessibility" ) )
318 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT");
319 if ( project->isActiveConfig("tablet") )
320 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT");
321 }
322 if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
323 project->variables()["CONFIG"].remove("staticlib");
324 project->variables()["QMAKE_APP_OR_DLL"].append("1");
325 } else {
326 project->variables()["CONFIG"].append("staticlib");
327 }
328 if ( project->isActiveConfig("warn_off") ) {
329 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_OFF"];
330 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_OFF"];
331 } else if ( project->isActiveConfig("warn_on") ) {
332 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_ON"];
333 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_ON"];
334 }
335 if ( project->isActiveConfig("debug") ) {
336 if ( project->isActiveConfig("thread") ) {
337 // use the DLL RT even here
338 if ( project->variables()["DEFINES"].contains("QT_DLL") ) {
339 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLLDBG"];
340 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"];
341 } else {
342 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DBG"];
343 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DBG"];
344 }
345 }
346 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_DEBUG"];
347 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_DEBUG"];
348 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_DEBUG"];
349 } else {
350 if ( project->isActiveConfig("thread") ) {
351 if ( project->variables()["DEFINES"].contains("QT_DLL") ) {
352 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLL"];
353 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLL"];
354 } else {
355 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT"];
356 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT"];
357 }
358 }
359 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RELEASE"];
360 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RELEASE"];
361 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_RELEASE"];
362 }
363
364 if ( !project->variables()["QMAKE_INCDIR"].isEmpty())
365 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"];
366 if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") )
367 project->variables()["CONFIG"].append("windows");
368 if ( project->isActiveConfig("qt") ) {
369 project->variables()["CONFIG"].append("moc");
370 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"];
371 project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"];
372 if ( !project->isActiveConfig("debug") )
373 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG");
374 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) {
375 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty()) {
376 project->variables()["DEFINES"].append("QT_MAKEDLL");
377 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_QT_DLL"];
378 }
379 } else {
380 if(project->isActiveConfig("thread"))
381 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"];
382 else
383 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"];
384 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) {
385 int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt");
386 if ( hver == -1 )
387 hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt-mt");
388 if(hver != -1) {
389 QString ver;
390 ver.sprintf("libqt-%s" QTDLL_POSTFIX "%d.a", (project->isActiveConfig("thread") ? "-mt" : ""), hver);
391 QStringList &libs = project->variables()["QMAKE_LIBS"];
392// @@@HGTODO maybe we must change the replace regexp if we understand what's going on
393 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit)
394 (*libit).replace(QRegExp("qt(-mt)?\\.lib"), ver);
395 }
396 }
397 if ( project->isActiveConfig( "activeqt" ) ) {
398 project->variables().remove("QMAKE_LIBS_QT_ENTRY");
399 project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib";
400 if ( project->isActiveConfig( "dll" ) )
401 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"];
402 }
403 if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) {
404 project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"];
405 }
406 }
407 }
408 if ( project->isActiveConfig("opengl") ) {
409 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"];
410 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"];
411 }
412 if ( project->isActiveConfig("dll") ) {
413 project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE_DLL"];
414 project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE_DLL"];
415 project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE_DLL"];
416 project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS_DLL"];
417 if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty()) {
418 project->variables()["TARGET_EXT"].append(
419 QStringList::split('.',project->first("VERSION")).join("") + ".dll");
420 } else {
421 project->variables()["TARGET_EXT"].append(".dll");
422 }
423 } else {
424 project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE"];
425 project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE"];
426 project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE"];
427 project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS"];
428 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty()) {
429 project->variables()["TARGET_EXT"].append(".exe");
430 } else {
431 project->variables()["TARGET_EXT"].append(".a");
432 project->variables()["QMAKE_LFLAGS"].append("-static");
433 if(project->variables()["TARGET"].first().left(3) != "lib")
434 project->variables()["TARGET"].first().prepend("lib");
435 }
436 }
437 if ( project->isActiveConfig("windows") ) {
438 if ( project->isActiveConfig("console") ) {
439 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
440 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
441 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
442 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
443 } else {
444 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"];
445 }
446 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"];
447 } else {
448 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
449 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
450 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
451 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
452 }
453
454 if ( project->isActiveConfig("moc") )
455 setMocAware(TRUE);
456 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ',
457 "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH");
458 QStringList &l = project->variables()["QMAKE_FILETAGS"];
459 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
460 QStringList &gdmf = project->variables()[(*it)];
461 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner)
462 (*inner) = Option::fixPathToTargetOS((*inner), FALSE);
463 }
464
465 if ( project->isActiveConfig("dll") )
466 project->variables()["QMAKE_LFLAGS"].append(QString("-Wl,--out-implib,") + project->first("DESTDIR") + "\\lib"+ project->first("TARGET") + ".a");
467
468 if ( !project->variables()["DEF_FILE"].isEmpty() )
469 project->variables()["QMAKE_LFLAGS"].append(QString("-Wl,--output-def,") + project->first("DEF_FILE"));
470// if(!project->isActiveConfig("incremental"))
471 //project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no"));
472
473#if 0
474 if ( !project->variables()["VERSION"].isEmpty() ) {
475 QString version = project->variables()["VERSION"][0];
476 int firstDot = version.find( "." );
477 QString major = version.left( firstDot );
478 QString minor = version.right( version.length() - firstDot - 1 );
479 minor.replace( ".", "" );
480 project->variables()["QMAKE_LFLAGS"].append( "/VERSION:" + major + "." + minor );
481 }
482#endif
483 if ( !project->variables()["RC_FILE"].isEmpty()) {
484 if ( !project->variables()["RES_FILE"].isEmpty()) {
485 fprintf(stderr, "Both .rc and .res file specified.\n");
486 fprintf(stderr, "Please specify one of them, not both.");
487 exit(666);
488 }
489 project->variables()["RES_FILE"] = project->variables()["RC_FILE"];
490 project->variables()["RES_FILE"].first().replace(".rc",".o");
491 project->variables()["POST_TARGETDEPS"] += project->variables()["RES_FILE"];
492 }
493 if ( !project->variables()["RES_FILE"].isEmpty())
494 project->variables()["QMAKE_LIBS"] += project->variables()["RES_FILE"];
495
496 MakefileGenerator::init();
497 if ( !project->variables()["VERSION"].isEmpty()) {
498 QStringList l = QStringList::split('.', project->first("VERSION"));
499 project->variables()["VER_MAJ"].append(l[0]);
500 project->variables()["VER_MIN"].append(l[1]);
501 }
502 if(project->isActiveConfig("dll")) {
503 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") +"lib" + project->first("TARGET") + ".a");
504 }
505}
506
507void
508MingwMakefileGenerator::writeSubDirs(QTextStream &t)
509{
510 QString qs ;
511 QTextStream ts (&qs, IO_WriteOnly) ;
512 Win32MakefileGenerator::writeSubDirs( ts ) ;
513 QRegExp rx("(\\n\\tcd [^\\n\\t]+)(\\n\\t.+)\\n\\t@cd ..") ;
514 rx.setMinimal(true);
515 int pos = 0 ;
516 while ( -1 != (pos = rx.search( qs, pos)))
517 {
518 QString qsMatch = rx.cap(2);
519 qsMatch.replace("\n\t"," && \\\n\t");
520 qs.replace(pos+rx.cap(1).length(), rx.cap(2).length(), qsMatch );
521 pos += (rx.cap(1).length()+qsMatch.length());
522 }
523 t << qs ;
524}
diff --git a/qmake/generators/win32/mingw_make.h b/qmake/generators/win32/mingw_make.h
new file mode 100644
index 0000000..c00bf1b
--- a/dev/null
+++ b/qmake/generators/win32/mingw_make.h
@@ -0,0 +1,58 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
7**
8** This file is part of the network module of the Qt GUI Toolkit.
9**
10** This file may be distributed under the terms of the Q Public License
11** as defined by Trolltech AS of Norway and appearing in the file
12** LICENSE.QPL included in the packaging of this file.
13**
14** This file may be distributed and/or modified under the terms of the
15** GNU General Public License version 2 as published by the Free Software
16** Foundation and appearing in the file LICENSE.GPL included in the
17** packaging of this file.
18**
19** Licensees holding valid Qt Enterprise Edition licenses may use this
20** file in accordance with the Qt Commercial License Agreement provided
21** with the Software.
22**
23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25**
26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
27** information about Qt Commercial License Agreements.
28** See http://www.trolltech.com/qpl/ for QPL licensing information.
29** See http://www.trolltech.com/gpl/ for GPL licensing information.
30**
31** Contact info@trolltech.com if any conditions of this licensing are
32** not clear to you.
33**
34**********************************************************************/
35#ifndef __MINGW_MAKE_H__
36#define __MINGW_MAKE_H__
37
38#include "winmakefile.h"
39
40class MingwMakefileGenerator : public Win32MakefileGenerator
41{
42 bool init_flag;
43 void writeMingwParts(QTextStream &);
44 void writeSubDirs(QTextStream &t) ;
45
46 bool writeMakefile(QTextStream &);
47 void init();
48
49public:
50 MingwMakefileGenerator(QMakeProject *p);
51 ~MingwMakefileGenerator();
52
53};
54
55inline MingwMakefileGenerator::~MingwMakefileGenerator()
56{ }
57
58#endif /* __MINGW_MAKE_H__ */
diff --git a/qmake/generators/win32/msvc_dsp.cpp b/qmake/generators/win32/msvc_dsp.cpp
index 8b08c78..3fa0496 100644
--- a/qmake/generators/win32/msvc_dsp.cpp
+++ b/qmake/generators/win32/msvc_dsp.cpp
@@ -487,48 +487,72 @@ DspMakefileGenerator::writeDspParts(QTextStream &t)
487 t << "# PROP Exclude_From_Build 1" << endl; 487 t << "# PROP Exclude_From_Build 1" << endl;
488 t << "# End Source File" << endl << endl; 488 t << "# End Source File" << endl << endl;
489 } 489 }
490 } 490 }
491 else 491 else
492 t << var(variable); 492 t << var(variable);
493 } 493 }
494 t << line << endl; 494 t << line << endl;
495 } 495 }
496 t << endl; 496 t << endl;
497 file.close(); 497 file.close();
498 return TRUE; 498 return TRUE;
499} 499}
500 500
501 501
502 502
503void 503void
504DspMakefileGenerator::init() 504DspMakefileGenerator::init()
505{ 505{
506 if(init_flag) 506 if(init_flag)
507 return; 507 return;
508 QStringList::Iterator it; 508 QStringList::Iterator it;
509 init_flag = TRUE; 509 init_flag = TRUE;
510 510
511 const bool thread = project->isActiveConfig("thread");
512
513 if ( project->isActiveConfig("stl") ) {
514 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_ON"];
515 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_ON"];
516 } else {
517 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_OFF"];
518 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_OFF"];
519 }
520 if ( project->isActiveConfig("exceptions") ) {
521 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_ON"];
522 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_ON"];
523 } else {
524 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_OFF"];
525 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_OFF"];
526 }
527 if ( project->isActiveConfig("rtti") ) {
528 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_ON"];
529 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_ON"];
530 } else {
531 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_OFF"];
532 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_OFF"];
533 }
534
511 /* this should probably not be here, but I'm using it to wrap the .t files */ 535 /* this should probably not be here, but I'm using it to wrap the .t files */
512 if(project->first("TEMPLATE") == "vcapp" ) 536 if(project->first("TEMPLATE") == "vcapp" )
513 project->variables()["QMAKE_APP_FLAG"].append("1"); 537 project->variables()["QMAKE_APP_FLAG"].append("1");
514 else if(project->first("TEMPLATE") == "vclib") 538 else if(project->first("TEMPLATE") == "vclib")
515 project->variables()["QMAKE_LIB_FLAG"].append("1"); 539 project->variables()["QMAKE_LIB_FLAG"].append("1");
516 if ( project->variables()["QMAKESPEC"].isEmpty() ) 540 if ( project->variables()["QMAKESPEC"].isEmpty() )
517 project->variables()["QMAKESPEC"].append( getenv("QMAKESPEC") ); 541 project->variables()["QMAKESPEC"].append( getenv("QMAKESPEC") );
518 542
519 bool is_qt = (project->first("TARGET") == "qt"QTDLL_POSTFIX || project->first("TARGET") == "qt-mt"QTDLL_POSTFIX); 543 bool is_qt = (project->first("TARGET") == "qt"QTDLL_POSTFIX || project->first("TARGET") == "qt-mt"QTDLL_POSTFIX);
520 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"]; 544 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"];
521 545
522 QStringList &configs = project->variables()["CONFIG"]; 546 QStringList &configs = project->variables()["CONFIG"];
523 if (project->isActiveConfig("shared")) 547 if (project->isActiveConfig("shared"))
524 project->variables()["DEFINES"].append("QT_DLL"); 548 project->variables()["DEFINES"].append("QT_DLL");
525 if (project->isActiveConfig("qt_dll")) 549 if (project->isActiveConfig("qt_dll"))
526 if(configs.findIndex("qt") == -1) configs.append("qt"); 550 if(configs.findIndex("qt") == -1) configs.append("qt");
527 if ( project->isActiveConfig("qt") ) { 551 if ( project->isActiveConfig("qt") ) {
528 if ( project->isActiveConfig( "plugin" ) ) { 552 if ( project->isActiveConfig( "plugin" ) ) {
529 project->variables()["CONFIG"].append("dll"); 553 project->variables()["CONFIG"].append("dll");
530 project->variables()["DEFINES"].append("QT_PLUGIN"); 554 project->variables()["DEFINES"].append("QT_PLUGIN");
531 } 555 }
532 if ( (project->variables()["DEFINES"].findIndex("QT_NODLL") == -1) && 556 if ( (project->variables()["DEFINES"].findIndex("QT_NODLL") == -1) &&
533 ((project->variables()["DEFINES"].findIndex("QT_MAKEDLL") != -1 || 557 ((project->variables()["DEFINES"].findIndex("QT_MAKEDLL") != -1 ||
534 project->variables()["DEFINES"].findIndex("QT_DLL") != -1) || 558 project->variables()["DEFINES"].findIndex("QT_DLL") != -1) ||
@@ -547,103 +571,103 @@ DspMakefileGenerator::init()
547 571
548 if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") ) { 572 if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") ) {
549 project->variables()["CONFIG"].append("windows"); 573 project->variables()["CONFIG"].append("windows");
550 } 574 }
551 if ( !project->variables()["VERSION"].isEmpty() ) { 575 if ( !project->variables()["VERSION"].isEmpty() ) {
552 QString version = project->variables()["VERSION"][0]; 576 QString version = project->variables()["VERSION"][0];
553 int firstDot = version.find( "." ); 577 int firstDot = version.find( "." );
554 QString major = version.left( firstDot ); 578 QString major = version.left( firstDot );
555 QString minor = version.right( version.length() - firstDot - 1 ); 579 QString minor = version.right( version.length() - firstDot - 1 );
556 minor.replace( ".", "" ); 580 minor.replace( ".", "" );
557 project->variables()["MSVCDSP_VERSION"].append( "/VERSION:" + major + "." + minor ); 581 project->variables()["MSVCDSP_VERSION"].append( "/VERSION:" + major + "." + minor );
558 } 582 }
559 583
560 if ( project->isActiveConfig("qt") ) { 584 if ( project->isActiveConfig("qt") ) {
561 project->variables()["CONFIG"].append("moc"); 585 project->variables()["CONFIG"].append("moc");
562 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"]; 586 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"];
563 project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"]; 587 project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"];
564 588
565 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { 589 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) {
566 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { 590 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) {
567 project->variables()["DEFINES"].append("QT_MAKEDLL"); 591 project->variables()["DEFINES"].append("QT_MAKEDLL");
568 project->variables()["QMAKE_LFLAGS"].append("/base:\"0x39D00000\""); 592 project->variables()["QMAKE_LFLAGS"].append("/base:\"0x39D00000\"");
569 } 593 }
570 } else { 594 } else {
571 if(project->isActiveConfig("thread")) 595 if( thread )
572 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; 596 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"];
573 else 597 else
574 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; 598 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"];
575 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { 599 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) {
576 int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt"); 600 int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt");
577 if ( hver == -1 ) 601 if ( hver == -1 )
578 hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt-mt"); 602 hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt-mt");
579 if(hver != -1) { 603 if(hver != -1) {
580 QString ver; 604 QString ver;
581 ver.sprintf("qt%s" QTDLL_POSTFIX "%d.lib", (project->isActiveConfig("thread") ? "-mt" : ""), hver); 605 ver.sprintf("qt%s" QTDLL_POSTFIX "%d.lib", (thread ? "-mt" : ""), hver);
582 QStringList &libs = project->variables()["QMAKE_LIBS"]; 606 QStringList &libs = project->variables()["QMAKE_LIBS"];
583 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) 607 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit)
584 (*libit).replace(QRegExp("qt(-mt)?\\.lib"), ver); 608 (*libit).replace(QRegExp("qt(-mt)?\\.lib"), ver);
585 } 609 }
586 } 610 }
587 if ( project->isActiveConfig( "activeqt" ) ) { 611 if ( project->isActiveConfig( "activeqt" ) ) {
588 project->variables().remove("QMAKE_LIBS_QT_ENTRY"); 612 project->variables().remove("QMAKE_LIBS_QT_ENTRY");
589 project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib"; 613 project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib";
590 if ( project->isActiveConfig( "dll" ) ) 614 if ( project->isActiveConfig( "dll" ) )
591 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"]; 615 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"];
592 } 616 }
593 if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) { 617 if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) {
594 project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"]; 618 project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"];
595 } 619 }
596 } 620 }
597 } 621 }
598 622
599 if ( project->isActiveConfig("debug") ) { 623 if ( project->isActiveConfig("debug") ) {
600 if ( !project->first("OBJECTS_DIR").isEmpty() ) 624 if ( !project->first("OBJECTS_DIR").isEmpty() )
601 project->variables()["MSVCDSP_OBJECTSDIRDEB"] = project->first("OBJECTS_DIR"); 625 project->variables()["MSVCDSP_OBJECTSDIRDEB"] = project->first("OBJECTS_DIR");
602 else 626 else
603 project->variables()["MSVCDSP_OBJECTSDIRDEB"] = "Debug"; 627 project->variables()["MSVCDSP_OBJECTSDIRDEB"] = "Debug";
604 project->variables()["MSVCDSP_OBJECTSDIRREL"] = "Release"; 628 project->variables()["MSVCDSP_OBJECTSDIRREL"] = "Release";
605 if ( !project->first("DESTDIR").isEmpty() ) 629 if ( !project->first("DESTDIR").isEmpty() )
606 project->variables()["MSVCDSP_TARGETDIRDEB"] = project->first("DESTDIR"); 630 project->variables()["MSVCDSP_TARGETDIRDEB"] = project->first("DESTDIR");
607 else 631 else
608 project->variables()["MSVCDSP_TARGETDIRDEB"] = "Debug"; 632 project->variables()["MSVCDSP_TARGETDIRDEB"] = "Debug";
609 project->variables()["MSVCDSP_TARGETDIRREL"] = "Release"; 633 project->variables()["MSVCDSP_TARGETDIRREL"] = "Release";
610 } else { 634 } else {
611 if ( !project->first("OBJECTS_DIR").isEmpty() ) 635 if ( !project->first("OBJECTS_DIR").isEmpty() )
612 project->variables()["MSVCDSP_OBJECTSDIRREL"] = project->first("OBJECTS_DIR"); 636 project->variables()["MSVCDSP_OBJECTSDIRREL"] = project->first("OBJECTS_DIR");
613 project->variables()["MSVCDSP_OBJECTSDIRDEB"] = "Debug"; 637 project->variables()["MSVCDSP_OBJECTSDIRDEB"] = "Debug";
614 if ( !project->first("DESTDIR").isEmpty() ) 638 if ( !project->first("DESTDIR").isEmpty() )
615 project->variables()["MSVCDSP_TARGETDIRREL"] = project->first("DESTDIR"); 639 project->variables()["MSVCDSP_TARGETDIRREL"] = project->first("DESTDIR");
616 else 640 else
617 project->variables()["MSVCDSP_TARGETDIRREL"] = "Release"; 641 project->variables()["MSVCDSP_TARGETDIRREL"] = "Release";
618 project->variables()["MSVCDSP_TARGETDIRDEB"] = "Debug"; 642 project->variables()["MSVCDSP_TARGETDIRDEB"] = "Debug";
619 } 643 }
620 644
621 if ( project->isActiveConfig("opengl") ) { 645 if ( project->isActiveConfig("opengl") ) {
622 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; 646 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"];
623 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"]; 647 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"];
624 } 648 }
625 if ( project->isActiveConfig("thread") ) { 649 if ( thread ) {
626 if(project->isActiveConfig("qt")) 650 if(project->isActiveConfig("qt"))
627 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT" ); 651 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT" );
628 if ( project->isActiveConfig("dll") || project->first("TARGET") == "qtmain" 652 if ( project->isActiveConfig("dll") || project->first("TARGET") == "qtmain"
629 || !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { 653 || !project->variables()["QMAKE_QT_DLL"].isEmpty() ) {
630 project->variables()["MSVCDSP_MTDEFD"] += project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"]; 654 project->variables()["MSVCDSP_MTDEFD"] += project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"];
631 project->variables()["MSVCDSP_MTDEF"] += project->variables()["QMAKE_CXXFLAGS_MT_DLL"]; 655 project->variables()["MSVCDSP_MTDEF"] += project->variables()["QMAKE_CXXFLAGS_MT_DLL"];
632 } else { 656 } else {
633 // YES we want to use the DLL even in a static build 657 // YES we want to use the DLL even in a static build
634 project->variables()["MSVCDSP_MTDEFD"] += project->variables()["QMAKE_CXXFLAGS_MT_DBG"]; 658 project->variables()["MSVCDSP_MTDEFD"] += project->variables()["QMAKE_CXXFLAGS_MT_DBG"];
635 project->variables()["MSVCDSP_MTDEF"] += project->variables()["QMAKE_CXXFLAGS_MT"]; 659 project->variables()["MSVCDSP_MTDEF"] += project->variables()["QMAKE_CXXFLAGS_MT"];
636 } 660 }
637 if ( !project->variables()["DEFINES"].contains("QT_DLL") && is_qt 661 if ( !project->variables()["DEFINES"].contains("QT_DLL") && is_qt
638 && project->first("TARGET") != "qtmain" ) 662 && project->first("TARGET") != "qtmain" )
639 project->variables()["QMAKE_LFLAGS"].append("/NODEFAULTLIB:\"libc\""); 663 project->variables()["QMAKE_LFLAGS"].append("/NODEFAULTLIB:\"libc\"");
640 } 664 }
641 665
642 if(project->isActiveConfig("qt")) { 666 if(project->isActiveConfig("qt")) {
643 if ( project->isActiveConfig("accessibility" ) ) 667 if ( project->isActiveConfig("accessibility" ) )
644 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT"); 668 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT");
645 if ( project->isActiveConfig("tablet") ) 669 if ( project->isActiveConfig("tablet") )
646 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT"); 670 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT");
647 } 671 }
648 if ( project->isActiveConfig("dll") ) { 672 if ( project->isActiveConfig("dll") ) {
649 if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { 673 if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) {
@@ -711,239 +735,258 @@ DspMakefileGenerator::init()
711 project->variables()["MSVCDSP_SUBSYSTEM"].append("console"); 735 project->variables()["MSVCDSP_SUBSYSTEM"].append("console");
712 } else { 736 } else {
713 project->variables()["MSVCDSP_CONSOLE"].clear(); 737 project->variables()["MSVCDSP_CONSOLE"].clear();
714 project->variables()["MSVCDSP_WINCONDEF"].append("_WINDOWS"); 738 project->variables()["MSVCDSP_WINCONDEF"].append("_WINDOWS");
715 project->variables()["MSVCDSP_DSPTYPE"].append("0x0101"); 739 project->variables()["MSVCDSP_DSPTYPE"].append("0x0101");
716 project->variables()["MSVCDSP_SUBSYSTEM"].append("windows"); 740 project->variables()["MSVCDSP_SUBSYSTEM"].append("windows");
717 } 741 }
718 } else { 742 } else {
719 if ( project->isActiveConfig("dll") ) { 743 if ( project->isActiveConfig("dll") ) {
720 project->variables()["MSVCDSP_TEMPLATE"].append("win32dll" + project->first( "DSP_EXTENSION" ) ); 744 project->variables()["MSVCDSP_TEMPLATE"].append("win32dll" + project->first( "DSP_EXTENSION" ) );
721 } else { 745 } else {
722 project->variables()["MSVCDSP_TEMPLATE"].append("win32lib" + project->first( "DSP_EXTENSION" ) ); 746 project->variables()["MSVCDSP_TEMPLATE"].append("win32lib" + project->first( "DSP_EXTENSION" ) );
723 } 747 }
724 } 748 }
725 749
726 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"]; 750 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"];
727 751
728 project->variables()["MSVCDSP_LFLAGS" ] += project->variables()["QMAKE_LFLAGS"]; 752 project->variables()["MSVCDSP_LFLAGS" ] += project->variables()["QMAKE_LFLAGS"];
729 if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() ) 753 if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() )
730 project->variables()["MSVCDSP_LFLAGS" ].append(varGlue("QMAKE_LIBDIR","/LIBPATH:\"","\" /LIBPATH:\"","\"")); 754 project->variables()["MSVCDSP_LFLAGS" ].append(varGlue("QMAKE_LIBDIR","/LIBPATH:\"","\" /LIBPATH:\"","\""));
731 project->variables()["MSVCDSP_CXXFLAGS" ] += project->variables()["QMAKE_CXXFLAGS"]; 755 project->variables()["MSVCDSP_CXXFLAGS" ] += project->variables()["QMAKE_CXXFLAGS"];
732 project->variables()["MSVCDSP_DEFINES"].append(varGlue("DEFINES","/D ","" " /D ","")); 756 project->variables()["MSVCDSP_DEFINES"].append(varGlue("DEFINES","/D ","" " /D ",""));
733 project->variables()["MSVCDSP_DEFINES"].append(varGlue("PRL_EXPORT_DEFINES","/D ","" " /D ","")); 757 project->variables()["MSVCDSP_DEFINES"].append(varGlue("PRL_EXPORT_DEFINES","/D ","" " /D ",""));
734 758
759 processPrlFiles();
735 QStringList &libs = project->variables()["QMAKE_LIBS"]; 760 QStringList &libs = project->variables()["QMAKE_LIBS"];
736 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) { 761 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) {
737 QString lib = (*libit); 762 QString lib = (*libit);
738 lib.replace(QRegExp("\""), ""); 763 lib.replace(QRegExp("\""), "");
739 project->variables()["MSVCDSP_LIBS"].append(" \"" + lib + "\""); 764 project->variables()["MSVCDSP_LIBS"].append(" \"" + lib + "\"");
740 } 765 }
741 766
742 QStringList &incs = project->variables()["INCLUDEPATH"]; 767 QStringList &incs = project->variables()["INCLUDEPATH"];
743 for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) { 768 for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) {
744 QString inc = (*incit); 769 QString inc = (*incit);
745 inc.replace("\"", ""); 770 inc.replace("\"", "");
746 project->variables()["MSVCDSP_INCPATH"].append("/I \"" + inc + "\""); 771 project->variables()["MSVCDSP_INCPATH"].append("/I \"" + inc + "\"");
747 } 772 }
748 773
749 project->variables()["MSVCDSP_INCPATH"].append("/I \"" + specdir() + "\""); 774 project->variables()["MSVCDSP_INCPATH"].append("/I \"" + specdir() + "\"");
750 if ( project->isActiveConfig("qt") ) { 775 if ( project->isActiveConfig("qt") ) {
751 project->variables()["MSVCDSP_RELDEFS"].append("/D \"QT_NO_DEBUG\""); 776 project->variables()["MSVCDSP_RELDEFS"].append("/D \"QT_NO_DEBUG\"");
752 } else { 777 } else {
753 project->variables()["MSVCDSP_RELDEFS"].clear(); 778 project->variables()["MSVCDSP_RELDEFS"].clear();
754 } 779 }
755 780
756 QString dest; 781 QString dest;
782 QString postLinkStep;
783 QString copyDllStep;
784 QString activeQtStepPreCopyDll;
785 QString activeQtStepPostCopyDll;
786 QString activeQtStepPreCopyDllDebug;
787 QString activeQtStepPostCopyDllDebug;
788 QString activeQtStepPreCopyDllRelease;
789 QString activeQtStepPostCopyDllRelease;
790
791 if ( !project->variables()["QMAKE_POST_LINK"].isEmpty() )
792 postLinkStep += var("QMAKE_POST_LINK");
793
757 if ( !project->variables()["DESTDIR"].isEmpty() ) { 794 if ( !project->variables()["DESTDIR"].isEmpty() ) {
758 project->variables()["TARGET"].first().prepend(project->first("DESTDIR")); 795 project->variables()["TARGET"].first().prepend(project->first("DESTDIR"));
759 Option::fixPathToTargetOS(project->first("TARGET")); 796 Option::fixPathToTargetOS(project->first("TARGET"));
760 dest = project->first("TARGET"); 797 dest = project->first("TARGET");
761 if ( project->first("TARGET").startsWith("$(QTDIR)") ) 798 if ( project->first("TARGET").startsWith("$(QTDIR)") )
762 dest.replace( "$(QTDIR)", getenv("QTDIR") ); 799 dest.replace( "$(QTDIR)", getenv("QTDIR") );
763 project->variables()["MSVCDSP_TARGET"].append( 800 project->variables()["MSVCDSP_TARGET"].append(
764 QString("/out:\"") + dest + "\""); 801 QString("/out:\"") + dest + "\"");
765 if ( project->isActiveConfig("dll") ) { 802 if ( project->isActiveConfig("dll") ) {
766 QString imp = dest; 803 QString imp = dest;
767 imp.replace(".dll", ".lib"); 804 imp.replace(".dll", ".lib");
768 project->variables()["MSVCDSP_TARGET"].append(QString(" /implib:\"") + imp + "\""); 805 project->variables()["MSVCDSP_TARGET"].append(QString(" /implib:\"") + imp + "\"");
769 } 806 }
770 } 807 }
771 if ( project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty() ) { 808 if ( project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty() ) {
772 QStringList dlldirs = project->variables()["DLLDESTDIR"]; 809 QStringList dlldirs = project->variables()["DLLDESTDIR"];
773 QString copydll = "# Begin Special Build Tool\n" 810 if ( dlldirs.count() )
774 "TargetPath=" + dest + "\n" 811 copyDllStep += "\t";
775 "SOURCE=$(InputPath)\n"
776 "PostBuild_Desc=Copy DLL to " + project->first("DLLDESTDIR") + "\n"
777 "PostBuild_Cmds=";
778
779 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) { 812 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) {
780 copydll += "copy \"" + dest + "\" \"" + *dlldir + "\"\t"; 813 copyDllStep += "copy \"$(TargetPath)\" \"" + *dlldir + "\"\t";
781 } 814 }
782
783 copydll += "\n# End Special Build Tool";
784 project->variables()["MSVCDSP_COPY_DLL_REL"].append( copydll );
785 project->variables()["MSVCDSP_COPY_DLL_DBG"].append( copydll );
786 } 815 }
816
787 if ( project->isActiveConfig("activeqt") ) { 817 if ( project->isActiveConfig("activeqt") ) {
788 QString idl = project->variables()["QMAKE_IDL"].first(); 818 QString idl = project->variables()["QMAKE_IDL"].first();
789 QString idc = project->variables()["QMAKE_IDC"].first(); 819 QString idc = project->variables()["QMAKE_IDC"].first();
790 QString version = project->variables()["VERSION"].first(); 820 QString version = project->variables()["VERSION"].first();
791 if ( version.isEmpty() ) 821 if ( version.isEmpty() )
792 version = "1.0"; 822 version = "1.0";
793 823
794 project->variables()["MSVCDSP_IDLSOURCES"].append( "tmp\\" + targetfilename + ".idl" ); 824 project->variables()["MSVCDSP_IDLSOURCES"].append( "tmp\\" + targetfilename + ".idl" );
795 project->variables()["MSVCDSP_IDLSOURCES"].append( "tmp\\" + targetfilename + ".tlb" ); 825 project->variables()["MSVCDSP_IDLSOURCES"].append( "tmp\\" + targetfilename + ".tlb" );
796 project->variables()["MSVCDSP_IDLSOURCES"].append( "tmp\\" + targetfilename + ".midl" ); 826 project->variables()["MSVCDSP_IDLSOURCES"].append( "tmp\\" + targetfilename + ".midl" );
797 if ( project->isActiveConfig( "dll" ) ) { 827 if ( project->isActiveConfig( "dll" ) ) {
798 QString regcmd = "# Begin Special Build Tool\n" 828 activeQtStepPreCopyDll +=
799 "TargetPath=" + targetfilename + "\n" 829 "\t" + idc + " %1 -idl tmp\\" + targetfilename + ".idl -version " + version +
800 "SOURCE=$(InputPath)\n"
801 "PostBuild_Desc=Finalizing ActiveQt server...\n"
802 "PostBuild_Cmds=" +
803 idc + " %1 -idl tmp\\" + targetfilename + ".idl -version " + version +
804 "\t" + idl + " tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl" 830 "\t" + idl + " tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl"
805 "\t" + idc + " %1 /tlb tmp\\" + targetfilename + ".tlb" 831 "\t" + idc + " %1 /tlb tmp\\" + targetfilename + ".tlb";
806 "\t" + idc + " %1 /regserver\n" 832 activeQtStepPostCopyDll +=
807 "# End Special Build Tool"; 833 "\t" + idc + " %1 /regserver\n";
808 834
809 QString executable = project->variables()["MSVCDSP_TARGETDIRREL"].first() + "\\" + project->variables()["TARGET"].first(); 835 QString executable = project->variables()["MSVCDSP_TARGETDIRREL"].first() + "\\" + targetfilename + ".dll";
810 project->variables()["MSVCDSP_COPY_DLL_REL"].append( regcmd.arg(executable).arg(executable).arg(executable) ); 836 activeQtStepPreCopyDllRelease = activeQtStepPreCopyDll.arg(executable).arg(executable);
837 activeQtStepPostCopyDllRelease = activeQtStepPostCopyDll.arg(executable);
811 838
812 executable = project->variables()["MSVCDSP_TARGETDIRDEB"].first() + "\\" + project->variables()["TARGET"].first(); 839 executable = project->variables()["MSVCDSP_TARGETDIRDEB"].first() + "\\" + targetfilename + ".dll";
813 project->variables()["MSVCDSP_COPY_DLL_DBG"].append( regcmd.arg(executable).arg(executable).arg(executable) ); 840 activeQtStepPreCopyDllDebug = activeQtStepPreCopyDll.arg(executable).arg(executable);
841 activeQtStepPostCopyDllDebug = activeQtStepPostCopyDll.arg(executable);
814 } else { 842 } else {
815 QString regcmd = "# Begin Special Build Tool\n" 843 activeQtStepPreCopyDll +=
816 "TargetPath=" + targetfilename + "\n" 844 "\t%1 -dumpidl tmp\\" + targetfilename + ".idl -version " + version +
817 "SOURCE=$(InputPath)\n"
818 "PostBuild_Desc=Finalizing ActiveQt server...\n"
819 "PostBuild_Cmds="
820 "%1 -dumpidl tmp\\" + targetfilename + ".idl -version " + version +
821 "\t" + idl + " tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl" 845 "\t" + idl + " tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl"
822 "\t" + idc + " %1 /tlb tmp\\" + targetfilename + ".tlb" 846 "\t" + idc + " %1 /tlb tmp\\" + targetfilename + ".tlb";
823 "\t%1 -regserver\n" 847 activeQtStepPostCopyDll +=
824 "# End Special Build Tool"; 848 "\t%1 -regserver\n";
849 QString executable = project->variables()["MSVCDSP_TARGETDIRREL"].first() + "\\" + targetfilename + ".exe";
850 activeQtStepPreCopyDllRelease = activeQtStepPreCopyDll.arg(executable).arg(executable);
851 activeQtStepPostCopyDllRelease = activeQtStepPostCopyDll.arg(executable);
825 852
826 QString executable = project->variables()["MSVCDSP_TARGETDIRREL"].first() + "\\" + project->variables()["TARGET"].first(); 853 executable = project->variables()["MSVCDSP_TARGETDIRDEB"].first() + "\\" + targetfilename + ".exe";
827 project->variables()["MSVCDSP_REGSVR_REL"].append( regcmd.arg(executable).arg(executable).arg(executable) ); 854 activeQtStepPreCopyDllDebug = activeQtStepPreCopyDll.arg(executable).arg(executable);
855 activeQtStepPostCopyDllDebug = activeQtStepPostCopyDll.arg(executable);
856 }
828 857
829 executable = project->variables()["MSVCDSP_TARGETDIRDEB"].first() + "\\" + project->variables()["TARGET"].first();
830 project->variables()["MSVCDSP_REGSVR_DBG"].append( regcmd.arg(executable).arg(executable).arg(executable) );
831 } 858 }
832 859
860
861 if ( !postLinkStep.isEmpty() || !copyDllStep.isEmpty() || !activeQtStepPreCopyDllDebug.isEmpty() || !activeQtStepPreCopyDllRelease.isEmpty() ) {
862 project->variables()["MSVCDSP_POST_LINK_DBG"].append(
863 "# Begin Special Build Tool\n"
864 "SOURCE=$(InputPath)\n"
865 "PostBuild_Desc=Post Build Step\n"
866 "PostBuild_Cmds=" + postLinkStep + activeQtStepPreCopyDllDebug + copyDllStep + activeQtStepPostCopyDllDebug + "\n"
867 "# End Special Build Tool\n" );
868 project->variables()["MSVCDSP_POST_LINK_REL"].append(
869 "# Begin Special Build Tool\n"
870 "SOURCE=$(InputPath)\n"
871 "PostBuild_Desc=Post Build Step\n"
872 "PostBuild_Cmds=" + postLinkStep + activeQtStepPreCopyDllRelease + copyDllStep + activeQtStepPostCopyDllRelease + "\n"
873 "# End Special Build Tool\n" );
833 } 874 }
875
834 if ( !project->variables()["SOURCES"].isEmpty() || !project->variables()["RC_FILE"].isEmpty() ) { 876 if ( !project->variables()["SOURCES"].isEmpty() || !project->variables()["RC_FILE"].isEmpty() ) {
835 project->variables()["SOURCES"] += project->variables()["RC_FILE"]; 877 project->variables()["SOURCES"] += project->variables()["RC_FILE"];
836 } 878 }
837 QStringList &list = project->variables()["FORMS"]; 879 QStringList &list = project->variables()["FORMS"];
838 for( it = list.begin(); it != list.end(); ++it ) { 880 for( it = list.begin(); it != list.end(); ++it ) {
839 if ( QFile::exists( *it + ".h" ) ) 881 if ( QFile::exists( *it + ".h" ) )
840 project->variables()["SOURCES"].append( *it + ".h" ); 882 project->variables()["SOURCES"].append( *it + ".h" );
841 } 883 }
842 project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "MSVCDSP_LIBS"; 884 project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "MSVCDSP_LIBS";
843} 885}
844 886
845 887
846QString 888QString
847DspMakefileGenerator::findTemplate(QString file) 889DspMakefileGenerator::findTemplate(const QString &file)
848{ 890{
849 QString ret; 891 QString ret;
850 if(!QFile::exists((ret = file)) && 892 if(!QFile::exists((ret = file)) &&
851 !QFile::exists((ret = QString(Option::mkfile::qmakespec + "/" + file))) && 893 !QFile::exists((ret = QString(Option::mkfile::qmakespec + "/" + file))) &&
852 !QFile::exists((ret = QString(getenv("QTDIR")) + "/mkspecs/win32-msvc/" + file)) && 894 !QFile::exists((ret = QString(getenv("QTDIR")) + "/mkspecs/win32-msvc/" + file)) &&
853 !QFile::exists((ret = (QString(getenv("HOME")) + "/.tmake/" + file)))) 895 !QFile::exists((ret = (QString(getenv("HOME")) + "/.tmake/" + file))))
854 return ""; 896 return "";
855 return ret; 897 return ret;
856} 898}
857 899
858 900
859void 901void
860DspMakefileGenerator::processPrlVariable(const QString &var, const QStringList &l) 902DspMakefileGenerator::processPrlVariable(const QString &var, const QStringList &l)
861{ 903{
862 if(var == "QMAKE_PRL_DEFINES") { 904 if(var == "QMAKE_PRL_DEFINES") {
863 QStringList &out = project->variables()["MSVCDSP_DEFINES"]; 905 QStringList &out = project->variables()["MSVCDSP_DEFINES"];
864 for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) { 906 for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
865 if(out.findIndex((*it)) == -1) 907 if(out.findIndex((*it)) == -1)
866 out.append((" /D \"" + *it + "\"")); 908 out.append((" /D \"" + *it + "\""));
867 } 909 }
868 } else { 910 } else {
869 MakefileGenerator::processPrlVariable(var, l); 911 MakefileGenerator::processPrlVariable(var, l);
870 } 912 }
871} 913}
872 914
873 915
874int 916void
875DspMakefileGenerator::beginGroupForFile(QString file, QTextStream &t, 917DspMakefileGenerator::beginGroupForFile(QString file, QTextStream &t,
876 QString filter) 918 const QString& filter)
877{ 919{
878 if(project->isActiveConfig("flat")) 920 if(project->isActiveConfig("flat"))
879 return 0; 921 return;
880 922
881 fileFixify(file, QDir::currentDirPath(), QDir::currentDirPath(), TRUE); 923 fileFixify(file, QDir::currentDirPath(), QDir::currentDirPath(), TRUE);
882 file = file.section(Option::dir_sep, 0, -2); 924 file = file.section(Option::dir_sep, 0, -2);
883 if(file.right(Option::dir_sep.length()) != Option::dir_sep) 925 if(file.right(Option::dir_sep.length()) != Option::dir_sep)
884 file += Option::dir_sep; 926 file += Option::dir_sep;
885 if(file == currentGroup) 927 if(file == currentGroup)
886 return 0; 928 return;
887 929
888 if(file.isEmpty() || !QDir::isRelativePath(file)) { 930 if(file.isEmpty() || !QDir::isRelativePath(file)) {
889 endGroups(t); 931 endGroups(t);
890 return 0; 932 return;
891 } 933 }
892 if(file.startsWith(currentGroup)) 934 if(file.startsWith(currentGroup))
893 file = file.mid(currentGroup.length()); 935 file = file.mid(currentGroup.length());
894 else 936 int dirSep = currentGroup.findRev( Option::dir_sep );
895 endGroups(t); 937 while( !file.startsWith( currentGroup ) && dirSep != -1 ) {
896 int lvl = file.contains(Option::dir_sep), old_lvl = currentGroup.contains(Option::dir_sep); 938 currentGroup.truncate( dirSep );
897 if(lvl > old_lvl) { 939 dirSep = currentGroup.findRev( Option::dir_sep );
898 QStringList dirs = QStringList::split(Option::dir_sep, file); 940 if ( !file.startsWith( currentGroup ) && dirSep != -1 )
941 t << "\n# End Group\n";
942 }
943 if ( !file.startsWith( currentGroup ) ) {
944 t << "\n# End Group\n";
945 currentGroup = "";
946 }
947 QStringList dirs = QStringList::split(Option::dir_sep, file.right( file.length() - currentGroup.length() ) );
899 for(QStringList::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) { 948 for(QStringList::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) {
900 t << "# Begin Group \"" << (*dir_it) << "\"\n" 949 t << "# Begin Group \"" << (*dir_it) << "\"\n"
901 << "# Prop Default_Filter \"" << filter << "\"\n"; 950 << "# Prop Default_Filter \"" << filter << "\"\n";
902 } 951 }
903 } else {
904 for(int x = old_lvl - lvl; x; x--)
905 t << "\n# End Group\n";
906 }
907 currentGroup = file; 952 currentGroup = file;
908 return lvl - old_lvl;
909} 953}
910 954
911 955
912int 956void
913DspMakefileGenerator::endGroups(QTextStream &t) 957DspMakefileGenerator::endGroups(QTextStream &t)
914{ 958{
915 if(project->isActiveConfig("flat")) 959 if(project->isActiveConfig("flat"))
916 return 0; 960 return;
917 else if(currentGroup.isEmpty()) 961 else if(currentGroup.isEmpty())
918 return 0; 962 return;
919 963
920 QStringList dirs = QStringList::split(Option::dir_sep, currentGroup); 964 QStringList dirs = QStringList::split(Option::dir_sep, currentGroup);
921 for(QStringList::Iterator dir_it = dirs.end(); dir_it != dirs.begin(); --dir_it) { 965 for(QStringList::Iterator dir_it = dirs.end(); dir_it != dirs.begin(); --dir_it) {
922 t << "\n# End Group\n"; 966 t << "\n# End Group\n";
923 } 967 }
924 currentGroup = ""; 968 currentGroup = "";
925 return dirs.count();
926} 969}
927 970
928bool 971bool
929DspMakefileGenerator::openOutput(QFile &file) const 972DspMakefileGenerator::openOutput(QFile &file) const
930{ 973{
931 QString outdir; 974 QString outdir;
932 if(!file.name().isEmpty()) { 975 if(!file.name().isEmpty()) {
933 QFileInfo fi(file); 976 QFileInfo fi(file);
934 if(fi.isDir()) 977 if(fi.isDir())
935 outdir = file.name() + QDir::separator(); 978 outdir = file.name() + QDir::separator();
936 } 979 }
937 if(!outdir.isEmpty() || file.name().isEmpty()) 980 if(!outdir.isEmpty() || file.name().isEmpty())
938 file.setName(outdir + project->first("TARGET") + project->first("DSP_EXTENSION")); 981 file.setName(outdir + project->first("TARGET") + project->first("DSP_EXTENSION"));
939 if(QDir::isRelativePath(file.name())) { 982 if(QDir::isRelativePath(file.name())) {
940 QString ofile; 983 QString ofile;
941 ofile = file.name(); 984 ofile = file.name();
942 int slashfind = ofile.findRev('\\'); 985 int slashfind = ofile.findRev('\\');
943 if (slashfind == -1) { 986 if (slashfind == -1) {
944 ofile = ofile.replace(QRegExp("-"), "_"); 987 ofile = ofile.replace(QRegExp("-"), "_");
945 } else { 988 } else {
946 int hypenfind = ofile.find('-', slashfind); 989 int hypenfind = ofile.find('-', slashfind);
947 while (hypenfind != -1 && slashfind < hypenfind) { 990 while (hypenfind != -1 && slashfind < hypenfind) {
948 ofile = ofile.replace(hypenfind, 1, "_"); 991 ofile = ofile.replace(hypenfind, 1, "_");
949 hypenfind = ofile.find('-', hypenfind + 1); 992 hypenfind = ofile.find('-', hypenfind + 1);
diff --git a/qmake/generators/win32/msvc_dsp.h b/qmake/generators/win32/msvc_dsp.h
index a7fc3e7..3a7d18e 100644
--- a/qmake/generators/win32/msvc_dsp.h
+++ b/qmake/generators/win32/msvc_dsp.h
@@ -1,73 +1,73 @@
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
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this 21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software. 23** with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37#ifndef __DSPMAKE_H__ 37#ifndef __MSVC_DSP_H__
38#define __DSPMAKE_H__ 38#define __MSVC_DSP_H__
39 39
40#include "winmakefile.h" 40#include "winmakefile.h"
41#include <qvaluestack.h> 41#include <qvaluestack.h>
42 42
43class DspMakefileGenerator : public Win32MakefileGenerator 43class DspMakefileGenerator : public Win32MakefileGenerator
44{ 44{
45 QString currentGroup; 45 QString currentGroup;
46 int beginGroupForFile(QString file, QTextStream &, const QString filter=""); 46 void beginGroupForFile(QString file, QTextStream &, const QString& filter="");
47 int endGroups(QTextStream &); 47 void endGroups(QTextStream &);
48 48
49 bool init_flag; 49 bool init_flag;
50 bool writeDspParts(QTextStream &); 50 bool writeDspParts(QTextStream &);
51 51
52 bool writeMakefile(QTextStream &); 52 bool writeMakefile(QTextStream &);
53 QString findTemplate(QString file); 53 QString findTemplate(const QString &file);
54 void init(); 54 void init();
55 55
56public: 56public:
57 DspMakefileGenerator(QMakeProject *p); 57 DspMakefileGenerator(QMakeProject *p);
58 ~DspMakefileGenerator(); 58 ~DspMakefileGenerator();
59 59
60 bool openOutput(QFile &file) const; 60 bool openOutput(QFile &file) const;
61 61
62protected: 62protected:
63 virtual void processPrlVariable(const QString &, const QStringList &); 63 virtual void processPrlVariable(const QString &, const QStringList &);
64 virtual bool findLibraries(); 64 virtual bool findLibraries();
65}; 65};
66 66
67inline DspMakefileGenerator::~DspMakefileGenerator() 67inline DspMakefileGenerator::~DspMakefileGenerator()
68{ } 68{ }
69 69
70inline bool DspMakefileGenerator::findLibraries() 70inline bool DspMakefileGenerator::findLibraries()
71{ return Win32MakefileGenerator::findLibraries("MSVCDSP_LIBS"); } 71{ return Win32MakefileGenerator::findLibraries("MSVCDSP_LIBS"); }
72 72
73#endif /* __DSPMAKE_H__ */ 73#endif /* __MSVC_DSP_H__ */
diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp
index 9cc9a69..ecef34d 100644
--- a/qmake/generators/win32/msvc_nmake.cpp
+++ b/qmake/generators/win32/msvc_nmake.cpp
@@ -1,64 +1,65 @@
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
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this 21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software. 23** with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#include "msvc_nmake.h" 38#include "msvc_nmake.h"
39#include "option.h" 39#include "option.h"
40#include <qregexp.h> 40#include <qregexp.h>
41#include <qdict.h>
41#include <qdir.h> 42#include <qdir.h>
42#include <stdlib.h> 43#include <stdlib.h>
43#include <time.h> 44#include <time.h>
44 45
45 46
46NmakeMakefileGenerator::NmakeMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE) 47NmakeMakefileGenerator::NmakeMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE)
47{ 48{
48 49
49} 50}
50 51
51bool 52bool
52NmakeMakefileGenerator::writeMakefile(QTextStream &t) 53NmakeMakefileGenerator::writeMakefile(QTextStream &t)
53{ 54{
54 writeHeader(t); 55 writeHeader(t);
55 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) { 56 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {
56 t << "all clean:" << "\n\t" 57 t << "all clean:" << "\n\t"
57 << "@echo \"Some of the required modules (" 58 << "@echo \"Some of the required modules ("
58 << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t" 59 << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t"
59 << "@echo \"Skipped.\"" << endl << endl; 60 << "@echo \"Skipped.\"" << endl << endl;
60 writeMakeQmake(t); 61 writeMakeQmake(t);
61 return TRUE; 62 return TRUE;
62 } 63 }
63 64
64 if(project->first("TEMPLATE") == "app" || 65 if(project->first("TEMPLATE") == "app" ||
@@ -114,159 +115,209 @@ NmakeMakefileGenerator::writeNmakeParts(QTextStream &t)
114 lib.replace(QRegExp("\""), ""); 115 lib.replace(QRegExp("\""), "");
115 t << " \"" << lib << "\""; 116 t << " \"" << lib << "\"";
116 } 117 }
117 t << endl; 118 t << endl;
118 } 119 }
119 else { 120 else {
120 t << "LIB =" << var("QMAKE_LIB") << endl; 121 t << "LIB =" << var("QMAKE_LIB") << endl;
121 } 122 }
122 t << "MOC =" << (project->isEmpty("QMAKE_MOC") ? QString("moc") : 123 t << "MOC =" << (project->isEmpty("QMAKE_MOC") ? QString("moc") :
123 Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl; 124 Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl;
124 t << "UIC =" << (project->isEmpty("QMAKE_UIC") ? QString("uic") : 125 t << "UIC =" << (project->isEmpty("QMAKE_UIC") ? QString("uic") :
125 Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl; 126 Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl;
126 t << "QMAKE =" << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : 127 t << "QMAKE =" << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") :
127 Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl; 128 Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl;
128 t << "IDC =" << (project->isEmpty("QMAKE_IDC") ? QString("idc") : 129 t << "IDC =" << (project->isEmpty("QMAKE_IDC") ? QString("idc") :
129 Option::fixPathToTargetOS(var("QMAKE_IDC"), FALSE)) << endl; 130 Option::fixPathToTargetOS(var("QMAKE_IDC"), FALSE)) << endl;
130 t << "IDL =" << (project->isEmpty("QMAKE_IDL") ? QString("midl") : 131 t << "IDL =" << (project->isEmpty("QMAKE_IDL") ? QString("midl") :
131 Option::fixPathToTargetOS(var("QMAKE_IDL"), FALSE)) << endl; 132 Option::fixPathToTargetOS(var("QMAKE_IDL"), FALSE)) << endl;
132 t << "ZIP =" << var("QMAKE_ZIP") << endl; 133 t << "ZIP =" << var("QMAKE_ZIP") << endl;
133 t << "COPY_FILE= " << var("QMAKE_COPY") << endl; 134 t << "COPY_FILE= " << var("QMAKE_COPY") << endl;
134 t << "COPY_DIR= " << var("QMAKE_COPY") << endl; 135 t << "COPY_DIR= " << var("QMAKE_COPY") << endl;
135 t << "DEL_FILE= " << var("QMAKE_DEL_FILE") << endl; 136 t << "DEL_FILE= " << var("QMAKE_DEL_FILE") << endl;
136 t << "DEL_DIR= " << var("QMAKE_DEL_DIR") << endl; 137 t << "DEL_DIR= " << var("QMAKE_DEL_DIR") << endl;
137 t << "MOVE = " << var("QMAKE_MOVE") << endl; 138 t << "MOVE = " << var("QMAKE_MOVE") << endl;
139 t << "CHK_DIR_EXISTS =" << var("QMAKE_CHK_DIR_EXISTS") << endl;
140 t << "MKDIR =" << var("QMAKE_MKDIR") << endl;
138 t << endl; 141 t << endl;
139 142
140 t << "####### Files" << endl << endl; 143 t << "####### Files" << endl << endl;
141 t << "HEADERS =" << varList("HEADERS") << endl; 144 t << "HEADERS =" << varList("HEADERS") << endl;
142 t << "SOURCES =" << varList("SOURCES") << endl; 145 t << "SOURCES =" << varList("SOURCES") << endl;
143 t << "OBJECTS =" << varList("OBJECTS") << endl; 146 t << "OBJECTS =" << varList("OBJECTS") << endl;
144 t << "FORMS =" << varList("FORMS") << endl; 147 t << "FORMS =" << varList("FORMS") << endl;
145 t << "UICDECLS =" << varList("UICDECLS") << endl; 148 t << "UICDECLS =" << varList("UICDECLS") << endl;
146 t << "UICIMPLS =" << varList("UICIMPLS") << endl; 149 t << "UICIMPLS =" << varList("UICIMPLS") << endl;
147 t << "SRCMOC =" << varList("SRCMOC") << endl; 150 t << "SRCMOC =" << varList("SRCMOC") << endl;
148 t << "OBJMOC =" << varList("OBJMOC") << endl; 151 t << "OBJMOC =" << varList("OBJMOC") << endl;
149 t << "DIST =" << varList("DISTFILES") << endl; 152 t << "DIST =" << varList("DISTFILES") << endl;
150 t << "TARGET ="; 153 t << "TARGET =";
151 if( !project->variables()[ "DESTDIR" ].isEmpty() ) 154 if( !project->variables()[ "DESTDIR" ].isEmpty() )
152 t << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT")); 155 t << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT"));
153 else 156 else
154 t << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first(); 157 t << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first();
155 t << endl; 158 t << endl;
156 t << endl; 159 t << endl;
157 160
158 t << "####### Implicit rules" << endl << endl; 161 t << "####### Implicit rules" << endl << endl;
159 t << ".SUFFIXES: .cpp .cxx .cc .c" << endl << endl; 162 t << ".SUFFIXES: .c";
160 t << ".cpp.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; 163 QStringList::Iterator cppit;
161 t << ".cxx.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; 164 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
162 t << ".cc.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; 165 t << " " << (*cppit);
163 t << ".c.obj:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl; 166 t << endl << endl;
167 if(!project->isActiveConfig("no_batch")) {
168 // Batchmode doesn't use the non implicit rules QMAKE_RUN_CXX & QMAKE_RUN_CC
169 project->variables().remove("QMAKE_RUN_CXX");
170 project->variables().remove("QMAKE_RUN_CC");
171
172 QDict<void> source_directories;
173 source_directories.insert(".", (void*)1);
174 if(!project->isEmpty("MOC_DIR"))
175 source_directories.insert(project->first("MOC_DIR"), (void*)1);
176 if(!project->isEmpty("UI_SOURCES_DIR"))
177 source_directories.insert(project->first("UI_SOURCES_DIR"), (void*)1);
178 else if(!project->isEmpty("UI_DIR"))
179 source_directories.insert(project->first("UI_DIR"), (void*)1);
180 QString srcs[] = { QString("SOURCES"), QString("UICIMPLS"), QString("SRCMOC"), QString::null };
181 for(int x = 0; !srcs[x].isNull(); x++) {
182 QStringList &l = project->variables()[srcs[x]];
183 for(QStringList::Iterator sit = l.begin(); sit != l.end(); ++sit) {
184 QString sep = "\\";
185 if((*sit).find(sep) == -1)
186 sep = "/";
187 QString dir = (*sit).section(sep, 0, -2);
188 if(!dir.isEmpty() && !source_directories[dir])
189 source_directories.insert(dir, (void*)1);
190 }
191 }
192
193 for(QDictIterator<void> it(source_directories); it.current(); ++it) {
194 if(it.currentKey().isEmpty())
195 continue;
196 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
197 t << "{" << it.currentKey() << "}" << (*cppit) << "{" << var("OBJECTS_DIR") << "}" << Option::obj_ext << "::\n\t"
198 << var("QMAKE_RUN_CXX_IMP_BATCH").replace( QRegExp( "\\$@" ), var("OBJECTS_DIR") ) << endl << "\t$<" << endl << "<<" << endl << endl;
199 t << "{" << it.currentKey() << "}" << ".c{" << var("OBJECTS_DIR") << "}" << Option::obj_ext << "::\n\t"
200 << var("QMAKE_RUN_CC_IMP_BATCH").replace( QRegExp( "\\$@" ), var("OBJECTS_DIR") ) << endl << "\t$<" << endl << "<<" << endl << endl;
201 }
202 } else {
203 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
204 t << (*cppit) << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
205 t << ".c" << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;
206 }
164 207
165 t << "####### Build rules" << endl << endl; 208 t << "####### Build rules" << endl << endl;
166 t << "all: " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" << endl << endl; 209 t << "all: " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" << endl << endl;
167 t << "$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) " << var("TARGETDEPS"); 210 t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) "
211 << var("POST_TARGETDEPS");
168 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) { 212 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
169 t << "\n\t" << "$(LINK) $(LFLAGS) /OUT:$(TARGET) @<< " << "\n\t " 213 t << "\n\t" << "$(LINK) $(LFLAGS) /OUT:$(TARGET) @<< " << "\n\t "
170 << "$(OBJECTS) $(OBJMOC) $(LIBS)"; 214 << "$(OBJECTS) $(OBJMOC) $(LIBS)";
171 } else { 215 } else {
172 t << "\n\t" << "$(LIB) /OUT:$(TARGET) @<<" << "\n\t " 216 t << "\n\t" << "$(LIB) /OUT:$(TARGET) @<<" << "\n\t "
173 << "$(OBJECTS) $(OBJMOC)"; 217 << "$(OBJECTS) $(OBJMOC)";
174 } 218 }
175 t << endl << "<<" << endl; 219 t << endl << "<<" << endl;
220 if ( !project->variables()["QMAKE_POST_LINK"].isEmpty() )
221 t << "\t" << var( "QMAKE_POST_LINK" ) << endl;
176 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) { 222 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) {
177 QStringList dlldirs = project->variables()["DLLDESTDIR"]; 223 QStringList dlldirs = project->variables()["DLLDESTDIR"];
178 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) { 224 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) {
179 t << "\n\t" << "-copy $(TARGET) " << *dlldir; 225 t << "\n\t" << "-copy $(TARGET) " << *dlldir;
180 } 226 }
181 } 227 }
182 QString targetfilename = project->variables()["TARGET"].first(); 228 QString targetfilename = project->variables()["TARGET"].first();
183 if(project->isActiveConfig("activeqt")) { 229 if(project->isActiveConfig("activeqt")) {
184 QString version = project->variables()["VERSION"].first(); 230 QString version = project->variables()["VERSION"].first();
185 if ( version.isEmpty() ) 231 if ( version.isEmpty() )
186 version = "1.0"; 232 version = "1.0";
187 233
188 if ( project->isActiveConfig("dll")) { 234 if ( project->isActiveConfig("dll")) {
189 t << "\n\t" << ("-$(IDC) $(TARGET) /idl tmp\\" + targetfilename + ".idl -version " + version); 235 t << "\n\t" << ("-$(IDC) $(TARGET) /idl tmp\\" + targetfilename + ".idl -version " + version);
190 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl"); 236 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl");
191 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb"); 237 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb");
192 t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" ); 238 t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" );
193 } else { 239 } else {
194 t << "\n\t" << ("-$(TARGET) -dumpidl tmp\\" + targetfilename + ".idl -version " + version); 240 t << "\n\t" << ("-$(TARGET) -dumpidl tmp\\" + targetfilename + ".idl -version " + version);
195 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl"); 241 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl");
196 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb"); 242 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb");
197 t << "\n\t" << "-$(TARGET) -regserver"; 243 t << "\n\t" << "-$(TARGET) -regserver";
198 } 244 }
199 } 245 }
200 t << endl << endl; 246 t << endl << endl;
201 247
202 if(!project->variables()["RC_FILE"].isEmpty()) { 248 if(!project->variables()["RC_FILE"].isEmpty()) {
203 t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t" 249 t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t"
204 << var("QMAKE_RC") << " " << var("RC_FILE") << endl << endl; 250 << var("QMAKE_RC") << " " << var("RC_FILE") << endl << endl;
205 } 251 }
206 252
207 t << "mocables: $(SRCMOC)" << endl << endl; 253 t << "mocables: $(SRCMOC)" << endl << endl;
208 254
209 writeMakeQmake(t); 255 writeMakeQmake(t);
210 256
211 t << "dist:" << "\n\t" 257 t << "dist:" << "\n\t"
212 << "$(ZIP) " << var("PROJECT") << ".zip " 258 << "$(ZIP) " << var("PROJECT") << ".zip "
213 << var("PROJECT") << ".pro $(SOURCES) $(HEADERS) $(DIST) $(FORMS)" << endl << endl; 259 << var("PROJECT") << ".pro $(SOURCES) $(HEADERS) $(DIST) $(FORMS)" << endl << endl;
214 260
215 t << "clean:" 261 t << "clean:"
216 << varGlue("OBJECTS","\n\t-del ","\n\t-del ","") 262 << varGlue("OBJECTS","\n\t-del ","\n\t-del ","")
217 << varGlue("SRCMOC" ,"\n\t-del ","\n\t-del ","") 263 << varGlue("SRCMOC" ,"\n\t-del ","\n\t-del ","")
218 << varGlue("OBJMOC" ,"\n\t-del ","\n\t-del ","") 264 << varGlue("OBJMOC" ,"\n\t-del ","\n\t-del ","")
219 << varGlue("UICDECLS" ,"\n\t-del ","\n\t-del ","") 265 << varGlue("UICDECLS" ,"\n\t-del ","\n\t-del ","")
220 << varGlue("UICIMPLS" ,"\n\t-del ","\n\t-del ","") 266 << varGlue("UICIMPLS" ,"\n\t-del ","\n\t-del ","")
221 << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ","") 267 << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ","")
222 << varGlue("CLEAN_FILES","\n\t-del ","\n\t-del ",""); 268 << varGlue("CLEAN_FILES","\n\t-del ","\n\t-del ","");
269
223 if ( project->isActiveConfig("activeqt")) { 270 if ( project->isActiveConfig("activeqt")) {
224 t << ("\n\t-del tmp\\" + targetfilename + ".*"); 271 t << ("\n\t-del tmp\\" + targetfilename + ".*");
225 t << "\n\t-del tmp\\dump.*"; 272 t << "\n\t-del tmp\\dump.*";
226 } 273 }
227 if(!project->isEmpty("IMAGES")) 274 if(!project->isEmpty("IMAGES"))
228 t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-del ", "\n\t-del ", ""); 275 t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-del ", "\n\t-del ", "");
229 276
230 // blasted user defined targets 277 // blasted user defined targets
231 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"]; 278 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"];
232 for(QStringList::Iterator it = qut.begin(); it != qut.end(); ++it) { 279 for(QStringList::Iterator it = qut.begin(); it != qut.end(); ++it) {
233 QString targ = var((*it) + ".target"), 280 QString targ = var((*it) + ".target"),
234 cmd = var((*it) + ".commands"), deps; 281 cmd = var((*it) + ".commands"), deps;
235 if(targ.isEmpty()) 282 if(targ.isEmpty())
236 targ = (*it); 283 targ = (*it);
237 QStringList &deplist = project->variables()[(*it) + ".depends"]; 284 QStringList &deplist = project->variables()[(*it) + ".depends"];
238 for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) { 285 for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) {
239 QString dep = var((*dep_it) + ".target"); 286 QString dep = var((*dep_it) + ".target");
240 if(dep.isEmpty()) 287 if(dep.isEmpty())
241 dep = (*dep_it); 288 dep = (*dep_it);
242 deps += " " + dep; 289 deps += " " + dep;
243 } 290 }
244 t << "\n\n" << targ << ":" << deps << "\n\t" 291 t << "\n\n" << targ << ":" << deps << "\n\t"
245 << cmd; 292 << cmd;
246 } 293 }
247 294
248 t << endl << endl; 295 t << endl << endl;
296
297 t << "distclean: clean"
298 << "\n\t-del $(TARGET)"
299 << endl << endl;
249} 300}
250 301
251 302
252void 303void
253NmakeMakefileGenerator::init() 304NmakeMakefileGenerator::init()
254{ 305{
255 if(init_flag) 306 if(init_flag)
256 return; 307 return;
257 init_flag = TRUE; 308 init_flag = TRUE;
258 309
259 /* this should probably not be here, but I'm using it to wrap the .t files */ 310 /* this should probably not be here, but I'm using it to wrap the .t files */
260 if(project->first("TEMPLATE") == "app") 311 if(project->first("TEMPLATE") == "app")
261 project->variables()["QMAKE_APP_FLAG"].append("1"); 312 project->variables()["QMAKE_APP_FLAG"].append("1");
262 else if(project->first("TEMPLATE") == "lib") 313 else if(project->first("TEMPLATE") == "lib")
263 project->variables()["QMAKE_LIB_FLAG"].append("1"); 314 project->variables()["QMAKE_LIB_FLAG"].append("1");
264 else if(project->first("TEMPLATE") == "subdirs") { 315 else if(project->first("TEMPLATE") == "subdirs") {
265 MakefileGenerator::init(); 316 MakefileGenerator::init();
266 if(project->variables()["MAKEFILE"].isEmpty()) 317 if(project->variables()["MAKEFILE"].isEmpty())
267 project->variables()["MAKEFILE"].append("Makefile"); 318 project->variables()["MAKEFILE"].append("Makefile");
268 if(project->variables()["QMAKE"].isEmpty()) 319 if(project->variables()["QMAKE"].isEmpty())
269 project->variables()["QMAKE"].append("qmake"); 320 project->variables()["QMAKE"].append("qmake");
270 return; 321 return;
271 } 322 }
272 323
@@ -410,79 +461,102 @@ NmakeMakefileGenerator::init()
410 project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE"]; 461 project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE"];
411 project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS"]; 462 project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS"];
412 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty()) { 463 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty()) {
413 project->variables()["TARGET_EXT"].append(".exe"); 464 project->variables()["TARGET_EXT"].append(".exe");
414 } else { 465 } else {
415 project->variables()["TARGET_EXT"].append(".lib"); 466 project->variables()["TARGET_EXT"].append(".lib");
416 } 467 }
417 } 468 }
418 if ( project->isActiveConfig("windows") ) { 469 if ( project->isActiveConfig("windows") ) {
419 if ( project->isActiveConfig("console") ) { 470 if ( project->isActiveConfig("console") ) {
420 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"]; 471 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
421 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"]; 472 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
422 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"]; 473 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
423 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"]; 474 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
424 } else { 475 } else {
425 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"]; 476 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"];
426 } 477 }
427 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"]; 478 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"];
428 } else { 479 } else {
429 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"]; 480 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
430 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"]; 481 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
431 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"]; 482 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
432 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"]; 483 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
433 } 484 }
485 if ( project->isActiveConfig("stl") ) {
486 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_ON"];
487 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_ON"];
488 } else {
489 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_OFF"];
490 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_OFF"];
491 }
492 if ( project->isActiveConfig("exceptions") ) {
493 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_ON"];
494 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_ON"];
495 } else {
496 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_OFF"];
497 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_OFF"];
498 }
499 if ( project->isActiveConfig("rtti") ) {
500 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_ON"];
501 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_ON"];
502 } else {
503 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_OFF"];
504 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_OFF"];
505 }
506
434 507
435 if ( project->isActiveConfig("moc") ) 508 if ( project->isActiveConfig("moc") )
436 setMocAware(TRUE); 509 setMocAware(TRUE);
437 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; 510 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
438 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ', 511 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ',
439 "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH"); 512 "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH");
440 QStringList &l = project->variables()["QMAKE_FILETAGS"]; 513 QStringList &l = project->variables()["QMAKE_FILETAGS"];
441 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 514 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
442 QStringList &gdmf = project->variables()[(*it)]; 515 QStringList &gdmf = project->variables()[(*it)];
443 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner) 516 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner)
444 (*inner) = Option::fixPathToTargetOS((*inner), FALSE); 517 (*inner) = Option::fixPathToTargetOS((*inner), FALSE);
445 } 518 }
446 519
447 if ( !project->variables()["DEF_FILE"].isEmpty() ) 520 if ( !project->variables()["DEF_FILE"].isEmpty() )
448 project->variables()["QMAKE_LFLAGS"].append(QString("/DEF:") + project->first("DEF_FILE")); 521 project->variables()["QMAKE_LFLAGS"].append(QString("/DEF:") + project->first("DEF_FILE"));
449 if(!project->isActiveConfig("incremental")) 522 if(!project->isActiveConfig("incremental"))
450 project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no")); 523 project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no"));
451 524
452 if ( !project->variables()["VERSION"].isEmpty() ) { 525 if ( !project->variables()["VERSION"].isEmpty() ) {
453 QString version = project->variables()["VERSION"][0]; 526 QString version = project->variables()["VERSION"][0];
454 int firstDot = version.find( "." ); 527 int firstDot = version.find( "." );
455 QString major = version.left( firstDot ); 528 QString major = version.left( firstDot );
456 QString minor = version.right( version.length() - firstDot - 1 ); 529 QString minor = version.right( version.length() - firstDot - 1 );
457 minor.replace( ".", "" ); 530 minor.replace( ".", "" );
458 project->variables()["QMAKE_LFLAGS"].append( "/VERSION:" + major + "." + minor ); 531 project->variables()["QMAKE_LFLAGS"].append( "/VERSION:" + major + "." + minor );
459 } 532 }
460 if ( !project->variables()["RC_FILE"].isEmpty()) { 533 if ( !project->variables()["RC_FILE"].isEmpty()) {
461 if ( !project->variables()["RES_FILE"].isEmpty()) { 534 if ( !project->variables()["RES_FILE"].isEmpty()) {
462 fprintf(stderr, "Both .rc and .res file specified.\n"); 535 fprintf(stderr, "Both .rc and .res file specified.\n");
463 fprintf(stderr, "Please specify one of them, not both."); 536 fprintf(stderr, "Please specify one of them, not both.");
464 exit(666); 537 exit(666);
465 } 538 }
466 project->variables()["RES_FILE"] = project->variables()["RC_FILE"]; 539 project->variables()["RES_FILE"] = project->variables()["RC_FILE"];
467 project->variables()["RES_FILE"].first().replace(".rc",".res"); 540 project->variables()["RES_FILE"].first().replace(".rc",".res");
468 project->variables()["TARGETDEPS"] += project->variables()["RES_FILE"]; 541 project->variables()["POST_TARGETDEPS"] += project->variables()["RES_FILE"];
469 } 542 }
470 if ( !project->variables()["RES_FILE"].isEmpty()) 543 if ( !project->variables()["RES_FILE"].isEmpty())
471 project->variables()["QMAKE_LIBS"] += project->variables()["RES_FILE"]; 544 project->variables()["QMAKE_LIBS"] += project->variables()["RES_FILE"];
472 545
473 MakefileGenerator::init(); 546 MakefileGenerator::init();
474 if ( !project->variables()["VERSION"].isEmpty()) { 547 if ( !project->variables()["VERSION"].isEmpty()) {
475 QStringList l = QStringList::split('.', project->first("VERSION")); 548 QStringList l = QStringList::split('.', project->first("VERSION"));
476 project->variables()["VER_MAJ"].append(l[0]); 549 project->variables()["VER_MAJ"].append(l[0]);
477 project->variables()["VER_MIN"].append(l[1]); 550 project->variables()["VER_MIN"].append(l[1]);
478 } 551 }
552
553 QString version = QStringList::split('.', project->first("VERSION")).join("");
479 if(project->isActiveConfig("dll")) { 554 if(project->isActiveConfig("dll")) {
480 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + ".lib"); 555 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + version + ".exp");
481 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + ".exp");
482 } 556 }
483 if(project->isActiveConfig("debug")) { 557 if(project->isActiveConfig("debug")) {
484 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + ".pdb"); 558 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + version + ".pdb");
485 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + ".ilk"); 559 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + version + ".ilk");
486 project->variables()["QMAKE_CLEAN"].append("vc*.pdb"); 560 project->variables()["QMAKE_CLEAN"].append("vc*.pdb");
487 } 561 }
488} 562}
diff --git a/qmake/generators/win32/msvc_nmake.h b/qmake/generators/win32/msvc_nmake.h
index d3e170f..579fc35 100644
--- a/qmake/generators/win32/msvc_nmake.h
+++ b/qmake/generators/win32/msvc_nmake.h
@@ -1,59 +1,59 @@
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
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this 21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software. 23** with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37#ifndef __NMAKEMAKE_H__ 37#ifndef __MSVC_NMAKE_H__
38#define __NMAKEMAKE_H__ 38#define __MSVC_NMAKE_H__
39 39
40#include "winmakefile.h" 40#include "winmakefile.h"
41 41
42class NmakeMakefileGenerator : public Win32MakefileGenerator 42class NmakeMakefileGenerator : public Win32MakefileGenerator
43{ 43{
44 bool init_flag; 44 bool init_flag;
45 void writeNmakeParts(QTextStream &); 45 void writeNmakeParts(QTextStream &);
46 46
47 bool writeMakefile(QTextStream &); 47 bool writeMakefile(QTextStream &);
48 void init(); 48 void init();
49 49
50public: 50public:
51 NmakeMakefileGenerator(QMakeProject *p); 51 NmakeMakefileGenerator(QMakeProject *p);
52 ~NmakeMakefileGenerator(); 52 ~NmakeMakefileGenerator();
53 53
54}; 54};
55 55
56inline NmakeMakefileGenerator::~NmakeMakefileGenerator() 56inline NmakeMakefileGenerator::~NmakeMakefileGenerator()
57{ } 57{ }
58 58
59#endif /* __NMAKEMAKE_H__ */ 59#endif /* __MSVC_NMAKE_H__ */
diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp
index c2b9e30..7ffe4f7 100644
--- a/qmake/generators/win32/msvc_objectmodel.cpp
+++ b/qmake/generators/win32/msvc_objectmodel.cpp
@@ -362,49 +362,49 @@ VCCLCompilerTool::VCCLCompilerTool()
362 OptimizeForProcessor( procOptimizeBlended ), 362 OptimizeForProcessor( procOptimizeBlended ),
363 OptimizeForWindowsApplication( unset ), 363 OptimizeForWindowsApplication( unset ),
364 RuntimeLibrary( rtMultiThreaded ), 364 RuntimeLibrary( rtMultiThreaded ),
365 RuntimeTypeInfo( unset ), 365 RuntimeTypeInfo( unset ),
366 ShowIncludes( unset ), 366 ShowIncludes( unset ),
367 SmallerTypeCheck( unset ), 367 SmallerTypeCheck( unset ),
368 StringPooling( unset ), 368 StringPooling( unset ),
369 StructMemberAlignment( alignNotSet ), 369 StructMemberAlignment( alignNotSet ),
370 SuppressStartupBanner( unset ), 370 SuppressStartupBanner( unset ),
371 TreatWChar_tAsBuiltInType( unset ), 371 TreatWChar_tAsBuiltInType( unset ),
372 TurnOffAssemblyGeneration( unset ), 372 TurnOffAssemblyGeneration( unset ),
373 UndefineAllPreprocessorDefinitions( unset ), 373 UndefineAllPreprocessorDefinitions( unset ),
374 UsePrecompiledHeader( pchGenerateAuto ), 374 UsePrecompiledHeader( pchGenerateAuto ),
375 WarnAsError( unset ), 375 WarnAsError( unset ),
376 WarningLevel( warningLevel_0 ), 376 WarningLevel( warningLevel_0 ),
377 WholeProgramOptimization( unset ) 377 WholeProgramOptimization( unset )
378{ 378{
379} 379}
380 380
381QTextStream &operator<<( QTextStream &strm, const VCCLCompilerTool &tool ) 381QTextStream &operator<<( QTextStream &strm, const VCCLCompilerTool &tool )
382{ 382{
383 strm << _begTool3; 383 strm << _begTool3;
384 strm << _VCCLCompilerToolName; 384 strm << _VCCLCompilerToolName;
385 strm << XPair( _AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories ); 385 strm << XPair( _AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories );
386 strm << XPair( _AdditionalOptions, tool.AdditionalOptions ); 386 strm << XPair( _AdditionalOptions, tool.AdditionalOptions, " " );
387 strm << XPair( _AdditionalUsingDirectories, tool.AdditionalUsingDirectories ); 387 strm << XPair( _AdditionalUsingDirectories, tool.AdditionalUsingDirectories );
388 strm << SPair( _AssemblerListingLocation, tool.AssemblerListingLocation ); 388 strm << SPair( _AssemblerListingLocation, tool.AssemblerListingLocation );
389 if ( tool.AssemblerOutput != asmListingNone ) strm << EPair( _AssemblerOutput, tool.AssemblerOutput ); 389 if ( tool.AssemblerOutput != asmListingNone ) strm << EPair( _AssemblerOutput, tool.AssemblerOutput );
390 if ( tool.BasicRuntimeChecks != runtimeBasicCheckNone ) strm << EPair( _BasicRuntimeChecks, tool.BasicRuntimeChecks ); 390 if ( tool.BasicRuntimeChecks != runtimeBasicCheckNone ) strm << EPair( _BasicRuntimeChecks, tool.BasicRuntimeChecks );
391 if ( tool.BrowseInformation != brInfoNone ) strm << EPair( _BrowseInformation, tool.BrowseInformation ); 391 if ( tool.BrowseInformation != brInfoNone ) strm << EPair( _BrowseInformation, tool.BrowseInformation );
392 strm << SPair( _BrowseInformationFile, tool.BrowseInformationFile ); 392 strm << SPair( _BrowseInformationFile, tool.BrowseInformationFile );
393 strm << TPair( _BufferSecurityCheck, tool.BufferSecurityCheck ); 393 strm << TPair( _BufferSecurityCheck, tool.BufferSecurityCheck );
394 if ( tool.CallingConvention != callConventionDefault ) strm << EPair( _CallingConvention, tool.CallingConvention ); 394 if ( tool.CallingConvention != callConventionDefault ) strm << EPair( _CallingConvention, tool.CallingConvention );
395 if ( tool.CompileAs != compileAsDefault ) strm << EPair( _CompileAs, tool.CompileAs ); 395 if ( tool.CompileAs != compileAsDefault ) strm << EPair( _CompileAs, tool.CompileAs );
396 if ( tool.CompileAsManaged != managedDefault ) strm << EPair( _CompileAsManaged, tool.CompileAsManaged ); 396 if ( tool.CompileAsManaged != managedDefault ) strm << EPair( _CompileAsManaged, tool.CompileAsManaged );
397 strm << TPair( _CompileOnly, tool.CompileOnly ); 397 strm << TPair( _CompileOnly, tool.CompileOnly );
398 strm << EPair( _DebugInformationFormat, tool.DebugInformationFormat ); 398 strm << EPair( _DebugInformationFormat, tool.DebugInformationFormat );
399 strm << TPair( _DefaultCharIsUnsigned, tool.DefaultCharIsUnsigned ); 399 strm << TPair( _DefaultCharIsUnsigned, tool.DefaultCharIsUnsigned );
400 strm << TPair( _Detect64BitPortabilityProblems, tool.Detect64BitPortabilityProblems ); 400 strm << TPair( _Detect64BitPortabilityProblems, tool.Detect64BitPortabilityProblems );
401 strm << TPair( _DisableLanguageExtensions, tool.DisableLanguageExtensions ); 401 strm << TPair( _DisableLanguageExtensions, tool.DisableLanguageExtensions );
402 strm << XPair( _DisableSpecificWarnings, tool.DisableSpecificWarnings ); 402 strm << XPair( _DisableSpecificWarnings, tool.DisableSpecificWarnings );
403 strm << TPair( _EnableFiberSafeOptimizations, tool.EnableFiberSafeOptimizations ); 403 strm << TPair( _EnableFiberSafeOptimizations, tool.EnableFiberSafeOptimizations );
404 strm << TPair( _EnableFunctionLevelLinking, tool.EnableFunctionLevelLinking ); 404 strm << TPair( _EnableFunctionLevelLinking, tool.EnableFunctionLevelLinking );
405 strm << TPair( _EnableIntrinsicFunctions, tool.EnableIntrinsicFunctions ); 405 strm << TPair( _EnableIntrinsicFunctions, tool.EnableIntrinsicFunctions );
406 strm << TPair( _ExceptionHandling, tool.ExceptionHandling ); 406 strm << TPair( _ExceptionHandling, tool.ExceptionHandling );
407 strm << TPair( _ExpandAttributedSource, tool.ExpandAttributedSource ); 407 strm << TPair( _ExpandAttributedSource, tool.ExpandAttributedSource );
408 if ( tool.FavorSizeOrSpeed != favorNone ) strm << EPair( _FavorSizeOrSpeed, tool.FavorSizeOrSpeed ); 408 if ( tool.FavorSizeOrSpeed != favorNone ) strm << EPair( _FavorSizeOrSpeed, tool.FavorSizeOrSpeed );
409 strm << TPair( _ForceConformanceInForLoopScope, tool.ForceConformanceInForLoopScope ); 409 strm << TPair( _ForceConformanceInForLoopScope, tool.ForceConformanceInForLoopScope );
410 strm << XPair( _ForcedIncludeFiles, tool.ForcedIncludeFiles ); 410 strm << XPair( _ForcedIncludeFiles, tool.ForcedIncludeFiles );
@@ -433,82 +433,86 @@ QTextStream &operator<<( QTextStream &strm, const VCCLCompilerTool &tool )
433 strm << TPair( _StringPooling, tool.StringPooling ); 433 strm << TPair( _StringPooling, tool.StringPooling );
434 if ( tool.StructMemberAlignment != alignNotSet ) strm << EPair( _StructMemberAlignment, tool.StructMemberAlignment ); 434 if ( tool.StructMemberAlignment != alignNotSet ) strm << EPair( _StructMemberAlignment, tool.StructMemberAlignment );
435 strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner ); 435 strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner );
436 strm << TPair( _TreatWChar_tAsBuiltInType, tool.TreatWChar_tAsBuiltInType ); 436 strm << TPair( _TreatWChar_tAsBuiltInType, tool.TreatWChar_tAsBuiltInType );
437 strm << TPair( _TurnOffAssemblyGeneration, tool.TurnOffAssemblyGeneration ); 437 strm << TPair( _TurnOffAssemblyGeneration, tool.TurnOffAssemblyGeneration );
438 strm << TPair( _UndefineAllPreprocessorDefinitions, tool.UndefineAllPreprocessorDefinitions ); 438 strm << TPair( _UndefineAllPreprocessorDefinitions, tool.UndefineAllPreprocessorDefinitions );
439 strm << XPair( _UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions ); 439 strm << XPair( _UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions );
440 if ( !tool.PrecompiledHeaderFile.isEmpty() || 440 if ( !tool.PrecompiledHeaderFile.isEmpty() ||
441 !tool.PrecompiledHeaderThrough.isEmpty() ) 441 !tool.PrecompiledHeaderThrough.isEmpty() )
442 strm << EPair( _UsePrecompiledHeader, tool.UsePrecompiledHeader ); 442 strm << EPair( _UsePrecompiledHeader, tool.UsePrecompiledHeader );
443 strm << TPair( _WarnAsError, tool.WarnAsError ); 443 strm << TPair( _WarnAsError, tool.WarnAsError );
444 strm << EPair( _WarningLevel, tool.WarningLevel ); 444 strm << EPair( _WarningLevel, tool.WarningLevel );
445 strm << TPair( _WholeProgramOptimization, tool.WholeProgramOptimization ); 445 strm << TPair( _WholeProgramOptimization, tool.WholeProgramOptimization );
446 strm << "/>"; 446 strm << "/>";
447return strm; 447return strm;
448} 448}
449 449
450bool VCCLCompilerTool::parseOption( const char* option ) 450bool VCCLCompilerTool::parseOption( const char* option )
451{ 451{
452 // skip index 0 ('/' or '-') 452 // skip index 0 ('/' or '-')
453 char first = option[1]; 453 char first = option[1];
454 char second = option[2]; 454 char second = option[2];
455 char third = option[3]; 455 char third = option[3];
456 char fourth = option[4]; 456 char fourth = option[4];
457 bool found = TRUE;
457 458
458 switch ( first ) { 459 switch ( first ) {
459 case '?': 460 case '?':
460 case 'h': 461 case 'h':
461 qWarning( "Generator: Option '/?', '/help': MSVC.NET projects do not support outputting help info" ); 462 qWarning( "Generator: Option '/?', '/help': MSVC.NET projects do not support outputting help info" );
462 return FALSE; 463 found = FALSE;
464 break;
463 case '@': 465 case '@':
464 qWarning( "Generator: Option '/@': MSVC.NET projects do not support the use of a response file" ); 466 qWarning( "Generator: Option '/@': MSVC.NET projects do not support the use of a response file" );
465 return FALSE; 467 found = FALSE;
468 break;
466 case 'l': 469 case 'l':
467 qWarning( "Generator: Option '/link': qmake generator does not support passing link options through the compiler tool" ); 470 qWarning( "Generator: Option '/link': qmake generator does not support passing link options through the compiler tool" );
468 return FALSE; 471 found = FALSE;
469 472 break;
470 case 'A': 473 case 'A':
471 if ( second != 'I' ) 474 if ( second != 'I' ) {
472 return FALSE; 475 found = FALSE; break;
476 }
473 AdditionalUsingDirectories += option+2; 477 AdditionalUsingDirectories += option+2;
474 break; 478 break;
475 case 'C': 479 case 'C':
476 KeepComments = _True; 480 KeepComments = _True;
477 break; 481 break;
478 case 'D': 482 case 'D':
479 PreprocessorDefinitions += option+1; 483 PreprocessorDefinitions += option+1;
480 break; 484 break;
481 case 'E': 485 case 'E':
482 if ( second == 'H' ) { 486 if ( second == 'H' ) {
483 if ( third == 'a' || third == 'c' || third == 's' ) { 487 if ( third == 'a' || third == 'c' || third == 's' ) {
484 // ExceptionHandling must be false, or it will override 488 // ExceptionHandling must be false, or it will override
485 // with an /EHsc option 489 // with an /EHsc option
486 ExceptionHandling = _False; 490 ExceptionHandling = _False;
487 AdditionalOptions += option; 491 AdditionalOptions += option;
488 break; 492 break;
489 } 493 }
490 return FALSE; 494 found = FALSE; break;
491 } 495 }
492 GeneratePreprocessedFile = preprocessYes; 496 GeneratePreprocessedFile = preprocessYes;
493 break; 497 break;
494 case 'F': 498 case 'F':
495 if ( second <= '9' && second >= '0' ) { 499 if ( second <= '9' && second >= '0' ) {
496 AdditionalOptions += option; 500 AdditionalOptions += option;
497 break; 501 break;
498 } else { 502 } else {
499 switch ( second ) { 503 switch ( second ) {
500 case 'A': 504 case 'A':
501 if ( third == 'c' ) { 505 if ( third == 'c' ) {
502 AssemblerOutput = asmListingAsmMachine; 506 AssemblerOutput = asmListingAsmMachine;
503 if ( fourth == 's' ) 507 if ( fourth == 's' )
504 AssemblerOutput = asmListingAsmMachineSrc; 508 AssemblerOutput = asmListingAsmMachineSrc;
505 } else if ( third == 's' ) { 509 } else if ( third == 's' ) {
506 AssemblerOutput = asmListingAsmSrc; 510 AssemblerOutput = asmListingAsmSrc;
507 } else { 511 } else {
508 AssemblerOutput = asmListingAssemblyOnly; 512 AssemblerOutput = asmListingAssemblyOnly;
509 } 513 }
510 break; 514 break;
511 case 'a': 515 case 'a':
512 AssemblerListingLocation = option+3; 516 AssemblerListingLocation = option+3;
513 break; 517 break;
514 case 'I': 518 case 'I':
@@ -523,58 +527,58 @@ bool VCCLCompilerTool::parseOption( const char* option )
523 BrowseInformationFile = option+3; 527 BrowseInformationFile = option+3;
524 break; 528 break;
525 case 'U': 529 case 'U':
526 ForcedUsingFiles += option+3; 530 ForcedUsingFiles += option+3;
527 break; 531 break;
528 case 'd': 532 case 'd':
529 ProgramDataBaseFileName = option+3; 533 ProgramDataBaseFileName = option+3;
530 break; 534 break;
531 case 'e': 535 case 'e':
532 OutputFile = option+3; 536 OutputFile = option+3;
533 break; 537 break;
534 case 'm': 538 case 'm':
535 AdditionalOptions += option; 539 AdditionalOptions += option;
536 break; 540 break;
537 case 'o': 541 case 'o':
538 ObjectFile = option+3; 542 ObjectFile = option+3;
539 break; 543 break;
540 case 'p': 544 case 'p':
541 PrecompiledHeaderFile = option+3; 545 PrecompiledHeaderFile = option+3;
542 break; 546 break;
543 case 'x': 547 case 'x':
544 ExpandAttributedSource = _True; 548 ExpandAttributedSource = _True;
545 break; 549 break;
546 default: 550 default:
547 return FALSE; 551 found = FALSE; break;
548 } 552 }
549 } 553 }
550 break; 554 break;
551 case 'G': 555 case 'G':
552 switch ( second ) { 556 switch ( second ) {
553 case '3': 557 case '3':
554 case '4': 558 case '4':
555 qWarning( "Option '/G3' and '/G4' were phased out in Visual C++ 5.0" ); 559 qWarning( "Option '/G3' and '/G4' were phased out in Visual C++ 5.0" );
556 return FALSE; 560 found = FALSE; break;
557 case '5': 561 case '5':
558 OptimizeForProcessor = procOptimizePentium; 562 OptimizeForProcessor = procOptimizePentium;
559 break; 563 break;
560 case '6': 564 case '6':
561 case 'B': 565 case 'B':
562 OptimizeForProcessor = procOptimizePentiumProAndAbove; 566 OptimizeForProcessor = procOptimizePentiumProAndAbove;
563 break; 567 break;
564 case 'A': 568 case 'A':
565 OptimizeForWindowsApplication = _True; 569 OptimizeForWindowsApplication = _True;
566 break; 570 break;
567 case 'F': 571 case 'F':
568 StringPooling = _True; 572 StringPooling = _True;
569 break; 573 break;
570 case 'H': 574 case 'H':
571 AdditionalOptions += option; 575 AdditionalOptions += option;
572 break; 576 break;
573 case 'L': 577 case 'L':
574 WholeProgramOptimization = _True; 578 WholeProgramOptimization = _True;
575 if ( third == '-' ) 579 if ( third == '-' )
576 WholeProgramOptimization = _False; 580 WholeProgramOptimization = _False;
577 break; 581 break;
578 case 'R': 582 case 'R':
579 RuntimeTypeInfo = _True; 583 RuntimeTypeInfo = _True;
580 if ( third == '-' ) 584 if ( third == '-' )
@@ -598,410 +602,413 @@ bool VCCLCompilerTool::parseOption( const char* option )
598 case 'f': 602 case 'f':
599 StringPooling = _True; 603 StringPooling = _True;
600 AdditionalOptions += option; 604 AdditionalOptions += option;
601 break; 605 break;
602 case 'm': 606 case 'm':
603 MinimalRebuild = _True; 607 MinimalRebuild = _True;
604 if ( third == '-' ) 608 if ( third == '-' )
605 MinimalRebuild = _False; 609 MinimalRebuild = _False;
606 break; 610 break;
607 case 'r': 611 case 'r':
608 CallingConvention = callConventionFastCall; 612 CallingConvention = callConventionFastCall;
609 break; 613 break;
610 case 's': 614 case 's':
611 // Warning: following [num] is not used, 615 // Warning: following [num] is not used,
612 // were should we put it? 616 // were should we put it?
613 BufferSecurityCheck = _True; 617 BufferSecurityCheck = _True;
614 break; 618 break;
615 case 'y': 619 case 'y':
616 EnableFunctionLevelLinking = _True; 620 EnableFunctionLevelLinking = _True;
617 break; 621 break;
618 case 'z': 622 case 'z':
619 CallingConvention = callConventionStdCall; 623 CallingConvention = callConventionStdCall;
620 break; 624 break;
621 default: 625 default:
622 return FALSE; 626 found = FALSE; break;
623 } 627 }
624 break; 628 break;
625 case 'H': 629 case 'H':
626 AdditionalOptions += option; 630 AdditionalOptions += option;
627 break; 631 break;
628 case 'I': 632 case 'I':
629 AdditionalIncludeDirectories += option+2; 633 AdditionalIncludeDirectories += option+2;
630 break; 634 break;
631 case 'L': 635 case 'L':
632 if ( second == 'D' ) { 636 if ( second == 'D' ) {
633 AdditionalOptions += option; 637 AdditionalOptions += option;
634 break; 638 break;
635 } 639 }
636 return FALSE; 640 found = FALSE; break;
637 case 'M': 641 case 'M':
638 if ( second == 'D' ) { 642 if ( second == 'D' ) {
639 RuntimeLibrary = rtMultiThreadedDLL; 643 RuntimeLibrary = rtMultiThreadedDLL;
640 if ( third == 'd' ) 644 if ( third == 'd' )
641 RuntimeLibrary = rtMultiThreadedDebugDLL; 645 RuntimeLibrary = rtMultiThreadedDebugDLL;
642 break; 646 break;
643 } else if ( second == 'L' ) { 647 } else if ( second == 'L' ) {
644 RuntimeLibrary = rtSingleThreaded; 648 RuntimeLibrary = rtSingleThreaded;
645 if ( third == 'd' ) 649 if ( third == 'd' )
646 RuntimeLibrary = rtSingleThreadedDebug; 650 RuntimeLibrary = rtSingleThreadedDebug;
647 break; 651 break;
648 } else if ( second == 'T' ) { 652 } else if ( second == 'T' ) {
649 RuntimeLibrary = rtMultiThreaded; 653 RuntimeLibrary = rtMultiThreaded;
650 if ( third == 'd' ) 654 if ( third == 'd' )
651 RuntimeLibrary = rtMultiThreadedDebug; 655 RuntimeLibrary = rtMultiThreadedDebug;
652 break; 656 break;
653 } 657 }
654 return FALSE; 658 found = FALSE; break;
655 case 'O': 659 case 'O':
656 switch ( second ) { 660 switch ( second ) {
657 case '1': 661 case '1':
658 Optimization = optimizeMinSpace; 662 Optimization = optimizeMinSpace;
659 break; 663 break;
660 case '2': 664 case '2':
661 Optimization = optimizeMaxSpeed; 665 Optimization = optimizeMaxSpeed;
662 break; 666 break;
663 case 'a': 667 case 'a':
664 AdditionalOptions += option; 668 AdditionalOptions += option;
665 break; 669 break;
666 case 'b': 670 case 'b':
667 if ( third == '0' ) 671 if ( third == '0' )
668 InlineFunctionExpansion = expandDisable; 672 InlineFunctionExpansion = expandDisable;
669 else if ( third == '1' ) 673 else if ( third == '1' )
670 InlineFunctionExpansion = expandOnlyInline; 674 InlineFunctionExpansion = expandOnlyInline;
671 else if ( third == '2' ) 675 else if ( third == '2' )
672 InlineFunctionExpansion = expandAnySuitable; 676 InlineFunctionExpansion = expandAnySuitable;
673 else 677 else
674 return FALSE; 678 found = FALSE;
675 break; 679 break;
676 case 'd': 680 case 'd':
677 Optimization = optimizeDisabled; 681 Optimization = optimizeDisabled;
678 break; 682 break;
679 case 'g': 683 case 'g':
680 GlobalOptimizations = _True; 684 GlobalOptimizations = _True;
681 break; 685 break;
682 case 'i': 686 case 'i':
683 EnableIntrinsicFunctions = _True; 687 EnableIntrinsicFunctions = _True;
684 break; 688 break;
685 case 'p': 689 case 'p':
686 ImproveFloatingPointConsistency = _True; 690 ImproveFloatingPointConsistency = _True;
687 if ( third == '-' ) 691 if ( third == '-' )
688 ImproveFloatingPointConsistency = _False; 692 ImproveFloatingPointConsistency = _False;
689 break; 693 break;
690 case 's': 694 case 's':
691 FavorSizeOrSpeed = favorSize; 695 FavorSizeOrSpeed = favorSize;
692 break; 696 break;
693 case 't': 697 case 't':
694 FavorSizeOrSpeed = favorSpeed; 698 FavorSizeOrSpeed = favorSpeed;
695 break; 699 break;
696 case 'w': 700 case 'w':
697 AdditionalOptions += option; 701 AdditionalOptions += option;
698 break; 702 break;
699 case 'x': 703 case 'x':
700 Optimization = optimizeFull; 704 Optimization = optimizeFull;
701 break; 705 break;
702 case 'y': 706 case 'y':
703 OmitFramePointers = _True; 707 OmitFramePointers = _True;
704 if ( third == '-' ) 708 if ( third == '-' )
705 OmitFramePointers = _False; 709 OmitFramePointers = _False;
706 break; 710 break;
707 default: 711 default:
708 return FALSE; 712 found = FALSE; break;
709 } 713 }
710 break; 714 break;
711 case 'P': 715 case 'P':
712 GeneratePreprocessedFile = preprocessYes; 716 GeneratePreprocessedFile = preprocessYes;
713 break; 717 break;
714 case 'Q': 718 case 'Q':
715 if ( second == 'I' ) { 719 if ( second == 'I' ) {
716 AdditionalOptions += option; 720 AdditionalOptions += option;
717 break; 721 break;
718 } 722 }
719 return FALSE; 723 found = FALSE; break;
720 case 'R': 724 case 'R':
721 if ( second == 'T' && third == 'C' ) { 725 if ( second == 'T' && third == 'C' ) {
722 if ( fourth == '1' ) 726 if ( fourth == '1' )
723 BasicRuntimeChecks = runtimeBasicCheckAll; 727 BasicRuntimeChecks = runtimeBasicCheckAll;
724 else if ( fourth == 'c' ) 728 else if ( fourth == 'c' )
725 SmallerTypeCheck = _True; 729 SmallerTypeCheck = _True;
726 else if ( fourth == 's' ) 730 else if ( fourth == 's' )
727 BasicRuntimeChecks = runtimeCheckStackFrame; 731 BasicRuntimeChecks = runtimeCheckStackFrame;
728 else if ( fourth == 'u' ) 732 else if ( fourth == 'u' )
729 BasicRuntimeChecks = runtimeCheckUninitVariables; 733 BasicRuntimeChecks = runtimeCheckUninitVariables;
730 else 734 else
731 return FALSE; 735 found = FALSE; break;
732 } 736 }
733 break; 737 break;
734 case 'T': 738 case 'T':
735 if ( second == 'C' ) { 739 if ( second == 'C' ) {
736 CompileAs = compileAsC; 740 CompileAs = compileAsC;
737 } else if ( second == 'P' ) { 741 } else if ( second == 'P' ) {
738 CompileAs = compileAsCPlusPlus; 742 CompileAs = compileAsCPlusPlus;
739 } else { 743 } else {
740 qWarning( "Generator: Options '/Tp<filename>' and '/Tc<filename>' are not supported by qmake" ); 744 qWarning( "Generator: Options '/Tp<filename>' and '/Tc<filename>' are not supported by qmake" );
741 return FALSE; 745 found = FALSE; break;
742 } 746 }
743 break; 747 break;
744 case 'U': 748 case 'U':
745 UndefinePreprocessorDefinitions += option+2; 749 UndefinePreprocessorDefinitions += option+2;
746 break; 750 break;
747 case 'V': 751 case 'V':
748 AdditionalOptions += option; 752 AdditionalOptions += option;
749 break; 753 break;
750 case 'W': 754 case 'W':
751 switch ( second ) { 755 switch ( second ) {
752 case 'a': 756 case 'a':
753 case '4': 757 case '4':
754 WarningLevel = warningLevel_4; 758 WarningLevel = warningLevel_4;
755 break; 759 break;
756 case '3': 760 case '3':
757 WarningLevel = warningLevel_3; 761 WarningLevel = warningLevel_3;
758 break; 762 break;
759 case '2': 763 case '2':
760 WarningLevel = warningLevel_2; 764 WarningLevel = warningLevel_2;
761 break; 765 break;
762 case '1': 766 case '1':
763 WarningLevel = warningLevel_1; 767 WarningLevel = warningLevel_1;
764 break; 768 break;
765 case '0': 769 case '0':
766 WarningLevel = warningLevel_0; 770 WarningLevel = warningLevel_0;
767 break; 771 break;
768 case 'L': 772 case 'L':
769 AdditionalOptions += option; 773 AdditionalOptions += option;
770 break; 774 break;
771 case 'X': 775 case 'X':
772 WarnAsError = _True; 776 WarnAsError = _True;
773 break; 777 break;
774 case 'p': 778 case 'p':
775 if ( third == '6' && fourth == '4' ) { 779 if ( third == '6' && fourth == '4' ) {
776 Detect64BitPortabilityProblems = _True; 780 Detect64BitPortabilityProblems = _True;
777 break; 781 break;
778 } 782 }
779 // Fallthrough 783 // Fallthrough
780 default: 784 default:
781 return FALSE; 785 found = FALSE; break;
782 } 786 }
783 break; 787 break;
784 case 'X': 788 case 'X':
785 IgnoreStandardIncludePath = _True; 789 IgnoreStandardIncludePath = _True;
786 break; 790 break;
787 case 'Y': 791 case 'Y':
788 switch ( second ) { 792 switch ( second ) {
789 case '\0': 793 case '\0':
790 case '-': 794 case '-':
791 AdditionalOptions += option; 795 AdditionalOptions += option;
792 break; 796 break;
793 case 'X': 797 case 'X':
794 UsePrecompiledHeader = pchGenerateAuto; 798 UsePrecompiledHeader = pchGenerateAuto;
795 PrecompiledHeaderFile = option+3; 799 PrecompiledHeaderFile = option+3;
796 break; 800 break;
797 case 'c': 801 case 'c':
798 UsePrecompiledHeader = pchCreateUsingSpecific; 802 UsePrecompiledHeader = pchCreateUsingSpecific;
799 PrecompiledHeaderFile = option+3; 803 PrecompiledHeaderFile = option+3;
800 break; 804 break;
801 case 'd': 805 case 'd':
802 case 'l': 806 case 'l':
803 AdditionalOptions =+ option; 807 AdditionalOptions =+ option;
804 break; 808 break;
805 case 'u': 809 case 'u':
806 UsePrecompiledHeader = pchUseUsingSpecific; 810 UsePrecompiledHeader = pchUseUsingSpecific;
807 PrecompiledHeaderFile = option+3; 811 PrecompiledHeaderFile = option+3;
808 break; 812 break;
809 default: 813 default:
810 return FALSE; 814 found = FALSE; break;
811 } 815 }
812 break; 816 break;
813 case 'Z': 817 case 'Z':
814 switch ( second ) { 818 switch ( second ) {
815 case '7': 819 case '7':
816 DebugInformationFormat = debugOldStyleInfo; 820 DebugInformationFormat = debugOldStyleInfo;
817 break; 821 break;
818 case 'I': 822 case 'I':
819 DebugInformationFormat = debugEditAndContinue; 823 DebugInformationFormat = debugEditAndContinue;
820 break; 824 break;
821 case 'd': 825 case 'd':
822 DebugInformationFormat = debugLineInfoOnly; 826 DebugInformationFormat = debugLineInfoOnly;
823 break; 827 break;
824 case 'i': 828 case 'i':
825 DebugInformationFormat = debugEnabled; 829 DebugInformationFormat = debugEnabled;
826 break; 830 break;
827 case 'l': 831 case 'l':
828 DebugInformationFormat = debugEditAndContinue; 832 DebugInformationFormat = debugEditAndContinue;
829 break; 833 break;
830 case 'a': 834 case 'a':
831 DisableLanguageExtensions = _True; 835 DisableLanguageExtensions = _True;
832 break; 836 break;
833 case 'e': 837 case 'e':
834 DisableLanguageExtensions = _False; 838 DisableLanguageExtensions = _False;
835 break; 839 break;
836 case 'c': 840 case 'c':
837 if ( third == ':' ) { 841 if ( third == ':' ) {
838 if ( fourth == 'f' ) 842 if ( fourth == 'f' )
839 ForceConformanceInForLoopScope = _True; 843 ForceConformanceInForLoopScope = _True;
840 else if ( fourth == 'w' ) 844 else if ( fourth == 'w' )
841 TreatWChar_tAsBuiltInType = _True; 845 TreatWChar_tAsBuiltInType = _True;
842 else 846 else
843 return FALSE; 847 found = FALSE;
844 } else { 848 } else {
845 return FALSE; 849 found = FALSE; break;
846 } 850 }
847 break; 851 break;
848 case 'g': 852 case 'g':
849 case 'm': 853 case 'm':
850 case 's': 854 case 's':
851 AdditionalOptions += option; 855 AdditionalOptions += option;
852 break; 856 break;
853 case 'p': 857 case 'p':
854 switch ( third ) 858 switch ( third )
855 { 859 {
856 case '\0': 860 case '\0':
857 case '1': 861 case '1':
858 StructMemberAlignment = alignSingleByte; 862 StructMemberAlignment = alignSingleByte;
859 if ( fourth == '6' ) 863 if ( fourth == '6' )
860 StructMemberAlignment = alignSixteenBytes; 864 StructMemberAlignment = alignSixteenBytes;
861 break; 865 break;
862 case '2': 866 case '2':
863 StructMemberAlignment = alignTwoBytes; 867 StructMemberAlignment = alignTwoBytes;
864 break; 868 break;
865 case '4': 869 case '4':
866 StructMemberAlignment = alignFourBytes; 870 StructMemberAlignment = alignFourBytes;
867 break; 871 break;
868 case '8': 872 case '8':
869 StructMemberAlignment = alignEightBytes; 873 StructMemberAlignment = alignEightBytes;
870 break; 874 break;
871 default: 875 default:
872 return FALSE; 876 found = FALSE; break;
873 } 877 }
874 break; 878 break;
875 default: 879 default:
876 return FALSE; 880 found = FALSE; break;
877 } 881 }
878 break; 882 break;
879 case 'c': 883 case 'c':
880 if ( second == '\0' ) { 884 if ( second == '\0' ) {
881 CompileOnly = _True; 885 CompileOnly = _True;
882 } else if ( second == 'l' ) { 886 } else if ( second == 'l' ) {
883 if ( *(option+5) == 'n' ) { 887 if ( *(option+5) == 'n' ) {
884 CompileAsManaged = managedAssembly; 888 CompileAsManaged = managedAssembly;
885 TurnOffAssemblyGeneration = _True; 889 TurnOffAssemblyGeneration = _True;
886 } else { 890 } else {
887 CompileAsManaged = managedAssembly; 891 CompileAsManaged = managedAssembly;
888 } 892 }
889 } else { 893 } else {
890 return FALSE; 894 found = FALSE; break;
891 } 895 }
892 break; 896 break;
893 case 'd': 897 case 'd':
894 if ( second != 'r' ) 898 if ( second != 'r' ) {
895 return FALSE; 899 found = FALSE; break;
900 }
896 CompileAsManaged = managedAssembly; 901 CompileAsManaged = managedAssembly;
897 break; 902 break;
898 case 'n': 903 case 'n':
899 if ( second == 'o' && third == 'B' && fourth == 'o' ) { 904 if ( second == 'o' && third == 'B' && fourth == 'o' ) {
900 AdditionalOptions += "/noBool"; 905 AdditionalOptions += "/noBool";
901 break; 906 break;
902 } 907 }
903 if ( second == 'o' && third == 'l' && fourth == 'o' ) { 908 if ( second == 'o' && third == 'l' && fourth == 'o' ) {
904 SuppressStartupBanner = _True; 909 SuppressStartupBanner = _True;
905 break; 910 break;
906 } 911 }
907 return FALSE; 912 found = FALSE; break;
908 case 's': 913 case 's':
909 if ( second == 'h' && third == 'o' && fourth == 'w' ) { 914 if ( second == 'h' && third == 'o' && fourth == 'w' ) {
910 ShowIncludes = _True; 915 ShowIncludes = _True;
911 break; 916 break;
912 } 917 }
913 return FALSE; 918 found = FALSE; break;
914 case 'u': 919 case 'u':
915 UndefineAllPreprocessorDefinitions = _True; 920 UndefineAllPreprocessorDefinitions = _True;
916 break; 921 break;
917 case 'v': 922 case 'v':
918 if ( second == 'd' || second == 'm' ) { 923 if ( second == 'd' || second == 'm' ) {
919 AdditionalOptions += option; 924 AdditionalOptions += option;
920 break; 925 break;
921 } 926 }
922 return FALSE; 927 found = FALSE; break;
923 case 'w': 928 case 'w':
924 switch ( second ) { 929 switch ( second ) {
925 case '\0': 930 case '\0':
926 WarningLevel = warningLevel_0; 931 WarningLevel = warningLevel_0;
927 break; 932 break;
928 case 'd': 933 case 'd':
929 DisableSpecificWarnings += option+3; 934 DisableSpecificWarnings += option+3;
930 break; 935 break;
931 default: 936 default:
932 AdditionalOptions += option; 937 AdditionalOptions += option;
933 } 938 }
934 break; 939 break;
935 default: 940 default:
936 return FALSE; 941 found = FALSE; break;
937 } 942 }
943 if( !found )
944 warn_msg( WarnLogic, "Could not parse Compiler option: %s", option );
938 return TRUE; 945 return TRUE;
939} 946}
940 947
941// VCLinkerTool ----------------------------------------------------- 948// VCLinkerTool -----------------------------------------------------
942VCLinkerTool::VCLinkerTool() 949VCLinkerTool::VCLinkerTool()
943 :EnableCOMDATFolding( optFoldingDefault ), 950 :EnableCOMDATFolding( optFoldingDefault ),
944 GenerateDebugInformation( unset ), 951 GenerateDebugInformation( unset ),
945 GenerateMapFile( unset ), 952 GenerateMapFile( unset ),
946 HeapCommitSize( -1 ), 953 HeapCommitSize( -1 ),
947 HeapReserveSize( -1 ), 954 HeapReserveSize( -1 ),
948 IgnoreAllDefaultLibraries( unset ), 955 IgnoreAllDefaultLibraries( unset ),
949 IgnoreEmbeddedIDL( unset ), 956 IgnoreEmbeddedIDL( unset ),
950 IgnoreImportLibrary( unset ), 957 IgnoreImportLibrary( unset ),
951 LargeAddressAware( addrAwareDefault ), 958 LargeAddressAware( addrAwareDefault ),
952 LinkDLL( unset ), 959 LinkDLL( unset ),
953 LinkIncremental( linkIncrementalYes ), 960 LinkIncremental( linkIncrementalYes ),
954 LinkTimeCodeGeneration( unset ), 961 LinkTimeCodeGeneration( unset ),
955 MapExports( unset ), 962 MapExports( unset ),
956 MapLines( unset ), 963 MapLines( unset ),
957 OptimizeForWindows98( optWin98Default ), 964 OptimizeForWindows98( optWin98Default ),
958 OptimizeReferences( optReferencesDefault ), 965 OptimizeReferences( optReferencesDefault ),
959 RegisterOutput( unset ), 966 RegisterOutput( unset ),
960 ResourceOnlyDLL( unset ), 967 ResourceOnlyDLL( unset ),
961 SetChecksum( unset ), 968 SetChecksum( unset ),
962 ShowProgress( linkProgressNotSet ), 969 ShowProgress( linkProgressNotSet ),
963 StackCommitSize( -1 ), 970 StackCommitSize( -1 ),
964 StackReserveSize( -1 ), 971 StackReserveSize( -1 ),
965 SubSystem( subSystemNotSet ), 972 SubSystem( subSystemNotSet ),
966 SupportUnloadOfDelayLoadedDLL( unset ), 973 SupportUnloadOfDelayLoadedDLL( unset ),
967 SuppressStartupBanner( unset ), 974 SuppressStartupBanner( unset ),
968 SwapRunFromCD( unset ), 975 SwapRunFromCD( unset ),
969 SwapRunFromNet( unset ), 976 SwapRunFromNet( unset ),
970 TargetMachine( machineNotSet ), 977 TargetMachine( machineNotSet ),
971 TerminalServerAware( termSvrAwareDefault ), 978 TerminalServerAware( termSvrAwareDefault ),
972 TurnOffAssemblyGeneration( unset ), 979 TurnOffAssemblyGeneration( unset ),
973 TypeLibraryResourceID( 0 ) 980 TypeLibraryResourceID( 0 )
974{ 981{
975} 982}
976 983
977QTextStream &operator<<( QTextStream &strm, const VCLinkerTool &tool ) 984QTextStream &operator<<( QTextStream &strm, const VCLinkerTool &tool )
978{ 985{
979 strm << _begTool3; 986 strm << _begTool3;
980 strm << _VCLinkerToolName; 987 strm << _VCLinkerToolName;
981 strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies, " " ); 988 strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies, " " );
982 strm << XPair( _AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories ); 989 strm << XPair( _AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories );
983 strm << XPair( _AdditionalOptions, tool.AdditionalOptions ); 990 strm << XPair( _AdditionalOptions, tool.AdditionalOptions, " " );
984 strm << XPair( _AddModuleNamesToAssembly, tool.AddModuleNamesToAssembly ); 991 strm << XPair( _AddModuleNamesToAssembly, tool.AddModuleNamesToAssembly );
985 strm << SPair( _BaseAddress, tool.BaseAddress ); 992 strm << SPair( _BaseAddress, tool.BaseAddress );
986 strm << XPair( _DelayLoadDLLs, tool.DelayLoadDLLs ); 993 strm << XPair( _DelayLoadDLLs, tool.DelayLoadDLLs );
987 if ( tool.EnableCOMDATFolding != optFoldingDefault ) strm << EPair( _EnableCOMDATFolding, tool.EnableCOMDATFolding ); 994 if ( tool.EnableCOMDATFolding != optFoldingDefault ) strm << EPair( _EnableCOMDATFolding, tool.EnableCOMDATFolding );
988 strm << SPair( _EntryPointSymbol, tool.EntryPointSymbol ); 995 strm << SPair( _EntryPointSymbol, tool.EntryPointSymbol );
989 strm << XPair( _ForceSymbolReferences, tool.ForceSymbolReferences ); 996 strm << XPair( _ForceSymbolReferences, tool.ForceSymbolReferences );
990 strm << SPair( _FunctionOrder, tool.FunctionOrder ); 997 strm << SPair( _FunctionOrder, tool.FunctionOrder );
991 strm << TPair( _GenerateDebugInformation, tool.GenerateDebugInformation ); 998 strm << TPair( _GenerateDebugInformation, tool.GenerateDebugInformation );
992 strm << TPair( _GenerateMapFile, tool.GenerateMapFile ); 999 strm << TPair( _GenerateMapFile, tool.GenerateMapFile );
993 if ( tool.HeapCommitSize != -1 ) strm << LPair( _HeapCommitSize, tool.HeapCommitSize ); 1000 if ( tool.HeapCommitSize != -1 ) strm << LPair( _HeapCommitSize, tool.HeapCommitSize );
994 if ( tool.HeapReserveSize != -1 ) strm << LPair( _HeapReserveSize, tool.HeapReserveSize ); 1001 if ( tool.HeapReserveSize != -1 ) strm << LPair( _HeapReserveSize, tool.HeapReserveSize );
995 strm << TPair( _IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries ); 1002 strm << TPair( _IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries );
996 strm << XPair( _IgnoreDefaultLibraryNames, tool.IgnoreDefaultLibraryNames ); 1003 strm << XPair( _IgnoreDefaultLibraryNames, tool.IgnoreDefaultLibraryNames );
997 strm << TPair( _IgnoreEmbeddedIDL, tool.IgnoreEmbeddedIDL ); 1004 strm << TPair( _IgnoreEmbeddedIDL, tool.IgnoreEmbeddedIDL );
998 strm << TPair( _IgnoreImportLibrary, tool.IgnoreImportLibrary ); 1005 strm << TPair( _IgnoreImportLibrary, tool.IgnoreImportLibrary );
999 strm << SPair( _ImportLibrary, tool.ImportLibrary ); 1006 strm << SPair( _ImportLibrary, tool.ImportLibrary );
1000 if ( tool.LargeAddressAware != addrAwareDefault ) strm << EPair( _LargeAddressAware, tool.LargeAddressAware ); 1007 if ( tool.LargeAddressAware != addrAwareDefault ) strm << EPair( _LargeAddressAware, tool.LargeAddressAware );
1001 strm << TPair( _LinkDLL, tool.LinkDLL ); 1008 strm << TPair( _LinkDLL, tool.LinkDLL );
1002 if ( tool.LinkIncremental != linkIncrementalDefault ) strm << EPair( _LinkIncremental, tool.LinkIncremental ); 1009 if ( tool.LinkIncremental != linkIncrementalDefault ) strm << EPair( _LinkIncremental, tool.LinkIncremental );
1003 strm << TPair( _LinkTimeCodeGeneration, tool.LinkTimeCodeGeneration ); 1010 strm << TPair( _LinkTimeCodeGeneration, tool.LinkTimeCodeGeneration );
1004 strm << SPair( _LinkToManagedResourceFile, tool.LinkToManagedResourceFile ); 1011 strm << SPair( _LinkToManagedResourceFile, tool.LinkToManagedResourceFile );
1005 strm << TPair( _MapExports, tool.MapExports ); 1012 strm << TPair( _MapExports, tool.MapExports );
1006 strm << SPair( _MapFileName, tool.MapFileName ); 1013 strm << SPair( _MapFileName, tool.MapFileName );
1007 strm << TPair( _MapLines, tool.MapLines ); 1014 strm << TPair( _MapLines, tool.MapLines );
@@ -1039,87 +1046,91 @@ QTextStream &operator<<( QTextStream &strm, const VCLinkerTool &tool )
1039// Slightly rewritten to stop on ':' ',' and '\0' 1046// Slightly rewritten to stop on ':' ',' and '\0'
1040// Original routine in qtranslator.cpp ---------- 1047// Original routine in qtranslator.cpp ----------
1041static uint elfHash( const char* name ) 1048static uint elfHash( const char* name )
1042{ 1049{
1043 const uchar *k; 1050 const uchar *k;
1044 uint h = 0; 1051 uint h = 0;
1045 uint g; 1052 uint g;
1046 1053
1047 if ( name ) { 1054 if ( name ) {
1048 k = (const uchar *) name; 1055 k = (const uchar *) name;
1049 while ( (*k) && 1056 while ( (*k) &&
1050 (*k)!= ':' && 1057 (*k)!= ':' &&
1051 (*k)!=',' && 1058 (*k)!=',' &&
1052 (*k)!=' ' ) { 1059 (*k)!=' ' ) {
1053 h = ( h << 4 ) + *k++; 1060 h = ( h << 4 ) + *k++;
1054 if ( (g = (h & 0xf0000000)) != 0 ) 1061 if ( (g = (h & 0xf0000000)) != 0 )
1055 h ^= g >> 24; 1062 h ^= g >> 24;
1056 h &= ~g; 1063 h &= ~g;
1057 } 1064 }
1058 } 1065 }
1059 if ( !h ) 1066 if ( !h )
1060 h = 1; 1067 h = 1;
1061 return h; 1068 return h;
1062} 1069}
1070
1071//#define USE_DISPLAY_HASH
1072#ifdef USE_DISPLAY_HASH
1063static void displayHash( const char* str ) 1073static void displayHash( const char* str )
1064{ 1074{
1065 printf( "case 0x%07x: // %s\n break;\n", elfHash(str), str ); 1075 printf( "case 0x%07x: // %s\n break;\n", elfHash(str), str );
1066} 1076}
1077#endif
1067 1078
1068bool VCLinkerTool::parseOption( const char* option ) 1079bool VCLinkerTool::parseOption( const char* option )
1069{ 1080{
1070#if 0 1081#ifdef USE_DISPLAY_HASH
1071 // Main options 1082 // Main options
1072 displayHash( "/ALIGN" ); displayHash( "/ALLOWBIND" ); displayHash( "/ASSEMBLYMODULE" ); 1083 displayHash( "/ALIGN" ); displayHash( "/ALLOWBIND" ); displayHash( "/ASSEMBLYMODULE" );
1073 displayHash( "/ASSEMBLYRESOURCE" ); displayHash( "/BASE" ); displayHash( "/DEBUG" ); 1084 displayHash( "/ASSEMBLYRESOURCE" ); displayHash( "/BASE" ); displayHash( "/DEBUG" );
1074 displayHash( "/DEF" ); displayHash( "/DEFAULTLIB" ); displayHash( "/DELAY" ); 1085 displayHash( "/DEF" ); displayHash( "/DEFAULTLIB" ); displayHash( "/DELAY" );
1075 displayHash( "/DELAYLOAD" ); displayHash( "/DLL" ); displayHash( "/DRIVER" ); 1086 displayHash( "/DELAYLOAD" ); displayHash( "/DLL" ); displayHash( "/DRIVER" );
1076 displayHash( "/ENTRY" ); displayHash( "/EXETYPE" ); displayHash( "/EXPORT" ); 1087 displayHash( "/ENTRY" ); displayHash( "/EXETYPE" ); displayHash( "/EXPORT" );
1077 displayHash( "/FIXED" ); displayHash( "/FORCE" ); displayHash( "/HEAP" ); 1088 displayHash( "/FIXED" ); displayHash( "/FORCE" ); displayHash( "/HEAP" );
1078 displayHash( "/IDLOUT" ); displayHash( "/IGNOREIDL" ); displayHash( "/IMPLIB" ); 1089 displayHash( "/IDLOUT" ); displayHash( "/IGNOREIDL" ); displayHash( "/IMPLIB" );
1079 displayHash( "/INCLUDE" ); displayHash( "/INCREMENTAL" ); displayHash( "/LARGEADDRESSAWARE" ); 1090 displayHash( "/INCLUDE" ); displayHash( "/INCREMENTAL" ); displayHash( "/LARGEADDRESSAWARE" );
1080 displayHash( "/LIBPATH" ); displayHash( "/LTCG" ); displayHash( "/MACHINE" ); 1091 displayHash( "/LIBPATH" ); displayHash( "/LTCG" ); displayHash( "/MACHINE" );
1081 displayHash( "/MAP" ); displayHash( "/MAPINFO" ); displayHash( "/MERGE" ); 1092 displayHash( "/MAP" ); displayHash( "/MAPINFO" ); displayHash( "/MERGE" );
1082 displayHash( "/MIDL" ); displayHash( "/NOASSEMBLY" ); displayHash( "/NODEFAULTLIB" ); 1093 displayHash( "/MIDL" ); displayHash( "/NOASSEMBLY" ); displayHash( "/NODEFAULTLIB" );
1083 displayHash( "/NOENTRY" ); displayHash( "/NOLOGO" ); displayHash( "/OPT" ); 1094 displayHash( "/NOENTRY" ); displayHash( "/NOLOGO" ); displayHash( "/OPT" );
1084 displayHash( "/ORDER" ); displayHash( "/OUT" ); displayHash( "/PDB" ); 1095 displayHash( "/ORDER" ); displayHash( "/OUT" ); displayHash( "/PDB" );
1085 displayHash( "/PDBSTRIPPED" ); displayHash( "/RELEASE" ); displayHash( "/SECTION" ); 1096 displayHash( "/PDBSTRIPPED" ); displayHash( "/RELEASE" ); displayHash( "/SECTION" );
1086 displayHash( "/STACK" ); displayHash( "/STUB" ); displayHash( "/SUBSYSTEM" ); 1097 displayHash( "/STACK" ); displayHash( "/STUB" ); displayHash( "/SUBSYSTEM" );
1087 displayHash( "/SWAPRUN" ); displayHash( "/TLBID" ); displayHash( "/TLBOUT" ); 1098 displayHash( "/SWAPRUN" ); displayHash( "/TLBID" ); displayHash( "/TLBOUT" );
1088 displayHash( "/TSAWARE" ); displayHash( "/VERBOSE" ); displayHash( "/VERSION" ); 1099 displayHash( "/TSAWARE" ); displayHash( "/VERBOSE" ); displayHash( "/VERSION" );
1089 displayHash( "/VXD" ); displayHash( "/WS " ); 1100 displayHash( "/VXD" ); displayHash( "/WS " );
1090#endif 1101#endif
1091#if 0 1102#ifdef USE_DISPLAY_HASH
1092 // Sub options 1103 // Sub options
1093 displayHash( "UNLOAD" ); displayHash( "NOBIND" ); displayHash( "no" ); displayHash( "NOSTATUS" ); displayHash( "STATUS" ); 1104 displayHash( "UNLOAD" ); displayHash( "NOBIND" ); displayHash( "no" ); displayHash( "NOSTATUS" ); displayHash( "STATUS" );
1094 displayHash( "AM33" ); displayHash( "ARM" ); displayHash( "CEE" ); displayHash( "IA64" ); displayHash( "X86" ); displayHash( "M32R" ); 1105 displayHash( "AM33" ); displayHash( "ARM" ); displayHash( "CEE" ); displayHash( "IA64" ); displayHash( "X86" ); displayHash( "M32R" );
1095 displayHash( "MIPS" ); displayHash( "MIPS16" ); displayHash( "MIPSFPU" ); displayHash( "MIPSFPU16" ); displayHash( "MIPSR41XX" ); displayHash( "PPC" ); 1106 displayHash( "MIPS" ); displayHash( "MIPS16" ); displayHash( "MIPSFPU" ); displayHash( "MIPSFPU16" ); displayHash( "MIPSR41XX" ); displayHash( "PPC" );
1096 displayHash( "SH3" ); displayHash( "SH4" ); displayHash( "SH5" ); displayHash( "THUMB" ); displayHash( "TRICORE" ); displayHash( "EXPORTS" ); 1107 displayHash( "SH3" ); displayHash( "SH4" ); displayHash( "SH5" ); displayHash( "THUMB" ); displayHash( "TRICORE" ); displayHash( "EXPORTS" );
1097 displayHash( "LINES" ); displayHash( "REF" ); displayHash( "NOREF" ); displayHash( "ICF" ); displayHash( "WIN98" ); displayHash( "NOWIN98" ); 1108 displayHash( "LINES" ); displayHash( "REF" ); displayHash( "NOREF" ); displayHash( "ICF" ); displayHash( "WIN98" ); displayHash( "NOWIN98" );
1098 displayHash( "CONSOLE" ); displayHash( "EFI_APPLICATION" ); displayHash( "EFI_BOOT_SERVICE_DRIVER" ); displayHash( "EFI_ROM" ); displayHash( "EFI_RUNTIME_DRIVER" ); displayHash( "NATIVE" ); 1109 displayHash( "CONSOLE" ); displayHash( "EFI_APPLICATION" ); displayHash( "EFI_BOOT_SERVICE_DRIVER" ); displayHash( "EFI_ROM" ); displayHash( "EFI_RUNTIME_DRIVER" ); displayHash( "NATIVE" );
1099 displayHash( "POSIX" ); displayHash( "WINDOWS" ); displayHash( "WINDOWSCE" ); displayHash( "NET" ); displayHash( "CD" ); displayHash( "NO" ); 1110 displayHash( "POSIX" ); displayHash( "WINDOWS" ); displayHash( "WINDOWSCE" ); displayHash( "NET" ); displayHash( "CD" ); displayHash( "NO" );
1100#endif 1111#endif
1101 1112 bool found = TRUE;
1102 switch ( elfHash(option) ) { 1113 switch ( elfHash(option) ) {
1103 case 0x3360dbe: // /ALIGN[:number] 1114 case 0x3360dbe: // /ALIGN[:number]
1104 case 0x1485c34: // /ALLOWBIND[:NO] 1115 case 0x1485c34: // /ALLOWBIND[:NO]
1105 case 0x6b21972: // /DEFAULTLIB:library 1116 case 0x6b21972: // /DEFAULTLIB:library
1106 case 0x396ea92: // /DRIVER[:UPONLY | :WDM] 1117 case 0x396ea92: // /DRIVER[:UPONLY | :WDM]
1107 case 0xaca9d75: // /EXETYPE[:DYNAMIC | :DEV386] 1118 case 0xaca9d75: // /EXETYPE[:DYNAMIC | :DEV386]
1108 case 0x3ad5444: // /EXPORT:entryname[,@ordinal[,NONAME]][,DATA] 1119 case 0x3ad5444: // /EXPORT:entryname[,@ordinal[,NONAME]][,DATA]
1109 case 0x33aec94: // /FIXED[:NO] 1120 case 0x33aec94: // /FIXED[:NO]
1110 case 0x33b4675: // /FORCE:[MULTIPLE|UNRESOLVED] 1121 case 0x33b4675: // /FORCE:[MULTIPLE|UNRESOLVED]
1111 case 0x7988f7e: // /SECTION:name,[E][R][W][S][D][K][L][P][X][,ALIGN=#] 1122 case 0x7988f7e: // /SECTION:name,[E][R][W][S][D][K][L][P][X][,ALIGN=#]
1112 case 0x0348992: // /STUB:filename 1123 case 0x0348992: // /STUB:filename
1113 case 0x0034bc4: // /VXD 1124 case 0x0034bc4: // /VXD
1114 case 0x0034c50: // /WS 1125 case 0x0034c50: // /WS
1115 AdditionalOptions += option; 1126 AdditionalOptions += option;
1116 break; 1127 break;
1117 case 0x679c075: // /ASSEMBLYMODULE:filename 1128 case 0x679c075: // /ASSEMBLYMODULE:filename
1118 AddModuleNamesToAssembly += option+15; 1129 AddModuleNamesToAssembly += option+15;
1119 break; 1130 break;
1120 case 0x062d065: // /ASSEMBLYRESOURCE:filename 1131 case 0x062d065: // /ASSEMBLYRESOURCE:filename
1121 LinkToManagedResourceFile = option+18; 1132 LinkToManagedResourceFile = option+18;
1122 break; 1133 break;
1123 case 0x0336675: // /BASE:{address | @filename,key} 1134 case 0x0336675: // /BASE:{address | @filename,key}
1124 // Do we need to do a manual lookup when '@filename,key'? 1135 // Do we need to do a manual lookup when '@filename,key'?
1125 // Seems BaseAddress only can contain the location... 1136 // Seems BaseAddress only can contain the location...
@@ -1195,49 +1206,49 @@ bool VCLinkerTool::parseOption( const char* option )
1195 // Very limited documentation on all options but X86, 1206 // Very limited documentation on all options but X86,
1196 // so we put the others in AdditionalOptions... 1207 // so we put the others in AdditionalOptions...
1197 case 0x0046063: // AM33 1208 case 0x0046063: // AM33
1198 case 0x000466d: // ARM 1209 case 0x000466d: // ARM
1199 case 0x0004795: // CEE 1210 case 0x0004795: // CEE
1200 case 0x004d494: // IA64 1211 case 0x004d494: // IA64
1201 case 0x0050672: // M32R 1212 case 0x0050672: // M32R
1202 case 0x0051e53: // MIPS 1213 case 0x0051e53: // MIPS
1203 case 0x51e5646: // MIPS16 1214 case 0x51e5646: // MIPS16
1204 case 0x1e57b05: // MIPSFPU 1215 case 0x1e57b05: // MIPSFPU
1205 case 0x57b09a6: // MIPSFPU16 1216 case 0x57b09a6: // MIPSFPU16
1206 case 0x5852738: // MIPSR41XX 1217 case 0x5852738: // MIPSR41XX
1207 case 0x0005543: // PPC 1218 case 0x0005543: // PPC
1208 case 0x00057b3: // SH3 1219 case 0x00057b3: // SH3
1209 case 0x00057b4: // SH4 1220 case 0x00057b4: // SH4
1210 case 0x00057b5: // SH5 1221 case 0x00057b5: // SH5
1211 case 0x058da12: // THUMB 1222 case 0x058da12: // THUMB
1212 case 0x96d8435: // TRICORE 1223 case 0x96d8435: // TRICORE
1213 AdditionalOptions += option; 1224 AdditionalOptions += option;
1214 break; 1225 break;
1215 case 0x0005bb6: // X86 1226 case 0x0005bb6: // X86
1216 TargetMachine = machineX86; 1227 TargetMachine = machineX86;
1217 break; 1228 break;
1218 default: 1229 default:
1219 return FALSE; 1230 found = FALSE;
1220 } 1231 }
1221 break; 1232 break;
1222 case 0x0034160: // /MAP[:filename] 1233 case 0x0034160: // /MAP[:filename]
1223 GenerateMapFile = _True; 1234 GenerateMapFile = _True;
1224 MapFileName = option+5; 1235 MapFileName = option+5;
1225 break; 1236 break;
1226 case 0x164e1ef: // /MAPINFO:{EXPORTS|LINES} 1237 case 0x164e1ef: // /MAPINFO:{EXPORTS|LINES}
1227 if ( *(option+9) == 'E' ) 1238 if ( *(option+9) == 'E' )
1228 MapExports = _True; 1239 MapExports = _True;
1229 else if ( *(option+9) == 'L' ) 1240 else if ( *(option+9) == 'L' )
1230 MapLines = _True; 1241 MapLines = _True;
1231 break; 1242 break;
1232 case 0x341a6b5: // /MERGE:from=to 1243 case 0x341a6b5: // /MERGE:from=to
1233 MergeSections = option+7; 1244 MergeSections = option+7;
1234 break; 1245 break;
1235 case 0x0341d8c: // /MIDL:@file 1246 case 0x0341d8c: // /MIDL:@file
1236 MidlCommandFile = option+7; 1247 MidlCommandFile = option+7;
1237 break; 1248 break;
1238 case 0x84e2679: // /NOASSEMBLY 1249 case 0x84e2679: // /NOASSEMBLY
1239 TurnOffAssemblyGeneration = _True; 1250 TurnOffAssemblyGeneration = _True;
1240 break; 1251 break;
1241 case 0x2b21942: // /NODEFAULTLIB[:library] 1252 case 0x2b21942: // /NODEFAULTLIB[:library]
1242 if ( *(option+13) == '\0' ) 1253 if ( *(option+13) == '\0' )
1243 IgnoreAllDefaultLibraries = _True; 1254 IgnoreAllDefaultLibraries = _True;
@@ -1254,316 +1265,319 @@ bool VCLinkerTool::parseOption( const char* option )
1254 { 1265 {
1255 char third = *(option+7); 1266 char third = *(option+7);
1256 switch ( third ) { 1267 switch ( third ) {
1257 case 'F': // REF 1268 case 'F': // REF
1258 if ( *(option+5) == 'R' ) { 1269 if ( *(option+5) == 'R' ) {
1259 OptimizeReferences = optReferences; 1270 OptimizeReferences = optReferences;
1260 } else { // ICF[=iterations] 1271 } else { // ICF[=iterations]
1261 EnableCOMDATFolding = optFolding; 1272 EnableCOMDATFolding = optFolding;
1262 // [=iterations] case is not documented 1273 // [=iterations] case is not documented
1263 } 1274 }
1264 break; 1275 break;
1265 case 'R': // NOREF 1276 case 'R': // NOREF
1266 OptimizeReferences = optNoReferences; 1277 OptimizeReferences = optNoReferences;
1267 break; 1278 break;
1268 case 'I': // NOICF 1279 case 'I': // NOICF
1269 EnableCOMDATFolding = optNoFolding; 1280 EnableCOMDATFolding = optNoFolding;
1270 break; 1281 break;
1271 case 'N': // WIN98 1282 case 'N': // WIN98
1272 OptimizeForWindows98 = optWin98Yes; 1283 OptimizeForWindows98 = optWin98Yes;
1273 break; 1284 break;
1274 case 'W': // NOWIN98 1285 case 'W': // NOWIN98
1275 OptimizeForWindows98 = optWin98No; 1286 OptimizeForWindows98 = optWin98No;
1276 break; 1287 break;
1277 default: 1288 default:
1278 return FALSE; 1289 found = FALSE;
1279 } 1290 }
1280 } 1291 }
1281 break; 1292 break;
1282 case 0x34468a2: // /ORDER:@filename 1293 case 0x34468a2: // /ORDER:@filename
1283 FunctionOrder = option+8; 1294 FunctionOrder = option+8;
1284 break; 1295 break;
1285 case 0x00344a4: // /OUT:filename 1296 case 0x00344a4: // /OUT:filename
1286 OutputFile = option+5; 1297 OutputFile = option+5;
1287 break; 1298 break;
1288 case 0x0034482: // /PDB:filename 1299 case 0x0034482: // /PDB:filename
1289 ProgramDatabaseFile = option+5; 1300 ProgramDatabaseFile = option+5;
1290 break; 1301 break;
1291 case 0xa2ad314: // /PDBSTRIPPED:pdb_file_name 1302 case 0xa2ad314: // /PDBSTRIPPED:pdb_file_name
1292 StripPrivateSymbols = option+13; 1303 StripPrivateSymbols = option+13;
1293 break; 1304 break;
1294 case 0x6a09535: // /RELEASE 1305 case 0x6a09535: // /RELEASE
1295 SetChecksum = _True; 1306 SetChecksum = _True;
1296 break; 1307 break;
1297 case 0x348857b: // /STACK:reserve[,commit] 1308 case 0x348857b: // /STACK:reserve[,commit]
1298 { 1309 {
1299 QStringList both = QStringList::split( ",", option+7 ); 1310 QStringList both = QStringList::split( ",", option+7 );
1300 StackReserveSize = both[0].toLong(); 1311 StackReserveSize = both[0].toLong();
1301 if ( both.count() == 2 ) 1312 if ( both.count() == 2 )
1302 StackCommitSize = both[1].toLong(); 1313 StackCommitSize = both[1].toLong();
1303 } 1314 }
1304 break; 1315 break;
1305 case 0x78dc00d: // /SUBSYSTEM:{CONSOLE|EFI_APPLICATION|EFI_BOOT_SERVICE_DRIVER|EFI_ROM|EFI_RUNTIME_DRIVER|NATIVE|POSIX|WINDOWS|WINDOWSCE}[,major[.minor]] 1316 case 0x78dc00d: // /SUBSYSTEM:{CONSOLE|EFI_APPLICATION|EFI_BOOT_SERVICE_DRIVER|EFI_ROM|EFI_RUNTIME_DRIVER|NATIVE|POSIX|WINDOWS|WINDOWSCE}[,major[.minor]]
1306 { 1317 {
1307 // Split up in subsystem, and version number 1318 // Split up in subsystem, and version number
1308 QStringList both = QStringList::split( ",", option+11 ); 1319 QStringList both = QStringList::split( ",", option+11 );
1309 switch ( elfHash(both[0].latin1()) ) { 1320 switch ( elfHash(both[0].latin1()) ) {
1310 case 0x8438445: // CONSOLE 1321 case 0x8438445: // CONSOLE
1311 SubSystem = subSystemConsole; 1322 SubSystem = subSystemConsole;
1312 break; 1323 break;
1313 case 0xbe29493: // WINDOWS 1324 case 0xbe29493: // WINDOWS
1314 SubSystem = subSystemWindows; 1325 SubSystem = subSystemWindows;
1315 break; 1326 break;
1316 // The following are undocumented, so add them to AdditionalOptions 1327 // The following are undocumented, so add them to AdditionalOptions
1317 case 0x240949e: // EFI_APPLICATION 1328 case 0x240949e: // EFI_APPLICATION
1318 case 0xe617652: // EFI_BOOT_SERVICE_DRIVER 1329 case 0xe617652: // EFI_BOOT_SERVICE_DRIVER
1319 case 0x9af477d: // EFI_ROM 1330 case 0x9af477d: // EFI_ROM
1320 case 0xd34df42: // EFI_RUNTIME_DRIVER 1331 case 0xd34df42: // EFI_RUNTIME_DRIVER
1321 case 0x5268ea5: // NATIVE 1332 case 0x5268ea5: // NATIVE
1322 case 0x05547e8: // POSIX 1333 case 0x05547e8: // POSIX
1323 case 0x2949c95: // WINDOWSCE 1334 case 0x2949c95: // WINDOWSCE
1324 AdditionalOptions += option; 1335 AdditionalOptions += option;
1325 break; 1336 break;
1326 default: 1337 default:
1327 return FALSE; 1338 found = FALSE;
1328 } 1339 }
1329 } 1340 }
1330 break; 1341 break;
1331 case 0x8b654de: // /SWAPRUN:{NET | CD} 1342 case 0x8b654de: // /SWAPRUN:{NET | CD}
1332 if ( *(option+9) == 'N' ) 1343 if ( *(option+9) == 'N' )
1333 SwapRunFromNet = _True; 1344 SwapRunFromNet = _True;
1334 else if ( *(option+9) == 'C' ) 1345 else if ( *(option+9) == 'C' )
1335 SwapRunFromCD = _True; 1346 SwapRunFromCD = _True;
1336 else 1347 else
1337 return FALSE; 1348 found = FALSE;
1338 break; 1349 break;
1339 case 0x34906d4: // /TLBID:id 1350 case 0x34906d4: // /TLBID:id
1340 TypeLibraryResourceID = QString( option+7 ).toLong(); 1351 TypeLibraryResourceID = QString( option+7 ).toLong();
1341 break; 1352 break;
1342 case 0x4907494: // /TLBOUT:[path\]filename 1353 case 0x4907494: // /TLBOUT:[path\]filename
1343 TypeLibraryFile = option+8; 1354 TypeLibraryFile = option+8;
1344 break; 1355 break;
1345 case 0x976b525: // /TSAWARE[:NO] 1356 case 0x976b525: // /TSAWARE[:NO]
1346 if ( *(option+8) == ':' ) 1357 if ( *(option+8) == ':' )
1347 TerminalServerAware = termSvrAwareNo; 1358 TerminalServerAware = termSvrAwareNo;
1348 else 1359 else
1349 TerminalServerAware = termSvrAwareYes; 1360 TerminalServerAware = termSvrAwareYes;
1350 break; 1361 break;
1351 case 0xaa67735: // /VERBOSE[:lib] 1362 case 0xaa67735: // /VERBOSE[:lib]
1352 if ( *(option+9) == ':' ) { 1363 if ( *(option+9) == ':' ) {
1353 ShowProgress = linkProgressLibs; 1364 ShowProgress = linkProgressLibs;
1354 AdditionalOptions += option; 1365 AdditionalOptions += option;
1355 } else { 1366 } else {
1356 ShowProgress = linkProgressAll; 1367 ShowProgress = linkProgressAll;
1357 } 1368 }
1358 break; 1369 break;
1359 case 0xaa77f7e: // /VERSION:major[.minor] 1370 case 0xaa77f7e: // /VERSION:major[.minor]
1360 Version = option+9; 1371 Version = option+9;
1361 break; 1372 break;
1362 default: 1373 default:
1363 return FALSE; 1374 found = FALSE;
1364 } 1375 }
1365 return TRUE; 1376 if( !found )
1377 warn_msg( WarnLogic, "Could not parse Linker options: %s", option );
1378 return found;
1366} 1379}
1367 1380
1368// VCMIDLTool ------------------------------------------------------- 1381// VCMIDLTool -------------------------------------------------------
1369VCMIDLTool::VCMIDLTool() 1382VCMIDLTool::VCMIDLTool()
1370 :DefaultCharType( midlCharUnsigned ), 1383 :DefaultCharType( midlCharUnsigned ),
1371 EnableErrorChecks( midlDisableAll ), 1384 EnableErrorChecks( midlDisableAll ),
1372 ErrorCheckAllocations( unset ), 1385 ErrorCheckAllocations( unset ),
1373 ErrorCheckBounds( unset ), 1386 ErrorCheckBounds( unset ),
1374 ErrorCheckEnumRange( unset ), 1387 ErrorCheckEnumRange( unset ),
1375 ErrorCheckRefPointers( unset ), 1388 ErrorCheckRefPointers( unset ),
1376 ErrorCheckStubData( unset ), 1389 ErrorCheckStubData( unset ),
1377 GenerateStublessProxies( unset ), 1390 GenerateStublessProxies( unset ),
1378 GenerateTypeLibrary( unset ), 1391 GenerateTypeLibrary( unset ),
1379 IgnoreStandardIncludePath( unset ), 1392 IgnoreStandardIncludePath( unset ),
1380 MkTypLibCompatible( unset ), 1393 MkTypLibCompatible( unset ),
1381 StructMemberAlignment( midlAlignNotSet ), 1394 StructMemberAlignment( midlAlignNotSet ),
1382 SuppressStartupBanner( unset ), 1395 SuppressStartupBanner( unset ),
1383 TargetEnvironment( midlTargetNotSet ), 1396 TargetEnvironment( midlTargetNotSet ),
1384 ValidateParameters( unset ), 1397 ValidateParameters( unset ),
1385 WarnAsError( unset ), 1398 WarnAsError( unset ),
1386 WarningLevel( midlWarningLevel_0 ) 1399 WarningLevel( midlWarningLevel_0 )
1387{ 1400{
1388} 1401}
1389 1402
1390QTextStream &operator<<( QTextStream &strm, const VCMIDLTool &tool ) 1403QTextStream &operator<<( QTextStream &strm, const VCMIDLTool &tool )
1391{ 1404{
1392 strm << _begTool3; 1405 strm << _begTool3;
1393 strm << _VCMIDLToolName; 1406 strm << _VCMIDLToolName;
1394 strm << XPair( _AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories ); 1407 strm << XPair( _AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories );
1395 strm << XPair( _AdditionalOptions, tool.AdditionalOptions ); 1408 strm << XPair( _AdditionalOptions, tool.AdditionalOptions, " " );
1396 strm << XPair( _CPreprocessOptions, tool.CPreprocessOptions ); 1409 strm << XPair( _CPreprocessOptions, tool.CPreprocessOptions );
1397 strm << EPair( _DefaultCharType, tool.DefaultCharType ); 1410 strm << EPair( _DefaultCharType, tool.DefaultCharType );
1398 strm << SPair( _DLLDataFileName, tool.DLLDataFileName ); 1411 strm << SPair( _DLLDataFileName, tool.DLLDataFileName );
1399 strm << EPair( _EnableErrorChecks, tool.EnableErrorChecks ); 1412 strm << EPair( _EnableErrorChecks, tool.EnableErrorChecks );
1400 strm << TPair( _ErrorCheckAllocations, tool.ErrorCheckAllocations ); 1413 strm << TPair( _ErrorCheckAllocations, tool.ErrorCheckAllocations );
1401 strm << TPair( _ErrorCheckBounds, tool.ErrorCheckBounds ); 1414 strm << TPair( _ErrorCheckBounds, tool.ErrorCheckBounds );
1402 strm << TPair( _ErrorCheckEnumRange, tool.ErrorCheckEnumRange ); 1415 strm << TPair( _ErrorCheckEnumRange, tool.ErrorCheckEnumRange );
1403 strm << TPair( _ErrorCheckRefPointers, tool.ErrorCheckRefPointers ); 1416 strm << TPair( _ErrorCheckRefPointers, tool.ErrorCheckRefPointers );
1404 strm << TPair( _ErrorCheckStubData, tool.ErrorCheckStubData ); 1417 strm << TPair( _ErrorCheckStubData, tool.ErrorCheckStubData );
1405 strm << XPair( _FullIncludePath, tool.FullIncludePath ); 1418 strm << XPair( _FullIncludePath, tool.FullIncludePath );
1406 strm << TPair( _GenerateStublessProxies, tool.GenerateStublessProxies ); 1419 strm << TPair( _GenerateStublessProxies, tool.GenerateStublessProxies );
1407 strm << TPair( _GenerateTypeLibrary, tool.GenerateTypeLibrary ); 1420 strm << TPair( _GenerateTypeLibrary, tool.GenerateTypeLibrary );
1408 strm << SPair( _HeaderFileName, tool.HeaderFileName ); 1421 strm << SPair( _HeaderFileName, tool.HeaderFileName );
1409 strm << TPair( _IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath ); 1422 strm << TPair( _IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath );
1410 strm << SPair( _InterfaceIdentifierFileName, tool.InterfaceIdentifierFileName ); 1423 strm << SPair( _InterfaceIdentifierFileName, tool.InterfaceIdentifierFileName );
1411 strm << TPair( _MkTypLibCompatible, tool.MkTypLibCompatible ); 1424 strm << TPair( _MkTypLibCompatible, tool.MkTypLibCompatible );
1412 strm << SPair( _OutputDirectory4, tool.OutputDirectory ); 1425 strm << SPair( _OutputDirectory4, tool.OutputDirectory );
1413 strm << XPair( _PreprocessorDefinitions, tool.PreprocessorDefinitions ); 1426 strm << XPair( _PreprocessorDefinitions, tool.PreprocessorDefinitions );
1414 strm << SPair( _ProxyFileName, tool.ProxyFileName ); 1427 strm << SPair( _ProxyFileName, tool.ProxyFileName );
1415 strm << SPair( _RedirectOutputAndErrors, tool.RedirectOutputAndErrors ); 1428 strm << SPair( _RedirectOutputAndErrors, tool.RedirectOutputAndErrors );
1416 if ( tool.StructMemberAlignment != midlAlignNotSet) strm << EPair( _StructMemberAlignment, tool.StructMemberAlignment ); 1429 if ( tool.StructMemberAlignment != midlAlignNotSet) strm << EPair( _StructMemberAlignment, tool.StructMemberAlignment );
1417 strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner ); 1430 strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner );
1418 if ( tool.TargetEnvironment != midlTargetNotSet ) strm << EPair( _TargetEnvironment, tool.TargetEnvironment ); 1431 if ( tool.TargetEnvironment != midlTargetNotSet ) strm << EPair( _TargetEnvironment, tool.TargetEnvironment );
1419 strm << SPair( _TypeLibraryName, tool.TypeLibraryName ); 1432 strm << SPair( _TypeLibraryName, tool.TypeLibraryName );
1420 strm << XPair( _UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions ); 1433 strm << XPair( _UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions );
1421 strm << TPair( _ValidateParameters, tool.ValidateParameters ); 1434 strm << TPair( _ValidateParameters, tool.ValidateParameters );
1422 strm << TPair( _WarnAsError, tool.WarnAsError ); 1435 strm << TPair( _WarnAsError, tool.WarnAsError );
1423 strm << EPair( _WarningLevel, tool.WarningLevel ); 1436 strm << EPair( _WarningLevel, tool.WarningLevel );
1424 strm << "/>"; 1437 strm << "/>";
1425 return strm; 1438 return strm;
1426} 1439}
1427 1440
1428bool VCMIDLTool::parseOption( const char* option ) 1441bool VCMIDLTool::parseOption( const char* option )
1429{ 1442{
1430#if 0 1443#ifdef USE_DISPLAY_HASH
1431 displayHash( "/D name[=def]" ); displayHash( "/I directory-list" ); displayHash( "/Oi" ); 1444 displayHash( "/D name[=def]" ); displayHash( "/I directory-list" ); displayHash( "/Oi" );
1432 displayHash( "/Oic" ); displayHash( "/Oicf" ); displayHash( "/Oif" ); displayHash( "/Os" ); 1445 displayHash( "/Oic" ); displayHash( "/Oicf" ); displayHash( "/Oif" ); displayHash( "/Os" );
1433 displayHash( "/U name" ); displayHash( "/WX" ); displayHash( "/W{0|1|2|3|4}" ); 1446 displayHash( "/U name" ); displayHash( "/WX" ); displayHash( "/W{0|1|2|3|4}" );
1434 displayHash( "/Zp {N}" ); displayHash( "/Zs" ); displayHash( "/acf filename" ); 1447 displayHash( "/Zp {N}" ); displayHash( "/Zs" ); displayHash( "/acf filename" );
1435 displayHash( "/align {N}" ); displayHash( "/app_config" ); displayHash( "/c_ext" ); 1448 displayHash( "/align {N}" ); displayHash( "/app_config" ); displayHash( "/c_ext" );
1436 displayHash( "/char ascii7" ); displayHash( "/char signed" ); displayHash( "/char unsigned" ); 1449 displayHash( "/char ascii7" ); displayHash( "/char signed" ); displayHash( "/char unsigned" );
1437 displayHash( "/client none" ); displayHash( "/client stub" ); displayHash( "/confirm" ); 1450 displayHash( "/client none" ); displayHash( "/client stub" ); displayHash( "/confirm" );
1438 displayHash( "/cpp_cmd cmd_line" ); displayHash( "/cpp_opt options" ); 1451 displayHash( "/cpp_cmd cmd_line" ); displayHash( "/cpp_opt options" );
1439 displayHash( "/cstub filename" ); displayHash( "/dlldata filename" ); displayHash( "/env win32" ); 1452 displayHash( "/cstub filename" ); displayHash( "/dlldata filename" ); displayHash( "/env win32" );
1440 displayHash( "/env win64" ); displayHash( "/error all" ); displayHash( "/error allocation" ); 1453 displayHash( "/env win64" ); displayHash( "/error all" ); displayHash( "/error allocation" );
1441 displayHash( "/error bounds_check" ); displayHash( "/error enum" ); displayHash( "/error none" ); 1454 displayHash( "/error bounds_check" ); displayHash( "/error enum" ); displayHash( "/error none" );
1442 displayHash( "/error ref" ); displayHash( "/error stub_data" ); displayHash( "/h filename" ); 1455 displayHash( "/error ref" ); displayHash( "/error stub_data" ); displayHash( "/h filename" );
1443 displayHash( "/header filename" ); displayHash( "/iid filename" ); displayHash( "/lcid" ); 1456 displayHash( "/header filename" ); displayHash( "/iid filename" ); displayHash( "/lcid" );
1444 displayHash( "/mktyplib203" ); displayHash( "/ms_ext" ); displayHash( "/ms_union" ); 1457 displayHash( "/mktyplib203" ); displayHash( "/ms_ext" ); displayHash( "/ms_union" );
1445 displayHash( "/msc_ver <nnnn>" ); displayHash( "/newtlb" ); displayHash( "/no_cpp" ); 1458 displayHash( "/msc_ver <nnnn>" ); displayHash( "/newtlb" ); displayHash( "/no_cpp" );
1446 displayHash( "/no_def_idir" ); displayHash( "/no_default_epv" ); displayHash( "/no_format_opt" ); 1459 displayHash( "/no_def_idir" ); displayHash( "/no_default_epv" ); displayHash( "/no_format_opt" );
1447 displayHash( "/no_warn" ); displayHash( "/nocpp" ); displayHash( "/nologo" ); displayHash( "/notlb" ); 1460 displayHash( "/no_warn" ); displayHash( "/nocpp" ); displayHash( "/nologo" ); displayHash( "/notlb" );
1448 displayHash( "/o filename" ); displayHash( "/oldnames" ); displayHash( "/oldtlb" ); 1461 displayHash( "/o filename" ); displayHash( "/oldnames" ); displayHash( "/oldtlb" );
1449 displayHash( "/osf" ); displayHash( "/out directory" ); displayHash( "/pack {N}" ); 1462 displayHash( "/osf" ); displayHash( "/out directory" ); displayHash( "/pack {N}" );
1450 displayHash( "/prefix all" ); displayHash( "/prefix client" ); displayHash( "/prefix server" ); 1463 displayHash( "/prefix all" ); displayHash( "/prefix client" ); displayHash( "/prefix server" );
1451 displayHash( "/prefix switch" ); displayHash( "/protocol all" ); displayHash( "/protocol dce" ); 1464 displayHash( "/prefix switch" ); displayHash( "/protocol all" ); displayHash( "/protocol dce" );
1452 displayHash( "/protocol ndr64" ); displayHash( "/proxy filename" ); displayHash( "/robust" ); 1465 displayHash( "/protocol ndr64" ); displayHash( "/proxy filename" ); displayHash( "/robust" );
1453 displayHash( "/rpcss" ); displayHash( "/savePP" ); displayHash( "/server none" ); 1466 displayHash( "/rpcss" ); displayHash( "/savePP" ); displayHash( "/server none" );
1454 displayHash( "/server stub" ); displayHash( "/sstub filename" ); displayHash( "/syntax_check" ); 1467 displayHash( "/server stub" ); displayHash( "/sstub filename" ); displayHash( "/syntax_check" );
1455 displayHash( "/target {system}" ); displayHash( "/tlb filename" ); displayHash( "/use_epv" ); 1468 displayHash( "/target {system}" ); displayHash( "/tlb filename" ); displayHash( "/use_epv" );
1456 displayHash( "/win32" ); displayHash( "/win64" ); 1469 displayHash( "/win32" ); displayHash( "/win64" );
1457#endif 1470#endif
1471 bool found = TRUE;
1458 int offset = 0; 1472 int offset = 0;
1459 switch( elfHash(option) ) { 1473 switch( elfHash(option) ) {
1460 case 0x0000334: // /D name[=def] 1474 case 0x0000334: // /D name[=def]
1461 PreprocessorDefinitions += option+3; 1475 PreprocessorDefinitions += option+3;
1462 break; 1476 break;
1463 case 0x0000339: // /I directory-list 1477 case 0x0000339: // /I directory-list
1464 AdditionalIncludeDirectories += option+3; 1478 AdditionalIncludeDirectories += option+3;
1465 break; 1479 break;
1466 case 0x0345f96: // /Oicf 1480 case 0x0345f96: // /Oicf
1467 case 0x00345f6: // /Oif 1481 case 0x00345f6: // /Oif
1468 GenerateStublessProxies = _True; 1482 GenerateStublessProxies = _True;
1469 break; 1483 break;
1470 case 0x0000345: // /U name 1484 case 0x0000345: // /U name
1471 UndefinePreprocessorDefinitions += option+3; 1485 UndefinePreprocessorDefinitions += option+3;
1472 break; 1486 break;
1473 case 0x00034c8: // /WX 1487 case 0x00034c8: // /WX
1474 WarnAsError = _True; 1488 WarnAsError = _True;
1475 break; 1489 break;
1476 case 0x3582fde: // /align {N} 1490 case 0x3582fde: // /align {N}
1477 offset = 3; // Fallthrough 1491 offset = 3; // Fallthrough
1478 case 0x0003510: // /Zp {N} 1492 case 0x0003510: // /Zp {N}
1479 switch ( *(option+offset+4) ) { 1493 switch ( *(option+offset+4) ) {
1480 case '1': 1494 case '1':
1481 StructMemberAlignment = ( *(option+offset+5) == '\0' ) ? midlAlignSingleByte : midlAlignSixteenBytes; 1495 StructMemberAlignment = ( *(option+offset+5) == '\0' ) ? midlAlignSingleByte : midlAlignSixteenBytes;
1482 break; 1496 break;
1483 case '2': 1497 case '2':
1484 StructMemberAlignment = midlAlignTwoBytes; 1498 StructMemberAlignment = midlAlignTwoBytes;
1485 break; 1499 break;
1486 case '4': 1500 case '4':
1487 StructMemberAlignment = midlAlignFourBytes; 1501 StructMemberAlignment = midlAlignFourBytes;
1488 break; 1502 break;
1489 case '8': 1503 case '8':
1490 StructMemberAlignment = midlAlignEightBytes; 1504 StructMemberAlignment = midlAlignEightBytes;
1491 break; 1505 break;
1492 default: 1506 default:
1493 return FALSE; 1507 found = FALSE;
1494 } 1508 }
1495 break; 1509 break;
1496 case 0x0359e82: // /char {ascii7|signed|unsigned} 1510 case 0x0359e82: // /char {ascii7|signed|unsigned}
1497 switch( *(option+6) ) { 1511 switch( *(option+6) ) {
1498 case 'a': 1512 case 'a':
1499 DefaultCharType = midlCharAscii7; 1513 DefaultCharType = midlCharAscii7;
1500 break; 1514 break;
1501 case 's': 1515 case 's':
1502 DefaultCharType = midlCharSigned; 1516 DefaultCharType = midlCharSigned;
1503 break; 1517 break;
1504 case 'u': 1518 case 'u':
1505 DefaultCharType = midlCharUnsigned; 1519 DefaultCharType = midlCharUnsigned;
1506 break; 1520 break;
1507 default: 1521 default:
1508 return FALSE; 1522 found = FALSE;
1509 } 1523 }
1510 break; 1524 break;
1511 case 0xa766524: // /cpp_opt options 1525 case 0xa766524: // /cpp_opt options
1512 CPreprocessOptions += option+9; 1526 CPreprocessOptions += option+9;
1513 break; 1527 break;
1514 case 0xb32abf1: // /dlldata filename 1528 case 0xb32abf1: // /dlldata filename
1515 DLLDataFileName = option + 9; 1529 DLLDataFileName = option + 9;
1516 break; 1530 break;
1517 case 0x0035c56: // /env {win32|win64} 1531 case 0x0035c56: // /env {win32|win64}
1518 TargetEnvironment = ( *(option+8) == '6' ) ? midlTargetWin64 : midlTargetWin32; 1532 TargetEnvironment = ( *(option+8) == '6' ) ? midlTargetWin64 : midlTargetWin32;
1519 break; 1533 break;
1520 case 0x35c9962: // /error {all|allocation|bounds_check|enum|none|ref|stub_data} 1534 case 0x35c9962: // /error {all|allocation|bounds_check|enum|none|ref|stub_data}
1521 EnableErrorChecks = midlEnableCustom; 1535 EnableErrorChecks = midlEnableCustom;
1522 switch ( *(option+7) ) { 1536 switch ( *(option+7) ) {
1523 case 'a': 1537 case 'a':
1524 if ( *(option+10) == '\0' ) 1538 if ( *(option+10) == '\0' )
1525 EnableErrorChecks = midlEnableAll; 1539 EnableErrorChecks = midlEnableAll;
1526 else 1540 else
1527 ErrorCheckAllocations = _True; 1541 ErrorCheckAllocations = _True;
1528 break; 1542 break;
1529 case 'b': 1543 case 'b':
1530 ErrorCheckBounds = _True; 1544 ErrorCheckBounds = _True;
1531 break; 1545 break;
1532 case 'e': 1546 case 'e':
1533 ErrorCheckEnumRange = _True; 1547 ErrorCheckEnumRange = _True;
1534 break; 1548 break;
1535 case 'n': 1549 case 'n':
1536 EnableErrorChecks = midlDisableAll; 1550 EnableErrorChecks = midlDisableAll;
1537 break; 1551 break;
1538 case 'r': 1552 case 'r':
1539 break;
1540 ErrorCheckRefPointers = _True; 1553 ErrorCheckRefPointers = _True;
1541 case 's':
1542 break; 1554 break;
1555 case 's':
1543 ErrorCheckStubData = _True; 1556 ErrorCheckStubData = _True;
1557 break;
1544 default: 1558 default:
1545 return FALSE; 1559 found = FALSE;
1546 } 1560 }
1547 break; 1561 break;
1548 case 0x5eb7af2: // /header filename 1562 case 0x5eb7af2: // /header filename
1549 offset = 5; 1563 offset = 5;
1550 case 0x0000358: // /h filename 1564 case 0x0000358: // /h filename
1551 HeaderFileName = option + offset + 3; 1565 HeaderFileName = option + offset + 3;
1552 break; 1566 break;
1553 case 0x0035ff4: // /iid filename 1567 case 0x0035ff4: // /iid filename
1554 InterfaceIdentifierFileName = option+5; 1568 InterfaceIdentifierFileName = option+5;
1555 break; 1569 break;
1556 case 0x64b7933: // /mktyplib203 1570 case 0x64b7933: // /mktyplib203
1557 MkTypLibCompatible = _True; 1571 MkTypLibCompatible = _True;
1558 break; 1572 break;
1559 case 0x8e0b0a2: // /no_def_idir 1573 case 0x8e0b0a2: // /no_def_idir
1560 IgnoreStandardIncludePath = _True; 1574 IgnoreStandardIncludePath = _True;
1561 break; 1575 break;
1562 case 0x65635ef: // /nologo 1576 case 0x65635ef: // /nologo
1563 SuppressStartupBanner = _True; 1577 SuppressStartupBanner = _True;
1564 break; 1578 break;
1565 case 0x3656b22: // /notlb 1579 case 0x3656b22: // /notlb
1566 GenerateTypeLibrary = _True; 1580 GenerateTypeLibrary = _True;
1567 break; 1581 break;
1568 case 0x000035f: // /o filename 1582 case 0x000035f: // /o filename
1569 RedirectOutputAndErrors = option+3; 1583 RedirectOutputAndErrors = option+3;
@@ -1626,116 +1640,118 @@ bool VCMIDLTool::parseOption( const char* option )
1626 case 0xce9b12b: // /syntax_check 1640 case 0xce9b12b: // /syntax_check
1627 case 0xc9b5f16: // /use_epv 1641 case 0xc9b5f16: // /use_epv
1628 AdditionalOptions += option; 1642 AdditionalOptions += option;
1629 break; 1643 break;
1630 default: 1644 default:
1631 // /W{0|1|2|3|4} case 1645 // /W{0|1|2|3|4} case
1632 if ( *(option+1) == 'W' ) { 1646 if ( *(option+1) == 'W' ) {
1633 switch ( *(option+2) ) { 1647 switch ( *(option+2) ) {
1634 case '0': 1648 case '0':
1635 WarningLevel = midlWarningLevel_0; 1649 WarningLevel = midlWarningLevel_0;
1636 break; 1650 break;
1637 case '1': 1651 case '1':
1638 WarningLevel = midlWarningLevel_1; 1652 WarningLevel = midlWarningLevel_1;
1639 break; 1653 break;
1640 case '2': 1654 case '2':
1641 WarningLevel = midlWarningLevel_2; 1655 WarningLevel = midlWarningLevel_2;
1642 break; 1656 break;
1643 case '3': 1657 case '3':
1644 WarningLevel = midlWarningLevel_3; 1658 WarningLevel = midlWarningLevel_3;
1645 break; 1659 break;
1646 case '4': 1660 case '4':
1647 WarningLevel = midlWarningLevel_4; 1661 WarningLevel = midlWarningLevel_4;
1648 break; 1662 break;
1649 default: 1663 default:
1650 return FALSE; 1664 found = FALSE;
1651 } 1665 }
1652 } 1666 }
1653 break; 1667 break;
1654 } 1668 }
1669 if( !found )
1670 warn_msg( WarnLogic, "Could not parse MIDL option: %s", option );
1655 return TRUE; 1671 return TRUE;
1656} 1672}
1657 1673
1658// VCLibrarianTool -------------------------------------------------- 1674// VCLibrarianTool --------------------------------------------------
1659VCLibrarianTool::VCLibrarianTool() 1675VCLibrarianTool::VCLibrarianTool()
1660 :IgnoreAllDefaultLibraries( unset ), 1676 :IgnoreAllDefaultLibraries( unset ),
1661 SuppressStartupBanner( _True ) 1677 SuppressStartupBanner( _True )
1662{ 1678{
1663} 1679}
1664 1680
1665QTextStream &operator<<( QTextStream &strm, const VCLibrarianTool &tool ) 1681QTextStream &operator<<( QTextStream &strm, const VCLibrarianTool &tool )
1666{ 1682{
1667 strm << _begTool3; 1683 strm << _begTool3;
1668 strm << SPair( _ToolName, QString( "VCLibrarianTool" ) ); 1684 strm << SPair( _ToolName, QString( "VCLibrarianTool" ) );
1669 strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies ); 1685 strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies );
1670 strm << XPair( _AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories ); 1686 strm << XPair( _AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories );
1671 strm << XPair( _AdditionalOptions, tool.AdditionalOptions ); 1687 strm << XPair( _AdditionalOptions, tool.AdditionalOptions, " " );
1672 strm << XPair( _ExportNamedFunctions, tool.ExportNamedFunctions ); 1688 strm << XPair( _ExportNamedFunctions, tool.ExportNamedFunctions );
1673 strm << XPair( _ForceSymbolReferences, tool.ForceSymbolReferences ); 1689 strm << XPair( _ForceSymbolReferences, tool.ForceSymbolReferences );
1674 strm << TPair( _IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries ); 1690 strm << TPair( _IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries );
1675 strm << XPair( _IgnoreDefaultLibraryNames, tool.IgnoreDefaultLibraryNames ); 1691 strm << XPair( _IgnoreDefaultLibraryNames, tool.IgnoreDefaultLibraryNames );
1676 strm << SPair( _ModuleDefinitionFile, tool.ModuleDefinitionFile ); 1692 strm << SPair( _ModuleDefinitionFile, tool.ModuleDefinitionFile );
1677 strm << SPair( _OutputFile, tool.OutputFile ); 1693 strm << SPair( _OutputFile, tool.OutputFile );
1678 strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner ); 1694 strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner );
1679 strm << "/>"; 1695 strm << "/>";
1680 return strm; 1696 return strm;
1681} 1697}
1682 1698
1683// VCCustomBuildTool ------------------------------------------------ 1699// VCCustomBuildTool ------------------------------------------------
1684VCCustomBuildTool::VCCustomBuildTool() 1700VCCustomBuildTool::VCCustomBuildTool()
1685{ 1701{
1686 ToolName = "VCCustomBuildTool"; 1702 ToolName = "VCCustomBuildTool";
1687} 1703}
1688 1704
1689QTextStream &operator<<( QTextStream &strm, const VCCustomBuildTool &tool ) 1705QTextStream &operator<<( QTextStream &strm, const VCCustomBuildTool &tool )
1690{ 1706{
1691 strm << _begTool3; 1707 strm << _begTool3;
1692 strm << SPair( _ToolName, tool.ToolName ); 1708 strm << SPair( _ToolName, tool.ToolName );
1693 strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies, ";" ); 1709 strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies, ";" );
1694 strm << SPair( _CommandLine4, tool.CommandLine ); 1710 strm << SPair( _CommandLine4, tool.CommandLine );
1695 strm << SPair( _Description4, tool.Description ); 1711 strm << SPair( _Description4, tool.Description );
1696 strm << SPair( _Outputs4, tool.Outputs ); 1712 strm << SPair( _Outputs4, tool.Outputs );
1697 strm << SPair( _ToolPath, tool.ToolPath ); 1713 strm << SPair( _ToolPath, tool.ToolPath );
1698 strm << "/>"; 1714 strm << "/>";
1699 return strm; 1715 return strm;
1700} 1716}
1701 1717
1702// VCResourceCompilerTool ------------------------------------------- 1718// VCResourceCompilerTool -------------------------------------------
1703VCResourceCompilerTool::VCResourceCompilerTool() 1719VCResourceCompilerTool::VCResourceCompilerTool()
1704 : Culture( rcUseDefault ), 1720 : Culture( rcUseDefault ),
1705 IgnoreStandardIncludePath( unset ), 1721 IgnoreStandardIncludePath( unset ),
1706 ShowProgress( linkProgressNotSet ) 1722 ShowProgress( linkProgressNotSet )
1707{ 1723{
1708 PreprocessorDefinitions = "NDEBUG"; 1724 PreprocessorDefinitions = "NDEBUG";
1709} 1725}
1710 1726
1711QTextStream &operator<<( QTextStream &strm, const VCResourceCompilerTool &tool ) 1727QTextStream &operator<<( QTextStream &strm, const VCResourceCompilerTool &tool )
1712{ 1728{
1713 strm << _begTool3; 1729 strm << _begTool3;
1714 strm << _VCResourceCompilerToolName; 1730 strm << _VCResourceCompilerToolName;
1715 strm << SPair( _ToolPath, tool.ToolPath ); 1731 strm << SPair( _ToolPath, tool.ToolPath );
1716 strm << XPair( _AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories ); 1732 strm << XPair( _AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories );
1717 strm << XPair( _AdditionalOptions, tool.AdditionalOptions ); 1733 strm << XPair( _AdditionalOptions, tool.AdditionalOptions, " " );
1718 if ( tool.Culture != rcUseDefault ) strm << EPair( _Culture, tool.Culture ); 1734 if ( tool.Culture != rcUseDefault ) strm << EPair( _Culture, tool.Culture );
1719 strm << XPair( _FullIncludePath, tool.FullIncludePath ); 1735 strm << XPair( _FullIncludePath, tool.FullIncludePath );
1720 strm << TPair( _IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath ); 1736 strm << TPair( _IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath );
1721 strm << XPair( _PreprocessorDefinitions, tool.PreprocessorDefinitions ); 1737 strm << XPair( _PreprocessorDefinitions, tool.PreprocessorDefinitions );
1722 strm << SPair( _ResourceOutputFileName, tool.ResourceOutputFileName ); 1738 strm << SPair( _ResourceOutputFileName, tool.ResourceOutputFileName );
1723 if ( tool.ShowProgress != linkProgressNotSet ) strm << EPair( _ShowProgress, tool.ShowProgress ); 1739 if ( tool.ShowProgress != linkProgressNotSet ) strm << EPair( _ShowProgress, tool.ShowProgress );
1724 strm << "/>"; 1740 strm << "/>";
1725 return strm; 1741 return strm;
1726} 1742}
1727 1743
1728// VCEventTool ------------------------------------------------- 1744// VCEventTool -------------------------------------------------
1729QTextStream &operator<<( QTextStream &strm, const VCEventTool &tool ) 1745QTextStream &operator<<( QTextStream &strm, const VCEventTool &tool )
1730{ 1746{
1731 strm << _begTool3; 1747 strm << _begTool3;
1732 strm << SPair( _ToolName, tool.ToolName ); 1748 strm << SPair( _ToolName, tool.ToolName );
1733 strm << SPair( _ToolPath, tool.ToolPath ); 1749 strm << SPair( _ToolPath, tool.ToolPath );
1734 strm << SPair( _CommandLine4, tool.CommandLine ); 1750 strm << SPair( _CommandLine4, tool.CommandLine );
1735 strm << SPair( _Description4, tool.Description ); 1751 strm << SPair( _Description4, tool.Description );
1736 strm << TPair( _ExcludedFromBuild, tool.ExcludedFromBuild ); 1752 strm << TPair( _ExcludedFromBuild, tool.ExcludedFromBuild );
1737 strm << "/>"; 1753 strm << "/>";
1738 return strm; 1754 return strm;
1739} 1755}
1740 1756
1741// VCPostBuildEventTool --------------------------------------------- 1757// VCPostBuildEventTool ---------------------------------------------
@@ -1830,106 +1846,127 @@ void VCFilter::generateMOC( QTextStream &strm, QString str ) const
1830 strm << _Name5; 1846 strm << _Name5;
1831 strm << Config->Name; 1847 strm << Config->Name;
1832 strm << "\">"; 1848 strm << "\">";
1833 strm << _begTool5; 1849 strm << _begTool5;
1834 strm << _VCCustomBuildTool; 1850 strm << _VCCustomBuildTool;
1835 strm << _Description6; 1851 strm << _Description6;
1836 strm << "Moc'ing " << str << "...\""; 1852 strm << "Moc'ing " << str << "...\"";
1837 strm << _CommandLine6; 1853 strm << _CommandLine6;
1838 strm << mocApp; 1854 strm << mocApp;
1839 strm << " " << str << " -o " << mocOutput << "\""; 1855 strm << " " << str << " -o " << mocOutput << "\"";
1840 strm << _AdditionalDependencies6; 1856 strm << _AdditionalDependencies6;
1841 strm << mocApp << "\""; 1857 strm << mocApp << "\"";
1842 strm << _Outputs6; 1858 strm << _Outputs6;
1843 strm << mocOutput << "\""; 1859 strm << mocOutput << "\"";
1844 strm << "/>"; 1860 strm << "/>";
1845 strm << _endFileConfiguration; 1861 strm << _endFileConfiguration;
1846} 1862}
1847 1863
1848void VCFilter::generateUIC( QTextStream &strm, const QString& str ) const 1864void VCFilter::generateUIC( QTextStream &strm, const QString& str ) const
1849{ 1865{
1850 QString uicApp = Project->var("QMAKE_UIC"); 1866 QString uicApp = Project->var("QMAKE_UIC");
1851 QString mocApp = Project->var( "QMAKE_MOC" ); 1867 QString mocApp = Project->var( "QMAKE_MOC" );
1852 QString fname = str.section( '\\', -1 ); 1868 QString fname = str.section( '\\', -1 );
1853 QString mocDir = Project->var( "MOC_DIR" ); 1869 QString mocDir = Project->var( "MOC_DIR" );
1854 int dot = fname.findRev( '.' ); 1870 QString uiDir = Project->var( "UI_DIR" );
1855 if( dot != -1 ) 1871 QString uiHeaders;
1856 fname.truncate( dot ); 1872 QString uiSources;
1857 1873
1874 // Determining the paths for the output files.
1858 int slash = str.findRev( '\\' ); 1875 int slash = str.findRev( '\\' );
1859 QString pname = ( slash != -1 ) ? str.left( slash+1 ) : QString(".\\"); 1876 QString pname = ( slash != -1 ) ? str.left( slash+1 ) : QString(".\\");
1877 if( !uiDir.isEmpty() ) {
1878 uiHeaders = uiDir;
1879 uiSources = uiDir;
1880 } else {
1881 uiHeaders = Project->var( "UI_HEADERS_DIR" );
1882 uiSources = Project->var( "UI_SOURCES_DIR" );
1883 if( uiHeaders.isEmpty() )
1884 uiHeaders = pname;
1885 if( uiSources.isEmpty() )
1886 uiSources = pname;
1887 }
1888 if( !uiHeaders.endsWith( "\\" ) )
1889 uiHeaders += "\\";
1890 if( !uiSources.endsWith( "\\" ) )
1891 uiSources += "\\";
1892
1893 // Determine the file name.
1894 int dot = fname.findRev( '.' );
1895 if( dot != -1 )
1896 fname.truncate( dot );
1860 1897
1861 strm << _begFileConfiguration; 1898 strm << _begFileConfiguration;
1862 strm << _Name5; 1899 strm << _Name5;
1863 strm << Config->Name; 1900 strm << Config->Name;
1864 strm << "\">"; 1901 strm << "\">";
1865 strm << _begTool5; 1902 strm << _begTool5;
1866 strm << _VCCustomBuildTool; 1903 strm << _VCCustomBuildTool;
1867 strm << _Description6; 1904 strm << _Description6;
1868 strm << "Uic'ing " << str << "...\""; 1905 strm << "Uic'ing " << str << "...\"";
1869 strm << _CommandLine6; 1906 strm << _CommandLine6;
1870 strm << uicApp << " " << str << " -o " << pname << fname << ".h &amp;&amp; "; // Create .h from .ui file 1907 strm << uicApp << " " << str << " -o " << uiHeaders << fname << ".h &amp;&amp; "; // Create .h from .ui file
1871 strm << uicApp << " " << str << " -i " << fname << ".h -o " << pname << fname << ".cpp &amp;&amp; ";// Create .cpp from .ui file 1908 strm << uicApp << " " << str << " -i " << fname << ".h -o " << uiSources << fname << ".cpp &amp;&amp; ";// Create .cpp from .ui file
1872 strm << mocApp << " " << pname << fname << ".h -o " << mocDir << "moc_" << fname << ".cpp\""; 1909 strm << mocApp << " " << uiHeaders << fname << ".h -o " << mocDir << "moc_" << fname << ".cpp\"";
1873 strm << _AdditionalDependencies6; 1910 strm << _AdditionalDependencies6;
1874 strm << mocApp << ";" << uicApp << "\""; 1911 strm << mocApp << ";" << uicApp << "\"";
1875 strm << _Outputs6; 1912 strm << _Outputs6;
1876 strm << pname << fname << ".h;" << pname << fname << ".cpp;" << mocDir << "moc_" << fname << ".cpp\""; 1913 strm << uiHeaders << fname << ".h;" << uiSources << fname << ".cpp;" << mocDir << "moc_" << fname << ".cpp\"";
1877 strm << "/>"; 1914 strm << "/>";
1878 strm << _endFileConfiguration; 1915 strm << _endFileConfiguration;
1879} 1916}
1880 1917
1881QTextStream &operator<<( QTextStream &strm, const VCFilter &tool ) 1918QTextStream &operator<<( QTextStream &strm, const VCFilter &tool )
1882{ 1919{
1883 if ( tool.Files.count() == 0 ) 1920 if ( tool.Files.count() == 0 )
1884 return strm; 1921 return strm;
1885 1922
1886 strm << _begFilter; 1923 strm << _begFilter;
1887 strm << SPair( _Name3, tool.Name ); 1924 strm << SPair( _Name3, tool.Name );
1888 strm << TPair( _ParseFiles, tool.ParseFiles ); 1925 strm << TPair( _ParseFiles, tool.ParseFiles );
1889 strm << SPair( _Filter, tool.Filter ); 1926 strm << SPair( _Filter, tool.Filter );
1890 strm << ">"; 1927 strm << ">";
1891 for ( QStringList::ConstIterator it = tool.Files.begin(); it != tool.Files.end(); ++it ) { 1928 for ( QStringList::ConstIterator it = tool.Files.begin(); it != tool.Files.end(); ++it ) {
1892 strm << _begFile; 1929 strm << _begFile;
1893 strm << SPair( _RelativePath, *it ); 1930 strm << SPair( _RelativePath, *it );
1894 strm << ">"; 1931 strm << ">";
1895 if ( tool.CustomBuild == moc ) 1932 if ( tool.CustomBuild == moc )
1896 tool.generateMOC( strm, *it ); 1933 tool.generateMOC( strm, *it );
1897 else if ( tool.CustomBuild == uic ) 1934 else if ( tool.CustomBuild == uic )
1898 tool.generateUIC( strm, *it ); 1935 tool.generateUIC( strm, *it );
1899 strm << _endFile; 1936 strm << _endFile;
1900 } 1937 }
1901 1938
1902 strm << _endFilter; 1939 strm << _endFilter;
1903 return strm; 1940 return strm;
1904} 1941}
1905 1942
1906// VCProject -------------------------------------------------------- 1943// VCProject --------------------------------------------------------
1907VCProject::VCProject() 1944VCProject::VCProject()
1908{ 1945{
1909 QUuid uniqueId;
1910#if defined(Q_WS_WIN32) 1946#if defined(Q_WS_WIN32)
1911 GUID guid; 1947 GUID guid;
1948 QUuid uniqueId;
1912 HRESULT h = CoCreateGuid( &guid ); 1949 HRESULT h = CoCreateGuid( &guid );
1913 if ( h == S_OK ) 1950 if ( h == S_OK )
1914 uniqueId = QUuid( guid ); 1951 uniqueId = QUuid( guid );
1915 ProjectGUID = uniqueId.toString(); 1952 ProjectGUID = uniqueId.toString();
1916#else 1953#else
1917 // Qt doesn't support GUID on other platforms yet 1954 // Qt doesn't support GUID on other platforms yet
1918 ProjectGUID = ""; 1955 ProjectGUID = "";
1919#endif 1956#endif
1920} 1957}
1921 1958
1922QTextStream &operator<<( QTextStream &strm, const VCProject &tool ) 1959QTextStream &operator<<( QTextStream &strm, const VCProject &tool )
1923{ 1960{
1924 strm << _xmlInit; 1961 strm << _xmlInit;
1925 strm << _begVisualStudioProject; 1962 strm << _begVisualStudioProject;
1926 strm << _ProjectType; 1963 strm << _ProjectType;
1927 strm << SPair( _Version1, tool.Version ); 1964 strm << SPair( _Version1, tool.Version );
1928 strm << SPair( _Name1, tool.Name ); 1965 strm << SPair( _Name1, tool.Name );
1929 strm << SPair( _ProjectGUID, tool.ProjectGUID ); 1966 strm << SPair( _ProjectGUID, tool.ProjectGUID );
1930 strm << SPair( _SccProjectName, tool.SccProjectName ); 1967 strm << SPair( _SccProjectName, tool.SccProjectName );
1931 strm << SPair( _SccLocalPath, tool.SccLocalPath ); 1968 strm << SPair( _SccLocalPath, tool.SccLocalPath );
1932 strm << ">"; 1969 strm << ">";
1933 strm << _begPlatforms; 1970 strm << _begPlatforms;
1934 strm << _begPlatform; 1971 strm << _begPlatform;
1935 strm << SPair( _Name3, tool.PlatformName ); 1972 strm << SPair( _Name3, tool.PlatformName );
diff --git a/qmake/generators/win32/msvc_objectmodel.h b/qmake/generators/win32/msvc_objectmodel.h
index 2d09280..1dca68d 100644
--- a/qmake/generators/win32/msvc_objectmodel.h
+++ b/qmake/generators/win32/msvc_objectmodel.h
@@ -369,69 +369,67 @@ enum TypeOfDebugger {
369 DbgAuto 369 DbgAuto
370}; 370};
371enum useOfATL { 371enum useOfATL {
372 useATLNotSet, 372 useATLNotSet,
373 useATLStatic, 373 useATLStatic,
374 useATLDynamic 374 useATLDynamic
375}; 375};
376enum useOfMfc { 376enum useOfMfc {
377 useMfcStdWin, 377 useMfcStdWin,
378 useMfcStatic, 378 useMfcStatic,
379 useMfcDynamic 379 useMfcDynamic
380}; 380};
381enum warningLevelOption { 381enum warningLevelOption {
382 warningLevel_0, 382 warningLevel_0,
383 warningLevel_1, 383 warningLevel_1,
384 warningLevel_2, 384 warningLevel_2,
385 warningLevel_3, 385 warningLevel_3,
386 warningLevel_4 386 warningLevel_4
387}; 387};
388 388
389class VCToolBase { 389class VCToolBase {
390protected: 390protected:
391 // Functions 391 // Functions
392 VCToolBase(){}; 392 VCToolBase(){};
393 ~VCToolBase(){}; 393 virtual ~VCToolBase(){}
394 virtual bool parseOption( const char* option ) = 0; 394 virtual bool parseOption( const char* option ) = 0;
395public: 395public:
396 bool parseOptions( QStringList& options ) { 396 void parseOptions( QStringList& options ) {
397 bool result = TRUE; 397 for ( QStringList::ConstIterator it=options.begin(); (it!=options.end()); it++ )
398 for ( QStringList::ConstIterator it=options.begin(); (it!=options.end()) && result; it++ ) 398 parseOption( (*it).latin1() );
399 result = parseOption( (*it).latin1() );
400 return result;
401 } 399 }
402}; 400};
403 401
404class VCConfiguration; 402class VCConfiguration;
405class VCProject; 403class VCProject;
406 404
407class VCCLCompilerTool : public VCToolBase 405class VCCLCompilerTool : public VCToolBase
408{ 406{
409public: 407public:
410 // Functions 408 // Functions
411 VCCLCompilerTool(); 409 VCCLCompilerTool();
412 ~VCCLCompilerTool(){}; 410 virtual ~VCCLCompilerTool(){}
413 virtual bool parseOption( const char* option ); 411 bool parseOption( const char* option );
414 412
415 // Variables 413 // Variables
416 QStringList AdditionalIncludeDirectories; 414 QStringList AdditionalIncludeDirectories;
417 QStringList AdditionalOptions; 415 QStringList AdditionalOptions;
418 QStringList AdditionalUsingDirectories; 416 QStringList AdditionalUsingDirectories;
419 QString AssemblerListingLocation; 417 QString AssemblerListingLocation;
420 asmListingOption AssemblerOutput; 418 asmListingOption AssemblerOutput;
421 basicRuntimeCheckOption BasicRuntimeChecks; 419 basicRuntimeCheckOption BasicRuntimeChecks;
422 browseInfoOption BrowseInformation; 420 browseInfoOption BrowseInformation;
423 QString BrowseInformationFile; 421 QString BrowseInformationFile;
424 triState BufferSecurityCheck; 422 triState BufferSecurityCheck;
425 callingConventionOption CallingConvention; 423 callingConventionOption CallingConvention;
426 CompileAsOptions CompileAs; 424 CompileAsOptions CompileAs;
427 compileAsManagedOptions CompileAsManaged; 425 compileAsManagedOptions CompileAsManaged;
428 triState CompileOnly; 426 triState CompileOnly;
429 debugOption DebugInformationFormat; 427 debugOption DebugInformationFormat;
430 triState DefaultCharIsUnsigned; 428 triState DefaultCharIsUnsigned;
431 triState Detect64BitPortabilityProblems; 429 triState Detect64BitPortabilityProblems;
432 triState DisableLanguageExtensions; 430 triState DisableLanguageExtensions;
433 QStringList DisableSpecificWarnings; 431 QStringList DisableSpecificWarnings;
434 triState EnableFiberSafeOptimizations; 432 triState EnableFiberSafeOptimizations;
435 triState EnableFunctionLevelLinking; 433 triState EnableFunctionLevelLinking;
436 triState EnableIntrinsicFunctions; 434 triState EnableIntrinsicFunctions;
437 triState ExceptionHandling; 435 triState ExceptionHandling;
@@ -459,50 +457,50 @@ public:
459 QString ProgramDataBaseFileName; 457 QString ProgramDataBaseFileName;
460 runtimeLibraryOption RuntimeLibrary; 458 runtimeLibraryOption RuntimeLibrary;
461 triState RuntimeTypeInfo; 459 triState RuntimeTypeInfo;
462 triState ShowIncludes; 460 triState ShowIncludes;
463 triState SmallerTypeCheck; 461 triState SmallerTypeCheck;
464 triState StringPooling; 462 triState StringPooling;
465 structMemberAlignOption StructMemberAlignment; 463 structMemberAlignOption StructMemberAlignment;
466 triState SuppressStartupBanner; 464 triState SuppressStartupBanner;
467 triState TreatWChar_tAsBuiltInType; 465 triState TreatWChar_tAsBuiltInType;
468 triState TurnOffAssemblyGeneration; 466 triState TurnOffAssemblyGeneration;
469 triState UndefineAllPreprocessorDefinitions; 467 triState UndefineAllPreprocessorDefinitions;
470 QStringList UndefinePreprocessorDefinitions; 468 QStringList UndefinePreprocessorDefinitions;
471 pchOption UsePrecompiledHeader; 469 pchOption UsePrecompiledHeader;
472 triState WarnAsError; 470 triState WarnAsError;
473 warningLevelOption WarningLevel; 471 warningLevelOption WarningLevel;
474 triState WholeProgramOptimization; 472 triState WholeProgramOptimization;
475 VCConfiguration* config; 473 VCConfiguration* config;
476}; 474};
477 475
478class VCLinkerTool : public VCToolBase 476class VCLinkerTool : public VCToolBase
479{ 477{
480public: 478public:
481 // Functions 479 // Functions
482 VCLinkerTool(); 480 VCLinkerTool();
483 ~VCLinkerTool(){}; 481 virtual ~VCLinkerTool(){}
484 virtual bool parseOption( const char* option ); 482 bool parseOption( const char* option );
485 483
486 // Variables 484 // Variables
487 QStringList AdditionalDependencies; 485 QStringList AdditionalDependencies;
488 QStringList AdditionalLibraryDirectories; 486 QStringList AdditionalLibraryDirectories;
489 QStringList AdditionalOptions; 487 QStringList AdditionalOptions;
490 QStringList AddModuleNamesToAssembly; 488 QStringList AddModuleNamesToAssembly;
491 QString BaseAddress; 489 QString BaseAddress;
492 QStringList DelayLoadDLLs; 490 QStringList DelayLoadDLLs;
493 optFoldingType EnableCOMDATFolding; 491 optFoldingType EnableCOMDATFolding;
494 QString EntryPointSymbol; 492 QString EntryPointSymbol;
495 QStringList ForceSymbolReferences; 493 QStringList ForceSymbolReferences;
496 QString FunctionOrder; 494 QString FunctionOrder;
497 triState GenerateDebugInformation; 495 triState GenerateDebugInformation;
498 triState GenerateMapFile; 496 triState GenerateMapFile;
499 long HeapCommitSize; 497 long HeapCommitSize;
500 long HeapReserveSize; 498 long HeapReserveSize;
501 triState IgnoreAllDefaultLibraries; 499 triState IgnoreAllDefaultLibraries;
502 QStringList IgnoreDefaultLibraryNames; 500 QStringList IgnoreDefaultLibraryNames;
503 triState IgnoreEmbeddedIDL; 501 triState IgnoreEmbeddedIDL;
504 triState IgnoreImportLibrary; 502 triState IgnoreImportLibrary;
505 QString ImportLibrary; 503 QString ImportLibrary;
506 addressAwarenessType LargeAddressAware; 504 addressAwarenessType LargeAddressAware;
507 triState LinkDLL; 505 triState LinkDLL;
508 linkIncrementalType LinkIncremental; 506 linkIncrementalType LinkIncremental;
@@ -524,243 +522,243 @@ public:
524 triState SetChecksum; 522 triState SetChecksum;
525 linkProgressOption ShowProgress; 523 linkProgressOption ShowProgress;
526 long StackCommitSize; 524 long StackCommitSize;
527 long StackReserveSize; 525 long StackReserveSize;
528 QString StripPrivateSymbols; // Should be list? 526 QString StripPrivateSymbols; // Should be list?
529 subSystemOption SubSystem; 527 subSystemOption SubSystem;
530 triState SupportUnloadOfDelayLoadedDLL; 528 triState SupportUnloadOfDelayLoadedDLL;
531 triState SuppressStartupBanner; 529 triState SuppressStartupBanner;
532 triState SwapRunFromCD; 530 triState SwapRunFromCD;
533 triState SwapRunFromNet; 531 triState SwapRunFromNet;
534 machineTypeOption TargetMachine; 532 machineTypeOption TargetMachine;
535 termSvrAwarenessType TerminalServerAware; 533 termSvrAwarenessType TerminalServerAware;
536 triState TurnOffAssemblyGeneration; 534 triState TurnOffAssemblyGeneration;
537 QString TypeLibraryFile; 535 QString TypeLibraryFile;
538 long TypeLibraryResourceID; 536 long TypeLibraryResourceID;
539 QString Version; 537 QString Version;
540 VCConfiguration* config; 538 VCConfiguration* config;
541}; 539};
542 540
543class VCMIDLTool : public VCToolBase 541class VCMIDLTool : public VCToolBase
544{ 542{
545public: 543public:
546 // Functions 544 // Functions
547 VCMIDLTool(); 545 VCMIDLTool();
548 ~VCMIDLTool(){}; 546 virtual ~VCMIDLTool(){}
549 virtual bool parseOption( const char* option ); 547 bool parseOption( const char* option );
550 548
551 // Variables 549 // Variables
552 QStringList AdditionalIncludeDirectories; 550 QStringList AdditionalIncludeDirectories;
553 QStringList AdditionalOptions; 551 QStringList AdditionalOptions;
554 QStringList CPreprocessOptions; 552 QStringList CPreprocessOptions;
555 midlCharOption DefaultCharType; 553 midlCharOption DefaultCharType;
556 QString DLLDataFileName; // Should be list? 554 QString DLLDataFileName; // Should be list?
557 midlErrorCheckOption EnableErrorChecks; 555 midlErrorCheckOption EnableErrorChecks;
558 triState ErrorCheckAllocations; 556 triState ErrorCheckAllocations;
559 triState ErrorCheckBounds; 557 triState ErrorCheckBounds;
560 triState ErrorCheckEnumRange; 558 triState ErrorCheckEnumRange;
561 triState ErrorCheckRefPointers; 559 triState ErrorCheckRefPointers;
562 triState ErrorCheckStubData; 560 triState ErrorCheckStubData;
563 QStringList FullIncludePath; 561 QStringList FullIncludePath;
564 triState GenerateStublessProxies; 562 triState GenerateStublessProxies;
565 triState GenerateTypeLibrary; 563 triState GenerateTypeLibrary;
566 QString HeaderFileName; 564 QString HeaderFileName;
567 triState IgnoreStandardIncludePath; 565 triState IgnoreStandardIncludePath;
568 QString InterfaceIdentifierFileName; 566 QString InterfaceIdentifierFileName;
569 triState MkTypLibCompatible; 567 triState MkTypLibCompatible;
570 QString OutputDirectory; 568 QString OutputDirectory;
571 QStringList PreprocessorDefinitions; 569 QStringList PreprocessorDefinitions;
572 QString ProxyFileName; 570 QString ProxyFileName;
573 QString RedirectOutputAndErrors; 571 QString RedirectOutputAndErrors;
574 midlStructMemberAlignOption StructMemberAlignment; 572 midlStructMemberAlignOption StructMemberAlignment;
575 triState SuppressStartupBanner; 573 triState SuppressStartupBanner;
576 midlTargetEnvironment TargetEnvironment; 574 midlTargetEnvironment TargetEnvironment;
577 QString TypeLibraryName; 575 QString TypeLibraryName;
578 QStringList UndefinePreprocessorDefinitions; 576 QStringList UndefinePreprocessorDefinitions;
579 triState ValidateParameters; 577 triState ValidateParameters;
580 triState WarnAsError; 578 triState WarnAsError;
581 midlWarningLevelOption WarningLevel; 579 midlWarningLevelOption WarningLevel;
582 VCConfiguration* config; 580 VCConfiguration* config;
583}; 581};
584 582
585class VCLibrarianTool : public VCToolBase 583class VCLibrarianTool : public VCToolBase
586{ 584{
587public: 585public:
588 // Functions 586 // Functions
589 VCLibrarianTool(); 587 VCLibrarianTool();
590 ~VCLibrarianTool(){}; 588 virtual ~VCLibrarianTool(){}
591 virtual bool parseOption( const char* option ){ return FALSE; }; 589 bool parseOption( const char* ){ return FALSE; };
592 590
593 // Variables 591 // Variables
594 QStringList AdditionalDependencies; 592 QStringList AdditionalDependencies;
595 QStringList AdditionalLibraryDirectories; 593 QStringList AdditionalLibraryDirectories;
596 QStringList AdditionalOptions; 594 QStringList AdditionalOptions;
597 QStringList ExportNamedFunctions; 595 QStringList ExportNamedFunctions;
598 QStringList ForceSymbolReferences; 596 QStringList ForceSymbolReferences;
599 triState IgnoreAllDefaultLibraries; 597 triState IgnoreAllDefaultLibraries;
600 QStringList IgnoreDefaultLibraryNames; 598 QStringList IgnoreDefaultLibraryNames;
601 QString ModuleDefinitionFile; 599 QString ModuleDefinitionFile;
602 QString OutputFile; 600 QString OutputFile;
603 triState SuppressStartupBanner; 601 triState SuppressStartupBanner;
604}; 602};
605 603
606class VCCustomBuildTool : public VCToolBase 604class VCCustomBuildTool : public VCToolBase
607{ 605{
608public: 606public:
609 // Functions 607 // Functions
610 VCCustomBuildTool(); 608 VCCustomBuildTool();
611 ~VCCustomBuildTool(){}; 609 virtual ~VCCustomBuildTool(){}
612 virtual bool parseOption( const char* option ){ return FALSE; }; 610 bool parseOption( const char* ){ return FALSE; };
613 611
614 // Variables 612 // Variables
615 QStringList AdditionalDependencies; 613 QStringList AdditionalDependencies;
616 QString CommandLine; 614 QString CommandLine;
617 QString Description; 615 QString Description;
618 QString Outputs; 616 QString Outputs;
619 QString ToolName; 617 QString ToolName;
620 QString ToolPath; 618 QString ToolPath;
621}; 619};
622 620
623class VCResourceCompilerTool : public VCToolBase 621class VCResourceCompilerTool : public VCToolBase
624{ 622{
625public: 623public:
626 // Functions 624 // Functions
627 VCResourceCompilerTool(); 625 VCResourceCompilerTool();
628 ~VCResourceCompilerTool(){}; 626 virtual ~VCResourceCompilerTool(){}
629 virtual bool parseOption( const char* option ){ return FALSE; }; 627 bool parseOption( const char* ){ return FALSE; };
630 628
631 // Variables 629 // Variables
632 QStringList AdditionalIncludeDirectories; 630 QStringList AdditionalIncludeDirectories;
633 QStringList AdditionalOptions; 631 QStringList AdditionalOptions;
634 enumResourceLangID Culture; 632 enumResourceLangID Culture;
635 QStringList FullIncludePath; 633 QStringList FullIncludePath;
636 triState IgnoreStandardIncludePath; 634 triState IgnoreStandardIncludePath;
637 QStringList PreprocessorDefinitions; 635 QStringList PreprocessorDefinitions;
638 QString ResourceOutputFileName; 636 QString ResourceOutputFileName;
639 linkProgressOption ShowProgress; 637 linkProgressOption ShowProgress;
640 QString ToolPath; 638 QString ToolPath;
641}; 639};
642 640
643class VCEventTool : public VCToolBase 641class VCEventTool : public VCToolBase
644{ 642{
645protected: 643protected:
646 // Functions 644 // Functions
647 VCEventTool() : ExcludedFromBuild( unset ){}; 645 VCEventTool() : ExcludedFromBuild( unset ){};
648 ~VCEventTool(){}; 646 virtual ~VCEventTool(){}
649 virtual bool parseOption( const char* option ){ return FALSE; }; 647 bool parseOption( const char* ){ return FALSE; };
650 648
651public: 649public:
652 // Variables 650 // Variables
653 QString CommandLine; 651 QString CommandLine;
654 QString Description; 652 QString Description;
655 triState ExcludedFromBuild; 653 triState ExcludedFromBuild;
656 QString ToolName; 654 QString ToolName;
657 QString ToolPath; 655 QString ToolPath;
658}; 656};
659 657
660class VCPostBuildEventTool : public VCEventTool 658class VCPostBuildEventTool : public VCEventTool
661{ 659{
662public: 660public:
663 VCPostBuildEventTool(); 661 VCPostBuildEventTool();
664 ~VCPostBuildEventTool(){}; 662 ~VCPostBuildEventTool(){}
665}; 663};
666 664
667class VCPreBuildEventTool : public VCEventTool 665class VCPreBuildEventTool : public VCEventTool
668{ 666{
669public: 667public:
670 VCPreBuildEventTool(); 668 VCPreBuildEventTool();
671 ~VCPreBuildEventTool(){}; 669 ~VCPreBuildEventTool(){}
672}; 670};
673 671
674class VCPreLinkEventTool : public VCEventTool 672class VCPreLinkEventTool : public VCEventTool
675{ 673{
676public: 674public:
677 VCPreLinkEventTool(); 675 VCPreLinkEventTool();
678 ~VCPreLinkEventTool(){}; 676 ~VCPreLinkEventTool(){}
679}; 677};
680 678
681class VCConfiguration 679class VCConfiguration
682{ 680{
683public: 681public:
684 // Functions 682 // Functions
685 VCConfiguration(); 683 VCConfiguration();
686 ~VCConfiguration(){}; 684 ~VCConfiguration(){}
687 685
688 // Variables 686 // Variables
689 triState ATLMinimizesCRunTimeLibraryUsage; 687 triState ATLMinimizesCRunTimeLibraryUsage;
690 triState BuildBrowserInformation; 688 triState BuildBrowserInformation;
691 charSet CharacterSet; 689 charSet CharacterSet;
692 ConfigurationTypesConfigurationType; 690 ConfigurationTypesConfigurationType;
693 QString DeleteExtensionsOnClean; 691 QString DeleteExtensionsOnClean;
694 QString ImportLibrary; 692 QString ImportLibrary;
695 QString IntermediateDirectory; 693 QString IntermediateDirectory;
696 QString Name; 694 QString Name;
697 QString OutputDirectory; 695 QString OutputDirectory;
698 QString PrimaryOutput; 696 QString PrimaryOutput;
699 QString ProgramDatabase; 697 QString ProgramDatabase;
700 triState RegisterOutput; 698 triState RegisterOutput;
701 useOfATL UseOfATL; 699 useOfATL UseOfATL;
702 useOfMfc UseOfMfc; 700 useOfMfc UseOfMfc;
703 triState WholeProgramOptimization; 701 triState WholeProgramOptimization;
704 702
705 // XML sub-parts 703 // XML sub-parts
706 VCCLCompilerTool compiler; 704 VCCLCompilerTool compiler;
707 VCLinkerTool linker; 705 VCLinkerTool linker;
708 VCLibrarianTool librarian; 706 VCLibrarianTool librarian;
709 VCCustomBuildTool custom; 707 VCCustomBuildTool custom;
710 VCMIDLTool idl; 708 VCMIDLTool idl;
711 VCPostBuildEventTool postBuild; 709 VCPostBuildEventTool postBuild;
712 VCPreBuildEventTool preBuild; 710 VCPreBuildEventTool preBuild;
713 VCPreLinkEventTool preLink; 711 VCPreLinkEventTool preLink;
714 VCResourceCompilerTool resource; 712 VCResourceCompilerTool resource;
715}; 713};
716 714
717class VcprojGenerator; 715class VcprojGenerator;
718class VCFilter 716class VCFilter
719{ 717{
720public: 718public:
721 // Functions 719 // Functions
722 VCFilter(); 720 VCFilter();
723 ~VCFilter(){}; 721 ~VCFilter(){}
724 void generateMOC( QTextStream &strm, QString str ) const; 722 void generateMOC( QTextStream &strm, QString str ) const;
725 void generateUIC( QTextStream &strm, const QString& str ) const; 723 void generateUIC( QTextStream &strm, const QString& str ) const;
726 724
727 // Variables 725 // Variables
728 QString Name; 726 QString Name;
729 QString Filter; 727 QString Filter;
730 triState ParseFiles; 728 triState ParseFiles;
731 QStringList Files; 729 QStringList Files;
732 VcprojGenerator*Project; 730 VcprojGenerator*Project;
733 VCConfiguration*Config; 731 VCConfiguration*Config;
734 customBuildCheckCustomBuild; 732 customBuildCheckCustomBuild;
735}; 733};
736 734
737class VCProject 735class VCProject
738{ 736{
739public: 737public:
740 // Functions 738 // Functions
741 VCProject(); 739 VCProject();
742 ~VCProject(){}; 740 ~VCProject(){}
743 741
744 // Variables 742 // Variables
745 QString Name; 743 QString Name;
746 QString Version; 744 QString Version;
747 QString ProjectGUID; 745 QString ProjectGUID;
748 QString SccProjectName; 746 QString SccProjectName;
749 QString SccLocalPath; 747 QString SccLocalPath;
750 QString PlatformName; 748 QString PlatformName;
751 749
752 // XML sub-parts 750 // XML sub-parts
753 VCConfigurationConfiguration; 751 VCConfigurationConfiguration;
754 VCFilter SourceFiles; 752 VCFilter SourceFiles;
755 VCFilter HeaderFiles; 753 VCFilter HeaderFiles;
756 VCFilter MOCFiles; 754 VCFilter MOCFiles;
757 VCFilter UICFiles; 755 VCFilter UICFiles;
758 VCFilter FormFiles; 756 VCFilter FormFiles;
759 VCFilter TranslationFiles; 757 VCFilter TranslationFiles;
760 VCFilter LexYaccFiles; 758 VCFilter LexYaccFiles;
761 VCFilter ResourceFiles; 759 VCFilter ResourceFiles;
762}; 760};
763 761
764QTextStream &operator<<( QTextStream &, const VCCLCompilerTool & ); 762QTextStream &operator<<( QTextStream &, const VCCLCompilerTool & );
765QTextStream &operator<<( QTextStream &, const VCLinkerTool & ); 763QTextStream &operator<<( QTextStream &, const VCLinkerTool & );
766QTextStream &operator<<( QTextStream &, const VCMIDLTool & ); 764QTextStream &operator<<( QTextStream &, const VCMIDLTool & );
diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp
index a2bb6e9..d2cbc31 100644
--- a/qmake/generators/win32/msvc_vcproj.cpp
+++ b/qmake/generators/win32/msvc_vcproj.cpp
@@ -1,208 +1,324 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of VcprojGenerator class. 4** Definition of VcprojGenerator 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
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this 21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software. 23** with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#include "msvc_vcproj.h" 38#include "msvc_vcproj.h"
39#include "option.h" 39#include "option.h"
40#include <qdir.h> 40#include <qdir.h>
41#include <stdlib.h>
42#include <qregexp.h> 41#include <qregexp.h>
42#include <qdict.h>
43#include <quuid.h>
44#include <stdlib.h>
43 45
44#if defined(Q_OS_WIN32) 46#if defined(Q_OS_WIN32)
45#include <objbase.h> 47#include <objbase.h>
48#ifndef GUID_DEFINED
49#define GUID_DEFINED
50typedef struct _GUID
51{
52 ulong Data1;
53 ushort Data2;
54 ushort Data3;
55 uchar Data4[8];
56} GUID;
57#endif
46#endif 58#endif
47 59
60// Flatfile Tags ----------------------------------------------------
61 const char* _snlHeader = "Microsoft Visual Studio Solution File, Format Version 7.00";
62 // The following UUID _may_ change for later servicepacks...
63 // If so we need to search through the registry at
64 // HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.0\Projects
65 // to find the subkey that contains a "PossibleProjectExtension"
66 // containing "vcproj"...
67 // Use the hardcoded value for now so projects generated on other
68 // platforms are actually usable.
69const char* _snlMSVCvcprojGUID = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}";
70 const char* _snlProjectBeg= "\nProject(\"";
71 const char* _snlProjectMid= "\") = ";
72 const char* _snlProjectEnd= "\nEndProject";
73 const char* _snlGlobalBeg= "\nGlobal";
74 const char* _snlGlobalEnd= "\nEndGlobal";
75 const char* _snlSolutionConf= "\n\tGlobalSection(SolutionConfiguration) = preSolution"
76 "\n\t\tConfigName.0 = Release"
77 "\n\tEndGlobalSection";
78 const char* _snlProjDepBeg= "\n\tGlobalSection(ProjectDependencies) = postSolution";
79 const char* _snlProjDepEnd= "\n\tEndGlobalSection";
80 const char* _snlProjConfBeg= "\n\tGlobalSection(ProjectConfiguration) = postSolution";
81 const char* _snlProjConfTag1= ".Release.ActiveCfg = Release|Win32";
82 const char* _snlProjConfTag2= ".Release.Build.0 = Release|Win32";
83 const char* _snlProjConfEnd= "\n\tEndGlobalSection";
84 const char* _snlExtSections= "\n\tGlobalSection(ExtensibilityGlobals) = postSolution"
85 "\n\tEndGlobalSection"
86 "\n\tGlobalSection(ExtensibilityAddIns) = postSolution"
87 "\n\tEndGlobalSection";
88// ------------------------------------------------------------------
89
48VcprojGenerator::VcprojGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE) 90VcprojGenerator::VcprojGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE)
49{ 91{
50} 92}
51 93
52/* \internal 94/* \internal
53 Generates a project file for the given profile. 95 Generates a project file for the given profile.
54 Options are either a Visual Studio projectfiles, or 96 Options are either a Visual Studio projectfiles, or
55 recursive projectfiles.. Maybe we can make .sln files 97 solutionfiles by parsing recursive projectdirectories.
56 someday?
57*/ 98*/
58bool VcprojGenerator::writeMakefile(QTextStream &t) 99bool VcprojGenerator::writeMakefile(QTextStream &t)
59{ 100{
60 // Check if all requirements are fullfilled 101 // Check if all requirements are fullfilled
61 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) { 102 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {
62 fprintf(stderr, "Project file not generated because all requirements not met:\n\t%s\n", 103 fprintf(stderr, "Project file not generated because all requirements not met:\n\t%s\n",
63 var("QMAKE_FAILED_REQUIREMENTS").latin1()); 104 var("QMAKE_FAILED_REQUIREMENTS").latin1());
64 return TRUE; 105 return TRUE;
65 } 106 }
66 107
67 // Generate full project file 108 // Generate project file
68 if(project->first("TEMPLATE") == "vcapp" || 109 if(project->first("TEMPLATE") == "vcapp" ||
69 project->first("TEMPLATE") == "vclib") { 110 project->first("TEMPLATE") == "vclib") {
70 debug_msg(1, "Generator: MSVC.NET: Writing project file" ); 111 debug_msg(1, "Generator: MSVC.NET: Writing project file" );
71 t << vcProject; 112 t << vcProject;
72 return TRUE; 113 return TRUE;
73 } else if(project->first("TEMPLATE") == "vcsubdirs") { // Generate recursive project 114 }
115 // Generate solution file
116 else if(project->first("TEMPLATE") == "vcsubdirs") {
74 debug_msg(1, "Generator: MSVC.NET: Writing solution file" ); 117 debug_msg(1, "Generator: MSVC.NET: Writing solution file" );
75 writeSubDirs(t); 118 writeSubDirs(t);
76 return TRUE; 119 return TRUE;
77 } 120 }
78 return FALSE; 121 return FALSE;
79 122
80} 123}
81 124
82struct VcsolutionDepend { 125struct VcsolutionDepend {
126 QString uuid;
83 QString vcprojFile, orig_target, target; 127 QString vcprojFile, orig_target, target;
128 ::target targetType;
84 QStringList dependencies; 129 QStringList dependencies;
85}; 130};
86 131
132QUuid VcprojGenerator::increaseUUID( const QUuid &id )
133{
134 QUuid result( id );
135 Q_LONG dataFirst = (result.data4[0] << 24) +
136 (result.data4[1] << 16) +
137 (result.data4[2] << 8) +
138 result.data4[3];
139 Q_LONG dataLast = (result.data4[4] << 24) +
140 (result.data4[5] << 16) +
141 (result.data4[6] << 8) +
142 result.data4[7];
143
144 if ( !(dataLast++) )
145 dataFirst++;
146
147 result.data4[0] = uchar((dataFirst >> 24) & 0xff);
148 result.data4[1] = uchar((dataFirst >> 16) & 0xff);
149 result.data4[2] = uchar((dataFirst >> 8) & 0xff);
150 result.data4[3] = uchar( dataFirst & 0xff);
151 result.data4[4] = uchar((dataLast >> 24) & 0xff);
152 result.data4[5] = uchar((dataLast >> 16) & 0xff);
153 result.data4[6] = uchar((dataLast >> 8) & 0xff);
154 result.data4[7] = uchar( dataLast & 0xff);
155 return result;
156}
157
87void VcprojGenerator::writeSubDirs(QTextStream &t) 158void VcprojGenerator::writeSubDirs(QTextStream &t)
88{ 159{
89 if(project->first("TEMPLATE") == "subdirs") { 160 if(project->first("TEMPLATE") == "subdirs") {
90 writeHeader(t); 161 writeHeader(t);
91 Win32MakefileGenerator::writeSubDirs(t); 162 Win32MakefileGenerator::writeSubDirs(t);
92 return; 163 return;
93 } 164 }
94 165
95 QPtrList<VcsolutionDepend> solution_depends; 166 t << _snlHeader;
96 solution_depends.setAutoDelete(TRUE); 167 QUuid solutionGUID;
168#if defined(Q_WS_WIN32)
169 GUID guid;
170 HRESULT h = CoCreateGuid( &guid );
171 if ( h == S_OK )
172 solutionGUID = QUuid( guid );
173#else
174 // Qt doesn't support GUID on other platforms yet,
175 // so we use the all-zero uuid, and increase that.
176#endif
177
178
179 QDict<VcsolutionDepend> solution_depends;
180 QPtrList<VcsolutionDepend> solution_cleanup;
181 solution_cleanup.setAutoDelete(TRUE);
97 QStringList subdirs = project->variables()["SUBDIRS"]; 182 QStringList subdirs = project->variables()["SUBDIRS"];
98 QString oldpwd = QDir::currentDirPath(); 183 QString oldpwd = QDir::currentDirPath();
99 for(QStringList::Iterator it = subdirs.begin(); it != subdirs.end(); ++it) { 184 for(QStringList::Iterator it = subdirs.begin(); it != subdirs.end(); ++it) {
100 QFileInfo fi(Option::fixPathToLocalOS((*it), TRUE)); 185 QFileInfo fi(Option::fixPathToLocalOS((*it), TRUE));
101 if(fi.exists()) { 186 if(fi.exists()) {
102 if(fi.isDir()) { 187 if(fi.isDir()) {
103 QString profile = (*it); 188 QString profile = (*it);
104 if(!profile.endsWith(Option::dir_sep)) 189 if(!profile.endsWith(Option::dir_sep))
105 profile += Option::dir_sep; 190 profile += Option::dir_sep;
106 profile += fi.baseName() + ".pro"; 191 profile += fi.baseName() + ".pro";
107 subdirs.append(profile); 192 subdirs.append(profile);
108 } else { 193 } else {
109 QMakeProject tmp_proj; 194 QMakeProject tmp_proj;
110 QString dir = fi.dirPath(), fn = fi.fileName(); 195 QString dir = fi.dirPath(), fn = fi.fileName();
111 if(!dir.isEmpty()) { 196 if(!dir.isEmpty()) {
112 if(!QDir::setCurrent(dir)) 197 if(!QDir::setCurrent(dir))
113 fprintf(stderr, "Cannot find directory: %s\n", dir.latin1()); 198 fprintf(stderr, "Cannot find directory: %s\n", dir.latin1());
114 } 199 }
115 if(tmp_proj.read(fn, oldpwd)) { 200 if(tmp_proj.read(fn, oldpwd)) {
116 if(tmp_proj.first("TEMPLATE") == "vcsubdirs") { 201 if(tmp_proj.first("TEMPLATE") == "vcsubdirs") {
117 QStringList tmp_subdirs = fileFixify(tmp_proj.variables()["SUBDIRS"]); 202 QStringList tmp_subdirs = fileFixify(tmp_proj.variables()["SUBDIRS"]);
118 subdirs += tmp_subdirs; 203 subdirs += tmp_subdirs;
119 } else if(tmp_proj.first("TEMPLATE") == "vcapp" || 204 } else if(tmp_proj.first("TEMPLATE") == "vcapp" || tmp_proj.first("TEMPLATE") == "vclib") {
120 tmp_proj.first("TEMPLATE") == "vclib") { 205 // Initialize a 'fake' project to get the correct variables
121 QString vcproj = fi.baseName() + project->first("VCPROJ_EXTENSION"); 206 // and to be able to extract all the dependencies
122 if(QFile::exists(vcproj) || 1) { 207 VcprojGenerator tmp_vcproj(&tmp_proj);
123 VcprojGenerator tmp_dsp(&tmp_proj); 208 tmp_vcproj.setNoIO(TRUE);
124 tmp_dsp.setNoIO(TRUE); 209 tmp_vcproj.init();
125 tmp_dsp.init();
126 if(Option::debug_level) { 210 if(Option::debug_level) {
127 QMap<QString, QStringList> &vars = tmp_proj.variables(); 211 QMap<QString, QStringList> &vars = tmp_proj.variables();
128 for(QMap<QString, QStringList>::Iterator it = vars.begin(); 212 for(QMap<QString, QStringList>::Iterator it = vars.begin();
129 it != vars.end(); ++it) { 213 it != vars.end(); ++it) {
130 if(it.key().left(1) != "." && !it.data().isEmpty()) 214 if(it.key().left(1) != "." && !it.data().isEmpty())
131 debug_msg(1, "%s: %s === %s", fn.latin1(), it.key().latin1(), 215 debug_msg(1, "%s: %s === %s", fn.latin1(), it.key().latin1(),
132 it.data().join(" :: ").latin1()); 216 it.data().join(" :: ").latin1());
133 } 217 }
134 } 218 }
219
220 // We assume project filename is [QMAKE_ORIG_TARGET].vcproj
221 QString vcproj = fixFilename(tmp_vcproj.project->first("QMAKE_ORIG_TARGET")) + project->first("VCPROJ_EXTENSION");
222
223 // If file doesn't exsist, then maybe the users configuration
224 // doesn't allow it to be created. Skip to next...
225 if(!QFile::exists(QDir::currentDirPath() + Option::dir_sep + vcproj)) {
226 qDebug( "Ignored (not found) '%s'", QString(QDir::currentDirPath() + Option::dir_sep + vcproj).latin1() );
227 goto nextfile; // # Dirty!
228 }
229
135 VcsolutionDepend *newDep = new VcsolutionDepend; 230 VcsolutionDepend *newDep = new VcsolutionDepend;
136 newDep->vcprojFile = fileFixify(vcproj); 231 newDep->vcprojFile = fileFixify(vcproj);
137 newDep->orig_target = tmp_proj.first("QMAKE_ORIG_TARGET"); 232 newDep->orig_target = tmp_proj.first("QMAKE_ORIG_TARGET");
138 newDep->target = tmp_proj.first("TARGET").section(Option::dir_sep, -1); 233 newDep->target = tmp_proj.first("TARGET").section(Option::dir_sep, -1);
234 newDep->targetType = tmp_vcproj.projectTarget;
235 {
236 static QUuid uuid = solutionGUID;
237 uuid = increaseUUID( uuid );
238 newDep->uuid = uuid.toString().upper();
239 }
139 if(newDep->target.endsWith(".dll")) 240 if(newDep->target.endsWith(".dll"))
140 newDep->target = newDep->target.left(newDep->target.length()-3) + "lib"; 241 newDep->target = newDep->target.left(newDep->target.length()-3) + "lib";
141 if(!tmp_proj.isEmpty("FORMS")) 242 if(!tmp_proj.isEmpty("FORMS"))
142 newDep->dependencies << "uic.exe"; 243 newDep->dependencies << "uic.exe";
143 { 244 {
144 QStringList where("QMAKE_LIBS"); 245 QStringList where("QMAKE_LIBS");
145 if(!tmp_proj.isEmpty("QMAKE_INTERNAL_PRL_LIBS")) 246 if(!tmp_proj.isEmpty("QMAKE_INTERNAL_PRL_LIBS"))
146 where = tmp_proj.variables()["QMAKE_INTERNAL_PRL_LIBS"]; 247 where = tmp_proj.variables()["QMAKE_INTERNAL_PRL_LIBS"];
147 for(QStringList::iterator wit = where.begin(); 248 for(QStringList::iterator wit = where.begin();
148 wit != where.end(); ++wit) { 249 wit != where.end(); ++wit) {
149 QStringList &l = tmp_proj.variables()[(*wit)]; 250 QStringList &l = tmp_proj.variables()[(*wit)];
150 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 251 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
151 QString opt = (*it); 252 QString opt = (*it);
152 if(!opt.startsWith("/")) //Not a switch 253 if(!opt.startsWith("/")) //Not a switch
153 newDep->dependencies << opt.section(Option::dir_sep, -1); 254 newDep->dependencies << opt.section(Option::dir_sep, -1);
154 } 255 }
155 } 256 }
156 } 257 }
157 solution_depends.append(newDep); 258 solution_cleanup.append(newDep);
259 solution_depends.insert(newDep->target, newDep);
260 {
261 QRegExp libVersion("[0-9]{3,3}\\.lib$");
262 if(libVersion.search(newDep->target) != -1)
263 solution_depends.insert(newDep->target.left(newDep->target.length() -
264 libVersion.matchedLength()) + ".lib", newDep);
158 } 265 }
266 t << _snlProjectBeg << _snlMSVCvcprojGUID << _snlProjectMid
267 << "\"" << newDep->orig_target << "\", \"" << newDep->vcprojFile
268 << "\", \"" << newDep->uuid << "\"";
269 t << _snlProjectEnd;
159 } 270 }
160 } 271 }
272nextfile:
161 QDir::setCurrent(oldpwd); 273 QDir::setCurrent(oldpwd);
162 } 274 }
163 } 275 }
164 } 276 }
165 277 t << _snlGlobalBeg;
278 t << _snlSolutionConf;
279 t << _snlProjDepBeg;
280 for(solution_cleanup.first(); solution_cleanup.current(); solution_cleanup.next()) {
281 int cnt = 0;
282 for(QStringList::iterator dit = solution_cleanup.current()->dependencies.begin();
283 dit != solution_cleanup.current()->dependencies.end();
284 ++dit) {
166 VcsolutionDepend *vc; 285 VcsolutionDepend *vc;
167 QMap<QString, int> uuids; 286 if((vc=solution_depends[*dit])) {
168 QRegExp libVersion("[0-9]{3,3}\\.lib$"); 287 if(solution_cleanup.current()->targetType != StaticLib || vc->targetType == Application)
169 for(vc = solution_depends.first(); vc; vc = solution_depends.next()) { 288 t << "\n\t\t" << solution_cleanup.current()->uuid << "." << cnt++ << " = " << vc->uuid;
170 static int uuid = 666;
171 uuids.insert(vc->target, uuid);
172 if(libVersion.match(vc->target) != -1)
173 uuids.insert(vc->target.left(vc->target.length() - libVersion.matchedLength()) + ".lib",
174 uuid);
175 t << "\"" << vc->orig_target << "\" \"" << vc->vcprojFile << "\" { " << uuid << " }" << endl;
176 uuid++;
177 } 289 }
178 for(vc = solution_depends.first(); vc; vc = solution_depends.next()) {
179 int uuid = uuids[vc->target], cnt = 0;
180 for(QStringList::iterator dit = vc->dependencies.begin(); dit != vc->dependencies.end(); ++dit) {
181 if(uuids.contains((*dit)))
182 t << uuid << "." << cnt++ << " = " << uuids[(*dit)] << endl;
183 } 290 }
184 } 291 }
292 t << _snlProjDepEnd;
293 t << _snlProjConfBeg;
294 for(solution_cleanup.first(); solution_cleanup.current(); solution_cleanup.next()) {
295 t << "\n\t\t" << solution_cleanup.current()->uuid << _snlProjConfTag1;
296 t << "\n\t\t" << solution_cleanup.current()->uuid << _snlProjConfTag2;
297 }
298 t << _snlProjConfEnd;
299 t << _snlExtSections;
300 t << _snlGlobalEnd;
185} 301}
186 302
187// ------------------------------------------------------------------------------------------------ 303// ------------------------------------------------------------------------------------------------
188// ------------------------------------------------------------------------------------------------ 304// ------------------------------------------------------------------------------------------------
189 305
190void VcprojGenerator::init() 306void VcprojGenerator::init()
191{ 307{
192 if( init_flag ) 308 if( init_flag )
193 return; 309 return;
194 if(project->first("TEMPLATE") == "vcsubdirs") { //too much work for subdirs 310 if(project->first("TEMPLATE") == "vcsubdirs") { //too much work for subdirs
195 init_flag = TRUE; 311 init_flag = TRUE;
196 return; 312 return;
197 } 313 }
198 314
199 debug_msg(1, "Generator: MSVC.NET: Initializing variables" ); 315 debug_msg(1, "Generator: MSVC.NET: Initializing variables" );
200 316
201/* 317/*
202 // Once to be nice and clean code... 318 // Once to be nice and clean code...
203 // Wouldn't life be great? 319 // Wouldn't life be great?
204 320
205 // Are we building Qt? 321 // Are we building Qt?
206 bool is_qt = 322 bool is_qt =
207 ( project->first("TARGET") == "qt"QTDLL_POSTFIX || 323 ( project->first("TARGET") == "qt"QTDLL_POSTFIX ||
208 project->first("TARGET") == "qt-mt"QTDLL_POSTFIX ); 324 project->first("TARGET") == "qt-mt"QTDLL_POSTFIX );
@@ -285,219 +401,238 @@ void VcprojGenerator::initConfiguration()
285 // Initialize XML sub elements 401 // Initialize XML sub elements
286 // - Do this first since main configuration elements may need 402 // - Do this first since main configuration elements may need
287 // - to know of certain compiler/linker options 403 // - to know of certain compiler/linker options
288 initCompilerTool(); 404 initCompilerTool();
289 if ( projectTarget == StaticLib ) 405 if ( projectTarget == StaticLib )
290 initLibrarianTool(); 406 initLibrarianTool();
291 else 407 else
292 initLinkerTool(); 408 initLinkerTool();
293 initIDLTool(); 409 initIDLTool();
294 410
295 // Own elements ----------------------------- 411 // Own elements -----------------------------
296 QString temp = project->first("BuildBrowserInformation"); 412 QString temp = project->first("BuildBrowserInformation");
297 switch ( projectTarget ) { 413 switch ( projectTarget ) {
298 case SharedLib: 414 case SharedLib:
299 vcProject.Configuration.ConfigurationType = typeDynamicLibrary; 415 vcProject.Configuration.ConfigurationType = typeDynamicLibrary;
300 break; 416 break;
301 case StaticLib: 417 case StaticLib:
302 vcProject.Configuration.ConfigurationType = typeStaticLibrary; 418 vcProject.Configuration.ConfigurationType = typeStaticLibrary;
303 break; 419 break;
304 case Application: 420 case Application:
305 default: 421 default:
306 vcProject.Configuration.ConfigurationType = typeApplication; 422 vcProject.Configuration.ConfigurationType = typeApplication;
307 break; 423 break;
308 } 424 }
309 vcProject.Configuration.Name = ( project->isActiveConfig( "release" ) ? "Release|" : "Debug|" ); 425 vcProject.Configuration.Name = ( project->isActiveConfig( "debug" ) ? "Debug|" : "Release|" );
310 vcProject.Configuration.Name += ( vcProject.Configuration.idl.TargetEnvironment == midlTargetWin64 ? "Win64" : "Win32" ); 426 vcProject.Configuration.Name += ( vcProject.Configuration.idl.TargetEnvironment == midlTargetWin64 ? "Win64" : "Win32" );
311 vcProject.Configuration.ATLMinimizesCRunTimeLibraryUsage = ( project->first("ATLMinimizesCRunTimeLibraryUsage").isEmpty() ? _False : _True ); 427 vcProject.Configuration.ATLMinimizesCRunTimeLibraryUsage = ( project->first("ATLMinimizesCRunTimeLibraryUsage").isEmpty() ? _False : _True );
312 vcProject.Configuration.BuildBrowserInformation = triState( temp.isEmpty() ? unset : temp.toShort() ); 428 vcProject.Configuration.BuildBrowserInformation = triState( temp.isEmpty() ? (short)unset : temp.toShort() );
313 temp = project->first("CharacterSet"); 429 temp = project->first("CharacterSet");
314 vcProject.Configuration.CharacterSet = charSet( temp.isEmpty() ? charSetNotSet : temp.toShort() ); 430 vcProject.Configuration.CharacterSet = charSet( temp.isEmpty() ? (short)charSetNotSet : temp.toShort() );
315 vcProject.Configuration.DeleteExtensionsOnClean = project->first("DeleteExtensionsOnClean"); 431 vcProject.Configuration.DeleteExtensionsOnClean = project->first("DeleteExtensionsOnClean");
316 vcProject.Configuration.ImportLibrary = vcProject.Configuration.linker.ImportLibrary; 432 vcProject.Configuration.ImportLibrary = vcProject.Configuration.linker.ImportLibrary;
317 vcProject.Configuration.IntermediateDirectory = project->first("OBJECTS_DIR"); 433 vcProject.Configuration.IntermediateDirectory = project->first("OBJECTS_DIR");
318// temp = (projectTarget == StaticLib) ? project->first("DESTDIR"):project->first("DLLDESTDIR"); 434// temp = (projectTarget == StaticLib) ? project->first("DESTDIR"):project->first("DLLDESTDIR");
319 vcProject.Configuration.OutputDirectory = "."; //( temp.isEmpty() ? QString(".") : temp ); 435 vcProject.Configuration.OutputDirectory = "."; //( temp.isEmpty() ? QString(".") : temp );
320 vcProject.Configuration.PrimaryOutput = project->first("PrimaryOutput"); 436 vcProject.Configuration.PrimaryOutput = project->first("PrimaryOutput");
321 vcProject.Configuration.WholeProgramOptimization = vcProject.Configuration.compiler.WholeProgramOptimization; 437 vcProject.Configuration.WholeProgramOptimization = vcProject.Configuration.compiler.WholeProgramOptimization;
322 temp = project->first("UseOfATL"); 438 temp = project->first("UseOfATL");
323 if ( !temp.isEmpty() ) 439 if ( !temp.isEmpty() )
324 vcProject.Configuration.UseOfATL = useOfATL( temp.toShort() ); 440 vcProject.Configuration.UseOfATL = useOfATL( temp.toShort() );
325 temp = project->first("UseOfMfc"); 441 temp = project->first("UseOfMfc");
326 if ( !temp.isEmpty() ) 442 if ( !temp.isEmpty() )
327 vcProject.Configuration.UseOfMfc = useOfMfc( temp.toShort() ); 443 vcProject.Configuration.UseOfMfc = useOfMfc( temp.toShort() );
328 444
329 // Configuration does not need parameters from 445 // Configuration does not need parameters from
330 // these sub XML items; 446 // these sub XML items;
331 initCustomBuildTool(); 447 initCustomBuildTool();
332 initPreBuildEventTools(); 448 initPreBuildEventTools();
333 initPostBuildEventTools(); 449 initPostBuildEventTools();
334 initPreLinkEventTools(); 450 initPreLinkEventTools();
335} 451}
336 452
337void VcprojGenerator::initCompilerTool() 453void VcprojGenerator::initCompilerTool()
338{ 454{
339 QString placement = project->first("OBJECTS_DIR"); 455 QString placement = project->first("OBJECTS_DIR");
340 if ( placement.isEmpty() ) 456 if ( placement.isEmpty() )
341 placement = project->isActiveConfig( "release" )? ".\\Release\\":".\\Debug\\"; 457 placement = ".\\";
342 458
343 vcProject.Configuration.compiler.AssemblerListingLocation = placement ; 459 vcProject.Configuration.compiler.AssemblerListingLocation = placement ;
344 vcProject.Configuration.compiler.ProgramDataBaseFileName = placement ; 460 vcProject.Configuration.compiler.ProgramDataBaseFileName = placement ;
345 vcProject.Configuration.compiler.ObjectFile = placement ; 461 vcProject.Configuration.compiler.ObjectFile = placement ;
346 vcProject.Configuration.compiler.PrecompiledHeaderFile = placement + project->first("QMAKE_ORIG_TARGET") + ".pch"; 462 vcProject.Configuration.compiler.PrecompiledHeaderFile = placement + project->first("QMAKE_ORIG_TARGET") + ".pch";
347 463
348 if ( project->isActiveConfig("debug") ){ 464 if ( project->isActiveConfig("debug") ){
349 // Debug version 465 // Debug version
350 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS"] ); 466 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS"] );
351 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_DEBUG"] ); 467 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_DEBUG"] );
352 if ( project->isActiveConfig("thread") ) { 468 if ( project->isActiveConfig("thread") ) {
353 if ( (projectTarget == Application) || (projectTarget == StaticLib) ) 469 if ( (projectTarget == Application) || (projectTarget == StaticLib) )
354 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DBG"] ); 470 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DBG"] );
355 else 471 else
356 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"] ); 472 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"] );
357 } else { 473 } else {
358 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_ST_DBG"] ); 474 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_ST_DBG"] );
359 } 475 }
360 } else { 476 } else {
361 // Release version 477 // Release version
362 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS"] ); 478 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS"] );
363 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_RELEASE"] ); 479 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_RELEASE"] );
364 vcProject.Configuration.compiler.PreprocessorDefinitions += "QT_NO_DEBUG"; 480 vcProject.Configuration.compiler.PreprocessorDefinitions += "QT_NO_DEBUG";
481 vcProject.Configuration.compiler.PreprocessorDefinitions += "NDEBUG";
365 if ( project->isActiveConfig("thread") ) { 482 if ( project->isActiveConfig("thread") ) {
366 if ( (projectTarget == Application) || (projectTarget == StaticLib) ) 483 if ( (projectTarget == Application) || (projectTarget == StaticLib) )
367 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT"] ); 484 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT"] );
368 else 485 else
369 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DLL"] ); 486 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DLL"] );
370 } else { 487 } else {
371 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_ST"] ); 488 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_ST"] );
372 } 489 }
373 } 490 }
374 491
375 // Common for both release and debug 492 // Common for both release and debug
376 if ( project->isActiveConfig("warn_off") ) 493 if ( project->isActiveConfig("warn_off") )
377 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_OFF"] ); 494 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_OFF"] );
378 else 495 else if ( project->isActiveConfig("warn_on") )
379 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_ON"] ); 496 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_ON"] );
380 if ( project->isActiveConfig("windows") ) 497 if ( project->isActiveConfig("windows") )
381 vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["MSVCPROJ_WINCONDEF"]; 498 vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["MSVCPROJ_WINCONDEF"];
382 499
383 // Can this be set for ALL configs? 500 // Can this be set for ALL configs?
384 // If so, use qmake.conf! 501 // If so, use qmake.conf!
385 if ( projectTarget == SharedLib ) 502 if ( projectTarget == SharedLib )
386 vcProject.Configuration.compiler.PreprocessorDefinitions += "_WINDOWS"; 503 vcProject.Configuration.compiler.PreprocessorDefinitions += "_WINDOWS";
387 504
388 vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["DEFINES"]; 505 vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["DEFINES"];
389 vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["PRL_EXPORT_DEFINES"]; 506 vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["PRL_EXPORT_DEFINES"];
390 vcProject.Configuration.compiler.parseOptions( project->variables()["MSVCPROJ_INCPATH"] ); 507 vcProject.Configuration.compiler.parseOptions( project->variables()["MSVCPROJ_INCPATH"] );
391} 508}
392 509
393void VcprojGenerator::initLibrarianTool() 510void VcprojGenerator::initLibrarianTool()
394{ 511{
395 vcProject.Configuration.librarian.OutputFile = project->first( "DESTDIR" ); 512 vcProject.Configuration.librarian.OutputFile = project->first( "DESTDIR" );
396 if( vcProject.Configuration.librarian.OutputFile.isEmpty() ) 513 if( vcProject.Configuration.librarian.OutputFile.isEmpty() )
397 vcProject.Configuration.librarian.OutputFile = ".\\"; 514 vcProject.Configuration.librarian.OutputFile = ".\\";
398 515
399 if( !vcProject.Configuration.librarian.OutputFile.endsWith("\\") ) 516 if( !vcProject.Configuration.librarian.OutputFile.endsWith("\\") )
400 vcProject.Configuration.librarian.OutputFile += '\\'; 517 vcProject.Configuration.librarian.OutputFile += '\\';
401 518
402 vcProject.Configuration.librarian.OutputFile += project->first("MSVCPROJ_TARGET"); 519 vcProject.Configuration.librarian.OutputFile += project->first("MSVCPROJ_TARGET");
403} 520}
404 521
405void VcprojGenerator::initLinkerTool() 522void VcprojGenerator::initLinkerTool()
406{ 523{
407 vcProject.Configuration.linker.parseOptions( project->variables()["MSVCPROJ_LFLAGS"] ); 524 vcProject.Configuration.linker.parseOptions( project->variables()["MSVCPROJ_LFLAGS"] );
408 vcProject.Configuration.linker.AdditionalDependencies += project->variables()["MSVCPROJ_LIBS"]; 525 vcProject.Configuration.linker.AdditionalDependencies += project->variables()["MSVCPROJ_LIBS"];
409 526
410 switch ( projectTarget ) { 527 switch ( projectTarget ) {
411 case Application: 528 case Application:
412 vcProject.Configuration.linker.OutputFile = project->first( "DESTDIR" ); 529 vcProject.Configuration.linker.OutputFile = project->first( "DESTDIR" );
413 break; 530 break;
414 case SharedLib: 531 case SharedLib:
415 vcProject.Configuration.linker.parseOptions( project->variables()["MSVCPROJ_LIBOPTIONS"] ); 532 vcProject.Configuration.linker.parseOptions( project->variables()["MSVCPROJ_LIBOPTIONS"] );
416 vcProject.Configuration.linker.OutputFile = project->first( "DLLDESTDIR" ); 533 vcProject.Configuration.linker.OutputFile = project->first( "DLLDESTDIR" );
417 break; 534 break;
535 case StaticLib: //unhandled - added to remove warnings..
536 break;
418 } 537 }
419 538
420 if( vcProject.Configuration.linker.OutputFile.isEmpty() ) 539 if( vcProject.Configuration.linker.OutputFile.isEmpty() )
421 vcProject.Configuration.linker.OutputFile = ".\\"; 540 vcProject.Configuration.linker.OutputFile = ".\\";
422 541
423 if( !vcProject.Configuration.linker.OutputFile.endsWith("\\") ) 542 if( !vcProject.Configuration.linker.OutputFile.endsWith("\\") )
424 vcProject.Configuration.linker.OutputFile += '\\'; 543 vcProject.Configuration.linker.OutputFile += '\\';
425 544
426 vcProject.Configuration.linker.OutputFile += project->first("MSVCPROJ_TARGET"); 545 vcProject.Configuration.linker.OutputFile += project->first("MSVCPROJ_TARGET");
427 vcProject.Configuration.linker.ProgramDatabaseFile = project->first("OBJECTS_DIR") + project->first("QMAKE_ORIG_TARGET") + ".pdb"; 546 vcProject.Configuration.linker.ProgramDatabaseFile = project->first("OBJECTS_DIR") + project->first("QMAKE_ORIG_TARGET") + ".pdb";
428 547
429 if ( project->isActiveConfig("debug") ){ 548 if ( project->isActiveConfig("debug") ){
430 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_DEBUG"] ); 549 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_DEBUG"] );
431 } else { 550 } else {
432 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_RELEASE"] ); 551 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_RELEASE"] );
433 } 552 }
434 553
435 if ( project->isActiveConfig("dll") ){ 554 if ( project->isActiveConfig("dll") ){
436 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_QT_DLL"] ); 555 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_QT_DLL"] );
437 } 556 }
438 557
439 if ( project->isActiveConfig("console") ){ 558 if ( project->isActiveConfig("console") ){
440 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_CONSOLE"] ); 559 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_CONSOLE"] );
441 } else { 560 } else {
442 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_WINDOWS"] ); 561 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_WINDOWS"] );
443 } 562 }
444 563
445} 564}
446 565
447void VcprojGenerator::initIDLTool() 566void VcprojGenerator::initIDLTool()
448{ 567{
449} 568}
450 569
451void VcprojGenerator::initCustomBuildTool() 570void VcprojGenerator::initCustomBuildTool()
452{ 571{
453} 572}
454 573
455void VcprojGenerator::initPreBuildEventTools() 574void VcprojGenerator::initPreBuildEventTools()
456{ 575{
457 QString collectionName = project->first("QMAKE_IMAGE_COLLECTION"); 576 QString collectionName = project->first("QMAKE_IMAGE_COLLECTION");
458 if( !collectionName.isEmpty() ) { 577 if( !collectionName.isEmpty() ) {
459 QStringList& list = project->variables()["IMAGES"]; 578 QStringList& list = project->variables()["IMAGES"];
460 vcProject.Configuration.preBuild.Description = "Generate imagecollection"; 579 vcProject.Configuration.preBuild.Description = "Generate imagecollection";
461 //vcProject.Configuration.preBuild.AdditionalDependencies += list; 580 //vcProject.Configuration.preBuild.AdditionalDependencies += list;
462 vcProject.Configuration.preBuild.CommandLine = project->first("QMAKE_UIC") + " -embed " + project->first("QMAKE_ORIG_TARGET") + " " + list.join(" ") + " -o " + collectionName; 581
582 QFile imgs( ".imgcol" );
583 imgs.open( IO_WriteOnly );
584 QTextStream s( &imgs );
585 QStringList::ConstIterator it = list.begin();
586 while( it!=list.end() ) {
587 s << *it << " ";
588 it++;
589 }
590
591 vcProject.Configuration.preBuild.CommandLine = project->first("QMAKE_UIC") + " -embed " + project->first("QMAKE_ORIG_TARGET") + " -f .imgcol -o " + collectionName;
463 //vcProject.Configuration.preBuild.Outputs = collectionName; 592 //vcProject.Configuration.preBuild.Outputs = collectionName;
464 593
465 } 594 }
466} 595}
467 596
468void VcprojGenerator::initPostBuildEventTools() 597void VcprojGenerator::initPostBuildEventTools()
469{ 598{
599 if ( !project->variables()["QMAKE_POST_LINK"].isEmpty() ) {
600 vcProject.Configuration.postBuild.Description = var("QMAKE_POST_LINK");
601 vcProject.Configuration.postBuild.CommandLine = var("QMAKE_POST_LINK");
602 }
470 if( project->isActiveConfig( "activeqt" ) ) { 603 if( project->isActiveConfig( "activeqt" ) ) {
471 QString name = project->first( "QMAKE_ORIG_TARGET" ); 604 QString name = project->first( "QMAKE_ORIG_TARGET" );
472 QString nameext = project->first( "TARGET" ); 605 QString nameext = project->first( "TARGET" );
473 QString objdir = project->first( "OBJECTS_DIR" ); 606 QString objdir = project->first( "OBJECTS_DIR" );
474 QString idc = project->first( "QMAKE_IDC" ); 607 QString idc = project->first( "QMAKE_IDC" );
475 608
476 vcProject.Configuration.postBuild.Description = "Finalizing ActiveQt server..."; 609 vcProject.Configuration.postBuild.Description = "Finalizing ActiveQt server...";
610 if ( !vcProject.Configuration.postBuild.CommandLine.isEmpty() )
611 vcProject.Configuration.postBuild.CommandLine += " &amp;&amp; ";
477 612
478 if( project->isActiveConfig( "dll" ) ) { // In process 613 if( project->isActiveConfig( "dll" ) ) { // In process
479 vcProject.Configuration.postBuild.CommandLine = 614 vcProject.Configuration.postBuild.CommandLine +=
480 // call idc to generate .idl file from .dll 615 // call idc to generate .idl file from .dll
481 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " -idl " + objdir + name + ".idl -version 1.0 &amp;&amp; " + 616 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " -idl " + objdir + name + ".idl -version 1.0 &amp;&amp; " +
482 // call midl to create implementations of the .idl file 617 // call midl to create implementations of the .idl file
483 project->first( "QMAKE_IDL" ) + " " + objdir + name + ".idl /nologo /o " + objdir + name + ".midl /tlb " + objdir + name + ".tlb /iid " + objdir + 618 project->first( "QMAKE_IDL" ) + " " + objdir + name + ".idl /nologo /o " + objdir + name + ".midl /tlb " + objdir + name + ".tlb /iid " + objdir +
484 "dump.midl /dlldata " + objdir + "dump.midl /cstub " + objdir + "dump.midl /header " + objdir + "dump.midl /proxy " + objdir + "dump.midl /sstub " + 619 "dump.midl /dlldata " + objdir + "dump.midl /cstub " + objdir + "dump.midl /header " + objdir + "dump.midl /proxy " + objdir + "dump.midl /sstub " +
485 objdir + "dump.midl &amp;&amp; " + 620 objdir + "dump.midl &amp;&amp; " +
486 // call idc to replace tlb... 621 // call idc to replace tlb...
487 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /tlb " + objdir + name + ".tlb &amp;&amp; " + 622 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /tlb " + objdir + name + ".tlb &amp;&amp; " +
488 // register server 623 // register server
489 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /regserver"; 624 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /regserver";
490 } else { // out of process 625 } else { // out of process
491 vcProject.Configuration.postBuild.CommandLine = 626 vcProject.Configuration.postBuild.CommandLine =
492 // call application to dump idl 627 // call application to dump idl
493 vcProject.Configuration.OutputDirectory + "\\" + nameext + " -dumpidl " + objdir + name + ".idl -version 1.0 &amp;&amp; " + 628 vcProject.Configuration.OutputDirectory + "\\" + nameext + " -dumpidl " + objdir + name + ".idl -version 1.0 &amp;&amp; " +
494 // call midl to create implementations of the .idl file 629 // call midl to create implementations of the .idl file
495 project->first( "QMAKE_IDL" ) + " " + objdir + name + ".idl /nologo /o " + objdir + name + ".midl /tlb " + objdir + name + ".tlb /iid " + objdir + 630 project->first( "QMAKE_IDL" ) + " " + objdir + name + ".idl /nologo /o " + objdir + name + ".midl /tlb " + objdir + name + ".tlb /iid " + objdir +
496 "dump.midl /dlldata " + objdir + "dump.midl /cstub " + objdir + "dump.midl /header " + objdir + "dump.midl /proxy " + objdir + "dump.midl /sstub " + 631 "dump.midl /dlldata " + objdir + "dump.midl /cstub " + objdir + "dump.midl /header " + objdir + "dump.midl /proxy " + objdir + "dump.midl /sstub " +
497 objdir + "dump.midl &amp;&amp; " + 632 objdir + "dump.midl &amp;&amp; " +
498 // call idc to replace tlb... 633 // call idc to replace tlb...
499 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /tlb " + objdir + name + ".tlb &amp;&amp; " + 634 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /tlb " + objdir + name + ".tlb &amp;&amp; " +
500 // call app to register 635 // call app to register
501 vcProject.Configuration.OutputDirectory + "\\" + nameext + " -regserver"; 636 vcProject.Configuration.OutputDirectory + "\\" + nameext + " -regserver";
502 } 637 }
503 } 638 }
@@ -581,75 +716,82 @@ void VcprojGenerator::initLexYaccFiles()
581 vcProject.LexYaccFiles.Name = "Lex / Yacc Files"; 716 vcProject.LexYaccFiles.Name = "Lex / Yacc Files";
582 vcProject.LexYaccFiles.ParseFiles = _False; 717 vcProject.LexYaccFiles.ParseFiles = _False;
583 vcProject.LexYaccFiles.Filter = "l;y"; 718 vcProject.LexYaccFiles.Filter = "l;y";
584 vcProject.LexYaccFiles.Files += project->variables()["LEXSOURCES"]; 719 vcProject.LexYaccFiles.Files += project->variables()["LEXSOURCES"];
585 vcProject.LexYaccFiles.Files += project->variables()["YACCSOURCES"]; 720 vcProject.LexYaccFiles.Files += project->variables()["YACCSOURCES"];
586 vcProject.LexYaccFiles.Files.sort(); 721 vcProject.LexYaccFiles.Files.sort();
587 vcProject.LexYaccFiles.Project = this; 722 vcProject.LexYaccFiles.Project = this;
588 vcProject.LexYaccFiles.CustomBuild = lexyacc; 723 vcProject.LexYaccFiles.CustomBuild = lexyacc;
589} 724}
590 725
591void VcprojGenerator::initResourceFiles() 726void VcprojGenerator::initResourceFiles()
592{ 727{
593 vcProject.ResourceFiles.Name = "Resources"; 728 vcProject.ResourceFiles.Name = "Resources";
594 vcProject.ResourceFiles.ParseFiles = _False; 729 vcProject.ResourceFiles.ParseFiles = _False;
595 vcProject.ResourceFiles.Filter = "cpp;ico;png;jpg;jpeg;gif;xpm;bmp;rc;ts"; 730 vcProject.ResourceFiles.Filter = "cpp;ico;png;jpg;jpeg;gif;xpm;bmp;rc;ts";
596 vcProject.ResourceFiles.Files += project->variables()["RC_FILE"]; 731 vcProject.ResourceFiles.Files += project->variables()["RC_FILE"];
597 vcProject.ResourceFiles.Files += project->variables()["QMAKE_IMAGE_COLLECTION"]; 732 vcProject.ResourceFiles.Files += project->variables()["QMAKE_IMAGE_COLLECTION"];
598 vcProject.ResourceFiles.Files += project->variables()["IMAGES"]; 733 vcProject.ResourceFiles.Files += project->variables()["IMAGES"];
599 vcProject.ResourceFiles.Files += project->variables()["IDLSOURCES"]; 734 vcProject.ResourceFiles.Files += project->variables()["IDLSOURCES"];
600 vcProject.ResourceFiles.Files.sort(); 735 vcProject.ResourceFiles.Files.sort();
601 vcProject.ResourceFiles.Project = this; 736 vcProject.ResourceFiles.Project = this;
602 vcProject.ResourceFiles.CustomBuild = none; 737 vcProject.ResourceFiles.CustomBuild = none;
603} 738}
604 739
605/*
606// $$MSVCPROJ_IDLSOURCES ---------------------------------------------
607void VcprojGenerator::writeIDLs( QTextStream &t )
608{
609 QStringList &l = project->variables()["MSVCPROJ_IDLSOURCES"];
610 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
611 t << "# Begin Source File" << endl << endl;
612 t << "SOURCE=" << (*it) << endl;
613 t << "# PROP Exclude_From_Build 1" << endl;
614 t << "# End Source File" << endl << endl;
615 }
616 debug_msg(3, "Generator: MSVC.NET: Added IDLs" );
617}
618*/
619
620/* \internal 740/* \internal
621 Sets up all needed variables from the environment and all the different caches and .conf files 741 Sets up all needed variables from the environment and all the different caches and .conf files
622*/ 742*/
623 743
624void VcprojGenerator::initOld() 744void VcprojGenerator::initOld()
625{ 745{
626 if( init_flag ) 746 if( init_flag )
627 return; 747 return;
628 748
629 init_flag = TRUE; 749 init_flag = TRUE;
630 QStringList::Iterator it; 750 QStringList::Iterator it;
631 751
752 if ( project->isActiveConfig("stl") ) {
753 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_ON"];
754 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_ON"];
755 } else {
756 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_OFF"];
757 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_OFF"];
758 }
759 if ( project->isActiveConfig("exceptions") ) {
760 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_ON"];
761 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_ON"];
762 } else {
763 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_OFF"];
764 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_OFF"];
765 }
766 if ( project->isActiveConfig("rtti") ) {
767 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_ON"];
768 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_ON"];
769 } else {
770 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_OFF"];
771 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_OFF"];
772 }
773
632 // this should probably not be here, but I'm using it to wrap the .t files 774 // this should probably not be here, but I'm using it to wrap the .t files
633 if(project->first("TEMPLATE") == "vcapp" ) 775 if(project->first("TEMPLATE") == "vcapp" )
634 project->variables()["QMAKE_APP_FLAG"].append("1"); 776 project->variables()["QMAKE_APP_FLAG"].append("1");
635 else if(project->first("TEMPLATE") == "vclib") 777 else if(project->first("TEMPLATE") == "vclib")
636 project->variables()["QMAKE_LIB_FLAG"].append("1"); 778 project->variables()["QMAKE_LIB_FLAG"].append("1");
637 if ( project->variables()["QMAKESPEC"].isEmpty() ) 779 if ( project->variables()["QMAKESPEC"].isEmpty() )
638 project->variables()["QMAKESPEC"].append( getenv("QMAKESPEC") ); 780 project->variables()["QMAKESPEC"].append( getenv("QMAKESPEC") );
639 781
640 bool is_qt = 782 bool is_qt =
641 ( project->first("TARGET") == "qt"QTDLL_POSTFIX || 783 ( project->first("TARGET") == "qt"QTDLL_POSTFIX ||
642 project->first("TARGET") == "qt-mt"QTDLL_POSTFIX ); 784 project->first("TARGET") == "qt-mt"QTDLL_POSTFIX );
643 785
644 QStringList &configs = project->variables()["CONFIG"]; 786 QStringList &configs = project->variables()["CONFIG"];
645 787
646 if ( project->isActiveConfig( "shared" ) ) 788 if ( project->isActiveConfig( "shared" ) )
647 project->variables()["DEFINES"].append( "QT_DLL" ); 789 project->variables()["DEFINES"].append( "QT_DLL" );
648 790
649 if ( project->isActiveConfig( "qt_dll" ) && 791 if ( project->isActiveConfig( "qt_dll" ) &&
650 configs.findIndex("qt") == -1 ) 792 configs.findIndex("qt") == -1 )
651 configs.append("qt"); 793 configs.append("qt");
652 794
653 if ( project->isActiveConfig( "qt" ) ) { 795 if ( project->isActiveConfig( "qt" ) ) {
654 if ( project->isActiveConfig( "plugin" ) ) { 796 if ( project->isActiveConfig( "plugin" ) ) {
655 project->variables()["CONFIG"].append( "dll" ); 797 project->variables()["CONFIG"].append( "dll" );
@@ -767,156 +909,175 @@ void VcprojGenerator::initOld()
767 909
768 // DLL ----------------------------------------------------------- 910 // DLL -----------------------------------------------------------
769 if ( project->isActiveConfig("dll") ) { 911 if ( project->isActiveConfig("dll") ) {
770 if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { 912 if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) {
771 QString ver_xyz(project->first("VERSION")); 913 QString ver_xyz(project->first("VERSION"));
772 ver_xyz.replace(QRegExp("\\."), ""); 914 ver_xyz.replace(QRegExp("\\."), "");
773 project->variables()["TARGET_EXT"].append(ver_xyz + ".dll"); 915 project->variables()["TARGET_EXT"].append(ver_xyz + ".dll");
774 } else { 916 } else {
775 project->variables()["TARGET_EXT"].append(".dll"); 917 project->variables()["TARGET_EXT"].append(".dll");
776 } 918 }
777 } 919 }
778 // EXE / LIB ----------------------------------------------------- 920 // EXE / LIB -----------------------------------------------------
779 else { 921 else {
780 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) 922 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() )
781 project->variables()["TARGET_EXT"].append(".exe"); 923 project->variables()["TARGET_EXT"].append(".exe");
782 else 924 else
783 project->variables()["TARGET_EXT"].append(".lib"); 925 project->variables()["TARGET_EXT"].append(".lib");
784 } 926 }
785 927
786 project->variables()["MSVCPROJ_VER"] = "7.00"; 928 project->variables()["MSVCPROJ_VER"] = "7.00";
787 project->variables()["MSVCPROJ_DEBUG_OPT"] = "/GZ /ZI"; 929 project->variables()["MSVCPROJ_DEBUG_OPT"] = "/GZ /ZI";
788 930
789 // INCREMENTAL:NO ------------------------------------------------ 931 // INCREMENTAL:NO ------------------------------------------------
790 if(!project->isActiveConfig("incremental")) { 932 if(!project->isActiveConfig("incremental")) {
791 project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no")); 933 project->variables()["QMAKE_LFLAGS"].append(QString("/INCREMENTAL:no"));
792 if ( is_qt ) 934 if ( is_qt )
793 project->variables()["MSVCPROJ_DEBUG_OPT"] = "/GZ /Zi"; 935 project->variables()["MSVCPROJ_DEBUG_OPT"] = "/GZ /Zi";
794 } 936 }
795 937
796 // MOC ----------------------------------------------------------- 938 // MOC -----------------------------------------------------------
797 if ( project->isActiveConfig("moc") ) 939 if ( project->isActiveConfig("moc") )
798 setMocAware(TRUE); 940 setMocAware(TRUE);
799 941
800 942
801 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; 943 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
944 // Update -lname to name.lib, and -Ldir to
945 QStringList &libList = project->variables()["QMAKE_LIBS"];
946 for( it = libList.begin(); it != libList.end(); ) {
947 QString s = *it;
948 if( s.startsWith( "-l" ) ) {
949 it = libList.remove( it );
950 it = libList.insert( it, s.mid( 2 ) + ".lib" );
951 } else if( s.startsWith( "-L" ) ) {
952 it = libList.remove( it );
953 } else {
954 it++;
955 }
956 }
802 957
803 // Run through all variables containing filepaths, and ----------- 958 // Run through all variables containing filepaths, and -----------
804 // slash-slosh them correctly depending on current OS ----------- 959 // slash-slosh them correctly depending on current OS -----------
805 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ', "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH"); 960 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ', "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH");
806 QStringList &l = project->variables()["QMAKE_FILETAGS"]; 961 QStringList &l = project->variables()["QMAKE_FILETAGS"];
807 for(it = l.begin(); it != l.end(); ++it) { 962 for(it = l.begin(); it != l.end(); ++it) {
808 QStringList &gdmf = project->variables()[(*it)]; 963 QStringList &gdmf = project->variables()[(*it)];
809 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner) 964 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner)
810 (*inner) = Option::fixPathToTargetOS((*inner), FALSE); 965 (*inner) = Option::fixPathToTargetOS((*inner), FALSE);
811 } 966 }
812 967
813 // Get filename w/o extention ----------------------------------- 968 // Get filename w/o extention -----------------------------------
814 QString msvcproj_project = ""; 969 QString msvcproj_project = "";
815 QString targetfilename = ""; 970 QString targetfilename = "";
816 if ( project->variables()["TARGET"].count() ) { 971 if ( project->variables()["TARGET"].count() ) {
817 msvcproj_project = project->variables()["TARGET"].first(); 972 msvcproj_project = project->variables()["TARGET"].first();
818 targetfilename = msvcproj_project; 973 targetfilename = msvcproj_project;
819 } 974 }
820 975
821 // Save filename w/o extention in $$QMAKE_ORIG_TARGET ------------ 976 // Save filename w/o extention in $$QMAKE_ORIG_TARGET ------------
822 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"]; 977 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"];
823 978
824 // TARGET (add extention to $$TARGET) ---------------------------- 979 // TARGET (add extention to $$TARGET)
825 project->variables()["TARGET"].first() += project->first("TARGET_EXT"); 980 //project->variables()["MSVCPROJ_DEFINES"].append(varGlue(".first() += project->first("TARGET_EXT");
826 981
827 // Init base class too ------------------------------------------- 982 // Init base class too -------------------------------------------
828 MakefileGenerator::init(); 983 MakefileGenerator::init();
829 984
830 985
831 if ( msvcproj_project.isEmpty() ) 986 if ( msvcproj_project.isEmpty() )
832 msvcproj_project = Option::output.name(); 987 msvcproj_project = Option::output.name();
833 988
834 msvcproj_project = msvcproj_project.right( msvcproj_project.length() - msvcproj_project.findRev( "\\" ) - 1 ); 989 msvcproj_project = msvcproj_project.right( msvcproj_project.length() - msvcproj_project.findRev( "\\" ) - 1 );
835 msvcproj_project = msvcproj_project.left( msvcproj_project.findRev( "." ) ); 990 msvcproj_project = msvcproj_project.left( msvcproj_project.findRev( "." ) );
836 msvcproj_project.replace(QRegExp("-"), ""); 991 msvcproj_project.replace(QRegExp("-"), "");
837 992
838 project->variables()["MSVCPROJ_PROJECT"].append(msvcproj_project); 993 project->variables()["MSVCPROJ_PROJECT"].append(msvcproj_project);
839 QStringList &proj = project->variables()["MSVCPROJ_PROJECT"]; 994 QStringList &proj = project->variables()["MSVCPROJ_PROJECT"];
840 995
841 for(it = proj.begin(); it != proj.end(); ++it) 996 for(it = proj.begin(); it != proj.end(); ++it)
842 (*it).replace(QRegExp("\\.[a-zA-Z0-9_]*$"), ""); 997 (*it).replace(QRegExp("\\.[a-zA-Z0-9_]*$"), "");
843 998
844 // SUBSYSTEM ----------------------------------------------------- 999 // SUBSYSTEM -----------------------------------------------------
845 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { 1000 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
846 project->variables()["MSVCPROJ_TEMPLATE"].append("win32app" + project->first( "VCPROJ_EXTENSION" ) ); 1001 project->variables()["MSVCPROJ_TEMPLATE"].append("win32app" + project->first( "VCPROJ_EXTENSION" ) );
847 if ( project->isActiveConfig("console") ) { 1002 if ( project->isActiveConfig("console") ) {
848 project->variables()["MSVCPROJ_CONSOLE"].append("CONSOLE"); 1003 project->variables()["MSVCPROJ_CONSOLE"].append("CONSOLE");
849 project->variables()["MSVCPROJ_WINCONDEF"].append("_CONSOLE"); 1004 project->variables()["MSVCPROJ_WINCONDEF"].append("_CONSOLE");
850 project->variables()["MSVCPROJ_VCPROJTYPE"].append("0x0103"); 1005 project->variables()["MSVCPROJ_VCPROJTYPE"].append("0x0103");
851 project->variables()["MSVCPROJ_SUBSYSTEM"].append("CONSOLE"); 1006 project->variables()["MSVCPROJ_SUBSYSTEM"].append("CONSOLE");
852 } else { 1007 } else {
853 project->variables()["MSVCPROJ_CONSOLE"].clear(); 1008 project->variables()["MSVCPROJ_CONSOLE"].clear();
854 project->variables()["MSVCPROJ_WINCONDEF"].append("_WINDOWS"); 1009 project->variables()["MSVCPROJ_WINCONDEF"].append("_WINDOWS");
855 project->variables()["MSVCPROJ_VCPROJTYPE"].append("0x0101"); 1010 project->variables()["MSVCPROJ_VCPROJTYPE"].append("0x0101");
856 project->variables()["MSVCPROJ_SUBSYSTEM"].append("WINDOWS"); 1011 project->variables()["MSVCPROJ_SUBSYSTEM"].append("WINDOWS");
857 } 1012 }
858 } else { 1013 } else {
859 if ( project->isActiveConfig("dll") ) { 1014 if ( project->isActiveConfig("dll") ) {
860 project->variables()["MSVCPROJ_TEMPLATE"].append("win32dll" + project->first( "VCPROJ_EXTENSION" ) ); 1015 project->variables()["MSVCPROJ_TEMPLATE"].append("win32dll" + project->first( "VCPROJ_EXTENSION" ) );
861 } else { 1016 } else {
862 project->variables()["MSVCPROJ_TEMPLATE"].append("win32lib" + project->first( "VCPROJ_EXTENSION" ) ); 1017 project->variables()["MSVCPROJ_TEMPLATE"].append("win32lib" + project->first( "VCPROJ_EXTENSION" ) );
863 } 1018 }
864 } 1019 }
865 1020
866 // $$QMAKE.. -> $$MSVCPROJ.. ------------------------------------- 1021 // $$QMAKE.. -> $$MSVCPROJ.. -------------------------------------
867 project->variables()["MSVCPROJ_LIBS"] += project->variables()["QMAKE_LIBS"]; 1022 project->variables()["MSVCPROJ_LIBS"] += project->variables()["QMAKE_LIBS"];
868 project->variables()["MSVCPROJ_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"]; 1023 project->variables()["MSVCPROJ_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"];
869 project->variables()["MSVCPROJ_LFLAGS" ] += project->variables()["QMAKE_LFLAGS"]; 1024 project->variables()["MSVCPROJ_LFLAGS" ] += project->variables()["QMAKE_LFLAGS"];
870 if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() ) 1025 if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() ) {
871 project->variables()["MSVCPROJ_LFLAGS" ].append(varGlue("QMAKE_LIBDIR","/LIBPATH:"," /LIBPATH:","")); 1026 QStringList strl = project->variables()["QMAKE_LIBDIR"];
1027 QStringList::iterator stri;
1028 for ( stri = strl.begin(); stri != strl.end(); ++stri ) {
1029 if ( !(*stri).startsWith("/LIBPATH:") )
1030 (*stri).prepend( "/LIBPATH:" );
1031 }
1032 project->variables()["MSVCPROJ_LFLAGS"] += strl;
1033 }
872 project->variables()["MSVCPROJ_CXXFLAGS" ] += project->variables()["QMAKE_CXXFLAGS"]; 1034 project->variables()["MSVCPROJ_CXXFLAGS" ] += project->variables()["QMAKE_CXXFLAGS"];
873 // We don't use this... Direct manipulation of compiler object 1035 // We don't use this... Direct manipulation of compiler object
874 //project->variables()["MSVCPROJ_DEFINES"].append(varGlue("DEFINES","/D ","" " /D ","")); 1036 //project->variables()["MSVCPROJ_DEFINES"].append(varGlue("DEFINES","/D ","" " /D ",""));
875 //project->variables()["MSVCPROJ_DEFINES"].append(varGlue("PRL_EXPORT_DEFINES","/D ","" " /D ","")); 1037 //project->variables()["MSVCPROJ_DEFINES"].append(varGlue("PRL_EXPORT_DEFINES","/D ","" " /D ",""));
876 QStringList &incs = project->variables()["INCLUDEPATH"]; 1038 QStringList &incs = project->variables()["INCLUDEPATH"];
877 for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) { 1039 for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) {
878 QString inc = (*incit); 1040 QString inc = (*incit);
879 inc.replace(QRegExp("\""), ""); 1041 inc.replace(QRegExp("\""), "");
880 project->variables()["MSVCPROJ_INCPATH"].append("/I" + inc ); 1042 project->variables()["MSVCPROJ_INCPATH"].append("/I" + inc );
881 } 1043 }
882 project->variables()["MSVCPROJ_INCPATH"].append("/I" + specdir()); 1044 project->variables()["MSVCPROJ_INCPATH"].append("/I" + specdir());
883 1045
884 QString dest; 1046 QString dest;
885 project->variables()["MSVCPROJ_TARGET"] = project->first("TARGET"); 1047 project->variables()["MSVCPROJ_TARGET"] = project->first("TARGET");
886 if ( !project->variables()["DESTDIR"].isEmpty() ) {
887 project->variables()["TARGET"].first().prepend(project->first("DESTDIR"));
888 Option::fixPathToTargetOS(project->first("TARGET")); 1048 Option::fixPathToTargetOS(project->first("TARGET"));
889 dest = project->first("TARGET"); 1049 dest = project->first("TARGET") + project->first( "TARGET_EXT" );
890 if ( project->first("TARGET").startsWith("$(QTDIR)") ) 1050 if ( project->first("TARGET").startsWith("$(QTDIR)") )
891 dest.replace( QRegExp("\\$\\(QTDIR\\)"), getenv("QTDIR") ); 1051 dest.replace( QRegExp("\\$\\(QTDIR\\)"), getenv("QTDIR") );
892 project->variables()["MSVCPROJ_TARGET"].append( 1052 project->variables()["MSVCPROJ_TARGET"] = dest;
893 QString("/OUT:") + dest );
894 if ( project->isActiveConfig("dll") ) { 1053 if ( project->isActiveConfig("dll") ) {
895 QString imp = dest; 1054 QString imp = project->first( "DESTDIR" );
1055 if( !imp.isNull() && !imp.endsWith( "\\" ) )
1056 imp += "\\";
1057 imp += dest;
896 imp.replace(QRegExp("\\.dll"), ".lib"); 1058 imp.replace(QRegExp("\\.dll"), ".lib");
897 project->variables()["MSVCPROJ_LIBOPTIONS"] += (QString("/IMPLIB:") + imp ); 1059 project->variables()["MSVCPROJ_LIBOPTIONS"] += QString("/IMPLIB:") + imp;
898 }
899 } 1060 }
900 1061
901 // DLL COPY ------------------------------------------------------ 1062 // DLL COPY ------------------------------------------------------
902 if ( project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty() ) { 1063 if ( project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty() ) {
903 QStringList dlldirs = project->variables()["DLLDESTDIR"]; 1064 QStringList dlldirs = project->variables()["DLLDESTDIR"];
904 QString copydll = "# Begin Special Build Tool\n" 1065 QString copydll = "# Begin Special Build Tool\n"
905 "TargetPath=" + dest + "\n" 1066 "TargetPath=" + dest + "\n"
906 "SOURCE=$(InputPath)\n" 1067 "SOURCE=$(InputPath)\n"
907 "PostBuild_Desc=Copy DLL to " + project->first("DLLDESTDIR") + "\n" 1068 "PostBuild_Desc=Copy DLL to " + project->first("DLLDESTDIR") + "\n"
908 "PostBuild_Cmds="; 1069 "PostBuild_Cmds=";
909 1070
910 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) { 1071 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) {
911 copydll += "copy \"" + dest + "\" \"" + *dlldir + "\"\t"; 1072 copydll += "copy \"" + dest + "\" \"" + *dlldir + "\"\t";
912 } 1073 }
913 1074
914 copydll += "\n# End Special Build Tool"; 1075 copydll += "\n# End Special Build Tool";
915 project->variables()["MSVCPROJ_COPY_DLL_REL"].append( copydll ); 1076 project->variables()["MSVCPROJ_COPY_DLL_REL"].append( copydll );
916 project->variables()["MSVCPROJ_COPY_DLL_DBG"].append( copydll ); 1077 project->variables()["MSVCPROJ_COPY_DLL_DBG"].append( copydll );
917 } 1078 }
918 1079
919 // ACTIVEQT ------------------------------------------------------ 1080 // ACTIVEQT ------------------------------------------------------
920 if ( project->isActiveConfig("activeqt") ) { 1081 if ( project->isActiveConfig("activeqt") ) {
921 QString idl = project->variables()["QMAKE_IDL"].first(); 1082 QString idl = project->variables()["QMAKE_IDL"].first();
922 QString idc = project->variables()["QMAKE_IDC"].first(); 1083 QString idc = project->variables()["QMAKE_IDC"].first();
@@ -975,76 +1136,79 @@ void VcprojGenerator::initOld()
975 project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "MSVCPROJ_LFLAGS" << "MSVCPROJ_LIBS"; 1136 project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "MSVCPROJ_LFLAGS" << "MSVCPROJ_LIBS";
976 1137
977 // Verbose output if "-d -d"... 1138 // Verbose output if "-d -d"...
978 outputVariables(); 1139 outputVariables();
979} 1140}
980 1141
981// ------------------------------------------------------------------------------------------------ 1142// ------------------------------------------------------------------------------------------------
982// ------------------------------------------------------------------------------------------------ 1143// ------------------------------------------------------------------------------------------------
983 1144
984bool VcprojGenerator::openOutput(QFile &file) const 1145bool VcprojGenerator::openOutput(QFile &file) const
985{ 1146{
986 QString outdir; 1147 QString outdir;
987 if(!file.name().isEmpty()) { 1148 if(!file.name().isEmpty()) {
988 QFileInfo fi(file); 1149 QFileInfo fi(file);
989 if(fi.isDir()) 1150 if(fi.isDir())
990 outdir = file.name() + QDir::separator(); 1151 outdir = file.name() + QDir::separator();
991 } 1152 }
992 if(!outdir.isEmpty() || file.name().isEmpty()) { 1153 if(!outdir.isEmpty() || file.name().isEmpty()) {
993 QString ext = project->first("VCPROJ_EXTENSION"); 1154 QString ext = project->first("VCPROJ_EXTENSION");
994 if(project->first("TEMPLATE") == "vcsubdirs") 1155 if(project->first("TEMPLATE") == "vcsubdirs")
995 ext = project->first("VCSOLUTION_EXTENSION"); 1156 ext = project->first("VCSOLUTION_EXTENSION");
996 file.setName(outdir + project->first("TARGET") + ext); 1157 file.setName(outdir + project->first("TARGET") + ext);
997 } 1158 }
998 if(QDir::isRelativePath(file.name())) { 1159 if(QDir::isRelativePath(file.name())) {
999 QString ofile; 1160 file.setName( Option::fixPathToLocalOS(QDir::currentDirPath() + Option::dir_sep + fixFilename(file.name())) );
1000 ofile = file.name(); 1161 }
1162 return Win32MakefileGenerator::openOutput(file);
1163}
1164
1165QString VcprojGenerator::fixFilename(QString ofile) const
1166{
1001 int slashfind = ofile.findRev('\\'); 1167 int slashfind = ofile.findRev('\\');
1002 if (slashfind == -1) { 1168 if (slashfind == -1) {
1003 ofile = ofile.replace("-", "_"); 1169 ofile = ofile.replace('-', '_');
1004 } else { 1170 } else {
1005 int hypenfind = ofile.find('-', slashfind); 1171 int hypenfind = ofile.find('-', slashfind);
1006 while (hypenfind != -1 && slashfind < hypenfind) { 1172 while (hypenfind != -1 && slashfind < hypenfind) {
1007 ofile = ofile.replace(hypenfind, 1, "_"); 1173 ofile = ofile.replace(hypenfind, 1, '_');
1008 hypenfind = ofile.find('-', hypenfind + 1); 1174 hypenfind = ofile.find('-', hypenfind + 1);
1009 } 1175 }
1010 } 1176 }
1011 file.setName(Option::fixPathToLocalOS(QDir::currentDirPath() + Option::dir_sep + ofile)); 1177 return ofile;
1012 }
1013 return Win32MakefileGenerator::openOutput(file);
1014} 1178}
1015 1179
1016QString VcprojGenerator::findTemplate(QString file) 1180QString VcprojGenerator::findTemplate(QString file)
1017{ 1181{
1018 QString ret; 1182 QString ret;
1019 if(!QFile::exists((ret = file)) && 1183 if(!QFile::exists((ret = file)) &&
1020 !QFile::exists((ret = QString(Option::mkfile::qmakespec + "/" + file))) && 1184 !QFile::exists((ret = QString(Option::mkfile::qmakespec + "/" + file))) &&
1021 !QFile::exists((ret = QString(getenv("QTDIR")) + "/mkspecs/win32-msvc.net/" + file)) && 1185 !QFile::exists((ret = QString(getenv("QTDIR")) + "/mkspecs/win32-msvc.net/" + file)) &&
1022 !QFile::exists((ret = (QString(getenv("HOME")) + "/.tmake/" + file)))) 1186 !QFile::exists((ret = (QString(getenv("HOME")) + "/.tmake/" + file))))
1023 return ""; 1187 return "";
1024 debug_msg(1, "Generator: MSVC.NET: Found template \'%s\'", ret.latin1() ); 1188 debug_msg(1, "Generator: MSVC.NET: Found template \'%s\'", ret.latin1() );
1025 return ret; 1189 return ret;
1026} 1190}
1027 1191
1028 1192
1029void VcprojGenerator::processPrlVariable(const QString &var, const QStringList &l) 1193void VcprojGenerator::processPrlVariable(const QString &var, const QStringList &l)
1030{ 1194{
1031 if(var == "QMAKE_PRL_DEFINES") { 1195 if(var == "QMAKE_PRL_DEFINES") {
1032 QStringList &out = project->variables()["MSVCPROJ_DEFINES"]; 1196 QStringList &out = project->variables()["MSVCPROJ_DEFINES"];
1033 for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) { 1197 for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
1034 if(out.findIndex((*it)) == -1) 1198 if(out.findIndex((*it)) == -1)
1035 out.append((" /D " + *it )); 1199 out.append((" /D " + *it ));
1036 } 1200 }
1037 } else { 1201 } else {
1038 MakefileGenerator::processPrlVariable(var, l); 1202 MakefileGenerator::processPrlVariable(var, l);
1039 } 1203 }
1040} 1204}
1041 1205
1042void VcprojGenerator::outputVariables() 1206void VcprojGenerator::outputVariables()
1043{ 1207{
1044#if 0 1208#if 0
1045 debug_msg(3, "Generator: MSVC.NET: List of current variables:" ); 1209 qDebug( "Generator: MSVC.NET: List of current variables:" );
1046 for ( QMap<QString, QStringList>::ConstIterator it = project->variables().begin(); it != project->variables().end(); ++it) { 1210 for ( QMap<QString, QStringList>::ConstIterator it = project->variables().begin(); it != project->variables().end(); ++it) {
1047 debug_msg(3, "Generator: MSVC.NET: %s => %s", it.key().latin1(), it.data().join(" | ").latin1() ); 1211 qDebug( "Generator: MSVC.NET: %s => %s", it.key().latin1(), it.data().join(" | ").latin1() );
1048 } 1212 }
1049#endif 1213#endif
1050} 1214}
diff --git a/qmake/generators/win32/msvc_vcproj.h b/qmake/generators/win32/msvc_vcproj.h
index 583b164..69e0c02 100644
--- a/qmake/generators/win32/msvc_vcproj.h
+++ b/qmake/generators/win32/msvc_vcproj.h
@@ -1,129 +1,115 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of VcprojGenerator class. 4** Definition of VcprojGenerator 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
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this 21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software. 23** with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37#ifndef __VCPROJMAKE_H__ 37#ifndef __MSVC_VCPROJ_H__
38#define __VCPROJMAKE_H__ 38#define __MSVC_VCPROJ_H__
39 39
40#include "winmakefile.h" 40#include "winmakefile.h"
41#include "msvc_objectmodel.h" 41#include "msvc_objectmodel.h"
42 42
43enum target { 43enum target {
44 Application, 44 Application,
45 SharedLib, 45 SharedLib,
46 StaticLib 46 StaticLib
47}; 47};
48 48
49struct QUuid;
49class VcprojGenerator : public Win32MakefileGenerator 50class VcprojGenerator : public Win32MakefileGenerator
50{ 51{
51 bool init_flag; 52 bool init_flag;
52 bool writeVcprojParts(QTextStream &); 53 bool writeVcprojParts(QTextStream &);
53 54
54 bool writeMakefile(QTextStream &); 55 bool writeMakefile(QTextStream &);
55 virtual void writeSubDirs(QTextStream &t); 56 virtual void writeSubDirs(QTextStream &t);
56 QString findTemplate(QString file); 57 QString findTemplate(QString file);
57 void init(); 58 void init();
58 59
59public: 60public:
60 VcprojGenerator(QMakeProject *p); 61 VcprojGenerator(QMakeProject *p);
61 ~VcprojGenerator(); 62 ~VcprojGenerator();
62 63
63 QString defaultMakefile() const; 64 QString defaultMakefile() const;
64 virtual bool doDepends() const { return FALSE; } //never necesary 65 virtual bool doDepends() const { return FALSE; } //never necesary
65 66
66protected: 67protected:
67 virtual bool openOutput(QFile &file) const; 68 virtual bool openOutput(QFile &file) const;
68 virtual void processPrlVariable(const QString &, const QStringList &); 69 virtual void processPrlVariable(const QString &, const QStringList &);
69 virtual bool findLibraries(); 70 virtual bool findLibraries();
70 virtual void outputVariables(); 71 virtual void outputVariables();
72 QString fixFilename(QString ofile) const;
71 73
72 void initOld(); 74 void initOld();
73 void initProject(); 75 void initProject();
74 void initConfiguration(); 76 void initConfiguration();
75 void initCompilerTool(); 77 void initCompilerTool();
76 void initLinkerTool(); 78 void initLinkerTool();
77 void initLibrarianTool(); 79 void initLibrarianTool();
78 void initIDLTool(); 80 void initIDLTool();
79 void initCustomBuildTool(); 81 void initCustomBuildTool();
80 void initPreBuildEventTools(); 82 void initPreBuildEventTools();
81 void initPostBuildEventTools(); 83 void initPostBuildEventTools();
82 void initPreLinkEventTools(); 84 void initPreLinkEventTools();
83 void initSourceFiles(); 85 void initSourceFiles();
84 void initHeaderFiles(); 86 void initHeaderFiles();
85 void initMOCFiles(); 87 void initMOCFiles();
86 void initUICFiles(); 88 void initUICFiles();
87 void initFormsFiles(); 89 void initFormsFiles();
88 void initTranslationFiles(); 90 void initTranslationFiles();
89 void initLexYaccFiles(); 91 void initLexYaccFiles();
90 void initResourceFiles(); 92 void initResourceFiles();
91 93
92 /*
93 void writeGuid( QTextStream &t );
94 void writeAdditionalOptions( QTextStream &t );
95 void writeHeaders( QTextStream &t );
96 void writeSources( QTextStream &t );
97 void writeMocs( QTextStream &t );
98 void writeLexs( QTextStream &t );
99 void writeYaccs( QTextStream &t );
100 void writePictures( QTextStream &t );
101 void writeImages( QTextStream &t );
102 void writeIDLs( QTextStream &t );
103
104 void writeForms( QTextStream &t );
105 void writeFormsSourceHeaders( QString &variable, QTextStream &t );
106 void writeTranslations( QTextStream &t );
107 void writeStrippedTranslations( QTextStream &t );
108 */
109
110 VCProject vcProject; 94 VCProject vcProject;
111 target projectTarget; 95 target projectTarget;
112 96
97private:
98 QUuid increaseUUID(const QUuid &id);
113 friend class VCFilter; 99 friend class VCFilter;
114}; 100};
115 101
116inline VcprojGenerator::~VcprojGenerator() 102inline VcprojGenerator::~VcprojGenerator()
117{ } 103{ }
118 104
119inline QString VcprojGenerator::defaultMakefile() const 105inline QString VcprojGenerator::defaultMakefile() const
120{ 106{
121 return project->first("TARGET") + project->first("VCPROJ_EXTENSION"); 107 return project->first("TARGET") + project->first("VCPROJ_EXTENSION");
122} 108}
123 109
124inline bool VcprojGenerator::findLibraries() 110inline bool VcprojGenerator::findLibraries()
125{ 111{
126 return Win32MakefileGenerator::findLibraries("MSVCVCPROJ_LIBS"); 112 return Win32MakefileGenerator::findLibraries("MSVCVCPROJ_LIBS");
127} 113}
128 114
129#endif /* __VCPROJMAKE_H__ */ 115#endif /* __MSVC_VCPROJ_H__ */
diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp
index a07c921..bc3fed9 100644
--- a/qmake/generators/win32/winmakefile.cpp
+++ b/qmake/generators/win32/winmakefile.cpp
@@ -98,254 +98,294 @@ Win32MakefileGenerator::writeSubDirs(QTextStream &t)
98 QPtrListIterator<SubDir> it(subdirs); 98 QPtrListIterator<SubDir> it(subdirs);
99 99
100 if(!project->isEmpty("MAKEFILE")) 100 if(!project->isEmpty("MAKEFILE"))
101 t << "MAKEFILE=" << var("MAKEFILE") << endl; 101 t << "MAKEFILE=" << var("MAKEFILE") << endl;
102 t << "QMAKE =" << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl; 102 t << "QMAKE =" << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl;
103 t << "SUBTARGETS= "; 103 t << "SUBTARGETS= ";
104 for( it.toFirst(); it.current(); ++it) 104 for( it.toFirst(); it.current(); ++it)
105 t << " \\\n\t\t" << it.current()->target; 105 t << " \\\n\t\t" << it.current()->target;
106 t << endl << endl; 106 t << endl << endl;
107 t << "all: qmake_all $(SUBTARGETS)" << endl << endl; 107 t << "all: qmake_all $(SUBTARGETS)" << endl << endl;
108 108
109 for( it.toFirst(); it.current(); ++it) { 109 for( it.toFirst(); it.current(); ++it) {
110 bool have_dir = !(*it)->directory.isEmpty(); 110 bool have_dir = !(*it)->directory.isEmpty();
111 111
112 //make the makefile 112 //make the makefile
113 QString mkfile = (*it)->makefile; 113 QString mkfile = (*it)->makefile;
114 if(have_dir) 114 if(have_dir)
115 mkfile.prepend((*it)->directory + Option::dir_sep); 115 mkfile.prepend((*it)->directory + Option::dir_sep);
116 t << mkfile << ":"; 116 t << mkfile << ":";
117 if(project->variables()["QMAKE_NOFORCE"].isEmpty()) 117 if(project->variables()["QMAKE_NOFORCE"].isEmpty())
118 t << " FORCE"; 118 t << " FORCE";
119 if(have_dir) 119 if(have_dir)
120 t << "\n\t" << "cd " << (*it)->directory; 120 t << "\n\t" << "cd " << (*it)->directory;
121 t << "\n\t" << "$(QMAKE) " << (*it)->profile << " " << buildArgs(); 121 t << "\n\t" << "$(QMAKE) " << (*it)->profile << " " << buildArgs();
122 if((*it)->makefile != "$(MAKEFILE)")
123 t << " -o " << (*it)->makefile; 122 t << " -o " << (*it)->makefile;
124 if(have_dir) { 123 if(have_dir) {
125 int subLevels = it.current()->directory.contains(Option::dir_sep) + 1; 124 int subLevels = it.current()->directory.contains(Option::dir_sep) + 1;
126 t << "\n\t" << "@cd .."; 125 t << "\n\t" << "@cd ..";
127 for(int i = 1; i < subLevels; i++ ) 126 for(int i = 1; i < subLevels; i++ )
128 t << Option::dir_sep << ".."; 127 t << Option::dir_sep << "..";
129 } 128 }
130 t << endl; 129 t << endl;
131 130
132 //now actually build 131 //now actually build
133 t << (*it)->target << ": " << mkfile; 132 t << (*it)->target << ": " << mkfile;
134 if(project->variables()["QMAKE_NOFORCE"].isEmpty()) 133 if(project->variables()["QMAKE_NOFORCE"].isEmpty())
135 t << " FORCE"; 134 t << " FORCE";
136 if(have_dir) 135 if(have_dir)
137 t << "\n\t" << "cd " << (*it)->directory; 136 t << "\n\t" << "cd " << (*it)->directory;
138 t << "\n\t" << "$(MAKE)"; 137 t << "\n\t" << "$(MAKE)";
139 if((*it)->makefile != "$(MAKEFILE)")
140 t << " -f " << (*it)->makefile; 138 t << " -f " << (*it)->makefile;
141 if(have_dir) { 139 if(have_dir) {
142 int subLevels = it.current()->directory.contains(Option::dir_sep) + 1; 140 int subLevels = it.current()->directory.contains(Option::dir_sep) + 1;
143 t << "\n\t" << "@cd .."; 141 t << "\n\t" << "@cd ..";
144 for(int i = 1; i < subLevels; i++ ) 142 for(int i = 1; i < subLevels; i++ )
145 t << Option::dir_sep << ".."; 143 t << Option::dir_sep << "..";
146 } 144 }
147 t << endl << endl; 145 t << endl << endl;
148 } 146 }
149 147
150 if(project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].findIndex("qmake_all") == -1) 148 if(project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].findIndex("qmake_all") == -1)
151 project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].append("qmake_all"); 149 project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].append("qmake_all");
152 writeMakeQmake(t); 150 writeMakeQmake(t);
153 151
154 t << "qmake_all:"; 152 t << "qmake_all:";
155 if ( !subdirs.isEmpty() ) { 153 if ( !subdirs.isEmpty() ) {
156 for( it.toFirst(); it.current(); ++it) { 154 for( it.toFirst(); it.current(); ++it) {
157 QString subdir = (*it)->directory; 155 QString subdir = (*it)->directory;
156 QString profile = (*it)->profile;
158 int subLevels = subdir.contains(Option::dir_sep) + 1; 157 int subLevels = subdir.contains(Option::dir_sep) + 1;
159 t << "\n\t" 158 t << "\n\t"
160 << "cd " << subdir << "\n\t"; 159 << "cd " << subdir << "\n\t";
161 int lastSlash = subdir.findRev(Option::dir_sep); 160 int lastSlash = subdir.findRev(Option::dir_sep);
162 if(lastSlash != -1) 161 if(lastSlash != -1)
163 subdir = subdir.mid( lastSlash + 1 ); 162 subdir = subdir.mid( lastSlash + 1 );
164 t << "$(QMAKE) " << subdir << ".pro" 163 t << "$(QMAKE) "
165 << (!project->isEmpty("MAKEFILE") ? QString(" -o ") + var("MAKEFILE") : QString("")) 164 << ( !profile.isEmpty() ? profile : subdir + ".pro" )
165 << " -o " << (*it)->makefile
166 << " " << buildArgs() << "\n\t" 166 << " " << buildArgs() << "\n\t"
167 << "@cd .."; 167 << "@cd ..";
168 for(int i = 1; i < subLevels; i++ ) 168 for(int i = 1; i < subLevels; i++ )
169 t << Option::dir_sep << ".."; 169 t << Option::dir_sep << "..";
170 } 170 }
171 } else { 171 } else {
172 // Borland make does not like empty an empty command section, so insert 172 // Borland make does not like empty an empty command section, so insert
173 // a dummy command. 173 // a dummy command.
174 t << "\n\t" << "@cd ."; 174 t << "\n\t" << "@cd .";
175 } 175 }
176 t << endl << endl; 176 t << endl << endl;
177 177
178 QString targs[] = { QString("clean"), QString("install"), QString("mocclean"), QString::null }; 178 QString targs[] = { QString("clean"), QString("install"), QString("mocclean"), QString::null };
179 for(int x = 0; targs[x] != QString::null; x++) { 179 for(int x = 0; targs[x] != QString::null; x++) {
180 t << targs[x] << ": qmake_all"; 180 t << targs[x] << ": qmake_all";
181 if(targs[x] == "clean") 181 if(targs[x] == "clean")
182 t << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ", ""); 182 t << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ", "");
183 if (!subdirs.isEmpty()) { 183 if (!subdirs.isEmpty()) {
184 for( it.toFirst(); it.current(); ++it) { 184 for( it.toFirst(); it.current(); ++it) {
185 int subLevels = (*it)->directory.contains(Option::dir_sep) + 1; 185 int subLevels = (*it)->directory.contains(Option::dir_sep) + 1;
186 bool have_dir = !(*it)->directory.isEmpty(); 186 bool have_dir = !(*it)->directory.isEmpty();
187 if(have_dir) 187 if(have_dir)
188 t << "\n\t" << "cd " << (*it)->directory; 188 t << "\n\t" << "cd " << (*it)->directory;
189 QString in_file; 189 QString in_file = " -f " + (*it)->makefile;
190 if((*it)->makefile != "$(MAKEFILE)")
191 in_file = " -f " + (*it)->makefile;
192 t << "\n\t" << "$(MAKE) " << in_file << " " << targs[x]; 190 t << "\n\t" << "$(MAKE) " << in_file << " " << targs[x];
193 if(have_dir) { 191 if(have_dir) {
194 t << "\n\t" << "@cd .."; 192 t << "\n\t" << "@cd ..";
195 for(int i = 1; i < subLevels; i++ ) 193 for(int i = 1; i < subLevels; i++ )
196 t << Option::dir_sep << ".."; 194 t << Option::dir_sep << "..";
197 } 195 }
198 } 196 }
199 } else { 197 } else {
200 // Borland make does not like empty an empty command section, so 198 // Borland make does not like empty an empty command section, so
201 // insert a dummy command. 199 // insert a dummy command.
202 t << "\n\t" << "@cd ."; 200 t << "\n\t" << "@cd .";
203 } 201 }
204 t << endl << endl; 202 t << endl << endl;
205 } 203 }
206 204
207 if(project->variables()["QMAKE_NOFORCE"].isEmpty()) 205 if(project->variables()["QMAKE_NOFORCE"].isEmpty())
208 t << "FORCE:" << endl << endl; 206 t << "FORCE:" << endl << endl;
209} 207}
210 208
211 209
212int 210int
213Win32MakefileGenerator::findHighestVersion(const QString &d, const 211Win32MakefileGenerator::findHighestVersion(const QString &d, const QString &stem)
214 QString &stem)
215{ 212{
216 if(!QFile::exists(Option::fixPathToLocalOS(d))) 213 QString bd = Option::fixPathToLocalOS(d, TRUE);
214 if(!QFile::exists(bd))
217 return -1; 215 return -1;
218 if(!project->variables()["QMAKE_" + stem.upper() + 216 if(!project->variables()["QMAKE_" + stem.upper() + "_VERSION_OVERRIDE"].isEmpty())
219 "_VERSION_OVERRIDE"].isEmpty()) 217 return project->variables()["QMAKE_" + stem.upper() + "_VERSION_OVERRIDE"].first().toInt();
220 return project->variables()["QMAKE_" + stem.upper() + 218
221 "_VERSION_OVERRIDE"].first().toInt();
222 QString bd = d;
223 fixEnvVariables(bd);
224 QDir dir(bd); 219 QDir dir(bd);
225 int biggest=-1; 220 int biggest=-1;
226 QStringList entries = dir.entryList(); 221 QStringList entries = dir.entryList();
227 QRegExp regx( "(" + stem + "([0-9]*)).lib", FALSE ); 222 QString dllStem = stem + QTDLL_POSTFIX;
228 for(QStringList::Iterator it = entries.begin(); it != entries.end(); 223 QRegExp regx( "(" + dllStem + "([0-9]*)).lib", FALSE );
229 ++it) { 224 for(QStringList::Iterator it = entries.begin(); it != entries.end(); ++it) {
230 if(regx.exactMatch((*it))) 225 if(regx.exactMatch((*it)))
231 biggest = QMAX(biggest, (regx.cap(1) == stem || 226 biggest = QMAX(biggest, (regx.cap(1) == dllStem ||
232 regx.cap(2).isEmpty()) ? -1 : regx.cap(2).toInt()); 227 regx.cap(2).isEmpty()) ? -1 : regx.cap(2).toInt());
233 } 228 }
229 if(dir.exists(dllStem + Option::prl_ext)) {
230 QMakeProject proj;
231 if(proj.read(bd + dllStem + Option::prl_ext, QDir::currentDirPath(), TRUE)) {
232 if(!proj.isEmpty("QMAKE_PRL_VERSION"))
233 biggest = QMAX(biggest, proj.first("QMAKE_PRL_VERSION").replace(".", "").toInt());
234 }
235 }
234 return biggest; 236 return biggest;
235} 237}
236 238
237 239
238bool 240bool
239Win32MakefileGenerator::findLibraries(const QString &where) 241Win32MakefileGenerator::findLibraries(const QString &where)
240{ 242{
241 243
242 QStringList &l = project->variables()[where]; 244 QStringList &l = project->variables()[where];
243 QPtrList<MakefileDependDir> dirs; 245 QPtrList<MakefileDependDir> dirs;
246 {
247 QStringList &libpaths = project->variables()["QMAKE_LIBDIR"];
248 for(QStringList::Iterator libpathit = libpaths.begin(); libpathit != libpaths.end(); ++libpathit) {
249 QString r = (*libpathit), l = r;
250 fixEnvVariables(l);
251 dirs.append(new MakefileDependDir(r.replace("\"",""), l.replace("\"","")));
252 }
253 }
244 dirs.setAutoDelete(TRUE); 254 dirs.setAutoDelete(TRUE);
245 for(QStringList::Iterator it = l.begin(); it != l.end(); ) { 255 for(QStringList::Iterator it = l.begin(); it != l.end(); ) {
246 QString opt = (*it); 256 QChar quote;
247 bool remove = FALSE; 257 bool modified_opt = FALSE, remove = FALSE;
248 if(opt.startsWith("-L") || opt.startsWith("/L")) { 258 QString opt = (*it).stripWhiteSpace();
249 QString r = opt.right(opt.length() - 2), l = Option::fixPathToLocalOS(r); 259 if((opt[0] == '\'' || opt[0] == '"') && opt[(int)opt.length()-1] == opt[0]) {
260 quote = opt[0];
261 opt = opt.mid(1, opt.length()-2);
262 }
263 if(opt.startsWith("/LIBPATH:")) {
264 QString r = opt.mid(9), l = Option::fixPathToLocalOS(r);
265 dirs.append(new MakefileDependDir(r.replace("\"",""),
266 l.replace("\"","")));
267 } else if(opt.startsWith("-L") || opt.startsWith("/L")) {
268 QString r = opt.mid(2), l = Option::fixPathToLocalOS(r);
250 dirs.append(new MakefileDependDir(r.replace("\"",""), 269 dirs.append(new MakefileDependDir(r.replace("\"",""),
251 l.replace("\"",""))); 270 l.replace("\"","")));
252 remove = TRUE; 271 remove = TRUE; //we eat this switch
253 } else if(opt.startsWith("-l") || opt.startsWith("/l")) { 272 } else if(opt.startsWith("-l") || opt.startsWith("/l")) {
254 QString lib = opt.right(opt.length() - 2), out; 273 QString lib = opt.right(opt.length() - 2), out;
255 if(!lib.isEmpty()) { 274 if(!lib.isEmpty()) {
256 for(MakefileDependDir *mdd = dirs.first(); mdd; mdd = dirs.next() ) { 275 for(MakefileDependDir *mdd = dirs.first(); mdd; mdd = dirs.next() ) {
276 QString extension;
257 int ver = findHighestVersion(mdd->local_dir, lib); 277 int ver = findHighestVersion(mdd->local_dir, lib);
258 if(ver > 0) 278 if(ver > 0)
259 lib += QString::number(ver); 279 extension += QString::number(ver);
260 lib += ".lib"; 280 extension += ".lib";
261 if(QFile::exists(mdd->local_dir + Option::dir_sep + lib)) { 281 if(QFile::exists(mdd->local_dir + Option::dir_sep + lib + Option::prl_ext) ||
262 out = mdd->real_dir + Option::dir_sep + lib; 282 QFile::exists(mdd->local_dir + Option::dir_sep + lib + extension)) {
283 out = mdd->real_dir + Option::dir_sep + lib + extension;
263 break; 284 break;
264 } 285 }
265 } 286 }
266 } 287 }
267 if(out.isEmpty()) 288 if(out.isEmpty()) {
268 remove = TRUE; 289 remove = TRUE; //just eat it since we cannot find one..
269 else 290 } else {
291 modified_opt = TRUE;
270 (*it) = out; 292 (*it) = out;
293 }
271 } else if(!QFile::exists(Option::fixPathToLocalOS(opt))) { 294 } else if(!QFile::exists(Option::fixPathToLocalOS(opt))) {
272 QString dir, file = opt; 295 QPtrList<MakefileDependDir> lib_dirs;
296 QString file = opt;
273 int slsh = file.findRev(Option::dir_sep); 297 int slsh = file.findRev(Option::dir_sep);
274 if(slsh != -1) { 298 if(slsh != -1) {
275 dir = file.left(slsh+1); 299 QString r = file.left(slsh+1), l = r;
300 fixEnvVariables(l);
301 lib_dirs.append(new MakefileDependDir(r.replace("\"",""), l.replace("\"","")));
276 file = file.right(file.length() - slsh - 1); 302 file = file.right(file.length() - slsh - 1);
303 } else {
304 lib_dirs = dirs;
277 } 305 }
278 if ( !(project->variables()["QMAKE_QT_DLL"].isEmpty() && (file == "qt.lib" || file == "qt-mt.lib")) ) {
279 if(file.endsWith(".lib")) { 306 if(file.endsWith(".lib")) {
280 file = file.left(file.length() - 4); 307 file = file.left(file.length() - 4);
281 if(!file.at(file.length()-1).isNumber()) { 308 if(!file.at(file.length()-1).isNumber()) {
282 int ver = findHighestVersion(dir, file); 309 for(MakefileDependDir *mdd = lib_dirs.first(); mdd; mdd = lib_dirs.next() ) {
310 QString lib_tmpl(file + "%1" + ".lib");
311 int ver = findHighestVersion(mdd->local_dir, file);
283 if(ver != -1) { 312 if(ver != -1) {
284 file = QString(dir + file + "%1" + ".lib");
285 if(ver) 313 if(ver)
286 (*it) = file.arg(ver); 314 lib_tmpl = lib_tmpl.arg(ver);
287 else 315 else
288 (*it) = file.arg(""); 316 lib_tmpl = lib_tmpl.arg("");
317 if(slsh != -1) {
318 QString dir = mdd->real_dir;
319 if(!dir.endsWith(Option::dir_sep))
320 dir += Option::dir_sep;
321 lib_tmpl.prepend(dir);
322 }
323 modified_opt = TRUE;
324 (*it) = lib_tmpl;
325 break;
289 } 326 }
290 } 327 }
291 } 328 }
292 } 329 }
293 } 330 }
294 if(remove) 331 if(remove) {
295 it = l.remove(it); 332 it = l.remove(it);
296 else 333 } else {
334 if(!quote.isNull() && modified_opt)
335 (*it) = quote + (*it) + quote;
297 ++it; 336 ++it;
298 } 337 }
338 }
299 return TRUE; 339 return TRUE;
300} 340}
301 341
302void 342void
303Win32MakefileGenerator::processPrlFiles() 343Win32MakefileGenerator::processPrlFiles()
304{ 344{
305 QDict<void> processed; 345 QDict<void> processed;
306 QPtrList<MakefileDependDir> libdirs; 346 QPtrList<MakefileDependDir> libdirs;
307 libdirs.setAutoDelete(TRUE); 347 libdirs.setAutoDelete(TRUE);
308 { 348 {
309 QStringList &libpaths = project->variables()["QMAKE_LIBDIR"]; 349 QStringList &libpaths = project->variables()["QMAKE_LIBDIR"];
310 for(QStringList::Iterator libpathit = libpaths.begin(); libpathit != libpaths.end(); ++libpathit) { 350 for(QStringList::Iterator libpathit = libpaths.begin(); libpathit != libpaths.end(); ++libpathit) {
311 QString r = (*libpathit), l = r; 351 QString r = (*libpathit), l = r;
312 fixEnvVariables(l); 352 fixEnvVariables(l);
313 libdirs.append(new MakefileDependDir(r.replace("\"",""), 353 libdirs.append(new MakefileDependDir(r.replace("\"",""),
314 l.replace("\"",""))); 354 l.replace("\"","")));
315 } 355 }
316 } 356 }
317 for(bool ret = FALSE; TRUE; ret = FALSE) { 357 for(bool ret = FALSE; TRUE; ret = FALSE) {
318 //read in any prl files included.. 358 //read in any prl files included..
319 QStringList l_out; 359 QStringList l_out;
320 QString where = "QMAKE_LIBS"; 360 QString where = "QMAKE_LIBS";
321 if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS")) 361 if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS"))
322 where = project->first("QMAKE_INTERNAL_PRL_LIBS"); 362 where = project->first("QMAKE_INTERNAL_PRL_LIBS");
323 QStringList &l = project->variables()[where]; 363 QStringList &l = project->variables()[where];
324 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 364 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
325 QString opt = (*it); 365 QString opt = (*it);
326 if(opt.left(1) == "/") { 366 if(opt.startsWith("/")) {
327 if(opt.left(9) == "/LIBPATH:") { 367 if(opt.startsWith("/LIBPATH:")) {
328 QString r = opt.mid(9), l = r; 368 QString r = opt.mid(9), l = r;
329 fixEnvVariables(l); 369 fixEnvVariables(l);
330 libdirs.append(new MakefileDependDir(r.replace("\"",""), 370 libdirs.append(new MakefileDependDir(r.replace("\"",""),
331 l.replace("\"",""))); 371 l.replace("\"","")));
332 } 372 }
333 } else { 373 } else {
334 if(!processed[opt]) { 374 if(!processed[opt]) {
335 if(processPrlFile(opt)) { 375 if(processPrlFile(opt)) {
336 processed.insert(opt, (void*)1); 376 processed.insert(opt, (void*)1);
337 ret = TRUE; 377 ret = TRUE;
338 } else { 378 } else {
339 for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) { 379 for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) {
340 QString prl = mdd->local_dir + Option::dir_sep + opt; 380 QString prl = mdd->local_dir + Option::dir_sep + opt;
341 if(processed[prl]) { 381 if(processed[prl]) {
342 break; 382 break;
343 } else if(processPrlFile(prl)) { 383 } else if(processPrlFile(prl)) {
344 processed.insert(prl, (void*)1); 384 processed.insert(prl, (void*)1);
345 ret = TRUE; 385 ret = TRUE;
346 break; 386 break;
347 } 387 }
348 } 388 }
349 } 389 }
350 } 390 }
351 } 391 }