Diffstat (limited to 'qmake/generators/win32/mingw_make.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | qmake/generators/win32/mingw_make.cpp | 524 |
1 files changed, 524 insertions, 0 deletions
diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp new file mode 100644 index 0000000..7f58a55 --- a/dev/null +++ b/qmake/generators/win32/mingw_make.cpp | |||
@@ -0,0 +1,524 @@ | |||
1 | /**************************************************************************** | ||
2 | ** $Id$ | ||
3 | ** | ||
4 | ** Definition of ________ class. | ||
5 | ** | ||
6 | ** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. | ||
7 | ** | ||
8 | ** This file is part of the network module of the Qt GUI Toolkit. | ||
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 "mingw_make.h" | ||
37 | #include "option.h" | ||
38 | #include <qregexp.h> | ||
39 | #include <qdir.h> | ||
40 | #include <stdlib.h> | ||
41 | #include <time.h> | ||
42 | |||
43 | |||
44 | MingwMakefileGenerator::MingwMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE) | ||
45 | { | ||
46 | Option::obj_ext = ".o"; | ||
47 | } | ||
48 | |||
49 | bool | ||
50 | MingwMakefileGenerator::writeMakefile(QTextStream &t) | ||
51 | { | ||
52 | writeHeader(t); | ||
53 | if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) { | ||
54 | t << "all clean:" << "\n\t" | ||
55 | << "@echo \"Some of the required modules (" | ||
56 | << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t" | ||
57 | << "@echo \"Skipped.\"" << endl << endl; | ||
58 | writeMakeQmake(t); | ||
59 | return TRUE; | ||
60 | } | ||
61 | |||
62 | if(project->first("TEMPLATE") == "app" || | ||
63 | project->first("TEMPLATE") == "lib") { | ||
64 | writeMingwParts(t); | ||
65 | return MakefileGenerator::writeMakefile(t); | ||
66 | } | ||
67 | else if(project->first("TEMPLATE") == "subdirs") { | ||
68 | writeSubDirs(t); | ||
69 | return TRUE; | ||
70 | } | ||
71 | return FALSE; | ||
72 | } | ||
73 | |||
74 | void | ||
75 | MingwMakefileGenerator::writeMingwParts(QTextStream &t) | ||
76 | { | ||
77 | t << "####### Compiler, tools and options" << endl << endl; | ||
78 | t << "CC =" << var("QMAKE_CC") << endl; | ||
79 | t << "CXX =" << var("QMAKE_CXX") << endl; | ||
80 | t << "LEX = " << var("QMAKE_LEX") << endl; | ||
81 | t << "YACC = " << var("QMAKE_YACC") << endl; | ||
82 | t << "CFLAGS =" << var("QMAKE_CFLAGS") << " " | ||
83 | << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " " | ||
84 | << varGlue("DEFINES","-D"," -D","") << endl; | ||
85 | t << "CXXFLAGS =" << var("QMAKE_CXXFLAGS") << " " | ||
86 | << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " " | ||
87 | << varGlue("DEFINES","-D"," -D","") << endl; | ||
88 | t << "LEXFLAGS=" << var("QMAKE_LEXFLAGS") << endl; | ||
89 | t << "YACCFLAGS=" << var("QMAKE_YACCFLAGS") << endl; | ||
90 | |||
91 | t << "INCPATH ="; | ||
92 | QStringList &incs = project->variables()["INCLUDEPATH"]; | ||
93 | for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) { | ||
94 | QString inc = (*incit); | ||
95 | inc.replace(QRegExp("\\\\$"), "\\\\"); | ||
96 | inc.replace(QRegExp("\""), ""); | ||
97 | t << " -I" << inc ; | ||
98 | } | ||
99 | t << " -I" << specdir() | ||
100 | << endl; | ||
101 | if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) { | ||
102 | t << "LINK =" << var("QMAKE_LINK") << endl; | ||
103 | t << "LFLAGS ="; | ||
104 | if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() ) | ||
105 | t << varGlue("QMAKE_LIBDIR","-L",";","") << " "; | ||
106 | t << var("QMAKE_LFLAGS") << endl; | ||
107 | t << "LIBS =" << var("QMAKE_LIBS").replace(QRegExp("(\\slib|^lib)")," -l") << endl; | ||
108 | } | ||
109 | else { | ||
110 | t << "LIB =" << var("QMAKE_LIB") << endl; | ||
111 | } | ||
112 | t << "MOC =" << (project->isEmpty("QMAKE_MOC") ? QString("moc") : | ||
113 | Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl; | ||
114 | t << "UIC =" << (project->isEmpty("QMAKE_UIC") ? QString("uic") : | ||
115 | Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl; | ||
116 | t << "QMAKE =" << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : | ||
117 | Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl; | ||
118 | t << "IDC =" << (project->isEmpty("QMAKE_IDC") ? QString("idc") : | ||
119 | Option::fixPathToTargetOS(var("QMAKE_IDC"), FALSE)) << endl; | ||
120 | t << "IDL =" << (project->isEmpty("QMAKE_IDL") ? QString("midl") : | ||
121 | Option::fixPathToTargetOS(var("QMAKE_IDL"), FALSE)) << endl; | ||
122 | t << "ZIP =" << var("QMAKE_ZIP") << endl; | ||
123 | t << "DEF_FILE =" << varList("DEF_FILE") << endl; | ||
124 | t << "COPY_FILE= " << var("QMAKE_COPY") << endl; | ||
125 | t << "COPY_DIR= " << var("QMAKE_COPY") << endl; | ||
126 | t << "DEL_FILE= " << var("QMAKE_DEL_FILE") << endl; | ||
127 | t << "DEL_DIR= " << var("QMAKE_DEL_DIR") << endl; | ||
128 | t << "MOVE = " << var("QMAKE_MOVE") << endl; | ||
129 | t << "CHK_DIR_EXISTS =" << var("QMAKE_CHK_DIR_EXISTS") << endl; | ||
130 | t << "MKDIR =" << var("QMAKE_MKDIR") << endl; | ||
131 | t << endl; | ||
132 | |||
133 | t << "####### Output directory" << endl << endl; | ||
134 | if (! project->variables()["OBJECTS_DIR"].isEmpty()) | ||
135 | t << "OBJECTS_DIR = " << var("OBJECTS_DIR").replace(QRegExp("\\\\$"),"") << endl; | ||
136 | else | ||
137 | t << "OBJECTS_DIR = . " << endl; | ||
138 | if (! project->variables()["MOC_DIR"].isEmpty()) | ||
139 | t << "MOC_DIR = " << var("MOC_DIR").replace(QRegExp("\\\\$"),"") << endl; | ||
140 | else | ||
141 | t << "MOC_DIR = . " << endl; | ||
142 | t << endl; | ||
143 | |||
144 | t << "####### Files" << endl << endl; | ||
145 | t << "HEADERS =" << varList("HEADERS") << endl; | ||
146 | t << "SOURCES =" << varList("SOURCES") << endl; | ||
147 | // t << "OBJECTS =" << varList("OBJECTS").replace(QRegExp("\\.obj"),".o") << endl; | ||
148 | t << "OBJECTS =" << varList("OBJECTS") << endl; | ||
149 | t << "FORMS =" << varList("FORMS") << endl; | ||
150 | t << "UICDECLS =" << varList("UICDECLS") << endl; | ||
151 | t << "UICIMPLS =" << varList("UICIMPLS") << endl; | ||
152 | t << "SRCMOC =" << varList("SRCMOC") << endl; | ||
153 | t << "OBJMOC =" << varList("OBJMOC") << endl; | ||
154 | // t << "OBJMOC =" << varList("OBJMOC").replace(QRegExp("\\.obj"),".o") << endl; | ||
155 | t << "DIST =" << varList("DISTFILES") << endl; | ||
156 | t << "TARGET ="; | ||
157 | if( !project->variables()[ "DESTDIR" ].isEmpty() ) | ||
158 | t << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT")); | ||
159 | else | ||
160 | t << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first(); | ||
161 | t << endl; | ||
162 | t << endl; | ||
163 | |||
164 | t << "####### Implicit rules" << endl << endl; | ||
165 | t << ".SUFFIXES: .cpp .cxx .cc .C .c" << endl << endl; | ||
166 | t << ".cpp.o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; | ||
167 | t << ".cxx.o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; | ||
168 | t << ".cc.o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; | ||
169 | t << ".C.o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; | ||
170 | t << ".c.o:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl; | ||
171 | |||
172 | t << "####### Build rules" << endl << endl; | ||
173 | t << "all: " << "$(OBJECTS_DIR) " << "$(MOC_DIR) " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" << endl << endl; | ||
174 | t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) " | ||
175 | << var("POST_TARGETDEPS"); | ||
176 | if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) { | ||
177 | t << "\n\t" << "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)"; | ||
178 | } else { | ||
179 | t << "\n\t" << "$(LIB) $(TARGET) $(OBJECTS) $(OBJMOC)"; | ||
180 | } | ||
181 | |||
182 | if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) { | ||
183 | QStringList dlldirs = project->variables()["DLLDESTDIR"]; | ||
184 | for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) { | ||
185 | t << "\n\t" << "copy $(TARGET) " << *dlldir; | ||
186 | } | ||
187 | } | ||
188 | QString targetfilename = project->variables()["TARGET"].first(); | ||
189 | if(project->isActiveConfig("activeqt")) { | ||
190 | QString version = project->variables()["VERSION"].first(); | ||
191 | if ( version.isEmpty() ) | ||
192 | version = "1.0"; | ||
193 | |||
194 | if ( project->isActiveConfig("dll")) { | ||
195 | t << "\n\t" << ("-$(IDC) $(TARGET) /idl tmp\\" + targetfilename + ".idl -version " + version); | ||
196 | 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"); | ||
197 | t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb"); | ||
198 | t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" ); | ||
199 | } else { | ||
200 | t << "\n\t" << ("-$(TARGET) -dumpidl tmp\\" + targetfilename + ".idl -version " + version); | ||
201 | 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"); | ||
202 | t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb"); | ||
203 | t << "\n\t" << "-$(TARGET) -regserver"; | ||
204 | } | ||
205 | } | ||
206 | t << endl << endl; | ||
207 | |||
208 | if(!project->variables()["RC_FILE"].isEmpty()) { | ||
209 | t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t" | ||
210 | << var("QMAKE_RC") << " -i " << var("RC_FILE") << " -o " << var("RC_FILE").replace(QRegExp("\\.rc"),".o") << endl << endl; | ||
211 | } | ||
212 | project->variables()["RES_FILE"].first().replace(QRegExp("\\.rc"),".o"); | ||
213 | |||
214 | t << "mocables: $(SRCMOC)" << endl << endl; | ||
215 | |||
216 | t << "$(OBJECTS_DIR):" << "\n\t" | ||
217 | << "@if not exist $(OBJECTS_DIR) mkdir $(OBJECTS_DIR)" << endl << endl; | ||
218 | |||
219 | t << "$(MOC_DIR):" << "\n\t" | ||
220 | << "@if not exist $(MOC_DIR) mkdir $(MOC_DIR)" << endl << endl; | ||
221 | |||
222 | writeMakeQmake(t); | ||
223 | |||
224 | t << "dist:" << "\n\t" | ||
225 | << "$(ZIP) " << var("PROJECT") << ".zip " | ||
226 | << var("PROJECT") << ".pro $(SOURCES) $(HEADERS) $(DIST) $(FORMS)" << endl << endl; | ||
227 | |||
228 | t << "clean:" | ||
229 | << varGlue("OBJECTS","\n\t-del ","\n\t-del ","").replace(QRegExp("\\.obj"),".o") | ||
230 | << varGlue("SRCMOC" ,"\n\t-del ","\n\t-del ","") | ||
231 | << varGlue("OBJMOC" ,"\n\t-del ","\n\t-del ","").replace(QRegExp("\\.obj"),".o") | ||
232 | << varGlue("UICDECLS" ,"\n\t-del ","\n\t-del ","") | ||
233 | << varGlue("UICIMPLS" ,"\n\t-del ","\n\t-del ","") | ||
234 | << "\n\t-del $(TARGET)" | ||
235 | << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ","") | ||
236 | << varGlue("CLEAN_FILES","\n\t-del ","\n\t-del ",""); | ||
237 | if ( project->isActiveConfig("activeqt")) { | ||
238 | t << ("\n\t-del tmp\\" + targetfilename + ".*"); | ||
239 | t << "\n\t-del tmp\\dump.*"; | ||
240 | } | ||
241 | if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) | ||
242 | t << "\n\t-del " << var("DLLDESTDIR") << "\\" << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first(); | ||
243 | if(!project->isEmpty("IMAGES")) | ||
244 | t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-del ", "\n\t-del ", ""); | ||
245 | |||
246 | // blasted user defined targets | ||
247 | QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"]; | ||
248 | for(QStringList::Iterator it = qut.begin(); it != qut.end(); ++it) { | ||
249 | QString targ = var((*it) + ".target"), | ||
250 | cmd = var((*it) + ".commands"), deps; | ||
251 | if(targ.isEmpty()) | ||
252 | targ = (*it); | ||
253 | QStringList &deplist = project->variables()[(*it) + ".depends"]; | ||
254 | for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) { | ||
255 | QString dep = var((*dep_it) + ".target"); | ||
256 | if(dep.isEmpty()) | ||
257 | dep = (*dep_it); | ||
258 | deps += " " + dep; | ||
259 | } | ||
260 | t << "\n\n" << targ << ":" << deps << "\n\t" | ||
261 | << cmd; | ||
262 | } | ||
263 | |||
264 | t << endl << endl; | ||
265 | } | ||
266 | |||
267 | |||
268 | void | ||
269 | MingwMakefileGenerator::init() | ||
270 | { | ||
271 | if(init_flag) | ||
272 | return; | ||
273 | init_flag = TRUE; | ||
274 | |||
275 | /* this should probably not be here, but I'm using it to wrap the .t files */ | ||
276 | if(project->first("TEMPLATE") == "app") | ||
277 | project->variables()["QMAKE_APP_FLAG"].append("1"); | ||
278 | else if(project->first("TEMPLATE") == "lib") | ||
279 | project->variables()["QMAKE_LIB_FLAG"].append("1"); | ||
280 | else if(project->first("TEMPLATE") == "subdirs") { | ||
281 | MakefileGenerator::init(); | ||
282 | if(project->variables()["MAKEFILE"].isEmpty()) | ||
283 | project->variables()["MAKEFILE"].append("Makefile"); | ||
284 | if(project->variables()["QMAKE"].isEmpty()) | ||
285 | project->variables()["QMAKE"].append("qmake"); | ||
286 | return; | ||
287 | } | ||
288 | |||
289 | bool is_qt = (project->first("TARGET") == "qt"QTDLL_POSTFIX || project->first("TARGET") == "qt-mt"QTDLL_POSTFIX); | ||
290 | project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"]; | ||
291 | |||
292 | // LIBS defined in Profile comes first for gcc | ||
293 | project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; | ||
294 | |||
295 | QString targetfilename = project->variables()["TARGET"].first(); | ||
296 | QStringList &configs = project->variables()["CONFIG"]; | ||
297 | if (project->isActiveConfig("qt") && project->isActiveConfig("shared")) | ||
298 | project->variables()["DEFINES"].append("QT_DLL"); | ||
299 | if (project->isActiveConfig("qt_dll")) | ||
300 | if(configs.findIndex("qt") == -1) configs.append("qt"); | ||
301 | if ( project->isActiveConfig("qt") ) { | ||
302 | if ( project->isActiveConfig( "plugin" ) ) { | ||
303 | project->variables()["CONFIG"].append("dll"); | ||
304 | if(project->isActiveConfig("qt")) | ||
305 | project->variables()["DEFINES"].append("QT_PLUGIN"); | ||
306 | } | ||
307 | if ( (project->variables()["DEFINES"].findIndex("QT_NODLL") == -1) && | ||
308 | ((project->variables()["DEFINES"].findIndex("QT_MAKEDLL") != -1 || | ||
309 | project->variables()["DEFINES"].findIndex("QT_DLL") != -1) || | ||
310 | (getenv("QT_DLL") && !getenv("QT_NODLL"))) ) { | ||
311 | project->variables()["QMAKE_QT_DLL"].append("1"); | ||
312 | if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) | ||
313 | project->variables()["CONFIG"].append("dll"); | ||
314 | } | ||
315 | if ( project->isActiveConfig("thread") ) | ||
316 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT"); | ||
317 | if ( project->isActiveConfig("accessibility" ) ) | ||
318 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT"); | ||
319 | if ( project->isActiveConfig("tablet") ) | ||
320 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT"); | ||
321 | } | ||
322 | if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { | ||
323 | project->variables()["CONFIG"].remove("staticlib"); | ||
324 | project->variables()["QMAKE_APP_OR_DLL"].append("1"); | ||
325 | } else { | ||
326 | project->variables()["CONFIG"].append("staticlib"); | ||
327 | } | ||
328 | if ( project->isActiveConfig("warn_off") ) { | ||
329 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_OFF"]; | ||
330 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_OFF"]; | ||
331 | } else if ( project->isActiveConfig("warn_on") ) { | ||
332 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_ON"]; | ||
333 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_ON"]; | ||
334 | } | ||
335 | if ( project->isActiveConfig("debug") ) { | ||
336 | if ( project->isActiveConfig("thread") ) { | ||
337 | // use the DLL RT even here | ||
338 | if ( project->variables()["DEFINES"].contains("QT_DLL") ) { | ||
339 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLLDBG"]; | ||
340 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"]; | ||
341 | } else { | ||
342 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DBG"]; | ||
343 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DBG"]; | ||
344 | } | ||
345 | } | ||
346 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_DEBUG"]; | ||
347 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_DEBUG"]; | ||
348 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_DEBUG"]; | ||
349 | } else { | ||
350 | if ( project->isActiveConfig("thread") ) { | ||
351 | if ( project->variables()["DEFINES"].contains("QT_DLL") ) { | ||
352 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLL"]; | ||
353 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLL"]; | ||
354 | } else { | ||
355 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT"]; | ||
356 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT"]; | ||
357 | } | ||
358 | } | ||
359 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RELEASE"]; | ||
360 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RELEASE"]; | ||
361 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_RELEASE"]; | ||
362 | } | ||
363 | |||
364 | if ( !project->variables()["QMAKE_INCDIR"].isEmpty()) | ||
365 | project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"]; | ||
366 | if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") ) | ||
367 | project->variables()["CONFIG"].append("windows"); | ||
368 | if ( project->isActiveConfig("qt") ) { | ||
369 | project->variables()["CONFIG"].append("moc"); | ||
370 | project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"]; | ||
371 | project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"]; | ||
372 | if ( !project->isActiveConfig("debug") ) | ||
373 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG"); | ||
374 | if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { | ||
375 | if ( !project->variables()["QMAKE_QT_DLL"].isEmpty()) { | ||
376 | project->variables()["DEFINES"].append("QT_MAKEDLL"); | ||
377 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_QT_DLL"]; | ||
378 | } | ||
379 | } else { | ||
380 | if(project->isActiveConfig("thread")) | ||
381 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; | ||
382 | else | ||
383 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; | ||
384 | if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { | ||
385 | int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt"); | ||
386 | if ( hver == -1 ) | ||
387 | hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt-mt"); | ||
388 | if(hver != -1) { | ||
389 | QString ver; | ||
390 | ver.sprintf("libqt-%s" QTDLL_POSTFIX "%d.a", (project->isActiveConfig("thread") ? "-mt" : ""), hver); | ||
391 | QStringList &libs = project->variables()["QMAKE_LIBS"]; | ||
392 | // @@@HGTODO maybe we must change the replace regexp if we understand what's going on | ||
393 | for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) | ||
394 | (*libit).replace(QRegExp("qt(-mt)?\\.lib"), ver); | ||
395 | } | ||
396 | } | ||
397 | if ( project->isActiveConfig( "activeqt" ) ) { | ||
398 | project->variables().remove("QMAKE_LIBS_QT_ENTRY"); | ||
399 | project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib"; | ||
400 | if ( project->isActiveConfig( "dll" ) ) | ||
401 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"]; | ||
402 | } | ||
403 | if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) { | ||
404 | project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"]; | ||
405 | } | ||
406 | } | ||
407 | } | ||
408 | if ( project->isActiveConfig("opengl") ) { | ||
409 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; | ||
410 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"]; | ||
411 | } | ||
412 | if ( project->isActiveConfig("dll") ) { | ||
413 | project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE_DLL"]; | ||
414 | project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE_DLL"]; | ||
415 | project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE_DLL"]; | ||
416 | project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS_DLL"]; | ||
417 | if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty()) { | ||
418 | project->variables()["TARGET_EXT"].append( | ||
419 | QStringList::split('.',project->first("VERSION")).join("") + ".dll"); | ||
420 | } else { | ||
421 | project->variables()["TARGET_EXT"].append(".dll"); | ||
422 | } | ||
423 | } else { | ||
424 | project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE"]; | ||
425 | project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE"]; | ||
426 | project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE"]; | ||
427 | project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS"]; | ||
428 | if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty()) { | ||
429 | project->variables()["TARGET_EXT"].append(".exe"); | ||
430 | } else { | ||
431 | project->variables()["TARGET_EXT"].append(".a"); | ||
432 | project->variables()["QMAKE_LFLAGS"].append("-static"); | ||
433 | if(project->variables()["TARGET"].first().left(3) != "lib") | ||
434 | project->variables()["TARGET"].first().prepend("lib"); | ||
435 | } | ||
436 | } | ||
437 | if ( project->isActiveConfig("windows") ) { | ||
438 | if ( project->isActiveConfig("console") ) { | ||
439 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"]; | ||
440 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"]; | ||
441 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"]; | ||
442 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"]; | ||
443 | } else { | ||
444 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"]; | ||
445 | } | ||
446 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"]; | ||
447 | } else { | ||
448 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"]; | ||
449 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"]; | ||
450 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"]; | ||
451 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"]; | ||
452 | } | ||
453 | |||
454 | if ( project->isActiveConfig("moc") ) | ||
455 | setMocAware(TRUE); | ||
456 | project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ', | ||
457 | "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH"); | ||
458 | QStringList &l = project->variables()["QMAKE_FILETAGS"]; | ||
459 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { | ||
460 | QStringList &gdmf = project->variables()[(*it)]; | ||
461 | for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner) | ||
462 | (*inner) = Option::fixPathToTargetOS((*inner), FALSE); | ||
463 | } | ||
464 | |||
465 | if ( project->isActiveConfig("dll") ) | ||
466 | project->variables()["QMAKE_LFLAGS"].append(QString("-Wl,--out-implib,") + project->first("DESTDIR") + "\\lib"+ project->first("TARGET") + ".a"); | ||
467 | |||
468 | if ( !project->variables()["DEF_FILE"].isEmpty() ) | ||
469 | project->variables()["QMAKE_LFLAGS"].append(QString("-Wl,--output-def,") + project->first("DEF_FILE")); | ||
470 | // if(!project->isActiveConfig("incremental")) | ||
471 | //project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no")); | ||
472 | |||
473 | #if 0 | ||
474 | if ( !project->variables()["VERSION"].isEmpty() ) { | ||
475 | QString version = project->variables()["VERSION"][0]; | ||
476 | int firstDot = version.find( "." ); | ||
477 | QString major = version.left( firstDot ); | ||
478 | QString minor = version.right( version.length() - firstDot - 1 ); | ||
479 | minor.replace( ".", "" ); | ||
480 | project->variables()["QMAKE_LFLAGS"].append( "/VERSION:" + major + "." + minor ); | ||
481 | } | ||
482 | #endif | ||
483 | if ( !project->variables()["RC_FILE"].isEmpty()) { | ||
484 | if ( !project->variables()["RES_FILE"].isEmpty()) { | ||
485 | fprintf(stderr, "Both .rc and .res file specified.\n"); | ||
486 | fprintf(stderr, "Please specify one of them, not both."); | ||
487 | exit(666); | ||
488 | } | ||
489 | project->variables()["RES_FILE"] = project->variables()["RC_FILE"]; | ||
490 | project->variables()["RES_FILE"].first().replace(".rc",".o"); | ||
491 | project->variables()["POST_TARGETDEPS"] += project->variables()["RES_FILE"]; | ||
492 | } | ||
493 | if ( !project->variables()["RES_FILE"].isEmpty()) | ||
494 | project->variables()["QMAKE_LIBS"] += project->variables()["RES_FILE"]; | ||
495 | |||
496 | MakefileGenerator::init(); | ||
497 | if ( !project->variables()["VERSION"].isEmpty()) { | ||
498 | QStringList l = QStringList::split('.', project->first("VERSION")); | ||
499 | project->variables()["VER_MAJ"].append(l[0]); | ||
500 | project->variables()["VER_MIN"].append(l[1]); | ||
501 | } | ||
502 | if(project->isActiveConfig("dll")) { | ||
503 | project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") +"lib" + project->first("TARGET") + ".a"); | ||
504 | } | ||
505 | } | ||
506 | |||
507 | void | ||
508 | MingwMakefileGenerator::writeSubDirs(QTextStream &t) | ||
509 | { | ||
510 | QString qs ; | ||
511 | QTextStream ts (&qs, IO_WriteOnly) ; | ||
512 | Win32MakefileGenerator::writeSubDirs( ts ) ; | ||
513 | QRegExp rx("(\\n\\tcd [^\\n\\t]+)(\\n\\t.+)\\n\\t@cd ..") ; | ||
514 | rx.setMinimal(true); | ||
515 | int pos = 0 ; | ||
516 | while ( -1 != (pos = rx.search( qs, pos))) | ||
517 | { | ||
518 | QString qsMatch = rx.cap(2); | ||
519 | qsMatch.replace("\n\t"," && \\\n\t"); | ||
520 | qs.replace(pos+rx.cap(1).length(), rx.cap(2).length(), qsMatch ); | ||
521 | pos += (rx.cap(1).length()+qsMatch.length()); | ||
522 | } | ||
523 | t << qs ; | ||
524 | } | ||