0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the qmake application of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
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 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
38 |
** $QT_END_LICENSE$
|
|
39 |
**
|
|
40 |
****************************************************************************/
|
|
41 |
|
|
42 |
#include "unixmake.h"
|
|
43 |
#include "option.h"
|
|
44 |
#include <qregexp.h>
|
|
45 |
#include <qfile.h>
|
|
46 |
#include <qhash.h>
|
|
47 |
#include <qdir.h>
|
|
48 |
#include <time.h>
|
|
49 |
#include <qdebug.h>
|
|
50 |
|
|
51 |
QT_BEGIN_NAMESPACE
|
|
52 |
|
|
53 |
void
|
|
54 |
UnixMakefileGenerator::init()
|
|
55 |
{
|
|
56 |
if(init_flag)
|
|
57 |
return;
|
|
58 |
init_flag = true;
|
|
59 |
|
|
60 |
if(project->isEmpty("QMAKE_EXTENSION_SHLIB")) {
|
|
61 |
if(project->isEmpty("QMAKE_CYGWIN_SHLIB")) {
|
|
62 |
project->values("QMAKE_EXTENSION_SHLIB").append("so");
|
|
63 |
} else {
|
|
64 |
project->values("QMAKE_EXTENSION_SHLIB").append("dll");
|
|
65 |
}
|
|
66 |
}
|
|
67 |
|
|
68 |
if(!project->isEmpty("QMAKE_FAILED_REQUIREMENTS")) /* no point */
|
|
69 |
return;
|
|
70 |
|
|
71 |
QStringList &configs = project->values("CONFIG");
|
|
72 |
if(project->isEmpty("ICON") && !project->isEmpty("RC_FILE"))
|
|
73 |
project->values("ICON") = project->values("RC_FILE");
|
|
74 |
if(project->isEmpty("QMAKE_EXTENSION_PLUGIN"))
|
|
75 |
project->values("QMAKE_EXTENSION_PLUGIN").append(project->first("QMAKE_EXTENSION_SHLIB"));
|
|
76 |
if(project->isEmpty("QMAKE_COPY_FILE"))
|
|
77 |
project->values("QMAKE_COPY_FILE").append("$(COPY)");
|
|
78 |
if(project->isEmpty("QMAKE_STREAM_EDITOR"))
|
|
79 |
project->values("QMAKE_STREAM_EDITOR").append("sed");
|
|
80 |
if(project->isEmpty("QMAKE_COPY_DIR"))
|
|
81 |
project->values("QMAKE_COPY_DIR").append("$(COPY) -R");
|
|
82 |
if(project->isEmpty("QMAKE_INSTALL_FILE"))
|
|
83 |
project->values("QMAKE_INSTALL_FILE").append("$(COPY_FILE)");
|
|
84 |
if(project->isEmpty("QMAKE_INSTALL_DIR"))
|
|
85 |
project->values("QMAKE_INSTALL_DIR").append("$(COPY_DIR)");
|
|
86 |
if(project->isEmpty("QMAKE_INSTALL_PROGRAM"))
|
|
87 |
project->values("QMAKE_INSTALL_PROGRAM").append("$(COPY_FILE)");
|
|
88 |
if(project->isEmpty("QMAKE_LIBTOOL"))
|
|
89 |
project->values("QMAKE_LIBTOOL").append("libtool --silent");
|
|
90 |
if(project->isEmpty("QMAKE_SYMBOLIC_LINK"))
|
|
91 |
project->values("QMAKE_SYMBOLIC_LINK").append("ln -sf");
|
|
92 |
|
|
93 |
/* this should probably not be here, but I'm using it to wrap the .t files */
|
|
94 |
if(project->first("TEMPLATE") == "app")
|
|
95 |
project->values("QMAKE_APP_FLAG").append("1");
|
|
96 |
else if(project->first("TEMPLATE") == "lib")
|
|
97 |
project->values("QMAKE_LIB_FLAG").append("1");
|
|
98 |
else if(project->first("TEMPLATE") == "subdirs") {
|
|
99 |
MakefileGenerator::init();
|
|
100 |
if(project->isEmpty("MAKEFILE"))
|
|
101 |
project->values("MAKEFILE").append("Makefile");
|
|
102 |
if(project->isEmpty("QMAKE_QMAKE"))
|
|
103 |
project->values("QMAKE_QMAKE").append("qmake");
|
|
104 |
if(project->values("QMAKE_INTERNAL_QMAKE_DEPS").indexOf("qmake_all") == -1)
|
|
105 |
project->values("QMAKE_INTERNAL_QMAKE_DEPS").append("qmake_all");
|
|
106 |
return; /* subdirs is done */
|
|
107 |
}
|
|
108 |
|
|
109 |
//If the TARGET looks like a path split it into DESTDIR and the resulting TARGET
|
|
110 |
if(!project->isEmpty("TARGET")) {
|
|
111 |
project->values("TARGET") = escapeFilePaths(project->values("TARGET"));
|
|
112 |
QString targ = unescapeFilePath(project->first("TARGET"));
|
|
113 |
int slsh = qMax(targ.lastIndexOf('/'), targ.lastIndexOf(Option::dir_sep));
|
|
114 |
if(slsh != -1) {
|
|
115 |
if(project->isEmpty("DESTDIR"))
|
|
116 |
project->values("DESTDIR").append("");
|
|
117 |
else if(project->first("DESTDIR").right(1) != Option::dir_sep)
|
|
118 |
project->values("DESTDIR") = QStringList(project->first("DESTDIR") + Option::dir_sep);
|
|
119 |
project->values("DESTDIR") = QStringList(project->first("DESTDIR") + targ.left(slsh+1));
|
|
120 |
project->values("TARGET") = QStringList(targ.mid(slsh+1));
|
|
121 |
}
|
|
122 |
}
|
|
123 |
|
|
124 |
project->values("QMAKE_ORIG_TARGET") = project->values("TARGET");
|
|
125 |
project->values("QMAKE_ORIG_DESTDIR") = project->values("DESTDIR");
|
|
126 |
project->values("QMAKE_LIBS") += escapeFilePaths(project->values("LIBS"));
|
|
127 |
project->values("QMAKE_LIBS_PRIVATE") += escapeFilePaths(project->values("LIBS_PRIVATE"));
|
|
128 |
if((!project->isEmpty("QMAKE_LIB_FLAG") && !project->isActiveConfig("staticlib")) ||
|
|
129 |
(project->isActiveConfig("qt") && project->isActiveConfig("plugin"))) {
|
|
130 |
if(configs.indexOf("dll") == -1) configs.append("dll");
|
|
131 |
} else if(!project->isEmpty("QMAKE_APP_FLAG") || project->isActiveConfig("dll")) {
|
|
132 |
configs.removeAll("staticlib");
|
|
133 |
}
|
|
134 |
if(!project->isEmpty("QMAKE_INCREMENTAL"))
|
|
135 |
project->values("QMAKE_LFLAGS") += project->values("QMAKE_LFLAGS_INCREMENTAL");
|
|
136 |
else if(!project->isEmpty("QMAKE_LFLAGS_PREBIND") &&
|
|
137 |
!project->values("QMAKE_LIB_FLAG").isEmpty() &&
|
|
138 |
project->isActiveConfig("dll"))
|
|
139 |
project->values("QMAKE_LFLAGS") += project->values("QMAKE_LFLAGS_PREBIND");
|
|
140 |
if(!project->isEmpty("QMAKE_INCDIR"))
|
|
141 |
project->values("INCLUDEPATH") += project->values("QMAKE_INCDIR");
|
|
142 |
if(!project->isEmpty("QMAKE_LIBDIR")) {
|
|
143 |
const QStringList &libdirs = project->values("QMAKE_LIBDIR");
|
|
144 |
for(int i = 0; i < libdirs.size(); ++i) {
|
|
145 |
if(!project->isEmpty("QMAKE_LFLAGS_RPATH") && project->isActiveConfig("rpath_libdirs"))
|
|
146 |
project->values("QMAKE_LFLAGS") += var("QMAKE_LFLAGS_RPATH") + libdirs[i];
|
|
147 |
if (project->isActiveConfig("rvct_linker")) {
|
|
148 |
project->values("QMAKE_LIBDIR_FLAGS") += "--userlibpath " + escapeFilePath(libdirs[i]);
|
|
149 |
} else {
|
|
150 |
project->values("QMAKE_LIBDIR_FLAGS") += "-L" + escapeFilePath(libdirs[i]);
|
|
151 |
}
|
|
152 |
}
|
|
153 |
}
|
|
154 |
if(project->isActiveConfig("macx") && !project->isEmpty("QMAKE_FRAMEWORKPATH")) {
|
|
155 |
const QStringList &fwdirs = project->values("QMAKE_FRAMEWORKPATH");
|
|
156 |
for(int i = 0; i < fwdirs.size(); ++i) {
|
|
157 |
project->values("QMAKE_FRAMEWORKPATH_FLAGS") += "-F" + escapeFilePath(fwdirs[i]);
|
|
158 |
}
|
|
159 |
}
|
|
160 |
if(!project->isEmpty("QMAKE_RPATHDIR")) {
|
|
161 |
const QStringList &rpathdirs = project->values("QMAKE_RPATHDIR");
|
|
162 |
for(int i = 0; i < rpathdirs.size(); ++i) {
|
|
163 |
if(!project->isEmpty("QMAKE_LFLAGS_RPATH"))
|
|
164 |
project->values("QMAKE_LFLAGS") += var("QMAKE_LFLAGS_RPATH") + escapeFilePath(QFileInfo(rpathdirs[i]).absoluteFilePath());
|
|
165 |
}
|
|
166 |
}
|
|
167 |
|
|
168 |
project->values("QMAKE_FILETAGS") << "SOURCES" << "GENERATED_SOURCES" << "TARGET" << "DESTDIR";
|
|
169 |
if(!project->isEmpty("QMAKE_EXTRA_COMPILERS")) {
|
|
170 |
const QStringList &quc = project->values("QMAKE_EXTRA_COMPILERS");
|
|
171 |
for(int i = 0; i < quc.size(); ++i)
|
|
172 |
project->values("QMAKE_FILETAGS") += project->values(quc[i]+".input");
|
|
173 |
}
|
|
174 |
|
|
175 |
if(project->isActiveConfig("GNUmake") && !project->isEmpty("QMAKE_CFLAGS_DEPS"))
|
|
176 |
include_deps = true; //do not generate deps
|
|
177 |
if(project->isActiveConfig("compile_libtool"))
|
|
178 |
Option::obj_ext = ".lo"; //override the .o
|
|
179 |
|
|
180 |
MakefileGenerator::init();
|
|
181 |
|
|
182 |
QString comps[] = { "C", "CXX", "OBJC", "OBJCXX", QString() };
|
|
183 |
for(int i = 0; !comps[i].isNull(); i++) {
|
|
184 |
QString compile_flag = var("QMAKE_COMPILE_FLAG");
|
|
185 |
if(compile_flag.isEmpty())
|
|
186 |
compile_flag = "-c";
|
|
187 |
|
|
188 |
if(doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER")) {
|
|
189 |
QString pchFlags = var("QMAKE_" + comps[i] + "FLAGS_USE_PRECOMPILE");
|
|
190 |
|
|
191 |
QString pchBaseName;
|
|
192 |
if(!project->isEmpty("PRECOMPILED_DIR")) {
|
|
193 |
pchBaseName = Option::fixPathToTargetOS(project->first("PRECOMPILED_DIR"));
|
|
194 |
if(!pchBaseName.endsWith(Option::dir_sep))
|
|
195 |
pchBaseName += Option::dir_sep;
|
|
196 |
}
|
|
197 |
pchBaseName += project->first("QMAKE_ORIG_TARGET");
|
|
198 |
|
|
199 |
// replace place holders
|
|
200 |
pchFlags = pchFlags.replace("${QMAKE_PCH_INPUT}",
|
|
201 |
fileFixify(project->first("PRECOMPILED_HEADER")));
|
|
202 |
pchFlags = pchFlags.replace("${QMAKE_PCH_OUTPUT_BASE}", pchBaseName);
|
|
203 |
if (project->isActiveConfig("icc_pch_style")) {
|
|
204 |
// icc style
|
|
205 |
pchFlags = pchFlags.replace("${QMAKE_PCH_OUTPUT}",
|
|
206 |
pchBaseName + project->first("QMAKE_PCH_OUTPUT_EXT"));
|
|
207 |
}
|
|
208 |
|
|
209 |
if (!pchFlags.isEmpty())
|
|
210 |
compile_flag += " " + pchFlags;
|
|
211 |
}
|
|
212 |
|
|
213 |
QString cflags;
|
|
214 |
if(comps[i] == "OBJC" || comps[i] == "OBJCXX")
|
|
215 |
cflags += " $(CFLAGS)";
|
|
216 |
else
|
|
217 |
cflags += " $(" + comps[i] + "FLAGS)";
|
|
218 |
compile_flag += cflags + " $(INCPATH)";
|
|
219 |
|
|
220 |
QString compiler = comps[i];
|
|
221 |
if (compiler == "C")
|
|
222 |
compiler = "CC";
|
|
223 |
|
|
224 |
QString runComp = "QMAKE_RUN_" + compiler;
|
|
225 |
if(project->isEmpty(runComp))
|
|
226 |
project->values(runComp).append("$(" + compiler + ") " + compile_flag + " -o $obj $src");
|
|
227 |
QString runCompImp = "QMAKE_RUN_" + compiler + "_IMP";
|
|
228 |
if(project->isEmpty(runCompImp))
|
|
229 |
project->values(runCompImp).append("$(" + compiler + ") " + compile_flag + " -o \"$@\" \"$<\"");
|
|
230 |
}
|
|
231 |
|
|
232 |
if(project->isActiveConfig("macx") && !project->isEmpty("TARGET") && !project->isActiveConfig("compile_libtool") &&
|
|
233 |
((project->isActiveConfig("build_pass") || project->isEmpty("BUILDS")))) {
|
|
234 |
QString bundle;
|
|
235 |
if(project->isActiveConfig("bundle") && !project->isEmpty("QMAKE_BUNDLE_EXTENSION")) {
|
|
236 |
bundle = unescapeFilePath(project->first("TARGET"));
|
|
237 |
if(!project->isEmpty("QMAKE_BUNDLE_NAME"))
|
|
238 |
bundle = unescapeFilePath(project->first("QMAKE_BUNDLE_NAME"));
|
|
239 |
if(!bundle.endsWith(project->first("QMAKE_BUNDLE_EXTENSION")))
|
|
240 |
bundle += project->first("QMAKE_BUNDLE_EXTENSION");
|
|
241 |
} else if(project->first("TEMPLATE") == "app" && project->isActiveConfig("app_bundle")) {
|
|
242 |
bundle = unescapeFilePath(project->first("TARGET"));
|
|
243 |
if(!project->isEmpty("QMAKE_APPLICATION_BUNDLE_NAME"))
|
|
244 |
bundle = unescapeFilePath(project->first("QMAKE_APPLICATION_BUNDLE_NAME"));
|
|
245 |
if(!bundle.endsWith(".app"))
|
|
246 |
bundle += ".app";
|
|
247 |
if(project->isEmpty("QMAKE_BUNDLE_LOCATION"))
|
|
248 |
project->values("QMAKE_BUNDLE_LOCATION").append("Contents/MacOS");
|
|
249 |
project->values("QMAKE_PKGINFO").append(project->first("DESTDIR") + bundle + "/Contents/PkgInfo");
|
|
250 |
project->values("QMAKE_BUNDLE_RESOURCE_FILE").append(project->first("DESTDIR") + bundle + "/Contents/Resources/empty.lproj");
|
|
251 |
} else if(project->first("TEMPLATE") == "lib" && !project->isActiveConfig("staticlib") &&
|
|
252 |
((!project->isActiveConfig("plugin") && project->isActiveConfig("lib_bundle")) ||
|
|
253 |
(project->isActiveConfig("plugin") && project->isActiveConfig("plugin_bundle")))) {
|
|
254 |
bundle = unescapeFilePath(project->first("TARGET"));
|
|
255 |
if(project->isActiveConfig("plugin")) {
|
|
256 |
if(!project->isEmpty("QMAKE_PLUGIN_BUNDLE_NAME"))
|
|
257 |
bundle = unescapeFilePath(project->first("QMAKE_PLUGIN_BUNDLE_NAME"));
|
|
258 |
if(!project->isEmpty("QMAKE_BUNDLE_EXTENSION") && !bundle.endsWith(project->first("QMAKE_BUNDLE_EXTENSION")))
|
|
259 |
bundle += project->first("QMAKE_BUNDLE_EXTENSION");
|
|
260 |
else if(!bundle.endsWith(".plugin"))
|
|
261 |
bundle += ".plugin";
|
|
262 |
if(project->isEmpty("QMAKE_BUNDLE_LOCATION"))
|
|
263 |
project->values("QMAKE_BUNDLE_LOCATION").append("Contents/MacOS");
|
|
264 |
} else {
|
|
265 |
if(!project->isEmpty("QMAKE_FRAMEWORK_BUNDLE_NAME"))
|
|
266 |
bundle = unescapeFilePath(project->first("QMAKE_FRAMEWORK_BUNDLE_NAME"));
|
|
267 |
if(!project->isEmpty("QMAKE_BUNDLE_EXTENSION") && !bundle.endsWith(project->first("QMAKE_BUNDLE_EXTENSION")))
|
|
268 |
bundle += project->first("QMAKE_BUNDLE_EXTENSION");
|
|
269 |
else if(!bundle.endsWith(".framework"))
|
|
270 |
bundle += ".framework";
|
|
271 |
}
|
|
272 |
}
|
|
273 |
if(!bundle.isEmpty()) {
|
|
274 |
project->values("QMAKE_BUNDLE") = QStringList(bundle);
|
|
275 |
project->values("ALL_DEPS") += project->first("QMAKE_PKGINFO");
|
|
276 |
project->values("ALL_DEPS") += project->first("QMAKE_BUNDLE_RESOURCE_FILE");
|
|
277 |
} else {
|
|
278 |
project->values("QMAKE_BUNDLE").clear();
|
|
279 |
project->values("QMAKE_BUNDLE_LOCATION").clear();
|
|
280 |
}
|
|
281 |
} else { //no bundling here
|
|
282 |
project->values("QMAKE_BUNDLE").clear();
|
|
283 |
project->values("QMAKE_BUNDLE_LOCATION").clear();
|
|
284 |
}
|
|
285 |
|
|
286 |
if(!project->isEmpty("QMAKE_INTERNAL_INCLUDED_FILES"))
|
|
287 |
project->values("DISTFILES") += project->values("QMAKE_INTERNAL_INCLUDED_FILES");
|
|
288 |
project->values("DISTFILES") += project->projectFile();
|
|
289 |
|
|
290 |
init2();
|
|
291 |
project->values("QMAKE_INTERNAL_PRL_LIBS") << "QMAKE_LIBDIR_FLAGS" << "QMAKE_FRAMEWORKPATH_FLAGS" << "QMAKE_LIBS";
|
|
292 |
if(!project->isEmpty("QMAKE_MAX_FILES_PER_AR")) {
|
|
293 |
bool ok;
|
|
294 |
int max_files = project->first("QMAKE_MAX_FILES_PER_AR").toInt(&ok);
|
|
295 |
QStringList ar_sublibs, objs = project->values("OBJECTS");
|
|
296 |
if(ok && max_files > 5 && max_files < (int)objs.count()) {
|
|
297 |
QString lib;
|
|
298 |
for(int i = 0, obj_cnt = 0, lib_cnt = 0; i != objs.size(); ++i) {
|
|
299 |
if((++obj_cnt) >= max_files) {
|
|
300 |
if(lib_cnt) {
|
|
301 |
lib.sprintf("lib%s-tmp%d.a",
|
|
302 |
project->first("QMAKE_ORIG_TARGET").toLatin1().constData(), lib_cnt);
|
|
303 |
ar_sublibs << lib;
|
|
304 |
obj_cnt = 0;
|
|
305 |
}
|
|
306 |
lib_cnt++;
|
|
307 |
}
|
|
308 |
}
|
|
309 |
}
|
|
310 |
if(!ar_sublibs.isEmpty()) {
|
|
311 |
project->values("QMAKE_AR_SUBLIBS") = ar_sublibs;
|
|
312 |
project->values("QMAKE_INTERNAL_PRL_LIBS") << "QMAKE_AR_SUBLIBS";
|
|
313 |
}
|
|
314 |
}
|
|
315 |
|
|
316 |
if(project->isActiveConfig("compile_libtool")) {
|
|
317 |
const QString libtoolify[] = { "QMAKE_RUN_CC", "QMAKE_RUN_CC_IMP",
|
|
318 |
"QMAKE_RUN_CXX", "QMAKE_RUN_CXX_IMP",
|
|
319 |
"QMAKE_LINK_THREAD", "QMAKE_LINK", "QMAKE_AR_CMD", "QMAKE_LINK_SHLIB_CMD",
|
|
320 |
QString() };
|
|
321 |
for(int i = 0; !libtoolify[i].isNull(); i++) {
|
|
322 |
QStringList &l = project->values(libtoolify[i]);
|
|
323 |
if(!l.isEmpty()) {
|
|
324 |
QString libtool_flags, comp_flags;
|
|
325 |
if(libtoolify[i].startsWith("QMAKE_LINK") || libtoolify[i] == "QMAKE_AR_CMD") {
|
|
326 |
libtool_flags += " --mode=link";
|
|
327 |
if(project->isActiveConfig("staticlib")) {
|
|
328 |
libtool_flags += " -static";
|
|
329 |
} else {
|
|
330 |
if(!project->isEmpty("QMAKE_LIB_FLAG")) {
|
|
331 |
int maj = project->first("VER_MAJ").toInt();
|
|
332 |
int min = project->first("VER_MIN").toInt();
|
|
333 |
int pat = project->first("VER_PAT").toInt();
|
|
334 |
comp_flags += " -version-info " + QString::number(10*maj + min) +
|
|
335 |
":" + QString::number(pat) + ":0";
|
|
336 |
if(libtoolify[i] != "QMAKE_AR_CMD") {
|
|
337 |
QString rpath = Option::output_dir;
|
|
338 |
if(!project->isEmpty("DESTDIR")) {
|
|
339 |
rpath = project->first("DESTDIR");
|
|
340 |
if(QDir::isRelativePath(rpath))
|
|
341 |
rpath.prepend(Option::output_dir + Option::dir_sep);
|
|
342 |
}
|
|
343 |
comp_flags += " -rpath " + Option::fixPathToTargetOS(rpath, false);
|
|
344 |
}
|
|
345 |
}
|
|
346 |
}
|
|
347 |
if(project->isActiveConfig("plugin"))
|
|
348 |
libtool_flags += " -module";
|
|
349 |
} else {
|
|
350 |
libtool_flags += " --mode=compile";
|
|
351 |
}
|
|
352 |
l.first().prepend("$(LIBTOOL)" + libtool_flags + " ");
|
|
353 |
if(!comp_flags.isEmpty())
|
|
354 |
l.first() += comp_flags;
|
|
355 |
}
|
|
356 |
}
|
|
357 |
}
|
|
358 |
}
|
|
359 |
|
|
360 |
void
|
|
361 |
UnixMakefileGenerator::processPrlVariable(const QString &var, const QStringList &l)
|
|
362 |
{
|
|
363 |
if(var == "QMAKE_PRL_LIBS") {
|
|
364 |
project->values("QMAKE_CURRENT_PRL_LIBS") += l;
|
|
365 |
} else
|
|
366 |
MakefileGenerator::processPrlVariable(var, l);
|
|
367 |
}
|
|
368 |
|
|
369 |
QStringList
|
|
370 |
&UnixMakefileGenerator::findDependencies(const QString &file)
|
|
371 |
{
|
|
372 |
QStringList &ret = MakefileGenerator::findDependencies(file);
|
|
373 |
// Note: The QMAKE_IMAGE_COLLECTION file have all images
|
|
374 |
// as dependency, so don't add precompiled header then
|
|
375 |
if(doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER")
|
|
376 |
&& file != project->first("QMAKE_IMAGE_COLLECTION")) {
|
|
377 |
QString header_prefix;
|
|
378 |
if(!project->isEmpty("PRECOMPILED_DIR"))
|
|
379 |
header_prefix = project->first("PRECOMPILED_DIR");
|
|
380 |
header_prefix += project->first("QMAKE_ORIG_TARGET") + project->first("QMAKE_PCH_OUTPUT_EXT");
|
|
381 |
if (project->isActiveConfig("icc_pch_style")) {
|
|
382 |
// icc style
|
|
383 |
for(QStringList::Iterator it = Option::cpp_ext.begin(); it != Option::cpp_ext.end(); ++it) {
|
|
384 |
if(file.endsWith(*it)) {
|
|
385 |
ret += header_prefix;
|
|
386 |
break;
|
|
387 |
}
|
|
388 |
}
|
|
389 |
} else {
|
|
390 |
// gcc style
|
|
391 |
header_prefix += Option::dir_sep + project->first("QMAKE_PRECOMP_PREFIX");
|
|
392 |
for(QStringList::Iterator it = Option::c_ext.begin(); it != Option::c_ext.end(); ++it) {
|
|
393 |
if(file.endsWith(*it)) {
|
|
394 |
if(!project->isEmpty("QMAKE_CFLAGS_PRECOMPILE")) {
|
|
395 |
QString precomp_c_h = header_prefix + "c";
|
|
396 |
if(!ret.contains(precomp_c_h))
|
|
397 |
ret += precomp_c_h;
|
|
398 |
}
|
|
399 |
if(project->isActiveConfig("objective_c")) {
|
|
400 |
if(!project->isEmpty("QMAKE_OBJCFLAGS_PRECOMPILE")) {
|
|
401 |
QString precomp_objc_h = header_prefix + "objective-c";
|
|
402 |
if(!ret.contains(precomp_objc_h))
|
|
403 |
ret += precomp_objc_h;
|
|
404 |
}
|
|
405 |
if(!project->isEmpty("QMAKE_OBJCXXFLAGS_PRECOMPILE")) {
|
|
406 |
QString precomp_objcpp_h = header_prefix + "objective-c++";
|
|
407 |
if(!ret.contains(precomp_objcpp_h))
|
|
408 |
ret += precomp_objcpp_h;
|
|
409 |
}
|
|
410 |
}
|
|
411 |
break;
|
|
412 |
}
|
|
413 |
}
|
|
414 |
for(QStringList::Iterator it = Option::cpp_ext.begin(); it != Option::cpp_ext.end(); ++it) {
|
|
415 |
if(file.endsWith(*it)) {
|
|
416 |
if(!project->isEmpty("QMAKE_CXXFLAGS_PRECOMPILE")) {
|
|
417 |
QString precomp_cpp_h = header_prefix + "c++";
|
|
418 |
if(!ret.contains(precomp_cpp_h))
|
|
419 |
ret += precomp_cpp_h;
|
|
420 |
}
|
|
421 |
if(project->isActiveConfig("objective_c")) {
|
|
422 |
if(!project->isEmpty("QMAKE_OBJCXXFLAGS_PRECOMPILE")) {
|
|
423 |
QString precomp_objcpp_h = header_prefix + "objective-c++";
|
|
424 |
if(!ret.contains(precomp_objcpp_h))
|
|
425 |
ret += precomp_objcpp_h;
|
|
426 |
}
|
|
427 |
}
|
|
428 |
break;
|
|
429 |
}
|
|
430 |
}
|
|
431 |
}
|
|
432 |
}
|
|
433 |
return ret;
|
|
434 |
}
|
|
435 |
|
|
436 |
bool
|
|
437 |
UnixMakefileGenerator::findLibraries()
|
|
438 |
{
|
|
439 |
QList<QMakeLocalFileName> libdirs, frameworkdirs;
|
|
440 |
frameworkdirs.append(QMakeLocalFileName("/System/Library/Frameworks"));
|
|
441 |
frameworkdirs.append(QMakeLocalFileName("/Library/Frameworks"));
|
|
442 |
const QString lflags[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_FRAMEWORKPATH_FLAGS", "QMAKE_LFLAGS", "QMAKE_LIBS", "QMAKE_LIBS_PRIVATE", QString() };
|
|
443 |
for(int i = 0; !lflags[i].isNull(); i++) {
|
|
444 |
QStringList &l = project->values(lflags[i]);
|
|
445 |
for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
|
|
446 |
bool do_suffix = true;
|
|
447 |
QString stub, dir, extn, opt = (*it).trimmed();
|
|
448 |
if(opt.startsWith("-")) {
|
|
449 |
if(opt.startsWith("-L")) {
|
|
450 |
QMakeLocalFileName f(opt.right(opt.length()-2));
|
|
451 |
if(!libdirs.contains(f))
|
|
452 |
libdirs.append(f);
|
|
453 |
} else if(opt.startsWith("-l")) {
|
|
454 |
if (project->isActiveConfig("rvct_linker")) {
|
|
455 |
(*it) = "lib" + opt.mid(2) + ".so";
|
|
456 |
} else {
|
|
457 |
stub = opt.mid(2);
|
|
458 |
}
|
|
459 |
} else if(Option::target_mode == Option::TARG_MACX_MODE && opt.startsWith("-F")) {
|
|
460 |
frameworkdirs.append(QMakeLocalFileName(opt.right(opt.length()-2)));
|
|
461 |
} else if(Option::target_mode == Option::TARG_MACX_MODE && opt.startsWith("-framework")) {
|
|
462 |
if(opt.length() > 11) {
|
|
463 |
opt = opt.mid(11);
|
|
464 |
} else {
|
|
465 |
++it;
|
|
466 |
opt = (*it);
|
|
467 |
}
|
|
468 |
do_suffix = false;
|
|
469 |
extn = "";
|
|
470 |
dir = "/System/Library/Frameworks/" + opt + ".framework/";
|
|
471 |
stub = opt;
|
|
472 |
}
|
|
473 |
} else {
|
|
474 |
extn = dir = "";
|
|
475 |
stub = opt;
|
|
476 |
int slsh = opt.lastIndexOf(Option::dir_sep);
|
|
477 |
if(slsh != -1) {
|
|
478 |
dir = opt.left(slsh);
|
|
479 |
stub = opt.mid(slsh+1);
|
|
480 |
}
|
|
481 |
QRegExp stub_reg("^.*lib(" + stub + "[^./=]*)\\.(.*)$");
|
|
482 |
if(stub_reg.exactMatch(stub)) {
|
|
483 |
stub = stub_reg.cap(1);
|
|
484 |
extn = stub_reg.cap(2);
|
|
485 |
}
|
|
486 |
}
|
|
487 |
if(!stub.isEmpty()) {
|
|
488 |
if(do_suffix && !project->isEmpty("QMAKE_" + stub.toUpper() + "_SUFFIX"))
|
|
489 |
stub += project->first("QMAKE_" + stub.toUpper() + "_SUFFIX");
|
|
490 |
bool found = false;
|
|
491 |
QStringList extens;
|
|
492 |
if(!extn.isNull())
|
|
493 |
extens << extn;
|
|
494 |
else
|
|
495 |
extens << project->values("QMAKE_EXTENSION_SHLIB").first() << "a";
|
|
496 |
for(QStringList::Iterator extit = extens.begin(); extit != extens.end(); ++extit) {
|
|
497 |
if(dir.isNull()) {
|
|
498 |
QString lib_stub;
|
|
499 |
for(QList<QMakeLocalFileName>::Iterator dep_it = libdirs.begin(); dep_it != libdirs.end(); ++dep_it) {
|
|
500 |
if(exists((*dep_it).local() + Option::dir_sep + "lib" + stub +
|
|
501 |
"." + (*extit))) {
|
|
502 |
lib_stub = stub;
|
|
503 |
break;
|
|
504 |
}
|
|
505 |
}
|
|
506 |
if(!lib_stub.isNull()) {
|
|
507 |
(*it) = "-l" + lib_stub;
|
|
508 |
found = true;
|
|
509 |
break;
|
|
510 |
}
|
|
511 |
} else {
|
|
512 |
if(exists("lib" + stub + "." + (*extit))) {
|
|
513 |
(*it) = "lib" + stub + "." + (*extit);
|
|
514 |
found = true;
|
|
515 |
break;
|
|
516 |
}
|
|
517 |
}
|
|
518 |
}
|
|
519 |
if(!found && project->isActiveConfig("compile_libtool")) {
|
|
520 |
for(int dep_i = 0; dep_i < libdirs.size(); ++dep_i) {
|
|
521 |
if(exists(libdirs[dep_i].local() + Option::dir_sep + "lib" + stub + Option::libtool_ext)) {
|
|
522 |
(*it) = libdirs[dep_i].real() + Option::dir_sep + "lib" + stub + Option::libtool_ext;
|
|
523 |
found = true;
|
|
524 |
break;
|
|
525 |
}
|
|
526 |
}
|
|
527 |
}
|
|
528 |
}
|
|
529 |
}
|
|
530 |
}
|
|
531 |
return false;
|
|
532 |
}
|
|
533 |
|
|
534 |
QString linkLib(const QString &file, const QString &libName) {
|
|
535 |
QString ret;
|
|
536 |
QRegExp reg("^.*lib(" + QRegExp::escape(libName) + "[^./=]*).*$");
|
|
537 |
if(reg.exactMatch(file))
|
|
538 |
ret = "-l" + reg.cap(1);
|
|
539 |
return ret;
|
|
540 |
}
|
|
541 |
|
|
542 |
void
|
|
543 |
UnixMakefileGenerator::processPrlFiles()
|
|
544 |
{
|
|
545 |
QList<QMakeLocalFileName> libdirs, frameworkdirs;
|
|
546 |
frameworkdirs.append(QMakeLocalFileName("/System/Library/Frameworks"));
|
|
547 |
frameworkdirs.append(QMakeLocalFileName("/Library/Frameworks"));
|
|
548 |
const QString lflags[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_FRAMEWORKPATH_FLAGS", "QMAKE_LFLAGS", "QMAKE_LIBS", QString() };
|
|
549 |
for(int i = 0; !lflags[i].isNull(); i++) {
|
|
550 |
QStringList &l = project->values(lflags[i]);
|
|
551 |
for(int lit = 0; lit < l.size(); ++lit) {
|
|
552 |
QString opt = l.at(lit).trimmed();
|
|
553 |
if(opt.startsWith("-")) {
|
|
554 |
if(opt.startsWith("-L")) {
|
|
555 |
QMakeLocalFileName l(opt.right(opt.length()-2));
|
|
556 |
if(!libdirs.contains(l))
|
|
557 |
libdirs.append(l);
|
|
558 |
} else if(opt.startsWith("-l")) {
|
|
559 |
QString lib = opt.right(opt.length() - 2);
|
|
560 |
for(int dep_i = 0; dep_i < libdirs.size(); ++dep_i) {
|
|
561 |
const QMakeLocalFileName &lfn = libdirs[dep_i];
|
|
562 |
if(!project->isActiveConfig("compile_libtool")) { //give them the .libs..
|
|
563 |
QString la = lfn.local() + Option::dir_sep + "lib" + lib + Option::libtool_ext;
|
|
564 |
if(exists(la) && QFile::exists(lfn.local() + Option::dir_sep + ".libs")) {
|
|
565 |
QString dot_libs = lfn.real() + Option::dir_sep + ".libs";
|
|
566 |
l.append("-L" + dot_libs);
|
|
567 |
libdirs.append(QMakeLocalFileName(dot_libs));
|
|
568 |
}
|
|
569 |
}
|
|
570 |
|
|
571 |
QString prl = lfn.local() + Option::dir_sep + "lib" + lib;
|
|
572 |
if(!project->isEmpty("QMAKE_" + lib.toUpper() + "_SUFFIX"))
|
|
573 |
prl += project->first("QMAKE_" + lib.toUpper() + "_SUFFIX");
|
|
574 |
if(processPrlFile(prl)) {
|
|
575 |
if(prl.startsWith(lfn.local()))
|
|
576 |
prl.replace(0, lfn.local().length(), lfn.real());
|
|
577 |
opt = linkLib(prl, lib);
|
|
578 |
break;
|
|
579 |
}
|
|
580 |
}
|
|
581 |
} else if(Option::target_mode == Option::TARG_MACX_MODE && opt.startsWith("-F")) {
|
|
582 |
QMakeLocalFileName f(opt.right(opt.length()-2));
|
|
583 |
if(!frameworkdirs.contains(f))
|
|
584 |
frameworkdirs.append(f);
|
|
585 |
} else if(Option::target_mode == Option::TARG_MACX_MODE && opt.startsWith("-framework")) {
|
|
586 |
if(opt.length() > 11)
|
|
587 |
opt = opt.mid(11);
|
|
588 |
else
|
|
589 |
opt = l.at(++lit);
|
|
590 |
opt = opt.trimmed();
|
|
591 |
const QList<QMakeLocalFileName> dirs = frameworkdirs + libdirs;
|
|
592 |
for(int dep_i = 0; dep_i < dirs.size(); ++dep_i) {
|
|
593 |
QString prl = dirs[dep_i].local() + "/" + opt + ".framework/" + opt + Option::prl_ext;
|
|
594 |
if(processPrlFile(prl))
|
|
595 |
break;
|
|
596 |
}
|
|
597 |
}
|
|
598 |
} else if(!opt.isNull()) {
|
|
599 |
QString lib = opt;
|
|
600 |
processPrlFile(lib);
|
|
601 |
#if 0
|
|
602 |
if(ret)
|
|
603 |
opt = linkLib(lib, "");
|
|
604 |
#endif
|
|
605 |
if(!opt.isEmpty())
|
|
606 |
l.replaceInStrings(lib, opt);
|
|
607 |
}
|
|
608 |
|
|
609 |
QStringList &prl_libs = project->values("QMAKE_CURRENT_PRL_LIBS");
|
|
610 |
if(!prl_libs.isEmpty()) {
|
|
611 |
for(int prl = 0; prl < prl_libs.size(); ++prl)
|
|
612 |
l.insert(lit+prl+1, prl_libs.at(prl));
|
|
613 |
prl_libs.clear();
|
|
614 |
}
|
|
615 |
}
|
|
616 |
|
|
617 |
//merge them into a logical order
|
|
618 |
if(!project->isActiveConfig("no_smart_library_merge") && !project->isActiveConfig("no_lflags_merge")) {
|
|
619 |
QStringList lflags;
|
|
620 |
for(int lit = 0; lit < l.size(); ++lit) {
|
|
621 |
QString opt = l.at(lit).trimmed();
|
|
622 |
if(opt.startsWith("-")) {
|
|
623 |
if(opt.startsWith("-L") ||
|
|
624 |
(Option::target_mode == Option::TARG_MACX_MODE && opt.startsWith("-F"))) {
|
|
625 |
if(lit == 0 || l.lastIndexOf(opt, lit-1) == -1)
|
|
626 |
lflags.append(opt);
|
|
627 |
} else if(opt.startsWith("-l")) {
|
|
628 |
if(lit == l.size()-1 || l.indexOf(opt, lit+1) == -1)
|
|
629 |
lflags.append(opt);
|
|
630 |
} else if(Option::target_mode == Option::TARG_MACX_MODE && opt.startsWith("-framework")) {
|
|
631 |
if(opt.length() > 11)
|
|
632 |
opt = opt.mid(11);
|
|
633 |
else
|
|
634 |
opt = l.at(++lit);
|
|
635 |
bool found = false;
|
|
636 |
for(int x = lit+1; x < l.size(); ++x) {
|
|
637 |
QString xf = l.at(x);
|
|
638 |
if(xf.startsWith("-framework")) {
|
|
639 |
QString framework;
|
|
640 |
if(xf.length() > 11)
|
|
641 |
framework = xf.mid(11);
|
|
642 |
else
|
|
643 |
framework = l.at(++x);
|
|
644 |
if(framework == opt) {
|
|
645 |
found = true;
|
|
646 |
break;
|
|
647 |
}
|
|
648 |
}
|
|
649 |
}
|
|
650 |
if(!found) {
|
|
651 |
lflags.append("-framework");
|
|
652 |
lflags.append(opt);
|
|
653 |
}
|
|
654 |
} else {
|
|
655 |
lflags.append(opt);
|
|
656 |
}
|
|
657 |
} else if(!opt.isNull()) {
|
|
658 |
if(lit == 0 || l.lastIndexOf(opt, lit-1) == -1)
|
|
659 |
lflags.append(opt);
|
|
660 |
}
|
|
661 |
}
|
|
662 |
l = lflags;
|
|
663 |
}
|
|
664 |
}
|
|
665 |
}
|
|
666 |
|
|
667 |
QString
|
|
668 |
UnixMakefileGenerator::defaultInstall(const QString &t)
|
|
669 |
{
|
|
670 |
if(t != "target" || project->first("TEMPLATE") == "subdirs")
|
|
671 |
return QString();
|
|
672 |
|
|
673 |
bool bundle = false;
|
|
674 |
const QString root = "$(INSTALL_ROOT)";
|
|
675 |
QStringList &uninst = project->values(t + ".uninstall");
|
|
676 |
QString ret, destdir=project->first("DESTDIR");
|
|
677 |
QString targetdir = Option::fixPathToTargetOS(project->first("target.path"), false);
|
|
678 |
if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep)
|
|
679 |
destdir += Option::dir_sep;
|
|
680 |
targetdir = fileFixify(targetdir, FileFixifyAbsolute);
|
|
681 |
if(targetdir.right(1) != Option::dir_sep)
|
|
682 |
targetdir += Option::dir_sep;
|
|
683 |
|
|
684 |
QStringList links;
|
|
685 |
QString target="$(TARGET)";
|
|
686 |
QStringList &targets = project->values(t + ".targets");
|
|
687 |
if(!project->isEmpty("QMAKE_BUNDLE")) {
|
|
688 |
target = project->first("QMAKE_BUNDLE");
|
|
689 |
bundle = true;
|
|
690 |
} else if(project->first("TEMPLATE") == "app") {
|
|
691 |
target = "$(QMAKE_TARGET)";
|
|
692 |
} else if(project->first("TEMPLATE") == "lib") {
|
|
693 |
if(project->isEmpty("QMAKE_CYGWIN_SHLIB")) {
|
|
694 |
if(!project->isActiveConfig("staticlib") && !project->isActiveConfig("plugin")) {
|
|
695 |
if(project->isEmpty("QMAKE_HPUX_SHLIB")) {
|
|
696 |
links << "$(TARGET0)" << "$(TARGET1)" << "$(TARGET2)";
|
|
697 |
} else {
|
|
698 |
links << "$(TARGET0)";
|
|
699 |
}
|
|
700 |
}
|
|
701 |
}
|
|
702 |
}
|
|
703 |
for(int i = 0; i < targets.size(); ++i) {
|
|
704 |
QString src = targets.at(i),
|
|
705 |
dst = filePrefixRoot(root, targetdir + src.section('/', -1));
|
|
706 |
if(!ret.isEmpty())
|
|
707 |
ret += "\n\t";
|
|
708 |
ret += "-$(INSTALL_FILE) \"" + src + "\" \"" + dst + "\"";
|
|
709 |
if(!uninst.isEmpty())
|
|
710 |
uninst.append("\n\t");
|
|
711 |
uninst.append("-$(DEL_FILE) \"" + dst + "\"");
|
|
712 |
}
|
|
713 |
|
|
714 |
if(!bundle && project->isActiveConfig("compile_libtool")) {
|
|
715 |
QString src_targ = target;
|
|
716 |
if(src_targ == "$(TARGET)")
|
|
717 |
src_targ = "$(TARGETL)";
|
|
718 |
QString dst_dir = fileFixify(targetdir, FileFixifyAbsolute);
|
|
719 |
if(QDir::isRelativePath(dst_dir))
|
|
720 |
dst_dir = Option::fixPathToTargetOS(Option::output_dir + Option::dir_sep + dst_dir);
|
|
721 |
ret = "-$(LIBTOOL) --mode=install cp \"" + src_targ + "\" \"" + filePrefixRoot(root, dst_dir) + "\"";
|
|
722 |
uninst.append("-$(LIBTOOL) --mode=uninstall \"" + src_targ + "\"");
|
|
723 |
} else {
|
|
724 |
QString src_targ = target;
|
|
725 |
if(!destdir.isEmpty())
|
|
726 |
src_targ = Option::fixPathToTargetOS(destdir + target, false);
|
|
727 |
QString dst_targ = filePrefixRoot(root, fileFixify(targetdir + target, FileFixifyAbsolute));
|
|
728 |
if(bundle) {
|
|
729 |
if(!ret.isEmpty())
|
|
730 |
ret += "\n\t";
|
|
731 |
ret += "$(DEL_FILE) -r \"" + dst_targ + "\"\n\t";
|
|
732 |
}
|
|
733 |
if(!ret.isEmpty())
|
|
734 |
ret += "\n\t";
|
|
735 |
|
|
736 |
QString copy_cmd("-");
|
|
737 |
if (bundle)
|
|
738 |
copy_cmd += "$(INSTALL_DIR)";
|
|
739 |
else if (project->first("TEMPLATE") == "lib" && project->isActiveConfig("staticlib"))
|
|
740 |
copy_cmd += "$(INSTALL_FILE)";
|
|
741 |
else
|
|
742 |
copy_cmd += "$(INSTALL_PROGRAM)";
|
|
743 |
copy_cmd += " \"" + src_targ + "\" \"" + dst_targ + "\"";
|
|
744 |
if(project->first("TEMPLATE") == "lib" && !project->isActiveConfig("staticlib")
|
|
745 |
&& project->values(t + ".CONFIG").indexOf("fix_rpath") != -1) {
|
|
746 |
if(!project->isEmpty("QMAKE_FIX_RPATH")) {
|
|
747 |
ret += copy_cmd;
|
|
748 |
ret += "\n\t-" + var("QMAKE_FIX_RPATH") + " \"" +
|
|
749 |
dst_targ + "\" \"" + dst_targ + "\"";
|
|
750 |
} else if(!project->isEmpty("QMAKE_LFLAGS_RPATH")) {
|
|
751 |
ret += "-$(LINK) $(LFLAGS) " + var("QMAKE_LFLAGS_RPATH") + targetdir + " -o \"" +
|
|
752 |
dst_targ + "\" $(OBJECTS) $(LIBS) $(OBJCOMP)";
|
|
753 |
} else {
|
|
754 |
ret += copy_cmd;
|
|
755 |
}
|
|
756 |
} else {
|
|
757 |
ret += copy_cmd;
|
|
758 |
}
|
|
759 |
|
|
760 |
if(project->first("TEMPLATE") == "lib" && project->isActiveConfig("staticlib")) {
|
|
761 |
if(!project->isEmpty("QMAKE_RANLIB"))
|
|
762 |
ret += QString("\n\t$(RANLIB) \"") + dst_targ + "\"";
|
|
763 |
} else if(!project->isActiveConfig("debug") && !project->isActiveConfig("nostrip") && !project->isEmpty("QMAKE_STRIP")) {
|
|
764 |
ret += "\n\t-$(STRIP)";
|
|
765 |
if(project->first("TEMPLATE") == "lib" && !project->isEmpty("QMAKE_STRIPFLAGS_LIB"))
|
|
766 |
ret += " " + var("QMAKE_STRIPFLAGS_LIB");
|
|
767 |
else if(project->first("TEMPLATE") == "app" && !project->isEmpty("QMAKE_STRIPFLAGS_APP"))
|
|
768 |
ret += " " + var("QMAKE_STRIPFLAGS_APP");
|
|
769 |
if(bundle)
|
|
770 |
ret = " \"" + dst_targ + "/Contents/MacOS/$(QMAKE_TARGET)\"";
|
|
771 |
else
|
|
772 |
ret += " \"" + dst_targ + "\"";
|
|
773 |
}
|
|
774 |
if(!uninst.isEmpty())
|
|
775 |
uninst.append("\n\t");
|
|
776 |
if(bundle)
|
|
777 |
uninst.append("-$(DEL_FILE) -r \"" + dst_targ + "\"");
|
|
778 |
else
|
|
779 |
uninst.append("-$(DEL_FILE) \"" + dst_targ + "\"");
|
|
780 |
if(!links.isEmpty()) {
|
|
781 |
for(int i = 0; i < links.size(); ++i) {
|
|
782 |
if(Option::target_mode == Option::TARG_WIN_MODE ||
|
|
783 |
Option::target_mode == Option::TARG_MAC9_MODE) {
|
|
784 |
} else if(Option::target_mode == Option::TARG_UNIX_MODE ||
|
|
785 |
Option::target_mode == Option::TARG_MACX_MODE) {
|
|
786 |
QString link = Option::fixPathToTargetOS(destdir + links[i], false);
|
|
787 |
int lslash = link.lastIndexOf(Option::dir_sep);
|
|
788 |
if(lslash != -1)
|
|
789 |
link = link.right(link.length() - (lslash + 1));
|
|
790 |
QString dst_link = filePrefixRoot(root, fileFixify(targetdir + link, FileFixifyAbsolute));
|
|
791 |
ret += "\n\t-$(SYMLINK) \"$(TARGET)\" \"" + dst_link + "\"";
|
|
792 |
if(!uninst.isEmpty())
|
|
793 |
uninst.append("\n\t");
|
|
794 |
uninst.append("-$(DEL_FILE) \"" + dst_link + "\"");
|
|
795 |
}
|
|
796 |
}
|
|
797 |
}
|
|
798 |
}
|
|
799 |
if(project->first("TEMPLATE") == "lib") {
|
|
800 |
QStringList types;
|
|
801 |
types << "prl" << "libtool" << "pkgconfig";
|
|
802 |
for(int i = 0; i < types.size(); ++i) {
|
|
803 |
const QString type = types.at(i);
|
|
804 |
QString meta;
|
|
805 |
if(type == "prl" && project->isActiveConfig("create_prl") && !project->isActiveConfig("no_install_prl") &&
|
|
806 |
!project->isEmpty("QMAKE_INTERNAL_PRL_FILE"))
|
|
807 |
meta = prlFileName(false);
|
|
808 |
if(type == "libtool" && project->isActiveConfig("create_libtool") && !project->isActiveConfig("compile_libtool"))
|
|
809 |
meta = libtoolFileName(false);
|
|
810 |
if(type == "pkgconfig" && project->isActiveConfig("create_pc"))
|
|
811 |
meta = pkgConfigFileName(false);
|
|
812 |
if(!meta.isEmpty()) {
|
|
813 |
QString src_meta = meta;
|
|
814 |
if(!destdir.isEmpty())
|
|
815 |
src_meta = Option::fixPathToTargetOS(destdir + meta, false);
|
|
816 |
QString dst_meta = filePrefixRoot(root, fileFixify(targetdir + meta, FileFixifyAbsolute));
|
|
817 |
if(!uninst.isEmpty())
|
|
818 |
uninst.append("\n\t");
|
|
819 |
uninst.append("-$(DEL_FILE) \"" + dst_meta + "\"");
|
|
820 |
const QString replace_rule("QMAKE_" + type.toUpper() + "_INSTALL_REPLACE");
|
|
821 |
const QString dst_meta_dir = fileInfo(dst_meta).path();
|
|
822 |
if(!dst_meta_dir.isEmpty()) {
|
|
823 |
if(!ret.isEmpty())
|
|
824 |
ret += "\n\t";
|
|
825 |
ret += mkdir_p_asstring(dst_meta_dir, true);
|
|
826 |
}
|
|
827 |
QString install_meta = "$(INSTALL_FILE) \"" + src_meta + "\" \"" + dst_meta + "\"";
|
|
828 |
if(project->isEmpty(replace_rule) || project->isActiveConfig("no_sed_meta_install")) {
|
|
829 |
if(!ret.isEmpty())
|
|
830 |
ret += "\n\t";
|
|
831 |
ret += "-" + install_meta;
|
|
832 |
} else {
|
|
833 |
if(!ret.isEmpty())
|
|
834 |
ret += "\n\t";
|
|
835 |
ret += "-$(SED)";
|
|
836 |
QStringList replace_rules = project->values(replace_rule);
|
|
837 |
for(int r = 0; r < replace_rules.size(); ++r) {
|
|
838 |
const QString match = project->first(replace_rules.at(r) + ".match"),
|
|
839 |
replace = project->first(replace_rules.at(r) + ".replace");
|
|
840 |
if(!match.isEmpty() /*&& match != replace*/)
|
|
841 |
ret += " -e \"s," + match + "," + replace + ",g\"";
|
|
842 |
}
|
|
843 |
ret += " \"" + src_meta + "\" >\"" + dst_meta + "\"";
|
|
844 |
//ret += " || " + install_meta;
|
|
845 |
}
|
|
846 |
}
|
|
847 |
}
|
|
848 |
}
|
|
849 |
return ret;
|
|
850 |
}
|
|
851 |
|
|
852 |
QString
|
|
853 |
UnixMakefileGenerator::escapeFilePath(const QString &path) const
|
|
854 |
{
|
|
855 |
QString ret = path;
|
|
856 |
if(!ret.isEmpty()) {
|
|
857 |
ret = unescapeFilePath(ret).replace(QLatin1Char(' '), QLatin1String("\\ "));
|
|
858 |
debug_msg(2, "EscapeFilePath: %s -> %s", path.toLatin1().constData(), ret.toLatin1().constData());
|
|
859 |
}
|
|
860 |
return ret;
|
|
861 |
}
|
|
862 |
|
|
863 |
QT_END_NAMESPACE
|