Diffstat (limited to 'qmake/generators/unix/unixmake.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | qmake/generators/unix/unixmake.cpp | 520 |
1 files changed, 520 insertions, 0 deletions
diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp new file mode 100644 index 0000000..7df95b2 --- a/dev/null +++ b/qmake/generators/unix/unixmake.cpp | |||
@@ -0,0 +1,520 @@ | |||
1 | /**************************************************************************** | ||
2 | ** $Id$ | ||
3 | ** | ||
4 | ** Definition of ________ class. | ||
5 | ** | ||
6 | ** Created : 970521 | ||
7 | ** | ||
8 | ** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. | ||
9 | ** | ||
10 | ** This file is part of the network module of the Qt GUI Toolkit. | ||
11 | ** | ||
12 | ** This file may be distributed under the terms of the Q Public License | ||
13 | ** as defined by Trolltech AS of Norway and appearing in the file | ||
14 | ** LICENSE.QPL included in the packaging of this file. | ||
15 | ** | ||
16 | ** This file may be distributed and/or modified under the terms of the | ||
17 | ** GNU General Public License version 2 as published by the Free Software | ||
18 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
19 | ** packaging of this file. | ||
20 | ** | ||
21 | ** Licensees holding valid Qt Enterprise Edition licenses may use this | ||
22 | ** file in accordance with the Qt Commercial License Agreement provided | ||
23 | ** with the Software. | ||
24 | ** | ||
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
27 | ** | ||
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | ||
29 | ** information about Qt Commercial License Agreements. | ||
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | ||
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
32 | ** | ||
33 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
34 | ** not clear to you. | ||
35 | ** | ||
36 | **********************************************************************/ | ||
37 | |||
38 | #include "unixmake.h" | ||
39 | #include "option.h" | ||
40 | #include <qregexp.h> | ||
41 | #include <qfile.h> | ||
42 | #include <qdict.h> | ||
43 | #include <qdir.h> | ||
44 | #include <time.h> | ||
45 | |||
46 | |||
47 | void | ||
48 | UnixMakefileGenerator::init() | ||
49 | { | ||
50 | if(init_flag) | ||
51 | return; | ||
52 | init_flag = TRUE; | ||
53 | |||
54 | if(!project->isEmpty("QMAKE_FAILED_REQUIREMENTS")) /* no point */ | ||
55 | return; | ||
56 | |||
57 | QStringList &configs = project->variables()["CONFIG"]; | ||
58 | /* this should probably not be here, but I'm using it to wrap the .t files */ | ||
59 | if(project->first("TEMPLATE") == "app") | ||
60 | project->variables()["QMAKE_APP_FLAG"].append("1"); | ||
61 | else if(project->first("TEMPLATE") == "lib") | ||
62 | project->variables()["QMAKE_LIB_FLAG"].append("1"); | ||
63 | else if(project->first("TEMPLATE") == "subdirs") { | ||
64 | MakefileGenerator::init(); | ||
65 | if(project->isEmpty("MAKEFILE")) | ||
66 | project->variables()["MAKEFILE"].append("Makefile"); | ||
67 | if(project->isEmpty("QMAKE")) | ||
68 | project->variables()["QMAKE"].append("qmake"); | ||
69 | if(project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].findIndex("qmake_all") == -1) | ||
70 | project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].append("qmake_all"); | ||
71 | return; /* subdirs is done */ | ||
72 | } | ||
73 | |||
74 | if( project->isEmpty("QMAKE_EXTENSION_SHLIB") ) { | ||
75 | QString os = project->variables()["QMAKESPEC"].first().section( '-', 0, 0 ); | ||
76 | if ( os == "cygwin" ) { | ||
77 | project->variables()["QMAKE_EXTENSION_SHLIB"].append( "dll" ); | ||
78 | } else { | ||
79 | project->variables()["QMAKE_EXTENSION_SHLIB"].append( "so" ); | ||
80 | } | ||
81 | } | ||
82 | if( project->isEmpty("QMAKE_COPY_FILE") ) | ||
83 | project->variables()["QMAKE_COPY_FILE"].append( "$(COPY) -p" ); | ||
84 | if( project->isEmpty("QMAKE_COPY_DIR") ) | ||
85 | project->variables()["QMAKE_COPY_DIR"].append( "$(COPY) -pR" ); | ||
86 | //If the TARGET looks like a path split it into DESTDIR and the resulting TARGET | ||
87 | if(!project->isEmpty("TARGET")) { | ||
88 | QString targ = project->first("TARGET"); | ||
89 | int slsh = QMAX(targ.findRev('/'), targ.findRev(Option::dir_sep)); | ||
90 | if(slsh != -1) { | ||
91 | if(project->isEmpty("DESTDIR")) | ||
92 | project->values("DESTDIR").append(""); | ||
93 | else if(project->first("DESTDIR").right(1) != Option::dir_sep) | ||
94 | project->variables()["DESTDIR"] = project->first("DESTDIR") + Option::dir_sep; | ||
95 | project->variables()["DESTDIR"] = project->first("DESTDIR") + targ.left(slsh+1); | ||
96 | project->variables()["TARGET"] = targ.mid(slsh+1); | ||
97 | } | ||
98 | } | ||
99 | |||
100 | project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"]; | ||
101 | |||
102 | bool is_qt = (project->first("TARGET") == "qt" || project->first("TARGET") == "qte" || | ||
103 | project->first("TARGET") == "qt-mt" || project->first("TARGET") == "qte-mt"); | ||
104 | bool extern_libs = !project->isEmpty("QMAKE_APP_FLAG") || | ||
105 | (!project->isEmpty("QMAKE_LIB_FLAG") && | ||
106 | project->isActiveConfig("dll")) || is_qt; | ||
107 | if(!project->isActiveConfig("global_init_link_order")) | ||
108 | project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; | ||
109 | if ( (!project->isEmpty("QMAKE_LIB_FLAG") && !project->isActiveConfig("staticlib") ) || | ||
110 | (project->isActiveConfig("qt") && project->isActiveConfig( "plugin" ) )) { | ||
111 | if(configs.findIndex("dll") == -1) configs.append("dll"); | ||
112 | } else if ( !project->isEmpty("QMAKE_APP_FLAG") || project->isActiveConfig("dll") ) { | ||
113 | configs.remove("staticlib"); | ||
114 | } | ||
115 | if ( project->isActiveConfig("warn_off") ) { | ||
116 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_OFF"]; | ||
117 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_OFF"]; | ||
118 | } else if ( project->isActiveConfig("warn_on") ) { | ||
119 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_ON"]; | ||
120 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_ON"]; | ||
121 | } | ||
122 | if ( project->isActiveConfig("debug") ) { | ||
123 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_DEBUG"]; | ||
124 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_DEBUG"]; | ||
125 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_DEBUG"]; | ||
126 | } else { | ||
127 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RELEASE"]; | ||
128 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RELEASE"]; | ||
129 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_RELEASE"]; | ||
130 | } | ||
131 | if(!project->isEmpty("QMAKE_INCREMENTAL")) | ||
132 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_INCREMENTAL"]; | ||
133 | else if(!project->isEmpty("QMAKE_LFLAGS_PREBIND") && | ||
134 | !project->variables()["QMAKE_LIB_FLAG"].isEmpty() && | ||
135 | project->isActiveConfig("dll")) | ||
136 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_PREBIND"]; | ||
137 | if(!project->isEmpty("QMAKE_INCDIR")) | ||
138 | project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"]; | ||
139 | if(!project->isEmpty("QMAKE_LIBDIR")) { | ||
140 | if ( !project->isEmpty("QMAKE_RPATH") ) | ||
141 | project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR", " " + var("QMAKE_RPATH"), | ||
142 | " " + var("QMAKE_RPATH"), ""); | ||
143 | project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue( "QMAKE_LIBDIR", "-L", " -L", "" ); | ||
144 | } | ||
145 | if ( extern_libs && (project->isActiveConfig("qt") || project->isActiveConfig("opengl")) ) { | ||
146 | if(configs.findIndex("x11lib") == -1) | ||
147 | configs.append("x11lib"); | ||
148 | if ( project->isActiveConfig("opengl") && configs.findIndex("x11inc") == -1 ) | ||
149 | configs.append("x11inc"); | ||
150 | } | ||
151 | if ( project->isActiveConfig("x11") ) { | ||
152 | if(configs.findIndex("x11lib") == -1) | ||
153 | configs.append("x11lib"); | ||
154 | if(configs.findIndex("x11inc") == -1) | ||
155 | configs.append("x11inc"); | ||
156 | } | ||
157 | if ( project->isActiveConfig("qt") ) { | ||
158 | if ( project->isActiveConfig("accessibility" ) ) | ||
159 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT"); | ||
160 | if ( project->isActiveConfig("tablet") ) | ||
161 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT"); | ||
162 | if(configs.findIndex("moc")) configs.append("moc"); | ||
163 | project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QT"]; | ||
164 | if ( !project->isActiveConfig("debug") ) | ||
165 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG"); | ||
166 | if ( !is_qt ) { | ||
167 | if ( !project->isEmpty("QMAKE_LIBDIR_QT") ) { | ||
168 | if ( !project->isEmpty("QMAKE_RPATH") ) | ||
169 | project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_QT", " " + var("QMAKE_RPATH"), | ||
170 | " " + var("QMAKE_RPATH"), ""); | ||
171 | project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_QT", "-L", " -L", ""); | ||
172 | } | ||
173 | if (project->isActiveConfig("thread") && !project->isEmpty("QMAKE_LIBS_QT_THREAD")) | ||
174 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; | ||
175 | else | ||
176 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; | ||
177 | } | ||
178 | } | ||
179 | if ( project->isActiveConfig("thread") ) { | ||
180 | if(project->isActiveConfig("qt")) | ||
181 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT"); | ||
182 | if ( !project->isEmpty("QMAKE_CFLAGS_THREAD")) | ||
183 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_THREAD"]; | ||
184 | if( !project->isEmpty("QMAKE_CXXFLAGS_THREAD")) | ||
185 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_THREAD"]; | ||
186 | project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_THREAD"]; | ||
187 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_THREAD"]; | ||
188 | if(!project->isEmpty("QMAKE_LFLAGS_THREAD")) | ||
189 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_THREAD"]; | ||
190 | } | ||
191 | if ( project->isActiveConfig("opengl") ) { | ||
192 | project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_OPENGL"]; | ||
193 | if(!project->isEmpty("QMAKE_LIBDIR_OPENGL")) | ||
194 | project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_OPENGL", "-L", " -L", ""); | ||
195 | if ( is_qt ) | ||
196 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL_QT"]; | ||
197 | else | ||
198 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; | ||
199 | } | ||
200 | if(project->isActiveConfig("global_init_link_order")) | ||
201 | project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; | ||
202 | if ( project->isActiveConfig("x11sm") ) | ||
203 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_X11SM"]; | ||
204 | if ( project->isActiveConfig("dylib") ) | ||
205 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_DYNLOAD"]; | ||
206 | if ( project->isActiveConfig("x11inc") ) | ||
207 | project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_X11"]; | ||
208 | if ( project->isActiveConfig("x11lib") ) { | ||
209 | if(!project->isEmpty("QMAKE_LIBDIR_X11")) | ||
210 | project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_X11", "-L", " -L", ""); | ||
211 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_X11"]; | ||
212 | } | ||
213 | if ( project->isActiveConfig("moc") ) | ||
214 | setMocAware(TRUE); | ||
215 | if ( project->isEmpty("QMAKE_RUN_CC") ) | ||
216 | project->variables()["QMAKE_RUN_CC"].append("$(CC) -c $(CFLAGS) $(INCPATH) -o $obj $src"); | ||
217 | if ( project->isEmpty("QMAKE_RUN_CC_IMP") ) | ||
218 | project->variables()["QMAKE_RUN_CC_IMP"].append("$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<"); | ||
219 | if ( project->isEmpty("QMAKE_RUN_CXX") ) | ||
220 | project->variables()["QMAKE_RUN_CXX"].append("$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $obj $src"); | ||
221 | if ( project->isEmpty("QMAKE_RUN_CXX_IMP") ) | ||
222 | project->variables()["QMAKE_RUN_CXX_IMP"].append("$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<"); | ||
223 | project->variables()["QMAKE_FILETAGS"] += QStringList::split("HEADERS SOURCES TARGET DESTDIR", " "); | ||
224 | if ( !project->isEmpty("PRECOMPH") ) { | ||
225 | initOutPaths(); // Need to fix MOC_DIR since we do this before init() | ||
226 | QString allmoc = fileFixify(project->first("MOC_DIR") + "/allmoc.cpp", QDir::currentDirPath(), Option::output_dir); | ||
227 | project->variables()["SOURCES"].prepend(allmoc); | ||
228 | project->variables()["HEADERS_ORIG"] = project->variables()["HEADERS"]; | ||
229 | project->variables()["HEADERS"].clear(); | ||
230 | } | ||
231 | if( project->isActiveConfig("GNUmake") && !project->isEmpty("QMAKE_CFLAGS_DEPS")) | ||
232 | include_deps = TRUE; //do not generate deps | ||
233 | |||
234 | MakefileGenerator::init(); | ||
235 | if ( project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) { | ||
236 | if(!project->isEmpty("QMAKE_APP_FLAG")) { | ||
237 | if(project->isEmpty("DESTDIR")) | ||
238 | project->values("DESTDIR").append(""); | ||
239 | project->variables()["DESTDIR"].first() += project->variables()["TARGET"].first() + | ||
240 | ".app/Contents/MacOS/"; | ||
241 | project->variables()["QMAKE_PKGINFO"].append(project->first("DESTDIR") + "../PkgInfo"); | ||
242 | project->variables()["ALL_DEPS"] += project->first("QMAKE_PKGINFO"); | ||
243 | |||
244 | QString plist = specdir() + QDir::separator() + "Info.plist." + | ||
245 | project->first("TEMPLATE"); | ||
246 | if(QFile::exists(Option::fixPathToLocalOS(plist))) { | ||
247 | project->variables()["QMAKE_INFO_PLIST"].append(plist); | ||
248 | project->variables()["QMAKE_INFO_PLIST_OUT"].append(project->first("DESTDIR") + | ||
249 | "../Info.plist"); | ||
250 | project->variables()["ALL_DEPS"] += project->first("QMAKE_INFO_PLIST_OUT"); | ||
251 | if(!project->isEmpty("RC_FILE")) | ||
252 | project->variables()["ALL_DEPS"] += project->first("DESTDIR") + | ||
253 | "../Resources/application.icns"; | ||
254 | } | ||
255 | } | ||
256 | } | ||
257 | |||
258 | if(!project->isEmpty("QMAKE_INTERNAL_INCLUDED_FILES")) | ||
259 | project->variables()["DISTFILES"] += project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"]; | ||
260 | project->variables()["DISTFILES"] += Option::mkfile::project_files; | ||
261 | |||
262 | init2(); | ||
263 | project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "QMAKE_LIBDIR_FLAGS" << "QMAKE_LIBS"; | ||
264 | if(!project->isEmpty("QMAKE_MAX_FILES_PER_AR")) { | ||
265 | bool ok; | ||
266 | int max_files = project->first("QMAKE_MAX_FILES_PER_AR").toInt(&ok); | ||
267 | QStringList ar_sublibs, objs = project->variables()["OBJECTS"] + project->variables()["OBJMOC"]; | ||
268 | if(ok && max_files > 5 && max_files < (int)objs.count()) { | ||
269 | int obj_cnt = 0, lib_cnt = 0; | ||
270 | QString lib; | ||
271 | for(QStringList::Iterator objit = objs.begin(); objit != objs.end(); ++objit) { | ||
272 | if((++obj_cnt) >= max_files) { | ||
273 | if(lib_cnt) { | ||
274 | lib.sprintf("lib%s-tmp%d.a", project->first("QMAKE_ORIG_TARGET").latin1(), lib_cnt); | ||
275 | ar_sublibs << lib; | ||
276 | obj_cnt = 0; | ||
277 | } | ||
278 | lib_cnt++; | ||
279 | } | ||
280 | } | ||
281 | } | ||
282 | if(!ar_sublibs.isEmpty()) { | ||
283 | project->variables()["QMAKE_AR_SUBLIBS"] = ar_sublibs; | ||
284 | project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "QMAKE_AR_SUBLIBS"; | ||
285 | } | ||
286 | } | ||
287 | } | ||
288 | |||
289 | QStringList | ||
290 | UnixMakefileGenerator::uniqueSetLFlags(const QStringList &list1, QStringList &list2) | ||
291 | { | ||
292 | QStringList ret; | ||
293 | for(QStringList::ConstIterator it = list1.begin(); it != list1.end(); ++it) { | ||
294 | bool unique = TRUE; | ||
295 | if((*it).startsWith("-")) { | ||
296 | if((*it).startsWith("-l") || (*it).startsWith("-L")) { | ||
297 | unique = list2.findIndex((*it)) == -1; | ||
298 | } else if(project->isActiveConfig("macx") && (*it).startsWith("-framework")) { | ||
299 | int as_one = TRUE; | ||
300 | QString framework_in; | ||
301 | if((*it).length() > 11) { | ||
302 | framework_in = (*it).mid(11); | ||
303 | } else { | ||
304 | if(it != list1.end()) { | ||
305 | ++it; | ||
306 | as_one = FALSE; | ||
307 | framework_in = (*it); | ||
308 | } | ||
309 | } | ||
310 | if(!framework_in.isEmpty()) { | ||
311 | for(QStringList::ConstIterator outit = list2.begin(); outit != list2.end(); ++outit) { | ||
312 | if((*outit).startsWith("-framework")) { | ||
313 | QString framework_out; | ||
314 | if((*outit).length() > 11) { | ||
315 | framework_out = (*outit).mid(11); | ||
316 | } else { | ||
317 | if(it != list2.end()) { | ||
318 | ++outit; | ||
319 | framework_out = (*outit); | ||
320 | } | ||
321 | } | ||
322 | if(framework_out == framework_in) { | ||
323 | unique = FALSE; | ||
324 | break; | ||
325 | } | ||
326 | } | ||
327 | } | ||
328 | if(unique) { | ||
329 | unique = FALSE; //because I'm about to just insert it myself | ||
330 | if(as_one) { | ||
331 | ret.append("-framework " + framework_in); | ||
332 | } else { | ||
333 | ret.append("-framework"); | ||
334 | ret.append(framework_in); | ||
335 | } | ||
336 | } | ||
337 | } | ||
338 | } else { | ||
339 | unique = (list2.findIndex((*it)) == -1); | ||
340 | } | ||
341 | } else if(QFile::exists((*it))) { | ||
342 | unique = (list2.findIndex((*it)) == -1); | ||
343 | } | ||
344 | if(unique) | ||
345 | ret.append((*it)); | ||
346 | } | ||
347 | return ret; | ||
348 | } | ||
349 | |||
350 | |||
351 | void | ||
352 | UnixMakefileGenerator::processPrlVariable(const QString &var, const QStringList &l) | ||
353 | { | ||
354 | if(var == "QMAKE_PRL_LIBS") | ||
355 | project->variables()["QMAKE_CURRENT_PRL_LIBS"] += uniqueSetLFlags(l, project->variables()["QMAKE_LIBS"]); | ||
356 | else | ||
357 | MakefileGenerator::processPrlVariable(var, l); | ||
358 | } | ||
359 | |||
360 | void | ||
361 | UnixMakefileGenerator::processPrlFiles() | ||
362 | { | ||
363 | QDict<void> processed; | ||
364 | QPtrList<MakefileDependDir> libdirs; | ||
365 | libdirs.setAutoDelete(TRUE); | ||
366 | const QString lflags[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_LIBS", QString::null }; | ||
367 | for(int i = 0; !lflags[i].isNull(); i++) { | ||
368 | for(bool ret = FALSE; TRUE; ret = FALSE) { | ||
369 | QStringList l_out; | ||
370 | QStringList &l = project->variables()[lflags[i]]; | ||
371 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { | ||
372 | project->variables()["QMAKE_CURRENT_PRL_LIBS"].clear(); | ||
373 | QString opt = (*it).stripWhiteSpace();; | ||
374 | if(opt.startsWith("-")) { | ||
375 | if(opt.startsWith("-L")) { | ||
376 | QString r = opt.right(opt.length() - 2), l = r; | ||
377 | fixEnvVariables(l); | ||
378 | libdirs.append(new MakefileDependDir(r.replace("\"",""), | ||
379 | l.replace("\"",""))); | ||
380 | } else if(opt.startsWith("-l") && !processed[opt]) { | ||
381 | QString lib = opt.right(opt.length() - 2), prl; | ||
382 | for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) { | ||
383 | prl = mdd->local_dir + Option::dir_sep + "lib" + lib + Option::prl_ext; | ||
384 | if(processPrlFile(prl)) { | ||
385 | if(prl.startsWith(mdd->local_dir)) | ||
386 | prl.replace(0, mdd->local_dir.length(), mdd->real_dir); | ||
387 | QRegExp reg("^.*lib(" + lib + "[^./=]*)\\..*$"); | ||
388 | if(reg.exactMatch(prl)) | ||
389 | prl = "-l" + reg.cap(1); | ||
390 | opt = prl; | ||
391 | processed.insert(opt, (void*)1); | ||
392 | ret = TRUE; | ||
393 | break; | ||
394 | } | ||
395 | } | ||
396 | } else if(project->isActiveConfig("macx") && opt.startsWith("-framework")) { | ||
397 | if(opt.length() > 11) { | ||
398 | opt = opt.mid(11); | ||
399 | } else { | ||
400 | ++it; | ||
401 | opt = (*it); | ||
402 | } | ||
403 | QString prl = "/System/Library/Frameworks/" + opt + | ||
404 | ".framework/" + opt + Option::prl_ext; | ||
405 | if(processPrlFile(prl)) | ||
406 | ret = TRUE; | ||
407 | l_out.append("-framework"); | ||
408 | } | ||
409 | if(!opt.isEmpty()) | ||
410 | l_out.append(opt); | ||
411 | l_out += uniqueSetLFlags(project->variables()["QMAKE_CURRENT_PRL_LIBS"], l_out); | ||
412 | } else { | ||
413 | if(!processed[opt] && processPrlFile(opt)) { | ||
414 | processed.insert(opt, (void*)1); | ||
415 | ret = TRUE; | ||
416 | } | ||
417 | if(!opt.isEmpty()) | ||
418 | l_out.append(opt); | ||
419 | l_out += uniqueSetLFlags(project->variables()["QMAKE_CURRENT_PRL_LIBS"], l_out); | ||
420 | } | ||
421 | } | ||
422 | if(ret && l != l_out) | ||
423 | l = l_out; | ||
424 | else | ||
425 | break; | ||
426 | } | ||
427 | } | ||
428 | } | ||
429 | |||
430 | QString | ||
431 | UnixMakefileGenerator::defaultInstall(const QString &t) | ||
432 | { | ||
433 | if(t != "target" || project->first("TEMPLATE") == "subdirs") | ||
434 | return QString(); | ||
435 | |||
436 | bool resource = FALSE; | ||
437 | QStringList &uninst = project->variables()[t + ".uninstall"]; | ||
438 | QString ret, destdir=fileFixify(project->first("DESTDIR")); | ||
439 | QString targetdir = Option::fixPathToTargetOS(project->first("target.path"), FALSE); | ||
440 | if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep) | ||
441 | destdir += Option::dir_sep; | ||
442 | targetdir = "$(INSTALL_ROOT)" + Option::fixPathToTargetOS(targetdir, FALSE); | ||
443 | if(targetdir.right(1) != Option::dir_sep) | ||
444 | targetdir += Option::dir_sep; | ||
445 | |||
446 | QStringList links; | ||
447 | QString target="$(TARGET)"; | ||
448 | if(project->first("TEMPLATE") == "app") { | ||
449 | target = "$(QMAKE_TARGET)"; | ||
450 | if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) { | ||
451 | destdir += "../../../"; | ||
452 | target += ".app"; | ||
453 | resource = TRUE; | ||
454 | } | ||
455 | } else if(project->first("TEMPLATE") == "lib") { | ||
456 | if(project->isActiveConfig("create_prl") && !project->isEmpty("QMAKE_INTERNAL_PRL_FILE")) { | ||
457 | QString dst_prl = project->first("QMAKE_INTERNAL_PRL_FILE"); | ||
458 | int slsh = dst_prl.findRev('/'); | ||
459 | if(slsh != -1) | ||
460 | dst_prl = dst_prl.right(dst_prl.length() - slsh - 1); | ||
461 | dst_prl = targetdir + dst_prl; | ||
462 | ret += "-$(COPY) " + project->first("QMAKE_INTERNAL_PRL_FILE") + " " + dst_prl; | ||
463 | if(!uninst.isEmpty()) | ||
464 | uninst.append("\n\t"); | ||
465 | uninst.append("-$(DEL_FILE) \"" + dst_prl + "\""); | ||
466 | } | ||
467 | QString os = project->variables()["QMAKESPEC"].first().section( '-', 0, 0 ); | ||
468 | if ( os != "cygwin" ) { | ||
469 | if ( !project->isActiveConfig("staticlib") && !project->isActiveConfig("plugin") ) { | ||
470 | if ( os == "hpux" ) { | ||
471 | links << "$(TARGET0)"; | ||
472 | } else { | ||
473 | links << "$(TARGET0)" << "$(TARGET1)" << "$(TARGET2)"; | ||
474 | } | ||
475 | } | ||
476 | } | ||
477 | } | ||
478 | QString src_targ = target; | ||
479 | if(!destdir.isEmpty()) | ||
480 | src_targ = Option::fixPathToTargetOS(destdir + target, FALSE); | ||
481 | QString dst_targ = fileFixify(targetdir + target); | ||
482 | if(!ret.isEmpty()) | ||
483 | ret += "\n\t"; | ||
484 | ret += QString(resource ? "-$(COPY_DIR)" : "-$(COPY)") + " \"" + | ||
485 | src_targ + "\" \"" + dst_targ + "\""; | ||
486 | if(!project->isEmpty("QMAKE_STRIP")) { | ||
487 | ret += "\n\t-" + var("QMAKE_STRIP"); | ||
488 | if(resource) | ||
489 | ret = " \"" + dst_targ + "/Contents/MacOS/$(QMAKE_TARGET)"; | ||
490 | else | ||
491 | ret += " \"" + dst_targ + "\""; | ||
492 | } | ||
493 | if(!uninst.isEmpty()) | ||
494 | uninst.append("\n\t"); | ||
495 | if(resource) | ||
496 | uninst.append("-$(DEL_FILE) -r \"" + dst_targ + "\""); | ||
497 | else | ||
498 | uninst.append("-$(DEL_FILE) \"" + dst_targ + "\""); | ||
499 | if(!links.isEmpty()) { | ||
500 | for(QStringList::Iterator it = links.begin(); it != links.end(); it++) { | ||
501 | if(Option::target_mode == Option::TARG_WIN_MODE || | ||
502 | Option::target_mode == Option::TARG_MAC9_MODE) { | ||
503 | } else if(Option::target_mode == Option::TARG_UNIX_MODE || | ||
504 | Option::target_mode == Option::TARG_MACX_MODE) { | ||
505 | QString link = Option::fixPathToTargetOS(destdir + (*it), FALSE); | ||
506 | int lslash = link.findRev(Option::dir_sep); | ||
507 | if(lslash != -1) | ||
508 | link = link.right(link.length() - (lslash + 1)); | ||
509 | QString dst_link = fileFixify(targetdir + link); | ||
510 | ret += "\n\t-$(SYMLINK) \"$(TARGET)\" \"" + dst_link + "\""; | ||
511 | if(!uninst.isEmpty()) | ||
512 | uninst.append("\n\t"); | ||
513 | uninst.append("-$(DEL_FILE) \"" + dst_link + "\""); | ||
514 | } | ||
515 | } | ||
516 | } | ||
517 | return ret; | ||
518 | } | ||
519 | |||
520 | |||