Diffstat (limited to 'qmake/generators/win32/msvc_nmake.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | qmake/generators/win32/msvc_nmake.cpp | 321 |
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,26 +1,24 @@ | |||
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 |
14 | ** LICENSE.QPL included in the packaging of this file. | 12 | ** LICENSE.QPL included in the packaging of this file. |
15 | ** | 13 | ** |
16 | ** This file may be distributed and/or modified under the terms of the | 14 | ** 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 | 15 | ** GNU General Public License version 2 as published by the Free Software |
18 | ** Foundation and appearing in the file LICENSE.GPL included in the | 16 | ** Foundation and appearing in the file LICENSE.GPL included in the |
19 | ** packaging of this file. | 17 | ** packaging of this file. |
20 | ** | 18 | ** |
21 | ** Licensees holding valid Qt Enterprise Edition licenses may use this | 19 | ** Licensees holding valid Qt Enterprise Edition licenses may use this |
22 | ** file in accordance with the Qt Commercial License Agreement provided | 20 | ** file in accordance with the Qt Commercial License Agreement provided |
23 | ** with the Software. | 21 | ** with the Software. |
24 | ** | 22 | ** |
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 23 | ** 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. | 24 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
@@ -30,319 +28,483 @@ | |||
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | 28 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. |
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 29 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
32 | ** | 30 | ** |
33 | ** Contact info@trolltech.com if any conditions of this licensing are | 31 | ** Contact info@trolltech.com if any conditions of this licensing are |
34 | ** not clear to you. | 32 | ** not clear to you. |
35 | ** | 33 | ** |
36 | **********************************************************************/ | 34 | **********************************************************************/ |
37 | 35 | ||
38 | #include "msvc_nmake.h" | 36 | #include "msvc_nmake.h" |
39 | #include "option.h" | 37 | #include "option.h" |
40 | #include <qregexp.h> | 38 | #include <qregexp.h> |
41 | #include <qdict.h> | 39 | #include <qdict.h> |
42 | #include <qdir.h> | 40 | #include <qdir.h> |
43 | #include <stdlib.h> | 41 | #include <stdlib.h> |
44 | #include <time.h> | 42 | #include <time.h> |
45 | 43 | ||
46 | |||
47 | NmakeMakefileGenerator::NmakeMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE) | 44 | NmakeMakefileGenerator::NmakeMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE) |
48 | { | 45 | { |
49 | 46 | ||
50 | } | 47 | } |
51 | 48 | ||
52 | bool | 49 | bool |
53 | NmakeMakefileGenerator::writeMakefile(QTextStream &t) | 50 | 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" |
60 | << "@echo \"Skipped.\"" << endl << endl; | 62 | << "@echo \"Skipped.\"" << endl << endl; |
61 | writeMakeQmake(t); | 63 | writeMakeQmake(t); |
62 | return TRUE; | 64 | return TRUE; |
63 | } | 65 | } |
64 | 66 | ||
65 | if(project->first("TEMPLATE") == "app" || | 67 | if(project->first("TEMPLATE") == "app" || |
66 | project->first("TEMPLATE") == "lib") { | 68 | project->first("TEMPLATE") == "lib") { |
67 | writeNmakeParts(t); | 69 | writeNmakeParts(t); |
68 | return MakefileGenerator::writeMakefile(t); | 70 | return MakefileGenerator::writeMakefile(t); |
69 | } | 71 | } |
70 | else if(project->first("TEMPLATE") == "subdirs") { | 72 | else if(project->first("TEMPLATE") == "subdirs") { |
71 | writeSubDirs(t); | 73 | writeSubDirs(t); |
72 | return TRUE; | 74 | return TRUE; |
73 | } | 75 | } |
74 | return FALSE; | 76 | return FALSE; |
75 | } | 77 | } |
76 | 78 | ||
79 | QStringList | ||
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 | |||
77 | void | 97 | void |
78 | NmakeMakefileGenerator::writeNmakeParts(QTextStream &t) | 98 | NmakeMakefileGenerator::writeNmakeParts(QTextStream &t) |
79 | { | 99 | { |
80 | t << "####### Compiler, tools and options" << endl << endl; | 100 | t << "####### Compiler, tools and options" << endl << endl; |
81 | t << "CC =" << var("QMAKE_CC") << endl; | 101 | t << "CC =" << var("QMAKE_CC") << endl; |
82 | t << "CXX =" << var("QMAKE_CXX") << endl; | 102 | t << "CXX =" << var("QMAKE_CXX") << endl; |
83 | t << "LEX = " << var("QMAKE_LEX") << endl; | 103 | t << "LEX = " << var("QMAKE_LEX") << endl; |
84 | t << "YACC = " << var("QMAKE_YACC") << endl; | 104 | t << "YACC = " << var("QMAKE_YACC") << endl; |
85 | t << "CFLAGS =" << var("QMAKE_CFLAGS") << " " | 105 | t << "CFLAGS =" << var("QMAKE_CFLAGS") << " " |
86 | << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " " | 106 | << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " " |
87 | << varGlue("DEFINES","-D"," -D","") << endl; | 107 | << varGlue("DEFINES","-D"," -D","") << endl; |
88 | t << "CXXFLAGS =" << var("QMAKE_CXXFLAGS") << " " | 108 | t << "CXXFLAGS =" << var("QMAKE_CXXFLAGS") << " " |
89 | << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " " | 109 | << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " " |
90 | << varGlue("DEFINES","-D"," -D","") << endl; | 110 | << varGlue("DEFINES","-D"," -D","") << endl; |
91 | t << "LEXFLAGS=" << var("QMAKE_LEXFLAGS") << endl; | 111 | t << "LEXFLAGS=" << var("QMAKE_LEXFLAGS") << endl; |
92 | t << "YACCFLAGS=" << var("QMAKE_YACCFLAGS") << endl; | 112 | t << "YACCFLAGS=" << var("QMAKE_YACCFLAGS") << endl; |
93 | 113 | ||
94 | t << "INCPATH ="; | 114 | t << "INCPATH ="; |
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() << "\"" |
103 | << endl; | 123 | << endl; |
104 | if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) { | 124 | if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) { |
105 | t << "LINK =" << var("QMAKE_LINK") << endl; | 125 | t << "LINK =" << var("QMAKE_LINK") << endl; |
106 | t << "LFLAGS =" << var("QMAKE_LFLAGS"); | 126 | t << "LFLAGS =" << var("QMAKE_LFLAGS"); |
107 | if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() ) | 127 | if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() ) |
108 | t << " " << varGlue("QMAKE_LIBDIR","/LIBPATH:\"","\" /LIBPATH:\"","\""); | 128 | t << " " << varGlue("QMAKE_LIBDIR","/LIBPATH:\"","\" /LIBPATH:\"","\""); |
109 | t << endl; | 129 | t << endl; |
110 | t << "LIBS ="; | 130 | t << "LIBS ="; |
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; |
119 | } | 139 | } |
120 | else { | 140 | else { |
121 | t << "LIB =" << var("QMAKE_LIB") << endl; | 141 | t << "LIB =" << var("QMAKE_LIB") << endl; |
122 | } | 142 | } |
123 | t << "MOC =" << (project->isEmpty("QMAKE_MOC") ? QString("moc") : | 143 | t << "MOC =" << (project->isEmpty("QMAKE_MOC") ? QString("moc") : |
124 | Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl; | 144 | Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl; |
125 | t << "UIC =" << (project->isEmpty("QMAKE_UIC") ? QString("uic") : | 145 | t << "UIC =" << (project->isEmpty("QMAKE_UIC") ? QString("uic") : |
126 | Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl; | 146 | Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl; |
127 | t << "QMAKE =" << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : | 147 | t << "QMAKE =" << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : |
128 | Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl; | 148 | Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl; |
129 | t << "IDC =" << (project->isEmpty("QMAKE_IDC") ? QString("idc") : | 149 | t << "IDC =" << (project->isEmpty("QMAKE_IDC") ? QString("idc") : |
130 | Option::fixPathToTargetOS(var("QMAKE_IDC"), FALSE)) << endl; | 150 | Option::fixPathToTargetOS(var("QMAKE_IDC"), FALSE)) << endl; |
131 | t << "IDL =" << (project->isEmpty("QMAKE_IDL") ? QString("midl") : | 151 | t << "IDL =" << (project->isEmpty("QMAKE_IDL") ? QString("midl") : |
132 | Option::fixPathToTargetOS(var("QMAKE_IDL"), FALSE)) << endl; | 152 | Option::fixPathToTargetOS(var("QMAKE_IDL"), FALSE)) << endl; |
133 | t << "ZIP =" << var("QMAKE_ZIP") << endl; | 153 | t << "ZIP =" << var("QMAKE_ZIP") << endl; |
134 | t << "COPY_FILE= " << var("QMAKE_COPY") << endl; | 154 | t << "COPY_FILE= " << var("QMAKE_COPY") << endl; |
135 | t << "COPY_DIR= " << var("QMAKE_COPY") << endl; | 155 | t << "COPY_DIR= " << var("QMAKE_COPY") << endl; |
136 | t << "DEL_FILE= " << var("QMAKE_DEL_FILE") << endl; | 156 | t << "DEL_FILE= " << var("QMAKE_DEL_FILE") << endl; |
137 | t << "DEL_DIR= " << var("QMAKE_DEL_DIR") << endl; | 157 | t << "DEL_DIR= " << var("QMAKE_DEL_DIR") << endl; |
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; |
144 | t << "HEADERS =" << varList("HEADERS") << endl; | 166 | t << "HEADERS =" << varList("HEADERS") << endl; |
145 | t << "SOURCES =" << varList("SOURCES") << endl; | 167 | t << "SOURCES =" << varList("SOURCES") << endl; |
146 | t << "OBJECTS =" << varList("OBJECTS") << endl; | 168 | t << "OBJECTS =" << varList("OBJECTS") << endl; |
147 | t << "FORMS =" << varList("FORMS") << endl; | 169 | t << "FORMS =" << varList("FORMS") << endl; |
148 | t << "UICDECLS =" << varList("UICDECLS") << endl; | 170 | t << "UICDECLS =" << varList("UICDECLS") << endl; |
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() ) |
155 | t << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT")); | 194 | t << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT")); |
156 | else | 195 | else |
157 | t << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first(); | 196 | t << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first(); |
158 | t << endl; | 197 | t << endl; |
159 | t << endl; | 198 | t << endl; |
160 | 199 | ||
161 | t << "####### Implicit rules" << endl << endl; | 200 | t << "####### Implicit rules" << endl << endl; |
162 | t << ".SUFFIXES: .c"; | 201 | t << ".SUFFIXES: .c"; |
163 | QStringList::Iterator cppit; | 202 | QStringList::Iterator cppit; |
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"); |
170 | project->variables().remove("QMAKE_RUN_CC"); | 210 | project->variables().remove("QMAKE_RUN_CC"); |
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]]; |
183 | for(QStringList::Iterator sit = l.begin(); sit != l.end(); ++sit) { | 225 | for(QStringList::Iterator sit = l.begin(); sit != l.end(); ++sit) { |
184 | QString sep = "\\"; | 226 | QString sep = "\\"; |
185 | if((*sit).find(sep) == -1) | 227 | if((*sit).find(sep) == -1) |
186 | sep = "/"; | 228 | sep = "/"; |
187 | QString dir = (*sit).section(sep, 0, -2); | 229 | QString dir = (*sit).section(sep, 0, -2); |
188 | if(!dir.isEmpty() && !source_directories[dir]) | 230 | if(!dir.isEmpty() && !source_directories[dir]) |
189 | source_directories.insert(dir, (void*)1); | 231 | source_directories.insert(dir, (void*)1); |
190 | } | 232 | } |
191 | } | 233 | } |
192 | 234 | ||
193 | for(QDictIterator<void> it(source_directories); it.current(); ++it) { | 235 | for(QDictIterator<void> it(source_directories); it.current(); ++it) { |
194 | if(it.currentKey().isEmpty()) | 236 | if(it.currentKey().isEmpty()) |
195 | continue; | 237 | continue; |
196 | for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) | 238 | 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" | 239 | 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; | 240 | << 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" | 241 | 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; | 242 | << var("QMAKE_RUN_CC_IMP_BATCH").replace( QRegExp( "\\$@" ), var("OBJECTS_DIR") ) << endl << "\t$<" << endl << "<<" << endl << endl; |
201 | } | 243 | } |
202 | } else { | 244 | } else { |
203 | for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) | 245 | 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; | 246 | 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; | 247 | t << ".c" << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl; |
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)"; |
215 | } else { | 257 | } else { |
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(); |
229 | if(project->isActiveConfig("activeqt")) { | 272 | if(project->isActiveConfig("activeqt")) { |
230 | QString version = project->variables()["VERSION"].first(); | 273 | QString version = project->variables()["VERSION"].first(); |
231 | if ( version.isEmpty() ) | 274 | if ( version.isEmpty() ) |
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 | } |
246 | t << endl << endl; | 289 | t << endl << endl; |
247 | 290 | ||
248 | if(!project->variables()["RC_FILE"].isEmpty()) { | 291 | if(!project->variables()["RC_FILE"].isEmpty()) { |
249 | t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t" | 292 | t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\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()) |
283 | targ = (*it); | 346 | targ = (*it); |
284 | QStringList &deplist = project->variables()[(*it) + ".depends"]; | 347 | QStringList &deplist = project->variables()[(*it) + ".depends"]; |
285 | for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) { | 348 | for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) { |
286 | QString dep = var((*dep_it) + ".target"); | 349 | QString dep = var((*dep_it) + ".target"); |
287 | if(dep.isEmpty()) | 350 | if(dep.isEmpty()) |
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 | ||
426 | QString | ||
427 | NmakeMakefileGenerator::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 | ||
303 | void | 454 | void |
304 | NmakeMakefileGenerator::init() | 455 | NmakeMakefileGenerator::init() |
305 | { | 456 | { |
306 | if(init_flag) | 457 | if(init_flag) |
307 | return; | 458 | return; |
308 | init_flag = TRUE; | 459 | init_flag = TRUE; |
309 | 460 | ||
310 | /* this should probably not be here, but I'm using it to wrap the .t files */ | 461 | /* this should probably not be here, but I'm using it to wrap the .t files */ |
311 | if(project->first("TEMPLATE") == "app") | 462 | if(project->first("TEMPLATE") == "app") |
312 | project->variables()["QMAKE_APP_FLAG"].append("1"); | 463 | project->variables()["QMAKE_APP_FLAG"].append("1"); |
313 | else if(project->first("TEMPLATE") == "lib") | 464 | else if(project->first("TEMPLATE") == "lib") |
314 | project->variables()["QMAKE_LIB_FLAG"].append("1"); | 465 | project->variables()["QMAKE_LIB_FLAG"].append("1"); |
315 | else if(project->first("TEMPLATE") == "subdirs") { | 466 | else if(project->first("TEMPLATE") == "subdirs") { |
316 | MakefileGenerator::init(); | 467 | MakefileGenerator::init(); |
317 | if(project->variables()["MAKEFILE"].isEmpty()) | 468 | if(project->variables()["MAKEFILE"].isEmpty()) |
318 | project->variables()["MAKEFILE"].append("Makefile"); | 469 | project->variables()["MAKEFILE"].append("Makefile"); |
319 | if(project->variables()["QMAKE"].isEmpty()) | 470 | if(project->variables()["QMAKE"].isEmpty()) |
320 | project->variables()["QMAKE"].append("qmake"); | 471 | project->variables()["QMAKE"].append("qmake"); |
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 | ||
327 | QString targetfilename = project->variables()["TARGET"].first(); | 483 | QString targetfilename = project->variables()["TARGET"].first(); |
328 | QStringList &configs = project->variables()["CONFIG"]; | 484 | QStringList &configs = project->variables()["CONFIG"]; |
329 | if (project->isActiveConfig("qt") && project->isActiveConfig("shared")) | 485 | if (project->isActiveConfig("qt") && project->isActiveConfig("shared")) |
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"); |
336 | if(project->isActiveConfig("qt")) | 498 | if(project->isActiveConfig("qt")) |
337 | project->variables()["DEFINES"].append("QT_PLUGIN"); | 499 | project->variables()["DEFINES"].append("QT_PLUGIN"); |
338 | } | 500 | } |
339 | if ( (project->variables()["DEFINES"].findIndex("QT_NODLL") == -1) && | 501 | if ( (project->variables()["DEFINES"].findIndex("QT_NODLL") == -1) && |
340 | ((project->variables()["DEFINES"].findIndex("QT_MAKEDLL") != -1 || | 502 | ((project->variables()["DEFINES"].findIndex("QT_MAKEDLL") != -1 || |
341 | project->variables()["DEFINES"].findIndex("QT_DLL") != -1) || | 503 | project->variables()["DEFINES"].findIndex("QT_DLL") != -1) || |
342 | (getenv("QT_DLL") && !getenv("QT_NODLL"))) ) { | 504 | (getenv("QT_DLL") && !getenv("QT_NODLL"))) ) { |
343 | project->variables()["QMAKE_QT_DLL"].append("1"); | 505 | project->variables()["QMAKE_QT_DLL"].append("1"); |
344 | if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) | 506 | if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) |
345 | project->variables()["CONFIG"].append("dll"); | 507 | project->variables()["CONFIG"].append("dll"); |
346 | } | 508 | } |
347 | if ( project->isActiveConfig("thread") ) | 509 | if ( project->isActiveConfig("thread") ) |
348 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT"); | 510 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT"); |
@@ -388,32 +550,39 @@ NmakeMakefileGenerator::init() | |||
388 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT"]; | 550 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT"]; |
389 | } | 551 | } |
390 | } | 552 | } |
391 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RELEASE"]; | 553 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RELEASE"]; |
392 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RELEASE"]; | 554 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RELEASE"]; |
393 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_RELEASE"]; | 555 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_RELEASE"]; |
394 | } | 556 | } |
395 | if ( project->isActiveConfig("thread") && !project->variables()["DEFINES"].contains("QT_DLL") | 557 | if ( project->isActiveConfig("thread") && !project->variables()["DEFINES"].contains("QT_DLL") |
396 | && !is_qt && project->first("TARGET") != "qtmain") { | 558 | && !is_qt && project->first("TARGET") != "qtmain") { |
397 | project->variables()["QMAKE_LFLAGS"].append("/NODEFAULTLIB:\"libc\""); | 559 | project->variables()["QMAKE_LFLAGS"].append("/NODEFAULTLIB:\"libc\""); |
398 | } | 560 | } |
399 | 561 | ||
400 | if ( !project->variables()["QMAKE_INCDIR"].isEmpty()) | 562 | if ( !project->variables()["QMAKE_INCDIR"].isEmpty()) |
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"]; |
407 | project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"]; | 576 | project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"]; |
408 | if ( !project->isActiveConfig("debug") ) | 577 | if ( !project->isActiveConfig("debug") ) |
409 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG"); | 578 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG"); |
410 | if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { | 579 | if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { |
411 | if ( !project->variables()["QMAKE_QT_DLL"].isEmpty()) { | 580 | if ( !project->variables()["QMAKE_QT_DLL"].isEmpty()) { |
412 | project->variables()["DEFINES"].append("QT_MAKEDLL"); | 581 | project->variables()["DEFINES"].append("QT_MAKEDLL"); |
413 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_QT_DLL"]; | 582 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_QT_DLL"]; |
414 | } | 583 | } |
415 | } else { | 584 | } else { |
416 | if(project->isActiveConfig("thread")) | 585 | if(project->isActiveConfig("thread")) |
417 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; | 586 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; |
418 | else | 587 | else |
419 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; | 588 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; |
@@ -495,68 +664,124 @@ NmakeMakefileGenerator::init() | |||
495 | } else { | 664 | } else { |
496 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_OFF"]; | 665 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_OFF"]; |
497 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_OFF"]; | 666 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_OFF"]; |
498 | } | 667 | } |
499 | if ( project->isActiveConfig("rtti") ) { | 668 | if ( project->isActiveConfig("rtti") ) { |
500 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_ON"]; | 669 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_ON"]; |
501 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_ON"]; | 670 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_ON"]; |
502 | } else { | 671 | } else { |
503 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_OFF"]; | 672 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_OFF"]; |
504 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_OFF"]; | 673 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_OFF"]; |
505 | } | 674 | } |
506 | 675 | ||
507 | 676 | ||
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); |
518 | } | 703 | } |
519 | 704 | ||
520 | if ( !project->variables()["DEF_FILE"].isEmpty() ) | 705 | if ( !project->variables()["DEF_FILE"].isEmpty() ) |
521 | project->variables()["QMAKE_LFLAGS"].append(QString("/DEF:") + project->first("DEF_FILE")); | 706 | project->variables()["QMAKE_LFLAGS"].append(QString("/DEF:") + project->first("DEF_FILE")); |
522 | if(!project->isActiveConfig("incremental")) | 707 | if(!project->isActiveConfig("incremental")) |
523 | project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no")); | 708 | project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no")); |
524 | 709 | ||
525 | if ( !project->variables()["VERSION"].isEmpty() ) { | 710 | if ( !project->variables()["VERSION"].isEmpty() ) { |
526 | QString version = project->variables()["VERSION"][0]; | 711 | QString version = project->variables()["VERSION"][0]; |
527 | int firstDot = version.find( "." ); | 712 | int firstDot = version.find( "." ); |
528 | QString major = version.left( firstDot ); | 713 | QString major = version.left( firstDot ); |
529 | QString minor = version.right( version.length() - firstDot - 1 ); | 714 | QString minor = version.right( version.length() - firstDot - 1 ); |
530 | minor.replace( ".", "" ); | 715 | minor.replace( ".", "" ); |
531 | project->variables()["QMAKE_LFLAGS"].append( "/VERSION:" + major + "." + minor ); | 716 | project->variables()["QMAKE_LFLAGS"].append( "/VERSION:" + major + "." + minor ); |
532 | } | 717 | } |
533 | if ( !project->variables()["RC_FILE"].isEmpty()) { | 718 | if ( !project->variables()["RC_FILE"].isEmpty()) { |
534 | if ( !project->variables()["RES_FILE"].isEmpty()) { | 719 | if ( !project->variables()["RES_FILE"].isEmpty()) { |
535 | fprintf(stderr, "Both .rc and .res file specified.\n"); | 720 | fprintf(stderr, "Both .rc and .res file specified.\n"); |
536 | fprintf(stderr, "Please specify one of them, not both."); | 721 | fprintf(stderr, "Please specify one of them, not both."); |
537 | exit(666); | 722 | exit(666); |
538 | } | 723 | } |
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]); |
550 | project->variables()["VER_MIN"].append(l[1]); | 754 | project->variables()["VER_MIN"].append(l[1]); |
551 | } | 755 | } |
552 | 756 | ||
553 | QString version = QStringList::split('.', project->first("VERSION")).join(""); | 757 | QString version = QStringList::split('.', project->first("VERSION")).join(""); |
554 | if(project->isActiveConfig("dll")) { | 758 | if(project->isActiveConfig("dll")) { |
555 | project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + version + ".exp"); | 759 | project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + version + ".exp"); |
556 | } | 760 | } |
557 | if(project->isActiveConfig("debug")) { | 761 | if(project->isActiveConfig("debug")) { |
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 | } |