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,14 +1,14 @@
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
11** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
12** LICENSE.QPL included in the packaging of this file. 12** LICENSE.QPL included in the packaging of this file.
13** 13**
14** This file may be distributed and/or modified under the terms of the 14** This file may be distributed and/or modified under the terms of the
@@ -44,12 +44,18 @@
44MingwMakefileGenerator::MingwMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE) 44MingwMakefileGenerator::MingwMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE)
45{ 45{
46 Option::obj_ext = ".o"; 46 Option::obj_ext = ".o";
47} 47}
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{
52 writeHeader(t); 58 writeHeader(t);
53 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) { 59 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {
54 t << "all clean:" << "\n\t" 60 t << "all clean:" << "\n\t"
55 << "@echo \"Some of the required modules (" 61 << "@echo \"Some of the required modules ("
@@ -68,12 +74,27 @@ MingwMakefileGenerator::writeMakefile(QTextStream &t)
68 writeSubDirs(t); 74 writeSubDirs(t);
69 return TRUE; 75 return TRUE;
70 } 76 }
71 return FALSE; 77 return FALSE;
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)
76{ 97{
77 t << "####### Compiler, tools and options" << endl << endl; 98 t << "####### Compiler, tools and options" << endl << endl;
78 t << "CC =" << var("QMAKE_CC") << endl; 99 t << "CC =" << var("QMAKE_CC") << endl;
79 t << "CXX =" << var("QMAKE_CXX") << endl; 100 t << "CXX =" << var("QMAKE_CXX") << endl;
@@ -91,23 +112,22 @@ MingwMakefileGenerator::writeMingwParts(QTextStream &t)
91 t << "INCPATH ="; 112 t << "INCPATH =";
92 QStringList &incs = project->variables()["INCLUDEPATH"]; 113 QStringList &incs = project->variables()["INCLUDEPATH"];
93 for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) { 114 for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) {
94 QString inc = (*incit); 115 QString inc = (*incit);
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 {
110 t << "LIB =" << var("QMAKE_LIB") << endl; 130 t << "LIB =" << var("QMAKE_LIB") << endl;
111 } 131 }
112 t << "MOC =" << (project->isEmpty("QMAKE_MOC") ? QString("moc") : 132 t << "MOC =" << (project->isEmpty("QMAKE_MOC") ? QString("moc") :
113 Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl; 133 Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl;
@@ -125,12 +145,14 @@ MingwMakefileGenerator::writeMingwParts(QTextStream &t)
125 t << "COPY_DIR= " << var("QMAKE_COPY") << endl; 145 t << "COPY_DIR= " << var("QMAKE_COPY") << endl;
126 t << "DEL_FILE= " << var("QMAKE_DEL_FILE") << endl; 146 t << "DEL_FILE= " << var("QMAKE_DEL_FILE") << endl;
127 t << "DEL_DIR= " << var("QMAKE_DEL_DIR") << endl; 147 t << "DEL_DIR= " << var("QMAKE_DEL_DIR") << endl;
128 t << "MOVE = " << var("QMAKE_MOVE") << endl; 148 t << "MOVE = " << var("QMAKE_MOVE") << endl;
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
133 t << "####### Output directory" << endl << endl; 155 t << "####### Output directory" << endl << endl;
134 if (! project->variables()["OBJECTS_DIR"].isEmpty()) 156 if (! project->variables()["OBJECTS_DIR"].isEmpty())
135 t << "OBJECTS_DIR = " << var("OBJECTS_DIR").replace(QRegExp("\\\\$"),"") << endl; 157 t << "OBJECTS_DIR = " << var("OBJECTS_DIR").replace(QRegExp("\\\\$"),"") << endl;
136 else 158 else
@@ -141,20 +163,50 @@ MingwMakefileGenerator::writeMingwParts(QTextStream &t)
141 t << "MOC_DIR = . " << endl; 163 t << "MOC_DIR = . " << endl;
142 t << endl; 164 t << endl;
143 165
144 t << "####### Files" << endl << endl; 166 t << "####### Files" << endl << endl;
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;
150 t << "UICDECLS =" << varList("UICDECLS") << endl; 179 t << "UICDECLS =" << varList("UICDECLS") << endl;
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 =";
157 if( !project->variables()[ "DESTDIR" ].isEmpty() ) 209 if( !project->variables()[ "DESTDIR" ].isEmpty() )
158 t << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT")); 210 t << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT"));
159 else 211 else
160 t << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first(); 212 t << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first();
@@ -169,86 +221,86 @@ MingwMakefileGenerator::writeMingwParts(QTextStream &t)
169 t << ".C.o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; 221 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; 222 t << ".c.o:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;
171 223
172 t << "####### Build rules" << endl << endl; 224 t << "####### Build rules" << endl << endl;
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 }
188 QString targetfilename = project->variables()["TARGET"].first(); 240 QString targetfilename = project->variables()["TARGET"].first();
189 if(project->isActiveConfig("activeqt")) { 241 if(project->isActiveConfig("activeqt")) {
190 QString version = project->variables()["VERSION"].first(); 242 QString version = project->variables()["VERSION"].first();
191 if ( version.isEmpty() ) 243 if ( version.isEmpty() )
192 version = "1.0"; 244 version = "1.0";
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 }
205 } 257 }
206 t << endl << endl; 258 t << endl << endl;
207 259
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");
213 265
214 t << "mocables: $(SRCMOC)" << endl << endl; 266 t << "mocables: $(SRCMOC)" << endl << endl;
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);
223 275
224 t << "dist:" << "\n\t" 276 t << "dist:" << "\n\t"
225 << "$(ZIP) " << var("PROJECT") << ".zip " 277 << "$(ZIP) " << var("PROJECT") << ".zip "
226 << var("PROJECT") << ".pro $(SOURCES) $(HEADERS) $(DIST) $(FORMS)" << endl << endl; 278 << var("PROJECT") << ".pro $(SOURCES) $(HEADERS) $(DIST) $(FORMS)" << endl << endl;
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;
251 if(targ.isEmpty()) 303 if(targ.isEmpty())
252 targ = (*it); 304 targ = (*it);
253 QStringList &deplist = project->variables()[(*it) + ".depends"]; 305 QStringList &deplist = project->variables()[(*it) + ".depends"];
254 for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) { 306 for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) {
@@ -259,12 +311,61 @@ MingwMakefileGenerator::writeMingwParts(QTextStream &t)
259 } 311 }
260 t << "\n\n" << targ << ":" << deps << "\n\t" 312 t << "\n\n" << targ << ":" << deps << "\n\t"
261 << cmd; 313 << cmd;
262 } 314 }
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
267 368
268void 369void
269MingwMakefileGenerator::init() 370MingwMakefileGenerator::init()
270{ 371{
@@ -283,24 +384,33 @@ MingwMakefileGenerator::init()
283 project->variables()["MAKEFILE"].append("Makefile"); 384 project->variables()["MAKEFILE"].append("Makefile");
284 if(project->variables()["QMAKE"].isEmpty()) 385 if(project->variables()["QMAKE"].isEmpty())
285 project->variables()["QMAKE"].append("qmake"); 386 project->variables()["QMAKE"].append("qmake");
286 return; 387 return;
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"];
291 397
292 // LIBS defined in Profile comes first for gcc 398 // LIBS defined in Profile comes first for gcc
293 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; 399 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
294 400
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" ) ) {
303 project->variables()["CONFIG"].append("dll"); 413 project->variables()["CONFIG"].append("dll");
304 if(project->isActiveConfig("qt")) 414 if(project->isActiveConfig("qt"))
305 project->variables()["DEFINES"].append("QT_PLUGIN"); 415 project->variables()["DEFINES"].append("QT_PLUGIN");
306 } 416 }
@@ -316,25 +426,28 @@ MingwMakefileGenerator::init()
316 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT"); 426 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT");
317 if ( project->isActiveConfig("accessibility" ) ) 427 if ( project->isActiveConfig("accessibility" ) )
318 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT"); 428 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT");
319 if ( project->isActiveConfig("tablet") ) 429 if ( project->isActiveConfig("tablet") )
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");
324 project->variables()["QMAKE_APP_OR_DLL"].append("1"); 435 project->variables()["QMAKE_APP_OR_DLL"].append("1");
325 } else { 436 } else {
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"];
330 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_OFF"]; 442 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_OFF"];
331 } else if ( project->isActiveConfig("warn_on") ) { 443 } else if ( project->isActiveConfig("warn_on") ) {
332 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_ON"]; 444 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_ON"];
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") ) {
337 // use the DLL RT even here 450 // use the DLL RT even here
338 if ( project->variables()["DEFINES"].contains("QT_DLL") ) { 451 if ( project->variables()["DEFINES"].contains("QT_DLL") ) {
339 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLLDBG"]; 452 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLLDBG"];
340 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"]; 453 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"];
@@ -360,26 +473,29 @@ MingwMakefileGenerator::init()
360 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RELEASE"]; 473 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RELEASE"];
361 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_RELEASE"]; 474 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_RELEASE"];
362 } 475 }
363 476
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");
370 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"]; 485 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"];
371 project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"]; 486 project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"];
372 if ( !project->isActiveConfig("debug") ) 487 if ( !project->isActiveConfig("debug") )
373 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG"); 488 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG");
374 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { 489 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) {
375 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty()) { 490 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty()) {
376 project->variables()["DEFINES"].append("QT_MAKEDLL"); 491 project->variables()["DEFINES"].append("QT_MAKEDLL");
377 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_QT_DLL"]; 492 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_QT_DLL"];
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"];
382 else 498 else
383 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; 499 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"];
384 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { 500 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) {
385 int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt"); 501 int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt");
@@ -393,25 +509,33 @@ MingwMakefileGenerator::init()
393 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) 509 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit)
394 (*libit).replace(QRegExp("qt(-mt)?\\.lib"), ver); 510 (*libit).replace(QRegExp("qt(-mt)?\\.lib"), ver);
395 } 511 }
396 } 512 }
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"];
414 project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE_DLL"]; 538 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"]; 539 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"]; 540 project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS_DLL"];
417 if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty()) { 541 if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty()) {
@@ -431,12 +555,13 @@ MingwMakefileGenerator::init()
431 project->variables()["TARGET_EXT"].append(".a"); 555 project->variables()["TARGET_EXT"].append(".a");
432 project->variables()["QMAKE_LFLAGS"].append("-static"); 556 project->variables()["QMAKE_LFLAGS"].append("-static");
433 if(project->variables()["TARGET"].first().left(3) != "lib") 557 if(project->variables()["TARGET"].first().left(3) != "lib")
434 project->variables()["TARGET"].first().prepend("lib"); 558 project->variables()["TARGET"].first().prepend("lib");
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") ) {
439 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"]; 564 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
440 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"]; 565 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
441 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"]; 566 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
442 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"]; 567 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
@@ -448,28 +573,62 @@ MingwMakefileGenerator::init()
448 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"]; 573 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
449 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"]; 574 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
450 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"]; 575 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
451 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"]; 576 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
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)
462 (*inner) = Option::fixPathToTargetOS((*inner), FALSE); 616 (*inner) = Option::fixPathToTargetOS((*inner), FALSE);
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"));
472 631
473#if 0 632#if 0
474 if ( !project->variables()["VERSION"].isEmpty() ) { 633 if ( !project->variables()["VERSION"].isEmpty() ) {
475 QString version = project->variables()["VERSION"][0]; 634 QString version = project->variables()["VERSION"][0];
@@ -477,44 +636,69 @@ MingwMakefileGenerator::init()
477 QString major = version.left( firstDot ); 636 QString major = version.left( firstDot );
478 QString minor = version.right( version.length() - firstDot - 1 ); 637 QString minor = version.right( version.length() - firstDot - 1 );
479 minor.replace( ".", "" ); 638 minor.replace( ".", "" );
480 project->variables()["QMAKE_LFLAGS"].append( "/VERSION:" + major + "." + minor ); 639 project->variables()["QMAKE_LFLAGS"].append( "/VERSION:" + major + "." + minor );
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()) {
485 fprintf(stderr, "Both .rc and .res file specified.\n"); 645 fprintf(stderr, "Both .rc and .res file specified.\n");
486 fprintf(stderr, "Please specify one of them, not both."); 646 fprintf(stderr, "Please specify one of them, not both.");
487 exit(666); 647 exit(666);
488 } 648 }
489 project->variables()["RES_FILE"] = project->variables()["RC_FILE"]; 649 project->variables()["RES_FILE"] = project->variables()["RC_FILE"];
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"));
499 project->variables()["VER_MAJ"].append(l[0]); 662 project->variables()["VER_MAJ"].append(l[0]);
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
507void 691void
508MingwMakefileGenerator::writeSubDirs(QTextStream &t) 692MingwMakefileGenerator::writeSubDirs(QTextStream &t)
509{ 693{
510 QString qs ; 694 QString qs ;
511 QTextStream ts (&qs, IO_WriteOnly) ; 695 QTextStream ts (&qs, IO_WriteOnly) ;
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)))
517 { 701 {
518 QString qsMatch = rx.cap(2); 702 QString qsMatch = rx.cap(2);
519 qsMatch.replace("\n\t"," && \\\n\t"); 703 qsMatch.replace("\n\t"," && \\\n\t");
520 qs.replace(pos+rx.cap(1).length(), rx.cap(2).length(), qsMatch ); 704 qs.replace(pos+rx.cap(1).length(), rx.cap(2).length(), qsMatch );