1 | /****************************************************************************
|
---|
2 | ** $Id: msvc_nmake.cpp 8 2005-11-16 19:36:46Z dmik $
|
---|
3 | **
|
---|
4 | ** Implementation of NmakeMakefileGenerator class.
|
---|
5 | **
|
---|
6 | ** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
|
---|
7 | **
|
---|
8 | ** This file is part of qmake.
|
---|
9 | **
|
---|
10 | ** This file may be distributed under the terms of the Q Public License
|
---|
11 | ** as defined by Trolltech AS of Norway and appearing in the file
|
---|
12 | ** LICENSE.QPL included in the packaging of this file.
|
---|
13 | **
|
---|
14 | ** This file may be distributed and/or modified under the terms of the
|
---|
15 | ** GNU General Public License version 2 as published by the Free Software
|
---|
16 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
17 | ** packaging of this file.
|
---|
18 | **
|
---|
19 | ** Licensees holding valid Qt Enterprise Edition licenses may use this
|
---|
20 | ** file in accordance with the Qt Commercial License Agreement provided
|
---|
21 | ** with the Software.
|
---|
22 | **
|
---|
23 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
24 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
25 | **
|
---|
26 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
27 | ** information about Qt Commercial License Agreements.
|
---|
28 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
---|
29 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
30 | **
|
---|
31 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
32 | ** not clear to you.
|
---|
33 | **
|
---|
34 | **********************************************************************/
|
---|
35 |
|
---|
36 | #include "msvc_nmake.h"
|
---|
37 | #include "option.h"
|
---|
38 | #include <qregexp.h>
|
---|
39 | #include <qdict.h>
|
---|
40 | #include <qdir.h>
|
---|
41 | #include <stdlib.h>
|
---|
42 | #include <time.h>
|
---|
43 |
|
---|
44 | NmakeMakefileGenerator::NmakeMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE)
|
---|
45 | {
|
---|
46 |
|
---|
47 | }
|
---|
48 |
|
---|
49 | bool
|
---|
50 | NmakeMakefileGenerator::writeMakefile(QTextStream &t)
|
---|
51 | {
|
---|
52 | writeHeader(t);
|
---|
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 | }
|
---|
59 | t << "all clean:" << "\n\t"
|
---|
60 | << "@echo \"Some of the required modules ("
|
---|
61 | << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t"
|
---|
62 | << "@echo \"Skipped.\"" << endl << endl;
|
---|
63 | writeMakeQmake(t);
|
---|
64 | return TRUE;
|
---|
65 | }
|
---|
66 |
|
---|
67 | if(project->first("TEMPLATE") == "app" ||
|
---|
68 | project->first("TEMPLATE") == "lib") {
|
---|
69 | writeNmakeParts(t);
|
---|
70 | return MakefileGenerator::writeMakefile(t);
|
---|
71 | }
|
---|
72 | else if(project->first("TEMPLATE") == "subdirs") {
|
---|
73 | writeSubDirs(t);
|
---|
74 | return TRUE;
|
---|
75 | }
|
---|
76 | return FALSE;
|
---|
77 | }
|
---|
78 |
|
---|
79 | QStringList
|
---|
80 | &NmakeMakefileGenerator::findDependencies(const QString &file)
|
---|
81 | {
|
---|
82 | QStringList &aList = MakefileGenerator::findDependencies(file);
|
---|
83 | // [dmik] this method can be called from MakefileGenerator::init() before
|
---|
84 | // precompH is set in NmakeMakefileGenerator::init(), so we check it
|
---|
85 | // to avoid appending of NULL string to the list of dependencies
|
---|
86 | if (!precompH.isNull()) {
|
---|
87 | // Note: The QMAKE_IMAGE_COLLECTION file have all images
|
---|
88 | // as dependency, so don't add precompiled header then
|
---|
89 | if (file == project->first("QMAKE_IMAGE_COLLECTION"))
|
---|
90 | return aList;
|
---|
91 | for(QStringList::Iterator it = Option::cpp_ext.begin(); it != Option::cpp_ext.end(); ++it) {
|
---|
92 | if(file.endsWith(*it)) {
|
---|
93 | if(!aList.contains(precompH))
|
---|
94 | aList += precompH;
|
---|
95 | break;
|
---|
96 | }
|
---|
97 | }
|
---|
98 | }
|
---|
99 | return aList;
|
---|
100 | }
|
---|
101 |
|
---|
102 | void
|
---|
103 | NmakeMakefileGenerator::writeNmakeParts(QTextStream &t)
|
---|
104 | {
|
---|
105 | t << "####### Compiler, tools and options" << endl << endl;
|
---|
106 | t << "CC = " << var("QMAKE_CC") << endl;
|
---|
107 | t << "CXX = " << var("QMAKE_CXX") << endl;
|
---|
108 | t << "LEX = " << var("QMAKE_LEX") << endl;
|
---|
109 | t << "YACC = " << var("QMAKE_YACC") << endl;
|
---|
110 | t << "CFLAGS = " << var("QMAKE_CFLAGS") << " "
|
---|
111 | << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "
|
---|
112 | << varGlue("DEFINES","-D"," -D","") << endl;
|
---|
113 | t << "CXXFLAGS = " << var("QMAKE_CXXFLAGS") << " "
|
---|
114 | << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "
|
---|
115 | << varGlue("DEFINES","-D"," -D","") << endl;
|
---|
116 | t << "LEXFLAGS =" << var("QMAKE_LEXFLAGS") << endl;
|
---|
117 | t << "YACCFLAGS =" << var("QMAKE_YACCFLAGS") << endl;
|
---|
118 |
|
---|
119 | t << "INCPATH = ";
|
---|
120 | QStringList &incs = project->variables()["INCLUDEPATH"];
|
---|
121 | for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) {
|
---|
122 | QString inc = (*incit);
|
---|
123 | if (inc.endsWith("\\"))
|
---|
124 | inc.truncate(inc.length()-1);
|
---|
125 | t << " -I\"" << inc << "\"";
|
---|
126 | }
|
---|
127 | t << " -I\"" << specdir() << "\""
|
---|
128 | << endl;
|
---|
129 | if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
|
---|
130 | t << "LINK = " << var("QMAKE_LINK") << endl;
|
---|
131 | t << "LFLAGS = " << var("QMAKE_LFLAGS");
|
---|
132 | if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() )
|
---|
133 | t << " " << varGlue("QMAKE_LIBDIR","/LIBPATH:\"","\" /LIBPATH:\"","\"");
|
---|
134 | t << endl;
|
---|
135 | t << "LIBS = ";
|
---|
136 | QStringList &libs = project->variables()["QMAKE_LIBS"];
|
---|
137 | for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) {
|
---|
138 | QString lib = (*libit);
|
---|
139 | if (lib.endsWith("\\"))
|
---|
140 | lib.truncate(lib.length()-1);
|
---|
141 | t << " \"" << lib << "\"";
|
---|
142 | }
|
---|
143 | t << endl;
|
---|
144 | }
|
---|
145 | else {
|
---|
146 | t << "LIB = " << var("QMAKE_LIB") << endl;
|
---|
147 | }
|
---|
148 | t << "MOC = " << (project->isEmpty("QMAKE_MOC") ? QString("moc") :
|
---|
149 | Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl;
|
---|
150 | t << "UIC = " << (project->isEmpty("QMAKE_UIC") ? QString("uic") :
|
---|
151 | Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl;
|
---|
152 | t << "QMAKE = " << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") :
|
---|
153 | Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl;
|
---|
154 | t << "IDC = " << (project->isEmpty("QMAKE_IDC") ? QString("idc") :
|
---|
155 | Option::fixPathToTargetOS(var("QMAKE_IDC"), FALSE)) << endl;
|
---|
156 | t << "IDL = " << (project->isEmpty("QMAKE_IDL") ? QString("midl") :
|
---|
157 | Option::fixPathToTargetOS(var("QMAKE_IDL"), FALSE)) << endl;
|
---|
158 | t << "ZIP = " << var("QMAKE_ZIP") << endl;
|
---|
159 | t << "COPY_FILE = " << var("QMAKE_COPY") << endl;
|
---|
160 | t << "COPY_DIR = " << var("QMAKE_COPY") << endl;
|
---|
161 | t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl;
|
---|
162 | t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl;
|
---|
163 | t << "MOVE = " << var("QMAKE_MOVE") << endl;
|
---|
164 | t << "CHK_DIR_EXISTS = " << var("QMAKE_CHK_DIR_EXISTS") << endl;
|
---|
165 | t << "MKDIR = " << var("QMAKE_MKDIR") << endl;
|
---|
166 | t << endl;
|
---|
167 |
|
---|
168 | t << "####### Files" << endl << endl;
|
---|
169 | t << "HEADERS = " << varList("HEADERS") << endl;
|
---|
170 | t << "SOURCES = " << varList("SOURCES") << endl;
|
---|
171 | t << "OBJECTS = " << varList("OBJECTS") << endl;
|
---|
172 | t << "FORMS = " << varList("FORMS") << endl;
|
---|
173 | t << "UICDECLS = " << varList("UICDECLS") << endl;
|
---|
174 | t << "UICIMPLS = " << varList("UICIMPLS") << endl;
|
---|
175 | t << "SRCMOC = " << varList("SRCMOC") << endl;
|
---|
176 | t << "OBJMOC = " << varList("OBJMOC") << endl;
|
---|
177 |
|
---|
178 | QString extraCompilerDeps;
|
---|
179 | if(!project->isEmpty("QMAKE_EXTRA_WIN_COMPILERS")) {
|
---|
180 | t << "OBJCOMP = " << varList("OBJCOMP") << endl;
|
---|
181 | extraCompilerDeps += " $(OBJCOMP) ";
|
---|
182 |
|
---|
183 | QStringList &comps = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"];
|
---|
184 | for(QStringList::Iterator compit = comps.begin(); compit != comps.end(); ++compit) {
|
---|
185 | QStringList &vars = project->variables()[(*compit) + ".variables"];
|
---|
186 | for(QStringList::Iterator varit = vars.begin(); varit != vars.end(); ++varit) {
|
---|
187 | QStringList vals = project->variables()[(*varit)];
|
---|
188 | if(!vals.isEmpty())
|
---|
189 | t << "QMAKE_COMP_" << (*varit) << " = " << valList(vals) << endl;
|
---|
190 | }
|
---|
191 | }
|
---|
192 | }
|
---|
193 |
|
---|
194 | t << "DIST = " << varList("DISTFILES") << endl;
|
---|
195 | t << "TARGET = ";
|
---|
196 | if( !project->variables()[ "DESTDIR" ].isEmpty() )
|
---|
197 | t << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT"));
|
---|
198 | else
|
---|
199 | t << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first();
|
---|
200 | t << endl;
|
---|
201 | t << endl;
|
---|
202 |
|
---|
203 | t << "####### Implicit rules" << endl << endl;
|
---|
204 | t << ".SUFFIXES: .c";
|
---|
205 | QStringList::Iterator cppit;
|
---|
206 | for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
|
---|
207 | t << " " << (*cppit);
|
---|
208 | t << endl << endl;
|
---|
209 |
|
---|
210 | if(!project->isActiveConfig("no_batch")) {
|
---|
211 | // Batchmode doesn't use the non implicit rules QMAKE_RUN_CXX & QMAKE_RUN_CC
|
---|
212 | project->variables().remove("QMAKE_RUN_CXX");
|
---|
213 | project->variables().remove("QMAKE_RUN_CC");
|
---|
214 |
|
---|
215 | QDict<void> source_directories;
|
---|
216 | source_directories.insert(".", (void*)1);
|
---|
217 | QString directories[] = { QString("MOC_DIR"), QString("UI_SOURCES_DIR"), QString("UI_DIR"), QString::null };
|
---|
218 | for(int y = 0; !directories[y].isNull(); y++) {
|
---|
219 | QString dirTemp = project->first(directories[y]);
|
---|
220 | if (dirTemp.endsWith("\\"))
|
---|
221 | dirTemp.truncate(dirTemp.length()-1);
|
---|
222 | if(!dirTemp.isEmpty())
|
---|
223 | source_directories.insert(dirTemp, (void*)1);
|
---|
224 | }
|
---|
225 | QString srcs[] = { QString("SOURCES"), QString("UICIMPLS"), QString("SRCMOC"), QString::null };
|
---|
226 | for(int x = 0; !srcs[x].isNull(); x++) {
|
---|
227 | QStringList &l = project->variables()[srcs[x]];
|
---|
228 | for(QStringList::Iterator sit = l.begin(); sit != l.end(); ++sit) {
|
---|
229 | QString sep = "\\";
|
---|
230 | if((*sit).find(sep) == -1)
|
---|
231 | sep = "/";
|
---|
232 | QString dir = (*sit).section(sep, 0, -2);
|
---|
233 | if(!dir.isEmpty() && !source_directories[dir])
|
---|
234 | source_directories.insert(dir, (void*)1);
|
---|
235 | }
|
---|
236 | }
|
---|
237 |
|
---|
238 | for(QDictIterator<void> it(source_directories); it.current(); ++it) {
|
---|
239 | if(it.currentKey().isEmpty())
|
---|
240 | continue;
|
---|
241 | for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
|
---|
242 | t << "{" << it.currentKey() << "}" << (*cppit) << "{" << var("OBJECTS_DIR") << "}" << Option::obj_ext << "::\n\t"
|
---|
243 | << var("QMAKE_RUN_CXX_IMP_BATCH").replace( QRegExp( "\\$@" ), var("OBJECTS_DIR") ) << endl << "\t$<" << endl << "<<" << endl << endl;
|
---|
244 | t << "{" << it.currentKey() << "}" << ".c{" << var("OBJECTS_DIR") << "}" << Option::obj_ext << "::\n\t"
|
---|
245 | << var("QMAKE_RUN_CC_IMP_BATCH").replace( QRegExp( "\\$@" ), var("OBJECTS_DIR") ) << endl << "\t$<" << endl << "<<" << endl << endl;
|
---|
246 | }
|
---|
247 | } else {
|
---|
248 | for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
|
---|
249 | t << (*cppit) << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
|
---|
250 | t << ".c" << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;
|
---|
251 | }
|
---|
252 |
|
---|
253 | t << "####### Build rules" << endl << endl;
|
---|
254 | t << "all: " << fileFixify(Option::output.name()) << " " << varGlue("ALL_DEPS"," "," "," ") << "$(TARGET)" << endl << endl;
|
---|
255 | t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) "
|
---|
256 | << extraCompilerDeps << var("POST_TARGETDEPS");
|
---|
257 | if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
|
---|
258 | t << "\n\t" << "$(LINK) $(LFLAGS) /OUT:$(TARGET) @<< " << "\n\t "
|
---|
259 | << "$(OBJECTS) $(OBJMOC) $(LIBS)";
|
---|
260 | } else {
|
---|
261 | t << "\n\t" << "$(LIB) /OUT:$(TARGET) @<<" << "\n\t "
|
---|
262 | << "$(OBJECTS) $(OBJMOC)";
|
---|
263 | }
|
---|
264 | t << extraCompilerDeps;
|
---|
265 | t << endl << "<<" << endl;
|
---|
266 | if ( !project->variables()["QMAKE_POST_LINK"].isEmpty() )
|
---|
267 | t << "\t" << var( "QMAKE_POST_LINK" ) << endl;
|
---|
268 | if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) {
|
---|
269 | QStringList dlldirs = project->variables()["DLLDESTDIR"];
|
---|
270 | for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) {
|
---|
271 | t << "\n\t" << "-$(COPY_FILE) $(TARGET) " << *dlldir;
|
---|
272 | }
|
---|
273 | }
|
---|
274 | QString targetfilename = project->variables()["TARGET"].first();
|
---|
275 | if(project->isActiveConfig("activeqt")) {
|
---|
276 | QString version = project->variables()["VERSION"].first();
|
---|
277 | if ( version.isEmpty() )
|
---|
278 | version = "1.0";
|
---|
279 |
|
---|
280 | if ( project->isActiveConfig("dll")) {
|
---|
281 | t << "\n\t" << ("-$(IDC) $(TARGET) /idl " + var("OBJECTS_DIR") + targetfilename + ".idl -version " + version);
|
---|
282 | t << "\n\t" << ("-$(IDL) /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
|
---|
283 | t << "\n\t" << ("-$(IDC) $(TARGET) /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
|
---|
284 | t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" );
|
---|
285 | } else {
|
---|
286 | t << "\n\t" << ("-$(TARGET) -dumpidl " + var("OBJECTS_DIR") + targetfilename + ".idl -version " + version);
|
---|
287 | t << "\n\t" << ("-$(IDL) /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
|
---|
288 | t << "\n\t" << ("-$(IDC) $(TARGET) /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
|
---|
289 | t << "\n\t" << "-$(TARGET) -regserver";
|
---|
290 | }
|
---|
291 | }
|
---|
292 | t << endl << endl;
|
---|
293 |
|
---|
294 | if(!project->variables()["RC_FILE"].isEmpty()) {
|
---|
295 | t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t"
|
---|
296 | << var("QMAKE_RC") << " " << var("RC_FILE") << endl << endl;
|
---|
297 | }
|
---|
298 |
|
---|
299 | t << "mocables: $(SRCMOC)" << endl
|
---|
300 | << "uicables: $(UICIMPLS) $(UICDECLS)" << endl << endl;
|
---|
301 |
|
---|
302 | writeMakeQmake(t);
|
---|
303 |
|
---|
304 | QStringList dist_files = Option::mkfile::project_files;
|
---|
305 | if(!project->isEmpty("QMAKE_INTERNAL_INCLUDED_FILES"))
|
---|
306 | dist_files += project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"];
|
---|
307 | if(!project->isEmpty("TRANSLATIONS"))
|
---|
308 | dist_files << var("TRANSLATIONS");
|
---|
309 | if(!project->isEmpty("FORMS")) {
|
---|
310 | QStringList &forms = project->variables()["FORMS"];
|
---|
311 | for(QStringList::Iterator formit = forms.begin(); formit != forms.end(); ++formit) {
|
---|
312 | QString ui_h = fileFixify((*formit) + Option::h_ext.first());
|
---|
313 | if(QFile::exists(ui_h) )
|
---|
314 | dist_files << ui_h;
|
---|
315 | }
|
---|
316 | }
|
---|
317 | t << "dist:" << "\n\t"
|
---|
318 | << "$(ZIP) " << var("QMAKE_ORIG_TARGET") << ".zip " << "$(SOURCES) $(HEADERS) $(DIST) $(FORMS) "
|
---|
319 | << dist_files.join(" ") << " " << var("TRANSLATIONS") << " " << var("IMAGES") << endl << endl;
|
---|
320 |
|
---|
321 | t << "uiclean:"
|
---|
322 | << varGlue("UICDECLS" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")
|
---|
323 | << varGlue("UICIMPLS" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","") << endl;
|
---|
324 |
|
---|
325 | t << "mocclean:"
|
---|
326 | << varGlue("SRCMOC" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")
|
---|
327 | << varGlue("OBJMOC" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","") << endl;
|
---|
328 |
|
---|
329 | t << "clean: uiclean mocclean"
|
---|
330 | << varGlue("OBJECTS","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")
|
---|
331 | << varGlue("QMAKE_CLEAN","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","\n")
|
---|
332 | << varGlue("CLEAN_FILES","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","\n");
|
---|
333 | if ( project->isActiveConfig("activeqt")) {
|
---|
334 | t << ("\n\t-$(DEL_FILE) " + var("OBJECTS_DIR") + targetfilename + ".idl");
|
---|
335 | t << ("\n\t-$(DEL_FILE) " + var("OBJECTS_DIR") + targetfilename + ".tlb");
|
---|
336 | }
|
---|
337 | if(!project->isEmpty("IMAGES"))
|
---|
338 | t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-$(DEL_FILE) ", "\n\t-$(DEL_FILE) ", "");
|
---|
339 | t << endl;
|
---|
340 |
|
---|
341 | // user defined targets
|
---|
342 |
|
---|
343 | QStringList::Iterator it;
|
---|
344 | QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"];
|
---|
345 | for(it = qut.begin(); it != qut.end(); ++it) {
|
---|
346 | QString targ = var((*it) + ".target"),
|
---|
347 | cmd = var((*it) + ".commands"), deps;
|
---|
348 | if(targ.isEmpty())
|
---|
349 | targ = (*it);
|
---|
350 | QStringList &deplist = project->variables()[(*it) + ".depends"];
|
---|
351 | for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) {
|
---|
352 | QString dep = var((*dep_it) + ".target");
|
---|
353 | if(dep.isEmpty())
|
---|
354 | dep = (*dep_it);
|
---|
355 | deps += " " + dep;
|
---|
356 | }
|
---|
357 | if(!project->variables()["QMAKE_NOFORCE"].isEmpty() &&
|
---|
358 | project->variables()[(*it) + ".CONFIG"].findIndex("phony") != -1)
|
---|
359 | deps += QString(" ") + "FORCE";
|
---|
360 | t << "\n\n" << targ << ":" << deps << "\n\t"
|
---|
361 | << cmd;
|
---|
362 | }
|
---|
363 | t << endl << endl;
|
---|
364 |
|
---|
365 | QStringList &quc = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"];
|
---|
366 | for(it = quc.begin(); it != quc.end(); ++it) {
|
---|
367 | QString tmp_out = project->variables()[(*it) + ".output"].first();
|
---|
368 | QString tmp_cmd = project->variables()[(*it) + ".commands"].join(" ");
|
---|
369 | QString tmp_dep = project->variables()[(*it) + ".depends"].join(" ");
|
---|
370 | QStringList &vars = project->variables()[(*it) + ".variables"];
|
---|
371 | if(tmp_out.isEmpty() || tmp_cmd.isEmpty())
|
---|
372 | continue;
|
---|
373 | QStringList &tmp = project->variables()[(*it) + ".input"];
|
---|
374 | for(QStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {
|
---|
375 | QStringList &inputs = project->variables()[(*it2)];
|
---|
376 | for(QStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {
|
---|
377 | QFileInfo fi(Option::fixPathToLocalOS((*input)));
|
---|
378 | QString in = Option::fixPathToTargetOS((*input), FALSE),
|
---|
379 | out = tmp_out, cmd = tmp_cmd, deps;
|
---|
380 | out.replace("${QMAKE_FILE_BASE}", fi.baseName());
|
---|
381 | out.replace("${QMAKE_FILE_NAME}", fi.fileName());
|
---|
382 | cmd.replace("${QMAKE_FILE_BASE}", fi.baseName());
|
---|
383 | cmd.replace("${QMAKE_FILE_OUT}", out);
|
---|
384 | cmd.replace("${QMAKE_FILE_NAME}", fi.fileName());
|
---|
385 | for(QStringList::Iterator it3 = vars.begin(); it3 != vars.end(); ++it3)
|
---|
386 | cmd.replace("$(" + (*it3) + ")", "$(QMAKE_COMP_" + (*it3)+")");
|
---|
387 | if(!tmp_dep.isEmpty()) {
|
---|
388 | char buff[256];
|
---|
389 | QString dep_cmd = tmp_dep;
|
---|
390 | dep_cmd.replace("${QMAKE_FILE_NAME}", fi.fileName());
|
---|
391 | if(FILE *proc = QT_POPEN(dep_cmd.latin1(), "r")) {
|
---|
392 | while(!feof(proc)) {
|
---|
393 | int read_in = fread(buff, 1, 255, proc);
|
---|
394 | if(!read_in)
|
---|
395 | break;
|
---|
396 | int l = 0;
|
---|
397 | for(int i = 0; i < read_in; i++) {
|
---|
398 | if(buff[i] == '\n' || buff[i] == ' ') {
|
---|
399 | deps += " " + QCString(buff+l, (i - l) + 1);
|
---|
400 | l = i;
|
---|
401 | }
|
---|
402 | }
|
---|
403 | }
|
---|
404 | fclose(proc);
|
---|
405 | }
|
---|
406 | }
|
---|
407 | t << out << ": " << in << deps << "\n\t"
|
---|
408 | << cmd << endl << endl;
|
---|
409 | }
|
---|
410 | }
|
---|
411 | }
|
---|
412 | t << endl;
|
---|
413 |
|
---|
414 | if(project->variables()["QMAKE_NOFORCE"].isEmpty())
|
---|
415 | t << "FORCE:" << endl << endl;
|
---|
416 |
|
---|
417 | t << "distclean: clean"
|
---|
418 | << "\n\t-$(DEL_FILE) $(TARGET)"
|
---|
419 | << endl << endl;
|
---|
420 |
|
---|
421 | // precompiled header
|
---|
422 | if(usePCH) {
|
---|
423 | QString precompRule = QString("-c -Yc -Fp%1 -Fo%2").arg(precompPch).arg(precompObj);
|
---|
424 | t << precompObj << ": " << precompH << " " << findDependencies(precompH).join(" \\\n\t\t")
|
---|
425 | << "\n\t" << "$(CXX) " + precompRule +" $(CXXFLAGS) $(INCPATH) -TP " << precompH << endl << endl;
|
---|
426 | }
|
---|
427 | }
|
---|
428 |
|
---|
429 | QString
|
---|
430 | NmakeMakefileGenerator::var(const QString &value)
|
---|
431 | {
|
---|
432 | if (usePCH) {
|
---|
433 | if ((value == "QMAKE_RUN_CXX_IMP_BATCH"
|
---|
434 | || value == "QMAKE_RUN_CXX_IMP"
|
---|
435 | || value == "QMAKE_RUN_CXX")) {
|
---|
436 | QFileInfo precompHInfo(precompH);
|
---|
437 | QString precompRule = QString("-c -FI%1 -Yu%2 -Fp%3")
|
---|
438 | .arg(precompHInfo.fileName())
|
---|
439 | .arg(precompHInfo.fileName())
|
---|
440 | .arg(precompPch);
|
---|
441 | QString p = MakefileGenerator::var(value);
|
---|
442 | p.replace("-c", precompRule);
|
---|
443 | // Cannot use -Gm with -FI & -Yu, as this gives an
|
---|
444 | // internal compiler error, on the newer compilers
|
---|
445 | p.remove("-Gm");
|
---|
446 | return p;
|
---|
447 | } else if (value == "QMAKE_CXXFLAGS") {
|
---|
448 | // Remove internal compiler error option
|
---|
449 | return MakefileGenerator::var(value).remove("-Gm");
|
---|
450 | }
|
---|
451 | }
|
---|
452 |
|
---|
453 | // Normal val
|
---|
454 | return MakefileGenerator::var(value);
|
---|
455 | }
|
---|
456 |
|
---|
457 | void
|
---|
458 | NmakeMakefileGenerator::init()
|
---|
459 | {
|
---|
460 | if(init_flag)
|
---|
461 | return;
|
---|
462 | init_flag = TRUE;
|
---|
463 |
|
---|
464 | /* this should probably not be here, but I'm using it to wrap the .t files */
|
---|
465 | if(project->first("TEMPLATE") == "app")
|
---|
466 | project->variables()["QMAKE_APP_FLAG"].append("1");
|
---|
467 | else if(project->first("TEMPLATE") == "lib")
|
---|
468 | project->variables()["QMAKE_LIB_FLAG"].append("1");
|
---|
469 | else if(project->first("TEMPLATE") == "subdirs") {
|
---|
470 | MakefileGenerator::init();
|
---|
471 | if(project->variables()["MAKEFILE"].isEmpty())
|
---|
472 | project->variables()["MAKEFILE"].append("Makefile");
|
---|
473 | if(project->variables()["QMAKE"].isEmpty())
|
---|
474 | project->variables()["QMAKE"].append("qmake");
|
---|
475 | return;
|
---|
476 | }
|
---|
477 |
|
---|
478 | bool is_qt = (project->first("TARGET") == "qt"QTDLL_POSTFIX || project->first("TARGET") == "qt-mt"QTDLL_POSTFIX);
|
---|
479 | project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"];
|
---|
480 |
|
---|
481 | QString targetfilename = project->variables()["TARGET"].first();
|
---|
482 | QStringList &configs = project->variables()["CONFIG"];
|
---|
483 | if (project->isActiveConfig("qt") && project->isActiveConfig("shared"))
|
---|
484 | project->variables()["DEFINES"].append("QT_DLL");
|
---|
485 | if (project->isActiveConfig("qt_dll"))
|
---|
486 | if(configs.findIndex("qt") == -1) configs.append("qt");
|
---|
487 | if ( project->isActiveConfig("qtopia") ) {
|
---|
488 | if(configs.findIndex("qtopialib") == -1)
|
---|
489 | configs.append("qtopialib");
|
---|
490 | if(configs.findIndex("qtopiainc") == -1)
|
---|
491 | configs.append("qtopiainc");
|
---|
492 | }
|
---|
493 | if ( project->isActiveConfig("qt") ) {
|
---|
494 | if ( project->isActiveConfig( "plugin" ) ) {
|
---|
495 | project->variables()["CONFIG"].append("dll");
|
---|
496 | if(project->isActiveConfig("qt"))
|
---|
497 | project->variables()["DEFINES"].append("QT_PLUGIN");
|
---|
498 | }
|
---|
499 | if ( (project->variables()["DEFINES"].findIndex("QT_NODLL") == -1) &&
|
---|
500 | ((project->variables()["DEFINES"].findIndex("QT_MAKEDLL") != -1 ||
|
---|
501 | project->variables()["DEFINES"].findIndex("QT_DLL") != -1) ||
|
---|
502 | (getenv("QT_DLL") && !getenv("QT_NODLL"))) ) {
|
---|
503 | project->variables()["QMAKE_QT_DLL"].append("1");
|
---|
504 | if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() )
|
---|
505 | project->variables()["CONFIG"].append("dll");
|
---|
506 | }
|
---|
507 | if ( project->isActiveConfig("thread") )
|
---|
508 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT");
|
---|
509 | if ( project->isActiveConfig("accessibility" ) )
|
---|
510 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT");
|
---|
511 | if ( project->isActiveConfig("tablet") )
|
---|
512 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT");
|
---|
513 | }
|
---|
514 | if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
|
---|
515 | project->variables()["CONFIG"].remove("staticlib");
|
---|
516 | project->variables()["QMAKE_APP_OR_DLL"].append("1");
|
---|
517 | } else {
|
---|
518 | project->variables()["CONFIG"].append("staticlib");
|
---|
519 | }
|
---|
520 | if ( project->isActiveConfig("warn_off") ) {
|
---|
521 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_OFF"];
|
---|
522 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_OFF"];
|
---|
523 | } else if ( project->isActiveConfig("warn_on") ) {
|
---|
524 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_ON"];
|
---|
525 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_ON"];
|
---|
526 | }
|
---|
527 | if ( project->isActiveConfig("debug") ) {
|
---|
528 | if ( project->isActiveConfig("thread") ) {
|
---|
529 | // use the DLL RT even here
|
---|
530 | if ( project->variables()["DEFINES"].contains("QT_DLL") ) {
|
---|
531 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLLDBG"];
|
---|
532 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"];
|
---|
533 | } else {
|
---|
534 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DBG"];
|
---|
535 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DBG"];
|
---|
536 | }
|
---|
537 | }
|
---|
538 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_DEBUG"];
|
---|
539 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_DEBUG"];
|
---|
540 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_DEBUG"];
|
---|
541 | } else {
|
---|
542 | if ( project->isActiveConfig("thread") ) {
|
---|
543 | if ( project->variables()["DEFINES"].contains("QT_DLL") ) {
|
---|
544 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLL"];
|
---|
545 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLL"];
|
---|
546 | } else {
|
---|
547 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT"];
|
---|
548 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT"];
|
---|
549 | }
|
---|
550 | }
|
---|
551 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RELEASE"];
|
---|
552 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RELEASE"];
|
---|
553 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_RELEASE"];
|
---|
554 | }
|
---|
555 | if ( project->isActiveConfig("thread") && !project->variables()["DEFINES"].contains("QT_DLL")
|
---|
556 | && !is_qt && project->first("TARGET") != "qtmain") {
|
---|
557 | project->variables()["QMAKE_LFLAGS"].append("/NODEFAULTLIB:\"libc\"");
|
---|
558 | }
|
---|
559 |
|
---|
560 | if ( !project->variables()["QMAKE_INCDIR"].isEmpty())
|
---|
561 | project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"];
|
---|
562 | if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") )
|
---|
563 | project->variables()["CONFIG"].append("windows");
|
---|
564 | if ( project->isActiveConfig("qtopiainc") )
|
---|
565 | project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QTOPIA"];
|
---|
566 | if ( project->isActiveConfig("qtopialib") ) {
|
---|
567 | if(!project->isEmpty("QMAKE_LIBDIR_QTOPIA"))
|
---|
568 | project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QTOPIA"];
|
---|
569 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QTOPIA"];
|
---|
570 | }
|
---|
571 | if ( project->isActiveConfig("qt") ) {
|
---|
572 | project->variables()["CONFIG"].append("moc");
|
---|
573 | project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QT"];
|
---|
574 | project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"];
|
---|
575 | if ( !project->isActiveConfig("debug") )
|
---|
576 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG");
|
---|
577 | if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) {
|
---|
578 | if ( !project->variables()["QMAKE_QT_DLL"].isEmpty()) {
|
---|
579 | project->variables()["DEFINES"].append("QT_MAKEDLL");
|
---|
580 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_QT_DLL"];
|
---|
581 | }
|
---|
582 | } else {
|
---|
583 | if(project->isActiveConfig("thread"))
|
---|
584 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"];
|
---|
585 | else
|
---|
586 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"];
|
---|
587 | if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) {
|
---|
588 | int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt");
|
---|
589 | if ( hver == -1 )
|
---|
590 | hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt-mt");
|
---|
591 | if(hver != -1) {
|
---|
592 | QString ver;
|
---|
593 | ver.sprintf("qt%s" QTDLL_POSTFIX "%d.lib", (project->isActiveConfig("thread") ? "-mt" : ""), hver);
|
---|
594 | QStringList &libs = project->variables()["QMAKE_LIBS"];
|
---|
595 | for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit)
|
---|
596 | (*libit).replace(QRegExp("qt(-mt)?\\.lib"), ver);
|
---|
597 | }
|
---|
598 | }
|
---|
599 | if ( project->isActiveConfig( "activeqt" ) ) {
|
---|
600 | project->variables().remove("QMAKE_LIBS_QT_ENTRY");
|
---|
601 | project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib";
|
---|
602 | if ( project->isActiveConfig( "dll" ) )
|
---|
603 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"];
|
---|
604 | }
|
---|
605 | if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) {
|
---|
606 | project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"];
|
---|
607 | }
|
---|
608 | }
|
---|
609 | }
|
---|
610 | if ( project->isActiveConfig("opengl") ) {
|
---|
611 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"];
|
---|
612 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"];
|
---|
613 | }
|
---|
614 | if ( project->isActiveConfig("dll") ) {
|
---|
615 | project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE_DLL"];
|
---|
616 | project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE_DLL"];
|
---|
617 | project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE_DLL"];
|
---|
618 | project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS_DLL"];
|
---|
619 | if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty()) {
|
---|
620 | project->variables()["TARGET_EXT"].append(
|
---|
621 | QStringList::split('.',project->first("VERSION")).join("") + ".dll");
|
---|
622 | } else {
|
---|
623 | project->variables()["TARGET_EXT"].append(".dll");
|
---|
624 | }
|
---|
625 | } else {
|
---|
626 | project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE"];
|
---|
627 | project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE"];
|
---|
628 | project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE"];
|
---|
629 | project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS"];
|
---|
630 | if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty()) {
|
---|
631 | project->variables()["TARGET_EXT"].append(".exe");
|
---|
632 | } else {
|
---|
633 | project->variables()["TARGET_EXT"].append(".lib");
|
---|
634 | }
|
---|
635 | }
|
---|
636 | if ( project->isActiveConfig("windows") ) {
|
---|
637 | if ( project->isActiveConfig("console") ) {
|
---|
638 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
|
---|
639 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
|
---|
640 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
|
---|
641 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
|
---|
642 | } else {
|
---|
643 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"];
|
---|
644 | }
|
---|
645 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"];
|
---|
646 | } else {
|
---|
647 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
|
---|
648 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
|
---|
649 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
|
---|
650 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
|
---|
651 | }
|
---|
652 | if ( project->isActiveConfig("stl") ) {
|
---|
653 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_ON"];
|
---|
654 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_ON"];
|
---|
655 | } else {
|
---|
656 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_OFF"];
|
---|
657 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_OFF"];
|
---|
658 | }
|
---|
659 | if ( project->isActiveConfig("exceptions") ) {
|
---|
660 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_ON"];
|
---|
661 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_ON"];
|
---|
662 | } else {
|
---|
663 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_OFF"];
|
---|
664 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_OFF"];
|
---|
665 | }
|
---|
666 | if ( project->isActiveConfig("rtti") ) {
|
---|
667 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_ON"];
|
---|
668 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_ON"];
|
---|
669 | } else {
|
---|
670 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_OFF"];
|
---|
671 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_OFF"];
|
---|
672 | }
|
---|
673 |
|
---|
674 |
|
---|
675 | if ( project->isActiveConfig("moc") )
|
---|
676 | setMocAware(TRUE);
|
---|
677 | project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
|
---|
678 |
|
---|
679 | QStringList &libList = project->variables()["QMAKE_LIBS"];
|
---|
680 | for( QStringList::Iterator stIt = libList.begin(); stIt != libList.end(); ) {
|
---|
681 | QString s = *stIt;
|
---|
682 | if( s.startsWith( "-l" ) ) {
|
---|
683 | stIt = libList.remove( stIt );
|
---|
684 | stIt = libList.insert( stIt, s.mid( 2 ) + ".lib" );
|
---|
685 | } else if( s.startsWith( "-L" ) ) {
|
---|
686 | stIt = libList.remove( stIt );
|
---|
687 | project->variables()["QMAKE_LIBDIR"].append(QDir::convertSeparators(s.mid( 2 )));
|
---|
688 | } else {
|
---|
689 | stIt++;
|
---|
690 | }
|
---|
691 | }
|
---|
692 |
|
---|
693 | project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ',
|
---|
694 | "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH");
|
---|
695 | QStringList &l = project->variables()["QMAKE_FILETAGS"];
|
---|
696 | QStringList::Iterator it;
|
---|
697 | for(it = l.begin(); it != l.end(); ++it) {
|
---|
698 | QStringList &gdmf = project->variables()[(*it)];
|
---|
699 | for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner)
|
---|
700 | (*inner) = Option::fixPathToTargetOS((*inner), FALSE);
|
---|
701 | }
|
---|
702 |
|
---|
703 | if ( !project->variables()["DEF_FILE"].isEmpty() )
|
---|
704 | project->variables()["QMAKE_LFLAGS"].append(QString("/DEF:") + project->first("DEF_FILE"));
|
---|
705 | if(!project->isActiveConfig("incremental"))
|
---|
706 | project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no"));
|
---|
707 |
|
---|
708 | if ( !project->variables()["VERSION"].isEmpty() ) {
|
---|
709 | QString version = project->variables()["VERSION"][0];
|
---|
710 | int firstDot = version.find( "." );
|
---|
711 | QString major = version.left( firstDot );
|
---|
712 | QString minor = version.right( version.length() - firstDot - 1 );
|
---|
713 | minor.replace( ".", "" );
|
---|
714 | project->variables()["QMAKE_LFLAGS"].append( "/VERSION:" + major + "." + minor );
|
---|
715 | }
|
---|
716 | if ( !project->variables()["RC_FILE"].isEmpty()) {
|
---|
717 | if ( !project->variables()["RES_FILE"].isEmpty()) {
|
---|
718 | fprintf(stderr, "Both .rc and .res file specified.\n");
|
---|
719 | fprintf(stderr, "Please specify one of them, not both.");
|
---|
720 | exit(666);
|
---|
721 | }
|
---|
722 | project->variables()["RES_FILE"] = project->variables()["RC_FILE"];
|
---|
723 | project->variables()["RES_FILE"].first().replace(".rc",".res");
|
---|
724 | project->variables()["POST_TARGETDEPS"] += project->variables()["RES_FILE"];
|
---|
725 | project->variables()["CLEAN_FILES"] += project->variables()["RES_FILE"];
|
---|
726 | }
|
---|
727 | if ( !project->variables()["RES_FILE"].isEmpty())
|
---|
728 | project->variables()["QMAKE_LIBS"] += project->variables()["RES_FILE"];
|
---|
729 |
|
---|
730 | // Base class init!
|
---|
731 | MakefileGenerator::init();
|
---|
732 |
|
---|
733 | // Setup PCH variables
|
---|
734 | precompH = project->first("PRECOMPILED_HEADER");
|
---|
735 | usePCH = !precompH.isEmpty() && project->isActiveConfig("precompile_header");
|
---|
736 | if (usePCH) {
|
---|
737 | // Created files
|
---|
738 | precompObj = var("OBJECTS_DIR") + project->first("TARGET") + "_pch" + Option::obj_ext;
|
---|
739 | precompPch = var("OBJECTS_DIR") + project->first("TARGET") + "_pch.pch";
|
---|
740 | // Add linking of precompObj (required for whole precompiled classes)
|
---|
741 | project->variables()["OBJECTS"] += precompObj;
|
---|
742 | // Add pch file to cleanup
|
---|
743 | project->variables()["QMAKE_CLEAN"] += precompPch;
|
---|
744 | // Return to variable pool
|
---|
745 | project->variables()["PRECOMPILED_OBJECT"] = precompObj;
|
---|
746 | project->variables()["PRECOMPILED_PCH"] = precompPch;
|
---|
747 | }
|
---|
748 |
|
---|
749 | if ( !project->variables()["VERSION"].isEmpty()) {
|
---|
750 | QStringList l = QStringList::split('.', project->first("VERSION"));
|
---|
751 | project->variables()["VER_MAJ"].append(l[0]);
|
---|
752 | project->variables()["VER_MIN"].append(l[1]);
|
---|
753 | }
|
---|
754 |
|
---|
755 | QString version = QStringList::split('.', project->first("VERSION")).join("");
|
---|
756 | if(project->isActiveConfig("dll")) {
|
---|
757 | project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + version + ".exp");
|
---|
758 | }
|
---|
759 | if(project->isActiveConfig("debug")) {
|
---|
760 | project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + version + ".pdb");
|
---|
761 | project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + version + ".ilk");
|
---|
762 | project->variables()["QMAKE_CLEAN"].append("vc*.pdb");
|
---|
763 | project->variables()["QMAKE_CLEAN"].append("vc*.idb");
|
---|
764 | }
|
---|
765 |
|
---|
766 | QStringList &quc = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"];
|
---|
767 | for(it = quc.begin(); it != quc.end(); ++it) {
|
---|
768 | QString tmp_out = project->variables()[(*it) + ".output"].first();
|
---|
769 | if(tmp_out.isEmpty())
|
---|
770 | continue;
|
---|
771 | QStringList &tmp = project->variables()[(*it) + ".input"];
|
---|
772 | for(QStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {
|
---|
773 | QStringList &inputs = project->variables()[(*it2)];
|
---|
774 | for(QStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {
|
---|
775 | QFileInfo fi(Option::fixPathToLocalOS((*input)));
|
---|
776 | QString in = Option::fixPathToTargetOS((*input), FALSE),
|
---|
777 | out = tmp_out;
|
---|
778 | out.replace("${QMAKE_FILE_BASE}", fi.baseName());
|
---|
779 | out.replace("${QMAKE_FILE_NAME}", fi.fileName());
|
---|
780 | if(project->variables()[(*it) + ".CONFIG"].findIndex("no_link") == -1)
|
---|
781 | project->variables()["OBJCOMP"] += out;
|
---|
782 | }
|
---|
783 | }
|
---|
784 | }
|
---|
785 | }
|
---|