author | kergoth <kergoth> | 2002-11-01 00:10:42 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2002-11-01 00:10:42 (UTC) |
commit | 5042e3cf0d3514552769e441f5aad590c8eaf967 (patch) (unidiff) | |
tree | 4a5ea45f3519d981a172ab5275bf38c6fa778dec /qmake/generators/unix/unixmake2.cpp | |
parent | 108c1c753e74e989cc13923086996791428c9af4 (diff) | |
download | opie-5042e3cf0d3514552769e441f5aad590c8eaf967.zip opie-5042e3cf0d3514552769e441f5aad590c8eaf967.tar.gz opie-5042e3cf0d3514552769e441f5aad590c8eaf967.tar.bz2 |
Adding qmake in preperation for new build system
Diffstat (limited to 'qmake/generators/unix/unixmake2.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | qmake/generators/unix/unixmake2.cpp | 1048 |
1 files changed, 1048 insertions, 0 deletions
diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp new file mode 100644 index 0000000..1797b98 --- a/dev/null +++ b/qmake/generators/unix/unixmake2.cpp | |||
@@ -0,0 +1,1048 @@ | |||
1 | /**************************************************************************** | ||
2 | ** $Id$ | ||
3 | ** | ||
4 | ** Definition of ________ class. | ||
5 | ** | ||
6 | ** Created : 970521 | ||
7 | ** | ||
8 | ** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. | ||
9 | ** | ||
10 | ** This file is part of the network module of the Qt GUI Toolkit. | ||
11 | ** | ||
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 | ||
14 | ** LICENSE.QPL included in the packaging of this file. | ||
15 | ** | ||
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 | ||
18 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
19 | ** packaging of this file. | ||
20 | ** | ||
21 | ** Licensees holding valid Qt Enterprise Edition licenses may use this | ||
22 | ** file in accordance with the Qt Commercial License Agreement provided | ||
23 | ** with the Software. | ||
24 | ** | ||
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. | ||
27 | ** | ||
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | ||
29 | ** information about Qt Commercial License Agreements. | ||
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | ||
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
32 | ** | ||
33 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
34 | ** not clear to you. | ||
35 | ** | ||
36 | **********************************************************************/ | ||
37 | |||
38 | #include "unixmake.h" | ||
39 | #include "option.h" | ||
40 | #include <qregexp.h> | ||
41 | #include <qfile.h> | ||
42 | #include <qdir.h> | ||
43 | #include <time.h> | ||
44 | |||
45 | |||
46 | UnixMakefileGenerator::UnixMakefileGenerator(QMakeProject *p) : MakefileGenerator(p), init_flag(FALSE), include_deps(FALSE) | ||
47 | { | ||
48 | |||
49 | } | ||
50 | |||
51 | bool | ||
52 | UnixMakefileGenerator::writeMakefile(QTextStream &t) | ||
53 | { | ||
54 | writeHeader(t); | ||
55 | if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) { | ||
56 | t << "all clean:" << "\n\t" | ||
57 | << "@echo \"Some of the required modules (" | ||
58 | << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t" | ||
59 | << "@echo \"Skipped.\"" << endl << endl; | ||
60 | writeMakeQmake(t); | ||
61 | return TRUE; | ||
62 | } | ||
63 | |||
64 | if (project->variables()["TEMPLATE"].first() == "app" || | ||
65 | project->variables()["TEMPLATE"].first() == "lib") { | ||
66 | writeMakeParts(t); | ||
67 | return MakefileGenerator::writeMakefile(t); | ||
68 | } else if(project->variables()["TEMPLATE"].first() == "subdirs") { | ||
69 | writeSubdirs(t); | ||
70 | return TRUE; | ||
71 | } | ||
72 | return FALSE; | ||
73 | } | ||
74 | |||
75 | void | ||
76 | UnixMakefileGenerator::writeMakeParts(QTextStream &t) | ||
77 | { | ||
78 | QString deps = fileFixify(Option::output.name()), prl; | ||
79 | bool do_incremental = (project->isActiveConfig("incremental") && | ||
80 | !project->variables()["QMAKE_INCREMENTAL"].isEmpty() && | ||
81 | (!project->variables()["QMAKE_APP_FLAG"].isEmpty() || | ||
82 | !project->isActiveConfig("staticlib"))), | ||
83 | src_incremental=FALSE, moc_incremental=FALSE; | ||
84 | QString os = project->variables()["QMAKESPEC"].first().section( '-', 0, 0 ); | ||
85 | |||
86 | t << "####### Compiler, tools and options" << endl << endl; | ||
87 | t << "CC = "; | ||
88 | if (project->isActiveConfig("thread") && | ||
89 | ! project->variables()["QMAKE_CC_THREAD"].isEmpty()) | ||
90 | t << var("QMAKE_CC_THREAD") << endl; | ||
91 | else | ||
92 | t << var("QMAKE_CC") << endl; | ||
93 | |||
94 | t << "CXX = "; | ||
95 | if (project->isActiveConfig("thread") && | ||
96 | ! project->variables()["QMAKE_CXX_THREAD"].isEmpty()) | ||
97 | t << var("QMAKE_CXX_THREAD") << endl; | ||
98 | else | ||
99 | t << var("QMAKE_CXX") << endl; | ||
100 | |||
101 | t << "LEX = " << var("QMAKE_LEX") << endl; | ||
102 | t << "YACC = " << var("QMAKE_YACC") << endl; | ||
103 | t << "CFLAGS = " << var("QMAKE_CFLAGS") << " " | ||
104 | << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " " | ||
105 | << varGlue("DEFINES","-D"," -D","") << endl; | ||
106 | t << "CXXFLAGS = " << var("QMAKE_CXXFLAGS") << " " | ||
107 | << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " " | ||
108 | << varGlue("DEFINES","-D"," -D","") << endl; | ||
109 | t << "LEXFLAGS = " << var("QMAKE_LEXFLAGS") << endl; | ||
110 | t << "YACCFLAGS= " << var("QMAKE_YACCFLAGS") << endl; | ||
111 | t << "INCPATH = " << varGlue("INCLUDEPATH","-I", " -I", "") << " -I" << specdir() << endl; | ||
112 | |||
113 | if(!project->isActiveConfig("staticlib")) { | ||
114 | t << "LINK = "; | ||
115 | if (project->isActiveConfig("thread") && | ||
116 | ! project->variables()["QMAKE_LINK_THREAD"].isEmpty()) | ||
117 | t << var("QMAKE_LINK_THREAD") << endl; | ||
118 | else | ||
119 | t << var("QMAKE_LINK") << endl; | ||
120 | |||
121 | t << "LFLAGS = " << var("QMAKE_LFLAGS") << endl; | ||
122 | t << "LIBS = " << "$(SUBLIBS) " << var("QMAKE_LIBDIR_FLAGS") << " " << var("QMAKE_LIBS") << endl; | ||
123 | } | ||
124 | |||
125 | t << "AR = " << var("QMAKE_AR") << endl; | ||
126 | t << "RANLIB = " << var("QMAKE_RANLIB") << endl; | ||
127 | t << "MOC = " << var("QMAKE_MOC") << endl; | ||
128 | t << "UIC = "<< var("QMAKE_UIC") << endl; | ||
129 | t << "QMAKE = "<< (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl; | ||
130 | t << "TAR = "<< var("QMAKE_TAR") << endl; | ||
131 | t << "GZIP = " << var("QMAKE_GZIP") << endl; | ||
132 | t << "COPY = " << var("QMAKE_COPY") << endl; | ||
133 | t << "COPY_FILE= " << var("QMAKE_COPY_FILE") << endl; | ||
134 | t << "COPY_DIR = " << var("QMAKE_COPY_DIR") << endl; | ||
135 | t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; | ||
136 | t << "SYMLINK = " << var("QMAKE_SYMBOLIC_LINK") << endl; | ||
137 | t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl; | ||
138 | t << "MOVE = " << var("QMAKE_MOVE") << endl; | ||
139 | t << endl; | ||
140 | |||
141 | t << "####### Output directory" << endl << endl; | ||
142 | if (! project->variables()["OBJECTS_DIR"].isEmpty()) | ||
143 | t << "OBJECTS_DIR = " << var("OBJECTS_DIR") << endl; | ||
144 | else | ||
145 | t << "OBJECTS_DIR = ./" << endl; | ||
146 | t << endl; | ||
147 | |||
148 | /* files */ | ||
149 | t << "####### Files" << endl << endl; | ||
150 | t << "HEADERS = " << varList("HEADERS") << endl; | ||
151 | t << "SOURCES = " << varList("SOURCES") << endl; | ||
152 | if(do_incremental) { | ||
153 | QStringList &objs = project->variables()["OBJECTS"], &incrs = project->variables()["QMAKE_INCREMENTAL"], incrs_out; | ||
154 | t << "OBJECTS = "; | ||
155 | for(QStringList::Iterator objit = objs.begin(); objit != objs.end(); ++objit) { | ||
156 | bool increment = FALSE; | ||
157 | for(QStringList::Iterator incrit = incrs.begin(); incrit != incrs.end(); ++incrit) { | ||
158 | if((*objit).find(QRegExp((*incrit), TRUE, TRUE)) != -1) { | ||
159 | increment = TRUE; | ||
160 | incrs_out.append((*objit)); | ||
161 | break; | ||
162 | } | ||
163 | } | ||
164 | if(!increment) | ||
165 | t << "\\\n\t\t" << (*objit); | ||
166 | } | ||
167 | if(incrs_out.count() == objs.count()) { //we just switched places, no real incrementals to be done! | ||
168 | t << incrs_out.join(" \\\n\t\t") << endl; | ||
169 | } else if(!incrs_out.count()) { | ||
170 | t << endl; | ||
171 | } else { | ||
172 | src_incremental = TRUE; | ||
173 | t << endl; | ||
174 | t << "INCREMENTAL_OBJECTS = " << incrs_out.join(" \\\n\t\t") << endl; | ||
175 | } | ||
176 | } else { | ||
177 | t << "OBJECTS = " << varList("OBJECTS") << endl; | ||
178 | } | ||
179 | t << "FORMS = " << varList("FORMS") << endl; | ||
180 | t << "UICDECLS = " << varList("UICDECLS") << endl; | ||
181 | t << "UICIMPLS = " << varList("UICIMPLS") << endl; | ||
182 | QString srcMoc = varList("SRCMOC"), objMoc = varList("OBJMOC"); | ||
183 | t << "SRCMOC = " << srcMoc << endl; | ||
184 | if(do_incremental) { | ||
185 | QStringList &objs = project->variables()["OBJMOC"], | ||
186 | &incrs = project->variables()["QMAKE_INCREMENTAL"], incrs_out; | ||
187 | t << "OBJMOC = "; | ||
188 | for(QStringList::Iterator objit = objs.begin(); objit != objs.end(); ++objit) { | ||
189 | bool increment = FALSE; | ||
190 | for(QStringList::Iterator incrit = incrs.begin(); incrit != incrs.end(); ++incrit) { | ||
191 | if((*objit).find(QRegExp((*incrit), TRUE, TRUE)) != -1) { | ||
192 | increment = TRUE; | ||
193 | incrs_out.append((*objit)); | ||
194 | break; | ||
195 | } | ||
196 | } | ||
197 | if(!increment) | ||
198 | t << "\\\n\t\t" << (*objit); | ||
199 | } | ||
200 | if(incrs_out.count() == objs.count()) { //we just switched places, no real incrementals to be done! | ||
201 | t << incrs_out.join(" \\\n\t\t") << endl; | ||
202 | } else if(!incrs_out.count()) { | ||
203 | t << endl; | ||
204 | } else { | ||
205 | moc_incremental = TRUE; | ||
206 | t << endl; | ||
207 | t << "INCREMENTAL_OBJMOC = " << incrs_out.join(" \\\n\t\t") << endl; | ||
208 | } | ||
209 | } else { | ||
210 | t << "OBJMOC = " << objMoc << endl; | ||
211 | } | ||
212 | if(do_incremental && !moc_incremental && !src_incremental) | ||
213 | do_incremental = FALSE; | ||
214 | t << "DIST = " << varList("DISTFILES") << endl; | ||
215 | t << "QMAKE_TARGET = " << var("QMAKE_ORIG_TARGET") << endl; | ||
216 | t << "DESTDIR = " << var("DESTDIR") << endl; | ||
217 | t << "TARGET = " << var("TARGET") << endl; | ||
218 | if(project->isActiveConfig("plugin") ) { | ||
219 | t << "TARGETD = " << var("TARGET") << endl; | ||
220 | } else if (!project->isActiveConfig("staticlib") && project->variables()["QMAKE_APP_FLAG"].isEmpty()) { | ||
221 | t << "TARGETA= " << var("TARGETA") << endl; | ||
222 | if (os == "hpux") { | ||
223 | t << "TARGETD= " << var("TARGET_x") << endl; | ||
224 | t << "TARGET0= " << var("TARGET_") << endl; | ||
225 | } | ||
226 | else { | ||
227 | t << "TARGETD= " << var("TARGET_x.y.z") << endl; | ||
228 | t << "TARGET0= " << var("TARGET_") << endl; | ||
229 | t << "TARGET1= " << var("TARGET_x") << endl; | ||
230 | t << "TARGET2= " << var("TARGET_x.y") << endl; | ||
231 | } | ||
232 | } | ||
233 | t << endl; | ||
234 | |||
235 | // blasted incldues | ||
236 | QStringList &qeui = project->variables()["QMAKE_EXTRA_UNIX_INCLUDES"]; | ||
237 | QStringList::Iterator it; | ||
238 | for( it = qeui.begin(); it != qeui.end(); ++it) | ||
239 | t << "include " << (*it) << endl; | ||
240 | |||
241 | /* rules */ | ||
242 | t << "first: all" << endl; | ||
243 | t << "####### Implicit rules" << endl << endl; | ||
244 | t << ".SUFFIXES: .c"; | ||
245 | QStringList::Iterator cppit; | ||
246 | for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) | ||
247 | t << " " << (*cppit); | ||
248 | t << endl << endl; | ||
249 | for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) | ||
250 | t << (*cppit) << ".o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; | ||
251 | t << ".c.o:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl; | ||
252 | |||
253 | if(include_deps) { | ||
254 | QString cmd=var("QMAKE_CFLAGS_DEPS") + " "; | ||
255 | cmd += varGlue("DEFINES","-D"," -D","") + varGlue("PRL_EXPORT_DEFINES"," -D"," -D",""); | ||
256 | if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) | ||
257 | cmd += " -I" + project->first("QMAKE_ABSOLUTE_SOURCE_PATH") + " "; | ||
258 | cmd += " $(INCPATH) " + varGlue("DEPENDPATH", "-I", " -I", ""); | ||
259 | QString odir; | ||
260 | if(!project->variables()["OBJECTS_DIR"].isEmpty()) | ||
261 | odir = project->first("OBJECTS_DIR"); | ||
262 | t << "###### Dependancies" << endl << endl; | ||
263 | t << odir << ".deps/%.d: %.cpp\n\t" | ||
264 | << "@echo Creating depend for $<" << "\n\t" | ||
265 | << "@test -d $(@D) || mkdir -p $(@D)" << "\n\t" | ||
266 | << "@$(CXX) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl; | ||
267 | |||
268 | t << odir << ".deps/%.d: %.c\n\t" | ||
269 | << "@echo Creating depend for $<" << "\n\t" | ||
270 | << "@test -d $(@D) || mkdir -p $(@D)" << "\n\t" | ||
271 | << "@$(CC) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl; | ||
272 | |||
273 | |||
274 | QString src[] = { "SOURCES", "UICIMPLS", "SRCMOC", QString::null }; | ||
275 | for(int x = 0; !src[x].isNull(); x++) { | ||
276 | QStringList &l = project->variables()[src[x]]; | ||
277 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { | ||
278 | if(!(*it).isEmpty()) { | ||
279 | QString d_file; | ||
280 | if((*it).endsWith(".c")) { | ||
281 | d_file = (*it).left((*it).length() - 2); | ||
282 | } else { | ||
283 | for(QStringList::Iterator cppit = Option::cpp_ext.begin(); | ||
284 | cppit != Option::cpp_ext.end(); ++cppit) { | ||
285 | if((*it).endsWith((*cppit))) { | ||
286 | d_file = (*it).left((*it).length() - (*cppit).length()); | ||
287 | break; | ||
288 | } | ||
289 | } | ||
290 | } | ||
291 | if(!d_file.isEmpty()) { | ||
292 | d_file = odir + ".deps/" + d_file + ".d"; | ||
293 | QStringList deps = findDependencies((*it)).grep(QRegExp(Option::moc_ext + "$")); | ||
294 | if(!deps.isEmpty()) | ||
295 | t << d_file << ": " << deps.join(" ") << endl; | ||
296 | t << "-include " << d_file << endl; | ||
297 | } | ||
298 | } | ||
299 | } | ||
300 | } | ||
301 | } | ||
302 | |||
303 | t << "####### Build rules" << endl << endl; | ||
304 | if(!project->variables()["SUBLIBS"].isEmpty()) { | ||
305 | QString libdir = "tmp/"; | ||
306 | if(!project->isEmpty("SUBLIBS_DIR")) | ||
307 | libdir = project->first("SUBLIBS_DIR"); | ||
308 | t << "SUBLIBS= "; | ||
309 | QStringList &l = project->variables()["SUBLIBS"]; | ||
310 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) | ||
311 | t << libdir << "lib" << (*it) << ".a "; | ||
312 | t << endl << endl; | ||
313 | } | ||
314 | if(project->isActiveConfig("depend_prl") && !project->isEmpty("QMAKE_PRL_INTERNAL_FILES")) { | ||
315 | QStringList &l = project->variables()["QMAKE_PRL_INTERNAL_FILES"]; | ||
316 | QStringList::Iterator it; | ||
317 | for(it = l.begin(); it != l.end(); ++it) { | ||
318 | QMakeProject proj; | ||
319 | if(proj.read((*it), QDir::currentDirPath()) && !proj.isEmpty("QMAKE_PRL_BUILD_DIR")) { | ||
320 | QString dir; | ||
321 | int slsh = (*it).findRev(Option::dir_sep); | ||
322 | if(slsh != -1) | ||
323 | dir = (*it).left(slsh + 1); | ||
324 | QString targ = dir + proj.first("QMAKE_PRL_TARGET"); | ||
325 | deps += " " + targ; | ||
326 | t << targ << ":" << "\n\t" | ||
327 | << "@echo \"Creating '" << targ << "'\"" << "\n\t" | ||
328 | << "(cd " << proj.first("QMAKE_PRL_BUILD_DIR") << ";" | ||
329 | << "$(MAKE) )" << endl; | ||
330 | } | ||
331 | } | ||
332 | } | ||
333 | if(!project->variables()["QMAKE_APP_FLAG"].isEmpty()) { | ||
334 | QString destdir = project->first("DESTDIR"); | ||
335 | if(do_incremental) { | ||
336 | //incremental target | ||
337 | QString incr_target = var("TARGET") + "_incremental"; | ||
338 | if(incr_target.find(Option::dir_sep) != -1) | ||
339 | incr_target = incr_target.right(incr_target.length() - | ||
340 | (incr_target.findRev(Option::dir_sep) + 1)); | ||
341 | QString incr_deps, incr_objs; | ||
342 | if(project->first("QMAKE_INCREMENTAL_STYLE") == "ld") { | ||
343 | QString incr_target_dir = var("OBJECTS_DIR") + incr_target + Option::obj_ext; | ||
344 | //actual target | ||
345 | t << incr_target_dir << ": $(OBJECTS)" << "\n\t" | ||
346 | << "ld -r -o "<< incr_target_dir << " $(OBJECTS)" << endl; | ||
347 | //communicated below | ||
348 | deps.prepend(incr_target_dir + " "); | ||
349 | incr_deps = "$(UICDECLS) $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC) $(OBJMOC)"; | ||
350 | if(!incr_objs.isEmpty()) | ||
351 | incr_objs += " "; | ||
352 | incr_objs += incr_target_dir; | ||
353 | } else { | ||
354 | //actual target | ||
355 | QString incr_target_dir = var("DESTDIR") + "lib" + incr_target + "." + | ||
356 | project->variables()["QMAKE_EXTENSION_SHLIB"].first(); | ||
357 | QString incr_lflags = var("QMAKE_LFLAGS_SHLIB") + " "; | ||
358 | if(project->isActiveConfig("debug")) | ||
359 | incr_lflags += var("QMAKE_LFLAGS_DEBUG"); | ||
360 | else | ||
361 | incr_lflags += var("QMAKE_LFLAGS_RELEASE"); | ||
362 | t << incr_target_dir << ": $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << "\n\t"; | ||
363 | if(!destdir.isEmpty()) | ||
364 | t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; | ||
365 | t << "$(LINK) " << incr_lflags << " -o "<< incr_target_dir << | ||
366 | " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << endl; | ||
367 | //communicated below | ||
368 | if(!destdir.isEmpty()) { | ||
369 | if(!incr_objs.isEmpty()) | ||
370 | incr_objs += " "; | ||
371 | incr_objs += "-L" + destdir; | ||
372 | } else { | ||
373 | if(!incr_objs.isEmpty()) | ||
374 | incr_objs += " "; | ||
375 | incr_objs += "-L" + QDir::currentDirPath(); | ||
376 | } | ||
377 | if(!incr_objs.isEmpty()) | ||
378 | incr_objs += " "; | ||
379 | incr_objs += " -l" + incr_target; | ||
380 | deps.prepend(incr_target_dir + " "); | ||
381 | incr_deps = "$(UICDECLS) $(OBJECTS) $(OBJMOC)"; | ||
382 | } | ||
383 | t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" | ||
384 | << endl << endl; | ||
385 | |||
386 | //real target | ||
387 | t << var("TARGET") << ": " << " " << incr_deps << " " << var("TARGETDEPS") << "\n\t"; | ||
388 | if(!destdir.isEmpty()) | ||
389 | t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; | ||
390 | if(!project->isEmpty("QMAKE_PRE_LINK")) | ||
391 | t << var("QMAKE_PRE_LINK") << "\n\t"; | ||
392 | t << "$(LINK) $(LFLAGS) -o $(TARGET) " << incr_deps << " " << incr_objs << " $(LIBS)"; | ||
393 | if(!project->isEmpty("QMAKE_POST_LINK")) | ||
394 | t << "\n\t" << var("QMAKE_POST_LINK"); | ||
395 | t << endl << endl; | ||
396 | } else { | ||
397 | t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" | ||
398 | << endl << endl; | ||
399 | |||
400 | t << "$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) " << var("TARGETDEPS") << "\n\t"; | ||
401 | if(!destdir.isEmpty()) | ||
402 | t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; | ||
403 | if(!project->isEmpty("QMAKE_PRE_LINK")) | ||
404 | t << var("QMAKE_PRE_LINK") << "\n\t"; | ||
405 | t << "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)"; | ||
406 | if(!project->isEmpty("QMAKE_POST_LINK")) | ||
407 | t << "\n\t" << var("QMAKE_POST_LINK"); | ||
408 | t << endl << endl; | ||
409 | } | ||
410 | } else if(!project->isActiveConfig("staticlib")) { | ||
411 | QString destdir = project->first("DESTDIR"), incr_deps; | ||
412 | if(do_incremental) { | ||
413 | QString s_ext = project->variables()["QMAKE_EXTENSION_SHLIB"].first(); | ||
414 | QString incr_target = var("QMAKE_ORIG_TARGET").replace( | ||
415 | QRegExp("\\." + s_ext), "").replace(QRegExp("^lib"), "") + "_incremental"; | ||
416 | if(incr_target.find(Option::dir_sep) != -1) | ||
417 | incr_target = incr_target.right(incr_target.length() - | ||
418 | (incr_target.findRev(Option::dir_sep) + 1)); | ||
419 | |||
420 | if(project->first("QMAKE_INCREMENTAL_STYLE") == "ld") { | ||
421 | QString incr_target_dir = var("OBJECTS_DIR") + incr_target + Option::obj_ext; | ||
422 | //actual target | ||
423 | const QString link_deps = "$(UICDECLS) $(OBJECTS) $(OBJMOC)"; | ||
424 | t << incr_target_dir << ": " << link_deps << "\n\t" | ||
425 | << "ld -r -o " << incr_target_dir << " " << link_deps << endl; | ||
426 | //communicated below | ||
427 | QStringList &cmd = project->variables()["QMAKE_LINK_SHLIB_CMD"]; | ||
428 | cmd.first().replace("$(OBJECTS) $(OBJMOC)", | ||
429 | "$(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)"); //ick | ||
430 | cmd.append(incr_target_dir); | ||
431 | deps.prepend(incr_target_dir + " "); | ||
432 | incr_deps = "$(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)"; | ||
433 | } else { | ||
434 | //actual target | ||
435 | QString incr_target_dir = var("DESTDIR") + "lib" + incr_target + "." + s_ext; | ||
436 | QString incr_lflags = var("QMAKE_LFLAGS_SHLIB") + " "; | ||
437 | if(!project->isEmpty("QMAKE_LFLAGS_INCREMENTAL")) | ||
438 | incr_lflags += var("QMAKE_LFLAGS_INCREMENTAL") + " "; | ||
439 | if(project->isActiveConfig("debug")) | ||
440 | incr_lflags += var("QMAKE_LFLAGS_DEBUG"); | ||
441 | else | ||
442 | incr_lflags += var("QMAKE_LFLAGS_RELEASE"); | ||
443 | t << incr_target_dir << ": $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << "\n\t"; | ||
444 | if(!destdir.isEmpty()) | ||
445 | t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; | ||
446 | t << "$(LINK) " << incr_lflags << " -o "<< incr_target_dir << | ||
447 | " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << endl; | ||
448 | //communicated below | ||
449 | QStringList &cmd = project->variables()["QMAKE_LINK_SHLIB_CMD"]; | ||
450 | if(!destdir.isEmpty()) | ||
451 | cmd.append(" -L" + destdir); | ||
452 | cmd.append(" -l" + incr_target); | ||
453 | deps.prepend(incr_target_dir + " "); | ||
454 | incr_deps = "$(UICDECLS) $(OBJECTS) $(OBJMOC)"; | ||
455 | } | ||
456 | |||
457 | t << "all: " << " " << deps << " " << varGlue("ALL_DEPS",""," ","") | ||
458 | << " " << var("DESTDIR_TARGET") << endl << endl; | ||
459 | |||
460 | //real target | ||
461 | t << var("DESTDIR_TARGET") << ": " << incr_deps << " $(SUBLIBS) " << | ||
462 | var("TARGETDEPS"); | ||
463 | } else { | ||
464 | t << "all: " << deps << " " << varGlue("ALL_DEPS",""," ","") << " " << | ||
465 | var("DESTDIR_TARGET") << endl << endl; | ||
466 | t << var("DESTDIR_TARGET") << ": $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) " << | ||
467 | var("TARGETDEPS"); | ||
468 | } | ||
469 | if(!destdir.isEmpty()) | ||
470 | t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir; | ||
471 | if(!project->isEmpty("QMAKE_PRE_LINK")) | ||
472 | t << "\n\t" << var("QMAKE_PRE_LINK"); | ||
473 | |||
474 | if(project->isActiveConfig("plugin")) { | ||
475 | t << "\n\t" | ||
476 | << "-$(DEL_FILE) $(TARGET)" << "\n\t" | ||
477 | << var("QMAKE_LINK_SHLIB_CMD"); | ||
478 | if(!destdir.isEmpty()) | ||
479 | t << "\n\t" | ||
480 | << "-$(MOVE) $(TARGET) " << var("DESTDIR"); | ||
481 | if(!project->isEmpty("QMAKE_POST_LINK")) | ||
482 | t << "\n\t" << var("QMAKE_POST_LINK") << "\n\t"; | ||
483 | t << endl << endl; | ||
484 | } else if ( os == "hpux" ) { | ||
485 | t << "\n\t" | ||
486 | << "-$(DEL_FILE) $(TARGET) $(TARGET0)" << "\n\t" | ||
487 | << var("QMAKE_LINK_SHLIB_CMD") << "\n\t"; | ||
488 | t << varGlue("QMAKE_LN_SHLIB",""," "," $(TARGET) $(TARGET0)"); | ||
489 | if(!destdir.isEmpty()) | ||
490 | t << "\n\t" | ||
491 | << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET)\n\t" | ||
492 | << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET0)\n\t" | ||
493 | << "-$(MOVE) $(TARGET) $(TARGET0) " << var("DESTDIR"); | ||
494 | if(!project->isEmpty("QMAKE_POST_LINK")) | ||
495 | t << "\n\t" << var("QMAKE_POST_LINK"); | ||
496 | t << endl << endl; | ||
497 | } else { | ||
498 | t << "\n\t" | ||
499 | << "-$(DEL_FILE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2)" << "\n\t" | ||
500 | << var("QMAKE_LINK_SHLIB_CMD") << "\n\t"; | ||
501 | t << varGlue("QMAKE_LN_SHLIB","-"," "," $(TARGET) $(TARGET0)") << "\n\t" | ||
502 | << varGlue("QMAKE_LN_SHLIB","-"," "," $(TARGET) $(TARGET1)") << "\n\t" | ||
503 | << varGlue("QMAKE_LN_SHLIB","-"," "," $(TARGET) $(TARGET2)"); | ||
504 | if(!destdir.isEmpty()) | ||
505 | t << "\n\t" | ||
506 | << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET)\n\t" | ||
507 | << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET0)\n\t" | ||
508 | << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET1)\n\t" | ||
509 | << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET2)\n\t" | ||
510 | << "-$(MOVE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) " << var("DESTDIR"); | ||
511 | if(!project->isEmpty("QMAKE_POST_LINK")) | ||
512 | t << "\n\t" << var("QMAKE_POST_LINK"); | ||
513 | t << endl << endl; | ||
514 | } | ||
515 | t << endl << endl; | ||
516 | |||
517 | if (! project->isActiveConfig("plugin")) { | ||
518 | t << "staticlib: $(TARGETA)" << endl << endl; | ||
519 | t << "$(TARGETA): $(UICDECLS) $(OBJECTS) $(OBJMOC)"; | ||
520 | if(do_incremental) | ||
521 | t << " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)"; | ||
522 | t << var("TARGETDEPS") << "\n\t" | ||
523 | << "-$(DEL_FILE) $(TARGETA) " << "\n\t" | ||
524 | << var("QMAKE_AR_CMD"); | ||
525 | if(do_incremental) | ||
526 | t << " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)"; | ||
527 | if(!project->isEmpty("QMAKE_RANLIB")) | ||
528 | t << "\n\t" << "$(RANLIB) $(TARGETA)"; | ||
529 | t << endl << endl; | ||
530 | } | ||
531 | } else { | ||
532 | t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << var("DESTDIR") << "$(TARGET) " | ||
533 | << varGlue("QMAKE_AR_SUBLIBS", var("DESTDIR"), " " + var("DESTDIR"), "") << "\n\n" | ||
534 | << "staticlib: " << var("DESTDIR") << "$(TARGET)" << "\n\n"; | ||
535 | if(project->isEmpty("QMAKE_AR_SUBLIBS")) { | ||
536 | t << var("DESTDIR") << "$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(TARGETDEPS) " << "\n\t"; | ||
537 | if(!project->isEmpty("DESTDIR")) { | ||
538 | QString destdir = project->first("DESTDIR"); | ||
539 | t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; | ||
540 | } | ||
541 | t << "-$(DEL_FILE) $(TARGET)" << "\n\t" | ||
542 | << var("QMAKE_AR_CMD") << "\n"; | ||
543 | if(!project->isEmpty("QMAKE_POST_LINK")) | ||
544 | t << "\t" << var("QMAKE_POST_LINK") << "\n"; | ||
545 | if(!project->isEmpty("QMAKE_RANLIB")) | ||
546 | t << "\t" << "$(RANLIB) $(TARGET)" << "\n"; | ||
547 | if(!project->isEmpty("DESTDIR")) | ||
548 | t << "\t" << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET)" << "\n" | ||
549 | << "\t" << "-$(MOVE) $(TARGET) " << var("DESTDIR") << "\n"; | ||
550 | } else { | ||
551 | int cnt = 0, max_files = project->first("QMAKE_MAX_FILES_PER_AR").toInt(); | ||
552 | QStringList objs = project->variables()["OBJECTS"] + project->variables()["OBJMOC"], | ||
553 | libs = project->variables()["QMAKE_AR_SUBLIBS"]; | ||
554 | libs.prepend("$(TARGET)"); | ||
555 | for(QStringList::Iterator libit = libs.begin(), objit = objs.begin(); | ||
556 | libit != libs.end(); ++libit) { | ||
557 | QStringList build; | ||
558 | for(cnt = 0; cnt < max_files && objit != objs.end(); ++objit, cnt++) | ||
559 | build << (*objit); | ||
560 | QString ar; | ||
561 | if((*libit) == "$(TARGET)") { | ||
562 | t << var("DESTDIR") << "$(TARGET): $(UICDECLS) " << " $(TARGETDEPS) " | ||
563 | << valList(build) << "\n\t"; | ||
564 | ar = project->variables()["QMAKE_AR_CMD"].first(); | ||
565 | ar = ar.replace("$(OBJMOC)", "").replace("$(OBJECTS)", | ||
566 | build.join(" ")); | ||
567 | } else { | ||
568 | t << (*libit) << ": " << valList(build) << "\n\t"; | ||
569 | ar = "$(AR) " + (*libit) + " " + build.join(" "); | ||
570 | } | ||
571 | if(!project->isEmpty("DESTDIR")) { | ||
572 | QString destdir = project->first("DESTDIR"); | ||
573 | t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; | ||
574 | } | ||
575 | t << "-$(DEL_FILE) " << (*libit) << "\n\t" | ||
576 | << ar << "\n"; | ||
577 | if(!project->isEmpty("QMAKE_POST_LINK")) | ||
578 | t << "\t" << var("QMAKE_POST_LINK") << "\n"; | ||
579 | if(!project->isEmpty("QMAKE_RANLIB")) | ||
580 | t << "\t" << "$(RANLIB) " << (*libit) << "\n"; | ||
581 | if(!project->isEmpty("DESTDIR")) | ||
582 | t << "\t" << "-$(DEL_FILE) " << var("DESTDIR") << (*libit) << "\n" | ||
583 | << "\t" << "-$(MOVE) " << (*libit) << " " << var("DESTDIR") << "\n"; | ||
584 | } | ||
585 | } | ||
586 | t << endl << endl; | ||
587 | } | ||
588 | |||
589 | t << "mocables: $(SRCMOC)" << endl << endl; | ||
590 | |||
591 | if(!project->isActiveConfig("no_mocdepend")) { | ||
592 | //this is an implicity depend on moc, so it will be built if necesary, however | ||
593 | //moc itself shouldn't have this dependancy - this is a little kludgy but it is | ||
594 | //better than the alternative for now. | ||
595 | QString moc = project->first("QMAKE_MOC"), target = project->first("TARGET"); | ||
596 | fixEnvVariables(target); | ||
597 | fixEnvVariables(moc); | ||
598 | if(target != moc) | ||
599 | t << "$(MOC): \n\t" | ||
600 | << "( cd $(QTDIR)/src/moc ; $(MAKE) )" << endl << endl; | ||
601 | } | ||
602 | |||
603 | writeMakeQmake(t); | ||
604 | |||
605 | if(!project->first("QMAKE_PKGINFO").isEmpty()) { | ||
606 | QString pkginfo = project->first("QMAKE_PKGINFO"); | ||
607 | QString destdir = project->first("DESTDIR"); | ||
608 | t << pkginfo << ": " << "\n\t"; | ||
609 | if(!destdir.isEmpty()) | ||
610 | t << "@test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; | ||
611 | t << "@$(DEL_FILE) " << pkginfo << "\n\t" | ||
612 | << "@echo \"APPL????\" >" << pkginfo << endl; | ||
613 | } | ||
614 | if(!project->first("QMAKE_INFO_PLIST").isEmpty()) { | ||
615 | QString info_plist = project->first("QMAKE_INFO_PLIST"), | ||
616 | info_plist_out = project->first("QMAKE_INFO_PLIST_OUT"); | ||
617 | QString destdir = project->first("DESTDIR"); | ||
618 | t << info_plist_out << ": " << "\n\t"; | ||
619 | if(!destdir.isEmpty()) | ||
620 | t << "@test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; | ||
621 | t << "@$(DEL_FILE) " << info_plist_out << "\n\t" | ||
622 | << "@cp \"" << info_plist << "\" \"" << info_plist_out << "\"" << endl; | ||
623 | if(!project->first("RC_FILE").isEmpty()) { | ||
624 | QString dir = destdir + "../Resources/"; | ||
625 | t << dir << "application.icns:" << "\n\t" | ||
626 | << "@test -d " << dir << " || mkdir -p " << dir << "\n\t" | ||
627 | << "@cp " << var("RC_FILE") << " " << dir << "application.icns" << endl; | ||
628 | } | ||
629 | } | ||
630 | |||
631 | QString ddir = project->isEmpty("QMAKE_DISTDIR") ? project->first("QMAKE_ORIG_TARGET") : | ||
632 | project->first("QMAKE_DISTDIR"); | ||
633 | QString ddir_c = fileFixify((project->isEmpty("OBJECTS_DIR") ? QString(".tmp/") : | ||
634 | project->first("OBJECTS_DIR")) + ddir); | ||
635 | t << "dist: " << "\n\t" | ||
636 | << "@mkdir -p " << ddir_c << " && " | ||
637 | << "$(COPY_FILE) --parents $(SOURCES) $(HEADERS) $(FORMS) $(DIST) " << ddir_c << Option::dir_sep << " && "; | ||
638 | if(!project->isEmpty("TRANSLATIONS")) | ||
639 | t << "$(COPY_FILE) --parents " << var("TRANSLATIONS") << " " << ddir_c << Option::dir_sep << " && "; | ||
640 | if(!project->isEmpty("FORMS")) { | ||
641 | QStringList &forms = project->variables()["FORMS"], ui_headers; | ||
642 | for(QStringList::Iterator formit = forms.begin(); formit != forms.end(); ++formit) { | ||
643 | QString ui_h = fileFixify((*formit) + Option::h_ext.first()); | ||
644 | if(QFile::exists(ui_h) ) | ||
645 | ui_headers << ui_h; | ||
646 | } | ||
647 | if(!ui_headers.isEmpty()) | ||
648 | t << "$(COPY_FILE) --parents " << val(ui_headers) << " " << ddir_c << Option::dir_sep << " && "; | ||
649 | } | ||
650 | t << "( cd `dirname " << ddir_c << "` && " | ||
651 | << "$(TAR) " << var("QMAKE_ORIG_TARGET") << ".tar " << ddir << " && " | ||
652 | << "$(GZIP) " << var("QMAKE_ORIG_TARGET") << ".tar ) && " | ||
653 | << "$(MOVE) `dirname " << ddir_c << "`" << Option::dir_sep << var("QMAKE_ORIG_TARGET") << ".tar.gz . && " | ||
654 | << "$(DEL_DIR) " << ddir_c | ||
655 | << endl << endl; | ||
656 | |||
657 | QString clean_targets; | ||
658 | if(mocAware()) { | ||
659 | t << "mocclean:" << "\n"; | ||
660 | if(!objMoc.isEmpty() || !srcMoc.isEmpty() || moc_incremental) { | ||
661 | if(!objMoc.isEmpty()) | ||
662 | t << "\t-$(DEL_FILE) $(OBJMOC)" << '\n'; | ||
663 | if(!srcMoc.isEmpty()) | ||
664 | t << "\t-$(DEL_FILE) $(SRCMOC)" << '\n'; | ||
665 | if(moc_incremental) | ||
666 | t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJMOC)" << '\n'; | ||
667 | clean_targets += " mocclean"; | ||
668 | } | ||
669 | t << endl; | ||
670 | } | ||
671 | t << "uiclean:" << "\n"; | ||
672 | if (!var("UICIMPLS").isEmpty() || !var("UICDECLS").isEmpty()) { | ||
673 | t << "\t-$(DEL_FILE) $(UICIMPLS) $(UICDECLS)" << "\n"; | ||
674 | clean_targets += " uiclean"; | ||
675 | } | ||
676 | t << endl; | ||
677 | |||
678 | if(do_incremental) { | ||
679 | t << "incrclean:" << "\n"; | ||
680 | if(src_incremental) | ||
681 | t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJECTS)" << "\n"; | ||
682 | if(moc_incremental) | ||
683 | t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJMOC)" << '\n'; | ||
684 | t << endl; | ||
685 | } | ||
686 | |||
687 | t << "clean:" << clean_targets << "\n\t"; | ||
688 | if(!project->isEmpty("OBJECTS")) | ||
689 | t << "-$(DEL_FILE) $(OBJECTS) " << "\n\t"; | ||
690 | if(!project->isEmpty("IMAGES")) | ||
691 | t << varGlue("QMAKE_IMAGE_COLLECTION", "\t-$(DEL_FILE) ", " ", "") << "\n\t"; | ||
692 | if(src_incremental) | ||
693 | t << "-$(DEL_FILE) $(INCREMENTAL_OBJECTS)" << "\n\t"; | ||
694 | t << varGlue("QMAKE_CLEAN","-$(DEL_FILE) "," ","\n\t") | ||
695 | << "-$(DEL_FILE) *~ core *.core" << "\n" | ||
696 | << varGlue("CLEAN_FILES","\t-$(DEL_FILE) "," ","") << endl << endl; | ||
697 | t << "####### Sub-libraries" << endl << endl; | ||
698 | if ( !project->variables()["SUBLIBS"].isEmpty() ) { | ||
699 | QString libdir = "tmp/"; | ||
700 | if(!project->isEmpty("SUBLIBS_DIR")) | ||
701 | libdir = project->first("SUBLIBS_DIR"); | ||
702 | QStringList &l = project->variables()["SUBLIBS"]; | ||
703 | for(it = l.begin(); it != l.end(); ++it) | ||
704 | t << libdir << "lib" << (*it) << ".a" << ":\n\t" | ||
705 | << var(QString("MAKELIB") + (*it)) << endl << endl; | ||
706 | } | ||
707 | |||
708 | QString destdir = project->first("DESTDIR"); | ||
709 | if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep) | ||
710 | destdir += Option::dir_sep; | ||
711 | t << "distclean: " << "clean\n\t" | ||
712 | << "-$(DEL_FILE) " << destdir << "$(TARGET)" << " " << "$(TARGET)" << "\n"; | ||
713 | if(!project->isActiveConfig("staticlib") && project->variables()["QMAKE_APP_FLAG"].isEmpty() && | ||
714 | !project->isActiveConfig("plugin")) | ||
715 | t << "\t-$(DEL_FILE) " << destdir << "$(TARGET0) " << destdir << "$(TARGET1) " | ||
716 | << destdir << "$(TARGET2) $(TARGETA)" << "\n"; | ||
717 | t << endl << endl; | ||
718 | |||
719 | if ( !project->isEmpty("PRECOMPH") ) { | ||
720 | QString outdir = project->first("MOC_DIR"); | ||
721 | QString qt_dot_h = Option::fixPathToLocalOS(project->first("PRECOMPH")); | ||
722 | t << "###### Combined headers" << endl << endl; | ||
723 | //XXX | ||
724 | t << outdir << "allmoc.cpp: " << qt_dot_h << " " | ||
725 | << varList("HEADERS_ORIG") << "\n\t" | ||
726 | << "echo '#include \"" << qt_dot_h << "\"' >" << outdir << "allmoc.cpp" << "\n\t" | ||
727 | << "$(CXX) -E -DQT_MOC_CPP -DQT_NO_STL $(CXXFLAGS) $(INCPATH) >" << outdir << "allmoc.h " | ||
728 | << outdir << "allmoc.cpp" << "\n\t" | ||
729 | << "$(MOC) -o " << outdir << "allmoc.cpp " << outdir << "allmoc.h" << "\n\t" | ||
730 | << "perl -pi -e 's{#include \"allmoc.h\"}{#define QT_H_CPP\\n#include \"" | ||
731 | << qt_dot_h << "\"}' " << outdir << "allmoc.cpp" << "\n\t" | ||
732 | << "$(DEL_FILE) " << outdir << "allmoc.h" << endl << endl; | ||
733 | } | ||
734 | |||
735 | // blasted user defined targets | ||
736 | QStringList &qut = project->variables()["QMAKE_EXTRA_UNIX_TARGETS"]; | ||
737 | for(it = qut.begin(); it != qut.end(); ++it) { | ||
738 | QString targ = var((*it) + ".target"), | ||
739 | cmd = var((*it) + ".commands"), deps; | ||
740 | if(targ.isEmpty()) | ||
741 | targ = (*it); | ||
742 | QStringList &deplist = project->variables()[(*it) + ".depends"]; | ||
743 | for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) { | ||
744 | QString dep = var((*dep_it) + ".target"); | ||
745 | if(dep.isEmpty()) | ||
746 | dep = (*dep_it); | ||
747 | deps += " " + dep; | ||
748 | } | ||
749 | t << targ << ":" << deps << "\n\t" | ||
750 | << cmd << endl << endl; | ||
751 | } | ||
752 | t <<"FORCE:" << endl << endl; | ||
753 | } | ||
754 | |||
755 | struct SubDir | ||
756 | { | ||
757 | QString directory, profile, target, makefile; | ||
758 | }; | ||
759 | |||
760 | void | ||
761 | UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct) | ||
762 | { | ||
763 | QPtrList<SubDir> subdirs; | ||
764 | { | ||
765 | QStringList subdirs_in = project->variables()["SUBDIRS"]; | ||
766 | for(QStringList::Iterator it = subdirs_in.begin(); it != subdirs_in.end(); ++it) { | ||
767 | QString file = (*it); | ||
768 | fileFixify(file); | ||
769 | SubDir *sd = new SubDir; | ||
770 | subdirs.append(sd); | ||
771 | sd->makefile = "$(MAKEFILE)"; | ||
772 | if((*it).right(4) == ".pro") { | ||
773 | int slsh = file.findRev(Option::dir_sep); | ||
774 | if(slsh != -1) { | ||
775 | sd->directory = file.left(slsh+1); | ||
776 | sd->profile = file.mid(slsh+1); | ||
777 | } else { | ||
778 | sd->profile = file; | ||
779 | } | ||
780 | } else { | ||
781 | sd->directory = file; | ||
782 | } | ||
783 | while(sd->directory.right(1) == Option::dir_sep) | ||
784 | sd->directory = sd->directory.left(sd->directory.length() - 1); | ||
785 | if(!sd->profile.isEmpty()) { | ||
786 | QString basename = sd->directory; | ||
787 | int new_slsh = basename.findRev(Option::dir_sep); | ||
788 | if(new_slsh != -1) | ||
789 | basename = basename.mid(new_slsh+1); | ||
790 | if(sd->profile != basename + ".pro") | ||
791 | sd->makefile += "." + sd->profile.left(sd->profile.length() - 4); //no need for the .pro | ||
792 | } | ||
793 | sd->target = "sub-" + (*it); | ||
794 | sd->target.replace('/', '-'); | ||
795 | sd->target.replace('.', '_'); | ||
796 | } | ||
797 | } | ||
798 | QPtrListIterator<SubDir> it(subdirs); | ||
799 | |||
800 | QString ofile = Option::output.name(); | ||
801 | if(ofile.findRev(Option::dir_sep) != -1) | ||
802 | ofile = ofile.right(ofile.length() - ofile.findRev(Option::dir_sep) -1); | ||
803 | t << "MAKEFILE =" << var("MAKEFILE") << endl; | ||
804 | t << "QMAKE =" << var("QMAKE") << endl; | ||
805 | t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; | ||
806 | t << "SUBTARGETS ="; // subdirectory targets are sub-directory | ||
807 | for( it.toFirst(); it.current(); ++it) | ||
808 | t << " \\\n\t\t" << it.current()->target; | ||
809 | t << endl << endl; | ||
810 | t << "first: all\n\nall: " << ofile << " $(SUBTARGETS)" << endl << endl; | ||
811 | |||
812 | // generate target rules | ||
813 | for( it.toFirst(); it.current(); ++it) { | ||
814 | bool have_dir = !(*it)->directory.isEmpty(); | ||
815 | QString mkfile = (*it)->makefile, out; | ||
816 | if(have_dir) | ||
817 | mkfile.prepend((*it)->directory + Option::dir_sep); | ||
818 | if(direct || (*it)->makefile != "$(MAKEFILE)") | ||
819 | out = " -o " + (*it)->makefile; | ||
820 | //qmake it | ||
821 | t << mkfile << ": " << "\n\t"; | ||
822 | if(have_dir) | ||
823 | t << "cd " << (*it)->directory << " && "; | ||
824 | t << "$(QMAKE) " << (*it)->profile << buildArgs() << out << endl; | ||
825 | //actually compile | ||
826 | t << (*it)->target << ": " << mkfile << " FORCE" << "\n\t"; | ||
827 | if(have_dir) | ||
828 | t << "cd " << (*it)->directory << " && "; | ||
829 | t << "$(MAKE) -f " << (*it)->makefile << endl << endl; | ||
830 | } | ||
831 | |||
832 | if (project->isActiveConfig("ordered")) { // generate dependencies | ||
833 | for( it.toFirst(); it.current(); ) { | ||
834 | QString tar = it.current()->target; | ||
835 | ++it; | ||
836 | if (it.current()) | ||
837 | t << it.current()->target << ": " << tar << endl; | ||
838 | } | ||
839 | t << endl; | ||
840 | } | ||
841 | |||
842 | writeMakeQmake(t); | ||
843 | |||
844 | if(project->isEmpty("SUBDIRS")) { | ||
845 | t << "all qmake_all distclean install uiclean mocclean clean: FORCE" << endl; | ||
846 | } else { | ||
847 | t << "all: $(SUBTARGETS)" << endl; | ||
848 | t << "qmake_all:"; | ||
849 | for( it.toFirst(); it.current(); ++it) { | ||
850 | t << " "; | ||
851 | if(!(*it)->directory.isEmpty()) | ||
852 | t << (*it)->directory << Option::dir_sep; | ||
853 | t << (*it)->makefile; | ||
854 | } | ||
855 | for( it.toFirst(); it.current(); ++it) { | ||
856 | t << "\n\t ( "; | ||
857 | if(!(*it)->directory.isEmpty()) | ||
858 | t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; "; | ||
859 | t << "grep \"^qmake_all:\" " << (*it)->makefile | ||
860 | << " && $(MAKE) -f " << (*it)->makefile << " qmake_all" << "; ) || true"; | ||
861 | } | ||
862 | t << endl; | ||
863 | t << "clean uninstall install uiclean mocclean: qmake_all FORCE"; | ||
864 | for( it.toFirst(); it.current(); ++it) { | ||
865 | t << "\n\t ( "; | ||
866 | if(!(*it)->directory.isEmpty()) | ||
867 | t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; "; | ||
868 | t << "$(MAKE) -f " << (*it)->makefile << " $@" << "; ) || true"; | ||
869 | } | ||
870 | t << endl; | ||
871 | t << "distclean: qmake_all FORCE"; | ||
872 | for( it.toFirst(); it.current(); ++it) { | ||
873 | t << "\n\t ( "; | ||
874 | if(!(*it)->directory.isEmpty()) | ||
875 | t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; "; | ||
876 | t << "$(MAKE) -f " << (*it)->makefile << " $@; $(DEL_FILE) " << (*it)->makefile << "; ) || true"; | ||
877 | } | ||
878 | t << endl << endl; | ||
879 | } | ||
880 | t <<"FORCE:" << endl << endl; | ||
881 | } | ||
882 | |||
883 | void UnixMakefileGenerator::init2() | ||
884 | { | ||
885 | //version handling | ||
886 | if(project->variables()["VERSION"].isEmpty()) | ||
887 | project->variables()["VERSION"].append("1.0." + | ||
888 | (project->isEmpty("VER_PAT") ? QString("0") : | ||
889 | project->first("VER_PAT")) ); | ||
890 | QStringList l = QStringList::split('.', project->first("VERSION")); | ||
891 | l << "0" << "0"; //make sure there are three | ||
892 | project->variables()["VER_MAJ"].append(l[0]); | ||
893 | project->variables()["VER_MIN"].append(l[1]); | ||
894 | project->variables()["VER_PAT"].append(l[2]); | ||
895 | |||
896 | if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { | ||
897 | #if 0 | ||
898 | if ( project->isActiveConfig("dll") ) { | ||
899 | project->variables()["TARGET"] += project->variables()["TARGET.so"]; | ||
900 | if(project->variables()["QMAKE_LFLAGS_SHAPP"].isEmpty()) | ||
901 | project->variables()["QMAKE_LFLAGS_SHAPP"] += project->variables()["QMAKE_LFLAGS_SHLIB"]; | ||
902 | if(!project->variables()["QMAKE_LFLAGS_SONAME"].isEmpty()) | ||
903 | project->variables()["QMAKE_LFLAGS_SONAME"].first() += project->first("TARGET"); | ||
904 | } | ||
905 | #endif | ||
906 | project->variables()["TARGET"].first().prepend(project->first("DESTDIR")); | ||
907 | } else if ( project->isActiveConfig("staticlib") ) { | ||
908 | project->variables()["TARGET"].first().prepend("lib"); | ||
909 | project->variables()["TARGET"].first() += ".a"; | ||
910 | if(project->variables()["QMAKE_AR_CMD"].isEmpty()) | ||
911 | project->variables()["QMAKE_AR_CMD"].append("$(AR) $(TARGET) $(OBJECTS) $(OBJMOC)"); | ||
912 | } else { | ||
913 | project->variables()["TARGETA"].append(project->first("DESTDIR") + "lib" + project->first("TARGET") + ".a"); | ||
914 | if ( !project->variables()["QMAKE_AR_CMD"].isEmpty() ) | ||
915 | project->variables()["QMAKE_AR_CMD"].first().replace("(TARGET)","(TARGETA)"); | ||
916 | else | ||
917 | project->variables()["QMAKE_AR_CMD"].append("$(AR) $(TARGETA) $(OBJECTS) $(OBJMOC)"); | ||
918 | QString os = project->variables()["QMAKESPEC"].first().section( '-', 0, 0 ); | ||
919 | if( project->isActiveConfig("plugin") ) { | ||
920 | project->variables()["TARGET_x.y.z"].append("lib" + | ||
921 | project->first("TARGET") + "." + project->first("QMAKE_EXTENSION_SHLIB")); | ||
922 | if(project->isActiveConfig("lib_version_first")) | ||
923 | project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + | ||
924 | project->first("VER_MAJ") + "." + | ||
925 | project->first("QMAKE_EXTENSION_SHLIB")); | ||
926 | else | ||
927 | project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + | ||
928 | project->first("QMAKE_EXTENSION_SHLIB") + | ||
929 | "." + project->first("VER_MAJ")); | ||
930 | |||
931 | project->variables()["TARGET"] = project->variables()["TARGET_x.y.z"]; | ||
932 | if(project->isActiveConfig("qt")) | ||
933 | project->variables()["DEFINES"].append("QT_PLUGIN"); | ||
934 | } else if ( os == "hpux" ) { | ||
935 | project->variables()["TARGET_"].append("lib" + project->first("TARGET") + ".sl"); | ||
936 | if(project->isActiveConfig("lib_version_first")) | ||
937 | project->variables()["TARGET_x"].append("lib" + project->first("VER_MAJ") + "." + | ||
938 | project->first("TARGET")); | ||
939 | else | ||
940 | project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + | ||
941 | project->first("VER_MAJ")); | ||
942 | project->variables()["TARGET"] = project->variables()["TARGET_x"]; | ||
943 | } else if ( os == "aix" ) { | ||
944 | project->variables()["TARGET_"].append("lib" + project->first("TARGET") + ".a"); | ||
945 | if(project->isActiveConfig("lib_version_first")) { | ||
946 | project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + | ||
947 | project->first("VER_MAJ") + "." + | ||
948 | project->first("QMAKE_EXTENSION_SHLIB")); | ||
949 | project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." + | ||
950 | project->first("VER_MAJ") + | ||
951 | "." + project->first("VER_MIN") + "." + | ||
952 | project->first("QMAKE_EXTENSION_SHLIB")); | ||
953 | project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") + "." + | ||
954 | project->first("VER_MAJ") + "." + | ||
955 | project->first("VER_MIN") + "." + | ||
956 | project->first("VER_PAT") + "." + | ||
957 | project->first("QMAKE_EXTENSION_SHLIB")); | ||
958 | } else { | ||
959 | project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + | ||
960 | project->first("QMAKE_EXTENSION_SHLIB") + | ||
961 | "." + project->first("VER_MAJ")); | ||
962 | project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." + | ||
963 | project->first("QMAKE_EXTENSION_SHLIB") + | ||
964 | "." + project->first("VER_MAJ") + | ||
965 | "." + project->first("VER_MIN")); | ||
966 | project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") + "." + | ||
967 | project->first("QMAKE_EXTENSION_SHLIB") + "." + | ||
968 | project->first("VER_MAJ") + "." + | ||
969 | project->first("VER_MIN") + "." + | ||
970 | project->first("VER_PAT")); | ||
971 | } | ||
972 | project->variables()["TARGET"] = project->variables()["TARGET_x.y.z"]; | ||
973 | } else { | ||
974 | project->variables()["TARGET_"].append("lib" + project->first("TARGET") + "." + | ||
975 | project->first("QMAKE_EXTENSION_SHLIB")); | ||
976 | if(project->isActiveConfig("lib_version_first")) { | ||
977 | project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + | ||
978 | project->first("VER_MAJ") + "." + | ||
979 | project->first("QMAKE_EXTENSION_SHLIB")); | ||
980 | project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." + | ||
981 | project->first("VER_MAJ") + | ||
982 | "." + project->first("VER_MIN") + "." + | ||
983 | project->first("QMAKE_EXTENSION_SHLIB")); | ||
984 | project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") + "." + | ||
985 | project->first("VER_MAJ") + "." + | ||
986 | project->first("VER_MIN") + "." + | ||
987 | project->first("VER_PAT") + "." + | ||
988 | project->variables()["QMAKE_EXTENSION_SHLIB"].first()); | ||
989 | } else { | ||
990 | project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + | ||
991 | project->first("QMAKE_EXTENSION_SHLIB") + | ||
992 | "." + project->first("VER_MAJ")); | ||
993 | project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." + | ||
994 | project->first("QMAKE_EXTENSION_SHLIB") | ||
995 | + "." + project->first("VER_MAJ") + | ||
996 | "." + project->first("VER_MIN")); | ||
997 | project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") + | ||
998 | "." + | ||
999 | project->variables()[ | ||
1000 | "QMAKE_EXTENSION_SHLIB"].first() + "." + | ||
1001 | project->first("VER_MAJ") + "." + | ||
1002 | project->first("VER_MIN") + "." + | ||
1003 | project->first("VER_PAT")); | ||
1004 | } | ||
1005 | project->variables()["TARGET"] = project->variables()["TARGET_x.y.z"]; | ||
1006 | } | ||
1007 | if(project->isEmpty("QMAKE_LN_SHLIB")) | ||
1008 | project->variables()["QMAKE_LN_SHLIB"].append("ln -s"); | ||
1009 | project->variables()["DESTDIR_TARGET"].append("$(TARGET)"); | ||
1010 | if ( !project->variables()["DESTDIR"].isEmpty() ) | ||
1011 | project->variables()["DESTDIR_TARGET"].first().prepend(project->first("DESTDIR")); | ||
1012 | if ( !project->variables()["QMAKE_LFLAGS_SONAME"].isEmpty() && !project->variables()["TARGET_x"].isEmpty() ) | ||
1013 | project->variables()["QMAKE_LFLAGS_SONAME"].first() += project->first("TARGET_x"); | ||
1014 | if ( project->variables()["QMAKE_LINK_SHLIB_CMD"].isEmpty() ) | ||
1015 | project->variables()["QMAKE_LINK_SHLIB_CMD"].append( | ||
1016 | "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)"); | ||
1017 | } | ||
1018 | if(project->isEmpty("QMAKE_SYMBOLIC_LINK")) | ||
1019 | project->variables()["QMAKE_SYMBOLIC_LINK"].append("ln -sf"); | ||
1020 | if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { | ||
1021 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SHAPP"]; | ||
1022 | } else if ( project->isActiveConfig("dll") ) { | ||
1023 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_SHLIB"]; | ||
1024 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_SHLIB"]; | ||
1025 | if ( project->isActiveConfig("plugin") ) { | ||
1026 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_PLUGIN"]; | ||
1027 | if( !project->isActiveConfig("plugin_no_soname") ) | ||
1028 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SONAME"]; | ||
1029 | } else { | ||
1030 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SHLIB"]; | ||
1031 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SONAME"]; | ||
1032 | } | ||
1033 | QString destdir = project->first("DESTDIR"); | ||
1034 | if ( !destdir.isEmpty() && !project->variables()["QMAKE_RPATH"].isEmpty() ) { | ||
1035 | QString rpath_destdir = destdir; | ||
1036 | if(QDir::isRelativePath(rpath_destdir)) { | ||
1037 | QFileInfo fi(Option::fixPathToLocalOS(rpath_destdir)); | ||
1038 | if(fi.convertToAbs()) //strange, shouldn't really happen | ||
1039 | rpath_destdir = Option::fixPathToTargetOS(rpath_destdir, FALSE); | ||
1040 | else | ||
1041 | rpath_destdir = fi.filePath(); | ||
1042 | } else { | ||
1043 | rpath_destdir = Option::fixPathToTargetOS(rpath_destdir, FALSE); | ||
1044 | } | ||
1045 | project->variables()["QMAKE_LFLAGS"] += project->first("QMAKE_RPATH") + rpath_destdir; | ||
1046 | } | ||
1047 | } | ||
1048 | } | ||