summaryrefslogtreecommitdiff
path: root/qmake/generators/win32/msvc_nmake.cpp
Unidiff
Diffstat (limited to 'qmake/generators/win32/msvc_nmake.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/generators/win32/msvc_nmake.cpp98
1 files changed, 86 insertions, 12 deletions
diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp
index 9cc9a69..ecef34d 100644
--- a/qmake/generators/win32/msvc_nmake.cpp
+++ b/qmake/generators/win32/msvc_nmake.cpp
@@ -1,64 +1,65 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of ________ class. 4** Definition of ________ class.
5** 5**
6** Created : 970521 6** Created : 970521
7** 7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the network module of the Qt GUI Toolkit. 10** This file is part of the network module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this 21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software. 23** with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#include "msvc_nmake.h" 38#include "msvc_nmake.h"
39#include "option.h" 39#include "option.h"
40#include <qregexp.h> 40#include <qregexp.h>
41#include <qdict.h>
41#include <qdir.h> 42#include <qdir.h>
42#include <stdlib.h> 43#include <stdlib.h>
43#include <time.h> 44#include <time.h>
44 45
45 46
46NmakeMakefileGenerator::NmakeMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE) 47NmakeMakefileGenerator::NmakeMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE)
47{ 48{
48 49
49} 50}
50 51
51bool 52bool
52NmakeMakefileGenerator::writeMakefile(QTextStream &t) 53NmakeMakefileGenerator::writeMakefile(QTextStream &t)
53{ 54{
54 writeHeader(t); 55 writeHeader(t);
55 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) { 56 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {
56 t << "all clean:" << "\n\t" 57 t << "all clean:" << "\n\t"
57 << "@echo \"Some of the required modules (" 58 << "@echo \"Some of the required modules ("
58 << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t" 59 << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t"
59 << "@echo \"Skipped.\"" << endl << endl; 60 << "@echo \"Skipped.\"" << endl << endl;
60 writeMakeQmake(t); 61 writeMakeQmake(t);
61 return TRUE; 62 return TRUE;
62 } 63 }
63 64
64 if(project->first("TEMPLATE") == "app" || 65 if(project->first("TEMPLATE") == "app" ||
@@ -114,159 +115,209 @@ NmakeMakefileGenerator::writeNmakeParts(QTextStream &t)
114 lib.replace(QRegExp("\""), ""); 115 lib.replace(QRegExp("\""), "");
115 t << " \"" << lib << "\""; 116 t << " \"" << lib << "\"";
116 } 117 }
117 t << endl; 118 t << endl;
118 } 119 }
119 else { 120 else {
120 t << "LIB =" << var("QMAKE_LIB") << endl; 121 t << "LIB =" << var("QMAKE_LIB") << endl;
121 } 122 }
122 t << "MOC =" << (project->isEmpty("QMAKE_MOC") ? QString("moc") : 123 t << "MOC =" << (project->isEmpty("QMAKE_MOC") ? QString("moc") :
123 Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl; 124 Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl;
124 t << "UIC =" << (project->isEmpty("QMAKE_UIC") ? QString("uic") : 125 t << "UIC =" << (project->isEmpty("QMAKE_UIC") ? QString("uic") :
125 Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl; 126 Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl;
126 t << "QMAKE =" << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : 127 t << "QMAKE =" << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") :
127 Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl; 128 Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl;
128 t << "IDC =" << (project->isEmpty("QMAKE_IDC") ? QString("idc") : 129 t << "IDC =" << (project->isEmpty("QMAKE_IDC") ? QString("idc") :
129 Option::fixPathToTargetOS(var("QMAKE_IDC"), FALSE)) << endl; 130 Option::fixPathToTargetOS(var("QMAKE_IDC"), FALSE)) << endl;
130 t << "IDL =" << (project->isEmpty("QMAKE_IDL") ? QString("midl") : 131 t << "IDL =" << (project->isEmpty("QMAKE_IDL") ? QString("midl") :
131 Option::fixPathToTargetOS(var("QMAKE_IDL"), FALSE)) << endl; 132 Option::fixPathToTargetOS(var("QMAKE_IDL"), FALSE)) << endl;
132 t << "ZIP =" << var("QMAKE_ZIP") << endl; 133 t << "ZIP =" << var("QMAKE_ZIP") << endl;
133 t << "COPY_FILE= " << var("QMAKE_COPY") << endl; 134 t << "COPY_FILE= " << var("QMAKE_COPY") << endl;
134 t << "COPY_DIR= " << var("QMAKE_COPY") << endl; 135 t << "COPY_DIR= " << var("QMAKE_COPY") << endl;
135 t << "DEL_FILE= " << var("QMAKE_DEL_FILE") << endl; 136 t << "DEL_FILE= " << var("QMAKE_DEL_FILE") << endl;
136 t << "DEL_DIR= " << var("QMAKE_DEL_DIR") << endl; 137 t << "DEL_DIR= " << var("QMAKE_DEL_DIR") << endl;
137 t << "MOVE = " << var("QMAKE_MOVE") << endl; 138 t << "MOVE = " << var("QMAKE_MOVE") << endl;
139 t << "CHK_DIR_EXISTS =" << var("QMAKE_CHK_DIR_EXISTS") << endl;
140 t << "MKDIR =" << var("QMAKE_MKDIR") << endl;
138 t << endl; 141 t << endl;
139 142
140 t << "####### Files" << endl << endl; 143 t << "####### Files" << endl << endl;
141 t << "HEADERS =" << varList("HEADERS") << endl; 144 t << "HEADERS =" << varList("HEADERS") << endl;
142 t << "SOURCES =" << varList("SOURCES") << endl; 145 t << "SOURCES =" << varList("SOURCES") << endl;
143 t << "OBJECTS =" << varList("OBJECTS") << endl; 146 t << "OBJECTS =" << varList("OBJECTS") << endl;
144 t << "FORMS =" << varList("FORMS") << endl; 147 t << "FORMS =" << varList("FORMS") << endl;
145 t << "UICDECLS =" << varList("UICDECLS") << endl; 148 t << "UICDECLS =" << varList("UICDECLS") << endl;
146 t << "UICIMPLS =" << varList("UICIMPLS") << endl; 149 t << "UICIMPLS =" << varList("UICIMPLS") << endl;
147 t << "SRCMOC =" << varList("SRCMOC") << endl; 150 t << "SRCMOC =" << varList("SRCMOC") << endl;
148 t << "OBJMOC =" << varList("OBJMOC") << endl; 151 t << "OBJMOC =" << varList("OBJMOC") << endl;
149 t << "DIST =" << varList("DISTFILES") << endl; 152 t << "DIST =" << varList("DISTFILES") << endl;
150 t << "TARGET ="; 153 t << "TARGET =";
151 if( !project->variables()[ "DESTDIR" ].isEmpty() ) 154 if( !project->variables()[ "DESTDIR" ].isEmpty() )
152 t << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT")); 155 t << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT"));
153 else 156 else
154 t << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first(); 157 t << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first();
155 t << endl; 158 t << endl;
156 t << endl; 159 t << endl;
157 160
158 t << "####### Implicit rules" << endl << endl; 161 t << "####### Implicit rules" << endl << endl;
159 t << ".SUFFIXES: .cpp .cxx .cc .c" << endl << endl; 162 t << ".SUFFIXES: .c";
160 t << ".cpp.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; 163 QStringList::Iterator cppit;
161 t << ".cxx.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; 164 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
162 t << ".cc.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; 165 t << " " << (*cppit);
163 t << ".c.obj:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl; 166 t << endl << endl;
167 if(!project->isActiveConfig("no_batch")) {
168 // Batchmode doesn't use the non implicit rules QMAKE_RUN_CXX & QMAKE_RUN_CC
169 project->variables().remove("QMAKE_RUN_CXX");
170 project->variables().remove("QMAKE_RUN_CC");
171
172 QDict<void> source_directories;
173 source_directories.insert(".", (void*)1);
174 if(!project->isEmpty("MOC_DIR"))
175 source_directories.insert(project->first("MOC_DIR"), (void*)1);
176 if(!project->isEmpty("UI_SOURCES_DIR"))
177 source_directories.insert(project->first("UI_SOURCES_DIR"), (void*)1);
178 else if(!project->isEmpty("UI_DIR"))
179 source_directories.insert(project->first("UI_DIR"), (void*)1);
180 QString srcs[] = { QString("SOURCES"), QString("UICIMPLS"), QString("SRCMOC"), QString::null };
181 for(int x = 0; !srcs[x].isNull(); x++) {
182 QStringList &l = project->variables()[srcs[x]];
183 for(QStringList::Iterator sit = l.begin(); sit != l.end(); ++sit) {
184 QString sep = "\\";
185 if((*sit).find(sep) == -1)
186 sep = "/";
187 QString dir = (*sit).section(sep, 0, -2);
188 if(!dir.isEmpty() && !source_directories[dir])
189 source_directories.insert(dir, (void*)1);
190 }
191 }
192
193 for(QDictIterator<void> it(source_directories); it.current(); ++it) {
194 if(it.currentKey().isEmpty())
195 continue;
196 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
197 t << "{" << it.currentKey() << "}" << (*cppit) << "{" << var("OBJECTS_DIR") << "}" << Option::obj_ext << "::\n\t"
198 << var("QMAKE_RUN_CXX_IMP_BATCH").replace( QRegExp( "\\$@" ), var("OBJECTS_DIR") ) << endl << "\t$<" << endl << "<<" << endl << endl;
199 t << "{" << it.currentKey() << "}" << ".c{" << var("OBJECTS_DIR") << "}" << Option::obj_ext << "::\n\t"
200 << var("QMAKE_RUN_CC_IMP_BATCH").replace( QRegExp( "\\$@" ), var("OBJECTS_DIR") ) << endl << "\t$<" << endl << "<<" << endl << endl;
201 }
202 } else {
203 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
204 t << (*cppit) << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
205 t << ".c" << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;
206 }
164 207
165 t << "####### Build rules" << endl << endl; 208 t << "####### Build rules" << endl << endl;
166 t << "all: " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" << endl << endl; 209 t << "all: " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" << endl << endl;
167 t << "$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) " << var("TARGETDEPS"); 210 t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) "
211 << var("POST_TARGETDEPS");
168 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) { 212 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
169 t << "\n\t" << "$(LINK) $(LFLAGS) /OUT:$(TARGET) @<< " << "\n\t " 213 t << "\n\t" << "$(LINK) $(LFLAGS) /OUT:$(TARGET) @<< " << "\n\t "
170 << "$(OBJECTS) $(OBJMOC) $(LIBS)"; 214 << "$(OBJECTS) $(OBJMOC) $(LIBS)";
171 } else { 215 } else {
172 t << "\n\t" << "$(LIB) /OUT:$(TARGET) @<<" << "\n\t " 216 t << "\n\t" << "$(LIB) /OUT:$(TARGET) @<<" << "\n\t "
173 << "$(OBJECTS) $(OBJMOC)"; 217 << "$(OBJECTS) $(OBJMOC)";
174 } 218 }
175 t << endl << "<<" << endl; 219 t << endl << "<<" << endl;
220 if ( !project->variables()["QMAKE_POST_LINK"].isEmpty() )
221 t << "\t" << var( "QMAKE_POST_LINK" ) << endl;
176 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) { 222 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) {
177 QStringList dlldirs = project->variables()["DLLDESTDIR"]; 223 QStringList dlldirs = project->variables()["DLLDESTDIR"];
178 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) { 224 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) {
179 t << "\n\t" << "-copy $(TARGET) " << *dlldir; 225 t << "\n\t" << "-copy $(TARGET) " << *dlldir;
180 } 226 }
181 } 227 }
182 QString targetfilename = project->variables()["TARGET"].first(); 228 QString targetfilename = project->variables()["TARGET"].first();
183 if(project->isActiveConfig("activeqt")) { 229 if(project->isActiveConfig("activeqt")) {
184 QString version = project->variables()["VERSION"].first(); 230 QString version = project->variables()["VERSION"].first();
185 if ( version.isEmpty() ) 231 if ( version.isEmpty() )
186 version = "1.0"; 232 version = "1.0";
187 233
188 if ( project->isActiveConfig("dll")) { 234 if ( project->isActiveConfig("dll")) {
189 t << "\n\t" << ("-$(IDC) $(TARGET) /idl tmp\\" + targetfilename + ".idl -version " + version); 235 t << "\n\t" << ("-$(IDC) $(TARGET) /idl tmp\\" + targetfilename + ".idl -version " + version);
190 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl"); 236 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl");
191 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb"); 237 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb");
192 t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" ); 238 t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" );
193 } else { 239 } else {
194 t << "\n\t" << ("-$(TARGET) -dumpidl tmp\\" + targetfilename + ".idl -version " + version); 240 t << "\n\t" << ("-$(TARGET) -dumpidl tmp\\" + targetfilename + ".idl -version " + version);
195 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl"); 241 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl");
196 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb"); 242 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb");
197 t << "\n\t" << "-$(TARGET) -regserver"; 243 t << "\n\t" << "-$(TARGET) -regserver";
198 } 244 }
199 } 245 }
200 t << endl << endl; 246 t << endl << endl;
201 247
202 if(!project->variables()["RC_FILE"].isEmpty()) { 248 if(!project->variables()["RC_FILE"].isEmpty()) {
203 t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t" 249 t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t"
204 << var("QMAKE_RC") << " " << var("RC_FILE") << endl << endl; 250 << var("QMAKE_RC") << " " << var("RC_FILE") << endl << endl;
205 } 251 }
206 252
207 t << "mocables: $(SRCMOC)" << endl << endl; 253 t << "mocables: $(SRCMOC)" << endl << endl;
208 254
209 writeMakeQmake(t); 255 writeMakeQmake(t);
210 256
211 t << "dist:" << "\n\t" 257 t << "dist:" << "\n\t"
212 << "$(ZIP) " << var("PROJECT") << ".zip " 258 << "$(ZIP) " << var("PROJECT") << ".zip "
213 << var("PROJECT") << ".pro $(SOURCES) $(HEADERS) $(DIST) $(FORMS)" << endl << endl; 259 << var("PROJECT") << ".pro $(SOURCES) $(HEADERS) $(DIST) $(FORMS)" << endl << endl;
214 260
215 t << "clean:" 261 t << "clean:"
216 << varGlue("OBJECTS","\n\t-del ","\n\t-del ","") 262 << varGlue("OBJECTS","\n\t-del ","\n\t-del ","")
217 << varGlue("SRCMOC" ,"\n\t-del ","\n\t-del ","") 263 << varGlue("SRCMOC" ,"\n\t-del ","\n\t-del ","")
218 << varGlue("OBJMOC" ,"\n\t-del ","\n\t-del ","") 264 << varGlue("OBJMOC" ,"\n\t-del ","\n\t-del ","")
219 << varGlue("UICDECLS" ,"\n\t-del ","\n\t-del ","") 265 << varGlue("UICDECLS" ,"\n\t-del ","\n\t-del ","")
220 << varGlue("UICIMPLS" ,"\n\t-del ","\n\t-del ","") 266 << varGlue("UICIMPLS" ,"\n\t-del ","\n\t-del ","")
221 << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ","") 267 << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ","")
222 << varGlue("CLEAN_FILES","\n\t-del ","\n\t-del ",""); 268 << varGlue("CLEAN_FILES","\n\t-del ","\n\t-del ","");
269
223 if ( project->isActiveConfig("activeqt")) { 270 if ( project->isActiveConfig("activeqt")) {
224 t << ("\n\t-del tmp\\" + targetfilename + ".*"); 271 t << ("\n\t-del tmp\\" + targetfilename + ".*");
225 t << "\n\t-del tmp\\dump.*"; 272 t << "\n\t-del tmp\\dump.*";
226 } 273 }
227 if(!project->isEmpty("IMAGES")) 274 if(!project->isEmpty("IMAGES"))
228 t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-del ", "\n\t-del ", ""); 275 t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-del ", "\n\t-del ", "");
229 276
230 // blasted user defined targets 277 // blasted user defined targets
231 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"]; 278 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"];
232 for(QStringList::Iterator it = qut.begin(); it != qut.end(); ++it) { 279 for(QStringList::Iterator it = qut.begin(); it != qut.end(); ++it) {
233 QString targ = var((*it) + ".target"), 280 QString targ = var((*it) + ".target"),
234 cmd = var((*it) + ".commands"), deps; 281 cmd = var((*it) + ".commands"), deps;
235 if(targ.isEmpty()) 282 if(targ.isEmpty())
236 targ = (*it); 283 targ = (*it);
237 QStringList &deplist = project->variables()[(*it) + ".depends"]; 284 QStringList &deplist = project->variables()[(*it) + ".depends"];
238 for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) { 285 for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) {
239 QString dep = var((*dep_it) + ".target"); 286 QString dep = var((*dep_it) + ".target");
240 if(dep.isEmpty()) 287 if(dep.isEmpty())
241 dep = (*dep_it); 288 dep = (*dep_it);
242 deps += " " + dep; 289 deps += " " + dep;
243 } 290 }
244 t << "\n\n" << targ << ":" << deps << "\n\t" 291 t << "\n\n" << targ << ":" << deps << "\n\t"
245 << cmd; 292 << cmd;
246 } 293 }
247 294
248 t << endl << endl; 295 t << endl << endl;
296
297 t << "distclean: clean"
298 << "\n\t-del $(TARGET)"
299 << endl << endl;
249} 300}
250 301
251 302
252void 303void
253NmakeMakefileGenerator::init() 304NmakeMakefileGenerator::init()
254{ 305{
255 if(init_flag) 306 if(init_flag)
256 return; 307 return;
257 init_flag = TRUE; 308 init_flag = TRUE;
258 309
259 /* this should probably not be here, but I'm using it to wrap the .t files */ 310 /* this should probably not be here, but I'm using it to wrap the .t files */
260 if(project->first("TEMPLATE") == "app") 311 if(project->first("TEMPLATE") == "app")
261 project->variables()["QMAKE_APP_FLAG"].append("1"); 312 project->variables()["QMAKE_APP_FLAG"].append("1");
262 else if(project->first("TEMPLATE") == "lib") 313 else if(project->first("TEMPLATE") == "lib")
263 project->variables()["QMAKE_LIB_FLAG"].append("1"); 314 project->variables()["QMAKE_LIB_FLAG"].append("1");
264 else if(project->first("TEMPLATE") == "subdirs") { 315 else if(project->first("TEMPLATE") == "subdirs") {
265 MakefileGenerator::init(); 316 MakefileGenerator::init();
266 if(project->variables()["MAKEFILE"].isEmpty()) 317 if(project->variables()["MAKEFILE"].isEmpty())
267 project->variables()["MAKEFILE"].append("Makefile"); 318 project->variables()["MAKEFILE"].append("Makefile");
268 if(project->variables()["QMAKE"].isEmpty()) 319 if(project->variables()["QMAKE"].isEmpty())
269 project->variables()["QMAKE"].append("qmake"); 320 project->variables()["QMAKE"].append("qmake");
270 return; 321 return;
271 } 322 }
272 323
@@ -410,79 +461,102 @@ NmakeMakefileGenerator::init()
410 project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE"]; 461 project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE"];
411 project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS"]; 462 project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS"];
412 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty()) { 463 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty()) {
413 project->variables()["TARGET_EXT"].append(".exe"); 464 project->variables()["TARGET_EXT"].append(".exe");
414 } else { 465 } else {
415 project->variables()["TARGET_EXT"].append(".lib"); 466 project->variables()["TARGET_EXT"].append(".lib");
416 } 467 }
417 } 468 }
418 if ( project->isActiveConfig("windows") ) { 469 if ( project->isActiveConfig("windows") ) {
419 if ( project->isActiveConfig("console") ) { 470 if ( project->isActiveConfig("console") ) {
420 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"]; 471 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
421 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"]; 472 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
422 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"]; 473 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
423 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"]; 474 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
424 } else { 475 } else {
425 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"]; 476 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"];
426 } 477 }
427 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"]; 478 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"];
428 } else { 479 } else {
429 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"]; 480 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
430 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"]; 481 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
431 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"]; 482 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
432 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"]; 483 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
433 } 484 }
485 if ( project->isActiveConfig("stl") ) {
486 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_ON"];
487 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_ON"];
488 } else {
489 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_OFF"];
490 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_OFF"];
491 }
492 if ( project->isActiveConfig("exceptions") ) {
493 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_ON"];
494 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_ON"];
495 } else {
496 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_OFF"];
497 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_OFF"];
498 }
499 if ( project->isActiveConfig("rtti") ) {
500 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_ON"];
501 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_ON"];
502 } else {
503 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_OFF"];
504 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_OFF"];
505 }
506
434 507
435 if ( project->isActiveConfig("moc") ) 508 if ( project->isActiveConfig("moc") )
436 setMocAware(TRUE); 509 setMocAware(TRUE);
437 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; 510 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
438 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ', 511 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ',
439 "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH"); 512 "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH");
440 QStringList &l = project->variables()["QMAKE_FILETAGS"]; 513 QStringList &l = project->variables()["QMAKE_FILETAGS"];
441 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 514 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
442 QStringList &gdmf = project->variables()[(*it)]; 515 QStringList &gdmf = project->variables()[(*it)];
443 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner) 516 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner)
444 (*inner) = Option::fixPathToTargetOS((*inner), FALSE); 517 (*inner) = Option::fixPathToTargetOS((*inner), FALSE);
445 } 518 }
446 519
447 if ( !project->variables()["DEF_FILE"].isEmpty() ) 520 if ( !project->variables()["DEF_FILE"].isEmpty() )
448 project->variables()["QMAKE_LFLAGS"].append(QString("/DEF:") + project->first("DEF_FILE")); 521 project->variables()["QMAKE_LFLAGS"].append(QString("/DEF:") + project->first("DEF_FILE"));
449 if(!project->isActiveConfig("incremental")) 522 if(!project->isActiveConfig("incremental"))
450 project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no")); 523 project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no"));
451 524
452 if ( !project->variables()["VERSION"].isEmpty() ) { 525 if ( !project->variables()["VERSION"].isEmpty() ) {
453 QString version = project->variables()["VERSION"][0]; 526 QString version = project->variables()["VERSION"][0];
454 int firstDot = version.find( "." ); 527 int firstDot = version.find( "." );
455 QString major = version.left( firstDot ); 528 QString major = version.left( firstDot );
456 QString minor = version.right( version.length() - firstDot - 1 ); 529 QString minor = version.right( version.length() - firstDot - 1 );
457 minor.replace( ".", "" ); 530 minor.replace( ".", "" );
458 project->variables()["QMAKE_LFLAGS"].append( "/VERSION:" + major + "." + minor ); 531 project->variables()["QMAKE_LFLAGS"].append( "/VERSION:" + major + "." + minor );
459 } 532 }
460 if ( !project->variables()["RC_FILE"].isEmpty()) { 533 if ( !project->variables()["RC_FILE"].isEmpty()) {
461 if ( !project->variables()["RES_FILE"].isEmpty()) { 534 if ( !project->variables()["RES_FILE"].isEmpty()) {
462 fprintf(stderr, "Both .rc and .res file specified.\n"); 535 fprintf(stderr, "Both .rc and .res file specified.\n");
463 fprintf(stderr, "Please specify one of them, not both."); 536 fprintf(stderr, "Please specify one of them, not both.");
464 exit(666); 537 exit(666);
465 } 538 }
466 project->variables()["RES_FILE"] = project->variables()["RC_FILE"]; 539 project->variables()["RES_FILE"] = project->variables()["RC_FILE"];
467 project->variables()["RES_FILE"].first().replace(".rc",".res"); 540 project->variables()["RES_FILE"].first().replace(".rc",".res");
468 project->variables()["TARGETDEPS"] += project->variables()["RES_FILE"]; 541 project->variables()["POST_TARGETDEPS"] += project->variables()["RES_FILE"];
469 } 542 }
470 if ( !project->variables()["RES_FILE"].isEmpty()) 543 if ( !project->variables()["RES_FILE"].isEmpty())
471 project->variables()["QMAKE_LIBS"] += project->variables()["RES_FILE"]; 544 project->variables()["QMAKE_LIBS"] += project->variables()["RES_FILE"];
472 545
473 MakefileGenerator::init(); 546 MakefileGenerator::init();
474 if ( !project->variables()["VERSION"].isEmpty()) { 547 if ( !project->variables()["VERSION"].isEmpty()) {
475 QStringList l = QStringList::split('.', project->first("VERSION")); 548 QStringList l = QStringList::split('.', project->first("VERSION"));
476 project->variables()["VER_MAJ"].append(l[0]); 549 project->variables()["VER_MAJ"].append(l[0]);
477 project->variables()["VER_MIN"].append(l[1]); 550 project->variables()["VER_MIN"].append(l[1]);
478 } 551 }
552
553 QString version = QStringList::split('.', project->first("VERSION")).join("");
479 if(project->isActiveConfig("dll")) { 554 if(project->isActiveConfig("dll")) {
480 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + ".lib"); 555 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + version + ".exp");
481 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + ".exp");
482 } 556 }
483 if(project->isActiveConfig("debug")) { 557 if(project->isActiveConfig("debug")) {
484 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + ".pdb"); 558 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + version + ".pdb");
485 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + ".ilk"); 559 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + version + ".ilk");
486 project->variables()["QMAKE_CLEAN"].append("vc*.pdb"); 560 project->variables()["QMAKE_CLEAN"].append("vc*.pdb");
487 } 561 }
488} 562}