summaryrefslogtreecommitdiff
path: root/qmake/generators
authorzecke <zecke>2004-07-15 17:36:57 (UTC)
committer zecke <zecke>2004-07-15 17:36:57 (UTC)
commit323e9a7472a110b4befba7320540263147505bae (patch) (unidiff)
tree14c810bdb9c0603a30356b17b4bdf9ccb72741c6 /qmake/generators
parentaa292b322f1ecb43dd8f4e3cd295855730dd9f59 (diff)
downloadopie-323e9a7472a110b4befba7320540263147505bae.zip
opie-323e9a7472a110b4befba7320540263147505bae.tar.gz
opie-323e9a7472a110b4befba7320540263147505bae.tar.bz2
Manually updatet to qmake1.06a which includes support for precompiled
headers. Opies 'PRO' keyword was already reintroduced
Diffstat (limited to 'qmake/generators') (more/less context) (show whitespace changes)
-rw-r--r--qmake/generators/mac/metrowerks_xml.cpp21
-rw-r--r--qmake/generators/mac/metrowerks_xml.h17
-rw-r--r--qmake/generators/mac/pbuilder_pbx.cpp801
-rw-r--r--qmake/generators/mac/pbuilder_pbx.h31
-rw-r--r--qmake/generators/makefile.cpp548
-rw-r--r--qmake/generators/makefile.h39
-rw-r--r--qmake/generators/projectgenerator.cpp36
-rw-r--r--qmake/generators/projectgenerator.h8
-rw-r--r--qmake/generators/unix/unixmake.cpp441
-rw-r--r--qmake/generators/unix/unixmake.h22
-rw-r--r--qmake/generators/unix/unixmake2.cpp596
-rw-r--r--qmake/generators/win32/borland_bmake.cpp218
-rw-r--r--qmake/generators/win32/borland_bmake.h9
-rw-r--r--qmake/generators/win32/mingw_make.cpp284
-rw-r--r--qmake/generators/win32/mingw_make.h11
-rw-r--r--qmake/generators/win32/msvc_dsp.cpp238
-rw-r--r--qmake/generators/win32/msvc_dsp.h13
-rw-r--r--qmake/generators/win32/msvc_nmake.cpp315
-rw-r--r--qmake/generators/win32/msvc_nmake.h15
-rw-r--r--qmake/generators/win32/msvc_objectmodel.cpp341
-rw-r--r--qmake/generators/win32/msvc_objectmodel.h43
-rw-r--r--qmake/generators/win32/msvc_vcproj.cpp686
-rw-r--r--qmake/generators/win32/msvc_vcproj.h14
-rw-r--r--qmake/generators/win32/winmakefile.cpp121
-rw-r--r--qmake/generators/win32/winmakefile.h10
25 files changed, 3741 insertions, 1137 deletions
diff --git a/qmake/generators/mac/metrowerks_xml.cpp b/qmake/generators/mac/metrowerks_xml.cpp
index 125749d..baaeeec 100644
--- a/qmake/generators/mac/metrowerks_xml.cpp
+++ b/qmake/generators/mac/metrowerks_xml.cpp
@@ -1,13 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Definition of ________ class.
5** 3**
6** Created : 970521 4** Implementation of MetrowerksMakefileGenerator class.
7** 5**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. 6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 7**
10** This file is part of the network module of the Qt GUI Toolkit. 8** This file is part of qmake.
11** 9**
12** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
@@ -42,13 +40,12 @@
42#include <qregexp.h> 40#include <qregexp.h>
43#include <stdlib.h> 41#include <stdlib.h>
44#include <time.h> 42#include <time.h>
45#ifdef Q_OS_MAC 43#if !defined(QWS) && defined(Q_OS_MAC)
46#include <Carbon/Carbon.h> 44#include <Carbon/Carbon.h>
47#include <sys/types.h> 45#include <sys/types.h>
48#include <sys/stat.h> 46#include <sys/stat.h>
49#endif 47#endif
50 48
51
52MetrowerksMakefileGenerator::MetrowerksMakefileGenerator(QMakeProject *p) : MakefileGenerator(p), init_flag(FALSE) 49MetrowerksMakefileGenerator::MetrowerksMakefileGenerator(QMakeProject *p) : MakefileGenerator(p), init_flag(FALSE)
53{ 50{
54 51
@@ -607,7 +604,7 @@ MetrowerksMakefileGenerator::init()
607 604
608 605
609QString 606QString
610MetrowerksMakefileGenerator::findTemplate(QString file) 607MetrowerksMakefileGenerator::findTemplate(const QString &file)
611{ 608{
612 QString ret; 609 QString ret;
613 if(!QFile::exists(ret = file) && 610 if(!QFile::exists(ret = file) &&
@@ -621,7 +618,7 @@ MetrowerksMakefileGenerator::findTemplate(QString file)
621bool 618bool
622MetrowerksMakefileGenerator::createFork(const QString &f) 619MetrowerksMakefileGenerator::createFork(const QString &f)
623{ 620{
624#if defined(Q_OS_MACX) 621#if !defined(QWS) && defined(Q_OS_MACX)
625 FSRef fref; 622 FSRef fref;
626 FSSpec fileSpec; 623 FSSpec fileSpec;
627 if(QFile::exists(f)) { 624 if(QFile::exists(f)) {
@@ -664,7 +661,7 @@ MetrowerksMakefileGenerator::fixifyToMacPath(QString &p, QString &v, bool )
664 static QString st_volume; 661 static QString st_volume;
665 if(st_volume.isEmpty()) { 662 if(st_volume.isEmpty()) {
666 st_volume = var("QMAKE_VOLUMENAME"); 663 st_volume = var("QMAKE_VOLUMENAME");
667#ifdef Q_OS_MAC 664#if !defined(QWS) && defined(Q_OS_MACX)
668 if(st_volume.isEmpty()) { 665 if(st_volume.isEmpty()) {
669 uchar foo[512]; 666 uchar foo[512];
670 HVolumeParam pb; 667 HVolumeParam pb;
@@ -733,7 +730,7 @@ MetrowerksMakefileGenerator::processPrlFiles()
733 } else if(opt.left(2) == "-l") { 730 } else if(opt.left(2) == "-l") {
734 QString lib = opt.right(opt.length() - 2), prl; 731 QString lib = opt.right(opt.length() - 2), prl;
735 for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) { 732 for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) {
736 prl = mdd->local_dir + Option::dir_sep + "lib" + lib + Option::prl_ext; 733 prl = mdd->local_dir + Option::dir_sep + "lib" + lib;
737 if(processPrlFile(prl)) { 734 if(processPrlFile(prl)) {
738 if(prl.startsWith(mdd->local_dir)) 735 if(prl.startsWith(mdd->local_dir))
739 prl.replace(0, mdd->local_dir.length(), mdd->real_dir); 736 prl.replace(0, mdd->local_dir.length(), mdd->real_dir);
@@ -751,7 +748,7 @@ MetrowerksMakefileGenerator::processPrlFiles()
751 ++it; 748 ++it;
752 opt = (*it); 749 opt = (*it);
753 QString prl = "/System/Library/Frameworks/" + opt + 750 QString prl = "/System/Library/Frameworks/" + opt +
754 ".framework/" + opt + Option::prl_ext; 751 ".framework/" + opt;
755 if(processPrlFile(prl)) 752 if(processPrlFile(prl))
756 ret = TRUE; 753 ret = TRUE;
757 } 754 }
diff --git a/qmake/generators/mac/metrowerks_xml.h b/qmake/generators/mac/metrowerks_xml.h
index ae3cfae..0aa3615 100644
--- a/qmake/generators/mac/metrowerks_xml.h
+++ b/qmake/generators/mac/metrowerks_xml.h
@@ -1,13 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Definition of ________ class.
5** 3**
6** Created : 970521 4** Definition of MetrowerksMakefileGenerator class.
7** 5**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 7**
10** This file is part of the network module of the Qt GUI Toolkit. 8** This file is part of qmake.
11** 9**
12** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
@@ -34,8 +32,9 @@
34** not clear to you. 32** not clear to you.
35** 33**
36**********************************************************************/ 34**********************************************************************/
37#ifndef __METROWERKSMAKE_H__ 35
38#define __METROWERKSMAKE_H__ 36#ifndef __METROWERKS_XML_H__
37#define __METROWERKS_XML_H__
39 38
40#include "makefile.h" 39#include "makefile.h"
41 40
@@ -50,7 +49,7 @@ class MetrowerksMakefileGenerator : public MakefileGenerator
50 bool writeSubDirs(QTextStream &); 49 bool writeSubDirs(QTextStream &);
51 50
52 bool writeMakefile(QTextStream &); 51 bool writeMakefile(QTextStream &);
53 QString findTemplate(QString file); 52 QString findTemplate(const QString &file);
54 void init(); 53 void init();
55public: 54public:
56 MetrowerksMakefileGenerator(QMakeProject *p); 55 MetrowerksMakefileGenerator(QMakeProject *p);
@@ -66,4 +65,4 @@ protected:
66inline MetrowerksMakefileGenerator::~MetrowerksMakefileGenerator() 65inline MetrowerksMakefileGenerator::~MetrowerksMakefileGenerator()
67{ } 66{ }
68 67
69#endif /* __METROWERKSMAKE_H__ */ 68#endif /* __METROWERKS_XML_H__ */
diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp
index b46005b..9d1286e 100644
--- a/qmake/generators/mac/pbuilder_pbx.cpp
+++ b/qmake/generators/mac/pbuilder_pbx.cpp
@@ -1,13 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Definition of ________ class.
5** 3**
6** Created : 970521 4** Implementation of ProjectBuilderMakefileGenerator class.
7** 5**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 7**
10** This file is part of the network module of the Qt GUI Toolkit. 8** This file is part of qmake.
11** 9**
12** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
@@ -37,11 +35,13 @@
37 35
38#include "pbuilder_pbx.h" 36#include "pbuilder_pbx.h"
39#include "option.h" 37#include "option.h"
38#include "meta.h"
40#include <qdir.h> 39#include <qdir.h>
41#include <qdict.h> 40#include <qdict.h>
42#include <qregexp.h> 41#include <qregexp.h>
43#include <stdlib.h> 42#include <stdlib.h>
44#include <time.h> 43#include <time.h>
44#include "qtmd5.h"
45#ifdef Q_OS_UNIX 45#ifdef Q_OS_UNIX
46# include <sys/types.h> 46# include <sys/types.h>
47# include <sys/stat.h> 47# include <sys/stat.h>
@@ -49,7 +49,6 @@
49 49
50// Note: this is fairly hacky, but it does the job... 50// Note: this is fairly hacky, but it does the job...
51 51
52
53ProjectBuilderMakefileGenerator::ProjectBuilderMakefileGenerator(QMakeProject *p) : UnixMakefileGenerator(p) 52ProjectBuilderMakefileGenerator::ProjectBuilderMakefileGenerator(QMakeProject *p) : UnixMakefileGenerator(p)
54{ 53{
55 54
@@ -67,16 +66,210 @@ ProjectBuilderMakefileGenerator::writeMakefile(QTextStream &t)
67 66
68 project->variables()["MAKEFILE"].clear(); 67 project->variables()["MAKEFILE"].clear();
69 project->variables()["MAKEFILE"].append("Makefile"); 68 project->variables()["MAKEFILE"].append("Makefile");
70 if(project->first("TEMPLATE") == "app" || project->first("TEMPLATE") == "lib") { 69 if(project->first("TEMPLATE") == "app" || project->first("TEMPLATE") == "lib")
71 return writeMakeParts(t); 70 return writeMakeParts(t);
72 } else if(project->first("TEMPLATE") == "subdirs") { 71 else if(project->first("TEMPLATE") == "subdirs")
73 writeSubdirs(t, FALSE); 72 return writeSubdirs(t, FALSE);
74 return TRUE;
75 }
76 return FALSE; 73 return FALSE;
77} 74}
78 75
79bool 76bool
77ProjectBuilderMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
78{
79 QString mkwrap = fileFixify(pbx_dir + Option::dir_sep + ".." + Option::dir_sep + project->first("MAKEFILE"),
80 QDir::currentDirPath());
81 QFile mkwrapf(mkwrap);
82 if(mkwrapf.open(IO_WriteOnly | IO_Translate)) {
83 debug_msg(1, "pbuilder: Creating file: %s", mkwrap.latin1());
84 QTextStream mkwrapt(&mkwrapf);
85 UnixMakefileGenerator::writeSubdirs(mkwrapt, direct);
86 }
87
88 //HEADER
89 t << "// !$*UTF8*$!" << "\n"
90 << "{" << "\n"
91 << "\t" << "archiveVersion = 1;" << "\n"
92 << "\t" << "classes = {" << "\n" << "\t" << "};" << "\n"
93 << "\t" << "objectVersion = " << pbuilderVersion() << ";" << "\n"
94 << "\t" << "objects = {" << endl;
95
96 //SUBDIRS
97 QStringList subdirs = project->variables()["SUBDIRS"];
98 QString oldpwd = QDir::currentDirPath();
99 QMap<QString, QStringList> groups;
100 for(QStringList::Iterator it = subdirs.begin(); it != subdirs.end(); ++it) {
101 QFileInfo fi(Option::fixPathToLocalOS((*it), TRUE));
102 if(fi.exists()) {
103 if(fi.isDir()) {
104 QString profile = (*it);
105 if(!profile.endsWith(Option::dir_sep))
106 profile += Option::dir_sep;
107 profile += fi.baseName() + ".pro";
108 subdirs.append(profile);
109 } else {
110 QMakeProject tmp_proj;
111 QString dir = fi.dirPath(), fn = fi.fileName();
112 if(!dir.isEmpty()) {
113 if(!QDir::setCurrent(dir))
114 fprintf(stderr, "Cannot find directory: %s\n", dir.latin1());
115 }
116 if(tmp_proj.read(fn, oldpwd)) {
117 if(Option::debug_level) {
118 QMap<QString, QStringList> &vars = tmp_proj.variables();
119 for(QMap<QString, QStringList>::Iterator it = vars.begin();
120 it != vars.end(); ++it) {
121 if(it.key().left(1) != "." && !it.data().isEmpty())
122 debug_msg(1, "%s: %s === %s", fn.latin1(), it.key().latin1(),
123 it.data().join(" :: ").latin1());
124 }
125 }
126 if(tmp_proj.first("TEMPLATE") == "subdirs") {
127 subdirs += fileFixify(tmp_proj.variables()["SUBDIRS"]);
128 } else if(tmp_proj.first("TEMPLATE") == "app" || tmp_proj.first("TEMPLATE") == "lib") {
129 QString pbxproj = QDir::currentDirPath() + Option::dir_sep + tmp_proj.first("TARGET") + projectSuffix();
130 if(!QFile::exists(pbxproj)) {
131 warn_msg(WarnLogic, "Ignored (not found) '%s'", pbxproj.latin1());
132 goto nextfile; // # Dirty!
133 }
134 project->variables()["QMAKE_PBX_SUBDIRS"] += pbxproj;
135 //PROJECTREF
136 {
137 bool in_root = TRUE;
138 QString name = QDir::currentDirPath();
139 QString project_key = keyFor(pbxproj + "_PROJECTREF");
140 if(project->isActiveConfig("flat")) {
141 QString flat_file = fileFixify(name, oldpwd, Option::output_dir, TRUE);
142 if(flat_file.find(Option::dir_sep) != -1) {
143 QStringList dirs = QStringList::split(Option::dir_sep, flat_file);
144 name = dirs.back();
145 }
146 } else {
147 QString flat_file = fileFixify(name, oldpwd, Option::output_dir, TRUE);
148 if(QDir::isRelativePath(flat_file) && flat_file.find(Option::dir_sep) != -1) {
149 QString last_grp("QMAKE_PBX_HEIR_GROUP");
150 QStringList dirs = QStringList::split(Option::dir_sep, flat_file);
151 name = dirs.back();
152 for(QStringList::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) {
153 QString new_grp(last_grp + Option::dir_sep + (*dir_it)), new_grp_key(keyFor(new_grp));
154 if(dir_it == dirs.begin()) {
155 if(!groups.contains(new_grp))
156 project->variables()["QMAKE_PBX_GROUPS"].append(new_grp_key);
157 } else {
158 if(!groups[last_grp].contains(new_grp_key))
159 groups[last_grp] += new_grp_key;
160 }
161 last_grp = new_grp;
162 }
163 groups[last_grp] += project_key;
164 in_root = FALSE;
165 }
166 }
167 if(in_root)
168 project->variables()["QMAKE_PBX_GROUPS"] += project_key;
169 t << "\t\t" << project_key << " = {" << "\n"
170 << "\t\t\t" << "isa = PBXFileReference;" << "\n"
171 << "\t\t\t" << "name = " << tmp_proj.first("TARGET") << ";" << "\n"
172 << "\t\t\t" << "path = " << pbxproj << ";" << "\n"
173 << "\t\t\t" << "refType = 0;" << "\n"
174 << "\t\t\t" << "sourceTree = \"<absolute>\";" << "\n"
175 << "\t\t" << "};" << "\n";
176 //PRODUCTGROUP
177 t << "\t\t" << keyFor(pbxproj + "_PRODUCTGROUP") << " = {" << "\n"
178 << "\t\t\t" << "children = (" << "\n"
179 << "\t\t\t" << ");" << "\n"
180 << "\t\t\t" << "isa = PBXGroup;" << "\n"
181 << "\t\t\t" << "name = Products;" << "\n"
182 << "\t\t\t" << "refType = 4;" << "\n"
183 << "\t\t\t" << "sourceTree = \"<group>\";" << "\n"
184 << "\t\t" << "};" << "\n";
185 }
186 }
187 }
188nextfile:
189 QDir::setCurrent(oldpwd);
190 }
191 }
192 }
193 for(QMap<QString, QStringList>::Iterator grp_it = groups.begin(); grp_it != groups.end(); ++grp_it) {
194 t << "\t\t" << keyFor(grp_it.key()) << " = {" << "\n"
195 << "\t\t\t" << "isa = PBXGroup;" << "\n"
196 << "\t\t\t" << "children = (" << "\n"
197 << valGlue(grp_it.data(), "\t\t\t\t", ",\n\t\t\t\t", "\n")
198 << "\t\t\t" << ");" << "\n"
199 << "\t\t\t" << "name = \"" << grp_it.key().section(Option::dir_sep, -1) << "\";" << "\n"
200 << "\t\t\t" << "refType = 4;" << "\n"
201 << "\t\t" << "};" << "\n";
202 }
203
204 //DUMP EVERYTHING THAT TIES THE ABOVE TOGETHER
205 //BUILDSTYLE
206 QString active_buildstyle;
207#if 0
208 for(int as_release = 0; as_release < 2; as_release++)
209#else
210 bool as_release = !project->isActiveConfig("debug");
211#endif
212 {
213 QString key = keyFor("QMAKE_PBX_" + QString(as_release ? "RELEASE" : "DEBUG"));
214 if(project->isActiveConfig("debug") != as_release)
215 active_buildstyle = key;
216 project->variables()["QMAKE_PBX_BUILDSTYLES"].append(key);
217 t << "\t\t" << key << " = {" << "\n"
218 << "\t\t\t" << "buildRules = (" << "\n"
219 << "\t\t\t" << ");" << "\n"
220 << "\t\t\t" << "buildSettings = {" << "\n"
221 << "\t\t\t\t" << "COPY_PHASE_STRIP = " << (as_release ? "YES" : "NO") << ";" << "\n";
222 if(as_release)
223 t << "\t\t\t\t" << "DEBUGGING_SYMBOLS = NO;" << "\n";
224 t << "\t\t\t" << "};" << "\n"
225 << "\t\t\t" << "isa = PBXBuildStyle;" << "\n"
226 << "\t\t\t" << "name = " << (as_release ? "Deployment" : "Development") << ";" << "\n"
227 << "\t\t" << "};" << "\n";
228 }
229
230 //ROOT_GROUP
231 t << "\t\t" << keyFor("QMAKE_PBX_ROOT_GROUP") << " = {" << "\n"
232 << "\t\t\t" << "children = (" << "\n"
233 << varGlue("QMAKE_PBX_GROUPS", "\t\t\t\t", ",\n\t\t\t\t", "\n")
234 << "\t\t\t" << ");" << "\n"
235 << "\t\t\t" << "isa = PBXGroup;" << "\n"
236 << "\t\t\t" << "refType = 4;" << "\n"
237 << "\t\t\t" << "sourceTree = \"<group>\";" << "\n"
238 << "\t\t" << "};" << "\n";
239
240 //ROOT
241 t << "\t\t" << keyFor("QMAKE_PBX_ROOT") << " = {" << "\n"
242 << "\t\t\t" << "buildSettings = {" << "\n"
243 << "\t\t\t" << "};" << "\n"
244 << "\t\t\t" << "buildStyles = (" << "\n"
245 << varGlue("QMAKE_PBX_BUILDSTYLES", "\t\t\t\t", ",\n\t\t\t\t", "\n")
246 << "\t\t\t" << ");" << "\n"
247 << "\t\t\t" << "isa = PBXProject;" << "\n"
248 << "\t\t\t" << "mainGroup = " << keyFor("QMAKE_PBX_ROOT_GROUP") << ";" << "\n"
249 << "\t\t\t" << "projectDirPath = \"\";" << "\n"
250 << "\t\t\t" << "projectReferences = (" << "\n";
251 {
252 QStringList &libdirs = project->variables()["QMAKE_PBX_SUBDIRS"];
253 for(QStringList::Iterator it = libdirs.begin(); it != libdirs.end(); ++it)
254 t << "\t\t\t\t" << "{" << "\n"
255 << "\t\t\t\t\t" << "ProductGroup = " << keyFor((*it) + "_PRODUCTGROUP") << ";" << "\n"
256 << "\t\t\t\t\t" << "ProjectRef = " << keyFor((*it) + "_PROJECTREF") << ";" << "\n"
257 << "\t\t\t\t" << "}," << "\n";
258 }
259 t << "\t\t\t" << ");" << "\n"
260 << "\t\t\t" << "targets = (" << "\n"
261 << "\t\t\t" << ");" << "\n"
262 << "\t\t" << "};" << "\n";
263
264 //FOOTER
265 t << "\t" << "};" << "\n"
266 << "\t" << "rootObject = " << keyFor("QMAKE_PBX_ROOT") << ";" << "\n"
267 << "}" << endl;
268
269 return TRUE;
270}
271
272bool
80ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) 273ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
81{ 274{
82 int i; 275 int i;
@@ -107,7 +300,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
107 } 300 }
108 QString phase_key = keyFor("QMAKE_PBX_MAKEQMAKE_BUILDPHASE"); 301 QString phase_key = keyFor("QMAKE_PBX_MAKEQMAKE_BUILDPHASE");
109 mkfile = fileFixify(mkfile, QDir::currentDirPath()); 302 mkfile = fileFixify(mkfile, QDir::currentDirPath());
110 project->variables()["QMAKE_PBX_BUILDPHASES"].append(phase_key); 303 project->variables()["QMAKE_PBX_PRESCRIPT_BUILDPHASES"].append(phase_key);
111 t << "\t\t" << phase_key << " = {" << "\n" 304 t << "\t\t" << phase_key << " = {" << "\n"
112 << "\t\t\t" << "buildActionMask = 2147483647;" << "\n" 305 << "\t\t\t" << "buildActionMask = 2147483647;" << "\n"
113 << "\t\t\t" << "files = (" << "\n" 306 << "\t\t\t" << "files = (" << "\n"
@@ -126,29 +319,74 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
126 319
127 //DUMP SOURCES 320 //DUMP SOURCES
128 QMap<QString, QStringList> groups; 321 QMap<QString, QStringList> groups;
129 QString srcs[] = { "SOURCES", "SRCMOC", "UICIMPLS", QString::null }; 322 QString srcs[] = { "HEADERS", "SOURCES", "SRCMOC", "UICIMPLS", "QMAKE_IMAGE_COLLECTION",
323 "FORMS", "QMAKE_INTERNAL_INCLUDED_FILES", QString::null };
130 for(i = 0; !srcs[i].isNull(); i++) { 324 for(i = 0; !srcs[i].isNull(); i++) {
131 tmp = project->variables()[srcs[i]]; 325 tmp = project->variables()[srcs[i]];
326 if(srcs[i] == "QMAKE_INTERNAL_INCLUDED_FILES") {
327 QString pfile = project->projectFile();
328 if(pfile != "(stdin)")
329 tmp.prepend(pfile);
330 }
132 QStringList &src_list = project->variables()["QMAKE_PBX_" + srcs[i]]; 331 QStringList &src_list = project->variables()["QMAKE_PBX_" + srcs[i]];
332 QStringList &root_group_list = project->variables()["QMAKE_PBX_GROUPS"];
333
334 //hard coded groups..
335 QString src_group;
336 if(srcs[i] == "SOURCES")
337 src_group = "Sources";
338 else if(srcs[i] == "HEADERS")
339 src_group = "Headers";
340 else if(srcs[i] == "SRCMOC")
341 src_group = "Sources [moc]";
342 else if(srcs[i] == "UICIMPLS" || srcs[i] == "FORMS")
343 src_group = "Sources [uic]";
344 else if(srcs[i] == "QMAKE_IMAGE_COLLECTION")
345 src_group = "Sources [images]";
346 else if(srcs[i] == "QMAKE_INTERNAL_INCLUDED_FILES")
347 src_group = "Sources [qmake]";
348
133 for(QStringList::Iterator it = tmp.begin(); it != tmp.end(); ++it) { 349 for(QStringList::Iterator it = tmp.begin(); it != tmp.end(); ++it) {
134 QString file = fileFixify((*it)); 350 QStringList files = (*it);
135 if(file.endsWith(Option::moc_ext)) 351 bool buildable = TRUE;
352 if(srcs[i] == "FORMS") {
353 QString form_dot_h = (*it) + Option::h_ext.first();
354 if(QFile::exists(form_dot_h))
355 files += form_dot_h;
356 buildable = FALSE;
357 } else if(srcs[i] == "HEADERS" || srcs[i] == "QMAKE_INTERNAL_INCLUDED_FILES") {
358 buildable = FALSE;
359 }
360
361 files = fileFixify(files);
362 for(QStringList::Iterator file_it = files.begin(); file_it != files.end(); ++file_it) {
363 QString file = (*file_it);
364 if(file.length() >= 2 && (file[0] == '"' || file[0] == '\'') && file[(int) file.length()-1] == file[0])
365 file = file.mid(1, file.length()-2);
366 if(file.endsWith(Option::cpp_moc_ext) || file.endsWith(Option::prl_ext))
136 continue; 367 continue;
137 bool in_root = TRUE; 368 bool in_root = TRUE;
138 QString src_key = keyFor(file); 369 QString src_key = keyFor(file), name = file;
139 if(!project->isActiveConfig("flat")) { 370 if(project->isActiveConfig("flat")) {
371 QString flat_file = fileFixify(file, QDir::currentDirPath(), Option::output_dir, TRUE);
372 if(flat_file.find(Option::dir_sep) != -1) {
373 QStringList dirs = QStringList::split(Option::dir_sep, flat_file);
374 name = dirs.back();
375 }
376 } else {
140 QString flat_file = fileFixify(file, QDir::currentDirPath(), Option::output_dir, TRUE); 377 QString flat_file = fileFixify(file, QDir::currentDirPath(), Option::output_dir, TRUE);
141 if(QDir::isRelativePath(flat_file) && flat_file.find(Option::dir_sep) != -1) { 378 if(QDir::isRelativePath(flat_file) && flat_file.find(Option::dir_sep) != -1) {
142 QString last_grp("QMAKE_PBX_" + srcs[i] + "_HEIR_GROUP"); 379 QString last_grp("QMAKE_PBX_" + src_group + "_HEIR_GROUP");
143 QStringList dirs = QStringList::split(Option::dir_sep, flat_file); 380 QStringList dirs = QStringList::split(Option::dir_sep, flat_file);
381 name = dirs.back();
144 dirs.pop_back(); //remove the file portion as it will be added via src_key 382 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) { 383 for(QStringList::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) {
146 QString new_grp(last_grp + Option::dir_sep + (*dir_it)), 384 QString new_grp(last_grp + Option::dir_sep + (*dir_it)), new_grp_key(keyFor(new_grp));
147 new_grp_key(keyFor(new_grp)), last_grp_key(keyFor(last_grp));
148 if(dir_it == dirs.begin()) { 385 if(dir_it == dirs.begin()) {
149 if(!groups.contains(new_grp)) 386 if(!src_list.contains(new_grp_key))
150 project->variables()["QMAKE_PBX_" + srcs[i]].append(new_grp_key); 387 src_list.append(new_grp_key);
151 } else { 388 } else {
389 if(!groups[last_grp].contains(new_grp_key))
152 groups[last_grp] += new_grp_key; 390 groups[last_grp] += new_grp_key;
153 } 391 }
154 last_grp = new_grp; 392 last_grp = new_grp;
@@ -162,10 +400,22 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
162 //source reference 400 //source reference
163 t << "\t\t" << src_key << " = {" << "\n" 401 t << "\t\t" << src_key << " = {" << "\n"
164 << "\t\t\t" << "isa = PBXFileReference;" << "\n" 402 << "\t\t\t" << "isa = PBXFileReference;" << "\n"
403 << "\t\t\t" << "name = \"" << name << "\";" << "\n"
165 << "\t\t\t" << "path = \"" << file << "\";" << "\n" 404 << "\t\t\t" << "path = \"" << file << "\";" << "\n"
166 << "\t\t\t" << "refType = " << reftypeForFile(file) << ";" << "\n" 405 << "\t\t\t" << "refType = " << reftypeForFile(file) << ";" << "\n";
167 << "\t\t" << "};" << "\n"; 406 if (ideType() == MAC_XCODE) {
168 //build reference 407 QString filetype;
408 for(QStringList::Iterator cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) {
409 if(file.endsWith((*cppit))) {
410 filetype = "sourcecode.cpp.cpp";
411 break;
412 }
413 }
414 if(!filetype.isNull())
415 t << "\t\t\t" << "lastKnownFileType = " << filetype << ";" << "\n";
416 }
417 t << "\t\t" << "};" << "\n";
418 if(buildable) { //build reference
169 QString obj_key = file + ".o"; 419 QString obj_key = file + ".o";
170 obj_key = keyFor(obj_key); 420 obj_key = keyFor(obj_key);
171 t << "\t\t" << obj_key << " = {" << "\n" 421 t << "\t\t" << obj_key << " = {" << "\n"
@@ -178,8 +428,9 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
178 << "\t\t" << "};" << "\n"; 428 << "\t\t" << "};" << "\n";
179 project->variables()["QMAKE_PBX_OBJ"].append(obj_key); 429 project->variables()["QMAKE_PBX_OBJ"].append(obj_key);
180 } 430 }
431 }
432 }
181 if(!src_list.isEmpty()) { 433 if(!src_list.isEmpty()) {
182 QString grp;
183 if(srcs[i] == "SOURCES") { 434 if(srcs[i] == "SOURCES") {
184 if(project->first("TEMPLATE") == "app" && !project->isEmpty("RC_FILE")) { //Icon 435 if(project->first("TEMPLATE") == "app" && !project->isEmpty("RC_FILE")) { //Icon
185 QString icns_file = keyFor("ICNS_FILE"); 436 QString icns_file = keyFor("ICNS_FILE");
@@ -196,26 +447,15 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
196 << "\t\t\t" << "};" << "\n" 447 << "\t\t\t" << "};" << "\n"
197 << "\t\t" << "};" << "\n"; 448 << "\t\t" << "};" << "\n";
198 } 449 }
199 grp = "Sources";
200 } else if(srcs[i] == "SRCMOC") {
201 grp = "Mocables";
202 } else if(srcs[i] == "UICIMPLS") {
203 grp = "UICables";
204 } 450 }
205 QString grp_key = keyFor(grp); 451
206 project->variables()["QMAKE_PBX_GROUPS"].append(grp_key); 452 QString src_group_key = keyFor(src_group);
207 t << "\t\t" << grp_key << " = {" << "\n" 453 if(root_group_list.findIndex(src_group_key) == -1)
208 << "\t\t\t" << "children = (" << "\n" 454 root_group_list += src_group_key;
209 << varGlue("QMAKE_PBX_" + srcs[i], "\t\t\t\t", ",\n\t\t\t\t", "\n") 455 groups[src_group] += src_list;
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 } 456 }
216 } 457 }
217 for(QMap<QString, QStringList>::Iterator grp_it = groups.begin(); 458 for(QMap<QString, QStringList>::Iterator grp_it = groups.begin(); grp_it != groups.end(); ++grp_it) {
218 grp_it != groups.end(); ++grp_it) {
219 t << "\t\t" << keyFor(grp_it.key()) << " = {" << "\n" 459 t << "\t\t" << keyFor(grp_it.key()) << " = {" << "\n"
220 << "\t\t\t" << "isa = PBXGroup;" << "\n" 460 << "\t\t\t" << "isa = PBXGroup;" << "\n"
221 << "\t\t\t" << "children = (" << "\n" 461 << "\t\t\t" << "children = (" << "\n"
@@ -236,8 +476,8 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
236 debug_msg(1, "pbuilder: Creating file: %s", mkfile.latin1()); 476 debug_msg(1, "pbuilder: Creating file: %s", mkfile.latin1());
237 QTextStream mkt(&mkf); 477 QTextStream mkt(&mkf);
238 writeHeader(mkt); 478 writeHeader(mkt);
239 mkt << "MOC = " << var("QMAKE_MOC") << endl; 479 mkt << "MOC = " << Option::fixPathToTargetOS(var("QMAKE_MOC")) << endl;
240 mkt << "UIC = " << var("QMAKE_UIC") << endl; 480 mkt << "UIC = " << Option::fixPathToTargetOS(var("QMAKE_UIC")) << endl;
241 mkt << "LEX = " << var("QMAKE_LEX") << endl; 481 mkt << "LEX = " << var("QMAKE_LEX") << endl;
242 mkt << "LEXFLAGS = " << var("QMAKE_LEXFLAGS") << endl; 482 mkt << "LEXFLAGS = " << var("QMAKE_LEXFLAGS") << endl;
243 mkt << "YACC = " << var("QMAKE_YACC") << endl; 483 mkt << "YACC = " << var("QMAKE_YACC") << endl;
@@ -245,6 +485,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
245 mkt << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; 485 mkt << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl;
246 mkt << "MOVE = " << var("QMAKE_MOVE") << endl << endl; 486 mkt << "MOVE = " << var("QMAKE_MOVE") << endl << endl;
247 mkt << "FORMS = " << varList("UICIMPLS") << endl; 487 mkt << "FORMS = " << varList("UICIMPLS") << endl;
488 mkt << "IMAGES = " << varList("QMAKE_IMAGE_COLLECTION") << endl;
248 mkt << "MOCS = " << varList("SRCMOC") << endl; 489 mkt << "MOCS = " << varList("SRCMOC") << endl;
249 mkt << "PARSERS ="; 490 mkt << "PARSERS =";
250 if(!project->isEmpty("YACCSOURCES")) { 491 if(!project->isEmpty("YACCSOURCES")) {
@@ -264,14 +505,16 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
264 } 505 }
265 } 506 }
266 mkt << "\n"; 507 mkt << "\n";
267 mkt << "preprocess: $(FORMS) $(MOCS) $(PARSERS)" << endl; 508 mkt << "preprocess: $(FORMS) $(MOCS) $(PARSERS) $(IMAGES)" << endl;
268 mkt << "preprocess_clean: mocclean uiclean parser_clean" << endl << endl; 509 mkt << "clean preprocess_clean: mocclean uiclean parser_clean" << endl << endl;
269 mkt << "mocclean:" << "\n"; 510 mkt << "mocclean:" << "\n";
270 if(!project->isEmpty("SRCMOC")) 511 if(!project->isEmpty("SRCMOC"))
271 mkt << "\t-rm -f $(MOCS)" << "\n"; 512 mkt << "\t-rm -f $(MOCS)" << "\n";
272 mkt << "uiclean:" << "\n"; 513 mkt << "uiclean:" << "\n";
273 if(!project->isEmpty("UICIMPLS")) 514 if(!project->isEmpty("UICIMPLS"))
274 mkt << "\t-rm -f $(FORMS)" << "\n"; 515 mkt << "\t-rm -f $(FORMS)" << "\n";
516 if(!project->isEmpty("QMAKE_IMAGE_COLLECTION"))
517 mkt << "\t-rm -f $(IMAGES)" << "\n";
275 mkt << "parser_clean:" << "\n"; 518 mkt << "parser_clean:" << "\n";
276 if(!project->isEmpty("YACCSOURCES") || !project->isEmpty("LEXSOURCES")) 519 if(!project->isEmpty("YACCSOURCES") || !project->isEmpty("LEXSOURCES"))
277 mkt << "\t-rm -f $(PARSERS)" << "\n"; 520 mkt << "\t-rm -f $(PARSERS)" << "\n";
@@ -281,36 +524,31 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
281 writeMocSrc(mkt, "UICDECLS"); 524 writeMocSrc(mkt, "UICDECLS");
282 writeYaccSrc(mkt, "YACCSOURCES"); 525 writeYaccSrc(mkt, "YACCSOURCES");
283 writeLexSrc(mkt, "LEXSOURCES"); 526 writeLexSrc(mkt, "LEXSOURCES");
527 writeImageSrc(mkt, "QMAKE_IMAGE_COLLECTION");
284 mkf.close(); 528 mkf.close();
285 } 529 }
286 QString target_key = keyFor("QMAKE_PBX_PREPROCESS_TARGET");
287 mkfile = fileFixify(mkfile, QDir::currentDirPath()); 530 mkfile = fileFixify(mkfile, QDir::currentDirPath());
288 t << "\t\t" << target_key << " = {" << "\n" 531 QString phase_key = keyFor("QMAKE_PBX_PREPROCESS_TARGET");
289 << "\t\t\t" << "buildArgumentsString = \"-f " << mkfile << "\";" << "\n" 532 //project->variables()["QMAKE_PBX_BUILDPHASES"].append(phase_key);
290 << "\t\t\t" << "buildPhases = (" << "\n" 533 project->variables()["QMAKE_PBX_PRESCRIPT_BUILDPHASES"].append(phase_key);
534 t << "\t\t" << phase_key << " = {" << "\n"
535 << "\t\t\t" << "buildActionMask = 2147483647;" << "\n"
536 << "\t\t\t" << "files = (" << "\n"
291 << "\t\t\t" << ");" << "\n" 537 << "\t\t\t" << ");" << "\n"
292 << "\t\t\t" << "buildSettings = {" << "\n" 538 << "\t\t\t" << "generatedFileNames = (" << "\n"
293 << "\t\t\t" << "};" << "\n" 539 << varGlue("QMAKE_PBX_OBJ", "\t\t\t\t", ",\n\t\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" 540 << "\t\t\t" << ");" << "\n"
298 << "\t\t\t" << "isa = PBXLegacyTarget;" << "\n" 541 << "\t\t\t" << "isa = PBXShellScriptBuildPhase;" << "\n"
299 << "\t\t\t" << "name = QtPreprocessors;" << "\n" 542 << "\t\t\t" << "name = \"Qt Preprocessors\";" << "\n"
300 << "\t\t\t" << "productName = QtPreprocessors;" << "\n" 543 << "\t\t\t" << "neededFileNames = (" << "\n"
301 << "\t\t\t" << "settingsToExpand = 6;" << "\n" 544 << varGlue("QMAKE_PBX_OBJ", "\t\t\t\t", ",\n\t\t\t\t", "\n")
302 << "\t\t\t" << "settingsToPassInEnvironment = 287;" << "\n" 545 << "\t\t\t" << ");" << "\n"
303 << "\t\t\t" << "settingsToPassOnCommandLine = 280;" << "\n" 546 << "\t\t\t" << "shellPath = /bin/sh;" << "\n"
304 << "\t\t\t" << "shouldsUseHeadermap = 0;" << "\n" 547 << "\t\t\t" << "shellScript = \"make -C " << QDir::currentDirPath() <<
305 << "\t\t" << "};" << "\n"; 548 " -f " << mkfile << "\";" << "\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"; 549 << "\t\t" << "};" << "\n";
313 } 550 }
551
314 //SOURCE BUILDPHASE 552 //SOURCE BUILDPHASE
315 if(!project->isEmpty("QMAKE_PBX_OBJ")) { 553 if(!project->isEmpty("QMAKE_PBX_OBJ")) {
316 QString grp = "Build Sources", key = keyFor(grp); 554 QString grp = "Build Sources", key = keyFor(grp);
@@ -327,40 +565,44 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
327 565
328 if(!project->isActiveConfig("staticlib")) { //DUMP LIBRARIES 566 if(!project->isActiveConfig("staticlib")) { //DUMP LIBRARIES
329 QStringList &libdirs = project->variables()["QMAKE_PBX_LIBPATHS"]; 567 QStringList &libdirs = project->variables()["QMAKE_PBX_LIBPATHS"];
330 QString libs[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_LIBS", QString::null }; 568 QString libs[] = { "QMAKE_LFLAGS", "QMAKE_LIBDIR_FLAGS", "QMAKE_LIBS", QString::null };
331 for(i = 0; !libs[i].isNull(); i++) { 569 for(i = 0; !libs[i].isNull(); i++) {
332 tmp = project->variables()[libs[i]]; 570 tmp = project->variables()[libs[i]];
333 for(QStringList::Iterator it = tmp.begin(); it != tmp.end();) { 571 for(QStringList::Iterator it = tmp.begin(); it != tmp.end();) {
334 bool remove = FALSE; 572 bool remove = FALSE;
335 QString library, name, opt = (*it).stripWhiteSpace(); 573 QString library, name, opt = (*it).stripWhiteSpace();
574 if(opt.length() >= 2 && (opt[0] == '"' || opt[0] == '\'') && opt[(int) opt.length()-1] == opt[0])
575 opt = opt.mid(1, opt.length()-2);
336 if(opt.startsWith("-L")) { 576 if(opt.startsWith("-L")) {
337 QString r = opt.right(opt.length() - 2); 577 QString r = opt.right(opt.length() - 2);
338 fixEnvVariables(r); 578 fixEnvVariables(r);
339 libdirs.append(r); 579 libdirs.append(r);
580 } else if(opt == "-prebind") {
581 project->variables()["QMAKE_DO_PREBINDING"].append("TRUE");
582 remove = TRUE;
340 } else if(opt.startsWith("-l")) { 583 } else if(opt.startsWith("-l")) {
341 name = opt.right(opt.length() - 2); 584 name = opt.right(opt.length() - 2);
342 QString lib("lib" + name); 585 QString lib("lib" + name);
343 for(QStringList::Iterator lit = libdirs.begin(); lit != libdirs.end(); ++lit) { 586 for(QStringList::Iterator lit = libdirs.begin(); lit != libdirs.end(); ++lit) {
344 if(project->isActiveConfig("link_prl")) { 587 if(project->isActiveConfig("link_prl")) {
345 /* This isn't real nice, but it is real useful. This looks in a prl 588 /* 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 589 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 590 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 591 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 592 encode the version number in the Project file which might be a bad
350 things in days to come? --Sam 593 things in days to come? --Sam
351 */ 594 */
352 QString prl_file = (*lit) + Option::dir_sep + lib + Option::prl_ext; 595 QString lib_file = (*lit) + Option::dir_sep + lib;
353 if(QFile::exists(prl_file)) { 596 if(QMakeMetaInfo::libExists(lib_file)) {
354 QMakeProject proj; 597 QMakeMetaInfo libinfo;
355 if(proj.read(prl_file, QDir::currentDirPath())) { 598 if(libinfo.readLib(lib_file)) {
356 if(!proj.isEmpty("QMAKE_PRL_TARGET")) { 599 if(!libinfo.isEmpty("QMAKE_PRL_TARGET")) {
357 library = (*lit) + Option::dir_sep + proj.first("QMAKE_PRL_TARGET"); 600 library = (*lit) + Option::dir_sep + libinfo.first("QMAKE_PRL_TARGET");
358 debug_msg(1, "pbuilder: Found library (%s) via PRL %s (%s)", 601 debug_msg(1, "pbuilder: Found library (%s) via PRL %s (%s)",
359 opt.latin1(), prl_file.latin1(), library.latin1()); 602 opt.latin1(), lib_file.latin1(), library.latin1());
360 remove = TRUE; 603 remove = TRUE;
361 } 604 }
362 } 605 }
363
364 } 606 }
365 } 607 }
366 if(!remove) { 608 if(!remove) {
@@ -392,6 +634,8 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
392 break; 634 break;
393 } 635 }
394 } 636 }
637 } else if(opt == "-undefined") {
638 ++it; //the next option is not a library..
395 } else if(opt.left(1) != "-") { 639 } else if(opt.left(1) != "-") {
396 remove = TRUE; 640 remove = TRUE;
397 library = opt; 641 library = opt;
@@ -453,7 +697,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
453 } 697 }
454 QString phase_key = keyFor("QMAKE_PBX_SUBLIBS_BUILDPHASE"); 698 QString phase_key = keyFor("QMAKE_PBX_SUBLIBS_BUILDPHASE");
455 mkfile = fileFixify(mkfile, QDir::currentDirPath()); 699 mkfile = fileFixify(mkfile, QDir::currentDirPath());
456 project->variables()["QMAKE_PBX_BUILDPHASES"].append(phase_key); 700 project->variables()["QMAKE_PBX_PRESCRIPT_BUILDPHASES"].append(phase_key);
457 t << "\t\t" << phase_key << " = {" << "\n" 701 t << "\t\t" << phase_key << " = {" << "\n"
458 << "\t\t\t" << "buildActionMask = 2147483647;" << "\n" 702 << "\t\t\t" << "buildActionMask = 2147483647;" << "\n"
459 << "\t\t\t" << "files = (" << "\n" 703 << "\t\t\t" << "files = (" << "\n"
@@ -498,8 +742,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
498 << "\t\t\t" << "name = \"" << grp << "\";" << "\n" 742 << "\t\t\t" << "name = \"" << grp << "\";" << "\n"
499 << "\t\t" << "};" << "\n"; 743 << "\t\t" << "};" << "\n";
500 } 744 }
501 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console") && 745 if(!project->isActiveConfig("console") && project->first("TEMPLATE") == "app") { //BUNDLE RESOURCES
502 project->first("TEMPLATE") == "app") { //BUNDLE RESOURCES
503 QString grp("Bundle Resources"), key = keyFor(grp); 746 QString grp("Bundle Resources"), key = keyFor(grp);
504 project->variables()["QMAKE_PBX_BUILDPHASES"].append(key); 747 project->variables()["QMAKE_PBX_BUILDPHASES"].append(key);
505 t << "\t\t" << key << " = {" << "\n" 748 t << "\t\t" << key << " = {" << "\n"
@@ -511,21 +754,6 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
511 << "\t\t\t" << "name = \"" << grp << "\";" << "\n" 754 << "\t\t\t" << "name = \"" << grp << "\";" << "\n"
512 << "\t\t" << "};" << "\n"; 755 << "\t\t" << "};" << "\n";
513 } 756 }
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) 757 { //INSTALL BUILDPHASE (sh script)
530 QString targ = project->first("TARGET"); 758 QString targ = project->first("TARGET");
531 if(project->first("TEMPLATE") == "app" || 759 if(project->first("TEMPLATE") == "app" ||
@@ -540,7 +768,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
540 if(project->first("TEMPLATE") == "app") { 768 if(project->first("TEMPLATE") == "app") {
541 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) 769 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console"))
542 targ += ".app"; 770 targ += ".app";
543 } else if(!project->isActiveConfig("staticlib") && 771 } else if(!project->isActiveConfig("staticlib") && !project->isActiveConfig("plugin") &&
544 !project->isActiveConfig("frameworklib")) { 772 !project->isActiveConfig("frameworklib")) {
545 QString li[] = { "TARGET_", "TARGET_x", "TARGET_x.y", QString::null }; 773 QString li[] = { "TARGET_", "TARGET_x", "TARGET_x.y", QString::null };
546 for(int n = 0; !li[n].isNull(); n++) { 774 for(int n = 0; !li[n].isNull(); n++) {
@@ -559,7 +787,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
559 QString targ = project->first("QMAKE_ORIG_TARGET"), cpflags; 787 QString targ = project->first("QMAKE_ORIG_TARGET"), cpflags;
560 if(project->first("TEMPLATE") == "app") { 788 if(project->first("TEMPLATE") == "app") {
561 targ = project->first("TARGET"); 789 targ = project->first("TARGET");
562 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) { 790 if(!project->isActiveConfig("console")) {
563 targ += ".app"; 791 targ += ".app";
564 cpflags += "-r "; 792 cpflags += "-r ";
565 } 793 }
@@ -568,24 +796,26 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
568 targ = project->first("TARGET"); 796 targ = project->first("TARGET");
569 else 797 else
570 targ = project->first("TARGET_"); 798 targ = project->first("TARGET_");
799 }
571 int slsh = targ.findRev(Option::dir_sep); 800 int slsh = targ.findRev(Option::dir_sep);
572 if(slsh != -1) 801 if(slsh != -1)
573 targ = targ.right(targ.length() - slsh - 1); 802 targ = targ.right(targ.length() - slsh - 1);
574 } 803
575 QTextStream sht(&shf);
576 QString dstdir = project->first("DESTDIR"); 804 QString dstdir = project->first("DESTDIR");
577 fixEnvVariables(dstdir); 805 fixEnvVariables(dstdir);
578 806
807 QTextStream sht(&shf);
579 sht << "#!/bin/sh" << endl; 808 sht << "#!/bin/sh" << endl;
580 //copy the actual target 809 //copy the actual target
581 sht << "OUT_TARG=\"" << targ << "\"\n" 810 sht << "OUT_TARG=\"${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}\"\n"
582 << "[ -z \"$BUILD_ROOT\" ] || OUT_TARG=\"${BUILD_ROOT}/${OUT_TARG}\"" << endl; 811 << "if [ -e \"$OUT_TARG\" ]; then" << "\n"
583 sht << "[ \"$OUT_TARG\" = \"" 812 << " [ \"$OUT_TARG\" = \""
584 << (dstdir.isEmpty() ? QDir::currentDirPath() + QDir::separator(): dstdir) << targ << "\" ] || " 813 << (dstdir.isEmpty() ? QDir::currentDirPath() + QDir::separator(): dstdir) << targ << "\" ] || "
585 << "[ \"$OUT_TARG\" = \"" << targ << "\" ] || " 814 << "[ \"$OUT_TARG\" = \"" << targ << "\" ] || "
586 << "cp -r \"$OUT_TARG\" " << "\"" << dstdir << targ << "\"" << endl; 815 << "cp -r \"$OUT_TARG\" " << "\"" << dstdir << targ << "\"" << "\n"
816 << "fi" << endl;
587 //rename as a framework 817 //rename as a framework
588 if(project->first("TEMPLATE") == "lib" && project->isActiveConfig("frameworklib")) 818 if(project->first("TEMPLATE") == "lib" && project->isActiveConfig("frameworklib") && !project->isActiveConfig("plugin"))
589 sht << "ln -sf \"" << targ << "\" " << "\"" << dstdir << targ << "\"" << endl; 819 sht << "ln -sf \"" << targ << "\" " << "\"" << dstdir << targ << "\"" << endl;
590 //create all the version symlinks (just to be like unixmake) 820 //create all the version symlinks (just to be like unixmake)
591 for(QStringList::Iterator it = links.begin(); it != links.end(); ++it) { 821 for(QStringList::Iterator it = links.begin(); it != links.end(); ++it) {
@@ -600,7 +830,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
600 script = fileFixify(script, QDir::currentDirPath()); 830 script = fileFixify(script, QDir::currentDirPath());
601 project->variables()["QMAKE_PBX_BUILDPHASES"].append(phase_key); 831 project->variables()["QMAKE_PBX_BUILDPHASES"].append(phase_key);
602 t << "\t\t" << phase_key << " = {" << "\n" 832 t << "\t\t" << phase_key << " = {" << "\n"
603 << "\t\t\t" << "buildActionMask = 8;" << "\n" //only on install! 833 << "\t\t\t" << "buildActionMask = 2147483647;" << "\n"
604 << "\t\t\t" << "files = (" << "\n" 834 << "\t\t\t" << "files = (" << "\n"
605 << "\t\t\t" << ");" << "\n" 835 << "\t\t\t" << ");" << "\n"
606 << "\t\t\t" << "generatedFileNames = (" << "\n" 836 << "\t\t\t" << "generatedFileNames = (" << "\n"
@@ -614,6 +844,45 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
614 << "\t\t" << "};" << "\n"; 844 << "\t\t" << "};" << "\n";
615 } 845 }
616 } 846 }
847 if(/*ideType() == MAC_XCODE &&*/ !project->isEmpty("QMAKE_PBX_PRESCRIPT_BUILDPHASES") && 0) {
848 // build reference
849 t << "\t\t" << keyFor("QMAKE_PBX_PRESCRIPT_BUILDREFERENCE") << " = {" << "\n"
850 << "\t\t\t" << "includeInIndex = 0;" << "\n"
851 << "\t\t\t" << "isa = PBXFileReference;" << "\n"
852 << "\t\t\t" << "path = preprocessor.out;" << "\n"
853 << "\t\t\t" << "refType = 3;" << "\n"
854 << "\t\t\t" << "sourceTree = BUILT_PRODUCTS_DIR;" << "\n"
855 << "\t\t" << "};" << "\n";
856 project->variables()["QMAKE_PBX_PRODUCTS"].append(keyFor("QMAKE_PBX_PRESCRIPTS_BUILDREFERENCE"));
857 //build phase
858 QString prescript_key = keyFor("QMAKE_PBX_PRESCRIPTS_BUILDPHASE");
859 project->variables()["QMAKE_PBX_TARGETS"].append(prescript_key);
860 t << "\t\t" << prescript_key << " = {" << "\n"
861 << "\t\t\t" << "buildPhases = (" << "\n"
862 << varGlue("QMAKE_PBX_PRESCRIPT_BUILDPHASES", "\t\t\t\t", ",\n\t\t\t\t", "\n")
863 << "\t\t\t" << ");" << "\n"
864 << "\t\t\t" << "buildRules = (" << "\n"
865 << "\t\t\t" << ");" << "\n"
866 << "\t\t\t" << "buildSettings = {" << "\n"
867 << "\t\t\t" << "};" << "\n"
868 << "\t\t\t" << "dependencies = (" << "\n"
869 << "\t\t\t" << ");" << "\n"
870 << "\t\t\t" << "isa = PBXNativeTarget;" << "\n"
871 << "\t\t\t" << "name = \"Qt Preprocessor Steps\";" << "\n"
872 << "\t\t\t" << "productName = \"Qt Preprocessor Steps\";" << "\n"
873 << "\t\t\t" << "productReference = " << keyFor("QMAKE_PBX_PRESCRIPTS_BUILDREFERENCE") << ";" << "\n"
874 << "\t\t\t" << "productType = \"com.apple.product-type.tool\";" << "\n"
875 << "\t\t" << "};" << "\n";
876 //dependency
877 t << "\t\t" << keyFor("QMAKE_PBX_PRESCRIPTS_DEPENDENCY") << " = {" << "\n"
878 << "\t\t\t" << "isa = PBXTargetDependency;" << "\n"
879 << "\t\t\t" << "target = " << keyFor("QMAKE_PBX_PRESCRIPTS_BUILDPHASE") << ";" << "\n"
880 << "\t\t" << "};" << "\n";
881 project->variables()["QMAKE_PBX_TARGET_DEPENDS"].append(keyFor("QMAKE_PBX_PRESCRIPTS_DEPENDENCY"));
882 project->variables()["QMAKE_PBX_PRESCRIPT_BUILDPHASES"].clear(); //these are already consumed above
883 }
884
885 //DUMP EVERYTHING THAT TIES THE ABOVE TOGETHER
617 //ROOT_GROUP 886 //ROOT_GROUP
618 t << "\t\t" << keyFor("QMAKE_PBX_ROOT_GROUP") << " = {" << "\n" 887 t << "\t\t" << keyFor("QMAKE_PBX_ROOT_GROUP") << " = {" << "\n"
619 << "\t\t\t" << "children = (" << "\n" 888 << "\t\t\t" << "children = (" << "\n"
@@ -625,7 +894,9 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
625 << "\t\t\t" << "refType = 4;" << "\n" 894 << "\t\t\t" << "refType = 4;" << "\n"
626 << "\t\t" << "};" << "\n"; 895 << "\t\t" << "};" << "\n";
627 //REFERENCE 896 //REFERENCE
628 t << "\t\t" << keyFor("QMAKE_PBX_REFERENCE") << " = {" << "\n"; 897 project->variables()["QMAKE_PBX_PRODUCTS"].append(keyFor(pbx_dir + "QMAKE_PBX_REFERENCE"));
898 t << "\t\t" << keyFor(pbx_dir + "QMAKE_PBX_REFERENCE") << " = {" << "\n"
899 << "\t\t\t" << "fallbackIsa = PBXFileReference;" << "\n";
629 if(project->first("TEMPLATE") == "app") { 900 if(project->first("TEMPLATE") == "app") {
630 QString targ = project->first("QMAKE_ORIG_TARGET"); 901 QString targ = project->first("QMAKE_ORIG_TARGET");
631 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) { 902 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) {
@@ -653,31 +924,80 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
653 if(slsh != -1) 924 if(slsh != -1)
654 lib = lib.right(lib.length() - slsh - 1); 925 lib = lib.right(lib.length() - slsh - 1);
655 t << "\t\t\t" << "isa = PBXLibraryReference;" << "\n" 926 t << "\t\t\t" << "isa = PBXLibraryReference;" << "\n"
927 << "\t\t\t" << "expectedFileType = \"compiled.mach-o.dylib\";" << "\n"
656 << "\t\t\t" << "path = " << lib << ";\n" 928 << "\t\t\t" << "path = " << lib << ";\n"
657 << "\t\t\t" << "refType = " << reftypeForFile(lib) << ";" << "\n"; 929 << "\t\t\t" << "refType = " << 3/*reftypeForFile(lib)*/ << ";" << "\n"
930 << "\t\t\t" << "sourceTree = BUILT_PRODUCTS_DIR" << ";" << "\n";
658 } 931 }
659 t << "\t\t" << "};" << "\n"; 932 t << "\t\t" << "};" << "\n";
933 { //Products group
934 QString grp("Products"), key = keyFor(grp);
935 project->variables()["QMAKE_PBX_GROUPS"].append(key);
936 t << "\t\t" << key << " = {" << "\n"
937 << "\t\t\t" << "children = (" << "\n"
938 << varGlue("QMAKE_PBX_PRODUCTS", "\t\t\t\t", ",\n\t\t\t\t", "\n")
939 << "\t\t\t" << ");" << "\n"
940 << "\t\t\t" << "isa = PBXGroup;" << "\n"
941 << "\t\t\t" << "name = Products;" << "\n"
942 << "\t\t\t" << "refType = 4;" << "\n"
943 << "\t\t" << "};" << "\n";
944 }
660 //TARGET 945 //TARGET
661 t << "\t\t" << keyFor("QMAKE_PBX_TARGET") << " = {" << "\n" 946 QString target_key = keyFor("QMAKE_PBX_TARGET");
947 project->variables()["QMAKE_PBX_TARGETS"].append(target_key);
948 t << "\t\t" << target_key << " = {" << "\n"
662 << "\t\t\t" << "buildPhases = (" << "\n" 949 << "\t\t\t" << "buildPhases = (" << "\n"
950 << varGlue("QMAKE_PBX_PRESCRIPT_BUILDPHASES", "\t\t\t\t", ",\n\t\t\t\t", ",\n")
663 << varGlue("QMAKE_PBX_BUILDPHASES", "\t\t\t\t", ",\n\t\t\t\t", "\n") 951 << varGlue("QMAKE_PBX_BUILDPHASES", "\t\t\t\t", ",\n\t\t\t\t", "\n")
664 << "\t\t\t" << ");" << "\n" 952 << "\t\t\t" << ");" << "\n"
665 << "\t\t\t" << "buildSettings = {" << "\n" 953 << "\t\t\t" << "buildSettings = {" << "\n"
954 << "\t\t\t\t" << "CC = \"" << fixEnvsList("QMAKE_CC") << "\";" << "\n"
955 << "\t\t\t\t" << "CPLUSPLUS = \"" << fixEnvsList("QMAKE_CXX") << "\";" << "\n"
666 << "\t\t\t\t" << "FRAMEWORK_SEARCH_PATHS = \"\";" << "\n" 956 << "\t\t\t\t" << "FRAMEWORK_SEARCH_PATHS = \"\";" << "\n"
667 << "\t\t\t\t" << "HEADER_SEARCH_PATHS = \"" << fixEnvsList("INCLUDEPATH") << " " << fixEnvs(specdir()) << "\";" << "\n" 957 << "\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" 958 << "\t\t\t\t" << "LIBRARY_SEARCH_PATHS = \"" << var("QMAKE_PBX_LIBPATHS") << "\";" << "\n"
669 << "\t\t\t\t" << "OPTIMIZATION_CFLAGS = \"\";" << "\n" 959 << "\t\t\t\t" << "OPTIMIZATION_CFLAGS = \"\";" << "\n"
670 << "\t\t\t\t" << "OTHER_CFLAGS = \"" << 960 << "\t\t\t\t" << "OTHER_CFLAGS = \"" <<
671 fixEnvsList("QMAKE_CFLAGS") << varGlue("PRL_EXPORT_DEFINES"," -D"," -D","") << 961 fixEnvsList("QMAKE_CFLAGS") << fixQuotes(varGlue("PRL_EXPORT_DEFINES"," -D"," -D","")) <<
672 varGlue("DEFINES"," -D"," -D","") << "\";" << "\n" 962 fixQuotes(varGlue("DEFINES"," -D"," -D","")) << "\";" << "\n"
673 << "\t\t\t\t" << "LEXFLAGS = \"" << var("QMAKE_LEXFLAGS") << "\";" << "\n" 963 << "\t\t\t\t" << "LEXFLAGS = \"" << var("QMAKE_LEXFLAGS") << "\";" << "\n"
674 << "\t\t\t\t" << "YACCFLAGS = \"" << var("QMAKE_YACCFLAGS") << "\";" << "\n" 964 << "\t\t\t\t" << "YACCFLAGS = \"" << var("QMAKE_YACCFLAGS") << "\";" << "\n"
675 << "\t\t\t\t" << "OTHER_CPLUSPLUSFLAGS = \"" << 965 << "\t\t\t\t" << "OTHER_CPLUSPLUSFLAGS = \"" <<
676 fixEnvsList("QMAKE_CXXFLAGS") << varGlue("PRL_EXPORT_DEFINES"," -D"," -D","") << 966 fixEnvsList("QMAKE_CXXFLAGS") << fixQuotes(varGlue("PRL_EXPORT_DEFINES"," -D"," -D","")) <<
677 varGlue("DEFINES"," -D"," -D","") << "\";" << "\n" 967 fixQuotes(varGlue("DEFINES"," -D"," -D","")) << "\";" << "\n"
678 << "\t\t\t\t" << "OTHER_REZFLAGS = \"\";" << "\n" 968 << "\t\t\t\t" << "OTHER_REZFLAGS = \"\";" << "\n"
679 << "\t\t\t\t" << "SECTORDER_FLAGS = \"\";" << "\n" 969 << "\t\t\t\t" << "SECTORDER_FLAGS = \"\";" << "\n"
680 << "\t\t\t\t" << "WARNING_CFLAGS = \"\";" << "\n"; 970 << "\t\t\t\t" << "WARNING_CFLAGS = \"\";" << "\n"
971 << "\t\t\t\t" << "PREBINDING = " << (project->isEmpty("QMAKE_DO_PREBINDING") ? "NO" : "YES") << ";" << "\n";
972 if(!project->isEmpty("PRECOMPILED_HEADER")) {
973 if (ideType() == MAC_XCODE) {
974 t << "\t\t\t\t" << "GCC_PRECOMPILE_PREFIX_HEADER = \"YES\";" << "\n"
975 << "\t\t\t\t" << "GCC_PREFIX_HEADER = \"" << project->first("PRECOMPILED_HEADER") << "\";" << "\n";
976 } else {
977 t << "\t\t\t\t" << "PRECOMPILE_PREFIX_HEADER = \"YES\";" << "\n"
978 << "\t\t\t\t" << "PREFIX_HEADER = \"" << project->first("PRECOMPILED_HEADER") << "\";" << "\n";
979 }
980 }
981 if(project->first("TEMPLATE") == "app") {
982 QString plist = fileFixify(project->first("QMAKE_INFO_PLIST"));
983 if(plist.isEmpty())
984 plist = specdir() + QDir::separator() + "Info.plist." + project->first("TEMPLATE");
985 if(QFile::exists(plist)) {
986 QFile plist_in_file(plist);
987 if(plist_in_file.open(IO_ReadOnly)) {
988 QTextStream plist_in(&plist_in_file);
989 QString plist_in_text = plist_in.read();
990 plist_in_text = plist_in_text.replace("@ICON@", (project->isEmpty("RC_FILE") ? QString("") : project->first("RC_FILE").section(Option::dir_sep, -1)));
991 plist_in_text = plist_in_text.replace("@EXECUTABLE@", project->first("QMAKE_ORIG_TARGET"));
992 QFile plist_out_file("Info.plist");
993 if(plist_out_file.open(IO_WriteOnly | IO_Translate)) {
994 QTextStream plist_out(&plist_out_file);
995 plist_out << plist_in_text;
996 t << "\t\t\t\t" << "INFOPLIST_FILE = \"Info.plist\";" << "\n";
997 }
998 }
999 }
1000 }
681#if 1 1001#if 1
682 t << "\t\t\t\t" << "BUILD_ROOT = \"" << QDir::currentDirPath() << "\";" << "\n"; 1002 t << "\t\t\t\t" << "BUILD_ROOT = \"" << QDir::currentDirPath() << "\";" << "\n";
683#endif 1003#endif
@@ -685,50 +1005,91 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
685 t << "\t\t\t\t" << "OTHER_LDFLAGS = \"" << fixEnvsList("SUBLIBS") << " " << 1005 t << "\t\t\t\t" << "OTHER_LDFLAGS = \"" << fixEnvsList("SUBLIBS") << " " <<
686 fixEnvsList("QMAKE_LFLAGS") << " " << fixEnvsList("QMAKE_LIBDIR_FLAGS") << 1006 fixEnvsList("QMAKE_LFLAGS") << " " << fixEnvsList("QMAKE_LIBDIR_FLAGS") <<
687 " " << fixEnvsList("QMAKE_LIBS") << "\";" << "\n"; 1007 " " << fixEnvsList("QMAKE_LIBS") << "\";" << "\n";
688 if(!project->isEmpty("DESTDIR")) 1008 if(!project->isEmpty("DESTDIR")) {
689 t << "\t\t\t\t" << "INSTALL_PATH = \"" << project->first("DESTDIR") << "\";" << "\n"; 1009 QString dir = project->first("DESTDIR");
690 if(!project->isEmpty("VERSION") && project->first("VERSION") != "0.0.0") 1010 if (QDir::isRelativePath(dir))
691 t << "\t\t\t\t" << "DYLIB_CURRENT_VERSION = \"" << project->first("VERSION") << "\";" << "\n"; 1011 dir.prepend(QDir::currentDirPath() + Option::dir_sep);
1012 t << "\t\t\t\t" << "INSTALL_DIR = \"" << dir << "\";" << "\n";
1013 }
1014 if ( project->first("TEMPLATE") == "lib") {
1015 t << "\t\t\t\t" << "INSTALL_PATH = \"" << "\";" << "\n";
1016 }
1017 if(!project->isEmpty("VERSION") && project->first("VERSION") != "0.0.0") {
1018 t << "\t\t\t\t" << "DYLIB_CURRENT_VERSION = \"" << project->first("VER_MAJ") << "."
1019 << project->first("VER_MIN") << "." << project->first("VER_PAT") << "\";" << "\n";
1020 if(project->isEmpty("COMPAT_VERSION"))
1021 t << "\t\t\t\t" << "DYLIB_COMPATIBILITY_VERSION = \"" << project->first("VER_MAJ") << "."
1022 << project->first("VER_MIN") << "\";" << "\n";
1023 }
1024 if(!project->isEmpty("COMPAT_VERSION"))
1025 t << "\t\t\t\t" << "DYLIB_COMPATIBILITY_VERSION = \"" << project->first("COMPAT_VERSION") << "\";" << "\n";
1026
1027 if(ideType() == MAC_XCODE) {
692 if(!project->isEmpty("OBJECTS_DIR")) 1028 if(!project->isEmpty("OBJECTS_DIR"))
693 t << "\t\t\t\t" << "OBJECT_FILE_DIR = \"" << project->first("OBJECTS_DIR") << "\";" << "\n"; 1029 t << "\t\t\t\t" << "OBJROOT = \"" << project->first("OBJECTS_DIR") << "\";" << "\n";
1030 }
1031#if 0
1032 if(!project->isEmpty("DESTDIR"))
1033 t << "\t\t\t\t" << "SYMROOT = \"" << project->first("DESTDIR") << "\";" << "\n";
1034 else
1035 t << "\t\t\t\t" << "SYMROOT = \"" << QDir::currentDirPath() << "\";" << "\n";
1036#endif
694 if(project->first("TEMPLATE") == "app") { 1037 if(project->first("TEMPLATE") == "app") {
695 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) 1038 if(ideType() == MAC_PBUILDER && !project->isActiveConfig("console"))
696 t << "\t\t\t\t" << "WRAPPER_EXTENSION = app;" << "\n"; 1039 t << "\t\t\t\t" << "WRAPPER_EXTENSION = app;" << "\n";
697 t << "\t\t\t\t" << "PRODUCT_NAME = " << project->first("QMAKE_ORIG_TARGET") << ";" << "\n"; 1040 t << "\t\t\t\t" << "PRODUCT_NAME = " << project->first("QMAKE_ORIG_TARGET") << ";" << "\n";
698 } else { 1041 } else {
699 QString lib = project->first("QMAKE_ORIG_TARGET");
700 if(!project->isActiveConfig("plugin") && project->isActiveConfig("staticlib")) { 1042 if(!project->isActiveConfig("plugin") && project->isActiveConfig("staticlib")) {
701 t << "\t\t\t\t" << "LIBRARY_STYLE = STATIC;" << "\n"; 1043 t << "\t\t\t\t" << "LIBRARY_STYLE = STATIC;" << "\n";
702 lib = project->first("TARGET");
703 } else { 1044 } else {
704 t << "\t\t\t\t" << "LIBRARY_STYLE = DYNAMIC;" << "\n"; 1045 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 } 1046 }
711 } 1047 QString lib = project->first("QMAKE_ORIG_TARGET");
712 int slsh = lib.findRev(Option::dir_sep); 1048 if (!project->isActiveConfig("frameworklib") && !project->isActiveConfig("staticlib"))
713 if(slsh != -1) 1049 lib.prepend("lib");
714 lib = lib.right(lib.length() - slsh - 1);
715 t << "\t\t\t\t" << "PRODUCT_NAME = " << lib << ";" << "\n"; 1050 t << "\t\t\t\t" << "PRODUCT_NAME = " << lib << ";" << "\n";
716 } 1051 }
717 tmp = project->variables()["QMAKE_PBX_VARS"]; 1052 tmp = project->variables()["QMAKE_PBX_VARS"];
718 for(QStringList::Iterator it = tmp.begin(); it != tmp.end(); ++it) 1053 for(QStringList::Iterator it = tmp.begin(); it != tmp.end(); ++it) {
719 t << "\t\t\t\t" << (*it) << " = \"" << getenv((*it)) << "\";" << "\n"; 1054 QString var = (*it), val = getenv(var);
1055 if(!val && var == "TB")
1056 val = "/usr/bin/";
1057 t << "\t\t\t\t" << var << " = \"" << val << "\";" << "\n";
1058 }
720 t << "\t\t\t" << "};" << "\n" 1059 t << "\t\t\t" << "};" << "\n"
721 << "\t\t\t" << "conditionalBuildSettings = {" << "\n" 1060 << "\t\t\t" << "conditionalBuildSettings = {" << "\n"
722 << "\t\t\t" << "};" << "\n" 1061 << "\t\t\t" << "};" << "\n"
723 << "\t\t\t" << "dependencies = (" << "\n" 1062 << "\t\t\t" << "dependencies = (" << "\n"
724 << varGlue("QMAKE_PBX_TARGETDEPENDS", "\t\t\t\t", ",\n\t\t\t\t", "\n") 1063 << varGlue("QMAKE_PBX_TARGET_DEPENDS", "\t\t\t\t", ",\n\t\t\t\t", "\n")
725 << "\t\t\t" << ");" << "\n" 1064 << "\t\t\t" << ");" << "\n"
726 << "\t\t\t" << "productReference = " << keyFor("QMAKE_PBX_REFERENCE") << ";" << "\n" 1065 << "\t\t\t" << "productReference = " << keyFor(pbx_dir + "QMAKE_PBX_REFERENCE") << ";" << "\n"
727 << "\t\t\t" << "shouldUseHeadermap = 1;" << "\n"; 1066 << "\t\t\t" << "shouldUseHeadermap = 1;" << "\n";
1067 if(ideType() == MAC_XCODE)
1068 t << "\t\t\t" << "isa = PBXNativeTarget;" << "\n";
728 if(project->first("TEMPLATE") == "app") { 1069 if(project->first("TEMPLATE") == "app") {
729 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) { 1070 if(project->isActiveConfig("console")) {
730 t << "\t\t\t" << "isa = PBXApplicationTarget;" << "\n" 1071 if(ideType() == MAC_XCODE)
731 << "\t\t\t" << "productSettingsXML = " << "\"" << "<?xml version=" 1072 t << "\t\t\t" << "productType = \"com.apple.product-type.tool\";" << "\n";
1073 else
1074 t << "\t\t\t" << "isa = PBXToolTarget;" << "\n";
1075 } else {
1076 if(ideType() == MAC_XCODE)
1077 t << "\t\t\t" << "productType = \"com.apple.product-type.application\";" << "\n";
1078 else
1079 t << "\t\t\t" << "isa = PBXApplicationReference;" << "\n";
1080 t << "\t\t\t" << "productSettingsXML = \"";
1081 bool read_plist = false;
1082 if(QFile::exists("Info.plist")) {
1083 QFile plist("Info.plist");
1084 if(plist.open(IO_ReadOnly)) {
1085 read_plist = true;
1086 QTextStream stream(&plist);
1087 while(!stream.eof())
1088 t << stream.readLine().replace('"', "\\\"") << endl;
1089 }
1090 }
1091 if(!read_plist) {
1092 t << "<?xml version="
732 << "\\\"1.0\\\" encoding=" << "\\\"UTF-8\\\"" << "?>" << "\n" 1093 << "\\\"1.0\\\" encoding=" << "\\\"UTF-8\\\"" << "?>" << "\n"
733 << "\t\t\t\t" << "<!DOCTYPE plist SYSTEM \\\"file://localhost/System/" 1094 << "\t\t\t\t" << "<!DOCTYPE plist SYSTEM \\\"file://localhost/System/"
734 << "Library/DTDs/PropertyList.dtd\\\">" << "\n" 1095 << "Library/DTDs/PropertyList.dtd\\\">" << "\n"
@@ -745,44 +1106,65 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
745 << "\t\t\t\t\t" << "<key>CFBundlePackageType</key>" << "\n" 1106 << "\t\t\t\t\t" << "<key>CFBundlePackageType</key>" << "\n"
746 << "\t\t\t\t\t" << "<string>APPL</string>" << "\n" 1107 << "\t\t\t\t\t" << "<string>APPL</string>" << "\n"
747 << "\t\t\t\t\t" << "<key>CFBundleSignature</key>" << "\n" 1108 << "\t\t\t\t\t" << "<key>CFBundleSignature</key>" << "\n"
748 << "\t\t\t\t\t" << "<string>????</string>" << "\n" 1109 //Although the output below looks strange it is to avoid the trigraph ??<
1110 << "\t\t\t\t\t" << "<string>????" << "</string>" << "\n"
749 << "\t\t\t\t\t" << "<key>CFBundleVersion</key>" << "\n" 1111 << "\t\t\t\t\t" << "<key>CFBundleVersion</key>" << "\n"
750 << "\t\t\t\t\t" << "<string>0.1</string>" << "\n" 1112 << "\t\t\t\t\t" << "<string>0.1</string>" << "\n"
751 << "\t\t\t\t\t" << "<key>CSResourcesFileMapped</key>" << "\n" 1113 << "\t\t\t\t\t" << "<key>CSResourcesFileMapped</key>" << "\n"
752 << "\t\t\t\t\t" << "<true/>" << "\n" 1114 << "\t\t\t\t\t" << "<true/>" << "\n"
753 << "\t\t\t\t" << "</dict>" << "\n" 1115 << "\t\t\t\t" << "</dict>" << "\n"
754 << "\t\t\t\t" << "</plist>" << "\";" << "\n"; 1116 << "\t\t\t\t" << "</plist>";
755 } else {
756 t << "\t\t\t" << "isa = PBXToolTarget;" << "\n";
757 } 1117 }
1118 }
1119 t << "\";" << "\n";
758 t << "\t\t\t" << "name = \"" << project->first("QMAKE_ORIG_TARGET") << "\";" << "\n" 1120 t << "\t\t\t" << "name = \"" << project->first("QMAKE_ORIG_TARGET") << "\";" << "\n"
759 << "\t\t\t" << "productName = " << project->first("QMAKE_ORIG_TARGET") << ";" << "\n"; 1121 << "\t\t\t" << "productName = " << project->first("QMAKE_ORIG_TARGET") << ";" << "\n";
760 } else { 1122 } else {
761 QString lib = project->first("QMAKE_ORIG_TARGET"); 1123 QString lib = project->first("QMAKE_ORIG_TARGET");
762 if(!project->isActiveConfig("frameworklib")) 1124 if(!project->isActiveConfig("frameworklib") && !project->isActiveConfig("staticlib"))
763 lib.prepend("lib"); 1125 lib.prepend("lib");
764 t << "\t\t\t" << "isa = PBXLibraryTarget;" << "\n" 1126 t << "\t\t\t" << "name = \"" << lib << "\";" << "\n"
765 << "\t\t\t" << "name = \"" << lib << "\";" << "\n"
766 << "\t\t\t" << "productName = " << lib << ";" << "\n"; 1127 << "\t\t\t" << "productName = " << lib << ";" << "\n";
1128 if(ideType() == MAC_XCODE) {
1129 if(project->isActiveConfig("staticlib"))
1130 t << "\t\t\t" << "productType = \"com.apple.product-type.library.static\";" << "\n";
1131 else
1132 t << "\t\t\t" << "productType = \"com.apple.product-type.library.dynamic\";" << "\n";
1133 } else {
1134 t << "\t\t\t" << "isa = PBXLibraryTarget;" << "\n";
767 } 1135 }
1136 }
1137 t << "\t\t\t" << "startupPath = \"<<ProjectDirectory>>\";" << "\n";
768 if(!project->isEmpty("DESTDIR")) 1138 if(!project->isEmpty("DESTDIR"))
769 t << "\t\t\t" << "productInstallPath = \"" << project->first("DESTDIR") << "\";" << "\n"; 1139 t << "\t\t\t" << "productInstallPath = \"" << project->first("DESTDIR") << "\";" << "\n";
770 t << "\t\t" << "};" << "\n"; 1140 t << "\t\t" << "};" << "\n";
771 //DEBUG/RELEASE 1141 //DEBUG/RELEASE
772 for(i = 0; i < 2; i++) { 1142 QString active_buildstyle;
773 bool as_release = !i; 1143#if 0
774 if(project->isActiveConfig("debug")) 1144 for(int as_release = 0; as_release < 2; as_release++)
775 as_release = i; 1145#else
776 QString key = "QMAKE_PBX_" + QString(as_release ? "RELEASE" : "DEBUG"); 1146 bool as_release = !project->isActiveConfig("debug");
777 key = keyFor(key); 1147#endif
1148 {
1149 QString key = keyFor("QMAKE_PBX_" + QString(as_release ? "RELEASE" : "DEBUG"));
1150 if(project->isActiveConfig("debug") != as_release)
1151 active_buildstyle = key;
778 project->variables()["QMAKE_PBX_BUILDSTYLES"].append(key); 1152 project->variables()["QMAKE_PBX_BUILDSTYLES"].append(key);
779 t << "\t\t" << key << " = {" << "\n" 1153 t << "\t\t" << key << " = {" << "\n"
780 << "\t\t\t" << "buildRules = (" << "\n" 1154 << "\t\t\t" << "buildRules = (" << "\n"
781 << "\t\t\t" << ");" << "\n" 1155 << "\t\t\t" << ");" << "\n"
782 << "\t\t\t" << "buildSettings = {" << "\n" 1156 << "\t\t\t" << "buildSettings = {" << "\n"
783 << "\t\t\t\t" << "COPY_PHASE_STRIP = " << (as_release ? "YES" : "NO") << ";" << "\n"; 1157 << "\t\t\t\t" << "COPY_PHASE_STRIP = " << (as_release ? "YES" : "NO") << ";" << "\n";
784 if(as_release) 1158 if(as_release) {
785 t << "\t\t\t\t" << "DEBUGGING_SYMBOLS = NO;" << "\n"; 1159 t << "\t\t\t\t" << "DEBUGGING_SYMBOLS = NO;" << "\n";
1160 } else {
1161 t << "\t\t\t\t" << "GCC_ENABLE_FIX_AND_CONTINUE = "
1162 << (project->isActiveConfig("no_fix_and_continue") ? "NO" : "YES") << ";" << "\n"
1163 << "\t\t\t\t" << "GCC_GENERATE_DEBUGGING_SYMBOLS = YES;" << "\n"
1164 << "\t\t\t\t" << "GCC_OPTIMIZATION_LEVEL = 0;" << "\n"
1165 << "\t\t\t\t" << "ZERO_LINK ="
1166 << (project->isActiveConfig("no_zero_link") ? "NO" : "YES") << ";" << "\n";
1167 }
786 t << "\t\t\t" << "};" << "\n" 1168 t << "\t\t\t" << "};" << "\n"
787 << "\t\t\t" << "isa = PBXBuildStyle;" << "\n" 1169 << "\t\t\t" << "isa = PBXBuildStyle;" << "\n"
788 << "\t\t\t" << "name = " << (as_release ? "Deployment" : "Development") << ";" << "\n" 1170 << "\t\t\t" << "name = " << (as_release ? "Deployment" : "Development") << ";" << "\n"
@@ -793,10 +1175,12 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
793 << "\t\t\t" << "buildStyles = (" << "\n" 1175 << "\t\t\t" << "buildStyles = (" << "\n"
794 << varGlue("QMAKE_PBX_BUILDSTYLES", "\t\t\t\t", ",\n\t\t\t\t", "\n") 1176 << varGlue("QMAKE_PBX_BUILDSTYLES", "\t\t\t\t", ",\n\t\t\t\t", "\n")
795 << "\t\t\t" << ");" << "\n" 1177 << "\t\t\t" << ");" << "\n"
1178 << "\t\t\t" << "hasScannedForEncodings = 1;" << "\n"
796 << "\t\t\t" << "isa = PBXProject;" << "\n" 1179 << "\t\t\t" << "isa = PBXProject;" << "\n"
797 << "\t\t\t" << "mainGroup = " << keyFor("QMAKE_PBX_ROOT_GROUP") << ";" << "\n" 1180 << "\t\t\t" << "mainGroup = " << keyFor("QMAKE_PBX_ROOT_GROUP") << ";" << "\n"
1181 << "\t\t\t" << "projectDirPath = \"\";" << "\n"
798 << "\t\t\t" << "targets = (" << "\n" 1182 << "\t\t\t" << "targets = (" << "\n"
799 << "\t\t\t\t" << keyFor("QMAKE_PBX_TARGET") << "\n" 1183 << varGlue("QMAKE_PBX_TARGETS", "\t\t\t\t", ",\n\t\t\t\t", "\n")
800 << "\t\t\t" << ");" << "\n" 1184 << "\t\t\t" << ");" << "\n"
801 << "\t\t" << "};" << "\n"; 1185 << "\t\t" << "};" << "\n";
802 1186
@@ -805,6 +1189,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
805 << "\t" << "rootObject = " << keyFor("QMAKE_PBX_ROOT") << ";" << "\n" 1189 << "\t" << "rootObject = " << keyFor("QMAKE_PBX_ROOT") << ";" << "\n"
806 << "}" << endl; 1190 << "}" << endl;
807 1191
1192 if(project->isActiveConfig("generate_pbxbuild_makefile")) {
808 QString mkwrap = fileFixify(pbx_dir + Option::dir_sep + ".." + Option::dir_sep + project->first("MAKEFILE"), 1193 QString mkwrap = fileFixify(pbx_dir + Option::dir_sep + ".." + Option::dir_sep + project->first("MAKEFILE"),
809 QDir::currentDirPath()); 1194 QDir::currentDirPath());
810 QFile mkwrapf(mkwrap); 1195 QFile mkwrapf(mkwrap);
@@ -815,22 +1200,31 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
815 const char *cleans = "uiclean mocclean preprocess_clean "; 1200 const char *cleans = "uiclean mocclean preprocess_clean ";
816 mkwrapt << "#This is a makefile wrapper for PROJECT BUILDER\n" 1201 mkwrapt << "#This is a makefile wrapper for PROJECT BUILDER\n"
817 << "all:" << "\n\t" 1202 << "all:" << "\n\t"
818 << "cd " << (project->first("QMAKE_ORIG_TARGET") + ".pbproj/ && pbxbuild") << "\n" 1203 << "cd " << project->first("QMAKE_ORIG_TARGET") << projectSuffix() << "/ && " << pbxbuild() << "\n"
819 << "install: all" << "\n\t" 1204 << "install: all" << "\n\t"
820 << "cd " << (project->first("QMAKE_ORIG_TARGET") + ".pbproj/ && pbxbuild install") << "\n" 1205 << "cd " << project->first("QMAKE_ORIG_TARGET") << projectSuffix() << "/ && " << pbxbuild() << " install\n"
821 << "distclean clean: preprocess_clean" << "\n\t" 1206 << "distclean clean: preprocess_clean" << "\n\t"
822 << "cd " << (project->first("QMAKE_ORIG_TARGET") + ".pbproj/ && pbxbuild clean") << "\n" 1207 << "cd " << project->first("QMAKE_ORIG_TARGET") << projectSuffix() << "/ && " << pbxbuild() << " clean" << "\n"
823 << (!did_preprocess ? cleans : "") << ":" << "\n"; 1208 << (!did_preprocess ? cleans : "") << ":" << "\n";
824 if(did_preprocess) 1209 if(did_preprocess)
825 mkwrapt << cleans << ":" << "\n\t" 1210 mkwrapt << cleans << ":" << "\n\t"
826 << "make -f " 1211 << "make -f "
827 << pbx_dir << Option::dir_sep << "qt_preprocess.mak $@" << endl; 1212 << pbx_dir << Option::dir_sep << "qt_preprocess.mak $@" << endl;
828 } 1213 }
1214 }
829 return TRUE; 1215 return TRUE;
830} 1216}
831 1217
832QString 1218QString
833ProjectBuilderMakefileGenerator::fixEnvs(QString file) 1219ProjectBuilderMakefileGenerator::fixQuotes(const QString &val)
1220{
1221 QString ret(val);
1222 ret = ret.replace(QRegExp("('|\")"), "\\\\1");
1223 return ret;
1224}
1225
1226QString
1227ProjectBuilderMakefileGenerator::fixEnvs(const QString &file)
834{ 1228{
835 QRegExp reg_var("\\$\\((.*)\\)"); 1229 QRegExp reg_var("\\$\\((.*)\\)");
836 for(int rep = 0; (rep = reg_var.search(file, rep)) != -1; ) { 1230 for(int rep = 0; (rep = reg_var.search(file, rep)) != -1; ) {
@@ -842,7 +1236,7 @@ ProjectBuilderMakefileGenerator::fixEnvs(QString file)
842} 1236}
843 1237
844QString 1238QString
845ProjectBuilderMakefileGenerator::fixEnvsList(QString where) 1239ProjectBuilderMakefileGenerator::fixEnvsList(const QString &where)
846{ 1240{
847 QString ret; 1241 QString ret;
848 const QStringList &l = project->variables()[where]; 1242 const QStringList &l = project->variables()[where];
@@ -856,32 +1250,15 @@ ProjectBuilderMakefileGenerator::fixEnvsList(QString where)
856} 1250}
857 1251
858QString 1252QString
859ProjectBuilderMakefileGenerator::keyFor(QString block) 1253ProjectBuilderMakefileGenerator::keyFor(const QString &block)
860{ 1254{
861#if 0 //This make this code much easier to debug.. 1255#if 1 //This make this code much easier to debug..
1256 if(project->isActiveConfig("no_pb_munge_key"))
862 return block; 1257 return block;
863#endif 1258#endif
864
865 QString ret; 1259 QString ret;
866 if(!keys.contains(block)) { 1260 if(!keys.contains(block)) {
867#if 0 1261 ret = qtMD5(block.utf8()).left(24).upper();
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); 1262 keys.insert(block, ret);
886 } else { 1263 } else {
887 ret = keys[block]; 1264 ret = keys[block];
@@ -892,16 +1269,17 @@ ProjectBuilderMakefileGenerator::keyFor(QString block)
892bool 1269bool
893ProjectBuilderMakefileGenerator::openOutput(QFile &file) const 1270ProjectBuilderMakefileGenerator::openOutput(QFile &file) const
894{ 1271{
895 if(project->first("TEMPLATE") != "subdirs") { 1272 if(QDir::isRelativePath(file.name()))
1273 file.setName(Option::output_dir + file.name()); //pwd when qmake was run
896 QFileInfo fi(file); 1274 QFileInfo fi(file);
897 if(fi.extension() != "pbxproj" || file.name().isEmpty()) { 1275 if(fi.extension() != "pbxproj" || file.name().isEmpty()) {
898 QString output = file.name(); 1276 QString output = file.name();
899 if(fi.isDir()) 1277 if(fi.isDir())
900 output += QDir::separator(); 1278 output += QDir::separator();
901 if(fi.extension() != "pbproj") { 1279 if(!output.endsWith(projectSuffix())) {
902 if(file.name().isEmpty() || fi.isDir()) 1280 if(file.name().isEmpty() || fi.isDir())
903 output += project->first("TARGET"); 1281 output += project->first("TARGET");
904 output += QString(".pbproj") + QDir::separator(); 1282 output += projectSuffix() + QDir::separator();
905 } else if(output[(int)output.length() - 1] != QDir::separator()) { 1283 } else if(output[(int)output.length() - 1] != QDir::separator()) {
906 output += QDir::separator(); 1284 output += QDir::separator();
907 } 1285 }
@@ -913,8 +1291,6 @@ ProjectBuilderMakefileGenerator::openOutput(QFile &file) const
913 Option::output_dir = pbx_dir.section(Option::dir_sep, 0, -2); 1291 Option::output_dir = pbx_dir.section(Option::dir_sep, 0, -2);
914 return ret; 1292 return ret;
915 } 1293 }
916 return UnixMakefileGenerator::openOutput(file);
917}
918 1294
919/* This function is such a hack it is almost pointless, but it 1295/* This function is such a hack it is almost pointless, but it
920 eliminates the warning message from ProjectBuilder that the project 1296 eliminates the warning message from ProjectBuilder that the project
@@ -928,10 +1304,14 @@ ProjectBuilderMakefileGenerator::pbuilderVersion() const
928 QString ret; 1304 QString ret;
929 if(project->isEmpty("QMAKE_PBUILDER_VERSION")) { 1305 if(project->isEmpty("QMAKE_PBUILDER_VERSION")) {
930 QString version, version_plist = project->first("QMAKE_PBUILDER_VERSION_PLIST"); 1306 QString version, version_plist = project->first("QMAKE_PBUILDER_VERSION_PLIST");
931 if(version_plist.isEmpty()) 1307 if(version_plist.isEmpty()) {
932 version_plist = "/Developer/Applications/Project Builder.app/Contents/version.plist"; 1308 if(ideType() == MAC_XCODE && QFile::exists("/Developer/Applications/Xcode.app/Contents/version.plist"))
1309 version_plist = "/Developer/Applications/Xcode.app/Contents/version.plist";
933 else 1310 else
1311 version_plist = "/Developer/Applications/Project Builder.app/Contents/version.plist";
1312 } else {
934 version_plist = version_plist.replace(QRegExp("\""), ""); 1313 version_plist = version_plist.replace(QRegExp("\""), "");
1314 }
935 QFile version_file(version_plist); 1315 QFile version_file(version_plist);
936 if(version_file.open(IO_ReadOnly)) { 1316 if(version_file.open(IO_ReadOnly)) {
937 debug_msg(1, "pbuilder: version.plist: Reading file: %s", version_plist.latin1()); 1317 debug_msg(1, "pbuilder: version.plist: Reading file: %s", version_plist.latin1());
@@ -954,11 +1334,15 @@ ProjectBuilderMakefileGenerator::pbuilderVersion() const
954 } 1334 }
955 } 1335 }
956 version_file.close(); 1336 version_file.close();
957 } else debug_msg(1, "pbuilder: version.plist: Failure to open %s", version_plist.latin1()); 1337 } else { debug_msg(1, "pbuilder: version.plist: Failure to open %s", version_plist.latin1()); }
958 if(version.startsWith("2.0")) 1338 if(version_plist.contains("Xcode")) {
1339 ret = "39";
1340 } else {
1341 if(version.startsWith("2."))
959 ret = "38"; 1342 ret = "38";
960 else if(version == "1.1") 1343 else if(version == "1.1")
961 ret = "34"; 1344 ret = "34";
1345 }
962 } else { 1346 } else {
963 ret = project->first("QMAKE_PBUILDER_VERSION"); 1347 ret = project->first("QMAKE_PBUILDER_VERSION");
964 } 1348 }
@@ -974,10 +1358,39 @@ ProjectBuilderMakefileGenerator::pbuilderVersion() const
974 return 34; //my fallback 1358 return 34; //my fallback
975} 1359}
976 1360
977QString 1361int
978ProjectBuilderMakefileGenerator::reftypeForFile(QString where) 1362ProjectBuilderMakefileGenerator::reftypeForFile(const QString &where)
979{ 1363{
1364 int ret = 0; //absolute is the default..
980 if(QDir::isRelativePath(where)) 1365 if(QDir::isRelativePath(where))
981 return "4"; //relative 1366 ret = 4; //relative
982 return "0"; //absolute 1367 return ret;
1368}
1369
1370ProjectBuilderMakefileGenerator::IDE_TYPE
1371ProjectBuilderMakefileGenerator::ideType() const
1372{
1373 if(!project->isActiveConfig("no_pbx_xcode") &&
1374 (QFile::exists("/Developer/Applications/Xcode.app") || project->isActiveConfig("pbx_xcode")))
1375 return ProjectBuilderMakefileGenerator::MAC_XCODE;
1376 return ProjectBuilderMakefileGenerator::MAC_PBUILDER;
983} 1377}
1378
1379QString
1380ProjectBuilderMakefileGenerator::projectSuffix() const
1381{
1382 if(ideType() == MAC_XCODE)
1383 return ".xcode";
1384 return ".pbproj";
1385}
1386
1387QString
1388ProjectBuilderMakefileGenerator::pbxbuild()
1389{
1390 if(QFile::exists("/usr/bin/pbbuild"))
1391 return "pbbuild";
1392 if(QFile::exists("/usr/bin/xcodebuild"))
1393 return "xcodebuild";
1394 return (ideType() == MAC_XCODE ? "xcodebuild" : "pbxbuild");
1395}
1396
diff --git a/qmake/generators/mac/pbuilder_pbx.h b/qmake/generators/mac/pbuilder_pbx.h
index ec2e1be..4ffb9a8 100644
--- a/qmake/generators/mac/pbuilder_pbx.h
+++ b/qmake/generators/mac/pbuilder_pbx.h
@@ -1,13 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Definition of ________ class.
5** 3**
6** Created : 970521 4** Definition of ProjectBuilderMakefileGenerator class.
7** 5**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 7**
10** This file is part of the network module of the Qt GUI Toolkit. 8** This file is part of qmake.
11** 9**
12** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
@@ -34,8 +32,9 @@
34** not clear to you. 32** not clear to you.
35** 33**
36**********************************************************************/ 34**********************************************************************/
37#ifndef __PBUILDERMAKE_H__ 35
38#define __PBUILDERMAKE_H__ 36#ifndef __PBUILDER_PBX_H__
37#define __PBUILDER_PBX_H__
39 38
40#include "unixmake.h" 39#include "unixmake.h"
41 40
@@ -43,14 +42,21 @@ class ProjectBuilderMakefileGenerator : public UnixMakefileGenerator
43{ 42{
44 QString pbx_dir; 43 QString pbx_dir;
45 int pbuilderVersion() const; 44 int pbuilderVersion() const;
45 bool writeSubdirs(QTextStream &, bool);
46 bool writeMakeParts(QTextStream &); 46 bool writeMakeParts(QTextStream &);
47 bool writeMakefile(QTextStream &); 47 bool writeMakefile(QTextStream &);
48 48
49 QString pbxbuild();
49 QMap<QString, QString> keys; 50 QMap<QString, QString> keys;
50 QString keyFor(QString file); 51 QString keyFor(const QString &file);
51 QString fixEnvs(QString file); 52 QString fixQuotes(const QString &val);
52 QString fixEnvsList(QString where); 53 QString fixEnvs(const QString &file);
53 QString reftypeForFile(QString file); 54 QString fixEnvsList(const QString &where);
55 int reftypeForFile(const QString &where);
56 QString projectSuffix() const;
57
58 enum IDE_TYPE { MAC_XCODE, MAC_PBUILDER };
59 IDE_TYPE ideType() const;
54 60
55public: 61public:
56 ProjectBuilderMakefileGenerator(QMakeProject *p); 62 ProjectBuilderMakefileGenerator(QMakeProject *p);
@@ -58,6 +64,7 @@ public:
58 64
59 virtual bool openOutput(QFile &) const; 65 virtual bool openOutput(QFile &) const;
60protected: 66protected:
67 bool doPrecompiledHeaders() const { return FALSE; }
61 virtual bool doDepends() const { return FALSE; } //never necesary 68 virtual bool doDepends() const { return FALSE; } //never necesary
62}; 69};
63 70
@@ -65,4 +72,4 @@ inline ProjectBuilderMakefileGenerator::~ProjectBuilderMakefileGenerator()
65{ } 72{ }
66 73
67 74
68#endif /* __PBUILDERMAKE_H__ */ 75#endif /* __PBUILDER_PBX_H__ */
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
index c12375d..5ce387f 100644
--- a/qmake/generators/makefile.cpp
+++ b/qmake/generators/makefile.cpp
@@ -1,13 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Definition of ________ class.
5** 3**
6** Created : 970521 4** Implementation of MakefileGenerator class.
7** 5**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. 6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 7**
10** This file is part of the network module of the Qt GUI Toolkit. 8** This file is part of qmake.
11** 9**
12** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
@@ -37,6 +35,7 @@
37 35
38#include "makefile.h" 36#include "makefile.h"
39#include "option.h" 37#include "option.h"
38#include "meta.h"
40#include <qdir.h> 39#include <qdir.h>
41#include <qfile.h> 40#include <qfile.h>
42#include <qtextstream.h> 41#include <qtextstream.h>
@@ -58,8 +57,9 @@
58#ifndef S_ISDIR 57#ifndef S_ISDIR
59 #define S_ISDIR(m)(((m) & S_IFMT) == S_IFDIR) 58 #define S_ISDIR(m)(((m) & S_IFMT) == S_IFDIR)
60#endif 59#endif
60#define QMAKE_EOL(x) (x == '\r' || x == '\n')
61 61
62static QString mkdir_p_asstring(const QString &dir) 62QString mkdir_p_asstring(const QString &dir)
63{ 63{
64 QString ret = "@$(CHK_DIR_EXISTS) \"" + dir + "\" "; 64 QString ret = "@$(CHK_DIR_EXISTS) \"" + dir + "\" ";
65 if(Option::target_mode == Option::TARG_WIN_MODE) 65 if(Option::target_mode == Option::TARG_WIN_MODE)
@@ -74,7 +74,6 @@ static bool createDir(const QString& fullPath)
74{ 74{
75 if(QFile::exists(fullPath)) 75 if(QFile::exists(fullPath))
76 return FALSE; 76 return FALSE;
77
78 QDir dirTmp; 77 QDir dirTmp;
79 bool ret = TRUE; 78 bool ret = TRUE;
80 QString pathComponent, tmpPath; 79 QString pathComponent, tmpPath;
@@ -142,7 +141,7 @@ MakefileGenerator::generateMocList(const QString &fn_target)
142 x++; 141 x++;
143 if(total_size_read >= x) { 142 if(total_size_read >= x) {
144 if(*(big_buffer + x) == '/') { //c++ style comment 143 if(*(big_buffer + x) == '/') { //c++ style comment
145 for( ;x < total_size_read && *(big_buffer + x) != '\n'; x++); 144 for( ;x < total_size_read && !QMAKE_EOL(*(big_buffer + x)); x++);
146 line_count++; 145 line_count++;
147 } else if(*(big_buffer + x) == '*') { //c style comment 146 } else if(*(big_buffer + x) == '*') { //c style comment
148 for( ;x < total_size_read; x++) { 147 for( ;x < total_size_read; x++) {
@@ -160,7 +159,7 @@ MakefileGenerator::generateMocList(const QString &fn_target)
160 x += 2; 159 x += 2;
161 break; 160 break;
162 } 161 }
163 } else if(*(big_buffer + x) == '\n') { 162 } else if(QMAKE_EOL(*(big_buffer + x))) {
164 line_count++; 163 line_count++;
165 } 164 }
166 } 165 }
@@ -206,14 +205,14 @@ MakefileGenerator::generateMocList(const QString &fn_target)
206 break; 205 break;
207 } 206 }
208 if(cpp_ext) { 207 if(cpp_ext) {
209 mocFile += fn_target.mid(dir_pos+1, ext_pos - dir_pos-1) + Option::moc_ext; 208 mocFile += Option::cpp_moc_mod + fn_target.mid(dir_pos+1, ext_pos - dir_pos-1) + Option::cpp_moc_ext;
210 project->variables()["_SRCMOC"].append(mocFile); 209 project->variables()["_SRCMOC"].append(mocFile);
211 } else if(project->variables()["HEADERS"].findIndex(fn_target) != -1) { 210 } else if(project->variables()["HEADERS"].findIndex(fn_target) != -1) {
212 for(QStringList::Iterator hit = Option::h_ext.begin(); 211 for(QStringList::Iterator hit = Option::h_ext.begin();
213 hit != Option::h_ext.end(); ++hit) { 212 hit != Option::h_ext.end(); ++hit) {
214 if((fn_target.right(ext_len) == (*hit))) { 213 if((fn_target.right(ext_len) == (*hit))) {
215 mocFile += Option::moc_mod + fn_target.mid(dir_pos+1, ext_pos - dir_pos-1) + 214 mocFile += Option::h_moc_mod + fn_target.mid(dir_pos+1, ext_pos - dir_pos-1) +
216 Option::cpp_ext.first(); 215 Option::h_moc_ext;
217 logicWarn(mocFile, "SOURCES"); 216 logicWarn(mocFile, "SOURCES");
218 project->variables()["_HDRMOC"].append(mocFile); 217 project->variables()["_HDRMOC"].append(mocFile);
219 break; 218 break;
@@ -232,7 +231,7 @@ MakefileGenerator::generateMocList(const QString &fn_target)
232 231
233 while(x < total_size_read && SYMBOL_CHAR(*(big_buffer+x))) 232 while(x < total_size_read && SYMBOL_CHAR(*(big_buffer+x)))
234 x++; 233 x++;
235 if(*(big_buffer+x) == '\n') 234 if(QMAKE_EOL(*(big_buffer+x)))
236 line_count++; 235 line_count++;
237 } 236 }
238#undef OBJ_LEN 237#undef OBJ_LEN
@@ -243,9 +242,11 @@ MakefileGenerator::generateMocList(const QString &fn_target)
243bool 242bool
244MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const QString &f, bool recurse) 243MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const QString &f, bool recurse)
245{ 244{
246 QStringList &fndeps = findDependencies(f); 245 if(processedDependencies(f))
247 if(!fndeps.isEmpty())
248 return TRUE; 246 return TRUE;
247 setProcessedDependencies(f, TRUE);
248
249 QStringList &fndeps = findDependencies(f);
249 QString fn = fileFixify(f, QDir::currentDirPath(), Option::output_dir); 250 QString fn = fileFixify(f, QDir::currentDirPath(), Option::output_dir);
250 fn = Option::fixPathToLocalOS(fn, FALSE); 251 fn = Option::fixPathToLocalOS(fn, FALSE);
251 QString fix_env_fn = Option::fixPathToLocalOS(fn); 252 QString fix_env_fn = Option::fixPathToLocalOS(fn);
@@ -283,7 +284,7 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const
283 x++; 284 x++;
284 if(total_size_read >= x) { 285 if(total_size_read >= x) {
285 if(*(big_buffer + x) == '/') { //c++ style comment 286 if(*(big_buffer + x) == '/') { //c++ style comment
286 for( ; x < total_size_read && *(big_buffer + x) != '\n'; x++); 287 for( ; x < total_size_read && !QMAKE_EOL(*(big_buffer + x)); x++);
287 } else if(*(big_buffer + x) == '*') { //c style comment 288 } else if(*(big_buffer + x) == '*') { //c style comment
288 for( ; x < total_size_read; x++) { 289 for( ; x < total_size_read; x++) {
289 if(*(big_buffer + x) == '*') { 290 if(*(big_buffer + x) == '*') {
@@ -291,13 +292,16 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const
291 x += 2; 292 x += 2;
292 break; 293 break;
293 } 294 }
294 } else if(*(big_buffer + x) == '\n') { 295 } else if(QMAKE_EOL(*(big_buffer + x))) {
295 line_count++; 296 line_count++;
296 } 297 }
297 } 298 }
298 } 299 }
299 } 300 }
300 } 301 }
302 while(x < total_size_read && //Skip spaces
303 (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t'))
304 x++;
301 if(*(big_buffer + x) == '#') { 305 if(*(big_buffer + x) == '#') {
302 x++; 306 x++;
303 while(x < total_size_read && //Skip spaces after hash 307 while(x < total_size_read && //Skip spaces after hash
@@ -318,28 +322,31 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const
318 x++; 322 x++;
319 323
320 int inc_len; 324 int inc_len;
321 for(inc_len = 0; *(big_buffer + x + inc_len) != term; inc_len++); 325 for(inc_len = 0; *(big_buffer + x + inc_len) != term &&
326 !QMAKE_EOL(*(big_buffer + x + inc_len)); inc_len++);
322 *(big_buffer + x + inc_len) = '\0'; 327 *(big_buffer + x + inc_len) = '\0';
323 inc = big_buffer + x; 328 inc = big_buffer + x;
324 } else if(total_size_read >= x + 14 && !strncmp(big_buffer + x, "qmake_warning ", 14)) { 329 } else if(total_size_read >= x + 14 && !strncmp(big_buffer + x, "qmake_warning ", 14)) {
325 for(x+=14; //skip spaces after keyword 330 for(x+=14; //skip spaces after keyword
326 x < total_size_read && (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t'); 331 x < total_size_read && (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t');
327 x++); 332 x++);
328 char term = '\n'; 333 char term = 0;
329 if(*(big_buffer + x) == '"') 334 if(*(big_buffer + x) == '"')
330 term = '"'; 335 term = '"';
331 if(*(big_buffer + x) == '\'') 336 if(*(big_buffer + x) == '\'')
332 term = '\''; 337 term = '\'';
333 if(term != '\n') 338 if(term)
334 x++; 339 x++;
335 340
336 int msg_len; 341 int msg_len;
337 for(msg_len = 0; *(big_buffer + x + msg_len) != term; msg_len++); 342 for(msg_len = 0; (term && *(big_buffer + x + msg_len) != term) &&
343 !QMAKE_EOL(*(big_buffer + x + msg_len)); msg_len++);
344 const char saved_term = *(big_buffer + x + msg_len);
338 *(big_buffer + x + msg_len) = '\0'; 345 *(big_buffer + x + msg_len) = '\0';
339 QString msg = big_buffer + x; 346 QString msg = big_buffer + x;
340 debug_msg(0, "%s:%d qmake_warning -- %s", fix_env_fn.latin1(), 347 debug_msg(0, "%s:%d qmake_warning -- %s", fix_env_fn.latin1(),
341 line_count, msg.latin1()); 348 line_count, msg.latin1());
342 *(big_buffer + x + msg_len) = term; //put it back 349 *(big_buffer + x + msg_len) = saved_term; //put it back
343 } 350 }
344 } 351 }
345 } else if(ui_file) { 352 } else if(ui_file) {
@@ -351,11 +358,31 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const
351 x++; 358 x++;
352 if(total_size_read >= x + 12 && !strncmp(big_buffer + x, "includehint", 11) && 359 if(total_size_read >= x + 12 && !strncmp(big_buffer + x, "includehint", 11) &&
353 (*(big_buffer + x + 11) == ' ' || *(big_buffer + x + 11) == '>')) { 360 (*(big_buffer + x + 11) == ' ' || *(big_buffer + x + 11) == '>')) {
354 for(x += 12; *(big_buffer + x) != '>'; x++); 361 for(x += 11; *(big_buffer + x) != '>'; x++);
355 int inc_len = 0; 362 int inc_len = 0;
356 for(x += 1 ; *(big_buffer + x + inc_len) != '<'; inc_len++); 363 for(x += 1 ; *(big_buffer + x + inc_len) != '<'; inc_len++);
357 *(big_buffer + x + inc_len) = '\0'; 364 *(big_buffer + x + inc_len) = '\0';
358 inc = big_buffer + x; 365 inc = big_buffer + x;
366 } else if(total_size_read >= x + 13 && !strncmp(big_buffer + x, "customwidget", 12) &&
367 (*(big_buffer + x + 12) == ' ' || *(big_buffer + x + 12) == '>')) {
368 for(x += 13; *(big_buffer + x) != '>'; x++); //skip up to >
369 while(x < total_size_read) {
370 for(x++; *(big_buffer + x) != '<'; x++); //skip up to <
371 x++;
372 if(total_size_read >= x + 7 && !strncmp(big_buffer+x, "header", 6) &&
373 (*(big_buffer + x + 6) == ' ' || *(big_buffer + x + 6) == '>')) {
374 for(x += 7; *(big_buffer + x) != '>'; x++); //skip up to >
375 int inc_len = 0;
376 for(x += 1 ; *(big_buffer + x + inc_len) != '<'; inc_len++);
377 *(big_buffer + x + inc_len) = '\0';
378 inc = big_buffer + x;
379 break;
380 } else if(total_size_read >= x + 14 && !strncmp(big_buffer+x, "/customwidget", 13) &&
381 (*(big_buffer + x + 13) == ' ' || *(big_buffer + x + 13) == '>')) {
382 x += 14;
383 break;
384 }
385 }
359 } else if(total_size_read >= x + 8 && !strncmp(big_buffer + x, "include", 7) && 386 } else if(total_size_read >= x + 8 && !strncmp(big_buffer + x, "include", 7) &&
360 (*(big_buffer + x + 7) == ' ' || *(big_buffer + x + 7) == '>')) { 387 (*(big_buffer + x + 7) == ' ' || *(big_buffer + x + 7) == '>')) {
361 for(x += 8; *(big_buffer + x) != '>'; x++) { 388 for(x += 8; *(big_buffer + x) != '>'; x++) {
@@ -417,12 +444,15 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const
417 if(found) 444 if(found)
418 continue; 445 continue;
419 } 446 }
420
421 QString fqn; 447 QString fqn;
422 if(project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH") && 448 if(project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH") &&
423 !stat(fix_env_fndir + inc, &fst) && !S_ISDIR(fst.st_mode)) { 449 !stat(fix_env_fndir + inc, &fst) && !S_ISDIR(fst.st_mode)) {
424 fqn = fndir + inc; 450 fqn = fndir + inc;
425 goto handle_fqn; 451 goto handle_fqn;
452 } else if(project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH") &&
453 !stat(inc, &fst) && !S_ISDIR(fst.st_mode)) {
454 fqn = inc;
455 goto handle_fqn;
426 } else { 456 } else {
427 if((Option::target_mode == Option::TARG_MAC9_MODE && inc.find(':')) || 457 if((Option::target_mode == Option::TARG_MAC9_MODE && inc.find(':')) ||
428 (Option::target_mode == Option::TARG_WIN_MODE && inc[1] != ':') || 458 (Option::target_mode == Option::TARG_WIN_MODE && inc[1] != ':') ||
@@ -446,6 +476,7 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const
446 //and see if they go away.. 476 //and see if they go away..
447 if(depHeuristics.contains(inc)) { 477 if(depHeuristics.contains(inc)) {
448 fqn = depHeuristics[inc]; 478 fqn = depHeuristics[inc];
479 from_source_dir = FALSE;
449 } else if(Option::mkfile::do_dep_heuristics) { //some heuristics.. 480 } else if(Option::mkfile::do_dep_heuristics) { //some heuristics..
450 //is it a file from a .ui? 481 //is it a file from a .ui?
451 QString inc_file = inc.section(Option::dir_sep, -1); 482 QString inc_file = inc.section(Option::dir_sep, -1);
@@ -468,7 +499,7 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const
468 fqn += inc_file; 499 fqn += inc_file;
469 from_source_dir = FALSE; //uics go in the output_dir (so don't fix them) 500 from_source_dir = FALSE; //uics go in the output_dir (so don't fix them)
470 fqn = fileFixify(fqn, QDir::currentDirPath(), Option::output_dir); 501 fqn = fileFixify(fqn, QDir::currentDirPath(), Option::output_dir);
471 goto handle_fqn; 502 goto cache_fqn;
472 } 503 }
473 } 504 }
474 } 505 }
@@ -488,7 +519,9 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const
488 d = project->first("QMAKE_ABSOLUTE_SOURCE_PATH"); 519 d = project->first("QMAKE_ABSOLUTE_SOURCE_PATH");
489 if(s == lhs) { 520 if(s == lhs) {
490 fqn = d + inc; 521 fqn = d + inc;
491 goto handle_fqn; 522 from_source_dir = FALSE; //uics go in the output_dir (so don't fix them)
523 fqn = fileFixify(fqn, QDir::currentDirPath(), Option::output_dir);
524 goto cache_fqn;
492 } 525 }
493 } 526 }
494 } 527 }
@@ -509,13 +542,16 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const
509 d = project->first("QMAKE_ABSOLUTE_SOURCE_PATH"); 542 d = project->first("QMAKE_ABSOLUTE_SOURCE_PATH");
510 if(s == lhs) { 543 if(s == lhs) {
511 fqn = d + inc; 544 fqn = d + inc;
512 goto handle_fqn; 545 from_source_dir = FALSE; //uics go in the output_dir (so don't fix them)
546 fqn = fileFixify(fqn, QDir::currentDirPath(), Option::output_dir);
547 goto cache_fqn;
513 } 548 }
514 } 549 }
515 } 550 }
516 } 551 }
517 if(mocAware() && //is it a moc file? 552 if(mocAware() && //is it a moc file?
518 (inc.endsWith(Option::cpp_ext.first()) || inc.endsWith(Option::moc_ext))) { 553 ( inc.endsWith(Option::cpp_ext.first()) || inc.endsWith(Option::cpp_moc_ext) )
554 || ( (Option::cpp_ext.first() != Option::h_moc_ext) && inc.endsWith(Option::h_moc_ext) )) {
519 QString mocs[] = { QString("_HDRMOC"), QString("_SRCMOC"), QString::null }; 555 QString mocs[] = { QString("_HDRMOC"), QString("_SRCMOC"), QString::null };
520 for(int moc = 0; !mocs[moc].isNull(); moc++) { 556 for(int moc = 0; !mocs[moc].isNull(); moc++) {
521 QStringList &l = project->variables()[mocs[moc]]; 557 QStringList &l = project->variables()[mocs[moc]];
@@ -527,7 +563,7 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const
527 //Since it is include, no need to link it in as well 563 //Since it is include, no need to link it in as well
528 project->variables()["_SRCMOC"].append((*it)); 564 project->variables()["_SRCMOC"].append((*it));
529 l.remove(it); 565 l.remove(it);
530 } else if(!findMocSource(fqn).endsWith(fn)) { 566 } else if(!findMocSource(fqn).endsWith(fileFixify(fn))) {
531 /* Not really a very good test, but this will at least avoid 567 /* Not really a very good test, but this will at least avoid
532 confusion if it really does happen (since tmake/qmake 568 confusion if it really does happen (since tmake/qmake
533 previously didn't even allow this the test is mostly accurate) */ 569 previously didn't even allow this the test is mostly accurate) */
@@ -536,11 +572,17 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const
536 inc.latin1(), fqn.latin1(), fix_env_fn.latin1()); 572 inc.latin1(), fqn.latin1(), fix_env_fn.latin1());
537 } 573 }
538 from_source_dir = FALSE; //mocs go in the output_dir (so don't fix them) 574 from_source_dir = FALSE; //mocs go in the output_dir (so don't fix them)
539 goto handle_fqn; 575 goto cache_fqn;
540 } 576 }
541 } 577 }
542 } 578 }
543 } 579 }
580 fqn = findDependency(inc); //all else fails..
581 cache_fqn:
582 if(from_source_dir) {
583 fqn = fileFixify(fqn);
584 from_source_dir = FALSE;
585 }
544 depHeuristics.insert(inc, fqn); 586 depHeuristics.insert(inc, fqn);
545 } 587 }
546 } 588 }
@@ -555,7 +597,7 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const
555 outdeps->append(fqn); 597 outdeps->append(fqn);
556 } 598 }
557 //read past new line now.. 599 //read past new line now..
558 for( ; x < total_size_read && (*(big_buffer + x) != '\n'); x++); 600 for( ; x < total_size_read && !QMAKE_EOL(*(big_buffer + x)); x++);
559 line_count++; 601 line_count++;
560 } 602 }
561 603
@@ -564,7 +606,7 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const
564 generateDependencies(dirs, (*fnit), recurse); 606 generateDependencies(dirs, (*fnit), recurse);
565 QStringList &deplist = findDependencies((*fnit)); 607 QStringList &deplist = findDependencies((*fnit));
566 for(QStringList::Iterator it = deplist.begin(); it != deplist.end(); ++it) 608 for(QStringList::Iterator it = deplist.begin(); it != deplist.end(); ++it)
567 if(fndeps.findIndex((*it)) == -1) 609 if(fndeps.findIndex((*it)) == -1 && (*it) != fn)
568 fndeps.append((*it)); 610 fndeps.append((*it));
569 } 611 }
570 } 612 }
@@ -606,10 +648,14 @@ MakefileGenerator::initOutPaths()
606 QString currentDir = QDir::currentDirPath(); 648 QString currentDir = QDir::currentDirPath();
607 QString dirs[] = { QString("OBJECTS_DIR"), QString("MOC_DIR"), QString("UI_HEADERS_DIR"), 649 QString dirs[] = { QString("OBJECTS_DIR"), QString("MOC_DIR"), QString("UI_HEADERS_DIR"),
608 QString("UI_SOURCES_DIR"), QString("UI_DIR"), QString("DESTDIR"), 650 QString("UI_SOURCES_DIR"), QString("UI_DIR"), QString("DESTDIR"),
609 QString("SUBLIBS_DIR"), QString::null }; 651 QString("SUBLIBS_DIR"), QString("DLLDESTDIR"), QString::null };
610 for(int x = 0; dirs[x] != QString::null; x++) { 652 for(int x = 0; dirs[x] != QString::null; x++) {
611 if ( !v[dirs[x]].isEmpty() ) { 653 if ( !v[dirs[x]].isEmpty() ) {
612 QString orig_path = v[dirs[x]].first(); 654 QString orig_path = v[dirs[x]].first();
655#ifdef Q_WS_WIN
656 // We don't want to add a separator for DLLDESTDIR on Windows
657 if (!(dirs[x] == "DLLDESTDIR"))
658#endif
613 { 659 {
614 QString &path = v[dirs[x]].first(); 660 QString &path = v[dirs[x]].first();
615 path = fileFixify(path, Option::output_dir, Option::output_dir); 661 path = fileFixify(path, Option::output_dir, Option::output_dir);
@@ -661,6 +707,11 @@ MakefileGenerator::initOutPaths()
661#endif 707#endif
662 } 708 }
663 } 709 }
710 if ( !v["DESTDIR"].isEmpty() ) {
711 QDir d(v["DESTDIR"].first());
712 if(Option::fixPathToLocalOS(d.absPath()) == Option::fixPathToLocalOS(Option::output_dir))
713 v.remove("DESTDIR");
714 }
664 QDir::current().cd( currentDir ); 715 QDir::current().cd( currentDir );
665} 716}
666 717
@@ -674,12 +725,17 @@ MakefileGenerator::init()
674 725
675 QMap<QString, QStringList> &v = project->variables(); 726 QMap<QString, QStringList> &v = project->variables();
676 QString paths[] = { QString("SOURCES"), QString("FORMS"), QString("YACCSOURCES"), QString("INCLUDEPATH"), 727 QString paths[] = { QString("SOURCES"), QString("FORMS"), QString("YACCSOURCES"), QString("INCLUDEPATH"),
677 QString("HEADERS"), QString("HEADERS_ORIG"), 728 QString("HEADERS"), QString("HEADERS_ORIG"), QString("LEXSOURCES"),
678 QString("LEXSOURCES"), QString("QMAKE_INTERNAL_INCLUDED_FILES"), QString::null }; 729 QString("QMAKE_INTERNAL_INCLUDED_FILES"),
730 QString("PRECOMPILED_HEADER"), QString::null };
679 for(int y = 0; paths[y] != QString::null; y++) { 731 for(int y = 0; paths[y] != QString::null; y++) {
680 QStringList &l = v[paths[y]]; 732 QStringList &l = v[paths[y]];
681 if(!l.isEmpty()) 733 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
682 l = fileFixify(l); 734 if ((*it).isEmpty())
735 continue;
736 if(QFile::exists((*it)))
737 (*it) = fileFixify((*it));
738 }
683 } 739 }
684 740
685 /* get deps and mocables */ 741 /* get deps and mocables */
@@ -761,6 +817,7 @@ MakefileGenerator::init()
761 debug_msg(2, "Dependencies (cached): %s -> %s", file.latin1(), 817 debug_msg(2, "Dependencies (cached): %s -> %s", file.latin1(),
762 files.join(" :: ").latin1()); 818 files.join(" :: ").latin1());
763 findDependencies(file) = files; 819 findDependencies(file) = files;
820 setProcessedDependencies(file, TRUE);
764 } 821 }
765 } 822 }
766 } else { 823 } else {
@@ -810,18 +867,18 @@ MakefileGenerator::init()
810 if(!noIO()) { 867 if(!noIO()) {
811 QString sources[] = { QString("OBJECTS"), QString("LEXSOURCES"), QString("YACCSOURCES"), 868 QString sources[] = { QString("OBJECTS"), QString("LEXSOURCES"), QString("YACCSOURCES"),
812 QString("HEADERS"), QString("SOURCES"), QString("FORMS"), 869 QString("HEADERS"), QString("SOURCES"), QString("FORMS"),
813 QString::null }; 870 QString("PRECOMPILED_HEADER"), QString::null };
814 depHeuristics.clear(); 871 depHeuristics.clear();
815 bool write_cache = FALSE, read_cache = QFile::exists(cache_file); 872 bool write_cache = FALSE, read_cache = QFile::exists(cache_file);
816 for(int x = 0; sources[x] != QString::null; x++) { 873 int x;
874 for(x = 0; sources[x] != QString::null; x++) {
817 QStringList vpath, &l = v[sources[x]]; 875 QStringList vpath, &l = v[sources[x]];
818 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { 876 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) {
819 if(!(*val_it).isEmpty()) { 877 if(!(*val_it).isEmpty()) {
820 QString file = Option::fixPathToLocalOS((*val_it)); 878 QString file = fileFixify((*val_it), QDir::currentDirPath(), Option::output_dir);
821 QStringList file_list(file);
822 if(!QFile::exists(file)) { 879 if(!QFile::exists(file)) {
823 bool found = FALSE; 880 bool found = FALSE;
824 if(QDir::isRelativePath(file)) { 881 if(QDir::isRelativePath((*val_it))) {
825 if(vpath.isEmpty()) 882 if(vpath.isEmpty())
826 vpath = v["VPATH_" + sources[x]] + v["VPATH"] + 883 vpath = v["VPATH_" + sources[x]] + v["VPATH"] +
827 v["QMAKE_ABSOLUTE_SOURCE_PATH"] + v["DEPENDPATH"]; 884 v["QMAKE_ABSOLUTE_SOURCE_PATH"] + v["DEPENDPATH"];
@@ -858,13 +915,12 @@ MakefileGenerator::init()
858 warn_msg(WarnLogic, "Failure to find: %s", (*val_it).latin1()); 915 warn_msg(WarnLogic, "Failure to find: %s", (*val_it).latin1());
859 continue; 916 continue;
860 } else { 917 } else {
861 file_list.clear();
862 for(int i = 0; i < (int)d.count(); i++) { 918 for(int i = 0; i < (int)d.count(); i++) {
863 file_list.append(dir + d[i]); 919 QString file = fileFixify(dir + d[i]);
864 if(i == (int)d.count() - 1) 920 if(i == (int)d.count() - 1)
865 (*val_it) = dir + d[i]; 921 (*val_it) = file;
866 else 922 else
867 l.insert(val_it, dir + d[i]); 923 l.insert(val_it, file);
868 } 924 }
869 } 925 }
870 } else { 926 } else {
@@ -876,15 +932,18 @@ MakefileGenerator::init()
876 } 932 }
877 } 933 }
878 } 934 }
879 for(QStringList::Iterator file_it = file_list.begin(); 935 }
880 file_it != file_list.end(); ++file_it) { 936 }
881 QString file_list_file = fileFixify((*file_it)); 937 }
938 for(x = 0; sources[x] != QString::null; x++) {
939 QStringList &l = v[sources[x]];
940 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) {
882 bool found_cache_moc = FALSE, found_cache_dep = FALSE; 941 bool found_cache_moc = FALSE, found_cache_dep = FALSE;
883 if(read_cache && Option::output.name() != "-" && 942 if(read_cache && Option::output.name() != "-" &&
884 project->isActiveConfig("qmake_cache")) { 943 project->isActiveConfig("qmake_cache")) {
885 if(!findDependencies(file_list_file).isEmpty()) 944 if(processedDependencies((*val_it)))
886 found_cache_dep = TRUE; 945 found_cache_dep = TRUE;
887 if(cache_found_files[(*file_it)] == (void *)2) 946 if(cache_found_files[(*val_it)] == (void *)2)
888 found_cache_moc = TRUE; 947 found_cache_moc = TRUE;
889 if(!found_cache_moc || !found_cache_dep) 948 if(!found_cache_moc || !found_cache_dep)
890 write_cache = TRUE; 949 write_cache = TRUE;
@@ -892,12 +951,13 @@ MakefileGenerator::init()
892 /* Do moc before dependency checking since some includes can come from 951 /* Do moc before dependency checking since some includes can come from
893 moc_*.cpp files */ 952 moc_*.cpp files */
894 if(found_cache_moc) { 953 if(found_cache_moc) {
895 QString moc = findMocDestination(file_list_file); 954 QString fixed_file(fileFixify((*val_it), QDir::currentDirPath(), Option::output_dir));
955 QString moc = findMocDestination(fixed_file);
896 if(!moc.isEmpty()) { 956 if(!moc.isEmpty()) {
897 for(QStringList::Iterator cppit = Option::cpp_ext.begin(); 957 for(QStringList::Iterator cppit = Option::cpp_ext.begin();
898 cppit != Option::cpp_ext.end(); ++cppit) { 958 cppit != Option::cpp_ext.end(); ++cppit) {
899 if(file_list_file.endsWith((*cppit))) { 959 if(fixed_file.endsWith((*cppit))) {
900 QStringList &deps = findDependencies(file_list_file); 960 QStringList &deps = findDependencies(fixed_file);
901 if(!deps.contains(moc)) 961 if(!deps.contains(moc))
902 deps.append(moc); 962 deps.append(moc);
903 break; 963 break;
@@ -907,13 +967,11 @@ MakefileGenerator::init()
907 } else if(mocAware() && (sources[x] == "SOURCES" || sources[x] == "HEADERS") && 967 } else if(mocAware() && (sources[x] == "SOURCES" || sources[x] == "HEADERS") &&
908 (Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT || 968 (Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT ||
909 Option::mkfile::do_mocs)) { 969 Option::mkfile::do_mocs)) {
910 generateMocList((*file_it)); 970 generateMocList((*val_it));
911 } 971 }
912 if(!found_cache_dep && sources[x] != "OBJECTS") { 972 if(!found_cache_dep && sources[x] != "OBJECTS") {
913 debug_msg(5, "Looking for dependencies for %s", (*file_it).latin1()); 973 debug_msg(5, "Looking for dependencies for %s", (*val_it).latin1());
914 generateDependencies(deplist, (*file_it), doDepends()); 974 generateDependencies(deplist, (*val_it), doDepends());
915 }
916 }
917 } 975 }
918 } 976 }
919 } 977 }
@@ -932,7 +990,7 @@ MakefileGenerator::init()
932 cachet << "[depend]" << endl; 990 cachet << "[depend]" << endl;
933 for(QMap<QString, QStringList>::Iterator it = depends.begin(); 991 for(QMap<QString, QStringList>::Iterator it = depends.begin();
934 it != depends.end(); ++it) 992 it != depends.end(); ++it)
935 cachet << depKeyMap[it.key()] << " = " << it.data().join(" ") << endl; 993 cachet << dependencyKey(it.key()) << " = " << it.data().join(" ") << endl;
936 cachet << "[mocable]" << endl; 994 cachet << "[mocable]" << endl;
937 QString mc, moc_sources[] = { QString("HEADERS"), QString("SOURCES"), QString::null }; 995 QString mc, moc_sources[] = { QString("HEADERS"), QString("SOURCES"), QString::null };
938 for(int x = 0; moc_sources[x] != QString::null; x++) { 996 for(int x = 0; moc_sources[x] != QString::null; x++) {
@@ -1072,7 +1130,7 @@ MakefileGenerator::init()
1072 } 1130 }
1073 } 1131 }
1074 impl = fileFixify(impl, QDir::currentDirPath(), Option::output_dir); 1132 impl = fileFixify(impl, QDir::currentDirPath(), Option::output_dir);
1075 if(!impl.isEmpty()) 1133 if(!impl.isEmpty() && !impl.endsWith(Option::dir_sep))
1076 impl += Option::dir_sep; 1134 impl += Option::dir_sep;
1077 impl += fi.baseName(TRUE) + Option::cpp_ext.first(); 1135 impl += fi.baseName(TRUE) + Option::cpp_ext.first();
1078 if(Option::output_dir != QDir::currentDirPath() && 1136 if(Option::output_dir != QDir::currentDirPath() &&
@@ -1084,7 +1142,7 @@ MakefileGenerator::init()
1084 project->variables()["INCLUDEPATH"].append(decl); 1142 project->variables()["INCLUDEPATH"].append(decl);
1085 } 1143 }
1086 decl = fileFixify(decl, QDir::currentDirPath(), Option::output_dir); 1144 decl = fileFixify(decl, QDir::currentDirPath(), Option::output_dir);
1087 if(!decl.isEmpty()) 1145 if(!decl.isEmpty() && !decl.endsWith(Option::dir_sep))
1088 decl += Option::dir_sep; 1146 decl += Option::dir_sep;
1089 decl += fi.baseName(TRUE) + Option::h_ext.first(); 1147 decl += fi.baseName(TRUE) + Option::h_ext.first();
1090 logicWarn(impl, "SOURCES"); 1148 logicWarn(impl, "SOURCES");
@@ -1093,7 +1151,7 @@ MakefileGenerator::init()
1093 impls.append(impl); 1151 impls.append(impl);
1094 findDependencies(impl).append(decl); 1152 findDependencies(impl).append(decl);
1095 1153
1096 QString mocable = Option::moc_mod + fi.baseName(TRUE) + Option::cpp_ext.first(); 1154 QString mocable = Option::h_moc_mod + fi.baseName(TRUE) + Option::h_moc_ext;
1097 if(!v["MOC_DIR"].isEmpty()) 1155 if(!v["MOC_DIR"].isEmpty())
1098 mocable.prepend(v["MOC_DIR"].first()); 1156 mocable.prepend(v["MOC_DIR"].first());
1099 else if(fi.dirPath() != ".") 1157 else if(fi.dirPath() != ".")
@@ -1106,6 +1164,14 @@ MakefileGenerator::init()
1106 v["OBJECTS"] += (v["UICOBJECTS"] = createObjectList("UICDECLS")); 1164 v["OBJECTS"] += (v["UICOBJECTS"] = createObjectList("UICDECLS"));
1107 } 1165 }
1108 1166
1167 //Translation files
1168 if(!project->isEmpty("TRANSLATIONS")) {
1169 QStringList &trf = project->variables()["TRANSLATIONS"];
1170 for(QStringList::Iterator it = trf.begin(); it != trf.end(); ++it) {
1171 (*it) = Option::fixPathToLocalOS((*it));
1172 }
1173 }
1174
1109 //Image files 1175 //Image files
1110 if(!project->isEmpty("IMAGES")) { 1176 if(!project->isEmpty("IMAGES")) {
1111 if(project->isEmpty("QMAKE_IMAGE_COLLECTION")) 1177 if(project->isEmpty("QMAKE_IMAGE_COLLECTION"))
@@ -1140,6 +1206,7 @@ MakefileGenerator::init()
1140 if ( mocAware() ) { 1206 if ( mocAware() ) {
1141 if(!project->isEmpty("MOC_DIR")) 1207 if(!project->isEmpty("MOC_DIR"))
1142 project->variables()["INCLUDEPATH"].append(project->first("MOC_DIR")); 1208 project->variables()["INCLUDEPATH"].append(project->first("MOC_DIR"));
1209 if ( Option::h_moc_ext == Option::cpp_ext.first() )
1143 v["OBJMOC"] = createObjectList("_HDRMOC") + createObjectList("_UIMOC"); 1210 v["OBJMOC"] = createObjectList("_HDRMOC") + createObjectList("_UIMOC");
1144 1211
1145 QStringList &l = v["SRCMOC"]; 1212 QStringList &l = v["SRCMOC"];
@@ -1149,28 +1216,46 @@ MakefileGenerator::init()
1149 (*val_it) = Option::fixPathToTargetOS((*val_it), FALSE); 1216 (*val_it) = Option::fixPathToTargetOS((*val_it), FALSE);
1150 } 1217 }
1151 } 1218 }
1219
1220 QString fixpaths[] = { QString("PRE_TARGETDEPS"), QString("POST_TARGETDEPS"), QString::null };
1221 for(int path = 0; !fixpaths[path].isNull(); path++) {
1222 QStringList &l = v[fixpaths[path]];
1223 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) {
1224 if(!(*val_it).isEmpty())
1225 (*val_it) = Option::fixPathToTargetOS((*val_it), FALSE);
1226 }
1227 }
1228
1229 // Make sure the INCLUDEPATH doesn't contain any empty(/null) entries
1230 QStringList &ipl = project->variables()["INCLUDEPATH"];
1231 for(QStringList::Iterator ipl_it = ipl.begin(); ipl_it != ipl.end();) {
1232 if ((*ipl_it).isEmpty())
1233 ipl_it = ipl.remove(ipl_it);
1234 else
1235 ++ipl_it;
1236 }
1152} 1237}
1153 1238
1154bool 1239bool
1155MakefileGenerator::processPrlFile(QString &file) 1240MakefileGenerator::processPrlFile(QString &file)
1156{ 1241{
1157 bool ret = FALSE, try_replace_file=FALSE; 1242 bool ret = FALSE, try_replace_file=FALSE;
1158 QString prl_file; 1243 QString meta_file, orig_file = file;
1159 if(file.endsWith(Option::prl_ext)) { 1244 if(QMakeMetaInfo::libExists(file)) {
1160 try_replace_file = TRUE; 1245 try_replace_file = TRUE;
1161 prl_file = file; 1246 meta_file = file;
1162 file = ""; 1247 file = "";
1163 } else { 1248 } else {
1164 QString tmp = file; 1249 QString tmp = file;
1165 int ext = tmp.findRev('.'); 1250 int ext = tmp.findRev('.');
1166 if(ext != -1) 1251 if(ext != -1)
1167 tmp = tmp.left(ext); 1252 tmp = tmp.left(ext);
1168 prl_file = tmp + Option::prl_ext; 1253 meta_file = tmp;
1169 } 1254 }
1170 prl_file = fileFixify(prl_file); 1255 meta_file = fileFixify(meta_file);
1171 if(!QFile::exists(fileFixify(prl_file, QDir::currentDirPath(), Option::output_dir)) && 1256 if(!QMakeMetaInfo::libExists(fileFixify(meta_file, QDir::currentDirPath(), Option::output_dir)) &&
1172 project->isActiveConfig("qt")) { 1257 project->isActiveConfig("qt")) {
1173 QString stem = prl_file, dir, extn; 1258 QString stem = meta_file, dir, extn;
1174 int slsh = stem.findRev('/'), hadlib = 0; 1259 int slsh = stem.findRev('/'), hadlib = 0;
1175 if(slsh != -1) { 1260 if(slsh != -1) {
1176 dir = stem.left(slsh + 1); 1261 dir = stem.left(slsh + 1);
@@ -1190,39 +1275,53 @@ MakefileGenerator::processPrlFile(QString &file)
1190 stem = stem.left(stem.length() - 3); //lose the -mt 1275 stem = stem.left(stem.length() - 3); //lose the -mt
1191 else 1276 else
1192 stem += "-mt"; //try the thread case 1277 stem += "-mt"; //try the thread case
1193 prl_file = dir; 1278 meta_file = dir;
1194 if(hadlib) 1279 if(hadlib)
1195 prl_file += "lib"; 1280 meta_file += "lib";
1196 prl_file += stem + extn; 1281 meta_file += stem + extn;
1197 try_replace_file = TRUE; 1282 try_replace_file = TRUE;
1198 } 1283 }
1199 } 1284 }
1200 QString real_prl_file = Option::fixPathToLocalOS(prl_file); 1285 QString real_meta_file = Option::fixPathToLocalOS(meta_file);
1201 if(project->variables()["QMAKE_PRL_INTERNAL_FILES"].findIndex(prl_file) != -1) { 1286 if(project->variables()["QMAKE_PRL_INTERNAL_FILES"].findIndex(QMakeMetaInfo::findLib(meta_file)) != -1) {
1202 ret = TRUE; 1287 ret = TRUE;
1203 } else if(!real_prl_file.isEmpty() && 1288 } else if(!meta_file.isEmpty()) {
1204 QFile::exists(fileFixify(real_prl_file, QDir::currentDirPath(), Option::output_dir))) { 1289 QString f = fileFixify(real_meta_file, QDir::currentDirPath(), Option::output_dir);
1205 project->variables()["QMAKE_PRL_INTERNAL_FILES"].append(prl_file); 1290 if(QMakeMetaInfo::libExists(f)) {
1206 QMakeProject proj; 1291 QMakeMetaInfo libinfo;
1207 debug_msg(1, "Processing PRL file: %s", real_prl_file.latin1()); 1292 debug_msg(1, "Processing PRL file: %s", real_meta_file.latin1());
1208 if(!proj.read(fileFixify(real_prl_file, QDir::currentDirPath(), Option::output_dir), 1293 if(!libinfo.readLib(f)) {
1209 QDir::currentDirPath(), TRUE)) { 1294 fprintf(stderr, "Error processing meta file: %s\n", real_meta_file.latin1());
1210 fprintf(stderr, "Error processing prl file: %s\n", real_prl_file.latin1()); 1295 } else if(project->isActiveConfig("no_read_prl_" + libinfo.type().lower())) {
1296 debug_msg(2, "Ignored meta file %s [%s]", real_meta_file.latin1(), libinfo.type().latin1());
1211 } else { 1297 } else {
1212 ret = TRUE; 1298 ret = TRUE;
1213 QMap<QString, QStringList> &vars = proj.variables(); 1299 QMap<QString, QStringList> &vars = libinfo.variables();
1214 for( QMap<QString, QStringList>::Iterator it = vars.begin(); it != vars.end(); ++it) 1300 for( QMap<QString, QStringList>::Iterator it = vars.begin(); it != vars.end(); ++it)
1215 processPrlVariable(it.key(), it.data()); 1301 processPrlVariable(it.key(), it.data());
1216 if(try_replace_file && !proj.isEmpty("QMAKE_PRL_TARGET")) { 1302 if(try_replace_file && !libinfo.isEmpty("QMAKE_PRL_TARGET")) {
1217 QString dir; 1303 QString dir;
1218 int slsh = real_prl_file.findRev(Option::dir_sep); 1304 int slsh = real_meta_file.findRev(Option::dir_sep);
1219 if(slsh != -1) 1305 if(slsh != -1)
1220 dir = real_prl_file.left(slsh+1); 1306 dir = real_meta_file.left(slsh+1);
1221 file = dir + proj.first("QMAKE_PRL_TARGET"); 1307 file = libinfo.first("QMAKE_PRL_TARGET");
1308 if(QDir::isRelativePath(file))
1309 file.prepend(dir);
1222 } 1310 }
1223 } 1311 }
1224 if(ret) 1312 }
1225 project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"].append(prl_file); 1313 if(ret) {
1314 QString mf = QMakeMetaInfo::findLib(meta_file);
1315 project->variables()["QMAKE_PRL_INTERNAL_FILES"].append(mf);
1316 project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"].append(mf);
1317 }
1318 }
1319 if(try_replace_file && file.isEmpty()) {
1320#if 0
1321 warn_msg(WarnLogic, "Found prl [%s] file with no target [%s]!", meta_file.latin1(),
1322 orig_file.latin1());
1323#endif
1324 file = orig_file;
1226 } 1325 }
1227 return ret; 1326 return ret;
1228} 1327}
@@ -1296,6 +1395,10 @@ MakefileGenerator::writePrlFile(QTextStream &t)
1296 t << "QMAKE_PRL_TARGET = " << target << endl; 1395 t << "QMAKE_PRL_TARGET = " << target << endl;
1297 if(!project->isEmpty("PRL_EXPORT_DEFINES")) 1396 if(!project->isEmpty("PRL_EXPORT_DEFINES"))
1298 t << "QMAKE_PRL_DEFINES = " << project->variables()["PRL_EXPORT_DEFINES"].join(" ") << endl; 1397 t << "QMAKE_PRL_DEFINES = " << project->variables()["PRL_EXPORT_DEFINES"].join(" ") << endl;
1398 if(!project->isEmpty("PRL_EXPORT_CFLAGS"))
1399 t << "QMAKE_PRL_CFLAGS = " << project->variables()["PRL_EXPORT_CFLAGS"].join(" ") << endl;
1400 if(!project->isEmpty("PRL_EXPORT_CXXFLAGS"))
1401 t << "QMAKE_PRL_CXXFLAGS = " << project->variables()["PRL_EXPORT_CXXFLAGS"].join(" ") << endl;
1299 if(!project->isEmpty("CONFIG")) 1402 if(!project->isEmpty("CONFIG"))
1300 t << "QMAKE_PRL_CONFIG = " << project->variables()["CONFIG"].join(" ") << endl; 1403 t << "QMAKE_PRL_CONFIG = " << project->variables()["CONFIG"].join(" ") << endl;
1301 if(!project->isEmpty("VERSION")) 1404 if(!project->isEmpty("VERSION"))
@@ -1316,10 +1419,12 @@ MakefileGenerator::writePrlFile(QTextStream &t)
1316bool 1419bool
1317MakefileGenerator::write() 1420MakefileGenerator::write()
1318{ 1421{
1422 usePlatformDir();
1319 init(); 1423 init();
1320 findLibraries(); 1424 findLibraries();
1321 if((Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || //write prl 1425 if((Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || //write prl
1322 Option::qmake_mode == Option::QMAKE_GENERATE_PRL) && 1426 Option::qmake_mode == Option::QMAKE_GENERATE_PRL) &&
1427 project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty() &&
1323 project->isActiveConfig("create_prl") && project->first("TEMPLATE") == "lib" && 1428 project->isActiveConfig("create_prl") && project->first("TEMPLATE") == "lib" &&
1324 !project->isActiveConfig("plugin")) { 1429 !project->isActiveConfig("plugin")) {
1325 QString prl = var("TARGET"); 1430 QString prl = var("TARGET");
@@ -1346,7 +1451,7 @@ MakefileGenerator::write()
1346 project->isActiveConfig("link_prl")) //load up prl's' 1451 project->isActiveConfig("link_prl")) //load up prl's'
1347 processPrlFiles(); 1452 processPrlFiles();
1348 1453
1349 if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || 1454 if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || //write prl file
1350 Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) { 1455 Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) {
1351 QTextStream t(&Option::output); 1456 QTextStream t(&Option::output);
1352 writeMakefile(t); 1457 writeMakefile(t);
@@ -1354,6 +1459,61 @@ MakefileGenerator::write()
1354 return TRUE; 1459 return TRUE;
1355} 1460}
1356 1461
1462// Manipulate directories, so it's possible to build
1463// several cross-platform targets concurrently
1464void
1465MakefileGenerator::usePlatformDir()
1466{
1467 QString pltDir(project->first("QMAKE_PLATFORM_DIR"));
1468 if(pltDir.isEmpty())
1469 return;
1470 char sep = QDir::separator();
1471 QString slashPltDir = sep + pltDir;
1472
1473 QString filePath = project->first("DESTDIR");
1474 project->variables()["DESTDIR"] = filePath
1475 + (filePath.isEmpty() ? pltDir : slashPltDir);
1476
1477 filePath = project->first("DLLDESTDIR");
1478 project->variables()["DLLDESTDIR"] = filePath
1479 + (filePath.isEmpty() ? pltDir : slashPltDir);
1480
1481 filePath = project->first("OBJECTS_DIR");
1482 project->variables()["OBJECTS_DIR"] = filePath
1483 + (filePath.isEmpty() ? pltDir : slashPltDir);
1484
1485 filePath = project->first("QMAKE_LIBDIR_QT");
1486 project->variables()["QMAKE_LIBDIR_QT"] = filePath
1487 + (filePath.isEmpty() ? pltDir : slashPltDir);
1488
1489 filePath = project->first("QMAKE_LIBS_QT");
1490 int fpi = filePath.findRev(sep);
1491 if (fpi == -1)
1492 project->variables()["QMAKE_LIBS_QT"].prepend(pltDir + sep);
1493 else
1494 project->variables()["QMAKE_LIBS_QT"] = filePath.left(fpi)
1495 + slashPltDir
1496 + filePath.mid(fpi);
1497
1498 filePath = project->first("QMAKE_LIBS_QT_THREAD");
1499 fpi = filePath.findRev(sep);
1500 if (fpi == -1)
1501 project->variables()["QMAKE_LIBS_QT_THREAD"].prepend(pltDir + sep);
1502 else
1503 project->variables()["QMAKE_LIBS_QT_THREAD"] = filePath.left(fpi)
1504 + slashPltDir
1505 + filePath.mid(fpi);
1506
1507 filePath = project->first("QMAKE_LIBS_QT_ENTRY");
1508 fpi = filePath.findRev(sep);
1509 if (fpi == -1)
1510 project->variables()["QMAKE_LIBS_QT_ENTRY"].prepend(pltDir + sep);
1511 else
1512 project->variables()["QMAKE_LIBS_QT_ENTRY"] = filePath.left(fpi)
1513 + slashPltDir
1514 + filePath.mid(fpi);
1515}
1516
1357void 1517void
1358MakefileGenerator::writeObj(QTextStream &t, const QString &obj, const QString &src) 1518MakefileGenerator::writeObj(QTextStream &t, const QString &obj, const QString &src)
1359{ 1519{
@@ -1372,7 +1532,7 @@ MakefileGenerator::writeObj(QTextStream &t, const QString &obj, const QString &s
1372 QString sdep, odep = (*sit) + " "; 1532 QString sdep, odep = (*sit) + " ";
1373 QStringList deps = findDependencies((*sit)); 1533 QStringList deps = findDependencies((*sit));
1374 for(QStringList::Iterator dit = deps.begin(); dit != deps.end(); dit++) { 1534 for(QStringList::Iterator dit = deps.begin(); dit != deps.end(); dit++) {
1375 if((*dit).endsWith(Option::moc_ext)) 1535 if((*dit).endsWith(Option::cpp_moc_ext))
1376 odep += (*dit) + " "; 1536 odep += (*dit) + " ";
1377 else 1537 else
1378 sdep += (*dit) + " "; 1538 sdep += (*dit) + " ";
@@ -1406,8 +1566,8 @@ MakefileGenerator::writeObj(QTextStream &t, const QString &obj, const QString &s
1406 } 1566 }
1407 } 1567 }
1408 if (!use_implicit_rule && !project->isEmpty(comp)) { 1568 if (!use_implicit_rule && !project->isEmpty(comp)) {
1409 QString p = var(comp); 1569 QString p = var(comp), srcf(*sit);
1410 p.replace(stringSrc, (*sit)); 1570 p.replace(stringSrc, srcf);
1411 p.replace(stringObj, (*oit)); 1571 p.replace(stringObj, (*oit));
1412 t << "\n\t" << p; 1572 t << "\n\t" << p;
1413 } 1573 }
@@ -1421,15 +1581,13 @@ MakefileGenerator::writeUicSrc(QTextStream &t, const QString &ui)
1421{ 1581{
1422 QStringList &uil = project->variables()[ui]; 1582 QStringList &uil = project->variables()[ui];
1423 for(QStringList::Iterator it = uil.begin(); it != uil.end(); it++) { 1583 for(QStringList::Iterator it = uil.begin(); it != uil.end(); it++) {
1424 QString deps = findDependencies((*it)).join(" \\\n\t\t"), decl, impl; 1584 QString decl, impl;
1425 { 1585 {
1426 QString tmp = (*it), impl_dir, decl_dir; 1586 QString tmp = (*it), impl_dir, decl_dir;
1427 decl = tmp.replace(QRegExp("\\" + Option::ui_ext + "$"), Option::h_ext.first()); 1587 decl = tmp.replace(QRegExp("\\" + Option::ui_ext + "$"), Option::h_ext.first());
1428 decl = fileFixify(decl, QDir::currentDirPath(), Option::output_dir);
1429 int dlen = decl.findRev(Option::dir_sep) + 1; 1588 int dlen = decl.findRev(Option::dir_sep) + 1;
1430 tmp = (*it); 1589 tmp = (*it);
1431 impl = tmp.replace(QRegExp("\\" + Option::ui_ext + "$"), Option::cpp_ext.first()); 1590 impl = tmp.replace(QRegExp("\\" + Option::ui_ext + "$"), Option::cpp_ext.first());
1432 impl = fileFixify(impl, QDir::currentDirPath(), Option::output_dir);
1433 int ilen = decl.findRev(Option::dir_sep) + 1; 1591 int ilen = decl.findRev(Option::dir_sep) + 1;
1434 if(!project->isEmpty("UI_DIR")) { 1592 if(!project->isEmpty("UI_DIR")) {
1435 impl_dir = project->first("UI_DIR"); 1593 impl_dir = project->first("UI_DIR");
@@ -1445,25 +1603,31 @@ MakefileGenerator::writeUicSrc(QTextStream &t, const QString &ui)
1445 impl = project->first("UI_SOURCES_DIR") + impl.right(impl.length() - ilen); 1603 impl = project->first("UI_SOURCES_DIR") + impl.right(impl.length() - ilen);
1446 } 1604 }
1447 } 1605 }
1606 impl = fileFixify(impl, QDir::currentDirPath(), Option::output_dir);
1607 decl = fileFixify(decl, QDir::currentDirPath(), Option::output_dir);
1448 if(decl_dir.isEmpty()) 1608 if(decl_dir.isEmpty())
1449 decl_dir = decl.left(dlen); 1609 decl_dir = decl.section(Option::dir_sep,0,-2);
1450 if(impl_dir.isEmpty()) 1610 if(impl_dir.isEmpty())
1451 impl_dir = impl.left(ilen); 1611 impl_dir = impl.section(Option::dir_sep,0,-2);
1452 if(!impl_dir.isEmpty()) 1612 if (QDir::isRelativePath(impl_dir))
1453 createDir(Option::output_dir + Option::dir_sep + impl_dir); 1613 impl_dir.prepend(Option::output_dir + Option::dir_sep);
1454 if(!decl_dir.isEmpty() && decl_dir != impl_dir) 1614 if (QDir::isRelativePath(decl_dir))
1455 createDir(Option::output_dir + Option::dir_sep + decl_dir); 1615 decl_dir.prepend(Option::output_dir + Option::dir_sep);
1456 } 1616 createDir(impl_dir);
1457 t << decl << ": " << (*it) << " " << deps << "\n\t" 1617 createDir(decl_dir);
1618 }
1619 QStringList deps = findDependencies((*it));
1620 deps.remove(decl); //avoid circular dependencies..
1621 t << decl << ": " << (*it) << " " << deps.join(" \\\n\t\t") << "\n\t"
1458 << "$(UIC) " << (*it) << " -o " << decl << endl << endl; 1622 << "$(UIC) " << (*it) << " -o " << decl << endl << endl;
1459 1623
1460 QString mildDecl = decl; 1624 QString mildDecl = decl;
1461 int k = mildDecl.findRev( Option::dir_sep ); 1625 int k = mildDecl.findRev( Option::dir_sep );
1462 if ( k != -1 ) 1626 if ( k != -1 )
1463 mildDecl = mildDecl.mid( k + 1 ); 1627 mildDecl = mildDecl.mid( k + 1 );
1464 1628 t << impl << ": " << decl << " " << (*it) << " " << deps.join(" \\\n\t\t") << "\n\t"
1465 t << impl << ": " << decl << " " << (*it) << " " << deps << "\n\t" 1629 << "$(UIC)";
1466 << "$(UIC) " << (*it) << " -i " << mildDecl << " -o " << impl << endl << endl; 1630 t << " " << (*it) << " -i " << mildDecl << " -o " << impl << endl << endl;
1467 } 1631 }
1468} 1632}
1469 1633
@@ -1477,7 +1641,8 @@ MakefileGenerator::writeMocObj(QTextStream &t, const QString &obj, const QString
1477 QString stringSrc("$src"), stringObj("$obj"); 1641 QString stringSrc("$src"), stringObj("$obj");
1478 for( ;sit != srcl.end() && oit != objl.end(); oit++, sit++) { 1642 for( ;sit != srcl.end() && oit != objl.end(); oit++, sit++) {
1479 QString hdr = findMocSource((*sit)); 1643 QString hdr = findMocSource((*sit));
1480 t << (*oit) << ": " << (*sit) << " " 1644 t << (*oit) << ": "
1645 << (*sit) << " " << findDependencies((*sit)).join(" \\\n\t\t") << " "
1481 << hdr << " " << findDependencies(hdr).join(" \\\n\t\t"); 1646 << hdr << " " << findDependencies(hdr).join(" \\\n\t\t");
1482 bool use_implicit_rule = !project->isEmpty("QMAKE_RUN_CXX_IMP"); 1647 bool use_implicit_rule = !project->isEmpty("QMAKE_RUN_CXX_IMP");
1483 if(use_implicit_rule) { 1648 if(use_implicit_rule) {
@@ -1490,8 +1655,8 @@ MakefileGenerator::writeMocObj(QTextStream &t, const QString &obj, const QString
1490 } 1655 }
1491 } 1656 }
1492 if (!use_implicit_rule && !project->isEmpty("QMAKE_RUN_CXX")) { 1657 if (!use_implicit_rule && !project->isEmpty("QMAKE_RUN_CXX")) {
1493 QString p = var("QMAKE_RUN_CXX"); 1658 QString p = var("QMAKE_RUN_CXX"), srcf(*sit);
1494 p.replace(stringSrc, (*sit)); 1659 p.replace(stringSrc, srcf);
1495 p.replace(stringObj, (*oit)); 1660 p.replace(stringObj, (*oit));
1496 t << "\n\t" << p; 1661 t << "\n\t" << p;
1497 } 1662 }
@@ -1512,7 +1677,8 @@ MakefileGenerator::writeMocSrc(QTextStream &t, const QString &src)
1512 deps += "$(MOC) "; 1677 deps += "$(MOC) ";
1513 deps += (*it); 1678 deps += (*it);
1514 t << m << ": " << deps << "\n\t" 1679 t << m << ": " << deps << "\n\t"
1515 << "$(MOC) " << (*it) << " -o " << m << endl << endl; 1680 << "$(MOC)";
1681 t << " " << (*it) << " -o " << m << endl << endl;
1516 } 1682 }
1517 } 1683 }
1518} 1684}
@@ -1545,6 +1711,9 @@ MakefileGenerator::writeYaccSrc(QTextStream &t, const QString &src)
1545 QString yaccflags = "$(YACCFLAGS)", mangle = "y"; 1711 QString yaccflags = "$(YACCFLAGS)", mangle = "y";
1546 if(!project->isActiveConfig("yacc_no_name_mangle")) { 1712 if(!project->isActiveConfig("yacc_no_name_mangle")) {
1547 mangle = fi.baseName(TRUE); 1713 mangle = fi.baseName(TRUE);
1714 if(!project->isEmpty("QMAKE_YACCFLAGS_MANGLE"))
1715 yaccflags += " " + var("QMAKE_YACCFLAGS_MANGLE").replace(stringBase, mangle);
1716 else
1548 yaccflags += " -p " + mangle; 1717 yaccflags += " -p " + mangle;
1549 } 1718 }
1550 QString out_h = default_out_h, out_c = default_out_c; 1719 QString out_h = default_out_h, out_c = default_out_c;
@@ -1621,8 +1790,8 @@ MakefileGenerator::writeImageObj(QTextStream &t, const QString &obj)
1621 } 1790 }
1622 } 1791 }
1623 if(!use_implicit_rule && !project->isEmpty("QMAKE_RUN_CXX")) { 1792 if(!use_implicit_rule && !project->isEmpty("QMAKE_RUN_CXX")) {
1624 QString p = var("QMAKE_RUN_CXX"); 1793 QString p = var("QMAKE_RUN_CXX"), srcf(src);
1625 p.replace( stringSrc, src); 1794 p.replace(stringSrc, srcf);
1626 p.replace( stringObj, (*oit)); 1795 p.replace( stringObj, (*oit));
1627 t << "\n\t" << p; 1796 t << "\n\t" << p;
1628 } 1797 }
@@ -1661,7 +1830,8 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs)
1661 QStringList &l = project->variables()[installs]; 1830 QStringList &l = project->variables()[installs];
1662 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 1831 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
1663 QString pvar = (*it) + ".path"; 1832 QString pvar = (*it) + ".path";
1664 if(project->variables()[pvar].isEmpty()) { 1833 if(project->variables()[(*it) + ".CONFIG"].findIndex("no_path") == -1 &&
1834 project->variables()[pvar].isEmpty()) {
1665 warn_msg(WarnLogic, "%s is not defined: install target not created\n", pvar.latin1()); 1835 warn_msg(WarnLogic, "%s is not defined: install target not created\n", pvar.latin1());
1666 continue; 1836 continue;
1667 } 1837 }
@@ -1669,13 +1839,13 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs)
1669 bool do_default = TRUE; 1839 bool do_default = TRUE;
1670 const QString root = "$(INSTALL_ROOT)"; 1840 const QString root = "$(INSTALL_ROOT)";
1671 QString target, dst= fileFixify(project->variables()[pvar].first()); 1841 QString target, dst= fileFixify(project->variables()[pvar].first());
1672#ifndef Q_WS_WIN
1673 if(dst.right(1) != Option::dir_sep) 1842 if(dst.right(1) != Option::dir_sep)
1674 dst += Option::dir_sep; 1843 dst += Option::dir_sep;
1675#endif 1844 QStringList tmp, uninst = project->variables()[(*it) + ".uninstall"];
1676 QStringList tmp, &uninst = project->variables()[(*it) + ".uninstall"];
1677 //other 1845 //other
1678 tmp = project->variables()[(*it) + ".extra"]; 1846 tmp = project->variables()[(*it) + ".extra"];
1847 if(tmp.isEmpty())
1848 tmp = project->variables()[(*it) + ".commands"]; //to allow compatible name
1679 if(!tmp.isEmpty()) { 1849 if(!tmp.isEmpty()) {
1680 do_default = FALSE; 1850 do_default = FALSE;
1681 if(!target.isEmpty()) 1851 if(!target.isEmpty())
@@ -1703,11 +1873,16 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs)
1703 QFileInfo fi(wild); 1873 QFileInfo fi(wild);
1704 if(!target.isEmpty()) 1874 if(!target.isEmpty())
1705 target += "\t"; 1875 target += "\t";
1706 target += QString(fi.isDir() ? "-$(COPY_DIR)" : "-$(COPY_FILE)") + " \"" + 1876 QString cmd = QString(fi.isDir() ? "-$(INSTALL_DIR)" : "-$(INSTALL_FILE)") + " \"" +
1707 Option::fixPathToTargetOS(fileFixify(wild), FALSE) + "\" \"" + root + dst + "\"\n"; 1877 Option::fixPathToTargetOS(fileFixify(wild, QString::null,
1878 QString::null, FALSE, FALSE), FALSE) +
1879 "\" \"" + root + dst + "\"\n";
1880 target += cmd;
1708 if(!project->isActiveConfig("debug") && 1881 if(!project->isActiveConfig("debug") &&
1709 !fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP")) 1882 !fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP"))
1710 target += QString("\t-") + var("QMAKE_STRIP") + " \"" + root + fileFixify(dst + filestr) + "\"\n"; 1883 target += QString("\t-") + var("QMAKE_STRIP") + " \"" +
1884 root + fileFixify(dst + filestr, QString::null, QString::null, FALSE, FALSE) +
1885 "\"\n";
1711 if(!uninst.isEmpty()) 1886 if(!uninst.isEmpty())
1712 uninst.append("\n\t"); 1887 uninst.append("\n\t");
1713 uninst.append( 1888 uninst.append(
@@ -1716,9 +1891,10 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs)
1716#else 1891#else
1717 QString("-$(DEL_FILE) -r") 1892 QString("-$(DEL_FILE) -r")
1718#endif 1893#endif
1719 + " \"" + root + fileFixify(dst + filestr) + "\""); 1894 + " \"" + root + fileFixify(dst + filestr, QString::null, QString::null, FALSE, FALSE) + "\"");
1720 continue; 1895 continue;
1721 } 1896 }
1897 fixEnvVariables(dirstr);
1722 QDir dir(dirstr, filestr); //wild 1898 QDir dir(dirstr, filestr); //wild
1723 for(uint x = 0; x < dir.count(); x++) { 1899 for(uint x = 0; x < dir.count(); x++) {
1724 QString file = dir[x]; 1900 QString file = dir[x];
@@ -1732,25 +1908,42 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs)
1732#else 1908#else
1733 QString("-$(DEL_FILE) -r") 1909 QString("-$(DEL_FILE) -r")
1734#endif 1910#endif
1735 + " \"" + root + fileFixify(dst + file) + "\""); 1911 + " \"" + root + fileFixify(dst + file, QString::null, QString::null, FALSE, FALSE) +
1736 QFileInfo fi(file); 1912 "\"");
1913 QFileInfo fi(Option::fixPathToTargetOS(fileFixify(dirstr + file), TRUE));
1737 if(!target.isEmpty()) 1914 if(!target.isEmpty())
1738 target += "\t"; 1915 target += "\t";
1739 target += QString(fi.isDir() ? "-$(COPY_DIR)" : "-$(COPY_FILE)") + " \"" + 1916 QString cmd = QString(fi.isDir() ? "-$(INSTALL_DIR)" : "-$(INSTALL_FILE)") + " \"" +
1740 Option::fixPathToTargetOS(fileFixify(dirstr + file), FALSE) + 1917 Option::fixPathToTargetOS(fileFixify(dirstr + file, QString::null,
1741 "\" \"" + root + fileFixify(dst) + "\"\n"; 1918 QString::null, FALSE, FALSE), FALSE) +
1919 "\" \"" + root + dst + "\"\n";
1920 target += cmd;
1742 if(!project->isActiveConfig("debug") && 1921 if(!project->isActiveConfig("debug") &&
1743 !fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP")) 1922 !fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP"))
1744 target += QString("\t-") + var("QMAKE_STRIP") + " \"" + root + fileFixify(dst + file) + "\"\n"; 1923 target += QString("\t-") + var("QMAKE_STRIP") + " \"" +
1924 root + fileFixify(dst + file, QString::null, QString::null, FALSE, FALSE) +
1925 "\"\n";
1745 } 1926 }
1746 } 1927 }
1747 } 1928 }
1748 //default? 1929 //default?
1749 if(do_default) 1930 if(do_default) {
1750 target = defaultInstall((*it)); 1931 target = defaultInstall((*it));
1932 uninst = project->variables()[(*it) + ".uninstall"];
1933 }
1751 1934
1752 if(!target.isEmpty()) { 1935 if(!target.isEmpty()) {
1753 t << "install_" << (*it) << ": " << "\n\t"; 1936 t << "install_" << (*it) << ": all ";
1937 const QStringList &deps = project->variables()[(*it) + ".depends"];
1938 if(!deps.isEmpty()) {
1939 for(QStringList::ConstIterator dep_it = deps.begin(); dep_it != deps.end(); ++dep_it) {
1940 QString targ = var((*dep_it) + ".target");
1941 if(targ.isEmpty())
1942 targ = (*dep_it);
1943 t << targ;
1944 }
1945 }
1946 t << "\n\t";
1754 const QStringList &dirs = project->variables()[pvar]; 1947 const QStringList &dirs = project->variables()[pvar];
1755 for(QStringList::ConstIterator pit = dirs.begin(); pit != dirs.end(); ++pit) { 1948 for(QStringList::ConstIterator pit = dirs.begin(); pit != dirs.end(); ++pit) {
1756 QString tmp_dst = fileFixify((*pit)); 1949 QString tmp_dst = fileFixify((*pit));
@@ -1761,20 +1954,24 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs)
1761 t << mkdir_p_asstring(root+tmp_dst) << "\n\t"; 1954 t << mkdir_p_asstring(root+tmp_dst) << "\n\t";
1762 } 1955 }
1763 t << target << endl << endl; 1956 t << target << endl << endl;
1764 all_installs += QString("install_") + (*it) + " ";
1765 if(!uninst.isEmpty()) { 1957 if(!uninst.isEmpty()) {
1766 t << "uninstall_" << (*it) << ": " << "\n\t" 1958 t << "uninstall_" << (*it) << ": " << "\n\t"
1767 << uninst.join("") << "\n\t" 1959 << uninst.join("") << "\n\t"
1768 << "-$(DEL_DIR) \"" << ( root + dst ) << "\"" << endl << endl; 1960 << "-$(DEL_DIR) \"" << ( root + dst ) << "\"" << endl << endl;
1769 all_uninstalls += "uninstall_" + (*it) + " ";
1770 } 1961 }
1771 t << endl; 1962 t << endl;
1963
1964 if(project->variables()[(*it) + ".CONFIG"].findIndex("no_default_install") == -1) {
1965 all_installs += QString("install_") + (*it) + " ";
1966 if(!uninst.isEmpty())
1967 all_uninstalls += "uninstall_" + (*it) + " ";
1968 }
1772 } else { 1969 } else {
1773 debug_msg(1, "no definition for install %s: install target not created",(*it).latin1()); 1970 debug_msg(1, "no definition for install %s: install target not created",(*it).latin1());
1774 } 1971 }
1775 } 1972 }
1776 t << "install: all " << all_installs << "\n\n"; 1973 t << "install: " << all_installs << " " << var("INSTALLDEPS") << "\n\n";
1777 t << "uninstall: " << all_uninstalls << "\n\n"; 1974 t << "uninstall: " << all_uninstalls << " " << var("UNINSTALLDEPS") << "\n\n";
1778} 1975}
1779 1976
1780QString 1977QString
@@ -1971,8 +2168,12 @@ MakefileGenerator::writeMakeQmake(QTextStream &t)
1971 t << ofile << ": " << fileFixify(pfile) << " "; 2168 t << ofile << ": " << fileFixify(pfile) << " ";
1972 if(Option::mkfile::do_cache) 2169 if(Option::mkfile::do_cache)
1973 t << fileFixify(Option::mkfile::cachefile) << " "; 2170 t << fileFixify(Option::mkfile::cachefile) << " ";
1974 if(!specdir().isEmpty()) 2171 if(!specdir().isEmpty()) {
2172 if (QFile::exists(Option::fixPathToLocalOS(specdir()+QDir::separator()+"qmake.conf")))
1975 t << specdir() << Option::dir_sep << "qmake.conf" << " "; 2173 t << specdir() << Option::dir_sep << "qmake.conf" << " ";
2174 else if (QFile::exists(Option::fixPathToLocalOS(specdir()+QDir::separator()+"tmake.conf")))
2175 t << specdir() << Option::dir_sep << "tmake.conf" << " ";
2176 }
1976 t << project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"].join(" \\\n\t\t") << "\n\t" 2177 t << project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"].join(" \\\n\t\t") << "\n\t"
1977 << qmake <<endl; 2178 << qmake <<endl;
1978 } 2179 }
@@ -1986,26 +2187,31 @@ MakefileGenerator::writeMakeQmake(QTextStream &t)
1986} 2187}
1987 2188
1988QStringList 2189QStringList
1989MakefileGenerator::fileFixify(const QStringList& files, const QString &out_dir, const QString &in_dir, bool force_fix) const 2190MakefileGenerator::fileFixify(const QStringList& files, const QString &out_dir, const QString &in_dir,
2191 bool force_fix, bool canon) const
1990{ 2192{
1991 if(files.isEmpty()) 2193 if(files.isEmpty())
1992 return files; 2194 return files;
1993 QStringList ret; 2195 QStringList ret;
1994 for(QStringList::ConstIterator it = files.begin(); it != files.end(); ++it) { 2196 for(QStringList::ConstIterator it = files.begin(); it != files.end(); ++it) {
1995 if(!(*it).isEmpty()) 2197 if(!(*it).isEmpty())
1996 ret << fileFixify((*it), out_dir, in_dir, force_fix); 2198 ret << fileFixify((*it), out_dir, in_dir, force_fix, canon);
1997 } 2199 }
1998 return ret; 2200 return ret;
1999} 2201}
2000 2202
2001QString 2203QString
2002MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const QString &in_d, bool force_fix) const 2204MakefileGenerator::fileFixify(const QString& file0, const QString &out_d,
2205 const QString &in_d, bool force_fix, bool canon) const
2003{ 2206{
2004 if(file0.isEmpty()) 2207 if(file0.isEmpty())
2005 return file0; 2208 return file0;
2006 QString key = file0; 2209 QString key = file0;
2007 if(!in_d.isEmpty() || !out_d.isEmpty() || force_fix) 2210 if(QDir::isRelativePath(file0))
2008 key.prepend(in_d + "--" + out_d + "--" + QString::number((int)force_fix) + "-"); 2211 key.prepend(QDir::currentDirPath() + "--");
2212 if(!in_d.isEmpty() || !out_d.isEmpty() || force_fix || !canon)
2213 key.prepend(in_d + "--" + out_d + "--" + QString::number((int)force_fix) + "--" +
2214 QString::number((int)canon) + "-");
2009 if(fileFixed.contains(key)) 2215 if(fileFixed.contains(key))
2010 return fileFixed[key]; 2216 return fileFixed[key];
2011 2217
@@ -2027,7 +2233,7 @@ MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const
2027 QString orig_file = file; 2233 QString orig_file = file;
2028 if(!force_fix && project->isActiveConfig("no_fixpath")) { 2234 if(!force_fix && project->isActiveConfig("no_fixpath")) {
2029 if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) { //absoluteify it 2235 if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) { //absoluteify it
2030 QString qfile = Option::fixPathToLocalOS(file); 2236 QString qfile = Option::fixPathToLocalOS(file, TRUE, canon);
2031 if(QDir::isRelativePath(file)) { //already absolute 2237 if(QDir::isRelativePath(file)) { //already absolute
2032 QFileInfo fi(qfile); 2238 QFileInfo fi(qfile);
2033 if(!fi.convertToAbs()) //strange 2239 if(!fi.convertToAbs()) //strange
@@ -2035,14 +2241,17 @@ MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const
2035 } 2241 }
2036 } 2242 }
2037 } else { //fix it.. 2243 } else { //fix it..
2038 QString qfile(Option::fixPathToLocalOS(file, TRUE)), in_dir(in_d), out_dir(out_d); 2244 QString qfile(Option::fixPathToLocalOS(file, TRUE, canon)), in_dir(in_d), out_dir(out_d);
2039 { 2245 {
2040 if(out_dir.isNull()) 2246 if(out_dir.isNull() || QDir::isRelativePath(out_dir))
2041 out_dir = Option::output_dir; 2247 out_dir.prepend(Option::output_dir + QDir::separator());
2042 if(out_dir == ".") 2248 if(out_dir == ".")
2043 out_dir = QDir::currentDirPath(); 2249 out_dir = QDir::currentDirPath();
2044 if(in_dir.isEmpty() || in_dir == ".") 2250 if(in_dir.isEmpty() || QDir::isRelativePath(in_dir))
2251 in_dir.prepend(QDir::currentDirPath() + QDir::separator());
2252 if(in_dir == ".")
2045 in_dir = QDir::currentDirPath(); 2253 in_dir = QDir::currentDirPath();
2254
2046 if(!QDir::isRelativePath(in_dir) || !QDir::isRelativePath(out_dir)) { 2255 if(!QDir::isRelativePath(in_dir) || !QDir::isRelativePath(out_dir)) {
2047 QFileInfo in_fi(in_dir); 2256 QFileInfo in_fi(in_dir);
2048 if(!in_fi.convertToAbs()) 2257 if(!in_fi.convertToAbs())
@@ -2065,13 +2274,13 @@ MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const
2065 file.prepend(Option::dir_sep); 2274 file.prepend(Option::dir_sep);
2066 file.prepend(in_dir); 2275 file.prepend(in_dir);
2067 } 2276 }
2068 file = Option::fixPathToTargetOS(file, FALSE); 2277 file = Option::fixPathToTargetOS(file, FALSE, canon);
2069 if(QFile::exists(file) && file == Option::fixPathToTargetOS(file, TRUE)) { 2278 if(canon && QFile::exists(file) && file == Option::fixPathToTargetOS(file, TRUE, canon)) {
2070 QString real_file = QDir(file).canonicalPath(); 2279 QString real_file = QDir(file).canonicalPath();
2071 if(!real_file.isEmpty()) 2280 if(!real_file.isEmpty())
2072 file = real_file; 2281 file = real_file;
2073 } 2282 }
2074 QString match_dir = Option::fixPathToTargetOS(out_dir, FALSE); 2283 QString match_dir = Option::fixPathToTargetOS(out_dir, FALSE, canon);
2075 if(file == match_dir) { 2284 if(file == match_dir) {
2076 file = ""; 2285 file = "";
2077 } else if(file.startsWith(match_dir) && 2286 } else if(file.startsWith(match_dir) &&
@@ -2100,12 +2309,13 @@ MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const
2100 } 2309 }
2101 } 2310 }
2102 } 2311 }
2103 file = Option::fixPathToTargetOS(file, FALSE); 2312 file = Option::fixPathToTargetOS(file, FALSE, canon);
2104 if(file.isEmpty()) 2313 if(file.isEmpty())
2105 file = "."; 2314 file = ".";
2106 if(!quote.isNull()) 2315 if(!quote.isNull())
2107 file = quote + file + quote; 2316 file = quote + file + quote;
2108 debug_msg(3, "Fixed %s :: to :: %s (%d)", orig_file.latin1(), file.latin1(), depth); 2317 debug_msg(3, "Fixed %s :: to :: %s (%d) [%s::%s]", orig_file.latin1(), file.latin1(), depth,
2318 in_d.latin1(), out_d.latin1());
2109 ((MakefileGenerator*)this)->fileFixed.insert(key, file); 2319 ((MakefileGenerator*)this)->fileFixed.insert(key, file);
2110 return file; 2320 return file;
2111} 2321}
@@ -2138,16 +2348,35 @@ void MakefileGenerator::logicWarn(const QString &f, const QString &w)
2138 } 2348 }
2139} 2349}
2140 2350
2141QStringList 2351QString
2142&MakefileGenerator::findDependencies(const QString &file) 2352MakefileGenerator::dependencyKey(const QString &file) const
2143{ 2353{
2144 QString key = file; 2354 QString key = file;
2145 Option::fixPathToTargetOS(key); 2355 Option::fixPathToTargetOS(key);
2146 if(key.find(Option::dir_sep)) 2356 if(key.find(Option::dir_sep))
2147 key = key.right(key.length() - key.findRev(Option::dir_sep) - 1); 2357 key = key.right(key.length() - key.findRev(Option::dir_sep) - 1);
2148 if(!depKeyMap.contains(key)) 2358 return key;
2149 depKeyMap.insert(key, file); 2359}
2150 return depends[key]; 2360
2361void
2362MakefileGenerator::setProcessedDependencies(const QString &file, bool b)
2363{
2364 depProcessed[dependencyKey(file)] = b;
2365}
2366
2367bool
2368MakefileGenerator::processedDependencies(const QString &file)
2369{
2370 QString key = dependencyKey(file);
2371 if(!depProcessed.contains(key))
2372 return FALSE;
2373 return depProcessed[key];
2374}
2375
2376QStringList
2377&MakefileGenerator::findDependencies(const QString &file)
2378{
2379 return depends[dependencyKey(file)];
2151} 2380}
2152 2381
2153 2382
@@ -2157,8 +2386,8 @@ MakefileGenerator::specdir()
2157 if(!spec.isEmpty()) 2386 if(!spec.isEmpty())
2158 return spec; 2387 return spec;
2159 spec = Option::mkfile::qmakespec; 2388 spec = Option::mkfile::qmakespec;
2160 const char *d = getenv("QTDIR"); 2389#if 0
2161 if(d) { 2390 if(const char *d = getenv("QTDIR")) {
2162 QString qdir = Option::fixPathToTargetOS(QString(d)); 2391 QString qdir = Option::fixPathToTargetOS(QString(d));
2163 if(qdir.endsWith(QString(QChar(QDir::separator())))) 2392 if(qdir.endsWith(QString(QChar(QDir::separator()))))
2164 qdir.truncate(qdir.length()-1); 2393 qdir.truncate(qdir.length()-1);
@@ -2172,6 +2401,9 @@ MakefileGenerator::specdir()
2172 spec = absSpec; 2401 spec = absSpec;
2173 } 2402 }
2174 } 2403 }
2404#else
2405 spec = Option::fixPathToTargetOS(spec);
2406#endif
2175 return spec; 2407 return spec;
2176} 2408}
2177 2409
@@ -2181,6 +2413,8 @@ MakefileGenerator::openOutput(QFile &file) const
2181 { 2413 {
2182 QString outdir; 2414 QString outdir;
2183 if(!file.name().isEmpty()) { 2415 if(!file.name().isEmpty()) {
2416 if(QDir::isRelativePath(file.name()))
2417 file.setName(Option::output_dir + file.name()); //pwd when qmake was run
2184 QFileInfo fi(file); 2418 QFileInfo fi(file);
2185 if(fi.isDir()) 2419 if(fi.isDir())
2186 outdir = file.name() + QDir::separator(); 2420 outdir = file.name() + QDir::separator();
diff --git a/qmake/generators/makefile.h b/qmake/generators/makefile.h
index 4fdabe8..e818089 100644
--- a/qmake/generators/makefile.h
+++ b/qmake/generators/makefile.h
@@ -1,13 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Definition of ________ class.
5** 3**
6** Created : 970521 4** Definition of MakefileGenerator class.
7** 5**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. 6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 7**
10** This file is part of the network module of the Qt GUI Toolkit. 8** This file is part of qmake.
11** 9**
12** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
@@ -41,13 +39,21 @@
41#include "project.h" 39#include "project.h"
42#include <qtextstream.h> 40#include <qtextstream.h>
43 41
42#ifdef Q_OS_WIN32
43#define QT_POPEN _popen
44#else
45#define QT_POPEN popen
46#endif
47
44class MakefileGenerator 48class MakefileGenerator
45{ 49{
46 QString spec; 50 QString spec;
47 bool init_opath_already, init_already, moc_aware, no_io; 51 bool init_opath_already, init_already, moc_aware, no_io;
48 QStringList createObjectList(const QString &var); 52 QStringList createObjectList(const QString &var);
49 QString build_args(); 53 QString build_args();
50 QMap<QString, QString> depHeuristics, depKeyMap, fileFixed; 54 QString dependencyKey(const QString &file) const;
55 QMap<QString, bool> depProcessed;
56 QMap<QString, QString> depHeuristics, fileFixed;
51 QMap<QString, QString> mocablesToMOC, mocablesFromMOC; 57 QMap<QString, QString> mocablesToMOC, mocablesFromMOC;
52 QMap<QString, QStringList> depends; 58 QMap<QString, QStringList> depends;
53 59
@@ -81,7 +87,7 @@ protected:
81 87
82 QString findMocSource(const QString &moc_file) const; 88 QString findMocSource(const QString &moc_file) const;
83 QString findMocDestination(const QString &src_file) const; 89 QString findMocDestination(const QString &src_file) const;
84 QStringList &findDependencies(const QString &file); 90 virtual QStringList &findDependencies(const QString &file);
85 91
86 void setNoIO(bool o); 92 void setNoIO(bool o);
87 bool noIO() const; 93 bool noIO() const;
@@ -97,6 +103,9 @@ protected:
97 void initOutPaths(); 103 void initOutPaths();
98 virtual void init(); 104 virtual void init();
99 105
106 //for cross-platform dependent directories
107 virtual void usePlatformDir();
108
100 //for installs 109 //for installs
101 virtual QString defaultInstall(const QString &); 110 virtual QString defaultInstall(const QString &);
102 111
@@ -108,8 +117,12 @@ protected:
108 117
109 //make sure libraries are found 118 //make sure libraries are found
110 virtual bool findLibraries(); 119 virtual bool findLibraries();
120 virtual QString findDependency(const QString &);
121
122 void setProcessedDependencies(const QString &file, bool b);
123 bool processedDependencies(const QString &file);
111 124
112 QString var(const QString &var); 125 virtual QString var(const QString &var);
113 QString varGlue(const QString &var, const QString &before, const QString &glue, const QString &after); 126 QString varGlue(const QString &var, const QString &before, const QString &glue, const QString &after);
114 QString varList(const QString &var); 127 QString varList(const QString &var);
115 QString val(const QStringList &varList); 128 QString val(const QStringList &varList);
@@ -118,15 +131,15 @@ protected:
118 131
119 132
120 QString fileFixify(const QString& file, const QString &out_dir=QString::null, 133 QString fileFixify(const QString& file, const QString &out_dir=QString::null,
121 const QString &in_dir=QString::null, bool force_fix=FALSE) const; 134 const QString &in_dir=QString::null, bool force_fix=FALSE, bool canon=TRUE) const;
122 QStringList fileFixify(const QStringList& files, const QString &out_dir=QString::null, 135 QStringList fileFixify(const QStringList& files, const QString &out_dir=QString::null,
123 const QString &in_dir=QString::null, bool force_fix=FALSE) const; 136 const QString &in_dir=QString::null, bool force_fix=FALSE, bool canon=TRUE) const;
124public: 137public:
125 MakefileGenerator(QMakeProject *p); 138 MakefileGenerator(QMakeProject *p);
126 virtual ~MakefileGenerator(); 139 virtual ~MakefileGenerator();
127 140
128 static MakefileGenerator *create(QMakeProject *); 141 static MakefileGenerator *create(QMakeProject *);
129 bool write(); 142 virtual bool write();
130 virtual bool openOutput(QFile &) const; 143 virtual bool openOutput(QFile &) const;
131}; 144};
132 145
@@ -166,8 +179,12 @@ inline QString MakefileGenerator::defaultInstall(const QString &)
166inline bool MakefileGenerator::findLibraries() 179inline bool MakefileGenerator::findLibraries()
167{ return TRUE; } 180{ return TRUE; }
168 181
182inline QString MakefileGenerator::findDependency(const QString &)
183{ return QString(""); }
184
169inline MakefileGenerator::~MakefileGenerator() 185inline MakefileGenerator::~MakefileGenerator()
170{ } 186{ }
171 187
188QString mkdir_p_asstring(const QString &dir);
172 189
173#endif /* __MAKEFILE_H__ */ 190#endif /* __MAKEFILE_H__ */
diff --git a/qmake/generators/projectgenerator.cpp b/qmake/generators/projectgenerator.cpp
index 1515216..1c17379 100644
--- a/qmake/generators/projectgenerator.cpp
+++ b/qmake/generators/projectgenerator.cpp
@@ -1,13 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Definition of ________ class.
5** 3**
6** Created : 970521 4** Implementation of ProjectGenerator class.
7** 5**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 7**
10** This file is part of the network module of the Qt GUI Toolkit. 8** This file is part of qmake.
11** 9**
12** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
@@ -157,6 +155,7 @@ ProjectGenerator::init()
157 QStringList dirs = Option::projfile::project_dirs; 155 QStringList dirs = Option::projfile::project_dirs;
158 if(Option::projfile::do_pwd) 156 if(Option::projfile::do_pwd)
159 dirs.prepend("."); 157 dirs.prepend(".");
158 const QString out_file = fileFixify(Option::output.name());
160 for(QStringList::Iterator pd = dirs.begin(); pd != dirs.end(); pd++) { 159 for(QStringList::Iterator pd = dirs.begin(); pd != dirs.end(); pd++) {
161 if(QFile::exists((*pd))) { 160 if(QFile::exists((*pd))) {
162 QString newdir = (*pd); 161 QString newdir = (*pd);
@@ -171,14 +170,17 @@ ProjectGenerator::init()
171 QDir d(newdir, "*.pro"); 170 QDir d(newdir, "*.pro");
172 d.setFilter(QDir::Files); 171 d.setFilter(QDir::Files);
173 for(int i = 0; i < (int)d.count(); i++) { 172 for(int i = 0; i < (int)d.count(); i++) {
174 QString nd = newdir + QDir::separator() + d[i]; 173 QString nd = newdir;
174 if(nd == ".")
175 nd = "";
176 else if(!nd.isEmpty() && !nd.endsWith(QString(QChar(QDir::separator()))))
177 nd += QDir::separator();
178 nd += d[i];
175 fileFixify(nd); 179 fileFixify(nd);
176 if(d[i] != "." && d[i] != ".." && !subdirs.contains(nd)) { 180 if(d[i] != "." && d[i] != ".." && !subdirs.contains(nd) && !out_file.endsWith(nd))
177 if(newdir + d[i] != Option::output_dir + Option::output.name())
178 subdirs.append(nd); 181 subdirs.append(nd);
179 } 182 }
180 } 183 }
181 }
182 if(Option::projfile::do_recursive) { 184 if(Option::projfile::do_recursive) {
183 QDir d(newdir); 185 QDir d(newdir);
184 d.setFilter(QDir::Dirs); 186 d.setFilter(QDir::Dirs);
@@ -324,7 +326,7 @@ ProjectGenerator::init()
324 break; 326 break;
325 } 327 }
326 } 328 }
327 if(!found && (*val_it).endsWith(Option::moc_ext)) 329 if(!found && (*val_it).endsWith(Option::cpp_moc_ext))
328 found = TRUE; 330 found = TRUE;
329 if(found) 331 if(found)
330 val_it = l.remove(val_it); 332 val_it = l.remove(val_it);
@@ -391,7 +393,7 @@ ProjectGenerator::addFile(QString file)
391 int s = file.findRev(Option::dir_sep); 393 int s = file.findRev(Option::dir_sep);
392 if(s != -1) 394 if(s != -1)
393 dir = file.left(s+1); 395 dir = file.left(s+1);
394 if(file.mid(dir.length(), Option::moc_mod.length()) == Option::moc_mod) 396 if(file.mid(dir.length(), Option::h_moc_mod.length()) == Option::h_moc_mod)
395 return FALSE; 397 return FALSE;
396 398
397 QString where; 399 QString where;
@@ -435,7 +437,7 @@ ProjectGenerator::addFile(QString file)
435 437
436 438
437QString 439QString
438ProjectGenerator::getWritableVar(const QString &v, bool /*fixPath*/) 440ProjectGenerator::getWritableVar(const QString &v, bool fixPath)
439{ 441{
440 QStringList &vals = project->variables()[v]; 442 QStringList &vals = project->variables()[v];
441 if(vals.isEmpty()) 443 if(vals.isEmpty())
@@ -455,10 +457,14 @@ ProjectGenerator::getWritableVar(const QString &v, bool /*fixPath*/)
455 spaces += " "; 457 spaces += " ";
456 join = vals.join(" \\\n" + spaces); 458 join = vals.join(" \\\n" + spaces);
457 } 459 }
460#if 0
458 // ### Commented out for now so that project generation works. 461 // ### Commented out for now so that project generation works.
459 // Sam: can you look at why this was needed? 462 // Sam: it had to do with trailing \'s (ie considered continuation lines)
460 /* if(fixPath) 463 if(fixPath)
461 join = join.replace("\\", "/");*/ 464 join = join.replace("\\", "/");
465#else
466 Q_UNUSED(fixPath);
467#endif
462 return ret + join + "\n"; 468 return ret + join + "\n";
463} 469}
464 470
diff --git a/qmake/generators/projectgenerator.h b/qmake/generators/projectgenerator.h
index 055a784..bebb259 100644
--- a/qmake/generators/projectgenerator.h
+++ b/qmake/generators/projectgenerator.h
@@ -1,13 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Definition of ________ class.
5** 3**
6** Created : 970521 4** Definition of ProjectGenerator class.
7** 5**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 7**
10** This file is part of the network module of the Qt GUI Toolkit. 8** This file is part of qmake.
11** 9**
12** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp
index e274481..caaddee 100644
--- a/qmake/generators/unix/unixmake.cpp
+++ b/qmake/generators/unix/unixmake.cpp
@@ -1,13 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Definition of ________ class.
5** 3**
6** Created : 970521 4** Implementation of UnixMakefileGenerator class.
7** 5**
8** Copyright (C) 1992-2003 Trolltech AS. All rights reserved. 6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 7**
10** This file is part of the network module of the Qt GUI Toolkit. 8** This file is part of qmake.
11** 9**
12** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
@@ -78,10 +76,24 @@ UnixMakefileGenerator::init()
78 project->variables()["QMAKE_EXTENSION_SHLIB"].append( "dll" ); 76 project->variables()["QMAKE_EXTENSION_SHLIB"].append( "dll" );
79 } 77 }
80 } 78 }
79 if( project->isEmpty("QMAKE_CFLAGS_PRECOMPILE"))
80 project->variables()["QMAKE_CFLAGS_PRECOMPILE"].append("-x c-header -c");
81 if( project->isEmpty("QMAKE_CXXFLAGS_PRECOMPILE"))
82 project->variables()["QMAKE_CXXFLAGS_PRECOMPILE"].append("-x c++-header -c");
83 if( project->isEmpty("QMAKE_CFLAGS_USE_PRECOMPILE"))
84 project->variables()["QMAKE_CFLAGS_USE_PRECOMPILE"].append("-include");
85 if( project->isEmpty("QMAKE_EXTENSION_PLUGIN") )
86 project->variables()["QMAKE_EXTENSION_PLUGIN"].append(project->first("QMAKE_EXTENSION_SHLIB"));
81 if( project->isEmpty("QMAKE_COPY_FILE") ) 87 if( project->isEmpty("QMAKE_COPY_FILE") )
82 project->variables()["QMAKE_COPY_FILE"].append( "$(COPY) -p" ); 88 project->variables()["QMAKE_COPY_FILE"].append( "$(COPY)" );
83 if( project->isEmpty("QMAKE_COPY_DIR") ) 89 if( project->isEmpty("QMAKE_COPY_DIR") )
84 project->variables()["QMAKE_COPY_DIR"].append( "$(COPY) -pR" ); 90 project->variables()["QMAKE_COPY_DIR"].append( "$(COPY) -R" );
91 if( project->isEmpty("QMAKE_INSTALL_FILE") )
92 project->variables()["QMAKE_INSTALL_FILE"].append( "$(COPY_FILE)" );
93 if( project->isEmpty("QMAKE_INSTALL_DIR") )
94 project->variables()["QMAKE_INSTALL_DIR"].append( "$(COPY_DIR)" );
95 if( project->isEmpty("QMAKE_LIBTOOL") )
96 project->variables()["QMAKE_LIBTOOL"].append( "libtool --silent" );
85 //If the TARGET looks like a path split it into DESTDIR and the resulting TARGET 97 //If the TARGET looks like a path split it into DESTDIR and the resulting TARGET
86 if(!project->isEmpty("TARGET")) { 98 if(!project->isEmpty("TARGET")) {
87 QString targ = project->first("TARGET"); 99 QString targ = project->first("TARGET");
@@ -103,7 +115,6 @@ UnixMakefileGenerator::init()
103 bool extern_libs = !project->isEmpty("QMAKE_APP_FLAG") || 115 bool extern_libs = !project->isEmpty("QMAKE_APP_FLAG") ||
104 (!project->isEmpty("QMAKE_LIB_FLAG") && 116 (!project->isEmpty("QMAKE_LIB_FLAG") &&
105 project->isActiveConfig("dll")) || is_qt; 117 project->isActiveConfig("dll")) || is_qt;
106 if(!project->isActiveConfig("global_init_link_order"))
107 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; 118 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
108 if ( (!project->isEmpty("QMAKE_LIB_FLAG") && !project->isActiveConfig("staticlib") ) || 119 if ( (!project->isEmpty("QMAKE_LIB_FLAG") && !project->isActiveConfig("staticlib") ) ||
109 (project->isActiveConfig("qt") && project->isActiveConfig( "plugin" ) )) { 120 (project->isActiveConfig("qt") && project->isActiveConfig( "plugin" ) )) {
@@ -137,21 +148,22 @@ UnixMakefileGenerator::init()
137 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"]; 148 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"];
138 if(!project->isEmpty("QMAKE_LIBDIR")) { 149 if(!project->isEmpty("QMAKE_LIBDIR")) {
139 if ( !project->isEmpty("QMAKE_RPATH") ) 150 if ( !project->isEmpty("QMAKE_RPATH") )
140 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR", " " + var("QMAKE_RPATH"), 151 project->variables()["QMAKE_LFLAGS"] += varGlue("QMAKE_LIBDIR", " " + var("QMAKE_RPATH"),
141 " " + var("QMAKE_RPATH"), ""); 152 " " + var("QMAKE_RPATH"), "");
142 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue( "QMAKE_LIBDIR", "-L", " -L", "" ); 153 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue( "QMAKE_LIBDIR", "-L", " -L", "" );
143 } 154 }
144 if ( extern_libs && (project->isActiveConfig("qt") || project->isActiveConfig("opengl")) ) { 155 if ( project->isActiveConfig("qtopia") ) {
145 if(configs.findIndex("x11lib") == -1) 156 if(configs.findIndex("qtopialib") == -1)
146 configs.append("x11lib"); 157 configs.append("qtopialib");
147 if ( project->isActiveConfig("opengl") && configs.findIndex("x11inc") == -1 ) 158 if(configs.findIndex("qtopiainc") == -1)
148 configs.append("x11inc"); 159 configs.append("qtopiainc");
149 } 160 }
150 if ( project->isActiveConfig("x11") ) { 161 if ( project->isActiveConfig("qtopiainc") )
151 if(configs.findIndex("x11lib") == -1) 162 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QTOPIA"];
152 configs.append("x11lib"); 163 if ( project->isActiveConfig("qtopialib") ) {
153 if(configs.findIndex("x11inc") == -1) 164 if(!project->isEmpty("QMAKE_LIBDIR_QTOPIA"))
154 configs.append("x11inc"); 165 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_QTOPIA", "-L", " -L", "");
166 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QTOPIA"];
155 } 167 }
156 if ( project->isActiveConfig("qt") ) { 168 if ( project->isActiveConfig("qt") ) {
157 if ( project->isActiveConfig("accessibility" ) ) 169 if ( project->isActiveConfig("accessibility" ) )
@@ -163,19 +175,23 @@ UnixMakefileGenerator::init()
163 if ( !project->isActiveConfig("debug") ) 175 if ( !project->isActiveConfig("debug") )
164 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG"); 176 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG");
165 if ( !is_qt ) { 177 if ( !is_qt ) {
166 if ( !project->isEmpty("QMAKE_LIBDIR_QT") ) { 178 if ( !project->isEmpty("QMAKE_RPATH") ) {
167 if ( !project->isEmpty("QMAKE_RPATH") ) 179 if ( !project->isEmpty("QMAKE_RTLDIR_QT") )
168 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_QT", " " + var("QMAKE_RPATH"), 180 project->variables()["QMAKE_LFLAGS"] += varGlue("QMAKE_RTLDIR_QT", " " + var("QMAKE_RPATH"),
181 " " + var("QMAKE_RPATH"), "");
182 else if ( !project->isEmpty("QMAKE_LIBDIR_QT") )
183 project->variables()["QMAKE_LFLAGS"] += varGlue("QMAKE_LIBDIR_QT", " " + var("QMAKE_RPATH"),
169 " " + var("QMAKE_RPATH"), ""); 184 " " + var("QMAKE_RPATH"), "");
170 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_QT", "-L", " -L", "");
171 } 185 }
186 if ( !project->isEmpty("QMAKE_LIBDIR_QT") )
187 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_QT", "-L", " -L", "");
172 if (project->isActiveConfig("thread") && !project->isEmpty("QMAKE_LIBS_QT_THREAD")) 188 if (project->isActiveConfig("thread") && !project->isEmpty("QMAKE_LIBS_QT_THREAD"))
173 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; 189 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"];
174 else 190 else
175 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; 191 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"];
176 } 192 }
177 } 193 }
178 if ( project->isActiveConfig("opengl") ) { 194 if ( project->isActiveConfig("opengl") && !project->isActiveConfig("dlopen_opengl")) {
179 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_OPENGL"]; 195 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_OPENGL"];
180 if(!project->isEmpty("QMAKE_LIBDIR_OPENGL")) 196 if(!project->isEmpty("QMAKE_LIBDIR_OPENGL"))
181 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_OPENGL", "-L", " -L", ""); 197 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_OPENGL", "-L", " -L", "");
@@ -184,8 +200,18 @@ UnixMakefileGenerator::init()
184 else 200 else
185 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; 201 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"];
186 } 202 }
187 if(project->isActiveConfig("global_init_link_order")) 203 if ( extern_libs && (project->isActiveConfig("qt") || project->isActiveConfig("opengl")) ) {
188 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; 204 if(configs.findIndex("x11lib") == -1)
205 configs.append("x11lib");
206 if ( project->isActiveConfig("opengl") && configs.findIndex("x11inc") == -1 )
207 configs.append("x11inc");
208 }
209 if ( project->isActiveConfig("x11") ) {
210 if(configs.findIndex("x11lib") == -1)
211 configs.append("x11lib");
212 if(configs.findIndex("x11inc") == -1)
213 configs.append("x11inc");
214 }
189 if ( project->isActiveConfig("x11inc") ) 215 if ( project->isActiveConfig("x11inc") )
190 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_X11"]; 216 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_X11"];
191 if ( project->isActiveConfig("x11lib") ) { 217 if ( project->isActiveConfig("x11lib") ) {
@@ -200,10 +226,14 @@ UnixMakefileGenerator::init()
200 if ( project->isActiveConfig("thread") ) { 226 if ( project->isActiveConfig("thread") ) {
201 if(project->isActiveConfig("qt")) 227 if(project->isActiveConfig("qt"))
202 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT"); 228 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT");
203 if ( !project->isEmpty("QMAKE_CFLAGS_THREAD")) 229 if ( !project->isEmpty("QMAKE_CFLAGS_THREAD")) {
204 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_THREAD"]; 230 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_THREAD"];
205 if( !project->isEmpty("QMAKE_CXXFLAGS_THREAD")) 231 project->variables()["PRL_EXPORT_CFLAGS"] += project->variables()["QMAKE_CFLAGS_THREAD"];
232 }
233 if( !project->isEmpty("QMAKE_CXXFLAGS_THREAD")) {
206 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_THREAD"]; 234 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_THREAD"];
235 project->variables()["PRL_EXPORT_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_THREAD"];
236 }
207 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_THREAD"]; 237 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_THREAD"];
208 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_THREAD"]; 238 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_THREAD"];
209 if(!project->isEmpty("QMAKE_LFLAGS_THREAD")) 239 if(!project->isEmpty("QMAKE_LFLAGS_THREAD"))
@@ -211,24 +241,35 @@ UnixMakefileGenerator::init()
211 } 241 }
212 if ( project->isActiveConfig("moc") ) 242 if ( project->isActiveConfig("moc") )
213 setMocAware(TRUE); 243 setMocAware(TRUE);
214 if ( project->isEmpty("QMAKE_RUN_CC") ) 244 QString compile_flag = var("QMAKE_COMPILE_FLAG");
215 project->variables()["QMAKE_RUN_CC"].append("$(CC) -c $(CFLAGS) $(INCPATH) -o $obj $src"); 245 if(compile_flag.isEmpty())
216 if ( project->isEmpty("QMAKE_RUN_CC_IMP") ) 246 compile_flag = "-c";
217 project->variables()["QMAKE_RUN_CC_IMP"].append("$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<"); 247 if(doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER")) {
218 if ( project->isEmpty("QMAKE_RUN_CXX") ) 248 QString prefix_flags = project->first("QMAKE_CFLAGS_PREFIX_INCLUDE");
219 project->variables()["QMAKE_RUN_CXX"].append("$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $obj $src"); 249 if(prefix_flags.isEmpty())
220 if ( project->isEmpty("QMAKE_RUN_CXX_IMP") ) 250 prefix_flags = "-include";
221 project->variables()["QMAKE_RUN_CXX_IMP"].append("$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<"); 251 compile_flag += " " + prefix_flags + " " + project->first("QMAKE_ORIG_TARGET");
222 project->variables()["QMAKE_FILETAGS"] += QStringList::split("HEADERS SOURCES TARGET DESTDIR", " "); 252 }
223 if ( !project->isEmpty("PRECOMPH") ) { 253 if(!project->isEmpty("ALLMOC_HEADER")) {
224 initOutPaths(); // Need to fix MOC_DIR since we do this before init() 254 initOutPaths(); // Need to fix outdirs since we do this before init() (because we could add to SOURCES et al)
225 QString allmoc = fileFixify(project->first("MOC_DIR") + "/allmoc.cpp", QDir::currentDirPath(), Option::output_dir); 255 QString allmoc = fileFixify(project->first("MOC_DIR") + "/allmoc.cpp", QDir::currentDirPath(), Option::output_dir);
226 project->variables()["SOURCES"].prepend(allmoc); 256 project->variables()["SOURCES"].prepend(allmoc);
227 project->variables()["HEADERS_ORIG"] = project->variables()["HEADERS"]; 257 project->variables()["HEADERS_ORIG"] = project->variables()["HEADERS"];
228 project->variables()["HEADERS"].clear(); 258 project->variables()["HEADERS"].clear();
229 } 259 }
260 if ( project->isEmpty("QMAKE_RUN_CC") )
261 project->variables()["QMAKE_RUN_CC"].append("$(CC) " + compile_flag + " $(CFLAGS) $(INCPATH) -o $obj $src");
262 if ( project->isEmpty("QMAKE_RUN_CC_IMP") )
263 project->variables()["QMAKE_RUN_CC_IMP"].append("$(CC) " + compile_flag + " $(CFLAGS) $(INCPATH) -o $@ $<");
264 if ( project->isEmpty("QMAKE_RUN_CXX") )
265 project->variables()["QMAKE_RUN_CXX"].append("$(CXX) " + compile_flag + " $(CXXFLAGS) $(INCPATH) -o $obj $src");
266 if ( project->isEmpty("QMAKE_RUN_CXX_IMP") )
267 project->variables()["QMAKE_RUN_CXX_IMP"].append("$(CXX) " + compile_flag + " $(CXXFLAGS) $(INCPATH) -o $@ $<");
268 project->variables()["QMAKE_FILETAGS"] += QStringList::split("HEADERS SOURCES TARGET DESTDIR", " ");
230 if( project->isActiveConfig("GNUmake") && !project->isEmpty("QMAKE_CFLAGS_DEPS")) 269 if( project->isActiveConfig("GNUmake") && !project->isEmpty("QMAKE_CFLAGS_DEPS"))
231 include_deps = TRUE; //do not generate deps 270 include_deps = TRUE; //do not generate deps
271 if(project->isActiveConfig("compile_libtool"))
272 Option::obj_ext = ".lo"; //override the .o
232 273
233 MakefileGenerator::init(); 274 MakefileGenerator::init();
234 if ( project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) { 275 if ( project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) {
@@ -240,9 +281,11 @@ UnixMakefileGenerator::init()
240 project->variables()["QMAKE_PKGINFO"].append(project->first("DESTDIR") + "../PkgInfo"); 281 project->variables()["QMAKE_PKGINFO"].append(project->first("DESTDIR") + "../PkgInfo");
241 project->variables()["ALL_DEPS"] += project->first("QMAKE_PKGINFO"); 282 project->variables()["ALL_DEPS"] += project->first("QMAKE_PKGINFO");
242 283
243 QString plist = specdir() + QDir::separator() + "Info.plist." + 284 QString plist = fileFixify(project->first("QMAKE_INFO_PLIST"));
244 project->first("TEMPLATE"); 285 if(plist.isEmpty())
286 plist = specdir() + QDir::separator() + "Info.plist." + project->first("TEMPLATE");
245 if(QFile::exists(Option::fixPathToLocalOS(plist))) { 287 if(QFile::exists(Option::fixPathToLocalOS(plist))) {
288 if(project->isEmpty("QMAKE_INFO_PLIST"))
246 project->variables()["QMAKE_INFO_PLIST"].append(plist); 289 project->variables()["QMAKE_INFO_PLIST"].append(plist);
247 project->variables()["QMAKE_INFO_PLIST_OUT"].append(project->first("DESTDIR") + 290 project->variables()["QMAKE_INFO_PLIST_OUT"].append(project->first("DESTDIR") +
248 "../Info.plist"); 291 "../Info.plist");
@@ -283,49 +326,105 @@ UnixMakefileGenerator::init()
283 project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "QMAKE_AR_SUBLIBS"; 326 project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "QMAKE_AR_SUBLIBS";
284 } 327 }
285 } 328 }
329
330 if(project->isActiveConfig("compile_libtool")) {
331 const QString libtoolify[] = { "QMAKE_RUN_CC", "QMAKE_RUN_CC_IMP",
332 "QMAKE_RUN_CXX", "QMAKE_RUN_CXX_IMP",
333 "QMAKE_LINK_THREAD", "QMAKE_LINK", "QMAKE_AR_CMD", "QMAKE_LINK_SHLIB_CMD",
334 QString::null };
335 for(int i = 0; !libtoolify[i].isNull(); i++) {
336 QStringList &l = project->variables()[libtoolify[i]];
337 if(!l.isEmpty()) {
338 QString libtool_flags, comp_flags;
339 if(libtoolify[i].startsWith("QMAKE_LINK") || libtoolify[i] == "QMAKE_AR_CMD") {
340 libtool_flags += " --mode=link";
341 if(project->isActiveConfig("staticlib")) {
342 libtool_flags += " -static";
343 } else {
344 if(!project->isEmpty("QMAKE_LIB_FLAG")) {
345 int maj = project->first("VER_MAJ").toInt();
346 int min = project->first("VER_MIN").toInt();
347 int pat = project->first("VER_PAT").toInt();
348 comp_flags += " -version-info " + QString::number(10*maj + min) +
349 ":" + QString::number(pat) + ":0";
350 if(libtoolify[i] != "QMAKE_AR_CMD") {
351 QString rpath = Option::output_dir;
352 if(!project->isEmpty("DESTDIR")) {
353 rpath = project->first("DESTDIR");
354 if(QDir::isRelativePath(rpath))
355 rpath.prepend(Option::output_dir + Option::dir_sep);
356 }
357 comp_flags += " -rpath " + Option::fixPathToTargetOS(rpath, FALSE);
358 }
359 }
360 }
361 if(project->isActiveConfig("plugin"))
362 libtool_flags += " -module";
363 } else {
364 libtool_flags += " --mode=compile";
365 }
366 l.first().prepend("$(LIBTOOL)" + libtool_flags + " ");
367 if(!comp_flags.isEmpty())
368 l.first() += comp_flags;
369 }
370 }
371 }
286} 372}
287 373
288QStringList 374QStringList
289UnixMakefileGenerator::uniqueSetLFlags(const QStringList &list1, QStringList &list2) 375UnixMakefileGenerator::combineSetLFlags(const QStringList &list1, const QStringList &list2)
290{ 376{
377 if(project->isActiveConfig("no_smart_library_merge"))
378 return list1 + list2;
379
291 QStringList ret; 380 QStringList ret;
292 for(QStringList::ConstIterator it = list1.begin(); it != list1.end(); ++it) { 381 for(int i = 0; i < 2; i++) {
293 bool unique = TRUE; 382 const QStringList *lst = i ? &list2 : &list1;
383 for(QStringList::ConstIterator it = lst->begin(); it != lst->end(); ++it) {
294 if((*it).startsWith("-")) { 384 if((*it).startsWith("-")) {
295 if((*it).startsWith("-l") || (*it).startsWith("-L")) { 385 if((*it).startsWith("-L")) {
296 unique = list2.findIndex((*it)) == -1; 386 if(ret.findIndex((*it)) == -1)
387 ret.append((*it));
388 } else if((*it).startsWith("-l")) {
389 while(1) {
390 QStringList::Iterator idx = ret.find((*it));
391 if(idx == ret.end())
392 break;
393 ret.remove(idx);
394 }
395 ret.append((*it));
297 } else if(project->isActiveConfig("macx") && (*it).startsWith("-framework")) { 396 } else if(project->isActiveConfig("macx") && (*it).startsWith("-framework")) {
298 int as_one = TRUE; 397 int as_one = TRUE;
299 QString framework_in; 398 QString framework_in;
300 if((*it).length() > 11) { 399 if((*it).length() > 11) {
301 framework_in = (*it).mid(11); 400 framework_in = (*it).mid(11);
302 } else { 401 } else {
303 if(it != list1.end()) { 402 if(it != lst->end()) {
304 ++it; 403 ++it;
305 as_one = FALSE; 404 as_one = FALSE;
306 framework_in = (*it); 405 framework_in = (*it);
307 } 406 }
308 } 407 }
309 if(!framework_in.isEmpty()) { 408 if(!framework_in.isEmpty()) {
310 for(QStringList::ConstIterator outit = list2.begin(); outit != list2.end(); ++outit) { 409 for(QStringList::Iterator outit = ret.begin(); outit != ret.end(); ++outit) {
311 if((*outit).startsWith("-framework")) { 410 if((*outit).startsWith("-framework")) {
312 QString framework_out; 411 int found = 0;
313 if((*outit).length() > 11) { 412 if((*outit).length() > 11) {
314 framework_out = (*outit).mid(11); 413 if(framework_in == (*outit).mid(11))
414 found = 1;
315 } else { 415 } else {
316 if(it != list2.end()) { 416 if(it != lst->end()) {
317 ++outit; 417 ++outit;
318 framework_out = (*outit); 418 if(framework_in == (*outit)) {
419 --outit;
420 found = 2;
319 } 421 }
320 } 422 }
321 if(framework_out == framework_in) {
322 unique = FALSE;
323 break;
324 } 423 }
424 for(int i = 0; i < found; i++)
425 outit = ret.remove(outit);
325 } 426 }
326 } 427 }
327 if(unique) {
328 unique = FALSE; //because I'm about to just insert it myself
329 if(as_one) { 428 if(as_one) {
330 ret.append("-framework " + framework_in); 429 ret.append("-framework " + framework_in);
331 } else { 430 } else {
@@ -333,29 +432,107 @@ UnixMakefileGenerator::uniqueSetLFlags(const QStringList &list1, QStringList &li
333 ret.append(framework_in); 432 ret.append(framework_in);
334 } 433 }
335 } 434 }
336 }
337 } else { 435 } else {
338 unique = (list2.findIndex((*it)) == -1); 436#if 1
437 while(1) {
438 QStringList::Iterator idx = ret.find((*it));
439 if(idx == ret.end())
440 break;
441 ret.remove(idx);
339 } 442 }
340 } else if(QFile::exists((*it))) { 443#endif
341 unique = (list2.findIndex((*it)) == -1); 444 ret.append((*it));
445 }
446 } else /*if(QFile::exists((*it)))*/ {
447 while(1) {
448 QStringList::Iterator idx = ret.find((*it));
449 if(idx == ret.end())
450 break;
451 ret.remove(idx);
342 } 452 }
343 if(unique)
344 ret.append((*it)); 453 ret.append((*it));
345 } 454 }
455 }
456 }
346 return ret; 457 return ret;
347} 458}
348 459
349
350void 460void
351UnixMakefileGenerator::processPrlVariable(const QString &var, const QStringList &l) 461UnixMakefileGenerator::processPrlVariable(const QString &var, const QStringList &l)
352{ 462{
353 if(var == "QMAKE_PRL_LIBS") 463 if(var == "QMAKE_PRL_LIBS")
354 project->variables()["QMAKE_CURRENT_PRL_LIBS"] += uniqueSetLFlags(l, project->variables()["QMAKE_LIBS"]); 464 project->variables()["QMAKE_CURRENT_PRL_LIBS"] = combineSetLFlags(project->variables()["QMAKE_CURRENT_PRL_LIBS"] +
465 project->variables()["QMAKE_LIBS"], l);
355 else 466 else
356 MakefileGenerator::processPrlVariable(var, l); 467 MakefileGenerator::processPrlVariable(var, l);
357} 468}
358 469
470QString
471UnixMakefileGenerator::findDependency(const QString &dep)
472{
473 QStringList::Iterator it;
474 {
475 QStringList &qut = project->variables()["QMAKE_EXTRA_UNIX_TARGETS"];
476 for(it = qut.begin(); it != qut.end(); ++it) {
477 QString targ = var((*it) + ".target");
478 if(targ.isEmpty())
479 targ = (*it);
480 if(targ.endsWith(dep))
481 return targ;
482 }
483 }
484 {
485 QStringList &quc = project->variables()["QMAKE_EXTRA_UNIX_COMPILERS"];
486 for(it = quc.begin(); it != quc.end(); ++it) {
487 QString tmp_out = project->variables()[(*it) + ".output"].first();
488 QString tmp_cmd = project->variables()[(*it) + ".commands"].join(" ");
489 if(tmp_out.isEmpty() || tmp_cmd.isEmpty())
490 continue;
491 QStringList &tmp = project->variables()[(*it) + ".input"];
492 for(QStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {
493 QStringList &inputs = project->variables()[(*it2)];
494 for(QStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {
495 QString out = tmp_out;
496 QFileInfo fi(Option::fixPathToLocalOS((*input)));
497 out.replace("${QMAKE_FILE_BASE}", fi.baseName());
498 out.replace("${QMAKE_FILE_NAME}", fi.fileName());
499 if(out.endsWith(dep))
500 return out;
501 }
502 }
503 }
504 }
505 return MakefileGenerator::findDependency(dep);
506}
507
508QStringList
509&UnixMakefileGenerator::findDependencies(const QString &file)
510{
511 QStringList &ret = MakefileGenerator::findDependencies(file);
512 // Note: The QMAKE_IMAGE_COLLECTION file have all images
513 // as dependency, so don't add precompiled header then
514 if(doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER")
515 && file != project->first("QMAKE_IMAGE_COLLECTION")) {
516 QString header_prefix = project->first("QMAKE_ORIG_TARGET") + ".gch" + Option::dir_sep;
517 header_prefix += project->first("QMAKE_PRECOMP_PREFIX");
518 if(file.endsWith(".c")) {
519 QString precomp_h = header_prefix + "c";
520 if(!ret.contains(precomp_h))
521 ret += precomp_h;
522 } else {
523 for(QStringList::Iterator it = Option::cpp_ext.begin(); it != Option::cpp_ext.end(); ++it) {
524 if(file.endsWith(*it)) {
525 QString precomp_h = header_prefix + "c++";
526 if(!ret.contains(precomp_h))
527 ret += precomp_h;
528 break;
529 }
530 }
531 }
532 }
533 return ret;
534}
535
359bool 536bool
360UnixMakefileGenerator::findLibraries() 537UnixMakefileGenerator::findLibraries()
361{ 538{
@@ -400,7 +577,7 @@ UnixMakefileGenerator::findLibraries()
400 } 577 }
401 } 578 }
402 if(!stub.isEmpty()) { 579 if(!stub.isEmpty()) {
403 const QString modifs[] = { "-mt", QString::null }; 580 const QString modifs[] = { "", "-mt", QString::null };
404 for(int modif = 0; !modifs[modif].isNull(); modif++) { 581 for(int modif = 0; !modifs[modif].isNull(); modif++) {
405 bool found = FALSE; 582 bool found = FALSE;
406 QStringList extens; 583 QStringList extens;
@@ -431,8 +608,18 @@ UnixMakefileGenerator::findLibraries()
431 } 608 }
432 } 609 }
433 } 610 }
611 if(!found && project->isActiveConfig("compile_libtool")) {
612 for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) {
613 if(QFile::exists(mdd->local_dir + Option::dir_sep + "lib" + stub + modifs[modif] + Option::libtool_ext)) {
614 (*it) = mdd->real_dir + Option::dir_sep + "lib" + stub + modifs[modif] + Option::libtool_ext;
615 found = TRUE;
616 break;
617 }
618 }
619 }
434 if(found) 620 if(found)
435 break; 621 break;
622
436 } 623 }
437 } 624 }
438 } 625 }
@@ -440,6 +627,14 @@ UnixMakefileGenerator::findLibraries()
440 return FALSE; 627 return FALSE;
441} 628}
442 629
630QString linkLib(const QString &file, const QString &libName) {
631 QString ret;
632 QRegExp reg("^.*lib(" + libName + "[^./=]*).*$");
633 if(reg.exactMatch(file))
634 ret = "-l" + reg.cap(1);
635 return ret;
636}
637
443void 638void
444UnixMakefileGenerator::processPrlFiles() 639UnixMakefileGenerator::processPrlFiles()
445{ 640{
@@ -453,7 +648,7 @@ UnixMakefileGenerator::processPrlFiles()
453 QStringList &l = project->variables()[lflags[i]]; 648 QStringList &l = project->variables()[lflags[i]];
454 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 649 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
455 project->variables()["QMAKE_CURRENT_PRL_LIBS"].clear(); 650 project->variables()["QMAKE_CURRENT_PRL_LIBS"].clear();
456 QString opt = (*it).stripWhiteSpace();; 651 QString opt = (*it).stripWhiteSpace();
457 if(opt.startsWith("-")) { 652 if(opt.startsWith("-")) {
458 if(opt.startsWith("-L")) { 653 if(opt.startsWith("-L")) {
459 QString r = opt.right(opt.length() - 2), l = r; 654 QString r = opt.right(opt.length() - 2), l = r;
@@ -461,16 +656,22 @@ UnixMakefileGenerator::processPrlFiles()
461 libdirs.append(new MakefileDependDir(r.replace("\"",""), 656 libdirs.append(new MakefileDependDir(r.replace("\"",""),
462 l.replace("\"",""))); 657 l.replace("\"","")));
463 } else if(opt.startsWith("-l") && !processed[opt]) { 658 } else if(opt.startsWith("-l") && !processed[opt]) {
464 QString lib = opt.right(opt.length() - 2), prl; 659 QString lib = opt.right(opt.length() - 2);
465 for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) { 660 for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) {
466 prl = mdd->local_dir + Option::dir_sep + "lib" + lib + Option::prl_ext; 661 if(!project->isActiveConfig("compile_libtool")) { //give them the .libs..
662 QString la = mdd->local_dir + Option::dir_sep + "lib" + lib + Option::libtool_ext;
663 if(QFile::exists(la) && QFile::exists(mdd->local_dir + Option::dir_sep + ".libs")) {
664 l_out.append("-L" + mdd->real_dir + Option::dir_sep + ".libs");
665 libdirs.append(new MakefileDependDir(mdd->real_dir + Option::dir_sep + ".libs",
666 mdd->local_dir + Option::dir_sep + ".libs"));
667 }
668 }
669
670 QString prl = mdd->local_dir + Option::dir_sep + "lib" + lib;
467 if(processPrlFile(prl)) { 671 if(processPrlFile(prl)) {
468 if(prl.startsWith(mdd->local_dir)) 672 if(prl.startsWith(mdd->local_dir))
469 prl.replace(0, mdd->local_dir.length(), mdd->real_dir); 673 prl.replace(0, mdd->local_dir.length(), mdd->real_dir);
470 QRegExp reg("^.*lib(" + lib + "[^./=]*)\\..*$"); 674 opt = linkLib(prl, lib);
471 if(reg.exactMatch(prl))
472 prl = "-l" + reg.cap(1);
473 opt = prl;
474 processed.insert(opt, (void*)1); 675 processed.insert(opt, (void*)1);
475 ret = TRUE; 676 ret = TRUE;
476 break; 677 break;
@@ -484,22 +685,27 @@ UnixMakefileGenerator::processPrlFiles()
484 opt = (*it); 685 opt = (*it);
485 } 686 }
486 QString prl = "/System/Library/Frameworks/" + opt + 687 QString prl = "/System/Library/Frameworks/" + opt +
487 ".framework/" + opt + Option::prl_ext; 688 ".framework/" + opt;
488 if(processPrlFile(prl)) 689 if(processPrlFile(prl))
489 ret = TRUE; 690 ret = TRUE;
490 l_out.append("-framework"); 691 l_out.append("-framework");
491 } 692 }
492 if(!opt.isEmpty()) 693 if(!opt.isEmpty())
493 l_out.append(opt); 694 l_out.append(opt);
494 l_out += uniqueSetLFlags(project->variables()["QMAKE_CURRENT_PRL_LIBS"], l_out); 695 l_out = combineSetLFlags(l_out, project->variables()["QMAKE_CURRENT_PRL_LIBS"]);
495 } else { 696 } else {
496 if(!processed[opt] && processPrlFile(opt)) { 697 QString lib = opt;
497 processed.insert(opt, (void*)1); 698 if(!processed[lib] && processPrlFile(lib)) {
699 processed.insert(lib, (void*)1);
498 ret = TRUE; 700 ret = TRUE;
499 } 701 }
702#if 0
703 if(ret)
704 opt = linkLib(lib, "");
705#endif
500 if(!opt.isEmpty()) 706 if(!opt.isEmpty())
501 l_out.append(opt); 707 l_out.append(opt);
502 l_out += uniqueSetLFlags(project->variables()["QMAKE_CURRENT_PRL_LIBS"], l_out); 708 l_out = combineSetLFlags(l_out, project->variables()["QMAKE_CURRENT_PRL_LIBS"]);
503 } 709 }
504 } 710 }
505 if(ret && l != l_out) 711 if(ret && l != l_out)
@@ -537,17 +743,65 @@ UnixMakefileGenerator::defaultInstall(const QString &t)
537 resource = TRUE; 743 resource = TRUE;
538 } 744 }
539 } else if(project->first("TEMPLATE") == "lib") { 745 } else if(project->first("TEMPLATE") == "lib") {
540 if(project->isActiveConfig("create_prl") && !project->isEmpty("QMAKE_INTERNAL_PRL_FILE")) { 746 if(project->isActiveConfig("create_prl") && !project->isActiveConfig("no_install_prl") &&
747 !project->isEmpty("QMAKE_INTERNAL_PRL_FILE")) {
541 QString dst_prl = project->first("QMAKE_INTERNAL_PRL_FILE"); 748 QString dst_prl = project->first("QMAKE_INTERNAL_PRL_FILE");
542 int slsh = dst_prl.findRev('/'); 749 int slsh = dst_prl.findRev('/');
543 if(slsh != -1) 750 if(slsh != -1)
544 dst_prl = dst_prl.right(dst_prl.length() - slsh - 1); 751 dst_prl = dst_prl.right(dst_prl.length() - slsh - 1);
545 dst_prl = root + targetdir + dst_prl; 752 dst_prl = root + targetdir + dst_prl;
546 ret += "-$(COPY) \"" + project->first("QMAKE_INTERNAL_PRL_FILE") + "\" \"" + dst_prl + "\""; 753 ret += "-$(INSTALL_FILE) \"" + project->first("QMAKE_INTERNAL_PRL_FILE") + "\" \"" + dst_prl + "\"";
547 if(!uninst.isEmpty()) 754 if(!uninst.isEmpty())
548 uninst.append("\n\t"); 755 uninst.append("\n\t");
549 uninst.append("-$(DEL_FILE) \"" + dst_prl + "\""); 756 uninst.append("-$(DEL_FILE) \"" + dst_prl + "\"");
550 } 757 }
758 if(project->isActiveConfig("create_libtool") && !project->isActiveConfig("compile_libtool")) {
759 QString src_lt = var("QMAKE_ORIG_TARGET");
760 int slsh = src_lt.findRev(Option::dir_sep);
761 if(slsh != -1)
762 src_lt = src_lt.right(src_lt.length() - slsh);
763 int dot = src_lt.find('.');
764 if(dot != -1)
765 src_lt = src_lt.left(dot);
766 src_lt += Option::libtool_ext;
767 src_lt.prepend("lib");
768 QString dst_lt = root + targetdir + src_lt;
769 if(!project->isEmpty("DESTDIR")) {
770 src_lt.prepend(var("DESTDIR"));
771 src_lt = Option::fixPathToLocalOS(fileFixify(src_lt,
772 QDir::currentDirPath(), Option::output_dir));
773 }
774 if(!ret.isEmpty())
775 ret += "\n\t";
776 ret += "-$(INSTALL_FILE) \"" + src_lt + "\" \"" + dst_lt + "\"";
777 if(!uninst.isEmpty())
778 uninst.append("\n\t");
779 uninst.append("-$(DEL_FILE) \"" + dst_lt + "\"");
780 }
781 if(project->isActiveConfig("create_pc")) {
782 QString src_pc = var("QMAKE_ORIG_TARGET");
783 int slsh = src_pc.findRev(Option::dir_sep);
784 if(slsh != -1)
785 src_pc = src_pc.right(src_pc.length() - slsh);
786 int dot = src_pc.find('.');
787 if(dot != -1)
788 src_pc = src_pc.left(dot);
789 src_pc += ".pc";
790 QString d = root + targetdir + "pkgconfig" + Option::dir_sep;
791 QString dst_pc = d + src_pc;
792 if(!project->isEmpty("DESTDIR")) {
793 src_pc.prepend(var("DESTDIR"));
794 src_pc = Option::fixPathToLocalOS(fileFixify(src_pc,
795 QDir::currentDirPath(), Option::output_dir));
796 }
797 if(!ret.isEmpty())
798 ret += "\n\t";
799 ret += mkdir_p_asstring(d) + "\n\t";
800 ret += "-$(INSTALL_FILE) \"" + src_pc + "\" \"" + dst_pc + "\"";
801 if(!uninst.isEmpty())
802 uninst.append("\n\t");
803 uninst.append("-$(DEL_FILE) \"" + dst_pc + "\"");
804 }
551 if ( project->isEmpty("QMAKE_CYGWIN_SHLIB") ) { 805 if ( project->isEmpty("QMAKE_CYGWIN_SHLIB") ) {
552 if ( !project->isActiveConfig("staticlib") && !project->isActiveConfig("plugin") ) { 806 if ( !project->isActiveConfig("staticlib") && !project->isActiveConfig("plugin") ) {
553 if ( project->isEmpty("QMAKE_HPUX_SHLIB") ) { 807 if ( project->isEmpty("QMAKE_HPUX_SHLIB") ) {
@@ -558,18 +812,37 @@ UnixMakefileGenerator::defaultInstall(const QString &t)
558 } 812 }
559 } 813 }
560 } 814 }
815
816 if(!resource && project->isActiveConfig("compile_libtool")) {
817 QString src_targ = target;
818 if(src_targ == "$(TARGET)")
819 src_targ = "$(TARGETL)";
820 QString dst_dir = fileFixify(targetdir);
821 if(QDir::isRelativePath(dst_dir))
822 dst_dir = Option::fixPathToTargetOS(Option::output_dir + Option::dir_sep + dst_dir);
823 ret = "-$(LIBTOOL) --mode=install cp \"" + src_targ + "\" \"" + root + dst_dir + "\"";
824 uninst.append("-$(LIBTOOL) --mode=uninstall \"" + src_targ + "\"");
825 } else {
561 QString src_targ = target; 826 QString src_targ = target;
562 if(!destdir.isEmpty()) 827 if(!destdir.isEmpty())
563 src_targ = Option::fixPathToTargetOS(destdir + target, FALSE); 828 src_targ = Option::fixPathToTargetOS(destdir + target, FALSE);
564 QString dst_targ = root + fileFixify(targetdir + target); 829 QString dst_targ = root + fileFixify(targetdir + target,
830 QDir::currentDirPath(), Option::output_dir);
565 if(!ret.isEmpty()) 831 if(!ret.isEmpty())
566 ret += "\n\t"; 832 ret += "\n\t";
567 ret += QString(resource ? "-$(COPY_DIR)" : "-$(COPY)") + " \"" + 833 if(resource)
834 ret += "$(DEL_FILE) -r \"" + dst_targ + "\"" + "\n\t";
835 if(!ret.isEmpty())
836 ret += "\n\t";
837 ret += QString(resource ? "-$(INSTALL_DIR)" : "-$(INSTALL_FILE)") + " \"" +
568 src_targ + "\" \"" + dst_targ + "\""; 838 src_targ + "\" \"" + dst_targ + "\"";
569 if(!project->isActiveConfig("debug") && !project->isEmpty("QMAKE_STRIP")) { 839 if(!project->isActiveConfig("debug") && !project->isEmpty("QMAKE_STRIP") &&
840 (project->first("TEMPLATE") != "lib" || !project->isActiveConfig("staticlib"))) {
570 ret += "\n\t-" + var("QMAKE_STRIP"); 841 ret += "\n\t-" + var("QMAKE_STRIP");
571 if(!project->isEmpty("QMAKE_STRIPFLAGS_LIB") && project->first("TEMPLATE") == "lib") 842 if(project->first("TEMPLATE") == "lib" && !project->isEmpty("QMAKE_STRIPFLAGS_LIB"))
572 ret += " " + var("QMAKE_STRIPFLAGS_LIB"); 843 ret += " " + var("QMAKE_STRIPFLAGS_LIB");
844 else if(project->first("TEMPLATE") == "app" && !project->isEmpty("QMAKE_STRIPFLAGS_APP"))
845 ret += " " + var("QMAKE_STRIPFLAGS_APP");
573 if(resource) 846 if(resource)
574 ret = " \"" + dst_targ + "/Contents/MacOS/$(QMAKE_TARGET)\""; 847 ret = " \"" + dst_targ + "/Contents/MacOS/$(QMAKE_TARGET)\"";
575 else 848 else
@@ -591,7 +864,7 @@ UnixMakefileGenerator::defaultInstall(const QString &t)
591 int lslash = link.findRev(Option::dir_sep); 864 int lslash = link.findRev(Option::dir_sep);
592 if(lslash != -1) 865 if(lslash != -1)
593 link = link.right(link.length() - (lslash + 1)); 866 link = link.right(link.length() - (lslash + 1));
594 QString dst_link = root + fileFixify(targetdir + link); 867 QString dst_link = root + targetdir + link;
595 ret += "\n\t-$(SYMLINK) \"$(TARGET)\" \"" + dst_link + "\""; 868 ret += "\n\t-$(SYMLINK) \"$(TARGET)\" \"" + dst_link + "\"";
596 if(!uninst.isEmpty()) 869 if(!uninst.isEmpty())
597 uninst.append("\n\t"); 870 uninst.append("\n\t");
@@ -599,6 +872,6 @@ UnixMakefileGenerator::defaultInstall(const QString &t)
599 } 872 }
600 } 873 }
601 } 874 }
875 }
602 return ret; 876 return ret;
603} 877}
604
diff --git a/qmake/generators/unix/unixmake.h b/qmake/generators/unix/unixmake.h
index 3d00214..91ec3b1 100644
--- a/qmake/generators/unix/unixmake.h
+++ b/qmake/generators/unix/unixmake.h
@@ -1,13 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Definition of ________ class.
5** 3**
6** Created : 970521 4** Definition of UnixMakefileGenerator class.
7** 5**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 7**
10** This file is part of the network module of the Qt GUI Toolkit. 8** This file is part of qmake.
11** 9**
12** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
@@ -34,6 +32,7 @@
34** not clear to you. 32** not clear to you.
35** 33**
36**********************************************************************/ 34**********************************************************************/
35
37#ifndef __UNIXMAKE_H__ 36#ifndef __UNIXMAKE_H__
38#define __UNIXMAKE_H__ 37#define __UNIXMAKE_H__
39 38
@@ -43,19 +42,30 @@ class UnixMakefileGenerator : public MakefileGenerator
43{ 42{
44 bool init_flag, include_deps; 43 bool init_flag, include_deps;
45 bool writeMakefile(QTextStream &); 44 bool writeMakefile(QTextStream &);
46 QStringList uniqueSetLFlags(const QStringList &list1, QStringList &list2); 45 void writeExtraVariables(QTextStream &);
46 QString libtoolFileName();
47 void writeLibtoolFile(); // for libtool
48 QString pkgConfigPrefix() const;
49 QString pkgConfigFileName();
50 QString pkgConfigFixPath(QString) const;
51 void writePkgConfigFile(); // for pkg-config
52 QStringList combineSetLFlags(const QStringList &list1, const QStringList &list2);
53 void writePrlFile(QTextStream &);
47 54
48public: 55public:
49 UnixMakefileGenerator(QMakeProject *p); 56 UnixMakefileGenerator(QMakeProject *p);
50 ~UnixMakefileGenerator(); 57 ~UnixMakefileGenerator();
51 58
52protected: 59protected:
60 virtual bool doPrecompiledHeaders() const { return project->isActiveConfig("precompile_header"); }
53 virtual bool doDepends() const { return !include_deps && MakefileGenerator::doDepends(); } 61 virtual bool doDepends() const { return !include_deps && MakefileGenerator::doDepends(); }
54 virtual QString defaultInstall(const QString &); 62 virtual QString defaultInstall(const QString &);
55 virtual void processPrlVariable(const QString &, const QStringList &); 63 virtual void processPrlVariable(const QString &, const QStringList &);
56 virtual void processPrlFiles(); 64 virtual void processPrlFiles();
57 65
58 virtual bool findLibraries(); 66 virtual bool findLibraries();
67 virtual QString findDependency(const QString &);
68 virtual QStringList &findDependencies(const QString &);
59 virtual void init(); 69 virtual void init();
60 70
61 void writeMakeParts(QTextStream &); 71 void writeMakeParts(QTextStream &);
diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp
index d8a4a0d..21348a6 100644
--- a/qmake/generators/unix/unixmake2.cpp
+++ b/qmake/generators/unix/unixmake2.cpp
@@ -1,13 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Definition of ________ class.
5** 3**
6** Created : 970521 4** Implementation of UnixMakefileGenerator class.
7** 5**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. 6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 7**
10** This file is part of the network module of the Qt GUI Toolkit. 8** This file is part of qmake.
11** 9**
12** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
@@ -37,23 +35,49 @@
37 35
38#include "unixmake.h" 36#include "unixmake.h"
39#include "option.h" 37#include "option.h"
38#include "meta.h"
40#include <qregexp.h> 39#include <qregexp.h>
41#include <qfile.h> 40#include <qfile.h>
42#include <qdir.h> 41#include <qdir.h>
43#include <time.h> 42#include <time.h>
44 43
44QString mkdir_p_asstring(const QString &dir);
45 45
46UnixMakefileGenerator::UnixMakefileGenerator(QMakeProject *p) : MakefileGenerator(p), init_flag(FALSE), include_deps(FALSE) 46UnixMakefileGenerator::UnixMakefileGenerator(QMakeProject *p) : MakefileGenerator(p), init_flag(FALSE), include_deps(FALSE)
47{ 47{
48 48
49} 49}
50 50
51void
52UnixMakefileGenerator::writePrlFile(QTextStream &t)
53{
54 MakefileGenerator::writePrlFile(t);
55 // libtool support
56 if(project->isActiveConfig("create_libtool") && project->first("TEMPLATE") == "lib") { //write .la
57 if(project->isActiveConfig("compile_libtool"))
58 warn_msg(WarnLogic, "create_libtool specified with compile_libtool can lead to conflicting .la\n"
59 "formats, create_libtool has been disabled\n");
60 else
61 writeLibtoolFile();
62 }
63 // pkg-config support
64 if(project->isActiveConfig("create_pc") && project->first("TEMPLATE") == "lib")
65 writePkgConfigFile();
66}
67
51bool 68bool
52UnixMakefileGenerator::writeMakefile(QTextStream &t) 69UnixMakefileGenerator::writeMakefile(QTextStream &t)
53{ 70{
71
54 writeHeader(t); 72 writeHeader(t);
55 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) { 73 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {
56 t << "all clean:" << "\n\t" 74 t << "QMAKE = "<< (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl;
75 { //write the extra unix targets..
76 QStringList &qut = project->variables()["QMAKE_EXTRA_UNIX_TARGETS"];
77 for(QStringList::ConstIterator it = qut.begin(); it != qut.end(); ++it)
78 t << *it << " ";
79 }
80 t << "all clean install distclean mocables uninstall uicables:" << "\n\t"
57 << "@echo \"Some of the required modules (" 81 << "@echo \"Some of the required modules ("
58 << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t" 82 << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t"
59 << "@echo \"Skipped.\"" << endl << endl; 83 << "@echo \"Skipped.\"" << endl << endl;
@@ -73,9 +97,31 @@ UnixMakefileGenerator::writeMakefile(QTextStream &t)
73} 97}
74 98
75void 99void
100UnixMakefileGenerator::writeExtraVariables(QTextStream &t)
101{
102 bool first = TRUE;
103 QMap<QString, QStringList> &vars = project->variables();
104 QStringList &exports = project->variables()["QMAKE_EXTRA_UNIX_VARIABLES"];
105 for(QMap<QString, QStringList>::Iterator it = vars.begin(); it != vars.end(); ++it) {
106 for(QStringList::Iterator exp_it = exports.begin(); exp_it != exports.end(); ++exp_it) {
107 QRegExp rx((*exp_it), FALSE, TRUE);
108 if(rx.exactMatch(it.key())) {
109 if(first) {
110 t << "\n####### Custom Variables" << endl;
111 first = FALSE;
112 }
113 t << "EXPORT_" << it.key() << " = " << it.data().join(" ") << endl;
114 }
115 }
116 }
117 if(!first)
118 t << endl;
119}
120
121void
76UnixMakefileGenerator::writeMakeParts(QTextStream &t) 122UnixMakefileGenerator::writeMakeParts(QTextStream &t)
77{ 123{
78 QString deps = fileFixify(Option::output.name()), prl; 124 QString deps = fileFixify(Option::output.name()), target_deps, prl;
79 bool do_incremental = (project->isActiveConfig("incremental") && 125 bool do_incremental = (project->isActiveConfig("incremental") &&
80 !project->variables()["QMAKE_INCREMENTAL"].isEmpty() && 126 !project->variables()["QMAKE_INCREMENTAL"].isEmpty() &&
81 (!project->variables()["QMAKE_APP_FLAG"].isEmpty() || 127 (!project->variables()["QMAKE_APP_FLAG"].isEmpty() ||
@@ -135,9 +181,14 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
135 t << "QMAKE = "<< (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl; 181 t << "QMAKE = "<< (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl;
136 t << "TAR = "<< var("QMAKE_TAR") << endl; 182 t << "TAR = "<< var("QMAKE_TAR") << endl;
137 t << "GZIP = " << var("QMAKE_GZIP") << endl; 183 t << "GZIP = " << var("QMAKE_GZIP") << endl;
184 if(project->isActiveConfig("compile_libtool"))
185 t << "LIBTOOL= " << var("QMAKE_LIBTOOL") << endl;
138 t << "COPY = " << var("QMAKE_COPY") << endl; 186 t << "COPY = " << var("QMAKE_COPY") << endl;
139 t << "COPY_FILE= " << var("QMAKE_COPY_FILE") << endl; 187 t << "COPY_FILE= " << var("QMAKE_COPY_FILE") << endl;
140 t << "COPY_DIR = " << var("QMAKE_COPY_DIR") << endl; 188 t << "COPY_DIR = " << var("QMAKE_COPY_DIR") << endl;
189 t << "INSTALL_FILE= " << var("QMAKE_INSTALL_FILE") << endl;
190 t << "INSTALL_DIR = " << var("QMAKE_INSTALL_DIR") << endl;
191
141 t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; 192 t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl;
142 t << "SYMLINK = " << var("QMAKE_SYMBOLIC_LINK") << endl; 193 t << "SYMLINK = " << var("QMAKE_SYMBOLIC_LINK") << endl;
143 t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl; 194 t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl;
@@ -220,9 +271,25 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
220 } 271 }
221 if(do_incremental && !moc_incremental && !src_incremental) 272 if(do_incremental && !moc_incremental && !src_incremental)
222 do_incremental = FALSE; 273 do_incremental = FALSE;
274 if(!project->isEmpty("QMAKE_EXTRA_UNIX_COMPILERS")) {
275 t << "OBJCOMP = " << varList("OBJCOMP") << endl;
276 target_deps += " $(OBJCOMP)";
277
278 QStringList &comps = project->variables()["QMAKE_EXTRA_UNIX_COMPILERS"];
279 for(QStringList::Iterator compit = comps.begin(); compit != comps.end(); ++compit) {
280 QStringList &vars = project->variables()[(*compit) + ".variables"];
281 for(QStringList::Iterator varit = vars.begin(); varit != vars.end(); ++varit) {
282 QStringList vals = project->variables()[(*varit)];
283 if(!vals.isEmpty())
284 t << "QMAKE_COMP_" << (*varit) << " = " << valList(vals) << endl;
285 }
286 }
287 }
223 t << "DIST = " << valList(fileFixify(project->variables()["DISTFILES"])) << endl; 288 t << "DIST = " << valList(fileFixify(project->variables()["DISTFILES"])) << endl;
224 t << "QMAKE_TARGET = " << var("QMAKE_ORIG_TARGET") << endl; 289 t << "QMAKE_TARGET = " << var("QMAKE_ORIG_TARGET") << endl;
225 t << "DESTDIR = " << var("DESTDIR") << endl; 290 t << "DESTDIR = " << var("DESTDIR") << endl;
291 if(project->isActiveConfig("compile_libtool"))
292 t << "TARGETL= " << var("TARGET_la") << endl;
226 t << "TARGET = " << var("TARGET") << endl; 293 t << "TARGET = " << var("TARGET") << endl;
227 if(project->isActiveConfig("plugin") ) { 294 if(project->isActiveConfig("plugin") ) {
228 t << "TARGETD = " << var("TARGET") << endl; 295 t << "TARGETD = " << var("TARGET") << endl;
@@ -238,9 +305,10 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
238 t << "TARGET0= " << var("TARGET_") << endl; 305 t << "TARGET0= " << var("TARGET_") << endl;
239 } 306 }
240 } 307 }
308 writeExtraVariables(t);
241 t << endl; 309 t << endl;
242 310
243 // blasted incldues 311 // blasted includes
244 QStringList &qeui = project->variables()["QMAKE_EXTRA_UNIX_INCLUDES"]; 312 QStringList &qeui = project->variables()["QMAKE_EXTRA_UNIX_INCLUDES"];
245 QStringList::Iterator it; 313 QStringList::Iterator it;
246 for( it = qeui.begin(); it != qeui.end(); ++it) 314 for( it = qeui.begin(); it != qeui.end(); ++it)
@@ -249,14 +317,14 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
249 /* rules */ 317 /* rules */
250 t << "first: all" << endl; 318 t << "first: all" << endl;
251 t << "####### Implicit rules" << endl << endl; 319 t << "####### Implicit rules" << endl << endl;
252 t << ".SUFFIXES: .c"; 320 t << ".SUFFIXES: .c " << Option::obj_ext;
253 QStringList::Iterator cppit; 321 QStringList::Iterator cppit;
254 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) 322 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
255 t << " " << (*cppit); 323 t << " " << (*cppit);
256 t << endl << endl; 324 t << endl << endl;
257 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) 325 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
258 t << (*cppit) << ".o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; 326 t << (*cppit) << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
259 t << ".c.o:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl; 327 t << ".c" << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;
260 328
261 if(include_deps) { 329 if(include_deps) {
262 QString cmd=var("QMAKE_CFLAGS_DEPS") + " "; 330 QString cmd=var("QMAKE_CFLAGS_DEPS") + " ";
@@ -278,7 +346,6 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
278 << "@test -d $(@D) || mkdir -p $(@D)" << "\n\t" 346 << "@test -d $(@D) || mkdir -p $(@D)" << "\n\t"
279 << "@$(CC) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl; 347 << "@$(CC) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl;
280 348
281
282 QString src[] = { "SOURCES", "UICIMPLS", "SRCMOC", QString::null }; 349 QString src[] = { "SOURCES", "UICIMPLS", "SRCMOC", QString::null };
283 for(int x = 0; !src[x].isNull(); x++) { 350 for(int x = 0; !src[x].isNull(); x++) {
284 QStringList &l = project->variables()[src[x]]; 351 QStringList &l = project->variables()[src[x]];
@@ -298,10 +365,10 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
298 } 365 }
299 if(!d_file.isEmpty()) { 366 if(!d_file.isEmpty()) {
300 d_file = odir + ".deps/" + d_file + ".d"; 367 d_file = odir + ".deps/" + d_file + ".d";
301 QStringList deps = findDependencies((*it)).grep(QRegExp(Option::moc_ext + "$")); 368 QStringList deps = findDependencies((*it)).grep(QRegExp(Option::cpp_moc_ext + "$"));
302 if(!deps.isEmpty()) 369 if(!deps.isEmpty())
303 t << d_file << ": " << deps.join(" ") << endl; 370 t << d_file << ": " << deps.join(" ") << endl;
304 t << "-include " << d_file << endl; 371 t << var("QMAKE_CFLAGS_USE_PRECOMPILE") << " " << d_file << endl;
305 } 372 }
306 } 373 }
307 } 374 }
@@ -323,17 +390,17 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
323 QStringList &l = project->variables()["QMAKE_PRL_INTERNAL_FILES"]; 390 QStringList &l = project->variables()["QMAKE_PRL_INTERNAL_FILES"];
324 QStringList::Iterator it; 391 QStringList::Iterator it;
325 for(it = l.begin(); it != l.end(); ++it) { 392 for(it = l.begin(); it != l.end(); ++it) {
326 QMakeProject proj; 393 QMakeMetaInfo libinfo;
327 if(proj.read((*it), QDir::currentDirPath()) && !proj.isEmpty("QMAKE_PRL_BUILD_DIR")) { 394 if(libinfo.readLib((*it)) && !libinfo.isEmpty("QMAKE_PRL_BUILD_DIR")) {
328 QString dir; 395 QString dir;
329 int slsh = (*it).findRev(Option::dir_sep); 396 int slsh = (*it).findRev(Option::dir_sep);
330 if(slsh != -1) 397 if(slsh != -1)
331 dir = (*it).left(slsh + 1); 398 dir = (*it).left(slsh + 1);
332 QString targ = dir + proj.first("QMAKE_PRL_TARGET"); 399 QString targ = dir + libinfo.first("QMAKE_PRL_TARGET");
333 deps += " " + targ; 400 deps += " " + targ;
334 t << targ << ":" << "\n\t" 401 t << targ << ":" << "\n\t"
335 << "@echo \"Creating '" << targ << "'\"" << "\n\t" 402 << "@echo \"Creating '" << targ << "'\"" << "\n\t"
336 << "(cd " << proj.first("QMAKE_PRL_BUILD_DIR") << ";" 403 << "(cd " << libinfo.first("QMAKE_PRL_BUILD_DIR") << ";"
337 << "$(MAKE) )" << endl; 404 << "$(MAKE) )" << endl;
338 } 405 }
339 } 406 }
@@ -392,13 +459,13 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
392 << endl << endl; 459 << endl << endl;
393 460
394 //real target 461 //real target
395 t << var("TARGET") << ": " << var("PRE_TARGETDEPS") << " " << incr_deps 462 t << var("TARGET") << ": " << var("PRE_TARGETDEPS") << " " << incr_deps << " " << target_deps
396 << " " << var("POST_TARGETDEPS") << "\n\t"; 463 << " " << var("POST_TARGETDEPS") << "\n\t";
397 if(!destdir.isEmpty()) 464 if(!destdir.isEmpty())
398 t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; 465 t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
399 if(!project->isEmpty("QMAKE_PRE_LINK")) 466 if(!project->isEmpty("QMAKE_PRE_LINK"))
400 t << var("QMAKE_PRE_LINK") << "\n\t"; 467 t << var("QMAKE_PRE_LINK") << "\n\t";
401 t << "$(LINK) $(LFLAGS) -o $(TARGET) " << incr_deps << " " << incr_objs << " $(LIBS)"; 468 t << "$(LINK) $(LFLAGS) -o $(TARGET) " << incr_deps << " " << incr_objs << " $(OBJCOMP) $(LIBS)";
402 if(!project->isEmpty("QMAKE_POST_LINK")) 469 if(!project->isEmpty("QMAKE_POST_LINK"))
403 t << "\n\t" << var("QMAKE_POST_LINK"); 470 t << "\n\t" << var("QMAKE_POST_LINK");
404 t << endl << endl; 471 t << endl << endl;
@@ -407,12 +474,12 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
407 << endl << endl; 474 << endl << endl;
408 475
409 t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) " 476 t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) "
410 << var("POST_TARGETDEPS") << "\n\t"; 477 << target_deps << " " << var("POST_TARGETDEPS") << "\n\t";
411 if(!destdir.isEmpty()) 478 if(!destdir.isEmpty())
412 t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; 479 t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
413 if(!project->isEmpty("QMAKE_PRE_LINK")) 480 if(!project->isEmpty("QMAKE_PRE_LINK"))
414 t << var("QMAKE_PRE_LINK") << "\n\t"; 481 t << var("QMAKE_PRE_LINK") << "\n\t";
415 t << "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)"; 482 t << "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(OBJCOMP) $(LIBS)";
416 if(!project->isEmpty("QMAKE_POST_LINK")) 483 if(!project->isEmpty("QMAKE_POST_LINK"))
417 t << "\n\t" << var("QMAKE_POST_LINK"); 484 t << "\n\t" << var("QMAKE_POST_LINK");
418 t << endl << endl; 485 t << endl << endl;
@@ -469,19 +536,23 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
469 536
470 //real target 537 //real target
471 t << var("DESTDIR_TARGET") << ": " << var("PRE_TARGETDEPS") << " " 538 t << var("DESTDIR_TARGET") << ": " << var("PRE_TARGETDEPS") << " "
472 << incr_deps << " $(SUBLIBS) " << var("POST_TARGETDEPS"); 539 << incr_deps << " $(SUBLIBS) " << target_deps << " " << var("POST_TARGETDEPS");
473 } else { 540 } else {
474 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," ","") << " " << 541 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," ","") << " " <<
475 var("DESTDIR_TARGET") << endl << endl; 542 var("DESTDIR_TARGET") << endl << endl;
476 t << var("DESTDIR_TARGET") << ": " << var("PRE_TARGETDEPS") 543 t << var("DESTDIR_TARGET") << ": " << var("PRE_TARGETDEPS")
477 << " $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) " << var("POST_TARGETDEPS"); 544 << " $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) $(OBJCOMP) " << target_deps
545 << " " << var("POST_TARGETDEPS");
478 } 546 }
479 if(!destdir.isEmpty()) 547 if(!destdir.isEmpty())
480 t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir; 548 t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir;
481 if(!project->isEmpty("QMAKE_PRE_LINK")) 549 if(!project->isEmpty("QMAKE_PRE_LINK"))
482 t << "\n\t" << var("QMAKE_PRE_LINK"); 550 t << "\n\t" << var("QMAKE_PRE_LINK");
483 551
484 if(project->isActiveConfig("plugin")) { 552 if(project->isActiveConfig("compile_libtool")) {
553 t << "\n\t"
554 << var("QMAKE_LINK_SHLIB_CMD");
555 } else if(project->isActiveConfig("plugin")) {
485 t << "\n\t" 556 t << "\n\t"
486 << "-$(DEL_FILE) $(TARGET)" << "\n\t" 557 << "-$(DEL_FILE) $(TARGET)" << "\n\t"
487 << var("QMAKE_LINK_SHLIB_CMD"); 558 << var("QMAKE_LINK_SHLIB_CMD");
@@ -526,7 +597,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
526 597
527 if (! project->isActiveConfig("plugin")) { 598 if (! project->isActiveConfig("plugin")) {
528 t << "staticlib: $(TARGETA)" << endl << endl; 599 t << "staticlib: $(TARGETA)" << endl << endl;
529 t << "$(TARGETA): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC)"; 600 t << "$(TARGETA): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) $(OBJCOMP)";
530 if(do_incremental) 601 if(do_incremental)
531 t << " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)"; 602 t << " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)";
532 t << var("POST_TARGETDEPS") << "\n\t" 603 t << var("POST_TARGETDEPS") << "\n\t"
@@ -544,7 +615,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
544 << "staticlib: " << var("DESTDIR") << "$(TARGET)" << "\n\n"; 615 << "staticlib: " << var("DESTDIR") << "$(TARGET)" << "\n\n";
545 if(project->isEmpty("QMAKE_AR_SUBLIBS")) { 616 if(project->isEmpty("QMAKE_AR_SUBLIBS")) {
546 t << var("DESTDIR") << "$(TARGET): " << var("PRE_TARGETDEPS") 617 t << var("DESTDIR") << "$(TARGET): " << var("PRE_TARGETDEPS")
547 << " $(UICDECLS) $(OBJECTS) $(OBJMOC) " << var("POST_TARGETDEPS") << "\n\t"; 618 << " $(UICDECLS) $(OBJECTS) $(OBJMOC) $(OBJCOMP) " << var("POST_TARGETDEPS") << "\n\t";
548 if(!project->isEmpty("DESTDIR")) { 619 if(!project->isEmpty("DESTDIR")) {
549 QString destdir = project->first("DESTDIR"); 620 QString destdir = project->first("DESTDIR");
550 t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; 621 t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
@@ -560,7 +631,8 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
560 << "\t" << "-$(MOVE) $(TARGET) " << var("DESTDIR") << "\n"; 631 << "\t" << "-$(MOVE) $(TARGET) " << var("DESTDIR") << "\n";
561 } else { 632 } else {
562 int max_files = project->first("QMAKE_MAX_FILES_PER_AR").toInt(); 633 int max_files = project->first("QMAKE_MAX_FILES_PER_AR").toInt();
563 QStringList objs = project->variables()["OBJECTS"] + project->variables()["OBJMOC"], 634 QStringList objs = project->variables()["OBJECTS"] + project->variables()["OBJMOC"] +
635 project->variables()["OBJCOMP"],
564 libs = project->variables()["QMAKE_AR_SUBLIBS"]; 636 libs = project->variables()["QMAKE_AR_SUBLIBS"];
565 libs.prepend("$(TARGET)"); 637 libs.prepend("$(TARGET)");
566 for(QStringList::Iterator libit = libs.begin(), objit = objs.begin(); 638 for(QStringList::Iterator libit = libs.begin(), objit = objs.begin();
@@ -597,21 +669,44 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
597 t << endl << endl; 669 t << endl << endl;
598 } 670 }
599 671
600 t << "mocables: $(SRCMOC)" << endl << endl; 672 t << "mocables: $(SRCMOC)" << endl
673 << "uicables: $(UICDECLS) $(UICIMPLS)" << endl << endl;
601 674
602 if(!project->isActiveConfig("no_mocdepend")) { 675 if(!project->isActiveConfig("no_mocdepend")) {
603 //this is an implicity depend on moc, so it will be built if necesary, however 676 //this is an implicity depend on moc, so it will be built if necesary, however
604 //moc itself shouldn't have this dependency - this is a little kludgy but it is 677 //moc itself shouldn't have this dependency - this is a little kludgy but it is
605 //better than the alternative for now. 678 //better than the alternative for now.
606 QString moc = project->first("QMAKE_MOC"), target = project->first("TARGET"); 679 QString moc = project->first("QMAKE_MOC"), target = project->first("TARGET"),
680 moc_dir = "$(QTDIR)/src/moc";
681 if(!project->isEmpty("QMAKE_MOC_SRC"))
682 moc_dir = project->first("QMAKE_MOC_SRC");
607 fixEnvVariables(target); 683 fixEnvVariables(target);
608 fixEnvVariables(moc); 684 fixEnvVariables(moc);
609 if(target != moc) 685 if(target != moc)
610 t << "$(MOC): \n\t" 686 t << "$(MOC): \n\t"
611 << "( cd $(QTDIR)/src/moc ; $(MAKE) )" << endl << endl; 687 << "( cd " << moc_dir << " && $(MAKE) )" << endl << endl;
612 } 688 }
613 689
614 writeMakeQmake(t); 690 writeMakeQmake(t);
691 if(project->isEmpty("QMAKE_FAILED_REQUIREMENTS") && !project->isActiveConfig("no_autoqmake")) {
692 QString meta_files;
693 if(project->isActiveConfig("create_libtool") && project->first("TEMPLATE") == "lib" &&
694 !project->isActiveConfig("compile_libtool")) { //libtool
695 if(!meta_files.isEmpty())
696 meta_files += " ";
697 meta_files += libtoolFileName();
698 }
699 if(project->isActiveConfig("create_pc") && project->first("TEMPLATE") == "lib") { //pkg-config
700 if(!meta_files.isEmpty())
701 meta_files += " ";
702 meta_files += pkgConfigFileName();
703 }
704 if(!meta_files.isEmpty()) {
705 QStringList files = fileFixify(Option::mkfile::project_files);
706 t << meta_files << ": " << "\n\t"
707 << "@$(QMAKE) -prl " << buildArgs() << " " << files.join(" ") << endl;
708 }
709 }
615 710
616 if(!project->first("QMAKE_PKGINFO").isEmpty()) { 711 if(!project->first("QMAKE_PKGINFO").isEmpty()) {
617 QString pkginfo = project->first("QMAKE_PKGINFO"); 712 QString pkginfo = project->first("QMAKE_PKGINFO");
@@ -630,12 +725,14 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
630 if(!destdir.isEmpty()) 725 if(!destdir.isEmpty())
631 t << "@test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; 726 t << "@test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
632 t << "@$(DEL_FILE) " << info_plist_out << "\n\t" 727 t << "@$(DEL_FILE) " << info_plist_out << "\n\t"
633 << "@cp \"" << info_plist << "\" \"" << info_plist_out << "\"" << endl; 728 << "@sed -e \"s,@ICON@,application.icns,g\" -e \"s,@EXECUTABLE@," << var("QMAKE_ORIG_TARGET")
729 << ",g\" \"" << info_plist << "\" >\"" << info_plist_out << "\"" << endl;
634 if(!project->first("RC_FILE").isEmpty()) { 730 if(!project->first("RC_FILE").isEmpty()) {
635 QString dir = destdir + "../Resources/"; 731 QString dir = destdir + "../Resources/";
636 t << dir << "application.icns:" << "\n\t" 732 t << dir << "application.icns: " << var("RC_FILE") << "\n\t"
637 << "@test -d " << dir << " || mkdir -p " << dir << "\n\t" 733 << "@test -d " << dir << " || mkdir -p " << dir << "\n\t"
638 << "@cp " << var("RC_FILE") << " " << dir << "application.icns" << endl; 734 << "@$(DEL_FILE) " << dir << "application.icns" << "\n\t"
735 << "@$(COPY_FILE) " << var("RC_FILE") << " " << dir << "application.icns" << endl;
639 } 736 }
640 } 737 }
641 738
@@ -648,6 +745,8 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
648 << "$(COPY_FILE) --parents $(SOURCES) $(HEADERS) $(FORMS) $(DIST) " << ddir_c << Option::dir_sep << " && "; 745 << "$(COPY_FILE) --parents $(SOURCES) $(HEADERS) $(FORMS) $(DIST) " << ddir_c << Option::dir_sep << " && ";
649 if(!project->isEmpty("TRANSLATIONS")) 746 if(!project->isEmpty("TRANSLATIONS"))
650 t << "$(COPY_FILE) --parents " << var("TRANSLATIONS") << " " << ddir_c << Option::dir_sep << " && "; 747 t << "$(COPY_FILE) --parents " << var("TRANSLATIONS") << " " << ddir_c << Option::dir_sep << " && ";
748 if(!project->isEmpty("IMAGES"))
749 t << "$(COPY_FILE) --parents " << var("IMAGES") << " " << ddir_c << Option::dir_sep << " && ";
651 if(!project->isEmpty("FORMS")) { 750 if(!project->isEmpty("FORMS")) {
652 QStringList &forms = project->variables()["FORMS"], ui_headers; 751 QStringList &forms = project->variables()["FORMS"], ui_headers;
653 for(QStringList::Iterator formit = forms.begin(); formit != forms.end(); ++formit) { 752 for(QStringList::Iterator formit = forms.begin(); formit != forms.end(); ++formit) {
@@ -666,8 +765,8 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
666 << endl << endl; 765 << endl << endl;
667 766
668 QString clean_targets; 767 QString clean_targets;
669 if(mocAware()) {
670 t << "mocclean:" << "\n"; 768 t << "mocclean:" << "\n";
769 if(mocAware()) {
671 if(!objMoc.isEmpty() || !srcMoc.isEmpty() || moc_incremental) { 770 if(!objMoc.isEmpty() || !srcMoc.isEmpty() || moc_incremental) {
672 if(!objMoc.isEmpty()) 771 if(!objMoc.isEmpty())
673 t << "\t-$(DEL_FILE) $(OBJMOC)" << '\n'; 772 t << "\t-$(DEL_FILE) $(OBJMOC)" << '\n';
@@ -697,8 +796,8 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
697 dir = fileFixify(dir, QDir::currentDirPath(), Option::output_dir); 796 dir = fileFixify(dir, QDir::currentDirPath(), Option::output_dir);
698 if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep) 797 if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep)
699 dir += Option::dir_sep; 798 dir += Option::dir_sep;
700 clean << dir + fi.baseName(TRUE) + Option::yacc_mod + Option::cpp_ext.first(); 799 clean << ( dir + fi.baseName(TRUE) + Option::yacc_mod + Option::cpp_ext.first() );
701 clean << dir + fi.baseName(TRUE) + Option::yacc_mod + Option::h_ext.first(); 800 clean << ( dir + fi.baseName(TRUE) + Option::yacc_mod + Option::h_ext.first() );
702 } 801 }
703 if(!clean.isEmpty()) { 802 if(!clean.isEmpty()) {
704 t << "\t-$(DEL_FILE) " << clean.join(" ") << "\n"; 803 t << "\t-$(DEL_FILE) " << clean.join(" ") << "\n";
@@ -717,7 +816,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
717 dir = fileFixify(dir, QDir::currentDirPath(), Option::output_dir); 816 dir = fileFixify(dir, QDir::currentDirPath(), Option::output_dir);
718 if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep) 817 if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep)
719 dir += Option::dir_sep; 818 dir += Option::dir_sep;
720 clean << dir + fi.baseName(TRUE) + Option::lex_mod + Option::cpp_ext.first(); 819 clean << ( dir + fi.baseName(TRUE) + Option::lex_mod + Option::cpp_ext.first() );
721 } 820 }
722 if(!clean.isEmpty()) { 821 if(!clean.isEmpty()) {
723 t << "\t-$(DEL_FILE) " << clean.join(" ") << "\n"; 822 t << "\t-$(DEL_FILE) " << clean.join(" ") << "\n";
@@ -735,8 +834,18 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
735 } 834 }
736 835
737 t << "clean:" << clean_targets << "\n\t"; 836 t << "clean:" << clean_targets << "\n\t";
738 if(!project->isEmpty("OBJECTS")) 837 if(!project->isEmpty("OBJECTS")) {
838 if(project->isActiveConfig("compile_libtool"))
839 t << "-$(LIBTOOL) --mode=clean $(DEL_FILE) $(OBJECTS)" << "\n\t";
840 else
739 t << "-$(DEL_FILE) $(OBJECTS) " << "\n\t"; 841 t << "-$(DEL_FILE) $(OBJECTS) " << "\n\t";
842 }
843 if(doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER")) {
844 QString header_prefix = project->first("QMAKE_PRECOMP_PREFIX");
845 QString precomph_out_dir = project->first("QMAKE_ORIG_TARGET") + ".gch" + Option::dir_sep;
846 t << "-$(DEL_FILE) " << precomph_out_dir << header_prefix + "c "
847 << precomph_out_dir << header_prefix << "c++" << "\n\t";
848 }
740 if(!project->isEmpty("IMAGES")) 849 if(!project->isEmpty("IMAGES"))
741 t << varGlue("QMAKE_IMAGE_COLLECTION", "\t-$(DEL_FILE) ", " ", "") << "\n\t"; 850 t << varGlue("QMAKE_IMAGE_COLLECTION", "\t-$(DEL_FILE) ", " ", "") << "\n\t";
742 if(src_incremental) 851 if(src_incremental)
@@ -762,31 +871,55 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
762 if(project->first("TEMPLATE") == "app" && 871 if(project->first("TEMPLATE") == "app" &&
763 project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) 872 project->isActiveConfig("resource_fork") && !project->isActiveConfig("console"))
764 t << "\t-$(DEL_FILE) -r " << destdir.section(Option::dir_sep, 0, -4) << "\n"; 873 t << "\t-$(DEL_FILE) -r " << destdir.section(Option::dir_sep, 0, -4) << "\n";
874 else if(project->isActiveConfig("compile_libtool"))
875 t << "\t-$(LIBTOOL) --mode=clean $(DEL_FILE) " << "$(TARGET)" << "\n";
765 else 876 else
766 t << "\t-$(DEL_FILE) " << destdir << "$(TARGET)" << " " << "$(TARGET)" << "\n"; 877 t << "\t-$(DEL_FILE) " << destdir << "$(TARGET)" << " " << "$(TARGET)" << "\n";
767 if(!project->isActiveConfig("staticlib") && project->variables()["QMAKE_APP_FLAG"].isEmpty() && 878 if(!project->isActiveConfig("staticlib") && project->variables()["QMAKE_APP_FLAG"].isEmpty() &&
768 !project->isActiveConfig("plugin")) 879 !project->isActiveConfig("plugin") && !project->isActiveConfig("compile_libtool"))
769 t << "\t-$(DEL_FILE) " << destdir << "$(TARGET0) " << destdir << "$(TARGET1) " 880 t << "\t-$(DEL_FILE) " << destdir << "$(TARGET0) " << destdir << "$(TARGET1) "
770 << destdir << "$(TARGET2) $(TARGETA)" << "\n"; 881 << destdir << "$(TARGET2) $(TARGETA)" << "\n";
771 t << endl << endl; 882 t << endl << endl;
772 883
773 if ( !project->isEmpty("PRECOMPH") ) { 884 if(doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER") ) {
885 QString precomph = fileFixify(project->first("PRECOMPILED_HEADER"));
886 t << "###### Prefix headers" << endl;
887 QString comps[] = { "C", "CXX", QString::null };
888 for(int i = 0; !comps[i].isNull(); i++) {
889 QString flags = var("QMAKE_" + comps[i] + "FLAGS_PRECOMPILE");
890 flags += " $(" + comps[i] + "FLAGS)";
891
892 QString header_prefix = project->first("QMAKE_PRECOMP_PREFIX");
893 QString outdir = project->first("QMAKE_ORIG_TARGET") + ".gch" + Option::dir_sep, outfile = outdir;
894 QString compiler;
895 if(comps[i] == "C") {
896 outfile += header_prefix + "c";
897 compiler = "$(CC) ";
898 } else {
899 outfile += header_prefix + "c++";
900 compiler = "$(CXX) ";
901 }
902 t << outfile << ": " << precomph << " " << findDependencies(precomph).join(" \\\n\t\t")
903 << "\n\t" << "test -d " << outdir << " || mkdir -p " << outdir
904 << "\n\t" << compiler << flags << " $(INCPATH) " << precomph << " -o " << outfile << endl << endl;
905 }
906 }
907 if(!project->isEmpty("ALLMOC_HEADER")) {
774 QString outdir = project->first("MOC_DIR"); 908 QString outdir = project->first("MOC_DIR");
775 QString qt_dot_h = Option::fixPathToLocalOS(project->first("PRECOMPH")); 909 QString precomph = fileFixify(project->first("ALLMOC_HEADER"));
776 t << "###### Combined headers" << endl << endl; 910 t << "###### Combined headers" << endl << endl
777 //XXX 911 << outdir << "allmoc.cpp: " << precomph << " "
778 t << outdir << "allmoc.cpp: " << qt_dot_h << " "
779 << varList("HEADERS_ORIG") << "\n\t" 912 << varList("HEADERS_ORIG") << "\n\t"
780 << "echo '#include \"" << qt_dot_h << "\"' >" << outdir << "allmoc.cpp" << "\n\t" 913 << "echo '#include \"" << precomph << "\"' >" << outdir << "allmoc.cpp" << "\n\t"
781 << "$(CXX) -E -DQT_MOC_CPP -DQT_NO_STL $(CXXFLAGS) $(INCPATH) >" << outdir << "allmoc.h " 914 << "$(CXX) -E -DQT_MOC_CPP -DQT_NO_STL $(CXXFLAGS) $(INCPATH) >" << outdir << "allmoc.h "
782 << outdir << "allmoc.cpp" << "\n\t" 915 << outdir << "allmoc.cpp" << "\n\t"
783 << "$(MOC) -o " << outdir << "allmoc.cpp " << outdir << "allmoc.h" << "\n\t" 916 << "$(MOC) -o " << outdir << "allmoc.cpp " << outdir << "allmoc.h" << "\n\t"
784 << "perl -pi -e 's{#include \"allmoc.h\"}{#define QT_H_CPP\\n#include \"" 917 << "perl -pi -e 's{#include \"allmoc.h\"}{#define QT_H_CPP\\n#include \""
785 << qt_dot_h << "\"}' " << outdir << "allmoc.cpp" << "\n\t" 918 << precomph << "\"}' " << outdir << "allmoc.cpp" << "\n\t"
786 << "$(DEL_FILE) " << outdir << "allmoc.h" << endl << endl; 919 << "$(DEL_FILE) " << outdir << "allmoc.h" << endl << endl;
787 } 920 }
788 921
789 // blasted user defined targets 922 // user defined targets
790 QStringList &qut = project->variables()["QMAKE_EXTRA_UNIX_TARGETS"]; 923 QStringList &qut = project->variables()["QMAKE_EXTRA_UNIX_TARGETS"];
791 for(it = qut.begin(); it != qut.end(); ++it) { 924 for(it = qut.begin(); it != qut.end(); ++it) {
792 QString targ = var((*it) + ".target"), 925 QString targ = var((*it) + ".target"),
@@ -800,9 +933,59 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
800 dep = (*dep_it); 933 dep = (*dep_it);
801 deps += " " + dep; 934 deps += " " + dep;
802 } 935 }
936 if(project->variables()[(*it) + ".CONFIG"].findIndex("phony") != -1)
937 deps += QString(" ") + "FORCE";
803 t << targ << ":" << deps << "\n\t" 938 t << targ << ":" << deps << "\n\t"
804 << cmd << endl << endl; 939 << cmd << endl << endl;
805 } 940 }
941 // user defined compilers
942 QStringList &quc = project->variables()["QMAKE_EXTRA_UNIX_COMPILERS"];
943 for(it = quc.begin(); it != quc.end(); ++it) {
944 QString tmp_out = project->variables()[(*it) + ".output"].first();
945 QString tmp_cmd = project->variables()[(*it) + ".commands"].join(" ");
946 QString tmp_dep = project->variables()[(*it) + ".depends"].join(" ");
947 QStringList &vars = project->variables()[(*it) + ".variables"];
948 if(tmp_out.isEmpty() || tmp_cmd.isEmpty())
949 continue;
950 QStringList &tmp = project->variables()[(*it) + ".input"];
951 for(QStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {
952 QStringList &inputs = project->variables()[(*it2)];
953 for(QStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {
954 QFileInfo fi(Option::fixPathToLocalOS((*input)));
955 QString in = Option::fixPathToTargetOS((*input), FALSE),
956 out = tmp_out, cmd = tmp_cmd, deps;
957 out.replace("${QMAKE_FILE_BASE}", fi.baseName());
958 out.replace("${QMAKE_FILE_NAME}", fi.fileName());
959 cmd.replace("${QMAKE_FILE_BASE}", fi.baseName());
960 cmd.replace("${QMAKE_FILE_OUT}", out);
961 cmd.replace("${QMAKE_FILE_NAME}", fi.fileName());
962 for(QStringList::Iterator it3 = vars.begin(); it3 != vars.end(); ++it3)
963 cmd.replace("$(" + (*it3) + ")", "$(QMAKE_COMP_" + (*it3)+")");
964 if(!tmp_dep.isEmpty()) {
965 char buff[256];
966 QString dep_cmd = tmp_dep;
967 dep_cmd.replace("${QMAKE_FILE_NAME}", fi.fileName());
968 if(FILE *proc = QT_POPEN(dep_cmd.latin1(), "r")) {
969 while(!feof(proc)) {
970 int read_in = int(fread(buff, 1, 255, proc));
971 if(!read_in)
972 break;
973 int l = 0;
974 for(int i = 0; i < read_in; i++) {
975 if(buff[i] == '\n' || buff[i] == ' ') {
976 deps += " " + QCString(buff+l, (i - l) + 1);
977 l = i;
978 }
979 }
980 }
981 fclose(proc);
982 }
983 }
984 t << out << ": " << in << deps << "\n\t"
985 << cmd << endl << endl;
986 }
987 }
988 }
806 t <<"FORCE:" << endl << endl; 989 t <<"FORCE:" << endl << endl;
807} 990}
808 991
@@ -814,6 +997,12 @@ struct SubDir
814void 997void
815UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct) 998UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
816{ 999{
1000 // blasted includes
1001 QStringList &qeui = project->variables()["QMAKE_EXTRA_UNIX_INCLUDES"];
1002 for(QStringList::Iterator qeui_it = qeui.begin(); qeui_it != qeui.end(); ++qeui_it)
1003 t << "include " << (*qeui_it) << endl;
1004 writeExtraVariables(t);
1005
817 QPtrList<SubDir> subdirs; 1006 QPtrList<SubDir> subdirs;
818 { 1007 {
819 QStringList subdirs_in = project->variables()["SUBDIRS"]; 1008 QStringList subdirs_in = project->variables()["SUBDIRS"];
@@ -832,6 +1021,8 @@ UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
832 sd->profile = file; 1021 sd->profile = file;
833 } 1022 }
834 } else { 1023 } else {
1024 if(!file.isEmpty())
1025 sd->profile = file.section(Option::dir_sep, -1) + ".pro";
835 sd->directory = file; 1026 sd->directory = file;
836 } 1027 }
837 while(sd->directory.right(1) == Option::dir_sep) 1028 while(sd->directory.right(1) == Option::dir_sep)
@@ -857,6 +1048,10 @@ UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
857 t << "MAKEFILE =" << var("MAKEFILE") << endl; 1048 t << "MAKEFILE =" << var("MAKEFILE") << endl;
858 t << "QMAKE =" << var("QMAKE") << endl; 1049 t << "QMAKE =" << var("QMAKE") << endl;
859 t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; 1050 t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl;
1051 t << "CHK_DIR_EXISTS= " << var("QMAKE_CHK_DIR_EXISTS") << endl;
1052 t << "MKDIR = " << var("QMAKE_MKDIR") << endl;
1053 t << "INSTALL_FILE= " << var("QMAKE_INSTALL_FILE") << endl;
1054 t << "INSTALL_DIR = " << var("QMAKE_INSTALL_DIR") << endl;
860 t << "SUBTARGETS ="; // subdirectory targets are sub-directory 1055 t << "SUBTARGETS ="; // subdirectory targets are sub-directory
861 for( it.toFirst(); it.current(); ++it) 1056 for( it.toFirst(); it.current(); ++it)
862 t << " \\\n\t\t" << it.current()->target; 1057 t << " \\\n\t\t" << it.current()->target;
@@ -874,8 +1069,10 @@ UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
874 //qmake it 1069 //qmake it
875 t << mkfile << ": " << "\n\t"; 1070 t << mkfile << ": " << "\n\t";
876 if(have_dir) 1071 if(have_dir)
877 t << "cd " << (*it)->directory << " && "; 1072 t << mkdir_p_asstring((*it)->directory) << "\n\t"
878 t << "$(QMAKE) " << (*it)->profile << buildArgs() << out << endl; 1073 << "cd " << (*it)->directory << " && ";
1074 QString profile = fileFixify((*it)->profile, (*it)->directory, (*it)->directory);
1075 t << "$(QMAKE) " << profile << buildArgs() << out << endl;
879 //actually compile 1076 //actually compile
880 t << (*it)->target << ": " << mkfile << " FORCE" << "\n\t"; 1077 t << (*it)->target << ": " << mkfile << " FORCE" << "\n\t";
881 if(have_dir) 1078 if(have_dir)
@@ -896,7 +1093,8 @@ UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
896 writeMakeQmake(t); 1093 writeMakeQmake(t);
897 1094
898 if(project->isEmpty("SUBDIRS")) { 1095 if(project->isEmpty("SUBDIRS")) {
899 t << "all qmake_all distclean install uiclean mocclean lexclean yaccclean clean: FORCE" << endl; 1096 t << "all qmake_all distclean uicables mocables install_subdirs uninstall_subdirs"
1097 << " uiclean mocclean lexclean yaccclean clean " << var("SUBDIR_TARGETS") << ": FORCE" << endl;
900 } else { 1098 } else {
901 t << "all: $(SUBTARGETS)" << endl; 1099 t << "all: $(SUBTARGETS)" << endl;
902 t << "qmake_all:"; 1100 t << "qmake_all:";
@@ -914,7 +1112,8 @@ UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
914 << " && $(MAKE) -f " << (*it)->makefile << " qmake_all" << "; ) || true"; 1112 << " && $(MAKE) -f " << (*it)->makefile << " qmake_all" << "; ) || true";
915 } 1113 }
916 t << endl; 1114 t << endl;
917 t << "clean uninstall install uiclean mocclean lexclean yaccclean: qmake_all FORCE"; 1115 t << "clean uicables mocables uiclean mocclean lexclean yaccclean "
1116 << var("SUBDIR_TARGETS") << ": qmake_all FORCE";
918 for( it.toFirst(); it.current(); ++it) { 1117 for( it.toFirst(); it.current(); ++it) {
919 t << "\n\t ( "; 1118 t << "\n\t ( ";
920 if(!(*it)->directory.isEmpty()) 1119 if(!(*it)->directory.isEmpty())
@@ -922,6 +1121,22 @@ UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
922 t << "$(MAKE) -f " << (*it)->makefile << " $@" << "; ) || true"; 1121 t << "$(MAKE) -f " << (*it)->makefile << " $@" << "; ) || true";
923 } 1122 }
924 t << endl; 1123 t << endl;
1124 t << "uninstall_subdirs: qmake_all FORCE";
1125 for( it.toFirst(); it.current(); ++it) {
1126 t << "\n\t ( ";
1127 if(!(*it)->directory.isEmpty())
1128 t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; ";
1129 t << "$(MAKE) -f " << (*it)->makefile << " uninstall" << "; ) || true";
1130 }
1131 t << endl;
1132 t << "install_subdirs: qmake_all FORCE";
1133 for( it.toFirst(); it.current(); ++it) {
1134 t << "\n\t ( ";
1135 if(!(*it)->directory.isEmpty())
1136 t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; ";
1137 t << "$(MAKE) -f " << (*it)->makefile << " install" << "; ) || true";
1138 }
1139 t << endl;
925 t << "distclean: qmake_all FORCE"; 1140 t << "distclean: qmake_all FORCE";
926 for( it.toFirst(); it.current(); ++it) { 1141 for( it.toFirst(); it.current(); ++it) {
927 t << "\n\t ( "; 1142 t << "\n\t ( ";
@@ -931,6 +1146,31 @@ UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
931 } 1146 }
932 t << endl << endl; 1147 t << endl << endl;
933 } 1148 }
1149
1150 //installations
1151 project->variables()["INSTALLDEPS"] += "install_subdirs";
1152 project->variables()["UNINSTALLDEPS"] += "uninstall_subdirs";
1153 writeInstalls(t, "INSTALLS");
1154
1155 // user defined targets
1156 QStringList &qut = project->variables()["QMAKE_EXTRA_UNIX_TARGETS"];
1157 for(QStringList::Iterator qut_it = qut.begin(); qut_it != qut.end(); ++qut_it) {
1158 QString targ = var((*qut_it) + ".target"),
1159 cmd = var((*qut_it) + ".commands"), deps;
1160 if(targ.isEmpty())
1161 targ = (*qut_it);
1162 QStringList &deplist = project->variables()[(*qut_it) + ".depends"];
1163 for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) {
1164 QString dep = var((*dep_it) + ".target");
1165 if(dep.isEmpty())
1166 dep = (*dep_it);
1167 deps += " " + dep;
1168 }
1169 if(project->variables()[(*qut_it) + ".CONFIG"].findIndex("phony") != -1)
1170 deps += QString(" ") + "FORCE";
1171 t << targ << ":" << deps << "\n\t"
1172 << cmd << endl << endl;
1173 }
934 t <<"FORCE:" << endl << endl; 1174 t <<"FORCE:" << endl << endl;
935} 1175}
936 1176
@@ -967,20 +1207,26 @@ void UnixMakefileGenerator::init2()
967 project->variables()["QMAKE_AR_CMD"].append("$(AR) $(TARGET) $(OBJECTS) $(OBJMOC)"); 1207 project->variables()["QMAKE_AR_CMD"].append("$(AR) $(TARGET) $(OBJECTS) $(OBJMOC)");
968 } else { 1208 } else {
969 project->variables()["TARGETA"].append(project->first("DESTDIR") + "lib" + project->first("TARGET") + ".a"); 1209 project->variables()["TARGETA"].append(project->first("DESTDIR") + "lib" + project->first("TARGET") + ".a");
1210 if( project->isActiveConfig("compile_libtool") )
1211 project->variables()["TARGET_la"] = project->first("DESTDIR") + "lib" + project->first("TARGET") + Option::libtool_ext;
1212
970 if ( !project->variables()["QMAKE_AR_CMD"].isEmpty() ) 1213 if ( !project->variables()["QMAKE_AR_CMD"].isEmpty() )
971 project->variables()["QMAKE_AR_CMD"].first().replace("(TARGET)","(TARGETA)"); 1214 project->variables()["QMAKE_AR_CMD"].first().replace("(TARGET)","(TARGETA)");
972 else 1215 else
973 project->variables()["QMAKE_AR_CMD"].append("$(AR) $(TARGETA) $(OBJECTS) $(OBJMOC)"); 1216 project->variables()["QMAKE_AR_CMD"].append("$(AR) $(TARGETA) $(OBJECTS) $(OBJMOC)");
974 if( project->isActiveConfig("plugin") ) { 1217 if( project->isActiveConfig("compile_libtool") ) {
1218 project->variables()["TARGET"] = project->variables()["TARGET_la"];
1219 } else if( project->isActiveConfig("plugin") ) {
975 project->variables()["TARGET_x.y.z"].append("lib" + 1220 project->variables()["TARGET_x.y.z"].append("lib" +
976 project->first("TARGET") + "." + project->first("QMAKE_EXTENSION_SHLIB")); 1221 project->first("TARGET") + "." +
1222 project->first("QMAKE_EXTENSION_PLUGIN"));
977 if(project->isActiveConfig("lib_version_first")) 1223 if(project->isActiveConfig("lib_version_first"))
978 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + 1224 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
979 project->first("VER_MAJ") + "." + 1225 project->first("VER_MAJ") + "." +
980 project->first("QMAKE_EXTENSION_SHLIB")); 1226 project->first("QMAKE_EXTENSION_PLUGIN"));
981 else 1227 else
982 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + 1228 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
983 project->first("QMAKE_EXTENSION_SHLIB") + 1229 project->first("QMAKE_EXTENSION_PLUGIN") +
984 "." + project->first("VER_MAJ")); 1230 "." + project->first("VER_MAJ"));
985 1231
986 project->variables()["TARGET"] = project->variables()["TARGET_x.y.z"]; 1232 project->variables()["TARGET"] = project->variables()["TARGET_x.y.z"];
@@ -1075,21 +1321,43 @@ void UnixMakefileGenerator::init2()
1075 } 1321 }
1076 if ( project->variables()["QMAKE_LINK_SHLIB_CMD"].isEmpty() ) 1322 if ( project->variables()["QMAKE_LINK_SHLIB_CMD"].isEmpty() )
1077 project->variables()["QMAKE_LINK_SHLIB_CMD"].append( 1323 project->variables()["QMAKE_LINK_SHLIB_CMD"].append(
1078 "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)"); 1324 "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) $(OBJCOMP)");
1079 } 1325 }
1080 if(project->isEmpty("QMAKE_SYMBOLIC_LINK")) 1326 if(project->isEmpty("QMAKE_SYMBOLIC_LINK"))
1081 project->variables()["QMAKE_SYMBOLIC_LINK"].append("ln -sf"); 1327 project->variables()["QMAKE_SYMBOLIC_LINK"].append("ln -sf");
1082 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { 1328 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
1083 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SHAPP"]; 1329 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_APP"];
1330 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_APP"];
1331 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_APP"];
1084 } else if ( project->isActiveConfig("dll") ) { 1332 } else if ( project->isActiveConfig("dll") ) {
1333 if( !project->isActiveConfig("plugin") || !project->isActiveConfig("plugin_no_share_shlib_cflags")) {
1085 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_SHLIB"]; 1334 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_SHLIB"];
1086 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_SHLIB"]; 1335 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_SHLIB"];
1336 }
1087 if ( project->isActiveConfig("plugin") ) { 1337 if ( project->isActiveConfig("plugin") ) {
1338 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_PLUGIN"];
1339 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_PLUGIN"];
1088 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_PLUGIN"]; 1340 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_PLUGIN"];
1089 if( !project->isActiveConfig("plugin_no_soname") ) 1341 if( project->isActiveConfig("plugin_with_soname") && !project->isActiveConfig("compile_libtool"))
1090 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SONAME"]; 1342 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SONAME"];
1091 } else { 1343 } else {
1092 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SHLIB"]; 1344 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SHLIB"];
1345 if(!project->isEmpty("QMAKE_LFLAGS_COMPAT_VERSION")) {
1346 if(project->isEmpty("COMPAT_VERSION"))
1347 project->variables()["QMAKE_LFLAGS"] += QString(project->first("QMAKE_LFLAGS_COMPAT_VERSION") +
1348 project->first("VER_MAJ") + "." +
1349 project->first("VER_MIN"));
1350 else
1351 project->variables()["QMAKE_LFLAGS"] += QString(project->first("QMAKE_LFLAGS_COMPAT_VERSION") +
1352 project->first("COMPATIBILITY_VERSION"));
1353 }
1354 if(!project->isEmpty("QMAKE_LFLAGS_VERSION")) {
1355 project->variables()["QMAKE_LFLAGS"] += QString(project->first("QMAKE_LFLAGS_VERSION") +
1356 project->first("VER_MAJ") + "." +
1357 project->first("VER_MIN") + "." +
1358 project->first("VER_PAT"));
1359 }
1360 if(!project->isActiveConfig("compile_libtool"))
1093 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SONAME"]; 1361 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SONAME"];
1094 } 1362 }
1095 QString destdir = project->first("DESTDIR"); 1363 QString destdir = project->first("DESTDIR");
@@ -1107,4 +1375,214 @@ void UnixMakefileGenerator::init2()
1107 project->variables()["QMAKE_LFLAGS"] += project->first("QMAKE_RPATH") + rpath_destdir; 1375 project->variables()["QMAKE_LFLAGS"] += project->first("QMAKE_RPATH") + rpath_destdir;
1108 } 1376 }
1109 } 1377 }
1378 QStringList &quc = project->variables()["QMAKE_EXTRA_UNIX_COMPILERS"];
1379 for(QStringList::Iterator it = quc.begin(); it != quc.end(); ++it) {
1380 QString tmp_out = project->variables()[(*it) + ".output"].first();
1381 if(tmp_out.isEmpty())
1382 continue;
1383 QStringList &tmp = project->variables()[(*it) + ".input"];
1384 for(QStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {
1385 QStringList &inputs = project->variables()[(*it2)];
1386 for(QStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {
1387 QFileInfo fi(Option::fixPathToLocalOS((*input)));
1388 QString in = Option::fixPathToTargetOS((*input), FALSE),
1389 out = tmp_out;
1390 out.replace("${QMAKE_FILE_BASE}", fi.baseName());
1391 out.replace("${QMAKE_FILE_NAME}", fi.fileName());
1392 if(project->variables()[(*it) + ".CONFIG"].findIndex("no_link") == -1)
1393 project->variables()["OBJCOMP"] += out;
1394 }
1395 }
1396 }
1397}
1398
1399QString
1400UnixMakefileGenerator::libtoolFileName()
1401{
1402 QString ret = var("TARGET");
1403 int slsh = ret.findRev(Option::dir_sep);
1404 if(slsh != -1)
1405 ret = ret.right(ret.length() - slsh);
1406 int dot = ret.find('.');
1407 if(dot != -1)
1408 ret = ret.left(dot);
1409 ret += Option::libtool_ext;
1410 if(!project->isEmpty("DESTDIR"))
1411 ret.prepend(var("DESTDIR"));
1412 return ret;
1413}
1414
1415void
1416UnixMakefileGenerator::writeLibtoolFile()
1417{
1418 QString fname = libtoolFileName(), lname = fname;
1419 int slsh = lname.findRev(Option::dir_sep);
1420 if(slsh != -1)
1421 lname = lname.right(lname.length() - slsh - 1);
1422 QFile ft(fname);
1423 if(!ft.open(IO_WriteOnly))
1424 return;
1425 project->variables()["ALL_DEPS"].append(fname);
1426
1427 QTextStream t(&ft);
1428 t << "# " << lname << " - a libtool library file\n";
1429 time_t now = time(NULL);
1430 t << "# Generated by qmake/libtool (" << qmake_version() << ") (Qt "
1431 << QT_VERSION_STR << ") on: " << ctime(&now) << "\n";
1432
1433 t << "# The name that we can dlopen(3).\n"
1434 << "dlname='" << var(project->isActiveConfig("plugin") ? "TARGET" : "TARGET_x")
1435 << "'\n\n";
1436
1437 t << "# Names of this library.\n";
1438 t << "library_names='";
1439 if(project->isActiveConfig("plugin")) {
1440 t << var("TARGET");
1441 } else {
1442 if (project->isEmpty("QMAKE_HPUX_SHLIB"))
1443 t << var("TARGET_x.y.z") << " ";
1444 t << var("TARGET_x") << " " << var("TARGET_");
1445 }
1446 t << "'\n\n";
1447
1448 t << "# The name of the static archive.\n"
1449 << "old_library='" << lname.left(lname.length()-Option::libtool_ext.length()) << ".a'\n\n";
1450
1451 t << "# Libraries that this one depends upon.\n";
1452 QStringList libs;
1453 if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS"))
1454 libs = project->variables()["QMAKE_INTERNAL_PRL_LIBS"];
1455 else
1456 libs << "QMAKE_LIBS"; //obvious one
1457 t << "dependency_libs='";
1458 for(QStringList::ConstIterator it = libs.begin(); it != libs.end(); ++it)
1459 t << project->variables()[(*it)].join(" ") << " ";
1460 t << "'\n\n";
1461
1462 t << "# Version information for " << lname << "\n";
1463 int maj = project->first("VER_MAJ").toInt();
1464 int min = project->first("VER_MIN").toInt();
1465 int pat = project->first("VER_PAT").toInt();
1466 t << "current=" << (10*maj + min) << "\n" // best I can think of
1467 << "age=0\n"
1468 << "revision=" << pat << "\n\n";
1469
1470 t << "# Is this an already installed library.\n"
1471 "installed=yes\n\n"; // ###
1472
1473 t << "# Files to dlopen/dlpreopen.\n"
1474 "dlopen=''\n"
1475 "dlpreopen=''\n\n";
1476
1477 QString install_dir = project->first("target.path");
1478 if(install_dir.isEmpty())
1479 install_dir = project->first("DESTDIR");
1480 t << "# Directory that this library needs to be installed in:\n"
1481 "libdir='" << Option::fixPathToTargetOS(install_dir, FALSE) << "'\n";
1482}
1483
1484QString
1485UnixMakefileGenerator::pkgConfigFileName()
1486{
1487 QString ret = var("TARGET");
1488 int slsh = ret.findRev(Option::dir_sep);
1489 if(slsh != -1)
1490 ret = ret.right(ret.length() - slsh);
1491 if(ret.startsWith("lib"))
1492 ret = ret.mid(3);
1493 int dot = ret.find('.');
1494 if(dot != -1)
1495 ret = ret.left(dot);
1496 ret += Option::pkgcfg_ext;
1497 if(!project->isEmpty("DESTDIR")) {
1498 ret.prepend(var("DESTDIR"));
1499 ret = Option::fixPathToLocalOS(fileFixify(ret,QDir::currentDirPath(), Option::output_dir));
1500 }
1501 return ret;
1502}
1503
1504QString
1505UnixMakefileGenerator::pkgConfigPrefix() const
1506{
1507 if(!project->isEmpty("QMAKE_PKGCONFIG_PREFIX"))
1508 return project->first("QMAKE_PKGCONFIG_PREFIX");
1509 return qInstallPath();
1510}
1511
1512QString
1513UnixMakefileGenerator::pkgConfigFixPath(QString path) const
1514{
1515 QString prefix = pkgConfigPrefix();
1516 if(path.startsWith(prefix))
1517 path = path.replace(prefix, "${prefix}");
1518 return path;
1519}
1520
1521void
1522UnixMakefileGenerator::writePkgConfigFile() // ### does make sense only for libqt so far
1523{
1524 QString fname = pkgConfigFileName(), lname = fname;
1525 int slsh = lname.findRev(Option::dir_sep);
1526 if(slsh != -1)
1527 lname = lname.right(lname.length() - slsh - 1);
1528 QFile ft(fname);
1529 if(!ft.open(IO_WriteOnly))
1530 return;
1531 project->variables()["ALL_DEPS"].append(fname);
1532 QTextStream t(&ft);
1533
1534 QString prefix = pkgConfigPrefix();
1535 QString libDir = project->first("QMAKE_PKGCONFIG_LIBDIR");
1536 if(libDir.isEmpty())
1537 libDir = prefix + "/lib";
1538 QString includeDir = project->first("QMAKE_PKGCONFIG_INCDIR");
1539 if(includeDir.isEmpty())
1540 includeDir = prefix + "/include";
1541
1542 t << "prefix=" << prefix << endl;
1543 t << "exec_prefix=${prefix}\n"
1544 << "libdir=" << pkgConfigFixPath(libDir) << "\n"
1545 << "includedir=" << pkgConfigFixPath(includeDir) << endl;
1546 // non-standard entry. Provides useful info normally only
1547 // contained in the internal .qmake.cache file
1548 t << varGlue("CONFIG", "qt_config=", " ", "") << endl << endl;
1549
1550 t << "Name: Qt" << endl;
1551 QString desc = project->first("QMAKE_PKGCONFIG_DESCRIPTION");
1552 if(desc.isEmpty()) {
1553 desc = project->first("TARGET").lower();
1554 desc.replace(0, 1, desc[0].upper());
1555 if(project->first("TEMPLATE") == "lib") {
1556 if(project->isActiveConfig("plugin"))
1557 desc += " Plugin";
1558 else
1559 desc += " Library";
1560 } else if(project->first("TEMPLATE") == "app") {
1561 desc += " Application";
1562 }
1563 }
1564 t << "Description: " << desc << endl;
1565 t << "Version: " << project->first("VERSION") << endl;
1566
1567 // libs
1568 QStringList libs;
1569 if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS"))
1570 libs = project->variables()["QMAKE_INTERNAL_PRL_LIBS"];
1571 else
1572 libs << "QMAKE_LIBS"; //obvious one
1573 if(project->isActiveConfig("thread"))
1574 libs << "QMAKE_LFLAGS_THREAD"; //not sure about this one, but what about things like -pthread?
1575 t << "Libs: -L${libdir} -l" << lname.left(lname.length()-Option::libtool_ext.length()) << " ";
1576 for(QStringList::ConstIterator it = libs.begin(); it != libs.end(); ++it)
1577 t << project->variables()[(*it)].join(" ") << " ";
1578 t << endl;
1579
1580 // flags
1581 // ### too many
1582 t << "Cflags: "
1583 // << var("QMAKE_CXXFLAGS") << " "
1584 << varGlue("PRL_EXPORT_DEFINES","-D"," -D"," ")
1585 << project->variables()["PRL_EXPORT_CXXFLAGS"].join(" ")
1586 // << varGlue("DEFINES","-D"," -D"," ")
1587 << " -I${includedir}";
1110} 1588}
diff --git a/qmake/generators/win32/borland_bmake.cpp b/qmake/generators/win32/borland_bmake.cpp
index 26eea88..12607cf 100644
--- a/qmake/generators/win32/borland_bmake.cpp
+++ b/qmake/generators/win32/borland_bmake.cpp
@@ -1,13 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Definition of ________ class.
5** 3**
6** Created : 970521 4** NmakeMakefileGenerator of BorlandMakefileGenerator class.
7** 5**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. 6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 7**
10** This file is part of the network module of the Qt GUI Toolkit. 8** This file is part of qmake.
11** 9**
12** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
@@ -134,6 +132,8 @@ BorlandMakefileGenerator::writeBorlandParts(QTextStream &t)
134 t << "MOVE = " << var("QMAKE_MOVE") << endl; 132 t << "MOVE = " << var("QMAKE_MOVE") << endl;
135 t << "CHK_DIR_EXISTS =" << var("QMAKE_CHK_DIR_EXISTS") << endl; 133 t << "CHK_DIR_EXISTS =" << var("QMAKE_CHK_DIR_EXISTS") << endl;
136 t << "MKDIR =" << var("QMAKE_MKDIR") << endl; 134 t << "MKDIR =" << var("QMAKE_MKDIR") << endl;
135 t << "INSTALL_FILE= " << var("QMAKE_INSTALL_FILE") << endl;
136 t << "INSTALL_DIR = " << var("QMAKE_INSTALL_DIR") << endl;
137 t << endl; 137 t << endl;
138 138
139 t << "####### Files" << endl << endl; 139 t << "####### Files" << endl << endl;
@@ -145,6 +145,23 @@ BorlandMakefileGenerator::writeBorlandParts(QTextStream &t)
145 t << "UICIMPLS =" << varList("UICIMPLS") << endl; 145 t << "UICIMPLS =" << varList("UICIMPLS") << endl;
146 t << "SRCMOC =" << varList("SRCMOC") << endl; 146 t << "SRCMOC =" << varList("SRCMOC") << endl;
147 t << "OBJMOC =" << varList("OBJMOC") << endl; 147 t << "OBJMOC =" << varList("OBJMOC") << endl;
148
149 QString extraCompilerDeps;
150 if(!project->isEmpty("QMAKE_EXTRA_WIN_COMPILERS")) {
151 t << "OBJCOMP = " << varList("OBJCOMP") << endl;
152 extraCompilerDeps += " $(OBJCOMP) ";
153
154 QStringList &comps = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"];
155 for(QStringList::Iterator compit = comps.begin(); compit != comps.end(); ++compit) {
156 QStringList &vars = project->variables()[(*compit) + ".variables"];
157 for(QStringList::Iterator varit = vars.begin(); varit != vars.end(); ++varit) {
158 QStringList vals = project->variables()[(*varit)];
159 if(!vals.isEmpty())
160 t << "QMAKE_COMP_" << (*varit) << " = " << valList(vals) << endl;
161 }
162 }
163 }
164
148 t << "DIST =" << varList("DISTFILES") << endl; 165 t << "DIST =" << varList("DISTFILES") << endl;
149 t << "TARGET =" 166 t << "TARGET ="
150 << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT")) 167 << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT"))
@@ -162,18 +179,19 @@ BorlandMakefileGenerator::writeBorlandParts(QTextStream &t)
162 t << ".c" << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl; 179 t << ".c" << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;
163 180
164 t << "####### Build rules" << endl << endl; 181 t << "####### Build rules" << endl << endl;
165 t << "all: " << varGlue("ALL_DEPS",""," "," ") << " $(TARGET)" << endl << endl; 182 t << "all: " << fileFixify(Option::output.name()) << " " << varGlue("ALL_DEPS"," "," "," ") << " $(TARGET)" << endl << endl;
166 t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) " 183 t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) "
167 << var("POST_TARGETDEPS"); 184 << extraCompilerDeps << var("POST_TARGETDEPS");
168 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) { 185 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
169 t << "\n\t" << "$(LINK) @&&|" << "\n\t" 186 t << "\n\t" << "$(LINK) @&&|" << "\n\t"
170 << "$(LFLAGS) $(OBJECTS) $(OBJMOC),$(TARGET),,$(LIBS),$(DEF_FILE),$(RES_FILE)"; 187 << "$(LFLAGS) $(OBJECTS) $(OBJMOC),$(TARGET),,$(LIBS),$(DEF_FILE),$(RES_FILE)";
171 } else { 188 } else {
172 t << "\n\t-del $(TARGET)" 189 t << "\n\t-$(DEL_FILE) $(TARGET)"
173 << "\n\t" << "$(LIB) $(TARGET) @&&|" << " \n+" 190 << "\n\t" << "$(LIB) $(TARGET) @&&|" << " \n+"
174 << project->variables()["OBJECTS"].join(" \\\n+") << " \\\n+" 191 << project->variables()["OBJECTS"].join(" \\\n+") << " \\\n+"
175 << project->variables()["OBJMOC"].join(" \\\n+"); 192 << project->variables()["OBJMOC"].join(" \\\n+");
176 } 193 }
194 t << extraCompilerDeps;
177 t << endl << "|" << endl; 195 t << endl << "|" << endl;
178 196
179 if ( !project->variables()["QMAKE_POST_LINK"].isEmpty() ) 197 if ( !project->variables()["QMAKE_POST_LINK"].isEmpty() )
@@ -182,7 +200,7 @@ BorlandMakefileGenerator::writeBorlandParts(QTextStream &t)
182 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) { 200 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) {
183 QStringList dlldirs = project->variables()["DLLDESTDIR"]; 201 QStringList dlldirs = project->variables()["DLLDESTDIR"];
184 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) { 202 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) {
185 t << "\n\t" << "-copy $(TARGET) " << *dlldir; 203 t << "\n\t" << "-$(COPY_FILE) \"$(TARGET)\" " << *dlldir;
186 } 204 }
187 } 205 }
188 QString targetfilename = project->variables()["TARGET"].first(); 206 QString targetfilename = project->variables()["TARGET"].first();
@@ -192,14 +210,14 @@ BorlandMakefileGenerator::writeBorlandParts(QTextStream &t)
192 version = "1.0"; 210 version = "1.0";
193 211
194 if ( project->isActiveConfig("dll")) { 212 if ( project->isActiveConfig("dll")) {
195 t << "\n\t" << ("-$(IDC) $(TARGET) /idl tmp\\" + targetfilename + ".idl -version " + version); 213 t << "\n\t" << ("-$(IDC) $(TARGET) /idl " + var("OBJECTS_DIR") + targetfilename + ".idl -version " + version);
196 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl"); 214 t << "\n\t" << ("-$(IDL) /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
197 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb"); 215 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
198 t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" ); 216 t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" );
199 } else { 217 } else {
200 t << "\n\t" << ("-$(TARGET) -dumpidl tmp\\" + targetfilename + ".idl -version " + version); 218 t << "\n\t" << ("-$(TARGET) -dumpidl " + var("OBJECTS_DIR") + targetfilename + ".idl -version " + version);
201 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl"); 219 t << "\n\t" << ("-$(IDL) /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
202 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb"); 220 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
203 t << "\n\t" << ("-$(TARGET) -regserver"); 221 t << "\n\t" << ("-$(TARGET) -regserver");
204 } 222 }
205 } 223 }
@@ -209,32 +227,60 @@ BorlandMakefileGenerator::writeBorlandParts(QTextStream &t)
209 t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t" 227 t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t"
210 << var("QMAKE_RC") << " " << var("RC_FILE") << endl << endl; 228 << var("QMAKE_RC") << " " << var("RC_FILE") << endl << endl;
211 } 229 }
212 t << "mocables: $(SRCMOC)" << endl << endl; 230 t << "mocables: $(SRCMOC)" << endl
231 << "uicables: $(UICIMPLS) $(UICDECLS)" << endl << endl;
213 232
214 writeMakeQmake(t); 233 writeMakeQmake(t);
215 234
235 QStringList dist_files = Option::mkfile::project_files;
236 if(!project->isEmpty("QMAKE_INTERNAL_INCLUDED_FILES"))
237 dist_files += project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"];
238 if(!project->isEmpty("TRANSLATIONS"))
239 dist_files << var("TRANSLATIONS");
240 if(!project->isEmpty("FORMS")) {
241 QStringList &forms = project->variables()["FORMS"];
242 for(QStringList::Iterator formit = forms.begin(); formit != forms.end(); ++formit) {
243 QString ui_h = fileFixify((*formit) + Option::h_ext.first());
244 if(QFile::exists(ui_h) )
245 dist_files << ui_h;
246 }
247 }
216 t << "dist:" << "\n\t" 248 t << "dist:" << "\n\t"
217 << "$(ZIP) " << var("PROJECT") << ".zip " << var("PROJECT") << ".pro $(SOURCES) $(HEADERS) $(DIST) $(FORMS)" 249 << "$(ZIP) " << var("QMAKE_ORIG_TARGET") << ".zip " << "$(SOURCES) $(HEADERS) $(DIST) $(FORMS) "
218 << endl << endl; 250 << dist_files.join(" ") << " " << var("TRANSLATIONS") << " " << var("IMAGES") << endl << endl;
251
252 t << "uiclean:";
253 QString uiclean = varGlue("UICDECLS" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","") + varGlue("UICIMPLS" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","");
254 if ( uiclean.isEmpty() ) {
255 // Borland make does not like an empty command section
256 uiclean = "\n\t@cd .";
257 }
258 t << uiclean << endl;
219 259
220 t << "clean:\n" 260 t << "mocclean:";
221 << varGlue("OBJECTS","\t-del ","\n\t-del ","") 261 QString mocclean = varGlue("SRCMOC" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","") + varGlue("OBJMOC" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","");
222 << varGlue("SRCMOC" ,"\n\t-del ","\n\t-del ","") 262 if ( mocclean.isEmpty() ) {
223 << varGlue("OBJMOC" ,"\n\t-del ","\n\t-del ","") 263 // Borland make does not like an empty command section
224 << varGlue("UICDECLS" ,"\n\t-del ","\n\t-del ","") 264 mocclean = "\n\t@cd .";
225 << varGlue("UICIMPLS" ,"\n\t-del ","\n\t-del ","") 265 }
226 << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ","") 266 t << mocclean << endl;
227 << varGlue("CLEAN_FILES","\n\t-del ","\n\t-del ",""); 267
268 t << "clean: uiclean mocclean"
269 << varGlue("OBJECTS","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")
270 << varGlue("QMAKE_CLEAN","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")
271 << varGlue("CLEAN_FILES","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","");
228 if ( project->isActiveConfig("activeqt")) { 272 if ( project->isActiveConfig("activeqt")) {
229 t << ("\n\t-del tmp\\" + targetfilename + ".*"); 273 t << ("\n\t-$(DEL_FILE) " + var("OBJECTS_DIR") + targetfilename + ".idl");
230 t << "\n\t-del tmp\\dump.*"; 274 t << ("\n\t-$(DEL_FILE) " + var("OBJECTS_DIR") + targetfilename + ".tlb");
231 } 275 }
232 if(!project->isEmpty("IMAGES")) 276 if(!project->isEmpty("IMAGES"))
233 t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-del ", "\n\t-del ", ""); 277 t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-$(DEL_FILE) ", "\n\t-$(DEL_FILE) ", "");
278 t << endl;
234 279
235 // blasted user defined targets 280 // user defined targets
281 QStringList::Iterator it;
236 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"]; 282 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"];
237 for(QStringList::Iterator it = qut.begin(); it != qut.end(); ++it) { 283 for(it = qut.begin(); it != qut.end(); ++it) {
238 QString targ = var((*it) + ".target"), 284 QString targ = var((*it) + ".target"),
239 cmd = var((*it) + ".commands"), deps; 285 cmd = var((*it) + ".commands"), deps;
240 if(targ.isEmpty()) 286 if(targ.isEmpty())
@@ -246,14 +292,66 @@ BorlandMakefileGenerator::writeBorlandParts(QTextStream &t)
246 dep = (*dep_it); 292 dep = (*dep_it);
247 deps += " " + dep; 293 deps += " " + dep;
248 } 294 }
295 if(!project->variables()["QMAKE_NOFORCE"].isEmpty() &&
296 project->variables()[(*it) + ".CONFIG"].findIndex("phony") != -1)
297 deps += QString(" ") + "FORCE";
249 t << "\n\n" << targ << ":" << deps << "\n\t" 298 t << "\n\n" << targ << ":" << deps << "\n\t"
250 << cmd; 299 << cmd;
251 } 300 }
252 301
253 t << endl << endl; 302 t << endl << endl;
254 303
304 QStringList &quc = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"];
305 for(it = quc.begin(); it != quc.end(); ++it) {
306 QString tmp_out = project->variables()[(*it) + ".output"].first();
307 QString tmp_cmd = project->variables()[(*it) + ".commands"].join(" ");
308 QString tmp_dep = project->variables()[(*it) + ".depends"].join(" ");
309 QStringList &vars = project->variables()[(*it) + ".variables"];
310 if(tmp_out.isEmpty() || tmp_cmd.isEmpty())
311 continue;
312 QStringList &tmp = project->variables()[(*it) + ".input"];
313 for(QStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {
314 QStringList &inputs = project->variables()[(*it2)];
315 for(QStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {
316 QFileInfo fi(Option::fixPathToLocalOS((*input)));
317 QString in = Option::fixPathToTargetOS((*input), FALSE),
318 out = tmp_out, cmd = tmp_cmd, deps;
319 out.replace("${QMAKE_FILE_BASE}", fi.baseName());
320 out.replace("${QMAKE_FILE_NAME}", fi.fileName());
321 cmd.replace("${QMAKE_FILE_BASE}", fi.baseName());
322 cmd.replace("${QMAKE_FILE_OUT}", out);
323 cmd.replace("${QMAKE_FILE_NAME}", fi.fileName());
324 for(QStringList::Iterator it3 = vars.begin(); it3 != vars.end(); ++it3)
325 cmd.replace("$(" + (*it3) + ")", "$(QMAKE_COMP_" + (*it3)+")");
326 if(!tmp_dep.isEmpty()) {
327 char buff[256];
328 QString dep_cmd = tmp_dep;
329 dep_cmd.replace("${QMAKE_FILE_NAME}", fi.fileName());
330 if(FILE *proc = QT_POPEN(dep_cmd.latin1(), "r")) {
331 while(!feof(proc)) {
332 int read_in = int(fread(buff, 1, 255, proc));
333 if(!read_in)
334 break;
335 int l = 0;
336 for(int i = 0; i < read_in; i++) {
337 if(buff[i] == '\n' || buff[i] == ' ') {
338 deps += " " + QCString(buff+l, (i - l) + 1);
339 l = i;
340 }
341 }
342 }
343 fclose(proc);
344 }
345 }
346 t << out << ": " << in << deps << "\n\t"
347 << cmd << endl << endl;
348 }
349 }
350 }
351 t << endl;
352
255 t << "distclean: clean" 353 t << "distclean: clean"
256 << "\n\t-del $(TARGET)" 354 << "\n\t-$(DEL_FILE) $(TARGET)"
257 << endl << endl; 355 << endl << endl;
258} 356}
259 357
@@ -280,12 +378,23 @@ BorlandMakefileGenerator::init()
280 return; 378 return;
281 } 379 }
282 380
381 if(project->isEmpty("QMAKE_INSTALL_FILE"))
382 project->variables()["QMAKE_INSTALL_FILE"].append("$(COPY_FILE)");
383 if(project->isEmpty("QMAKE_INSTALL_DIR"))
384 project->variables()["QMAKE_INSTALL_DIR"].append("$(COPY_DIR)");
385
283 bool is_qt = (project->first("TARGET") == "qt"QTDLL_POSTFIX || project->first("TARGET") == "qtmt"QTDLL_POSTFIX); 386 bool is_qt = (project->first("TARGET") == "qt"QTDLL_POSTFIX || project->first("TARGET") == "qtmt"QTDLL_POSTFIX);
284 QStringList &configs = project->variables()["CONFIG"]; 387 QStringList &configs = project->variables()["CONFIG"];
285 if (project->isActiveConfig("shared")) 388 if (project->isActiveConfig("shared"))
286 project->variables()["DEFINES"].append("QT_DLL"); 389 project->variables()["DEFINES"].append("QT_DLL");
287 if (project->isActiveConfig("qt_dll")) 390 if (project->isActiveConfig("qt_dll"))
288 if(configs.findIndex("qt") == -1) configs.append("qt"); 391 if(configs.findIndex("qt") == -1) configs.append("qt");
392 if ( project->isActiveConfig("qtopia") ) {
393 if(configs.findIndex("qtopialib") == -1)
394 configs.append("qtopialib");
395 if(configs.findIndex("qtopiainc") == -1)
396 configs.append("qtopiainc");
397 }
289 if ( project->isActiveConfig("qt") ) { 398 if ( project->isActiveConfig("qt") ) {
290 if ( project->isActiveConfig("plugin") ) { 399 if ( project->isActiveConfig("plugin") ) {
291 project->variables()["CONFIG"].append("dll"); 400 project->variables()["CONFIG"].append("dll");
@@ -356,6 +465,13 @@ BorlandMakefileGenerator::init()
356 if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") ) { 465 if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") ) {
357 project->variables()["CONFIG"].append("windows"); 466 project->variables()["CONFIG"].append("windows");
358 } 467 }
468 if ( project->isActiveConfig("qtopiainc") )
469 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QTOPIA"];
470 if ( project->isActiveConfig("qtopialib") ) {
471 if(!project->isEmpty("QMAKE_LIBDIR_QTOPIA"))
472 project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QTOPIA"];
473 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QTOPIA"];
474 }
359 if ( project->isActiveConfig("qt") ) { 475 if ( project->isActiveConfig("qt") ) {
360 project->variables()["CONFIG"].append("moc"); 476 project->variables()["CONFIG"].append("moc");
361 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"]; 477 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"];
@@ -468,10 +584,25 @@ BorlandMakefileGenerator::init()
468 setMocAware(TRUE); 584 setMocAware(TRUE);
469 } 585 }
470 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; 586 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
587 // Update -lname to name.lib, and -Ldir to
588 QStringList &libList = project->variables()["QMAKE_LIBS"];
589 for( QStringList::Iterator stIt = libList.begin(); stIt != libList.end(); ) {
590 QString s = *stIt;
591 if( s.startsWith( "-l" ) ) {
592 stIt = libList.remove( stIt );
593 stIt = libList.insert( stIt, s.mid( 2 ) + ".lib" );
594 } else if( s.startsWith( "-L" ) ) {
595 stIt = libList.remove( stIt );
596 project->variables()["QMAKE_LIBDIR"].append(QDir::convertSeparators(s.mid( 2 )));
597 } else {
598 stIt++;
599 }
600 }
471 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ', 601 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ',
472 "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH"); 602 "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH");
473 QStringList &l = project->variables()["QMAKE_FILETAGS"]; 603 QStringList &l = project->variables()["QMAKE_FILETAGS"];
474 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 604 QStringList::Iterator it;
605 for(it = l.begin(); it != l.end(); ++it) {
475 QStringList &gdmf = project->variables()[(*it)]; 606 QStringList &gdmf = project->variables()[(*it)];
476 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner) 607 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner)
477 (*inner) = Option::fixPathToTargetOS((*inner), FALSE); 608 (*inner) = Option::fixPathToTargetOS((*inner), FALSE);
@@ -486,6 +617,7 @@ BorlandMakefileGenerator::init()
486 project->variables()["RES_FILE"] = project->variables()["RC_FILE"]; 617 project->variables()["RES_FILE"] = project->variables()["RC_FILE"];
487 project->variables()["RES_FILE"].first().replace(".rc",".res"); 618 project->variables()["RES_FILE"].first().replace(".rc",".res");
488 project->variables()["POST_TARGETDEPS"] += project->variables()["RES_FILE"]; 619 project->variables()["POST_TARGETDEPS"] += project->variables()["RES_FILE"];
620 project->variables()["CLEAN_FILES"] += project->variables()["RES_FILE"];
489 } 621 }
490 MakefileGenerator::init(); 622 MakefileGenerator::init();
491 if ( !project->variables()["VERSION"].isEmpty()) { 623 if ( !project->variables()["VERSION"].isEmpty()) {
@@ -506,4 +638,24 @@ BorlandMakefileGenerator::init()
506 project->variables()["QMAKE_CLEAN"].append( 638 project->variables()["QMAKE_CLEAN"].append(
507 project->first("DESTDIR") + project->first("TARGET") + tdsPostfix ); 639 project->first("DESTDIR") + project->first("TARGET") + tdsPostfix );
508 } 640 }
641
642 QStringList &quc = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"];
643 for(it = quc.begin(); it != quc.end(); ++it) {
644 QString tmp_out = project->variables()[(*it) + ".output"].first();
645 if(tmp_out.isEmpty())
646 continue;
647 QStringList &tmp = project->variables()[(*it) + ".input"];
648 for(QStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {
649 QStringList &inputs = project->variables()[(*it2)];
650 for(QStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {
651 QFileInfo fi(Option::fixPathToLocalOS((*input)));
652 QString in = Option::fixPathToTargetOS((*input), FALSE),
653 out = tmp_out;
654 out.replace("${QMAKE_FILE_BASE}", fi.baseName());
655 out.replace("${QMAKE_FILE_NAME}", fi.fileName());
656 if(project->variables()[(*it) + ".CONFIG"].findIndex("no_link") == -1)
657 project->variables()["OBJCOMP"] += out;
658 }
659 }
660 }
509} 661}
diff --git a/qmake/generators/win32/borland_bmake.h b/qmake/generators/win32/borland_bmake.h
index 5ffed58..700e7f7 100644
--- a/qmake/generators/win32/borland_bmake.h
+++ b/qmake/generators/win32/borland_bmake.h
@@ -1,13 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Definition of ________ class.
5** 3**
6** Created : 970521 4** Definition of BorlandMakefileGenerator class.
7** 5**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. 6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 7**
10** This file is part of the network module of the Qt GUI Toolkit. 8** This file is part of qmake.
11** 9**
12** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
@@ -34,6 +32,7 @@
34** not clear to you. 32** not clear to you.
35** 33**
36**********************************************************************/ 34**********************************************************************/
35
37#ifndef __BORLAND_BMAKE_H__ 36#ifndef __BORLAND_BMAKE_H__
38#define __BORLAND_BMAKE_H__ 37#define __BORLAND_BMAKE_H__
39 38
diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp
index 7f58a55..c693d6a 100644
--- a/qmake/generators/win32/mingw_make.cpp
+++ b/qmake/generators/win32/mingw_make.cpp
@@ -1,11 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Definition of ________ class.
5** 3**
6** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. 4** Implementation of MingwMakefileGenerator class.
7** 5**
8** This file is part of the network module of the Qt GUI Toolkit. 6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
7**
8** This file is part of qmake.
9** 9**
10** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
11** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
@@ -47,6 +47,12 @@ MingwMakefileGenerator::MingwMakefileGenerator(QMakeProject *p) : Win32MakefileG
47} 47}
48 48
49bool 49bool
50MingwMakefileGenerator::findLibraries() // todo - pascal
51{
52 return TRUE;
53}
54
55bool
50MingwMakefileGenerator::writeMakefile(QTextStream &t) 56MingwMakefileGenerator::writeMakefile(QTextStream &t)
51{ 57{
52 writeHeader(t); 58 writeHeader(t);
@@ -71,6 +77,21 @@ MingwMakefileGenerator::writeMakefile(QTextStream &t)
71 return FALSE; 77 return FALSE;
72} 78}
73 79
80void createLdObjectScriptFile(const QString & fileName, QStringList & objList)
81{
82 QString filePath = Option::output_dir + QDir::separator() + fileName;
83 QFile file(filePath);
84 if (file.open(IO_WriteOnly | IO_Translate )) {
85 QTextStream t(&file);
86 t << "INPUT(" << endl;
87 for (QStringList::Iterator it = objList.begin(); it != objList.end(); ++it ) {
88 t << *it << endl;
89 }
90 t << ");" << endl;
91 file.close();
92 }
93}
94
74void 95void
75MingwMakefileGenerator::writeMingwParts(QTextStream &t) 96MingwMakefileGenerator::writeMingwParts(QTextStream &t)
76{ 97{
@@ -94,17 +115,16 @@ MingwMakefileGenerator::writeMingwParts(QTextStream &t)
94 QString inc = (*incit); 115 QString inc = (*incit);
95 inc.replace(QRegExp("\\\\$"), "\\\\"); 116 inc.replace(QRegExp("\\\\$"), "\\\\");
96 inc.replace(QRegExp("\""), ""); 117 inc.replace(QRegExp("\""), "");
97 t << " -I" << inc ; 118 t << " -I" << "\"" << inc << "\"";
98 } 119 }
99 t << " -I" << specdir() 120 t << " -I" << "\"" << specdir() << "\"" << endl;
100 << endl;
101 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) { 121 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
102 t << "LINK =" << var("QMAKE_LINK") << endl; 122 t << "LINK =" << var("QMAKE_LINK") << endl;
103 t << "LFLAGS ="; 123 t << "LFLAGS =" << var("QMAKE_LFLAGS") << endl;
124 t << "LIBS =";
104 if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() ) 125 if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() )
105 t << varGlue("QMAKE_LIBDIR","-L",";","") << " "; 126 t << varGlue("QMAKE_LIBDIR","-L\"","\" -L\"","\"") << " ";
106 t << var("QMAKE_LFLAGS") << endl; 127 t << var("QMAKE_LIBS").replace(QRegExp("(\\slib|^lib)")," -l") << endl;
107 t << "LIBS =" << var("QMAKE_LIBS").replace(QRegExp("(\\slib|^lib)")," -l") << endl;
108 } 128 }
109 else { 129 else {
110 t << "LIB =" << var("QMAKE_LIB") << endl; 130 t << "LIB =" << var("QMAKE_LIB") << endl;
@@ -128,6 +148,8 @@ MingwMakefileGenerator::writeMingwParts(QTextStream &t)
128 t << "MOVE = " << var("QMAKE_MOVE") << endl; 148 t << "MOVE = " << var("QMAKE_MOVE") << endl;
129 t << "CHK_DIR_EXISTS =" << var("QMAKE_CHK_DIR_EXISTS") << endl; 149 t << "CHK_DIR_EXISTS =" << var("QMAKE_CHK_DIR_EXISTS") << endl;
130 t << "MKDIR =" << var("QMAKE_MKDIR") << endl; 150 t << "MKDIR =" << var("QMAKE_MKDIR") << endl;
151 t << "INSTALL_FILE= " << var("QMAKE_INSTALL_FILE") << endl;
152 t << "INSTALL_DIR = " << var("QMAKE_INSTALL_DIR") << endl;
131 t << endl; 153 t << endl;
132 154
133 t << "####### Output directory" << endl << endl; 155 t << "####### Output directory" << endl << endl;
@@ -144,14 +166,44 @@ MingwMakefileGenerator::writeMingwParts(QTextStream &t)
144 t << "####### Files" << endl << endl; 166 t << "####### Files" << endl << endl;
145 t << "HEADERS =" << varList("HEADERS") << endl; 167 t << "HEADERS =" << varList("HEADERS") << endl;
146 t << "SOURCES =" << varList("SOURCES") << endl; 168 t << "SOURCES =" << varList("SOURCES") << endl;
147 // t << "OBJECTS =" << varList("OBJECTS").replace(QRegExp("\\.obj"),".o") << endl; 169 QString objectsLinkLine;
170 if (!project->variables()["QMAKE_APP_OR_DLL"].isEmpty() &&
171 project->variables()["OBJECTS"].count() > var("QMAKE_LINK_OBJECT_MAX").toUInt()) {
172 createLdObjectScriptFile(var("QMAKE_LINK_OBJECT_SCRIPT"), project->variables()["OBJECTS"]);
173 objectsLinkLine = var("QMAKE_LINK_OBJECT_SCRIPT");
174 } else {
175 objectsLinkLine = "$(OBJECTS)";
176 }
148 t << "OBJECTS =" << varList("OBJECTS") << endl; 177 t << "OBJECTS =" << varList("OBJECTS") << endl;
149 t << "FORMS =" << varList("FORMS") << endl; 178 t << "FORMS =" << varList("FORMS") << endl;
150 t << "UICDECLS =" << varList("UICDECLS") << endl; 179 t << "UICDECLS =" << varList("UICDECLS") << endl;
151 t << "UICIMPLS =" << varList("UICIMPLS") << endl; 180 t << "UICIMPLS =" << varList("UICIMPLS") << endl;
152 t << "SRCMOC =" << varList("SRCMOC") << endl; 181 t << "SRCMOC =" << varList("SRCMOC") << endl;
182 QString objmocLinkLine;
183 if (!project->variables()["QMAKE_APP_OR_DLL"].isEmpty() &&
184 project->variables()["OBJMOC"].count() > var("QMAKE_LINK_OBJECT_MAX").toUInt()) {
185 createLdObjectScriptFile(var("QMAKE_LINK_OBJMOC_SCRIPT"), project->variables()["OBJMOC"]);
186 objmocLinkLine = var("QMAKE_LINK_OBJMOC_SCRIPT");
187 } else {
188 objmocLinkLine = "$(OBJMOC)";
189 }
153 t << "OBJMOC =" << varList("OBJMOC") << endl; 190 t << "OBJMOC =" << varList("OBJMOC") << endl;
154 // t << "OBJMOC =" << varList("OBJMOC").replace(QRegExp("\\.obj"),".o") << endl; 191 QString extraCompilerDeps;
192 if(!project->isEmpty("QMAKE_EXTRA_WIN_COMPILERS")) {
193 t << "OBJCOMP = " << varList("OBJCOMP") << endl;
194 extraCompilerDeps += " $(OBJCOMP) ";
195
196 QStringList &comps = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"];
197 for(QStringList::Iterator compit = comps.begin(); compit != comps.end(); ++compit) {
198 QStringList &vars = project->variables()[(*compit) + ".variables"];
199 for(QStringList::Iterator varit = vars.begin(); varit != vars.end(); ++varit) {
200 QStringList vals = project->variables()[(*varit)];
201 if(!vals.isEmpty())
202 t << "QMAKE_COMP_" << (*varit) << " = " << valList(vals) << endl;
203 }
204 }
205 }
206
155 t << "DIST =" << varList("DISTFILES") << endl; 207 t << "DIST =" << varList("DISTFILES") << endl;
156 t << "TARGET ="; 208 t << "TARGET =";
157 if( !project->variables()[ "DESTDIR" ].isEmpty() ) 209 if( !project->variables()[ "DESTDIR" ].isEmpty() )
@@ -172,17 +224,17 @@ MingwMakefileGenerator::writeMingwParts(QTextStream &t)
172 t << "####### Build rules" << endl << endl; 224 t << "####### Build rules" << endl << endl;
173 t << "all: " << "$(OBJECTS_DIR) " << "$(MOC_DIR) " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" << endl << endl; 225 t << "all: " << "$(OBJECTS_DIR) " << "$(MOC_DIR) " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" << endl << endl;
174 t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) " 226 t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) "
175 << var("POST_TARGETDEPS"); 227 << extraCompilerDeps << var("POST_TARGETDEPS");
176 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) { 228 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
177 t << "\n\t" << "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)"; 229 t << "\n\t" << "$(LINK) $(LFLAGS) -o $(TARGET) " << objectsLinkLine << " " << objmocLinkLine << " $(LIBS)";
178 } else { 230 } else {
179 t << "\n\t" << "$(LIB) $(TARGET) $(OBJECTS) $(OBJMOC)"; 231 t << "\n\t" << "$(LIB) $(TARGET) " << objectsLinkLine << " " << objmocLinkLine;
180 } 232 }
181 233 t << extraCompilerDeps;
182 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) { 234 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) {
183 QStringList dlldirs = project->variables()["DLLDESTDIR"]; 235 QStringList dlldirs = project->variables()["DLLDESTDIR"];
184 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) { 236 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) {
185 t << "\n\t" << "copy $(TARGET) " << *dlldir; 237 t << "\n\t" << "$(COPY_FILE) \"$(TARGET)\" " << *dlldir;
186 } 238 }
187 } 239 }
188 QString targetfilename = project->variables()["TARGET"].first(); 240 QString targetfilename = project->variables()["TARGET"].first();
@@ -192,14 +244,14 @@ MingwMakefileGenerator::writeMingwParts(QTextStream &t)
192 version = "1.0"; 244 version = "1.0";
193 245
194 if ( project->isActiveConfig("dll")) { 246 if ( project->isActiveConfig("dll")) {
195 t << "\n\t" << ("-$(IDC) $(TARGET) /idl tmp\\" + targetfilename + ".idl -version " + version); 247 t << "\n\t" << ("-$(IDC) $(TARGET) /idl " + var("OBJECTS_DIR") + targetfilename + ".idl -version " + version);
196 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl"); 248 t << "\n\t" << ("-$(IDL) /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
197 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb"); 249 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
198 t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" ); 250 t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" );
199 } else { 251 } else {
200 t << "\n\t" << ("-$(TARGET) -dumpidl tmp\\" + targetfilename + ".idl -version " + version); 252 t << "\n\t" << ("-$(TARGET) -dumpidl " + var("OBJECTS_DIR") + targetfilename + ".idl -version " + version);
201 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl"); 253 t << "\n\t" << ("-$(IDL) /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
202 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb"); 254 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
203 t << "\n\t" << "-$(TARGET) -regserver"; 255 t << "\n\t" << "-$(TARGET) -regserver";
204 } 256 }
205 } 257 }
@@ -207,17 +259,17 @@ MingwMakefileGenerator::writeMingwParts(QTextStream &t)
207 259
208 if(!project->variables()["RC_FILE"].isEmpty()) { 260 if(!project->variables()["RC_FILE"].isEmpty()) {
209 t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t" 261 t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t"
210 << var("QMAKE_RC") << " -i " << var("RC_FILE") << " -o " << var("RC_FILE").replace(QRegExp("\\.rc"),".o") << endl << endl; 262 << var("QMAKE_RC") << " -i " << var("RC_FILE") << " -o " << var("RC_FILE").replace(QRegExp("\\.rc"),".o") << " --include-dir=" << QFileInfo(var("RC_FILE")).dirPath() << endl << endl;
211 } 263 }
212 project->variables()["RES_FILE"].first().replace(QRegExp("\\.rc"),".o"); 264 project->variables()["RES_FILE"].first().replace(QRegExp("\\.rc"),".o");
213 265
214 t << "mocables: $(SRCMOC)" << endl << endl; 266 t << "mocables: $(SRCMOC)" << endl << endl;
215 267
216 t << "$(OBJECTS_DIR):" << "\n\t" 268 t << "$(OBJECTS_DIR):" << "\n\t"
217 << "@if not exist $(OBJECTS_DIR) mkdir $(OBJECTS_DIR)" << endl << endl; 269 << "@if not exist $(OBJECTS_DIR) $(MKDIR) $(OBJECTS_DIR)" << endl << endl;
218 270
219 t << "$(MOC_DIR):" << "\n\t" 271 t << "$(MOC_DIR):" << "\n\t"
220 << "@if not exist $(MOC_DIR) mkdir $(MOC_DIR)" << endl << endl; 272 << "@if not exist $(MOC_DIR) $(MKDIR) $(MOC_DIR)" << endl << endl;
221 273
222 writeMakeQmake(t); 274 writeMakeQmake(t);
223 275
@@ -226,26 +278,26 @@ MingwMakefileGenerator::writeMingwParts(QTextStream &t)
226 << var("PROJECT") << ".pro $(SOURCES) $(HEADERS) $(DIST) $(FORMS)" << endl << endl; 278 << var("PROJECT") << ".pro $(SOURCES) $(HEADERS) $(DIST) $(FORMS)" << endl << endl;
227 279
228 t << "clean:" 280 t << "clean:"
229 << varGlue("OBJECTS","\n\t-del ","\n\t-del ","").replace(QRegExp("\\.obj"),".o") 281 << varGlue("OBJECTS","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","").replace(QRegExp("\\.obj"),".o")
230 << varGlue("SRCMOC" ,"\n\t-del ","\n\t-del ","") 282 << varGlue("SRCMOC" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")
231 << varGlue("OBJMOC" ,"\n\t-del ","\n\t-del ","").replace(QRegExp("\\.obj"),".o") 283 << varGlue("OBJMOC" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","").replace(QRegExp("\\.obj"),".o")
232 << varGlue("UICDECLS" ,"\n\t-del ","\n\t-del ","") 284 << varGlue("UICDECLS" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")
233 << varGlue("UICIMPLS" ,"\n\t-del ","\n\t-del ","") 285 << varGlue("UICIMPLS" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")
234 << "\n\t-del $(TARGET)" 286 << "\n\t-$(DEL_FILE) $(TARGET)"
235 << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ","") 287 << varGlue("QMAKE_CLEAN","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")
236 << varGlue("CLEAN_FILES","\n\t-del ","\n\t-del ",""); 288 << varGlue("CLEAN_FILES","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","");
237 if ( project->isActiveConfig("activeqt")) { 289 if ( project->isActiveConfig("activeqt")) {
238 t << ("\n\t-del tmp\\" + targetfilename + ".*"); 290 t << ("\n\t-$(DEL_FILE) " + var("OBJECTS_DIR") + targetfilename + ".idl");
239 t << "\n\t-del tmp\\dump.*"; 291 t << ("\n\t-$(DEL_FILE) " + var("OBJECTS_DIR") + targetfilename + ".tlb");
240 } 292 }
241 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty())
242 t << "\n\t-del " << var("DLLDESTDIR") << "\\" << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first();
243 if(!project->isEmpty("IMAGES")) 293 if(!project->isEmpty("IMAGES"))
244 t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-del ", "\n\t-del ", ""); 294 t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-$(DEL_FILE) ", "\n\t-$(DEL_FILE) ", "");
245 295
246 // blasted user defined targets 296 // user defined targets
297 QStringList::Iterator it;
247 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"]; 298 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"];
248 for(QStringList::Iterator it = qut.begin(); it != qut.end(); ++it) { 299
300 for(it = qut.begin(); it != qut.end(); ++it) {
249 QString targ = var((*it) + ".target"), 301 QString targ = var((*it) + ".target"),
250 cmd = var((*it) + ".commands"), deps; 302 cmd = var((*it) + ".commands"), deps;
251 if(targ.isEmpty()) 303 if(targ.isEmpty())
@@ -262,6 +314,55 @@ MingwMakefileGenerator::writeMingwParts(QTextStream &t)
262 } 314 }
263 315
264 t << endl << endl; 316 t << endl << endl;
317
318 QStringList &quc = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"];
319 for(it = quc.begin(); it != quc.end(); ++it) {
320 QString tmp_out = project->variables()[(*it) + ".output"].first();
321 QString tmp_cmd = project->variables()[(*it) + ".commands"].join(" ");
322 QString tmp_dep = project->variables()[(*it) + ".depends"].join(" ");
323 QStringList &vars = project->variables()[(*it) + ".variables"];
324 if(tmp_out.isEmpty() || tmp_cmd.isEmpty())
325 continue;
326 QStringList &tmp = project->variables()[(*it) + ".input"];
327 for(QStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {
328 QStringList &inputs = project->variables()[(*it2)];
329 for(QStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {
330 QFileInfo fi(Option::fixPathToLocalOS((*input)));
331 QString in = Option::fixPathToTargetOS((*input), FALSE),
332 out = tmp_out, cmd = tmp_cmd, deps;
333 out.replace("${QMAKE_FILE_BASE}", fi.baseName());
334 out.replace("${QMAKE_FILE_NAME}", fi.fileName());
335 cmd.replace("${QMAKE_FILE_BASE}", fi.baseName());
336 cmd.replace("${QMAKE_FILE_OUT}", out);
337 cmd.replace("${QMAKE_FILE_NAME}", fi.fileName());
338 for(QStringList::Iterator it3 = vars.begin(); it3 != vars.end(); ++it3)
339 cmd.replace("$(" + (*it3) + ")", "$(QMAKE_COMP_" + (*it3)+")");
340 if(!tmp_dep.isEmpty()) {
341 char buff[256];
342 QString dep_cmd = tmp_dep;
343 dep_cmd.replace("${QMAKE_FILE_NAME}", fi.fileName());
344 if(FILE *proc = QT_POPEN(dep_cmd.latin1(), "r")) {
345 while(!feof(proc)) {
346 int read_in = int(fread(buff, 1, 255, proc));
347 if(!read_in)
348 break;
349 int l = 0;
350 for(int i = 0; i < read_in; i++) {
351 if(buff[i] == '\n' || buff[i] == ' ') {
352 deps += " " + QCString(buff+l, (i - l) + 1);
353 l = i;
354 }
355 }
356 }
357 fclose(proc);
358 }
359 }
360 t << out << ": " << in << deps << "\n\t"
361 << cmd << endl << endl;
362 }
363 }
364 }
365 t << endl;
265} 366}
266 367
267 368
@@ -286,6 +387,11 @@ MingwMakefileGenerator::init()
286 return; 387 return;
287 } 388 }
288 389
390 if(project->isEmpty("QMAKE_INSTALL_FILE"))
391 project->variables()["QMAKE_INSTALL_FILE"].append("$(COPY_FILE)");
392 if(project->isEmpty("QMAKE_INSTALL_DIR"))
393 project->variables()["QMAKE_INSTALL_DIR"].append("$(COPY_DIR)");
394
289 bool is_qt = (project->first("TARGET") == "qt"QTDLL_POSTFIX || project->first("TARGET") == "qt-mt"QTDLL_POSTFIX); 395 bool is_qt = (project->first("TARGET") == "qt"QTDLL_POSTFIX || project->first("TARGET") == "qt-mt"QTDLL_POSTFIX);
290 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"]; 396 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"];
291 397
@@ -294,10 +400,14 @@ MingwMakefileGenerator::init()
294 400
295 QString targetfilename = project->variables()["TARGET"].first(); 401 QString targetfilename = project->variables()["TARGET"].first();
296 QStringList &configs = project->variables()["CONFIG"]; 402 QStringList &configs = project->variables()["CONFIG"];
403
297 if (project->isActiveConfig("qt") && project->isActiveConfig("shared")) 404 if (project->isActiveConfig("qt") && project->isActiveConfig("shared"))
298 project->variables()["DEFINES"].append("QT_DLL"); 405 project->variables()["DEFINES"].append("QT_DLL");
406
299 if (project->isActiveConfig("qt_dll")) 407 if (project->isActiveConfig("qt_dll"))
300 if(configs.findIndex("qt") == -1) configs.append("qt"); 408 if (configs.findIndex("qt") == -1)
409 configs.append("qt");
410
301 if ( project->isActiveConfig("qt") ) { 411 if ( project->isActiveConfig("qt") ) {
302 if ( project->isActiveConfig( "plugin" ) ) { 412 if ( project->isActiveConfig( "plugin" ) ) {
303 project->variables()["CONFIG"].append("dll"); 413 project->variables()["CONFIG"].append("dll");
@@ -319,12 +429,14 @@ MingwMakefileGenerator::init()
319 if ( project->isActiveConfig("tablet") ) 429 if ( project->isActiveConfig("tablet") )
320 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT"); 430 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT");
321 } 431 }
432
322 if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { 433 if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
323 project->variables()["CONFIG"].remove("staticlib"); 434 project->variables()["CONFIG"].remove("staticlib");
324 project->variables()["QMAKE_APP_OR_DLL"].append("1"); 435 project->variables()["QMAKE_APP_OR_DLL"].append("1");
325 } else { 436 } else {
326 project->variables()["CONFIG"].append("staticlib"); 437 project->variables()["CONFIG"].append("staticlib");
327 } 438 }
439
328 if ( project->isActiveConfig("warn_off") ) { 440 if ( project->isActiveConfig("warn_off") ) {
329 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_OFF"]; 441 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_OFF"];
330 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_OFF"]; 442 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_OFF"];
@@ -332,6 +444,7 @@ MingwMakefileGenerator::init()
332 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_ON"]; 444 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_ON"];
333 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_ON"]; 445 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_ON"];
334 } 446 }
447
335 if ( project->isActiveConfig("debug") ) { 448 if ( project->isActiveConfig("debug") ) {
336 if ( project->isActiveConfig("thread") ) { 449 if ( project->isActiveConfig("thread") ) {
337 // use the DLL RT even here 450 // use the DLL RT even here
@@ -363,8 +476,10 @@ MingwMakefileGenerator::init()
363 476
364 if ( !project->variables()["QMAKE_INCDIR"].isEmpty()) 477 if ( !project->variables()["QMAKE_INCDIR"].isEmpty())
365 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"]; 478 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"];
479
366 if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") ) 480 if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") )
367 project->variables()["CONFIG"].append("windows"); 481 project->variables()["CONFIG"].append("windows");
482
368 if ( project->isActiveConfig("qt") ) { 483 if ( project->isActiveConfig("qt") ) {
369 project->variables()["CONFIG"].append("moc"); 484 project->variables()["CONFIG"].append("moc");
370 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"]; 485 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"];
@@ -377,6 +492,7 @@ MingwMakefileGenerator::init()
377 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_QT_DLL"]; 492 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_QT_DLL"];
378 } 493 }
379 } else { 494 } else {
495
380 if(project->isActiveConfig("thread")) 496 if(project->isActiveConfig("thread"))
381 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; 497 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"];
382 else 498 else
@@ -396,19 +512,27 @@ MingwMakefileGenerator::init()
396 } 512 }
397 if ( project->isActiveConfig( "activeqt" ) ) { 513 if ( project->isActiveConfig( "activeqt" ) ) {
398 project->variables().remove("QMAKE_LIBS_QT_ENTRY"); 514 project->variables().remove("QMAKE_LIBS_QT_ENTRY");
399 project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib"; 515 project->variables()["QMAKE_LIBS_QT_ENTRY"] = "-lqaxserver";
400 if ( project->isActiveConfig( "dll" ) ) 516 if ( project->isActiveConfig( "dll" ) ) {
401 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"]; 517 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"];
402 } 518 }
519 }
403 if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) { 520 if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) {
404 project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"]; 521 project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"];
405 } 522 }
523
524 // QMAKE_LIBS_QT_ENTRY should be first on the link line as it needs qt
525 project->variables()["QMAKE_LIBS"].remove(project->variables()["QMAKE_LIBS_QT_ENTRY"].first());
526 project->variables()["QMAKE_LIBS"].prepend(project->variables()["QMAKE_LIBS_QT_ENTRY"].first());
527
406 } 528 }
407 } 529 }
530
408 if ( project->isActiveConfig("opengl") ) { 531 if ( project->isActiveConfig("opengl") ) {
409 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; 532 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"];
410 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"]; 533 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"];
411 } 534 }
535
412 if ( project->isActiveConfig("dll") ) { 536 if ( project->isActiveConfig("dll") ) {
413 project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE_DLL"]; 537 project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE_DLL"];
414 project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE_DLL"]; 538 project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE_DLL"];
@@ -434,6 +558,7 @@ MingwMakefileGenerator::init()
434 project->variables()["TARGET"].first().prepend("lib"); 558 project->variables()["TARGET"].first().prepend("lib");
435 } 559 }
436 } 560 }
561
437 if ( project->isActiveConfig("windows") ) { 562 if ( project->isActiveConfig("windows") ) {
438 if ( project->isActiveConfig("console") ) { 563 if ( project->isActiveConfig("console") ) {
439 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"]; 564 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
@@ -451,22 +576,56 @@ MingwMakefileGenerator::init()
451 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"]; 576 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
452 } 577 }
453 578
579 if ( project->isActiveConfig("exceptions") ) {
580 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_ON"];
581 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_ON"];
582 } else {
583 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_OFF"];
584 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_OFF"];
585 }
586
587 if ( project->isActiveConfig("rtti") ) {
588 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_ON"];
589 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_ON"];
590 } else {
591 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_OFF"];
592 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_OFF"];
593 }
594
454 if ( project->isActiveConfig("moc") ) 595 if ( project->isActiveConfig("moc") )
455 setMocAware(TRUE); 596 setMocAware(TRUE);
597
598 // add -L libs to libdir
599 QStringList &libs = project->variables()["QMAKE_LIBS"];
600 for ( QStringList::Iterator libit = libs.begin(); libit != libs.end(); ) {
601 if ( (*libit).startsWith( "-L" ) ) {
602 project->variables()["QMAKE_LIBDIR"] += (*libit).mid(2);
603 libit = libs.remove( libit );
604 } else {
605 ++libit;
606 }
607 }
608
456 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ', 609 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ',
457 "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH"); 610 "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH");
458 QStringList &l = project->variables()["QMAKE_FILETAGS"]; 611 QStringList &l = project->variables()["QMAKE_FILETAGS"];
459 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 612 QStringList::Iterator it;
613 for(it = l.begin(); it != l.end(); ++it) {
460 QStringList &gdmf = project->variables()[(*it)]; 614 QStringList &gdmf = project->variables()[(*it)];
461 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner) 615 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner)
462 (*inner) = Option::fixPathToTargetOS((*inner), FALSE); 616 (*inner) = Option::fixPathToTargetOS((*inner), FALSE);
463 } 617 }
464 618
465 if ( project->isActiveConfig("dll") ) 619 if ( project->isActiveConfig("dll") ) {
466 project->variables()["QMAKE_LFLAGS"].append(QString("-Wl,--out-implib,") + project->first("DESTDIR") + "\\lib"+ project->first("TARGET") + ".a"); 620 QString destDir = "";
621 if (!project->first("DESTDIR").isEmpty())
622 destDir = project->first("DESTDIR") + Option::dir_sep;
623 project->variables()["QMAKE_LFLAGS"].append(QString("-Wl,--out-implib,") +
624 destDir + "lib" + project->first("TARGET") + ".a");
625 }
467 626
468 if ( !project->variables()["DEF_FILE"].isEmpty() ) 627 if ( !project->variables()["DEF_FILE"].isEmpty() )
469 project->variables()["QMAKE_LFLAGS"].append(QString("-Wl,--output-def,") + project->first("DEF_FILE")); 628 project->variables()["QMAKE_LFLAGS"].append(QString("-Wl,") + project->first("DEF_FILE"));
470// if(!project->isActiveConfig("incremental")) 629// if(!project->isActiveConfig("incremental"))
471 //project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no")); 630 //project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no"));
472 631
@@ -480,6 +639,7 @@ MingwMakefileGenerator::init()
480 project->variables()["QMAKE_LFLAGS"].append( "/VERSION:" + major + "." + minor ); 639 project->variables()["QMAKE_LFLAGS"].append( "/VERSION:" + major + "." + minor );
481 } 640 }
482#endif 641#endif
642
483 if ( !project->variables()["RC_FILE"].isEmpty()) { 643 if ( !project->variables()["RC_FILE"].isEmpty()) {
484 if ( !project->variables()["RES_FILE"].isEmpty()) { 644 if ( !project->variables()["RES_FILE"].isEmpty()) {
485 fprintf(stderr, "Both .rc and .res file specified.\n"); 645 fprintf(stderr, "Both .rc and .res file specified.\n");
@@ -489,19 +649,43 @@ MingwMakefileGenerator::init()
489 project->variables()["RES_FILE"] = project->variables()["RC_FILE"]; 649 project->variables()["RES_FILE"] = project->variables()["RC_FILE"];
490 project->variables()["RES_FILE"].first().replace(".rc",".o"); 650 project->variables()["RES_FILE"].first().replace(".rc",".o");
491 project->variables()["POST_TARGETDEPS"] += project->variables()["RES_FILE"]; 651 project->variables()["POST_TARGETDEPS"] += project->variables()["RES_FILE"];
652 project->variables()["CLEAN_FILES"] += project->variables()["RES_FILE"];
492 } 653 }
654
493 if ( !project->variables()["RES_FILE"].isEmpty()) 655 if ( !project->variables()["RES_FILE"].isEmpty())
494 project->variables()["QMAKE_LIBS"] += project->variables()["RES_FILE"]; 656 project->variables()["QMAKE_LIBS"] += project->variables()["RES_FILE"];
495 657
496 MakefileGenerator::init(); 658 MakefileGenerator::init();
659
497 if ( !project->variables()["VERSION"].isEmpty()) { 660 if ( !project->variables()["VERSION"].isEmpty()) {
498 QStringList l = QStringList::split('.', project->first("VERSION")); 661 QStringList l = QStringList::split('.', project->first("VERSION"));
499 project->variables()["VER_MAJ"].append(l[0]); 662 project->variables()["VER_MAJ"].append(l[0]);
500 project->variables()["VER_MIN"].append(l[1]); 663 project->variables()["VER_MIN"].append(l[1]);
501 } 664 }
665
502 if(project->isActiveConfig("dll")) { 666 if(project->isActiveConfig("dll")) {
503 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") +"lib" + project->first("TARGET") + ".a"); 667 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") +"lib" + project->first("TARGET") + ".a");
504 } 668 }
669
670 QStringList &quc = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"];
671 for(it = quc.begin(); it != quc.end(); ++it) {
672 QString tmp_out = project->variables()[(*it) + ".output"].first();
673 if(tmp_out.isEmpty())
674 continue;
675 QStringList &tmp = project->variables()[(*it) + ".input"];
676 for(QStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {
677 QStringList &inputs = project->variables()[(*it2)];
678 for(QStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {
679 QFileInfo fi(Option::fixPathToLocalOS((*input)));
680 QString in = Option::fixPathToTargetOS((*input), FALSE),
681 out = tmp_out;
682 out.replace("${QMAKE_FILE_BASE}", fi.baseName());
683 out.replace("${QMAKE_FILE_NAME}", fi.fileName());
684 if(project->variables()[(*it) + ".CONFIG"].findIndex("no_link") == -1)
685 project->variables()["OBJCOMP"] += out;
686 }
687 }
688 }
505} 689}
506 690
507void 691void
@@ -511,7 +695,7 @@ MingwMakefileGenerator::writeSubDirs(QTextStream &t)
511 QTextStream ts (&qs, IO_WriteOnly) ; 695 QTextStream ts (&qs, IO_WriteOnly) ;
512 Win32MakefileGenerator::writeSubDirs( ts ) ; 696 Win32MakefileGenerator::writeSubDirs( ts ) ;
513 QRegExp rx("(\\n\\tcd [^\\n\\t]+)(\\n\\t.+)\\n\\t@cd ..") ; 697 QRegExp rx("(\\n\\tcd [^\\n\\t]+)(\\n\\t.+)\\n\\t@cd ..") ;
514 rx.setMinimal(true); 698 rx.setMinimal(TRUE);
515 int pos = 0 ; 699 int pos = 0 ;
516 while ( -1 != (pos = rx.search( qs, pos))) 700 while ( -1 != (pos = rx.search( qs, pos)))
517 { 701 {
diff --git a/qmake/generators/win32/mingw_make.h b/qmake/generators/win32/mingw_make.h
index c00bf1b..d971e3a 100644
--- a/qmake/generators/win32/mingw_make.h
+++ b/qmake/generators/win32/mingw_make.h
@@ -1,11 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Definition of ________ class.
5** 3**
6** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. 4** Definition of MingwMakefileGenerator class.
7** 5**
8** This file is part of the network module of the Qt GUI Toolkit. 6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
7**
8** This file is part of qmake.
9** 9**
10** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
11** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
@@ -32,6 +32,7 @@
32** not clear to you. 32** not clear to you.
33** 33**
34**********************************************************************/ 34**********************************************************************/
35
35#ifndef __MINGW_MAKE_H__ 36#ifndef __MINGW_MAKE_H__
36#define __MINGW_MAKE_H__ 37#define __MINGW_MAKE_H__
37 38
@@ -46,6 +47,8 @@ class MingwMakefileGenerator : public Win32MakefileGenerator
46 bool writeMakefile(QTextStream &); 47 bool writeMakefile(QTextStream &);
47 void init(); 48 void init();
48 49
50 virtual bool findLibraries();
51
49public: 52public:
50 MingwMakefileGenerator(QMakeProject *p); 53 MingwMakefileGenerator(QMakeProject *p);
51 ~MingwMakefileGenerator(); 54 ~MingwMakefileGenerator();
diff --git a/qmake/generators/win32/msvc_dsp.cpp b/qmake/generators/win32/msvc_dsp.cpp
index 3fa0496..d2abac6 100644
--- a/qmake/generators/win32/msvc_dsp.cpp
+++ b/qmake/generators/win32/msvc_dsp.cpp
@@ -1,13 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Definition of ________ class.
5** 3**
6** Created : 970521 4** Implementation of DspMakefileGenerator class.
7** 5**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. 6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 7**
10** This file is part of the network module of the Qt GUI Toolkit. 8** This file is part of qmake.
11** 9**
12** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
@@ -78,6 +76,8 @@ DspMakefileGenerator::writeDspParts(QTextStream &t)
78 } else { 76 } else {
79 dspfile = project->first("MSVCDSP_TEMPLATE"); 77 dspfile = project->first("MSVCDSP_TEMPLATE");
80 } 78 }
79 if (dspfile.startsWith("\"") && dspfile.endsWith("\""))
80 dspfile = dspfile.mid(1, dspfile.length() - 2);
81 QString dspfile_loc = findTemplate(dspfile); 81 QString dspfile_loc = findTemplate(dspfile);
82 82
83 QFile file(dspfile_loc); 83 QFile file(dspfile_loc);
@@ -87,6 +87,30 @@ DspMakefileGenerator::writeDspParts(QTextStream &t)
87 } 87 }
88 QTextStream dsp(&file); 88 QTextStream dsp(&file);
89 89
90 QString platform = "Win32";
91 if ( !project->variables()["QMAKE_PLATFORM"].isEmpty() )
92 platform = varGlue("QMAKE_PLATFORM", "", " ", "");
93
94 // Setup PCH variables
95 precompH = project->first("PRECOMPILED_HEADER");
96 QString namePCH = QFileInfo(precompH).fileName();
97 usePCH = !precompH.isEmpty() && project->isActiveConfig("precompile_header");
98 if (usePCH) {
99 // Created files
100 QString origTarget = project->first("QMAKE_ORIG_TARGET");
101 origTarget.replace(QRegExp("-"), "_");
102 precompObj = "\"$(IntDir)\\" + origTarget + Option::obj_ext + "\"";
103 precompPch = "\"$(IntDir)\\" + origTarget + ".pch\"";
104 // Add PRECOMPILED_HEADER to HEADERS
105 if (!project->variables()["HEADERS"].contains(precompH))
106 project->variables()["HEADERS"] += precompH;
107 // Add precompile compiler options
108 project->variables()["PRECOMPILED_FLAGS_REL"] = "/Yu\"" + namePCH + "\" /FI\"" + namePCH + "\" ";
109 project->variables()["PRECOMPILED_FLAGS_DEB"] = "/Yu\"" + namePCH + "\" /FI\"" + namePCH + "\" ";
110 // Return to variable pool
111 project->variables()["PRECOMPILED_OBJECT"] = precompObj;
112 project->variables()["PRECOMPILED_PCH"] = precompPch;
113 }
90 int rep; 114 int rep;
91 QString line; 115 QString line;
92 while ( !dsp.eof() ) { 116 while ( !dsp.eof() ) {
@@ -111,7 +135,9 @@ DspMakefileGenerator::writeDspParts(QTextStream &t)
111 for( it = list.begin(); it != list.end(); ++it) { 135 for( it = list.begin(); it != list.end(); ++it) {
112 beginGroupForFile((*it), t); 136 beginGroupForFile((*it), t);
113 t << "# Begin Source File\n\nSOURCE=" << (*it) << endl; 137 t << "# Begin Source File\n\nSOURCE=" << (*it) << endl;
114 if ( project->isActiveConfig("moc") && (*it).endsWith(Option::moc_ext)) { 138 if (usePCH && (*it).endsWith(".c"))
139 t << "# SUBTRACT CPP /FI\"" << namePCH << "\" /Yu\"" << namePCH << "\" /Fp" << endl;
140 if ( project->isActiveConfig("moc") && (*it).endsWith(Option::cpp_moc_ext)) {
115 QString base = (*it); 141 QString base = (*it);
116 base.replace(QRegExp("\\..*$"), "").upper(); 142 base.replace(QRegExp("\\..*$"), "").upper();
117 base.replace(QRegExp("[^a-zA-Z]"), "_"); 143 base.replace(QRegExp("[^a-zA-Z]"), "_");
@@ -124,8 +150,8 @@ DspMakefileGenerator::writeDspParts(QTextStream &t)
124 150
125 t << "USERDEP_" << base << "=\".\\" << findMocSource((*it)) << "\" \"$(QTDIR)\\bin\\moc.exe\"" << endl << endl; 151 t << "USERDEP_" << base << "=\".\\" << findMocSource((*it)) << "\" \"$(QTDIR)\\bin\\moc.exe\"" << endl << endl;
126 152
127 t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build 153 t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Release\"" << build
128 << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" 154 << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Debug\""
129 << build << "!ENDIF " << endl << endl; 155 << build << "!ENDIF " << endl << endl;
130 } 156 }
131 t << "# End Source File" << endl; 157 t << "# End Source File" << endl;
@@ -146,25 +172,77 @@ DspMakefileGenerator::writeDspParts(QTextStream &t)
146 for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { 172 for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
147 // beginGroupForFile((*it), t); 173 // beginGroupForFile((*it), t);
148 t << "# Begin Source File\n\nSOURCE=" << (*it) << endl << endl; 174 t << "# Begin Source File\n\nSOURCE=" << (*it) << endl << endl;
149 if ( project->isActiveConfig("moc") && !findMocDestination((*it)).isEmpty()) { 175 QString compilePCH;
176 QStringList customDependencies;
177 QString createMOC;
178 QString buildCmdsR, buildCmdsD;
179 QString buildCmds = "\nBuildCmds= \\\n";
180 // Create unique baseID
150 QString base = (*it); 181 QString base = (*it);
182 {
151 base.replace(QRegExp("\\..*$"), "").upper(); 183 base.replace(QRegExp("\\..*$"), "").upper();
152 base.replace(QRegExp("[^a-zA-Z]"), "_"); 184 base.replace(QRegExp("[^a-zA-Z]"), "_");
153 185 }
186 if (usePCH && precompH.endsWith(*it)) {
187 QString basicBuildCmd = QString("\tcl.exe /TP /W3 /FD /c /D \"WIN32\" /Yc /Fp\"%1\" /Fo\"%2\" %3 %4 %5 %6 %7 %8 %9 /D \"")
188 .arg(precompPch)
189 .arg(precompObj)
190 .arg(var("MSVCDSP_INCPATH"))
191 .arg(var("MSVCDSP_DEFINES"))
192 .arg(var("MSVCDSP_CXXFLAGS"));
193 buildCmdsR = basicBuildCmd
194 .arg("/D \"NDEBUG\"")
195 .arg(var("QMAKE_CXXFLAGS_RELEASE"))
196 .arg(var("MSVCDSP_MTDEF"))
197 .arg(var("MSVCDSP_RELDEFS"));
198 buildCmdsD = basicBuildCmd
199 .arg("/D \"_DEBUG\" /Od")
200 .arg(var("QMAKE_CXXFLAGS_DEBUG"))
201 .arg(var("MSVCDSP_MTDEFD"))
202 .arg(var("MSVCDSP_DEBUG_OPT"));
203 if (project->first("TEMPLATE") == "vcapp") {// App
204 buildCmdsR += var("MSVCDSP_WINCONDEF");
205 buildCmdsD += var("MSVCDSP_WINCONDEF");
206 } else if (project->isActiveConfig("dll")) {// Dll
207 buildCmdsR += "_WINDOWS\" /D \"_USRDLL";
208 buildCmdsD += "_WINDOWS\" /D \"_USRDLL";
209 } else { // Lib
210 buildCmdsR += "_LIB";
211 buildCmdsD += "_LIB";
212 }
213 buildCmdsR += "\" /Fd\"$(IntDir)\\\\\" " + (*it) + " \\\n";
214 buildCmdsD += "\" /Fd\"$(IntDir)\\\\\" " + (*it) + " \\\n";
215
216 compilePCH = precompPch + " : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n $(BuildCmds)\n\n";
217
218 QStringList &tmp = findDependencies(precompH);
219 if(!tmp.isEmpty()) // Got Deps for PCH
220 customDependencies += tmp;
221 }
222 if (project->isActiveConfig("moc") && !findMocDestination((*it)).isEmpty()) {
154 QString mocpath = var( "QMAKE_MOC" ); 223 QString mocpath = var( "QMAKE_MOC" );
155 mocpath = mocpath.replace( QRegExp( "\\..*$" ), "" ) + " "; 224 mocpath = mocpath.replace( QRegExp( "\\..*$" ), "" ) + " ";
225 buildCmds += "\t" + mocpath + (*it) + " -o " + findMocDestination((*it)) + " \\\n";
226 createMOC = "\"" + findMocDestination((*it)) +"\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n $(BuildCmds)\n\n";
227 customDependencies += "\"$(QTDIR)\\bin\\moc.exe\"";
228 }
229 if (!createMOC.isEmpty() || !compilePCH.isEmpty()) {
230 bool doMOC = !createMOC.isEmpty();
231 bool doPCH = !compilePCH.isEmpty();
232 QString build = "\n\n# Begin Custom Build - "+
233 QString(doMOC?"Moc'ing ":"") +
234 QString((doMOC&&doPCH)?" and ":"") +
235 QString(doPCH?"Creating PCH cpp from ":"") +
236 (*it) + "...\nInputPath=.\\" + (*it) + "\n\n" +
237 buildCmds + "%1\n" +
238 createMOC +
239 compilePCH +
240 "# End Custom Build\n\n";
156 241
157 QString build = "\n\n# Begin Custom Build - Moc'ing " + (*it) + 242 t << "USERDEP_" << base << "=" << valGlue(customDependencies, "\"", "\" \"", "\"") << endl << endl;
158 "...\n" "InputPath=.\\" + (*it) + "\n\n" "\"" + findMocDestination((*it)) + 243 t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Release\"" << build.arg(buildCmdsR)
159 "\"" " : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n" 244 << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Debug\"" << build.arg(buildCmdsD)
160 "\t" + mocpath + (*it) + " -o " + 245 << "!ENDIF " << endl << endl;
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 } 246 }
169 t << "# End Source File" << endl; 247 t << "# End Source File" << endl;
170 } 248 }
@@ -252,7 +330,7 @@ DspMakefileGenerator::writeDspParts(QTextStream &t)
252 for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { 330 for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
253 // beginGroupForFile((*it), t); 331 // beginGroupForFile((*it), t);
254 t << "# Begin Source File\n\nSOURCE=" << (*it) << endl; 332 t << "# Begin Source File\n\nSOURCE=" << (*it) << endl;
255 if ( project->isActiveConfig("moc") && (*it).endsWith(Option::moc_ext)) { 333 if ( project->isActiveConfig("moc") && (*it).endsWith(Option::cpp_moc_ext)) {
256 QString base = (*it); 334 QString base = (*it);
257 base.replace(QRegExp("\\..*$"), "").upper(); 335 base.replace(QRegExp("\\..*$"), "").upper();
258 base.replace(QRegExp("[^a-zA-Z]"), "_"); 336 base.replace(QRegExp("[^a-zA-Z]"), "_");
@@ -265,8 +343,8 @@ DspMakefileGenerator::writeDspParts(QTextStream &t)
265 343
266 t << "USERDEP_" << base << "=\".\\" << findMocSource((*it)) << "\" \"$(QTDIR)\\bin\\moc.exe\"" << endl << endl; 344 t << "USERDEP_" << base << "=\".\\" << findMocSource((*it)) << "\" \"$(QTDIR)\\bin\\moc.exe\"" << endl << endl;
267 345
268 t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build 346 t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Release\"" << build
269 << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" 347 << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Debug\""
270 << build << "!ENDIF " << endl << endl; 348 << build << "!ENDIF " << endl << endl;
271 } 349 }
272 t << "# End Source File" << endl; 350 t << "# End Source File" << endl;
@@ -387,19 +465,20 @@ DspMakefileGenerator::writeDspParts(QTextStream &t)
387 "InputPath=.\\" + base + "\n\n" "BuildCmds= \\\n\t" + uicpath + base + 465 "InputPath=.\\" + base + "\n\n" "BuildCmds= \\\n\t" + uicpath + base +
388 " -o " + uiHeadersDir + fname + ".h \\\n" "\t" + uicpath + base + 466 " -o " + uiHeadersDir + fname + ".h \\\n" "\t" + uicpath + base +
389 " -i " + fname + ".h -o " + uiSourcesDir + fname + ".cpp \\\n" 467 " -i " + fname + ".h -o " + uiSourcesDir + fname + ".cpp \\\n"
390 "\t" + mocpath + uiHeadersDir + fname + ".h -o " + mocFile + "moc_" + fname + ".cpp \\\n"; 468 "\t" + mocpath + " " + uiHeadersDir +
469 fname + ".h -o " + mocFile + Option::h_moc_mod + fname + Option::h_moc_ext + " \\\n";
391 470
392 build.append("\n\"" + uiHeadersDir + fname + ".h\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n" 471 build.append("\n\"" + uiHeadersDir + fname + ".h\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n"
393 "\t$(BuildCmds)\n\n" 472 "\t$(BuildCmds)\n\n"
394 "\"" + uiSourcesDir + fname + ".cpp\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n" 473 "\"" + uiSourcesDir + fname + ".cpp\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n"
395 "\t$(BuildCmds)\n\n" 474 "\t$(BuildCmds)\n\n"
396 "\"" + mocFile + "moc_" + fname + ".cpp\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n" 475 "\"" + mocFile + Option::h_moc_mod + fname + Option::h_moc_ext + "\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n"
397 "\t$(BuildCmds)\n\n"); 476 "\t$(BuildCmds)\n\n");
398 477
399 build.append("# End Custom Build\n\n"); 478 build.append("# End Custom Build\n\n");
400 479
401 t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build 480 t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Release\"" << build
402 << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" << build 481 << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Debug\"" << build
403 << "!ENDIF \n\n" << "# End Source File" << endl; 482 << "!ENDIF \n\n" << "# End Source File" << endl;
404 } 483 }
405 // endGroups(t); 484 // endGroups(t);
@@ -429,8 +508,8 @@ DspMakefileGenerator::writeDspParts(QTextStream &t)
429 "\tdel " + fname + "\\\n" 508 "\tdel " + fname + "\\\n"
430 "\tcopy lex.yy.c " + fname + "\n\n" + 509 "\tcopy lex.yy.c " + fname + "\n\n" +
431 "# End Custom Build\n\n"; 510 "# End Custom Build\n\n";
432 t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build 511 t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Release\"" << build
433 << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" << build 512 << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Debug\"" << build
434 << "!ENDIF \n\n" << build 513 << "!ENDIF \n\n" << build
435 514
436 << "# End Source File" << endl; 515 << "# End Source File" << endl;
@@ -465,8 +544,8 @@ DspMakefileGenerator::writeDspParts(QTextStream &t)
465 "\tmove y.tab.c " + fname + Option::cpp_ext.first() + "\n\n" + 544 "\tmove y.tab.c " + fname + Option::cpp_ext.first() + "\n\n" +
466 "# End Custom Build\n\n"; 545 "# End Custom Build\n\n";
467 546
468 t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build 547 t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Release\"" << build
469 << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" << build 548 << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Debug\"" << build
470 << "!ENDIF \n\n" 549 << "!ENDIF \n\n"
471 << "# End Source File" << endl; 550 << "# End Source File" << endl;
472 } 551 }
@@ -532,6 +611,7 @@ DspMakefileGenerator::init()
532 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_OFF"]; 611 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_OFF"];
533 } 612 }
534 613
614
535 /* this should probably not be here, but I'm using it to wrap the .t files */ 615 /* this should probably not be here, but I'm using it to wrap the .t files */
536 if(project->first("TEMPLATE") == "vcapp" ) 616 if(project->first("TEMPLATE") == "vcapp" )
537 project->variables()["QMAKE_APP_FLAG"].append("1"); 617 project->variables()["QMAKE_APP_FLAG"].append("1");
@@ -548,6 +628,12 @@ DspMakefileGenerator::init()
548 project->variables()["DEFINES"].append("QT_DLL"); 628 project->variables()["DEFINES"].append("QT_DLL");
549 if (project->isActiveConfig("qt_dll")) 629 if (project->isActiveConfig("qt_dll"))
550 if(configs.findIndex("qt") == -1) configs.append("qt"); 630 if(configs.findIndex("qt") == -1) configs.append("qt");
631 if ( project->isActiveConfig("qtopia") ) {
632 if(configs.findIndex("qtopialib") == -1)
633 configs.append("qtopialib");
634 if(configs.findIndex("qtopiainc") == -1)
635 configs.append("qtopiainc");
636 }
551 if ( project->isActiveConfig("qt") ) { 637 if ( project->isActiveConfig("qt") ) {
552 if ( project->isActiveConfig( "plugin" ) ) { 638 if ( project->isActiveConfig( "plugin" ) ) {
553 project->variables()["CONFIG"].append("dll"); 639 project->variables()["CONFIG"].append("dll");
@@ -581,6 +667,14 @@ DspMakefileGenerator::init()
581 project->variables()["MSVCDSP_VERSION"].append( "/VERSION:" + major + "." + minor ); 667 project->variables()["MSVCDSP_VERSION"].append( "/VERSION:" + major + "." + minor );
582 } 668 }
583 669
670 if ( project->isActiveConfig("qtopiainc") )
671 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QTOPIA"];
672 if ( project->isActiveConfig("qtopialib") ) {
673 if(!project->isEmpty("QMAKE_LIBDIR_QTOPIA"))
674 project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QTOPIA"];
675 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QTOPIA"];
676 }
677
584 if ( project->isActiveConfig("qt") ) { 678 if ( project->isActiveConfig("qt") ) {
585 project->variables()["CONFIG"].append("moc"); 679 project->variables()["CONFIG"].append("moc");
586 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"]; 680 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"];
@@ -634,6 +728,8 @@ DspMakefileGenerator::init()
634 } else { 728 } else {
635 if ( !project->first("OBJECTS_DIR").isEmpty() ) 729 if ( !project->first("OBJECTS_DIR").isEmpty() )
636 project->variables()["MSVCDSP_OBJECTSDIRREL"] = project->first("OBJECTS_DIR"); 730 project->variables()["MSVCDSP_OBJECTSDIRREL"] = project->first("OBJECTS_DIR");
731 else
732 project->variables()["MSVCDSP_OBJECTSDIRREL"] = "Release";
637 project->variables()["MSVCDSP_OBJECTSDIRDEB"] = "Debug"; 733 project->variables()["MSVCDSP_OBJECTSDIRDEB"] = "Debug";
638 if ( !project->first("DESTDIR").isEmpty() ) 734 if ( !project->first("DESTDIR").isEmpty() )
639 project->variables()["MSVCDSP_TARGETDIRREL"] = project->first("DESTDIR"); 735 project->variables()["MSVCDSP_TARGETDIRREL"] = project->first("DESTDIR");
@@ -670,6 +766,10 @@ DspMakefileGenerator::init()
670 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT"); 766 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT");
671 } 767 }
672 if ( project->isActiveConfig("dll") ) { 768 if ( project->isActiveConfig("dll") ) {
769 project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE_DLL"];
770 project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE_DLL"];
771 project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE_DLL"];
772 project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS_DLL"];
673 if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { 773 if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) {
674 QString ver_xyz(project->first("VERSION")); 774 QString ver_xyz(project->first("VERSION"));
675 ver_xyz.replace(".", ""); 775 ver_xyz.replace(".", "");
@@ -678,12 +778,33 @@ DspMakefileGenerator::init()
678 project->variables()["TARGET_EXT"].append(".dll"); 778 project->variables()["TARGET_EXT"].append(".dll");
679 } 779 }
680 } else { 780 } else {
781 project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE"];
782 project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE"];
783 project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE"];
784 project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS"];
681 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) 785 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() )
682 project->variables()["TARGET_EXT"].append(".exe"); 786 project->variables()["TARGET_EXT"].append(".exe");
683 else 787 else
684 project->variables()["TARGET_EXT"].append(".lib"); 788 project->variables()["TARGET_EXT"].append(".lib");
685 } 789 }
686 790
791 if ( project->isActiveConfig("windows") ) {
792 if ( project->isActiveConfig("console") ) {
793 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
794 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
795 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
796 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
797 } else {
798 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"];
799 }
800 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"];
801 } else {
802 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
803 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
804 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
805 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
806 }
807
687 project->variables()["MSVCDSP_VER"] = "6.00"; 808 project->variables()["MSVCDSP_VER"] = "6.00";
688 project->variables()["MSVCDSP_DEBUG_OPT"] = "/GZ /ZI"; 809 project->variables()["MSVCDSP_DEBUG_OPT"] = "/GZ /ZI";
689 810
@@ -732,12 +853,10 @@ DspMakefileGenerator::init()
732 project->variables()["MSVCDSP_CONSOLE"].append("Console"); 853 project->variables()["MSVCDSP_CONSOLE"].append("Console");
733 project->variables()["MSVCDSP_WINCONDEF"].append("_CONSOLE"); 854 project->variables()["MSVCDSP_WINCONDEF"].append("_CONSOLE");
734 project->variables()["MSVCDSP_DSPTYPE"].append("0x0103"); 855 project->variables()["MSVCDSP_DSPTYPE"].append("0x0103");
735 project->variables()["MSVCDSP_SUBSYSTEM"].append("console");
736 } else { 856 } else {
737 project->variables()["MSVCDSP_CONSOLE"].clear(); 857 project->variables()["MSVCDSP_CONSOLE"].clear();
738 project->variables()["MSVCDSP_WINCONDEF"].append("_WINDOWS"); 858 project->variables()["MSVCDSP_WINCONDEF"].append("_WINDOWS");
739 project->variables()["MSVCDSP_DSPTYPE"].append("0x0101"); 859 project->variables()["MSVCDSP_DSPTYPE"].append("0x0101");
740 project->variables()["MSVCDSP_SUBSYSTEM"].append("windows");
741 } 860 }
742 } else { 861 } else {
743 if ( project->isActiveConfig("dll") ) { 862 if ( project->isActiveConfig("dll") ) {
@@ -749,6 +868,19 @@ DspMakefileGenerator::init()
749 868
750 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"]; 869 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"];
751 870
871 processPrlFiles();
872
873 // Update -lname to name.lib,
874 QStringList &libs2 = project->variables()["QMAKE_LIBS"];
875 for ( QStringList::Iterator libit2 = libs2.begin(); libit2 != libs2.end(); ++libit2 ) {
876 if ( (*libit2).startsWith( "-l" ) ) {
877 (*libit2) = (*libit2).mid( 2 ) + ".lib";
878 } else if ( (*libit2).startsWith( "-L" ) ) {
879 project->variables()["QMAKE_LIBDIR"] += (*libit2).mid(2);
880 libit2 = libs2.remove( libit2 );
881 }
882 }
883
752 project->variables()["MSVCDSP_LFLAGS" ] += project->variables()["QMAKE_LFLAGS"]; 884 project->variables()["MSVCDSP_LFLAGS" ] += project->variables()["QMAKE_LFLAGS"];
753 if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() ) 885 if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() )
754 project->variables()["MSVCDSP_LFLAGS" ].append(varGlue("QMAKE_LIBDIR","/LIBPATH:\"","\" /LIBPATH:\"","\"")); 886 project->variables()["MSVCDSP_LFLAGS" ].append(varGlue("QMAKE_LIBDIR","/LIBPATH:\"","\" /LIBPATH:\"","\""));
@@ -756,7 +888,9 @@ DspMakefileGenerator::init()
756 project->variables()["MSVCDSP_DEFINES"].append(varGlue("DEFINES","/D ","" " /D ","")); 888 project->variables()["MSVCDSP_DEFINES"].append(varGlue("DEFINES","/D ","" " /D ",""));
757 project->variables()["MSVCDSP_DEFINES"].append(varGlue("PRL_EXPORT_DEFINES","/D ","" " /D ","")); 889 project->variables()["MSVCDSP_DEFINES"].append(varGlue("PRL_EXPORT_DEFINES","/D ","" " /D ",""));
758 890
759 processPrlFiles(); 891 if (!project->variables()["RES_FILE"].isEmpty())
892 project->variables()["QMAKE_LIBS"] += project->variables()["RES_FILE"];
893
760 QStringList &libs = project->variables()["QMAKE_LIBS"]; 894 QStringList &libs = project->variables()["QMAKE_LIBS"];
761 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) { 895 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) {
762 QString lib = (*libit); 896 QString lib = (*libit);
@@ -768,6 +902,8 @@ DspMakefileGenerator::init()
768 for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) { 902 for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) {
769 QString inc = (*incit); 903 QString inc = (*incit);
770 inc.replace("\"", ""); 904 inc.replace("\"", "");
905 if(inc.endsWith("\\")) // Remove trailing \'s from paths
906 inc.truncate(inc.length()-1);
771 project->variables()["MSVCDSP_INCPATH"].append("/I \"" + inc + "\""); 907 project->variables()["MSVCDSP_INCPATH"].append("/I \"" + inc + "\"");
772 } 908 }
773 909
@@ -820,15 +956,12 @@ DspMakefileGenerator::init()
820 QString version = project->variables()["VERSION"].first(); 956 QString version = project->variables()["VERSION"].first();
821 if ( version.isEmpty() ) 957 if ( version.isEmpty() )
822 version = "1.0"; 958 version = "1.0";
823 959 project->variables()["MSVCDSP_IDLSOURCES"].append( var("OBJECTS_DIR") + targetfilename + ".idl" );
824 project->variables()["MSVCDSP_IDLSOURCES"].append( "tmp\\" + targetfilename + ".idl" );
825 project->variables()["MSVCDSP_IDLSOURCES"].append( "tmp\\" + targetfilename + ".tlb" );
826 project->variables()["MSVCDSP_IDLSOURCES"].append( "tmp\\" + targetfilename + ".midl" );
827 if ( project->isActiveConfig( "dll" ) ) { 960 if ( project->isActiveConfig( "dll" ) ) {
828 activeQtStepPreCopyDll += 961 activeQtStepPreCopyDll +=
829 "\t" + idc + " %1 -idl tmp\\" + targetfilename + ".idl -version " + version + 962 "\t" + idc + " %1 -idl " + var("OBJECTS_DIR") + targetfilename + ".idl -version " + version +
830 "\t" + idl + " tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl" 963 "\t" + idl + " /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb" +
831 "\t" + idc + " %1 /tlb tmp\\" + targetfilename + ".tlb"; 964 "\t" + idc + " %2 /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb";
832 activeQtStepPostCopyDll += 965 activeQtStepPostCopyDll +=
833 "\t" + idc + " %1 /regserver\n"; 966 "\t" + idc + " %1 /regserver\n";
834 967
@@ -841,9 +974,9 @@ DspMakefileGenerator::init()
841 activeQtStepPostCopyDllDebug = activeQtStepPostCopyDll.arg(executable); 974 activeQtStepPostCopyDllDebug = activeQtStepPostCopyDll.arg(executable);
842 } else { 975 } else {
843 activeQtStepPreCopyDll += 976 activeQtStepPreCopyDll +=
844 "\t%1 -dumpidl tmp\\" + targetfilename + ".idl -version " + version + 977 "\t%1 -dumpidl " + var("OBJECTS_DIR") + targetfilename + ".idl -version " + version +
845 "\t" + idl + " tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl" 978 "\t" + idl + " /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb" +
846 "\t" + idc + " %1 /tlb tmp\\" + targetfilename + ".tlb"; 979 "\t" + idc + " %2 /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb";
847 activeQtStepPostCopyDll += 980 activeQtStepPostCopyDll +=
848 "\t%1 -regserver\n"; 981 "\t%1 -regserver\n";
849 QString executable = project->variables()["MSVCDSP_TARGETDIRREL"].first() + "\\" + targetfilename + ".exe"; 982 QString executable = project->variables()["MSVCDSP_TARGETDIRREL"].first() + "\\" + targetfilename + ".exe";
@@ -919,7 +1052,6 @@ DspMakefileGenerator::beginGroupForFile(QString file, QTextStream &t,
919{ 1052{
920 if(project->isActiveConfig("flat")) 1053 if(project->isActiveConfig("flat"))
921 return; 1054 return;
922
923 fileFixify(file, QDir::currentDirPath(), QDir::currentDirPath(), TRUE); 1055 fileFixify(file, QDir::currentDirPath(), QDir::currentDirPath(), TRUE);
924 file = file.section(Option::dir_sep, 0, -2); 1056 file = file.section(Option::dir_sep, 0, -2);
925 if(file.right(Option::dir_sep.length()) != Option::dir_sep) 1057 if(file.right(Option::dir_sep.length()) != Option::dir_sep)
@@ -931,19 +1063,23 @@ DspMakefileGenerator::beginGroupForFile(QString file, QTextStream &t,
931 endGroups(t); 1063 endGroups(t);
932 return; 1064 return;
933 } 1065 }
934 if(file.startsWith(currentGroup)) 1066
935 file = file.mid(currentGroup.length()); 1067 QString tempFile = file;
1068 if(tempFile.startsWith(currentGroup))
1069 tempFile = tempFile.mid(currentGroup.length());
936 int dirSep = currentGroup.findRev( Option::dir_sep ); 1070 int dirSep = currentGroup.findRev( Option::dir_sep );
937 while( !file.startsWith( currentGroup ) && dirSep != -1 ) { 1071
1072 while( !tempFile.startsWith( currentGroup ) && dirSep != -1 ) {
938 currentGroup.truncate( dirSep ); 1073 currentGroup.truncate( dirSep );
939 dirSep = currentGroup.findRev( Option::dir_sep ); 1074 dirSep = currentGroup.findRev( Option::dir_sep );
940 if ( !file.startsWith( currentGroup ) && dirSep != -1 ) 1075 if ( !tempFile.startsWith( currentGroup ) && dirSep != -1 )
941 t << "\n# End Group\n"; 1076 t << "\n# End Group\n";
942 } 1077 }
943 if ( !file.startsWith( currentGroup ) ) { 1078 if ( !file.startsWith( currentGroup ) ) {
944 t << "\n# End Group\n"; 1079 t << "\n# End Group\n";
945 currentGroup = ""; 1080 currentGroup = "";
946 } 1081 }
1082
947 QStringList dirs = QStringList::split(Option::dir_sep, file.right( file.length() - currentGroup.length() ) ); 1083 QStringList dirs = QStringList::split(Option::dir_sep, file.right( file.length() - currentGroup.length() ) );
948 for(QStringList::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) { 1084 for(QStringList::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) {
949 t << "# Begin Group \"" << (*dir_it) << "\"\n" 1085 t << "# Begin Group \"" << (*dir_it) << "\"\n"
@@ -973,6 +1109,8 @@ DspMakefileGenerator::openOutput(QFile &file) const
973{ 1109{
974 QString outdir; 1110 QString outdir;
975 if(!file.name().isEmpty()) { 1111 if(!file.name().isEmpty()) {
1112 if(QDir::isRelativePath(file.name()))
1113 file.setName(Option::output_dir + file.name()); //pwd when qmake was run
976 QFileInfo fi(file); 1114 QFileInfo fi(file);
977 if(fi.isDir()) 1115 if(fi.isDir())
978 outdir = file.name() + QDir::separator(); 1116 outdir = file.name() + QDir::separator();
diff --git a/qmake/generators/win32/msvc_dsp.h b/qmake/generators/win32/msvc_dsp.h
index 3a7d18e..0e86539 100644
--- a/qmake/generators/win32/msvc_dsp.h
+++ b/qmake/generators/win32/msvc_dsp.h
@@ -1,13 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Definition of ________ class.
5** 3**
6** Created : 970521 4** Definition of DspMakefileGenerator class.
7** 5**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. 6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 7**
10** This file is part of the network module of the Qt GUI Toolkit. 8** This file is part of qmake.
11** 9**
12** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
@@ -34,6 +32,7 @@
34** not clear to you. 32** not clear to you.
35** 33**
36**********************************************************************/ 34**********************************************************************/
35
37#ifndef __MSVC_DSP_H__ 36#ifndef __MSVC_DSP_H__
38#define __MSVC_DSP_H__ 37#define __MSVC_DSP_H__
39 38
@@ -62,6 +61,10 @@ public:
62protected: 61protected:
63 virtual void processPrlVariable(const QString &, const QStringList &); 62 virtual void processPrlVariable(const QString &, const QStringList &);
64 virtual bool findLibraries(); 63 virtual bool findLibraries();
64
65 QString precompH,
66 precompObj, precompPch;
67 bool usePCH;
65}; 68};
66 69
67inline DspMakefileGenerator::~DspMakefileGenerator() 70inline DspMakefileGenerator::~DspMakefileGenerator()
diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp
index ecef34d..528cb19 100644
--- a/qmake/generators/win32/msvc_nmake.cpp
+++ b/qmake/generators/win32/msvc_nmake.cpp
@@ -1,13 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Definition of ________ class.
5** 3**
6** Created : 970521 4** Implementation of NmakeMakefileGenerator class.
7** 5**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. 6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 7**
10** This file is part of the network module of the Qt GUI Toolkit. 8** This file is part of qmake.
11** 9**
12** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
@@ -43,7 +41,6 @@
43#include <stdlib.h> 41#include <stdlib.h>
44#include <time.h> 42#include <time.h>
45 43
46
47NmakeMakefileGenerator::NmakeMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE) 44NmakeMakefileGenerator::NmakeMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE)
48{ 45{
49 46
@@ -54,6 +51,11 @@ NmakeMakefileGenerator::writeMakefile(QTextStream &t)
54{ 51{
55 writeHeader(t); 52 writeHeader(t);
56 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) { 53 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {
54 { //write the extra unix targets..
55 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"];
56 for(QStringList::ConstIterator it = qut.begin(); it != qut.end(); ++it)
57 t << *it << " ";
58 }
57 t << "all clean:" << "\n\t" 59 t << "all clean:" << "\n\t"
58 << "@echo \"Some of the required modules (" 60 << "@echo \"Some of the required modules ("
59 << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t" 61 << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t"
@@ -74,6 +76,24 @@ NmakeMakefileGenerator::writeMakefile(QTextStream &t)
74 return FALSE; 76 return FALSE;
75} 77}
76 78
79QStringList
80&NmakeMakefileGenerator::findDependencies(const QString &file)
81{
82 QStringList &aList = MakefileGenerator::findDependencies(file);
83 // Note: The QMAKE_IMAGE_COLLECTION file have all images
84 // as dependency, so don't add precompiled header then
85 if (file == project->first("QMAKE_IMAGE_COLLECTION"))
86 return aList;
87 for(QStringList::Iterator it = Option::cpp_ext.begin(); it != Option::cpp_ext.end(); ++it) {
88 if(file.endsWith(*it)) {
89 if(!aList.contains(precompH))
90 aList += precompH;
91 break;
92 }
93 }
94 return aList;
95}
96
77void 97void
78NmakeMakefileGenerator::writeNmakeParts(QTextStream &t) 98NmakeMakefileGenerator::writeNmakeParts(QTextStream &t)
79{ 99{
@@ -95,8 +115,8 @@ NmakeMakefileGenerator::writeNmakeParts(QTextStream &t)
95 QStringList &incs = project->variables()["INCLUDEPATH"]; 115 QStringList &incs = project->variables()["INCLUDEPATH"];
96 for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) { 116 for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) {
97 QString inc = (*incit); 117 QString inc = (*incit);
98 inc.replace(QRegExp("\\\\$"), "\\\\"); 118 if (inc.endsWith("\\"))
99 inc.replace("\"", ""); 119 inc.truncate(inc.length()-1);
100 t << " -I\"" << inc << "\""; 120 t << " -I\"" << inc << "\"";
101 } 121 }
102 t << " -I\"" << specdir() << "\"" 122 t << " -I\"" << specdir() << "\""
@@ -111,8 +131,8 @@ NmakeMakefileGenerator::writeNmakeParts(QTextStream &t)
111 QStringList &libs = project->variables()["QMAKE_LIBS"]; 131 QStringList &libs = project->variables()["QMAKE_LIBS"];
112 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) { 132 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) {
113 QString lib = (*libit); 133 QString lib = (*libit);
114 lib.replace(QRegExp("\\\\$"), "\\\\"); 134 if (lib.endsWith("\\"))
115 lib.replace(QRegExp("\""), ""); 135 lib.truncate(lib.length()-1);
116 t << " \"" << lib << "\""; 136 t << " \"" << lib << "\"";
117 } 137 }
118 t << endl; 138 t << endl;
@@ -138,6 +158,8 @@ NmakeMakefileGenerator::writeNmakeParts(QTextStream &t)
138 t << "MOVE = " << var("QMAKE_MOVE") << endl; 158 t << "MOVE = " << var("QMAKE_MOVE") << endl;
139 t << "CHK_DIR_EXISTS =" << var("QMAKE_CHK_DIR_EXISTS") << endl; 159 t << "CHK_DIR_EXISTS =" << var("QMAKE_CHK_DIR_EXISTS") << endl;
140 t << "MKDIR =" << var("QMAKE_MKDIR") << endl; 160 t << "MKDIR =" << var("QMAKE_MKDIR") << endl;
161 t << "INSTALL_FILE= " << var("QMAKE_INSTALL_FILE") << endl;
162 t << "INSTALL_DIR = " << var("QMAKE_INSTALL_DIR") << endl;
141 t << endl; 163 t << endl;
142 164
143 t << "####### Files" << endl << endl; 165 t << "####### Files" << endl << endl;
@@ -149,6 +171,23 @@ NmakeMakefileGenerator::writeNmakeParts(QTextStream &t)
149 t << "UICIMPLS =" << varList("UICIMPLS") << endl; 171 t << "UICIMPLS =" << varList("UICIMPLS") << endl;
150 t << "SRCMOC =" << varList("SRCMOC") << endl; 172 t << "SRCMOC =" << varList("SRCMOC") << endl;
151 t << "OBJMOC =" << varList("OBJMOC") << endl; 173 t << "OBJMOC =" << varList("OBJMOC") << endl;
174
175 QString extraCompilerDeps;
176 if(!project->isEmpty("QMAKE_EXTRA_WIN_COMPILERS")) {
177 t << "OBJCOMP = " << varList("OBJCOMP") << endl;
178 extraCompilerDeps += " $(OBJCOMP) ";
179
180 QStringList &comps = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"];
181 for(QStringList::Iterator compit = comps.begin(); compit != comps.end(); ++compit) {
182 QStringList &vars = project->variables()[(*compit) + ".variables"];
183 for(QStringList::Iterator varit = vars.begin(); varit != vars.end(); ++varit) {
184 QStringList vals = project->variables()[(*varit)];
185 if(!vals.isEmpty())
186 t << "QMAKE_COMP_" << (*varit) << " = " << valList(vals) << endl;
187 }
188 }
189 }
190
152 t << "DIST =" << varList("DISTFILES") << endl; 191 t << "DIST =" << varList("DISTFILES") << endl;
153 t << "TARGET ="; 192 t << "TARGET =";
154 if( !project->variables()[ "DESTDIR" ].isEmpty() ) 193 if( !project->variables()[ "DESTDIR" ].isEmpty() )
@@ -164,6 +203,7 @@ NmakeMakefileGenerator::writeNmakeParts(QTextStream &t)
164 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) 203 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
165 t << " " << (*cppit); 204 t << " " << (*cppit);
166 t << endl << endl; 205 t << endl << endl;
206
167 if(!project->isActiveConfig("no_batch")) { 207 if(!project->isActiveConfig("no_batch")) {
168 // Batchmode doesn't use the non implicit rules QMAKE_RUN_CXX & QMAKE_RUN_CC 208 // Batchmode doesn't use the non implicit rules QMAKE_RUN_CXX & QMAKE_RUN_CC
169 project->variables().remove("QMAKE_RUN_CXX"); 209 project->variables().remove("QMAKE_RUN_CXX");
@@ -171,12 +211,14 @@ NmakeMakefileGenerator::writeNmakeParts(QTextStream &t)
171 211
172 QDict<void> source_directories; 212 QDict<void> source_directories;
173 source_directories.insert(".", (void*)1); 213 source_directories.insert(".", (void*)1);
174 if(!project->isEmpty("MOC_DIR")) 214 QString directories[] = { QString("MOC_DIR"), QString("UI_SOURCES_DIR"), QString("UI_DIR"), QString::null };
175 source_directories.insert(project->first("MOC_DIR"), (void*)1); 215 for(int y = 0; !directories[y].isNull(); y++) {
176 if(!project->isEmpty("UI_SOURCES_DIR")) 216 QString dirTemp = project->first(directories[y]);
177 source_directories.insert(project->first("UI_SOURCES_DIR"), (void*)1); 217 if (dirTemp.endsWith("\\"))
178 else if(!project->isEmpty("UI_DIR")) 218 dirTemp.truncate(dirTemp.length()-1);
179 source_directories.insert(project->first("UI_DIR"), (void*)1); 219 if(!dirTemp.isEmpty())
220 source_directories.insert(dirTemp, (void*)1);
221 }
180 QString srcs[] = { QString("SOURCES"), QString("UICIMPLS"), QString("SRCMOC"), QString::null }; 222 QString srcs[] = { QString("SOURCES"), QString("UICIMPLS"), QString("SRCMOC"), QString::null };
181 for(int x = 0; !srcs[x].isNull(); x++) { 223 for(int x = 0; !srcs[x].isNull(); x++) {
182 QStringList &l = project->variables()[srcs[x]]; 224 QStringList &l = project->variables()[srcs[x]];
@@ -206,9 +248,9 @@ NmakeMakefileGenerator::writeNmakeParts(QTextStream &t)
206 } 248 }
207 249
208 t << "####### Build rules" << endl << endl; 250 t << "####### Build rules" << endl << endl;
209 t << "all: " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" << endl << endl; 251 t << "all: " << fileFixify(Option::output.name()) << " " << varGlue("ALL_DEPS"," "," "," ") << "$(TARGET)" << endl << endl;
210 t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) " 252 t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) "
211 << var("POST_TARGETDEPS"); 253 << extraCompilerDeps << var("POST_TARGETDEPS");
212 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) { 254 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
213 t << "\n\t" << "$(LINK) $(LFLAGS) /OUT:$(TARGET) @<< " << "\n\t " 255 t << "\n\t" << "$(LINK) $(LFLAGS) /OUT:$(TARGET) @<< " << "\n\t "
214 << "$(OBJECTS) $(OBJMOC) $(LIBS)"; 256 << "$(OBJECTS) $(OBJMOC) $(LIBS)";
@@ -216,13 +258,14 @@ NmakeMakefileGenerator::writeNmakeParts(QTextStream &t)
216 t << "\n\t" << "$(LIB) /OUT:$(TARGET) @<<" << "\n\t " 258 t << "\n\t" << "$(LIB) /OUT:$(TARGET) @<<" << "\n\t "
217 << "$(OBJECTS) $(OBJMOC)"; 259 << "$(OBJECTS) $(OBJMOC)";
218 } 260 }
261 t << extraCompilerDeps;
219 t << endl << "<<" << endl; 262 t << endl << "<<" << endl;
220 if ( !project->variables()["QMAKE_POST_LINK"].isEmpty() ) 263 if ( !project->variables()["QMAKE_POST_LINK"].isEmpty() )
221 t << "\t" << var( "QMAKE_POST_LINK" ) << endl; 264 t << "\t" << var( "QMAKE_POST_LINK" ) << endl;
222 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) { 265 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) {
223 QStringList dlldirs = project->variables()["DLLDESTDIR"]; 266 QStringList dlldirs = project->variables()["DLLDESTDIR"];
224 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) { 267 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) {
225 t << "\n\t" << "-copy $(TARGET) " << *dlldir; 268 t << "\n\t" << "-$(COPY_FILE) \"$(TARGET)\" " << *dlldir;
226 } 269 }
227 } 270 }
228 QString targetfilename = project->variables()["TARGET"].first(); 271 QString targetfilename = project->variables()["TARGET"].first();
@@ -232,14 +275,14 @@ NmakeMakefileGenerator::writeNmakeParts(QTextStream &t)
232 version = "1.0"; 275 version = "1.0";
233 276
234 if ( project->isActiveConfig("dll")) { 277 if ( project->isActiveConfig("dll")) {
235 t << "\n\t" << ("-$(IDC) $(TARGET) /idl tmp\\" + targetfilename + ".idl -version " + version); 278 t << "\n\t" << ("-$(IDC) $(TARGET) /idl " + var("OBJECTS_DIR") + targetfilename + ".idl -version " + version);
236 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl"); 279 t << "\n\t" << ("-$(IDL) /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
237 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb"); 280 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
238 t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" ); 281 t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" );
239 } else { 282 } else {
240 t << "\n\t" << ("-$(TARGET) -dumpidl tmp\\" + targetfilename + ".idl -version " + version); 283 t << "\n\t" << ("-$(TARGET) -dumpidl " + var("OBJECTS_DIR") + targetfilename + ".idl -version " + version);
241 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl"); 284 t << "\n\t" << ("-$(IDL) /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
242 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb"); 285 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
243 t << "\n\t" << "-$(TARGET) -regserver"; 286 t << "\n\t" << "-$(TARGET) -regserver";
244 } 287 }
245 } 288 }
@@ -250,33 +293,53 @@ NmakeMakefileGenerator::writeNmakeParts(QTextStream &t)
250 << var("QMAKE_RC") << " " << var("RC_FILE") << endl << endl; 293 << var("QMAKE_RC") << " " << var("RC_FILE") << endl << endl;
251 } 294 }
252 295
253 t << "mocables: $(SRCMOC)" << endl << endl; 296 t << "mocables: $(SRCMOC)" << endl
297 << "uicables: $(UICIMPLS) $(UICDECLS)" << endl << endl;
254 298
255 writeMakeQmake(t); 299 writeMakeQmake(t);
256 300
301 QStringList dist_files = Option::mkfile::project_files;
302 if(!project->isEmpty("QMAKE_INTERNAL_INCLUDED_FILES"))
303 dist_files += project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"];
304 if(!project->isEmpty("TRANSLATIONS"))
305 dist_files << var("TRANSLATIONS");
306 if(!project->isEmpty("FORMS")) {
307 QStringList &forms = project->variables()["FORMS"];
308 for(QStringList::Iterator formit = forms.begin(); formit != forms.end(); ++formit) {
309 QString ui_h = fileFixify((*formit) + Option::h_ext.first());
310 if(QFile::exists(ui_h) )
311 dist_files << ui_h;
312 }
313 }
257 t << "dist:" << "\n\t" 314 t << "dist:" << "\n\t"
258 << "$(ZIP) " << var("PROJECT") << ".zip " 315 << "$(ZIP) " << var("QMAKE_ORIG_TARGET") << ".zip " << "$(SOURCES) $(HEADERS) $(DIST) $(FORMS) "
259 << var("PROJECT") << ".pro $(SOURCES) $(HEADERS) $(DIST) $(FORMS)" << endl << endl; 316 << dist_files.join(" ") << " " << var("TRANSLATIONS") << " " << var("IMAGES") << endl << endl;
260 317
261 t << "clean:" 318 t << "uiclean:"
262 << varGlue("OBJECTS","\n\t-del ","\n\t-del ","") 319 << varGlue("UICDECLS" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")
263 << varGlue("SRCMOC" ,"\n\t-del ","\n\t-del ","") 320 << varGlue("UICIMPLS" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","") << endl;
264 << varGlue("OBJMOC" ,"\n\t-del ","\n\t-del ","")
265 << varGlue("UICDECLS" ,"\n\t-del ","\n\t-del ","")
266 << varGlue("UICIMPLS" ,"\n\t-del ","\n\t-del ","")
267 << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ","")
268 << varGlue("CLEAN_FILES","\n\t-del ","\n\t-del ","");
269 321
322 t << "mocclean:"
323 << varGlue("SRCMOC" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")
324 << varGlue("OBJMOC" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","") << endl;
325
326 t << "clean: uiclean mocclean"
327 << varGlue("OBJECTS","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")
328 << varGlue("QMAKE_CLEAN","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","\n")
329 << varGlue("CLEAN_FILES","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","\n");
270 if ( project->isActiveConfig("activeqt")) { 330 if ( project->isActiveConfig("activeqt")) {
271 t << ("\n\t-del tmp\\" + targetfilename + ".*"); 331 t << ("\n\t-$(DEL_FILE) " + var("OBJECTS_DIR") + targetfilename + ".idl");
272 t << "\n\t-del tmp\\dump.*"; 332 t << ("\n\t-$(DEL_FILE) " + var("OBJECTS_DIR") + targetfilename + ".tlb");
273 } 333 }
274 if(!project->isEmpty("IMAGES")) 334 if(!project->isEmpty("IMAGES"))
275 t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-del ", "\n\t-del ", ""); 335 t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-$(DEL_FILE) ", "\n\t-$(DEL_FILE) ", "");
336 t << endl;
337
338 // user defined targets
276 339
277 // blasted user defined targets 340 QStringList::Iterator it;
278 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"]; 341 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"];
279 for(QStringList::Iterator it = qut.begin(); it != qut.end(); ++it) { 342 for(it = qut.begin(); it != qut.end(); ++it) {
280 QString targ = var((*it) + ".target"), 343 QString targ = var((*it) + ".target"),
281 cmd = var((*it) + ".commands"), deps; 344 cmd = var((*it) + ".commands"), deps;
282 if(targ.isEmpty()) 345 if(targ.isEmpty())
@@ -288,17 +351,105 @@ NmakeMakefileGenerator::writeNmakeParts(QTextStream &t)
288 dep = (*dep_it); 351 dep = (*dep_it);
289 deps += " " + dep; 352 deps += " " + dep;
290 } 353 }
354 if(!project->variables()["QMAKE_NOFORCE"].isEmpty() &&
355 project->variables()[(*it) + ".CONFIG"].findIndex("phony") != -1)
356 deps += QString(" ") + "FORCE";
291 t << "\n\n" << targ << ":" << deps << "\n\t" 357 t << "\n\n" << targ << ":" << deps << "\n\t"
292 << cmd; 358 << cmd;
293 } 359 }
294
295 t << endl << endl; 360 t << endl << endl;
296 361
362 QStringList &quc = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"];
363 for(it = quc.begin(); it != quc.end(); ++it) {
364 QString tmp_out = project->variables()[(*it) + ".output"].first();
365 QString tmp_cmd = project->variables()[(*it) + ".commands"].join(" ");
366 QString tmp_dep = project->variables()[(*it) + ".depends"].join(" ");
367 QStringList &vars = project->variables()[(*it) + ".variables"];
368 if(tmp_out.isEmpty() || tmp_cmd.isEmpty())
369 continue;
370 QStringList &tmp = project->variables()[(*it) + ".input"];
371 for(QStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {
372 QStringList &inputs = project->variables()[(*it2)];
373 for(QStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {
374 QFileInfo fi(Option::fixPathToLocalOS((*input)));
375 QString in = Option::fixPathToTargetOS((*input), FALSE),
376 out = tmp_out, cmd = tmp_cmd, deps;
377 out.replace("${QMAKE_FILE_BASE}", fi.baseName());
378 out.replace("${QMAKE_FILE_NAME}", fi.fileName());
379 cmd.replace("${QMAKE_FILE_BASE}", fi.baseName());
380 cmd.replace("${QMAKE_FILE_OUT}", out);
381 cmd.replace("${QMAKE_FILE_NAME}", fi.fileName());
382 for(QStringList::Iterator it3 = vars.begin(); it3 != vars.end(); ++it3)
383 cmd.replace("$(" + (*it3) + ")", "$(QMAKE_COMP_" + (*it3)+")");
384 if(!tmp_dep.isEmpty()) {
385 char buff[256];
386 QString dep_cmd = tmp_dep;
387 dep_cmd.replace("${QMAKE_FILE_NAME}", fi.fileName());
388 if(FILE *proc = QT_POPEN(dep_cmd.latin1(), "r")) {
389 while(!feof(proc)) {
390 int read_in = int(fread(buff, 1, 255, proc));
391 if(!read_in)
392 break;
393 int l = 0;
394 for(int i = 0; i < read_in; i++) {
395 if(buff[i] == '\n' || buff[i] == ' ') {
396 deps += " " + QCString(buff+l, (i - l) + 1);
397 l = i;
398 }
399 }
400 }
401 fclose(proc);
402 }
403 }
404 t << out << ": " << in << deps << "\n\t"
405 << cmd << endl << endl;
406 }
407 }
408 }
409 t << endl;
410
411 if(project->variables()["QMAKE_NOFORCE"].isEmpty())
412 t << "FORCE:" << endl << endl;
413
297 t << "distclean: clean" 414 t << "distclean: clean"
298 << "\n\t-del $(TARGET)" 415 << "\n\t-$(DEL_FILE) $(TARGET)"
299 << endl << endl; 416 << endl << endl;
417
418 // precompiled header
419 if(usePCH) {
420 QString precompRule = QString("-c -Yc -Fp%1 -Fo%2").arg(precompPch).arg(precompObj);
421 t << precompObj << ": " << precompH << " " << findDependencies(precompH).join(" \\\n\t\t")
422 << "\n\t" << "$(CXX) " + precompRule +" $(CXXFLAGS) $(INCPATH) -TP " << precompH << endl << endl;
423 }
300} 424}
301 425
426QString
427NmakeMakefileGenerator::var(const QString &value)
428{
429 if (usePCH) {
430 if ((value == "QMAKE_RUN_CXX_IMP_BATCH"
431 || value == "QMAKE_RUN_CXX_IMP"
432 || value == "QMAKE_RUN_CXX")) {
433 QFileInfo precompHInfo(precompH);
434 QString precompRule = QString("-c -FI%1 -Yu%2 -Fp%3")
435 .arg(precompHInfo.fileName())
436 .arg(precompHInfo.fileName())
437 .arg(precompPch);
438 QString p = MakefileGenerator::var(value);
439 p.replace("-c", precompRule);
440 // Cannot use -Gm with -FI & -Yu, as this gives an
441 // internal compiler error, on the newer compilers
442 p.remove("-Gm");
443 return p;
444 } else if (value == "QMAKE_CXXFLAGS") {
445 // Remove internal compiler error option
446 return MakefileGenerator::var(value).remove("-Gm");
447 }
448 }
449
450 // Normal val
451 return MakefileGenerator::var(value);
452}
302 453
303void 454void
304NmakeMakefileGenerator::init() 455NmakeMakefileGenerator::init()
@@ -321,6 +472,11 @@ NmakeMakefileGenerator::init()
321 return; 472 return;
322 } 473 }
323 474
475 if(project->isEmpty("QMAKE_INSTALL_FILE"))
476 project->variables()["QMAKE_INSTALL_FILE"].append("$(COPY_FILE)");
477 if(project->isEmpty("QMAKE_INSTALL_DIR"))
478 project->variables()["QMAKE_INSTALL_DIR"].append("$(COPY_DIR)");
479
324 bool is_qt = (project->first("TARGET") == "qt"QTDLL_POSTFIX || project->first("TARGET") == "qt-mt"QTDLL_POSTFIX); 480 bool is_qt = (project->first("TARGET") == "qt"QTDLL_POSTFIX || project->first("TARGET") == "qt-mt"QTDLL_POSTFIX);
325 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"]; 481 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"];
326 482
@@ -330,6 +486,12 @@ NmakeMakefileGenerator::init()
330 project->variables()["DEFINES"].append("QT_DLL"); 486 project->variables()["DEFINES"].append("QT_DLL");
331 if (project->isActiveConfig("qt_dll")) 487 if (project->isActiveConfig("qt_dll"))
332 if(configs.findIndex("qt") == -1) configs.append("qt"); 488 if(configs.findIndex("qt") == -1) configs.append("qt");
489 if ( project->isActiveConfig("qtopia") ) {
490 if(configs.findIndex("qtopialib") == -1)
491 configs.append("qtopialib");
492 if(configs.findIndex("qtopiainc") == -1)
493 configs.append("qtopiainc");
494 }
333 if ( project->isActiveConfig("qt") ) { 495 if ( project->isActiveConfig("qt") ) {
334 if ( project->isActiveConfig( "plugin" ) ) { 496 if ( project->isActiveConfig( "plugin" ) ) {
335 project->variables()["CONFIG"].append("dll"); 497 project->variables()["CONFIG"].append("dll");
@@ -401,6 +563,13 @@ NmakeMakefileGenerator::init()
401 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"]; 563 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"];
402 if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") ) 564 if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") )
403 project->variables()["CONFIG"].append("windows"); 565 project->variables()["CONFIG"].append("windows");
566 if ( project->isActiveConfig("qtopiainc") )
567 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QTOPIA"];
568 if ( project->isActiveConfig("qtopialib") ) {
569 if(!project->isEmpty("QMAKE_LIBDIR_QTOPIA"))
570 project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QTOPIA"];
571 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QTOPIA"];
572 }
404 if ( project->isActiveConfig("qt") ) { 573 if ( project->isActiveConfig("qt") ) {
405 project->variables()["CONFIG"].append("moc"); 574 project->variables()["CONFIG"].append("moc");
406 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"]; 575 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"];
@@ -508,10 +677,26 @@ NmakeMakefileGenerator::init()
508 if ( project->isActiveConfig("moc") ) 677 if ( project->isActiveConfig("moc") )
509 setMocAware(TRUE); 678 setMocAware(TRUE);
510 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; 679 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
680
681 QStringList &libList = project->variables()["QMAKE_LIBS"];
682 for( QStringList::Iterator stIt = libList.begin(); stIt != libList.end(); ) {
683 QString s = *stIt;
684 if( s.startsWith( "-l" ) ) {
685 stIt = libList.remove( stIt );
686 stIt = libList.insert( stIt, s.mid( 2 ) + ".lib" );
687 } else if( s.startsWith( "-L" ) ) {
688 stIt = libList.remove( stIt );
689 project->variables()["QMAKE_LIBDIR"].append(QDir::convertSeparators(s.mid( 2 )));
690 } else {
691 stIt++;
692 }
693 }
694
511 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ', 695 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ',
512 "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH"); 696 "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH");
513 QStringList &l = project->variables()["QMAKE_FILETAGS"]; 697 QStringList &l = project->variables()["QMAKE_FILETAGS"];
514 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 698 QStringList::Iterator it;
699 for(it = l.begin(); it != l.end(); ++it) {
515 QStringList &gdmf = project->variables()[(*it)]; 700 QStringList &gdmf = project->variables()[(*it)];
516 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner) 701 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner)
517 (*inner) = Option::fixPathToTargetOS((*inner), FALSE); 702 (*inner) = Option::fixPathToTargetOS((*inner), FALSE);
@@ -539,11 +724,30 @@ NmakeMakefileGenerator::init()
539 project->variables()["RES_FILE"] = project->variables()["RC_FILE"]; 724 project->variables()["RES_FILE"] = project->variables()["RC_FILE"];
540 project->variables()["RES_FILE"].first().replace(".rc",".res"); 725 project->variables()["RES_FILE"].first().replace(".rc",".res");
541 project->variables()["POST_TARGETDEPS"] += project->variables()["RES_FILE"]; 726 project->variables()["POST_TARGETDEPS"] += project->variables()["RES_FILE"];
727 project->variables()["CLEAN_FILES"] += project->variables()["RES_FILE"];
542 } 728 }
543 if ( !project->variables()["RES_FILE"].isEmpty()) 729 if ( !project->variables()["RES_FILE"].isEmpty())
544 project->variables()["QMAKE_LIBS"] += project->variables()["RES_FILE"]; 730 project->variables()["QMAKE_LIBS"] += project->variables()["RES_FILE"];
545 731
732 // Base class init!
546 MakefileGenerator::init(); 733 MakefileGenerator::init();
734
735 // Setup PCH variables
736 precompH = project->first("PRECOMPILED_HEADER");
737 usePCH = !precompH.isEmpty() && project->isActiveConfig("precompile_header");
738 if (usePCH) {
739 // Created files
740 precompObj = var("OBJECTS_DIR") + project->first("TARGET") + "_pch" + Option::obj_ext;
741 precompPch = var("OBJECTS_DIR") + project->first("TARGET") + "_pch.pch";
742 // Add linking of precompObj (required for whole precompiled classes)
743 project->variables()["OBJECTS"] += precompObj;
744 // Add pch file to cleanup
745 project->variables()["QMAKE_CLEAN"] += precompPch;
746 // Return to variable pool
747 project->variables()["PRECOMPILED_OBJECT"] = precompObj;
748 project->variables()["PRECOMPILED_PCH"] = precompPch;
749 }
750
547 if ( !project->variables()["VERSION"].isEmpty()) { 751 if ( !project->variables()["VERSION"].isEmpty()) {
548 QStringList l = QStringList::split('.', project->first("VERSION")); 752 QStringList l = QStringList::split('.', project->first("VERSION"));
549 project->variables()["VER_MAJ"].append(l[0]); 753 project->variables()["VER_MAJ"].append(l[0]);
@@ -558,5 +762,26 @@ NmakeMakefileGenerator::init()
558 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + version + ".pdb"); 762 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + version + ".pdb");
559 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + version + ".ilk"); 763 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + version + ".ilk");
560 project->variables()["QMAKE_CLEAN"].append("vc*.pdb"); 764 project->variables()["QMAKE_CLEAN"].append("vc*.pdb");
765 project->variables()["QMAKE_CLEAN"].append("vc*.idb");
766 }
767
768 QStringList &quc = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"];
769 for(it = quc.begin(); it != quc.end(); ++it) {
770 QString tmp_out = project->variables()[(*it) + ".output"].first();
771 if(tmp_out.isEmpty())
772 continue;
773 QStringList &tmp = project->variables()[(*it) + ".input"];
774 for(QStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {
775 QStringList &inputs = project->variables()[(*it2)];
776 for(QStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {
777 QFileInfo fi(Option::fixPathToLocalOS((*input)));
778 QString in = Option::fixPathToTargetOS((*input), FALSE),
779 out = tmp_out;
780 out.replace("${QMAKE_FILE_BASE}", fi.baseName());
781 out.replace("${QMAKE_FILE_NAME}", fi.fileName());
782 if(project->variables()[(*it) + ".CONFIG"].findIndex("no_link") == -1)
783 project->variables()["OBJCOMP"] += out;
784 }
785 }
561 } 786 }
562} 787}
diff --git a/qmake/generators/win32/msvc_nmake.h b/qmake/generators/win32/msvc_nmake.h
index 579fc35..f2996cd 100644
--- a/qmake/generators/win32/msvc_nmake.h
+++ b/qmake/generators/win32/msvc_nmake.h
@@ -1,13 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Definition of ________ class.
5** 3**
6** Created : 970521 4** Definition of NmakeMakefileGenerator class.
7** 5**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. 6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 7**
10** This file is part of the network module of the Qt GUI Toolkit. 8** This file is part of qmake.
11** 9**
12** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
@@ -34,6 +32,7 @@
34** not clear to you. 32** not clear to you.
35** 33**
36**********************************************************************/ 34**********************************************************************/
35
37#ifndef __MSVC_NMAKE_H__ 36#ifndef __MSVC_NMAKE_H__
38#define __MSVC_NMAKE_H__ 37#define __MSVC_NMAKE_H__
39 38
@@ -47,6 +46,12 @@ class NmakeMakefileGenerator : public Win32MakefileGenerator
47 bool writeMakefile(QTextStream &); 46 bool writeMakefile(QTextStream &);
48 void init(); 47 void init();
49 48
49protected:
50 QStringList &findDependencies(const QString &file);
51 QString var(const QString &value);
52 QString precompH, precompObj, precompPch;
53 bool usePCH;
54
50public: 55public:
51 NmakeMakefileGenerator(QMakeProject *p); 56 NmakeMakefileGenerator(QMakeProject *p);
52 ~NmakeMakefileGenerator(); 57 ~NmakeMakefileGenerator();
diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp
index 7ffe4f7..a672c2d 100644
--- a/qmake/generators/win32/msvc_objectmodel.cpp
+++ b/qmake/generators/win32/msvc_objectmodel.cpp
@@ -1,11 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Definition of ________ class.
5** 3**
6** Copyright (C) 2002 Trolltech AS. All rights reserved. 4** Implementation of VCProject class.
7** 5**
8** This file is part of the network module of the Qt GUI Toolkit. 6** Copyright (C) 2002-2003 Trolltech AS. All rights reserved.
7**
8** This file is part of qmake.
9** 9**
10** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
11** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
@@ -37,21 +37,7 @@
37#include "msvc_vcproj.h" 37#include "msvc_vcproj.h"
38#include <qtextstream.h> 38#include <qtextstream.h>
39#include <qstringlist.h> 39#include <qstringlist.h>
40#include <quuid.h> 40#include <qfileinfo.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 41
56// XML Tags --------------------------------------------------------- 42// XML Tags ---------------------------------------------------------
57 const char* _xmlInit = "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>"; 43 const char* _xmlInit = "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>";
@@ -281,7 +267,6 @@ struct XPair {
281 267
282// void streamSPair( QTextStream &strm, const char *n, const QString &s ) 268// void streamSPair( QTextStream &strm, const char *n, const QString &s )
283 269
284
285// Streaming operators for property Pairs --------------------------- 270// Streaming operators for property Pairs ---------------------------
286QTextStream &operator<<( QTextStream &strm, const TPair &prop ) 271QTextStream &operator<<( QTextStream &strm, const TPair &prop )
287{ 272{
@@ -318,7 +303,7 @@ QTextStream &operator<<( QTextStream &strm, const LPair &prop )
318QTextStream &operator<<( QTextStream &strm, const SPair &prop ) 303QTextStream &operator<<( QTextStream &strm, const SPair &prop )
319{ 304{
320 if ( !prop.value.isEmpty() ) 305 if ( !prop.value.isEmpty() )
321 strm << prop.name << prop.value.latin1() << "\""; 306 strm << prop.name << QString(prop.value).remove("\"") << "\"";
322 return strm; 307 return strm;
323} 308}
324 309
@@ -334,7 +319,7 @@ VCCLCompilerTool::VCCLCompilerTool()
334 :AssemblerOutput( asmListingNone ), 319 :AssemblerOutput( asmListingNone ),
335 BasicRuntimeChecks( runtimeBasicCheckNone ), 320 BasicRuntimeChecks( runtimeBasicCheckNone ),
336 BrowseInformation( brInfoNone ), 321 BrowseInformation( brInfoNone ),
337 BufferSecurityCheck( unset ), 322 BufferSecurityCheck( _False ),
338 CallingConvention( callConventionDefault ), 323 CallingConvention( callConventionDefault ),
339 CompileAs( compileAsDefault ), 324 CompileAs( compileAsDefault ),
340 CompileAsManaged( managedDefault ), 325 CompileAsManaged( managedDefault ),
@@ -346,7 +331,7 @@ VCCLCompilerTool::VCCLCompilerTool()
346 EnableFiberSafeOptimizations( unset ), 331 EnableFiberSafeOptimizations( unset ),
347 EnableFunctionLevelLinking( unset ), 332 EnableFunctionLevelLinking( unset ),
348 EnableIntrinsicFunctions( unset ), 333 EnableIntrinsicFunctions( unset ),
349 ExceptionHandling( unset ), 334 ExceptionHandling( _False ),
350 ExpandAttributedSource( unset ), 335 ExpandAttributedSource( unset ),
351 FavorSizeOrSpeed( favorNone ), 336 FavorSizeOrSpeed( favorNone ),
352 ForceConformanceInForLoopScope( unset ), 337 ForceConformanceInForLoopScope( unset ),
@@ -354,13 +339,14 @@ VCCLCompilerTool::VCCLCompilerTool()
354 GlobalOptimizations( unset ), 339 GlobalOptimizations( unset ),
355 IgnoreStandardIncludePath( unset ), 340 IgnoreStandardIncludePath( unset ),
356 ImproveFloatingPointConsistency( unset ), 341 ImproveFloatingPointConsistency( unset ),
357 InlineFunctionExpansion( expandOnlyInline ), 342 InlineFunctionExpansion( expandDefault ),
358 KeepComments( unset ), 343 KeepComments( unset ),
359 MinimalRebuild( unset ), 344 MinimalRebuild( unset ),
360 OmitFramePointers( unset ), 345 OmitFramePointers( unset ),
361 Optimization( optimizeDisabled ), 346 Optimization( optimizeCustom ),
362 OptimizeForProcessor( procOptimizeBlended ), 347 OptimizeForProcessor( procOptimizeBlended ),
363 OptimizeForWindowsApplication( unset ), 348 OptimizeForWindowsApplication( unset ),
349 ProgramDataBaseFileName( "" ),
364 RuntimeLibrary( rtMultiThreaded ), 350 RuntimeLibrary( rtMultiThreaded ),
365 RuntimeTypeInfo( unset ), 351 RuntimeTypeInfo( unset ),
366 ShowIncludes( unset ), 352 ShowIncludes( unset ),
@@ -371,7 +357,7 @@ VCCLCompilerTool::VCCLCompilerTool()
371 TreatWChar_tAsBuiltInType( unset ), 357 TreatWChar_tAsBuiltInType( unset ),
372 TurnOffAssemblyGeneration( unset ), 358 TurnOffAssemblyGeneration( unset ),
373 UndefineAllPreprocessorDefinitions( unset ), 359 UndefineAllPreprocessorDefinitions( unset ),
374 UsePrecompiledHeader( pchGenerateAuto ), 360 UsePrecompiledHeader( pchNone ),
375 WarnAsError( unset ), 361 WarnAsError( unset ),
376 WarningLevel( warningLevel_0 ), 362 WarningLevel( warningLevel_0 ),
377 WholeProgramOptimization( unset ) 363 WholeProgramOptimization( unset )
@@ -395,7 +381,7 @@ QTextStream &operator<<( QTextStream &strm, const VCCLCompilerTool &tool )
395 if ( tool.CompileAs != compileAsDefault ) strm << EPair( _CompileAs, tool.CompileAs ); 381 if ( tool.CompileAs != compileAsDefault ) strm << EPair( _CompileAs, tool.CompileAs );
396 if ( tool.CompileAsManaged != managedDefault ) strm << EPair( _CompileAsManaged, tool.CompileAsManaged ); 382 if ( tool.CompileAsManaged != managedDefault ) strm << EPair( _CompileAsManaged, tool.CompileAsManaged );
397 strm << TPair( _CompileOnly, tool.CompileOnly ); 383 strm << TPair( _CompileOnly, tool.CompileOnly );
398 strm << EPair( _DebugInformationFormat, tool.DebugInformationFormat ); 384 if ( tool.DebugInformationFormat != debugUnknown ) strm << EPair( _DebugInformationFormat, tool.DebugInformationFormat );
399 strm << TPair( _DefaultCharIsUnsigned, tool.DefaultCharIsUnsigned ); 385 strm << TPair( _DefaultCharIsUnsigned, tool.DefaultCharIsUnsigned );
400 strm << TPair( _Detect64BitPortabilityProblems, tool.Detect64BitPortabilityProblems ); 386 strm << TPair( _Detect64BitPortabilityProblems, tool.Detect64BitPortabilityProblems );
401 strm << TPair( _DisableLanguageExtensions, tool.DisableLanguageExtensions ); 387 strm << TPair( _DisableLanguageExtensions, tool.DisableLanguageExtensions );
@@ -409,24 +395,24 @@ QTextStream &operator<<( QTextStream &strm, const VCCLCompilerTool &tool )
409 strm << TPair( _ForceConformanceInForLoopScope, tool.ForceConformanceInForLoopScope ); 395 strm << TPair( _ForceConformanceInForLoopScope, tool.ForceConformanceInForLoopScope );
410 strm << XPair( _ForcedIncludeFiles, tool.ForcedIncludeFiles ); 396 strm << XPair( _ForcedIncludeFiles, tool.ForcedIncludeFiles );
411 strm << XPair( _ForcedUsingFiles, tool.ForcedUsingFiles ); 397 strm << XPair( _ForcedUsingFiles, tool.ForcedUsingFiles );
412 strm << EPair( _GeneratePreprocessedFile, tool.GeneratePreprocessedFile ); 398 if ( tool.GeneratePreprocessedFile != preprocessUnknown)strm << EPair( _GeneratePreprocessedFile, tool.GeneratePreprocessedFile );
413 strm << TPair( _GlobalOptimizations, tool.GlobalOptimizations ); 399 strm << TPair( _GlobalOptimizations, tool.GlobalOptimizations );
414 strm << TPair( _IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath ); 400 strm << TPair( _IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath );
415 strm << TPair( _ImproveFloatingPointConsistency, tool.ImproveFloatingPointConsistency ); 401 strm << TPair( _ImproveFloatingPointConsistency, tool.ImproveFloatingPointConsistency );
416 strm << EPair( _InlineFunctionExpansion, tool.InlineFunctionExpansion ); 402 if ( tool.InlineFunctionExpansion != expandDefault ) strm << EPair( _InlineFunctionExpansion, tool.InlineFunctionExpansion );
417 strm << TPair( _KeepComments, tool.KeepComments ); 403 strm << TPair( _KeepComments, tool.KeepComments );
418 strm << TPair( _MinimalRebuild, tool.MinimalRebuild ); 404 strm << TPair( _MinimalRebuild, tool.MinimalRebuild );
419 strm << SPair( _ObjectFile, tool.ObjectFile ); 405 strm << SPair( _ObjectFile, tool.ObjectFile );
420 strm << TPair( _OmitFramePointers, tool.OmitFramePointers ); 406 strm << TPair( _OmitFramePointers, tool.OmitFramePointers );
421 strm << EPair( _Optimization, tool.Optimization ); 407 if ( tool.Optimization != optimizeDefault ) strm << EPair( _Optimization, tool.Optimization );
422 if ( tool.OptimizeForProcessor != procOptimizeBlended ) strm << EPair( _OptimizeForProcessor, tool.OptimizeForProcessor ); 408 if ( tool.OptimizeForProcessor != procOptimizeBlended ) strm << EPair( _OptimizeForProcessor, tool.OptimizeForProcessor );
423 strm << TPair( _OptimizeForWindowsApplication, tool.OptimizeForWindowsApplication ); 409 strm << TPair( _OptimizeForWindowsApplication, tool.OptimizeForWindowsApplication );
424 strm << SPair( _OutputFile, tool.OutputFile ); 410 strm << SPair( _OutputFile, tool.OutputFile );
425 strm << SPair( _PrecompiledHeaderFile, tool.PrecompiledHeaderFile ); 411 strm << SPair( _PrecompiledHeaderFile, tool.PrecompiledHeaderFile );
426 strm << SPair( _PrecompiledHeaderThrough, tool.PrecompiledHeaderThrough ); 412 strm << SPair( _PrecompiledHeaderThrough, tool.PrecompiledHeaderThrough );
427 strm << XPair( _PreprocessorDefinitions, tool.PreprocessorDefinitions ); 413 strm << XPair( _PreprocessorDefinitions, tool.PreprocessorDefinitions );
428 strm << SPair( _ProgramDataBaseFileName, tool.ProgramDataBaseFileName ); 414 if ( !tool.ProgramDataBaseFileName.isNull() ) strm << _ProgramDataBaseFileName << tool.ProgramDataBaseFileName.latin1() << "\"";
429 strm << EPair( _RuntimeLibrary, tool.RuntimeLibrary ); 415 if ( tool.RuntimeLibrary != rtUnknown ) strm << EPair( _RuntimeLibrary, tool.RuntimeLibrary );
430 strm << TPair( _RuntimeTypeInfo, tool.RuntimeTypeInfo ); 416 strm << TPair( _RuntimeTypeInfo, tool.RuntimeTypeInfo );
431 strm << TPair( _ShowIncludes, tool.ShowIncludes ); 417 strm << TPair( _ShowIncludes, tool.ShowIncludes );
432 strm << TPair( _SmallerTypeCheck, tool.SmallerTypeCheck ); 418 strm << TPair( _SmallerTypeCheck, tool.SmallerTypeCheck );
@@ -441,7 +427,7 @@ QTextStream &operator<<( QTextStream &strm, const VCCLCompilerTool &tool )
441 !tool.PrecompiledHeaderThrough.isEmpty() ) 427 !tool.PrecompiledHeaderThrough.isEmpty() )
442 strm << EPair( _UsePrecompiledHeader, tool.UsePrecompiledHeader ); 428 strm << EPair( _UsePrecompiledHeader, tool.UsePrecompiledHeader );
443 strm << TPair( _WarnAsError, tool.WarnAsError ); 429 strm << TPair( _WarnAsError, tool.WarnAsError );
444 strm << EPair( _WarningLevel, tool.WarningLevel ); 430 if ( tool.WarningLevel != warningLevelUnknown ) strm << EPair( _WarningLevel, tool.WarningLevel );
445 strm << TPair( _WholeProgramOptimization, tool.WholeProgramOptimization ); 431 strm << TPair( _WholeProgramOptimization, tool.WholeProgramOptimization );
446 strm << "/>"; 432 strm << "/>";
447return strm; 433return strm;
@@ -474,22 +460,29 @@ bool VCCLCompilerTool::parseOption( const char* option )
474 if ( second != 'I' ) { 460 if ( second != 'I' ) {
475 found = FALSE; break; 461 found = FALSE; break;
476 } 462 }
477 AdditionalUsingDirectories += option+2; 463 AdditionalUsingDirectories += option+3;
478 break; 464 break;
479 case 'C': 465 case 'C':
480 KeepComments = _True; 466 KeepComments = _True;
481 break; 467 break;
482 case 'D': 468 case 'D':
483 PreprocessorDefinitions += option+1; 469 PreprocessorDefinitions += option+2;
484 break; 470 break;
485 case 'E': 471 case 'E':
486 if ( second == 'H' ) { 472 if ( second == 'H' ) {
487 if ( third == 'a' || third == 'c' || third == 's' ) { 473 if ( third == 'a'
474 || (third == 'c' && fourth != 's')
475 || (third == 's' && fourth != 'c') ) {
488 // ExceptionHandling must be false, or it will override 476 // ExceptionHandling must be false, or it will override
489 // with an /EHsc option 477 // with an /EHsc option
490 ExceptionHandling = _False; 478 ExceptionHandling = _False;
491 AdditionalOptions += option; 479 AdditionalOptions += option;
492 break; 480 break;
481 } else if ( (third == 'c' && fourth == 's')
482 || (third == 's' && fourth == 'c') ) {
483 ExceptionHandling = _True;
484 AdditionalOptions += option;
485 break;
493 } 486 }
494 found = FALSE; break; 487 found = FALSE; break;
495 } 488 }
@@ -591,6 +584,9 @@ bool VCCLCompilerTool::parseOption( const char* option )
591 EnableFiberSafeOptimizations = _True; 584 EnableFiberSafeOptimizations = _True;
592 break; 585 break;
593 case 'X': 586 case 'X':
587 // ExceptionHandling == true will override with
588 // an /EHsc option, which is correct with /GX
589 ExceptionHandling = _True; // Fall-through
594 case 'Z': 590 case 'Z':
595 case 'e': 591 case 'e':
596 case 'h': 592 case 'h':
@@ -954,10 +950,10 @@ VCLinkerTool::VCLinkerTool()
954 HeapReserveSize( -1 ), 950 HeapReserveSize( -1 ),
955 IgnoreAllDefaultLibraries( unset ), 951 IgnoreAllDefaultLibraries( unset ),
956 IgnoreEmbeddedIDL( unset ), 952 IgnoreEmbeddedIDL( unset ),
957 IgnoreImportLibrary( unset ), 953 IgnoreImportLibrary( _True ),
958 LargeAddressAware( addrAwareDefault ), 954 LargeAddressAware( addrAwareDefault ),
959 LinkDLL( unset ), 955 LinkDLL( unset ),
960 LinkIncremental( linkIncrementalYes ), 956 LinkIncremental( linkIncrementalDefault ),
961 LinkTimeCodeGeneration( unset ), 957 LinkTimeCodeGeneration( unset ),
962 MapExports( unset ), 958 MapExports( unset ),
963 MapLines( unset ), 959 MapLines( unset ),
@@ -1019,7 +1015,7 @@ QTextStream &operator<<( QTextStream &strm, const VCLinkerTool &tool )
1019 if ( tool.OptimizeForWindows98 != optWin98Default ) strm << EPair( _OptimizeForWindows98, tool.OptimizeForWindows98 ); 1015 if ( tool.OptimizeForWindows98 != optWin98Default ) strm << EPair( _OptimizeForWindows98, tool.OptimizeForWindows98 );
1020 if ( tool.OptimizeReferences != optReferencesDefault ) strm << EPair( _OptimizeReferences, tool.OptimizeReferences ); 1016 if ( tool.OptimizeReferences != optReferencesDefault ) strm << EPair( _OptimizeReferences, tool.OptimizeReferences );
1021 strm << SPair( _OutputFile, tool.OutputFile ); 1017 strm << SPair( _OutputFile, tool.OutputFile );
1022 strm << SPair( _ProgramDatabaseFile, tool.ProgramDatabaseFile ); 1018 strm << _ProgramDatabaseFile << tool.ProgramDatabaseFile << "\"";
1023 strm << TPair( _RegisterOutput, tool.RegisterOutput ); 1019 strm << TPair( _RegisterOutput, tool.RegisterOutput );
1024 strm << TPair( _ResourceOnlyDLL, tool.ResourceOnlyDLL ); 1020 strm << TPair( _ResourceOnlyDLL, tool.ResourceOnlyDLL );
1025 strm << TPair( _SetChecksum, tool.SetChecksum ); 1021 strm << TPair( _SetChecksum, tool.SetChecksum );
@@ -1707,9 +1703,9 @@ QTextStream &operator<<( QTextStream &strm, const VCCustomBuildTool &tool )
1707 strm << _begTool3; 1703 strm << _begTool3;
1708 strm << SPair( _ToolName, tool.ToolName ); 1704 strm << SPair( _ToolName, tool.ToolName );
1709 strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies, ";" ); 1705 strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies, ";" );
1710 strm << SPair( _CommandLine4, tool.CommandLine ); 1706 strm << XPair( _CommandLine4, tool.CommandLine, "\n" );
1711 strm << SPair( _Description4, tool.Description ); 1707 strm << SPair( _Description4, tool.Description );
1712 strm << SPair( _Outputs4, tool.Outputs ); 1708 strm << XPair( _Outputs4, tool.Outputs, ";" );
1713 strm << SPair( _ToolPath, tool.ToolPath ); 1709 strm << SPair( _ToolPath, tool.ToolPath );
1714 strm << "/>"; 1710 strm << "/>";
1715 return strm; 1711 return strm;
@@ -1826,43 +1822,39 @@ QTextStream &operator<<( QTextStream &strm, const VCConfiguration &tool )
1826VCFilter::VCFilter() 1822VCFilter::VCFilter()
1827 : ParseFiles( unset ) 1823 : ParseFiles( unset )
1828{ 1824{
1825 useCustomBuildTool = FALSE;
1826 useCompilerTool = FALSE;
1829} 1827}
1830 1828
1831void VCFilter::generateMOC( QTextStream &strm, QString str ) const 1829void VCFilter::addMOCstage( QTextStream &strm, QString filename )
1832{ 1830{
1833 QString mocOutput = Project->findMocDestination( str ); 1831 QString mocOutput = Project->findMocDestination( filename );
1834 QString mocApp = Project->var( "QMAKE_MOC" ); 1832 QString mocApp = Project->var( "QMAKE_MOC" );
1835 1833
1836 if( mocOutput.isEmpty() ) { 1834 if( mocOutput.isEmpty() && filename.endsWith(".moc") ) {
1837 // In specialcases we DO moc .cpp files 1835 // In specialcases we DO moc .cpp files
1838 // when the result is an .moc file 1836 // when the result is an .moc file
1839 if ( !str.endsWith(".moc") ) 1837 mocOutput = filename;
1840 return; 1838 filename = Project->findMocSource( mocOutput );
1841 mocOutput = str;
1842 str = Project->findMocSource( mocOutput );
1843 } 1839 }
1844 1840
1845 strm << _begFileConfiguration; 1841 if (mocOutput.isEmpty())
1846 strm << _Name5; 1842 return;
1847 strm << Config->Name; 1843
1848 strm << "\">"; 1844 CustomBuildTool = VCCustomBuildTool();
1849 strm << _begTool5; 1845 useCustomBuildTool = TRUE;
1850 strm << _VCCustomBuildTool; 1846 CustomBuildTool.Description = "Moc&apos;ing " + filename + "...";
1851 strm << _Description6; 1847 CustomBuildTool.CommandLine += (mocApp + " "
1852 strm << "Moc'ing " << str << "...\""; 1848 + filename + " -o " + mocOutput);
1853 strm << _CommandLine6; 1849 CustomBuildTool.AdditionalDependencies = mocApp;
1854 strm << mocApp; 1850 CustomBuildTool.Outputs += mocOutput;
1855 strm << " " << str << " -o " << mocOutput << "\"";
1856 strm << _AdditionalDependencies6;
1857 strm << mocApp << "\"";
1858 strm << _Outputs6;
1859 strm << mocOutput << "\"";
1860 strm << "/>";
1861 strm << _endFileConfiguration;
1862} 1851}
1863 1852
1864void VCFilter::generateUIC( QTextStream &strm, const QString& str ) const 1853void VCFilter::addUICstage( QTextStream &strm, QString str )
1865{ 1854{
1855 CustomBuildTool = VCCustomBuildTool();
1856 useCustomBuildTool = TRUE;
1857
1866 QString uicApp = Project->var("QMAKE_UIC"); 1858 QString uicApp = Project->var("QMAKE_UIC");
1867 QString mocApp = Project->var( "QMAKE_MOC" ); 1859 QString mocApp = Project->var( "QMAKE_MOC" );
1868 QString fname = str.section( '\\', -1 ); 1860 QString fname = str.section( '\\', -1 );
@@ -1895,27 +1887,103 @@ void VCFilter::generateUIC( QTextStream &strm, const QString& str ) const
1895 if( dot != -1 ) 1887 if( dot != -1 )
1896 fname.truncate( dot ); 1888 fname.truncate( dot );
1897 1889
1898 strm << _begFileConfiguration; 1890 if ( mocDir.isEmpty() )
1899 strm << _Name5; 1891 mocDir = pname;
1900 strm << Config->Name; 1892
1901 strm << "\">"; 1893 CustomBuildTool.Description = ("Uic'ing " + str + "...\"");
1902 strm << _begTool5; 1894 CustomBuildTool.CommandLine += // Create .h from .ui file
1903 strm << _VCCustomBuildTool; 1895 uicApp + " " + str + " -o " + uiHeaders + fname + ".h";
1904 strm << _Description6; 1896 CustomBuildTool.CommandLine += // Create .cpp from .ui file
1905 strm << "Uic'ing " << str << "...\""; 1897 uicApp + " " + str + " -i " + fname + ".h -o " + uiSources + fname + ".cpp";
1906 strm << _CommandLine6; 1898 CustomBuildTool.CommandLine += // Moc the headerfile
1907 strm << uicApp << " " << str << " -o " << uiHeaders << fname << ".h &amp;&amp; "; // Create .h from .ui file 1899 mocApp + " " + uiHeaders + fname + ".h -o " + mocDir + Option::h_moc_mod + fname + Option::h_moc_ext;
1908 strm << uicApp << " " << str << " -i " << fname << ".h -o " << uiSources << fname << ".cpp &amp;&amp; ";// Create .cpp from .ui file 1900
1909 strm << mocApp << " " << uiHeaders << fname << ".h -o " << mocDir << "moc_" << fname << ".cpp\""; 1901 CustomBuildTool.AdditionalDependencies += mocApp;
1910 strm << _AdditionalDependencies6; 1902 CustomBuildTool.AdditionalDependencies += uicApp;
1911 strm << mocApp << ";" << uicApp << "\""; 1903 CustomBuildTool.Outputs +=
1912 strm << _Outputs6; 1904 uiHeaders + fname + ".h;" + uiSources + fname + ".cpp;" + mocDir + Option::h_moc_mod + fname + Option::h_moc_ext;
1913 strm << uiHeaders << fname << ".h;" << uiSources << fname << ".cpp;" << mocDir << "moc_" << fname << ".cpp\""; 1905}
1914 strm << "/>"; 1906
1915 strm << _endFileConfiguration; 1907void VCFilter::modifyPCHstage( QTextStream &strm, QString str )
1908{
1909 bool isCFile = str.endsWith(".c");
1910 bool isHFile = (str.endsWith(".h") && str == Project->precompH);
1911
1912 if (!isCFile && !isHFile)
1913 return;
1914
1915 CompilerTool = VCCLCompilerTool();
1916 useCompilerTool = TRUE;
1917
1918 // Unset some default options
1919 CompilerTool.BufferSecurityCheck = unset;
1920 CompilerTool.DebugInformationFormat = debugUnknown;
1921 CompilerTool.ExceptionHandling = unset;
1922 CompilerTool.GeneratePreprocessedFile = preprocessUnknown;
1923 CompilerTool.Optimization = optimizeDefault;
1924 CompilerTool.ProgramDataBaseFileName = QString::null;
1925 CompilerTool.RuntimeLibrary = rtUnknown;
1926 CompilerTool.WarningLevel = warningLevelUnknown;
1927
1928 // Setup PCH options
1929 CompilerTool.UsePrecompiledHeader = (isCFile ? pchNone : pchCreateUsingSpecific);
1930 CompilerTool.PrecompiledHeaderThrough = "$(NOINHERIT)";
1931 CompilerTool.ForcedIncludeFiles = "$(NOINHERIT)";
1916} 1932}
1917 1933
1918QTextStream &operator<<( QTextStream &strm, const VCFilter &tool ) 1934bool VCFilter::addIMGstage( QTextStream &strm, QString str )
1935{
1936 bool isCorH = FALSE;
1937 if (str.endsWith(".c") || str.endsWith(".rc"))
1938 isCorH = TRUE;
1939 QStringList::Iterator it;
1940 for(it = Option::cpp_ext.begin(); it != Option::cpp_ext.end(); ++it)
1941 if(str.endsWith(*it))
1942 isCorH = TRUE;
1943 for(it = Option::h_ext.begin(); it != Option::h_ext.end(); ++it)
1944 if(str.endsWith(*it))
1945 isCorH = TRUE;
1946
1947 QString collectionName = Project->project->first("QMAKE_IMAGE_COLLECTION");
1948 if (str.isEmpty() || isCorH || collectionName.isEmpty())
1949 return FALSE;
1950
1951 CustomBuildTool = VCCustomBuildTool();
1952 useCustomBuildTool = TRUE;
1953
1954 // Some projects (like designer core) may have too many images to
1955 // call uic directly. Therefor we have to create a temporary
1956 // file, with the image list, and call uic with the -f option.
1957 QString tmpFileCmd = "echo ";
1958 QString tmpImageFilename = ".imgcol";
1959 QStringList& list = Project->project->variables()["IMAGES"];
1960 bool firstOutput = TRUE;
1961 it = list.begin();
1962 while( it!=list.end() ) {
1963 tmpFileCmd += (*it) + " ";
1964 ++it;
1965 if (tmpFileCmd.length()>250 || it==list.end()) {
1966 CustomBuildTool.CommandLine += tmpFileCmd
1967 + (firstOutput?"> ":">> ")
1968 + tmpImageFilename;
1969 tmpFileCmd = "echo ";
1970 firstOutput = FALSE;
1971 }
1972 }
1973
1974 QString uicApp = Project->var("QMAKE_UIC");
1975 CustomBuildTool.Description = ("Generate imagecollection");
1976 CustomBuildTool.CommandLine +=
1977 uicApp + " -embed " + Project->project->first("QMAKE_ORIG_TARGET")
1978 + " -f .imgcol -o " + collectionName;
1979 CustomBuildTool.AdditionalDependencies += uicApp;
1980 CustomBuildTool.AdditionalDependencies += list;
1981 CustomBuildTool.Outputs = collectionName;
1982 CustomBuildTool.Outputs += tmpImageFilename;
1983 return TRUE;
1984}
1985
1986QTextStream &operator<<( QTextStream &strm, VCFilter &tool )
1919{ 1987{
1920 if ( tool.Files.count() == 0 ) 1988 if ( tool.Files.count() == 0 )
1921 return strm; 1989 return strm;
@@ -1925,17 +1993,77 @@ QTextStream &operator<<( QTextStream &strm, const VCFilter &tool )
1925 strm << TPair( _ParseFiles, tool.ParseFiles ); 1993 strm << TPair( _ParseFiles, tool.ParseFiles );
1926 strm << SPair( _Filter, tool.Filter ); 1994 strm << SPair( _Filter, tool.Filter );
1927 strm << ">"; 1995 strm << ">";
1996
1997 bool resourceBuild = FALSE;
1998 int currentLevels = 0;
1999 QStringList currentDirs;
1928 for ( QStringList::ConstIterator it = tool.Files.begin(); it != tool.Files.end(); ++it ) { 2000 for ( QStringList::ConstIterator it = tool.Files.begin(); it != tool.Files.end(); ++it ) {
2001 if ( !tool.flat_files ) {
2002 QStringList newDirs = QStringList::split('\\',(*it));
2003 newDirs.pop_back(); // Skip the filename
2004
2005 int newLevels = int(newDirs.count());
2006 int equalLevels = 0;
2007 for (int i = 0; i<currentLevels; i++, equalLevels++ )
2008 if (currentDirs[i] != newDirs[i])
2009 break;
2010 int closeFilters = currentLevels - equalLevels;
2011 int openFilters = newLevels - equalLevels;
2012
2013 // close previous non-equal filter
2014 while ( closeFilters-- )
2015 strm << _endFilter;
2016
2017 // open new non-equal filters
2018 newLevels = 0;
2019 while ( openFilters-- ) {
2020 strm << _begFilter;
2021 strm << SPair( _Name3, newDirs[equalLevels + newLevels] );
2022 strm << _Filter << "\">"; // Blank filter
2023 ++newLevels;
2024 }
2025 currentDirs = newDirs;
2026 currentLevels = int(newDirs.count());
2027 }
2028
2029 tool.useCustomBuildTool = FALSE;
2030 tool.useCompilerTool = FALSE;
2031 // Add UIC, MOC and PCH stages to file
2032 if ( tool.CustomBuild == moc )
2033 tool.addMOCstage( strm, *it );
2034 else if ( tool.CustomBuild == uic )
2035 tool.addUICstage( strm, *it );
2036 else if ( tool.CustomBuild == resource ) {
2037 if (!resourceBuild)
2038 resourceBuild = tool.addIMGstage(strm, *it);
2039 }
2040 if (tool.Project->usePCH)
2041 tool.modifyPCHstage( strm, *it );
2042
1929 strm << _begFile; 2043 strm << _begFile;
1930 strm << SPair( _RelativePath, *it ); 2044 strm << SPair( _RelativePath, *it );
1931 strm << ">"; 2045 strm << ">";
1932 if ( tool.CustomBuild == moc ) 2046 // Output custom build and compiler options
1933 tool.generateMOC( strm, *it ); 2047 // for all configurations
1934 else if ( tool.CustomBuild == uic ) 2048 if (tool.useCustomBuildTool || tool.useCompilerTool) {
1935 tool.generateUIC( strm, *it ); 2049 for ( uint i = 0; i < tool.Config->count(); i++ ) {
2050 strm << _begFileConfiguration;
2051 strm << _Name5;
2052 strm << (*tool.Config)[i].Name;
2053 strm << "\">";
2054 if (tool.useCustomBuildTool)
2055 strm << tool.CustomBuildTool;
2056 if (tool.useCompilerTool)
2057 strm << tool.CompilerTool;
2058 strm << _endFileConfiguration;
2059 }
2060 }
1936 strm << _endFile; 2061 strm << _endFile;
1937 } 2062 }
1938 2063 // close remaining open filters, in non-flat mode
2064 while ( !tool.flat_files && currentLevels-- ) {
2065 strm << _endFilter;
2066 }
1939 strm << _endFilter; 2067 strm << _endFilter;
1940 return strm; 2068 return strm;
1941} 2069}
@@ -1943,17 +2071,9 @@ QTextStream &operator<<( QTextStream &strm, const VCFilter &tool )
1943// VCProject -------------------------------------------------------- 2071// VCProject --------------------------------------------------------
1944VCProject::VCProject() 2072VCProject::VCProject()
1945{ 2073{
1946#if defined(Q_WS_WIN32) 2074 VCConfiguration conf;
1947 GUID guid; 2075 Configuration += conf ; // Release
1948 QUuid uniqueId; 2076 //Configuration += conf ; // Debug added later, after Release init
1949 HRESULT h = CoCreateGuid( &guid );
1950 if ( h == S_OK )
1951 uniqueId = QUuid( guid );
1952 ProjectGUID = uniqueId.toString();
1953#else
1954 // Qt doesn't support GUID on other platforms yet
1955 ProjectGUID = "";
1956#endif
1957} 2077}
1958 2078
1959QTextStream &operator<<( QTextStream &strm, const VCProject &tool ) 2079QTextStream &operator<<( QTextStream &strm, const VCProject &tool )
@@ -1973,17 +2093,18 @@ QTextStream &operator<<( QTextStream &strm, const VCProject &tool )
1973 strm << "/>"; 2093 strm << "/>";
1974 strm << _endPlatforms; 2094 strm << _endPlatforms;
1975 strm << _begConfigurations; 2095 strm << _begConfigurations;
1976 strm << tool.Configuration; 2096 for ( uint i = 0; i < tool.Configuration.count(); i++ )
2097 strm << tool.Configuration[i];
1977 strm << _endConfigurations; 2098 strm << _endConfigurations;
1978 strm << _begFiles; 2099 strm << _begFiles;
1979 strm << tool.SourceFiles; 2100 strm << (VCFilter&)tool.SourceFiles;
1980 strm << tool.HeaderFiles; 2101 strm << (VCFilter&)tool.HeaderFiles;
1981 strm << tool.MOCFiles; 2102 strm << (VCFilter&)tool.MOCFiles;
1982 strm << tool.UICFiles; 2103 strm << (VCFilter&)tool.UICFiles;
1983 strm << tool.FormFiles; 2104 strm << (VCFilter&)tool.FormFiles;
1984 strm << tool.TranslationFiles; 2105 strm << (VCFilter&)tool.TranslationFiles;
1985 strm << tool.LexYaccFiles; 2106 strm << (VCFilter&)tool.LexYaccFiles;
1986 strm << tool.ResourceFiles; 2107 strm << (VCFilter&)tool.ResourceFiles;
1987 strm << _endFiles; 2108 strm << _endFiles;
1988 strm << _begGlobals; 2109 strm << _begGlobals;
1989 strm << _endGlobals; 2110 strm << _endGlobals;
diff --git a/qmake/generators/win32/msvc_objectmodel.h b/qmake/generators/win32/msvc_objectmodel.h
index 1dca68d..9ce38d2 100644
--- a/qmake/generators/win32/msvc_objectmodel.h
+++ b/qmake/generators/win32/msvc_objectmodel.h
@@ -1,11 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Definition of ________ class.
5** 3**
6** Copyright (C) 2002 Trolltech AS. All rights reserved. 4** Definition of VCProject class.
7** 5**
8** This file is part of the network module of the Qt GUI Toolkit. 6** Copyright (C) 2002-2003 Trolltech AS. All rights reserved.
7**
8** This file is part of qmake.
9** 9**
10** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
11** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
@@ -32,6 +32,7 @@
32** not clear to you. 32** not clear to you.
33** 33**
34**********************************************************************/ 34**********************************************************************/
35
35#ifndef __MSVC_OBJECTMODEL_H__ 36#ifndef __MSVC_OBJECTMODEL_H__
36#define __MSVC_OBJECTMODEL_H__ 37#define __MSVC_OBJECTMODEL_H__
37 38
@@ -56,7 +57,8 @@ enum customBuildCheck {
56 none, 57 none,
57 moc, 58 moc,
58 uic, 59 uic,
59 lexyacc 60 lexyacc,
61 resource
60}; 62};
61enum triState { 63enum triState {
62 unset = -1, 64 unset = -1,
@@ -114,6 +116,7 @@ enum ConfigurationTypes {
114 typeGeneric = 10 116 typeGeneric = 10
115}; 117};
116enum debugOption { 118enum debugOption {
119 debugUnknown = -1,
117 debugDisabled, 120 debugDisabled,
118 debugOldStyleInfo, 121 debugOldStyleInfo,
119 debugLineInfoOnly, 122 debugLineInfoOnly,
@@ -240,7 +243,8 @@ enum genProxyLanguage {
240enum inlineExpansionOption { 243enum inlineExpansionOption {
241 expandDisable, 244 expandDisable,
242 expandOnlyInline, 245 expandOnlyInline,
243 expandAnySuitable 246 expandAnySuitable,
247 expandDefault // Not useful number, but stops the output
244}; 248};
245enum linkIncrementalType { 249enum linkIncrementalType {
246 linkIncrementalDefault, 250 linkIncrementalDefault,
@@ -296,7 +300,8 @@ enum optimizeOption {
296 optimizeMinSpace, 300 optimizeMinSpace,
297 optimizeMaxSpeed, 301 optimizeMaxSpeed,
298 optimizeFull, 302 optimizeFull,
299 optimizeCustom 303 optimizeCustom,
304 optimizeDefault // Not useful number, but stops the output
300}; 305};
301enum optRefType { 306enum optRefType {
302 optReferencesDefault, 307 optReferencesDefault,
@@ -315,6 +320,7 @@ enum pchOption {
315 pchUseUsingSpecific 320 pchUseUsingSpecific
316}; 321};
317enum preprocessOption { 322enum preprocessOption {
323 preprocessUnknown = -1,
318 preprocessNo, 324 preprocessNo,
319 preprocessYes, 325 preprocessYes,
320 preprocessNoLineNumbers 326 preprocessNoLineNumbers
@@ -330,6 +336,7 @@ enum RemoteDebuggerType {
330 DbgRemoteTCPIP 336 DbgRemoteTCPIP
331}; 337};
332enum runtimeLibraryOption { 338enum runtimeLibraryOption {
339 rtUnknown = -1,
333 rtMultiThreaded, 340 rtMultiThreaded,
334 rtMultiThreadedDebug, 341 rtMultiThreadedDebug,
335 rtMultiThreadedDLL, 342 rtMultiThreadedDLL,
@@ -379,6 +386,7 @@ enum useOfMfc {
379 useMfcDynamic 386 useMfcDynamic
380}; 387};
381enum warningLevelOption { 388enum warningLevelOption {
389 warningLevelUnknown = -1,
382 warningLevel_0, 390 warningLevel_0,
383 warningLevel_1, 391 warningLevel_1,
384 warningLevel_2, 392 warningLevel_2,
@@ -611,9 +619,9 @@ public:
611 619
612 // Variables 620 // Variables
613 QStringList AdditionalDependencies; 621 QStringList AdditionalDependencies;
614 QString CommandLine; 622 QStringList CommandLine;
615 QString Description; 623 QString Description;
616 QString Outputs; 624 QStringList Outputs;
617 QString ToolName; 625 QString ToolName;
618 QString ToolPath; 626 QString ToolPath;
619}; 627};
@@ -719,8 +727,10 @@ public:
719 // Functions 727 // Functions
720 VCFilter(); 728 VCFilter();
721 ~VCFilter(){} 729 ~VCFilter(){}
722 void generateMOC( QTextStream &strm, QString str ) const; 730 void addMOCstage( QTextStream &strm, QString str );
723 void generateUIC( QTextStream &strm, const QString& str ) const; 731 void addUICstage( QTextStream &strm, QString str );
732 bool addIMGstage( QTextStream &strm, QString str );
733 void modifyPCHstage( QTextStream &strm, QString str );
724 734
725 // Variables 735 // Variables
726 QString Name; 736 QString Name;
@@ -728,8 +738,13 @@ public:
728 triState ParseFiles; 738 triState ParseFiles;
729 QStringList Files; 739 QStringList Files;
730 VcprojGenerator*Project; 740 VcprojGenerator*Project;
731 VCConfiguration*Config; 741 QValueList<VCConfiguration> *Config;
732 customBuildCheckCustomBuild; 742 customBuildCheckCustomBuild;
743 bool useCustomBuildTool;
744 VCCustomBuildTool CustomBuildTool;
745 bool useCompilerTool;
746 VCCLCompilerTool CompilerTool;
747 bool flat_files;
733}; 748};
734 749
735class VCProject 750class VCProject
@@ -748,7 +763,7 @@ public:
748 QString PlatformName; 763 QString PlatformName;
749 764
750 // XML sub-parts 765 // XML sub-parts
751 VCConfigurationConfiguration; 766 QValueList<VCConfiguration> Configuration;
752 VCFilter SourceFiles; 767 VCFilter SourceFiles;
753 VCFilter HeaderFiles; 768 VCFilter HeaderFiles;
754 VCFilter MOCFiles; 769 VCFilter MOCFiles;
@@ -767,7 +782,7 @@ QTextStream &operator<<( QTextStream &, const VCLibrarianTool & );
767QTextStream &operator<<( QTextStream &, const VCResourceCompilerTool & ); 782QTextStream &operator<<( QTextStream &, const VCResourceCompilerTool & );
768QTextStream &operator<<( QTextStream &, const VCEventTool & ); 783QTextStream &operator<<( QTextStream &, const VCEventTool & );
769QTextStream &operator<<( QTextStream &, const VCConfiguration & ); 784QTextStream &operator<<( QTextStream &, const VCConfiguration & );
770QTextStream &operator<<( QTextStream &, const VCFilter & ); 785QTextStream &operator<<( QTextStream &, VCFilter & );
771QTextStream &operator<<( QTextStream &, const VCProject & ); 786QTextStream &operator<<( QTextStream &, const VCProject & );
772 787
773#endif //__MSVC_OBJECTMODEL_H__ 788#endif //__MSVC_OBJECTMODEL_H__
diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp
index d2cbc31..aa8fe16 100644
--- a/qmake/generators/win32/msvc_vcproj.cpp
+++ b/qmake/generators/win32/msvc_vcproj.cpp
@@ -1,13 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Definition of VcprojGenerator class.
5** 3**
6** Created : 970521 4** Implementation of VcprojGenerator class.
7** 5**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. 6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 7**
10** This file is part of the network module of the Qt GUI Toolkit. 8** This file is part of qmake.
11** 9**
12** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
@@ -37,28 +35,68 @@
37 35
38#include "msvc_vcproj.h" 36#include "msvc_vcproj.h"
39#include "option.h" 37#include "option.h"
38#include "qtmd5.h" // SG's MD5 addon
40#include <qdir.h> 39#include <qdir.h>
41#include <qregexp.h> 40#include <qregexp.h>
42#include <qdict.h> 41#include <qdict.h>
43#include <quuid.h> 42#include <quuid.h>
44#include <stdlib.h> 43#include <stdlib.h>
44#include <qsettings.h>
45 45
46#if defined(Q_OS_WIN32) 46//#define DEBUG_SOLUTION_GEN
47#include <objbase.h> 47//#define DEBUG_PROJECT_GEN
48#ifndef GUID_DEFINED 48
49#define GUID_DEFINED 49// Registry keys for .NET version detection -------------------------
50typedef struct _GUID 50 const char* _regNet2002 = "Microsoft\\VisualStudio\\7.0\\Setup\\VC\\ProductDir";
51 const char* _regNet2003 = "Microsoft\\VisualStudio\\7.1\\Setup\\VC\\ProductDir";
52
53bool use_net2003_version()
51{ 54{
52 ulong Data1; 55#ifndef Q_OS_WIN32
53 ushort Data2; 56 return FALSE; // Always generate 7.0 versions on other platforms
54 ushort Data3; 57#else
55 uchar Data4[8]; 58 // Only search for the version once
56} GUID; 59 static int current_version = -1;
57#endif 60 if (current_version!=-1)
61 return (current_version==71);
62
63 // Fallback to .NET 2002
64 current_version = 70;
65
66 // Get registry entries for both versions
67 bool ok = false;
68 QSettings setting;
69 QString path2002 = setting.readEntry(_regNet2002);
70 QString path2003 = setting.readEntry(_regNet2003);
71
72 if ( path2002.isNull() || path2003.isNull() ) {
73 // Only have one MSVC, so use that one
74 current_version = (path2003.isNull() ? 70 : 71);
75 } else {
76 // Have both, so figure out the current
77 QString paths = getenv("PATH");
78 QStringList pathlist = QStringList::split(";", paths.lower());
79
80 path2003 = path2003.lower();
81 QStringList::iterator it;
82 for(it=pathlist.begin(); it!=pathlist.end(); ++it) {
83 if ((*it).contains(path2003)) {
84 current_version = 71;
85 } else if ((*it).contains(path2002)
86 && current_version == 71) {
87 fprintf( stderr, "Both .NET 2002 & .NET 2003 directories for VC found in you PATH variable!\nFallback to .NET 2002 project generation" );
88 current_version = 70;
89 break;
90 }
91 }
92 }
93 return (current_version==71);
58#endif 94#endif
95};
59 96
60// Flatfile Tags ---------------------------------------------------- 97// Flatfile Tags ----------------------------------------------------
61 const char* _snlHeader = "Microsoft Visual Studio Solution File, Format Version 7.00"; 98 const char* _slnHeader70= "Microsoft Visual Studio Solution File, Format Version 7.00";
99 const char* _slnHeader71= "Microsoft Visual Studio Solution File, Format Version 8.00";
62 // The following UUID _may_ change for later servicepacks... 100 // The following UUID _may_ change for later servicepacks...
63 // If so we need to search through the registry at 101 // If so we need to search through the registry at
64 // HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.0\Projects 102 // HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.0\Projects
@@ -66,22 +104,25 @@ const char* _snlHeader = "Microsoft Visual Studio Solution File, Format Version
66 // containing "vcproj"... 104 // containing "vcproj"...
67 // Use the hardcoded value for now so projects generated on other 105 // Use the hardcoded value for now so projects generated on other
68 // platforms are actually usable. 106 // platforms are actually usable.
69const char* _snlMSVCvcprojGUID = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"; 107const char* _slnMSVCvcprojGUID = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}";
70 const char* _snlProjectBeg= "\nProject(\""; 108 const char* _slnProjectBeg= "\nProject(\"";
71 const char* _snlProjectMid= "\") = "; 109 const char* _slnProjectMid= "\") = ";
72 const char* _snlProjectEnd= "\nEndProject"; 110 const char* _slnProjectEnd= "\nEndProject";
73 const char* _snlGlobalBeg= "\nGlobal"; 111 const char* _slnGlobalBeg= "\nGlobal";
74 const char* _snlGlobalEnd= "\nEndGlobal"; 112 const char* _slnGlobalEnd= "\nEndGlobal";
75 const char* _snlSolutionConf= "\n\tGlobalSection(SolutionConfiguration) = preSolution" 113 const char* _slnSolutionConf= "\n\tGlobalSection(SolutionConfiguration) = preSolution"
76 "\n\t\tConfigName.0 = Release" 114 "\n\t\tConfigName.0 = Debug"
115 "\n\t\tConfigName.1 = Release"
77 "\n\tEndGlobalSection"; 116 "\n\tEndGlobalSection";
78 const char* _snlProjDepBeg= "\n\tGlobalSection(ProjectDependencies) = postSolution"; 117 const char* _slnProjDepBeg= "\n\tGlobalSection(ProjectDependencies) = postSolution";
79 const char* _snlProjDepEnd= "\n\tEndGlobalSection"; 118 const char* _slnProjDepEnd= "\n\tEndGlobalSection";
80 const char* _snlProjConfBeg= "\n\tGlobalSection(ProjectConfiguration) = postSolution"; 119 const char* _slnProjConfBeg= "\n\tGlobalSection(ProjectConfiguration) = postSolution";
81 const char* _snlProjConfTag1= ".Release.ActiveCfg = Release|Win32"; 120 const char* _slnProjRelConfTag1= ".Release.ActiveCfg = Release|Win32";
82 const char* _snlProjConfTag2= ".Release.Build.0 = Release|Win32"; 121 const char* _slnProjRelConfTag2= ".Release.Build.0 = Release|Win32";
83 const char* _snlProjConfEnd= "\n\tEndGlobalSection"; 122 const char* _slnProjDbgConfTag1= ".Debug.ActiveCfg = Debug|Win32";
84 const char* _snlExtSections= "\n\tGlobalSection(ExtensibilityGlobals) = postSolution" 123 const char* _slnProjDbgConfTag2= ".Debug.Build.0 = Debug|Win32";
124 const char* _slnProjConfEnd= "\n\tEndGlobalSection";
125 const char* _slnExtSections= "\n\tGlobalSection(ExtensibilityGlobals) = postSolution"
85 "\n\tEndGlobalSection" 126 "\n\tEndGlobalSection"
86 "\n\tGlobalSection(ExtensibilityAddIns) = postSolution" 127 "\n\tGlobalSection(ExtensibilityAddIns) = postSolution"
87 "\n\tEndGlobalSection"; 128 "\n\tEndGlobalSection";
@@ -126,9 +167,39 @@ struct VcsolutionDepend {
126 QString uuid; 167 QString uuid;
127 QString vcprojFile, orig_target, target; 168 QString vcprojFile, orig_target, target;
128 ::target targetType; 169 ::target targetType;
170 bool debugBuild;
129 QStringList dependencies; 171 QStringList dependencies;
130}; 172};
131 173
174QUuid VcprojGenerator::getProjectUUID(const QString &filename)
175{
176 bool validUUID = true;
177
178 // Read GUID from variable-space
179 QUuid uuid = project->first("GUID");
180
181 // If none, create one based on the MD5 of absolute project path
182 if (uuid.isNull() || !filename.isNull()) {
183 QString abspath = filename.isNull()?project->first("QMAKE_MAKEFILE"):filename;
184 qtMD5(abspath.utf8(), (unsigned char*)(&uuid));
185 validUUID = !uuid.isNull();
186 uuid.data4[0] = (uuid.data4[0] & 0x3F) | 0x80; // UV_DCE variant
187 uuid.data3 = (uuid.data3 & 0x0FFF) | (QUuid::Name<<12);
188 }
189
190 // If still not valid, generate new one, and suggest adding to .pro
191 if (uuid.isNull() || !validUUID) {
192 uuid = QUuid::createUuid();
193 fprintf(stderr,
194 "qmake couldn't create a GUID based on filepath, and we couldn't\nfind a valid GUID in the .pro file (Consider adding\n'GUID = %s' to the .pro file)\n",
195 uuid.toString().upper().latin1());
196 }
197
198 // Store GUID in variable-space
199 project->values("GUID") = uuid.toString().upper();
200 return uuid;
201}
202
132QUuid VcprojGenerator::increaseUUID( const QUuid &id ) 203QUuid VcprojGenerator::increaseUUID( const QUuid &id )
133{ 204{
134 QUuid result( id ); 205 QUuid result( id );
@@ -163,24 +234,17 @@ void VcprojGenerator::writeSubDirs(QTextStream &t)
163 return; 234 return;
164 } 235 }
165 236
166 t << _snlHeader; 237 t << (use_net2003_version() ? _slnHeader71 : _slnHeader70);
167 QUuid solutionGUID;
168#if defined(Q_WS_WIN32)
169 GUID guid;
170 HRESULT h = CoCreateGuid( &guid );
171 if ( h == S_OK )
172 solutionGUID = QUuid( guid );
173#else
174 // Qt doesn't support GUID on other platforms yet,
175 // so we use the all-zero uuid, and increase that.
176#endif
177
178 238
179 QDict<VcsolutionDepend> solution_depends; 239 QDict<VcsolutionDepend> solution_depends;
240
180 QPtrList<VcsolutionDepend> solution_cleanup; 241 QPtrList<VcsolutionDepend> solution_cleanup;
181 solution_cleanup.setAutoDelete(TRUE); 242 solution_cleanup.setAutoDelete(TRUE);
243
244
182 QStringList subdirs = project->variables()["SUBDIRS"]; 245 QStringList subdirs = project->variables()["SUBDIRS"];
183 QString oldpwd = QDir::currentDirPath(); 246 QString oldpwd = QDir::currentDirPath();
247
184 for(QStringList::Iterator it = subdirs.begin(); it != subdirs.end(); ++it) { 248 for(QStringList::Iterator it = subdirs.begin(); it != subdirs.end(); ++it) {
185 QFileInfo fi(Option::fixPathToLocalOS((*it), TRUE)); 249 QFileInfo fi(Option::fixPathToLocalOS((*it), TRUE));
186 if(fi.exists()) { 250 if(fi.exists()) {
@@ -199,8 +263,7 @@ void VcprojGenerator::writeSubDirs(QTextStream &t)
199 } 263 }
200 if(tmp_proj.read(fn, oldpwd)) { 264 if(tmp_proj.read(fn, oldpwd)) {
201 if(tmp_proj.first("TEMPLATE") == "vcsubdirs") { 265 if(tmp_proj.first("TEMPLATE") == "vcsubdirs") {
202 QStringList tmp_subdirs = fileFixify(tmp_proj.variables()["SUBDIRS"]); 266 subdirs += fileFixify(tmp_proj.variables()["SUBDIRS"]);
203 subdirs += tmp_subdirs;
204 } else if(tmp_proj.first("TEMPLATE") == "vcapp" || tmp_proj.first("TEMPLATE") == "vclib") { 267 } else if(tmp_proj.first("TEMPLATE") == "vcapp" || tmp_proj.first("TEMPLATE") == "vclib") {
205 // Initialize a 'fake' project to get the correct variables 268 // Initialize a 'fake' project to get the correct variables
206 // and to be able to extract all the dependencies 269 // and to be able to extract all the dependencies
@@ -223,25 +286,27 @@ void VcprojGenerator::writeSubDirs(QTextStream &t)
223 // If file doesn't exsist, then maybe the users configuration 286 // If file doesn't exsist, then maybe the users configuration
224 // doesn't allow it to be created. Skip to next... 287 // doesn't allow it to be created. Skip to next...
225 if(!QFile::exists(QDir::currentDirPath() + Option::dir_sep + vcproj)) { 288 if(!QFile::exists(QDir::currentDirPath() + Option::dir_sep + vcproj)) {
226 qDebug( "Ignored (not found) '%s'", QString(QDir::currentDirPath() + Option::dir_sep + vcproj).latin1() ); 289 warn_msg(WarnLogic, "Ignored (not found) '%s'", QString(QDir::currentDirPath() + Option::dir_sep + vcproj).latin1() );
227 goto nextfile; // # Dirty! 290 goto nextfile; // # Dirty!
228 } 291 }
229 292
230 VcsolutionDepend *newDep = new VcsolutionDepend; 293 VcsolutionDepend *newDep = new VcsolutionDepend;
231 newDep->vcprojFile = fileFixify(vcproj); 294 newDep->vcprojFile = fileFixify(vcproj);
232 newDep->orig_target = tmp_proj.first("QMAKE_ORIG_TARGET"); 295 newDep->orig_target = tmp_proj.first("QMAKE_ORIG_TARGET");
233 newDep->target = tmp_proj.first("TARGET").section(Option::dir_sep, -1); 296 newDep->target = tmp_proj.first("MSVCPROJ_TARGET").section(Option::dir_sep, -1);
234 newDep->targetType = tmp_vcproj.projectTarget; 297 newDep->targetType = tmp_vcproj.projectTarget;
235 { 298 newDep->debugBuild = tmp_proj.isActiveConfig("debug");
236 static QUuid uuid = solutionGUID; 299 newDep->uuid = getProjectUUID(Option::fixPathToLocalOS(QDir::currentDirPath() + QDir::separator() + vcproj)).toString().upper();
237 uuid = increaseUUID( uuid ); 300
238 newDep->uuid = uuid.toString().upper(); 301 // We want to store it as the .lib name.
239 }
240 if(newDep->target.endsWith(".dll")) 302 if(newDep->target.endsWith(".dll"))
241 newDep->target = newDep->target.left(newDep->target.length()-3) + "lib"; 303 newDep->target = newDep->target.left(newDep->target.length()-3) + "lib";
304
305 // All projects using Forms are dependent on uic.exe
242 if(!tmp_proj.isEmpty("FORMS")) 306 if(!tmp_proj.isEmpty("FORMS"))
243 newDep->dependencies << "uic.exe"; 307 newDep->dependencies << "uic.exe";
244 { 308
309 // Add all unknown libs to the deps
245 QStringList where("QMAKE_LIBS"); 310 QStringList where("QMAKE_LIBS");
246 if(!tmp_proj.isEmpty("QMAKE_INTERNAL_PRL_LIBS")) 311 if(!tmp_proj.isEmpty("QMAKE_INTERNAL_PRL_LIBS"))
247 where = tmp_proj.variables()["QMAKE_INTERNAL_PRL_LIBS"]; 312 where = tmp_proj.variables()["QMAKE_INTERNAL_PRL_LIBS"];
@@ -250,23 +315,38 @@ void VcprojGenerator::writeSubDirs(QTextStream &t)
250 QStringList &l = tmp_proj.variables()[(*wit)]; 315 QStringList &l = tmp_proj.variables()[(*wit)];
251 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 316 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
252 QString opt = (*it); 317 QString opt = (*it);
253 if(!opt.startsWith("/")) //Not a switch 318 if(!opt.startsWith("/") && // Not a switch
319 opt != newDep->target && // Not self
320 opt != "opengl32.lib" && // We don't care about these libs
321 opt != "glu32.lib" && // to make depgen alittle faster
322 opt != "kernel32.lib" &&
323 opt != "user32.lib" &&
324 opt != "gdi32.lib" &&
325 opt != "comdlg32.lib" &&
326 opt != "advapi32.lib" &&
327 opt != "shell32.lib" &&
328 opt != "ole32.lib" &&
329 opt != "oleaut32.lib" &&
330 opt != "uuid.lib" &&
331 opt != "imm32.lib" &&
332 opt != "winmm.lib" &&
333 opt != "wsock32.lib" &&
334 opt != "winspool.lib" &&
335 opt != "delayimp.lib" )
336 {
254 newDep->dependencies << opt.section(Option::dir_sep, -1); 337 newDep->dependencies << opt.section(Option::dir_sep, -1);
255 } 338 }
256 } 339 }
257 } 340 }
341#ifdef DEBUG_SOLUTION_GEN
342 qDebug( "Deps for %20s: [%s]", newDep->target.latin1(), newDep->dependencies.join(" :: " ).latin1() );
343#endif
258 solution_cleanup.append(newDep); 344 solution_cleanup.append(newDep);
259 solution_depends.insert(newDep->target, newDep); 345 solution_depends.insert(newDep->target, newDep);
260 { 346 t << _slnProjectBeg << _slnMSVCvcprojGUID << _slnProjectMid
261 QRegExp libVersion("[0-9]{3,3}\\.lib$");
262 if(libVersion.search(newDep->target) != -1)
263 solution_depends.insert(newDep->target.left(newDep->target.length() -
264 libVersion.matchedLength()) + ".lib", newDep);
265 }
266 t << _snlProjectBeg << _snlMSVCvcprojGUID << _snlProjectMid
267 << "\"" << newDep->orig_target << "\", \"" << newDep->vcprojFile 347 << "\"" << newDep->orig_target << "\", \"" << newDep->vcprojFile
268 << "\", \"" << newDep->uuid << "\""; 348 << "\", \"" << newDep->uuid << "\"";
269 t << _snlProjectEnd; 349 t << _slnProjectEnd;
270 } 350 }
271 } 351 }
272nextfile: 352nextfile:
@@ -274,30 +354,35 @@ nextfile:
274 } 354 }
275 } 355 }
276 } 356 }
277 t << _snlGlobalBeg; 357 t << _slnGlobalBeg;
278 t << _snlSolutionConf; 358 t << _slnSolutionConf;
279 t << _snlProjDepBeg; 359 t << _slnProjDepBeg;
360
361 // Figure out dependencies
280 for(solution_cleanup.first(); solution_cleanup.current(); solution_cleanup.next()) { 362 for(solution_cleanup.first(); solution_cleanup.current(); solution_cleanup.next()) {
363 if(solution_cleanup.current()->targetType == StaticLib)
364 continue; // Shortcut, Static libs are not dep.
281 int cnt = 0; 365 int cnt = 0;
282 for(QStringList::iterator dit = solution_cleanup.current()->dependencies.begin(); 366 for(QStringList::iterator dit = solution_cleanup.current()->dependencies.begin();
283 dit != solution_cleanup.current()->dependencies.end(); 367 dit != solution_cleanup.current()->dependencies.end();
284 ++dit) { 368 ++dit)
285 VcsolutionDepend *vc; 369 {
286 if((vc=solution_depends[*dit])) { 370 VcsolutionDepend *vc = solution_depends[*dit];
287 if(solution_cleanup.current()->targetType != StaticLib || vc->targetType == Application) 371 if(vc)
288 t << "\n\t\t" << solution_cleanup.current()->uuid << "." << cnt++ << " = " << vc->uuid; 372 t << "\n\t\t" << solution_cleanup.current()->uuid << "." << cnt++ << " = " << vc->uuid;
289 } 373 }
290 } 374 }
291 } 375 t << _slnProjDepEnd;
292 t << _snlProjDepEnd; 376 t << _slnProjConfBeg;
293 t << _snlProjConfBeg;
294 for(solution_cleanup.first(); solution_cleanup.current(); solution_cleanup.next()) { 377 for(solution_cleanup.first(); solution_cleanup.current(); solution_cleanup.next()) {
295 t << "\n\t\t" << solution_cleanup.current()->uuid << _snlProjConfTag1; 378 t << "\n\t\t" << solution_cleanup.current()->uuid << _slnProjDbgConfTag1;
296 t << "\n\t\t" << solution_cleanup.current()->uuid << _snlProjConfTag2; 379 t << "\n\t\t" << solution_cleanup.current()->uuid << _slnProjDbgConfTag2;
380 t << "\n\t\t" << solution_cleanup.current()->uuid << _slnProjRelConfTag1;
381 t << "\n\t\t" << solution_cleanup.current()->uuid << _slnProjRelConfTag2;
297 } 382 }
298 t << _snlProjConfEnd; 383 t << _slnProjConfEnd;
299 t << _snlExtSections; 384 t << _slnExtSections;
300 t << _snlGlobalEnd; 385 t << _slnGlobalEnd;
301} 386}
302 387
303// ------------------------------------------------------------------------------------------------ 388// ------------------------------------------------------------------------------------------------
@@ -369,6 +454,24 @@ void VcprojGenerator::init()
369 else 454 else
370 projectTarget = SharedLib; 455 projectTarget = SharedLib;
371 } 456 }
457
458 // Setup PCH variables
459 precompH = project->first("PRECOMPILED_HEADER");
460 usePCH = !precompH.isEmpty() && project->isActiveConfig("precompile_header");
461 if (usePCH) {
462 precompHFilename = QFileInfo(precompH).fileName();
463 // Created files
464 QString origTarget = project->first("QMAKE_ORIG_TARGET");
465 precompObj = origTarget + Option::obj_ext;
466 precompPch = origTarget + ".pch";
467 // Add PRECOMPILED_HEADER to HEADERS
468 if (!project->variables()["HEADERS"].contains(precompH))
469 project->variables()["HEADERS"] += precompH;
470 // Return to variable pool
471 project->variables()["PRECOMPILED_OBJECT"] = precompObj;
472 project->variables()["PRECOMPILED_PCH"] = precompPch;
473 }
474
372 initProject(); // Fills the whole project with proper data 475 initProject(); // Fills the whole project with proper data
373} 476}
374 477
@@ -389,8 +492,9 @@ void VcprojGenerator::initProject()
389 492
390 // Own elements ----------------------------- 493 // Own elements -----------------------------
391 vcProject.Name = project->first("QMAKE_ORIG_TARGET"); 494 vcProject.Name = project->first("QMAKE_ORIG_TARGET");
392 vcProject.Version = "7.00"; 495 vcProject.Version = use_net2003_version() ? "7.10" : "7.00";
393 vcProject.PlatformName = ( vcProject.Configuration.idl.TargetEnvironment == midlTargetWin64 ? "Win64" : "Win32" ); 496 vcProject.ProjectGUID = getProjectUUID().toString().upper();
497 vcProject.PlatformName = ( vcProject.Configuration[0].idl.TargetEnvironment == midlTargetWin64 ? "Win64" : "Win32" );
394 // These are not used by Qt, but may be used by customers 498 // These are not used by Qt, but may be used by customers
395 vcProject.SccProjectName = project->first("SCCPROJECTNAME"); 499 vcProject.SccProjectName = project->first("SCCPROJECTNAME");
396 vcProject.SccLocalPath = project->first("SCCLOCALPATH"); 500 vcProject.SccLocalPath = project->first("SCCLOCALPATH");
@@ -412,35 +516,37 @@ void VcprojGenerator::initConfiguration()
412 QString temp = project->first("BuildBrowserInformation"); 516 QString temp = project->first("BuildBrowserInformation");
413 switch ( projectTarget ) { 517 switch ( projectTarget ) {
414 case SharedLib: 518 case SharedLib:
415 vcProject.Configuration.ConfigurationType = typeDynamicLibrary; 519 vcProject.Configuration[0].ConfigurationType = typeDynamicLibrary;
416 break; 520 break;
417 case StaticLib: 521 case StaticLib:
418 vcProject.Configuration.ConfigurationType = typeStaticLibrary; 522 vcProject.Configuration[0].ConfigurationType = typeStaticLibrary;
419 break; 523 break;
420 case Application: 524 case Application:
421 default: 525 default:
422 vcProject.Configuration.ConfigurationType = typeApplication; 526 vcProject.Configuration[0].ConfigurationType = typeApplication;
423 break; 527 break;
424 } 528 }
425 vcProject.Configuration.Name = ( project->isActiveConfig( "debug" ) ? "Debug|" : "Release|" ); 529
426 vcProject.Configuration.Name += ( vcProject.Configuration.idl.TargetEnvironment == midlTargetWin64 ? "Win64" : "Win32" ); 530 // Release version of the Configuration ---------------
427 vcProject.Configuration.ATLMinimizesCRunTimeLibraryUsage = ( project->first("ATLMinimizesCRunTimeLibraryUsage").isEmpty() ? _False : _True ); 531 VCConfiguration &RConf = vcProject.Configuration[0];
428 vcProject.Configuration.BuildBrowserInformation = triState( temp.isEmpty() ? (short)unset : temp.toShort() ); 532 RConf.Name = "Release";
533 RConf.Name += ( RConf.idl.TargetEnvironment == midlTargetWin64 ? "|Win64" : "|Win32" );
534 RConf.ATLMinimizesCRunTimeLibraryUsage = ( project->first("ATLMinimizesCRunTimeLibraryUsage").isEmpty() ? _False : _True );
535 RConf.BuildBrowserInformation = triState( temp.isEmpty() ? (short)unset : temp.toShort() );
429 temp = project->first("CharacterSet"); 536 temp = project->first("CharacterSet");
430 vcProject.Configuration.CharacterSet = charSet( temp.isEmpty() ? (short)charSetNotSet : temp.toShort() ); 537 RConf.CharacterSet = charSet( temp.isEmpty() ? (short)charSetNotSet : temp.toShort() );
431 vcProject.Configuration.DeleteExtensionsOnClean = project->first("DeleteExtensionsOnClean"); 538 RConf.DeleteExtensionsOnClean = project->first("DeleteExtensionsOnClean");
432 vcProject.Configuration.ImportLibrary = vcProject.Configuration.linker.ImportLibrary; 539 RConf.ImportLibrary = RConf.linker.ImportLibrary;
433 vcProject.Configuration.IntermediateDirectory = project->first("OBJECTS_DIR"); 540 RConf.IntermediateDirectory = project->first("OBJECTS_DIR");
434// temp = (projectTarget == StaticLib) ? project->first("DESTDIR"):project->first("DLLDESTDIR"); 541 RConf.OutputDirectory = ".";
435 vcProject.Configuration.OutputDirectory = "."; //( temp.isEmpty() ? QString(".") : temp ); 542 RConf.PrimaryOutput = project->first("PrimaryOutput");
436 vcProject.Configuration.PrimaryOutput = project->first("PrimaryOutput"); 543 RConf.WholeProgramOptimization = RConf.compiler.WholeProgramOptimization;
437 vcProject.Configuration.WholeProgramOptimization = vcProject.Configuration.compiler.WholeProgramOptimization;
438 temp = project->first("UseOfATL"); 544 temp = project->first("UseOfATL");
439 if ( !temp.isEmpty() ) 545 if ( !temp.isEmpty() )
440 vcProject.Configuration.UseOfATL = useOfATL( temp.toShort() ); 546 RConf.UseOfATL = useOfATL( temp.toShort() );
441 temp = project->first("UseOfMfc"); 547 temp = project->first("UseOfMfc");
442 if ( !temp.isEmpty() ) 548 if ( !temp.isEmpty() )
443 vcProject.Configuration.UseOfMfc = useOfMfc( temp.toShort() ); 549 RConf.UseOfMfc = useOfMfc( temp.toShort() );
444 550
445 // Configuration does not need parameters from 551 // Configuration does not need parameters from
446 // these sub XML items; 552 // these sub XML items;
@@ -448,6 +554,39 @@ void VcprojGenerator::initConfiguration()
448 initPreBuildEventTools(); 554 initPreBuildEventTools();
449 initPostBuildEventTools(); 555 initPostBuildEventTools();
450 initPreLinkEventTools(); 556 initPreLinkEventTools();
557
558 // Debug version of the Configuration -----------------
559 VCConfiguration DConf = vcProject.Configuration[0]; // Create copy configuration for debug
560 DConf.Name = "Debug";
561 DConf.Name += ( DConf.idl.TargetEnvironment == midlTargetWin64 ? "|Win64" : "|Win32" );
562
563 // Set definite values in both configurations
564 DConf.compiler.PreprocessorDefinitions.remove("NDEBUG");
565 RConf.compiler.PreprocessorDefinitions += "NDEBUG";
566 RConf.linker.GenerateDebugInformation = _False;
567 DConf.linker.GenerateDebugInformation = _True;
568
569 // Modify configurations, based on Qt build
570 if ( project->isActiveConfig("debug") ) {
571 RConf.IntermediateDirectory =
572 RConf.compiler.AssemblerListingLocation =
573 RConf.compiler.ObjectFile = "Release\\";
574 RConf.librarian.OutputFile =
575 RConf.linker.OutputFile = RConf.IntermediateDirectory + "\\" + project->first("MSVCPROJ_TARGET");
576 RConf.linker.parseOptions(project->variables()["QMAKE_LFLAGS_RELEASE"]);
577 RConf.compiler.parseOptions(project->variables()["QMAKE_CFLAGS_RELEASE"]);
578 } else {
579 DConf.IntermediateDirectory =
580 DConf.compiler.AssemblerListingLocation =
581 DConf.compiler.ObjectFile = "Debug\\";
582 DConf.librarian.OutputFile =
583 DConf.linker.OutputFile = DConf.IntermediateDirectory + "\\" + project->first("MSVCPROJ_TARGET");
584 DConf.linker.DelayLoadDLLs.clear();
585 DConf.compiler.parseOptions(project->variables()["QMAKE_CFLAGS_DEBUG"]);
586 }
587
588 // Add Debug configuration to project
589 vcProject.Configuration += DConf;
451} 590}
452 591
453void VcprojGenerator::initCompilerTool() 592void VcprojGenerator::initCompilerTool()
@@ -456,109 +595,129 @@ void VcprojGenerator::initCompilerTool()
456 if ( placement.isEmpty() ) 595 if ( placement.isEmpty() )
457 placement = ".\\"; 596 placement = ".\\";
458 597
459 vcProject.Configuration.compiler.AssemblerListingLocation = placement ; 598 VCConfiguration &RConf = vcProject.Configuration[0];
460 vcProject.Configuration.compiler.ProgramDataBaseFileName = placement ; 599 RConf.compiler.AssemblerListingLocation = placement ;
461 vcProject.Configuration.compiler.ObjectFile = placement ; 600 RConf.compiler.ProgramDataBaseFileName = ".\\" ;
462 vcProject.Configuration.compiler.PrecompiledHeaderFile = placement + project->first("QMAKE_ORIG_TARGET") + ".pch"; 601 RConf.compiler.ObjectFile = placement ;
602 // PCH
603 if ( usePCH ) {
604 RConf.compiler.UsePrecompiledHeader = pchUseUsingSpecific;
605 RConf.compiler.PrecompiledHeaderFile = "$(IntDir)\\" + precompPch;
606 RConf.compiler.PrecompiledHeaderThrough = precompHFilename;
607 RConf.compiler.ForcedIncludeFiles = precompHFilename;
608 // Minimal build option triggers an Internal Compiler Error
609 // when used in conjunction with /FI and /Yu, so remove it
610 project->variables()["QMAKE_CFLAGS_DEBUG"].remove("-Gm");
611 project->variables()["QMAKE_CFLAGS_DEBUG"].remove("/Gm");
612 project->variables()["QMAKE_CXXFLAGS_DEBUG"].remove("-Gm");
613 project->variables()["QMAKE_CXXFLAGS_DEBUG"].remove("/Gm");
614 }
463 615
464 if ( project->isActiveConfig("debug") ){ 616 if ( project->isActiveConfig("debug") ){
465 // Debug version 617 // Debug version
466 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS"] ); 618 RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS"] );
467 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_DEBUG"] ); 619 RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_DEBUG"] );
468 if ( project->isActiveConfig("thread") ) { 620 if ( project->isActiveConfig("thread") ) {
469 if ( (projectTarget == Application) || (projectTarget == StaticLib) ) 621 if ( (projectTarget == Application) || (projectTarget == StaticLib) )
470 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DBG"] ); 622 RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DBG"] );
471 else 623 else
472 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"] ); 624 RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"] );
473 } else { 625 } else {
474 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_ST_DBG"] ); 626 RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DBG"] );
475 } 627 }
476 } else { 628 } else {
477 // Release version 629 // Release version
478 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS"] ); 630 RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS"] );
479 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_RELEASE"] ); 631 RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_RELEASE"] );
480 vcProject.Configuration.compiler.PreprocessorDefinitions += "QT_NO_DEBUG"; 632 RConf.compiler.PreprocessorDefinitions += "QT_NO_DEBUG";
481 vcProject.Configuration.compiler.PreprocessorDefinitions += "NDEBUG"; 633 RConf.compiler.PreprocessorDefinitions += "NDEBUG";
482 if ( project->isActiveConfig("thread") ) { 634 if ( project->isActiveConfig("thread") ) {
483 if ( (projectTarget == Application) || (projectTarget == StaticLib) ) 635 if ( (projectTarget == Application) || (projectTarget == StaticLib) )
484 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT"] ); 636 RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT"] );
485 else 637 else
486 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DLL"] ); 638 RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DLL"] );
487 } else { 639 } else {
488 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_ST"] ); 640 RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT"] );
489 } 641 }
490 } 642 }
491 643
492 // Common for both release and debug 644 // Common for both release and debug
493 if ( project->isActiveConfig("warn_off") ) 645 if ( project->isActiveConfig("warn_off") )
494 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_OFF"] ); 646 RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_OFF"] );
495 else if ( project->isActiveConfig("warn_on") ) 647 else if ( project->isActiveConfig("warn_on") )
496 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_ON"] ); 648 RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_ON"] );
497 if ( project->isActiveConfig("windows") ) 649 if ( project->isActiveConfig("windows") )
498 vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["MSVCPROJ_WINCONDEF"]; 650 RConf.compiler.PreprocessorDefinitions += project->variables()["MSVCPROJ_WINCONDEF"];
499 651
500 // Can this be set for ALL configs? 652 // Can this be set for ALL configs?
501 // If so, use qmake.conf! 653 // If so, use qmake.conf!
502 if ( projectTarget == SharedLib ) 654 if ( projectTarget == SharedLib )
503 vcProject.Configuration.compiler.PreprocessorDefinitions += "_WINDOWS"; 655 RConf.compiler.PreprocessorDefinitions += "_WINDOWS";
656
657 RConf.compiler.PreprocessorDefinitions += project->variables()["DEFINES"];
658 RConf.compiler.PreprocessorDefinitions += project->variables()["PRL_EXPORT_DEFINES"];
659 QStringList::iterator it;
660 for(it=RConf.compiler.PreprocessorDefinitions.begin();
661 it!=RConf.compiler.PreprocessorDefinitions.end();
662 ++it)
663 (*it).replace('\"', "&quot;");
504 664
505 vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["DEFINES"]; 665 RConf.compiler.parseOptions( project->variables()["MSVCPROJ_INCPATH"] );
506 vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["PRL_EXPORT_DEFINES"];
507 vcProject.Configuration.compiler.parseOptions( project->variables()["MSVCPROJ_INCPATH"] );
508} 666}
509 667
510void VcprojGenerator::initLibrarianTool() 668void VcprojGenerator::initLibrarianTool()
511{ 669{
512 vcProject.Configuration.librarian.OutputFile = project->first( "DESTDIR" ); 670 VCConfiguration &RConf = vcProject.Configuration[0];
513 if( vcProject.Configuration.librarian.OutputFile.isEmpty() ) 671 RConf.librarian.OutputFile = project->first( "DESTDIR" );
514 vcProject.Configuration.librarian.OutputFile = ".\\"; 672 if( RConf.librarian.OutputFile.isEmpty() )
673 RConf.librarian.OutputFile = ".\\";
515 674
516 if( !vcProject.Configuration.librarian.OutputFile.endsWith("\\") ) 675 if( !RConf.librarian.OutputFile.endsWith("\\") )
517 vcProject.Configuration.librarian.OutputFile += '\\'; 676 RConf.librarian.OutputFile += '\\';
518 677
519 vcProject.Configuration.librarian.OutputFile += project->first("MSVCPROJ_TARGET"); 678 RConf.librarian.OutputFile += project->first("MSVCPROJ_TARGET");
520} 679}
521 680
522void VcprojGenerator::initLinkerTool() 681void VcprojGenerator::initLinkerTool()
523{ 682{
524 vcProject.Configuration.linker.parseOptions( project->variables()["MSVCPROJ_LFLAGS"] ); 683 VCConfiguration &RConf = vcProject.Configuration[0];
525 vcProject.Configuration.linker.AdditionalDependencies += project->variables()["MSVCPROJ_LIBS"]; 684 RConf.linker.parseOptions( project->variables()["MSVCPROJ_LFLAGS"] );
685 RConf.linker.AdditionalDependencies += project->variables()["MSVCPROJ_LIBS"];
526 686
527 switch ( projectTarget ) { 687 switch ( projectTarget ) {
528 case Application: 688 case Application:
529 vcProject.Configuration.linker.OutputFile = project->first( "DESTDIR" ); 689 RConf.linker.OutputFile = project->first( "DESTDIR" );
530 break; 690 break;
531 case SharedLib: 691 case SharedLib:
532 vcProject.Configuration.linker.parseOptions( project->variables()["MSVCPROJ_LIBOPTIONS"] ); 692 RConf.linker.parseOptions( project->variables()["MSVCPROJ_LIBOPTIONS"] );
533 vcProject.Configuration.linker.OutputFile = project->first( "DLLDESTDIR" ); 693 RConf.linker.OutputFile = project->first( "DESTDIR" );
534 break; 694 break;
535 case StaticLib: //unhandled - added to remove warnings.. 695 case StaticLib: //unhandled - added to remove warnings..
536 break; 696 break;
537 } 697 }
538 698
539 if( vcProject.Configuration.linker.OutputFile.isEmpty() ) 699 if( RConf.linker.OutputFile.isEmpty() )
540 vcProject.Configuration.linker.OutputFile = ".\\"; 700 RConf.linker.OutputFile = ".\\";
541 701
542 if( !vcProject.Configuration.linker.OutputFile.endsWith("\\") ) 702 if( !RConf.linker.OutputFile.endsWith("\\") )
543 vcProject.Configuration.linker.OutputFile += '\\'; 703 RConf.linker.OutputFile += '\\';
544 704
545 vcProject.Configuration.linker.OutputFile += project->first("MSVCPROJ_TARGET"); 705 RConf.linker.OutputFile += project->first("MSVCPROJ_TARGET");
546 vcProject.Configuration.linker.ProgramDatabaseFile = project->first("OBJECTS_DIR") + project->first("QMAKE_ORIG_TARGET") + ".pdb";
547 706
548 if ( project->isActiveConfig("debug") ){ 707 if ( project->isActiveConfig("debug") ){
549 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_DEBUG"] ); 708 RConf.linker.parseOptions( project->variables()["QMAKE_LFLAGS_DEBUG"] );
550 } else { 709 } else {
551 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_RELEASE"] ); 710 RConf.linker.parseOptions( project->variables()["QMAKE_LFLAGS_RELEASE"] );
552 } 711 }
553 712
554 if ( project->isActiveConfig("dll") ){ 713 if ( project->isActiveConfig("dll") ){
555 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_QT_DLL"] ); 714 RConf.linker.parseOptions( project->variables()["QMAKE_LFLAGS_QT_DLL"] );
556 } 715 }
557 716
558 if ( project->isActiveConfig("console") ){ 717 if ( project->isActiveConfig("console") ){
559 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_CONSOLE"] ); 718 RConf.linker.parseOptions( project->variables()["QMAKE_LFLAGS_CONSOLE"] );
560 } else { 719 } else {
561 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_WINDOWS"] ); 720 RConf.linker.parseOptions( project->variables()["QMAKE_LFLAGS_WINDOWS"] );
562 } 721 }
563 722
564} 723}
@@ -573,32 +732,22 @@ void VcprojGenerator::initCustomBuildTool()
573 732
574void VcprojGenerator::initPreBuildEventTools() 733void VcprojGenerator::initPreBuildEventTools()
575{ 734{
576 QString collectionName = project->first("QMAKE_IMAGE_COLLECTION");
577 if( !collectionName.isEmpty() ) {
578 QStringList& list = project->variables()["IMAGES"];
579 vcProject.Configuration.preBuild.Description = "Generate imagecollection";
580 //vcProject.Configuration.preBuild.AdditionalDependencies += list;
581
582 QFile imgs( ".imgcol" );
583 imgs.open( IO_WriteOnly );
584 QTextStream s( &imgs );
585 QStringList::ConstIterator it = list.begin();
586 while( it!=list.end() ) {
587 s << *it << " ";
588 it++;
589 }
590
591 vcProject.Configuration.preBuild.CommandLine = project->first("QMAKE_UIC") + " -embed " + project->first("QMAKE_ORIG_TARGET") + " -f .imgcol -o " + collectionName;
592 //vcProject.Configuration.preBuild.Outputs = collectionName;
593
594 }
595} 735}
596 736
597void VcprojGenerator::initPostBuildEventTools() 737void VcprojGenerator::initPostBuildEventTools()
598{ 738{
739 VCConfiguration &RConf = vcProject.Configuration[0];
599 if ( !project->variables()["QMAKE_POST_LINK"].isEmpty() ) { 740 if ( !project->variables()["QMAKE_POST_LINK"].isEmpty() ) {
600 vcProject.Configuration.postBuild.Description = var("QMAKE_POST_LINK"); 741 RConf.postBuild.Description = var("QMAKE_POST_LINK");
601 vcProject.Configuration.postBuild.CommandLine = var("QMAKE_POST_LINK"); 742 RConf.postBuild.CommandLine = var("QMAKE_POST_LINK");
743 RConf.postBuild.Description.replace(" && ", " &amp;&amp; ");
744 RConf.postBuild.CommandLine.replace(" && ", " &amp;&amp; ");
745 }
746 if ( !project->variables()["MSVCPROJ_COPY_DLL"].isEmpty() ) {
747 if ( !RConf.postBuild.CommandLine.isEmpty() )
748 RConf.postBuild.CommandLine += " &amp;&amp; ";
749 RConf.postBuild.Description += var("MSVCPROJ_COPY_DLL_DESC");
750 RConf.postBuild.CommandLine += var("MSVCPROJ_COPY_DLL");
602 } 751 }
603 if( project->isActiveConfig( "activeqt" ) ) { 752 if( project->isActiveConfig( "activeqt" ) ) {
604 QString name = project->first( "QMAKE_ORIG_TARGET" ); 753 QString name = project->first( "QMAKE_ORIG_TARGET" );
@@ -606,34 +755,30 @@ void VcprojGenerator::initPostBuildEventTools()
606 QString objdir = project->first( "OBJECTS_DIR" ); 755 QString objdir = project->first( "OBJECTS_DIR" );
607 QString idc = project->first( "QMAKE_IDC" ); 756 QString idc = project->first( "QMAKE_IDC" );
608 757
609 vcProject.Configuration.postBuild.Description = "Finalizing ActiveQt server..."; 758 RConf.postBuild.Description = "Finalizing ActiveQt server...";
610 if ( !vcProject.Configuration.postBuild.CommandLine.isEmpty() ) 759 if ( !RConf.postBuild.CommandLine.isEmpty() )
611 vcProject.Configuration.postBuild.CommandLine += " &amp;&amp; "; 760 RConf.postBuild.CommandLine += " &amp;&amp; ";
612 761
613 if( project->isActiveConfig( "dll" ) ) { // In process 762 if( project->isActiveConfig( "dll" ) ) { // In process
614 vcProject.Configuration.postBuild.CommandLine += 763 RConf.postBuild.CommandLine +=
615 // call idc to generate .idl file from .dll 764 // call idc to generate .idl file from .dll
616 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " -idl " + objdir + name + ".idl -version 1.0 &amp;&amp; " + 765 idc + " &quot;$(TargetPath)&quot; -idl " + objdir + name + ".idl -version 1.0 &amp;&amp; " +
617 // call midl to create implementations of the .idl file 766 // call midl to create implementations of the .idl file
618 project->first( "QMAKE_IDL" ) + " " + objdir + name + ".idl /nologo /o " + objdir + name + ".midl /tlb " + objdir + name + ".tlb /iid " + objdir + 767 project->first( "QMAKE_IDL" ) + " /nologo " + objdir + name + ".idl /tlb " + objdir + name + ".tlb &amp;&amp; " +
619 "dump.midl /dlldata " + objdir + "dump.midl /cstub " + objdir + "dump.midl /header " + objdir + "dump.midl /proxy " + objdir + "dump.midl /sstub " +
620 objdir + "dump.midl &amp;&amp; " +
621 // call idc to replace tlb... 768 // call idc to replace tlb...
622 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /tlb " + objdir + name + ".tlb &amp;&amp; " + 769 idc + " &quot;$(TargetPath)&quot; /tlb " + objdir + name + ".tlb &amp;&amp; " +
623 // register server 770 // register server
624 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /regserver"; 771 idc + " &quot;$(TargetPath)&quot; /regserver";
625 } else { // out of process 772 } else { // out of process
626 vcProject.Configuration.postBuild.CommandLine = 773 RConf.postBuild.CommandLine =
627 // call application to dump idl 774 // call application to dump idl
628 vcProject.Configuration.OutputDirectory + "\\" + nameext + " -dumpidl " + objdir + name + ".idl -version 1.0 &amp;&amp; " + 775 "&quot;$(TargetPath)&quot; -dumpidl " + objdir + name + ".idl -version 1.0 &amp;&amp; " +
629 // call midl to create implementations of the .idl file 776 // call midl to create implementations of the .idl file
630 project->first( "QMAKE_IDL" ) + " " + objdir + name + ".idl /nologo /o " + objdir + name + ".midl /tlb " + objdir + name + ".tlb /iid " + objdir + 777 project->first( "QMAKE_IDL" ) + " /nologo " + objdir + name + ".idl /tlb " + objdir + name + ".tlb &amp;&amp; " +
631 "dump.midl /dlldata " + objdir + "dump.midl /cstub " + objdir + "dump.midl /header " + objdir + "dump.midl /proxy " + objdir + "dump.midl /sstub " +
632 objdir + "dump.midl &amp;&amp; " +
633 // call idc to replace tlb... 778 // call idc to replace tlb...
634 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /tlb " + objdir + name + ".tlb &amp;&amp; " + 779 idc + " &quot;$(TargetPath)&quot; /tlb " + objdir + name + ".tlb &amp;&amp; " +
635 // call app to register 780 // call app to register
636 vcProject.Configuration.OutputDirectory + "\\" + nameext + " -regserver"; 781 "&quot;$(TargetPath)&quot; -regserver";
637 } 782 }
638 } 783 }
639} 784}
@@ -642,12 +787,88 @@ void VcprojGenerator::initPreLinkEventTools()
642{ 787{
643} 788}
644 789
790
791// ------------------------------------------------------------------
792// Helper functions to do proper sorting of the
793// qstringlists, for both flat and non-flat modes.
794inline bool XLessThanY( QString &x, QString &y, bool flat_mode )
795{
796 if ( flat_mode ) {
797 QString subX = x.mid( x.findRev('\\')+1 );
798 QString subY = y.mid( y.findRev('\\')+1 );
799 return QString::compare(subX, subY) < 0;
800 }
801
802 int xPos = 0;
803 int yPos = 0;
804 int xSlashPos;
805 int ySlashPos;
806 for (;;) {
807 xSlashPos = x.find('\\', xPos);
808 ySlashPos = y.find('\\', yPos);
809
810 if (xSlashPos == -1 && ySlashPos != -1) {
811 return false;
812 } else if (xSlashPos != -1 && ySlashPos == -1) {
813 return true;
814 } else if (xSlashPos == -1 /* && yySlashPos == -1 */) {
815 QString subX = x.mid(xPos);
816 QString subY = y.mid(yPos);
817 return QString::compare(subX, subY) < 0;
818 } else {
819 QString subX = x.mid(xPos, xSlashPos - xPos);
820 QString subY = y.mid(yPos, ySlashPos - yPos);
821 int cmp = QString::compare(subX, subY);
822 if (cmp != 0)
823 return cmp < 0;
824 }
825 xPos = xSlashPos + 1;
826 yPos = ySlashPos + 1;
827 }
828 return false;
829}
830void nonflatDir_BubbleSort( QStringList& list, bool flat_mode )
831{
832 QStringList::Iterator b = list.begin();
833 QStringList::Iterator e = list.end();
834 QStringList::Iterator last = e;
835 --last; // goto last
836 if ( last == b )// shortcut
837 return;
838 while( b != last ) {// sort them
839 bool swapped = FALSE;
840 QStringList::Iterator swap_pos = b;
841 QStringList::Iterator x = e;
842 QStringList::Iterator y = x;
843 --y;
844 QString swap_str;
845 do {
846 --x;
847 --y;
848 if ( XLessThanY(*x,*y, flat_mode) ) {
849 swapped = TRUE;
850 swap_str = (*x); // Swap -------
851 (*x) = (*y);
852 (*y) = swap_str; // ------------
853 swap_pos = y;
854 }
855 } while( y != b );
856 if ( !swapped )
857 return;
858 b = swap_pos;
859 ++b;
860 }
861}
862// ------------------------------------------------------------------
863
645void VcprojGenerator::initSourceFiles() 864void VcprojGenerator::initSourceFiles()
646{ 865{
866 vcProject.SourceFiles.flat_files = project->isActiveConfig("flat");
647 vcProject.SourceFiles.Name = "Source Files"; 867 vcProject.SourceFiles.Name = "Source Files";
648 vcProject.SourceFiles.Filter = "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"; 868 vcProject.SourceFiles.Filter = "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat";
649 vcProject.SourceFiles.Files += project->variables()["SOURCES"]; 869 vcProject.SourceFiles.Files += project->variables()["SOURCES"];
650 vcProject.SourceFiles.Files.sort(); 870 nonflatDir_BubbleSort( vcProject.SourceFiles.Files,
871 vcProject.SourceFiles.flat_files );
651 vcProject.SourceFiles.Project = this; 872 vcProject.SourceFiles.Project = this;
652 vcProject.SourceFiles.Config = &(vcProject.Configuration); 873 vcProject.SourceFiles.Config = &(vcProject.Configuration);
653 vcProject.SourceFiles.CustomBuild = none; 874 vcProject.SourceFiles.CustomBuild = none;
@@ -655,10 +876,16 @@ void VcprojGenerator::initSourceFiles()
655 876
656void VcprojGenerator::initHeaderFiles() 877void VcprojGenerator::initHeaderFiles()
657{ 878{
879 vcProject.HeaderFiles.flat_files = project->isActiveConfig("flat");
658 vcProject.HeaderFiles.Name = "Header Files"; 880 vcProject.HeaderFiles.Name = "Header Files";
659 vcProject.HeaderFiles.Filter = "h;hpp;hxx;hm;inl"; 881 vcProject.HeaderFiles.Filter = "h;hpp;hxx;hm;inl";
660 vcProject.HeaderFiles.Files += project->variables()["HEADERS"]; 882 vcProject.HeaderFiles.Files += project->variables()["HEADERS"];
661 vcProject.HeaderFiles.Files.sort(); 883 if (usePCH) { // Generated PCH cpp file
884 if (!vcProject.HeaderFiles.Files.contains(precompH))
885 vcProject.HeaderFiles.Files += precompH;
886 }
887 nonflatDir_BubbleSort( vcProject.HeaderFiles.Files,
888 vcProject.HeaderFiles.flat_files );
662 vcProject.HeaderFiles.Project = this; 889 vcProject.HeaderFiles.Project = this;
663 vcProject.HeaderFiles.Config = &(vcProject.Configuration); 890 vcProject.HeaderFiles.Config = &(vcProject.Configuration);
664 vcProject.HeaderFiles.CustomBuild = moc; 891 vcProject.HeaderFiles.CustomBuild = moc;
@@ -666,10 +893,12 @@ void VcprojGenerator::initHeaderFiles()
666 893
667void VcprojGenerator::initMOCFiles() 894void VcprojGenerator::initMOCFiles()
668{ 895{
896 vcProject.MOCFiles.flat_files = project->isActiveConfig("flat");
669 vcProject.MOCFiles.Name = "Generated MOC Files"; 897 vcProject.MOCFiles.Name = "Generated MOC Files";
670 vcProject.MOCFiles.Filter = "cpp;c;cxx;moc"; 898 vcProject.MOCFiles.Filter = "cpp;c;cxx;moc";
671 vcProject.MOCFiles.Files += project->variables()["SRCMOC"]; 899 vcProject.MOCFiles.Files += project->variables()["SRCMOC"];
672 vcProject.MOCFiles.Files.sort(); 900 nonflatDir_BubbleSort( vcProject.MOCFiles.Files,
901 vcProject.MOCFiles.flat_files );
673 vcProject.MOCFiles.Project = this; 902 vcProject.MOCFiles.Project = this;
674 vcProject.MOCFiles.Config = &(vcProject.Configuration); 903 vcProject.MOCFiles.Config = &(vcProject.Configuration);
675 vcProject.MOCFiles.CustomBuild = moc; 904 vcProject.MOCFiles.CustomBuild = moc;
@@ -677,23 +906,27 @@ void VcprojGenerator::initMOCFiles()
677 906
678void VcprojGenerator::initUICFiles() 907void VcprojGenerator::initUICFiles()
679{ 908{
680 vcProject.UICFiles.Name = "Generated UI Files"; 909 vcProject.UICFiles.flat_files = project->isActiveConfig("flat");
910 vcProject.UICFiles.Name = "Generated Form Files";
681 vcProject.UICFiles.Filter = "cpp;c;cxx;h;hpp;hxx;"; 911 vcProject.UICFiles.Filter = "cpp;c;cxx;h;hpp;hxx;";
682 vcProject.UICFiles.Project = this; 912 vcProject.UICFiles.Project = this;
683 vcProject.UICFiles.Files += project->variables()["UICDECLS"]; 913 vcProject.UICFiles.Files += project->variables()["UICDECLS"];
684 vcProject.UICFiles.Files += project->variables()["UICIMPLS"]; 914 vcProject.UICFiles.Files += project->variables()["UICIMPLS"];
685 vcProject.UICFiles.Files.sort(); 915 nonflatDir_BubbleSort( vcProject.UICFiles.Files,
916 vcProject.UICFiles.flat_files );
686 vcProject.UICFiles.Config = &(vcProject.Configuration); 917 vcProject.UICFiles.Config = &(vcProject.Configuration);
687 vcProject.UICFiles.CustomBuild = none; 918 vcProject.UICFiles.CustomBuild = none;
688} 919}
689 920
690void VcprojGenerator::initFormsFiles() 921void VcprojGenerator::initFormsFiles()
691{ 922{
923 vcProject.FormFiles.flat_files = project->isActiveConfig("flat");
692 vcProject.FormFiles.Name = "Forms"; 924 vcProject.FormFiles.Name = "Forms";
693 vcProject.FormFiles.ParseFiles = _False; 925 vcProject.FormFiles.ParseFiles = _False;
694 vcProject.FormFiles.Filter = "ui"; 926 vcProject.FormFiles.Filter = "ui";
695 vcProject.FormFiles.Files += project->variables()["FORMS"]; 927 vcProject.FormFiles.Files += project->variables()["FORMS"];
696 vcProject.FormFiles.Files.sort(); 928 nonflatDir_BubbleSort( vcProject.FormFiles.Files,
929 vcProject.FormFiles.flat_files );
697 vcProject.FormFiles.Project = this; 930 vcProject.FormFiles.Project = this;
698 vcProject.FormFiles.Config = &(vcProject.Configuration); 931 vcProject.FormFiles.Config = &(vcProject.Configuration);
699 vcProject.FormFiles.CustomBuild = uic; 932 vcProject.FormFiles.CustomBuild = uic;
@@ -701,11 +934,13 @@ void VcprojGenerator::initFormsFiles()
701 934
702void VcprojGenerator::initTranslationFiles() 935void VcprojGenerator::initTranslationFiles()
703{ 936{
937 vcProject.TranslationFiles.flat_files = project->isActiveConfig("flat");
704 vcProject.TranslationFiles.Name = "Translations Files"; 938 vcProject.TranslationFiles.Name = "Translations Files";
705 vcProject.TranslationFiles.ParseFiles = _False; 939 vcProject.TranslationFiles.ParseFiles = _False;
706 vcProject.TranslationFiles.Filter = "ts"; 940 vcProject.TranslationFiles.Filter = "ts";
707 vcProject.TranslationFiles.Files += project->variables()["TRANSLATIONS"]; 941 vcProject.TranslationFiles.Files += project->variables()["TRANSLATIONS"];
708 vcProject.TranslationFiles.Files.sort(); 942 nonflatDir_BubbleSort( vcProject.TranslationFiles.Files,
943 vcProject.TranslationFiles.flat_files );
709 vcProject.TranslationFiles.Project = this; 944 vcProject.TranslationFiles.Project = this;
710 vcProject.TranslationFiles.Config = &(vcProject.Configuration); 945 vcProject.TranslationFiles.Config = &(vcProject.Configuration);
711 vcProject.TranslationFiles.CustomBuild = none; 946 vcProject.TranslationFiles.CustomBuild = none;
@@ -713,18 +948,22 @@ void VcprojGenerator::initTranslationFiles()
713 948
714void VcprojGenerator::initLexYaccFiles() 949void VcprojGenerator::initLexYaccFiles()
715{ 950{
951 vcProject.LexYaccFiles.flat_files = project->isActiveConfig("flat");
716 vcProject.LexYaccFiles.Name = "Lex / Yacc Files"; 952 vcProject.LexYaccFiles.Name = "Lex / Yacc Files";
717 vcProject.LexYaccFiles.ParseFiles = _False; 953 vcProject.LexYaccFiles.ParseFiles = _False;
718 vcProject.LexYaccFiles.Filter = "l;y"; 954 vcProject.LexYaccFiles.Filter = "l;y";
719 vcProject.LexYaccFiles.Files += project->variables()["LEXSOURCES"]; 955 vcProject.LexYaccFiles.Files += project->variables()["LEXSOURCES"];
720 vcProject.LexYaccFiles.Files += project->variables()["YACCSOURCES"]; 956 vcProject.LexYaccFiles.Files += project->variables()["YACCSOURCES"];
721 vcProject.LexYaccFiles.Files.sort(); 957 nonflatDir_BubbleSort( vcProject.LexYaccFiles.Files,
958 vcProject.LexYaccFiles.flat_files );
722 vcProject.LexYaccFiles.Project = this; 959 vcProject.LexYaccFiles.Project = this;
960 vcProject.LexYaccFiles.Config = &(vcProject.Configuration);
723 vcProject.LexYaccFiles.CustomBuild = lexyacc; 961 vcProject.LexYaccFiles.CustomBuild = lexyacc;
724} 962}
725 963
726void VcprojGenerator::initResourceFiles() 964void VcprojGenerator::initResourceFiles()
727{ 965{
966 vcProject.ResourceFiles.flat_files = project->isActiveConfig("flat");
728 vcProject.ResourceFiles.Name = "Resources"; 967 vcProject.ResourceFiles.Name = "Resources";
729 vcProject.ResourceFiles.ParseFiles = _False; 968 vcProject.ResourceFiles.ParseFiles = _False;
730 vcProject.ResourceFiles.Filter = "cpp;ico;png;jpg;jpeg;gif;xpm;bmp;rc;ts"; 969 vcProject.ResourceFiles.Filter = "cpp;ico;png;jpg;jpeg;gif;xpm;bmp;rc;ts";
@@ -732,9 +971,11 @@ void VcprojGenerator::initResourceFiles()
732 vcProject.ResourceFiles.Files += project->variables()["QMAKE_IMAGE_COLLECTION"]; 971 vcProject.ResourceFiles.Files += project->variables()["QMAKE_IMAGE_COLLECTION"];
733 vcProject.ResourceFiles.Files += project->variables()["IMAGES"]; 972 vcProject.ResourceFiles.Files += project->variables()["IMAGES"];
734 vcProject.ResourceFiles.Files += project->variables()["IDLSOURCES"]; 973 vcProject.ResourceFiles.Files += project->variables()["IDLSOURCES"];
735 vcProject.ResourceFiles.Files.sort(); 974 nonflatDir_BubbleSort( vcProject.ResourceFiles.Files,
975 vcProject.ResourceFiles.flat_files );
736 vcProject.ResourceFiles.Project = this; 976 vcProject.ResourceFiles.Project = this;
737 vcProject.ResourceFiles.CustomBuild = none; 977 vcProject.ResourceFiles.Config = &(vcProject.Configuration);
978 vcProject.ResourceFiles.CustomBuild = resource;
738} 979}
739 980
740/* \internal 981/* \internal
@@ -865,7 +1106,6 @@ void VcprojGenerator::initOld()
865 project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib"; 1106 project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib";
866 if ( project->isActiveConfig( "dll" ) ) { 1107 if ( project->isActiveConfig( "dll" ) ) {
867 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"]; 1108 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"];
868 project->variables()["MSVCPROJ_LFLAGS"].append("/DEF:"+project->first("DEF_FILE"));
869 } 1109 }
870 } 1110 }
871 if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) { 1111 if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) {
@@ -939,6 +1179,15 @@ void VcprojGenerator::initOld()
939 if ( project->isActiveConfig("moc") ) 1179 if ( project->isActiveConfig("moc") )
940 setMocAware(TRUE); 1180 setMocAware(TRUE);
941 1181
1182 // /VERSION:x.yz -------------------------------------------------
1183 if ( !project->variables()["VERSION"].isEmpty() ) {
1184 QString version = project->variables()["VERSION"][0];
1185 int firstDot = version.find( "." );
1186 QString major = version.left( firstDot );
1187 QString minor = version.right( version.length() - firstDot - 1 );
1188 minor.replace( ".", "" );
1189 project->variables()["QMAKE_LFLAGS"].append( "/VERSION:" + major + "." + minor );
1190 }
942 1191
943 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; 1192 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
944 // Update -lname to name.lib, and -Ldir to 1193 // Update -lname to name.lib, and -Ldir to
@@ -949,6 +1198,7 @@ void VcprojGenerator::initOld()
949 it = libList.remove( it ); 1198 it = libList.remove( it );
950 it = libList.insert( it, s.mid( 2 ) + ".lib" ); 1199 it = libList.insert( it, s.mid( 2 ) + ".lib" );
951 } else if( s.startsWith( "-L" ) ) { 1200 } else if( s.startsWith( "-L" ) ) {
1201 project->variables()["QMAKE_LIBDIR"] += (*it).mid(2);
952 it = libList.remove( it ); 1202 it = libList.remove( it );
953 } else { 1203 } else {
954 it++; 1204 it++;
@@ -1050,31 +1300,28 @@ void VcprojGenerator::initOld()
1050 if ( project->first("TARGET").startsWith("$(QTDIR)") ) 1300 if ( project->first("TARGET").startsWith("$(QTDIR)") )
1051 dest.replace( QRegExp("\\$\\(QTDIR\\)"), getenv("QTDIR") ); 1301 dest.replace( QRegExp("\\$\\(QTDIR\\)"), getenv("QTDIR") );
1052 project->variables()["MSVCPROJ_TARGET"] = dest; 1302 project->variables()["MSVCPROJ_TARGET"] = dest;
1053 if ( project->isActiveConfig("dll") ) {
1054 QString imp = project->first( "DESTDIR" );
1055 if( !imp.isNull() && !imp.endsWith( "\\" ) )
1056 imp += "\\";
1057 imp += dest;
1058 imp.replace(QRegExp("\\.dll"), ".lib");
1059 project->variables()["MSVCPROJ_LIBOPTIONS"] += QString("/IMPLIB:") + imp;
1060 }
1061 1303
1062 // DLL COPY ------------------------------------------------------ 1304 // DLL COPY ------------------------------------------------------
1063 if ( project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty() ) { 1305 if ( project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty() ) {
1064 QStringList dlldirs = project->variables()["DLLDESTDIR"]; 1306 QStringList dlldirs = project->variables()["DLLDESTDIR"];
1065 QString copydll = "# Begin Special Build Tool\n" 1307 QString copydll("");
1066 "TargetPath=" + dest + "\n" 1308 QStringList::Iterator dlldir;
1067 "SOURCE=$(InputPath)\n" 1309 for ( dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) {
1068 "PostBuild_Desc=Copy DLL to " + project->first("DLLDESTDIR") + "\n" 1310 if ( !copydll.isEmpty() )
1069 "PostBuild_Cmds="; 1311 copydll += " && ";
1312 copydll += "copy &quot;$(TargetPath)&quot; &quot;" + *dlldir + "&quot;";
1313 }
1070 1314
1071 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) { 1315 QString deststr( "Copy " + dest + " to " );
1072 copydll += "copy \"" + dest + "\" \"" + *dlldir + "\"\t"; 1316 for ( dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ) {
1317 deststr += *dlldir;
1318 ++dlldir;
1319 if ( dlldir != dlldirs.end() )
1320 deststr += ", ";
1073 } 1321 }
1074 1322
1075 copydll += "\n# End Special Build Tool"; 1323 project->variables()["MSVCPROJ_COPY_DLL"].append( copydll );
1076 project->variables()["MSVCPROJ_COPY_DLL_REL"].append( copydll ); 1324 project->variables()["MSVCPROJ_COPY_DLL_DESC"].append( deststr );
1077 project->variables()["MSVCPROJ_COPY_DLL_DBG"].append( copydll );
1078 } 1325 }
1079 1326
1080 // ACTIVEQT ------------------------------------------------------ 1327 // ACTIVEQT ------------------------------------------------------
@@ -1085,18 +1332,17 @@ void VcprojGenerator::initOld()
1085 if ( version.isEmpty() ) 1332 if ( version.isEmpty() )
1086 version = "1.0"; 1333 version = "1.0";
1087 1334
1088 project->variables()["MSVCPROJ_IDLSOURCES"].append( "tmp\\" + targetfilename + ".idl" ); 1335 QString objdir = project->first( "OBJECTS_DIR" );
1089 project->variables()["MSVCPROJ_IDLSOURCES"].append( "tmp\\" + targetfilename + ".tlb" ); 1336 project->variables()["MSVCPROJ_IDLSOURCES"].append( objdir + targetfilename + ".idl" );
1090 project->variables()["MSVCPROJ_IDLSOURCES"].append( "tmp\\" + targetfilename + ".midl" );
1091 if ( project->isActiveConfig( "dll" ) ) { 1337 if ( project->isActiveConfig( "dll" ) ) {
1092 QString regcmd = "# Begin Special Build Tool\n" 1338 QString regcmd = "# Begin Special Build Tool\n"
1093 "TargetPath=" + targetfilename + "\n" 1339 "TargetPath=" + targetfilename + "\n"
1094 "SOURCE=$(InputPath)\n" 1340 "SOURCE=$(InputPath)\n"
1095 "PostBuild_Desc=Finalizing ActiveQt server...\n" 1341 "PostBuild_Desc=Finalizing ActiveQt server...\n"
1096 "PostBuild_Cmds=" + 1342 "PostBuild_Cmds=" +
1097 idc + " %1 -idl tmp\\" + targetfilename + ".idl -version " + version + 1343 idc + " %1 -idl " + objdir + targetfilename + ".idl -version " + version +
1098 "\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" 1344 "\t" + idl + " /nologo " + objdir + targetfilename + ".idl /tlb " + objdir + targetfilename + ".tlb" +
1099 "\t" + idc + " %1 /tlb tmp\\" + targetfilename + ".tlb" 1345 "\t" + idc + " %1 /tlb " + objdir + targetfilename + ".tlb"
1100 "\tregsvr32 /s %1\n" 1346 "\tregsvr32 /s %1\n"
1101 "# End Special Build Tool"; 1347 "# End Special Build Tool";
1102 1348
@@ -1111,9 +1357,9 @@ void VcprojGenerator::initOld()
1111 "SOURCE=$(InputPath)\n" 1357 "SOURCE=$(InputPath)\n"
1112 "PostBuild_Desc=Finalizing ActiveQt server...\n" 1358 "PostBuild_Desc=Finalizing ActiveQt server...\n"
1113 "PostBuild_Cmds=" 1359 "PostBuild_Cmds="
1114 "%1 -dumpidl tmp\\" + targetfilename + ".idl -version " + version + 1360 "%1 -dumpidl " + objdir + targetfilename + ".idl -version " + version +
1115 "\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" 1361 "\t" + idl + " /nologo " + objdir + targetfilename + ".idl /tlb " + objdir + targetfilename + ".tlb"
1116 "\t" + idc + " %1 /tlb tmp\\" + targetfilename + ".tlb" 1362 "\t" + idc + " %1 /tlb " + objdir + targetfilename + ".tlb"
1117 "\t%1 -regserver\n" 1363 "\t%1 -regserver\n"
1118 "# End Special Build Tool"; 1364 "# End Special Build Tool";
1119 1365
@@ -1123,9 +1369,11 @@ void VcprojGenerator::initOld()
1123 executable = project->variables()["MSVCPROJ_TARGETDIRDEB"].first() + "\\" + project->variables()["TARGET"].first(); 1369 executable = project->variables()["MSVCPROJ_TARGETDIRDEB"].first() + "\\" + project->variables()["TARGET"].first();
1124 project->variables()["MSVCPROJ_REGSVR_DBG"].append( regcmd.arg(executable).arg(executable).arg(executable) ); 1370 project->variables()["MSVCPROJ_REGSVR_DBG"].append( regcmd.arg(executable).arg(executable).arg(executable) );
1125 } 1371 }
1126
1127 } 1372 }
1128 1373
1374 if ( !project->variables()["DEF_FILE"].isEmpty() )
1375 project->variables()["MSVCPROJ_LFLAGS"].append("/DEF:"+project->first("DEF_FILE"));
1376
1129 // FORMS --------------------------------------------------------- 1377 // FORMS ---------------------------------------------------------
1130 QStringList &list = project->variables()["FORMS"]; 1378 QStringList &list = project->variables()["FORMS"];
1131 for( it = list.begin(); it != list.end(); ++it ) { 1379 for( it = list.begin(); it != list.end(); ++it ) {
diff --git a/qmake/generators/win32/msvc_vcproj.h b/qmake/generators/win32/msvc_vcproj.h
index 69e0c02..d1ca666 100644
--- a/qmake/generators/win32/msvc_vcproj.h
+++ b/qmake/generators/win32/msvc_vcproj.h
@@ -1,13 +1,12 @@
1
1/**************************************************************************** 2/****************************************************************************
2** $Id$
3** 3**
4** Definition of VcprojGenerator class.
5** 4**
6** Created : 970521 5** Definition of VcprojGenerator class.
7** 6**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. 7** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 8**
10** This file is part of the network module of the Qt GUI Toolkit. 9** This file is part of qmake.
11** 10**
12** This file may be distributed under the terms of the Q Public License 11** 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 12** as defined by Trolltech AS of Norway and appearing in the file
@@ -34,6 +33,7 @@
34** not clear to you. 33** not clear to you.
35** 34**
36**********************************************************************/ 35**********************************************************************/
36
37#ifndef __MSVC_VCPROJ_H__ 37#ifndef __MSVC_VCPROJ_H__
38#define __MSVC_VCPROJ_H__ 38#define __MSVC_VCPROJ_H__
39 39
@@ -63,6 +63,9 @@ public:
63 63
64 QString defaultMakefile() const; 64 QString defaultMakefile() const;
65 virtual bool doDepends() const { return FALSE; } //never necesary 65 virtual bool doDepends() const { return FALSE; } //never necesary
66 QString precompH, precompHFilename,
67 precompObj, precompPch;
68 bool usePCH;
66 69
67protected: 70protected:
68 virtual bool openOutput(QFile &file) const; 71 virtual bool openOutput(QFile &file) const;
@@ -95,6 +98,7 @@ protected:
95 target projectTarget; 98 target projectTarget;
96 99
97private: 100private:
101 QUuid getProjectUUID(const QString &filename=QString::null);
98 QUuid increaseUUID(const QUuid &id); 102 QUuid increaseUUID(const QUuid &id);
99 friend class VCFilter; 103 friend class VCFilter;
100}; 104};
diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp
index bc3fed9..cd733c6 100644
--- a/qmake/generators/win32/winmakefile.cpp
+++ b/qmake/generators/win32/winmakefile.cpp
@@ -1,13 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Definition of ________ class.
5** 3**
6** Created : 970521 4** Implementation of Win32MakefileGenerator class.
7** 5**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 7**
10** This file is part of the network module of the Qt GUI Toolkit. 8** This file is part of qmake.
11** 9**
12** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
@@ -38,6 +36,7 @@
38#include "winmakefile.h" 36#include "winmakefile.h"
39#include "option.h" 37#include "option.h"
40#include "project.h" 38#include "project.h"
39#include "meta.h"
41#include <qtextstream.h> 40#include <qtextstream.h>
42#include <qstring.h> 41#include <qstring.h>
43#include <qdict.h> 42#include <qdict.h>
@@ -97,14 +96,13 @@ Win32MakefileGenerator::writeSubDirs(QTextStream &t)
97 } 96 }
98 QPtrListIterator<SubDir> it(subdirs); 97 QPtrListIterator<SubDir> it(subdirs);
99 98
100 if(!project->isEmpty("MAKEFILE")) 99 t << "MAKEFILE = " << (project->isEmpty("MAKEFILE") ? QString("Makefile") : var("MAKEFILE")) << endl;
101 t << "MAKEFILE=" << var("MAKEFILE") << endl;
102 t << "QMAKE =" << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl; 100 t << "QMAKE =" << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl;
103 t << "SUBTARGETS= "; 101 t << "SUBTARGETS= ";
104 for( it.toFirst(); it.current(); ++it) 102 for( it.toFirst(); it.current(); ++it)
105 t << " \\\n\t\t" << it.current()->target; 103 t << " \\\n\t\t" << it.current()->target;
106 t << endl << endl; 104 t << endl << endl;
107 t << "all: qmake_all $(SUBTARGETS)" << endl << endl; 105 t << "all: $(MAKEFILE) $(SUBTARGETS)" << endl << endl;
108 106
109 for( it.toFirst(); it.current(); ++it) { 107 for( it.toFirst(); it.current(); ++it) {
110 bool have_dir = !(*it)->directory.isEmpty(); 108 bool have_dir = !(*it)->directory.isEmpty();
@@ -114,8 +112,6 @@ Win32MakefileGenerator::writeSubDirs(QTextStream &t)
114 if(have_dir) 112 if(have_dir)
115 mkfile.prepend((*it)->directory + Option::dir_sep); 113 mkfile.prepend((*it)->directory + Option::dir_sep);
116 t << mkfile << ":"; 114 t << mkfile << ":";
117 if(project->variables()["QMAKE_NOFORCE"].isEmpty())
118 t << " FORCE";
119 if(have_dir) 115 if(have_dir)
120 t << "\n\t" << "cd " << (*it)->directory; 116 t << "\n\t" << "cd " << (*it)->directory;
121 t << "\n\t" << "$(QMAKE) " << (*it)->profile << " " << buildArgs(); 117 t << "\n\t" << "$(QMAKE) " << (*it)->profile << " " << buildArgs();
@@ -145,6 +141,16 @@ Win32MakefileGenerator::writeSubDirs(QTextStream &t)
145 t << endl << endl; 141 t << endl << endl;
146 } 142 }
147 143
144 if (project->isActiveConfig("ordered")) { // generate dependencies
145 for( it.toFirst(); it.current(); ) {
146 QString tar = it.current()->target;
147 ++it;
148 if (it.current())
149 t << it.current()->target << ": " << tar << endl;
150 }
151 t << endl;
152 }
153
148 if(project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].findIndex("qmake_all") == -1) 154 if(project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].findIndex("qmake_all") == -1)
149 project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].append("qmake_all"); 155 project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].append("qmake_all");
150 writeMakeQmake(t); 156 writeMakeQmake(t);
@@ -175,11 +181,18 @@ Win32MakefileGenerator::writeSubDirs(QTextStream &t)
175 } 181 }
176 t << endl << endl; 182 t << endl << endl;
177 183
178 QString targs[] = { QString("clean"), QString("install"), QString("mocclean"), QString::null }; 184 QStringList targs;
179 for(int x = 0; targs[x] != QString::null; x++) { 185 targs << "clean" << "install_subdirs" << "mocables" << "uicables" << "uiclean" << "mocclean";
180 t << targs[x] << ": qmake_all"; 186 targs += project->values("SUBDIR_TARGETS");
181 if(targs[x] == "clean") 187 for(QStringList::Iterator targ_it = targs.begin(); targ_it != targs.end(); ++targ_it) {
182 t << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ", ""); 188 t << (*targ_it) << ": qmake_all";
189 QString targ = (*targ_it);
190 if(targ == "install_subdirs")
191 targ = "install";
192 else if(targ == "uninstall_subdirs")
193 targ = "uninstall";
194 if(targ == "clean")
195 t << varGlue("QMAKE_CLEAN","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ", "");
183 if (!subdirs.isEmpty()) { 196 if (!subdirs.isEmpty()) {
184 for( it.toFirst(); it.current(); ++it) { 197 for( it.toFirst(); it.current(); ++it) {
185 int subLevels = (*it)->directory.contains(Option::dir_sep) + 1; 198 int subLevels = (*it)->directory.contains(Option::dir_sep) + 1;
@@ -187,7 +200,7 @@ Win32MakefileGenerator::writeSubDirs(QTextStream &t)
187 if(have_dir) 200 if(have_dir)
188 t << "\n\t" << "cd " << (*it)->directory; 201 t << "\n\t" << "cd " << (*it)->directory;
189 QString in_file = " -f " + (*it)->makefile; 202 QString in_file = " -f " + (*it)->makefile;
190 t << "\n\t" << "$(MAKE) " << in_file << " " << targs[x]; 203 t << "\n\t" << "$(MAKE) " << in_file << " " << targ;
191 if(have_dir) { 204 if(have_dir) {
192 t << "\n\t" << "@cd .."; 205 t << "\n\t" << "@cd ..";
193 for(int i = 1; i < subLevels; i++ ) 206 for(int i = 1; i < subLevels; i++ )
@@ -202,6 +215,32 @@ Win32MakefileGenerator::writeSubDirs(QTextStream &t)
202 t << endl << endl; 215 t << endl << endl;
203 } 216 }
204 217
218 //installations
219 project->variables()["INSTALLDEPS"] += "install_subdirs";
220 project->variables()["UNINSTALLDEPS"] += "uninstall_subdirs";
221 writeInstalls(t, "INSTALLS");
222
223 // user defined targets
224 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"];
225 for(QStringList::Iterator sit = qut.begin(); sit != qut.end(); ++sit) {
226 QString targ = var((*sit) + ".target"),
227 cmd = var((*sit) + ".commands"), deps;
228 if(targ.isEmpty())
229 targ = (*sit);
230 QStringList &deplist = project->variables()[(*sit) + ".depends"];
231 for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) {
232 QString dep = var((*dep_it) + ".target");
233 if(dep.isEmpty())
234 dep = (*dep_it);
235 deps += " " + dep;
236 }
237 if(!project->variables()["QMAKE_NOFORCE"].isEmpty() &&
238 project->variables()[(*sit) + ".CONFIG"].findIndex("phony") != -1)
239 deps += QString(" ") + "FORCE";
240 t << "\n\n" << targ << ":" << deps << "\n\t"
241 << cmd;
242 }
243
205 if(project->variables()["QMAKE_NOFORCE"].isEmpty()) 244 if(project->variables()["QMAKE_NOFORCE"].isEmpty())
206 t << "FORCE:" << endl << endl; 245 t << "FORCE:" << endl << endl;
207} 246}
@@ -226,16 +265,50 @@ Win32MakefileGenerator::findHighestVersion(const QString &d, const QString &stem
226 biggest = QMAX(biggest, (regx.cap(1) == dllStem || 265 biggest = QMAX(biggest, (regx.cap(1) == dllStem ||
227 regx.cap(2).isEmpty()) ? -1 : regx.cap(2).toInt()); 266 regx.cap(2).isEmpty()) ? -1 : regx.cap(2).toInt());
228 } 267 }
229 if(dir.exists(dllStem + Option::prl_ext)) { 268 QMakeMetaInfo libinfo;
230 QMakeProject proj; 269 if(libinfo.readLib(bd + dllStem)) {
231 if(proj.read(bd + dllStem + Option::prl_ext, QDir::currentDirPath(), TRUE)) { 270 if(!libinfo.isEmpty("QMAKE_PRL_VERSION"))
232 if(!proj.isEmpty("QMAKE_PRL_VERSION")) 271 biggest = QMAX(biggest, libinfo.first("QMAKE_PRL_VERSION").replace(".", "").toInt());
233 biggest = QMAX(biggest, proj.first("QMAKE_PRL_VERSION").replace(".", "").toInt());
234 }
235 } 272 }
236 return biggest; 273 return biggest;
237} 274}
238 275
276QString
277Win32MakefileGenerator::findDependency(const QString &dep)
278{
279 {
280 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"];
281 for(QStringList::Iterator it = qut.begin(); it != qut.end(); ++it) {
282 QString targ = var((*it) + ".target");
283 if(targ.isEmpty())
284 targ = (*it);
285 if(targ.endsWith(dep))
286 return targ;
287 }
288 }
289 {
290 QStringList &quc = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"];
291 for(QStringList::Iterator it = quc.begin(); it != quc.end(); ++it) {
292 QString tmp_out = project->variables()[(*it) + ".output"].first();
293 QString tmp_cmd = project->variables()[(*it) + ".commands"].join(" ");
294 if(tmp_out.isEmpty() || tmp_cmd.isEmpty())
295 continue;
296 QStringList &tmp = project->variables()[(*it) + ".input"];
297 for(QStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {
298 QStringList &inputs = project->variables()[(*it2)];
299 for(QStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {
300 QString out = tmp_out;
301 QFileInfo fi(Option::fixPathToLocalOS((*input)));
302 out.replace("${QMAKE_FILE_BASE}", fi.baseName());
303 out.replace("${QMAKE_FILE_NAME}", fi.fileName());
304 if(out.endsWith(dep))
305 return out;
306 }
307 }
308 }
309 }
310 return MakefileGenerator::findDependency(dep);
311}
239 312
240bool 313bool
241Win32MakefileGenerator::findLibraries(const QString &where) 314Win32MakefileGenerator::findLibraries(const QString &where)
@@ -278,7 +351,7 @@ Win32MakefileGenerator::findLibraries(const QString &where)
278 if(ver > 0) 351 if(ver > 0)
279 extension += QString::number(ver); 352 extension += QString::number(ver);
280 extension += ".lib"; 353 extension += ".lib";
281 if(QFile::exists(mdd->local_dir + Option::dir_sep + lib + Option::prl_ext) || 354 if(QMakeMetaInfo::libExists(mdd->local_dir + Option::dir_sep + lib) ||
282 QFile::exists(mdd->local_dir + Option::dir_sep + lib + extension)) { 355 QFile::exists(mdd->local_dir + Option::dir_sep + lib + extension)) {
283 out = mdd->real_dir + Option::dir_sep + lib + extension; 356 out = mdd->real_dir + Option::dir_sep + lib + extension;
284 break; 357 break;
@@ -303,6 +376,7 @@ Win32MakefileGenerator::findLibraries(const QString &where)
303 } else { 376 } else {
304 lib_dirs = dirs; 377 lib_dirs = dirs;
305 } 378 }
379 if (!project->variables()["QMAKE_QT_DLL"].isEmpty()) {
306 if(file.endsWith(".lib")) { 380 if(file.endsWith(".lib")) {
307 file = file.left(file.length() - 4); 381 file = file.left(file.length() - 4);
308 if(!file.at(file.length()-1).isNumber()) { 382 if(!file.at(file.length()-1).isNumber()) {
@@ -328,6 +402,7 @@ Win32MakefileGenerator::findLibraries(const QString &where)
328 } 402 }
329 } 403 }
330 } 404 }
405 }
331 if(remove) { 406 if(remove) {
332 it = l.remove(it); 407 it = l.remove(it);
333 } else { 408 } else {
diff --git a/qmake/generators/win32/winmakefile.h b/qmake/generators/win32/winmakefile.h
index 75ba0e0..dac4a99 100644
--- a/qmake/generators/win32/winmakefile.h
+++ b/qmake/generators/win32/winmakefile.h
@@ -1,13 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Definition of ________ class.
5** 3**
6** Created : 970521 4** Definition of Win32MakefileGenerator class.
7** 5**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 7**
10** This file is part of the network module of the Qt GUI Toolkit. 8** This file is part of qmake.
11** 9**
12** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
@@ -34,6 +32,7 @@
34** not clear to you. 32** not clear to you.
35** 33**
36**********************************************************************/ 34**********************************************************************/
35
37#ifndef __WINMAKEFILE_H__ 36#ifndef __WINMAKEFILE_H__
38#define __WINMAKEFILE_H__ 37#define __WINMAKEFILE_H__
39 38
@@ -53,6 +52,7 @@ protected:
53 virtual void writeSubDirs(QTextStream &t); 52 virtual void writeSubDirs(QTextStream &t);
54 int findHighestVersion(const QString &dir, const QString &stem); 53 int findHighestVersion(const QString &dir, const QString &stem);
55 bool findLibraries(const QString &); 54 bool findLibraries(const QString &);
55 QString findDependency(const QString &);
56 virtual bool findLibraries(); 56 virtual bool findLibraries();
57 virtual void processPrlFiles(); 57 virtual void processPrlFiles();
58 58