summaryrefslogtreecommitdiff
path: root/qmake/generators/win32/mingw_make.cpp
Unidiff
Diffstat (limited to 'qmake/generators/win32/mingw_make.cpp') (more/less context) (show whitespace changes)
-rw-r--r--qmake/generators/win32/mingw_make.cpp284
1 files changed, 234 insertions, 50 deletions
diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp
index 7f58a55..c693d6a 100644
--- a/qmake/generators/win32/mingw_make.cpp
+++ b/qmake/generators/win32/mingw_make.cpp
@@ -1,10 +1,10 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Definition of ________ class.
5** 3**
6** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. 4** Implementation of MingwMakefileGenerator class.
7** 5**
8** This file is part of the network module of the Qt GUI Toolkit. 6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
7**
8** This file is part of qmake.
9** 9**
10** 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
@@ -48,4 +48,10 @@ MingwMakefileGenerator::MingwMakefileGenerator(QMakeProject *p) : Win32MakefileG
48 48
49bool 49bool
50MingwMakefileGenerator::findLibraries() // todo - pascal
51{
52 return TRUE;
53}
54
55bool
50MingwMakefileGenerator::writeMakefile(QTextStream &t) 56MingwMakefileGenerator::writeMakefile(QTextStream &t)
51{ 57{
@@ -72,4 +78,19 @@ MingwMakefileGenerator::writeMakefile(QTextStream &t)
72} 78}
73 79
80void createLdObjectScriptFile(const QString & fileName, QStringList & objList)
81{
82 QString filePath = Option::output_dir + QDir::separator() + fileName;
83 QFile file(filePath);
84 if (file.open(IO_WriteOnly | IO_Translate )) {
85 QTextStream t(&file);
86 t << "INPUT(" << endl;
87 for (QStringList::Iterator it = objList.begin(); it != objList.end(); ++it ) {
88 t << *it << endl;
89 }
90 t << ");" << endl;
91 file.close();
92 }
93}
94
74void 95void
75MingwMakefileGenerator::writeMingwParts(QTextStream &t) 96MingwMakefileGenerator::writeMingwParts(QTextStream &t)
@@ -95,15 +116,14 @@ MingwMakefileGenerator::writeMingwParts(QTextStream &t)
95 inc.replace(QRegExp("\\\\$"), "\\\\"); 116 inc.replace(QRegExp("\\\\$"), "\\\\");
96 inc.replace(QRegExp("\""), ""); 117 inc.replace(QRegExp("\""), "");
97 t << " -I" << inc ; 118 t << " -I" << "\"" << inc << "\"";
98 } 119 }
99 t << " -I" << specdir() 120 t << " -I" << "\"" << specdir() << "\"" << endl;
100 << endl;
101 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) { 121 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
102 t << "LINK =" << var("QMAKE_LINK") << endl; 122 t << "LINK =" << var("QMAKE_LINK") << endl;
103 t << "LFLAGS ="; 123 t << "LFLAGS =" << var("QMAKE_LFLAGS") << endl;
124 t << "LIBS =";
104 if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() ) 125 if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() )
105 t << varGlue("QMAKE_LIBDIR","-L",";","") << " "; 126 t << varGlue("QMAKE_LIBDIR","-L\"","\" -L\"","\"") << " ";
106 t << var("QMAKE_LFLAGS") << endl; 127 t << var("QMAKE_LIBS").replace(QRegExp("(\\slib|^lib)")," -l") << endl;
107 t << "LIBS =" << var("QMAKE_LIBS").replace(QRegExp("(\\slib|^lib)")," -l") << endl;
108 } 128 }
109 else { 129 else {
@@ -129,4 +149,6 @@ MingwMakefileGenerator::writeMingwParts(QTextStream &t)
129 t << "CHK_DIR_EXISTS =" << var("QMAKE_CHK_DIR_EXISTS") << endl; 149 t << "CHK_DIR_EXISTS =" << var("QMAKE_CHK_DIR_EXISTS") << endl;
130 t << "MKDIR =" << var("QMAKE_MKDIR") << endl; 150 t << "MKDIR =" << var("QMAKE_MKDIR") << endl;
151 t << "INSTALL_FILE= " << var("QMAKE_INSTALL_FILE") << endl;
152 t << "INSTALL_DIR = " << var("QMAKE_INSTALL_DIR") << endl;
131 t << endl; 153 t << endl;
132 154
@@ -145,5 +167,12 @@ MingwMakefileGenerator::writeMingwParts(QTextStream &t)
145 t << "HEADERS =" << varList("HEADERS") << endl; 167 t << "HEADERS =" << varList("HEADERS") << endl;
146 t << "SOURCES =" << varList("SOURCES") << endl; 168 t << "SOURCES =" << varList("SOURCES") << endl;
147 // t << "OBJECTS =" << varList("OBJECTS").replace(QRegExp("\\.obj"),".o") << endl; 169 QString objectsLinkLine;
170 if (!project->variables()["QMAKE_APP_OR_DLL"].isEmpty() &&
171 project->variables()["OBJECTS"].count() > var("QMAKE_LINK_OBJECT_MAX").toUInt()) {
172 createLdObjectScriptFile(var("QMAKE_LINK_OBJECT_SCRIPT"), project->variables()["OBJECTS"]);
173 objectsLinkLine = var("QMAKE_LINK_OBJECT_SCRIPT");
174 } else {
175 objectsLinkLine = "$(OBJECTS)";
176 }
148 t << "OBJECTS =" << varList("OBJECTS") << endl; 177 t << "OBJECTS =" << varList("OBJECTS") << endl;
149 t << "FORMS =" << varList("FORMS") << endl; 178 t << "FORMS =" << varList("FORMS") << endl;
@@ -151,6 +180,29 @@ MingwMakefileGenerator::writeMingwParts(QTextStream &t)
151 t << "UICIMPLS =" << varList("UICIMPLS") << endl; 180 t << "UICIMPLS =" << varList("UICIMPLS") << endl;
152 t << "SRCMOC =" << varList("SRCMOC") << endl; 181 t << "SRCMOC =" << varList("SRCMOC") << endl;
182 QString objmocLinkLine;
183 if (!project->variables()["QMAKE_APP_OR_DLL"].isEmpty() &&
184 project->variables()["OBJMOC"].count() > var("QMAKE_LINK_OBJECT_MAX").toUInt()) {
185 createLdObjectScriptFile(var("QMAKE_LINK_OBJMOC_SCRIPT"), project->variables()["OBJMOC"]);
186 objmocLinkLine = var("QMAKE_LINK_OBJMOC_SCRIPT");
187 } else {
188 objmocLinkLine = "$(OBJMOC)";
189 }
153 t << "OBJMOC =" << varList("OBJMOC") << endl; 190 t << "OBJMOC =" << varList("OBJMOC") << endl;
154 // t << "OBJMOC =" << varList("OBJMOC").replace(QRegExp("\\.obj"),".o") << endl; 191 QString extraCompilerDeps;
192 if(!project->isEmpty("QMAKE_EXTRA_WIN_COMPILERS")) {
193 t << "OBJCOMP = " << varList("OBJCOMP") << endl;
194 extraCompilerDeps += " $(OBJCOMP) ";
195
196 QStringList &comps = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"];
197 for(QStringList::Iterator compit = comps.begin(); compit != comps.end(); ++compit) {
198 QStringList &vars = project->variables()[(*compit) + ".variables"];
199 for(QStringList::Iterator varit = vars.begin(); varit != vars.end(); ++varit) {
200 QStringList vals = project->variables()[(*varit)];
201 if(!vals.isEmpty())
202 t << "QMAKE_COMP_" << (*varit) << " = " << valList(vals) << endl;
203 }
204 }
205 }
206
155 t << "DIST =" << varList("DISTFILES") << endl; 207 t << "DIST =" << varList("DISTFILES") << endl;
156 t << "TARGET ="; 208 t << "TARGET =";
@@ -173,15 +225,15 @@ MingwMakefileGenerator::writeMingwParts(QTextStream &t)
173 t << "all: " << "$(OBJECTS_DIR) " << "$(MOC_DIR) " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" << endl << endl; 225 t << "all: " << "$(OBJECTS_DIR) " << "$(MOC_DIR) " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" << endl << endl;
174 t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) " 226 t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) "
175 << var("POST_TARGETDEPS"); 227 << extraCompilerDeps << var("POST_TARGETDEPS");
176 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) { 228 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
177 t << "\n\t" << "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)"; 229 t << "\n\t" << "$(LINK) $(LFLAGS) -o $(TARGET) " << objectsLinkLine << " " << objmocLinkLine << " $(LIBS)";
178 } else { 230 } else {
179 t << "\n\t" << "$(LIB) $(TARGET) $(OBJECTS) $(OBJMOC)"; 231 t << "\n\t" << "$(LIB) $(TARGET) " << objectsLinkLine << " " << objmocLinkLine;
180 } 232 }
181 233 t << extraCompilerDeps;
182 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) { 234 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) {
183 QStringList dlldirs = project->variables()["DLLDESTDIR"]; 235 QStringList dlldirs = project->variables()["DLLDESTDIR"];
184 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) { 236 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) {
185 t << "\n\t" << "copy $(TARGET) " << *dlldir; 237 t << "\n\t" << "$(COPY_FILE) \"$(TARGET)\" " << *dlldir;
186 } 238 }
187 } 239 }
@@ -193,12 +245,12 @@ MingwMakefileGenerator::writeMingwParts(QTextStream &t)
193 245
194 if ( project->isActiveConfig("dll")) { 246 if ( project->isActiveConfig("dll")) {
195 t << "\n\t" << ("-$(IDC) $(TARGET) /idl tmp\\" + targetfilename + ".idl -version " + version); 247 t << "\n\t" << ("-$(IDC) $(TARGET) /idl " + var("OBJECTS_DIR") + 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"); 248 t << "\n\t" << ("-$(IDL) /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
197 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb"); 249 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
198 t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" ); 250 t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" );
199 } else { 251 } else {
200 t << "\n\t" << ("-$(TARGET) -dumpidl tmp\\" + targetfilename + ".idl -version " + version); 252 t << "\n\t" << ("-$(TARGET) -dumpidl " + var("OBJECTS_DIR") + 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"); 253 t << "\n\t" << ("-$(IDL) /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
202 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb"); 254 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");
203 t << "\n\t" << "-$(TARGET) -regserver"; 255 t << "\n\t" << "-$(TARGET) -regserver";
204 } 256 }
@@ -208,5 +260,5 @@ MingwMakefileGenerator::writeMingwParts(QTextStream &t)
208 if(!project->variables()["RC_FILE"].isEmpty()) { 260 if(!project->variables()["RC_FILE"].isEmpty()) {
209 t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t" 261 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; 262 << var("QMAKE_RC") << " -i " << var("RC_FILE") << " -o " << var("RC_FILE").replace(QRegExp("\\.rc"),".o") << " --include-dir=" << QFileInfo(var("RC_FILE")).dirPath() << endl << endl;
211 } 263 }
212 project->variables()["RES_FILE"].first().replace(QRegExp("\\.rc"),".o"); 264 project->variables()["RES_FILE"].first().replace(QRegExp("\\.rc"),".o");
@@ -215,8 +267,8 @@ MingwMakefileGenerator::writeMingwParts(QTextStream &t)
215 267
216 t << "$(OBJECTS_DIR):" << "\n\t" 268 t << "$(OBJECTS_DIR):" << "\n\t"
217 << "@if not exist $(OBJECTS_DIR) mkdir $(OBJECTS_DIR)" << endl << endl; 269 << "@if not exist $(OBJECTS_DIR) $(MKDIR) $(OBJECTS_DIR)" << endl << endl;
218 270
219 t << "$(MOC_DIR):" << "\n\t" 271 t << "$(MOC_DIR):" << "\n\t"
220 << "@if not exist $(MOC_DIR) mkdir $(MOC_DIR)" << endl << endl; 272 << "@if not exist $(MOC_DIR) $(MKDIR) $(MOC_DIR)" << endl << endl;
221 273
222 writeMakeQmake(t); 274 writeMakeQmake(t);
@@ -227,24 +279,24 @@ MingwMakefileGenerator::writeMingwParts(QTextStream &t)
227 279
228 t << "clean:" 280 t << "clean:"
229 << varGlue("OBJECTS","\n\t-del ","\n\t-del ","").replace(QRegExp("\\.obj"),".o") 281 << varGlue("OBJECTS","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","").replace(QRegExp("\\.obj"),".o")
230 << varGlue("SRCMOC" ,"\n\t-del ","\n\t-del ","") 282 << varGlue("SRCMOC" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")
231 << varGlue("OBJMOC" ,"\n\t-del ","\n\t-del ","").replace(QRegExp("\\.obj"),".o") 283 << varGlue("OBJMOC" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","").replace(QRegExp("\\.obj"),".o")
232 << varGlue("UICDECLS" ,"\n\t-del ","\n\t-del ","") 284 << varGlue("UICDECLS" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")
233 << varGlue("UICIMPLS" ,"\n\t-del ","\n\t-del ","") 285 << varGlue("UICIMPLS" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")
234 << "\n\t-del $(TARGET)" 286 << "\n\t-$(DEL_FILE) $(TARGET)"
235 << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ","") 287 << varGlue("QMAKE_CLEAN","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")
236 << varGlue("CLEAN_FILES","\n\t-del ","\n\t-del ",""); 288 << varGlue("CLEAN_FILES","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","");
237 if ( project->isActiveConfig("activeqt")) { 289 if ( project->isActiveConfig("activeqt")) {
238 t << ("\n\t-del tmp\\" + targetfilename + ".*"); 290 t << ("\n\t-$(DEL_FILE) " + var("OBJECTS_DIR") + targetfilename + ".idl");
239 t << "\n\t-del tmp\\dump.*"; 291 t << ("\n\t-$(DEL_FILE) " + var("OBJECTS_DIR") + targetfilename + ".tlb");
240 } 292 }
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")) 293 if(!project->isEmpty("IMAGES"))
244 t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-del ", "\n\t-del ", ""); 294 t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-$(DEL_FILE) ", "\n\t-$(DEL_FILE) ", "");
245 295
246 // blasted user defined targets 296 // user defined targets
297 QStringList::Iterator it;
247 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"]; 298 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"];
248 for(QStringList::Iterator it = qut.begin(); it != qut.end(); ++it) { 299
300 for(it = qut.begin(); it != qut.end(); ++it) {
249 QString targ = var((*it) + ".target"), 301 QString targ = var((*it) + ".target"),
250 cmd = var((*it) + ".commands"), deps; 302 cmd = var((*it) + ".commands"), deps;
@@ -263,4 +315,53 @@ MingwMakefileGenerator::writeMingwParts(QTextStream &t)
263 315
264 t << endl << endl; 316 t << endl << endl;
317
318 QStringList &quc = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"];
319 for(it = quc.begin(); it != quc.end(); ++it) {
320 QString tmp_out = project->variables()[(*it) + ".output"].first();
321 QString tmp_cmd = project->variables()[(*it) + ".commands"].join(" ");
322 QString tmp_dep = project->variables()[(*it) + ".depends"].join(" ");
323 QStringList &vars = project->variables()[(*it) + ".variables"];
324 if(tmp_out.isEmpty() || tmp_cmd.isEmpty())
325 continue;
326 QStringList &tmp = project->variables()[(*it) + ".input"];
327 for(QStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {
328 QStringList &inputs = project->variables()[(*it2)];
329 for(QStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {
330 QFileInfo fi(Option::fixPathToLocalOS((*input)));
331 QString in = Option::fixPathToTargetOS((*input), FALSE),
332 out = tmp_out, cmd = tmp_cmd, deps;
333 out.replace("${QMAKE_FILE_BASE}", fi.baseName());
334 out.replace("${QMAKE_FILE_NAME}", fi.fileName());
335 cmd.replace("${QMAKE_FILE_BASE}", fi.baseName());
336 cmd.replace("${QMAKE_FILE_OUT}", out);
337 cmd.replace("${QMAKE_FILE_NAME}", fi.fileName());
338 for(QStringList::Iterator it3 = vars.begin(); it3 != vars.end(); ++it3)
339 cmd.replace("$(" + (*it3) + ")", "$(QMAKE_COMP_" + (*it3)+")");
340 if(!tmp_dep.isEmpty()) {
341 char buff[256];
342 QString dep_cmd = tmp_dep;
343 dep_cmd.replace("${QMAKE_FILE_NAME}", fi.fileName());
344 if(FILE *proc = QT_POPEN(dep_cmd.latin1(), "r")) {
345 while(!feof(proc)) {
346 int read_in = int(fread(buff, 1, 255, proc));
347 if(!read_in)
348 break;
349 int l = 0;
350 for(int i = 0; i < read_in; i++) {
351 if(buff[i] == '\n' || buff[i] == ' ') {
352 deps += " " + QCString(buff+l, (i - l) + 1);
353 l = i;
354 }
355 }
356 }
357 fclose(proc);
358 }
359 }
360 t << out << ": " << in << deps << "\n\t"
361 << cmd << endl << endl;
362 }
363 }
364 }
365 t << endl;
265} 366}
266 367
@@ -287,4 +388,9 @@ MingwMakefileGenerator::init()
287 } 388 }
288 389
390 if(project->isEmpty("QMAKE_INSTALL_FILE"))
391 project->variables()["QMAKE_INSTALL_FILE"].append("$(COPY_FILE)");
392 if(project->isEmpty("QMAKE_INSTALL_DIR"))
393 project->variables()["QMAKE_INSTALL_DIR"].append("$(COPY_DIR)");
394
289 bool is_qt = (project->first("TARGET") == "qt"QTDLL_POSTFIX || project->first("TARGET") == "qt-mt"QTDLL_POSTFIX); 395 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"]; 396 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"];
@@ -295,8 +401,12 @@ MingwMakefileGenerator::init()
295 QString targetfilename = project->variables()["TARGET"].first(); 401 QString targetfilename = project->variables()["TARGET"].first();
296 QStringList &configs = project->variables()["CONFIG"]; 402 QStringList &configs = project->variables()["CONFIG"];
403
297 if (project->isActiveConfig("qt") && project->isActiveConfig("shared")) 404 if (project->isActiveConfig("qt") && project->isActiveConfig("shared"))
298 project->variables()["DEFINES"].append("QT_DLL"); 405 project->variables()["DEFINES"].append("QT_DLL");
406
299 if (project->isActiveConfig("qt_dll")) 407 if (project->isActiveConfig("qt_dll"))
300 if(configs.findIndex("qt") == -1) configs.append("qt"); 408 if (configs.findIndex("qt") == -1)
409 configs.append("qt");
410
301 if ( project->isActiveConfig("qt") ) { 411 if ( project->isActiveConfig("qt") ) {
302 if ( project->isActiveConfig( "plugin" ) ) { 412 if ( project->isActiveConfig( "plugin" ) ) {
@@ -320,4 +430,5 @@ MingwMakefileGenerator::init()
320 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT"); 430 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT");
321 } 431 }
432
322 if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { 433 if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
323 project->variables()["CONFIG"].remove("staticlib"); 434 project->variables()["CONFIG"].remove("staticlib");
@@ -326,4 +437,5 @@ MingwMakefileGenerator::init()
326 project->variables()["CONFIG"].append("staticlib"); 437 project->variables()["CONFIG"].append("staticlib");
327 } 438 }
439
328 if ( project->isActiveConfig("warn_off") ) { 440 if ( project->isActiveConfig("warn_off") ) {
329 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_OFF"]; 441 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_OFF"];
@@ -333,4 +445,5 @@ MingwMakefileGenerator::init()
333 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_ON"]; 445 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_ON"];
334 } 446 }
447
335 if ( project->isActiveConfig("debug") ) { 448 if ( project->isActiveConfig("debug") ) {
336 if ( project->isActiveConfig("thread") ) { 449 if ( project->isActiveConfig("thread") ) {
@@ -364,6 +477,8 @@ MingwMakefileGenerator::init()
364 if ( !project->variables()["QMAKE_INCDIR"].isEmpty()) 477 if ( !project->variables()["QMAKE_INCDIR"].isEmpty())
365 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"]; 478 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"];
479
366 if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") ) 480 if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") )
367 project->variables()["CONFIG"].append("windows"); 481 project->variables()["CONFIG"].append("windows");
482
368 if ( project->isActiveConfig("qt") ) { 483 if ( project->isActiveConfig("qt") ) {
369 project->variables()["CONFIG"].append("moc"); 484 project->variables()["CONFIG"].append("moc");
@@ -378,4 +493,5 @@ MingwMakefileGenerator::init()
378 } 493 }
379 } else { 494 } else {
495
380 if(project->isActiveConfig("thread")) 496 if(project->isActiveConfig("thread"))
381 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; 497 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"];
@@ -397,17 +513,25 @@ MingwMakefileGenerator::init()
397 if ( project->isActiveConfig( "activeqt" ) ) { 513 if ( project->isActiveConfig( "activeqt" ) ) {
398 project->variables().remove("QMAKE_LIBS_QT_ENTRY"); 514 project->variables().remove("QMAKE_LIBS_QT_ENTRY");
399 project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib"; 515 project->variables()["QMAKE_LIBS_QT_ENTRY"] = "-lqaxserver";
400 if ( project->isActiveConfig( "dll" ) ) 516 if ( project->isActiveConfig( "dll" ) ) {
401 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"]; 517 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"];
402 } 518 }
519 }
403 if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) { 520 if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) {
404 project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"]; 521 project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"];
405 } 522 }
523
524 // QMAKE_LIBS_QT_ENTRY should be first on the link line as it needs qt
525 project->variables()["QMAKE_LIBS"].remove(project->variables()["QMAKE_LIBS_QT_ENTRY"].first());
526 project->variables()["QMAKE_LIBS"].prepend(project->variables()["QMAKE_LIBS_QT_ENTRY"].first());
527
406 } 528 }
407 } 529 }
530
408 if ( project->isActiveConfig("opengl") ) { 531 if ( project->isActiveConfig("opengl") ) {
409 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; 532 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"];
410 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"]; 533 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"];
411 } 534 }
535
412 if ( project->isActiveConfig("dll") ) { 536 if ( project->isActiveConfig("dll") ) {
413 project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE_DLL"]; 537 project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE_DLL"];
@@ -435,4 +559,5 @@ MingwMakefileGenerator::init()
435 } 559 }
436 } 560 }
561
437 if ( project->isActiveConfig("windows") ) { 562 if ( project->isActiveConfig("windows") ) {
438 if ( project->isActiveConfig("console") ) { 563 if ( project->isActiveConfig("console") ) {
@@ -452,10 +577,39 @@ MingwMakefileGenerator::init()
452 } 577 }
453 578
579 if ( project->isActiveConfig("exceptions") ) {
580 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_ON"];
581 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_ON"];
582 } else {
583 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_OFF"];
584 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_OFF"];
585 }
586
587 if ( project->isActiveConfig("rtti") ) {
588 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_ON"];
589 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_ON"];
590 } else {
591 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_OFF"];
592 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_OFF"];
593 }
594
454 if ( project->isActiveConfig("moc") ) 595 if ( project->isActiveConfig("moc") )
455 setMocAware(TRUE); 596 setMocAware(TRUE);
597
598 // add -L libs to libdir
599 QStringList &libs = project->variables()["QMAKE_LIBS"];
600 for ( QStringList::Iterator libit = libs.begin(); libit != libs.end(); ) {
601 if ( (*libit).startsWith( "-L" ) ) {
602 project->variables()["QMAKE_LIBDIR"] += (*libit).mid(2);
603 libit = libs.remove( libit );
604 } else {
605 ++libit;
606 }
607 }
608
456 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ', 609 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ',
457 "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH"); 610 "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH");
458 QStringList &l = project->variables()["QMAKE_FILETAGS"]; 611 QStringList &l = project->variables()["QMAKE_FILETAGS"];
459 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 612 QStringList::Iterator it;
613 for(it = l.begin(); it != l.end(); ++it) {
460 QStringList &gdmf = project->variables()[(*it)]; 614 QStringList &gdmf = project->variables()[(*it)];
461 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner) 615 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner)
@@ -463,9 +617,14 @@ MingwMakefileGenerator::init()
463 } 617 }
464 618
465 if ( project->isActiveConfig("dll") ) 619 if ( project->isActiveConfig("dll") ) {
466 project->variables()["QMAKE_LFLAGS"].append(QString("-Wl,--out-implib,") + project->first("DESTDIR") + "\\lib"+ project->first("TARGET") + ".a"); 620 QString destDir = "";
621 if (!project->first("DESTDIR").isEmpty())
622 destDir = project->first("DESTDIR") + Option::dir_sep;
623 project->variables()["QMAKE_LFLAGS"].append(QString("-Wl,--out-implib,") +
624 destDir + "lib" + project->first("TARGET") + ".a");
625 }
467 626
468 if ( !project->variables()["DEF_FILE"].isEmpty() ) 627 if ( !project->variables()["DEF_FILE"].isEmpty() )
469 project->variables()["QMAKE_LFLAGS"].append(QString("-Wl,--output-def,") + project->first("DEF_FILE")); 628 project->variables()["QMAKE_LFLAGS"].append(QString("-Wl,") + project->first("DEF_FILE"));
470// if(!project->isActiveConfig("incremental")) 629// if(!project->isActiveConfig("incremental"))
471 //project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no")); 630 //project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no"));
@@ -481,4 +640,5 @@ MingwMakefileGenerator::init()
481 } 640 }
482#endif 641#endif
642
483 if ( !project->variables()["RC_FILE"].isEmpty()) { 643 if ( !project->variables()["RC_FILE"].isEmpty()) {
484 if ( !project->variables()["RES_FILE"].isEmpty()) { 644 if ( !project->variables()["RES_FILE"].isEmpty()) {
@@ -490,9 +650,12 @@ MingwMakefileGenerator::init()
490 project->variables()["RES_FILE"].first().replace(".rc",".o"); 650 project->variables()["RES_FILE"].first().replace(".rc",".o");
491 project->variables()["POST_TARGETDEPS"] += project->variables()["RES_FILE"]; 651 project->variables()["POST_TARGETDEPS"] += project->variables()["RES_FILE"];
652 project->variables()["CLEAN_FILES"] += project->variables()["RES_FILE"];
492 } 653 }
654
493 if ( !project->variables()["RES_FILE"].isEmpty()) 655 if ( !project->variables()["RES_FILE"].isEmpty())
494 project->variables()["QMAKE_LIBS"] += project->variables()["RES_FILE"]; 656 project->variables()["QMAKE_LIBS"] += project->variables()["RES_FILE"];
495 657
496 MakefileGenerator::init(); 658 MakefileGenerator::init();
659
497 if ( !project->variables()["VERSION"].isEmpty()) { 660 if ( !project->variables()["VERSION"].isEmpty()) {
498 QStringList l = QStringList::split('.', project->first("VERSION")); 661 QStringList l = QStringList::split('.', project->first("VERSION"));
@@ -500,7 +663,28 @@ MingwMakefileGenerator::init()
500 project->variables()["VER_MIN"].append(l[1]); 663 project->variables()["VER_MIN"].append(l[1]);
501 } 664 }
665
502 if(project->isActiveConfig("dll")) { 666 if(project->isActiveConfig("dll")) {
503 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") +"lib" + project->first("TARGET") + ".a"); 667 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") +"lib" + project->first("TARGET") + ".a");
504 } 668 }
669
670 QStringList &quc = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"];
671 for(it = quc.begin(); it != quc.end(); ++it) {
672 QString tmp_out = project->variables()[(*it) + ".output"].first();
673 if(tmp_out.isEmpty())
674 continue;
675 QStringList &tmp = project->variables()[(*it) + ".input"];
676 for(QStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {
677 QStringList &inputs = project->variables()[(*it2)];
678 for(QStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {
679 QFileInfo fi(Option::fixPathToLocalOS((*input)));
680 QString in = Option::fixPathToTargetOS((*input), FALSE),
681 out = tmp_out;
682 out.replace("${QMAKE_FILE_BASE}", fi.baseName());
683 out.replace("${QMAKE_FILE_NAME}", fi.fileName());
684 if(project->variables()[(*it) + ".CONFIG"].findIndex("no_link") == -1)
685 project->variables()["OBJCOMP"] += out;
686 }
687 }
688 }
505} 689}
506 690
@@ -512,5 +696,5 @@ MingwMakefileGenerator::writeSubDirs(QTextStream &t)
512 Win32MakefileGenerator::writeSubDirs( ts ) ; 696 Win32MakefileGenerator::writeSubDirs( ts ) ;
513 QRegExp rx("(\\n\\tcd [^\\n\\t]+)(\\n\\t.+)\\n\\t@cd ..") ; 697 QRegExp rx("(\\n\\tcd [^\\n\\t]+)(\\n\\t.+)\\n\\t@cd ..") ;
514 rx.setMinimal(true); 698 rx.setMinimal(TRUE);
515 int pos = 0 ; 699 int pos = 0 ;
516 while ( -1 != (pos = rx.search( qs, pos))) 700 while ( -1 != (pos = rx.search( qs, pos)))