Diffstat (limited to 'qmake/generators/win32/msvc_nmake.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | qmake/generators/win32/msvc_nmake.cpp | 98 |
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 | |||
@@ -2,13 +2,13 @@ | |||
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. |
@@ -35,12 +35,13 @@ | |||
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 | ||
46 | NmakeMakefileGenerator::NmakeMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE) | 47 | NmakeMakefileGenerator::NmakeMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE) |
@@ -132,12 +133,14 @@ NmakeMakefileGenerator::writeNmakeParts(QTextStream &t) | |||
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; |
@@ -153,29 +156,72 @@ NmakeMakefileGenerator::writeNmakeParts(QTextStream &t) | |||
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 | } |
@@ -217,12 +263,13 @@ NmakeMakefileGenerator::writeNmakeParts(QTextStream &t) | |||
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 ", ""); |
@@ -243,12 +290,16 @@ NmakeMakefileGenerator::writeNmakeParts(QTextStream &t) | |||
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 | ||
252 | void | 303 | void |
253 | NmakeMakefileGenerator::init() | 304 | NmakeMakefileGenerator::init() |
254 | { | 305 | { |
@@ -428,12 +479,34 @@ NmakeMakefileGenerator::init() | |||
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"); |
@@ -462,27 +535,28 @@ NmakeMakefileGenerator::init() | |||
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 | } |