1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the qmake application of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Lesser General Public License Usage
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
18 | ** General Public License version 2.1 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
20 | ** packaging of this file. Please review the following information to
|
---|
21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
23 | **
|
---|
24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #include "unixmake.h"
|
---|
43 | #include "option.h"
|
---|
44 | #include "meta.h"
|
---|
45 | #include <qregexp.h>
|
---|
46 | #include <qbytearray.h>
|
---|
47 | #include <qfile.h>
|
---|
48 | #include <qdir.h>
|
---|
49 | #include <qdatetime.h>
|
---|
50 | #include <qdebug.h>
|
---|
51 | #include <time.h>
|
---|
52 |
|
---|
53 | QT_BEGIN_NAMESPACE
|
---|
54 |
|
---|
55 | UnixMakefileGenerator::UnixMakefileGenerator() : MakefileGenerator(), init_flag(false), include_deps(false)
|
---|
56 | {
|
---|
57 |
|
---|
58 | }
|
---|
59 |
|
---|
60 | void
|
---|
61 | UnixMakefileGenerator::writePrlFile(QTextStream &t)
|
---|
62 | {
|
---|
63 | MakefileGenerator::writePrlFile(t);
|
---|
64 | // libtool support
|
---|
65 |
|
---|
66 | if(project->isActiveConfig("create_libtool") && project->first("TEMPLATE") == "lib") { //write .la
|
---|
67 | if(project->isActiveConfig("compile_libtool"))
|
---|
68 | warn_msg(WarnLogic, "create_libtool specified with compile_libtool can lead to conflicting .la\n"
|
---|
69 | "formats, create_libtool has been disabled\n");
|
---|
70 | else
|
---|
71 | writeLibtoolFile();
|
---|
72 | }
|
---|
73 | // pkg-config support
|
---|
74 | if(project->isActiveConfig("create_pc") && project->first("TEMPLATE") == "lib")
|
---|
75 | writePkgConfigFile();
|
---|
76 | }
|
---|
77 |
|
---|
78 | bool
|
---|
79 | UnixMakefileGenerator::writeMakefile(QTextStream &t)
|
---|
80 | {
|
---|
81 |
|
---|
82 | writeHeader(t);
|
---|
83 | if(!project->values("QMAKE_FAILED_REQUIREMENTS").isEmpty()) {
|
---|
84 | t << "QMAKE = " << var("QMAKE_QMAKE") << endl;
|
---|
85 | QStringList &qut = project->values("QMAKE_EXTRA_TARGETS");
|
---|
86 | for(QStringList::ConstIterator it = qut.begin(); it != qut.end(); ++it)
|
---|
87 | t << *it << " ";
|
---|
88 | t << "first all clean install distclean uninstall qmake_all:" << "\n\t"
|
---|
89 | << "@echo \"Some of the required modules ("
|
---|
90 | << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t"
|
---|
91 | << "@echo \"Skipped.\"" << endl << endl;
|
---|
92 | writeMakeQmake(t);
|
---|
93 | if(project->isEmpty("QMAKE_NOFORCE"))
|
---|
94 | t << "FORCE:" << endl << endl;
|
---|
95 | return true;
|
---|
96 | }
|
---|
97 |
|
---|
98 | if (project->values("TEMPLATE").first() == "app" ||
|
---|
99 | project->values("TEMPLATE").first() == "lib") {
|
---|
100 | if(Option::mkfile::do_stub_makefile && MakefileGenerator::writeStubMakefile(t))
|
---|
101 | return true;
|
---|
102 | writeMakeParts(t);
|
---|
103 | return MakefileGenerator::writeMakefile(t);
|
---|
104 | } else if(project->values("TEMPLATE").first() == "subdirs") {
|
---|
105 | MakefileGenerator::writeSubDirs(t);
|
---|
106 | return true;
|
---|
107 | }
|
---|
108 | return false;
|
---|
109 | }
|
---|
110 |
|
---|
111 | void
|
---|
112 | UnixMakefileGenerator::writeMakeParts(QTextStream &t)
|
---|
113 | {
|
---|
114 | QString deps = fileFixify(Option::output.fileName()), target_deps, prl;
|
---|
115 | bool do_incremental = (project->isActiveConfig("incremental") &&
|
---|
116 | !project->values("QMAKE_INCREMENTAL").isEmpty() &&
|
---|
117 | (!project->values("QMAKE_APP_FLAG").isEmpty() ||
|
---|
118 | (!project->isActiveConfig("staticlib")))),
|
---|
119 | src_incremental=false;
|
---|
120 |
|
---|
121 | t << "####### Compiler, tools and options" << endl << endl;
|
---|
122 | t << "CC = " << var("QMAKE_CC") << endl;
|
---|
123 | t << "CXX = " << var("QMAKE_CXX") << endl;
|
---|
124 | t << "DEFINES = "
|
---|
125 | << varGlue("PRL_EXPORT_DEFINES","-D"," -D"," ")
|
---|
126 | << varGlue("DEFINES","-D"," -D","") << endl;
|
---|
127 | t << "CFLAGS = " << var("QMAKE_CFLAGS") << " $(DEFINES)" << endl;
|
---|
128 | t << "CXXFLAGS = " << var("QMAKE_CXXFLAGS") << " $(DEFINES)" << endl;
|
---|
129 | t << "INCPATH = " << "-I" << specdir();
|
---|
130 | if(!project->isActiveConfig("no_include_pwd")) {
|
---|
131 | QString pwd = escapeFilePath(fileFixify(qmake_getpwd()));
|
---|
132 | if(pwd.isEmpty())
|
---|
133 | pwd = ".";
|
---|
134 | t << " -I" << pwd;
|
---|
135 | }
|
---|
136 | {
|
---|
137 | const QStringList &incs = project->values("INCLUDEPATH");
|
---|
138 | for(int i = 0; i < incs.size(); ++i) {
|
---|
139 | QString inc = escapeFilePath(incs.at(i));
|
---|
140 | if(!inc.isEmpty())
|
---|
141 | t << " " << "-I" << inc;
|
---|
142 | }
|
---|
143 | }
|
---|
144 | if(!project->isEmpty("QMAKE_FRAMEWORKPATH_FLAGS"))
|
---|
145 | t << " " << var("QMAKE_FRAMEWORKPATH_FLAGS");
|
---|
146 | t << endl;
|
---|
147 |
|
---|
148 | if(!project->isActiveConfig("staticlib")) {
|
---|
149 | t << "LINK = " << var("QMAKE_LINK") << endl;
|
---|
150 | t << "LFLAGS = " << var("QMAKE_LFLAGS") << endl;
|
---|
151 | t << "LIBS = " << "$(SUBLIBS) " << var("QMAKE_FRAMEWORKPATH_FLAGS") << " "
|
---|
152 | << var("QMAKE_LIBDIR_FLAGS") << " " << var("QMAKE_LIBS") << " " << var("QMAKE_LIBS_PRIVATE") << endl;
|
---|
153 | }
|
---|
154 |
|
---|
155 | t << "AR = " << var("QMAKE_AR") << endl;
|
---|
156 | t << "RANLIB = " << var("QMAKE_RANLIB") << endl;
|
---|
157 | t << "QMAKE = " << var("QMAKE_QMAKE") << endl;
|
---|
158 | t << "TAR = " << var("QMAKE_TAR") << endl;
|
---|
159 | t << "COMPRESS = " << var("QMAKE_GZIP") << endl;
|
---|
160 | if(project->isActiveConfig("compile_libtool"))
|
---|
161 | t << "LIBTOOL = " << var("QMAKE_LIBTOOL") << endl;
|
---|
162 | t << "COPY = " << var("QMAKE_COPY") << endl;
|
---|
163 | t << "SED = " << var("QMAKE_STREAM_EDITOR") << endl;
|
---|
164 | t << "COPY_FILE = " << var("QMAKE_COPY_FILE") << endl;
|
---|
165 | t << "COPY_DIR = " << var("QMAKE_COPY_DIR") << endl;
|
---|
166 | t << "STRIP = " << var("QMAKE_STRIP") << endl;
|
---|
167 | t << "INSTALL_FILE = " << var("QMAKE_INSTALL_FILE") << endl;
|
---|
168 | t << "INSTALL_DIR = " << var("QMAKE_INSTALL_DIR") << endl;
|
---|
169 | t << "INSTALL_PROGRAM = " << var("QMAKE_INSTALL_PROGRAM") << endl;
|
---|
170 |
|
---|
171 | t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl;
|
---|
172 | t << "SYMLINK = " << var("QMAKE_SYMBOLIC_LINK") << endl;
|
---|
173 | t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl;
|
---|
174 | t << "MOVE = " << var("QMAKE_MOVE") << endl;
|
---|
175 | t << "CHK_DIR_EXISTS= " << var("QMAKE_CHK_DIR_EXISTS") << endl;
|
---|
176 | t << "MKDIR = " << var("QMAKE_MKDIR") << endl;
|
---|
177 | if(!project->isEmpty("QMAKE_MACOSX_DEPLOYMENT_TARGET"))
|
---|
178 | t << "export MACOSX_DEPLOYMENT_TARGET = " //exported to children processes
|
---|
179 | << project->first("QMAKE_MACOSX_DEPLOYMENT_TARGET") << endl;
|
---|
180 |
|
---|
181 | if (!project->isEmpty("QMAKE_SYMBIAN_SHLIB")) {
|
---|
182 | t << "vpath %.dso " << project->values("QMAKE_LIBDIR").join(":") << endl;
|
---|
183 | t << "vpath %.lib " << project->values("QMAKE_LIBDIR").join(":") << endl;
|
---|
184 | }
|
---|
185 |
|
---|
186 | t << endl;
|
---|
187 |
|
---|
188 | t << "####### Output directory" << endl << endl;
|
---|
189 | if (! project->values("OBJECTS_DIR").isEmpty())
|
---|
190 | t << "OBJECTS_DIR = " << var("OBJECTS_DIR") << endl;
|
---|
191 | else
|
---|
192 | t << "OBJECTS_DIR = ./" << endl;
|
---|
193 | t << endl;
|
---|
194 |
|
---|
195 | /* files */
|
---|
196 | t << "####### Files" << endl << endl;
|
---|
197 | t << "SOURCES = " << valList(escapeFilePaths(project->values("SOURCES"))) << " "
|
---|
198 | << valList(escapeFilePaths(project->values("GENERATED_SOURCES"))) << endl;
|
---|
199 | if(do_incremental) {
|
---|
200 | QStringList &objs = project->values("OBJECTS"), &incrs = project->values("QMAKE_INCREMENTAL"), incrs_out;
|
---|
201 | t << "OBJECTS = ";
|
---|
202 | for(QStringList::Iterator objit = objs.begin(); objit != objs.end(); ++objit) {
|
---|
203 | bool increment = false;
|
---|
204 | for(QStringList::Iterator incrit = incrs.begin(); incrit != incrs.end(); ++incrit) {
|
---|
205 | if((*objit).indexOf(QRegExp((*incrit), Qt::CaseSensitive,
|
---|
206 | QRegExp::Wildcard)) != -1) {
|
---|
207 | increment = true;
|
---|
208 | incrs_out.append((*objit));
|
---|
209 | break;
|
---|
210 | }
|
---|
211 | }
|
---|
212 | if(!increment)
|
---|
213 | t << "\\\n\t\t" << (*objit);
|
---|
214 | }
|
---|
215 | if(incrs_out.count() == objs.count()) { //we just switched places, no real incrementals to be done!
|
---|
216 | t << escapeFilePaths(incrs_out).join(" \\\n\t\t") << endl;
|
---|
217 | } else if(!incrs_out.count()) {
|
---|
218 | t << endl;
|
---|
219 | } else {
|
---|
220 | src_incremental = true;
|
---|
221 | t << endl;
|
---|
222 | t << "INCREMENTAL_OBJECTS = " << escapeFilePaths(incrs_out).join(" \\\n\t\t") << endl;
|
---|
223 | }
|
---|
224 | } else {
|
---|
225 | t << "OBJECTS = " << valList(escapeFilePaths(project->values("OBJECTS"))) << endl;
|
---|
226 | }
|
---|
227 | if(do_incremental && !src_incremental)
|
---|
228 | do_incremental = false;
|
---|
229 | t << "DIST = " << valList(fileFixify(project->values("DISTFILES"))) << endl;
|
---|
230 | t << "QMAKE_TARGET = " << var("QMAKE_ORIG_TARGET") << endl;
|
---|
231 | t << "DESTDIR = " << var("DESTDIR") << endl;
|
---|
232 | if(project->isActiveConfig("compile_libtool"))
|
---|
233 | t << "TARGETL = " << var("TARGET_la") << endl;
|
---|
234 | t << "TARGET = " << escapeFilePath(var("TARGET")) << endl;
|
---|
235 | if(project->isActiveConfig("plugin")) {
|
---|
236 | t << "TARGETD = " << escapeFilePath(var("TARGET")) << endl;
|
---|
237 | } else if(!project->isActiveConfig("staticlib") && project->values("QMAKE_APP_FLAG").isEmpty()) {
|
---|
238 | t << "TARGETA = " << escapeFilePath(var("TARGETA")) << endl;
|
---|
239 | if(!project->isEmpty("QMAKE_BUNDLE")) {
|
---|
240 | t << "TARGETD = " << escapeFilePath(var("TARGET_x.y")) << endl;
|
---|
241 | t << "TARGET0 = " << escapeFilePath(var("TARGET_")) << endl;
|
---|
242 | } else if(!project->isEmpty("QMAKE_SYMBIAN_SHLIB")) {
|
---|
243 | t << "TARGETD = " << escapeFilePath(var("TARGET")) << endl;
|
---|
244 | } else if(project->isEmpty("QMAKE_HPUX_SHLIB")) {
|
---|
245 | t << "TARGETD = " << escapeFilePath(var("TARGET_x.y.z")) << endl;
|
---|
246 | t << "TARGET0 = " << escapeFilePath(var("TARGET_")) << endl;
|
---|
247 | t << "TARGET1 = " << escapeFilePath(var("TARGET_x")) << endl;
|
---|
248 | t << "TARGET2 = " << escapeFilePath(var("TARGET_x.y")) << endl;
|
---|
249 | } else {
|
---|
250 | t << "TARGETD = " << escapeFilePath(var("TARGET_x")) << endl;
|
---|
251 | t << "TARGET0 = " << escapeFilePath(var("TARGET_")) << endl;
|
---|
252 | }
|
---|
253 | }
|
---|
254 | writeExtraCompilerVariables(t);
|
---|
255 | writeExtraVariables(t);
|
---|
256 | t << endl;
|
---|
257 |
|
---|
258 | // blasted includes
|
---|
259 | QStringList &qeui = project->values("QMAKE_EXTRA_INCLUDES");
|
---|
260 | QStringList::Iterator it;
|
---|
261 | for(it = qeui.begin(); it != qeui.end(); ++it)
|
---|
262 | t << "include " << (*it) << endl;
|
---|
263 |
|
---|
264 | /* rules */
|
---|
265 | t << "first: all" << endl;
|
---|
266 | t << "####### Implicit rules" << endl << endl;
|
---|
267 | t << ".SUFFIXES: " << Option::obj_ext;
|
---|
268 | for(QStringList::Iterator cit = Option::c_ext.begin(); cit != Option::c_ext.end(); ++cit)
|
---|
269 | t << " " << (*cit);
|
---|
270 | for(QStringList::Iterator cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
|
---|
271 | t << " " << (*cppit);
|
---|
272 | t << endl << endl;
|
---|
273 | for(QStringList::Iterator cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
|
---|
274 | t << (*cppit) << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
|
---|
275 | for(QStringList::Iterator cit = Option::c_ext.begin(); cit != Option::c_ext.end(); ++cit)
|
---|
276 | t << (*cit) << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;
|
---|
277 |
|
---|
278 | if(include_deps) {
|
---|
279 | QString cmd=var("QMAKE_CFLAGS_DEPS") + " ";
|
---|
280 | cmd += varGlue("DEFINES","-D"," -D","") + varGlue("PRL_EXPORT_DEFINES"," -D"," -D","");
|
---|
281 | if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH"))
|
---|
282 | cmd += " -I" + project->first("QMAKE_ABSOLUTE_SOURCE_PATH") + " ";
|
---|
283 | cmd += " $(INCPATH) " + varGlue("DEPENDPATH", "-I", " -I", "");
|
---|
284 | QString odir;
|
---|
285 | if(!project->values("OBJECTS_DIR").isEmpty())
|
---|
286 | odir = project->first("OBJECTS_DIR");
|
---|
287 | t << "###### Dependencies" << endl << endl;
|
---|
288 | t << odir << ".deps/%.d: %.cpp\n\t";
|
---|
289 | if(project->isActiveConfig("echo_depend_creation"))
|
---|
290 | t << "@echo Creating depend for $<" << "\n\t";
|
---|
291 | t << mkdir_p_asstring("$(@D)") << "\n\t"
|
---|
292 | << "@$(CXX) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl;
|
---|
293 |
|
---|
294 | t << odir << ".deps/%.d: %.c\n\t";
|
---|
295 | if(project->isActiveConfig("echo_depend_creation"))
|
---|
296 | t << "@echo Creating depend for $<" << "\n\t";
|
---|
297 | t << mkdir_p_asstring("$(@D)") << "\n\t"
|
---|
298 | << "@$(CC) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl;
|
---|
299 |
|
---|
300 | QString src[] = { "SOURCES", "GENERATED_SOURCES", QString() };
|
---|
301 | for(int x = 0; !src[x].isNull(); x++) {
|
---|
302 | QStringList &l = project->values(src[x]);
|
---|
303 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
|
---|
304 | if(!(*it).isEmpty()) {
|
---|
305 | QString d_file;
|
---|
306 | for(QStringList::Iterator cit = Option::c_ext.begin();
|
---|
307 | cit != Option::c_ext.end(); ++cit) {
|
---|
308 | if((*it).endsWith((*cit))) {
|
---|
309 | d_file = (*it).left((*it).length() - (*cit).length());
|
---|
310 | break;
|
---|
311 | }
|
---|
312 | }
|
---|
313 | if(d_file.isEmpty()) {
|
---|
314 | for(QStringList::Iterator cppit = Option::cpp_ext.begin();
|
---|
315 | cppit != Option::cpp_ext.end(); ++cppit) {
|
---|
316 | if((*it).endsWith((*cppit))) {
|
---|
317 | d_file = (*it).left((*it).length() - (*cppit).length());
|
---|
318 | break;
|
---|
319 | }
|
---|
320 | }
|
---|
321 | }
|
---|
322 | if(!d_file.isEmpty()) {
|
---|
323 | d_file = odir + ".deps/" + d_file + ".d";
|
---|
324 | QStringList deps = findDependencies((*it)).filter(QRegExp(Option::cpp_moc_ext + "$"));
|
---|
325 | if(!deps.isEmpty())
|
---|
326 | t << d_file << ": " << deps.join(" ") << endl;
|
---|
327 | t << "-include " << d_file << endl;
|
---|
328 | project->values("QMAKE_DISTCLEAN") += d_file;
|
---|
329 | }
|
---|
330 | }
|
---|
331 | }
|
---|
332 | }
|
---|
333 | }
|
---|
334 |
|
---|
335 | t << "####### Build rules" << endl << endl;
|
---|
336 | if(!project->values("SUBLIBS").isEmpty()) {
|
---|
337 | QString libdir = "tmp/";
|
---|
338 | if(!project->isEmpty("SUBLIBS_DIR"))
|
---|
339 | libdir = project->first("SUBLIBS_DIR");
|
---|
340 | t << "SUBLIBS = ";
|
---|
341 | QStringList &l = project->values("SUBLIBS");
|
---|
342 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it)
|
---|
343 | t << libdir << project->first("QMAKE_PREFIX_STATICLIB") << (*it) << "."
|
---|
344 | << project->first("QMAKE_EXTENSION_STATICLIB") << " ";
|
---|
345 | t << endl << endl;
|
---|
346 | }
|
---|
347 | if(project->isActiveConfig("depend_prl") && !project->isEmpty("QMAKE_PRL_INTERNAL_FILES")) {
|
---|
348 | QStringList &l = project->values("QMAKE_PRL_INTERNAL_FILES");
|
---|
349 | QStringList::Iterator it;
|
---|
350 | for(it = l.begin(); it != l.end(); ++it) {
|
---|
351 | QMakeMetaInfo libinfo;
|
---|
352 | if(libinfo.readLib((*it)) && !libinfo.isEmpty("QMAKE_PRL_BUILD_DIR")) {
|
---|
353 | QString dir;
|
---|
354 | int slsh = (*it).lastIndexOf(Option::dir_sep);
|
---|
355 | if(slsh != -1)
|
---|
356 | dir = (*it).left(slsh + 1);
|
---|
357 | QString targ = dir + libinfo.first("QMAKE_PRL_TARGET");
|
---|
358 | target_deps += " " + targ;
|
---|
359 | t << targ << ":" << "\n\t"
|
---|
360 | << "@echo \"Creating '" << targ << "'\"" << "\n\t"
|
---|
361 | << "(cd " << libinfo.first("QMAKE_PRL_BUILD_DIR") << ";"
|
---|
362 | << "$(MAKE))" << endl;
|
---|
363 | }
|
---|
364 | }
|
---|
365 | }
|
---|
366 | if(!project->values("QMAKE_APP_FLAG").isEmpty()) {
|
---|
367 | QString destdir = project->first("DESTDIR");
|
---|
368 | if(!project->isEmpty("QMAKE_BUNDLE")) {
|
---|
369 | QString bundle_loc = project->first("QMAKE_BUNDLE_LOCATION");
|
---|
370 | if(!bundle_loc.isEmpty() && !bundle_loc.startsWith("/"))
|
---|
371 | bundle_loc.prepend("/");
|
---|
372 | if(!bundle_loc.endsWith("/"))
|
---|
373 | bundle_loc += "/";
|
---|
374 | destdir += project->first("QMAKE_BUNDLE") + bundle_loc;
|
---|
375 | }
|
---|
376 | if(do_incremental) {
|
---|
377 | //incremental target
|
---|
378 | QString incr_target = var("TARGET") + "_incremental";
|
---|
379 | if(incr_target.indexOf(Option::dir_sep) != -1)
|
---|
380 | incr_target = incr_target.right(incr_target.length() -
|
---|
381 | (incr_target.lastIndexOf(Option::dir_sep) + 1));
|
---|
382 | QString incr_deps, incr_objs;
|
---|
383 | if(project->first("QMAKE_INCREMENTAL_STYLE") == "ld") {
|
---|
384 | QString incr_target_dir = var("OBJECTS_DIR") + incr_target + Option::obj_ext;
|
---|
385 | //actual target
|
---|
386 | t << incr_target_dir << ": $(OBJECTS)" << "\n\t"
|
---|
387 | << "ld -r -o "<< incr_target_dir << " $(OBJECTS)" << endl;
|
---|
388 | //communicated below
|
---|
389 | deps.prepend(incr_target_dir + " ");
|
---|
390 | incr_deps = "$(INCREMENTAL_OBJECTS)";
|
---|
391 | if(!incr_objs.isEmpty())
|
---|
392 | incr_objs += " ";
|
---|
393 | incr_objs += incr_target_dir;
|
---|
394 | } else {
|
---|
395 | //actual target
|
---|
396 | QString incr_target_dir = var("DESTDIR") + "lib" + incr_target + "." +
|
---|
397 | project->values("QMAKE_EXTENSION_SHLIB").first();
|
---|
398 | QString incr_lflags = var("QMAKE_LFLAGS_SHLIB") + " ";
|
---|
399 | if(project->isActiveConfig("debug"))
|
---|
400 | incr_lflags += var("QMAKE_LFLAGS_DEBUG");
|
---|
401 | else
|
---|
402 | incr_lflags += var("QMAKE_LFLAGS_RELEASE");
|
---|
403 | t << incr_target_dir << ": $(INCREMENTAL_OBJECTS)" << "\n\t";
|
---|
404 | if(!destdir.isEmpty())
|
---|
405 | t << "\n\t" << mkdir_p_asstring(destdir) << "\n\t";
|
---|
406 | t << "$(LINK) " << incr_lflags << " -o "<< incr_target_dir <<
|
---|
407 | " $(INCREMENTAL_OBJECTS)" << endl;
|
---|
408 | //communicated below
|
---|
409 | if(!destdir.isEmpty()) {
|
---|
410 | if(!incr_objs.isEmpty())
|
---|
411 | incr_objs += " ";
|
---|
412 | incr_objs += "-L" + destdir;
|
---|
413 | } else {
|
---|
414 | if(!incr_objs.isEmpty())
|
---|
415 | incr_objs += " ";
|
---|
416 | incr_objs += "-L" + qmake_getpwd();
|
---|
417 | }
|
---|
418 | if(!incr_objs.isEmpty())
|
---|
419 | incr_objs += " ";
|
---|
420 | incr_objs += " -l" + incr_target;
|
---|
421 | deps.prepend(incr_target_dir + " ");
|
---|
422 | incr_deps = "$(OBJECTS)";
|
---|
423 | }
|
---|
424 | t << "all: " << escapeDependencyPath(deps) << " " << valGlue(escapeDependencyPaths(project->values("ALL_DEPS")),""," "," ") << "$(TARGET)"
|
---|
425 | << endl << endl;
|
---|
426 |
|
---|
427 | //real target
|
---|
428 | t << var("TARGET") << ": " << var("PRE_TARGETDEPS") << " " << incr_deps << " " << target_deps
|
---|
429 | << " " << var("POST_TARGETDEPS") << "\n\t";
|
---|
430 | if(!destdir.isEmpty())
|
---|
431 | t << "\n\t" << mkdir_p_asstring(destdir) << "\n\t";
|
---|
432 | if(!project->isEmpty("QMAKE_PRE_LINK"))
|
---|
433 | t << var("QMAKE_PRE_LINK") << "\n\t";
|
---|
434 | t << "$(LINK) $(LFLAGS) -o $(TARGET) " << incr_deps << " " << incr_objs << " $(OBJCOMP) $(LIBS)";
|
---|
435 | if(!project->isEmpty("QMAKE_POST_LINK"))
|
---|
436 | t << "\n\t" << var("QMAKE_POST_LINK");
|
---|
437 | t << endl << endl;
|
---|
438 | } else {
|
---|
439 | t << "all: " << escapeDependencyPath(deps) << " " << valGlue(escapeDependencyPaths(project->values("ALL_DEPS")),""," "," ") << "$(TARGET)"
|
---|
440 | << endl << endl;
|
---|
441 |
|
---|
442 | t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(OBJECTS) "
|
---|
443 | << target_deps << " " << var("POST_TARGETDEPS") << "\n\t";
|
---|
444 | if(!destdir.isEmpty())
|
---|
445 | t << mkdir_p_asstring(destdir) << "\n\t";
|
---|
446 | if(!project->isEmpty("QMAKE_PRE_LINK"))
|
---|
447 | t << var("QMAKE_PRE_LINK") << "\n\t";
|
---|
448 | t << "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)";
|
---|
449 | if(!project->isEmpty("QMAKE_POST_LINK"))
|
---|
450 | t << "\n\t" << var("QMAKE_POST_LINK");
|
---|
451 | t << endl << endl;
|
---|
452 | }
|
---|
453 | } else if(!project->isActiveConfig("staticlib")) {
|
---|
454 | QString destdir = unescapeFilePath(project->first("DESTDIR")), incr_deps;
|
---|
455 | if(!project->isEmpty("QMAKE_BUNDLE")) {
|
---|
456 | QString bundle_loc = project->first("QMAKE_BUNDLE_LOCATION");
|
---|
457 | if(!bundle_loc.isEmpty() && !bundle_loc.startsWith("/"))
|
---|
458 | bundle_loc.prepend("/");
|
---|
459 | if(!bundle_loc.endsWith("/"))
|
---|
460 | bundle_loc += "/";
|
---|
461 | destdir += project->first("QMAKE_BUNDLE") + bundle_loc;
|
---|
462 | }
|
---|
463 | destdir = escapeFilePath(destdir);
|
---|
464 |
|
---|
465 | if(do_incremental) {
|
---|
466 | QString s_ext = project->values("QMAKE_EXTENSION_SHLIB").first();
|
---|
467 | QString incr_target = var("QMAKE_ORIG_TARGET").replace(
|
---|
468 | QRegExp("\\." + s_ext), "").replace(QRegExp("^lib"), "") + "_incremental";
|
---|
469 | if(incr_target.indexOf(Option::dir_sep) != -1)
|
---|
470 | incr_target = incr_target.right(incr_target.length() -
|
---|
471 | (incr_target.lastIndexOf(Option::dir_sep) + 1));
|
---|
472 | incr_target = escapeFilePath(incr_target);
|
---|
473 |
|
---|
474 | if(project->first("QMAKE_INCREMENTAL_STYLE") == "ld") {
|
---|
475 | QString incr_target_dir = escapeFilePath(var("OBJECTS_DIR") + incr_target + Option::obj_ext);
|
---|
476 | //actual target
|
---|
477 | const QString link_deps = "$(OBJECTS) ";
|
---|
478 | t << incr_target_dir << ": " << link_deps << "\n\t"
|
---|
479 | << "ld -r -o " << incr_target_dir << " " << link_deps << endl;
|
---|
480 | //communicated below
|
---|
481 | QStringList &cmd = project->values("QMAKE_LINK_SHLIB_CMD");
|
---|
482 | cmd.first().replace("$(OBJECTS) ", "$(INCREMENTAL_OBJECTS)"); //ick
|
---|
483 | cmd.append(incr_target_dir);
|
---|
484 | deps.prepend(incr_target_dir + " ");
|
---|
485 | incr_deps = "$(INCREMENTAL_OBJECTS)";
|
---|
486 | } else {
|
---|
487 | //actual target
|
---|
488 | QString incr_target_dir = escapeFilePath(destdir + "lib" + incr_target + "." + s_ext);
|
---|
489 | QString incr_lflags = var("QMAKE_LFLAGS_SHLIB") + " ";
|
---|
490 | if(!project->isEmpty("QMAKE_LFLAGS_INCREMENTAL"))
|
---|
491 | incr_lflags += var("QMAKE_LFLAGS_INCREMENTAL") + " ";
|
---|
492 | if(project->isActiveConfig("debug"))
|
---|
493 | incr_lflags += var("QMAKE_LFLAGS_DEBUG");
|
---|
494 | else
|
---|
495 | incr_lflags += var("QMAKE_LFLAGS_RELEASE");
|
---|
496 | t << incr_target_dir << ": $(INCREMENTAL_OBJECTS)" << "\n\t";
|
---|
497 | if(!destdir.isEmpty())
|
---|
498 | t << mkdir_p_asstring(destdir) << "\n\t";
|
---|
499 | t << "$(LINK) " << incr_lflags << " -o "<< incr_target_dir <<
|
---|
500 | " $(INCREMENTAL_OBJECTS)" << endl;
|
---|
501 | //communicated below
|
---|
502 | QStringList &cmd = project->values("QMAKE_LINK_SHLIB_CMD");
|
---|
503 | if(!destdir.isEmpty())
|
---|
504 | cmd.append(" -L" + destdir);
|
---|
505 | cmd.append(" -l" + incr_target);
|
---|
506 | deps.prepend(incr_target_dir + " ");
|
---|
507 | incr_deps = "$(OBJECTS)";
|
---|
508 | }
|
---|
509 |
|
---|
510 | t << "all: " << " " << escapeDependencyPath(deps) << " " << valGlue(escapeDependencyPaths(project->values("ALL_DEPS")),""," "," ")
|
---|
511 | << " " << destdir << "$(TARGET)" << endl << endl;
|
---|
512 |
|
---|
513 | //real target
|
---|
514 | t << destdir << "$(TARGET): " << var("PRE_TARGETDEPS") << " "
|
---|
515 | << incr_deps << " $(SUBLIBS) " << target_deps << " " << var("POST_TARGETDEPS");
|
---|
516 | } else {
|
---|
517 | t << "all: " << escapeDependencyPath(deps) << " " << valGlue(escapeDependencyPaths(project->values("ALL_DEPS")),""," "," ") << " " <<
|
---|
518 | destdir << "$(TARGET)" << endl << endl;
|
---|
519 | t << destdir << "$(TARGET): " << var("PRE_TARGETDEPS")
|
---|
520 | << " $(OBJECTS) $(SUBLIBS) $(OBJCOMP) " << target_deps
|
---|
521 | << " " << var("POST_TARGETDEPS");
|
---|
522 | }
|
---|
523 | if(!destdir.isEmpty())
|
---|
524 | t << "\n\t" << mkdir_p_asstring(destdir);
|
---|
525 | if(!project->isEmpty("QMAKE_PRE_LINK"))
|
---|
526 | t << "\n\t" << var("QMAKE_PRE_LINK");
|
---|
527 |
|
---|
528 | if(project->isActiveConfig("compile_libtool")) {
|
---|
529 | t << "\n\t"
|
---|
530 | << var("QMAKE_LINK_SHLIB_CMD");
|
---|
531 | } else if(project->isActiveConfig("plugin")) {
|
---|
532 | t << "\n\t"
|
---|
533 | << "-$(DEL_FILE) $(TARGET)" << "\n\t"
|
---|
534 | << var("QMAKE_LINK_SHLIB_CMD");
|
---|
535 | if(!destdir.isEmpty())
|
---|
536 | t << "\n\t"
|
---|
537 | << "-$(MOVE) $(TARGET) " << destdir;
|
---|
538 | if(!project->isEmpty("QMAKE_POST_LINK"))
|
---|
539 | t << "\n\t" << var("QMAKE_POST_LINK") << "\n\t";
|
---|
540 | t << endl << endl;
|
---|
541 | } else if(!project->isEmpty("QMAKE_BUNDLE")) {
|
---|
542 | t << "\n\t"
|
---|
543 | << "-$(DEL_FILE) $(TARGET) $(TARGET0) $(DESTDIR)$(TARGET0)" << "\n\t"
|
---|
544 | << var("QMAKE_LINK_SHLIB_CMD") << "\n\t"
|
---|
545 | << mkdir_p_asstring("\"`dirname $(DESTDIR)$(TARGETD)`\"", false) << "\n\t"
|
---|
546 | << "-$(MOVE) $(TARGET) $(DESTDIR)$(TARGETD)" << "\n\t"
|
---|
547 | << mkdir_p_asstring("\"`dirname $(DESTDIR)$(TARGET0)`\"", false) << "\n\t"
|
---|
548 | << varGlue("QMAKE_LN_SHLIB","-"," "," Versions/" +
|
---|
549 | project->first("QMAKE_FRAMEWORK_VERSION") +
|
---|
550 | "/$(TARGET) $(DESTDIR)$(TARGET0)") << "\n\t"
|
---|
551 | << "-$(DEL_FILE) " << destdir << "Versions/Current" << "\n\t"
|
---|
552 | << varGlue("QMAKE_LN_SHLIB","-"," ", " " + project->first("QMAKE_FRAMEWORK_VERSION") +
|
---|
553 | " " + destdir + "Versions/Current") << "\n\t";
|
---|
554 | if(!project->isEmpty("QMAKE_POST_LINK"))
|
---|
555 | t << "\n\t" << var("QMAKE_POST_LINK");
|
---|
556 | t << endl << endl;
|
---|
557 | } else if(!project->isEmpty("QMAKE_SYMBIAN_SHLIB")) {
|
---|
558 | t << "\n\t"
|
---|
559 | << "-$(DEL_FILE) $(TARGET)" << "\n\t"
|
---|
560 | << var("QMAKE_LINK_SHLIB_CMD");
|
---|
561 | if(!destdir.isEmpty())
|
---|
562 | t << "\n\t"
|
---|
563 | << "-$(DEL_FILE) " << destdir << "$(TARGET)\n\t"
|
---|
564 | << "-$(MOVE) $(TARGET) " << destdir;
|
---|
565 | if(!project->isEmpty("QMAKE_POST_LINK"))
|
---|
566 | t << "\n\t" << var("QMAKE_POST_LINK");
|
---|
567 | t << endl << endl;
|
---|
568 | } else if(project->isEmpty("QMAKE_HPUX_SHLIB")) {
|
---|
569 | t << "\n\t"
|
---|
570 | << "-$(DEL_FILE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2)" << "\n\t"
|
---|
571 | << var("QMAKE_LINK_SHLIB_CMD") << "\n\t";
|
---|
572 | t << varGlue("QMAKE_LN_SHLIB","-"," "," $(TARGET) $(TARGET0)") << "\n\t"
|
---|
573 | << varGlue("QMAKE_LN_SHLIB","-"," "," $(TARGET) $(TARGET1)") << "\n\t"
|
---|
574 | << varGlue("QMAKE_LN_SHLIB","-"," "," $(TARGET) $(TARGET2)");
|
---|
575 | if(!destdir.isEmpty())
|
---|
576 | t << "\n\t"
|
---|
577 | << "-$(DEL_FILE) " << destdir << "$(TARGET)\n\t"
|
---|
578 | << "-$(DEL_FILE) " << destdir << "$(TARGET0)\n\t"
|
---|
579 | << "-$(DEL_FILE) " << destdir << "$(TARGET1)\n\t"
|
---|
580 | << "-$(DEL_FILE) " << destdir << "$(TARGET2)\n\t"
|
---|
581 | << "-$(MOVE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) " << destdir;
|
---|
582 | if(!project->isEmpty("QMAKE_POST_LINK"))
|
---|
583 | t << "\n\t" << var("QMAKE_POST_LINK");
|
---|
584 | t << endl << endl;
|
---|
585 | } else {
|
---|
586 | t << "\n\t"
|
---|
587 | << "-$(DEL_FILE) $(TARGET) $(TARGET0)" << "\n\t"
|
---|
588 | << var("QMAKE_LINK_SHLIB_CMD") << "\n\t";
|
---|
589 | t << varGlue("QMAKE_LN_SHLIB",""," "," $(TARGET) $(TARGET0)");
|
---|
590 | if(!destdir.isEmpty())
|
---|
591 | t << "\n\t"
|
---|
592 | << "-$(DEL_FILE) " << destdir << "$(TARGET)\n\t"
|
---|
593 | << "-$(DEL_FILE) " << destdir << "$(TARGET0)\n\t"
|
---|
594 | << "-$(MOVE) $(TARGET) $(TARGET0) " << destdir;
|
---|
595 | if(!project->isEmpty("QMAKE_POST_LINK"))
|
---|
596 | t << "\n\t" << var("QMAKE_POST_LINK");
|
---|
597 | t << endl << endl;
|
---|
598 | }
|
---|
599 | t << endl << endl;
|
---|
600 |
|
---|
601 | if (! project->isActiveConfig("plugin")) {
|
---|
602 | t << "staticlib: $(TARGETA)" << endl << endl;
|
---|
603 | t << "$(TARGETA): " << var("PRE_TARGETDEPS") << " $(OBJECTS) $(OBJCOMP)";
|
---|
604 | if(do_incremental)
|
---|
605 | t << " $(INCREMENTAL_OBJECTS)";
|
---|
606 | t << " " << var("POST_TARGETDEPS") << "\n\t"
|
---|
607 | << "-$(DEL_FILE) $(TARGETA) " << "\n\t"
|
---|
608 | << var("QMAKE_AR_CMD");
|
---|
609 | if(do_incremental)
|
---|
610 | t << " $(INCREMENTAL_OBJECTS)";
|
---|
611 | if(!project->isEmpty("QMAKE_RANLIB"))
|
---|
612 | t << "\n\t" << "$(RANLIB) $(TARGETA)";
|
---|
613 | t << endl << endl;
|
---|
614 | }
|
---|
615 | } else {
|
---|
616 | QString destdir = project->first("DESTDIR");
|
---|
617 | t << "all: " << escapeDependencyPath(deps) << " " << valGlue(escapeDependencyPaths(project->values("ALL_DEPS")),""," "," ") << destdir << "$(TARGET) "
|
---|
618 | << varGlue("QMAKE_AR_SUBLIBS", destdir, " " + destdir, "") << "\n\n"
|
---|
619 | << "staticlib: " << destdir << "$(TARGET)" << "\n\n";
|
---|
620 | if(project->isEmpty("QMAKE_AR_SUBLIBS")) {
|
---|
621 | t << destdir << "$(TARGET): " << var("PRE_TARGETDEPS")
|
---|
622 | << " $(OBJECTS) $(OBJCOMP) " << var("POST_TARGETDEPS") << "\n\t";
|
---|
623 | if(!destdir.isEmpty())
|
---|
624 | t << mkdir_p_asstring(destdir) << "\n\t";
|
---|
625 | t << "-$(DEL_FILE) $(TARGET)" << "\n\t"
|
---|
626 | << var("QMAKE_AR_CMD") << "\n";
|
---|
627 | if(!project->isEmpty("QMAKE_POST_LINK"))
|
---|
628 | t << "\t" << var("QMAKE_POST_LINK") << "\n";
|
---|
629 | if(!project->isEmpty("QMAKE_RANLIB"))
|
---|
630 | t << "\t" << "$(RANLIB) $(TARGET)" << "\n";
|
---|
631 | if(!destdir.isEmpty())
|
---|
632 | t << "\t" << "-$(DEL_FILE) " << destdir << "$(TARGET)" << "\n"
|
---|
633 | << "\t" << "-$(MOVE) $(TARGET) " << destdir << "\n";
|
---|
634 | } else {
|
---|
635 | int max_files = project->first("QMAKE_MAX_FILES_PER_AR").toInt();
|
---|
636 | QStringList objs = project->values("OBJECTS") + project->values("OBJCOMP"),
|
---|
637 | libs = project->values("QMAKE_AR_SUBLIBS");
|
---|
638 | libs.prepend("$(TARGET)");
|
---|
639 | for(QStringList::Iterator libit = libs.begin(), objit = objs.begin();
|
---|
640 | libit != libs.end(); ++libit) {
|
---|
641 | QStringList build;
|
---|
642 | for(int cnt = 0; cnt < max_files && objit != objs.end(); ++objit, cnt++)
|
---|
643 | build << (*objit);
|
---|
644 | QString ar;
|
---|
645 | if((*libit) == "$(TARGET)") {
|
---|
646 | t << destdir << "$(TARGET): " << var("PRE_TARGETDEPS")
|
---|
647 | << " " << var("POST_TARGETDEPS") << valList(build) << "\n\t";
|
---|
648 | ar = project->values("QMAKE_AR_CMD").first();
|
---|
649 | ar = ar.replace("$(OBJECTS)", build.join(" "));
|
---|
650 | } else {
|
---|
651 | t << (*libit) << ": " << valList(build) << "\n\t";
|
---|
652 | ar = "$(AR) " + (*libit) + " " + build.join(" ");
|
---|
653 | }
|
---|
654 | if(!destdir.isEmpty())
|
---|
655 | t << mkdir_p_asstring(destdir) << "\n\t";
|
---|
656 | t << "-$(DEL_FILE) " << (*libit) << "\n\t"
|
---|
657 | << ar << "\n";
|
---|
658 | if(!project->isEmpty("QMAKE_POST_LINK"))
|
---|
659 | t << "\t" << var("QMAKE_POST_LINK") << "\n";
|
---|
660 | if(!project->isEmpty("QMAKE_RANLIB"))
|
---|
661 | t << "\t" << "$(RANLIB) " << (*libit) << "\n";
|
---|
662 | if(!destdir.isEmpty())
|
---|
663 | t << "\t" << "-$(DEL_FILE) " << destdir << (*libit) << "\n"
|
---|
664 | << "\t" << "-$(MOVE) " << (*libit) << " " << destdir << "\n";
|
---|
665 | }
|
---|
666 | }
|
---|
667 | t << endl << endl;
|
---|
668 | }
|
---|
669 |
|
---|
670 | writeMakeQmake(t);
|
---|
671 | if(project->isEmpty("QMAKE_FAILED_REQUIREMENTS") && !project->isActiveConfig("no_autoqmake")) {
|
---|
672 | QString meta_files;
|
---|
673 | if(project->isActiveConfig("create_libtool") && project->first("TEMPLATE") == "lib" &&
|
---|
674 | !project->isActiveConfig("compile_libtool")) { //libtool
|
---|
675 | if(!meta_files.isEmpty())
|
---|
676 | meta_files += " ";
|
---|
677 | meta_files += libtoolFileName();
|
---|
678 | }
|
---|
679 | if(project->isActiveConfig("create_pc") && project->first("TEMPLATE") == "lib") { //pkg-config
|
---|
680 | if(!meta_files.isEmpty())
|
---|
681 | meta_files += " ";
|
---|
682 | meta_files += pkgConfigFileName();
|
---|
683 | }
|
---|
684 | if(!meta_files.isEmpty())
|
---|
685 | t << escapeDependencyPath(meta_files) << ": " << "\n\t"
|
---|
686 | << "@$(QMAKE) -prl " << buildArgs() << " " << project->projectFile() << endl;
|
---|
687 | }
|
---|
688 |
|
---|
689 | if(!project->first("QMAKE_PKGINFO").isEmpty()) {
|
---|
690 | QString pkginfo = escapeFilePath(project->first("QMAKE_PKGINFO"));
|
---|
691 | QString destdir = escapeFilePath(project->first("DESTDIR") + project->first("QMAKE_BUNDLE") + "/Contents");
|
---|
692 | t << pkginfo << ": " << "\n\t";
|
---|
693 | if(!destdir.isEmpty())
|
---|
694 | t << mkdir_p_asstring(destdir) << "\n\t";
|
---|
695 | t << "@$(DEL_FILE) " << pkginfo << "\n\t"
|
---|
696 | << "@echo \"APPL"
|
---|
697 | << (project->isEmpty("QMAKE_PKGINFO_TYPEINFO") ? QString::fromLatin1("????") : project->first("QMAKE_PKGINFO_TYPEINFO").left(4))
|
---|
698 | << "\" >" << pkginfo << endl;
|
---|
699 | }
|
---|
700 | if(!project->first("QMAKE_BUNDLE_RESOURCE_FILE").isEmpty()) {
|
---|
701 | QString resources = escapeFilePath(project->first("QMAKE_BUNDLE_RESOURCE_FILE"));
|
---|
702 | QString destdir = escapeFilePath(project->first("DESTDIR") + project->first("QMAKE_BUNDLE") + "/Contents/Resources");
|
---|
703 | t << resources << ": " << "\n\t";
|
---|
704 | t << mkdir_p_asstring(destdir) << "\n\t";
|
---|
705 | t << "@touch " << resources << "\n\t" << endl;
|
---|
706 | }
|
---|
707 | if(!project->isEmpty("QMAKE_BUNDLE")) {
|
---|
708 | //copy the plist
|
---|
709 | QString info_plist = escapeFilePath(fileFixify(project->first("QMAKE_INFO_PLIST"))),
|
---|
710 | info_plist_out = escapeFilePath(project->first("QMAKE_INFO_PLIST_OUT"));
|
---|
711 | QString destdir = info_plist_out.section(Option::dir_sep, 0, -2);
|
---|
712 | t << info_plist_out << ": " << "\n\t";
|
---|
713 | if(!destdir.isEmpty())
|
---|
714 | t << mkdir_p_asstring(destdir) << "\n\t";
|
---|
715 | if(project->first("TEMPLATE") == "app") {
|
---|
716 | QString icon = fileFixify(var("ICON"));
|
---|
717 | t << "@$(DEL_FILE) " << info_plist_out << "\n\t"
|
---|
718 | << "@sed "
|
---|
719 | << "-e \"s,@ICON@," << icon.section(Option::dir_sep, -1) << ",g\" "
|
---|
720 | << "-e \"s,@EXECUTABLE@," << var("QMAKE_ORIG_TARGET") << ",g\" "
|
---|
721 | << "-e \"s,@TYPEINFO@,"<< (project->isEmpty("QMAKE_PKGINFO_TYPEINFO") ?
|
---|
722 | QString::fromLatin1("????") : project->first("QMAKE_PKGINFO_TYPEINFO").left(4)) << ",g\" "
|
---|
723 | << "" << info_plist << " >" << info_plist_out << endl;
|
---|
724 | //copy the icon
|
---|
725 | if(!project->isEmpty("ICON")) {
|
---|
726 | QString dir = project->first("DESTDIR") + project->first("QMAKE_BUNDLE") + "/Contents/Resources/";
|
---|
727 | const QString icon_path = escapeFilePath(dir + icon.section(Option::dir_sep, -1));
|
---|
728 | t << icon_path << ": " << icon << "\n\t"
|
---|
729 | << mkdir_p_asstring(dir) << "\n\t"
|
---|
730 | << "@$(DEL_FILE) " << icon_path << "\n\t"
|
---|
731 | << "@$(COPY_FILE) " << escapeFilePath(icon) << " " << icon_path << endl;
|
---|
732 | }
|
---|
733 | } else {
|
---|
734 | t << "@$(DEL_FILE) " << info_plist_out << "\n\t"
|
---|
735 | << "@sed "
|
---|
736 | << "-e \"s,@LIBRARY@," << var("QMAKE_ORIG_TARGET") << ",g\" "
|
---|
737 | << "-e \"s,@SHORT_VERSION@," << project->first("VER_MAJ") << "." << project->first("VER_MIN") << ",g\" "
|
---|
738 | << "-e \"s,@TYPEINFO@,"
|
---|
739 | << (project->isEmpty("QMAKE_PKGINFO_TYPEINFO") ?
|
---|
740 | QString::fromLatin1("????") : project->first("QMAKE_PKGINFO_TYPEINFO").left(4)) << ",g\" "
|
---|
741 | << "" << info_plist << " >" << info_plist_out << endl;
|
---|
742 | }
|
---|
743 | //copy other data
|
---|
744 | if(!project->isEmpty("QMAKE_BUNDLE_DATA")) {
|
---|
745 | QString bundle_dir = project->first("DESTDIR") + project->first("QMAKE_BUNDLE") + "/";
|
---|
746 | const QStringList &bundle_data = project->values("QMAKE_BUNDLE_DATA");
|
---|
747 | for(int i = 0; i < bundle_data.count(); i++) {
|
---|
748 | const QStringList &files = project->values(bundle_data[i] + ".files");
|
---|
749 | QString path = bundle_dir;
|
---|
750 | if(!project->isEmpty(bundle_data[i] + ".version")) {
|
---|
751 | QString version = project->first(bundle_data[i] + ".version") + "/" +
|
---|
752 | project->first("QMAKE_FRAMEWORK_VERSION") + "/";
|
---|
753 | t << Option::fixPathToLocalOS(path + project->first(bundle_data[i] + ".path")) << ": " << "\n\t"
|
---|
754 | << mkdir_p_asstring(path) << "\n\t"
|
---|
755 | << "@$(SYMLINK) " << version << project->first(bundle_data[i] + ".path") << " " << path << endl;
|
---|
756 | path += version;
|
---|
757 | }
|
---|
758 | path += project->first(bundle_data[i] + ".path");
|
---|
759 | path = Option::fixPathToLocalOS(path);
|
---|
760 | for(int file = 0; file < files.count(); file++) {
|
---|
761 | QString src = fileFixify(files[file], FileFixifyAbsolute);
|
---|
762 | if (!QFile::exists(src))
|
---|
763 | src = files[file];
|
---|
764 | src = escapeFilePath(src);
|
---|
765 | const QString dst = escapeFilePath(path + Option::dir_sep + fileInfo(files[file]).fileName());
|
---|
766 | t << dst << ": " << src << "\n\t"
|
---|
767 | << mkdir_p_asstring(path) << "\n\t";
|
---|
768 | QFileInfo fi(fileInfo(files[file]));
|
---|
769 | if(fi.isDir())
|
---|
770 | t << "@$(DEL_FILE) -r " << dst << "\n\t"
|
---|
771 | << "@$(COPY_DIR) " << src << " " << dst << endl;
|
---|
772 | else
|
---|
773 | t << "@$(DEL_FILE) " << dst << "\n\t"
|
---|
774 | << "@$(COPY_FILE) " << src << " " << dst << endl;
|
---|
775 | }
|
---|
776 | }
|
---|
777 | }
|
---|
778 | }
|
---|
779 |
|
---|
780 | QString ddir;
|
---|
781 | QString packageName(project->first("QMAKE_ORIG_TARGET"));
|
---|
782 | if(!project->isActiveConfig("no_dist_version"))
|
---|
783 | packageName += var("VERSION");
|
---|
784 | if (project->isEmpty("QMAKE_DISTDIR"))
|
---|
785 | ddir = packageName;
|
---|
786 | else
|
---|
787 | ddir = project->first("QMAKE_DISTDIR");
|
---|
788 |
|
---|
789 | QString ddir_c = escapeFilePath(fileFixify((project->isEmpty("OBJECTS_DIR") ? QString(".tmp/") :
|
---|
790 | project->first("OBJECTS_DIR")) + ddir));
|
---|
791 | t << "dist: " << "\n\t"
|
---|
792 | << mkdir_p_asstring(ddir_c) << "\n\t"
|
---|
793 | << "$(COPY_FILE) --parents $(SOURCES) $(DIST) " << ddir_c << Option::dir_sep << " && ";
|
---|
794 | if(!project->isEmpty("QMAKE_EXTRA_COMPILERS")) {
|
---|
795 | const QStringList &quc = project->values("QMAKE_EXTRA_COMPILERS");
|
---|
796 | for(QStringList::ConstIterator it = quc.begin(); it != quc.end(); ++it) {
|
---|
797 | const QStringList &var = project->values((*it)+".input");
|
---|
798 | for(QStringList::ConstIterator var_it = var.begin(); var_it != var.end(); ++var_it) {
|
---|
799 | const QStringList &val = project->values((*var_it));
|
---|
800 | if(val.isEmpty())
|
---|
801 | continue;
|
---|
802 | t << "$(COPY_FILE) --parents " << val.join(" ") << " " << ddir_c << Option::dir_sep << " && ";
|
---|
803 | }
|
---|
804 | }
|
---|
805 | }
|
---|
806 | if(!project->isEmpty("TRANSLATIONS"))
|
---|
807 | t << "$(COPY_FILE) --parents " << var("TRANSLATIONS") << " " << ddir_c << Option::dir_sep << " && ";
|
---|
808 | t << "(cd `dirname " << ddir_c << "` && "
|
---|
809 | << "$(TAR) " << packageName << ".tar " << ddir << " && "
|
---|
810 | << "$(COMPRESS) " << packageName << ".tar) && "
|
---|
811 | << "$(MOVE) `dirname " << ddir_c << "`" << Option::dir_sep << packageName << ".tar.gz . && "
|
---|
812 | << "$(DEL_FILE) -r " << ddir_c
|
---|
813 | << endl << endl;
|
---|
814 |
|
---|
815 | t << endl;
|
---|
816 |
|
---|
817 | QString clean_targets = "compiler_clean " + var("CLEAN_DEPS");
|
---|
818 | if(do_incremental) {
|
---|
819 | t << "incrclean:" << "\n";
|
---|
820 | if(src_incremental)
|
---|
821 | t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJECTS)" << "\n";
|
---|
822 | t << endl;
|
---|
823 | }
|
---|
824 |
|
---|
825 | t << "clean:" << clean_targets << "\n\t";
|
---|
826 | if(!project->isEmpty("OBJECTS")) {
|
---|
827 | if(project->isActiveConfig("compile_libtool"))
|
---|
828 | t << "-$(LIBTOOL) --mode=clean $(DEL_FILE) $(OBJECTS)" << "\n\t";
|
---|
829 | else
|
---|
830 | t << "-$(DEL_FILE) $(OBJECTS)" << "\n\t";
|
---|
831 | }
|
---|
832 | if(doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER")) {
|
---|
833 | QStringList precomp_files;
|
---|
834 | QString precomph_out_dir;
|
---|
835 |
|
---|
836 | if(!project->isEmpty("PRECOMPILED_DIR"))
|
---|
837 | precomph_out_dir = project->first("PRECOMPILED_DIR");
|
---|
838 | precomph_out_dir += project->first("QMAKE_ORIG_TARGET") + project->first("QMAKE_PCH_OUTPUT_EXT");
|
---|
839 |
|
---|
840 | if (project->isActiveConfig("icc_pch_style")) {
|
---|
841 | // icc style
|
---|
842 | QString pchBaseName = project->first("QMAKE_ORIG_TARGET");
|
---|
843 | QString pchOutput;
|
---|
844 | if(!project->isEmpty("PRECOMPILED_DIR"))
|
---|
845 | pchOutput = project->first("PRECOMPILED_DIR");
|
---|
846 | pchOutput += pchBaseName + project->first("QMAKE_PCH_OUTPUT_EXT");
|
---|
847 | QString sourceFile = pchOutput + Option::cpp_ext.first();
|
---|
848 | QString objectFile = createObjectList(QStringList(sourceFile)).first();
|
---|
849 |
|
---|
850 | precomp_files << precomph_out_dir << sourceFile << objectFile;
|
---|
851 | } else {
|
---|
852 | // gcc style
|
---|
853 | precomph_out_dir += Option::dir_sep;
|
---|
854 |
|
---|
855 | QString header_prefix = project->first("QMAKE_PRECOMP_PREFIX");
|
---|
856 | if(!project->isEmpty("QMAKE_CFLAGS_PRECOMPILE"))
|
---|
857 | precomp_files += precomph_out_dir + header_prefix + "c";
|
---|
858 | if(!project->isEmpty("QMAKE_CXXFLAGS_PRECOMPILE"))
|
---|
859 | precomp_files += precomph_out_dir + header_prefix + "c++";
|
---|
860 | if(project->isActiveConfig("objective_c")) {
|
---|
861 | if(!project->isEmpty("QMAKE_OBJCFLAGS_PRECOMPILE"))
|
---|
862 | precomp_files += precomph_out_dir + header_prefix + "objective-c";
|
---|
863 | if(!project->isEmpty("QMAKE_OBJCXXFLAGS_PRECOMPILE"))
|
---|
864 | precomp_files += precomph_out_dir + header_prefix + "objective-c++";
|
---|
865 | }
|
---|
866 | }
|
---|
867 | t << "-$(DEL_FILE) " << precomp_files.join(" ") << "\n\t";
|
---|
868 | }
|
---|
869 | if(!project->isEmpty("IMAGES"))
|
---|
870 | t << varGlue("QMAKE_IMAGE_COLLECTION", "\t-$(DEL_FILE) ", " ", "") << "\n\t";
|
---|
871 | if(src_incremental)
|
---|
872 | t << "-$(DEL_FILE) $(INCREMENTAL_OBJECTS)" << "\n\t";
|
---|
873 | t << varGlue("QMAKE_CLEAN","-$(DEL_FILE) "," ","\n\t")
|
---|
874 | << "-$(DEL_FILE) *~ core *.core" << "\n"
|
---|
875 | << varGlue("CLEAN_FILES","\t-$(DEL_FILE) "," ","") << endl << endl;
|
---|
876 | t << "####### Sub-libraries" << endl << endl;
|
---|
877 | if (!project->values("SUBLIBS").isEmpty()) {
|
---|
878 | QString libdir = "tmp/";
|
---|
879 | if(!project->isEmpty("SUBLIBS_DIR"))
|
---|
880 | libdir = project->first("SUBLIBS_DIR");
|
---|
881 | QStringList &l = project->values("SUBLIBS");
|
---|
882 | for(it = l.begin(); it != l.end(); ++it)
|
---|
883 | t << libdir << project->first("QMAKE_PREFIX_STATICLIB") << (*it) << "."
|
---|
884 | << project->first("QMAKE_EXTENSION_STATICLIB") << ":\n\t"
|
---|
885 | << var(QString("MAKELIB") + (*it)) << endl << endl;
|
---|
886 | }
|
---|
887 |
|
---|
888 | QString destdir = project->first("DESTDIR");
|
---|
889 | if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep)
|
---|
890 | destdir += Option::dir_sep;
|
---|
891 | t << "distclean: " << "clean\n";
|
---|
892 | if(!project->isEmpty("QMAKE_BUNDLE")) {
|
---|
893 | QString bundlePath = escapeFilePath(destdir + project->first("QMAKE_BUNDLE"));
|
---|
894 | t << "\t-$(DEL_FILE) -r " << bundlePath << endl;
|
---|
895 | } else if(project->isActiveConfig("compile_libtool")) {
|
---|
896 | t << "\t-$(LIBTOOL) --mode=clean $(DEL_FILE) " << "$(TARGET)" << endl;
|
---|
897 | } else if(!project->isActiveConfig("staticlib") && project->values("QMAKE_APP_FLAG").isEmpty() &&
|
---|
898 | !project->isActiveConfig("plugin")) {
|
---|
899 | t << "\t-$(DEL_FILE) " << destdir << "$(TARGET)" << " " << endl;
|
---|
900 | if (project->values("QMAKE_SYMBIAN_SHLIB").isEmpty())
|
---|
901 | t << "\t-$(DEL_FILE) " << destdir << "$(TARGET0) " << destdir << "$(TARGET1) "
|
---|
902 | << destdir << "$(TARGET2) $(TARGETA)" << endl;
|
---|
903 | } else {
|
---|
904 | t << "\t-$(DEL_FILE) " << "$(TARGET)" << " " << endl;
|
---|
905 | }
|
---|
906 | t << varGlue("QMAKE_DISTCLEAN","\t-$(DEL_FILE) "," ","\n");
|
---|
907 | {
|
---|
908 | QString ofile = Option::fixPathToTargetOS(fileFixify(Option::output.fileName()));
|
---|
909 | if(!ofile.isEmpty())
|
---|
910 | t << "\t-$(DEL_FILE) " << ofile << endl;
|
---|
911 | }
|
---|
912 | t << endl << endl;
|
---|
913 |
|
---|
914 | if(doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER")) {
|
---|
915 | QString pchInput = project->first("PRECOMPILED_HEADER");
|
---|
916 | t << "###### Prefix headers" << endl;
|
---|
917 | QString comps[] = { "C", "CXX", "OBJC", "OBJCXX", QString() };
|
---|
918 | for(int i = 0; !comps[i].isNull(); i++) {
|
---|
919 | QString pchFlags = var("QMAKE_" + comps[i] + "FLAGS_PRECOMPILE");
|
---|
920 | if(pchFlags.isEmpty())
|
---|
921 | continue;
|
---|
922 |
|
---|
923 | QString cflags;
|
---|
924 | if(comps[i] == "OBJC" || comps[i] == "OBJCXX")
|
---|
925 | cflags += " $(CFLAGS)";
|
---|
926 | else
|
---|
927 | cflags += " $(" + comps[i] + "FLAGS)";
|
---|
928 |
|
---|
929 | QString pchBaseName = project->first("QMAKE_ORIG_TARGET");
|
---|
930 | QString pchOutput;
|
---|
931 | if(!project->isEmpty("PRECOMPILED_DIR"))
|
---|
932 | pchOutput = project->first("PRECOMPILED_DIR");
|
---|
933 | pchOutput += pchBaseName + project->first("QMAKE_PCH_OUTPUT_EXT");
|
---|
934 |
|
---|
935 | if (project->isActiveConfig("icc_pch_style")) {
|
---|
936 | // icc style
|
---|
937 | QString sourceFile = pchOutput + Option::cpp_ext.first();
|
---|
938 | QString objectFile = createObjectList(QStringList(sourceFile)).first();
|
---|
939 | t << pchOutput << ": " << pchInput << " " << findDependencies(pchInput).join(" \\\n\t\t")
|
---|
940 | << "\n\techo \"// Automatically generated, do not modify\" > " << sourceFile
|
---|
941 | << "\n\trm -f " << pchOutput;
|
---|
942 |
|
---|
943 | pchFlags = pchFlags.replace("${QMAKE_PCH_TEMP_SOURCE}", sourceFile)
|
---|
944 | .replace("${QMAKE_PCH_TEMP_OBJECT}", objectFile);
|
---|
945 | } else {
|
---|
946 | // gcc style
|
---|
947 | QString header_prefix = project->first("QMAKE_PRECOMP_PREFIX");
|
---|
948 |
|
---|
949 | pchOutput += Option::dir_sep;
|
---|
950 | QString pchOutputDir = pchOutput, pchOutputFile;
|
---|
951 |
|
---|
952 | if(comps[i] == "C") {
|
---|
953 | pchOutputFile = "c";
|
---|
954 | } else if(comps[i] == "CXX") {
|
---|
955 | pchOutputFile = "c++";
|
---|
956 | } else if(project->isActiveConfig("objective_c")) {
|
---|
957 | if(comps[i] == "OBJC")
|
---|
958 | pchOutputFile = "objective-c";
|
---|
959 | else if(comps[i] == "OBJCXX")
|
---|
960 | pchOutputFile = "objective-c++";
|
---|
961 | }
|
---|
962 | if(pchOutputFile.isEmpty())
|
---|
963 | continue;
|
---|
964 | pchOutput += header_prefix + pchOutputFile;
|
---|
965 |
|
---|
966 | t << pchOutput << ": " << pchInput << " " << findDependencies(pchInput).join(" \\\n\t\t")
|
---|
967 | << "\n\t" << mkdir_p_asstring(pchOutputDir);
|
---|
968 | }
|
---|
969 | pchFlags = pchFlags.replace("${QMAKE_PCH_INPUT}", pchInput)
|
---|
970 | .replace("${QMAKE_PCH_OUTPUT_BASE}", pchBaseName)
|
---|
971 | .replace("${QMAKE_PCH_OUTPUT}", pchOutput);
|
---|
972 |
|
---|
973 | QString compiler;
|
---|
974 | if(comps[i] == "C" || comps[i] == "OBJC" || comps[i] == "OBJCXX")
|
---|
975 | compiler = "$(CC)";
|
---|
976 | else
|
---|
977 | compiler = "$(CXX)";
|
---|
978 |
|
---|
979 | // compile command
|
---|
980 | t << "\n\t" << compiler << cflags << " $(INCPATH) " << pchFlags << endl << endl;
|
---|
981 | }
|
---|
982 | }
|
---|
983 |
|
---|
984 | writeExtraTargets(t);
|
---|
985 | writeExtraCompilerTargets(t);
|
---|
986 | }
|
---|
987 |
|
---|
988 | void UnixMakefileGenerator::init2()
|
---|
989 | {
|
---|
990 | //version handling
|
---|
991 | if(project->isEmpty("VERSION"))
|
---|
992 | project->values("VERSION").append("1.0." +
|
---|
993 | (project->isEmpty("VER_PAT") ? QString("0") :
|
---|
994 | project->first("VER_PAT")));
|
---|
995 | QStringList l = project->first("VERSION").split('.');
|
---|
996 | l << "0" << "0"; //make sure there are three
|
---|
997 | project->values("VER_MAJ").append(l[0]);
|
---|
998 | project->values("VER_MIN").append(l[1]);
|
---|
999 | project->values("VER_PAT").append(l[2]);
|
---|
1000 | if(project->isEmpty("QMAKE_FRAMEWORK_VERSION"))
|
---|
1001 | project->values("QMAKE_FRAMEWORK_VERSION").append(project->values("VER_MAJ").first());
|
---|
1002 |
|
---|
1003 | if (!project->values("QMAKE_APP_FLAG").isEmpty()) {
|
---|
1004 | if(!project->isEmpty("QMAKE_BUNDLE")) {
|
---|
1005 | QString bundle_loc = project->first("QMAKE_BUNDLE_LOCATION");
|
---|
1006 | if(!bundle_loc.isEmpty() && !bundle_loc.startsWith("/"))
|
---|
1007 | bundle_loc.prepend("/");
|
---|
1008 | if(!bundle_loc.endsWith("/"))
|
---|
1009 | bundle_loc += "/";
|
---|
1010 | project->values("TARGET").first().prepend(project->first("QMAKE_BUNDLE") + bundle_loc);
|
---|
1011 | }
|
---|
1012 | if(!project->isEmpty("TARGET"))
|
---|
1013 | project->values("TARGET").first().prepend(project->first("DESTDIR"));
|
---|
1014 | if (!project->values("QMAKE_CYGWIN_EXE").isEmpty())
|
---|
1015 | project->values("TARGET_EXT").append(".exe");
|
---|
1016 | } else if (project->isActiveConfig("staticlib")) {
|
---|
1017 | project->values("TARGET").first().prepend(project->first("QMAKE_PREFIX_STATICLIB"));
|
---|
1018 | project->values("TARGET").first() += "." + project->first("QMAKE_EXTENSION_STATICLIB");
|
---|
1019 | if(project->values("QMAKE_AR_CMD").isEmpty())
|
---|
1020 | project->values("QMAKE_AR_CMD").append("$(AR) $(TARGET) $(OBJECTS)");
|
---|
1021 | } else {
|
---|
1022 | project->values("TARGETA").append(project->first("DESTDIR") + project->first("QMAKE_PREFIX_STATICLIB")
|
---|
1023 | + project->first("TARGET") + "." + project->first("QMAKE_EXTENSION_STATICLIB"));
|
---|
1024 | if(project->isActiveConfig("compile_libtool"))
|
---|
1025 | project->values("TARGET_la") = QStringList(project->first("DESTDIR") + "lib" + project->first("TARGET") + Option::libtool_ext);
|
---|
1026 |
|
---|
1027 | if (!project->values("QMAKE_AR_CMD").isEmpty())
|
---|
1028 | project->values("QMAKE_AR_CMD").first().replace("(TARGET)","(TARGETA)");
|
---|
1029 | else
|
---|
1030 | project->values("QMAKE_AR_CMD").append("$(AR) $(TARGETA) $(OBJECTS)");
|
---|
1031 | if(project->isActiveConfig("compile_libtool")) {
|
---|
1032 | project->values("TARGET") = project->values("TARGET_la");
|
---|
1033 | } else if(!project->isEmpty("QMAKE_BUNDLE")) {
|
---|
1034 | QString bundle_loc = project->first("QMAKE_BUNDLE_LOCATION");
|
---|
1035 | if(!bundle_loc.isEmpty() && !bundle_loc.startsWith("/"))
|
---|
1036 | bundle_loc.prepend("/");
|
---|
1037 | if(!bundle_loc.endsWith("/"))
|
---|
1038 | bundle_loc += "/";
|
---|
1039 | project->values("TARGET_").append(project->first("QMAKE_BUNDLE") +
|
---|
1040 | bundle_loc + unescapeFilePath(project->first("TARGET")));
|
---|
1041 | project->values("TARGET_x.y").append(project->first("QMAKE_BUNDLE") +
|
---|
1042 | "/Versions/" +
|
---|
1043 | project->first("QMAKE_FRAMEWORK_VERSION") +
|
---|
1044 | bundle_loc + unescapeFilePath(project->first("TARGET")));
|
---|
1045 | } else if(project->isActiveConfig("plugin")) {
|
---|
1046 | QString prefix;
|
---|
1047 | if(!project->isActiveConfig("no_plugin_name_prefix"))
|
---|
1048 | prefix = "lib";
|
---|
1049 | project->values("TARGET_x.y.z").append(prefix +
|
---|
1050 | project->first("TARGET") + "." +
|
---|
1051 | project->first("QMAKE_EXTENSION_PLUGIN"));
|
---|
1052 | if(project->isActiveConfig("lib_version_first"))
|
---|
1053 | project->values("TARGET_x").append(prefix + project->first("TARGET") + "." +
|
---|
1054 | project->first("VER_MAJ") + "." +
|
---|
1055 | project->first("QMAKE_EXTENSION_PLUGIN"));
|
---|
1056 | else
|
---|
1057 | project->values("TARGET_x").append(prefix + project->first("TARGET") + "." +
|
---|
1058 | project->first("QMAKE_EXTENSION_PLUGIN") +
|
---|
1059 | "." + project->first("VER_MAJ"));
|
---|
1060 | project->values("TARGET") = project->values("TARGET_x.y.z");
|
---|
1061 | } else if (!project->isEmpty("QMAKE_HPUX_SHLIB")) {
|
---|
1062 | project->values("TARGET_").append("lib" + project->first("TARGET") + ".sl");
|
---|
1063 | if(project->isActiveConfig("lib_version_first"))
|
---|
1064 | project->values("TARGET_x").append("lib" + project->first("VER_MAJ") + "." +
|
---|
1065 | project->first("TARGET"));
|
---|
1066 | else
|
---|
1067 | project->values("TARGET_x").append("lib" + project->first("TARGET") + "." +
|
---|
1068 | project->first("VER_MAJ"));
|
---|
1069 | project->values("TARGET") = project->values("TARGET_x");
|
---|
1070 | } else if (!project->isEmpty("QMAKE_AIX_SHLIB")) {
|
---|
1071 | project->values("TARGET_").append(project->first("QMAKE_PREFIX_STATICLIB") + project->first("TARGET")
|
---|
1072 | + "." + project->first("QMAKE_EXTENSION_STATICLIB"));
|
---|
1073 | if(project->isActiveConfig("lib_version_first")) {
|
---|
1074 | project->values("TARGET_x").append("lib" + project->first("TARGET") + "." +
|
---|
1075 | project->first("VER_MAJ") + "." +
|
---|
1076 | project->first("QMAKE_EXTENSION_SHLIB"));
|
---|
1077 | project->values("TARGET_x.y").append("lib" + project->first("TARGET") + "." +
|
---|
1078 | project->first("VER_MAJ") +
|
---|
1079 | "." + project->first("VER_MIN") + "." +
|
---|
1080 | project->first("QMAKE_EXTENSION_SHLIB"));
|
---|
1081 | project->values("TARGET_x.y.z").append("lib" + project->first("TARGET") + "." +
|
---|
1082 | project->first("VER_MAJ") + "." +
|
---|
1083 | project->first("VER_MIN") + "." +
|
---|
1084 | project->first("VER_PAT") + "." +
|
---|
1085 | project->first("QMAKE_EXTENSION_SHLIB"));
|
---|
1086 | } else {
|
---|
1087 | project->values("TARGET_x").append("lib" + project->first("TARGET") + "." +
|
---|
1088 | project->first("QMAKE_EXTENSION_SHLIB") +
|
---|
1089 | "." + project->first("VER_MAJ"));
|
---|
1090 | project->values("TARGET_x.y").append("lib" + project->first("TARGET") + "." +
|
---|
1091 | project->first("QMAKE_EXTENSION_SHLIB") +
|
---|
1092 | "." + project->first("VER_MAJ") +
|
---|
1093 | "." + project->first("VER_MIN"));
|
---|
1094 | project->values("TARGET_x.y.z").append("lib" + project->first("TARGET") + "." +
|
---|
1095 | project->first("QMAKE_EXTENSION_SHLIB") + "." +
|
---|
1096 | project->first("VER_MAJ") + "." +
|
---|
1097 | project->first("VER_MIN") + "." +
|
---|
1098 | project->first("VER_PAT"));
|
---|
1099 | }
|
---|
1100 | project->values("TARGET") = project->values("TARGET_x.y.z");
|
---|
1101 | } else if (!project->isEmpty("QMAKE_SYMBIAN_SHLIB")) {
|
---|
1102 | project->values("TARGET_").append(project->first("TARGET") + "." +
|
---|
1103 | project->first("QMAKE_EXTENSION_SHLIB"));
|
---|
1104 | project->values("TARGET") = project->values("TARGET_");
|
---|
1105 | } else {
|
---|
1106 | project->values("TARGET_").append("lib" + project->first("TARGET") + "." +
|
---|
1107 | project->first("QMAKE_EXTENSION_SHLIB"));
|
---|
1108 | if(project->isActiveConfig("lib_version_first")) {
|
---|
1109 | project->values("TARGET_x").append("lib" + project->first("TARGET") + "." +
|
---|
1110 | project->first("VER_MAJ") + "." +
|
---|
1111 | project->first("QMAKE_EXTENSION_SHLIB"));
|
---|
1112 | project->values("TARGET_x.y").append("lib" + project->first("TARGET") + "." +
|
---|
1113 | project->first("VER_MAJ") +
|
---|
1114 | "." + project->first("VER_MIN") + "." +
|
---|
1115 | project->first("QMAKE_EXTENSION_SHLIB"));
|
---|
1116 | project->values("TARGET_x.y.z").append("lib" + project->first("TARGET") + "." +
|
---|
1117 | project->first("VER_MAJ") + "." +
|
---|
1118 | project->first("VER_MIN") + "." +
|
---|
1119 | project->first("VER_PAT") + "." +
|
---|
1120 | project->values("QMAKE_EXTENSION_SHLIB").first());
|
---|
1121 | } else {
|
---|
1122 | project->values("TARGET_x").append("lib" + project->first("TARGET") + "." +
|
---|
1123 | project->first("QMAKE_EXTENSION_SHLIB") +
|
---|
1124 | "." + project->first("VER_MAJ"));
|
---|
1125 | project->values("TARGET_x.y").append("lib" + project->first("TARGET") + "." +
|
---|
1126 | project->first("QMAKE_EXTENSION_SHLIB")
|
---|
1127 | + "." + project->first("VER_MAJ") +
|
---|
1128 | "." + project->first("VER_MIN"));
|
---|
1129 | project->values("TARGET_x.y.z").append("lib" + project->first("TARGET") +
|
---|
1130 | "." +
|
---|
1131 | project->values(
|
---|
1132 | "QMAKE_EXTENSION_SHLIB").first() + "." +
|
---|
1133 | project->first("VER_MAJ") + "." +
|
---|
1134 | project->first("VER_MIN") + "." +
|
---|
1135 | project->first("VER_PAT"));
|
---|
1136 | }
|
---|
1137 | project->values("TARGET") = project->values("TARGET_x.y.z");
|
---|
1138 | }
|
---|
1139 | if(project->isEmpty("QMAKE_LN_SHLIB"))
|
---|
1140 | project->values("QMAKE_LN_SHLIB").append("ln -s");
|
---|
1141 | if (!project->values("QMAKE_LFLAGS_SONAME").isEmpty()) {
|
---|
1142 | QString soname;
|
---|
1143 | if(project->isActiveConfig("plugin")) {
|
---|
1144 | if(!project->values("TARGET").isEmpty())
|
---|
1145 | soname += project->first("TARGET");
|
---|
1146 | } else if(!project->isEmpty("QMAKE_BUNDLE")) {
|
---|
1147 | soname += project->first("TARGET_x.y");
|
---|
1148 | } else if(!project->values("TARGET_x").isEmpty()) {
|
---|
1149 | soname += project->first("TARGET_x");
|
---|
1150 | }
|
---|
1151 | if(!soname.isEmpty()) {
|
---|
1152 | if(project->isActiveConfig("absolute_library_soname") &&
|
---|
1153 | project->values("INSTALLS").indexOf("target") != -1 &&
|
---|
1154 | !project->isEmpty("target.path")) {
|
---|
1155 | QString instpath = Option::fixPathToTargetOS(project->first("target.path"));
|
---|
1156 | if(!instpath.endsWith(Option::dir_sep))
|
---|
1157 | instpath += Option::dir_sep;
|
---|
1158 | soname.prepend(instpath);
|
---|
1159 | }
|
---|
1160 | project->values("QMAKE_LFLAGS_SONAME").first() += escapeFilePath(soname);
|
---|
1161 | }
|
---|
1162 | }
|
---|
1163 | if (project->values("QMAKE_LINK_SHLIB_CMD").isEmpty())
|
---|
1164 | project->values("QMAKE_LINK_SHLIB_CMD").append(
|
---|
1165 | "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(LIBS) $(OBJCOMP)");
|
---|
1166 | }
|
---|
1167 | if (!project->values("QMAKE_APP_FLAG").isEmpty()) {
|
---|
1168 | project->values("QMAKE_CFLAGS") += project->values("QMAKE_CFLAGS_APP");
|
---|
1169 | project->values("QMAKE_CXXFLAGS") += project->values("QMAKE_CXXFLAGS_APP");
|
---|
1170 | project->values("QMAKE_LFLAGS") += project->values("QMAKE_LFLAGS_APP");
|
---|
1171 | } else if (project->isActiveConfig("dll")) {
|
---|
1172 | if(!project->isActiveConfig("plugin") || !project->isActiveConfig("plugin_no_share_shlib_cflags")) {
|
---|
1173 | project->values("QMAKE_CFLAGS") += project->values("QMAKE_CFLAGS_SHLIB");
|
---|
1174 | project->values("QMAKE_CXXFLAGS") += project->values("QMAKE_CXXFLAGS_SHLIB");
|
---|
1175 | }
|
---|
1176 | if (project->isActiveConfig("plugin")) {
|
---|
1177 | project->values("QMAKE_CFLAGS") += project->values("QMAKE_CFLAGS_PLUGIN");
|
---|
1178 | project->values("QMAKE_CXXFLAGS") += project->values("QMAKE_CXXFLAGS_PLUGIN");
|
---|
1179 | project->values("QMAKE_LFLAGS") += project->values("QMAKE_LFLAGS_PLUGIN");
|
---|
1180 | if(project->isActiveConfig("plugin_with_soname") && !project->isActiveConfig("compile_libtool"))
|
---|
1181 | project->values("QMAKE_LFLAGS") += project->values("QMAKE_LFLAGS_SONAME");
|
---|
1182 | } else {
|
---|
1183 | project->values("QMAKE_LFLAGS") += project->values("QMAKE_LFLAGS_SHLIB");
|
---|
1184 | if(!project->isEmpty("QMAKE_LFLAGS_COMPAT_VERSION")) {
|
---|
1185 | if(project->isEmpty("COMPAT_VERSION"))
|
---|
1186 | project->values("QMAKE_LFLAGS") += QString(project->first("QMAKE_LFLAGS_COMPAT_VERSION") +
|
---|
1187 | project->first("VER_MAJ") + "." +
|
---|
1188 | project->first("VER_MIN"));
|
---|
1189 | else
|
---|
1190 | project->values("QMAKE_LFLAGS") += QString(project->first("QMAKE_LFLAGS_COMPAT_VERSION") +
|
---|
1191 | project->first("COMPATIBILITY_VERSION"));
|
---|
1192 | }
|
---|
1193 | if(!project->isEmpty("QMAKE_LFLAGS_VERSION")) {
|
---|
1194 | project->values("QMAKE_LFLAGS") += QString(project->first("QMAKE_LFLAGS_VERSION") +
|
---|
1195 | project->first("VER_MAJ") + "." +
|
---|
1196 | project->first("VER_MIN") + "." +
|
---|
1197 | project->first("VER_PAT"));
|
---|
1198 | }
|
---|
1199 | if(!project->isActiveConfig("compile_libtool"))
|
---|
1200 | project->values("QMAKE_LFLAGS") += project->values("QMAKE_LFLAGS_SONAME");
|
---|
1201 | }
|
---|
1202 | }
|
---|
1203 |
|
---|
1204 | if(!project->isEmpty("QMAKE_BUNDLE")) {
|
---|
1205 | QString plist = fileFixify(project->first("QMAKE_INFO_PLIST"));
|
---|
1206 | if(plist.isEmpty())
|
---|
1207 | plist = specdir() + QDir::separator() + "Info.plist." + project->first("TEMPLATE");
|
---|
1208 | if(exists(Option::fixPathToLocalOS(plist))) {
|
---|
1209 | if(project->isEmpty("QMAKE_INFO_PLIST"))
|
---|
1210 | project->values("QMAKE_INFO_PLIST").append(plist);
|
---|
1211 | project->values("QMAKE_INFO_PLIST_OUT").append(project->first("DESTDIR") +
|
---|
1212 | project->first("QMAKE_BUNDLE") +
|
---|
1213 | "/Contents/Info.plist");
|
---|
1214 | project->values("ALL_DEPS") += project->first("QMAKE_INFO_PLIST_OUT");
|
---|
1215 | if(!project->isEmpty("ICON") && project->first("TEMPLATE") == "app")
|
---|
1216 | project->values("ALL_DEPS") += project->first("DESTDIR") +
|
---|
1217 | project->first("QMAKE_BUNDLE") +
|
---|
1218 | "/Contents/Resources/" + project->first("ICON").section('/', -1);
|
---|
1219 | if(!project->isEmpty("QMAKE_BUNDLE_DATA")) {
|
---|
1220 | QString bundle_dir = project->first("DESTDIR") + project->first("QMAKE_BUNDLE") + "/";
|
---|
1221 | QStringList &alldeps = project->values("ALL_DEPS");
|
---|
1222 | const QStringList &bundle_data = project->values("QMAKE_BUNDLE_DATA");
|
---|
1223 | for(int i = 0; i < bundle_data.count(); i++) {
|
---|
1224 | const QStringList &files = project->values(bundle_data[i] + ".files");
|
---|
1225 | QString path = bundle_dir;
|
---|
1226 | if(!project->isEmpty(bundle_data[i] + ".version")) {
|
---|
1227 | alldeps += Option::fixPathToLocalOS(path + Option::dir_sep +
|
---|
1228 | project->first(bundle_data[i] + ".path"));
|
---|
1229 | path += project->first(bundle_data[i] + ".version") + "/" +
|
---|
1230 | project->first("QMAKE_FRAMEWORK_VERSION") + "/";
|
---|
1231 | }
|
---|
1232 | path += project->first(bundle_data[i] + ".path");
|
---|
1233 | path = Option::fixPathToLocalOS(path);
|
---|
1234 | for(int file = 0; file < files.count(); file++)
|
---|
1235 | alldeps += path + Option::dir_sep + fileInfo(files[file]).fileName();
|
---|
1236 | }
|
---|
1237 | }
|
---|
1238 | }
|
---|
1239 | }
|
---|
1240 | }
|
---|
1241 |
|
---|
1242 | QString
|
---|
1243 | UnixMakefileGenerator::libtoolFileName(bool fixify)
|
---|
1244 | {
|
---|
1245 | QString ret = var("TARGET");
|
---|
1246 | int slsh = ret.lastIndexOf(Option::dir_sep);
|
---|
1247 | if(slsh != -1)
|
---|
1248 | ret = ret.right(ret.length() - slsh - 1);
|
---|
1249 | int dot = ret.indexOf('.');
|
---|
1250 | if(dot != -1)
|
---|
1251 | ret = ret.left(dot);
|
---|
1252 | ret += Option::libtool_ext;
|
---|
1253 | if(!project->isEmpty("QMAKE_LIBTOOL_DESTDIR"))
|
---|
1254 | ret.prepend(project->first("QMAKE_LIBTOOL_DESTDIR") + Option::dir_sep);
|
---|
1255 | if(fixify) {
|
---|
1256 | if(QDir::isRelativePath(ret) && !project->isEmpty("DESTDIR"))
|
---|
1257 | ret.prepend(project->first("DESTDIR"));
|
---|
1258 | ret = Option::fixPathToLocalOS(fileFixify(ret, qmake_getpwd(), Option::output_dir));
|
---|
1259 | }
|
---|
1260 | return ret;
|
---|
1261 | }
|
---|
1262 |
|
---|
1263 | void
|
---|
1264 | UnixMakefileGenerator::writeLibtoolFile()
|
---|
1265 | {
|
---|
1266 | QString fname = libtoolFileName(), lname = fname;
|
---|
1267 | mkdir(fileInfo(fname).path());
|
---|
1268 | int slsh = lname.lastIndexOf(Option::dir_sep);
|
---|
1269 | if(slsh != -1)
|
---|
1270 | lname = lname.right(lname.length() - slsh - 1);
|
---|
1271 | QFile ft(fname);
|
---|
1272 | if(!ft.open(QIODevice::WriteOnly))
|
---|
1273 | return;
|
---|
1274 | project->values("ALL_DEPS").append(fileFixify(fname));
|
---|
1275 |
|
---|
1276 | QTextStream t(&ft);
|
---|
1277 | t << "# " << lname << " - a libtool library file\n";
|
---|
1278 | t << "# Generated by qmake/libtool (" << qmake_version() << ") (Qt "
|
---|
1279 | << QT_VERSION_STR << ") on: " << QDateTime::currentDateTime().toString();
|
---|
1280 | t << "\n";
|
---|
1281 |
|
---|
1282 | t << "# The name that we can dlopen(3).\n"
|
---|
1283 | << "dlname='" << var(project->isActiveConfig("plugin") ? "TARGET" : "TARGET_x")
|
---|
1284 | << "'\n\n";
|
---|
1285 |
|
---|
1286 | t << "# Names of this library.\n";
|
---|
1287 | t << "library_names='";
|
---|
1288 | if(project->isActiveConfig("plugin")) {
|
---|
1289 | t << var("TARGET");
|
---|
1290 | } else {
|
---|
1291 | if (project->isEmpty("QMAKE_HPUX_SHLIB"))
|
---|
1292 | t << var("TARGET_x.y.z") << " ";
|
---|
1293 | t << var("TARGET_x") << " " << var("TARGET_");
|
---|
1294 | }
|
---|
1295 | t << "'\n\n";
|
---|
1296 |
|
---|
1297 | t << "# The name of the static archive.\n"
|
---|
1298 | << "old_library='" << lname.left(lname.length()-Option::libtool_ext.length()) << ".a'\n\n";
|
---|
1299 |
|
---|
1300 | t << "# Libraries that this one depends upon.\n";
|
---|
1301 | QStringList libs;
|
---|
1302 | if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS"))
|
---|
1303 | libs = project->values("QMAKE_INTERNAL_PRL_LIBS");
|
---|
1304 | else
|
---|
1305 | libs << "QMAKE_LIBS"; //obvious one
|
---|
1306 | t << "dependency_libs='";
|
---|
1307 | for(QStringList::ConstIterator it = libs.begin(); it != libs.end(); ++it)
|
---|
1308 | t << project->values((*it)).join(" ") << " ";
|
---|
1309 | t << "'\n\n";
|
---|
1310 |
|
---|
1311 | t << "# Version information for " << lname << "\n";
|
---|
1312 | int maj = project->first("VER_MAJ").toInt();
|
---|
1313 | int min = project->first("VER_MIN").toInt();
|
---|
1314 | int pat = project->first("VER_PAT").toInt();
|
---|
1315 | t << "current=" << (10*maj + min) << "\n" // best I can think of
|
---|
1316 | << "age=0\n"
|
---|
1317 | << "revision=" << pat << "\n\n";
|
---|
1318 |
|
---|
1319 | t << "# Is this an already installed library.\n"
|
---|
1320 | "installed=yes\n\n"; // ###
|
---|
1321 |
|
---|
1322 | t << "# Files to dlopen/dlpreopen.\n"
|
---|
1323 | "dlopen=''\n"
|
---|
1324 | "dlpreopen=''\n\n";
|
---|
1325 |
|
---|
1326 | QString install_dir = project->first("QMAKE_LIBTOOL_LIBDIR");
|
---|
1327 | if(install_dir.isEmpty())
|
---|
1328 | install_dir = project->first("target.path");
|
---|
1329 | if(install_dir.isEmpty())
|
---|
1330 | install_dir = project->first("DESTDIR");
|
---|
1331 | t << "# Directory that this library needs to be installed in:\n"
|
---|
1332 | "libdir='" << Option::fixPathToTargetOS(install_dir, false) << "'\n";
|
---|
1333 | }
|
---|
1334 |
|
---|
1335 | QString
|
---|
1336 | UnixMakefileGenerator::pkgConfigFileName(bool fixify)
|
---|
1337 | {
|
---|
1338 | QString ret = var("TARGET");
|
---|
1339 | int slsh = ret.lastIndexOf(Option::dir_sep);
|
---|
1340 | if(slsh != -1)
|
---|
1341 | ret = ret.right(ret.length() - slsh - 1);
|
---|
1342 | if(ret.startsWith("lib"))
|
---|
1343 | ret = ret.mid(3);
|
---|
1344 | int dot = ret.indexOf('.');
|
---|
1345 | if(dot != -1)
|
---|
1346 | ret = ret.left(dot);
|
---|
1347 | ret += Option::pkgcfg_ext;
|
---|
1348 | if(!project->isEmpty("QMAKE_PKGCONFIG_DESTDIR"))
|
---|
1349 | ret.prepend(project->first("QMAKE_PKGCONFIG_DESTDIR") + Option::dir_sep);
|
---|
1350 | if(fixify) {
|
---|
1351 | if(QDir::isRelativePath(ret) && !project->isEmpty("DESTDIR"))
|
---|
1352 | ret.prepend(project->first("DESTDIR"));
|
---|
1353 | ret = Option::fixPathToLocalOS(fileFixify(ret, qmake_getpwd(), Option::output_dir));
|
---|
1354 | }
|
---|
1355 | return ret;
|
---|
1356 | }
|
---|
1357 |
|
---|
1358 | QString
|
---|
1359 | UnixMakefileGenerator::pkgConfigPrefix() const
|
---|
1360 | {
|
---|
1361 | if(!project->isEmpty("QMAKE_PKGCONFIG_PREFIX"))
|
---|
1362 | return project->first("QMAKE_PKGCONFIG_PREFIX");
|
---|
1363 | return QLibraryInfo::location(QLibraryInfo::PrefixPath);
|
---|
1364 | }
|
---|
1365 |
|
---|
1366 | QString
|
---|
1367 | UnixMakefileGenerator::pkgConfigFixPath(QString path) const
|
---|
1368 | {
|
---|
1369 | QString prefix = pkgConfigPrefix();
|
---|
1370 | if(path.startsWith(prefix))
|
---|
1371 | path = path.replace(prefix, "${prefix}");
|
---|
1372 | return path;
|
---|
1373 | }
|
---|
1374 |
|
---|
1375 | void
|
---|
1376 | UnixMakefileGenerator::writePkgConfigFile()
|
---|
1377 | {
|
---|
1378 | QString fname = pkgConfigFileName(), lname = fname;
|
---|
1379 | mkdir(fileInfo(fname).path());
|
---|
1380 | int slsh = lname.lastIndexOf(Option::dir_sep);
|
---|
1381 | if(slsh != -1)
|
---|
1382 | lname = lname.right(lname.length() - slsh - 1);
|
---|
1383 | QFile ft(fname);
|
---|
1384 | if(!ft.open(QIODevice::WriteOnly))
|
---|
1385 | return;
|
---|
1386 | project->values("ALL_DEPS").append(fileFixify(fname));
|
---|
1387 | QTextStream t(&ft);
|
---|
1388 |
|
---|
1389 | QString prefix = pkgConfigPrefix();
|
---|
1390 | QString libDir = project->first("QMAKE_PKGCONFIG_LIBDIR");
|
---|
1391 | if(libDir.isEmpty())
|
---|
1392 | libDir = prefix + Option::dir_sep + "lib" + Option::dir_sep;
|
---|
1393 | QString includeDir = project->first("QMAKE_PKGCONFIG_INCDIR");
|
---|
1394 | if(includeDir.isEmpty())
|
---|
1395 | includeDir = prefix + "/include";
|
---|
1396 |
|
---|
1397 | t << "prefix=" << prefix << endl;
|
---|
1398 | t << "exec_prefix=${prefix}\n"
|
---|
1399 | << "libdir=" << pkgConfigFixPath(libDir) << "\n"
|
---|
1400 | << "includedir=" << pkgConfigFixPath(includeDir) << endl;
|
---|
1401 | // non-standard entry. Provides useful info normally only
|
---|
1402 | // contained in the internal .qmake.cache file
|
---|
1403 | t << varGlue("CONFIG", "qt_config=", " ", "") << endl;
|
---|
1404 |
|
---|
1405 | //extra PKGCONFIG variables
|
---|
1406 | const QStringList &pkgconfig_vars = project->values("QMAKE_PKGCONFIG_VARIABLES");
|
---|
1407 | for(int i = 0; i < pkgconfig_vars.size(); ++i) {
|
---|
1408 | QString var = project->first(pkgconfig_vars.at(i) + ".name"),
|
---|
1409 | val = project->values(pkgconfig_vars.at(i) + ".value").join(" ");
|
---|
1410 | if(var.isEmpty())
|
---|
1411 | continue;
|
---|
1412 | if(val.isEmpty()) {
|
---|
1413 | const QStringList &var_vars = project->values(pkgconfig_vars.at(i) + ".variable");
|
---|
1414 | for(int v = 0; v < var_vars.size(); ++v) {
|
---|
1415 | const QStringList &vars = project->values(var_vars.at(v));
|
---|
1416 | for(int var = 0; var < vars.size(); ++var) {
|
---|
1417 | if(!val.isEmpty())
|
---|
1418 | val += " ";
|
---|
1419 | val += pkgConfigFixPath(vars.at(var));
|
---|
1420 | }
|
---|
1421 | }
|
---|
1422 | }
|
---|
1423 | t << var << "=" << val << endl;
|
---|
1424 | }
|
---|
1425 |
|
---|
1426 | t << endl;
|
---|
1427 |
|
---|
1428 | QString name = project->first("QMAKE_PKGCONFIG_NAME");
|
---|
1429 | if(name.isEmpty()) {
|
---|
1430 | name = project->first("QMAKE_ORIG_TARGET").toLower();
|
---|
1431 | name.replace(0, 1, name[0].toUpper());
|
---|
1432 | }
|
---|
1433 | t << "Name: " << name << endl;
|
---|
1434 | QString desc = project->values("QMAKE_PKGCONFIG_DESCRIPTION").join(" ");
|
---|
1435 | if(desc.isEmpty()) {
|
---|
1436 | if(name.isEmpty()) {
|
---|
1437 | desc = project->first("QMAKE_ORIG_TARGET").toLower();
|
---|
1438 | desc.replace(0, 1, desc[0].toUpper());
|
---|
1439 | } else {
|
---|
1440 | desc = name;
|
---|
1441 | }
|
---|
1442 | if(project->first("TEMPLATE") == "lib") {
|
---|
1443 | if(project->isActiveConfig("plugin"))
|
---|
1444 | desc += " Plugin";
|
---|
1445 | else
|
---|
1446 | desc += " Library";
|
---|
1447 | } else if(project->first("TEMPLATE") == "app") {
|
---|
1448 | desc += " Application";
|
---|
1449 | }
|
---|
1450 | }
|
---|
1451 | t << "Description: " << desc << endl;
|
---|
1452 | t << "Version: " << project->first("VERSION") << endl;
|
---|
1453 |
|
---|
1454 | // libs
|
---|
1455 | t << "Libs: ";
|
---|
1456 | QString pkgConfiglibDir;
|
---|
1457 | QString pkgConfiglibName;
|
---|
1458 | if (Option::target_mode == Option::TARG_MACX_MODE && project->isActiveConfig("lib_bundle")) {
|
---|
1459 | pkgConfiglibDir = "-F${libdir}";
|
---|
1460 | QString bundle;
|
---|
1461 | if (!project->isEmpty("QMAKE_FRAMEWORK_BUNDLE_NAME"))
|
---|
1462 | bundle = unescapeFilePath(project->first("QMAKE_FRAMEWORK_BUNDLE_NAME"));
|
---|
1463 | else
|
---|
1464 | bundle = unescapeFilePath(project->first("TARGET"));
|
---|
1465 | int suffix = bundle.lastIndexOf(".framework");
|
---|
1466 | if (suffix != -1)
|
---|
1467 | bundle = bundle.left(suffix);
|
---|
1468 | pkgConfiglibName = "-framework " + bundle + " ";
|
---|
1469 | } else {
|
---|
1470 | pkgConfiglibDir = "-L${libdir}";
|
---|
1471 | pkgConfiglibName = "-l" + lname.left(lname.length()-Option::libtool_ext.length());
|
---|
1472 | }
|
---|
1473 | t << pkgConfiglibDir << " " << pkgConfiglibName << " " << endl;
|
---|
1474 |
|
---|
1475 | QStringList libs;
|
---|
1476 | if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS")) {
|
---|
1477 | libs = project->values("QMAKE_INTERNAL_PRL_LIBS");
|
---|
1478 | } else {
|
---|
1479 | libs << "QMAKE_LIBS"; //obvious one
|
---|
1480 | }
|
---|
1481 | libs << "QMAKE_LIBS_PRIVATE";
|
---|
1482 | libs << "QMAKE_LFLAGS_THREAD"; //not sure about this one, but what about things like -pthread?
|
---|
1483 | t << "Libs.private: ";
|
---|
1484 | for(QStringList::ConstIterator it = libs.begin(); it != libs.end(); ++it) {
|
---|
1485 | t << project->values((*it)).join(" ") << " ";
|
---|
1486 | }
|
---|
1487 | t << endl;
|
---|
1488 |
|
---|
1489 | // flags
|
---|
1490 | // ### too many
|
---|
1491 | t << "Cflags: "
|
---|
1492 | // << var("QMAKE_CXXFLAGS") << " "
|
---|
1493 | << varGlue("PRL_EXPORT_DEFINES","-D"," -D"," ")
|
---|
1494 | << project->values("PRL_EXPORT_CXXFLAGS").join(" ")
|
---|
1495 | << project->values("QMAKE_PKGCONFIG_CFLAGS").join(" ")
|
---|
1496 | // << varGlue("DEFINES","-D"," -D"," ")
|
---|
1497 | << " -I${includedir}" << endl;
|
---|
1498 |
|
---|
1499 | // requires
|
---|
1500 | const QString requires = project->values("QMAKE_PKGCONFIG_REQUIRES").join(" ");
|
---|
1501 | if (!requires.isEmpty()) {
|
---|
1502 | t << "Requires: " << requires << endl;
|
---|
1503 | }
|
---|
1504 |
|
---|
1505 | t << endl;
|
---|
1506 | }
|
---|
1507 |
|
---|
1508 | QT_END_NAMESPACE
|
---|