summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/generators/unix/unixmake2.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp
index 7fbb9f4..d8a4a0d 100644
--- a/qmake/generators/unix/unixmake2.cpp
+++ b/qmake/generators/unix/unixmake2.cpp
@@ -1,400 +1,401 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of ________ class. 4** Definition of ________ class.
5** 5**
6** Created : 970521 6** Created : 970521
7** 7**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the network module of the Qt GUI Toolkit. 10** This file is part of the network module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this 21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software. 23** with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#include "unixmake.h" 38#include "unixmake.h"
39#include "option.h" 39#include "option.h"
40#include <qregexp.h> 40#include <qregexp.h>
41#include <qfile.h> 41#include <qfile.h>
42#include <qdir.h> 42#include <qdir.h>
43#include <time.h> 43#include <time.h>
44 44
45 45
46UnixMakefileGenerator::UnixMakefileGenerator(QMakeProject *p) : MakefileGenerator(p), init_flag(FALSE), include_deps(FALSE) 46UnixMakefileGenerator::UnixMakefileGenerator(QMakeProject *p) : MakefileGenerator(p), init_flag(FALSE), include_deps(FALSE)
47{ 47{
48 48
49} 49}
50 50
51bool 51bool
52UnixMakefileGenerator::writeMakefile(QTextStream &t) 52UnixMakefileGenerator::writeMakefile(QTextStream &t)
53{ 53{
54 writeHeader(t); 54 writeHeader(t);
55 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) { 55 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {
56 t << "all clean:" << "\n\t" 56 t << "all clean:" << "\n\t"
57 << "@echo \"Some of the required modules (" 57 << "@echo \"Some of the required modules ("
58 << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t" 58 << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t"
59 << "@echo \"Skipped.\"" << endl << endl; 59 << "@echo \"Skipped.\"" << endl << endl;
60 writeMakeQmake(t); 60 writeMakeQmake(t);
61 return TRUE; 61 return TRUE;
62 } 62 }
63 63
64 if (project->variables()["TEMPLATE"].first() == "app" || 64 if (project->variables()["TEMPLATE"].first() == "app" ||
65 project->variables()["TEMPLATE"].first() == "lib") { 65 project->variables()["TEMPLATE"].first() == "lib") {
66 writeMakeParts(t); 66 writeMakeParts(t);
67 return MakefileGenerator::writeMakefile(t); 67 return MakefileGenerator::writeMakefile(t);
68 } else if(project->variables()["TEMPLATE"].first() == "subdirs") { 68 } else if(project->variables()["TEMPLATE"].first() == "subdirs") {
69 writeSubdirs(t); 69 writeSubdirs(t);
70 return TRUE; 70 return TRUE;
71 } 71 }
72 return FALSE; 72 return FALSE;
73} 73}
74 74
75void 75void
76UnixMakefileGenerator::writeMakeParts(QTextStream &t) 76UnixMakefileGenerator::writeMakeParts(QTextStream &t)
77{ 77{
78 QString deps = fileFixify(Option::output.name()), prl; 78 QString deps = fileFixify(Option::output.name()), prl;
79 bool do_incremental = (project->isActiveConfig("incremental") && 79 bool do_incremental = (project->isActiveConfig("incremental") &&
80 !project->variables()["QMAKE_INCREMENTAL"].isEmpty() && 80 !project->variables()["QMAKE_INCREMENTAL"].isEmpty() &&
81 (!project->variables()["QMAKE_APP_FLAG"].isEmpty() || 81 (!project->variables()["QMAKE_APP_FLAG"].isEmpty() ||
82 !project->isActiveConfig("staticlib"))), 82 !project->isActiveConfig("staticlib"))),
83 src_incremental=FALSE, moc_incremental=FALSE; 83 src_incremental=FALSE, moc_incremental=FALSE;
84 84
85 t << "####### Compiler, tools and options" << endl << endl; 85 t << "####### Compiler, tools and options" << endl << endl;
86 t << "CC = "; 86 t << "CC = ";
87 if (project->isActiveConfig("thread") && 87 if (project->isActiveConfig("thread") &&
88 ! project->variables()["QMAKE_CC_THREAD"].isEmpty()) 88 ! project->variables()["QMAKE_CC_THREAD"].isEmpty())
89 t << var("QMAKE_CC_THREAD") << endl; 89 t << var("QMAKE_CC_THREAD") << endl;
90 else 90 else
91 t << var("QMAKE_CC") << endl; 91 t << var("QMAKE_CC") << endl;
92 92
93 t << "CXX = "; 93 t << "CXX = ";
94 if (project->isActiveConfig("thread") && 94 if (project->isActiveConfig("thread") &&
95 ! project->variables()["QMAKE_CXX_THREAD"].isEmpty()) 95 ! project->variables()["QMAKE_CXX_THREAD"].isEmpty())
96 t << var("QMAKE_CXX_THREAD") << endl; 96 t << var("QMAKE_CXX_THREAD") << endl;
97 else 97 else
98 t << var("QMAKE_CXX") << endl; 98 t << var("QMAKE_CXX") << endl;
99 99
100 t << "LEX = " << var("QMAKE_LEX") << endl; 100 t << "LEX = " << var("QMAKE_LEX") << endl;
101 t << "YACC = " << var("QMAKE_YACC") << endl; 101 t << "YACC = " << var("QMAKE_YACC") << endl;
102 t << "CFLAGS = " << var("QMAKE_CFLAGS") << " " 102 t << "CFLAGS = " << var("QMAKE_CFLAGS") << " "
103 << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " " 103 << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "
104 << varGlue("DEFINES","-D"," -D","") << endl; 104 << varGlue("DEFINES","-D"," -D","") << endl;
105 t << "CXXFLAGS = " << var("QMAKE_CXXFLAGS") << " " 105 t << "CXXFLAGS = " << var("QMAKE_CXXFLAGS") << " "
106 << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " " 106 << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "
107 << varGlue("DEFINES","-D"," -D","") << endl; 107 << varGlue("DEFINES","-D"," -D","") << endl;
108 t << "LEXFLAGS = " << var("QMAKE_LEXFLAGS") << endl; 108 t << "LEXFLAGS = " << var("QMAKE_LEXFLAGS") << endl;
109 t << "YACCFLAGS= " << var("QMAKE_YACCFLAGS") << endl; 109 t << "YACCFLAGS= " << var("QMAKE_YACCFLAGS") << endl;
110 t << "INCPATH = " << "-I" << specdir(); 110 t << "INCPATH = " << "-I" << specdir();
111 if(!project->isActiveConfig("no_include_pwd")) { 111 if(!project->isActiveConfig("no_include_pwd")) {
112 QString pwd = fileFixify(QDir::currentDirPath()); 112 QString pwd = fileFixify(QDir::currentDirPath());
113 if(pwd.isEmpty()) 113 if(pwd.isEmpty())
114 pwd = "."; 114 pwd = ".";
115 t << " -I" << pwd; 115 t << " -I" << pwd;
116 } 116 }
117 t << varGlue("INCLUDEPATH"," -I", " -I", "") << endl; 117 t << varGlue("INCLUDEPATH"," -I", " -I", "") << endl;
118 118
119 if(!project->isActiveConfig("staticlib")) { 119 if(!project->isActiveConfig("staticlib")) {
120 t << "LINK = "; 120 t << "LINK = ";
121 if (project->isActiveConfig("thread") && 121 if (project->isActiveConfig("thread") &&
122 ! project->variables()["QMAKE_LINK_THREAD"].isEmpty()) 122 ! project->variables()["QMAKE_LINK_THREAD"].isEmpty())
123 t << var("QMAKE_LINK_THREAD") << endl; 123 t << var("QMAKE_LINK_THREAD") << endl;
124 else 124 else
125 t << var("QMAKE_LINK") << endl; 125 t << var("QMAKE_LINK") << endl;
126 126
127 t << "LFLAGS = " << var("QMAKE_LFLAGS") << endl; 127 t << "LFLAGS = " << var("QMAKE_LFLAGS") << endl;
128 t << "LIBS = " << "$(SUBLIBS) " << var("QMAKE_LIBDIR_FLAGS") << " " << var("QMAKE_LIBS") << endl; 128 t << "LIBS = " << "$(SUBLIBS) " << var("QMAKE_LIBDIR_FLAGS") << " " << var("QMAKE_LIBS") << endl;
129 } 129 }
130 130
131 t << "AR = " << var("QMAKE_AR") << endl; 131 t << "AR = " << var("QMAKE_AR") << endl;
132 t << "RANLIB = " << var("QMAKE_RANLIB") << endl; 132 t << "RANLIB = " << var("QMAKE_RANLIB") << endl;
133 t << "MOC = " << var("QMAKE_MOC") << endl; 133 t << "MOC = " << var("QMAKE_MOC") << endl;
134 t << "UIC = "<< var("QMAKE_UIC") << endl; 134 t << "UIC = "<< var("QMAKE_UIC") << endl;
135 t << "QMAKE = "<< (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl; 135 t << "QMAKE = "<< (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl;
136 t << "TAR = "<< var("QMAKE_TAR") << endl; 136 t << "TAR = "<< var("QMAKE_TAR") << endl;
137 t << "GZIP = " << var("QMAKE_GZIP") << endl; 137 t << "GZIP = " << var("QMAKE_GZIP") << endl;
138 t << "COPY = " << var("QMAKE_COPY") << endl; 138 t << "COPY = " << var("QMAKE_COPY") << endl;
139 t << "COPY_FILE= " << var("QMAKE_COPY_FILE") << endl; 139 t << "COPY_FILE= " << var("QMAKE_COPY_FILE") << endl;
140 t << "COPY_DIR = " << var("QMAKE_COPY_DIR") << endl; 140 t << "COPY_DIR = " << var("QMAKE_COPY_DIR") << endl;
141 t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; 141 t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl;
142 t << "SYMLINK = " << var("QMAKE_SYMBOLIC_LINK") << endl; 142 t << "SYMLINK = " << var("QMAKE_SYMBOLIC_LINK") << endl;
143 t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl; 143 t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl;
144 t << "MOVE = " << var("QMAKE_MOVE") << endl; 144 t << "MOVE = " << var("QMAKE_MOVE") << endl;
145 t << "PRO = " << fileFixify(project->projectFile() )<< endl;
145 t << "CHK_DIR_EXISTS= " << var("QMAKE_CHK_DIR_EXISTS") << endl; 146 t << "CHK_DIR_EXISTS= " << var("QMAKE_CHK_DIR_EXISTS") << endl;
146 t << "MKDIR = " << var("QMAKE_MKDIR") << endl; 147 t << "MKDIR = " << var("QMAKE_MKDIR") << endl;
147 t << endl; 148 t << endl;
148 149
149 t << "####### Output directory" << endl << endl; 150 t << "####### Output directory" << endl << endl;
150 if (! project->variables()["OBJECTS_DIR"].isEmpty()) 151 if (! project->variables()["OBJECTS_DIR"].isEmpty())
151 t << "OBJECTS_DIR = " << var("OBJECTS_DIR") << endl; 152 t << "OBJECTS_DIR = " << var("OBJECTS_DIR") << endl;
152 else 153 else
153 t << "OBJECTS_DIR = ./" << endl; 154 t << "OBJECTS_DIR = ./" << endl;
154 t << endl; 155 t << endl;
155 156
156 /* files */ 157 /* files */
157 t << "####### Files" << endl << endl; 158 t << "####### Files" << endl << endl;
158 t << "HEADERS = " << varList("HEADERS") << endl; 159 t << "HEADERS = " << varList("HEADERS") << endl;
159 t << "SOURCES = " << varList("SOURCES") << endl; 160 t << "SOURCES = " << varList("SOURCES") << endl;
160 if(do_incremental) { 161 if(do_incremental) {
161 QStringList &objs = project->variables()["OBJECTS"], &incrs = project->variables()["QMAKE_INCREMENTAL"], incrs_out; 162 QStringList &objs = project->variables()["OBJECTS"], &incrs = project->variables()["QMAKE_INCREMENTAL"], incrs_out;
162 t << "OBJECTS = "; 163 t << "OBJECTS = ";
163 for(QStringList::Iterator objit = objs.begin(); objit != objs.end(); ++objit) { 164 for(QStringList::Iterator objit = objs.begin(); objit != objs.end(); ++objit) {
164 bool increment = FALSE; 165 bool increment = FALSE;
165 for(QStringList::Iterator incrit = incrs.begin(); incrit != incrs.end(); ++incrit) { 166 for(QStringList::Iterator incrit = incrs.begin(); incrit != incrs.end(); ++incrit) {
166 if((*objit).find(QRegExp((*incrit), TRUE, TRUE)) != -1) { 167 if((*objit).find(QRegExp((*incrit), TRUE, TRUE)) != -1) {
167 increment = TRUE; 168 increment = TRUE;
168 incrs_out.append((*objit)); 169 incrs_out.append((*objit));
169 break; 170 break;
170 } 171 }
171 } 172 }
172 if(!increment) 173 if(!increment)
173 t << "\\\n\t\t" << (*objit); 174 t << "\\\n\t\t" << (*objit);
174 } 175 }
175 if(incrs_out.count() == objs.count()) { //we just switched places, no real incrementals to be done! 176 if(incrs_out.count() == objs.count()) { //we just switched places, no real incrementals to be done!
176 t << incrs_out.join(" \\\n\t\t") << endl; 177 t << incrs_out.join(" \\\n\t\t") << endl;
177 } else if(!incrs_out.count()) { 178 } else if(!incrs_out.count()) {
178 t << endl; 179 t << endl;
179 } else { 180 } else {
180 src_incremental = TRUE; 181 src_incremental = TRUE;
181 t << endl; 182 t << endl;
182 t << "INCREMENTAL_OBJECTS = " << incrs_out.join(" \\\n\t\t") << endl; 183 t << "INCREMENTAL_OBJECTS = " << incrs_out.join(" \\\n\t\t") << endl;
183 } 184 }
184 } else { 185 } else {
185 t << "OBJECTS = " << varList("OBJECTS") << endl; 186 t << "OBJECTS = " << varList("OBJECTS") << endl;
186 } 187 }
187 t << "FORMS = " << varList("FORMS") << endl; 188 t << "FORMS = " << varList("FORMS") << endl;
188 t << "UICDECLS = " << varList("UICDECLS") << endl; 189 t << "UICDECLS = " << varList("UICDECLS") << endl;
189 t << "UICIMPLS = " << varList("UICIMPLS") << endl; 190 t << "UICIMPLS = " << varList("UICIMPLS") << endl;
190 QString srcMoc = varList("SRCMOC"), objMoc = varList("OBJMOC"); 191 QString srcMoc = varList("SRCMOC"), objMoc = varList("OBJMOC");
191 t << "SRCMOC = " << srcMoc << endl; 192 t << "SRCMOC = " << srcMoc << endl;
192 if(do_incremental) { 193 if(do_incremental) {
193 QStringList &objs = project->variables()["OBJMOC"], 194 QStringList &objs = project->variables()["OBJMOC"],
194 &incrs = project->variables()["QMAKE_INCREMENTAL"], incrs_out; 195 &incrs = project->variables()["QMAKE_INCREMENTAL"], incrs_out;
195 t << "OBJMOC = "; 196 t << "OBJMOC = ";
196 for(QStringList::Iterator objit = objs.begin(); objit != objs.end(); ++objit) { 197 for(QStringList::Iterator objit = objs.begin(); objit != objs.end(); ++objit) {
197 bool increment = FALSE; 198 bool increment = FALSE;
198 for(QStringList::Iterator incrit = incrs.begin(); incrit != incrs.end(); ++incrit) { 199 for(QStringList::Iterator incrit = incrs.begin(); incrit != incrs.end(); ++incrit) {
199 if((*objit).find(QRegExp((*incrit), TRUE, TRUE)) != -1) { 200 if((*objit).find(QRegExp((*incrit), TRUE, TRUE)) != -1) {
200 increment = TRUE; 201 increment = TRUE;
201 incrs_out.append((*objit)); 202 incrs_out.append((*objit));
202 break; 203 break;
203 } 204 }
204 } 205 }
205 if(!increment) 206 if(!increment)
206 t << "\\\n\t\t" << (*objit); 207 t << "\\\n\t\t" << (*objit);
207 } 208 }
208 if(incrs_out.count() == objs.count()) { //we just switched places, no real incrementals to be done! 209 if(incrs_out.count() == objs.count()) { //we just switched places, no real incrementals to be done!
209 t << incrs_out.join(" \\\n\t\t") << endl; 210 t << incrs_out.join(" \\\n\t\t") << endl;
210 } else if(!incrs_out.count()) { 211 } else if(!incrs_out.count()) {
211 t << endl; 212 t << endl;
212 } else { 213 } else {
213 moc_incremental = TRUE; 214 moc_incremental = TRUE;
214 t << endl; 215 t << endl;
215 t << "INCREMENTAL_OBJMOC = " << incrs_out.join(" \\\n\t\t") << endl; 216 t << "INCREMENTAL_OBJMOC = " << incrs_out.join(" \\\n\t\t") << endl;
216 } 217 }
217 } else { 218 } else {
218 t << "OBJMOC = " << objMoc << endl; 219 t << "OBJMOC = " << objMoc << endl;
219 } 220 }
220 if(do_incremental && !moc_incremental && !src_incremental) 221 if(do_incremental && !moc_incremental && !src_incremental)
221 do_incremental = FALSE; 222 do_incremental = FALSE;
222 t << "DIST = " << valList(fileFixify(project->variables()["DISTFILES"])) << endl; 223 t << "DIST = " << valList(fileFixify(project->variables()["DISTFILES"])) << endl;
223 t << "QMAKE_TARGET = " << var("QMAKE_ORIG_TARGET") << endl; 224 t << "QMAKE_TARGET = " << var("QMAKE_ORIG_TARGET") << endl;
224 t << "DESTDIR = " << var("DESTDIR") << endl; 225 t << "DESTDIR = " << var("DESTDIR") << endl;
225 t << "TARGET = " << var("TARGET") << endl; 226 t << "TARGET = " << var("TARGET") << endl;
226 if(project->isActiveConfig("plugin") ) { 227 if(project->isActiveConfig("plugin") ) {
227 t << "TARGETD = " << var("TARGET") << endl; 228 t << "TARGETD = " << var("TARGET") << endl;
228 } else if (!project->isActiveConfig("staticlib") && project->variables()["QMAKE_APP_FLAG"].isEmpty()) { 229 } else if (!project->isActiveConfig("staticlib") && project->variables()["QMAKE_APP_FLAG"].isEmpty()) {
229 t << "TARGETA= " << var("TARGETA") << endl; 230 t << "TARGETA= " << var("TARGETA") << endl;
230 if (project->isEmpty("QMAKE_HPUX_SHLIB")) { 231 if (project->isEmpty("QMAKE_HPUX_SHLIB")) {
231 t << "TARGETD= " << var("TARGET_x.y.z") << endl; 232 t << "TARGETD= " << var("TARGET_x.y.z") << endl;
232 t << "TARGET0= " << var("TARGET_") << endl; 233 t << "TARGET0= " << var("TARGET_") << endl;
233 t << "TARGET1= " << var("TARGET_x") << endl; 234 t << "TARGET1= " << var("TARGET_x") << endl;
234 t << "TARGET2= " << var("TARGET_x.y") << endl; 235 t << "TARGET2= " << var("TARGET_x.y") << endl;
235 } else { 236 } else {
236 t << "TARGETD= " << var("TARGET_x") << endl; 237 t << "TARGETD= " << var("TARGET_x") << endl;
237 t << "TARGET0= " << var("TARGET_") << endl; 238 t << "TARGET0= " << var("TARGET_") << endl;
238 } 239 }
239 } 240 }
240 t << endl; 241 t << endl;
241 242
242 // blasted incldues 243 // blasted incldues
243 QStringList &qeui = project->variables()["QMAKE_EXTRA_UNIX_INCLUDES"]; 244 QStringList &qeui = project->variables()["QMAKE_EXTRA_UNIX_INCLUDES"];
244 QStringList::Iterator it; 245 QStringList::Iterator it;
245 for( it = qeui.begin(); it != qeui.end(); ++it) 246 for( it = qeui.begin(); it != qeui.end(); ++it)
246 t << "include " << (*it) << endl; 247 t << "include " << (*it) << endl;
247 248
248 /* rules */ 249 /* rules */
249 t << "first: all" << endl; 250 t << "first: all" << endl;
250 t << "####### Implicit rules" << endl << endl; 251 t << "####### Implicit rules" << endl << endl;
251 t << ".SUFFIXES: .c"; 252 t << ".SUFFIXES: .c";
252 QStringList::Iterator cppit; 253 QStringList::Iterator cppit;
253 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) 254 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
254 t << " " << (*cppit); 255 t << " " << (*cppit);
255 t << endl << endl; 256 t << endl << endl;
256 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) 257 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
257 t << (*cppit) << ".o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; 258 t << (*cppit) << ".o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
258 t << ".c.o:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl; 259 t << ".c.o:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;
259 260
260 if(include_deps) { 261 if(include_deps) {
261 QString cmd=var("QMAKE_CFLAGS_DEPS") + " "; 262 QString cmd=var("QMAKE_CFLAGS_DEPS") + " ";
262 cmd += varGlue("DEFINES","-D"," -D","") + varGlue("PRL_EXPORT_DEFINES"," -D"," -D",""); 263 cmd += varGlue("DEFINES","-D"," -D","") + varGlue("PRL_EXPORT_DEFINES"," -D"," -D","");
263 if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) 264 if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH"))
264 cmd += " -I" + project->first("QMAKE_ABSOLUTE_SOURCE_PATH") + " "; 265 cmd += " -I" + project->first("QMAKE_ABSOLUTE_SOURCE_PATH") + " ";
265 cmd += " $(INCPATH) " + varGlue("DEPENDPATH", "-I", " -I", ""); 266 cmd += " $(INCPATH) " + varGlue("DEPENDPATH", "-I", " -I", "");
266 QString odir; 267 QString odir;
267 if(!project->variables()["OBJECTS_DIR"].isEmpty()) 268 if(!project->variables()["OBJECTS_DIR"].isEmpty())
268 odir = project->first("OBJECTS_DIR"); 269 odir = project->first("OBJECTS_DIR");
269 t << "###### Dependencies" << endl << endl; 270 t << "###### Dependencies" << endl << endl;
270 t << odir << ".deps/%.d: %.cpp\n\t" 271 t << odir << ".deps/%.d: %.cpp\n\t"
271 << "@echo Creating depend for $<" << "\n\t" 272 << "@echo Creating depend for $<" << "\n\t"
272 << "@test -d $(@D) || mkdir -p $(@D)" << "\n\t" 273 << "@test -d $(@D) || mkdir -p $(@D)" << "\n\t"
273 << "@$(CXX) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl; 274 << "@$(CXX) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl;
274 275
275 t << odir << ".deps/%.d: %.c\n\t" 276 t << odir << ".deps/%.d: %.c\n\t"
276 << "@echo Creating depend for $<" << "\n\t" 277 << "@echo Creating depend for $<" << "\n\t"
277 << "@test -d $(@D) || mkdir -p $(@D)" << "\n\t" 278 << "@test -d $(@D) || mkdir -p $(@D)" << "\n\t"
278 << "@$(CC) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl; 279 << "@$(CC) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl;
279 280
280 281
281 QString src[] = { "SOURCES", "UICIMPLS", "SRCMOC", QString::null }; 282 QString src[] = { "SOURCES", "UICIMPLS", "SRCMOC", QString::null };
282 for(int x = 0; !src[x].isNull(); x++) { 283 for(int x = 0; !src[x].isNull(); x++) {
283 QStringList &l = project->variables()[src[x]]; 284 QStringList &l = project->variables()[src[x]];
284 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 285 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
285 if(!(*it).isEmpty()) { 286 if(!(*it).isEmpty()) {
286 QString d_file; 287 QString d_file;
287 if((*it).endsWith(".c")) { 288 if((*it).endsWith(".c")) {
288 d_file = (*it).left((*it).length() - 2); 289 d_file = (*it).left((*it).length() - 2);
289 } else { 290 } else {
290 for(QStringList::Iterator cppit = Option::cpp_ext.begin(); 291 for(QStringList::Iterator cppit = Option::cpp_ext.begin();
291 cppit != Option::cpp_ext.end(); ++cppit) { 292 cppit != Option::cpp_ext.end(); ++cppit) {
292 if((*it).endsWith((*cppit))) { 293 if((*it).endsWith((*cppit))) {
293 d_file = (*it).left((*it).length() - (*cppit).length()); 294 d_file = (*it).left((*it).length() - (*cppit).length());
294 break; 295 break;
295 } 296 }
296 } 297 }
297 } 298 }
298 if(!d_file.isEmpty()) { 299 if(!d_file.isEmpty()) {
299 d_file = odir + ".deps/" + d_file + ".d"; 300 d_file = odir + ".deps/" + d_file + ".d";
300 QStringList deps = findDependencies((*it)).grep(QRegExp(Option::moc_ext + "$")); 301 QStringList deps = findDependencies((*it)).grep(QRegExp(Option::moc_ext + "$"));
301 if(!deps.isEmpty()) 302 if(!deps.isEmpty())
302 t << d_file << ": " << deps.join(" ") << endl; 303 t << d_file << ": " << deps.join(" ") << endl;
303 t << "-include " << d_file << endl; 304 t << "-include " << d_file << endl;
304 } 305 }
305 } 306 }
306 } 307 }
307 } 308 }
308 } 309 }
309 310
310 t << "####### Build rules" << endl << endl; 311 t << "####### Build rules" << endl << endl;
311 if(!project->variables()["SUBLIBS"].isEmpty()) { 312 if(!project->variables()["SUBLIBS"].isEmpty()) {
312 QString libdir = "tmp/"; 313 QString libdir = "tmp/";
313 if(!project->isEmpty("SUBLIBS_DIR")) 314 if(!project->isEmpty("SUBLIBS_DIR"))
314 libdir = project->first("SUBLIBS_DIR"); 315 libdir = project->first("SUBLIBS_DIR");
315 t << "SUBLIBS= "; 316 t << "SUBLIBS= ";
316 QStringList &l = project->variables()["SUBLIBS"]; 317 QStringList &l = project->variables()["SUBLIBS"];
317 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) 318 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it)
318 t << libdir << "lib" << (*it) << ".a "; 319 t << libdir << "lib" << (*it) << ".a ";
319 t << endl << endl; 320 t << endl << endl;
320 } 321 }
321 if(project->isActiveConfig("depend_prl") && !project->isEmpty("QMAKE_PRL_INTERNAL_FILES")) { 322 if(project->isActiveConfig("depend_prl") && !project->isEmpty("QMAKE_PRL_INTERNAL_FILES")) {
322 QStringList &l = project->variables()["QMAKE_PRL_INTERNAL_FILES"]; 323 QStringList &l = project->variables()["QMAKE_PRL_INTERNAL_FILES"];
323 QStringList::Iterator it; 324 QStringList::Iterator it;
324 for(it = l.begin(); it != l.end(); ++it) { 325 for(it = l.begin(); it != l.end(); ++it) {
325 QMakeProject proj; 326 QMakeProject proj;
326 if(proj.read((*it), QDir::currentDirPath()) && !proj.isEmpty("QMAKE_PRL_BUILD_DIR")) { 327 if(proj.read((*it), QDir::currentDirPath()) && !proj.isEmpty("QMAKE_PRL_BUILD_DIR")) {
327 QString dir; 328 QString dir;
328 int slsh = (*it).findRev(Option::dir_sep); 329 int slsh = (*it).findRev(Option::dir_sep);
329 if(slsh != -1) 330 if(slsh != -1)
330 dir = (*it).left(slsh + 1); 331 dir = (*it).left(slsh + 1);
331 QString targ = dir + proj.first("QMAKE_PRL_TARGET"); 332 QString targ = dir + proj.first("QMAKE_PRL_TARGET");
332 deps += " " + targ; 333 deps += " " + targ;
333 t << targ << ":" << "\n\t" 334 t << targ << ":" << "\n\t"
334 << "@echo \"Creating '" << targ << "'\"" << "\n\t" 335 << "@echo \"Creating '" << targ << "'\"" << "\n\t"
335 << "(cd " << proj.first("QMAKE_PRL_BUILD_DIR") << ";" 336 << "(cd " << proj.first("QMAKE_PRL_BUILD_DIR") << ";"
336 << "$(MAKE) )" << endl; 337 << "$(MAKE) )" << endl;
337 } 338 }
338 } 339 }
339 } 340 }
340 if(!project->variables()["QMAKE_APP_FLAG"].isEmpty()) { 341 if(!project->variables()["QMAKE_APP_FLAG"].isEmpty()) {
341 QString destdir = project->first("DESTDIR"); 342 QString destdir = project->first("DESTDIR");
342 if(do_incremental) { 343 if(do_incremental) {
343 //incremental target 344 //incremental target
344 QString incr_target = var("TARGET") + "_incremental"; 345 QString incr_target = var("TARGET") + "_incremental";
345 if(incr_target.find(Option::dir_sep) != -1) 346 if(incr_target.find(Option::dir_sep) != -1)
346 incr_target = incr_target.right(incr_target.length() - 347 incr_target = incr_target.right(incr_target.length() -
347 (incr_target.findRev(Option::dir_sep) + 1)); 348 (incr_target.findRev(Option::dir_sep) + 1));
348 QString incr_deps, incr_objs; 349 QString incr_deps, incr_objs;
349 if(project->first("QMAKE_INCREMENTAL_STYLE") == "ld") { 350 if(project->first("QMAKE_INCREMENTAL_STYLE") == "ld") {
350 QString incr_target_dir = var("OBJECTS_DIR") + incr_target + Option::obj_ext; 351 QString incr_target_dir = var("OBJECTS_DIR") + incr_target + Option::obj_ext;
351 //actual target 352 //actual target
352 t << incr_target_dir << ": $(OBJECTS)" << "\n\t" 353 t << incr_target_dir << ": $(OBJECTS)" << "\n\t"
353 << "ld -r -o "<< incr_target_dir << " $(OBJECTS)" << endl; 354 << "ld -r -o "<< incr_target_dir << " $(OBJECTS)" << endl;
354 //communicated below 355 //communicated below
355 deps.prepend(incr_target_dir + " "); 356 deps.prepend(incr_target_dir + " ");
356 incr_deps = "$(UICDECLS) $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC) $(OBJMOC)"; 357 incr_deps = "$(UICDECLS) $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC) $(OBJMOC)";
357 if(!incr_objs.isEmpty()) 358 if(!incr_objs.isEmpty())
358 incr_objs += " "; 359 incr_objs += " ";
359 incr_objs += incr_target_dir; 360 incr_objs += incr_target_dir;
360 } else { 361 } else {
361 //actual target 362 //actual target
362 QString incr_target_dir = var("DESTDIR") + "lib" + incr_target + "." + 363 QString incr_target_dir = var("DESTDIR") + "lib" + incr_target + "." +
363 project->variables()["QMAKE_EXTENSION_SHLIB"].first(); 364 project->variables()["QMAKE_EXTENSION_SHLIB"].first();
364 QString incr_lflags = var("QMAKE_LFLAGS_SHLIB") + " "; 365 QString incr_lflags = var("QMAKE_LFLAGS_SHLIB") + " ";
365 if(project->isActiveConfig("debug")) 366 if(project->isActiveConfig("debug"))
366 incr_lflags += var("QMAKE_LFLAGS_DEBUG"); 367 incr_lflags += var("QMAKE_LFLAGS_DEBUG");
367 else 368 else
368 incr_lflags += var("QMAKE_LFLAGS_RELEASE"); 369 incr_lflags += var("QMAKE_LFLAGS_RELEASE");
369 t << incr_target_dir << ": $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << "\n\t"; 370 t << incr_target_dir << ": $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << "\n\t";
370 if(!destdir.isEmpty()) 371 if(!destdir.isEmpty())
371 t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; 372 t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
372 t << "$(LINK) " << incr_lflags << " -o "<< incr_target_dir << 373 t << "$(LINK) " << incr_lflags << " -o "<< incr_target_dir <<
373 " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << endl; 374 " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << endl;
374 //communicated below 375 //communicated below
375 if(!destdir.isEmpty()) { 376 if(!destdir.isEmpty()) {
376 if(!incr_objs.isEmpty()) 377 if(!incr_objs.isEmpty())
377 incr_objs += " "; 378 incr_objs += " ";
378 incr_objs += "-L" + destdir; 379 incr_objs += "-L" + destdir;
379 } else { 380 } else {
380 if(!incr_objs.isEmpty()) 381 if(!incr_objs.isEmpty())
381 incr_objs += " "; 382 incr_objs += " ";
382 incr_objs += "-L" + QDir::currentDirPath(); 383 incr_objs += "-L" + QDir::currentDirPath();
383 } 384 }
384 if(!incr_objs.isEmpty()) 385 if(!incr_objs.isEmpty())
385 incr_objs += " "; 386 incr_objs += " ";
386 incr_objs += " -l" + incr_target; 387 incr_objs += " -l" + incr_target;
387 deps.prepend(incr_target_dir + " "); 388 deps.prepend(incr_target_dir + " ");
388 incr_deps = "$(UICDECLS) $(OBJECTS) $(OBJMOC)"; 389 incr_deps = "$(UICDECLS) $(OBJECTS) $(OBJMOC)";
389 } 390 }
390 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" 391 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)"
391 << endl << endl; 392 << endl << endl;
392 393
393 //real target 394 //real target
394 t << var("TARGET") << ": " << var("PRE_TARGETDEPS") << " " << incr_deps 395 t << var("TARGET") << ": " << var("PRE_TARGETDEPS") << " " << incr_deps
395 << " " << var("POST_TARGETDEPS") << "\n\t"; 396 << " " << var("POST_TARGETDEPS") << "\n\t";
396 if(!destdir.isEmpty()) 397 if(!destdir.isEmpty())
397 t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; 398 t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
398 if(!project->isEmpty("QMAKE_PRE_LINK")) 399 if(!project->isEmpty("QMAKE_PRE_LINK"))
399 t << var("QMAKE_PRE_LINK") << "\n\t"; 400 t << var("QMAKE_PRE_LINK") << "\n\t";
400 t << "$(LINK) $(LFLAGS) -o $(TARGET) " << incr_deps << " " << incr_objs << " $(LIBS)"; 401 t << "$(LINK) $(LFLAGS) -o $(TARGET) " << incr_deps << " " << incr_objs << " $(LIBS)";