summaryrefslogtreecommitdiff
path: root/qmake/generators
authorkergoth <kergoth>2002-11-01 00:10:42 (UTC)
committer kergoth <kergoth>2002-11-01 00:10:42 (UTC)
commit5042e3cf0d3514552769e441f5aad590c8eaf967 (patch) (unidiff)
tree4a5ea45f3519d981a172ab5275bf38c6fa778dec /qmake/generators
parent108c1c753e74e989cc13923086996791428c9af4 (diff)
downloadopie-5042e3cf0d3514552769e441f5aad590c8eaf967.zip
opie-5042e3cf0d3514552769e441f5aad590c8eaf967.tar.gz
opie-5042e3cf0d3514552769e441f5aad590c8eaf967.tar.bz2
Adding qmake in preperation for new build system
Diffstat (limited to 'qmake/generators') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/generators/mac/metrowerks_xml.cpp822
-rw-r--r--qmake/generators/mac/metrowerks_xml.h69
-rw-r--r--qmake/generators/mac/pbuilder_pbx.cpp983
-rw-r--r--qmake/generators/mac/pbuilder_pbx.h68
-rw-r--r--qmake/generators/unix/unixmake.cpp520
-rw-r--r--qmake/generators/unix/unixmake.h71
-rw-r--r--qmake/generators/unix/unixmake2.cpp1048
-rw-r--r--qmake/generators/win32/borland_bmake.cpp477
-rw-r--r--qmake/generators/win32/borland_bmake.h59
-rw-r--r--qmake/generators/win32/msvc_dsp.cpp955
-rw-r--r--qmake/generators/win32/msvc_dsp.h73
-rw-r--r--qmake/generators/win32/msvc_nmake.cpp488
-rw-r--r--qmake/generators/win32/msvc_nmake.h59
-rw-r--r--qmake/generators/win32/msvc_objectmodel.cpp1955
-rw-r--r--qmake/generators/win32/msvc_objectmodel.h775
-rw-r--r--qmake/generators/win32/msvc_vcproj.cpp1050
-rw-r--r--qmake/generators/win32/msvc_vcproj.h129
-rw-r--r--qmake/generators/win32/winmakefile.cpp360
-rw-r--r--qmake/generators/win32/winmakefile.h72
19 files changed, 10033 insertions, 0 deletions
diff --git a/qmake/generators/mac/metrowerks_xml.cpp b/qmake/generators/mac/metrowerks_xml.cpp
new file mode 100644
index 0000000..125749d
--- a/dev/null
+++ b/qmake/generators/mac/metrowerks_xml.cpp
@@ -0,0 +1,822 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Created : 970521
7**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
9**
10** This file is part of the network module of the Qt GUI Toolkit.
11**
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
14** LICENSE.QPL included in the packaging of this file.
15**
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
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software.
24**
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.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38#include "metrowerks_xml.h"
39#include "option.h"
40#include <qdir.h>
41#include <qdict.h>
42#include <qregexp.h>
43#include <stdlib.h>
44#include <time.h>
45#ifdef Q_OS_MAC
46#include <Carbon/Carbon.h>
47#include <sys/types.h>
48#include <sys/stat.h>
49#endif
50
51
52MetrowerksMakefileGenerator::MetrowerksMakefileGenerator(QMakeProject *p) : MakefileGenerator(p), init_flag(FALSE)
53{
54
55}
56
57bool
58MetrowerksMakefileGenerator::writeMakefile(QTextStream &t)
59{
60 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {
61 /* for now just dump, I need to generated an empty xml or something.. */
62 fprintf(stderr, "Project file not generated because all requirements not met:\n\t%s\n",
63 var("QMAKE_FAILED_REQUIREMENTS").latin1());
64 return TRUE;
65 }
66
67 if(project->first("TEMPLATE") == "app" ||
68 project->first("TEMPLATE") == "lib") {
69 return writeMakeParts(t);
70 }
71 else if(project->first("TEMPLATE") == "subdirs") {
72 writeHeader(t);
73 qDebug("Not supported!");
74 return TRUE;
75 }
76 return FALSE;
77}
78
79bool
80MetrowerksMakefileGenerator::writeMakeParts(QTextStream &t)
81{
82 //..grrr.. libs!
83 QStringList extra_objs;
84 bool do_libs = TRUE;
85 if(project->first("TEMPLATE") == "app")
86 extra_objs += project->variables()["QMAKE_CRT_OBJECTS"];
87 else if(project->first("TEMPLATE") == "lib" && project->isActiveConfig("staticlib"))
88 do_libs = FALSE;
89 if(do_libs)
90 extra_objs += project->variables()["QMAKE_LIBS"];
91 for(QStringList::Iterator val_it = extra_objs.begin();
92 val_it != extra_objs.end(); ++val_it) {
93 if((*val_it).startsWith("-L")) {
94 QString dir((*val_it).right((*val_it).length() - 2));
95 fixEnvVariables(dir);
96 if(project->variables()["DEPENDPATH"].findIndex(dir) == -1 &&
97 project->variables()["INCLUDEPATH"].findIndex(dir) == -1)
98 project->variables()["INCLUDEPATH"].append(dir);
99 } else if((*val_it).startsWith("-l")) {
100 QString lib("lib" + (*val_it).right((*val_it).length() - 2) + "." +
101 project->first("QMAKE_EXTENSION_SHLIB"));
102 if(project->variables()["LIBRARIES"].findIndex(lib) == -1)
103 project->variables()["LIBRARIES"].append(lib);
104 } else
105 if((*val_it) == "-framework") {
106 ++val_it;
107 if(val_it == extra_objs.end())
108 break;
109 QString frmwrk = (*val_it) + ".framework";
110 if(project->variables()["FRAMEWORKS"].findIndex(frmwrk) == -1)
111 project->variables()["FRAMEWORKS"].append(frmwrk);
112 } else if((*val_it).left(1) != "-") {
113 QString lib=(*val_it);
114 int s = lib.findRev('/');
115 if(s != -1) {
116 QString dir = lib.left(s);
117 lib = lib.right(lib.length() - s - 1);
118 fixEnvVariables(dir);
119 if(project->variables()["DEPENDPATH"].findIndex(dir) == -1 &&
120 project->variables()["INCLUDEPATH"].findIndex(dir) == -1)
121 project->variables()["INCLUDEPATH"].append(dir);
122 }
123 project->variables()["LIBRARIES"].append(lib);
124 }
125 }
126 //let metrowerks find the files & set the files to the type I expect
127 QDict<void> seen(293);
128 QString paths[] = { QString("SRCMOC"), QString("FORMS"), QString("UICDECLS"),
129 QString("UICIMPLS"), QString("SOURCES"),QString("HEADERS"),
130 QString::null };
131 for(int y = 0; paths[y] != QString::null; y++) {
132 QStringList &l = project->variables()[paths[y]];
133 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) {
134 //establish file types
135 seen.insert((*val_it), (void *)1);
136 createFork((*val_it)); //the file itself
137 QStringList &d = findDependencies((*val_it)); //depends
138 for(QStringList::Iterator dep_it = d.begin(); dep_it != d.end(); ++dep_it) {
139 if(!seen.find((*dep_it))) {
140 seen.insert((*dep_it), (void *)1);
141 createFork((*dep_it));
142 }
143 }
144 //now chop it
145 int s = (*val_it).findRev('/');
146 if(s != -1) {
147 QString dir = (*val_it).left(s);
148 (*val_it) = (*val_it).right((*val_it).length() - s - 1);
149 QString tmpd=dir, tmpv;
150 if(fixifyToMacPath(tmpd, tmpv)) {
151 bool add_in = TRUE;
152 QString deps[] = { QString("DEPENDPATH"),
153 QString("INCLUDEPATH"), QString::null },
154 dd, dv;
155 for(int yy = 0; deps[yy] != QString::null; yy++) {
156 QStringList &l2 = project->variables()[deps[yy]];
157 for(QStringList::Iterator val_it2 = l2.begin();
158 val_it2 != l2.end(); ++val_it2) {
159 QString dd= (*val_it2), dv;
160 if(!fixifyToMacPath(dd, dv))
161 continue;
162 if(dd == tmpd && tmpv == dv) {
163 add_in = FALSE;
164 break;
165 }
166 }
167 }
168 if(add_in)
169 project->variables()["INCLUDEPATH"].append(dir);
170 }
171 }
172 }
173 }
174 //need a defines file
175 if(!project->isEmpty("DEFINES")) {
176 QString pre_pref = project->first("TARGET_STEM");
177 if(project->first("TEMPLATE") == "lib")
178 pre_pref += project->isActiveConfig("staticlib") ? "_static" : "_shared";
179 project->variables()["CODEWARRIOR_PREFIX_HEADER"].append(pre_pref + "_prefix.h");
180 }
181
182 QString xmlfile = findTemplate(project->first("QMAKE_XML_TEMPLATE"));
183 QFile file(xmlfile);
184 if(!file.open(IO_ReadOnly )) {
185 fprintf(stderr, "Cannot open XML file: %s\n",
186 project->first("QMAKE_XML_TEMPLATE").latin1());
187 return FALSE;
188 }
189 QTextStream xml(&file);
190 createFork(Option::output.name());
191
192 int rep;
193 QString line;
194 while ( !xml.eof() ) {
195 line = xml.readLine();
196 while((rep = line.find(QRegExp("\\$\\$[!a-zA-Z0-9_-]*"))) != -1) {
197 QString torep = line.mid(rep, line.find(QRegExp("[^\\$!a-zA-Z0-9_-]"), rep) - rep);
198 QString variable = torep.right(torep.length()-2);
199
200 t << line.left(rep); //output the left side
201 line = line.right(line.length() - (rep + torep.length())); //now past the variable
202 if(variable == "CODEWARRIOR_HEADERS" || variable == "CODEWARRIOR_SOURCES" ||
203 variable == "CODEWARRIOR_LIBRARIES" || variable == "CODEWARRIOR_QPREPROCESS" ||
204 variable == "CODEWARRIOR_QPREPROCESSOUT") {
205 QString outcmd=variable.right(variable.length() - variable.findRev('_') - 1);
206 QStringList args;
207 if(outcmd == "QPREPROCESS")
208 args << "UICS" << "MOCS";
209 else if(outcmd == "QPREPROCESSOUT")
210 args << "SRCMOC" << "UICIMPLS" << "UICDELCS";
211 else
212 args << outcmd;
213 for(QStringList::Iterator arit = args.begin(); arit != args.end(); ++arit) {
214 QString arg = (*arit);
215 QString kind = "Text";
216 if(arg == "LIBRARIES")
217 kind = "Library";
218 if(!project->variables()[arg].isEmpty()) {
219 QStringList &list = project->variables()[arg];
220 for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
221 QString flag;
222 if(project->isActiveConfig("debug")) {
223 bool debug = TRUE;
224 if(outcmd == "QPREPROCESS") {
225 debug = FALSE;
226 } else {
227 for(QStringList::Iterator hit = Option::h_ext.begin(); hit != Option::h_ext.end(); ++hit) {
228 if((*it).endsWith((*hit))) {
229 debug = FALSE;
230 break;
231 }
232 }
233 }
234 if(debug)
235 flag = "Debug";
236 }
237 t << "\t\t\t\t<FILE>" << endl
238 << "\t\t\t\t\t<PATHTYPE>Name</PATHTYPE>" << endl
239 << "\t\t\t\t\t<PATH>" << (*it) << "</PATH>" << endl
240 << "\t\t\t\t\t<PATHFORMAT>MacOS</PATHFORMAT>" << endl
241 << "\t\t\t\t\t<FILEKIND>" << kind << "</FILEKIND>" << endl
242 << "\t\t\t\t\t<FILEFLAGS>" << flag << "</FILEFLAGS>" << endl
243 << "\t\t\t\t</FILE>" << endl;
244 }
245 }
246 }
247 } else if(variable == "CODEWARRIOR_SOURCES_LINKORDER" ||
248 variable == "CODEWARRIOR_HEADERS_LINKORDER" ||
249 variable == "CODEWARRIOR_LIBRARIES_LINKORDER" ||
250 variable == "CODEWARRIOR_QPREPROCESS_LINKORDER" ||
251 variable == "CODEWARRIOR_QPREPROCESSOUT_LINKORDER") {
252 QString outcmd=variable.mid(variable.find('_')+1,
253 variable.findRev('_')-(variable.find('_')+1));
254 QStringList args;
255 if(outcmd == "QPREPROCESS")
256 args << "UICS" << "MOCS";
257 else if(outcmd == "QPREPROCESSOUT")
258 args << "SRCMOC" << "UICIMPLS" << "UICDELCS";
259 else
260 args << outcmd;
261 for(QStringList::Iterator arit = args.begin(); arit != args.end(); ++arit) {
262 QString arg = (*arit);
263 if(!project->variables()[arg].isEmpty()) {
264 QStringList &list = project->variables()[arg];
265 for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
266 t << "\t\t\t\t<FILEREF>" << endl
267 << "\t\t\t\t\t<PATHTYPE>Name</PATHTYPE>" << endl
268 << "\t\t\t\t\t<PATH>" << (*it) << "</PATH>" << endl
269 << "\t\t\t\t\t<PATHFORMAT>MacOS</PATHFORMAT>" << endl
270 << "\t\t\t\t</FILEREF>" << endl;
271 }
272 }
273 }
274 } else if(variable == "CODEWARRIOR_HEADERS_GROUP" ||
275 variable == "CODEWARRIOR_SOURCES_GROUP" ||
276 variable == "CODEWARRIOR_LIBRARIES_GROUP" ||
277 variable == "CODEWARRIOR_QPREPROCESS_GROUP" ||
278 variable == "CODEWARRIOR_QPREPROCESSOUT_GROUP") {
279 QString outcmd = variable.mid(variable.find('_')+1,
280 variable.findRev('_')-(variable.find('_')+1));
281 QStringList args;
282 if(outcmd == "QPREPROCESS")
283 args << "UICS" << "MOCS";
284 else if(outcmd == "QPREPROCESSOUT")
285 args << "SRCMOC" << "UICIMPLS" << "UICDELCS";
286 else
287 args << outcmd;
288 for(QStringList::Iterator arit = args.begin(); arit != args.end(); ++arit) {
289 QString arg = (*arit);
290 if(!project->variables()[arg].isEmpty()) {
291 QStringList &list = project->variables()[arg];
292 for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
293 t << "\t\t\t\t<FILEREF>" << endl
294 << "\t\t\t\t\t<TARGETNAME>" << var("TARGET_STEM") << "</TARGETNAME>"
295 << endl
296 << "\t\t\t\t\t<PATHTYPE>Name</PATHTYPE>" << endl
297 << "\t\t\t\t\t<PATH>" << (*it) << "</PATH>" << endl
298 << "\t\t\t\t\t<PATHFORMAT>MacOS</PATHFORMAT>" << endl
299 << "\t\t\t\t</FILEREF>" << endl;
300 }
301 }
302 }
303 } else if(variable == "CODEWARRIOR_FRAMEWORKS") {
304 if(!project->isEmpty("FRAMEWORKS")) {
305 QStringList &list = project->variables()["FRAMEWORKS"];
306 for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
307 t << "\t\t\t\t<FRAMEWORK>" << endl
308 << "\t\t\t\t\t<FILEREF>" << endl
309 << "\t\t\t\t\t\t<PATHTYPE>Name</PATHTYPE>" << endl
310 << "\t\t\t\t\t\t<PATH>" << (*it) << "</PATH>" << endl
311 << "\t\t\t\t\t\t<PATHFORMAT>MacOS</PATHFORMAT>" << endl
312 << "\t\t\t\t\t</FILEREF>" << endl
313 << "\t\t\t\t</FRAMEWORK>" << endl;
314 }
315 }
316 } else if(variable == "CODEWARRIOR_DEPENDPATH" || variable == "CODEWARRIOR_INCLUDEPATH" ||
317 variable == "CODEWARRIOR_FRAMEWORKPATH") {
318 QString arg=variable.right(variable.length()-variable.find('_')-1);
319 QStringList list;
320 if(arg == "INCLUDEPATH") {
321 list = project->variables()[arg];
322 list << Option::mkfile::qmakespec;
323 list << QDir::current().currentDirPath();
324
325 QStringList &l = project->variables()["QMAKE_LIBS_PATH"];
326 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) {
327 QString p = (*val_it), v;
328 if(!fixifyToMacPath(p, v))
329 continue;
330
331 t << "\t\t\t\t\t<SETTING>" << endl
332 << "\t\t\t\t\t\t<SETTING><NAME>SearchPath</NAME>" << endl
333 << "\t\t\t\t\t\t\t<SETTING><NAME>Path</NAME>"
334 << "<VALUE>" << p << "</VALUE></SETTING>" << endl
335 << "\t\t\t\t\t\t\t<SETTING><NAME>PathFormat</NAME><VALUE>MacOS</VALUE></SETTING>" << endl
336 << "\t\t\t\t\t\t\t<SETTING><NAME>PathRoot</NAME><VALUE>CodeWarrior</VALUE></SETTING>" << endl
337 << "\t\t\t\t\t\t</SETTING>" << endl
338 << "\t\t\t\t\t\t<SETTING><NAME>Recursive</NAME><VALUE>true</VALUE></SETTING>" << endl
339 << "\t\t\t\t\t\t<SETTING><NAME>HostFlags</NAME><VALUE>All</VALUE></SETTING>" << endl
340 << "\t\t\t\t\t</SETTING>" << endl;
341 }
342 } else if(variable == "DEPENDPATH") {
343 QStringList &l = project->variables()[arg];
344 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it)
345 {
346 //apparently tmake used colon separation...
347 QStringList damn = QStringList::split(':', (*val_it));
348 if(!damn.isEmpty())
349 list += damn;
350 else
351 list.append((*val_it));
352 }
353 } else {
354 list = project->variables()[arg];
355 }
356 for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
357 QString p = (*it), v, recursive = "false", framework = "false";
358 if(p.startsWith("recursive--")) {
359 p = p.right(p.length() - 11);
360 recursive = "true";
361 }
362 if(!fixifyToMacPath(p, v))
363 continue;
364 if(arg == "FRAMEWORKPATH")
365 framework = "true";
366
367 t << "\t\t\t\t\t<SETTING>" << endl
368 << "\t\t\t\t\t\t<SETTING><NAME>SearchPath</NAME>" << endl
369 << "\t\t\t\t\t\t\t<SETTING><NAME>Path</NAME>"
370 << "<VALUE>" << p << "</VALUE></SETTING>" << endl
371 << "\t\t\t\t\t\t\t<SETTING><NAME>PathFormat</NAME><VALUE>MacOS</VALUE></SETTING>" << endl
372 << "\t\t\t\t\t\t\t<SETTING><NAME>PathRoot</NAME><VALUE>" << v << "</VALUE></SETTING>" << endl
373 << "\t\t\t\t\t\t</SETTING>" << endl
374 << "\t\t\t\t\t\t<SETTING><NAME>Recursive</NAME><VALUE>" << recursive << "</VALUE></SETTING>" << endl
375 << "\t\t\t\t\t\t<SETTING><NAME>FrameworkPath</NAME><VALUE>" << framework << "</VALUE></SETTING>" << endl
376 << "\t\t\t\t\t\t<SETTING><NAME>HostFlags</NAME><VALUE>All</VALUE></SETTING>" << endl
377 << "\t\t\t\t\t</SETTING>" << endl;
378 }
379 } else if(variable == "CODEWARRIOR_WARNING" || variable == "!CODEWARRIOR_WARNING") {
380 bool b = ((!project->isActiveConfig("warn_off")) &&
381 project->isActiveConfig("warn_on"));
382 if(variable.startsWith("!"))
383 b = !b;
384 t << (int)b;
385 } else if(variable == "CODEWARRIOR_TEMPLATE") {
386 if(project->first("TEMPLATE") == "app" ) {
387 t << "Executable";
388 } else if(project->first("TEMPLATE") == "lib") {
389 if(project->isActiveConfig("staticlib"))
390 t << "Library";
391 else
392 t << "SharedLibrary";
393 }
394 } else if(variable == "CODEWARRIOR_OUTPUT_DIR") {
395 QString outdir = "{Project}/", volume;
396 if(!project->isEmpty("DESTDIR"))
397 outdir = project->first("DESTDIR");
398 if(project->first("TEMPLATE") == "app" && !project->isActiveConfig("console"))
399 outdir += var("TARGET") + ".app/Contents/MacOS/";
400 if(fixifyToMacPath(outdir, volume, FALSE)) {
401 t << "\t\t\t<SETTING><NAME>Path</NAME><VALUE>" << outdir << "</VALUE></SETTING>"
402 << endl
403 << "\t\t\t<SETTING><NAME>PathFormat</NAME><VALUE>MacOS</VALUE></SETTING>" << endl
404 << "\t\t\t<SETTING><NAME>PathRoot</NAME><VALUE>" << volume << "</VALUE></SETTING>"
405 << endl;
406 }
407 } else if(variable == "CODEWARRIOR_PACKAGER_PANEL") {
408 if(project->first("TEMPLATE") == "app" && !project->isActiveConfig("console")) {
409 QString outdir = "{Project}/", volume;
410 if(!project->isEmpty("DESTDIR"))
411 outdir = project->first("DESTDIR");
412 outdir += var("TARGET") + ".app";
413 if(fixifyToMacPath(outdir, volume, FALSE)) {
414 t << "\t\t<SETTING><NAME>MWMacOSPackager_UsePackager</NAME>"
415 << "<VALUE>1</VALUE></SETTING>" << "\n"
416 << "\t\t<SETTING><NAME>MWMacOSPackager_FolderToPackage</NAME>" << "\n"
417 << "\t\t\t<SETTING><NAME>Path</NAME><VALUE>" << outdir
418 << "</VALUE></SETTING>" << "\n"
419 << "\t\t\t<SETTING><NAME>PathFormat</NAME><VALUE>MacOS</VALUE></SETTING>"
420 << "\n"
421 << "\t\t\t<SETTING><NAME>PathRoot</NAME><VALUE>" << volume
422 << "</VALUE></SETTING>" << "\n"
423 << "\t\t</SETTING>" << "\n"
424 << "\t\t<SETTING><NAME>MWMacOSPackager_CreateClassicAlias</NAME>"
425 << "<VALUE>0</VALUE></SETTING>" << "\n"
426 << "\t\t<SETTING><NAME>MWMacOSPackager_ClassicAliasMethod</NAME>"
427 << "<VALUE>UseTargetOutput</VALUE></SETTING>" << "\n"
428 << "\t\t<SETTING><NAME>MWMacOSPackager_ClassicAliasPath</NAME>"
429 << "<VALUE></VALUE></SETTING>" << "\n"
430 << "\t\t<SETTING><NAME>MWMacOSPackager_CreatePkgInfo</NAME>"
431 << "<VALUE>1</VALUE></SETTING>" << "\n"
432 << "\t\t<SETTING><NAME>MWMacOSPackager_PkgCreatorType</NAME>"
433 << "<VALUE>CUTE</VALUE></SETTING>" << "\n"
434 << "\t\t<SETTING><NAME>MWMacOSPackager_PkgFileType</NAME>"
435 << "<VALUE>APPL</VALUE></SETTING>" << endl;
436 }
437 }
438 } else if(variable == "CODEWARRIOR_FILETYPE") {
439 if(project->first("TEMPLATE") == "lib")
440 t << "MYDL";
441 else
442 t << "MEXE";
443 } else if(variable == "CODEWARRIOR_QTDIR") {
444 t << getenv("QTDIR");
445 } else if(variable == "CODEWARRIOR_CACHEMODDATES") {
446 t << "true";
447 } else {
448 t << var(variable);
449 }
450 }
451 t << line << endl;
452 }
453 t << endl;
454 file.close();
455
456 if(mocAware()) {
457 QString mocs = project->first("MOCS");
458 QFile mocfile(mocs);
459 if(!mocfile.open(IO_WriteOnly)) {
460 fprintf(stderr, "Cannot open MOCS file: %s\n", mocs.latin1());
461 } else {
462 createFork(mocs);
463 QTextStream mocs(&mocfile);
464 QStringList &list = project->variables()["SRCMOC"];
465 for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
466 QString src = findMocSource((*it));
467 if(src.findRev('/') != -1)
468 src = src.right(src.length() - src.findRev('/') - 1);
469 mocs << src << endl;
470 }
471 mocfile.close();
472 }
473 }
474
475 if(!project->isEmpty("FORMS")) {
476 QString uics = project->first("UICS");
477 QFile uicfile(uics);
478 if(!uicfile.open(IO_WriteOnly)) {
479 fprintf(stderr, "Cannot open UICS file: %s\n", uics.latin1());
480 } else {
481 createFork(uics);
482 QTextStream uics(&uicfile);
483 QStringList &list = project->variables()["FORMS"];
484 for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
485 QString ui = (*it);
486 if(ui.findRev('/') != -1)
487 ui = ui.right(ui.length() - ui.findRev('/') - 1);
488 uics << ui << endl;
489 }
490 uicfile.close();
491 }
492 }
493
494 if(!project->isEmpty("CODEWARRIOR_PREFIX_HEADER")) {
495 QFile prefixfile(project->first("CODEWARRIOR_PREFIX_HEADER"));
496 if(!prefixfile.open(IO_WriteOnly)) {
497 fprintf(stderr, "Cannot open PREFIX file: %s\n", prefixfile.name().latin1());
498 } else {
499 createFork(project->first("CODEWARRIOR_PREFIX_HEADER"));
500 QTextStream prefix(&prefixfile);
501 QStringList &list = project->variables()["DEFINES"];
502 for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
503 if((*it).find('=') != -1) {
504 int x = (*it).find('=');
505 prefix << "#define " << (*it).left(x) << " " << (*it).right((*it).length() - x - 1) << endl;
506 } else {
507 prefix << "#define " << (*it) << endl;
508 }
509 }
510 prefixfile.close();
511 }
512 }
513 return TRUE;
514}
515
516
517
518void
519MetrowerksMakefileGenerator::init()
520{
521 if(init_flag)
522 return;
523 init_flag = TRUE;
524
525 if ( project->isEmpty("QMAKE_XML_TEMPLATE") )
526 project->variables()["QMAKE_XML_TEMPLATE"].append("mwerkstmpl.xml");
527
528 QStringList &configs = project->variables()["CONFIG"];
529 if(project->isActiveConfig("qt")) {
530 if(configs.findIndex("moc")) configs.append("moc");
531 if ( !( (project->first("TARGET") == "qt") || (project->first("TARGET") == "qte") ||
532 (project->first("TARGET") == "qt-mt") ) )
533 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"];
534 if(configs.findIndex("moc"))
535 configs.append("moc");
536 if ( !project->isActiveConfig("debug") )
537 project->variables()["DEFINES"].append("QT_NO_DEBUG");
538 }
539
540 //version handling
541 if(project->variables()["VERSION"].isEmpty())
542 project->variables()["VERSION"].append("1.0." +
543 (project->isEmpty("VER_PAT") ? QString("0") :
544 project->first("VER_PAT")) );
545 QStringList ver = QStringList::split('.', project->first("VERSION"));
546 ver << "0" << "0"; //make sure there are three
547 project->variables()["VER_MAJ"].append(ver[0]);
548 project->variables()["VER_MIN"].append(ver[1]);
549 project->variables()["VER_PAT"].append(ver[2]);
550
551 if( !project->isEmpty("LIBS") )
552 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
553 if( project->variables()["QMAKE_EXTENSION_SHLIB"].isEmpty() )
554 project->variables()["QMAKE_EXTENSION_SHLIB"].append( "dylib" );
555
556 if ( project->isActiveConfig("moc") ) {
557 QString mocfile = project->first("TARGET");
558 if(project->first("TEMPLATE") == "lib")
559 mocfile += project->isActiveConfig("staticlib") ? "_static" : "_shared";
560 project->variables()["MOCS"].append(mocfile + ".mocs");
561 setMocAware(TRUE);
562 }
563 if(!project->isEmpty("FORMS")) {
564 QString uicfile = project->first("TARGET");
565 if(project->first("TEMPLATE") == "lib")
566 uicfile += project->isActiveConfig("staticlib") ? "_static" : "_shared";
567 project->variables()["UICS"].append(uicfile + ".uics");
568 }
569 if(project->isEmpty("DESTDIR"))
570 project->variables()["DESTDIR"].append(QDir::currentDirPath());
571 MakefileGenerator::init();
572
573 if ( project->isActiveConfig("opengl") ) {
574 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_OPENGL"];
575 if ( (project->first("TARGET") == "qt") || (project->first("TARGET") == "qte") ||
576 (project->first("TARGET") == "qt-mt") )
577 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL_QT"];
578 else
579 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"];
580 }
581
582 if(project->isActiveConfig("qt"))
583 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QT"];
584 if(project->isEmpty("FRAMEWORKPATH"))
585 project->variables()["FRAMEWORKPATH"].append("/System/Library/Frameworks/");
586
587 //set the target up
588 project->variables()["TARGET_STEM"] = project->variables()["TARGET"];
589 if(project->first("TEMPLATE") == "lib") {
590 if(project->isActiveConfig("staticlib"))
591 project->variables()["TARGET"].first() = "lib" + project->first("TARGET") + ".lib";
592 else
593 project->variables()["TARGET"].first() = "lib" + project->first("TARGET") + "." +
594 project->first("QMAKE_EXTENSION_SHLIB");
595
596 project->variables()["CODEWARRIOR_VERSION"].append(project->first("VER_MAJ") +
597 project->first("VER_MIN") +
598 project->first("VER_PAT"));
599 } else {
600 project->variables()["CODEWARRIOR_VERSION"].append("0");
601 if(project->isEmpty("QMAKE_ENTRYPOINT"))
602 project->variables()["QMAKE_ENTRYPOINT"].append("start");
603 project->variables()["CODEWARRIOR_ENTRYPOINT"].append(
604 project->first("QMAKE_ENTRYPOINT"));
605 }
606}
607
608
609QString
610MetrowerksMakefileGenerator::findTemplate(QString file)
611{
612 QString ret;
613 if(!QFile::exists(ret = file) &&
614 !QFile::exists((ret = Option::mkfile::qmakespec + QDir::separator() + file)) &&
615 !QFile::exists((ret = QString(getenv("QTDIR")) + "/mkspecs/mac-mwerks/" + file)) &&
616 !QFile::exists((ret = (QString(getenv("HOME")) + "/.tmake/" + file))))
617 return "";
618 return ret;
619}
620
621bool
622MetrowerksMakefileGenerator::createFork(const QString &f)
623{
624#if defined(Q_OS_MACX)
625 FSRef fref;
626 FSSpec fileSpec;
627 if(QFile::exists(f)) {
628 mode_t perms = 0;
629 {
630 struct stat s;
631 stat(f.latin1(), &s);
632 if(!(s.st_mode & S_IWUSR)) {
633 perms = s.st_mode;
634 chmod(f.latin1(), perms | S_IWUSR);
635 }
636 }
637 FILE *o = fopen(f.latin1(), "a");
638 if(!o)
639 return FALSE;
640 if(FSPathMakeRef((const UInt8 *)f.latin1(), &fref, NULL) == noErr) {
641 if(FSGetCatalogInfo(&fref, kFSCatInfoNone, NULL, NULL, &fileSpec, NULL) == noErr)
642 FSpCreateResFile(&fileSpec, 'CUTE', 'TEXT', smSystemScript);
643 else
644 qDebug("bogus %d", __LINE__);
645 } else
646 qDebug("bogus %d", __LINE__);
647 fclose(o);
648 if(perms)
649 chmod(f.latin1(), perms);
650 }
651#else
652 Q_UNUSED(f)
653#endif
654 return TRUE;
655}
656
657bool
658MetrowerksMakefileGenerator::fixifyToMacPath(QString &p, QString &v, bool )
659{
660 v = "Absolute";
661 if(p.find(':') != -1) //guess its macish already
662 return TRUE;
663
664 static QString st_volume;
665 if(st_volume.isEmpty()) {
666 st_volume = var("QMAKE_VOLUMENAME");
667#ifdef Q_OS_MAC
668 if(st_volume.isEmpty()) {
669 uchar foo[512];
670 HVolumeParam pb;
671 memset(&pb, '\0', sizeof(pb));
672 pb.ioVRefNum = 0;
673 pb.ioNamePtr = foo;
674 if(PBHGetVInfoSync((HParmBlkPtr)&pb) == noErr) {
675 int len = foo[0];
676 memcpy(foo,foo+1, len);
677 foo[len] = '\0';
678 st_volume = (char *)foo;
679 }
680 }
681#endif
682 }
683 QString volume = st_volume;
684
685 fixEnvVariables(p);
686 if(p.startsWith("\"") && p.endsWith("\""))
687 p = p.mid(1, p.length() - 2);
688 if(p.isEmpty())
689 return FALSE;
690 if(!p.endsWith("/"))
691 p += "/";
692 if(QDir::isRelativePath(p)) {
693 if(p.startsWith("{")) {
694 int eoc = p.find('}');
695 if(eoc == -1)
696 return FALSE;
697 volume = p.mid(1, eoc - 1);
698 p = p.right(p.length() - eoc - 1);
699 } else {
700 QFileInfo fi(p);
701 if(fi.convertToAbs()) //strange
702 return FALSE;
703 p = fi.filePath();
704 }
705 }
706 p = QDir::cleanDirPath(p);
707 if(!volume.isEmpty())
708 v = volume;
709 p.replace("/", ":");
710 if(p.right(1) != ":")
711 p += ':';
712 return TRUE;
713}
714
715void
716MetrowerksMakefileGenerator::processPrlFiles()
717{
718 QPtrList<MakefileDependDir> libdirs;
719 libdirs.setAutoDelete(TRUE);
720 const QString lflags[] = { "QMAKE_LIBS", QString::null };
721 for(int i = 0; !lflags[i].isNull(); i++) {
722 for(bool ret = FALSE; TRUE; ret = FALSE) {
723 QStringList l_out;
724 QStringList &l = project->variables()[lflags[i]];
725 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
726 QString opt = (*it);
727 if(opt.startsWith("-")) {
728 if(opt.startsWith("-L")) {
729 QString r = opt.right(opt.length() - 2), l = r;
730 fixEnvVariables(l);
731 libdirs.append(new MakefileDependDir(r.replace( "\"", ""),
732 l.replace( "\"", "")));
733 } else if(opt.left(2) == "-l") {
734 QString lib = opt.right(opt.length() - 2), prl;
735 for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) {
736 prl = mdd->local_dir + Option::dir_sep + "lib" + lib + Option::prl_ext;
737 if(processPrlFile(prl)) {
738 if(prl.startsWith(mdd->local_dir))
739 prl.replace(0, mdd->local_dir.length(), mdd->real_dir);
740 QRegExp reg("^.*lib(" + lib + "[^.]*)\\." +
741 project->first("QMAKE_EXTENSION_SHLIB") + "$");
742 if(reg.exactMatch(prl))
743 prl = "-l" + reg.cap(1);
744 opt = prl;
745 ret = TRUE;
746 break;
747 }
748 }
749 } else if(opt == "-framework") {
750 l_out.append(opt);
751 ++it;
752 opt = (*it);
753 QString prl = "/System/Library/Frameworks/" + opt +
754 ".framework/" + opt + Option::prl_ext;
755 if(processPrlFile(prl))
756 ret = TRUE;
757 }
758 if(!opt.isEmpty())
759 l_out.append(opt);
760 } else {
761 if(processPrlFile(opt))
762 ret = TRUE;
763 if(!opt.isEmpty())
764 l_out.append(opt);
765 }
766 }
767 if(ret)
768 l = l_out;
769 else
770 break;
771 }
772 }
773}
774
775void
776MetrowerksMakefileGenerator::processPrlVariable(const QString &var, const QStringList &l)
777{
778 if(var == "QMAKE_PRL_LIBS") {
779 QStringList &out = project->variables()["QMAKE_LIBS"];
780 for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
781 bool append = TRUE;
782 if((*it).startsWith("-")) {
783 if((*it).startsWith("-l") || (*it).startsWith("-L")) {
784 append = out.findIndex((*it)) == -1;
785 } else if((*it).startsWith("-framework")) {
786 ++it;
787 for(QStringList::ConstIterator outit = out.begin();
788 outit != out.end(); ++it) {
789 if((*outit) == "-framework") {
790 ++outit;
791 if((*outit) == (*it)) {
792 append = FALSE;
793 break;
794 }
795 }
796 }
797 }
798 } else if(QFile::exists((*it))) {
799 append = out.findIndex((*it));
800 }
801 if(append)
802 out.append((*it));
803 }
804 } else {
805 MakefileGenerator::processPrlVariable(var, l);
806 }
807}
808
809
810bool
811MetrowerksMakefileGenerator::openOutput(QFile &file) const
812{
813 QString outdir;
814 if(!file.name().isEmpty()) {
815 QFileInfo fi(file);
816 if(fi.isDir())
817 outdir = file.name() + QDir::separator();
818 }
819 if(!outdir.isEmpty() || file.name().isEmpty())
820 file.setName(outdir + project->first("TARGET") + ".xml");
821 return MakefileGenerator::openOutput(file);
822}
diff --git a/qmake/generators/mac/metrowerks_xml.h b/qmake/generators/mac/metrowerks_xml.h
new file mode 100644
index 0000000..ae3cfae
--- a/dev/null
+++ b/qmake/generators/mac/metrowerks_xml.h
@@ -0,0 +1,69 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Created : 970521
7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9**
10** This file is part of the network module of the Qt GUI Toolkit.
11**
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
14** LICENSE.QPL included in the packaging of this file.
15**
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
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software.
24**
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.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37#ifndef __METROWERKSMAKE_H__
38#define __METROWERKSMAKE_H__
39
40#include "makefile.h"
41
42class MetrowerksMakefileGenerator : public MakefileGenerator
43{
44 bool createFork(const QString &f);
45 bool fixifyToMacPath(QString &c, QString &v, bool exists=TRUE);
46
47 bool init_flag;
48
49 bool writeMakeParts(QTextStream &);
50 bool writeSubDirs(QTextStream &);
51
52 bool writeMakefile(QTextStream &);
53 QString findTemplate(QString file);
54 void init();
55public:
56 MetrowerksMakefileGenerator(QMakeProject *p);
57 ~MetrowerksMakefileGenerator();
58
59 bool openOutput(QFile &file) const;
60protected:
61 virtual void processPrlFiles();
62 virtual void processPrlVariable(const QString &var, const QStringList &l);
63 virtual bool doDepends() const { return FALSE; } //never necesary
64};
65
66inline MetrowerksMakefileGenerator::~MetrowerksMakefileGenerator()
67{ }
68
69#endif /* __METROWERKSMAKE_H__ */
diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp
new file mode 100644
index 0000000..8525058
--- a/dev/null
+++ b/qmake/generators/mac/pbuilder_pbx.cpp
@@ -0,0 +1,983 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Created : 970521
7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9**
10** This file is part of the network module of the Qt GUI Toolkit.
11**
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
14** LICENSE.QPL included in the packaging of this file.
15**
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
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software.
24**
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.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38#include "pbuilder_pbx.h"
39#include "option.h"
40#include <qdir.h>
41#include <qdict.h>
42#include <qregexp.h>
43#include <stdlib.h>
44#include <time.h>
45#ifdef Q_OS_UNIX
46# include <sys/types.h>
47# include <sys/stat.h>
48#endif
49
50// Note: this is fairly hacky, but it does the job...
51
52
53ProjectBuilderMakefileGenerator::ProjectBuilderMakefileGenerator(QMakeProject *p) : UnixMakefileGenerator(p)
54{
55
56}
57
58bool
59ProjectBuilderMakefileGenerator::writeMakefile(QTextStream &t)
60{
61 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {
62 /* for now just dump, I need to generated an empty xml or something.. */
63 fprintf(stderr, "Project file not generated because all requirements not met:\n\t%s\n",
64 var("QMAKE_FAILED_REQUIREMENTS").latin1());
65 return TRUE;
66 }
67
68 project->variables()["MAKEFILE"].clear();
69 project->variables()["MAKEFILE"].append("Makefile");
70 if(project->first("TEMPLATE") == "app" || project->first("TEMPLATE") == "lib") {
71 return writeMakeParts(t);
72 } else if(project->first("TEMPLATE") == "subdirs") {
73 writeSubdirs(t, FALSE);
74 return TRUE;
75 }
76 return FALSE;
77}
78
79bool
80ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
81{
82 int i;
83 QStringList tmp;
84 bool did_preprocess = FALSE;
85
86 //HEADER
87 t << "// !$*UTF8*$!" << "\n"
88 << "{" << "\n"
89 << "\t" << "archiveVersion = 1;" << "\n"
90 << "\t" << "classes = {" << "\n" << "\t" << "};" << "\n"
91 << "\t" << "objectVersion = " << pbuilderVersion() << ";" << "\n"
92 << "\t" << "objects = {" << endl;
93
94 //MAKE QMAKE equivlant
95 if(!project->isActiveConfig("no_autoqmake") && project->projectFile() != "(stdin)") {
96 QString mkfile = pbx_dir + Option::dir_sep + "qt_makeqmake.mak";
97 QFile mkf(mkfile);
98 if(mkf.open(IO_WriteOnly | IO_Translate)) {
99 debug_msg(1, "pbuilder: Creating file: %s", mkfile.latin1());
100 QTextStream mkt(&mkf);
101 writeHeader(mkt);
102 mkt << "QMAKE = "<<
103 (project->isEmpty("QMAKE_QMAKE") ? QString("$(QTDIR)/bin/qmake") :
104 var("QMAKE_QMAKE")) << endl;
105 writeMakeQmake(mkt);
106 mkf.close();
107 }
108 QString phase_key = keyFor("QMAKE_PBX_MAKEQMAKE_BUILDPHASE");
109 mkfile = fileFixify(mkfile, QDir::currentDirPath());
110 project->variables()["QMAKE_PBX_BUILDPHASES"].append(phase_key);
111 t << "\t\t" << phase_key << " = {" << "\n"
112 << "\t\t\t" << "buildActionMask = 2147483647;" << "\n"
113 << "\t\t\t" << "files = (" << "\n"
114 << "\t\t\t" << ");" << "\n"
115 << "\t\t\t" << "generatedFileNames = (" << "\n"
116 << "\t\t\t" << ");" << "\n"
117 << "\t\t\t" << "isa = PBXShellScriptBuildPhase;" << "\n"
118 << "\t\t\t" << "name = \"Qt Qmake\";" << "\n"
119 << "\t\t\t" << "neededFileNames = (" << "\n"
120 << "\t\t\t" << ");" << "\n"
121 << "\t\t\t" << "shellPath = /bin/sh;" << "\n"
122 << "\t\t\t" << "shellScript = \"make -C " << QDir::currentDirPath() <<
123 " -f " << mkfile << "\";" << "\n"
124 << "\t\t" << "};" << "\n";
125 }
126
127 //DUMP SOURCES
128 QMap<QString, QStringList> groups;
129 QString srcs[] = { "SOURCES", "SRCMOC", "UICIMPLS", QString::null };
130 for(i = 0; !srcs[i].isNull(); i++) {
131 tmp = project->variables()[srcs[i]];
132 QStringList &src_list = project->variables()["QMAKE_PBX_" + srcs[i]];
133 for(QStringList::Iterator it = tmp.begin(); it != tmp.end(); ++it) {
134 QString file = fileFixify((*it));
135 if(file.endsWith(Option::moc_ext))
136 continue;
137 bool in_root = TRUE;
138 QString src_key = keyFor(file);
139 if(!project->isActiveConfig("flat")) {
140 QString flat_file = fileFixify(file, QDir::currentDirPath(), Option::output_dir, TRUE);
141 if(QDir::isRelativePath(flat_file) && flat_file.find(Option::dir_sep) != -1) {
142 QString last_grp("QMAKE_PBX_" + srcs[i] + "_HEIR_GROUP");
143 QStringList dirs = QStringList::split(Option::dir_sep, flat_file);
144 dirs.pop_back(); //remove the file portion as it will be added via src_key
145 for(QStringList::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) {
146 QString new_grp(last_grp + Option::dir_sep + (*dir_it)),
147 new_grp_key(keyFor(new_grp)), last_grp_key(keyFor(last_grp));
148 if(dir_it == dirs.begin()) {
149 if(!groups.contains(new_grp))
150 project->variables()["QMAKE_PBX_" + srcs[i]].append(new_grp_key);
151 } else {
152 groups[last_grp] += new_grp_key;
153 }
154 last_grp = new_grp;
155 }
156 groups[last_grp] += src_key;
157 in_root = FALSE;
158 }
159 }
160 if(in_root)
161 src_list.append(src_key);
162 //source reference
163 t << "\t\t" << src_key << " = {" << "\n"
164 << "\t\t\t" << "isa = PBXFileReference;" << "\n"
165 << "\t\t\t" << "path = \"" << file << "\";" << "\n"
166 << "\t\t\t" << "refType = " << reftypeForFile(file) << ";" << "\n"
167 << "\t\t" << "};" << "\n";
168 //build reference
169 QString obj_key = file + ".o";
170 obj_key = keyFor(obj_key);
171 t << "\t\t" << obj_key << " = {" << "\n"
172 << "\t\t\t" << "fileRef = " << src_key << ";" << "\n"
173 << "\t\t\t" << "isa = PBXBuildFile;" << "\n"
174 << "\t\t\t" << "settings = {" << "\n"
175 << "\t\t\t\t" << "ATTRIBUTES = (" << "\n"
176 << "\t\t\t\t" << ");" << "\n"
177 << "\t\t\t" << "};" << "\n"
178 << "\t\t" << "};" << "\n";
179 project->variables()["QMAKE_PBX_OBJ"].append(obj_key);
180 }
181 if(!src_list.isEmpty()) {
182 QString grp;
183 if(srcs[i] == "SOURCES") {
184 if(project->first("TEMPLATE") == "app" && !project->isEmpty("RC_FILE")) { //Icon
185 QString icns_file = keyFor("ICNS_FILE");
186 src_list.append(icns_file);
187 t << "\t\t" << icns_file << " = {" << "\n"
188 << "\t\t\t" << "isa = PBXFileReference;" << "\n"
189 << "\t\t\t" << "path = \"" << project->first("RC_FILE") << "\";" << "\n"
190 << "\t\t\t" << "refType = " << reftypeForFile(project->first("RC_FILE")) << ";" << "\n"
191 << "\t\t" << "};" << "\n";
192 t << "\t\t" << keyFor("ICNS_FILE_REFERENCE") << " = {" << "\n"
193 << "\t\t\t" << "fileRef = " << icns_file << ";" << "\n"
194 << "\t\t\t" << "isa = PBXBuildFile;" << "\n"
195 << "\t\t\t" << "settings = {" << "\n"
196 << "\t\t\t" << "};" << "\n"
197 << "\t\t" << "};" << "\n";
198 }
199 grp = "Sources";
200 } else if(srcs[i] == "SRCMOC") {
201 grp = "Mocables";
202 } else if(srcs[i] == "UICIMPLS") {
203 grp = "UICables";
204 }
205 QString grp_key = keyFor(grp);
206 project->variables()["QMAKE_PBX_GROUPS"].append(grp_key);
207 t << "\t\t" << grp_key << " = {" << "\n"
208 << "\t\t\t" << "children = (" << "\n"
209 << varGlue("QMAKE_PBX_" + srcs[i], "\t\t\t\t", ",\n\t\t\t\t", "\n")
210 << "\t\t\t" << ");" << "\n"
211 << "\t\t\t" << "isa = PBXGroup;" << "\n"
212 << "\t\t\t" << "name = " << grp << ";" << "\n"
213 << "\t\t\t" << "refType = 4;" << "\n"
214 << "\t\t" << "};" << "\n";
215 }
216 }
217 for(QMap<QString, QStringList>::Iterator grp_it = groups.begin();
218 grp_it != groups.end(); ++grp_it) {
219 t << "\t\t" << keyFor(grp_it.key()) << " = {" << "\n"
220 << "\t\t\t" << "isa = PBXGroup;" << "\n"
221 << "\t\t\t" << "children = (" << "\n"
222 << valGlue(grp_it.data(), "\t\t\t\t", ",\n\t\t\t\t", "\n")
223 << "\t\t\t" << ");" << "\n"
224 << "\t\t\t" << "name = \"" << grp_it.key().section(Option::dir_sep, -1) << "\";" << "\n"
225 << "\t\t\t" << "refType = 4;" << "\n"
226 << "\t\t" << "};" << "\n";
227 }
228
229 //PREPROCESS BUILDPHASE (just a makefile)
230 if(!project->isEmpty("UICIMPLS") || !project->isEmpty("SRCMOC") ||
231 !project->isEmpty("YACCSOURCES") || !project->isEmpty("LEXSOURCES")) {
232 QString mkfile = pbx_dir + Option::dir_sep + "qt_preprocess.mak";
233 QFile mkf(mkfile);
234 if(mkf.open(IO_WriteOnly | IO_Translate)) {
235 did_preprocess = TRUE;
236 debug_msg(1, "pbuilder: Creating file: %s", mkfile.latin1());
237 QTextStream mkt(&mkf);
238 writeHeader(mkt);
239 mkt << "MOC = " << var("QMAKE_MOC") << endl;
240 mkt << "UIC = " << var("QMAKE_UIC") << endl;
241 mkt << "LEX = " << var("QMAKE_LEX") << endl;
242 mkt << "LEXFLAGS = " << var("QMAKE_LEXFLAGS") << endl;
243 mkt << "YACC = " << var("QMAKE_YACC") << endl;
244 mkt << "YACCFLAGS = " << var("QMAKE_YACCFLAGS") << endl;
245 mkt << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl;
246 mkt << "MOVE = " << var("QMAKE_MOVE") << endl << endl;
247 mkt << "FORMS = " << varList("UICIMPLS") << endl;
248 mkt << "MOCS = " << varList("SRCMOC") << endl;
249 mkt << "PARSERS =";
250 if(!project->isEmpty("YACCSOURCES")) {
251 QStringList &yaccs = project->variables()["YACCSOURCES"];
252 for(QStringList::Iterator yit = yaccs.begin(); yit != yaccs.end(); ++yit) {
253 QFileInfo fi((*yit));
254 mkt << " " << fi.dirPath() << Option::dir_sep << fi.baseName(TRUE)
255 << Option::yacc_mod << Option::cpp_ext.first();
256 }
257 }
258 if(!project->isEmpty("LEXSOURCES")) {
259 QStringList &lexs = project->variables()["LEXSOURCES"];
260 for(QStringList::Iterator lit = lexs.begin(); lit != lexs.end(); ++lit) {
261 QFileInfo fi((*lit));
262 mkt << " " << fi.dirPath() << Option::dir_sep << fi.baseName(TRUE)
263 << Option::lex_mod << Option::cpp_ext.first();
264 }
265 }
266 mkt << "\n";
267 mkt << "preprocess: $(FORMS) $(MOCS) $(PARSERS)" << endl;
268 mkt << "preprocess_clean: mocclean uiclean parser_clean" << endl << endl;
269 mkt << "mocclean:" << "\n";
270 if(!project->isEmpty("SRCMOC"))
271 mkt << "\t-rm -f $(MOCS)" << "\n";
272 mkt << "uiclean:" << "\n";
273 if(!project->isEmpty("UICIMPLS"))
274 mkt << "\t-rm -f $(FORMS)" << "\n";
275 mkt << "parser_clean:" << "\n";
276 if(!project->isEmpty("YACCSOURCES") || !project->isEmpty("LEXSOURCES"))
277 mkt << "\t-rm -f $(PARSERS)" << "\n";
278 writeUicSrc(mkt, "FORMS");
279 writeMocSrc(mkt, "HEADERS");
280 writeMocSrc(mkt, "SOURCES");
281 writeMocSrc(mkt, "UICDECLS");
282 writeYaccSrc(mkt, "YACCSOURCES");
283 writeLexSrc(mkt, "LEXSOURCES");
284 mkf.close();
285 }
286 QString target_key = keyFor("QMAKE_PBX_PREPROCESS_TARGET");
287 mkfile = fileFixify(mkfile, QDir::currentDirPath());
288 t << "\t\t" << target_key << " = {" << "\n"
289 << "\t\t\t" << "buildArgumentsString = \"-f " << mkfile << "\";" << "\n"
290 << "\t\t\t" << "buildPhases = (" << "\n"
291 << "\t\t\t" << ");" << "\n"
292 << "\t\t\t" << "buildSettings = {" << "\n"
293 << "\t\t\t" << "};" << "\n"
294 << "\t\t\t" << "buildToolPath = \"/usr/bin/gnumake\";"<< "\n"
295 << "\t\t\t" << "buildWorkingDirectory = \"" << QDir::currentDirPath() << "\";" << "\n"
296 << "\t\t\t" << "dependencies = (" << "\n"
297 << "\t\t\t" << ");" << "\n"
298 << "\t\t\t" << "isa = PBXLegacyTarget;" << "\n"
299 << "\t\t\t" << "name = QtPreprocessors;" << "\n"
300 << "\t\t\t" << "productName = QtPreprocessors;" << "\n"
301 << "\t\t\t" << "settingsToExpand = 6;" << "\n"
302 << "\t\t\t" << "settingsToPassInEnvironment = 287;" << "\n"
303 << "\t\t\t" << "settingsToPassOnCommandLine = 280;" << "\n"
304 << "\t\t\t" << "shouldsUseHeadermap = 0;" << "\n"
305 << "\t\t" << "};" << "\n";
306
307 QString target_depend_key = keyFor("QMAKE_PBX_PREPROCESS_TARGET_DEPEND");
308 project->variables()["QMAKE_PBX_TARGETDEPENDS"].append(target_depend_key);
309 t << "\t\t" << target_depend_key << " = {" << "\n"
310 << "\t\t\t" << "isa = PBXTargetDependency;" << "\n"
311 << "\t\t\t" << "target = " << target_key << ";" << "\n"
312 << "\t\t" << "};" << "\n";
313 }
314 //SOURCE BUILDPHASE
315 if(!project->isEmpty("QMAKE_PBX_OBJ")) {
316 QString grp = "Build Sources", key = keyFor(grp);
317 project->variables()["QMAKE_PBX_BUILDPHASES"].append(key);
318 t << "\t\t" << key << " = {" << "\n"
319 << "\t\t\t" << "buildActionMask = 2147483647;" << "\n"
320 << "\t\t\t" << "files = (" << "\n"
321 << varGlue("QMAKE_PBX_OBJ", "\t\t\t\t", ",\n\t\t\t\t", "\n")
322 << "\t\t\t" << ");" << "\n"
323 << "\t\t\t" << "isa = PBXSourcesBuildPhase;" << "\n"
324 << "\t\t\t" << "name = \"" << grp << "\";" << "\n"
325 << "\t\t" << "};" << "\n";
326 }
327
328 if(!project->isActiveConfig("staticlib")) { //DUMP LIBRARIES
329 QStringList &libdirs = project->variables()["QMAKE_PBX_LIBPATHS"];
330 QString libs[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_LIBS", QString::null };
331 for(i = 0; !libs[i].isNull(); i++) {
332 tmp = project->variables()[libs[i]];
333 for(QStringList::Iterator it = tmp.begin(); it != tmp.end();) {
334 bool remove = FALSE;
335 QString library, name, opt = (*it).stripWhiteSpace();
336 if(opt.startsWith("-L")) {
337 QString r = opt.right(opt.length() - 2);
338 fixEnvVariables(r);
339 libdirs.append(r);
340 } else if(opt.startsWith("-l")) {
341 name = opt.right(opt.length() - 2);
342 QString lib("lib" + name);
343 for(QStringList::Iterator lit = libdirs.begin(); lit != libdirs.end(); ++lit) {
344 if(project->isActiveConfig("link_prl")) {
345 /* This isn't real nice, but it is real usefull. This looks in a prl
346 for what the library will ultimately be called so we can stick it
347 in the ProjectFile. If the prl format ever changes (not likely) then
348 this will not really work. However, more concerning is that it will
349 encode the version number in the Project file which might be a bad
350 things in days to come? --Sam
351 */
352 QString prl_file = (*lit) + Option::dir_sep + lib + Option::prl_ext;
353 if(QFile::exists(prl_file)) {
354 QMakeProject proj;
355 if(proj.read(prl_file, QDir::currentDirPath())) {
356 if(!proj.isEmpty("QMAKE_PRL_TARGET")) {
357 library = (*lit) + Option::dir_sep + proj.first("QMAKE_PRL_TARGET");
358 debug_msg(1, "pbuilder: Found library (%s) via PRL %s (%s)",
359 opt.latin1(), prl_file.latin1(), library.latin1());
360 remove = TRUE;
361 }
362 }
363
364 }
365 }
366 if(!remove) {
367 QString extns[] = { ".dylib", ".so", ".a", QString::null };
368 for(int n = 0; !remove && !extns[n].isNull(); n++) {
369 QString tmp = (*lit) + Option::dir_sep + lib + extns[n];
370 if(QFile::exists(tmp)) {
371 library = tmp;
372 debug_msg(1, "pbuilder: Found library (%s) via %s",
373 opt.latin1(), library.latin1());
374 remove = TRUE;
375 }
376 }
377 }
378 }
379 } else if(opt == "-framework") {
380 ++it;
381 if(it == tmp.end())
382 break;
383 QStringList &fdirs = project->variables()["QMAKE_FRAMEWORKDIR"];
384 if(fdirs.isEmpty())
385 fdirs.append("/System/Library/Frameworks/");
386 for(QStringList::Iterator fit = fdirs.begin(); fit != fdirs.end(); ++fit) {
387 if(QFile::exists((*fit) + QDir::separator() + (*it) + ".framework")) {
388 --it;
389 it = tmp.remove(it);
390 remove = TRUE;
391 library = (*fit) + Option::dir_sep + (*it) + ".framework";
392 break;
393 }
394 }
395 } else if(opt.left(1) != "-") {
396 remove = TRUE;
397 library = opt;
398 }
399 if(!library.isEmpty()) {
400 if(name.isEmpty()) {
401 int slsh = library.findRev(Option::dir_sep);
402 if(slsh != -1)
403 name = library.right(library.length() - slsh - 1);
404 }
405 library = fileFixify(library);
406 QString key = keyFor(library);
407 bool is_frmwrk = (library.endsWith(".framework"));
408 t << "\t\t" << key << " = {" << "\n"
409 << "\t\t\t" << "isa = " << (is_frmwrk ? "PBXFrameworkReference" : "PBXFileReference") << ";" << "\n"
410 << "\t\t\t" << "name = \"" << name << "\";" << "\n"
411 << "\t\t\t" << "path = \"" << library << "\";" << "\n"
412 << "\t\t\t" << "refType = " << reftypeForFile(library) << ";" << "\n"
413 << "\t\t" << "};" << "\n";
414 project->variables()["QMAKE_PBX_LIBRARIES"].append(key);
415 QString obj_key = library + ".o";
416 obj_key = keyFor(obj_key);
417 t << "\t\t" << obj_key << " = {" << "\n"
418 << "\t\t\t" << "fileRef = " << key << ";" << "\n"
419 << "\t\t\t" << "isa = PBXBuildFile;" << "\n"
420 << "\t\t\t" << "settings = {" << "\n"
421 << "\t\t\t" << "};" << "\n"
422 << "\t\t" << "};" << "\n";
423 project->variables()["QMAKE_PBX_BUILD_LIBRARIES"].append(obj_key);
424 }
425 if(remove)
426 it = tmp.remove(it);
427 else
428 ++it;
429 }
430 project->variables()[libs[i]] = tmp;
431 }
432 }
433 //SUBLIBS BUILDPHASE (just another makefile)
434 if(!project->isEmpty("SUBLIBS")) {
435 QString mkfile = pbx_dir + Option::dir_sep + "qt_sublibs.mak";
436 QFile mkf(mkfile);
437 if(mkf.open(IO_WriteOnly | IO_Translate)) {
438 debug_msg(1, "pbuilder: Creating file: %s", mkfile.latin1());
439 QTextStream mkt(&mkf);
440 writeHeader(mkt);
441 mkt << "SUBLIBS= ";
442 tmp = project->variables()["SUBLIBS"];
443 QStringList::Iterator it;
444 for(it = tmp.begin(); it != tmp.end(); ++it)
445 t << "tmp/lib" << (*it) << ".a ";
446 t << endl << endl;
447 mkt << "sublibs: $(SUBLIBS)" << endl << endl;
448 tmp = project->variables()["SUBLIBS"];
449 for(it = tmp.begin(); it != tmp.end(); ++it)
450 t << "tmp/lib" << (*it) << ".a" << ":\n\t"
451 << var(QString("MAKELIB") + (*it)) << endl << endl;
452 mkf.close();
453 }
454 QString phase_key = keyFor("QMAKE_PBX_SUBLIBS_BUILDPHASE");
455 mkfile = fileFixify(mkfile, QDir::currentDirPath());
456 project->variables()["QMAKE_PBX_BUILDPHASES"].append(phase_key);
457 t << "\t\t" << phase_key << " = {" << "\n"
458 << "\t\t\t" << "buildActionMask = 2147483647;" << "\n"
459 << "\t\t\t" << "files = (" << "\n"
460 << "\t\t\t" << ");" << "\n"
461 << "\t\t\t" << "generatedFileNames = (" << "\n"
462 << "\t\t\t" << ");" << "\n"
463 << "\t\t\t" << "isa = PBXShellScriptBuildPhase;" << "\n"
464 << "\t\t\t" << "name = \"Qt Sublibs\";" << "\n"
465 << "\t\t\t" << "neededFileNames = (" << "\n"
466 << "\t\t\t" << ");" << "\n"
467 << "\t\t\t" << "shellPath = /bin/sh;" << "\n"
468 << "\t\t\t" << "shellScript = \"make -C " << QDir::currentDirPath() <<
469 " -f " << mkfile << "\";" << "\n"
470 << "\t\t" << "};" << "\n";
471 }
472 //LIBRARY BUILDPHASE
473 if(!project->isEmpty("QMAKE_PBX_LIBRARIES")) {
474 tmp = project->variables()["QMAKE_PBX_LIBRARIES"];
475 if(!tmp.isEmpty()) {
476 QString grp("External Frameworks and Libraries"), key = keyFor(grp);
477 project->variables()["QMAKE_PBX_GROUPS"].append(key);
478 t << "\t\t" << key << " = {" << "\n"
479 << "\t\t\t" << "children = (" << "\n"
480 << varGlue("QMAKE_PBX_LIBRARIES", "\t\t\t\t", ",\n\t\t\t\t", "\n")
481 << "\t\t\t" << ");" << "\n"
482 << "\t\t\t" << "isa = PBXGroup;" << "\n"
483 << "\t\t\t" << "name = \"" << grp << "\"" << ";" << "\n"
484 << "\t\t\t" << "path = \"\";" << "\n"
485 << "\t\t\t" << "refType = 4;" << "\n"
486 << "\t\t" << "};" << "\n";
487 }
488 }
489 {
490 QString grp("Frameworks & Libraries"), key = keyFor(grp);
491 project->variables()["QMAKE_PBX_BUILDPHASES"].append(key);
492 t << "\t\t" << key << " = {" << "\n"
493 << "\t\t\t" << "buildActionMask = 2147483647;" << "\n"
494 << "\t\t\t" << "files = (" << "\n"
495 << varGlue("QMAKE_PBX_BUILD_LIBRARIES", "\t\t\t\t", ",\n\t\t\t\t", "\n")
496 << "\t\t\t" << ");" << "\n"
497 << "\t\t\t" << "isa = PBXFrameworksBuildPhase;" << "\n"
498 << "\t\t\t" << "name = \"" << grp << "\";" << "\n"
499 << "\t\t" << "};" << "\n";
500 }
501 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console") &&
502 project->first("TEMPLATE") == "app") { //BUNDLE RESOURCES
503 QString grp("Bundle Resources"), key = keyFor(grp);
504 project->variables()["QMAKE_PBX_BUILDPHASES"].append(key);
505 t << "\t\t" << key << " = {" << "\n"
506 << "\t\t\t" << "buildActionMask = 2147483647;" << "\n"
507 << "\t\t\t" << "files = (" << "\n"
508 << (!project->isEmpty("RC_FILE") ? keyFor("ICNS_FILE_REFERENCE") : QString(""))
509 << "\t\t\t" << ");" << "\n"
510 << "\t\t\t" << "isa = PBXResourcesBuildPhase;" << "\n"
511 << "\t\t\t" << "name = \"" << grp << "\";" << "\n"
512 << "\t\t" << "};" << "\n";
513 }
514
515 //DUMP EVERYTHING THAT TIES THE ABOVE TOGETHER
516 //PRODUCTS
517 {
518 QString grp("Products"), key = keyFor(grp);
519 project->variables()["QMAKE_PBX_GROUPS"].append(key);
520 t << "\t\t" << key << " = {" << "\n"
521 << "\t\t\t" << "children = (" << "\n"
522 << "\t\t\t\t" << keyFor("QMAKE_PBX_REFERENCE") << "\n"
523 << "\t\t\t" << ");" << "\n"
524 << "\t\t\t" << "isa = PBXGroup;" << "\n"
525 << "\t\t\t" << "name = Products;" << "\n"
526 << "\t\t\t" << "refType = 4;" << "\n"
527 << "\t\t" << "};" << "\n";
528 }
529 { //INSTALL BUILDPHASE (sh script)
530 QString targ = project->first("TARGET");
531 if(project->first("TEMPLATE") == "app" ||
532 (project->first("TEMPLATE") == "lib" && !project->isActiveConfig("staticlib") &&
533 project->isActiveConfig("frameworklib")))
534 targ = project->first("QMAKE_ORIG_TARGET");
535 int slsh = targ.findRev(Option::dir_sep);
536 if(slsh != -1)
537 targ = targ.right(targ.length() - slsh - 1);
538 fixEnvVariables(targ);
539 QStringList links;
540 if(project->first("TEMPLATE") == "app") {
541 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console"))
542 targ += ".app";
543 } else if(!project->isActiveConfig("staticlib") &&
544 !project->isActiveConfig("frameworklib")) {
545 QString li[] = { "TARGET_", "TARGET_x", "TARGET_x.y", QString::null };
546 for(int n = 0; !li[n].isNull(); n++) {
547 QString t = project->first(li[n]);
548 slsh = t.findRev(Option::dir_sep);
549 if(slsh != -1)
550 t = t.right(t.length() - slsh);
551 fixEnvVariables(t);
552 links << t;
553 }
554 }
555 QString script = pbx_dir + Option::dir_sep + "qt_install.sh";
556 QFile shf(script);
557 if(shf.open(IO_WriteOnly | IO_Translate)) {
558 debug_msg(1, "pbuilder: Creating file: %s", script.latin1());
559 QString targ = project->first("QMAKE_ORIG_TARGET"), cpflags;
560 if(project->first("TEMPLATE") == "app") {
561 targ = project->first("TARGET");
562 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) {
563 targ += ".app";
564 cpflags += "-r ";
565 }
566 } else if(!project->isActiveConfig("frameworklib")) {
567 if(project->isActiveConfig("staticlib"))
568 targ = project->first("TARGET");
569 else
570 targ = project->first("TARGET_");
571 int slsh = targ.findRev(Option::dir_sep);
572 if(slsh != -1)
573 targ = targ.right(targ.length() - slsh - 1);
574 }
575 QTextStream sht(&shf);
576 QString dstdir = project->first("DESTDIR");
577 fixEnvVariables(dstdir);
578
579 sht << "#!/bin/sh" << endl;
580 //copy the actual target
581 sht << "OUT_TARG=\"" << targ << "\"\n"
582 << "[ -z \"$BUILD_ROOT\" ] || OUT_TARG=\"${BUILD_ROOT}/${OUT_TARG}\"" << endl;
583 sht << "[ \"$OUT_TARG\" = \""
584 << (dstdir.isEmpty() ? QDir::currentDirPath() + QDir::separator(): dstdir) << targ << "\" ] || "
585 << "[ \"$OUT_TARG\" = \"" << targ << "\" ] || "
586 << "cp -r \"$OUT_TARG\" " << "\"" << dstdir << targ << "\"" << endl;
587 //rename as a framework
588 if(project->first("TEMPLATE") == "lib" && project->isActiveConfig("frameworklib"))
589 sht << "ln -sf \"" << targ << "\" " << "\"" << dstdir << targ << "\"" << endl;
590 //create all the version symlinks (just to be like unixmake)
591 for(QStringList::Iterator it = links.begin(); it != links.end(); ++it) {
592 if(targ != (*it))
593 sht << "ln -sf \"" << targ << "\" " << "\"" << dstdir << (*it) << "\"" << endl;
594 }
595 shf.close();
596#ifdef Q_OS_UNIX
597 chmod(script.latin1(), S_IRWXU | S_IRWXG);
598#endif
599 QString phase_key = keyFor("QMAKE_PBX_INSTALL_BUILDPHASE");
600 script = fileFixify(script, QDir::currentDirPath());
601 project->variables()["QMAKE_PBX_BUILDPHASES"].append(phase_key);
602 t << "\t\t" << phase_key << " = {" << "\n"
603 << "\t\t\t" << "buildActionMask = 8;" << "\n" //only on install!
604 << "\t\t\t" << "files = (" << "\n"
605 << "\t\t\t" << ");" << "\n"
606 << "\t\t\t" << "generatedFileNames = (" << "\n"
607 << "\t\t\t" << ");" << "\n"
608 << "\t\t\t" << "isa = PBXShellScriptBuildPhase;" << "\n"
609 << "\t\t\t" << "name = \"Qt Install\";" << "\n"
610 << "\t\t\t" << "neededFileNames = (" << "\n"
611 << "\t\t\t" << ");" << "\n"
612 << "\t\t\t" << "shellPath = /bin/sh;" << "\n"
613 << "\t\t\t" << "shellScript = \"" << script << "\";" << "\n"
614 << "\t\t" << "};" << "\n";
615 }
616 }
617 //ROOT_GROUP
618 t << "\t\t" << keyFor("QMAKE_PBX_ROOT_GROUP") << " = {" << "\n"
619 << "\t\t\t" << "children = (" << "\n"
620 << varGlue("QMAKE_PBX_GROUPS", "\t\t\t\t", ",\n\t\t\t\t", "\n")
621 << "\t\t\t" << ");" << "\n"
622 << "\t\t\t" << "isa = PBXGroup;" << "\n"
623 << "\t\t\t" << "name = " << project->first("QMAKE_ORIG_TARGET") << ";" << "\n"
624 << "\t\t\t" << "path = \"\";" << "\n"
625 << "\t\t\t" << "refType = 4;" << "\n"
626 << "\t\t" << "};" << "\n";
627 //REFERENCE
628 t << "\t\t" << keyFor("QMAKE_PBX_REFERENCE") << " = {" << "\n";
629 if(project->first("TEMPLATE") == "app") {
630 QString targ = project->first("QMAKE_ORIG_TARGET");
631 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) {
632 targ += ".app";
633 t << "\t\t\t" << "isa = PBXApplicationReference;" << "\n";
634 } else {
635 t << "\t\t\t" << "isa = PBXExecutableFileReference;" << "\n";
636 }
637 QString app = (!project->isEmpty("DESTDIR") ? project->first("DESTDIR") + project->first("QMAKE_ORIG_TARGET") :
638 QDir::currentDirPath()) + Option::dir_sep + targ;
639 t << "\t\t\t" << "name = " << targ << ";" << "\n"
640 << "\t\t\t" << "path = \"" << targ << "\";" << "\n"
641 << "\t\t\t" << "refType = " << reftypeForFile(app) << ";" << "\n";
642 } else {
643 QString lib = project->first("QMAKE_ORIG_TARGET");
644 if(project->isActiveConfig("staticlib")) {
645 lib = project->first("TARGET");
646 } else if(!project->isActiveConfig("frameworklib")) {
647 if(project->isActiveConfig("plugin"))
648 lib = project->first("TARGET");
649 else
650 lib = project->first("TARGET_");
651 }
652 int slsh = lib.findRev(Option::dir_sep);
653 if(slsh != -1)
654 lib = lib.right(lib.length() - slsh - 1);
655 t << "\t\t\t" << "isa = PBXLibraryReference;" << "\n"
656 << "\t\t\t" << "path = " << lib << ";\n"
657 << "\t\t\t" << "refType = " << reftypeForFile(lib) << ";" << "\n";
658 }
659 t << "\t\t" << "};" << "\n";
660 //TARGET
661 t << "\t\t" << keyFor("QMAKE_PBX_TARGET") << " = {" << "\n"
662 << "\t\t\t" << "buildPhases = (" << "\n"
663 << varGlue("QMAKE_PBX_BUILDPHASES", "\t\t\t\t", ",\n\t\t\t\t", "\n")
664 << "\t\t\t" << ");" << "\n"
665 << "\t\t\t" << "buildSettings = {" << "\n"
666 << "\t\t\t\t" << "FRAMEWORK_SEARCH_PATHS = \"\";" << "\n"
667 << "\t\t\t\t" << "HEADER_SEARCH_PATHS = \"" << fixEnvsList("INCLUDEPATH") << " " << fixEnvs(specdir()) << "\";" << "\n"
668 << "\t\t\t\t" << "LIBRARY_SEARCH_PATHS = \"" << var("QMAKE_PBX_LIBPATHS") << "\";" << "\n"
669 << "\t\t\t\t" << "OPTIMIZATION_CFLAGS = \"\";" << "\n"
670 << "\t\t\t\t" << "OTHER_CFLAGS = \"" <<
671 fixEnvsList("QMAKE_CFLAGS") << varGlue("PRL_EXPORT_DEFINES"," -D"," -D","") <<
672 varGlue("DEFINES"," -D"," -D","") << "\";" << "\n"
673 << "\t\t\t\t" << "LEXFLAGS = \"" << var("QMAKE_LEXFLAGS") << "\";" << "\n"
674 << "\t\t\t\t" << "YACCFLAGS = \"" << var("QMAKE_YACCFLAGS") << "\";" << "\n"
675 << "\t\t\t\t" << "OTHER_CPLUSPLUSFLAGS = \"" <<
676 fixEnvsList("QMAKE_CXXFLAGS") << varGlue("PRL_EXPORT_DEFINES"," -D"," -D","") <<
677 varGlue("DEFINES"," -D"," -D","") << "\";" << "\n"
678 << "\t\t\t\t" << "OTHER_REZFLAGS = \"\";" << "\n"
679 << "\t\t\t\t" << "SECTORDER_FLAGS = \"\";" << "\n"
680 << "\t\t\t\t" << "WARNING_CFLAGS = \"\";" << "\n";
681#if 1
682 t << "\t\t\t\t" << "BUILD_ROOT = \"" << QDir::currentDirPath() << "\";" << "\n";
683#endif
684 if(!project->isActiveConfig("staticlib"))
685 t << "\t\t\t\t" << "OTHER_LDFLAGS = \"" << fixEnvsList("SUBLIBS") << " " <<
686 fixEnvsList("QMAKE_LFLAGS") << " " << fixEnvsList("QMAKE_LIBDIR_FLAGS") <<
687 " " << fixEnvsList("QMAKE_LIBS") << "\";" << "\n";
688 if(!project->isEmpty("DESTDIR"))
689 t << "\t\t\t\t" << "INSTALL_PATH = \"" << project->first("DESTDIR") << "\";" << "\n";
690 if(!project->isEmpty("VERSION") && project->first("VERSION") != "0.0.0")
691 t << "\t\t\t\t" << "DYLIB_CURRENT_VERSION = \"" << project->first("VERSION") << "\";" << "\n";
692 if(!project->isEmpty("OBJECTS_DIR"))
693 t << "\t\t\t\t" << "OBJECT_FILE_DIR = \"" << project->first("OBJECTS_DIR") << "\";" << "\n";
694 if(project->first("TEMPLATE") == "app") {
695 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console"))
696 t << "\t\t\t\t" << "WRAPPER_EXTENSION = app;" << "\n";
697 t << "\t\t\t\t" << "PRODUCT_NAME = " << project->first("QMAKE_ORIG_TARGET") << ";" << "\n";
698 } else {
699 QString lib = project->first("QMAKE_ORIG_TARGET");
700 if(!project->isActiveConfig("plugin") && project->isActiveConfig("staticlib")) {
701 t << "\t\t\t\t" << "LIBRARY_STYLE = STATIC;" << "\n";
702 lib = project->first("TARGET");
703 } else {
704 t << "\t\t\t\t" << "LIBRARY_STYLE = DYNAMIC;" << "\n";
705 if(!project->isActiveConfig("frameworklib")) {
706 if(project->isActiveConfig("plugin"))
707 lib = project->first("TARGET");
708 else
709 lib = project->first("TARGET_");
710 }
711 }
712 int slsh = lib.findRev(Option::dir_sep);
713 if(slsh != -1)
714 lib = lib.right(lib.length() - slsh - 1);
715 t << "\t\t\t\t" << "PRODUCT_NAME = " << lib << ";" << "\n";
716 }
717 tmp = project->variables()["QMAKE_PBX_VARS"];
718 for(QStringList::Iterator it = tmp.begin(); it != tmp.end(); ++it)
719 t << "\t\t\t\t" << (*it) << " = \"" << getenv((*it)) << "\";" << "\n";
720 t << "\t\t\t" << "};" << "\n"
721 << "\t\t\t" << "conditionalBuildSettings = {" << "\n"
722 << "\t\t\t" << "};" << "\n"
723 << "\t\t\t" << "dependencies = (" << "\n"
724 << varGlue("QMAKE_PBX_TARGETDEPENDS", "\t\t\t\t", ",\n\t\t\t\t", "\n")
725 << "\t\t\t" << ");" << "\n"
726 << "\t\t\t" << "productReference = " << keyFor("QMAKE_PBX_REFERENCE") << ";" << "\n"
727 << "\t\t\t" << "shouldUseHeadermap = 1;" << "\n";
728 if(project->first("TEMPLATE") == "app") {
729 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) {
730 t << "\t\t\t" << "isa = PBXApplicationTarget;" << "\n"
731 << "\t\t\t" << "productSettingsXML = " << "\"" << "<?xml version="
732 << "\\\"1.0\\\" encoding=" << "\\\"UTF-8\\\"" << "?>" << "\n"
733 << "\t\t\t\t" << "<!DOCTYPE plist SYSTEM \\\"file://localhost/System/"
734 << "Library/DTDs/PropertyList.dtd\\\">" << "\n"
735 << "\t\t\t\t" << "<plist version=\\\"0.9\\\">" << "\n"
736 << "\t\t\t\t" << "<dict>" << "\n"
737 << "\t\t\t\t\t" << "<key>CFBundleDevelopmentRegion</key>" << "\n"
738 << "\t\t\t\t\t" << "<string>English</string>" << "\n"
739 << "\t\t\t\t\t" << "<key>CFBundleExecutable</key>" << "\n"
740 << "\t\t\t\t\t" << "<string>" << project->first("QMAKE_ORIG_TARGET") << "</string>" << "\n"
741 << "\t\t\t\t\t" << "<key>CFBundleIconFile</key>" << "\n"
742 << "\t\t\t\t\t" << "<string>" << var("RC_FILE").section(Option::dir_sep, -1) << "</string>" << "\n"
743 << "\t\t\t\t\t" << "<key>CFBundleInfoDictionaryVersion</key>" << "\n"
744 << "\t\t\t\t\t" << "<string>6.0</string>" << "\n"
745 << "\t\t\t\t\t" << "<key>CFBundlePackageType</key>" << "\n"
746 << "\t\t\t\t\t" << "<string>APPL</string>" << "\n"
747 << "\t\t\t\t\t" << "<key>CFBundleSignature</key>" << "\n"
748 << "\t\t\t\t\t" << "<string>????</string>" << "\n"
749 << "\t\t\t\t\t" << "<key>CFBundleVersion</key>" << "\n"
750 << "\t\t\t\t\t" << "<string>0.1</string>" << "\n"
751 << "\t\t\t\t\t" << "<key>CSResourcesFileMapped</key>" << "\n"
752 << "\t\t\t\t\t" << "<true/>" << "\n"
753 << "\t\t\t\t" << "</dict>" << "\n"
754 << "\t\t\t\t" << "</plist>" << "\";" << "\n";
755 } else {
756 t << "\t\t\t" << "isa = PBXToolTarget;" << "\n";
757 }
758 t << "\t\t\t" << "name = \"" << project->first("QMAKE_ORIG_TARGET") << "\";" << "\n"
759 << "\t\t\t" << "productName = " << project->first("QMAKE_ORIG_TARGET") << ";" << "\n";
760 } else {
761 QString lib = project->first("QMAKE_ORIG_TARGET");
762 if(!project->isActiveConfig("frameworklib"))
763 lib.prepend("lib");
764 t << "\t\t\t" << "isa = PBXLibraryTarget;" << "\n"
765 << "\t\t\t" << "name = \"" << lib << "\";" << "\n"
766 << "\t\t\t" << "productName = " << lib << ";" << "\n";
767 }
768 if(!project->isEmpty("DESTDIR"))
769 t << "\t\t\t" << "productInstallPath = \"" << project->first("DESTDIR") << "\";" << "\n";
770 t << "\t\t" << "};" << "\n";
771 //DEBUG/RELEASE
772 for(i = 0; i < 2; i++) {
773 bool as_release = !i;
774 if(project->isActiveConfig("debug"))
775 as_release = i;
776 QString key = "QMAKE_PBX_" + QString(as_release ? "RELEASE" : "DEBUG");
777 key = keyFor(key);
778 project->variables()["QMAKE_PBX_BUILDSTYLES"].append(key);
779 t << "\t\t" << key << " = {" << "\n"
780 << "\t\t\t" << "buildRules = (" << "\n"
781 << "\t\t\t" << ");" << "\n"
782 << "\t\t\t" << "buildSettings = {" << "\n"
783 << "\t\t\t\t" << "COPY_PHASE_STRIP = " << (as_release ? "YES" : "NO") << ";" << "\n";
784 if(as_release)
785 t << "\t\t\t\t" << "DEBUGGING_SYMBOLS = NO;" << "\n";
786 t << "\t\t\t" << "};" << "\n"
787 << "\t\t\t" << "isa = PBXBuildStyle;" << "\n"
788 << "\t\t\t" << "name = " << (as_release ? "Deployment" : "Development") << ";" << "\n"
789 << "\t\t" << "};" << "\n";
790 }
791 //ROOT
792 t << "\t\t" << keyFor("QMAKE_PBX_ROOT") << " = {" << "\n"
793 << "\t\t\t" << "buildStyles = (" << "\n"
794 << varGlue("QMAKE_PBX_BUILDSTYLES", "\t\t\t\t", ",\n\t\t\t\t", "\n")
795 << "\t\t\t" << ");" << "\n"
796 << "\t\t\t" << "isa = PBXProject;" << "\n"
797 << "\t\t\t" << "mainGroup = " << keyFor("QMAKE_PBX_ROOT_GROUP") << ";" << "\n"
798 << "\t\t\t" << "targets = (" << "\n"
799 << "\t\t\t\t" << keyFor("QMAKE_PBX_TARGET") << "\n"
800 << "\t\t\t" << ");" << "\n"
801 << "\t\t" << "};" << "\n";
802
803 //FOOTER
804 t << "\t" << "};" << "\n"
805 << "\t" << "rootObject = " << keyFor("QMAKE_PBX_ROOT") << ";" << "\n"
806 << "}" << endl;
807
808 QString mkwrap = fileFixify(pbx_dir + Option::dir_sep + ".." + Option::dir_sep + project->first("MAKEFILE"),
809 QDir::currentDirPath());
810 QFile mkwrapf(mkwrap);
811 if(mkwrapf.open(IO_WriteOnly | IO_Translate)) {
812 debug_msg(1, "pbuilder: Creating file: %s", mkwrap.latin1());
813 QTextStream mkwrapt(&mkwrapf);
814 writeHeader(mkwrapt);
815 const char *cleans = "uiclean mocclean preprocess_clean ";
816 mkwrapt << "#This is a makefile wrapper for PROJECT BUILDER\n"
817 << "all:" << "\n\t"
818 << "cd " << (project->first("QMAKE_ORIG_TARGET") + ".pbproj/ && pbxbuild") << "\n"
819 << "install: all" << "\n\t"
820 << "cd " << (project->first("QMAKE_ORIG_TARGET") + ".pbproj/ && pbxbuild install") << "\n"
821 << "distclean clean: preprocess_clean" << "\n\t"
822 << "cd " << (project->first("QMAKE_ORIG_TARGET") + ".pbproj/ && pbxbuild clean") << "\n"
823 << (!did_preprocess ? cleans : "") << ":" << "\n";
824 if(did_preprocess)
825 mkwrapt << cleans << ":" << "\n\t"
826 << "make -f "
827 << pbx_dir << Option::dir_sep << "qt_preprocess.mak $@" << endl;
828 }
829 return TRUE;
830}
831
832QString
833ProjectBuilderMakefileGenerator::fixEnvs(QString file)
834{
835 QRegExp reg_var("\\$\\((.*)\\)");
836 for(int rep = 0; (rep = reg_var.search(file, rep)) != -1; ) {
837 if(project->variables()["QMAKE_PBX_VARS"].findIndex(reg_var.cap(1)) == -1)
838 project->variables()["QMAKE_PBX_VARS"].append(reg_var.cap(1));
839 rep += reg_var.matchedLength();
840 }
841 return file;
842}
843
844QString
845ProjectBuilderMakefileGenerator::fixEnvsList(QString where)
846{
847 QString ret;
848 const QStringList &l = project->variables()[where];
849 for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
850 fixEnvs((*it));
851 if(!ret.isEmpty())
852 ret += " ";
853 ret += (*it);
854 }
855 return ret;
856}
857
858QString
859ProjectBuilderMakefileGenerator::keyFor(QString block)
860{
861#if 0 //This make this code much easier to debug..
862 return block;
863#endif
864
865 QString ret;
866 if(!keys.contains(block)) {
867#if 0
868 static unsigned int r = 0;
869 ret.sprintf("%024x", ++r);
870#else //not really necesary, but makes it look more interesting..
871 static struct { unsigned int a1, a2, a3; } r = { 0, 0, 0 };
872 if(!r.a1 && !r.a2 && !r.a3) {
873 r.a1 = rand();
874 r.a2 = rand();
875 r.a3 = rand();
876 }
877 switch(rand() % 3) {
878 case 0: ++r.a1; break;
879 case 1: ++r.a2; break;
880 case 2: ++r.a3; break;
881 }
882 ret.sprintf("%08x%08x%08x", r.a1, r.a2, r.a3);
883#endif
884 ret = ret.upper();
885 keys.insert(block, ret);
886 } else {
887 ret = keys[block];
888 }
889 return ret;
890}
891
892bool
893ProjectBuilderMakefileGenerator::openOutput(QFile &file) const
894{
895 if(project->first("TEMPLATE") != "subdirs") {
896 QFileInfo fi(file);
897 if(fi.extension() != "pbxproj" || file.name().isEmpty()) {
898 QString output = file.name();
899 if(fi.isDir())
900 output += QDir::separator();
901 if(fi.extension() != "pbproj") {
902 if(file.name().isEmpty() || fi.isDir())
903 output += project->first("TARGET");
904 output += QString(".pbproj") + QDir::separator();
905 } else if(output[(int)output.length() - 1] != QDir::separator()) {
906 output += QDir::separator();
907 }
908 output += QString("project.pbxproj");
909 file.setName(output);
910 }
911 bool ret = UnixMakefileGenerator::openOutput(file);
912 ((ProjectBuilderMakefileGenerator*)this)->pbx_dir = Option::output_dir.section(Option::dir_sep, 0, -1);
913 Option::output_dir = pbx_dir.section(Option::dir_sep, 0, -2);
914 return ret;
915 }
916 return UnixMakefileGenerator::openOutput(file);
917}
918
919/* This function is such a hack it is almost pointless, but it
920 eliminates the warning message from ProjectBuilder that the project
921 file is for an older version. I guess this could be used someday if
922 the format of the output is dependant upon the version of
923 ProjectBuilder as well.
924*/
925int
926ProjectBuilderMakefileGenerator::pbuilderVersion() const
927{
928 QString ret;
929 if(project->isEmpty("QMAKE_PBUILDER_VERSION")) {
930 QString version, version_plist = project->first("QMAKE_PBUILDER_VERSION_PLIST");
931 if(version_plist.isEmpty())
932 version_plist = "/Developer/Applications/Project Builder.app/Contents/version.plist";
933 else
934 version_plist = version_plist.replace(QRegExp("\""), "");
935 QFile version_file(version_plist);
936 if(version_file.open(IO_ReadOnly)) {
937 debug_msg(1, "pbuilder: version.plist: Reading file: %s", version_plist.latin1());
938 QTextStream plist(&version_file);
939
940 bool in_dict = FALSE;
941 QString current_key;
942 QRegExp keyreg("^<key>(.*)</key>$"), stringreg("^<string>(.*)</string>$");
943 while(!plist.eof()) {
944 QString line = plist.readLine().stripWhiteSpace();
945 if(line == "<dict>")
946 in_dict = TRUE;
947 else if(line == "</dict>")
948 in_dict = FALSE;
949 else if(in_dict) {
950 if(keyreg.exactMatch(line))
951 current_key = keyreg.cap(1);
952 else if(current_key == "CFBundleShortVersionString" && stringreg.exactMatch(line))
953 version = stringreg.cap(1);
954 }
955 }
956 version_file.close();
957 } else debug_msg(1, "pbuilder: version.plist: Failure to open %s", version_plist.latin1());
958 if(version.startsWith("2.0"))
959 ret = "38";
960 else if(version == "1.1")
961 ret = "34";
962 } else {
963 ret = project->first("QMAKE_PBUILDER_VERSION");
964 }
965 if(!ret.isEmpty()) {
966 bool ok;
967 int int_ret = ret.toInt(&ok);
968 if(ok) {
969 debug_msg(1, "pbuilder: version.plist: Got version: %d", int_ret);
970 return int_ret;
971 }
972 }
973 debug_msg(1, "pbuilder: version.plist: Fallback to default version");
974 return 34; //my fallback
975}
976
977QString
978ProjectBuilderMakefileGenerator::reftypeForFile(QString where)
979{
980 if(QDir::isRelativePath(where))
981 return "4"; //relative
982 return "0"; //absolute
983}
diff --git a/qmake/generators/mac/pbuilder_pbx.h b/qmake/generators/mac/pbuilder_pbx.h
new file mode 100644
index 0000000..ec2e1be
--- a/dev/null
+++ b/qmake/generators/mac/pbuilder_pbx.h
@@ -0,0 +1,68 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Created : 970521
7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9**
10** This file is part of the network module of the Qt GUI Toolkit.
11**
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
14** LICENSE.QPL included in the packaging of this file.
15**
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
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software.
24**
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.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37#ifndef __PBUILDERMAKE_H__
38#define __PBUILDERMAKE_H__
39
40#include "unixmake.h"
41
42class ProjectBuilderMakefileGenerator : public UnixMakefileGenerator
43{
44 QString pbx_dir;
45 int pbuilderVersion() const;
46 bool writeMakeParts(QTextStream &);
47 bool writeMakefile(QTextStream &);
48
49 QMap<QString, QString> keys;
50 QString keyFor(QString file);
51 QString fixEnvs(QString file);
52 QString fixEnvsList(QString where);
53 QString reftypeForFile(QString file);
54
55public:
56 ProjectBuilderMakefileGenerator(QMakeProject *p);
57 ~ProjectBuilderMakefileGenerator();
58
59 virtual bool openOutput(QFile &) const;
60protected:
61 virtual bool doDepends() const { return FALSE; } //never necesary
62};
63
64inline ProjectBuilderMakefileGenerator::~ProjectBuilderMakefileGenerator()
65{ }
66
67
68#endif /* __PBUILDERMAKE_H__ */
diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp
new file mode 100644
index 0000000..7df95b2
--- a/dev/null
+++ b/qmake/generators/unix/unixmake.cpp
@@ -0,0 +1,520 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Created : 970521
7**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
9**
10** This file is part of the network module of the Qt GUI Toolkit.
11**
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
14** LICENSE.QPL included in the packaging of this file.
15**
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
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software.
24**
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.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38#include "unixmake.h"
39#include "option.h"
40#include <qregexp.h>
41#include <qfile.h>
42#include <qdict.h>
43#include <qdir.h>
44#include <time.h>
45
46
47void
48UnixMakefileGenerator::init()
49{
50 if(init_flag)
51 return;
52 init_flag = TRUE;
53
54 if(!project->isEmpty("QMAKE_FAILED_REQUIREMENTS")) /* no point */
55 return;
56
57 QStringList &configs = project->variables()["CONFIG"];
58 /* this should probably not be here, but I'm using it to wrap the .t files */
59 if(project->first("TEMPLATE") == "app")
60 project->variables()["QMAKE_APP_FLAG"].append("1");
61 else if(project->first("TEMPLATE") == "lib")
62 project->variables()["QMAKE_LIB_FLAG"].append("1");
63 else if(project->first("TEMPLATE") == "subdirs") {
64 MakefileGenerator::init();
65 if(project->isEmpty("MAKEFILE"))
66 project->variables()["MAKEFILE"].append("Makefile");
67 if(project->isEmpty("QMAKE"))
68 project->variables()["QMAKE"].append("qmake");
69 if(project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].findIndex("qmake_all") == -1)
70 project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].append("qmake_all");
71 return; /* subdirs is done */
72 }
73
74 if( project->isEmpty("QMAKE_EXTENSION_SHLIB") ) {
75 QString os = project->variables()["QMAKESPEC"].first().section( '-', 0, 0 );
76 if ( os == "cygwin" ) {
77 project->variables()["QMAKE_EXTENSION_SHLIB"].append( "dll" );
78 } else {
79 project->variables()["QMAKE_EXTENSION_SHLIB"].append( "so" );
80 }
81 }
82 if( project->isEmpty("QMAKE_COPY_FILE") )
83 project->variables()["QMAKE_COPY_FILE"].append( "$(COPY) -p" );
84 if( project->isEmpty("QMAKE_COPY_DIR") )
85 project->variables()["QMAKE_COPY_DIR"].append( "$(COPY) -pR" );
86 //If the TARGET looks like a path split it into DESTDIR and the resulting TARGET
87 if(!project->isEmpty("TARGET")) {
88 QString targ = project->first("TARGET");
89 int slsh = QMAX(targ.findRev('/'), targ.findRev(Option::dir_sep));
90 if(slsh != -1) {
91 if(project->isEmpty("DESTDIR"))
92 project->values("DESTDIR").append("");
93 else if(project->first("DESTDIR").right(1) != Option::dir_sep)
94 project->variables()["DESTDIR"] = project->first("DESTDIR") + Option::dir_sep;
95 project->variables()["DESTDIR"] = project->first("DESTDIR") + targ.left(slsh+1);
96 project->variables()["TARGET"] = targ.mid(slsh+1);
97 }
98 }
99
100 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"];
101
102 bool is_qt = (project->first("TARGET") == "qt" || project->first("TARGET") == "qte" ||
103 project->first("TARGET") == "qt-mt" || project->first("TARGET") == "qte-mt");
104 bool extern_libs = !project->isEmpty("QMAKE_APP_FLAG") ||
105 (!project->isEmpty("QMAKE_LIB_FLAG") &&
106 project->isActiveConfig("dll")) || is_qt;
107 if(!project->isActiveConfig("global_init_link_order"))
108 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
109 if ( (!project->isEmpty("QMAKE_LIB_FLAG") && !project->isActiveConfig("staticlib") ) ||
110 (project->isActiveConfig("qt") && project->isActiveConfig( "plugin" ) )) {
111 if(configs.findIndex("dll") == -1) configs.append("dll");
112 } else if ( !project->isEmpty("QMAKE_APP_FLAG") || project->isActiveConfig("dll") ) {
113 configs.remove("staticlib");
114 }
115 if ( project->isActiveConfig("warn_off") ) {
116 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_OFF"];
117 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_OFF"];
118 } else if ( project->isActiveConfig("warn_on") ) {
119 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_ON"];
120 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_ON"];
121 }
122 if ( project->isActiveConfig("debug") ) {
123 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_DEBUG"];
124 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_DEBUG"];
125 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_DEBUG"];
126 } else {
127 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RELEASE"];
128 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RELEASE"];
129 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_RELEASE"];
130 }
131 if(!project->isEmpty("QMAKE_INCREMENTAL"))
132 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_INCREMENTAL"];
133 else if(!project->isEmpty("QMAKE_LFLAGS_PREBIND") &&
134 !project->variables()["QMAKE_LIB_FLAG"].isEmpty() &&
135 project->isActiveConfig("dll"))
136 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_PREBIND"];
137 if(!project->isEmpty("QMAKE_INCDIR"))
138 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"];
139 if(!project->isEmpty("QMAKE_LIBDIR")) {
140 if ( !project->isEmpty("QMAKE_RPATH") )
141 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR", " " + var("QMAKE_RPATH"),
142 " " + var("QMAKE_RPATH"), "");
143 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue( "QMAKE_LIBDIR", "-L", " -L", "" );
144 }
145 if ( extern_libs && (project->isActiveConfig("qt") || project->isActiveConfig("opengl")) ) {
146 if(configs.findIndex("x11lib") == -1)
147 configs.append("x11lib");
148 if ( project->isActiveConfig("opengl") && configs.findIndex("x11inc") == -1 )
149 configs.append("x11inc");
150 }
151 if ( project->isActiveConfig("x11") ) {
152 if(configs.findIndex("x11lib") == -1)
153 configs.append("x11lib");
154 if(configs.findIndex("x11inc") == -1)
155 configs.append("x11inc");
156 }
157 if ( project->isActiveConfig("qt") ) {
158 if ( project->isActiveConfig("accessibility" ) )
159 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT");
160 if ( project->isActiveConfig("tablet") )
161 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT");
162 if(configs.findIndex("moc")) configs.append("moc");
163 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QT"];
164 if ( !project->isActiveConfig("debug") )
165 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG");
166 if ( !is_qt ) {
167 if ( !project->isEmpty("QMAKE_LIBDIR_QT") ) {
168 if ( !project->isEmpty("QMAKE_RPATH") )
169 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_QT", " " + var("QMAKE_RPATH"),
170 " " + var("QMAKE_RPATH"), "");
171 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_QT", "-L", " -L", "");
172 }
173 if (project->isActiveConfig("thread") && !project->isEmpty("QMAKE_LIBS_QT_THREAD"))
174 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"];
175 else
176 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"];
177 }
178 }
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") ) {
192 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_OPENGL"];
193 if(!project->isEmpty("QMAKE_LIBDIR_OPENGL"))
194 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_OPENGL", "-L", " -L", "");
195 if ( is_qt )
196 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL_QT"];
197 else
198 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"];
199 }
200 if(project->isActiveConfig("global_init_link_order"))
201 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") )
207 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_X11"];
208 if ( project->isActiveConfig("x11lib") ) {
209 if(!project->isEmpty("QMAKE_LIBDIR_X11"))
210 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_X11", "-L", " -L", "");
211 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_X11"];
212 }
213 if ( project->isActiveConfig("moc") )
214 setMocAware(TRUE);
215 if ( project->isEmpty("QMAKE_RUN_CC") )
216 project->variables()["QMAKE_RUN_CC"].append("$(CC) -c $(CFLAGS) $(INCPATH) -o $obj $src");
217 if ( project->isEmpty("QMAKE_RUN_CC_IMP") )
218 project->variables()["QMAKE_RUN_CC_IMP"].append("$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<");
219 if ( project->isEmpty("QMAKE_RUN_CXX") )
220 project->variables()["QMAKE_RUN_CXX"].append("$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $obj $src");
221 if ( project->isEmpty("QMAKE_RUN_CXX_IMP") )
222 project->variables()["QMAKE_RUN_CXX_IMP"].append("$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<");
223 project->variables()["QMAKE_FILETAGS"] += QStringList::split("HEADERS SOURCES TARGET DESTDIR", " ");
224 if ( !project->isEmpty("PRECOMPH") ) {
225 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);
227 project->variables()["SOURCES"].prepend(allmoc);
228 project->variables()["HEADERS_ORIG"] = project->variables()["HEADERS"];
229 project->variables()["HEADERS"].clear();
230 }
231 if( project->isActiveConfig("GNUmake") && !project->isEmpty("QMAKE_CFLAGS_DEPS"))
232 include_deps = TRUE; //do not generate deps
233
234 MakefileGenerator::init();
235 if ( project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) {
236 if(!project->isEmpty("QMAKE_APP_FLAG")) {
237 if(project->isEmpty("DESTDIR"))
238 project->values("DESTDIR").append("");
239 project->variables()["DESTDIR"].first() += project->variables()["TARGET"].first() +
240 ".app/Contents/MacOS/";
241 project->variables()["QMAKE_PKGINFO"].append(project->first("DESTDIR") + "../PkgInfo");
242 project->variables()["ALL_DEPS"] += project->first("QMAKE_PKGINFO");
243
244 QString plist = specdir() + QDir::separator() + "Info.plist." +
245 project->first("TEMPLATE");
246 if(QFile::exists(Option::fixPathToLocalOS(plist))) {
247 project->variables()["QMAKE_INFO_PLIST"].append(plist);
248 project->variables()["QMAKE_INFO_PLIST_OUT"].append(project->first("DESTDIR") +
249 "../Info.plist");
250 project->variables()["ALL_DEPS"] += project->first("QMAKE_INFO_PLIST_OUT");
251 if(!project->isEmpty("RC_FILE"))
252 project->variables()["ALL_DEPS"] += project->first("DESTDIR") +
253 "../Resources/application.icns";
254 }
255 }
256 }
257
258 if(!project->isEmpty("QMAKE_INTERNAL_INCLUDED_FILES"))
259 project->variables()["DISTFILES"] += project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"];
260 project->variables()["DISTFILES"] += Option::mkfile::project_files;
261
262 init2();
263 project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "QMAKE_LIBDIR_FLAGS" << "QMAKE_LIBS";
264 if(!project->isEmpty("QMAKE_MAX_FILES_PER_AR")) {
265 bool ok;
266 int max_files = project->first("QMAKE_MAX_FILES_PER_AR").toInt(&ok);
267 QStringList ar_sublibs, objs = project->variables()["OBJECTS"] + project->variables()["OBJMOC"];
268 if(ok && max_files > 5 && max_files < (int)objs.count()) {
269 int obj_cnt = 0, lib_cnt = 0;
270 QString lib;
271 for(QStringList::Iterator objit = objs.begin(); objit != objs.end(); ++objit) {
272 if((++obj_cnt) >= max_files) {
273 if(lib_cnt) {
274 lib.sprintf("lib%s-tmp%d.a", project->first("QMAKE_ORIG_TARGET").latin1(), lib_cnt);
275 ar_sublibs << lib;
276 obj_cnt = 0;
277 }
278 lib_cnt++;
279 }
280 }
281 }
282 if(!ar_sublibs.isEmpty()) {
283 project->variables()["QMAKE_AR_SUBLIBS"] = ar_sublibs;
284 project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "QMAKE_AR_SUBLIBS";
285 }
286 }
287}
288
289QStringList
290UnixMakefileGenerator::uniqueSetLFlags(const QStringList &list1, QStringList &list2)
291{
292 QStringList ret;
293 for(QStringList::ConstIterator it = list1.begin(); it != list1.end(); ++it) {
294 bool unique = TRUE;
295 if((*it).startsWith("-")) {
296 if((*it).startsWith("-l") || (*it).startsWith("-L")) {
297 unique = list2.findIndex((*it)) == -1;
298 } else if(project->isActiveConfig("macx") && (*it).startsWith("-framework")) {
299 int as_one = TRUE;
300 QString framework_in;
301 if((*it).length() > 11) {
302 framework_in = (*it).mid(11);
303 } else {
304 if(it != list1.end()) {
305 ++it;
306 as_one = FALSE;
307 framework_in = (*it);
308 }
309 }
310 if(!framework_in.isEmpty()) {
311 for(QStringList::ConstIterator outit = list2.begin(); outit != list2.end(); ++outit) {
312 if((*outit).startsWith("-framework")) {
313 QString framework_out;
314 if((*outit).length() > 11) {
315 framework_out = (*outit).mid(11);
316 } else {
317 if(it != list2.end()) {
318 ++outit;
319 framework_out = (*outit);
320 }
321 }
322 if(framework_out == framework_in) {
323 unique = FALSE;
324 break;
325 }
326 }
327 }
328 if(unique) {
329 unique = FALSE; //because I'm about to just insert it myself
330 if(as_one) {
331 ret.append("-framework " + framework_in);
332 } else {
333 ret.append("-framework");
334 ret.append(framework_in);
335 }
336 }
337 }
338 } else {
339 unique = (list2.findIndex((*it)) == -1);
340 }
341 } else if(QFile::exists((*it))) {
342 unique = (list2.findIndex((*it)) == -1);
343 }
344 if(unique)
345 ret.append((*it));
346 }
347 return ret;
348}
349
350
351void
352UnixMakefileGenerator::processPrlVariable(const QString &var, const QStringList &l)
353{
354 if(var == "QMAKE_PRL_LIBS")
355 project->variables()["QMAKE_CURRENT_PRL_LIBS"] += uniqueSetLFlags(l, project->variables()["QMAKE_LIBS"]);
356 else
357 MakefileGenerator::processPrlVariable(var, l);
358}
359
360void
361UnixMakefileGenerator::processPrlFiles()
362{
363 QDict<void> processed;
364 QPtrList<MakefileDependDir> libdirs;
365 libdirs.setAutoDelete(TRUE);
366 const QString lflags[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_LIBS", QString::null };
367 for(int i = 0; !lflags[i].isNull(); i++) {
368 for(bool ret = FALSE; TRUE; ret = FALSE) {
369 QStringList l_out;
370 QStringList &l = project->variables()[lflags[i]];
371 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
372 project->variables()["QMAKE_CURRENT_PRL_LIBS"].clear();
373 QString opt = (*it).stripWhiteSpace();;
374 if(opt.startsWith("-")) {
375 if(opt.startsWith("-L")) {
376 QString r = opt.right(opt.length() - 2), l = r;
377 fixEnvVariables(l);
378 libdirs.append(new MakefileDependDir(r.replace("\"",""),
379 l.replace("\"","")));
380 } else if(opt.startsWith("-l") && !processed[opt]) {
381 QString lib = opt.right(opt.length() - 2), prl;
382 for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) {
383 prl = mdd->local_dir + Option::dir_sep + "lib" + lib + Option::prl_ext;
384 if(processPrlFile(prl)) {
385 if(prl.startsWith(mdd->local_dir))
386 prl.replace(0, mdd->local_dir.length(), mdd->real_dir);
387 QRegExp reg("^.*lib(" + lib + "[^./=]*)\\..*$");
388 if(reg.exactMatch(prl))
389 prl = "-l" + reg.cap(1);
390 opt = prl;
391 processed.insert(opt, (void*)1);
392 ret = TRUE;
393 break;
394 }
395 }
396 } else if(project->isActiveConfig("macx") && opt.startsWith("-framework")) {
397 if(opt.length() > 11) {
398 opt = opt.mid(11);
399 } else {
400 ++it;
401 opt = (*it);
402 }
403 QString prl = "/System/Library/Frameworks/" + opt +
404 ".framework/" + opt + Option::prl_ext;
405 if(processPrlFile(prl))
406 ret = TRUE;
407 l_out.append("-framework");
408 }
409 if(!opt.isEmpty())
410 l_out.append(opt);
411 l_out += uniqueSetLFlags(project->variables()["QMAKE_CURRENT_PRL_LIBS"], l_out);
412 } else {
413 if(!processed[opt] && processPrlFile(opt)) {
414 processed.insert(opt, (void*)1);
415 ret = TRUE;
416 }
417 if(!opt.isEmpty())
418 l_out.append(opt);
419 l_out += uniqueSetLFlags(project->variables()["QMAKE_CURRENT_PRL_LIBS"], l_out);
420 }
421 }
422 if(ret && l != l_out)
423 l = l_out;
424 else
425 break;
426 }
427 }
428}
429
430QString
431UnixMakefileGenerator::defaultInstall(const QString &t)
432{
433 if(t != "target" || project->first("TEMPLATE") == "subdirs")
434 return QString();
435
436 bool resource = FALSE;
437 QStringList &uninst = project->variables()[t + ".uninstall"];
438 QString ret, destdir=fileFixify(project->first("DESTDIR"));
439 QString targetdir = Option::fixPathToTargetOS(project->first("target.path"), FALSE);
440 if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep)
441 destdir += Option::dir_sep;
442 targetdir = "$(INSTALL_ROOT)" + Option::fixPathToTargetOS(targetdir, FALSE);
443 if(targetdir.right(1) != Option::dir_sep)
444 targetdir += Option::dir_sep;
445
446 QStringList links;
447 QString target="$(TARGET)";
448 if(project->first("TEMPLATE") == "app") {
449 target = "$(QMAKE_TARGET)";
450 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) {
451 destdir += "../../../";
452 target += ".app";
453 resource = TRUE;
454 }
455 } else if(project->first("TEMPLATE") == "lib") {
456 if(project->isActiveConfig("create_prl") && !project->isEmpty("QMAKE_INTERNAL_PRL_FILE")) {
457 QString dst_prl = project->first("QMAKE_INTERNAL_PRL_FILE");
458 int slsh = dst_prl.findRev('/');
459 if(slsh != -1)
460 dst_prl = dst_prl.right(dst_prl.length() - slsh - 1);
461 dst_prl = targetdir + dst_prl;
462 ret += "-$(COPY) " + project->first("QMAKE_INTERNAL_PRL_FILE") + " " + dst_prl;
463 if(!uninst.isEmpty())
464 uninst.append("\n\t");
465 uninst.append("-$(DEL_FILE) \"" + dst_prl + "\"");
466 }
467 QString os = project->variables()["QMAKESPEC"].first().section( '-', 0, 0 );
468 if ( os != "cygwin" ) {
469 if ( !project->isActiveConfig("staticlib") && !project->isActiveConfig("plugin") ) {
470 if ( os == "hpux" ) {
471 links << "$(TARGET0)";
472 } else {
473 links << "$(TARGET0)" << "$(TARGET1)" << "$(TARGET2)";
474 }
475 }
476 }
477 }
478 QString src_targ = target;
479 if(!destdir.isEmpty())
480 src_targ = Option::fixPathToTargetOS(destdir + target, FALSE);
481 QString dst_targ = fileFixify(targetdir + target);
482 if(!ret.isEmpty())
483 ret += "\n\t";
484 ret += QString(resource ? "-$(COPY_DIR)" : "-$(COPY)") + " \"" +
485 src_targ + "\" \"" + dst_targ + "\"";
486 if(!project->isEmpty("QMAKE_STRIP")) {
487 ret += "\n\t-" + var("QMAKE_STRIP");
488 if(resource)
489 ret = " \"" + dst_targ + "/Contents/MacOS/$(QMAKE_TARGET)";
490 else
491 ret += " \"" + dst_targ + "\"";
492 }
493 if(!uninst.isEmpty())
494 uninst.append("\n\t");
495 if(resource)
496 uninst.append("-$(DEL_FILE) -r \"" + dst_targ + "\"");
497 else
498 uninst.append("-$(DEL_FILE) \"" + dst_targ + "\"");
499 if(!links.isEmpty()) {
500 for(QStringList::Iterator it = links.begin(); it != links.end(); it++) {
501 if(Option::target_mode == Option::TARG_WIN_MODE ||
502 Option::target_mode == Option::TARG_MAC9_MODE) {
503 } else if(Option::target_mode == Option::TARG_UNIX_MODE ||
504 Option::target_mode == Option::TARG_MACX_MODE) {
505 QString link = Option::fixPathToTargetOS(destdir + (*it), FALSE);
506 int lslash = link.findRev(Option::dir_sep);
507 if(lslash != -1)
508 link = link.right(link.length() - (lslash + 1));
509 QString dst_link = fileFixify(targetdir + link);
510 ret += "\n\t-$(SYMLINK) \"$(TARGET)\" \"" + dst_link + "\"";
511 if(!uninst.isEmpty())
512 uninst.append("\n\t");
513 uninst.append("-$(DEL_FILE) \"" + dst_link + "\"");
514 }
515 }
516 }
517 return ret;
518}
519
520
diff --git a/qmake/generators/unix/unixmake.h b/qmake/generators/unix/unixmake.h
new file mode 100644
index 0000000..e889dcc
--- a/dev/null
+++ b/qmake/generators/unix/unixmake.h
@@ -0,0 +1,71 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Created : 970521
7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9**
10** This file is part of the network module of the Qt GUI Toolkit.
11**
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
14** LICENSE.QPL included in the packaging of this file.
15**
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
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software.
24**
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.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37#ifndef __UNIXMAKE_H__
38#define __UNIXMAKE_H__
39
40#include "makefile.h"
41
42class UnixMakefileGenerator : public MakefileGenerator
43{
44 bool init_flag, include_deps;
45 bool writeMakefile(QTextStream &);
46 QStringList uniqueSetLFlags(const QStringList &list1, QStringList &list2);
47
48public:
49 UnixMakefileGenerator(QMakeProject *p);
50 ~UnixMakefileGenerator();
51
52protected:
53 virtual bool doDepends() const { return !include_deps && MakefileGenerator::doDepends(); }
54 virtual QString defaultInstall(const QString &);
55 virtual void processPrlVariable(const QString &, const QStringList &);
56 virtual void processPrlFiles();
57
58 virtual void init();
59
60 void writeMakeParts(QTextStream &);
61 void writeSubdirs(QTextStream &, bool=TRUE);
62
63private:
64 void init2();
65};
66
67inline UnixMakefileGenerator::~UnixMakefileGenerator()
68{ }
69
70
71#endif /* __UNIXMAKE_H__ */
diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp
new file mode 100644
index 0000000..1797b98
--- a/dev/null
+++ b/qmake/generators/unix/unixmake2.cpp
@@ -0,0 +1,1048 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Created : 970521
7**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
9**
10** This file is part of the network module of the Qt GUI Toolkit.
11**
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
14** LICENSE.QPL included in the packaging of this file.
15**
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
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software.
24**
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.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38#include "unixmake.h"
39#include "option.h"
40#include <qregexp.h>
41#include <qfile.h>
42#include <qdir.h>
43#include <time.h>
44
45
46UnixMakefileGenerator::UnixMakefileGenerator(QMakeProject *p) : MakefileGenerator(p), init_flag(FALSE), include_deps(FALSE)
47{
48
49}
50
51bool
52UnixMakefileGenerator::writeMakefile(QTextStream &t)
53{
54 writeHeader(t);
55 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {
56 t << "all clean:" << "\n\t"
57 << "@echo \"Some of the required modules ("
58 << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t"
59 << "@echo \"Skipped.\"" << endl << endl;
60 writeMakeQmake(t);
61 return TRUE;
62 }
63
64 if (project->variables()["TEMPLATE"].first() == "app" ||
65 project->variables()["TEMPLATE"].first() == "lib") {
66 writeMakeParts(t);
67 return MakefileGenerator::writeMakefile(t);
68 } else if(project->variables()["TEMPLATE"].first() == "subdirs") {
69 writeSubdirs(t);
70 return TRUE;
71 }
72 return FALSE;
73}
74
75void
76UnixMakefileGenerator::writeMakeParts(QTextStream &t)
77{
78 QString deps = fileFixify(Option::output.name()), prl;
79 bool do_incremental = (project->isActiveConfig("incremental") &&
80 !project->variables()["QMAKE_INCREMENTAL"].isEmpty() &&
81 (!project->variables()["QMAKE_APP_FLAG"].isEmpty() ||
82 !project->isActiveConfig("staticlib"))),
83 src_incremental=FALSE, moc_incremental=FALSE;
84 QString os = project->variables()["QMAKESPEC"].first().section( '-', 0, 0 );
85
86 t << "####### Compiler, tools and options" << endl << endl;
87 t << "CC = ";
88 if (project->isActiveConfig("thread") &&
89 ! project->variables()["QMAKE_CC_THREAD"].isEmpty())
90 t << var("QMAKE_CC_THREAD") << endl;
91 else
92 t << var("QMAKE_CC") << endl;
93
94 t << "CXX = ";
95 if (project->isActiveConfig("thread") &&
96 ! project->variables()["QMAKE_CXX_THREAD"].isEmpty())
97 t << var("QMAKE_CXX_THREAD") << endl;
98 else
99 t << var("QMAKE_CXX") << endl;
100
101 t << "LEX = " << var("QMAKE_LEX") << endl;
102 t << "YACC = " << var("QMAKE_YACC") << endl;
103 t << "CFLAGS = " << var("QMAKE_CFLAGS") << " "
104 << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "
105 << varGlue("DEFINES","-D"," -D","") << endl;
106 t << "CXXFLAGS = " << var("QMAKE_CXXFLAGS") << " "
107 << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "
108 << varGlue("DEFINES","-D"," -D","") << endl;
109 t << "LEXFLAGS = " << var("QMAKE_LEXFLAGS") << endl;
110 t << "YACCFLAGS= " << var("QMAKE_YACCFLAGS") << endl;
111 t << "INCPATH = " << varGlue("INCLUDEPATH","-I", " -I", "") << " -I" << specdir() << endl;
112
113 if(!project->isActiveConfig("staticlib")) {
114 t << "LINK = ";
115 if (project->isActiveConfig("thread") &&
116 ! project->variables()["QMAKE_LINK_THREAD"].isEmpty())
117 t << var("QMAKE_LINK_THREAD") << endl;
118 else
119 t << var("QMAKE_LINK") << endl;
120
121 t << "LFLAGS = " << var("QMAKE_LFLAGS") << endl;
122 t << "LIBS = " << "$(SUBLIBS) " << var("QMAKE_LIBDIR_FLAGS") << " " << var("QMAKE_LIBS") << endl;
123 }
124
125 t << "AR = " << var("QMAKE_AR") << endl;
126 t << "RANLIB = " << var("QMAKE_RANLIB") << endl;
127 t << "MOC = " << var("QMAKE_MOC") << endl;
128 t << "UIC = "<< var("QMAKE_UIC") << endl;
129 t << "QMAKE = "<< (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl;
130 t << "TAR = "<< var("QMAKE_TAR") << endl;
131 t << "GZIP = " << var("QMAKE_GZIP") << endl;
132 t << "COPY = " << var("QMAKE_COPY") << endl;
133 t << "COPY_FILE= " << var("QMAKE_COPY_FILE") << endl;
134 t << "COPY_DIR = " << var("QMAKE_COPY_DIR") << endl;
135 t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl;
136 t << "SYMLINK = " << var("QMAKE_SYMBOLIC_LINK") << endl;
137 t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl;
138 t << "MOVE = " << var("QMAKE_MOVE") << endl;
139 t << endl;
140
141 t << "####### Output directory" << endl << endl;
142 if (! project->variables()["OBJECTS_DIR"].isEmpty())
143 t << "OBJECTS_DIR = " << var("OBJECTS_DIR") << endl;
144 else
145 t << "OBJECTS_DIR = ./" << endl;
146 t << endl;
147
148 /* files */
149 t << "####### Files" << endl << endl;
150 t << "HEADERS = " << varList("HEADERS") << endl;
151 t << "SOURCES = " << varList("SOURCES") << endl;
152 if(do_incremental) {
153 QStringList &objs = project->variables()["OBJECTS"], &incrs = project->variables()["QMAKE_INCREMENTAL"], incrs_out;
154 t << "OBJECTS = ";
155 for(QStringList::Iterator objit = objs.begin(); objit != objs.end(); ++objit) {
156 bool increment = FALSE;
157 for(QStringList::Iterator incrit = incrs.begin(); incrit != incrs.end(); ++incrit) {
158 if((*objit).find(QRegExp((*incrit), TRUE, TRUE)) != -1) {
159 increment = TRUE;
160 incrs_out.append((*objit));
161 break;
162 }
163 }
164 if(!increment)
165 t << "\\\n\t\t" << (*objit);
166 }
167 if(incrs_out.count() == objs.count()) { //we just switched places, no real incrementals to be done!
168 t << incrs_out.join(" \\\n\t\t") << endl;
169 } else if(!incrs_out.count()) {
170 t << endl;
171 } else {
172 src_incremental = TRUE;
173 t << endl;
174 t << "INCREMENTAL_OBJECTS = " << incrs_out.join(" \\\n\t\t") << endl;
175 }
176 } else {
177 t << "OBJECTS = " << varList("OBJECTS") << endl;
178 }
179 t << "FORMS = " << varList("FORMS") << endl;
180 t << "UICDECLS = " << varList("UICDECLS") << endl;
181 t << "UICIMPLS = " << varList("UICIMPLS") << endl;
182 QString srcMoc = varList("SRCMOC"), objMoc = varList("OBJMOC");
183 t << "SRCMOC = " << srcMoc << endl;
184 if(do_incremental) {
185 QStringList &objs = project->variables()["OBJMOC"],
186 &incrs = project->variables()["QMAKE_INCREMENTAL"], incrs_out;
187 t << "OBJMOC = ";
188 for(QStringList::Iterator objit = objs.begin(); objit != objs.end(); ++objit) {
189 bool increment = FALSE;
190 for(QStringList::Iterator incrit = incrs.begin(); incrit != incrs.end(); ++incrit) {
191 if((*objit).find(QRegExp((*incrit), TRUE, TRUE)) != -1) {
192 increment = TRUE;
193 incrs_out.append((*objit));
194 break;
195 }
196 }
197 if(!increment)
198 t << "\\\n\t\t" << (*objit);
199 }
200 if(incrs_out.count() == objs.count()) { //we just switched places, no real incrementals to be done!
201 t << incrs_out.join(" \\\n\t\t") << endl;
202 } else if(!incrs_out.count()) {
203 t << endl;
204 } else {
205 moc_incremental = TRUE;
206 t << endl;
207 t << "INCREMENTAL_OBJMOC = " << incrs_out.join(" \\\n\t\t") << endl;
208 }
209 } else {
210 t << "OBJMOC = " << objMoc << endl;
211 }
212 if(do_incremental && !moc_incremental && !src_incremental)
213 do_incremental = FALSE;
214 t << "DIST = " << varList("DISTFILES") << endl;
215 t << "QMAKE_TARGET = " << var("QMAKE_ORIG_TARGET") << endl;
216 t << "DESTDIR = " << var("DESTDIR") << endl;
217 t << "TARGET = " << var("TARGET") << endl;
218 if(project->isActiveConfig("plugin") ) {
219 t << "TARGETD = " << var("TARGET") << endl;
220 } else if (!project->isActiveConfig("staticlib") && project->variables()["QMAKE_APP_FLAG"].isEmpty()) {
221 t << "TARGETA= " << var("TARGETA") << endl;
222 if (os == "hpux") {
223 t << "TARGETD= " << var("TARGET_x") << endl;
224 t << "TARGET0= " << var("TARGET_") << endl;
225 }
226 else {
227 t << "TARGETD= " << var("TARGET_x.y.z") << endl;
228 t << "TARGET0= " << var("TARGET_") << endl;
229 t << "TARGET1= " << var("TARGET_x") << endl;
230 t << "TARGET2= " << var("TARGET_x.y") << endl;
231 }
232 }
233 t << endl;
234
235 // blasted incldues
236 QStringList &qeui = project->variables()["QMAKE_EXTRA_UNIX_INCLUDES"];
237 QStringList::Iterator it;
238 for( it = qeui.begin(); it != qeui.end(); ++it)
239 t << "include " << (*it) << endl;
240
241 /* rules */
242 t << "first: all" << endl;
243 t << "####### Implicit rules" << endl << endl;
244 t << ".SUFFIXES: .c";
245 QStringList::Iterator cppit;
246 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
247 t << " " << (*cppit);
248 t << endl << endl;
249 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
250 t << (*cppit) << ".o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
251 t << ".c.o:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;
252
253 if(include_deps) {
254 QString cmd=var("QMAKE_CFLAGS_DEPS") + " ";
255 cmd += varGlue("DEFINES","-D"," -D","") + varGlue("PRL_EXPORT_DEFINES"," -D"," -D","");
256 if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH"))
257 cmd += " -I" + project->first("QMAKE_ABSOLUTE_SOURCE_PATH") + " ";
258 cmd += " $(INCPATH) " + varGlue("DEPENDPATH", "-I", " -I", "");
259 QString odir;
260 if(!project->variables()["OBJECTS_DIR"].isEmpty())
261 odir = project->first("OBJECTS_DIR");
262 t << "###### Dependancies" << endl << endl;
263 t << odir << ".deps/%.d: %.cpp\n\t"
264 << "@echo Creating depend for $<" << "\n\t"
265 << "@test -d $(@D) || mkdir -p $(@D)" << "\n\t"
266 << "@$(CXX) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl;
267
268 t << odir << ".deps/%.d: %.c\n\t"
269 << "@echo Creating depend for $<" << "\n\t"
270 << "@test -d $(@D) || mkdir -p $(@D)" << "\n\t"
271 << "@$(CC) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl;
272
273
274 QString src[] = { "SOURCES", "UICIMPLS", "SRCMOC", QString::null };
275 for(int x = 0; !src[x].isNull(); x++) {
276 QStringList &l = project->variables()[src[x]];
277 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
278 if(!(*it).isEmpty()) {
279 QString d_file;
280 if((*it).endsWith(".c")) {
281 d_file = (*it).left((*it).length() - 2);
282 } else {
283 for(QStringList::Iterator cppit = Option::cpp_ext.begin();
284 cppit != Option::cpp_ext.end(); ++cppit) {
285 if((*it).endsWith((*cppit))) {
286 d_file = (*it).left((*it).length() - (*cppit).length());
287 break;
288 }
289 }
290 }
291 if(!d_file.isEmpty()) {
292 d_file = odir + ".deps/" + d_file + ".d";
293 QStringList deps = findDependencies((*it)).grep(QRegExp(Option::moc_ext + "$"));
294 if(!deps.isEmpty())
295 t << d_file << ": " << deps.join(" ") << endl;
296 t << "-include " << d_file << endl;
297 }
298 }
299 }
300 }
301 }
302
303 t << "####### Build rules" << endl << endl;
304 if(!project->variables()["SUBLIBS"].isEmpty()) {
305 QString libdir = "tmp/";
306 if(!project->isEmpty("SUBLIBS_DIR"))
307 libdir = project->first("SUBLIBS_DIR");
308 t << "SUBLIBS= ";
309 QStringList &l = project->variables()["SUBLIBS"];
310 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it)
311 t << libdir << "lib" << (*it) << ".a ";
312 t << endl << endl;
313 }
314 if(project->isActiveConfig("depend_prl") && !project->isEmpty("QMAKE_PRL_INTERNAL_FILES")) {
315 QStringList &l = project->variables()["QMAKE_PRL_INTERNAL_FILES"];
316 QStringList::Iterator it;
317 for(it = l.begin(); it != l.end(); ++it) {
318 QMakeProject proj;
319 if(proj.read((*it), QDir::currentDirPath()) && !proj.isEmpty("QMAKE_PRL_BUILD_DIR")) {
320 QString dir;
321 int slsh = (*it).findRev(Option::dir_sep);
322 if(slsh != -1)
323 dir = (*it).left(slsh + 1);
324 QString targ = dir + proj.first("QMAKE_PRL_TARGET");
325 deps += " " + targ;
326 t << targ << ":" << "\n\t"
327 << "@echo \"Creating '" << targ << "'\"" << "\n\t"
328 << "(cd " << proj.first("QMAKE_PRL_BUILD_DIR") << ";"
329 << "$(MAKE) )" << endl;
330 }
331 }
332 }
333 if(!project->variables()["QMAKE_APP_FLAG"].isEmpty()) {
334 QString destdir = project->first("DESTDIR");
335 if(do_incremental) {
336 //incremental target
337 QString incr_target = var("TARGET") + "_incremental";
338 if(incr_target.find(Option::dir_sep) != -1)
339 incr_target = incr_target.right(incr_target.length() -
340 (incr_target.findRev(Option::dir_sep) + 1));
341 QString incr_deps, incr_objs;
342 if(project->first("QMAKE_INCREMENTAL_STYLE") == "ld") {
343 QString incr_target_dir = var("OBJECTS_DIR") + incr_target + Option::obj_ext;
344 //actual target
345 t << incr_target_dir << ": $(OBJECTS)" << "\n\t"
346 << "ld -r -o "<< incr_target_dir << " $(OBJECTS)" << endl;
347 //communicated below
348 deps.prepend(incr_target_dir + " ");
349 incr_deps = "$(UICDECLS) $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC) $(OBJMOC)";
350 if(!incr_objs.isEmpty())
351 incr_objs += " ";
352 incr_objs += incr_target_dir;
353 } else {
354 //actual target
355 QString incr_target_dir = var("DESTDIR") + "lib" + incr_target + "." +
356 project->variables()["QMAKE_EXTENSION_SHLIB"].first();
357 QString incr_lflags = var("QMAKE_LFLAGS_SHLIB") + " ";
358 if(project->isActiveConfig("debug"))
359 incr_lflags += var("QMAKE_LFLAGS_DEBUG");
360 else
361 incr_lflags += var("QMAKE_LFLAGS_RELEASE");
362 t << incr_target_dir << ": $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << "\n\t";
363 if(!destdir.isEmpty())
364 t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
365 t << "$(LINK) " << incr_lflags << " -o "<< incr_target_dir <<
366 " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << endl;
367 //communicated below
368 if(!destdir.isEmpty()) {
369 if(!incr_objs.isEmpty())
370 incr_objs += " ";
371 incr_objs += "-L" + destdir;
372 } else {
373 if(!incr_objs.isEmpty())
374 incr_objs += " ";
375 incr_objs += "-L" + QDir::currentDirPath();
376 }
377 if(!incr_objs.isEmpty())
378 incr_objs += " ";
379 incr_objs += " -l" + incr_target;
380 deps.prepend(incr_target_dir + " ");
381 incr_deps = "$(UICDECLS) $(OBJECTS) $(OBJMOC)";
382 }
383 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)"
384 << endl << endl;
385
386 //real target
387 t << var("TARGET") << ": " << " " << incr_deps << " " << var("TARGETDEPS") << "\n\t";
388 if(!destdir.isEmpty())
389 t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
390 if(!project->isEmpty("QMAKE_PRE_LINK"))
391 t << var("QMAKE_PRE_LINK") << "\n\t";
392 t << "$(LINK) $(LFLAGS) -o $(TARGET) " << incr_deps << " " << incr_objs << " $(LIBS)";
393 if(!project->isEmpty("QMAKE_POST_LINK"))
394 t << "\n\t" << var("QMAKE_POST_LINK");
395 t << endl << endl;
396 } else {
397 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)"
398 << endl << endl;
399
400 t << "$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) " << var("TARGETDEPS") << "\n\t";
401 if(!destdir.isEmpty())
402 t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
403 if(!project->isEmpty("QMAKE_PRE_LINK"))
404 t << var("QMAKE_PRE_LINK") << "\n\t";
405 t << "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)";
406 if(!project->isEmpty("QMAKE_POST_LINK"))
407 t << "\n\t" << var("QMAKE_POST_LINK");
408 t << endl << endl;
409 }
410 } else if(!project->isActiveConfig("staticlib")) {
411 QString destdir = project->first("DESTDIR"), incr_deps;
412 if(do_incremental) {
413 QString s_ext = project->variables()["QMAKE_EXTENSION_SHLIB"].first();
414 QString incr_target = var("QMAKE_ORIG_TARGET").replace(
415 QRegExp("\\." + s_ext), "").replace(QRegExp("^lib"), "") + "_incremental";
416 if(incr_target.find(Option::dir_sep) != -1)
417 incr_target = incr_target.right(incr_target.length() -
418 (incr_target.findRev(Option::dir_sep) + 1));
419
420 if(project->first("QMAKE_INCREMENTAL_STYLE") == "ld") {
421 QString incr_target_dir = var("OBJECTS_DIR") + incr_target + Option::obj_ext;
422 //actual target
423 const QString link_deps = "$(UICDECLS) $(OBJECTS) $(OBJMOC)";
424 t << incr_target_dir << ": " << link_deps << "\n\t"
425 << "ld -r -o " << incr_target_dir << " " << link_deps << endl;
426 //communicated below
427 QStringList &cmd = project->variables()["QMAKE_LINK_SHLIB_CMD"];
428 cmd.first().replace("$(OBJECTS) $(OBJMOC)",
429 "$(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)"); //ick
430 cmd.append(incr_target_dir);
431 deps.prepend(incr_target_dir + " ");
432 incr_deps = "$(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)";
433 } else {
434 //actual target
435 QString incr_target_dir = var("DESTDIR") + "lib" + incr_target + "." + s_ext;
436 QString incr_lflags = var("QMAKE_LFLAGS_SHLIB") + " ";
437 if(!project->isEmpty("QMAKE_LFLAGS_INCREMENTAL"))
438 incr_lflags += var("QMAKE_LFLAGS_INCREMENTAL") + " ";
439 if(project->isActiveConfig("debug"))
440 incr_lflags += var("QMAKE_LFLAGS_DEBUG");
441 else
442 incr_lflags += var("QMAKE_LFLAGS_RELEASE");
443 t << incr_target_dir << ": $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << "\n\t";
444 if(!destdir.isEmpty())
445 t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
446 t << "$(LINK) " << incr_lflags << " -o "<< incr_target_dir <<
447 " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << endl;
448 //communicated below
449 QStringList &cmd = project->variables()["QMAKE_LINK_SHLIB_CMD"];
450 if(!destdir.isEmpty())
451 cmd.append(" -L" + destdir);
452 cmd.append(" -l" + incr_target);
453 deps.prepend(incr_target_dir + " ");
454 incr_deps = "$(UICDECLS) $(OBJECTS) $(OBJMOC)";
455 }
456
457 t << "all: " << " " << deps << " " << varGlue("ALL_DEPS",""," ","")
458 << " " << var("DESTDIR_TARGET") << endl << endl;
459
460 //real target
461 t << var("DESTDIR_TARGET") << ": " << incr_deps << " $(SUBLIBS) " <<
462 var("TARGETDEPS");
463 } else {
464 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," ","") << " " <<
465 var("DESTDIR_TARGET") << endl << endl;
466 t << var("DESTDIR_TARGET") << ": $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) " <<
467 var("TARGETDEPS");
468 }
469 if(!destdir.isEmpty())
470 t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir;
471 if(!project->isEmpty("QMAKE_PRE_LINK"))
472 t << "\n\t" << var("QMAKE_PRE_LINK");
473
474 if(project->isActiveConfig("plugin")) {
475 t << "\n\t"
476 << "-$(DEL_FILE) $(TARGET)" << "\n\t"
477 << var("QMAKE_LINK_SHLIB_CMD");
478 if(!destdir.isEmpty())
479 t << "\n\t"
480 << "-$(MOVE) $(TARGET) " << var("DESTDIR");
481 if(!project->isEmpty("QMAKE_POST_LINK"))
482 t << "\n\t" << var("QMAKE_POST_LINK") << "\n\t";
483 t << endl << endl;
484 } else if ( os == "hpux" ) {
485 t << "\n\t"
486 << "-$(DEL_FILE) $(TARGET) $(TARGET0)" << "\n\t"
487 << var("QMAKE_LINK_SHLIB_CMD") << "\n\t";
488 t << varGlue("QMAKE_LN_SHLIB",""," "," $(TARGET) $(TARGET0)");
489 if(!destdir.isEmpty())
490 t << "\n\t"
491 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET)\n\t"
492 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET0)\n\t"
493 << "-$(MOVE) $(TARGET) $(TARGET0) " << var("DESTDIR");
494 if(!project->isEmpty("QMAKE_POST_LINK"))
495 t << "\n\t" << var("QMAKE_POST_LINK");
496 t << endl << endl;
497 } else {
498 t << "\n\t"
499 << "-$(DEL_FILE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2)" << "\n\t"
500 << var("QMAKE_LINK_SHLIB_CMD") << "\n\t";
501 t << varGlue("QMAKE_LN_SHLIB","-"," "," $(TARGET) $(TARGET0)") << "\n\t"
502 << varGlue("QMAKE_LN_SHLIB","-"," "," $(TARGET) $(TARGET1)") << "\n\t"
503 << varGlue("QMAKE_LN_SHLIB","-"," "," $(TARGET) $(TARGET2)");
504 if(!destdir.isEmpty())
505 t << "\n\t"
506 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET)\n\t"
507 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET0)\n\t"
508 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET1)\n\t"
509 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET2)\n\t"
510 << "-$(MOVE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) " << var("DESTDIR");
511 if(!project->isEmpty("QMAKE_POST_LINK"))
512 t << "\n\t" << var("QMAKE_POST_LINK");
513 t << endl << endl;
514 }
515 t << endl << endl;
516
517 if (! project->isActiveConfig("plugin")) {
518 t << "staticlib: $(TARGETA)" << endl << endl;
519 t << "$(TARGETA): $(UICDECLS) $(OBJECTS) $(OBJMOC)";
520 if(do_incremental)
521 t << " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)";
522 t << var("TARGETDEPS") << "\n\t"
523 << "-$(DEL_FILE) $(TARGETA) " << "\n\t"
524 << var("QMAKE_AR_CMD");
525 if(do_incremental)
526 t << " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)";
527 if(!project->isEmpty("QMAKE_RANLIB"))
528 t << "\n\t" << "$(RANLIB) $(TARGETA)";
529 t << endl << endl;
530 }
531 } else {
532 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << var("DESTDIR") << "$(TARGET) "
533 << varGlue("QMAKE_AR_SUBLIBS", var("DESTDIR"), " " + var("DESTDIR"), "") << "\n\n"
534 << "staticlib: " << var("DESTDIR") << "$(TARGET)" << "\n\n";
535 if(project->isEmpty("QMAKE_AR_SUBLIBS")) {
536 t << var("DESTDIR") << "$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(TARGETDEPS) " << "\n\t";
537 if(!project->isEmpty("DESTDIR")) {
538 QString destdir = project->first("DESTDIR");
539 t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
540 }
541 t << "-$(DEL_FILE) $(TARGET)" << "\n\t"
542 << var("QMAKE_AR_CMD") << "\n";
543 if(!project->isEmpty("QMAKE_POST_LINK"))
544 t << "\t" << var("QMAKE_POST_LINK") << "\n";
545 if(!project->isEmpty("QMAKE_RANLIB"))
546 t << "\t" << "$(RANLIB) $(TARGET)" << "\n";
547 if(!project->isEmpty("DESTDIR"))
548 t << "\t" << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET)" << "\n"
549 << "\t" << "-$(MOVE) $(TARGET) " << var("DESTDIR") << "\n";
550 } else {
551 int cnt = 0, max_files = project->first("QMAKE_MAX_FILES_PER_AR").toInt();
552 QStringList objs = project->variables()["OBJECTS"] + project->variables()["OBJMOC"],
553 libs = project->variables()["QMAKE_AR_SUBLIBS"];
554 libs.prepend("$(TARGET)");
555 for(QStringList::Iterator libit = libs.begin(), objit = objs.begin();
556 libit != libs.end(); ++libit) {
557 QStringList build;
558 for(cnt = 0; cnt < max_files && objit != objs.end(); ++objit, cnt++)
559 build << (*objit);
560 QString ar;
561 if((*libit) == "$(TARGET)") {
562 t << var("DESTDIR") << "$(TARGET): $(UICDECLS) " << " $(TARGETDEPS) "
563 << valList(build) << "\n\t";
564 ar = project->variables()["QMAKE_AR_CMD"].first();
565 ar = ar.replace("$(OBJMOC)", "").replace("$(OBJECTS)",
566 build.join(" "));
567 } else {
568 t << (*libit) << ": " << valList(build) << "\n\t";
569 ar = "$(AR) " + (*libit) + " " + build.join(" ");
570 }
571 if(!project->isEmpty("DESTDIR")) {
572 QString destdir = project->first("DESTDIR");
573 t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
574 }
575 t << "-$(DEL_FILE) " << (*libit) << "\n\t"
576 << ar << "\n";
577 if(!project->isEmpty("QMAKE_POST_LINK"))
578 t << "\t" << var("QMAKE_POST_LINK") << "\n";
579 if(!project->isEmpty("QMAKE_RANLIB"))
580 t << "\t" << "$(RANLIB) " << (*libit) << "\n";
581 if(!project->isEmpty("DESTDIR"))
582 t << "\t" << "-$(DEL_FILE) " << var("DESTDIR") << (*libit) << "\n"
583 << "\t" << "-$(MOVE) " << (*libit) << " " << var("DESTDIR") << "\n";
584 }
585 }
586 t << endl << endl;
587 }
588
589 t << "mocables: $(SRCMOC)" << endl << endl;
590
591 if(!project->isActiveConfig("no_mocdepend")) {
592 //this is an implicity depend on moc, so it will be built if necesary, however
593 //moc itself shouldn't have this dependancy - this is a little kludgy but it is
594 //better than the alternative for now.
595 QString moc = project->first("QMAKE_MOC"), target = project->first("TARGET");
596 fixEnvVariables(target);
597 fixEnvVariables(moc);
598 if(target != moc)
599 t << "$(MOC): \n\t"
600 << "( cd $(QTDIR)/src/moc ; $(MAKE) )" << endl << endl;
601 }
602
603 writeMakeQmake(t);
604
605 if(!project->first("QMAKE_PKGINFO").isEmpty()) {
606 QString pkginfo = project->first("QMAKE_PKGINFO");
607 QString destdir = project->first("DESTDIR");
608 t << pkginfo << ": " << "\n\t";
609 if(!destdir.isEmpty())
610 t << "@test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
611 t << "@$(DEL_FILE) " << pkginfo << "\n\t"
612 << "@echo \"APPL????\" >" << pkginfo << endl;
613 }
614 if(!project->first("QMAKE_INFO_PLIST").isEmpty()) {
615 QString info_plist = project->first("QMAKE_INFO_PLIST"),
616 info_plist_out = project->first("QMAKE_INFO_PLIST_OUT");
617 QString destdir = project->first("DESTDIR");
618 t << info_plist_out << ": " << "\n\t";
619 if(!destdir.isEmpty())
620 t << "@test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
621 t << "@$(DEL_FILE) " << info_plist_out << "\n\t"
622 << "@cp \"" << info_plist << "\" \"" << info_plist_out << "\"" << endl;
623 if(!project->first("RC_FILE").isEmpty()) {
624 QString dir = destdir + "../Resources/";
625 t << dir << "application.icns:" << "\n\t"
626 << "@test -d " << dir << " || mkdir -p " << dir << "\n\t"
627 << "@cp " << var("RC_FILE") << " " << dir << "application.icns" << endl;
628 }
629 }
630
631 QString ddir = project->isEmpty("QMAKE_DISTDIR") ? project->first("QMAKE_ORIG_TARGET") :
632 project->first("QMAKE_DISTDIR");
633 QString ddir_c = fileFixify((project->isEmpty("OBJECTS_DIR") ? QString(".tmp/") :
634 project->first("OBJECTS_DIR")) + ddir);
635 t << "dist: " << "\n\t"
636 << "@mkdir -p " << ddir_c << " && "
637 << "$(COPY_FILE) --parents $(SOURCES) $(HEADERS) $(FORMS) $(DIST) " << ddir_c << Option::dir_sep << " && ";
638 if(!project->isEmpty("TRANSLATIONS"))
639 t << "$(COPY_FILE) --parents " << var("TRANSLATIONS") << " " << ddir_c << Option::dir_sep << " && ";
640 if(!project->isEmpty("FORMS")) {
641 QStringList &forms = project->variables()["FORMS"], ui_headers;
642 for(QStringList::Iterator formit = forms.begin(); formit != forms.end(); ++formit) {
643 QString ui_h = fileFixify((*formit) + Option::h_ext.first());
644 if(QFile::exists(ui_h) )
645 ui_headers << ui_h;
646 }
647 if(!ui_headers.isEmpty())
648 t << "$(COPY_FILE) --parents " << val(ui_headers) << " " << ddir_c << Option::dir_sep << " && ";
649 }
650 t << "( cd `dirname " << ddir_c << "` && "
651 << "$(TAR) " << var("QMAKE_ORIG_TARGET") << ".tar " << ddir << " && "
652 << "$(GZIP) " << var("QMAKE_ORIG_TARGET") << ".tar ) && "
653 << "$(MOVE) `dirname " << ddir_c << "`" << Option::dir_sep << var("QMAKE_ORIG_TARGET") << ".tar.gz . && "
654 << "$(DEL_DIR) " << ddir_c
655 << endl << endl;
656
657 QString clean_targets;
658 if(mocAware()) {
659 t << "mocclean:" << "\n";
660 if(!objMoc.isEmpty() || !srcMoc.isEmpty() || moc_incremental) {
661 if(!objMoc.isEmpty())
662 t << "\t-$(DEL_FILE) $(OBJMOC)" << '\n';
663 if(!srcMoc.isEmpty())
664 t << "\t-$(DEL_FILE) $(SRCMOC)" << '\n';
665 if(moc_incremental)
666 t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJMOC)" << '\n';
667 clean_targets += " mocclean";
668 }
669 t << endl;
670 }
671 t << "uiclean:" << "\n";
672 if (!var("UICIMPLS").isEmpty() || !var("UICDECLS").isEmpty()) {
673 t << "\t-$(DEL_FILE) $(UICIMPLS) $(UICDECLS)" << "\n";
674 clean_targets += " uiclean";
675 }
676 t << endl;
677
678 if(do_incremental) {
679 t << "incrclean:" << "\n";
680 if(src_incremental)
681 t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJECTS)" << "\n";
682 if(moc_incremental)
683 t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJMOC)" << '\n';
684 t << endl;
685 }
686
687 t << "clean:" << clean_targets << "\n\t";
688 if(!project->isEmpty("OBJECTS"))
689 t << "-$(DEL_FILE) $(OBJECTS) " << "\n\t";
690 if(!project->isEmpty("IMAGES"))
691 t << varGlue("QMAKE_IMAGE_COLLECTION", "\t-$(DEL_FILE) ", " ", "") << "\n\t";
692 if(src_incremental)
693 t << "-$(DEL_FILE) $(INCREMENTAL_OBJECTS)" << "\n\t";
694 t << varGlue("QMAKE_CLEAN","-$(DEL_FILE) "," ","\n\t")
695 << "-$(DEL_FILE) *~ core *.core" << "\n"
696 << varGlue("CLEAN_FILES","\t-$(DEL_FILE) "," ","") << endl << endl;
697 t << "####### Sub-libraries" << endl << endl;
698 if ( !project->variables()["SUBLIBS"].isEmpty() ) {
699 QString libdir = "tmp/";
700 if(!project->isEmpty("SUBLIBS_DIR"))
701 libdir = project->first("SUBLIBS_DIR");
702 QStringList &l = project->variables()["SUBLIBS"];
703 for(it = l.begin(); it != l.end(); ++it)
704 t << libdir << "lib" << (*it) << ".a" << ":\n\t"
705 << var(QString("MAKELIB") + (*it)) << endl << endl;
706 }
707
708 QString destdir = project->first("DESTDIR");
709 if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep)
710 destdir += Option::dir_sep;
711 t << "distclean: " << "clean\n\t"
712 << "-$(DEL_FILE) " << destdir << "$(TARGET)" << " " << "$(TARGET)" << "\n";
713 if(!project->isActiveConfig("staticlib") && project->variables()["QMAKE_APP_FLAG"].isEmpty() &&
714 !project->isActiveConfig("plugin"))
715 t << "\t-$(DEL_FILE) " << destdir << "$(TARGET0) " << destdir << "$(TARGET1) "
716 << destdir << "$(TARGET2) $(TARGETA)" << "\n";
717 t << endl << endl;
718
719 if ( !project->isEmpty("PRECOMPH") ) {
720 QString outdir = project->first("MOC_DIR");
721 QString qt_dot_h = Option::fixPathToLocalOS(project->first("PRECOMPH"));
722 t << "###### Combined headers" << endl << endl;
723 //XXX
724 t << outdir << "allmoc.cpp: " << qt_dot_h << " "
725 << varList("HEADERS_ORIG") << "\n\t"
726 << "echo '#include \"" << qt_dot_h << "\"' >" << outdir << "allmoc.cpp" << "\n\t"
727 << "$(CXX) -E -DQT_MOC_CPP -DQT_NO_STL $(CXXFLAGS) $(INCPATH) >" << outdir << "allmoc.h "
728 << outdir << "allmoc.cpp" << "\n\t"
729 << "$(MOC) -o " << outdir << "allmoc.cpp " << outdir << "allmoc.h" << "\n\t"
730 << "perl -pi -e 's{#include \"allmoc.h\"}{#define QT_H_CPP\\n#include \""
731 << qt_dot_h << "\"}' " << outdir << "allmoc.cpp" << "\n\t"
732 << "$(DEL_FILE) " << outdir << "allmoc.h" << endl << endl;
733 }
734
735 // blasted user defined targets
736 QStringList &qut = project->variables()["QMAKE_EXTRA_UNIX_TARGETS"];
737 for(it = qut.begin(); it != qut.end(); ++it) {
738 QString targ = var((*it) + ".target"),
739 cmd = var((*it) + ".commands"), deps;
740 if(targ.isEmpty())
741 targ = (*it);
742 QStringList &deplist = project->variables()[(*it) + ".depends"];
743 for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) {
744 QString dep = var((*dep_it) + ".target");
745 if(dep.isEmpty())
746 dep = (*dep_it);
747 deps += " " + dep;
748 }
749 t << targ << ":" << deps << "\n\t"
750 << cmd << endl << endl;
751 }
752 t <<"FORCE:" << endl << endl;
753}
754
755struct SubDir
756{
757 QString directory, profile, target, makefile;
758};
759
760void
761UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
762{
763 QPtrList<SubDir> subdirs;
764 {
765 QStringList subdirs_in = project->variables()["SUBDIRS"];
766 for(QStringList::Iterator it = subdirs_in.begin(); it != subdirs_in.end(); ++it) {
767 QString file = (*it);
768 fileFixify(file);
769 SubDir *sd = new SubDir;
770 subdirs.append(sd);
771 sd->makefile = "$(MAKEFILE)";
772 if((*it).right(4) == ".pro") {
773 int slsh = file.findRev(Option::dir_sep);
774 if(slsh != -1) {
775 sd->directory = file.left(slsh+1);
776 sd->profile = file.mid(slsh+1);
777 } else {
778 sd->profile = file;
779 }
780 } else {
781 sd->directory = file;
782 }
783 while(sd->directory.right(1) == Option::dir_sep)
784 sd->directory = sd->directory.left(sd->directory.length() - 1);
785 if(!sd->profile.isEmpty()) {
786 QString basename = sd->directory;
787 int new_slsh = basename.findRev(Option::dir_sep);
788 if(new_slsh != -1)
789 basename = basename.mid(new_slsh+1);
790 if(sd->profile != basename + ".pro")
791 sd->makefile += "." + sd->profile.left(sd->profile.length() - 4); //no need for the .pro
792 }
793 sd->target = "sub-" + (*it);
794 sd->target.replace('/', '-');
795 sd->target.replace('.', '_');
796 }
797 }
798 QPtrListIterator<SubDir> it(subdirs);
799
800 QString ofile = Option::output.name();
801 if(ofile.findRev(Option::dir_sep) != -1)
802 ofile = ofile.right(ofile.length() - ofile.findRev(Option::dir_sep) -1);
803 t << "MAKEFILE =" << var("MAKEFILE") << endl;
804 t << "QMAKE =" << var("QMAKE") << endl;
805 t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl;
806 t << "SUBTARGETS ="; // subdirectory targets are sub-directory
807 for( it.toFirst(); it.current(); ++it)
808 t << " \\\n\t\t" << it.current()->target;
809 t << endl << endl;
810 t << "first: all\n\nall: " << ofile << " $(SUBTARGETS)" << endl << endl;
811
812 // generate target rules
813 for( it.toFirst(); it.current(); ++it) {
814 bool have_dir = !(*it)->directory.isEmpty();
815 QString mkfile = (*it)->makefile, out;
816 if(have_dir)
817 mkfile.prepend((*it)->directory + Option::dir_sep);
818 if(direct || (*it)->makefile != "$(MAKEFILE)")
819 out = " -o " + (*it)->makefile;
820 //qmake it
821 t << mkfile << ": " << "\n\t";
822 if(have_dir)
823 t << "cd " << (*it)->directory << " && ";
824 t << "$(QMAKE) " << (*it)->profile << buildArgs() << out << endl;
825 //actually compile
826 t << (*it)->target << ": " << mkfile << " FORCE" << "\n\t";
827 if(have_dir)
828 t << "cd " << (*it)->directory << " && ";
829 t << "$(MAKE) -f " << (*it)->makefile << endl << endl;
830 }
831
832 if (project->isActiveConfig("ordered")) { // generate dependencies
833 for( it.toFirst(); it.current(); ) {
834 QString tar = it.current()->target;
835 ++it;
836 if (it.current())
837 t << it.current()->target << ": " << tar << endl;
838 }
839 t << endl;
840 }
841
842 writeMakeQmake(t);
843
844 if(project->isEmpty("SUBDIRS")) {
845 t << "all qmake_all distclean install uiclean mocclean clean: FORCE" << endl;
846 } else {
847 t << "all: $(SUBTARGETS)" << endl;
848 t << "qmake_all:";
849 for( it.toFirst(); it.current(); ++it) {
850 t << " ";
851 if(!(*it)->directory.isEmpty())
852 t << (*it)->directory << Option::dir_sep;
853 t << (*it)->makefile;
854 }
855 for( it.toFirst(); it.current(); ++it) {
856 t << "\n\t ( ";
857 if(!(*it)->directory.isEmpty())
858 t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; ";
859 t << "grep \"^qmake_all:\" " << (*it)->makefile
860 << " && $(MAKE) -f " << (*it)->makefile << " qmake_all" << "; ) || true";
861 }
862 t << endl;
863 t << "clean uninstall install uiclean mocclean: qmake_all FORCE";
864 for( it.toFirst(); it.current(); ++it) {
865 t << "\n\t ( ";
866 if(!(*it)->directory.isEmpty())
867 t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; ";
868 t << "$(MAKE) -f " << (*it)->makefile << " $@" << "; ) || true";
869 }
870 t << endl;
871 t << "distclean: qmake_all FORCE";
872 for( it.toFirst(); it.current(); ++it) {
873 t << "\n\t ( ";
874 if(!(*it)->directory.isEmpty())
875 t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; ";
876 t << "$(MAKE) -f " << (*it)->makefile << " $@; $(DEL_FILE) " << (*it)->makefile << "; ) || true";
877 }
878 t << endl << endl;
879 }
880 t <<"FORCE:" << endl << endl;
881}
882
883void UnixMakefileGenerator::init2()
884{
885 //version handling
886 if(project->variables()["VERSION"].isEmpty())
887 project->variables()["VERSION"].append("1.0." +
888 (project->isEmpty("VER_PAT") ? QString("0") :
889 project->first("VER_PAT")) );
890 QStringList l = QStringList::split('.', project->first("VERSION"));
891 l << "0" << "0"; //make sure there are three
892 project->variables()["VER_MAJ"].append(l[0]);
893 project->variables()["VER_MIN"].append(l[1]);
894 project->variables()["VER_PAT"].append(l[2]);
895
896 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
897#if 0
898 if ( project->isActiveConfig("dll") ) {
899 project->variables()["TARGET"] += project->variables()["TARGET.so"];
900 if(project->variables()["QMAKE_LFLAGS_SHAPP"].isEmpty())
901 project->variables()["QMAKE_LFLAGS_SHAPP"] += project->variables()["QMAKE_LFLAGS_SHLIB"];
902 if(!project->variables()["QMAKE_LFLAGS_SONAME"].isEmpty())
903 project->variables()["QMAKE_LFLAGS_SONAME"].first() += project->first("TARGET");
904 }
905#endif
906 project->variables()["TARGET"].first().prepend(project->first("DESTDIR"));
907 } else if ( project->isActiveConfig("staticlib") ) {
908 project->variables()["TARGET"].first().prepend("lib");
909 project->variables()["TARGET"].first() += ".a";
910 if(project->variables()["QMAKE_AR_CMD"].isEmpty())
911 project->variables()["QMAKE_AR_CMD"].append("$(AR) $(TARGET) $(OBJECTS) $(OBJMOC)");
912 } else {
913 project->variables()["TARGETA"].append(project->first("DESTDIR") + "lib" + project->first("TARGET") + ".a");
914 if ( !project->variables()["QMAKE_AR_CMD"].isEmpty() )
915 project->variables()["QMAKE_AR_CMD"].first().replace("(TARGET)","(TARGETA)");
916 else
917 project->variables()["QMAKE_AR_CMD"].append("$(AR) $(TARGETA) $(OBJECTS) $(OBJMOC)");
918 QString os = project->variables()["QMAKESPEC"].first().section( '-', 0, 0 );
919 if( project->isActiveConfig("plugin") ) {
920 project->variables()["TARGET_x.y.z"].append("lib" +
921 project->first("TARGET") + "." + project->first("QMAKE_EXTENSION_SHLIB"));
922 if(project->isActiveConfig("lib_version_first"))
923 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
924 project->first("VER_MAJ") + "." +
925 project->first("QMAKE_EXTENSION_SHLIB"));
926 else
927 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
928 project->first("QMAKE_EXTENSION_SHLIB") +
929 "." + project->first("VER_MAJ"));
930
931 project->variables()["TARGET"] = project->variables()["TARGET_x.y.z"];
932 if(project->isActiveConfig("qt"))
933 project->variables()["DEFINES"].append("QT_PLUGIN");
934 } else if ( os == "hpux" ) {
935 project->variables()["TARGET_"].append("lib" + project->first("TARGET") + ".sl");
936 if(project->isActiveConfig("lib_version_first"))
937 project->variables()["TARGET_x"].append("lib" + project->first("VER_MAJ") + "." +
938 project->first("TARGET"));
939 else
940 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
941 project->first("VER_MAJ"));
942 project->variables()["TARGET"] = project->variables()["TARGET_x"];
943 } else if ( os == "aix" ) {
944 project->variables()["TARGET_"].append("lib" + project->first("TARGET") + ".a");
945 if(project->isActiveConfig("lib_version_first")) {
946 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
947 project->first("VER_MAJ") + "." +
948 project->first("QMAKE_EXTENSION_SHLIB"));
949 project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." +
950 project->first("VER_MAJ") +
951 "." + project->first("VER_MIN") + "." +
952 project->first("QMAKE_EXTENSION_SHLIB"));
953 project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") + "." +
954 project->first("VER_MAJ") + "." +
955 project->first("VER_MIN") + "." +
956 project->first("VER_PAT") + "." +
957 project->first("QMAKE_EXTENSION_SHLIB"));
958 } else {
959 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
960 project->first("QMAKE_EXTENSION_SHLIB") +
961 "." + project->first("VER_MAJ"));
962 project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." +
963 project->first("QMAKE_EXTENSION_SHLIB") +
964 "." + project->first("VER_MAJ") +
965 "." + project->first("VER_MIN"));
966 project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") + "." +
967 project->first("QMAKE_EXTENSION_SHLIB") + "." +
968 project->first("VER_MAJ") + "." +
969 project->first("VER_MIN") + "." +
970 project->first("VER_PAT"));
971 }
972 project->variables()["TARGET"] = project->variables()["TARGET_x.y.z"];
973 } else {
974 project->variables()["TARGET_"].append("lib" + project->first("TARGET") + "." +
975 project->first("QMAKE_EXTENSION_SHLIB"));
976 if(project->isActiveConfig("lib_version_first")) {
977 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
978 project->first("VER_MAJ") + "." +
979 project->first("QMAKE_EXTENSION_SHLIB"));
980 project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." +
981 project->first("VER_MAJ") +
982 "." + project->first("VER_MIN") + "." +
983 project->first("QMAKE_EXTENSION_SHLIB"));
984 project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") + "." +
985 project->first("VER_MAJ") + "." +
986 project->first("VER_MIN") + "." +
987 project->first("VER_PAT") + "." +
988 project->variables()["QMAKE_EXTENSION_SHLIB"].first());
989 } else {
990 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
991 project->first("QMAKE_EXTENSION_SHLIB") +
992 "." + project->first("VER_MAJ"));
993 project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." +
994 project->first("QMAKE_EXTENSION_SHLIB")
995 + "." + project->first("VER_MAJ") +
996 "." + project->first("VER_MIN"));
997 project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") +
998 "." +
999 project->variables()[
1000 "QMAKE_EXTENSION_SHLIB"].first() + "." +
1001 project->first("VER_MAJ") + "." +
1002 project->first("VER_MIN") + "." +
1003 project->first("VER_PAT"));
1004 }
1005 project->variables()["TARGET"] = project->variables()["TARGET_x.y.z"];
1006 }
1007 if(project->isEmpty("QMAKE_LN_SHLIB"))
1008 project->variables()["QMAKE_LN_SHLIB"].append("ln -s");
1009 project->variables()["DESTDIR_TARGET"].append("$(TARGET)");
1010 if ( !project->variables()["DESTDIR"].isEmpty() )
1011 project->variables()["DESTDIR_TARGET"].first().prepend(project->first("DESTDIR"));
1012 if ( !project->variables()["QMAKE_LFLAGS_SONAME"].isEmpty() && !project->variables()["TARGET_x"].isEmpty() )
1013 project->variables()["QMAKE_LFLAGS_SONAME"].first() += project->first("TARGET_x");
1014 if ( project->variables()["QMAKE_LINK_SHLIB_CMD"].isEmpty() )
1015 project->variables()["QMAKE_LINK_SHLIB_CMD"].append(
1016 "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)");
1017 }
1018 if(project->isEmpty("QMAKE_SYMBOLIC_LINK"))
1019 project->variables()["QMAKE_SYMBOLIC_LINK"].append("ln -sf");
1020 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
1021 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SHAPP"];
1022 } else if ( project->isActiveConfig("dll") ) {
1023 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_SHLIB"];
1024 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_SHLIB"];
1025 if ( project->isActiveConfig("plugin") ) {
1026 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_PLUGIN"];
1027 if( !project->isActiveConfig("plugin_no_soname") )
1028 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SONAME"];
1029 } else {
1030 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SHLIB"];
1031 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SONAME"];
1032 }
1033 QString destdir = project->first("DESTDIR");
1034 if ( !destdir.isEmpty() && !project->variables()["QMAKE_RPATH"].isEmpty() ) {
1035 QString rpath_destdir = destdir;
1036 if(QDir::isRelativePath(rpath_destdir)) {
1037 QFileInfo fi(Option::fixPathToLocalOS(rpath_destdir));
1038 if(fi.convertToAbs()) //strange, shouldn't really happen
1039 rpath_destdir = Option::fixPathToTargetOS(rpath_destdir, FALSE);
1040 else
1041 rpath_destdir = fi.filePath();
1042 } else {
1043 rpath_destdir = Option::fixPathToTargetOS(rpath_destdir, FALSE);
1044 }
1045 project->variables()["QMAKE_LFLAGS"] += project->first("QMAKE_RPATH") + rpath_destdir;
1046 }
1047 }
1048}
diff --git a/qmake/generators/win32/borland_bmake.cpp b/qmake/generators/win32/borland_bmake.cpp
new file mode 100644
index 0000000..ae7b47b
--- a/dev/null
+++ b/qmake/generators/win32/borland_bmake.cpp
@@ -0,0 +1,477 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Created : 970521
7**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
9**
10** This file is part of the network module of the Qt GUI Toolkit.
11**
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
14** LICENSE.QPL included in the packaging of this file.
15**
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
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software.
24**
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.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38#include "borland_bmake.h"
39#include "option.h"
40#include <qdir.h>
41#include <qregexp.h>
42#include <time.h>
43#include <stdlib.h>
44
45
46BorlandMakefileGenerator::BorlandMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE)
47{
48
49}
50
51bool
52BorlandMakefileGenerator::writeMakefile(QTextStream &t)
53{
54 writeHeader(t);
55 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {
56 t << "all clean:" << "\n\t"
57 << "@echo \"Some of the required modules ("
58 << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t"
59 << "@echo \"Skipped.\"" << endl << endl;
60 return TRUE;
61 }
62
63 if(project->first("TEMPLATE") == "app" ||
64 project->first("TEMPLATE") == "lib") {
65 writeBorlandParts(t);
66 return MakefileGenerator::writeMakefile(t);
67 }
68 else if(project->first("TEMPLATE") == "subdirs") {
69 writeSubDirs(t);
70 return TRUE;
71 }
72 return FALSE;
73}
74
75void
76BorlandMakefileGenerator::writeBorlandParts(QTextStream &t)
77{
78 t << "!if !$d(BCB)" << endl;
79 t << "BCB = $(MAKEDIR)\\.." << endl;
80 t << "!endif" << endl << endl;
81 t << "####### Compiler, tools and options" << endl << endl;
82 t << "CC =" << var("QMAKE_CC") << endl;
83 t << "CXX =" << var("QMAKE_CXX") << endl;
84 t << "LEX = " << var("QMAKE_LEX") << endl;
85 t << "YACC = " << var("QMAKE_YACC") << endl;
86 t << "CFLAGS =" << var("QMAKE_CFLAGS") << " "
87 << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "
88 << varGlue("DEFINES","-D"," -D","") << endl;
89 t << "CXXFLAGS=" << var("QMAKE_CXXFLAGS") << " "
90 << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "
91 << varGlue("DEFINES","-D"," -D","") << endl;
92 t << "LEXFLAGS=" << var("QMAKE_LEXFLAGS") << endl;
93 t << "YACCFLAGS=" << var("QMAKE_YACCFLAGS") << endl;
94
95 t << "INCPATH =";
96 QStringList &incs = project->variables()["INCLUDEPATH"];
97 for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) {
98 QString inc = (*incit);
99 inc.replace(QRegExp("\\\\*$"), "");
100 inc.replace("\"", "");
101 t << " -I\"" << inc << "\"";
102 }
103 t << " -I\"" << specdir() << "\""
104 << endl;
105
106 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
107 t << "LINK =" << var("QMAKE_LINK") << endl;
108 t << "LFLAGS =";
109 if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() )
110 t << varGlue("QMAKE_LIBDIR","-L",";","") << " ";
111 t << var("QMAKE_LFLAGS") << endl;
112 t << "LIBS =" << var("QMAKE_LIBS") << endl;
113 }
114 else {
115 t << "LIB =" << var("QMAKE_LIB") << endl;
116 }
117 t << "MOC =" << (project->isEmpty("QMAKE_MOC") ? QString("moc") :
118 Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl;
119 t << "UIC =" << (project->isEmpty("QMAKE_UIC") ? QString("uic") :
120 Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl;
121 t << "QMAKE = " << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") :
122 Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl;
123 t << "IDC =" << (project->isEmpty("QMAKE_IDC") ? QString("idc") :
124 Option::fixPathToTargetOS(var("QMAKE_IDC"), FALSE)) << endl;
125 t << "IDL =" << (project->isEmpty("QMAKE_IDL") ? QString("midl") :
126 Option::fixPathToTargetOS(var("QMAKE_IDL"), FALSE)) << endl;
127 t << "ZIP =" << var("QMAKE_ZIP") << endl;
128 t << "DEF_FILE =" << varList("DEF_FILE") << endl;
129 t << "RES_FILE =" << varList("RES_FILE") << endl;
130 t << "COPY_FILE = " << var("QMAKE_COPY") << endl;
131 t << "COPY_DIR = " << var("QMAKE_COPY") << endl;
132 t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl;
133 t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl;
134 t << "MOVE = " << var("QMAKE_MOVE") << endl;
135 t << endl;
136
137 t << "####### Files" << endl << endl;
138 t << "HEADERS =" << varList("HEADERS") << endl;
139 t << "SOURCES =" << varList("SOURCES") << endl;
140 t << "OBJECTS =" << varList("OBJECTS") << endl;
141 t << "FORMS =" << varList("FORMS") << endl;
142 t << "UICDECLS =" << varList("UICDECLS") << endl;
143 t << "UICIMPLS =" << varList("UICIMPLS") << endl;
144 t << "SRCMOC =" << varList("SRCMOC") << endl;
145 t << "OBJMOC =" << varList("OBJMOC") << endl;
146 t << "DIST =" << varList("DISTFILES") << endl;
147 t << "TARGET ="
148 << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT"))
149 << endl;
150 t << endl;
151
152 t << "####### Implicit rules" << endl << endl;
153 t << ".SUFFIXES: .cpp .cxx .cc .c" << endl << endl;
154 t << ".cpp.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
155 t << ".cxx.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
156 t << ".cc.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
157 t << ".c.obj:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;
158
159 t << "####### Build rules" << endl << endl;
160 t << "all: " << varGlue("ALL_DEPS",""," "," ") << " $(TARGET)" << endl << endl;
161 t << "$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) " << var("TARGETDEPS");
162 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
163 t << "\n\t" << "$(LINK) @&&|" << "\n\t"
164 << "$(LFLAGS) $(OBJECTS) $(OBJMOC),$(TARGET),,$(LIBS),$(DEF_FILE),$(RES_FILE)";
165 } else {
166 t << "\n\t-del $(TARGET)"
167 << "\n\t" << "$(LIB) $(TARGET) @&&|" << " \n+"
168 << project->variables()["OBJECTS"].join(" \\\n+") << " \\\n+"
169 << project->variables()["OBJMOC"].join(" \\\n+");
170 }
171 t << endl << "|" << endl;
172 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) {
173 QStringList dlldirs = project->variables()["DLLDESTDIR"];
174 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) {
175 t << "\n\t" << "-copy $(TARGET) " << *dlldir;
176 }
177 }
178 QString targetfilename = project->variables()["TARGET"].first();
179 if(project->isActiveConfig("activeqt")) {
180 QString version = project->variables()["VERSION"].first();
181 if ( version.isEmpty() )
182 version = "1.0";
183
184 if ( project->isActiveConfig("dll")) {
185 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");
187 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb");
188 t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" );
189 } else {
190 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");
192 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb");
193 t << "\n\t" << ("-$(TARGET) -regserver");
194 }
195 }
196 t << endl << endl;
197
198 if(!project->variables()["RC_FILE"].isEmpty()) {
199 t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t"
200 << var("QMAKE_RC") << " " << var("RC_FILE") << endl << endl;
201 }
202 t << "mocables: $(SRCMOC)" << endl << endl;
203
204 writeMakeQmake(t);
205
206 t << "dist:" << "\n\t"
207 << "$(ZIP) " << var("PROJECT") << ".zip " << var("PROJECT") << ".pro $(SOURCES) $(HEADERS) $(DIST) $(FORMS)"
208 << endl << endl;
209
210 t << "clean:\n"
211 << varGlue("OBJECTS","\t-del ","\n\t-del ","")
212 << varGlue("SRCMOC" ,"\n\t-del ","\n\t-del ","")
213 << varGlue("OBJMOC" ,"\n\t-del ","\n\t-del ","")
214 << varGlue("UICDECLS" ,"\n\t-del ","\n\t-del ","")
215 << varGlue("UICIMPLS" ,"\n\t-del ","\n\t-del ","")
216 << "\n\t-del $(TARGET)"
217 << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ","")
218 << varGlue("CLEAN_FILES","\n\t-del ","\n\t-del ","");
219 if ( project->isActiveConfig("activeqt")) {
220 t << ("\n\t-del tmp\\" + targetfilename + ".*");
221 t << "\n\t-del tmp\\dump.*";
222 }
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"))
226 t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-del ", "\n\t-del ", "");
227
228 // blasted user defined targets
229 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"];
230 for(QStringList::Iterator it = qut.begin(); it != qut.end(); ++it) {
231 QString targ = var((*it) + ".target"),
232 cmd = var((*it) + ".commands"), deps;
233 if(targ.isEmpty())
234 targ = (*it);
235 QStringList &deplist = project->variables()[(*it) + ".depends"];
236 for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) {
237 QString dep = var((*dep_it) + ".target");
238 if(dep.isEmpty())
239 dep = (*dep_it);
240 deps += " " + dep;
241 }
242 t << "\n\n" << targ << ":" << deps << "\n\t"
243 << cmd;
244 }
245
246 t << endl << endl;
247}
248
249void
250BorlandMakefileGenerator::init()
251{
252 if(init_flag)
253 return;
254 init_flag = TRUE;
255
256 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"];
257
258 /* this should probably not be here, but I'm using it to wrap the .t files */
259 if(project->first("TEMPLATE") == "app")
260 project->variables()["QMAKE_APP_FLAG"].append("1");
261 else if(project->first("TEMPLATE") == "lib")
262 project->variables()["QMAKE_LIB_FLAG"].append("1");
263 else if(project->first("TEMPLATE") == "subdirs") {
264 MakefileGenerator::init();
265 if(project->variables()["MAKEFILE"].isEmpty())
266 project->variables()["MAKEFILE"].append("Makefile");
267 if(project->variables()["QMAKE"].isEmpty())
268 project->variables()["QMAKE"].append("qmake");
269 return;
270 }
271
272 bool is_qt = (project->first("TARGET") == "qt"QTDLL_POSTFIX || project->first("TARGET") == "qtmt"QTDLL_POSTFIX);
273 QStringList &configs = project->variables()["CONFIG"];
274 if (project->isActiveConfig("shared"))
275 project->variables()["DEFINES"].append("QT_DLL");
276 if (project->isActiveConfig("qt_dll"))
277 if(configs.findIndex("qt") == -1) configs.append("qt");
278 if ( project->isActiveConfig("qt") ) {
279 if ( project->isActiveConfig("plugin") ) {
280 project->variables()["CONFIG"].append("dll");
281 project->variables()["DEFINES"].append("QT_PLUGIN");
282 }
283 if ( (project->variables()["DEFINES"].findIndex("QT_NODLL") == -1) &&
284 ((project->variables()["DEFINES"].findIndex("QT_MAKEDLL") != -1 ||
285 project->variables()["DEFINES"].findIndex("QT_DLL") != -1) ||
286 (getenv("QT_DLL") && !getenv("QT_NODLL"))) ) {
287 project->variables()["QMAKE_QT_DLL"].append("1");
288 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() )
289 project->variables()["CONFIG"].append("dll");
290 }
291 }
292 if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
293 project->variables()["CONFIG"].remove("staticlib");
294 project->variables()["QMAKE_APP_OR_DLL"].append("1");
295 } else {
296 project->variables()["CONFIG"].append("staticlib");
297 }
298 if ( project->isActiveConfig("warn_off") ) {
299 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_OFF"];
300 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_OFF"];
301 } else if ( project->isActiveConfig("warn_on") ) {
302 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_ON"];
303 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_ON"];
304 }
305 if(project->isActiveConfig("qt")) {
306 if ( project->isActiveConfig("thread") )
307 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT");
308 if ( project->isActiveConfig("accessibility" ) )
309 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT");
310 if ( project->isActiveConfig("tablet") )
311 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT");
312 }
313
314 if ( project->isActiveConfig("debug") ) {
315 if ( project->isActiveConfig("thread") ) {
316 if ( project->isActiveConfig("dll") ) {
317 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLLDBG"];
318 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"];
319 } else {
320 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DBG"];
321 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DBG"];
322 }
323 }
324 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_DEBUG"];
325 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_DEBUG"];
326 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_DEBUG"];
327 } else {
328 if ( project->isActiveConfig("thread") ) {
329 if ( project->isActiveConfig("dll") ) {
330 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLL"];
331 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLL"];
332 } else {
333 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT"];
334 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT"];
335 }
336 }
337 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RELEASE"];
338 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RELEASE"];
339 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_RELEASE"];
340 }
341
342 if ( !project->variables()["QMAKE_INCDIR"].isEmpty()) {
343 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"];
344 }
345 if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") ) {
346 project->variables()["CONFIG"].append("windows");
347 }
348 if ( project->isActiveConfig("qt") ) {
349 project->variables()["CONFIG"].append("moc");
350 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"];
351 project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"];
352 if ( !project->isActiveConfig("debug") )
353 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG");
354 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) {
355 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty()) {
356 project->variables()["DEFINES"].append("QT_MAKEDLL");
357 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_QT_DLL"];
358 }
359 } else {
360 if(project->isActiveConfig("thread"))
361 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"];
362 else
363 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"];
364 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) {
365 int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt");
366 if ( hver == -1 )
367 hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt-mt");
368 if(hver != -1) {
369 QString ver;
370 ver.sprintf("qt%s" QTDLL_POSTFIX "%d.lib", (project->isActiveConfig("thread") ? "mt" : ""), hver);
371 QStringList &libs = project->variables()["QMAKE_LIBS"];
372 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit)
373 (*libit).replace(QRegExp("qt(mt)?\\.lib"), ver);
374 }
375 }
376 if ( project->isActiveConfig( "activeqt" ) ) {
377 project->variables().remove("QMAKE_LIBS_QT_ENTRY");
378 project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib";
379 if ( project->isActiveConfig( "dll" ) )
380 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"];
381 }
382 if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) {
383 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"];
384 }
385 }
386 }
387 if ( project->isActiveConfig("opengl") ) {
388 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"];
389 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"];
390 }
391 if ( project->isActiveConfig("dll") ) {
392 project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE_DLL"];
393 project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE_DLL"];
394 project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE_DLL"];
395 project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS_DLL"];
396 if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty()) {
397 project->variables()["TARGET_EXT"].append(
398 QStringList::split('.',project->first("VERSION")).join("") + ".dll");
399 } else {
400 project->variables()["TARGET_EXT"].append(".dll");
401 }
402 } else {
403 project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE"];
404 project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE"];
405 project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE"];
406 project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS"];
407 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty()) {
408 project->variables()["TARGET_EXT"].append(".exe");
409 } else {
410 project->variables()["TARGET_EXT"].append(".lib");
411 }
412 }
413 if ( project->isActiveConfig("windows") ) {
414 if ( project->isActiveConfig("console") ) {
415 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
416 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
417 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
418 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
419 } else {
420 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"];
421 }
422 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"];
423 } else {
424 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
425 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
426 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
427 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
428 }
429 if ( project->isActiveConfig("thread") ) {
430 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_RTMT"];
431 } else {
432 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_RT"];
433 }
434 if ( project->isActiveConfig("moc") ) {
435 setMocAware(TRUE);
436 }
437 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
438 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ',
439 "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH");
440 QStringList &l = project->variables()["QMAKE_FILETAGS"];
441 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
442 QStringList &gdmf = project->variables()[(*it)];
443 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner)
444 (*inner) = Option::fixPathToTargetOS((*inner), FALSE);
445 }
446
447 if ( !project->variables()["RC_FILE"].isEmpty()) {
448 if ( !project->variables()["RES_FILE"].isEmpty()) {
449 fprintf(stderr, "Both .rc and .res file specified.\n");
450 fprintf(stderr, "Please specify one of them, not both.");
451 exit(666);
452 }
453 project->variables()["RES_FILE"] = project->variables()["RC_FILE"];
454 project->variables()["RES_FILE"].first().replace(".rc",".res");
455 project->variables()["TARGETDEPS"] += project->variables()["RES_FILE"];
456 }
457 MakefileGenerator::init();
458 if ( !project->variables()["VERSION"].isEmpty()) {
459 QStringList l = QStringList::split('.', project->first("VERSION"));
460 project->variables()["VER_MAJ"].append(l[0]);
461 project->variables()["VER_MIN"].append(l[1]);
462 }
463
464 if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
465 // bcc does not generate a .tds file for static libs
466 QString tdsPostfix;
467 if ( !project->variables()["VERSION"].isEmpty() ) {
468 tdsPostfix = QStringList::split( '.', project->first("VERSION") ).join("")
469 + ".tds";
470 } else {
471 tdsPostfix = ".tds";
472 }
473 project->variables()["QMAKE_CLEAN"].append(
474 project->first("DESTDIR") + project->first("TARGET") + tdsPostfix );
475 }
476}
477
diff --git a/qmake/generators/win32/borland_bmake.h b/qmake/generators/win32/borland_bmake.h
new file mode 100644
index 0000000..90f8229
--- a/dev/null
+++ b/qmake/generators/win32/borland_bmake.h
@@ -0,0 +1,59 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Created : 970521
7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9**
10** This file is part of the network module of the Qt GUI Toolkit.
11**
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
14** LICENSE.QPL included in the packaging of this file.
15**
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
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software.
24**
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.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37#ifndef __BORLANDMAKE_H__
38#define __BORLANDMAKE_H__
39
40#include "winmakefile.h"
41
42class BorlandMakefileGenerator : public Win32MakefileGenerator
43{
44 bool init_flag;
45 void writeBorlandParts(QTextStream &);
46
47 bool writeMakefile(QTextStream &);
48 void init();
49
50public:
51 BorlandMakefileGenerator(QMakeProject *p);
52 ~BorlandMakefileGenerator();
53};
54
55inline BorlandMakefileGenerator::~BorlandMakefileGenerator()
56{ }
57
58
59#endif /* __BORLANDMAKE_H__ */
diff --git a/qmake/generators/win32/msvc_dsp.cpp b/qmake/generators/win32/msvc_dsp.cpp
new file mode 100644
index 0000000..8b08c78
--- a/dev/null
+++ b/qmake/generators/win32/msvc_dsp.cpp
@@ -0,0 +1,955 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Created : 970521
7**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
9**
10** This file is part of the network module of the Qt GUI Toolkit.
11**
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
14** LICENSE.QPL included in the packaging of this file.
15**
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
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software.
24**
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.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38#include "msvc_dsp.h"
39#include "option.h"
40#include <qdir.h>
41#include <qregexp.h>
42#include <stdlib.h>
43#include <time.h>
44
45DspMakefileGenerator::DspMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE)
46{
47
48}
49
50bool
51DspMakefileGenerator::writeMakefile(QTextStream &t)
52{
53 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {
54 /* for now just dump, I need to generated an empty dsp or something.. */
55 fprintf(stderr, "Project file not generated because all requirements not met:\n\t%s\n",
56 var("QMAKE_FAILED_REQUIREMENTS").latin1());
57 return TRUE;
58 }
59
60 if(project->first("TEMPLATE") == "vcapp" ||
61 project->first("TEMPLATE") == "vclib") {
62 return writeDspParts(t);
63 }
64 else if(project->first("TEMPLATE") == "subdirs") {
65 writeHeader(t);
66 writeSubDirs(t);
67 return TRUE;
68 }
69 return FALSE;
70}
71
72bool
73DspMakefileGenerator::writeDspParts(QTextStream &t)
74{
75 QString dspfile;
76 if ( !project->variables()["DSP_TEMPLATE"].isEmpty() ) {
77 dspfile = project->first("DSP_TEMPLATE");
78 } else {
79 dspfile = project->first("MSVCDSP_TEMPLATE");
80 }
81 QString dspfile_loc = findTemplate(dspfile);
82
83 QFile file(dspfile_loc);
84 if(!file.open(IO_ReadOnly)) {
85 fprintf(stderr, "Cannot open dsp file: %s\n", dspfile.latin1());
86 return FALSE;
87 }
88 QTextStream dsp(&file);
89
90 int rep;
91 QString line;
92 while ( !dsp.eof() ) {
93 line = dsp.readLine();
94 while((rep = line.find(QRegExp("\\$\\$[a-zA-Z0-9_-]*"))) != -1) {
95 QString torep = line.mid(rep, line.find(QRegExp("[^\\$a-zA-Z0-9_-]"), rep) - rep);
96 QString variable = torep.right(torep.length()-2);
97
98 t << line.left(rep); //output the left side
99 line = line.right(line.length() - (rep + torep.length())); //now past the variable
100 if(variable == "MSVCDSP_SOURCES") {
101 if(project->variables()["SOURCES"].isEmpty())
102 continue;
103
104 QString mocpath = var( "QMAKE_MOC" );
105 mocpath = mocpath.replace( QRegExp( "\\..*$" ), "" ) + " ";
106
107 QStringList list = project->variables()["SOURCES"] + project->variables()["DEF_FILE"];
108 if(!project->isActiveConfig("flat"))
109 list.sort();
110 QStringList::Iterator it;
111 for( it = list.begin(); it != list.end(); ++it) {
112 beginGroupForFile((*it), t);
113 t << "# Begin Source File\n\nSOURCE=" << (*it) << endl;
114 if ( project->isActiveConfig("moc") && (*it).endsWith(Option::moc_ext)) {
115 QString base = (*it);
116 base.replace(QRegExp("\\..*$"), "").upper();
117 base.replace(QRegExp("[^a-zA-Z]"), "_");
118
119 QString build = "\n\n# Begin Custom Build - Moc'ing " + findMocSource((*it)) +
120 "...\n" "InputPath=.\\" + (*it) + "\n\n" "\"" + (*it) + "\""
121 " : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n"
122 "\t" + mocpath + findMocSource((*it)) + " -o " +
123 (*it) + "\n\n" "# End Custom Build\n\n";
124
125 t << "USERDEP_" << base << "=\".\\" << findMocSource((*it)) << "\" \"$(QTDIR)\\bin\\moc.exe\"" << endl << endl;
126
127 t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build
128 << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\""
129 << build << "!ENDIF " << endl << endl;
130 }
131 t << "# End Source File" << endl;
132 }
133 endGroups(t);
134 } else if(variable == "MSVCDSP_IMAGES") {
135 if(project->variables()["IMAGES"].isEmpty())
136 continue;
137 t << "# Begin Source File\n\nSOURCE=" << project->first("QMAKE_IMAGE_COLLECTION") << endl;
138 t << "# End Source File" << endl;
139 } else if(variable == "MSVCDSP_HEADERS") {
140 if(project->variables()["HEADERS"].isEmpty())
141 continue;
142
143 QStringList list = project->variables()["HEADERS"];
144 if(!project->isActiveConfig("flat"))
145 list.sort();
146 for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
147 // beginGroupForFile((*it), t);
148 t << "# Begin Source File\n\nSOURCE=" << (*it) << endl << endl;
149 if ( project->isActiveConfig("moc") && !findMocDestination((*it)).isEmpty()) {
150 QString base = (*it);
151 base.replace(QRegExp("\\..*$"), "").upper();
152 base.replace(QRegExp("[^a-zA-Z]"), "_");
153
154 QString mocpath = var( "QMAKE_MOC" );
155 mocpath = mocpath.replace( QRegExp( "\\..*$" ), "" ) + " ";
156
157 QString build = "\n\n# Begin Custom Build - Moc'ing " + (*it) +
158 "...\n" "InputPath=.\\" + (*it) + "\n\n" "\"" + findMocDestination((*it)) +
159 "\"" " : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n"
160 "\t" + mocpath + (*it) + " -o " +
161 findMocDestination((*it)) + "\n\n" "# End Custom Build\n\n";
162
163 t << "USERDEP_" << base << "=\"$(QTDIR)\\bin\\moc.exe\"" << endl << endl;
164
165 t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build
166 << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\""
167 << build << "!ENDIF " << endl << endl;
168 }
169 t << "# End Source File" << endl;
170 }
171 // endGroups(t);
172 } else if(variable == "MSVCDSP_FORMSOURCES" || variable == "MSVCDSP_FORMHEADERS") {
173 if(project->variables()["FORMS"].isEmpty())
174 continue;
175
176 QString uiSourcesDir;
177 QString uiHeadersDir;
178 if(!project->variables()["UI_DIR"].isEmpty()) {
179 uiSourcesDir = project->first("UI_DIR");
180 uiHeadersDir = project->first("UI_DIR");
181 } else {
182 if ( !project->variables()["UI_SOURCES_DIR"].isEmpty() )
183 uiSourcesDir = project->first("UI_SOURCES_DIR");
184 else
185 uiSourcesDir = "";
186 if ( !project->variables()["UI_HEADERS_DIR"].isEmpty() )
187 uiHeadersDir = project->first("UI_HEADERS_DIR");
188 else
189 uiHeadersDir = "";
190 }
191
192 QStringList list = project->variables()["FORMS"];
193 if(!project->isActiveConfig("flat"))
194 list.sort();
195 QString ext = variable == "MSVCDSP_FORMSOURCES" ? ".cpp" : ".h";
196 for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
197 QString base = (*it);
198 int dot = base.findRev(".");
199 base.replace( dot, base.length() - dot, ext );
200 QString fname = base;
201
202 int lbs = fname.findRev( "\\" );
203 QString fpath;
204 if ( lbs != -1 )
205 fpath = fname.left( lbs + 1 );
206 fname = fname.right( fname.length() - lbs - 1 );
207
208 if ( ext == ".cpp" && !uiSourcesDir.isEmpty() )
209 fname.prepend(uiSourcesDir);
210 else if ( ext == ".h" && !uiHeadersDir.isEmpty() )
211 fname.prepend(uiHeadersDir);
212 else
213 fname = base;
214 // beginGroupForFile(fname, t);
215 t << "# Begin Source File\n\nSOURCE=" << fname
216 << "\n# End Source File" << endl;
217 }
218 // endGroups(t);
219 } else if(variable == "MSVCDSP_TRANSLATIONS" ) {
220 if(project->variables()["TRANSLATIONS"].isEmpty())
221 continue;
222
223 t << "# Begin Group \"Translations\"\n";
224 t << "# Prop Default_Filter \"ts\"\n";
225
226 QStringList list = project->variables()["TRANSLATIONS"];
227 if(!project->isActiveConfig("flat"))
228 list.sort();
229 for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
230 QString sify = *it;
231 sify.replace('/', '\\' );
232 QString base = (*it);
233 base.replace(QRegExp("\\..*$"), "").upper();
234 base.replace(QRegExp("[^a-zA-Z]"), "_");
235
236 // beginGroupForFile(sify, t);
237 t << "# Begin Source File\n\nSOURCE=" << sify << endl;
238 t << "\n# End Source File" << endl;
239 }
240 // endGroups(t);
241 t << "\n# End Group\n";
242 } else if (variable == "MSVCDSP_MOCSOURCES" && project->isActiveConfig("moc")) {
243 if ( project->variables()["SRCMOC"].isEmpty())
244 continue;
245
246 QString mocpath = var( "QMAKE_MOC" );
247 mocpath = mocpath.replace( QRegExp( "\\..*$" ), "" ) + " ";
248
249 QStringList list = project->variables()["SRCMOC"];
250 if(!project->isActiveConfig("flat"))
251 list.sort();
252 for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
253 // beginGroupForFile((*it), t);
254 t << "# Begin Source File\n\nSOURCE=" << (*it) << endl;
255 if ( project->isActiveConfig("moc") && (*it).endsWith(Option::moc_ext)) {
256 QString base = (*it);
257 base.replace(QRegExp("\\..*$"), "").upper();
258 base.replace(QRegExp("[^a-zA-Z]"), "_");
259
260 QString build = "\n\n# Begin Custom Build - Moc'ing " + findMocSource((*it)) +
261 "...\n" "InputPath=.\\" + (*it) + "\n\n" "\"" + (*it) + "\""
262 " : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n"
263 "\t" + mocpath + findMocSource((*it)) + " -o " +
264 (*it) + "\n\n" "# End Custom Build\n\n";
265
266 t << "USERDEP_" << base << "=\".\\" << findMocSource((*it)) << "\" \"$(QTDIR)\\bin\\moc.exe\"" << endl << endl;
267
268 t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build
269 << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\""
270 << build << "!ENDIF " << endl << endl;
271 }
272 t << "# End Source File" << endl;
273 }
274 // endGroups(t);
275 } else if(variable == "MSVCDSP_PICTURES") {
276 if(project->variables()["IMAGES"].isEmpty())
277 continue;
278
279 t << "# Begin Group \"Images\"\n"
280 << "# Prop Default_Filter \"png jpeg bmp xpm\"\n";
281
282 QStringList list = project->variables()["IMAGES"];
283 if(!project->isActiveConfig("flat"))
284 list.sort();
285 QStringList::Iterator it;
286
287 // dump the image list to a file UIC can read.
288 QFile f( "images.tmp" );
289 f.open( IO_WriteOnly );
290 QTextStream ts( &f );
291 for( it = list.begin(); it != list.end(); ++it )
292 ts << " " << *it;
293 f.close();
294
295 // create an output step for images not more than once
296 bool imagesBuildDone = FALSE;
297 for( it = list.begin(); it != list.end(); ++it ) {
298 // beginGroupForFile((*it), t);
299 t << "# Begin Source File\n\nSOURCE=" << (*it) << endl;
300
301 QString base = (*it);
302 QString uicpath = var("QMAKE_UIC");
303 uicpath = uicpath.replace(QRegExp("\\..*$"), "") + " ";
304
305 if ( !imagesBuildDone ) {
306 imagesBuildDone = TRUE;
307 QString build = "\n\n# Begin Custom Build - Creating image collection...\n"
308 "InputPath=.\\" + base + "\n\n";
309
310 build += "\"" + project->first("QMAKE_IMAGE_COLLECTION") + "\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n";
311 build += "\t" + uicpath + "-embed " + project->first("QMAKE_ORIG_TARGET") + " -f images.tmp -o "
312 + project->first("QMAKE_IMAGE_COLLECTION") + "\n\n";
313 build.append("# End Custom Build\n\n");
314
315 t << "USERDEP_" << base << "=";
316 QStringList::Iterator it2 = list.begin();
317 while ( it2 != list.end() ) {
318 t << "\"" << (*it2) << "\"";
319 it2++;
320 if ( it2 != list.end() )
321 t << "\\\n";
322 }
323 t << endl << endl;
324
325 t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build
326 << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" << build
327 << "!ENDIF \n\n" << endl;
328 }
329
330 t << "# End Source File" << endl;
331 }
332 // endGroups(t);
333 t << "\n# End Group\n";
334 } else if(variable == "MSVCDSP_FORMS") {
335 if(project->variables()["FORMS"].isEmpty())
336 continue;
337
338 t << "# Begin Group \"Forms\"\n"
339 << "# Prop Default_Filter \"ui\"\n";
340
341 QString uicpath = var("QMAKE_UIC");
342 uicpath = uicpath.replace(QRegExp("\\..*$"), "") + " ";
343 QString mocpath = var( "QMAKE_MOC" );
344 mocpath = mocpath.replace( QRegExp( "\\..*$" ), "" ) + " ";
345
346 QStringList list = project->variables()["FORMS"];
347 if(!project->isActiveConfig("flat"))
348 list.sort();
349 for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
350 QString base = (*it);
351 // beginGroupForFile(base, t);
352 t << "# Begin Source File\n\nSOURCE=" << base << endl;
353
354 QString fname = base;
355 fname.replace(".ui", "");
356 int lbs = fname.findRev( "\\" );
357 QString fpath;
358 if ( lbs != -1 )
359 fpath = fname.left( lbs + 1 );
360 fname = fname.right( fname.length() - lbs - 1 );
361
362 QString mocFile;
363 if(!project->variables()["MOC_DIR"].isEmpty())
364 mocFile = project->first("MOC_DIR");
365 else
366 mocFile = fpath;
367
368 QString uiSourcesDir;
369 QString uiHeadersDir;
370 if(!project->variables()["UI_DIR"].isEmpty()) {
371 uiSourcesDir = project->first("UI_DIR");
372 uiHeadersDir = project->first("UI_DIR");
373 } else {
374 if ( !project->variables()["UI_SOURCES_DIR"].isEmpty() )
375 uiSourcesDir = project->first("UI_SOURCES_DIR");
376 else
377 uiSourcesDir = fpath;
378 if ( !project->variables()["UI_HEADERS_DIR"].isEmpty() )
379 uiHeadersDir = project->first("UI_HEADERS_DIR");
380 else
381 uiHeadersDir = fpath;
382 }
383
384 t << "USERDEP_" << base << "=\"$(QTDIR)\\bin\\moc.exe\" \"$(QTDIR)\\bin\\uic.exe\"" << endl << endl;
385
386 QString build = "\n\n# Begin Custom Build - Uic'ing " + base + "...\n"
387 "InputPath=.\\" + base + "\n\n" "BuildCmds= \\\n\t" + uicpath + base +
388 " -o " + uiHeadersDir + fname + ".h \\\n" "\t" + uicpath + base +
389 " -i " + fname + ".h -o " + uiSourcesDir + fname + ".cpp \\\n"
390 "\t" + mocpath + uiHeadersDir + fname + ".h -o " + mocFile + "moc_" + fname + ".cpp \\\n";
391
392 build.append("\n\"" + uiHeadersDir + fname + ".h\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n"
393 "\t$(BuildCmds)\n\n"
394 "\"" + uiSourcesDir + fname + ".cpp\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n"
395 "\t$(BuildCmds)\n\n"
396 "\"" + mocFile + "moc_" + fname + ".cpp\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n"
397 "\t$(BuildCmds)\n\n");
398
399 build.append("# End Custom Build\n\n");
400
401 t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build
402 << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" << build
403 << "!ENDIF \n\n" << "# End Source File" << endl;
404 }
405 // endGroups(t);
406 t << "\n# End Group\n";
407 } else if(variable == "MSVCDSP_LEXSOURCES") {
408 if(project->variables()["LEXSOURCES"].isEmpty())
409 continue;
410
411 t << "# Begin Group \"Lexables\"\n"
412 << "# Prop Default_Filter \"l\"\n";
413
414 QString lexpath = var("QMAKE_LEX") + varGlue("QMAKE_LEXFLAGS", " ", " ", "") + " ";
415
416 QStringList list = project->variables()["LEXSOURCES"];
417 if(!project->isActiveConfig("flat"))
418 list.sort();
419 for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
420 QString fname = (*it);
421 // beginGroupForFile(fname, t);
422 t << "# Begin Source File\n\nSOURCE=" << fname << endl;
423 fname.replace(".l", Option::lex_mod + Option::cpp_ext.first());
424
425 QString build = "\n\n# Begin Custom Build - Lex'ing " + (*it) + "...\n"
426 "InputPath=.\\" + (*it) + "\n\n"
427 "\"" + fname + "\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n"
428 "\t" + lexpath + (*it) + "\\\n"
429 "\tdel " + fname + "\\\n"
430 "\tcopy lex.yy.c " + fname + "\n\n" +
431 "# End Custom Build\n\n";
432 t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build
433 << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" << build
434 << "!ENDIF \n\n" << build
435
436 << "# End Source File" << endl;
437 }
438 // endGroups(t);
439 t << "\n# End Group\n";
440 } else if(variable == "MSVCDSP_YACCSOURCES") {
441 if(project->variables()["YACCSOURCES"].isEmpty())
442 continue;
443
444 t << "# Begin Group \"Yaccables\"\n"
445 << "# Prop Default_Filter \"y\"\n";
446
447 QString yaccpath = var("QMAKE_YACC") + varGlue("QMAKE_YACCFLAGS", " ", " ", "") + " ";
448
449 QStringList list = project->variables()["YACCSOURCES"];
450 if(!project->isActiveConfig("flat"))
451 list.sort();
452 for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
453 QString fname = (*it);
454 // beginGroupForFile(fname, t);
455 t << "# Begin Source File\n\nSOURCE=" << fname << endl;
456 fname.replace(".y", Option::yacc_mod);
457
458 QString build = "\n\n# Begin Custom Build - Yacc'ing " + (*it) + "...\n"
459 "InputPath=.\\" + (*it) + "\n\n"
460 "\"" + fname + Option::cpp_ext.first() + "\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n"
461 "\t" + yaccpath + (*it) + "\\\n"
462 "\tdel " + fname + Option::h_ext.first() + "\\\n"
463 "\tmove y.tab.h " + fname + Option::h_ext.first() + "\n\n" +
464 "\tdel " + fname + Option::cpp_ext.first() + "\\\n"
465 "\tmove y.tab.c " + fname + Option::cpp_ext.first() + "\n\n" +
466 "# End Custom Build\n\n";
467
468 t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build
469 << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" << build
470 << "!ENDIF \n\n"
471 << "# End Source File" << endl;
472 }
473 // endGroups(t);
474 t << "\n# End Group\n";
475 } else if( variable == "MSVCDSP_CONFIGMODE" ) {
476 if( project->isActiveConfig( "debug" ) )
477 t << "Debug";
478 else
479 t << "Release";
480 } else if( variable == "MSVCDSP_IDLSOURCES" ) {
481 QStringList list = project->variables()["MSVCDSP_IDLSOURCES"];
482 if(!project->isActiveConfig("flat"))
483 list.sort();
484 for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
485 t << "# Begin Source File" << endl << endl;
486 t << "SOURCE=" << (*it) << endl;
487 t << "# PROP Exclude_From_Build 1" << endl;
488 t << "# End Source File" << endl << endl;
489 }
490 }
491 else
492 t << var(variable);
493 }
494 t << line << endl;
495 }
496 t << endl;
497 file.close();
498 return TRUE;
499}
500
501
502
503void
504DspMakefileGenerator::init()
505{
506 if(init_flag)
507 return;
508 QStringList::Iterator it;
509 init_flag = TRUE;
510
511 /* this should probably not be here, but I'm using it to wrap the .t files */
512 if(project->first("TEMPLATE") == "vcapp" )
513 project->variables()["QMAKE_APP_FLAG"].append("1");
514 else if(project->first("TEMPLATE") == "vclib")
515 project->variables()["QMAKE_LIB_FLAG"].append("1");
516 if ( project->variables()["QMAKESPEC"].isEmpty() )
517 project->variables()["QMAKESPEC"].append( getenv("QMAKESPEC") );
518
519 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"];
521
522 QStringList &configs = project->variables()["CONFIG"];
523 if (project->isActiveConfig("shared"))
524 project->variables()["DEFINES"].append("QT_DLL");
525 if (project->isActiveConfig("qt_dll"))
526 if(configs.findIndex("qt") == -1) configs.append("qt");
527 if ( project->isActiveConfig("qt") ) {
528 if ( project->isActiveConfig( "plugin" ) ) {
529 project->variables()["CONFIG"].append("dll");
530 project->variables()["DEFINES"].append("QT_PLUGIN");
531 }
532 if ( (project->variables()["DEFINES"].findIndex("QT_NODLL") == -1) &&
533 ((project->variables()["DEFINES"].findIndex("QT_MAKEDLL") != -1 ||
534 project->variables()["DEFINES"].findIndex("QT_DLL") != -1) ||
535 (getenv("QT_DLL") && !getenv("QT_NODLL"))) ) {
536 project->variables()["QMAKE_QT_DLL"].append("1");
537 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() )
538 project->variables()["CONFIG"].append("dll");
539 }
540 }
541 if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
542 project->variables()["CONFIG"].remove("staticlib");
543 project->variables()["QMAKE_APP_OR_DLL"].append("1");
544 } else {
545 project->variables()["CONFIG"].append("staticlib");
546 }
547
548 if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") ) {
549 project->variables()["CONFIG"].append("windows");
550 }
551 if ( !project->variables()["VERSION"].isEmpty() ) {
552 QString version = project->variables()["VERSION"][0];
553 int firstDot = version.find( "." );
554 QString major = version.left( firstDot );
555 QString minor = version.right( version.length() - firstDot - 1 );
556 minor.replace( ".", "" );
557 project->variables()["MSVCDSP_VERSION"].append( "/VERSION:" + major + "." + minor );
558 }
559
560 if ( project->isActiveConfig("qt") ) {
561 project->variables()["CONFIG"].append("moc");
562 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"];
563 project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"];
564
565 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) {
566 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) {
567 project->variables()["DEFINES"].append("QT_MAKEDLL");
568 project->variables()["QMAKE_LFLAGS"].append("/base:\"0x39D00000\"");
569 }
570 } else {
571 if(project->isActiveConfig("thread"))
572 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"];
573 else
574 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"];
575 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) {
576 int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt");
577 if ( hver == -1 )
578 hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt-mt");
579 if(hver != -1) {
580 QString ver;
581 ver.sprintf("qt%s" QTDLL_POSTFIX "%d.lib", (project->isActiveConfig("thread") ? "-mt" : ""), hver);
582 QStringList &libs = project->variables()["QMAKE_LIBS"];
583 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit)
584 (*libit).replace(QRegExp("qt(-mt)?\\.lib"), ver);
585 }
586 }
587 if ( project->isActiveConfig( "activeqt" ) ) {
588 project->variables().remove("QMAKE_LIBS_QT_ENTRY");
589 project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib";
590 if ( project->isActiveConfig( "dll" ) )
591 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"];
592 }
593 if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) {
594 project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"];
595 }
596 }
597 }
598
599 if ( project->isActiveConfig("debug") ) {
600 if ( !project->first("OBJECTS_DIR").isEmpty() )
601 project->variables()["MSVCDSP_OBJECTSDIRDEB"] = project->first("OBJECTS_DIR");
602 else
603 project->variables()["MSVCDSP_OBJECTSDIRDEB"] = "Debug";
604 project->variables()["MSVCDSP_OBJECTSDIRREL"] = "Release";
605 if ( !project->first("DESTDIR").isEmpty() )
606 project->variables()["MSVCDSP_TARGETDIRDEB"] = project->first("DESTDIR");
607 else
608 project->variables()["MSVCDSP_TARGETDIRDEB"] = "Debug";
609 project->variables()["MSVCDSP_TARGETDIRREL"] = "Release";
610 } else {
611 if ( !project->first("OBJECTS_DIR").isEmpty() )
612 project->variables()["MSVCDSP_OBJECTSDIRREL"] = project->first("OBJECTS_DIR");
613 project->variables()["MSVCDSP_OBJECTSDIRDEB"] = "Debug";
614 if ( !project->first("DESTDIR").isEmpty() )
615 project->variables()["MSVCDSP_TARGETDIRREL"] = project->first("DESTDIR");
616 else
617 project->variables()["MSVCDSP_TARGETDIRREL"] = "Release";
618 project->variables()["MSVCDSP_TARGETDIRDEB"] = "Debug";
619 }
620
621 if ( project->isActiveConfig("opengl") ) {
622 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"];
623 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"];
624 }
625 if ( project->isActiveConfig("thread") ) {
626 if(project->isActiveConfig("qt"))
627 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT" );
628 if ( project->isActiveConfig("dll") || project->first("TARGET") == "qtmain"
629 || !project->variables()["QMAKE_QT_DLL"].isEmpty() ) {
630 project->variables()["MSVCDSP_MTDEFD"] += project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"];
631 project->variables()["MSVCDSP_MTDEF"] += project->variables()["QMAKE_CXXFLAGS_MT_DLL"];
632 } else {
633 // YES we want to use the DLL even in a static build
634 project->variables()["MSVCDSP_MTDEFD"] += project->variables()["QMAKE_CXXFLAGS_MT_DBG"];
635 project->variables()["MSVCDSP_MTDEF"] += project->variables()["QMAKE_CXXFLAGS_MT"];
636 }
637 if ( !project->variables()["DEFINES"].contains("QT_DLL") && is_qt
638 && project->first("TARGET") != "qtmain" )
639 project->variables()["QMAKE_LFLAGS"].append("/NODEFAULTLIB:\"libc\"");
640 }
641
642 if(project->isActiveConfig("qt")) {
643 if ( project->isActiveConfig("accessibility" ) )
644 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT");
645 if ( project->isActiveConfig("tablet") )
646 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT");
647 }
648 if ( project->isActiveConfig("dll") ) {
649 if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) {
650 QString ver_xyz(project->first("VERSION"));
651 ver_xyz.replace(".", "");
652 project->variables()["TARGET_EXT"].append(ver_xyz + ".dll");
653 } else {
654 project->variables()["TARGET_EXT"].append(".dll");
655 }
656 } else {
657 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() )
658 project->variables()["TARGET_EXT"].append(".exe");
659 else
660 project->variables()["TARGET_EXT"].append(".lib");
661 }
662
663 project->variables()["MSVCDSP_VER"] = "6.00";
664 project->variables()["MSVCDSP_DEBUG_OPT"] = "/GZ /ZI";
665
666 if(!project->isActiveConfig("incremental")) {
667 project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no"));
668 if ( is_qt )
669 project->variables()["MSVCDSP_DEBUG_OPT"] = "/GZ /Zi";
670 }
671
672 QString msvcdsp_project;
673 if ( project->variables()["TARGET"].count() )
674 msvcdsp_project = project->variables()["TARGET"].first();
675
676 QString targetfilename = project->variables()["TARGET"].first();
677 project->variables()["TARGET"].first() += project->first("TARGET_EXT");
678 if ( project->isActiveConfig("moc") )
679 setMocAware(TRUE);
680
681 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
682 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ',
683 "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH");
684 QStringList &l = project->variables()["QMAKE_FILETAGS"];
685 for(it = l.begin(); it != l.end(); ++it) {
686 QStringList &gdmf = project->variables()[(*it)];
687 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner)
688 (*inner) = Option::fixPathToTargetOS((*inner), FALSE);
689 }
690
691 MakefileGenerator::init();
692 if ( msvcdsp_project.isEmpty() )
693 msvcdsp_project = Option::output.name();
694
695 msvcdsp_project = msvcdsp_project.right( msvcdsp_project.length() - msvcdsp_project.findRev( "\\" ) - 1 );
696 msvcdsp_project = msvcdsp_project.left( msvcdsp_project.findRev( "." ) );
697 msvcdsp_project.replace("-", "");
698
699 project->variables()["MSVCDSP_PROJECT"].append(msvcdsp_project);
700 QStringList &proj = project->variables()["MSVCDSP_PROJECT"];
701
702 for(it = proj.begin(); it != proj.end(); ++it)
703 (*it).replace(QRegExp("\\.[a-zA-Z0-9_]*$"), "");
704
705 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
706 project->variables()["MSVCDSP_TEMPLATE"].append("win32app" + project->first( "DSP_EXTENSION" ) );
707 if ( project->isActiveConfig("console") ) {
708 project->variables()["MSVCDSP_CONSOLE"].append("Console");
709 project->variables()["MSVCDSP_WINCONDEF"].append("_CONSOLE");
710 project->variables()["MSVCDSP_DSPTYPE"].append("0x0103");
711 project->variables()["MSVCDSP_SUBSYSTEM"].append("console");
712 } else {
713 project->variables()["MSVCDSP_CONSOLE"].clear();
714 project->variables()["MSVCDSP_WINCONDEF"].append("_WINDOWS");
715 project->variables()["MSVCDSP_DSPTYPE"].append("0x0101");
716 project->variables()["MSVCDSP_SUBSYSTEM"].append("windows");
717 }
718 } else {
719 if ( project->isActiveConfig("dll") ) {
720 project->variables()["MSVCDSP_TEMPLATE"].append("win32dll" + project->first( "DSP_EXTENSION" ) );
721 } else {
722 project->variables()["MSVCDSP_TEMPLATE"].append("win32lib" + project->first( "DSP_EXTENSION" ) );
723 }
724 }
725
726 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"];
727
728 project->variables()["MSVCDSP_LFLAGS" ] += project->variables()["QMAKE_LFLAGS"];
729 if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() )
730 project->variables()["MSVCDSP_LFLAGS" ].append(varGlue("QMAKE_LIBDIR","/LIBPATH:\"","\" /LIBPATH:\"","\""));
731 project->variables()["MSVCDSP_CXXFLAGS" ] += project->variables()["QMAKE_CXXFLAGS"];
732 project->variables()["MSVCDSP_DEFINES"].append(varGlue("DEFINES","/D ","" " /D ",""));
733 project->variables()["MSVCDSP_DEFINES"].append(varGlue("PRL_EXPORT_DEFINES","/D ","" " /D ",""));
734
735 QStringList &libs = project->variables()["QMAKE_LIBS"];
736 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) {
737 QString lib = (*libit);
738 lib.replace(QRegExp("\""), "");
739 project->variables()["MSVCDSP_LIBS"].append(" \"" + lib + "\"");
740 }
741
742 QStringList &incs = project->variables()["INCLUDEPATH"];
743 for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) {
744 QString inc = (*incit);
745 inc.replace("\"", "");
746 project->variables()["MSVCDSP_INCPATH"].append("/I \"" + inc + "\"");
747 }
748
749 project->variables()["MSVCDSP_INCPATH"].append("/I \"" + specdir() + "\"");
750 if ( project->isActiveConfig("qt") ) {
751 project->variables()["MSVCDSP_RELDEFS"].append("/D \"QT_NO_DEBUG\"");
752 } else {
753 project->variables()["MSVCDSP_RELDEFS"].clear();
754 }
755
756 QString dest;
757 if ( !project->variables()["DESTDIR"].isEmpty() ) {
758 project->variables()["TARGET"].first().prepend(project->first("DESTDIR"));
759 Option::fixPathToTargetOS(project->first("TARGET"));
760 dest = project->first("TARGET");
761 if ( project->first("TARGET").startsWith("$(QTDIR)") )
762 dest.replace( "$(QTDIR)", getenv("QTDIR") );
763 project->variables()["MSVCDSP_TARGET"].append(
764 QString("/out:\"") + dest + "\"");
765 if ( project->isActiveConfig("dll") ) {
766 QString imp = dest;
767 imp.replace(".dll", ".lib");
768 project->variables()["MSVCDSP_TARGET"].append(QString(" /implib:\"") + imp + "\"");
769 }
770 }
771 if ( project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty() ) {
772 QStringList dlldirs = project->variables()["DLLDESTDIR"];
773 QString copydll = "# Begin Special Build Tool\n"
774 "TargetPath=" + dest + "\n"
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 ) {
780 copydll += "copy \"" + dest + "\" \"" + *dlldir + "\"\t";
781 }
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 }
787 if ( project->isActiveConfig("activeqt") ) {
788 QString idl = project->variables()["QMAKE_IDL"].first();
789 QString idc = project->variables()["QMAKE_IDC"].first();
790 QString version = project->variables()["VERSION"].first();
791 if ( version.isEmpty() )
792 version = "1.0";
793
794 project->variables()["MSVCDSP_IDLSOURCES"].append( "tmp\\" + targetfilename + ".idl" );
795 project->variables()["MSVCDSP_IDLSOURCES"].append( "tmp\\" + targetfilename + ".tlb" );
796 project->variables()["MSVCDSP_IDLSOURCES"].append( "tmp\\" + targetfilename + ".midl" );
797 if ( project->isActiveConfig( "dll" ) ) {
798 QString regcmd = "# Begin Special Build Tool\n"
799 "TargetPath=" + targetfilename + "\n"
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"
805 "\t" + idc + " %1 /tlb tmp\\" + targetfilename + ".tlb"
806 "\t" + idc + " %1 /regserver\n"
807 "# End Special Build Tool";
808
809 QString executable = project->variables()["MSVCDSP_TARGETDIRREL"].first() + "\\" + project->variables()["TARGET"].first();
810 project->variables()["MSVCDSP_COPY_DLL_REL"].append( regcmd.arg(executable).arg(executable).arg(executable) );
811
812 executable = project->variables()["MSVCDSP_TARGETDIRDEB"].first() + "\\" + project->variables()["TARGET"].first();
813 project->variables()["MSVCDSP_COPY_DLL_DBG"].append( regcmd.arg(executable).arg(executable).arg(executable) );
814 } else {
815 QString regcmd = "# Begin Special Build Tool\n"
816 "TargetPath=" + targetfilename + "\n"
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"
822 "\t" + idc + " %1 /tlb tmp\\" + targetfilename + ".tlb"
823 "\t%1 -regserver\n"
824 "# End Special Build Tool";
825
826 QString executable = project->variables()["MSVCDSP_TARGETDIRREL"].first() + "\\" + project->variables()["TARGET"].first();
827 project->variables()["MSVCDSP_REGSVR_REL"].append( regcmd.arg(executable).arg(executable).arg(executable) );
828
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 }
832
833 }
834 if ( !project->variables()["SOURCES"].isEmpty() || !project->variables()["RC_FILE"].isEmpty() ) {
835 project->variables()["SOURCES"] += project->variables()["RC_FILE"];
836 }
837 QStringList &list = project->variables()["FORMS"];
838 for( it = list.begin(); it != list.end(); ++it ) {
839 if ( QFile::exists( *it + ".h" ) )
840 project->variables()["SOURCES"].append( *it + ".h" );
841 }
842 project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "MSVCDSP_LIBS";
843}
844
845
846QString
847DspMakefileGenerator::findTemplate(QString file)
848{
849 QString ret;
850 if(!QFile::exists((ret = file)) &&
851 !QFile::exists((ret = QString(Option::mkfile::qmakespec + "/" + file))) &&
852 !QFile::exists((ret = QString(getenv("QTDIR")) + "/mkspecs/win32-msvc/" + file)) &&
853 !QFile::exists((ret = (QString(getenv("HOME")) + "/.tmake/" + file))))
854 return "";
855 return ret;
856}
857
858
859void
860DspMakefileGenerator::processPrlVariable(const QString &var, const QStringList &l)
861{
862 if(var == "QMAKE_PRL_DEFINES") {
863 QStringList &out = project->variables()["MSVCDSP_DEFINES"];
864 for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
865 if(out.findIndex((*it)) == -1)
866 out.append((" /D \"" + *it + "\""));
867 }
868 } else {
869 MakefileGenerator::processPrlVariable(var, l);
870 }
871}
872
873
874int
875DspMakefileGenerator::beginGroupForFile(QString file, QTextStream &t,
876 QString filter)
877{
878 if(project->isActiveConfig("flat"))
879 return 0;
880
881 fileFixify(file, QDir::currentDirPath(), QDir::currentDirPath(), TRUE);
882 file = file.section(Option::dir_sep, 0, -2);
883 if(file.right(Option::dir_sep.length()) != Option::dir_sep)
884 file += Option::dir_sep;
885 if(file == currentGroup)
886 return 0;
887
888 if(file.isEmpty() || !QDir::isRelativePath(file)) {
889 endGroups(t);
890 return 0;
891 }
892 if(file.startsWith(currentGroup))
893 file = file.mid(currentGroup.length());
894 else
895 endGroups(t);
896 int lvl = file.contains(Option::dir_sep), old_lvl = currentGroup.contains(Option::dir_sep);
897 if(lvl > old_lvl) {
898 QStringList dirs = QStringList::split(Option::dir_sep, file);
899 for(QStringList::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) {
900 t << "# Begin Group \"" << (*dir_it) << "\"\n"
901 << "# Prop Default_Filter \"" << filter << "\"\n";
902 }
903 } else {
904 for(int x = old_lvl - lvl; x; x--)
905 t << "\n# End Group\n";
906 }
907 currentGroup = file;
908 return lvl - old_lvl;
909}
910
911
912int
913DspMakefileGenerator::endGroups(QTextStream &t)
914{
915 if(project->isActiveConfig("flat"))
916 return 0;
917 else if(currentGroup.isEmpty())
918 return 0;
919
920 QStringList dirs = QStringList::split(Option::dir_sep, currentGroup);
921 for(QStringList::Iterator dir_it = dirs.end(); dir_it != dirs.begin(); --dir_it) {
922 t << "\n# End Group\n";
923 }
924 currentGroup = "";
925 return dirs.count();
926}
927
928bool
929DspMakefileGenerator::openOutput(QFile &file) const
930{
931 QString outdir;
932 if(!file.name().isEmpty()) {
933 QFileInfo fi(file);
934 if(fi.isDir())
935 outdir = file.name() + QDir::separator();
936 }
937 if(!outdir.isEmpty() || file.name().isEmpty())
938 file.setName(outdir + project->first("TARGET") + project->first("DSP_EXTENSION"));
939 if(QDir::isRelativePath(file.name())) {
940 QString ofile;
941 ofile = file.name();
942 int slashfind = ofile.findRev('\\');
943 if (slashfind == -1) {
944 ofile = ofile.replace(QRegExp("-"), "_");
945 } else {
946 int hypenfind = ofile.find('-', slashfind);
947 while (hypenfind != -1 && slashfind < hypenfind) {
948 ofile = ofile.replace(hypenfind, 1, "_");
949 hypenfind = ofile.find('-', hypenfind + 1);
950 }
951 }
952 file.setName(Option::fixPathToLocalOS(QDir::currentDirPath() + Option::dir_sep + ofile));
953 }
954 return Win32MakefileGenerator::openOutput(file);
955}
diff --git a/qmake/generators/win32/msvc_dsp.h b/qmake/generators/win32/msvc_dsp.h
new file mode 100644
index 0000000..a7fc3e7
--- a/dev/null
+++ b/qmake/generators/win32/msvc_dsp.h
@@ -0,0 +1,73 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Created : 970521
7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9**
10** This file is part of the network module of the Qt GUI Toolkit.
11**
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
14** LICENSE.QPL included in the packaging of this file.
15**
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
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software.
24**
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.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37#ifndef __DSPMAKE_H__
38#define __DSPMAKE_H__
39
40#include "winmakefile.h"
41#include <qvaluestack.h>
42
43class DspMakefileGenerator : public Win32MakefileGenerator
44{
45 QString currentGroup;
46 int beginGroupForFile(QString file, QTextStream &, const QString filter="");
47 int endGroups(QTextStream &);
48
49 bool init_flag;
50 bool writeDspParts(QTextStream &);
51
52 bool writeMakefile(QTextStream &);
53 QString findTemplate(QString file);
54 void init();
55
56public:
57 DspMakefileGenerator(QMakeProject *p);
58 ~DspMakefileGenerator();
59
60 bool openOutput(QFile &file) const;
61
62protected:
63 virtual void processPrlVariable(const QString &, const QStringList &);
64 virtual bool findLibraries();
65};
66
67inline DspMakefileGenerator::~DspMakefileGenerator()
68{ }
69
70inline bool DspMakefileGenerator::findLibraries()
71{ return Win32MakefileGenerator::findLibraries("MSVCDSP_LIBS"); }
72
73#endif /* __DSPMAKE_H__ */
diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp
new file mode 100644
index 0000000..9cc9a69
--- a/dev/null
+++ b/qmake/generators/win32/msvc_nmake.cpp
@@ -0,0 +1,488 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Created : 970521
7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9**
10** This file is part of the network module of the Qt GUI Toolkit.
11**
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
14** LICENSE.QPL included in the packaging of this file.
15**
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
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software.
24**
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.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38#include "msvc_nmake.h"
39#include "option.h"
40#include <qregexp.h>
41#include <qdir.h>
42#include <stdlib.h>
43#include <time.h>
44
45
46NmakeMakefileGenerator::NmakeMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE)
47{
48
49}
50
51bool
52NmakeMakefileGenerator::writeMakefile(QTextStream &t)
53{
54 writeHeader(t);
55 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {
56 t << "all clean:" << "\n\t"
57 << "@echo \"Some of the required modules ("
58 << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t"
59 << "@echo \"Skipped.\"" << endl << endl;
60 writeMakeQmake(t);
61 return TRUE;
62 }
63
64 if(project->first("TEMPLATE") == "app" ||
65 project->first("TEMPLATE") == "lib") {
66 writeNmakeParts(t);
67 return MakefileGenerator::writeMakefile(t);
68 }
69 else if(project->first("TEMPLATE") == "subdirs") {
70 writeSubDirs(t);
71 return TRUE;
72 }
73 return FALSE;
74}
75
76void
77NmakeMakefileGenerator::writeNmakeParts(QTextStream &t)
78{
79 t << "####### Compiler, tools and options" << endl << endl;
80 t << "CC =" << var("QMAKE_CC") << endl;
81 t << "CXX =" << var("QMAKE_CXX") << endl;
82 t << "LEX = " << var("QMAKE_LEX") << endl;
83 t << "YACC = " << var("QMAKE_YACC") << endl;
84 t << "CFLAGS =" << var("QMAKE_CFLAGS") << " "
85 << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "
86 << varGlue("DEFINES","-D"," -D","") << endl;
87 t << "CXXFLAGS =" << var("QMAKE_CXXFLAGS") << " "
88 << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "
89 << varGlue("DEFINES","-D"," -D","") << endl;
90 t << "LEXFLAGS=" << var("QMAKE_LEXFLAGS") << endl;
91 t << "YACCFLAGS=" << var("QMAKE_YACCFLAGS") << endl;
92
93 t << "INCPATH =";
94 QStringList &incs = project->variables()["INCLUDEPATH"];
95 for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) {
96 QString inc = (*incit);
97 inc.replace(QRegExp("\\\\$"), "\\\\");
98 inc.replace("\"", "");
99 t << " -I\"" << inc << "\"";
100 }
101 t << " -I\"" << specdir() << "\""
102 << endl;
103 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
104 t << "LINK =" << var("QMAKE_LINK") << endl;
105 t << "LFLAGS =" << var("QMAKE_LFLAGS");
106 if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() )
107 t << " " << varGlue("QMAKE_LIBDIR","/LIBPATH:\"","\" /LIBPATH:\"","\"");
108 t << endl;
109 t << "LIBS =";
110 QStringList &libs = project->variables()["QMAKE_LIBS"];
111 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) {
112 QString lib = (*libit);
113 lib.replace(QRegExp("\\\\$"), "\\\\");
114 lib.replace(QRegExp("\""), "");
115 t << " \"" << lib << "\"";
116 }
117 t << endl;
118 }
119 else {
120 t << "LIB =" << var("QMAKE_LIB") << endl;
121 }
122 t << "MOC =" << (project->isEmpty("QMAKE_MOC") ? QString("moc") :
123 Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl;
124 t << "UIC =" << (project->isEmpty("QMAKE_UIC") ? QString("uic") :
125 Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl;
126 t << "QMAKE =" << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") :
127 Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl;
128 t << "IDC =" << (project->isEmpty("QMAKE_IDC") ? QString("idc") :
129 Option::fixPathToTargetOS(var("QMAKE_IDC"), FALSE)) << endl;
130 t << "IDL =" << (project->isEmpty("QMAKE_IDL") ? QString("midl") :
131 Option::fixPathToTargetOS(var("QMAKE_IDL"), FALSE)) << endl;
132 t << "ZIP =" << var("QMAKE_ZIP") << endl;
133 t << "COPY_FILE= " << var("QMAKE_COPY") << endl;
134 t << "COPY_DIR= " << var("QMAKE_COPY") << endl;
135 t << "DEL_FILE= " << var("QMAKE_DEL_FILE") << endl;
136 t << "DEL_DIR= " << var("QMAKE_DEL_DIR") << endl;
137 t << "MOVE = " << var("QMAKE_MOVE") << endl;
138 t << endl;
139
140 t << "####### Files" << endl << endl;
141 t << "HEADERS =" << varList("HEADERS") << endl;
142 t << "SOURCES =" << varList("SOURCES") << endl;
143 t << "OBJECTS =" << varList("OBJECTS") << endl;
144 t << "FORMS =" << varList("FORMS") << endl;
145 t << "UICDECLS =" << varList("UICDECLS") << endl;
146 t << "UICIMPLS =" << varList("UICIMPLS") << endl;
147 t << "SRCMOC =" << varList("SRCMOC") << endl;
148 t << "OBJMOC =" << varList("OBJMOC") << endl;
149 t << "DIST =" << varList("DISTFILES") << endl;
150 t << "TARGET =";
151 if( !project->variables()[ "DESTDIR" ].isEmpty() )
152 t << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT"));
153 else
154 t << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first();
155 t << endl;
156 t << endl;
157
158 t << "####### Implicit rules" << endl << endl;
159 t << ".SUFFIXES: .cpp .cxx .cc .c" << endl << endl;
160 t << ".cpp.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
161 t << ".cxx.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
162 t << ".cc.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
163 t << ".c.obj:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;
164
165 t << "####### Build rules" << endl << endl;
166 t << "all: " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" << endl << endl;
167 t << "$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) " << var("TARGETDEPS");
168 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
169 t << "\n\t" << "$(LINK) $(LFLAGS) /OUT:$(TARGET) @<< " << "\n\t "
170 << "$(OBJECTS) $(OBJMOC) $(LIBS)";
171 } else {
172 t << "\n\t" << "$(LIB) /OUT:$(TARGET) @<<" << "\n\t "
173 << "$(OBJECTS) $(OBJMOC)";
174 }
175 t << endl << "<<" << endl;
176 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) {
177 QStringList dlldirs = project->variables()["DLLDESTDIR"];
178 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) {
179 t << "\n\t" << "-copy $(TARGET) " << *dlldir;
180 }
181 }
182 QString targetfilename = project->variables()["TARGET"].first();
183 if(project->isActiveConfig("activeqt")) {
184 QString version = project->variables()["VERSION"].first();
185 if ( version.isEmpty() )
186 version = "1.0";
187
188 if ( project->isActiveConfig("dll")) {
189 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");
191 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb");
192 t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" );
193 } else {
194 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");
196 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb");
197 t << "\n\t" << "-$(TARGET) -regserver";
198 }
199 }
200 t << endl << endl;
201
202 if(!project->variables()["RC_FILE"].isEmpty()) {
203 t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t"
204 << var("QMAKE_RC") << " " << var("RC_FILE") << endl << endl;
205 }
206
207 t << "mocables: $(SRCMOC)" << endl << endl;
208
209 writeMakeQmake(t);
210
211 t << "dist:" << "\n\t"
212 << "$(ZIP) " << var("PROJECT") << ".zip "
213 << var("PROJECT") << ".pro $(SOURCES) $(HEADERS) $(DIST) $(FORMS)" << endl << endl;
214
215 t << "clean:"
216 << varGlue("OBJECTS","\n\t-del ","\n\t-del ","")
217 << varGlue("SRCMOC" ,"\n\t-del ","\n\t-del ","")
218 << varGlue("OBJMOC" ,"\n\t-del ","\n\t-del ","")
219 << varGlue("UICDECLS" ,"\n\t-del ","\n\t-del ","")
220 << varGlue("UICIMPLS" ,"\n\t-del ","\n\t-del ","")
221 << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ","")
222 << varGlue("CLEAN_FILES","\n\t-del ","\n\t-del ","");
223 if ( project->isActiveConfig("activeqt")) {
224 t << ("\n\t-del tmp\\" + targetfilename + ".*");
225 t << "\n\t-del tmp\\dump.*";
226 }
227 if(!project->isEmpty("IMAGES"))
228 t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-del ", "\n\t-del ", "");
229
230 // blasted user defined targets
231 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"];
232 for(QStringList::Iterator it = qut.begin(); it != qut.end(); ++it) {
233 QString targ = var((*it) + ".target"),
234 cmd = var((*it) + ".commands"), deps;
235 if(targ.isEmpty())
236 targ = (*it);
237 QStringList &deplist = project->variables()[(*it) + ".depends"];
238 for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) {
239 QString dep = var((*dep_it) + ".target");
240 if(dep.isEmpty())
241 dep = (*dep_it);
242 deps += " " + dep;
243 }
244 t << "\n\n" << targ << ":" << deps << "\n\t"
245 << cmd;
246 }
247
248 t << endl << endl;
249}
250
251
252void
253NmakeMakefileGenerator::init()
254{
255 if(init_flag)
256 return;
257 init_flag = TRUE;
258
259 /* this should probably not be here, but I'm using it to wrap the .t files */
260 if(project->first("TEMPLATE") == "app")
261 project->variables()["QMAKE_APP_FLAG"].append("1");
262 else if(project->first("TEMPLATE") == "lib")
263 project->variables()["QMAKE_LIB_FLAG"].append("1");
264 else if(project->first("TEMPLATE") == "subdirs") {
265 MakefileGenerator::init();
266 if(project->variables()["MAKEFILE"].isEmpty())
267 project->variables()["MAKEFILE"].append("Makefile");
268 if(project->variables()["QMAKE"].isEmpty())
269 project->variables()["QMAKE"].append("qmake");
270 return;
271 }
272
273 bool is_qt = (project->first("TARGET") == "qt"QTDLL_POSTFIX || project->first("TARGET") == "qt-mt"QTDLL_POSTFIX);
274 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"];
275
276 QString targetfilename = project->variables()["TARGET"].first();
277 QStringList &configs = project->variables()["CONFIG"];
278 if (project->isActiveConfig("qt") && project->isActiveConfig("shared"))
279 project->variables()["DEFINES"].append("QT_DLL");
280 if (project->isActiveConfig("qt_dll"))
281 if(configs.findIndex("qt") == -1) configs.append("qt");
282 if ( project->isActiveConfig("qt") ) {
283 if ( project->isActiveConfig( "plugin" ) ) {
284 project->variables()["CONFIG"].append("dll");
285 if(project->isActiveConfig("qt"))
286 project->variables()["DEFINES"].append("QT_PLUGIN");
287 }
288 if ( (project->variables()["DEFINES"].findIndex("QT_NODLL") == -1) &&
289 ((project->variables()["DEFINES"].findIndex("QT_MAKEDLL") != -1 ||
290 project->variables()["DEFINES"].findIndex("QT_DLL") != -1) ||
291 (getenv("QT_DLL") && !getenv("QT_NODLL"))) ) {
292 project->variables()["QMAKE_QT_DLL"].append("1");
293 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() )
294 project->variables()["CONFIG"].append("dll");
295 }
296 if ( project->isActiveConfig("thread") )
297 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT");
298 if ( project->isActiveConfig("accessibility" ) )
299 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT");
300 if ( project->isActiveConfig("tablet") )
301 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT");
302 }
303 if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
304 project->variables()["CONFIG"].remove("staticlib");
305 project->variables()["QMAKE_APP_OR_DLL"].append("1");
306 } else {
307 project->variables()["CONFIG"].append("staticlib");
308 }
309 if ( project->isActiveConfig("warn_off") ) {
310 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_OFF"];
311 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_OFF"];
312 } else if ( project->isActiveConfig("warn_on") ) {
313 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_ON"];
314 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_ON"];
315 }
316 if ( project->isActiveConfig("debug") ) {
317 if ( project->isActiveConfig("thread") ) {
318 // use the DLL RT even here
319 if ( project->variables()["DEFINES"].contains("QT_DLL") ) {
320 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLLDBG"];
321 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"];
322 } else {
323 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DBG"];
324 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DBG"];
325 }
326 }
327 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_DEBUG"];
328 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_DEBUG"];
329 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_DEBUG"];
330 } else {
331 if ( project->isActiveConfig("thread") ) {
332 if ( project->variables()["DEFINES"].contains("QT_DLL") ) {
333 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLL"];
334 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLL"];
335 } else {
336 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT"];
337 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT"];
338 }
339 }
340 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RELEASE"];
341 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RELEASE"];
342 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_RELEASE"];
343 }
344 if ( project->isActiveConfig("thread") && !project->variables()["DEFINES"].contains("QT_DLL")
345 && !is_qt && project->first("TARGET") != "qtmain") {
346 project->variables()["QMAKE_LFLAGS"].append("/NODEFAULTLIB:\"libc\"");
347 }
348
349 if ( !project->variables()["QMAKE_INCDIR"].isEmpty())
350 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"];
351 if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") )
352 project->variables()["CONFIG"].append("windows");
353 if ( project->isActiveConfig("qt") ) {
354 project->variables()["CONFIG"].append("moc");
355 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"];
356 project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"];
357 if ( !project->isActiveConfig("debug") )
358 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG");
359 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) {
360 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty()) {
361 project->variables()["DEFINES"].append("QT_MAKEDLL");
362 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_QT_DLL"];
363 }
364 } else {
365 if(project->isActiveConfig("thread"))
366 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"];
367 else
368 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"];
369 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) {
370 int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt");
371 if ( hver == -1 )
372 hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt-mt");
373 if(hver != -1) {
374 QString ver;
375 ver.sprintf("qt%s" QTDLL_POSTFIX "%d.lib", (project->isActiveConfig("thread") ? "-mt" : ""), hver);
376 QStringList &libs = project->variables()["QMAKE_LIBS"];
377 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit)
378 (*libit).replace(QRegExp("qt(-mt)?\\.lib"), ver);
379 }
380 }
381 if ( project->isActiveConfig( "activeqt" ) ) {
382 project->variables().remove("QMAKE_LIBS_QT_ENTRY");
383 project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib";
384 if ( project->isActiveConfig( "dll" ) )
385 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"];
386 }
387 if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) {
388 project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"];
389 }
390 }
391 }
392 if ( project->isActiveConfig("opengl") ) {
393 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"];
394 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"];
395 }
396 if ( project->isActiveConfig("dll") ) {
397 project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE_DLL"];
398 project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE_DLL"];
399 project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE_DLL"];
400 project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS_DLL"];
401 if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty()) {
402 project->variables()["TARGET_EXT"].append(
403 QStringList::split('.',project->first("VERSION")).join("") + ".dll");
404 } else {
405 project->variables()["TARGET_EXT"].append(".dll");
406 }
407 } else {
408 project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE"];
409 project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE"];
410 project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE"];
411 project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS"];
412 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty()) {
413 project->variables()["TARGET_EXT"].append(".exe");
414 } else {
415 project->variables()["TARGET_EXT"].append(".lib");
416 }
417 }
418 if ( project->isActiveConfig("windows") ) {
419 if ( project->isActiveConfig("console") ) {
420 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
421 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
422 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
423 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
424 } else {
425 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"];
426 }
427 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"];
428 } else {
429 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
430 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
431 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
432 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
433 }
434
435 if ( project->isActiveConfig("moc") )
436 setMocAware(TRUE);
437 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
438 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ',
439 "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH");
440 QStringList &l = project->variables()["QMAKE_FILETAGS"];
441 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
442 QStringList &gdmf = project->variables()[(*it)];
443 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner)
444 (*inner) = Option::fixPathToTargetOS((*inner), FALSE);
445 }
446
447 if ( !project->variables()["DEF_FILE"].isEmpty() )
448 project->variables()["QMAKE_LFLAGS"].append(QString("/DEF:") + project->first("DEF_FILE"));
449 if(!project->isActiveConfig("incremental"))
450 project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no"));
451
452 if ( !project->variables()["VERSION"].isEmpty() ) {
453 QString version = project->variables()["VERSION"][0];
454 int firstDot = version.find( "." );
455 QString major = version.left( firstDot );
456 QString minor = version.right( version.length() - firstDot - 1 );
457 minor.replace( ".", "" );
458 project->variables()["QMAKE_LFLAGS"].append( "/VERSION:" + major + "." + minor );
459 }
460 if ( !project->variables()["RC_FILE"].isEmpty()) {
461 if ( !project->variables()["RES_FILE"].isEmpty()) {
462 fprintf(stderr, "Both .rc and .res file specified.\n");
463 fprintf(stderr, "Please specify one of them, not both.");
464 exit(666);
465 }
466 project->variables()["RES_FILE"] = project->variables()["RC_FILE"];
467 project->variables()["RES_FILE"].first().replace(".rc",".res");
468 project->variables()["TARGETDEPS"] += project->variables()["RES_FILE"];
469 }
470 if ( !project->variables()["RES_FILE"].isEmpty())
471 project->variables()["QMAKE_LIBS"] += project->variables()["RES_FILE"];
472
473 MakefileGenerator::init();
474 if ( !project->variables()["VERSION"].isEmpty()) {
475 QStringList l = QStringList::split('.', project->first("VERSION"));
476 project->variables()["VER_MAJ"].append(l[0]);
477 project->variables()["VER_MIN"].append(l[1]);
478 }
479 if(project->isActiveConfig("dll")) {
480 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + ".lib");
481 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + ".exp");
482 }
483 if(project->isActiveConfig("debug")) {
484 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + ".pdb");
485 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + ".ilk");
486 project->variables()["QMAKE_CLEAN"].append("vc*.pdb");
487 }
488}
diff --git a/qmake/generators/win32/msvc_nmake.h b/qmake/generators/win32/msvc_nmake.h
new file mode 100644
index 0000000..d3e170f
--- a/dev/null
+++ b/qmake/generators/win32/msvc_nmake.h
@@ -0,0 +1,59 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Created : 970521
7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9**
10** This file is part of the network module of the Qt GUI Toolkit.
11**
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
14** LICENSE.QPL included in the packaging of this file.
15**
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
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software.
24**
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.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37#ifndef __NMAKEMAKE_H__
38#define __NMAKEMAKE_H__
39
40#include "winmakefile.h"
41
42class NmakeMakefileGenerator : public Win32MakefileGenerator
43{
44 bool init_flag;
45 void writeNmakeParts(QTextStream &);
46
47 bool writeMakefile(QTextStream &);
48 void init();
49
50public:
51 NmakeMakefileGenerator(QMakeProject *p);
52 ~NmakeMakefileGenerator();
53
54};
55
56inline NmakeMakefileGenerator::~NmakeMakefileGenerator()
57{ }
58
59#endif /* __NMAKEMAKE_H__ */
diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp
new file mode 100644
index 0000000..c2b9e30
--- a/dev/null
+++ b/qmake/generators/win32/msvc_objectmodel.cpp
@@ -0,0 +1,1955 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Copyright (C) 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 "msvc_objectmodel.h"
37#include "msvc_vcproj.h"
38#include <qtextstream.h>
39#include <qstringlist.h>
40#include <quuid.h>
41
42#if defined(Q_OS_WIN32)
43#include <objbase.h>
44#ifndef GUID_DEFINED
45#define GUID_DEFINED
46typedef struct _GUID
47{
48 ulong Data1;
49 ushort Data2;
50 ushort Data3;
51 uchar Data4[8];
52} GUID;
53#endif
54#endif
55
56// XML Tags ---------------------------------------------------------
57 const char* _xmlInit = "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>";
58 const char* _begConfiguration = "\n\t\t<Configuration";
59 const char* _begConfigurations = "\n\t<Configurations>";
60 const char* _begFile = "\n\t\t\t<File";
61 const char* _begFileConfiguration = "\n\t\t\t\t<FileConfiguration";
62 const char* _begFiles = "\n\t<Files>";
63 const char* _begFilter = "\n\t\t<Filter";
64 const char* _begGlobals = "\n\t<Globals>";
65 const char* _begPlatform = "\n\t\t<Platform";
66 const char* _begPlatforms = "\n\t<Platforms>";
67 const char* _begTool3 = "\n\t\t\t<Tool";
68 const char* _begTool5 = "\n\t\t\t\t\t<Tool";
69 const char* _begVisualStudioProject = "\n<VisualStudioProject";
70 const char* _endConfiguration = "\n\t\t</Configuration>";
71 const char* _endConfigurations = "\n\t</Configurations>";
72 const char* _endFile = "\n\t\t\t</File>";
73 const char* _endFileConfiguration = "\n\t\t\t\t</FileConfiguration>";
74 const char* _endFiles = "\n\t</Files>";
75 const char* _endFilter = "\n\t\t</Filter>";
76 const char* _endGlobals = "\n\t</Globals>";
77 const char* _endPlatforms = "\n\t</Platforms>";
78 const char* _endVisualStudioProject = "\n</VisualStudioProject>";
79
80// XML Properties ---------------------------------------------------
81 const char* _AddModuleNamesToAssembly = "\n\t\t\t\tAddModuleNamesToAssembly=\"";
82 const char* _AdditionalDependencies4 = "\n\t\t\t\tAdditionalDependencies=\"";
83 const char* _AdditionalDependencies6 = "\n\t\t\t\t\t\tAdditionalDependencies=\"";
84 const char* _AdditionalIncludeDirectories = "\n\t\t\t\tAdditionalIncludeDirectories=\"";
85 const char* _AdditionalLibraryDirectories = "\n\t\t\t\tAdditionalLibraryDirectories=\"";
86 const char* _AdditionalOptions = "\n\t\t\t\tAdditionalOptions=\"";
87 const char* _AdditionalUsingDirectories = "\n\t\t\t\tAdditionalUsingDirectories=\"";
88 const char* _AssemblerListingLocation = "\n\t\t\t\tAssemblerListingLocation=\"";
89 const char* _AssemblerOutput = "\n\t\t\t\tAssemblerOutput=\"";
90 const char* _ATLMinimizesCRunTimeLibraryUsage= "\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"";
91 const char* _BaseAddress = "\n\t\t\t\tBaseAddress=\"";
92 const char* _BasicRuntimeChecks = "\n\t\t\t\tBasicRuntimeChecks=\"";
93 const char* _BrowseInformation = "\n\t\t\t\tBrowseInformation=\"";
94 const char* _BrowseInformationFile = "\n\t\t\t\tBrowseInformationFile=\"";
95 const char* _BufferSecurityCheck = "\n\t\t\t\tBufferSecurityCheck=\"";
96 const char* _BuildBrowserInformation = "\n\t\t\tBuildBrowserInformation=\"";
97 const char* _CPreprocessOptions = "\n\t\t\t\tCPreprocessOptions=\"";
98 const char* _CallingConvention = "\n\t\t\t\tCallingConvention=\"";
99 const char* _CharacterSet = "\n\t\t\tCharacterSet=\"";
100 const char* _CommandLine4 = "\n\t\t\t\tCommandLine=\"";
101 const char* _CommandLine6 = "\n\t\t\t\t\t\tCommandLine=\"";
102 const char* _CompileAs = "\n\t\t\t\tCompileAs=\"";
103 const char* _CompileAsManaged = "\n\t\t\t\tCompileAsManaged=\"";
104 const char* _CompileOnly = "\n\t\t\t\tCompileOnly=\"";
105 const char* _ConfigurationType = "\n\t\t\tConfigurationType=\"";
106 const char* _Culture = "\n\t\t\t\tCulture=\"";
107 const char* _DLLDataFileName = "\n\t\t\t\tDLLDataFileName=\"";
108 const char* _DebugInformationFormat = "\n\t\t\t\tDebugInformationFormat=\"";
109 const char* _DefaultCharIsUnsigned = "\n\t\t\t\tDefaultCharIsUnsigned=\"";
110 const char* _DefaultCharType = "\n\t\t\t\tDefaultCharType=\"";
111 const char* _DelayLoadDLLs = "\n\t\t\t\tDelayLoadDLLs=\"";
112 const char* _DeleteExtensionsOnClean = "\n\t\t\tDeleteExtensionsOnClean=\"";
113 const char* _Description4 = "\n\t\t\t\tDescription=\"";
114 const char* _Description6 = "\n\t\t\t\t\t\tDescription=\"";
115 const char* _Detect64BitPortabilityProblems = "\n\t\t\t\tDetect64BitPortabilityProblems=\"";
116 const char* _DisableLanguageExtensions = "\n\t\t\t\tDisableLanguageExtensions=\"";
117 const char* _DisableSpecificWarnings = "\n\t\t\t\tDisableSpecificWarnings=\"";
118 const char* _EnableCOMDATFolding = "\n\t\t\t\tEnableCOMDATFolding=\"";
119 const char* _EnableErrorChecks = "\n\t\t\t\tEnableErrorChecks=\"";
120 const char* _EnableFiberSafeOptimizations = "\n\t\t\t\tEnableFiberSafeOptimizations=\"";
121 const char* _EnableFunctionLevelLinking = "\n\t\t\t\tEnableFunctionLevelLinking=\"";
122 const char* _EnableIntrinsicFunctions = "\n\t\t\t\tEnableIntrinsicFunctions=\"";
123 const char* _EntryPointSymbol = "\n\t\t\t\tEntryPointSymbol=\"";
124 const char* _ErrorCheckAllocations = "\n\t\t\t\tErrorCheckAllocations=\"";
125 const char* _ErrorCheckBounds = "\n\t\t\t\tErrorCheckBounds=\"";
126 const char* _ErrorCheckEnumRange = "\n\t\t\t\tErrorCheckEnumRange=\"";
127 const char* _ErrorCheckRefPointers = "\n\t\t\t\tErrorCheckRefPointers=\"";
128 const char* _ErrorCheckStubData = "\n\t\t\t\tErrorCheckStubData=\"";
129 const char* _ExceptionHandling = "\n\t\t\t\tExceptionHandling=\"";
130 const char* _ExcludedFromBuild = "\n\t\t\t\tExcludedFromBuild=\"";
131 const char* _ExpandAttributedSource = "\n\t\t\t\tExpandAttributedSource=\"";
132 const char* _ExportNamedFunctions = "\n\t\t\t\tExportNamedFunctions=\"";
133 const char* _FavorSizeOrSpeed = "\n\t\t\t\tFavorSizeOrSpeed=\"";
134 const char* _Filter = "\n\t\t\tFilter=\"";
135 const char* _ForceConformanceInForLoopScope = "\n\t\t\t\tForceConformanceInForLoopScope=\"";
136 const char* _ForceSymbolReferences = "\n\t\t\t\tForceSymbolReferences=\"";
137 const char* _ForcedIncludeFiles = "\n\t\t\t\tForcedIncludeFiles=\"";
138 const char* _ForcedUsingFiles = "\n\t\t\t\tForcedUsingFiles=\"";
139 const char* _FullIncludePath = "\n\t\t\t\tFullIncludePath=\"";
140 const char* _FunctionOrder = "\n\t\t\t\tFunctionOrder=\"";
141 const char* _GenerateDebugInformation = "\n\t\t\t\tGenerateDebugInformation=\"";
142 const char* _GenerateMapFile = "\n\t\t\t\tGenerateMapFile=\"";
143 const char* _GeneratePreprocessedFile = "\n\t\t\t\tGeneratePreprocessedFile=\"";
144 const char* _GenerateStublessProxies = "\n\t\t\t\tGenerateStublessProxies=\"";
145 const char* _GenerateTypeLibrary = "\n\t\t\t\tGenerateTypeLibrary=\"";
146 const char* _GlobalOptimizations = "\n\t\t\t\tGlobalOptimizations=\"";
147 const char* _HeaderFileName = "\n\t\t\t\tHeaderFileName=\"";
148 const char* _HeapCommitSize = "\n\t\t\t\tHeapCommitSize=\"";
149 const char* _HeapReserveSize = "\n\t\t\t\tHeapReserveSize=\"";
150 const char* _IgnoreAllDefaultLibraries = "\n\t\t\t\tIgnoreAllDefaultLibraries=\"";
151 const char* _IgnoreDefaultLibraryNames = "\n\t\t\t\tIgnoreDefaultLibraryNames=\"";
152 const char* _IgnoreEmbeddedIDL = "\n\t\t\t\tIgnoreEmbeddedIDL=\"";
153 const char* _IgnoreImportLibrary = "\n\t\t\t\tIgnoreImportLibrary=\"";
154 const char* _IgnoreStandardIncludePath = "\n\t\t\t\tIgnoreStandardIncludePath=\"";
155 const char* _ImportLibrary = "\n\t\t\t\tImportLibrary=\"";
156 const char* _ImproveFloatingPointConsistency = "\n\t\t\t\tImproveFloatingPointConsistency=\"";
157 const char* _InlineFunctionExpansion = "\n\t\t\t\tInlineFunctionExpansion=\"";
158 const char* _InterfaceIdentifierFileName = "\n\t\t\t\tInterfaceIdentifierFileName=\"";
159 const char* _IntermediateDirectory = "\n\t\t\tIntermediateDirectory=\"";
160 const char* _KeepComments = "\n\t\t\t\tKeepComments=\"";
161 const char* _LargeAddressAware = "\n\t\t\t\tLargeAddressAware=\"";
162 const char* _LinkDLL = "\n\t\t\t\tLinkDLL=\"";
163 const char* _LinkIncremental = "\n\t\t\t\tLinkIncremental=\"";
164 const char* _LinkTimeCodeGeneration = "\n\t\t\t\tLinkTimeCodeGeneration=\"";
165 const char* _LinkToManagedResourceFile = "\n\t\t\t\tLinkToManagedResourceFile=\"";
166 const char* _MapExports = "\n\t\t\t\tMapExports=\"";
167 const char* _MapFileName = "\n\t\t\t\tMapFileName=\"";
168 const char* _MapLines = "\n\t\t\t\tMapLines =\"";
169 const char* _MergeSections = "\n\t\t\t\tMergeSections=\"";
170 const char* _MergedIDLBaseFileName = "\n\t\t\t\tMergedIDLBaseFileName=\"";
171 const char* _MidlCommandFile = "\n\t\t\t\tMidlCommandFile=\"";
172 const char* _MinimalRebuild = "\n\t\t\t\tMinimalRebuild=\"";
173 const char* _MkTypLibCompatible = "\n\t\t\t\tMkTypLibCompatible=\"";
174 const char* _ModuleDefinitionFile = "\n\t\t\t\tModuleDefinitionFile=\"";
175 const char* _Name1 = "\n\tName=\"";
176 const char* _Name2 = "\n\t\tName=\"";
177 const char* _Name3 = "\n\t\t\tName=\"";
178 const char* _Name4 = "\n\t\t\t\tName=\"";
179 const char* _Name5 = "\n\t\t\t\t\tName=\"";
180 const char* _ObjectFile = "\n\t\t\t\tObjectFile=\"";
181 const char* _OmitFramePointers = "\n\t\t\t\tOmitFramePointers=\"";
182 const char* _Optimization = "\n\t\t\t\tOptimization =\"";
183 const char* _OptimizeForProcessor = "\n\t\t\t\tOptimizeForProcessor=\"";
184 const char* _OptimizeForWindows98 = "\n\t\t\t\tOptimizeForWindows98=\"";
185 const char* _OptimizeForWindowsApplication = "\n\t\t\t\tOptimizeForWindowsApplication=\"";
186 const char* _OptimizeReferences = "\n\t\t\t\tOptimizeReferences=\"";
187 const char* _OutputDirectory3 = "\n\t\t\tOutputDirectory=\"";
188 const char* _OutputDirectory4 = "\n\t\t\t\tOutputDirectory=\"";
189 const char* _OutputFile = "\n\t\t\t\tOutputFile=\"";
190 const char* _Outputs4 = "\n\t\t\t\tOutputs=\"";
191 const char* _Outputs6 = "\n\t\t\t\t\t\tOutputs=\"";
192 const char* _ParseFiles = "\n\t\t\tParseFiles=\"";
193 const char* _PrecompiledHeaderFile = "\n\t\t\t\tPrecompiledHeaderFile=\"";
194 const char* _PrecompiledHeaderThrough = "\n\t\t\t\tPrecompiledHeaderThrough=\"";
195 const char* _PreprocessorDefinitions = "\n\t\t\t\tPreprocessorDefinitions=\"";
196 const char* _PrimaryOutput = "\n\t\t\tPrimaryOutput=\"";
197 const char* _ProjectGUID = "\n\tProjectGUID=\"";
198 const char* _ProjectType = "\n\tProjectType=\"Visual C++\"";
199 const char* _ProgramDatabase = "\n\t\t\tProgramDatabase=\"";
200 const char* _ProgramDataBaseFileName = "\n\t\t\t\tProgramDataBaseFileName=\"";
201 const char* _ProgramDatabaseFile = "\n\t\t\t\tProgramDatabaseFile=\"";
202 const char* _ProxyFileName = "\n\t\t\t\tProxyFileName=\"";
203 const char* _RedirectOutputAndErrors = "\n\t\t\t\tRedirectOutputAndErrors=\"";
204 const char* _RegisterOutput = "\n\t\t\t\tRegisterOutput=\"";
205 const char* _RelativePath = "\n\t\t\t\tRelativePath=\"";
206 const char* _ResourceOnlyDLL = "\n\t\t\t\tResourceOnlyDLL=\"";
207 const char* _ResourceOutputFileName = "\n\t\t\t\tResourceOutputFileName=\"";
208 const char* _RuntimeLibrary = "\n\t\t\t\tRuntimeLibrary=\"";
209 const char* _RuntimeTypeInfo = "\n\t\t\t\tRuntimeTypeInfo=\"";
210 const char* _SccProjectName = "\n\tSccProjectName=\"";
211 const char* _SccLocalPath = "\n\tSccLocalPath=\"";
212 const char* _SetChecksum = "\n\t\t\t\tSetChecksum=\"";
213 const char* _ShowIncludes = "\n\t\t\t\tShowIncludes=\"";
214 const char* _ShowProgress = "\n\t\t\t\tShowProgress=\"";
215 const char* _SmallerTypeCheck = "\n\t\t\t\tSmallerTypeCheck=\"";
216 const char* _StackCommitSize = "\n\t\t\t\tStackCommitSize=\"";
217 const char* _StackReserveSize = "\n\t\t\t\tStackReserveSize=\"";
218 const char* _StringPooling = "\n\t\t\t\tStringPooling=\"";
219 const char* _StripPrivateSymbols = "\n\t\t\t\tStripPrivateSymbols=\"";
220 const char* _StructMemberAlignment = "\n\t\t\t\tStructMemberAlignment=\"";
221 const char* _SubSystem = "\n\t\t\t\tSubSystem=\"";
222 const char* _SupportUnloadOfDelayLoadedDLL = "\n\t\t\t\tSupportUnloadOfDelayLoadedDLL=\"";
223 const char* _SuppressStartupBanner = "\n\t\t\t\tSuppressStartupBanner=\"";
224 const char* _SwapRunFromCD = "\n\t\t\t\tSwapRunFromCD=\"";
225 const char* _SwapRunFromNet = "\n\t\t\t\tSwapRunFromNet=\"";
226 const char* _TargetEnvironment = "\n\t\t\t\tTargetEnvironment=\"";
227 const char* _TargetMachine = "\n\t\t\t\tTargetMachine=\"";
228 const char* _TerminalServerAware = "\n\t\t\t\tTerminalServerAware=\"";
229 const char* _ToolName = "\n\t\t\t\tName=\"";
230 const char* _ToolPath = "\n\t\t\t\tPath=\"";
231 const char* _TreatWChar_tAsBuiltInType = "\n\t\t\t\tTreatWChar_tAsBuiltInType=\"";
232 const char* _TurnOffAssemblyGeneration = "\n\t\t\t\tTurnOffAssemblyGeneration=\"";
233 const char* _TypeLibraryFile = "\n\t\t\t\tTypeLibraryFile=\"";
234 const char* _TypeLibraryName = "\n\t\t\t\tTypeLibraryName=\"";
235 const char* _TypeLibraryResourceID = "\n\t\t\t\tTypeLibraryResourceID=\"";
236const char* _UndefineAllPreprocessorDefinitions = "\n\t\t\t\tUndefineAllPreprocessorDefinitions=\"";
237 const char* _UndefinePreprocessorDefinitions = "\n\t\t\t\tUndefinePreprocessorDefinitions=\"";
238 const char* _UseOfATL = "\n\t\t\tUseOfATL=\"";
239 const char* _UseOfMfc = "\n\t\t\tUseOfMfc=\"";
240 const char* _UsePrecompiledHeader = "\n\t\t\t\tUsePrecompiledHeader=\"";
241 const char* _ValidateParameters = "\n\t\t\t\tValidateParameters=\"";
242 const char* _VCCLCompilerToolName = "\n\t\t\t\tName=\"VCCLCompilerTool\"";
243 const char* _VCCustomBuildTool = "\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"";
244 const char* _VCLinkerToolName = "\n\t\t\t\tName=\"VCLinkerTool\"";
245 const char* _VCResourceCompilerToolName = "\n\t\t\t\tName=\"VCResourceCompilerTool\"";
246 const char* _VCMIDLToolName = "\n\t\t\t\tName=\"VCMIDLTool\"";
247 const char* _Version1 = "\n\tVersion=\"";
248 const char* _Version4 = "\n\t\t\t\tVersion=\"";
249 const char* _WarnAsError = "\n\t\t\t\tWarnAsError=\"";
250 const char* _WarnLevel = "\n\t\t\t\tWarnLevel=\"";
251 const char* _WarningLevel = "\n\t\t\t\tWarningLevel=\"";
252 const char* _WholeProgramOptimization = "\n\t\t\t\tWholeProgramOptimization=\"";
253
254// Property name and value as Pairs ---------------------------------
255struct TPair {
256 TPair( const char* n, const triState v ) : name(n), value(v) {};
257 const char* name;
258 const triState value;
259};
260struct EPair {
261 EPair( const char* n, const int v ) : name(n), value(v) {};
262 const char* name;
263 const int value;
264};
265struct LPair {
266 LPair( const char* n, const long v ) : name(n), value(v) {};
267 const char* name;
268 const long value;
269};
270struct SPair {
271 SPair( const char* n, const QString& v ) : name(n), value(v) {};
272 const char* name;
273 const QString& value;
274};
275struct XPair {
276 XPair( const char* n, const QStringList& v, const char* s = "," ) : name(n), value(v), sep(s) {};
277 const char* name;
278 const QStringList& value;
279 const char* sep;
280};
281
282// void streamSPair( QTextStream &strm, const char *n, const QString &s )
283
284
285// Streaming operators for property Pairs ---------------------------
286QTextStream &operator<<( QTextStream &strm, const TPair &prop )
287{
288 switch( prop.value ) {
289 case _False:
290 strm << prop.name << "FALSE\"";
291 break;
292 case _True:
293 strm << prop.name << "TRUE\"";
294 break;
295 case unset:
296 default:
297 break;
298 }
299 return strm;
300}
301
302/* Be sure to check that each enum is not set to
303 default before streaming it out. Defaults seem
304 to not be in the XML file.
305*/
306QTextStream &operator<<( QTextStream &strm, const EPair &prop )
307{
308 strm << prop.name << prop.value << "\"";
309 return strm;
310}
311
312QTextStream &operator<<( QTextStream &strm, const LPair &prop )
313{
314 strm << prop.name << prop.value << "\"";
315 return strm;
316}
317
318QTextStream &operator<<( QTextStream &strm, const SPair &prop )
319{
320 if ( !prop.value.isEmpty() )
321 strm << prop.name << prop.value.latin1() << "\"";
322 return strm;
323}
324
325QTextStream &operator<<( QTextStream &strm, const XPair &prop )
326{
327 if ( !prop.value.isEmpty() )
328 strm << prop.name << prop.value.join(prop.sep).latin1() << "\"";
329 return strm;
330}
331
332// VCCLCompilerTool -------------------------------------------------
333VCCLCompilerTool::VCCLCompilerTool()
334 :AssemblerOutput( asmListingNone ),
335 BasicRuntimeChecks( runtimeBasicCheckNone ),
336 BrowseInformation( brInfoNone ),
337 BufferSecurityCheck( unset ),
338 CallingConvention( callConventionDefault ),
339 CompileAs( compileAsDefault ),
340 CompileAsManaged( managedDefault ),
341 CompileOnly( unset ),
342 DebugInformationFormat( debugDisabled ),
343 DefaultCharIsUnsigned( unset ),
344 Detect64BitPortabilityProblems( unset ),
345 DisableLanguageExtensions( unset ),
346 EnableFiberSafeOptimizations( unset ),
347 EnableFunctionLevelLinking( unset ),
348 EnableIntrinsicFunctions( unset ),
349 ExceptionHandling( unset ),
350 ExpandAttributedSource( unset ),
351 FavorSizeOrSpeed( favorNone ),
352 ForceConformanceInForLoopScope( unset ),
353 GeneratePreprocessedFile( preprocessNo ),
354 GlobalOptimizations( unset ),
355 IgnoreStandardIncludePath( unset ),
356 ImproveFloatingPointConsistency( unset ),
357 InlineFunctionExpansion( expandOnlyInline ),
358 KeepComments( unset ),
359 MinimalRebuild( unset ),
360 OmitFramePointers( unset ),
361 Optimization( optimizeDisabled ),
362 OptimizeForProcessor( procOptimizeBlended ),
363 OptimizeForWindowsApplication( unset ),
364 RuntimeLibrary( rtMultiThreaded ),
365 RuntimeTypeInfo( unset ),
366 ShowIncludes( unset ),
367 SmallerTypeCheck( unset ),
368 StringPooling( unset ),
369 StructMemberAlignment( alignNotSet ),
370 SuppressStartupBanner( unset ),
371 TreatWChar_tAsBuiltInType( unset ),
372 TurnOffAssemblyGeneration( unset ),
373 UndefineAllPreprocessorDefinitions( unset ),
374 UsePrecompiledHeader( pchGenerateAuto ),
375 WarnAsError( unset ),
376 WarningLevel( warningLevel_0 ),
377 WholeProgramOptimization( unset )
378{
379}
380
381QTextStream &operator<<( QTextStream &strm, const VCCLCompilerTool &tool )
382{
383 strm << _begTool3;
384 strm << _VCCLCompilerToolName;
385 strm << XPair( _AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories );
386 strm << XPair( _AdditionalOptions, tool.AdditionalOptions );
387 strm << XPair( _AdditionalUsingDirectories, tool.AdditionalUsingDirectories );
388 strm << SPair( _AssemblerListingLocation, tool.AssemblerListingLocation );
389 if ( tool.AssemblerOutput != asmListingNone ) strm << EPair( _AssemblerOutput, tool.AssemblerOutput );
390 if ( tool.BasicRuntimeChecks != runtimeBasicCheckNone ) strm << EPair( _BasicRuntimeChecks, tool.BasicRuntimeChecks );
391 if ( tool.BrowseInformation != brInfoNone ) strm << EPair( _BrowseInformation, tool.BrowseInformation );
392 strm << SPair( _BrowseInformationFile, tool.BrowseInformationFile );
393 strm << TPair( _BufferSecurityCheck, tool.BufferSecurityCheck );
394 if ( tool.CallingConvention != callConventionDefault ) strm << EPair( _CallingConvention, tool.CallingConvention );
395 if ( tool.CompileAs != compileAsDefault ) strm << EPair( _CompileAs, tool.CompileAs );
396 if ( tool.CompileAsManaged != managedDefault ) strm << EPair( _CompileAsManaged, tool.CompileAsManaged );
397 strm << TPair( _CompileOnly, tool.CompileOnly );
398 strm << EPair( _DebugInformationFormat, tool.DebugInformationFormat );
399 strm << TPair( _DefaultCharIsUnsigned, tool.DefaultCharIsUnsigned );
400 strm << TPair( _Detect64BitPortabilityProblems, tool.Detect64BitPortabilityProblems );
401 strm << TPair( _DisableLanguageExtensions, tool.DisableLanguageExtensions );
402 strm << XPair( _DisableSpecificWarnings, tool.DisableSpecificWarnings );
403 strm << TPair( _EnableFiberSafeOptimizations, tool.EnableFiberSafeOptimizations );
404 strm << TPair( _EnableFunctionLevelLinking, tool.EnableFunctionLevelLinking );
405 strm << TPair( _EnableIntrinsicFunctions, tool.EnableIntrinsicFunctions );
406 strm << TPair( _ExceptionHandling, tool.ExceptionHandling );
407 strm << TPair( _ExpandAttributedSource, tool.ExpandAttributedSource );
408 if ( tool.FavorSizeOrSpeed != favorNone ) strm << EPair( _FavorSizeOrSpeed, tool.FavorSizeOrSpeed );
409 strm << TPair( _ForceConformanceInForLoopScope, tool.ForceConformanceInForLoopScope );
410 strm << XPair( _ForcedIncludeFiles, tool.ForcedIncludeFiles );
411 strm << XPair( _ForcedUsingFiles, tool.ForcedUsingFiles );
412 strm << EPair( _GeneratePreprocessedFile, tool.GeneratePreprocessedFile );
413 strm << TPair( _GlobalOptimizations, tool.GlobalOptimizations );
414 strm << TPair( _IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath );
415 strm << TPair( _ImproveFloatingPointConsistency, tool.ImproveFloatingPointConsistency );
416 strm << EPair( _InlineFunctionExpansion, tool.InlineFunctionExpansion );
417 strm << TPair( _KeepComments, tool.KeepComments );
418 strm << TPair( _MinimalRebuild, tool.MinimalRebuild );
419 strm << SPair( _ObjectFile, tool.ObjectFile );
420 strm << TPair( _OmitFramePointers, tool.OmitFramePointers );
421 strm << EPair( _Optimization, tool.Optimization );
422 if ( tool.OptimizeForProcessor != procOptimizeBlended ) strm << EPair( _OptimizeForProcessor, tool.OptimizeForProcessor );
423 strm << TPair( _OptimizeForWindowsApplication, tool.OptimizeForWindowsApplication );
424 strm << SPair( _OutputFile, tool.OutputFile );
425 strm << SPair( _PrecompiledHeaderFile, tool.PrecompiledHeaderFile );
426 strm << SPair( _PrecompiledHeaderThrough, tool.PrecompiledHeaderThrough );
427 strm << XPair( _PreprocessorDefinitions, tool.PreprocessorDefinitions );
428 strm << SPair( _ProgramDataBaseFileName, tool.ProgramDataBaseFileName );
429 strm << EPair( _RuntimeLibrary, tool.RuntimeLibrary );
430 strm << TPair( _RuntimeTypeInfo, tool.RuntimeTypeInfo );
431 strm << TPair( _ShowIncludes, tool.ShowIncludes );
432 strm << TPair( _SmallerTypeCheck, tool.SmallerTypeCheck );
433 strm << TPair( _StringPooling, tool.StringPooling );
434 if ( tool.StructMemberAlignment != alignNotSet ) strm << EPair( _StructMemberAlignment, tool.StructMemberAlignment );
435 strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner );
436 strm << TPair( _TreatWChar_tAsBuiltInType, tool.TreatWChar_tAsBuiltInType );
437 strm << TPair( _TurnOffAssemblyGeneration, tool.TurnOffAssemblyGeneration );
438 strm << TPair( _UndefineAllPreprocessorDefinitions, tool.UndefineAllPreprocessorDefinitions );
439 strm << XPair( _UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions );
440 if ( !tool.PrecompiledHeaderFile.isEmpty() ||
441 !tool.PrecompiledHeaderThrough.isEmpty() )
442 strm << EPair( _UsePrecompiledHeader, tool.UsePrecompiledHeader );
443 strm << TPair( _WarnAsError, tool.WarnAsError );
444 strm << EPair( _WarningLevel, tool.WarningLevel );
445 strm << TPair( _WholeProgramOptimization, tool.WholeProgramOptimization );
446 strm << "/>";
447return strm;
448}
449
450bool VCCLCompilerTool::parseOption( const char* option )
451{
452 // skip index 0 ('/' or '-')
453 char first = option[1];
454 char second = option[2];
455 char third = option[3];
456 char fourth = option[4];
457
458 switch ( first ) {
459 case '?':
460 case 'h':
461 qWarning( "Generator: Option '/?', '/help': MSVC.NET projects do not support outputting help info" );
462 return FALSE;
463 case '@':
464 qWarning( "Generator: Option '/@': MSVC.NET projects do not support the use of a response file" );
465 return FALSE;
466 case 'l':
467 qWarning( "Generator: Option '/link': qmake generator does not support passing link options through the compiler tool" );
468 return FALSE;
469
470 case 'A':
471 if ( second != 'I' )
472 return FALSE;
473 AdditionalUsingDirectories += option+2;
474 break;
475 case 'C':
476 KeepComments = _True;
477 break;
478 case 'D':
479 PreprocessorDefinitions += option+1;
480 break;
481 case 'E':
482 if ( second == 'H' ) {
483 if ( third == 'a' || third == 'c' || third == 's' ) {
484 // ExceptionHandling must be false, or it will override
485 // with an /EHsc option
486 ExceptionHandling = _False;
487 AdditionalOptions += option;
488 break;
489 }
490 return FALSE;
491 }
492 GeneratePreprocessedFile = preprocessYes;
493 break;
494 case 'F':
495 if ( second <= '9' && second >= '0' ) {
496 AdditionalOptions += option;
497 break;
498 } else {
499 switch ( second ) {
500 case 'A':
501 if ( third == 'c' ) {
502 AssemblerOutput = asmListingAsmMachine;
503 if ( fourth == 's' )
504 AssemblerOutput = asmListingAsmMachineSrc;
505 } else if ( third == 's' ) {
506 AssemblerOutput = asmListingAsmSrc;
507 } else {
508 AssemblerOutput = asmListingAssemblyOnly;
509 }
510 break;
511 case 'a':
512 AssemblerListingLocation = option+3;
513 break;
514 case 'I':
515 ForcedIncludeFiles += option+3;
516 break;
517 case 'R':
518 BrowseInformation = brAllInfo;
519 BrowseInformationFile = option+3;
520 break;
521 case 'r':
522 BrowseInformation = brNoLocalSymbols;
523 BrowseInformationFile = option+3;
524 break;
525 case 'U':
526 ForcedUsingFiles += option+3;
527 break;
528 case 'd':
529 ProgramDataBaseFileName = option+3;
530 break;
531 case 'e':
532 OutputFile = option+3;
533 break;
534 case 'm':
535 AdditionalOptions += option;
536 break;
537 case 'o':
538 ObjectFile = option+3;
539 break;
540 case 'p':
541 PrecompiledHeaderFile = option+3;
542 break;
543 case 'x':
544 ExpandAttributedSource = _True;
545 break;
546 default:
547 return FALSE;
548 }
549 }
550 break;
551 case 'G':
552 switch ( second ) {
553 case '3':
554 case '4':
555 qWarning( "Option '/G3' and '/G4' were phased out in Visual C++ 5.0" );
556 return FALSE;
557 case '5':
558 OptimizeForProcessor = procOptimizePentium;
559 break;
560 case '6':
561 case 'B':
562 OptimizeForProcessor = procOptimizePentiumProAndAbove;
563 break;
564 case 'A':
565 OptimizeForWindowsApplication = _True;
566 break;
567 case 'F':
568 StringPooling = _True;
569 break;
570 case 'H':
571 AdditionalOptions += option;
572 break;
573 case 'L':
574 WholeProgramOptimization = _True;
575 if ( third == '-' )
576 WholeProgramOptimization = _False;
577 break;
578 case 'R':
579 RuntimeTypeInfo = _True;
580 if ( third == '-' )
581 RuntimeTypeInfo = _False;
582 break;
583 case 'S':
584 BufferSecurityCheck = _True;
585 break;
586 case 'T':
587 EnableFiberSafeOptimizations = _True;
588 break;
589 case 'X':
590 case 'Z':
591 case 'e':
592 case 'h':
593 AdditionalOptions += option;
594 break;
595 case 'd':
596 CallingConvention = callConventionCDecl;
597 break;
598 case 'f':
599 StringPooling = _True;
600 AdditionalOptions += option;
601 break;
602 case 'm':
603 MinimalRebuild = _True;
604 if ( third == '-' )
605 MinimalRebuild = _False;
606 break;
607 case 'r':
608 CallingConvention = callConventionFastCall;
609 break;
610 case 's':
611 // Warning: following [num] is not used,
612 // were should we put it?
613 BufferSecurityCheck = _True;
614 break;
615 case 'y':
616 EnableFunctionLevelLinking = _True;
617 break;
618 case 'z':
619 CallingConvention = callConventionStdCall;
620 break;
621 default:
622 return FALSE;
623 }
624 break;
625 case 'H':
626 AdditionalOptions += option;
627 break;
628 case 'I':
629 AdditionalIncludeDirectories += option+2;
630 break;
631 case 'L':
632 if ( second == 'D' ) {
633 AdditionalOptions += option;
634 break;
635 }
636 return FALSE;
637 case 'M':
638 if ( second == 'D' ) {
639 RuntimeLibrary = rtMultiThreadedDLL;
640 if ( third == 'd' )
641 RuntimeLibrary = rtMultiThreadedDebugDLL;
642 break;
643 } else if ( second == 'L' ) {
644 RuntimeLibrary = rtSingleThreaded;
645 if ( third == 'd' )
646 RuntimeLibrary = rtSingleThreadedDebug;
647 break;
648 } else if ( second == 'T' ) {
649 RuntimeLibrary = rtMultiThreaded;
650 if ( third == 'd' )
651 RuntimeLibrary = rtMultiThreadedDebug;
652 break;
653 }
654 return FALSE;
655 case 'O':
656 switch ( second ) {
657 case '1':
658 Optimization = optimizeMinSpace;
659 break;
660 case '2':
661 Optimization = optimizeMaxSpeed;
662 break;
663 case 'a':
664 AdditionalOptions += option;
665 break;
666 case 'b':
667 if ( third == '0' )
668 InlineFunctionExpansion = expandDisable;
669 else if ( third == '1' )
670 InlineFunctionExpansion = expandOnlyInline;
671 else if ( third == '2' )
672 InlineFunctionExpansion = expandAnySuitable;
673 else
674 return FALSE;
675 break;
676 case 'd':
677 Optimization = optimizeDisabled;
678 break;
679 case 'g':
680 GlobalOptimizations = _True;
681 break;
682 case 'i':
683 EnableIntrinsicFunctions = _True;
684 break;
685 case 'p':
686 ImproveFloatingPointConsistency = _True;
687 if ( third == '-' )
688 ImproveFloatingPointConsistency = _False;
689 break;
690 case 's':
691 FavorSizeOrSpeed = favorSize;
692 break;
693 case 't':
694 FavorSizeOrSpeed = favorSpeed;
695 break;
696 case 'w':
697 AdditionalOptions += option;
698 break;
699 case 'x':
700 Optimization = optimizeFull;
701 break;
702 case 'y':
703 OmitFramePointers = _True;
704 if ( third == '-' )
705 OmitFramePointers = _False;
706 break;
707 default:
708 return FALSE;
709 }
710 break;
711 case 'P':
712 GeneratePreprocessedFile = preprocessYes;
713 break;
714 case 'Q':
715 if ( second == 'I' ) {
716 AdditionalOptions += option;
717 break;
718 }
719 return FALSE;
720 case 'R':
721 if ( second == 'T' && third == 'C' ) {
722 if ( fourth == '1' )
723 BasicRuntimeChecks = runtimeBasicCheckAll;
724 else if ( fourth == 'c' )
725 SmallerTypeCheck = _True;
726 else if ( fourth == 's' )
727 BasicRuntimeChecks = runtimeCheckStackFrame;
728 else if ( fourth == 'u' )
729 BasicRuntimeChecks = runtimeCheckUninitVariables;
730 else
731 return FALSE;
732 }
733 break;
734 case 'T':
735 if ( second == 'C' ) {
736 CompileAs = compileAsC;
737 } else if ( second == 'P' ) {
738 CompileAs = compileAsCPlusPlus;
739 } else {
740 qWarning( "Generator: Options '/Tp<filename>' and '/Tc<filename>' are not supported by qmake" );
741 return FALSE;
742 }
743 break;
744 case 'U':
745 UndefinePreprocessorDefinitions += option+2;
746 break;
747 case 'V':
748 AdditionalOptions += option;
749 break;
750 case 'W':
751 switch ( second ) {
752 case 'a':
753 case '4':
754 WarningLevel = warningLevel_4;
755 break;
756 case '3':
757 WarningLevel = warningLevel_3;
758 break;
759 case '2':
760 WarningLevel = warningLevel_2;
761 break;
762 case '1':
763 WarningLevel = warningLevel_1;
764 break;
765 case '0':
766 WarningLevel = warningLevel_0;
767 break;
768 case 'L':
769 AdditionalOptions += option;
770 break;
771 case 'X':
772 WarnAsError = _True;
773 break;
774 case 'p':
775 if ( third == '6' && fourth == '4' ) {
776 Detect64BitPortabilityProblems = _True;
777 break;
778 }
779 // Fallthrough
780 default:
781 return FALSE;
782 }
783 break;
784 case 'X':
785 IgnoreStandardIncludePath = _True;
786 break;
787 case 'Y':
788 switch ( second ) {
789 case '\0':
790 case '-':
791 AdditionalOptions += option;
792 break;
793 case 'X':
794 UsePrecompiledHeader = pchGenerateAuto;
795 PrecompiledHeaderFile = option+3;
796 break;
797 case 'c':
798 UsePrecompiledHeader = pchCreateUsingSpecific;
799 PrecompiledHeaderFile = option+3;
800 break;
801 case 'd':
802 case 'l':
803 AdditionalOptions =+ option;
804 break;
805 case 'u':
806 UsePrecompiledHeader = pchUseUsingSpecific;
807 PrecompiledHeaderFile = option+3;
808 break;
809 default:
810 return FALSE;
811 }
812 break;
813 case 'Z':
814 switch ( second ) {
815 case '7':
816 DebugInformationFormat = debugOldStyleInfo;
817 break;
818 case 'I':
819 DebugInformationFormat = debugEditAndContinue;
820 break;
821 case 'd':
822 DebugInformationFormat = debugLineInfoOnly;
823 break;
824 case 'i':
825 DebugInformationFormat = debugEnabled;
826 break;
827 case 'l':
828 DebugInformationFormat = debugEditAndContinue;
829 break;
830 case 'a':
831 DisableLanguageExtensions = _True;
832 break;
833 case 'e':
834 DisableLanguageExtensions = _False;
835 break;
836 case 'c':
837 if ( third == ':' ) {
838 if ( fourth == 'f' )
839 ForceConformanceInForLoopScope = _True;
840 else if ( fourth == 'w' )
841 TreatWChar_tAsBuiltInType = _True;
842 else
843 return FALSE;
844 } else {
845 return FALSE;
846 }
847 break;
848 case 'g':
849 case 'm':
850 case 's':
851 AdditionalOptions += option;
852 break;
853 case 'p':
854 switch ( third )
855 {
856 case '\0':
857 case '1':
858 StructMemberAlignment = alignSingleByte;
859 if ( fourth == '6' )
860 StructMemberAlignment = alignSixteenBytes;
861 break;
862 case '2':
863 StructMemberAlignment = alignTwoBytes;
864 break;
865 case '4':
866 StructMemberAlignment = alignFourBytes;
867 break;
868 case '8':
869 StructMemberAlignment = alignEightBytes;
870 break;
871 default:
872 return FALSE;
873 }
874 break;
875 default:
876 return FALSE;
877 }
878 break;
879 case 'c':
880 if ( second == '\0' ) {
881 CompileOnly = _True;
882 } else if ( second == 'l' ) {
883 if ( *(option+5) == 'n' ) {
884 CompileAsManaged = managedAssembly;
885 TurnOffAssemblyGeneration = _True;
886 } else {
887 CompileAsManaged = managedAssembly;
888 }
889 } else {
890 return FALSE;
891 }
892 break;
893 case 'd':
894 if ( second != 'r' )
895 return FALSE;
896 CompileAsManaged = managedAssembly;
897 break;
898 case 'n':
899 if ( second == 'o' && third == 'B' && fourth == 'o' ) {
900 AdditionalOptions += "/noBool";
901 break;
902 }
903 if ( second == 'o' && third == 'l' && fourth == 'o' ) {
904 SuppressStartupBanner = _True;
905 break;
906 }
907 return FALSE;
908 case 's':
909 if ( second == 'h' && third == 'o' && fourth == 'w' ) {
910 ShowIncludes = _True;
911 break;
912 }
913 return FALSE;
914 case 'u':
915 UndefineAllPreprocessorDefinitions = _True;
916 break;
917 case 'v':
918 if ( second == 'd' || second == 'm' ) {
919 AdditionalOptions += option;
920 break;
921 }
922 return FALSE;
923 case 'w':
924 switch ( second ) {
925 case '\0':
926 WarningLevel = warningLevel_0;
927 break;
928 case 'd':
929 DisableSpecificWarnings += option+3;
930 break;
931 default:
932 AdditionalOptions += option;
933 }
934 break;
935 default:
936 return FALSE;
937 }
938 return TRUE;
939}
940
941// VCLinkerTool -----------------------------------------------------
942VCLinkerTool::VCLinkerTool()
943 :EnableCOMDATFolding( optFoldingDefault ),
944 GenerateDebugInformation( unset ),
945 GenerateMapFile( unset ),
946 HeapCommitSize( -1 ),
947 HeapReserveSize( -1 ),
948 IgnoreAllDefaultLibraries( unset ),
949 IgnoreEmbeddedIDL( unset ),
950 IgnoreImportLibrary( unset ),
951 LargeAddressAware( addrAwareDefault ),
952 LinkDLL( unset ),
953 LinkIncremental( linkIncrementalYes ),
954 LinkTimeCodeGeneration( unset ),
955 MapExports( unset ),
956 MapLines( unset ),
957 OptimizeForWindows98( optWin98Default ),
958 OptimizeReferences( optReferencesDefault ),
959 RegisterOutput( unset ),
960 ResourceOnlyDLL( unset ),
961 SetChecksum( unset ),
962 ShowProgress( linkProgressNotSet ),
963 StackCommitSize( -1 ),
964 StackReserveSize( -1 ),
965 SubSystem( subSystemNotSet ),
966 SupportUnloadOfDelayLoadedDLL( unset ),
967 SuppressStartupBanner( unset ),
968 SwapRunFromCD( unset ),
969 SwapRunFromNet( unset ),
970 TargetMachine( machineNotSet ),
971 TerminalServerAware( termSvrAwareDefault ),
972 TurnOffAssemblyGeneration( unset ),
973 TypeLibraryResourceID( 0 )
974{
975}
976
977QTextStream &operator<<( QTextStream &strm, const VCLinkerTool &tool )
978{
979 strm << _begTool3;
980 strm << _VCLinkerToolName;
981 strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies, " " );
982 strm << XPair( _AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories );
983 strm << XPair( _AdditionalOptions, tool.AdditionalOptions );
984 strm << XPair( _AddModuleNamesToAssembly, tool.AddModuleNamesToAssembly );
985 strm << SPair( _BaseAddress, tool.BaseAddress );
986 strm << XPair( _DelayLoadDLLs, tool.DelayLoadDLLs );
987 if ( tool.EnableCOMDATFolding != optFoldingDefault ) strm << EPair( _EnableCOMDATFolding, tool.EnableCOMDATFolding );
988 strm << SPair( _EntryPointSymbol, tool.EntryPointSymbol );
989 strm << XPair( _ForceSymbolReferences, tool.ForceSymbolReferences );
990 strm << SPair( _FunctionOrder, tool.FunctionOrder );
991 strm << TPair( _GenerateDebugInformation, tool.GenerateDebugInformation );
992 strm << TPair( _GenerateMapFile, tool.GenerateMapFile );
993 if ( tool.HeapCommitSize != -1 ) strm << LPair( _HeapCommitSize, tool.HeapCommitSize );
994 if ( tool.HeapReserveSize != -1 ) strm << LPair( _HeapReserveSize, tool.HeapReserveSize );
995 strm << TPair( _IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries );
996 strm << XPair( _IgnoreDefaultLibraryNames, tool.IgnoreDefaultLibraryNames );
997 strm << TPair( _IgnoreEmbeddedIDL, tool.IgnoreEmbeddedIDL );
998 strm << TPair( _IgnoreImportLibrary, tool.IgnoreImportLibrary );
999 strm << SPair( _ImportLibrary, tool.ImportLibrary );
1000 if ( tool.LargeAddressAware != addrAwareDefault ) strm << EPair( _LargeAddressAware, tool.LargeAddressAware );
1001 strm << TPair( _LinkDLL, tool.LinkDLL );
1002 if ( tool.LinkIncremental != linkIncrementalDefault ) strm << EPair( _LinkIncremental, tool.LinkIncremental );
1003 strm << TPair( _LinkTimeCodeGeneration, tool.LinkTimeCodeGeneration );
1004 strm << SPair( _LinkToManagedResourceFile, tool.LinkToManagedResourceFile );
1005 strm << TPair( _MapExports, tool.MapExports );
1006 strm << SPair( _MapFileName, tool.MapFileName );
1007 strm << TPair( _MapLines, tool.MapLines );
1008 strm << SPair( _MergedIDLBaseFileName, tool.MergedIDLBaseFileName );
1009 strm << SPair( _MergeSections, tool.MergeSections );
1010 strm << SPair( _MidlCommandFile, tool.MidlCommandFile );
1011 strm << SPair( _ModuleDefinitionFile, tool.ModuleDefinitionFile );
1012 if ( tool.OptimizeForWindows98 != optWin98Default ) strm << EPair( _OptimizeForWindows98, tool.OptimizeForWindows98 );
1013 if ( tool.OptimizeReferences != optReferencesDefault ) strm << EPair( _OptimizeReferences, tool.OptimizeReferences );
1014 strm << SPair( _OutputFile, tool.OutputFile );
1015 strm << SPair( _ProgramDatabaseFile, tool.ProgramDatabaseFile );
1016 strm << TPair( _RegisterOutput, tool.RegisterOutput );
1017 strm << TPair( _ResourceOnlyDLL, tool.ResourceOnlyDLL );
1018 strm << TPair( _SetChecksum, tool.SetChecksum );
1019 if ( tool.ShowProgress != linkProgressNotSet ) strm << EPair( _ShowProgress, tool.ShowProgress );
1020 if ( tool.StackCommitSize != -1 ) strm << LPair( _StackCommitSize, tool.StackCommitSize );
1021 if ( tool.StackReserveSize != -1 ) strm << LPair( _StackReserveSize, tool.StackReserveSize );
1022 strm << SPair( _StripPrivateSymbols, tool.StripPrivateSymbols );
1023 strm << EPair( _SubSystem, tool.SubSystem );
1024 strm << TPair( _SupportUnloadOfDelayLoadedDLL, tool.SupportUnloadOfDelayLoadedDLL );
1025 strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner );
1026 strm << TPair( _SwapRunFromCD, tool.SwapRunFromCD );
1027 strm << TPair( _SwapRunFromNet, tool.SwapRunFromNet );
1028 if ( tool.TargetMachine != machineNotSet ) strm << EPair( _TargetMachine, tool.TargetMachine );
1029 if ( tool.TerminalServerAware != termSvrAwareDefault ) strm << EPair( _TerminalServerAware, tool.TerminalServerAware );
1030 strm << TPair( _TurnOffAssemblyGeneration, tool.TurnOffAssemblyGeneration );
1031 strm << SPair( _TypeLibraryFile, tool.TypeLibraryFile );
1032 if ( tool.TypeLibraryResourceID != rcUseDefault ) strm << LPair( _TypeLibraryResourceID, tool.TypeLibraryResourceID );
1033 strm << SPair( _Version4, tool.Version );
1034 strm << "/>";
1035 return strm;
1036}
1037
1038// Hashing routine to do fast option lookups ----
1039// Slightly rewritten to stop on ':' ',' and '\0'
1040// Original routine in qtranslator.cpp ----------
1041static uint elfHash( const char* name )
1042{
1043 const uchar *k;
1044 uint h = 0;
1045 uint g;
1046
1047 if ( name ) {
1048 k = (const uchar *) name;
1049 while ( (*k) &&
1050 (*k)!= ':' &&
1051 (*k)!=',' &&
1052 (*k)!=' ' ) {
1053 h = ( h << 4 ) + *k++;
1054 if ( (g = (h & 0xf0000000)) != 0 )
1055 h ^= g >> 24;
1056 h &= ~g;
1057 }
1058 }
1059 if ( !h )
1060 h = 1;
1061 return h;
1062}
1063static void displayHash( const char* str )
1064{
1065 printf( "case 0x%07x: // %s\n break;\n", elfHash(str), str );
1066}
1067
1068bool VCLinkerTool::parseOption( const char* option )
1069{
1070#if 0
1071 // Main options
1072 displayHash( "/ALIGN" ); displayHash( "/ALLOWBIND" ); displayHash( "/ASSEMBLYMODULE" );
1073 displayHash( "/ASSEMBLYRESOURCE" ); displayHash( "/BASE" ); displayHash( "/DEBUG" );
1074 displayHash( "/DEF" ); displayHash( "/DEFAULTLIB" ); displayHash( "/DELAY" );
1075 displayHash( "/DELAYLOAD" ); displayHash( "/DLL" ); displayHash( "/DRIVER" );
1076 displayHash( "/ENTRY" ); displayHash( "/EXETYPE" ); displayHash( "/EXPORT" );
1077 displayHash( "/FIXED" ); displayHash( "/FORCE" ); displayHash( "/HEAP" );
1078 displayHash( "/IDLOUT" ); displayHash( "/IGNOREIDL" ); displayHash( "/IMPLIB" );
1079 displayHash( "/INCLUDE" ); displayHash( "/INCREMENTAL" ); displayHash( "/LARGEADDRESSAWARE" );
1080 displayHash( "/LIBPATH" ); displayHash( "/LTCG" ); displayHash( "/MACHINE" );
1081 displayHash( "/MAP" ); displayHash( "/MAPINFO" ); displayHash( "/MERGE" );
1082 displayHash( "/MIDL" ); displayHash( "/NOASSEMBLY" ); displayHash( "/NODEFAULTLIB" );
1083 displayHash( "/NOENTRY" ); displayHash( "/NOLOGO" ); displayHash( "/OPT" );
1084 displayHash( "/ORDER" ); displayHash( "/OUT" ); displayHash( "/PDB" );
1085 displayHash( "/PDBSTRIPPED" ); displayHash( "/RELEASE" ); displayHash( "/SECTION" );
1086 displayHash( "/STACK" ); displayHash( "/STUB" ); displayHash( "/SUBSYSTEM" );
1087 displayHash( "/SWAPRUN" ); displayHash( "/TLBID" ); displayHash( "/TLBOUT" );
1088 displayHash( "/TSAWARE" ); displayHash( "/VERBOSE" ); displayHash( "/VERSION" );
1089 displayHash( "/VXD" ); displayHash( "/WS " );
1090#endif
1091#if 0
1092 // Sub options
1093 displayHash( "UNLOAD" ); displayHash( "NOBIND" ); displayHash( "no" ); displayHash( "NOSTATUS" ); displayHash( "STATUS" );
1094 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" );
1096 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" );
1098 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" );
1100#endif
1101
1102 switch ( elfHash(option) ) {
1103 case 0x3360dbe: // /ALIGN[:number]
1104 case 0x1485c34: // /ALLOWBIND[:NO]
1105 case 0x6b21972: // /DEFAULTLIB:library
1106 case 0x396ea92: // /DRIVER[:UPONLY | :WDM]
1107 case 0xaca9d75: // /EXETYPE[:DYNAMIC | :DEV386]
1108 case 0x3ad5444: // /EXPORT:entryname[,@ordinal[,NONAME]][,DATA]
1109 case 0x33aec94: // /FIXED[:NO]
1110 case 0x33b4675: // /FORCE:[MULTIPLE|UNRESOLVED]
1111 case 0x7988f7e: // /SECTION:name,[E][R][W][S][D][K][L][P][X][,ALIGN=#]
1112 case 0x0348992: // /STUB:filename
1113 case 0x0034bc4: // /VXD
1114 case 0x0034c50: // /WS
1115 AdditionalOptions += option;
1116 break;
1117 case 0x679c075: // /ASSEMBLYMODULE:filename
1118 AddModuleNamesToAssembly += option+15;
1119 break;
1120 case 0x062d065: // /ASSEMBLYRESOURCE:filename
1121 LinkToManagedResourceFile = option+18;
1122 break;
1123 case 0x0336675: // /BASE:{address | @filename,key}
1124 // Do we need to do a manual lookup when '@filename,key'?
1125 // Seems BaseAddress only can contain the location...
1126 // We don't use it in Qt, so keep it simple for now
1127 BaseAddress = option+6;
1128 break;
1129 case 0x3389797: // /DEBUG
1130 GenerateDebugInformation = _True;
1131 break;
1132 case 0x0033896: // /DEF:filename
1133 ModuleDefinitionFile = option+5;
1134 break;
1135 case 0x338a069: // /DELAY:{UNLOAD | NOBIND}
1136 // MS documentation does not specify what to do with
1137 // this option, so we'll put it in AdditionalOptions
1138 AdditionalOptions += option;
1139 break;
1140 case 0x06f4bf4: // /DELAYLOAD:dllname
1141 DelayLoadDLLs += option+11;
1142 break;
1143 // case 0x003390c: // /DLL
1144 // This option is not used for vcproj files
1145 //break;
1146 case 0x33a3979: // /ENTRY:function
1147 EntryPointSymbol = option+7;
1148 break;
1149 case 0x033c960: // /HEAP:reserve[,commit]
1150 {
1151 QStringList both = QStringList::split( ",", option+6 );
1152 HeapReserveSize = both[0].toLong();
1153 if ( both.count() == 2 )
1154 HeapCommitSize = both[1].toLong();
1155 }
1156 break;
1157 case 0x3d91494: // /IDLOUT:[path\]filename
1158 MergedIDLBaseFileName = option+8;
1159 break;
1160 case 0x345a04c: // /IGNOREIDL
1161 IgnoreEmbeddedIDL = _True;
1162 break;
1163 case 0x3e250e2: // /IMPLIB:filename
1164 ImportLibrary = option+8;
1165 break;
1166 case 0xe281ab5: // /INCLUDE:symbol
1167 ForceSymbolReferences += option+9;
1168 break;
1169 case 0xb28103c: // /INCREMENTAL[:no]
1170 if ( *(option+12) == ':' &&
1171 *(option+13) == 'n' )
1172 LinkIncremental = linkIncrementalNo;
1173 else
1174 LinkIncremental = linkIncrementalYes;
1175 break;
1176 case 0x26e4675: // /LARGEADDRESSAWARE[:no]
1177 if ( *(option+18) == ':' &&
1178 *(option+19) == 'n' )
1179 LargeAddressAware = addrAwareNoLarge;
1180 else
1181 LargeAddressAware = addrAwareLarge;
1182 break;
1183 case 0x0d745c8: // /LIBPATH:dir
1184 AdditionalLibraryDirectories += option+9;
1185 break;
1186 case 0x0341877: // /LTCG[:NOSTATUS|:STATUS]
1187 config->WholeProgramOptimization = _True;
1188 LinkTimeCodeGeneration = _True;
1189 if ( *(option+5) == ':' &&
1190 *(option+6) == 'S' )
1191 ShowProgress = linkProgressAll;
1192 break;
1193 case 0x157cf65: // /MACHINE:{AM33|ARM|CEE|IA64|X86|M32R|MIPS|MIPS16|MIPSFPU|MIPSFPU16|MIPSR41XX|PPC|SH3|SH4|SH5|THUMB|TRICORE}
1194 switch ( elfHash(option+9) ) {
1195 // Very limited documentation on all options but X86,
1196 // so we put the others in AdditionalOptions...
1197 case 0x0046063: // AM33
1198 case 0x000466d: // ARM
1199 case 0x0004795: // CEE
1200 case 0x004d494: // IA64
1201 case 0x0050672: // M32R
1202 case 0x0051e53: // MIPS
1203 case 0x51e5646: // MIPS16
1204 case 0x1e57b05: // MIPSFPU
1205 case 0x57b09a6: // MIPSFPU16
1206 case 0x5852738: // MIPSR41XX
1207 case 0x0005543: // PPC
1208 case 0x00057b3: // SH3
1209 case 0x00057b4: // SH4
1210 case 0x00057b5: // SH5
1211 case 0x058da12: // THUMB
1212 case 0x96d8435: // TRICORE
1213 AdditionalOptions += option;
1214 break;
1215 case 0x0005bb6: // X86
1216 TargetMachine = machineX86;
1217 break;
1218 default:
1219 return FALSE;
1220 }
1221 break;
1222 case 0x0034160: // /MAP[:filename]
1223 GenerateMapFile = _True;
1224 MapFileName = option+5;
1225 break;
1226 case 0x164e1ef: // /MAPINFO:{EXPORTS|LINES}
1227 if ( *(option+9) == 'E' )
1228 MapExports = _True;
1229 else if ( *(option+9) == 'L' )
1230 MapLines = _True;
1231 break;
1232 case 0x341a6b5: // /MERGE:from=to
1233 MergeSections = option+7;
1234 break;
1235 case 0x0341d8c: // /MIDL:@file
1236 MidlCommandFile = option+7;
1237 break;
1238 case 0x84e2679: // /NOASSEMBLY
1239 TurnOffAssemblyGeneration = _True;
1240 break;
1241 case 0x2b21942: // /NODEFAULTLIB[:library]
1242 if ( *(option+13) == '\0' )
1243 IgnoreAllDefaultLibraries = _True;
1244 else
1245 IgnoreDefaultLibraryNames += option+14;
1246 break;
1247 case 0x33a3a39: // /NOENTRY
1248 ResourceOnlyDLL = _True;
1249 break;
1250 case 0x434138f: // /NOLOGO
1251 SuppressStartupBanner = _True;
1252 break;
1253 case 0x0034454: // /OPT:{REF | NOREF | ICF[=iterations] | NOICF | WIN98 | NOWIN98}
1254 {
1255 char third = *(option+7);
1256 switch ( third ) {
1257 case 'F': // REF
1258 if ( *(option+5) == 'R' ) {
1259 OptimizeReferences = optReferences;
1260 } else { // ICF[=iterations]
1261 EnableCOMDATFolding = optFolding;
1262 // [=iterations] case is not documented
1263 }
1264 break;
1265 case 'R': // NOREF
1266 OptimizeReferences = optNoReferences;
1267 break;
1268 case 'I': // NOICF
1269 EnableCOMDATFolding = optNoFolding;
1270 break;
1271 case 'N': // WIN98
1272 OptimizeForWindows98 = optWin98Yes;
1273 break;
1274 case 'W': // NOWIN98
1275 OptimizeForWindows98 = optWin98No;
1276 break;
1277 default:
1278 return FALSE;
1279 }
1280 }
1281 break;
1282 case 0x34468a2: // /ORDER:@filename
1283 FunctionOrder = option+8;
1284 break;
1285 case 0x00344a4: // /OUT:filename
1286 OutputFile = option+5;
1287 break;
1288 case 0x0034482: // /PDB:filename
1289 ProgramDatabaseFile = option+5;
1290 break;
1291 case 0xa2ad314: // /PDBSTRIPPED:pdb_file_name
1292 StripPrivateSymbols = option+13;
1293 break;
1294 case 0x6a09535: // /RELEASE
1295 SetChecksum = _True;
1296 break;
1297 case 0x348857b: // /STACK:reserve[,commit]
1298 {
1299 QStringList both = QStringList::split( ",", option+7 );
1300 StackReserveSize = both[0].toLong();
1301 if ( both.count() == 2 )
1302 StackCommitSize = both[1].toLong();
1303 }
1304 break;
1305 case 0x78dc00d: // /SUBSYSTEM:{CONSOLE|EFI_APPLICATION|EFI_BOOT_SERVICE_DRIVER|EFI_ROM|EFI_RUNTIME_DRIVER|NATIVE|POSIX|WINDOWS|WINDOWSCE}[,major[.minor]]
1306 {
1307 // Split up in subsystem, and version number
1308 QStringList both = QStringList::split( ",", option+11 );
1309 switch ( elfHash(both[0].latin1()) ) {
1310 case 0x8438445: // CONSOLE
1311 SubSystem = subSystemConsole;
1312 break;
1313 case 0xbe29493: // WINDOWS
1314 SubSystem = subSystemWindows;
1315 break;
1316 // The following are undocumented, so add them to AdditionalOptions
1317 case 0x240949e: // EFI_APPLICATION
1318 case 0xe617652: // EFI_BOOT_SERVICE_DRIVER
1319 case 0x9af477d: // EFI_ROM
1320 case 0xd34df42: // EFI_RUNTIME_DRIVER
1321 case 0x5268ea5: // NATIVE
1322 case 0x05547e8: // POSIX
1323 case 0x2949c95: // WINDOWSCE
1324 AdditionalOptions += option;
1325 break;
1326 default:
1327 return FALSE;
1328 }
1329 }
1330 break;
1331 case 0x8b654de: // /SWAPRUN:{NET | CD}
1332 if ( *(option+9) == 'N' )
1333 SwapRunFromNet = _True;
1334 else if ( *(option+9) == 'C' )
1335 SwapRunFromCD = _True;
1336 else
1337 return FALSE;
1338 break;
1339 case 0x34906d4: // /TLBID:id
1340 TypeLibraryResourceID = QString( option+7 ).toLong();
1341 break;
1342 case 0x4907494: // /TLBOUT:[path\]filename
1343 TypeLibraryFile = option+8;
1344 break;
1345 case 0x976b525: // /TSAWARE[:NO]
1346 if ( *(option+8) == ':' )
1347 TerminalServerAware = termSvrAwareNo;
1348 else
1349 TerminalServerAware = termSvrAwareYes;
1350 break;
1351 case 0xaa67735: // /VERBOSE[:lib]
1352 if ( *(option+9) == ':' ) {
1353 ShowProgress = linkProgressLibs;
1354 AdditionalOptions += option;
1355 } else {
1356 ShowProgress = linkProgressAll;
1357 }
1358 break;
1359 case 0xaa77f7e: // /VERSION:major[.minor]
1360 Version = option+9;
1361 break;
1362 default:
1363 return FALSE;
1364 }
1365 return TRUE;
1366}
1367
1368// VCMIDLTool -------------------------------------------------------
1369VCMIDLTool::VCMIDLTool()
1370 :DefaultCharType( midlCharUnsigned ),
1371 EnableErrorChecks( midlDisableAll ),
1372 ErrorCheckAllocations( unset ),
1373 ErrorCheckBounds( unset ),
1374 ErrorCheckEnumRange( unset ),
1375 ErrorCheckRefPointers( unset ),
1376 ErrorCheckStubData( unset ),
1377 GenerateStublessProxies( unset ),
1378 GenerateTypeLibrary( unset ),
1379 IgnoreStandardIncludePath( unset ),
1380 MkTypLibCompatible( unset ),
1381 StructMemberAlignment( midlAlignNotSet ),
1382 SuppressStartupBanner( unset ),
1383 TargetEnvironment( midlTargetNotSet ),
1384 ValidateParameters( unset ),
1385 WarnAsError( unset ),
1386 WarningLevel( midlWarningLevel_0 )
1387{
1388}
1389
1390QTextStream &operator<<( QTextStream &strm, const VCMIDLTool &tool )
1391{
1392 strm << _begTool3;
1393 strm << _VCMIDLToolName;
1394 strm << XPair( _AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories );
1395 strm << XPair( _AdditionalOptions, tool.AdditionalOptions );
1396 strm << XPair( _CPreprocessOptions, tool.CPreprocessOptions );
1397 strm << EPair( _DefaultCharType, tool.DefaultCharType );
1398 strm << SPair( _DLLDataFileName, tool.DLLDataFileName );
1399 strm << EPair( _EnableErrorChecks, tool.EnableErrorChecks );
1400 strm << TPair( _ErrorCheckAllocations, tool.ErrorCheckAllocations );
1401 strm << TPair( _ErrorCheckBounds, tool.ErrorCheckBounds );
1402 strm << TPair( _ErrorCheckEnumRange, tool.ErrorCheckEnumRange );
1403 strm << TPair( _ErrorCheckRefPointers, tool.ErrorCheckRefPointers );
1404 strm << TPair( _ErrorCheckStubData, tool.ErrorCheckStubData );
1405 strm << XPair( _FullIncludePath, tool.FullIncludePath );
1406 strm << TPair( _GenerateStublessProxies, tool.GenerateStublessProxies );
1407 strm << TPair( _GenerateTypeLibrary, tool.GenerateTypeLibrary );
1408 strm << SPair( _HeaderFileName, tool.HeaderFileName );
1409 strm << TPair( _IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath );
1410 strm << SPair( _InterfaceIdentifierFileName, tool.InterfaceIdentifierFileName );
1411 strm << TPair( _MkTypLibCompatible, tool.MkTypLibCompatible );
1412 strm << SPair( _OutputDirectory4, tool.OutputDirectory );
1413 strm << XPair( _PreprocessorDefinitions, tool.PreprocessorDefinitions );
1414 strm << SPair( _ProxyFileName, tool.ProxyFileName );
1415 strm << SPair( _RedirectOutputAndErrors, tool.RedirectOutputAndErrors );
1416 if ( tool.StructMemberAlignment != midlAlignNotSet) strm << EPair( _StructMemberAlignment, tool.StructMemberAlignment );
1417 strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner );
1418 if ( tool.TargetEnvironment != midlTargetNotSet ) strm << EPair( _TargetEnvironment, tool.TargetEnvironment );
1419 strm << SPair( _TypeLibraryName, tool.TypeLibraryName );
1420 strm << XPair( _UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions );
1421 strm << TPair( _ValidateParameters, tool.ValidateParameters );
1422 strm << TPair( _WarnAsError, tool.WarnAsError );
1423 strm << EPair( _WarningLevel, tool.WarningLevel );
1424 strm << "/>";
1425 return strm;
1426}
1427
1428bool VCMIDLTool::parseOption( const char* option )
1429{
1430#if 0
1431 displayHash( "/D name[=def]" ); displayHash( "/I directory-list" ); displayHash( "/Oi" );
1432 displayHash( "/Oic" ); displayHash( "/Oicf" ); displayHash( "/Oif" ); displayHash( "/Os" );
1433 displayHash( "/U name" ); displayHash( "/WX" ); displayHash( "/W{0|1|2|3|4}" );
1434 displayHash( "/Zp {N}" ); displayHash( "/Zs" ); displayHash( "/acf filename" );
1435 displayHash( "/align {N}" ); displayHash( "/app_config" ); displayHash( "/c_ext" );
1436 displayHash( "/char ascii7" ); displayHash( "/char signed" ); displayHash( "/char unsigned" );
1437 displayHash( "/client none" ); displayHash( "/client stub" ); displayHash( "/confirm" );
1438 displayHash( "/cpp_cmd cmd_line" ); displayHash( "/cpp_opt options" );
1439 displayHash( "/cstub filename" ); displayHash( "/dlldata filename" ); displayHash( "/env win32" );
1440 displayHash( "/env win64" ); displayHash( "/error all" ); displayHash( "/error allocation" );
1441 displayHash( "/error bounds_check" ); displayHash( "/error enum" ); displayHash( "/error none" );
1442 displayHash( "/error ref" ); displayHash( "/error stub_data" ); displayHash( "/h filename" );
1443 displayHash( "/header filename" ); displayHash( "/iid filename" ); displayHash( "/lcid" );
1444 displayHash( "/mktyplib203" ); displayHash( "/ms_ext" ); displayHash( "/ms_union" );
1445 displayHash( "/msc_ver <nnnn>" ); displayHash( "/newtlb" ); displayHash( "/no_cpp" );
1446 displayHash( "/no_def_idir" ); displayHash( "/no_default_epv" ); displayHash( "/no_format_opt" );
1447 displayHash( "/no_warn" ); displayHash( "/nocpp" ); displayHash( "/nologo" ); displayHash( "/notlb" );
1448 displayHash( "/o filename" ); displayHash( "/oldnames" ); displayHash( "/oldtlb" );
1449 displayHash( "/osf" ); displayHash( "/out directory" ); displayHash( "/pack {N}" );
1450 displayHash( "/prefix all" ); displayHash( "/prefix client" ); displayHash( "/prefix server" );
1451 displayHash( "/prefix switch" ); displayHash( "/protocol all" ); displayHash( "/protocol dce" );
1452 displayHash( "/protocol ndr64" ); displayHash( "/proxy filename" ); displayHash( "/robust" );
1453 displayHash( "/rpcss" ); displayHash( "/savePP" ); displayHash( "/server none" );
1454 displayHash( "/server stub" ); displayHash( "/sstub filename" ); displayHash( "/syntax_check" );
1455 displayHash( "/target {system}" ); displayHash( "/tlb filename" ); displayHash( "/use_epv" );
1456 displayHash( "/win32" ); displayHash( "/win64" );
1457#endif
1458 int offset = 0;
1459 switch( elfHash(option) ) {
1460 case 0x0000334: // /D name[=def]
1461 PreprocessorDefinitions += option+3;
1462 break;
1463 case 0x0000339: // /I directory-list
1464 AdditionalIncludeDirectories += option+3;
1465 break;
1466 case 0x0345f96: // /Oicf
1467 case 0x00345f6: // /Oif
1468 GenerateStublessProxies = _True;
1469 break;
1470 case 0x0000345: // /U name
1471 UndefinePreprocessorDefinitions += option+3;
1472 break;
1473 case 0x00034c8: // /WX
1474 WarnAsError = _True;
1475 break;
1476 case 0x3582fde: // /align {N}
1477 offset = 3; // Fallthrough
1478 case 0x0003510: // /Zp {N}
1479 switch ( *(option+offset+4) ) {
1480 case '1':
1481 StructMemberAlignment = ( *(option+offset+5) == '\0' ) ? midlAlignSingleByte : midlAlignSixteenBytes;
1482 break;
1483 case '2':
1484 StructMemberAlignment = midlAlignTwoBytes;
1485 break;
1486 case '4':
1487 StructMemberAlignment = midlAlignFourBytes;
1488 break;
1489 case '8':
1490 StructMemberAlignment = midlAlignEightBytes;
1491 break;
1492 default:
1493 return FALSE;
1494 }
1495 break;
1496 case 0x0359e82: // /char {ascii7|signed|unsigned}
1497 switch( *(option+6) ) {
1498 case 'a':
1499 DefaultCharType = midlCharAscii7;
1500 break;
1501 case 's':
1502 DefaultCharType = midlCharSigned;
1503 break;
1504 case 'u':
1505 DefaultCharType = midlCharUnsigned;
1506 break;
1507 default:
1508 return FALSE;
1509 }
1510 break;
1511 case 0xa766524: // /cpp_opt options
1512 CPreprocessOptions += option+9;
1513 break;
1514 case 0xb32abf1: // /dlldata filename
1515 DLLDataFileName = option + 9;
1516 break;
1517 case 0x0035c56: // /env {win32|win64}
1518 TargetEnvironment = ( *(option+8) == '6' ) ? midlTargetWin64 : midlTargetWin32;
1519 break;
1520 case 0x35c9962: // /error {all|allocation|bounds_check|enum|none|ref|stub_data}
1521 EnableErrorChecks = midlEnableCustom;
1522 switch ( *(option+7) ) {
1523 case 'a':
1524 if ( *(option+10) == '\0' )
1525 EnableErrorChecks = midlEnableAll;
1526 else
1527 ErrorCheckAllocations = _True;
1528 break;
1529 case 'b':
1530 ErrorCheckBounds = _True;
1531 break;
1532 case 'e':
1533 ErrorCheckEnumRange = _True;
1534 break;
1535 case 'n':
1536 EnableErrorChecks = midlDisableAll;
1537 break;
1538 case 'r':
1539 break;
1540 ErrorCheckRefPointers = _True;
1541 case 's':
1542 break;
1543 ErrorCheckStubData = _True;
1544 default:
1545 return FALSE;
1546 }
1547 break;
1548 case 0x5eb7af2: // /header filename
1549 offset = 5;
1550 case 0x0000358: // /h filename
1551 HeaderFileName = option + offset + 3;
1552 break;
1553 case 0x0035ff4: // /iid filename
1554 InterfaceIdentifierFileName = option+5;
1555 break;
1556 case 0x64b7933: // /mktyplib203
1557 MkTypLibCompatible = _True;
1558 break;
1559 case 0x8e0b0a2: // /no_def_idir
1560 IgnoreStandardIncludePath = _True;
1561 break;
1562 case 0x65635ef: // /nologo
1563 SuppressStartupBanner = _True;
1564 break;
1565 case 0x3656b22: // /notlb
1566 GenerateTypeLibrary = _True;
1567 break;
1568 case 0x000035f: // /o filename
1569 RedirectOutputAndErrors = option+3;
1570 break;
1571 case 0x00366c4: // /out directory
1572 OutputDirectory = option+5;
1573 break;
1574 case 0x36796f9: // /proxy filename
1575 ProxyFileName = option+7;
1576 break;
1577 case 0x6959c94: // /robust
1578 ValidateParameters = _True;
1579 break;
1580 case 0x6a88df4: // /target {system}
1581 if ( *(option+11) == '6' )
1582 TargetEnvironment = midlTargetWin64;
1583 else
1584 TargetEnvironment = midlTargetWin32;
1585 break;
1586 case 0x0036b22: // /tlb filename
1587 TypeLibraryName = option+5;
1588 break;
1589 case 0x36e0162: // /win32
1590 TargetEnvironment = midlTargetWin32;
1591 break;
1592 case 0x36e0194: // /win64
1593 TargetEnvironment = midlTargetWin64;
1594 break;
1595 case 0x0003459: // /Oi
1596 case 0x00345f3: // /Oic
1597 case 0x0003463: // /Os
1598 case 0x0003513: // /Zs
1599 case 0x0035796: // /acf filename
1600 case 0x5b1cb97: // /app_config
1601 case 0x3595cf4: // /c_ext
1602 case 0x5a2fc64: // /client {none|stub}
1603 case 0xa64d3dd: // /confirm
1604 case 0xa765b64: // /cpp_cmd cmd_line
1605 case 0x35aabb2: // /cstub filename
1606 case 0x03629f4: // /lcid
1607 case 0x6495cc4: // /ms_ext
1608 case 0x96c7a1e: // /ms_union
1609 case 0x4996fa2: // /msc_ver <nnnn>
1610 case 0x64ceb12: // /newtlb
1611 case 0x6555a40: // /no_cpp
1612 case 0xf64d6a6: // /no_default_epv
1613 case 0x6dd9384: // /no_format_opt
1614 case 0x556dbee: // /no_warn
1615 case 0x3655a70: // /nocpp
1616 case 0x2b455a3: // /oldnames
1617 case 0x662bb12: // /oldtlb
1618 case 0x0036696: // /osf
1619 case 0x036679b: // /pack {N}
1620 case 0x678bd38: // /prefix {all|client|server|switch}
1621 case 0x96b702c: // /protocol {all|dce|ndr64}
1622 case 0x3696aa3: // /rpcss
1623 case 0x698ca60: // /savePP
1624 case 0x69c9cf2: // /server {none|stub}
1625 case 0x36aabb2: // /sstub filename
1626 case 0xce9b12b: // /syntax_check
1627 case 0xc9b5f16: // /use_epv
1628 AdditionalOptions += option;
1629 break;
1630 default:
1631 // /W{0|1|2|3|4} case
1632 if ( *(option+1) == 'W' ) {
1633 switch ( *(option+2) ) {
1634 case '0':
1635 WarningLevel = midlWarningLevel_0;
1636 break;
1637 case '1':
1638 WarningLevel = midlWarningLevel_1;
1639 break;
1640 case '2':
1641 WarningLevel = midlWarningLevel_2;
1642 break;
1643 case '3':
1644 WarningLevel = midlWarningLevel_3;
1645 break;
1646 case '4':
1647 WarningLevel = midlWarningLevel_4;
1648 break;
1649 default:
1650 return FALSE;
1651 }
1652 }
1653 break;
1654 }
1655 return TRUE;
1656}
1657
1658// VCLibrarianTool --------------------------------------------------
1659VCLibrarianTool::VCLibrarianTool()
1660 :IgnoreAllDefaultLibraries( unset ),
1661 SuppressStartupBanner( _True )
1662{
1663}
1664
1665QTextStream &operator<<( QTextStream &strm, const VCLibrarianTool &tool )
1666{
1667 strm << _begTool3;
1668 strm << SPair( _ToolName, QString( "VCLibrarianTool" ) );
1669 strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies );
1670 strm << XPair( _AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories );
1671 strm << XPair( _AdditionalOptions, tool.AdditionalOptions );
1672 strm << XPair( _ExportNamedFunctions, tool.ExportNamedFunctions );
1673 strm << XPair( _ForceSymbolReferences, tool.ForceSymbolReferences );
1674 strm << TPair( _IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries );
1675 strm << XPair( _IgnoreDefaultLibraryNames, tool.IgnoreDefaultLibraryNames );
1676 strm << SPair( _ModuleDefinitionFile, tool.ModuleDefinitionFile );
1677 strm << SPair( _OutputFile, tool.OutputFile );
1678 strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner );
1679 strm << "/>";
1680 return strm;
1681}
1682
1683// VCCustomBuildTool ------------------------------------------------
1684VCCustomBuildTool::VCCustomBuildTool()
1685{
1686 ToolName = "VCCustomBuildTool";
1687}
1688
1689QTextStream &operator<<( QTextStream &strm, const VCCustomBuildTool &tool )
1690{
1691 strm << _begTool3;
1692 strm << SPair( _ToolName, tool.ToolName );
1693 strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies, ";" );
1694 strm << SPair( _CommandLine4, tool.CommandLine );
1695 strm << SPair( _Description4, tool.Description );
1696 strm << SPair( _Outputs4, tool.Outputs );
1697 strm << SPair( _ToolPath, tool.ToolPath );
1698 strm << "/>";
1699 return strm;
1700}
1701
1702// VCResourceCompilerTool -------------------------------------------
1703VCResourceCompilerTool::VCResourceCompilerTool()
1704 : Culture( rcUseDefault ),
1705 IgnoreStandardIncludePath( unset ),
1706 ShowProgress( linkProgressNotSet )
1707{
1708 PreprocessorDefinitions = "NDEBUG";
1709}
1710
1711QTextStream &operator<<( QTextStream &strm, const VCResourceCompilerTool &tool )
1712{
1713 strm << _begTool3;
1714 strm << _VCResourceCompilerToolName;
1715 strm << SPair( _ToolPath, tool.ToolPath );
1716 strm << XPair( _AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories );
1717 strm << XPair( _AdditionalOptions, tool.AdditionalOptions );
1718 if ( tool.Culture != rcUseDefault ) strm << EPair( _Culture, tool.Culture );
1719 strm << XPair( _FullIncludePath, tool.FullIncludePath );
1720 strm << TPair( _IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath );
1721 strm << XPair( _PreprocessorDefinitions, tool.PreprocessorDefinitions );
1722 strm << SPair( _ResourceOutputFileName, tool.ResourceOutputFileName );
1723 if ( tool.ShowProgress != linkProgressNotSet ) strm << EPair( _ShowProgress, tool.ShowProgress );
1724 strm << "/>";
1725 return strm;
1726}
1727
1728// VCEventTool -------------------------------------------------
1729QTextStream &operator<<( QTextStream &strm, const VCEventTool &tool )
1730{
1731 strm << _begTool3;
1732 strm << SPair( _ToolName, tool.ToolName );
1733 strm << SPair( _ToolPath, tool.ToolPath );
1734 strm << SPair( _CommandLine4, tool.CommandLine );
1735 strm << SPair( _Description4, tool.Description );
1736 strm << TPair( _ExcludedFromBuild, tool.ExcludedFromBuild );
1737 strm << "/>";
1738 return strm;
1739}
1740
1741// VCPostBuildEventTool ---------------------------------------------
1742VCPostBuildEventTool::VCPostBuildEventTool()
1743{
1744 ToolName = "VCPostBuildEventTool";
1745}
1746
1747// VCPreBuildEventTool ----------------------------------------------
1748VCPreBuildEventTool::VCPreBuildEventTool()
1749{
1750 ToolName = "VCPreBuildEventTool";
1751}
1752
1753// VCPreLinkEventTool -----------------------------------------------
1754VCPreLinkEventTool::VCPreLinkEventTool()
1755{
1756 ToolName = "VCPreLinkEventTool";
1757}
1758
1759// VCConfiguration --------------------------------------------------
1760
1761VCConfiguration::VCConfiguration()
1762 :ATLMinimizesCRunTimeLibraryUsage( unset ),
1763 BuildBrowserInformation( unset ),
1764 CharacterSet( charSetNotSet ),
1765 ConfigurationType( typeApplication ),
1766 RegisterOutput( unset ),
1767 UseOfATL( useATLNotSet ),
1768 UseOfMfc( useMfcStdWin ),
1769 WholeProgramOptimization( unset )
1770{
1771 compiler.config = this;
1772 linker.config = this;
1773 idl.config = this;
1774}
1775
1776QTextStream &operator<<( QTextStream &strm, const VCConfiguration &tool )
1777{
1778 strm << _begConfiguration;
1779 strm << SPair( _Name3, tool.Name );
1780 strm << SPair( _OutputDirectory3, tool.OutputDirectory );
1781 strm << TPair( _ATLMinimizesCRunTimeLibraryUsage, tool.ATLMinimizesCRunTimeLibraryUsage );
1782 strm << TPair( _BuildBrowserInformation, tool.BuildBrowserInformation );
1783 if ( tool.CharacterSet != charSetNotSet)strm << EPair( _CharacterSet, tool.CharacterSet );
1784 strm << EPair( _ConfigurationType, tool.ConfigurationType );
1785 strm << SPair( _DeleteExtensionsOnClean, tool.DeleteExtensionsOnClean );
1786 strm << SPair( _ImportLibrary, tool.ImportLibrary );
1787 strm << SPair( _IntermediateDirectory, tool.IntermediateDirectory );
1788 strm << SPair( _PrimaryOutput, tool.PrimaryOutput );
1789 strm << SPair( _ProgramDatabase, tool.ProgramDatabase );
1790 strm << TPair( _RegisterOutput, tool.RegisterOutput );
1791 if ( tool.UseOfATL != useATLNotSet) strm << EPair( _UseOfATL, tool.UseOfATL );
1792 strm << EPair( _UseOfMfc, tool.UseOfMfc );
1793 strm << TPair( _WholeProgramOptimization, tool.WholeProgramOptimization );
1794 strm << ">";
1795 strm << tool.compiler;
1796 strm << tool.custom;
1797 if ( tool.ConfigurationType == typeStaticLibrary )
1798 strm << tool.librarian;
1799 else
1800 strm << tool.linker;
1801 strm << tool.idl;
1802 strm << tool.postBuild;
1803 strm << tool.preBuild;
1804 strm << tool.preLink;
1805 strm << tool.resource;
1806 strm << _endConfiguration;
1807 return strm;
1808}
1809// VCFilter ---------------------------------------------------------
1810VCFilter::VCFilter()
1811 : ParseFiles( unset )
1812{
1813}
1814
1815void VCFilter::generateMOC( QTextStream &strm, QString str ) const
1816{
1817 QString mocOutput = Project->findMocDestination( str );
1818 QString mocApp = Project->var( "QMAKE_MOC" );
1819
1820 if( mocOutput.isEmpty() ) {
1821 // In specialcases we DO moc .cpp files
1822 // when the result is an .moc file
1823 if ( !str.endsWith(".moc") )
1824 return;
1825 mocOutput = str;
1826 str = Project->findMocSource( mocOutput );
1827 }
1828
1829 strm << _begFileConfiguration;
1830 strm << _Name5;
1831 strm << Config->Name;
1832 strm << "\">";
1833 strm << _begTool5;
1834 strm << _VCCustomBuildTool;
1835 strm << _Description6;
1836 strm << "Moc'ing " << str << "...\"";
1837 strm << _CommandLine6;
1838 strm << mocApp;
1839 strm << " " << str << " -o " << mocOutput << "\"";
1840 strm << _AdditionalDependencies6;
1841 strm << mocApp << "\"";
1842 strm << _Outputs6;
1843 strm << mocOutput << "\"";
1844 strm << "/>";
1845 strm << _endFileConfiguration;
1846}
1847
1848void VCFilter::generateUIC( QTextStream &strm, const QString& str ) const
1849{
1850 QString uicApp = Project->var("QMAKE_UIC");
1851 QString mocApp = Project->var( "QMAKE_MOC" );
1852 QString fname = str.section( '\\', -1 );
1853 QString mocDir = Project->var( "MOC_DIR" );
1854 int dot = fname.findRev( '.' );
1855 if( dot != -1 )
1856 fname.truncate( dot );
1857
1858 int slash = str.findRev( '\\' );
1859 QString pname = ( slash != -1 ) ? str.left( slash+1 ) : QString(".\\");
1860
1861 strm << _begFileConfiguration;
1862 strm << _Name5;
1863 strm << Config->Name;
1864 strm << "\">";
1865 strm << _begTool5;
1866 strm << _VCCustomBuildTool;
1867 strm << _Description6;
1868 strm << "Uic'ing " << str << "...\"";
1869 strm << _CommandLine6;
1870 strm << uicApp << " " << str << " -o " << pname << 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
1872 strm << mocApp << " " << pname << fname << ".h -o " << mocDir << "moc_" << fname << ".cpp\"";
1873 strm << _AdditionalDependencies6;
1874 strm << mocApp << ";" << uicApp << "\"";
1875 strm << _Outputs6;
1876 strm << pname << fname << ".h;" << pname << fname << ".cpp;" << mocDir << "moc_" << fname << ".cpp\"";
1877 strm << "/>";
1878 strm << _endFileConfiguration;
1879}
1880
1881QTextStream &operator<<( QTextStream &strm, const VCFilter &tool )
1882{
1883 if ( tool.Files.count() == 0 )
1884 return strm;
1885
1886 strm << _begFilter;
1887 strm << SPair( _Name3, tool.Name );
1888 strm << TPair( _ParseFiles, tool.ParseFiles );
1889 strm << SPair( _Filter, tool.Filter );
1890 strm << ">";
1891 for ( QStringList::ConstIterator it = tool.Files.begin(); it != tool.Files.end(); ++it ) {
1892 strm << _begFile;
1893 strm << SPair( _RelativePath, *it );
1894 strm << ">";
1895 if ( tool.CustomBuild == moc )
1896 tool.generateMOC( strm, *it );
1897 else if ( tool.CustomBuild == uic )
1898 tool.generateUIC( strm, *it );
1899 strm << _endFile;
1900 }
1901
1902 strm << _endFilter;
1903 return strm;
1904}
1905
1906// VCProject --------------------------------------------------------
1907VCProject::VCProject()
1908{
1909 QUuid uniqueId;
1910#if defined(Q_WS_WIN32)
1911 GUID guid;
1912 HRESULT h = CoCreateGuid( &guid );
1913 if ( h == S_OK )
1914 uniqueId = QUuid( guid );
1915 ProjectGUID = uniqueId.toString();
1916#else
1917 // Qt doesn't support GUID on other platforms yet
1918 ProjectGUID = "";
1919#endif
1920}
1921
1922QTextStream &operator<<( QTextStream &strm, const VCProject &tool )
1923{
1924 strm << _xmlInit;
1925 strm << _begVisualStudioProject;
1926 strm << _ProjectType;
1927 strm << SPair( _Version1, tool.Version );
1928 strm << SPair( _Name1, tool.Name );
1929 strm << SPair( _ProjectGUID, tool.ProjectGUID );
1930 strm << SPair( _SccProjectName, tool.SccProjectName );
1931 strm << SPair( _SccLocalPath, tool.SccLocalPath );
1932 strm << ">";
1933 strm << _begPlatforms;
1934 strm << _begPlatform;
1935 strm << SPair( _Name3, tool.PlatformName );
1936 strm << "/>";
1937 strm << _endPlatforms;
1938 strm << _begConfigurations;
1939 strm << tool.Configuration;
1940 strm << _endConfigurations;
1941 strm << _begFiles;
1942 strm << tool.SourceFiles;
1943 strm << tool.HeaderFiles;
1944 strm << tool.MOCFiles;
1945 strm << tool.UICFiles;
1946 strm << tool.FormFiles;
1947 strm << tool.TranslationFiles;
1948 strm << tool.LexYaccFiles;
1949 strm << tool.ResourceFiles;
1950 strm << _endFiles;
1951 strm << _begGlobals;
1952 strm << _endGlobals;
1953 strm << _endVisualStudioProject;
1954 return strm;
1955}
diff --git a/qmake/generators/win32/msvc_objectmodel.h b/qmake/generators/win32/msvc_objectmodel.h
new file mode 100644
index 0000000..2d09280
--- a/dev/null
+++ b/qmake/generators/win32/msvc_objectmodel.h
@@ -0,0 +1,775 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Copyright (C) 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 __MSVC_OBJECTMODEL_H__
36#define __MSVC_OBJECTMODEL_H__
37
38#include "project.h"
39#include <qstring.h>
40#include <qstringlist.h>
41
42/*
43 This Object model is of course VERY simplyfied,
44 and does not actually follow the original MSVC
45 object model. However, it fulfilles the basic
46 needs for qmake
47*/
48
49/*
50 If a triState value is 'unset' then the
51 corresponding property is not in the output,
52 forcing the tool to utilize default values.
53 False/True values will be in the output...
54*/
55enum customBuildCheck {
56 none,
57 moc,
58 uic,
59 lexyacc
60};
61enum triState {
62 unset = -1,
63 _False = 0,
64 _True = 1
65};
66enum addressAwarenessType {
67 addrAwareDefault,
68 addrAwareNoLarge,
69 addrAwareLarge
70};
71enum asmListingOption {
72 asmListingNone,
73 asmListingAssemblyOnly,
74 asmListingAsmMachineSrc,
75 asmListingAsmMachine,
76 asmListingAsmSrc
77};
78enum basicRuntimeCheckOption {
79 runtimeBasicCheckNone,
80 runtimeCheckStackFrame,
81 runtimeCheckUninitVariables,
82 runtimeBasicCheckAll
83};
84enum browseInfoOption {
85 brInfoNone,
86 brAllInfo,
87 brNoLocalSymbols
88};
89enum callingConventionOption {
90 callConventionDefault = -1,
91 callConventionCDecl,
92 callConventionFastCall,
93 callConventionStdCall
94};
95enum charSet {
96 charSetNotSet,
97 charSetUnicode,
98 charSetMBCS
99};
100enum compileAsManagedOptions {
101 managedDefault = -1,
102 managedAssembly = 2
103};
104enum CompileAsOptions{
105 compileAsDefault,
106 compileAsC,
107 compileAsCPlusPlus
108};
109enum ConfigurationTypes {
110 typeUnknown = 0,
111 typeApplication = 1,
112 typeDynamicLibrary = 2,
113 typeStaticLibrary = 4,
114 typeGeneric = 10
115};
116enum debugOption {
117 debugDisabled,
118 debugOldStyleInfo,
119 debugLineInfoOnly,
120 debugEnabled,
121 debugEditAndContinue
122};
123enum eAppProtectionOption {
124 eAppProtectUnchanged,
125 eAppProtectLow,
126 eAppProtectMedium,
127 eAppProtectHigh
128};
129enum enumResourceLangID {
130 rcUseDefault = 0,
131 rcAfrikaans = 1078,
132 rcAlbanian = 1052,
133 rcArabicAlgeria = 5121,
134 rcArabicBahrain = 15361,
135 rcArabicEgypt = 3073,
136 rcArabicIraq = 2049,
137 rcArabicJordan = 11265,
138 rcArabicKuwait = 13313,
139 rcArabicLebanon = 12289,
140 rcArabicLibya = 4097,
141 rcArabicMorocco = 6145,
142 rcArabicOman = 8193,
143 rcArabicQatar = 16385,
144 rcArabicSaudi = 1025,
145 rcArabicSyria = 10241,
146 rcArabicTunisia = 7169,
147 rcArabicUnitedArabEmirates= 14337,
148 rcArabicYemen = 9217,
149 rcBasque = 1069,
150 rcBulgarian = 1026,
151 rcByelorussian = 1059,
152 rcCatalan = 1027,
153 rcChineseHongKong = 3076,
154 rcChinesePRC = 2052,
155 rcChineseSingapore = 4100,
156 rcChineseTaiwan = 1028,
157 rcCroatian = 1050,
158 rcCzech = 1029,
159 rcDanish = 1030,
160 rcDutchBelgium = 2067,
161 rcDutchStandard = 1043,
162 rcEnglishAustralia = 3081,
163 rcEnglishBritain = 2057,
164 rcEnglishCanada = 4105,
165 RcEnglishCaribbean = 9225,
166 rcEnglishIreland = 6153,
167 rcEnglishJamaica = 8201,
168 rcEnglishNewZealand = 5129,
169 rcEnglishSouthAfrica= 7177,
170 rcEnglishUS = 1033,
171 rcEstonian = 1061,
172 rcFarsi = 1065,
173 rcFinnish = 1035,
174 rcFrenchBelgium = 2060,
175 rcFrenchCanada = 3084,
176 rcFrenchLuxembourg = 5132,
177 rcFrenchStandard = 1036,
178 rcFrenchSwitzerland = 4108,
179 rcGermanAustria = 3079,
180 rcGermanLichtenstein= 5127,
181 rcGermanLuxembourg = 4103,
182 rcGermanStandard = 1031,
183 rcGermanSwitzerland = 2055,
184 rcGreek = 1032,
185 rcHebrew = 1037,
186 rcHungarian = 1038,
187 rcIcelandic = 1039,
188 rcIndonesian = 1057,
189 rcItalianStandard = 1040,
190 rcItalianSwitzerland= 2064,
191 rcJapanese = 1041,
192 rcKorean = 1042,
193 rcKoreanJohab = 2066,
194 rcLatvian = 1062,
195 rcLithuanian = 1063,
196 rcNorwegianBokmal = 1044,
197 rcNorwegianNynorsk = 2068,
198 rcPolish = 1045,
199 rcPortugueseBrazilian= 1046,
200 rcPortugueseStandard= 2070,
201 rcRomanian = 1048,
202 rcRussian = 1049,
203 rcSerbian = 2074,
204 rcSlovak = 1051,
205 rcSpanishArgentina = 11274,
206 rcSpanishBolivia = 16394,
207 rcSpanishChile = 13322,
208 rcSpanishColombia = 9226,
209 rcSpanishCostaRica = 5130,
210 rcSpanishDominicanRepublic= 7178,
211 rcSpanishEcuador = 12298,
212 rcSpanishGuatemala = 4106,
213 rcSpanishMexico = 2058,
214 rcSpanishModern = 3082,
215 rcSpanishPanama = 6154,
216 rcSpanishParaguay = 15370,
217 rcSpanishPeru = 10250,
218 rcSpanishTraditional= 1034,
219 rcSpanishUruguay = 14346,
220 rcSpanishVenezuela = 8202,
221 rcSwedish = 1053,
222 rcThai = 1054,
223 rcTurkish = 1055,
224 rcUkrainian = 1058,
225 rcUrdu = 1056
226};
227enum enumSccEvent {
228 eProjectInScc,
229 ePreDirtyNotification
230};
231enum favorSizeOrSpeedOption {
232 favorNone,
233 favorSpeed,
234 favorSize
235};
236enum genProxyLanguage {
237 genProxyNative,
238 genProxyManaged
239};
240enum inlineExpansionOption {
241 expandDisable,
242 expandOnlyInline,
243 expandAnySuitable
244};
245enum linkIncrementalType {
246 linkIncrementalDefault,
247 linkIncrementalNo,
248 linkIncrementalYes
249};
250enum linkProgressOption {
251 linkProgressNotSet,
252 linkProgressAll,
253 linkProgressLibs
254};
255enum machineTypeOption {
256 machineNotSet,
257 machineX86
258};
259enum midlCharOption {
260 midlCharUnsigned,
261 midlCharSigned,
262 midlCharAscii7
263};
264enum midlErrorCheckOption {
265 midlEnableCustom,
266 midlDisableAll,
267 midlEnableAll
268};
269enum midlStructMemberAlignOption {
270 midlAlignNotSet,
271 midlAlignSingleByte,
272 midlAlignTwoBytes,
273 midlAlignFourBytes,
274 midlAlignEightBytes,
275 midlAlignSixteenBytes
276};
277enum midlTargetEnvironment {
278 midlTargetNotSet,
279 midlTargetWin32,
280 midlTargetWin64
281};
282enum midlWarningLevelOption {
283 midlWarningLevel_0,
284 midlWarningLevel_1,
285 midlWarningLevel_2,
286 midlWarningLevel_3,
287 midlWarningLevel_4
288};
289enum optFoldingType {
290 optFoldingDefault,
291 optNoFolding,
292 optFolding
293};
294enum optimizeOption {
295 optimizeDisabled,
296 optimizeMinSpace,
297 optimizeMaxSpeed,
298 optimizeFull,
299 optimizeCustom
300};
301enum optRefType {
302 optReferencesDefault,
303 optNoReferences,
304 optReferences
305};
306enum optWin98Type {
307 optWin98Default,
308 optWin98No,
309 optWin98Yes
310};
311enum pchOption {
312 pchNone,
313 pchCreateUsingSpecific,
314 pchGenerateAuto,
315 pchUseUsingSpecific
316};
317enum preprocessOption {
318 preprocessNo,
319 preprocessYes,
320 preprocessNoLineNumbers
321};
322enum ProcessorOptimizeOption {
323 procOptimizeBlended,
324 procOptimizePentium,
325 procOptimizePentiumProAndAbove
326};
327enum RemoteDebuggerType {
328 DbgLocal,
329 DbgRemote,
330 DbgRemoteTCPIP
331};
332enum runtimeLibraryOption {
333 rtMultiThreaded,
334 rtMultiThreadedDebug,
335 rtMultiThreadedDLL,
336 rtMultiThreadedDebugDLL,
337 rtSingleThreaded,
338 rtSingleThreadedDebug
339};
340enum structMemberAlignOption {
341 alignNotSet,
342 alignSingleByte,
343 alignTwoBytes,
344 alignFourBytes,
345 alignEightBytes,
346 alignSixteenBytes
347};
348enum subSystemOption {
349 subSystemNotSet,
350 subSystemConsole,
351 subSystemWindows
352};
353enum termSvrAwarenessType {
354 termSvrAwareDefault,
355 termSvrAwareNo,
356 termSvrAwareYes
357};
358enum toolSetType {
359 toolSetUtility,
360 toolSetMakefile,
361 toolSetLinker,
362 toolSetLibrarian,
363 toolSetAll
364};
365enum TypeOfDebugger {
366 DbgNativeOnly,
367 DbgManagedOnly,
368 DbgMixed,
369 DbgAuto
370};
371enum useOfATL {
372 useATLNotSet,
373 useATLStatic,
374 useATLDynamic
375};
376enum useOfMfc {
377 useMfcStdWin,
378 useMfcStatic,
379 useMfcDynamic
380};
381enum warningLevelOption {
382 warningLevel_0,
383 warningLevel_1,
384 warningLevel_2,
385 warningLevel_3,
386 warningLevel_4
387};
388
389class VCToolBase {
390protected:
391 // Functions
392 VCToolBase(){};
393 ~VCToolBase(){};
394 virtual bool parseOption( const char* option ) = 0;
395public:
396 bool parseOptions( QStringList& options ) {
397 bool result = TRUE;
398 for ( QStringList::ConstIterator it=options.begin(); (it!=options.end()) && result; it++ )
399 result = parseOption( (*it).latin1() );
400 return result;
401 }
402};
403
404class VCConfiguration;
405class VCProject;
406
407class VCCLCompilerTool : public VCToolBase
408{
409public:
410 // Functions
411 VCCLCompilerTool();
412 ~VCCLCompilerTool(){};
413 virtual bool parseOption( const char* option );
414
415 // Variables
416 QStringList AdditionalIncludeDirectories;
417 QStringList AdditionalOptions;
418 QStringList AdditionalUsingDirectories;
419 QString AssemblerListingLocation;
420 asmListingOption AssemblerOutput;
421 basicRuntimeCheckOption BasicRuntimeChecks;
422 browseInfoOption BrowseInformation;
423 QString BrowseInformationFile;
424 triState BufferSecurityCheck;
425 callingConventionOption CallingConvention;
426 CompileAsOptions CompileAs;
427 compileAsManagedOptions CompileAsManaged;
428 triState CompileOnly;
429 debugOption DebugInformationFormat;
430 triState DefaultCharIsUnsigned;
431 triState Detect64BitPortabilityProblems;
432 triState DisableLanguageExtensions;
433 QStringList DisableSpecificWarnings;
434 triState EnableFiberSafeOptimizations;
435 triState EnableFunctionLevelLinking;
436 triState EnableIntrinsicFunctions;
437 triState ExceptionHandling;
438 triState ExpandAttributedSource;
439 favorSizeOrSpeedOption FavorSizeOrSpeed;
440 triState ForceConformanceInForLoopScope;
441 QStringList ForcedIncludeFiles;
442 QStringList ForcedUsingFiles;
443 preprocessOption GeneratePreprocessedFile;
444 triState GlobalOptimizations;
445 triState IgnoreStandardIncludePath;
446 triState ImproveFloatingPointConsistency;
447 inlineExpansionOption InlineFunctionExpansion;
448 triState KeepComments;
449 triState MinimalRebuild;
450 QString ObjectFile;
451 triState OmitFramePointers;
452 optimizeOption Optimization;
453 ProcessorOptimizeOption OptimizeForProcessor;
454 triState OptimizeForWindowsApplication;
455 QString OutputFile;
456 QString PrecompiledHeaderFile;
457 QString PrecompiledHeaderThrough;
458 QStringList PreprocessorDefinitions;
459 QString ProgramDataBaseFileName;
460 runtimeLibraryOption RuntimeLibrary;
461 triState RuntimeTypeInfo;
462 triState ShowIncludes;
463 triState SmallerTypeCheck;
464 triState StringPooling;
465 structMemberAlignOption StructMemberAlignment;
466 triState SuppressStartupBanner;
467 triState TreatWChar_tAsBuiltInType;
468 triState TurnOffAssemblyGeneration;
469 triState UndefineAllPreprocessorDefinitions;
470 QStringList UndefinePreprocessorDefinitions;
471 pchOption UsePrecompiledHeader;
472 triState WarnAsError;
473 warningLevelOption WarningLevel;
474 triState WholeProgramOptimization;
475 VCConfiguration* config;
476};
477
478class VCLinkerTool : public VCToolBase
479{
480public:
481 // Functions
482 VCLinkerTool();
483 ~VCLinkerTool(){};
484 virtual bool parseOption( const char* option );
485
486 // Variables
487 QStringList AdditionalDependencies;
488 QStringList AdditionalLibraryDirectories;
489 QStringList AdditionalOptions;
490 QStringList AddModuleNamesToAssembly;
491 QString BaseAddress;
492 QStringList DelayLoadDLLs;
493 optFoldingType EnableCOMDATFolding;
494 QString EntryPointSymbol;
495 QStringList ForceSymbolReferences;
496 QString FunctionOrder;
497 triState GenerateDebugInformation;
498 triState GenerateMapFile;
499 long HeapCommitSize;
500 long HeapReserveSize;
501 triState IgnoreAllDefaultLibraries;
502 QStringList IgnoreDefaultLibraryNames;
503 triState IgnoreEmbeddedIDL;
504 triState IgnoreImportLibrary;
505 QString ImportLibrary;
506 addressAwarenessType LargeAddressAware;
507 triState LinkDLL;
508 linkIncrementalType LinkIncremental;
509 triState LinkTimeCodeGeneration;
510 QString LinkToManagedResourceFile;
511 triState MapExports;
512 QString MapFileName;
513 triState MapLines;
514 QString MergedIDLBaseFileName;
515 QString MergeSections; // Should be list?
516 QString MidlCommandFile;
517 QString ModuleDefinitionFile; // Should be list?
518 optWin98Type OptimizeForWindows98;
519 optRefType OptimizeReferences;
520 QString OutputFile;
521 QString ProgramDatabaseFile;
522 triState RegisterOutput;
523 triState ResourceOnlyDLL;
524 triState SetChecksum;
525 linkProgressOption ShowProgress;
526 long StackCommitSize;
527 long StackReserveSize;
528 QString StripPrivateSymbols; // Should be list?
529 subSystemOption SubSystem;
530 triState SupportUnloadOfDelayLoadedDLL;
531 triState SuppressStartupBanner;
532 triState SwapRunFromCD;
533 triState SwapRunFromNet;
534 machineTypeOption TargetMachine;
535 termSvrAwarenessType TerminalServerAware;
536 triState TurnOffAssemblyGeneration;
537 QString TypeLibraryFile;
538 long TypeLibraryResourceID;
539 QString Version;
540 VCConfiguration* config;
541};
542
543class VCMIDLTool : public VCToolBase
544{
545public:
546 // Functions
547 VCMIDLTool();
548 ~VCMIDLTool(){};
549 virtual bool parseOption( const char* option );
550
551 // Variables
552 QStringList AdditionalIncludeDirectories;
553 QStringList AdditionalOptions;
554 QStringList CPreprocessOptions;
555 midlCharOption DefaultCharType;
556 QString DLLDataFileName; // Should be list?
557 midlErrorCheckOption EnableErrorChecks;
558 triState ErrorCheckAllocations;
559 triState ErrorCheckBounds;
560 triState ErrorCheckEnumRange;
561 triState ErrorCheckRefPointers;
562 triState ErrorCheckStubData;
563 QStringList FullIncludePath;
564 triState GenerateStublessProxies;
565 triState GenerateTypeLibrary;
566 QString HeaderFileName;
567 triState IgnoreStandardIncludePath;
568 QString InterfaceIdentifierFileName;
569 triState MkTypLibCompatible;
570 QString OutputDirectory;
571 QStringList PreprocessorDefinitions;
572 QString ProxyFileName;
573 QString RedirectOutputAndErrors;
574 midlStructMemberAlignOption StructMemberAlignment;
575 triState SuppressStartupBanner;
576 midlTargetEnvironment TargetEnvironment;
577 QString TypeLibraryName;
578 QStringList UndefinePreprocessorDefinitions;
579 triState ValidateParameters;
580 triState WarnAsError;
581 midlWarningLevelOption WarningLevel;
582 VCConfiguration* config;
583};
584
585class VCLibrarianTool : public VCToolBase
586{
587public:
588 // Functions
589 VCLibrarianTool();
590 ~VCLibrarianTool(){};
591 virtual bool parseOption( const char* option ){ return FALSE; };
592
593 // Variables
594 QStringList AdditionalDependencies;
595 QStringList AdditionalLibraryDirectories;
596 QStringList AdditionalOptions;
597 QStringList ExportNamedFunctions;
598 QStringList ForceSymbolReferences;
599 triState IgnoreAllDefaultLibraries;
600 QStringList IgnoreDefaultLibraryNames;
601 QString ModuleDefinitionFile;
602 QString OutputFile;
603 triState SuppressStartupBanner;
604};
605
606class VCCustomBuildTool : public VCToolBase
607{
608public:
609 // Functions
610 VCCustomBuildTool();
611 ~VCCustomBuildTool(){};
612 virtual bool parseOption( const char* option ){ return FALSE; };
613
614 // Variables
615 QStringList AdditionalDependencies;
616 QString CommandLine;
617 QString Description;
618 QString Outputs;
619 QString ToolName;
620 QString ToolPath;
621};
622
623class VCResourceCompilerTool : public VCToolBase
624{
625public:
626 // Functions
627 VCResourceCompilerTool();
628 ~VCResourceCompilerTool(){};
629 virtual bool parseOption( const char* option ){ return FALSE; };
630
631 // Variables
632 QStringList AdditionalIncludeDirectories;
633 QStringList AdditionalOptions;
634 enumResourceLangID Culture;
635 QStringList FullIncludePath;
636 triState IgnoreStandardIncludePath;
637 QStringList PreprocessorDefinitions;
638 QString ResourceOutputFileName;
639 linkProgressOption ShowProgress;
640 QString ToolPath;
641};
642
643class VCEventTool : public VCToolBase
644{
645protected:
646 // Functions
647 VCEventTool() : ExcludedFromBuild( unset ){};
648 ~VCEventTool(){};
649 virtual bool parseOption( const char* option ){ return FALSE; };
650
651public:
652 // Variables
653 QString CommandLine;
654 QString Description;
655 triState ExcludedFromBuild;
656 QString ToolName;
657 QString ToolPath;
658};
659
660class VCPostBuildEventTool : public VCEventTool
661{
662public:
663 VCPostBuildEventTool();
664 ~VCPostBuildEventTool(){};
665};
666
667class VCPreBuildEventTool : public VCEventTool
668{
669public:
670 VCPreBuildEventTool();
671 ~VCPreBuildEventTool(){};
672};
673
674class VCPreLinkEventTool : public VCEventTool
675{
676public:
677 VCPreLinkEventTool();
678 ~VCPreLinkEventTool(){};
679};
680
681class VCConfiguration
682{
683public:
684 // Functions
685 VCConfiguration();
686 ~VCConfiguration(){};
687
688 // Variables
689 triState ATLMinimizesCRunTimeLibraryUsage;
690 triState BuildBrowserInformation;
691 charSet CharacterSet;
692 ConfigurationTypesConfigurationType;
693 QString DeleteExtensionsOnClean;
694 QString ImportLibrary;
695 QString IntermediateDirectory;
696 QString Name;
697 QString OutputDirectory;
698 QString PrimaryOutput;
699 QString ProgramDatabase;
700 triState RegisterOutput;
701 useOfATL UseOfATL;
702 useOfMfc UseOfMfc;
703 triState WholeProgramOptimization;
704
705 // XML sub-parts
706 VCCLCompilerTool compiler;
707 VCLinkerTool linker;
708 VCLibrarianTool librarian;
709 VCCustomBuildTool custom;
710 VCMIDLTool idl;
711 VCPostBuildEventTool postBuild;
712 VCPreBuildEventTool preBuild;
713 VCPreLinkEventTool preLink;
714 VCResourceCompilerTool resource;
715};
716
717class VcprojGenerator;
718class VCFilter
719{
720public:
721 // Functions
722 VCFilter();
723 ~VCFilter(){};
724 void generateMOC( QTextStream &strm, QString str ) const;
725 void generateUIC( QTextStream &strm, const QString& str ) const;
726
727 // Variables
728 QString Name;
729 QString Filter;
730 triState ParseFiles;
731 QStringList Files;
732 VcprojGenerator*Project;
733 VCConfiguration*Config;
734 customBuildCheckCustomBuild;
735};
736
737class VCProject
738{
739public:
740 // Functions
741 VCProject();
742 ~VCProject(){};
743
744 // Variables
745 QString Name;
746 QString Version;
747 QString ProjectGUID;
748 QString SccProjectName;
749 QString SccLocalPath;
750 QString PlatformName;
751
752 // XML sub-parts
753 VCConfigurationConfiguration;
754 VCFilter SourceFiles;
755 VCFilter HeaderFiles;
756 VCFilter MOCFiles;
757 VCFilter UICFiles;
758 VCFilter FormFiles;
759 VCFilter TranslationFiles;
760 VCFilter LexYaccFiles;
761 VCFilter ResourceFiles;
762};
763
764QTextStream &operator<<( QTextStream &, const VCCLCompilerTool & );
765QTextStream &operator<<( QTextStream &, const VCLinkerTool & );
766QTextStream &operator<<( QTextStream &, const VCMIDLTool & );
767QTextStream &operator<<( QTextStream &, const VCCustomBuildTool & );
768QTextStream &operator<<( QTextStream &, const VCLibrarianTool & );
769QTextStream &operator<<( QTextStream &, const VCResourceCompilerTool & );
770QTextStream &operator<<( QTextStream &, const VCEventTool & );
771QTextStream &operator<<( QTextStream &, const VCConfiguration & );
772QTextStream &operator<<( QTextStream &, const VCFilter & );
773QTextStream &operator<<( QTextStream &, const VCProject & );
774
775#endif //__MSVC_OBJECTMODEL_H__
diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp
new file mode 100644
index 0000000..a2bb6e9
--- a/dev/null
+++ b/qmake/generators/win32/msvc_vcproj.cpp
@@ -0,0 +1,1050 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of VcprojGenerator class.
5**
6** Created : 970521
7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9**
10** This file is part of the network module of the Qt GUI Toolkit.
11**
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
14** LICENSE.QPL included in the packaging of this file.
15**
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
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software.
24**
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.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38#include "msvc_vcproj.h"
39#include "option.h"
40#include <qdir.h>
41#include <stdlib.h>
42#include <qregexp.h>
43
44#if defined(Q_OS_WIN32)
45#include <objbase.h>
46#endif
47
48VcprojGenerator::VcprojGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE)
49{
50}
51
52/* \internal
53 Generates a project file for the given profile.
54 Options are either a Visual Studio projectfiles, or
55 recursive projectfiles.. Maybe we can make .sln files
56 someday?
57*/
58bool VcprojGenerator::writeMakefile(QTextStream &t)
59{
60 // Check if all requirements are fullfilled
61 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {
62 fprintf(stderr, "Project file not generated because all requirements not met:\n\t%s\n",
63 var("QMAKE_FAILED_REQUIREMENTS").latin1());
64 return TRUE;
65 }
66
67 // Generate full project file
68 if(project->first("TEMPLATE") == "vcapp" ||
69 project->first("TEMPLATE") == "vclib") {
70 debug_msg(1, "Generator: MSVC.NET: Writing project file" );
71 t << vcProject;
72 return TRUE;
73 } else if(project->first("TEMPLATE") == "vcsubdirs") { // Generate recursive project
74 debug_msg(1, "Generator: MSVC.NET: Writing solution file" );
75 writeSubDirs(t);
76 return TRUE;
77 }
78 return FALSE;
79
80}
81
82struct VcsolutionDepend {
83 QString vcprojFile, orig_target, target;
84 QStringList dependencies;
85};
86
87void VcprojGenerator::writeSubDirs(QTextStream &t)
88{
89 if(project->first("TEMPLATE") == "subdirs") {
90 writeHeader(t);
91 Win32MakefileGenerator::writeSubDirs(t);
92 return;
93 }
94
95 QPtrList<VcsolutionDepend> solution_depends;
96 solution_depends.setAutoDelete(TRUE);
97 QStringList subdirs = project->variables()["SUBDIRS"];
98 QString oldpwd = QDir::currentDirPath();
99 for(QStringList::Iterator it = subdirs.begin(); it != subdirs.end(); ++it) {
100 QFileInfo fi(Option::fixPathToLocalOS((*it), TRUE));
101 if(fi.exists()) {
102 if(fi.isDir()) {
103 QString profile = (*it);
104 if(!profile.endsWith(Option::dir_sep))
105 profile += Option::dir_sep;
106 profile += fi.baseName() + ".pro";
107 subdirs.append(profile);
108 } else {
109 QMakeProject tmp_proj;
110 QString dir = fi.dirPath(), fn = fi.fileName();
111 if(!dir.isEmpty()) {
112 if(!QDir::setCurrent(dir))
113 fprintf(stderr, "Cannot find directory: %s\n", dir.latin1());
114 }
115 if(tmp_proj.read(fn, oldpwd)) {
116 if(tmp_proj.first("TEMPLATE") == "vcsubdirs") {
117 QStringList tmp_subdirs = fileFixify(tmp_proj.variables()["SUBDIRS"]);
118 subdirs += tmp_subdirs;
119 } else if(tmp_proj.first("TEMPLATE") == "vcapp" ||
120 tmp_proj.first("TEMPLATE") == "vclib") {
121 QString vcproj = fi.baseName() + project->first("VCPROJ_EXTENSION");
122 if(QFile::exists(vcproj) || 1) {
123 VcprojGenerator tmp_dsp(&tmp_proj);
124 tmp_dsp.setNoIO(TRUE);
125 tmp_dsp.init();
126 if(Option::debug_level) {
127 QMap<QString, QStringList> &vars = tmp_proj.variables();
128 for(QMap<QString, QStringList>::Iterator it = vars.begin();
129 it != vars.end(); ++it) {
130 if(it.key().left(1) != "." && !it.data().isEmpty())
131 debug_msg(1, "%s: %s === %s", fn.latin1(), it.key().latin1(),
132 it.data().join(" :: ").latin1());
133 }
134 }
135 VcsolutionDepend *newDep = new VcsolutionDepend;
136 newDep->vcprojFile = fileFixify(vcproj);
137 newDep->orig_target = tmp_proj.first("QMAKE_ORIG_TARGET");
138 newDep->target = tmp_proj.first("TARGET").section(Option::dir_sep, -1);
139 if(newDep->target.endsWith(".dll"))
140 newDep->target = newDep->target.left(newDep->target.length()-3) + "lib";
141 if(!tmp_proj.isEmpty("FORMS"))
142 newDep->dependencies << "uic.exe";
143 {
144 QStringList where("QMAKE_LIBS");
145 if(!tmp_proj.isEmpty("QMAKE_INTERNAL_PRL_LIBS"))
146 where = tmp_proj.variables()["QMAKE_INTERNAL_PRL_LIBS"];
147 for(QStringList::iterator wit = where.begin();
148 wit != where.end(); ++wit) {
149 QStringList &l = tmp_proj.variables()[(*wit)];
150 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
151 QString opt = (*it);
152 if(!opt.startsWith("/")) //Not a switch
153 newDep->dependencies << opt.section(Option::dir_sep, -1);
154 }
155 }
156 }
157 solution_depends.append(newDep);
158 }
159 }
160 }
161 QDir::setCurrent(oldpwd);
162 }
163 }
164 }
165
166 VcsolutionDepend *vc;
167 QMap<QString, int> uuids;
168 QRegExp libVersion("[0-9]{3,3}\\.lib$");
169 for(vc = solution_depends.first(); vc; vc = solution_depends.next()) {
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 }
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 }
184 }
185}
186
187// ------------------------------------------------------------------------------------------------
188// ------------------------------------------------------------------------------------------------
189
190void VcprojGenerator::init()
191{
192 if( init_flag )
193 return;
194 if(project->first("TEMPLATE") == "vcsubdirs") { //too much work for subdirs
195 init_flag = TRUE;
196 return;
197 }
198
199 debug_msg(1, "Generator: MSVC.NET: Initializing variables" );
200
201/*
202 // Once to be nice and clean code...
203 // Wouldn't life be great?
204
205 // Are we building Qt?
206 bool is_qt =
207 ( project->first("TARGET") == "qt"QTDLL_POSTFIX ||
208 project->first("TARGET") == "qt-mt"QTDLL_POSTFIX );
209
210 // Are we using Qt?
211 bool isQtActive = project->isActiveConfig("qt");
212
213 if ( isQtActive ) {
214 project->variables()["CONFIG"] += "moc";
215 project->variables()["CONFIG"] += "windows";
216 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QT"];
217 project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"];
218
219 if( projectTarget == SharedLib )
220 project->variables()["DEFINES"] += "QT_DLL";
221
222 if( project->isActiveConfig("accessibility" ) )
223 project->variables()["DEFINES"] += "QT_ACCESSIBILITY_SUPPORT";
224
225 if ( project->isActiveConfig("plugin")) {
226 project->variables()["DEFINES"] += "QT_PLUGIN";
227 project->variables()["CONFIG"] += "dll";
228 }
229
230 if( project->isActiveConfig("thread") ) {
231 project->variables()["DEFINES"] += "QT_THREAD_SUPPORT";
232 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"];
233 } else {
234 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"];
235 }
236 }
237
238 if ( project->isActiveConfig("opengl") ) {
239 project->variables()["CONFIG"] += "windows"; // <-- Also in 'qt' above
240 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"];
241 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"];
242
243 }
244*/
245 initOld(); // Currently calling old DSP code to set variables. CLEAN UP!
246
247 // Figure out what we're trying to build
248 if ( project->first("TEMPLATE") == "vcapp" ) {
249 projectTarget = Application;
250 } else if ( project->first("TEMPLATE") == "vclib") {
251 if ( project->isActiveConfig( "staticlib" ) )
252 projectTarget = StaticLib;
253 else
254 projectTarget = SharedLib;
255 }
256 initProject(); // Fills the whole project with proper data
257}
258
259void VcprojGenerator::initProject()
260{
261 // Initialize XML sub elements
262 // - Do this first since project elements may need
263 // - to know of certain configuration options
264 initConfiguration();
265 initSourceFiles();
266 initHeaderFiles();
267 initMOCFiles();
268 initUICFiles();
269 initFormsFiles();
270 initTranslationFiles();
271 initLexYaccFiles();
272 initResourceFiles();
273
274 // Own elements -----------------------------
275 vcProject.Name = project->first("QMAKE_ORIG_TARGET");
276 vcProject.Version = "7.00";
277 vcProject.PlatformName = ( vcProject.Configuration.idl.TargetEnvironment == midlTargetWin64 ? "Win64" : "Win32" );
278 // These are not used by Qt, but may be used by customers
279 vcProject.SccProjectName = project->first("SCCPROJECTNAME");
280 vcProject.SccLocalPath = project->first("SCCLOCALPATH");
281}
282
283void VcprojGenerator::initConfiguration()
284{
285 // Initialize XML sub elements
286 // - Do this first since main configuration elements may need
287 // - to know of certain compiler/linker options
288 initCompilerTool();
289 if ( projectTarget == StaticLib )
290 initLibrarianTool();
291 else
292 initLinkerTool();
293 initIDLTool();
294
295 // Own elements -----------------------------
296 QString temp = project->first("BuildBrowserInformation");
297 switch ( projectTarget ) {
298 case SharedLib:
299 vcProject.Configuration.ConfigurationType = typeDynamicLibrary;
300 break;
301 case StaticLib:
302 vcProject.Configuration.ConfigurationType = typeStaticLibrary;
303 break;
304 case Application:
305 default:
306 vcProject.Configuration.ConfigurationType = typeApplication;
307 break;
308 }
309 vcProject.Configuration.Name = ( project->isActiveConfig( "release" ) ? "Release|" : "Debug|" );
310 vcProject.Configuration.Name += ( vcProject.Configuration.idl.TargetEnvironment == midlTargetWin64 ? "Win64" : "Win32" );
311 vcProject.Configuration.ATLMinimizesCRunTimeLibraryUsage = ( project->first("ATLMinimizesCRunTimeLibraryUsage").isEmpty() ? _False : _True );
312 vcProject.Configuration.BuildBrowserInformation = triState( temp.isEmpty() ? unset : temp.toShort() );
313 temp = project->first("CharacterSet");
314 vcProject.Configuration.CharacterSet = charSet( temp.isEmpty() ? charSetNotSet : temp.toShort() );
315 vcProject.Configuration.DeleteExtensionsOnClean = project->first("DeleteExtensionsOnClean");
316 vcProject.Configuration.ImportLibrary = vcProject.Configuration.linker.ImportLibrary;
317 vcProject.Configuration.IntermediateDirectory = project->first("OBJECTS_DIR");
318// temp = (projectTarget == StaticLib) ? project->first("DESTDIR"):project->first("DLLDESTDIR");
319 vcProject.Configuration.OutputDirectory = "."; //( temp.isEmpty() ? QString(".") : temp );
320 vcProject.Configuration.PrimaryOutput = project->first("PrimaryOutput");
321 vcProject.Configuration.WholeProgramOptimization = vcProject.Configuration.compiler.WholeProgramOptimization;
322 temp = project->first("UseOfATL");
323 if ( !temp.isEmpty() )
324 vcProject.Configuration.UseOfATL = useOfATL( temp.toShort() );
325 temp = project->first("UseOfMfc");
326 if ( !temp.isEmpty() )
327 vcProject.Configuration.UseOfMfc = useOfMfc( temp.toShort() );
328
329 // Configuration does not need parameters from
330 // these sub XML items;
331 initCustomBuildTool();
332 initPreBuildEventTools();
333 initPostBuildEventTools();
334 initPreLinkEventTools();
335}
336
337void VcprojGenerator::initCompilerTool()
338{
339 QString placement = project->first("OBJECTS_DIR");
340 if ( placement.isEmpty() )
341 placement = project->isActiveConfig( "release" )? ".\\Release\\":".\\Debug\\";
342
343 vcProject.Configuration.compiler.AssemblerListingLocation = placement ;
344 vcProject.Configuration.compiler.ProgramDataBaseFileName = placement ;
345 vcProject.Configuration.compiler.ObjectFile = placement ;
346 vcProject.Configuration.compiler.PrecompiledHeaderFile = placement + project->first("QMAKE_ORIG_TARGET") + ".pch";
347
348 if ( project->isActiveConfig("debug") ){
349 // Debug version
350 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS"] );
351 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_DEBUG"] );
352 if ( project->isActiveConfig("thread") ) {
353 if ( (projectTarget == Application) || (projectTarget == StaticLib) )
354 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DBG"] );
355 else
356 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"] );
357 } else {
358 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_ST_DBG"] );
359 }
360 } else {
361 // Release version
362 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS"] );
363 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_RELEASE"] );
364 vcProject.Configuration.compiler.PreprocessorDefinitions += "QT_NO_DEBUG";
365 if ( project->isActiveConfig("thread") ) {
366 if ( (projectTarget == Application) || (projectTarget == StaticLib) )
367 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT"] );
368 else
369 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DLL"] );
370 } else {
371 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_ST"] );
372 }
373 }
374
375 // Common for both release and debug
376 if ( project->isActiveConfig("warn_off") )
377 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_OFF"] );
378 else
379 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_ON"] );
380 if ( project->isActiveConfig("windows") )
381 vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["MSVCPROJ_WINCONDEF"];
382
383 // Can this be set for ALL configs?
384 // If so, use qmake.conf!
385 if ( projectTarget == SharedLib )
386 vcProject.Configuration.compiler.PreprocessorDefinitions += "_WINDOWS";
387
388 vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["DEFINES"];
389 vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["PRL_EXPORT_DEFINES"];
390 vcProject.Configuration.compiler.parseOptions( project->variables()["MSVCPROJ_INCPATH"] );
391}
392
393void VcprojGenerator::initLibrarianTool()
394{
395 vcProject.Configuration.librarian.OutputFile = project->first( "DESTDIR" );
396 if( vcProject.Configuration.librarian.OutputFile.isEmpty() )
397 vcProject.Configuration.librarian.OutputFile = ".\\";
398
399 if( !vcProject.Configuration.librarian.OutputFile.endsWith("\\") )
400 vcProject.Configuration.librarian.OutputFile += '\\';
401
402 vcProject.Configuration.librarian.OutputFile += project->first("MSVCPROJ_TARGET");
403}
404
405void VcprojGenerator::initLinkerTool()
406{
407 vcProject.Configuration.linker.parseOptions( project->variables()["MSVCPROJ_LFLAGS"] );
408 vcProject.Configuration.linker.AdditionalDependencies += project->variables()["MSVCPROJ_LIBS"];
409
410 switch ( projectTarget ) {
411 case Application:
412 vcProject.Configuration.linker.OutputFile = project->first( "DESTDIR" );
413 break;
414 case SharedLib:
415 vcProject.Configuration.linker.parseOptions( project->variables()["MSVCPROJ_LIBOPTIONS"] );
416 vcProject.Configuration.linker.OutputFile = project->first( "DLLDESTDIR" );
417 break;
418 }
419
420 if( vcProject.Configuration.linker.OutputFile.isEmpty() )
421 vcProject.Configuration.linker.OutputFile = ".\\";
422
423 if( !vcProject.Configuration.linker.OutputFile.endsWith("\\") )
424 vcProject.Configuration.linker.OutputFile += '\\';
425
426 vcProject.Configuration.linker.OutputFile += project->first("MSVCPROJ_TARGET");
427 vcProject.Configuration.linker.ProgramDatabaseFile = project->first("OBJECTS_DIR") + project->first("QMAKE_ORIG_TARGET") + ".pdb";
428
429 if ( project->isActiveConfig("debug") ){
430 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_DEBUG"] );
431 } else {
432 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_RELEASE"] );
433 }
434
435 if ( project->isActiveConfig("dll") ){
436 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_QT_DLL"] );
437 }
438
439 if ( project->isActiveConfig("console") ){
440 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_CONSOLE"] );
441 } else {
442 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_WINDOWS"] );
443 }
444
445}
446
447void VcprojGenerator::initIDLTool()
448{
449}
450
451void VcprojGenerator::initCustomBuildTool()
452{
453}
454
455void VcprojGenerator::initPreBuildEventTools()
456{
457 QString collectionName = project->first("QMAKE_IMAGE_COLLECTION");
458 if( !collectionName.isEmpty() ) {
459 QStringList& list = project->variables()["IMAGES"];
460 vcProject.Configuration.preBuild.Description = "Generate imagecollection";
461 //vcProject.Configuration.preBuild.AdditionalDependencies += list;
462 vcProject.Configuration.preBuild.CommandLine = project->first("QMAKE_UIC") + " -embed " + project->first("QMAKE_ORIG_TARGET") + " " + list.join(" ") + " -o " + collectionName;
463 //vcProject.Configuration.preBuild.Outputs = collectionName;
464
465 }
466}
467
468void VcprojGenerator::initPostBuildEventTools()
469{
470 if( project->isActiveConfig( "activeqt" ) ) {
471 QString name = project->first( "QMAKE_ORIG_TARGET" );
472 QString nameext = project->first( "TARGET" );
473 QString objdir = project->first( "OBJECTS_DIR" );
474 QString idc = project->first( "QMAKE_IDC" );
475
476 vcProject.Configuration.postBuild.Description = "Finalizing ActiveQt server...";
477
478 if( project->isActiveConfig( "dll" ) ) { // In process
479 vcProject.Configuration.postBuild.CommandLine =
480 // call idc to generate .idl file from .dll
481 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " -idl " + objdir + name + ".idl -version 1.0 &amp;&amp; " +
482 // 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 +
484 "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; " +
486 // call idc to replace tlb...
487 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /tlb " + objdir + name + ".tlb &amp;&amp; " +
488 // register server
489 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /regserver";
490 } else { // out of process
491 vcProject.Configuration.postBuild.CommandLine =
492 // call application to dump idl
493 vcProject.Configuration.OutputDirectory + "\\" + nameext + " -dumpidl " + objdir + name + ".idl -version 1.0 &amp;&amp; " +
494 // 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 +
496 "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; " +
498 // call idc to replace tlb...
499 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /tlb " + objdir + name + ".tlb &amp;&amp; " +
500 // call app to register
501 vcProject.Configuration.OutputDirectory + "\\" + nameext + " -regserver";
502 }
503 }
504}
505
506void VcprojGenerator::initPreLinkEventTools()
507{
508}
509
510void VcprojGenerator::initSourceFiles()
511{
512 vcProject.SourceFiles.Name = "Source Files";
513 vcProject.SourceFiles.Filter = "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat";
514 vcProject.SourceFiles.Files += project->variables()["SOURCES"];
515 vcProject.SourceFiles.Files.sort();
516 vcProject.SourceFiles.Project = this;
517 vcProject.SourceFiles.Config = &(vcProject.Configuration);
518 vcProject.SourceFiles.CustomBuild = none;
519}
520
521void VcprojGenerator::initHeaderFiles()
522{
523 vcProject.HeaderFiles.Name = "Header Files";
524 vcProject.HeaderFiles.Filter = "h;hpp;hxx;hm;inl";
525 vcProject.HeaderFiles.Files += project->variables()["HEADERS"];
526 vcProject.HeaderFiles.Files.sort();
527 vcProject.HeaderFiles.Project = this;
528 vcProject.HeaderFiles.Config = &(vcProject.Configuration);
529 vcProject.HeaderFiles.CustomBuild = moc;
530}
531
532void VcprojGenerator::initMOCFiles()
533{
534 vcProject.MOCFiles.Name = "Generated MOC Files";
535 vcProject.MOCFiles.Filter = "cpp;c;cxx;moc";
536 vcProject.MOCFiles.Files += project->variables()["SRCMOC"];
537 vcProject.MOCFiles.Files.sort();
538 vcProject.MOCFiles.Project = this;
539 vcProject.MOCFiles.Config = &(vcProject.Configuration);
540 vcProject.MOCFiles.CustomBuild = moc;
541}
542
543void VcprojGenerator::initUICFiles()
544{
545 vcProject.UICFiles.Name = "Generated UI Files";
546 vcProject.UICFiles.Filter = "cpp;c;cxx;h;hpp;hxx;";
547 vcProject.UICFiles.Project = this;
548 vcProject.UICFiles.Files += project->variables()["UICDECLS"];
549 vcProject.UICFiles.Files += project->variables()["UICIMPLS"];
550 vcProject.UICFiles.Files.sort();
551 vcProject.UICFiles.Config = &(vcProject.Configuration);
552 vcProject.UICFiles.CustomBuild = none;
553}
554
555void VcprojGenerator::initFormsFiles()
556{
557 vcProject.FormFiles.Name = "Forms";
558 vcProject.FormFiles.ParseFiles = _False;
559 vcProject.FormFiles.Filter = "ui";
560 vcProject.FormFiles.Files += project->variables()["FORMS"];
561 vcProject.FormFiles.Files.sort();
562 vcProject.FormFiles.Project = this;
563 vcProject.FormFiles.Config = &(vcProject.Configuration);
564 vcProject.FormFiles.CustomBuild = uic;
565}
566
567void VcprojGenerator::initTranslationFiles()
568{
569 vcProject.TranslationFiles.Name = "Translations Files";
570 vcProject.TranslationFiles.ParseFiles = _False;
571 vcProject.TranslationFiles.Filter = "ts";
572 vcProject.TranslationFiles.Files += project->variables()["TRANSLATIONS"];
573 vcProject.TranslationFiles.Files.sort();
574 vcProject.TranslationFiles.Project = this;
575 vcProject.TranslationFiles.Config = &(vcProject.Configuration);
576 vcProject.TranslationFiles.CustomBuild = none;
577}
578
579void VcprojGenerator::initLexYaccFiles()
580{
581 vcProject.LexYaccFiles.Name = "Lex / Yacc Files";
582 vcProject.LexYaccFiles.ParseFiles = _False;
583 vcProject.LexYaccFiles.Filter = "l;y";
584 vcProject.LexYaccFiles.Files += project->variables()["LEXSOURCES"];
585 vcProject.LexYaccFiles.Files += project->variables()["YACCSOURCES"];
586 vcProject.LexYaccFiles.Files.sort();
587 vcProject.LexYaccFiles.Project = this;
588 vcProject.LexYaccFiles.CustomBuild = lexyacc;
589}
590
591void VcprojGenerator::initResourceFiles()
592{
593 vcProject.ResourceFiles.Name = "Resources";
594 vcProject.ResourceFiles.ParseFiles = _False;
595 vcProject.ResourceFiles.Filter = "cpp;ico;png;jpg;jpeg;gif;xpm;bmp;rc;ts";
596 vcProject.ResourceFiles.Files += project->variables()["RC_FILE"];
597 vcProject.ResourceFiles.Files += project->variables()["QMAKE_IMAGE_COLLECTION"];
598 vcProject.ResourceFiles.Files += project->variables()["IMAGES"];
599 vcProject.ResourceFiles.Files += project->variables()["IDLSOURCES"];
600 vcProject.ResourceFiles.Files.sort();
601 vcProject.ResourceFiles.Project = this;
602 vcProject.ResourceFiles.CustomBuild = none;
603}
604
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
621 Sets up all needed variables from the environment and all the different caches and .conf files
622*/
623
624void VcprojGenerator::initOld()
625{
626 if( init_flag )
627 return;
628
629 init_flag = TRUE;
630 QStringList::Iterator it;
631
632 // this should probably not be here, but I'm using it to wrap the .t files
633 if(project->first("TEMPLATE") == "vcapp" )
634 project->variables()["QMAKE_APP_FLAG"].append("1");
635 else if(project->first("TEMPLATE") == "vclib")
636 project->variables()["QMAKE_LIB_FLAG"].append("1");
637 if ( project->variables()["QMAKESPEC"].isEmpty() )
638 project->variables()["QMAKESPEC"].append( getenv("QMAKESPEC") );
639
640 bool is_qt =
641 ( project->first("TARGET") == "qt"QTDLL_POSTFIX ||
642 project->first("TARGET") == "qt-mt"QTDLL_POSTFIX );
643
644 QStringList &configs = project->variables()["CONFIG"];
645
646 if ( project->isActiveConfig( "shared" ) )
647 project->variables()["DEFINES"].append( "QT_DLL" );
648
649 if ( project->isActiveConfig( "qt_dll" ) &&
650 configs.findIndex("qt") == -1 )
651 configs.append("qt");
652
653 if ( project->isActiveConfig( "qt" ) ) {
654 if ( project->isActiveConfig( "plugin" ) ) {
655 project->variables()["CONFIG"].append( "dll" );
656 project->variables()["DEFINES"].append( "QT_PLUGIN" );
657 }
658 if ( ( project->variables()["DEFINES"].findIndex( "QT_NODLL" ) == -1 ) &&
659 (( project->variables()["DEFINES"].findIndex( "QT_MAKEDLL" ) != -1 ||
660 project->variables()["DEFINES"].findIndex( "QT_DLL" ) != -1 ) ||
661 ( getenv( "QT_DLL" ) && !getenv( "QT_NODLL" ))) ) {
662 project->variables()["QMAKE_QT_DLL"].append( "1" );
663 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() )
664 project->variables()["CONFIG"].append( "dll" );
665 }
666 }
667
668 // If we are a dll, then we cannot be a staticlib at the same time...
669 if ( project->isActiveConfig( "dll" ) || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
670 project->variables()["CONFIG"].remove( "staticlib" );
671 project->variables()["QMAKE_APP_OR_DLL"].append( "1" );
672 } else {
673 project->variables()["CONFIG"].append( "staticlib" );
674 }
675
676 // If we need 'qt' and/or 'opengl', then we need windows and not console
677 if ( project->isActiveConfig( "qt" ) || project->isActiveConfig( "opengl" ) ) {
678 project->variables()["CONFIG"].append( "windows" );
679 }
680
681 // Decode version, and add it to $$MSVCPROJ_VERSION --------------
682 if ( !project->variables()["VERSION"].isEmpty() ) {
683 QString version = project->variables()["VERSION"][0];
684 int firstDot = version.find( "." );
685 QString major = version.left( firstDot );
686 QString minor = version.right( version.length() - firstDot - 1 );
687 minor.replace( QRegExp( "\\." ), "" );
688 project->variables()["MSVCPROJ_VERSION"].append( "/VERSION:" + major + "." + minor );
689 }
690
691 // QT ------------------------------------------------------------
692 if ( project->isActiveConfig("qt") ) {
693 project->variables()["CONFIG"].append("moc");
694 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"];
695 project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"];
696
697 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) {
698 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) {
699 project->variables()["DEFINES"].append("QT_MAKEDLL");
700 project->variables()["QMAKE_LFLAGS"].append("/BASE:0x39D00000");
701 }
702 } else {
703 if(project->isActiveConfig("thread"))
704 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"];
705 else
706 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"];
707 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) {
708 int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt");
709 if( hver==-1 ) {
710 hver = findHighestVersion( project->first("QMAKE_LIBDIR_QT"), "qt-mt" );
711 }
712
713 if(hver != -1) {
714 QString ver;
715 ver.sprintf("qt%s" QTDLL_POSTFIX "%d.lib", (project->isActiveConfig("thread") ? "-mt" : ""), hver);
716 QStringList &libs = project->variables()["QMAKE_LIBS"];
717 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit)
718 (*libit).replace(QRegExp("qt(-mt)?\\.lib"), ver);
719 }
720 }
721 if ( project->isActiveConfig( "activeqt" ) ) {
722 project->variables().remove("QMAKE_LIBS_QT_ENTRY");
723 project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib";
724 if ( project->isActiveConfig( "dll" ) ) {
725 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"];
726 project->variables()["MSVCPROJ_LFLAGS"].append("/DEF:"+project->first("DEF_FILE"));
727 }
728 }
729 if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) {
730 project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"];
731 }
732 }
733 }
734
735 // Set target directories ----------------------------------------
736 // if ( !project->first("OBJECTS_DIR").isEmpty() )
737 //project->variables()["MSVCPROJ_OBJECTSDIR"] = project->first("OBJECTS_DIR");
738 // else
739 //project->variables()["MSVCPROJ_OBJECTSDIR"] = project->isActiveConfig( "release" )?"Release":"Debug";
740 // if ( !project->first("DESTDIR").isEmpty() )
741 //project->variables()["MSVCPROJ_TARGETDIR"] = project->first("DESTDIR");
742 // else
743 //project->variables()["MSVCPROJ_TARGETDIR"] = project->isActiveConfig( "release" )?"Release":"Debug";
744
745 // OPENGL --------------------------------------------------------
746 if ( project->isActiveConfig("opengl") ) {
747 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"];
748 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"];
749 }
750
751 // THREAD --------------------------------------------------------
752 if ( project->isActiveConfig("thread") ) {
753 if(project->isActiveConfig("qt"))
754 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT" );
755 if ( !project->variables()["DEFINES"].contains("QT_DLL") && is_qt
756 && project->first("TARGET") != "qtmain" )
757 project->variables()["QMAKE_LFLAGS"].append("/NODEFAULTLIB:libc");
758 }
759
760 // ACCESSIBILITY -------------------------------------------------
761 if(project->isActiveConfig("qt")) {
762 if ( project->isActiveConfig("accessibility" ) )
763 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT");
764 if ( project->isActiveConfig("tablet") )
765 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT");
766 }
767
768 // DLL -----------------------------------------------------------
769 if ( project->isActiveConfig("dll") ) {
770 if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) {
771 QString ver_xyz(project->first("VERSION"));
772 ver_xyz.replace(QRegExp("\\."), "");
773 project->variables()["TARGET_EXT"].append(ver_xyz + ".dll");
774 } else {
775 project->variables()["TARGET_EXT"].append(".dll");
776 }
777 }
778 // EXE / LIB -----------------------------------------------------
779 else {
780 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() )
781 project->variables()["TARGET_EXT"].append(".exe");
782 else
783 project->variables()["TARGET_EXT"].append(".lib");
784 }
785
786 project->variables()["MSVCPROJ_VER"] = "7.00";
787 project->variables()["MSVCPROJ_DEBUG_OPT"] = "/GZ /ZI";
788
789 // INCREMENTAL:NO ------------------------------------------------
790 if(!project->isActiveConfig("incremental")) {
791 project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no"));
792 if ( is_qt )
793 project->variables()["MSVCPROJ_DEBUG_OPT"] = "/GZ /Zi";
794 }
795
796 // MOC -----------------------------------------------------------
797 if ( project->isActiveConfig("moc") )
798 setMocAware(TRUE);
799
800
801 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
802
803 // Run through all variables containing filepaths, and -----------
804 // 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");
806 QStringList &l = project->variables()["QMAKE_FILETAGS"];
807 for(it = l.begin(); it != l.end(); ++it) {
808 QStringList &gdmf = project->variables()[(*it)];
809 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner)
810 (*inner) = Option::fixPathToTargetOS((*inner), FALSE);
811 }
812
813 // Get filename w/o extention -----------------------------------
814 QString msvcproj_project = "";
815 QString targetfilename = "";
816 if ( project->variables()["TARGET"].count() ) {
817 msvcproj_project = project->variables()["TARGET"].first();
818 targetfilename = msvcproj_project;
819 }
820
821 // Save filename w/o extention in $$QMAKE_ORIG_TARGET ------------
822 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"];
823
824 // TARGET (add extention to $$TARGET) ----------------------------
825 project->variables()["TARGET"].first() += project->first("TARGET_EXT");
826
827 // Init base class too -------------------------------------------
828 MakefileGenerator::init();
829
830
831 if ( msvcproj_project.isEmpty() )
832 msvcproj_project = Option::output.name();
833
834 msvcproj_project = msvcproj_project.right( msvcproj_project.length() - msvcproj_project.findRev( "\\" ) - 1 );
835 msvcproj_project = msvcproj_project.left( msvcproj_project.findRev( "." ) );
836 msvcproj_project.replace(QRegExp("-"), "");
837
838 project->variables()["MSVCPROJ_PROJECT"].append(msvcproj_project);
839 QStringList &proj = project->variables()["MSVCPROJ_PROJECT"];
840
841 for(it = proj.begin(); it != proj.end(); ++it)
842 (*it).replace(QRegExp("\\.[a-zA-Z0-9_]*$"), "");
843
844 // SUBSYSTEM -----------------------------------------------------
845 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
846 project->variables()["MSVCPROJ_TEMPLATE"].append("win32app" + project->first( "VCPROJ_EXTENSION" ) );
847 if ( project->isActiveConfig("console") ) {
848 project->variables()["MSVCPROJ_CONSOLE"].append("CONSOLE");
849 project->variables()["MSVCPROJ_WINCONDEF"].append("_CONSOLE");
850 project->variables()["MSVCPROJ_VCPROJTYPE"].append("0x0103");
851 project->variables()["MSVCPROJ_SUBSYSTEM"].append("CONSOLE");
852 } else {
853 project->variables()["MSVCPROJ_CONSOLE"].clear();
854 project->variables()["MSVCPROJ_WINCONDEF"].append("_WINDOWS");
855 project->variables()["MSVCPROJ_VCPROJTYPE"].append("0x0101");
856 project->variables()["MSVCPROJ_SUBSYSTEM"].append("WINDOWS");
857 }
858 } else {
859 if ( project->isActiveConfig("dll") ) {
860 project->variables()["MSVCPROJ_TEMPLATE"].append("win32dll" + project->first( "VCPROJ_EXTENSION" ) );
861 } else {
862 project->variables()["MSVCPROJ_TEMPLATE"].append("win32lib" + project->first( "VCPROJ_EXTENSION" ) );
863 }
864 }
865
866 // $$QMAKE.. -> $$MSVCPROJ.. -------------------------------------
867 project->variables()["MSVCPROJ_LIBS"] += project->variables()["QMAKE_LIBS"];
868 project->variables()["MSVCPROJ_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"];
869 project->variables()["MSVCPROJ_LFLAGS" ] += project->variables()["QMAKE_LFLAGS"];
870 if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() )
871 project->variables()["MSVCPROJ_LFLAGS" ].append(varGlue("QMAKE_LIBDIR","/LIBPATH:"," /LIBPATH:",""));
872 project->variables()["MSVCPROJ_CXXFLAGS" ] += project->variables()["QMAKE_CXXFLAGS"];
873 // We don't use this... Direct manipulation of compiler object
874 //project->variables()["MSVCPROJ_DEFINES"].append(varGlue("DEFINES","/D ","" " /D ",""));
875 //project->variables()["MSVCPROJ_DEFINES"].append(varGlue("PRL_EXPORT_DEFINES","/D ","" " /D ",""));
876 QStringList &incs = project->variables()["INCLUDEPATH"];
877 for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) {
878 QString inc = (*incit);
879 inc.replace(QRegExp("\""), "");
880 project->variables()["MSVCPROJ_INCPATH"].append("/I" + inc );
881 }
882 project->variables()["MSVCPROJ_INCPATH"].append("/I" + specdir());
883
884 QString dest;
885 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"));
889 dest = project->first("TARGET");
890 if ( project->first("TARGET").startsWith("$(QTDIR)") )
891 dest.replace( QRegExp("\\$\\(QTDIR\\)"), getenv("QTDIR") );
892 project->variables()["MSVCPROJ_TARGET"].append(
893 QString("/OUT:") + dest );
894 if ( project->isActiveConfig("dll") ) {
895 QString imp = dest;
896 imp.replace(QRegExp("\\.dll"), ".lib");
897 project->variables()["MSVCPROJ_LIBOPTIONS"] += (QString("/IMPLIB:") + imp );
898 }
899 }
900
901 // DLL COPY ------------------------------------------------------
902 if ( project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty() ) {
903 QStringList dlldirs = project->variables()["DLLDESTDIR"];
904 QString copydll = "# Begin Special Build Tool\n"
905 "TargetPath=" + dest + "\n"
906 "SOURCE=$(InputPath)\n"
907 "PostBuild_Desc=Copy DLL to " + project->first("DLLDESTDIR") + "\n"
908 "PostBuild_Cmds=";
909
910 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) {
911 copydll += "copy \"" + dest + "\" \"" + *dlldir + "\"\t";
912 }
913
914 copydll += "\n# End Special Build Tool";
915 project->variables()["MSVCPROJ_COPY_DLL_REL"].append( copydll );
916 project->variables()["MSVCPROJ_COPY_DLL_DBG"].append( copydll );
917 }
918
919 // ACTIVEQT ------------------------------------------------------
920 if ( project->isActiveConfig("activeqt") ) {
921 QString idl = project->variables()["QMAKE_IDL"].first();
922 QString idc = project->variables()["QMAKE_IDC"].first();
923 QString version = project->variables()["VERSION"].first();
924 if ( version.isEmpty() )
925 version = "1.0";
926
927 project->variables()["MSVCPROJ_IDLSOURCES"].append( "tmp\\" + targetfilename + ".idl" );
928 project->variables()["MSVCPROJ_IDLSOURCES"].append( "tmp\\" + targetfilename + ".tlb" );
929 project->variables()["MSVCPROJ_IDLSOURCES"].append( "tmp\\" + targetfilename + ".midl" );
930 if ( project->isActiveConfig( "dll" ) ) {
931 QString regcmd = "# Begin Special Build Tool\n"
932 "TargetPath=" + targetfilename + "\n"
933 "SOURCE=$(InputPath)\n"
934 "PostBuild_Desc=Finalizing ActiveQt server...\n"
935 "PostBuild_Cmds=" +
936 idc + " %1 -idl tmp\\" + targetfilename + ".idl -version " + version +
937 "\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"
938 "\t" + idc + " %1 /tlb tmp\\" + targetfilename + ".tlb"
939 "\tregsvr32 /s %1\n"
940 "# End Special Build Tool";
941
942 QString executable = project->variables()["MSVCPROJ_TARGETDIRREL"].first() + "\\" + project->variables()["TARGET"].first();
943 project->variables()["MSVCPROJ_COPY_DLL_REL"].append( regcmd.arg(executable).arg(executable).arg(executable) );
944
945 executable = project->variables()["MSVCPROJ_TARGETDIRDEB"].first() + "\\" + project->variables()["TARGET"].first();
946 project->variables()["MSVCPROJ_COPY_DLL_DBG"].append( regcmd.arg(executable).arg(executable).arg(executable) );
947 } else {
948 QString regcmd = "# Begin Special Build Tool\n"
949 "TargetPath=" + targetfilename + "\n"
950 "SOURCE=$(InputPath)\n"
951 "PostBuild_Desc=Finalizing ActiveQt server...\n"
952 "PostBuild_Cmds="
953 "%1 -dumpidl tmp\\" + targetfilename + ".idl -version " + version +
954 "\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"
955 "\t" + idc + " %1 /tlb tmp\\" + targetfilename + ".tlb"
956 "\t%1 -regserver\n"
957 "# End Special Build Tool";
958
959 QString executable = project->variables()["MSVCPROJ_TARGETDIRREL"].first() + "\\" + project->variables()["TARGET"].first();
960 project->variables()["MSVCPROJ_REGSVR_REL"].append( regcmd.arg(executable).arg(executable).arg(executable) );
961
962 executable = project->variables()["MSVCPROJ_TARGETDIRDEB"].first() + "\\" + project->variables()["TARGET"].first();
963 project->variables()["MSVCPROJ_REGSVR_DBG"].append( regcmd.arg(executable).arg(executable).arg(executable) );
964 }
965
966 }
967
968 // FORMS ---------------------------------------------------------
969 QStringList &list = project->variables()["FORMS"];
970 for( it = list.begin(); it != list.end(); ++it ) {
971 if ( QFile::exists( *it + ".h" ) )
972 project->variables()["SOURCES"].append( *it + ".h" );
973 }
974
975 project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "MSVCPROJ_LFLAGS" << "MSVCPROJ_LIBS";
976
977 // Verbose output if "-d -d"...
978 outputVariables();
979}
980
981// ------------------------------------------------------------------------------------------------
982// ------------------------------------------------------------------------------------------------
983
984bool VcprojGenerator::openOutput(QFile &file) const
985{
986 QString outdir;
987 if(!file.name().isEmpty()) {
988 QFileInfo fi(file);
989 if(fi.isDir())
990 outdir = file.name() + QDir::separator();
991 }
992 if(!outdir.isEmpty() || file.name().isEmpty()) {
993 QString ext = project->first("VCPROJ_EXTENSION");
994 if(project->first("TEMPLATE") == "vcsubdirs")
995 ext = project->first("VCSOLUTION_EXTENSION");
996 file.setName(outdir + project->first("TARGET") + ext);
997 }
998 if(QDir::isRelativePath(file.name())) {
999 QString ofile;
1000 ofile = file.name();
1001 int slashfind = ofile.findRev('\\');
1002 if (slashfind == -1) {
1003 ofile = ofile.replace("-", "_");
1004 } else {
1005 int hypenfind = ofile.find('-', slashfind);
1006 while (hypenfind != -1 && slashfind < hypenfind) {
1007 ofile = ofile.replace(hypenfind, 1, "_");
1008 hypenfind = ofile.find('-', hypenfind + 1);
1009 }
1010 }
1011 file.setName(Option::fixPathToLocalOS(QDir::currentDirPath() + Option::dir_sep + ofile));
1012 }
1013 return Win32MakefileGenerator::openOutput(file);
1014}
1015
1016QString VcprojGenerator::findTemplate(QString file)
1017{
1018 QString ret;
1019 if(!QFile::exists((ret = file)) &&
1020 !QFile::exists((ret = QString(Option::mkfile::qmakespec + "/" + file))) &&
1021 !QFile::exists((ret = QString(getenv("QTDIR")) + "/mkspecs/win32-msvc.net/" + file)) &&
1022 !QFile::exists((ret = (QString(getenv("HOME")) + "/.tmake/" + file))))
1023 return "";
1024 debug_msg(1, "Generator: MSVC.NET: Found template \'%s\'", ret.latin1() );
1025 return ret;
1026}
1027
1028
1029void VcprojGenerator::processPrlVariable(const QString &var, const QStringList &l)
1030{
1031 if(var == "QMAKE_PRL_DEFINES") {
1032 QStringList &out = project->variables()["MSVCPROJ_DEFINES"];
1033 for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
1034 if(out.findIndex((*it)) == -1)
1035 out.append((" /D " + *it ));
1036 }
1037 } else {
1038 MakefileGenerator::processPrlVariable(var, l);
1039 }
1040}
1041
1042void VcprojGenerator::outputVariables()
1043{
1044#if 0
1045 debug_msg(3, "Generator: MSVC.NET: List of current variables:" );
1046 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() );
1048 }
1049#endif
1050}
diff --git a/qmake/generators/win32/msvc_vcproj.h b/qmake/generators/win32/msvc_vcproj.h
new file mode 100644
index 0000000..583b164
--- a/dev/null
+++ b/qmake/generators/win32/msvc_vcproj.h
@@ -0,0 +1,129 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of VcprojGenerator class.
5**
6** Created : 970521
7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9**
10** This file is part of the network module of the Qt GUI Toolkit.
11**
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
14** LICENSE.QPL included in the packaging of this file.
15**
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
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software.
24**
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.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37#ifndef __VCPROJMAKE_H__
38#define __VCPROJMAKE_H__
39
40#include "winmakefile.h"
41#include "msvc_objectmodel.h"
42
43enum target {
44 Application,
45 SharedLib,
46 StaticLib
47};
48
49class VcprojGenerator : public Win32MakefileGenerator
50{
51 bool init_flag;
52 bool writeVcprojParts(QTextStream &);
53
54 bool writeMakefile(QTextStream &);
55 virtual void writeSubDirs(QTextStream &t);
56 QString findTemplate(QString file);
57 void init();
58
59public:
60 VcprojGenerator(QMakeProject *p);
61 ~VcprojGenerator();
62
63 QString defaultMakefile() const;
64 virtual bool doDepends() const { return FALSE; } //never necesary
65
66protected:
67 virtual bool openOutput(QFile &file) const;
68 virtual void processPrlVariable(const QString &, const QStringList &);
69 virtual bool findLibraries();
70 virtual void outputVariables();
71
72 void initOld();
73 void initProject();
74 void initConfiguration();
75 void initCompilerTool();
76 void initLinkerTool();
77 void initLibrarianTool();
78 void initIDLTool();
79 void initCustomBuildTool();
80 void initPreBuildEventTools();
81 void initPostBuildEventTools();
82 void initPreLinkEventTools();
83 void initSourceFiles();
84 void initHeaderFiles();
85 void initMOCFiles();
86 void initUICFiles();
87 void initFormsFiles();
88 void initTranslationFiles();
89 void initLexYaccFiles();
90 void initResourceFiles();
91
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;
111 target projectTarget;
112
113 friend class VCFilter;
114};
115
116inline VcprojGenerator::~VcprojGenerator()
117{ }
118
119inline QString VcprojGenerator::defaultMakefile() const
120{
121 return project->first("TARGET") + project->first("VCPROJ_EXTENSION");
122}
123
124inline bool VcprojGenerator::findLibraries()
125{
126 return Win32MakefileGenerator::findLibraries("MSVCVCPROJ_LIBS");
127}
128
129#endif /* __VCPROJMAKE_H__ */
diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp
new file mode 100644
index 0000000..a07c921
--- a/dev/null
+++ b/qmake/generators/win32/winmakefile.cpp
@@ -0,0 +1,360 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Created : 970521
7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9**
10** This file is part of the network module of the Qt GUI Toolkit.
11**
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
14** LICENSE.QPL included in the packaging of this file.
15**
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
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software.
24**
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.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38#include "winmakefile.h"
39#include "option.h"
40#include "project.h"
41#include <qtextstream.h>
42#include <qstring.h>
43#include <qdict.h>
44#include <qregexp.h>
45#include <qstringlist.h>
46#include <qdir.h>
47
48
49Win32MakefileGenerator::Win32MakefileGenerator(QMakeProject *p) : MakefileGenerator(p)
50{
51
52}
53
54
55struct SubDir
56{
57 QString directory, profile, target, makefile;
58};
59
60void
61Win32MakefileGenerator::writeSubDirs(QTextStream &t)
62{
63 QPtrList<SubDir> subdirs;
64 {
65 QStringList subdirs_in = project->variables()["SUBDIRS"];
66 for(QStringList::Iterator it = subdirs_in.begin(); it != subdirs_in.end(); ++it) {
67 QString file = (*it);
68 file = fileFixify(file);
69 SubDir *sd = new SubDir;
70 subdirs.append(sd);
71 sd->makefile = "$(MAKEFILE)";
72 if((*it).right(4) == ".pro") {
73 int slsh = file.findRev(Option::dir_sep);
74 if(slsh != -1) {
75 sd->directory = file.left(slsh+1);
76 sd->profile = file.mid(slsh+1);
77 } else {
78 sd->profile = file;
79 }
80 } else {
81 sd->directory = file;
82 }
83 while(sd->directory.right(1) == Option::dir_sep)
84 sd->directory = sd->directory.left(sd->directory.length() - 1);
85 if(!sd->profile.isEmpty()) {
86 QString basename = sd->directory;
87 int new_slsh = basename.findRev(Option::dir_sep);
88 if(new_slsh != -1)
89 basename = basename.mid(new_slsh+1);
90 if(sd->profile != basename + ".pro")
91 sd->makefile += "." + sd->profile.left(sd->profile.length() - 4); //no need for the .pro
92 }
93 sd->target = "sub-" + (*it);
94 sd->target.replace('/', '-');
95 sd->target.replace('.', '_');
96 }
97 }
98 QPtrListIterator<SubDir> it(subdirs);
99
100 if(!project->isEmpty("MAKEFILE"))
101 t << "MAKEFILE=" << var("MAKEFILE") << endl;
102 t << "QMAKE =" << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl;
103 t << "SUBTARGETS= ";
104 for( it.toFirst(); it.current(); ++it)
105 t << " \\\n\t\t" << it.current()->target;
106 t << endl << endl;
107 t << "all: qmake_all $(SUBTARGETS)" << endl << endl;
108
109 for( it.toFirst(); it.current(); ++it) {
110 bool have_dir = !(*it)->directory.isEmpty();
111
112 //make the makefile
113 QString mkfile = (*it)->makefile;
114 if(have_dir)
115 mkfile.prepend((*it)->directory + Option::dir_sep);
116 t << mkfile << ":";
117 if(project->variables()["QMAKE_NOFORCE"].isEmpty())
118 t << " FORCE";
119 if(have_dir)
120 t << "\n\t" << "cd " << (*it)->directory;
121 t << "\n\t" << "$(QMAKE) " << (*it)->profile << " " << buildArgs();
122 if((*it)->makefile != "$(MAKEFILE)")
123 t << " -o " << (*it)->makefile;
124 if(have_dir) {
125 int subLevels = it.current()->directory.contains(Option::dir_sep) + 1;
126 t << "\n\t" << "@cd ..";
127 for(int i = 1; i < subLevels; i++ )
128 t << Option::dir_sep << "..";
129 }
130 t << endl;
131
132 //now actually build
133 t << (*it)->target << ": " << mkfile;
134 if(project->variables()["QMAKE_NOFORCE"].isEmpty())
135 t << " FORCE";
136 if(have_dir)
137 t << "\n\t" << "cd " << (*it)->directory;
138 t << "\n\t" << "$(MAKE)";
139 if((*it)->makefile != "$(MAKEFILE)")
140 t << " -f " << (*it)->makefile;
141 if(have_dir) {
142 int subLevels = it.current()->directory.contains(Option::dir_sep) + 1;
143 t << "\n\t" << "@cd ..";
144 for(int i = 1; i < subLevels; i++ )
145 t << Option::dir_sep << "..";
146 }
147 t << endl << endl;
148 }
149
150 if(project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].findIndex("qmake_all") == -1)
151 project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].append("qmake_all");
152 writeMakeQmake(t);
153
154 t << "qmake_all:";
155 if ( !subdirs.isEmpty() ) {
156 for( it.toFirst(); it.current(); ++it) {
157 QString subdir = (*it)->directory;
158 int subLevels = subdir.contains(Option::dir_sep) + 1;
159 t << "\n\t"
160 << "cd " << subdir << "\n\t";
161 int lastSlash = subdir.findRev(Option::dir_sep);
162 if(lastSlash != -1)
163 subdir = subdir.mid( lastSlash + 1 );
164 t << "$(QMAKE) " << subdir << ".pro"
165 << (!project->isEmpty("MAKEFILE") ? QString(" -o ") + var("MAKEFILE") : QString(""))
166 << " " << buildArgs() << "\n\t"
167 << "@cd ..";
168 for(int i = 1; i < subLevels; i++ )
169 t << Option::dir_sep << "..";
170 }
171 } else {
172 // Borland make does not like empty an empty command section, so insert
173 // a dummy command.
174 t << "\n\t" << "@cd .";
175 }
176 t << endl << endl;
177
178 QString targs[] = { QString("clean"), QString("install"), QString("mocclean"), QString::null };
179 for(int x = 0; targs[x] != QString::null; x++) {
180 t << targs[x] << ": qmake_all";
181 if(targs[x] == "clean")
182 t << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ", "");
183 if (!subdirs.isEmpty()) {
184 for( it.toFirst(); it.current(); ++it) {
185 int subLevels = (*it)->directory.contains(Option::dir_sep) + 1;
186 bool have_dir = !(*it)->directory.isEmpty();
187 if(have_dir)
188 t << "\n\t" << "cd " << (*it)->directory;
189 QString in_file;
190 if((*it)->makefile != "$(MAKEFILE)")
191 in_file = " -f " + (*it)->makefile;
192 t << "\n\t" << "$(MAKE) " << in_file << " " << targs[x];
193 if(have_dir) {
194 t << "\n\t" << "@cd ..";
195 for(int i = 1; i < subLevels; i++ )
196 t << Option::dir_sep << "..";
197 }
198 }
199 } else {
200 // Borland make does not like empty an empty command section, so
201 // insert a dummy command.
202 t << "\n\t" << "@cd .";
203 }
204 t << endl << endl;
205 }
206
207 if(project->variables()["QMAKE_NOFORCE"].isEmpty())
208 t << "FORCE:" << endl << endl;
209}
210
211
212int
213Win32MakefileGenerator::findHighestVersion(const QString &d, const
214 QString &stem)
215{
216 if(!QFile::exists(Option::fixPathToLocalOS(d)))
217 return -1;
218 if(!project->variables()["QMAKE_" + stem.upper() +
219 "_VERSION_OVERRIDE"].isEmpty())
220 return project->variables()["QMAKE_" + stem.upper() +
221 "_VERSION_OVERRIDE"].first().toInt();
222 QString bd = d;
223 fixEnvVariables(bd);
224 QDir dir(bd);
225 int biggest=-1;
226 QStringList entries = dir.entryList();
227 QRegExp regx( "(" + stem + "([0-9]*)).lib", FALSE );
228 for(QStringList::Iterator it = entries.begin(); it != entries.end();
229 ++it) {
230 if(regx.exactMatch((*it)))
231 biggest = QMAX(biggest, (regx.cap(1) == stem ||
232 regx.cap(2).isEmpty()) ? -1 : regx.cap(2).toInt());
233 }
234 return biggest;
235}
236
237
238bool
239Win32MakefileGenerator::findLibraries(const QString &where)
240{
241
242 QStringList &l = project->variables()[where];
243 QPtrList<MakefileDependDir> dirs;
244 dirs.setAutoDelete(TRUE);
245 for(QStringList::Iterator it = l.begin(); it != l.end(); ) {
246 QString opt = (*it);
247 bool remove = FALSE;
248 if(opt.startsWith("-L") || opt.startsWith("/L")) {
249 QString r = opt.right(opt.length() - 2), l = Option::fixPathToLocalOS(r);
250 dirs.append(new MakefileDependDir(r.replace("\"",""),
251 l.replace("\"","")));
252 remove = TRUE;
253 } else if(opt.startsWith("-l") || opt.startsWith("/l")) {
254 QString lib = opt.right(opt.length() - 2), out;
255 if(!lib.isEmpty()) {
256 for(MakefileDependDir *mdd = dirs.first(); mdd; mdd = dirs.next() ) {
257 int ver = findHighestVersion(mdd->local_dir, lib);
258 if(ver > 0)
259 lib += QString::number(ver);
260 lib += ".lib";
261 if(QFile::exists(mdd->local_dir + Option::dir_sep + lib)) {
262 out = mdd->real_dir + Option::dir_sep + lib;
263 break;
264 }
265 }
266 }
267 if(out.isEmpty())
268 remove = TRUE;
269 else
270 (*it) = out;
271 } else if(!QFile::exists(Option::fixPathToLocalOS(opt))) {
272 QString dir, file = opt;
273 int slsh = file.findRev(Option::dir_sep);
274 if(slsh != -1) {
275 dir = file.left(slsh+1);
276 file = file.right(file.length() - slsh - 1);
277 }
278 if ( !(project->variables()["QMAKE_QT_DLL"].isEmpty() && (file == "qt.lib" || file == "qt-mt.lib")) ) {
279 if(file.endsWith(".lib")) {
280 file = file.left(file.length() - 4);
281 if(!file.at(file.length()-1).isNumber()) {
282 int ver = findHighestVersion(dir, file);
283 if(ver != -1) {
284 file = QString(dir + file + "%1" + ".lib");
285 if(ver)
286 (*it) = file.arg(ver);
287 else
288 (*it) = file.arg("");
289 }
290 }
291 }
292 }
293 }
294 if(remove)
295 it = l.remove(it);
296 else
297 ++it;
298 }
299 return TRUE;
300}
301
302void
303Win32MakefileGenerator::processPrlFiles()
304{
305 QDict<void> processed;
306 QPtrList<MakefileDependDir> libdirs;
307 libdirs.setAutoDelete(TRUE);
308 {
309 QStringList &libpaths = project->variables()["QMAKE_LIBDIR"];
310 for(QStringList::Iterator libpathit = libpaths.begin(); libpathit != libpaths.end(); ++libpathit) {
311 QString r = (*libpathit), l = r;
312 fixEnvVariables(l);
313 libdirs.append(new MakefileDependDir(r.replace("\"",""),
314 l.replace("\"","")));
315 }
316 }
317 for(bool ret = FALSE; TRUE; ret = FALSE) {
318 //read in any prl files included..
319 QStringList l_out;
320 QString where = "QMAKE_LIBS";
321 if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS"))
322 where = project->first("QMAKE_INTERNAL_PRL_LIBS");
323 QStringList &l = project->variables()[where];
324 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
325 QString opt = (*it);
326 if(opt.left(1) == "/") {
327 if(opt.left(9) == "/LIBPATH:") {
328 QString r = opt.mid(9), l = r;
329 fixEnvVariables(l);
330 libdirs.append(new MakefileDependDir(r.replace("\"",""),
331 l.replace("\"","")));
332 }
333 } else {
334 if(!processed[opt]) {
335 if(processPrlFile(opt)) {
336 processed.insert(opt, (void*)1);
337 ret = TRUE;
338 } else {
339 for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) {
340 QString prl = mdd->local_dir + Option::dir_sep + opt;
341 if(processed[prl]) {
342 break;
343 } else if(processPrlFile(prl)) {
344 processed.insert(prl, (void*)1);
345 ret = TRUE;
346 break;
347 }
348 }
349 }
350 }
351 }
352 if(!opt.isEmpty())
353 l_out.append(opt);
354 }
355 if(ret)
356 l = l_out;
357 else
358 break;
359 }
360}
diff --git a/qmake/generators/win32/winmakefile.h b/qmake/generators/win32/winmakefile.h
new file mode 100644
index 0000000..75ba0e0
--- a/dev/null
+++ b/qmake/generators/win32/winmakefile.h
@@ -0,0 +1,72 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Created : 970521
7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9**
10** This file is part of the network module of the Qt GUI Toolkit.
11**
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
14** LICENSE.QPL included in the packaging of this file.
15**
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
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software.
24**
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.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37#ifndef __WINMAKEFILE_H__
38#define __WINMAKEFILE_H__
39
40#include "makefile.h"
41
42// In the Qt evaluation and educational version, we have a postfix in the
43// library name (e.g. qtmteval301.dll). QTDLL_POSTFIX is used for this.
44// A script modifies these lines when building eval/edu version, so be careful
45// when changing them.
46#ifndef QTDLL_POSTFIX
47#define QTDLL_POSTFIX ""
48#endif
49
50class Win32MakefileGenerator : public MakefileGenerator
51{
52protected:
53 virtual void writeSubDirs(QTextStream &t);
54 int findHighestVersion(const QString &dir, const QString &stem);
55 bool findLibraries(const QString &);
56 virtual bool findLibraries();
57 virtual void processPrlFiles();
58
59public:
60 Win32MakefileGenerator(QMakeProject *p);
61 ~Win32MakefileGenerator();
62};
63
64inline Win32MakefileGenerator::~Win32MakefileGenerator()
65{ }
66
67inline bool Win32MakefileGenerator::findLibraries()
68{ return findLibraries("QMAKE_LIBS"); }
69
70
71
72#endif /* __WINMAKEFILE_H__ */