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.cpp321
1 files changed, 273 insertions, 48 deletions
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$ 2**
3** 3**
4** Definition of ________ class. 4** Implementation of NmakeMakefileGenerator class.
5** 5**
6** Created : 970521 6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
7** 7**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. 8** This file is part of qmake.
9**
10** This file is part of the network module of the Qt GUI Toolkit.
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 ","") 321
265 << varGlue("UICDECLS" ,"\n\t-del ","\n\t-del ","") 322 t << "mocclean:"
266 << varGlue("UICIMPLS" ,"\n\t-del ","\n\t-del ","") 323 << varGlue("SRCMOC" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")
267 << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ","") 324 << varGlue("OBJMOC" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","") << endl;
268 << varGlue("CLEAN_FILES","\n\t-del ","\n\t-del ",""); 325
269 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}