Diffstat (limited to 'qmake/generators/unix/unixmake.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | qmake/generators/unix/unixmake.cpp | 441 |
1 files changed, 357 insertions, 84 deletions
diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp index e274481..caaddee 100644 --- a/qmake/generators/unix/unixmake.cpp +++ b/qmake/generators/unix/unixmake.cpp | |||
@@ -1,18 +1,16 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** $Id$ | ||
3 | ** | 2 | ** |
4 | ** Definition of ________ class. | ||
5 | ** | 3 | ** |
6 | ** Created : 970521 | 4 | ** Implementation of UnixMakefileGenerator class. |
7 | ** | 5 | ** |
8 | ** Copyright (C) 1992-2003 Trolltech AS. All rights reserved. | 6 | ** Copyright (C) 1992-2003 Trolltech AS. All rights reserved. |
9 | ** | 7 | ** |
10 | ** This file is part of the network module of the Qt GUI Toolkit. | 8 | ** This file is part of qmake. |
11 | ** | 9 | ** |
12 | ** This file may be distributed under the terms of the Q Public License | 10 | ** 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 | 11 | ** as defined by Trolltech AS of Norway and appearing in the file |
14 | ** LICENSE.QPL included in the packaging of this file. | 12 | ** LICENSE.QPL included in the packaging of this file. |
15 | ** | 13 | ** |
16 | ** This file may be distributed and/or modified under the terms of the | 14 | ** 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 | 15 | ** GNU General Public License version 2 as published by the Free Software |
18 | ** Foundation and appearing in the file LICENSE.GPL included in the | 16 | ** Foundation and appearing in the file LICENSE.GPL included in the |
@@ -73,20 +71,34 @@ UnixMakefileGenerator::init() | |||
73 | 71 | ||
74 | if( project->isEmpty("QMAKE_EXTENSION_SHLIB") ) { | 72 | if( project->isEmpty("QMAKE_EXTENSION_SHLIB") ) { |
75 | if ( project->isEmpty("QMAKE_CYGWIN_SHLIB") ) { | 73 | if ( project->isEmpty("QMAKE_CYGWIN_SHLIB") ) { |
76 | project->variables()["QMAKE_EXTENSION_SHLIB"].append( "so" ); | 74 | project->variables()["QMAKE_EXTENSION_SHLIB"].append( "so" ); |
77 | } else { | 75 | } else { |
78 | project->variables()["QMAKE_EXTENSION_SHLIB"].append( "dll" ); | 76 | project->variables()["QMAKE_EXTENSION_SHLIB"].append( "dll" ); |
79 | } | 77 | } |
80 | } | 78 | } |
79 | if( project->isEmpty("QMAKE_CFLAGS_PRECOMPILE")) | ||
80 | project->variables()["QMAKE_CFLAGS_PRECOMPILE"].append("-x c-header -c"); | ||
81 | if( project->isEmpty("QMAKE_CXXFLAGS_PRECOMPILE")) | ||
82 | project->variables()["QMAKE_CXXFLAGS_PRECOMPILE"].append("-x c++-header -c"); | ||
83 | if( project->isEmpty("QMAKE_CFLAGS_USE_PRECOMPILE")) | ||
84 | project->variables()["QMAKE_CFLAGS_USE_PRECOMPILE"].append("-include"); | ||
85 | if( project->isEmpty("QMAKE_EXTENSION_PLUGIN") ) | ||
86 | project->variables()["QMAKE_EXTENSION_PLUGIN"].append(project->first("QMAKE_EXTENSION_SHLIB")); | ||
81 | if( project->isEmpty("QMAKE_COPY_FILE") ) | 87 | if( project->isEmpty("QMAKE_COPY_FILE") ) |
82 | project->variables()["QMAKE_COPY_FILE"].append( "$(COPY) -p" ); | 88 | project->variables()["QMAKE_COPY_FILE"].append( "$(COPY)" ); |
83 | if( project->isEmpty("QMAKE_COPY_DIR") ) | 89 | if( project->isEmpty("QMAKE_COPY_DIR") ) |
84 | project->variables()["QMAKE_COPY_DIR"].append( "$(COPY) -pR" ); | 90 | project->variables()["QMAKE_COPY_DIR"].append( "$(COPY) -R" ); |
91 | if( project->isEmpty("QMAKE_INSTALL_FILE") ) | ||
92 | project->variables()["QMAKE_INSTALL_FILE"].append( "$(COPY_FILE)" ); | ||
93 | if( project->isEmpty("QMAKE_INSTALL_DIR") ) | ||
94 | project->variables()["QMAKE_INSTALL_DIR"].append( "$(COPY_DIR)" ); | ||
95 | if( project->isEmpty("QMAKE_LIBTOOL") ) | ||
96 | project->variables()["QMAKE_LIBTOOL"].append( "libtool --silent" ); | ||
85 | //If the TARGET looks like a path split it into DESTDIR and the resulting TARGET | 97 | //If the TARGET looks like a path split it into DESTDIR and the resulting TARGET |
86 | if(!project->isEmpty("TARGET")) { | 98 | if(!project->isEmpty("TARGET")) { |
87 | QString targ = project->first("TARGET"); | 99 | QString targ = project->first("TARGET"); |
88 | int slsh = QMAX(targ.findRev('/'), targ.findRev(Option::dir_sep)); | 100 | int slsh = QMAX(targ.findRev('/'), targ.findRev(Option::dir_sep)); |
89 | if(slsh != -1) { | 101 | if(slsh != -1) { |
90 | if(project->isEmpty("DESTDIR")) | 102 | if(project->isEmpty("DESTDIR")) |
91 | project->values("DESTDIR").append(""); | 103 | project->values("DESTDIR").append(""); |
92 | else if(project->first("DESTDIR").right(1) != Option::dir_sep) | 104 | else if(project->first("DESTDIR").right(1) != Option::dir_sep) |
@@ -98,17 +110,16 @@ UnixMakefileGenerator::init() | |||
98 | 110 | ||
99 | project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"]; | 111 | project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"]; |
100 | 112 | ||
101 | bool is_qt = (project->first("TARGET") == "qt" || project->first("TARGET") == "qte" || | 113 | bool is_qt = (project->first("TARGET") == "qt" || project->first("TARGET") == "qte" || |
102 | project->first("TARGET") == "qt-mt" || project->first("TARGET") == "qte-mt"); | 114 | project->first("TARGET") == "qt-mt" || project->first("TARGET") == "qte-mt"); |
103 | bool extern_libs = !project->isEmpty("QMAKE_APP_FLAG") || | 115 | bool extern_libs = !project->isEmpty("QMAKE_APP_FLAG") || |
104 | (!project->isEmpty("QMAKE_LIB_FLAG") && | 116 | (!project->isEmpty("QMAKE_LIB_FLAG") && |
105 | project->isActiveConfig("dll")) || is_qt; | 117 | project->isActiveConfig("dll")) || is_qt; |
106 | if(!project->isActiveConfig("global_init_link_order")) | ||
107 | project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; | 118 | project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; |
108 | if ( (!project->isEmpty("QMAKE_LIB_FLAG") && !project->isActiveConfig("staticlib") ) || | 119 | if ( (!project->isEmpty("QMAKE_LIB_FLAG") && !project->isActiveConfig("staticlib") ) || |
109 | (project->isActiveConfig("qt") && project->isActiveConfig( "plugin" ) )) { | 120 | (project->isActiveConfig("qt") && project->isActiveConfig( "plugin" ) )) { |
110 | if(configs.findIndex("dll") == -1) configs.append("dll"); | 121 | if(configs.findIndex("dll") == -1) configs.append("dll"); |
111 | } else if ( !project->isEmpty("QMAKE_APP_FLAG") || project->isActiveConfig("dll") ) { | 122 | } else if ( !project->isEmpty("QMAKE_APP_FLAG") || project->isActiveConfig("dll") ) { |
112 | configs.remove("staticlib"); | 123 | configs.remove("staticlib"); |
113 | } | 124 | } |
114 | if ( project->isActiveConfig("warn_off") ) { | 125 | if ( project->isActiveConfig("warn_off") ) { |
@@ -132,122 +143,154 @@ UnixMakefileGenerator::init() | |||
132 | else if(!project->isEmpty("QMAKE_LFLAGS_PREBIND") && | 143 | else if(!project->isEmpty("QMAKE_LFLAGS_PREBIND") && |
133 | !project->variables()["QMAKE_LIB_FLAG"].isEmpty() && | 144 | !project->variables()["QMAKE_LIB_FLAG"].isEmpty() && |
134 | project->isActiveConfig("dll")) | 145 | project->isActiveConfig("dll")) |
135 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_PREBIND"]; | 146 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_PREBIND"]; |
136 | if(!project->isEmpty("QMAKE_INCDIR")) | 147 | if(!project->isEmpty("QMAKE_INCDIR")) |
137 | project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"]; | 148 | project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"]; |
138 | if(!project->isEmpty("QMAKE_LIBDIR")) { | 149 | if(!project->isEmpty("QMAKE_LIBDIR")) { |
139 | if ( !project->isEmpty("QMAKE_RPATH") ) | 150 | if ( !project->isEmpty("QMAKE_RPATH") ) |
140 | project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR", " " + var("QMAKE_RPATH"), | 151 | project->variables()["QMAKE_LFLAGS"] += varGlue("QMAKE_LIBDIR", " " + var("QMAKE_RPATH"), |
141 | " " + var("QMAKE_RPATH"), ""); | 152 | " " + var("QMAKE_RPATH"), ""); |
142 | project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue( "QMAKE_LIBDIR", "-L", " -L", "" ); | 153 | project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue( "QMAKE_LIBDIR", "-L", " -L", "" ); |
143 | } | 154 | } |
144 | if ( extern_libs && (project->isActiveConfig("qt") || project->isActiveConfig("opengl")) ) { | 155 | if ( project->isActiveConfig("qtopia") ) { |
145 | if(configs.findIndex("x11lib") == -1) | 156 | if(configs.findIndex("qtopialib") == -1) |
146 | configs.append("x11lib"); | 157 | configs.append("qtopialib"); |
147 | if ( project->isActiveConfig("opengl") && configs.findIndex("x11inc") == -1 ) | 158 | if(configs.findIndex("qtopiainc") == -1) |
148 | configs.append("x11inc"); | 159 | configs.append("qtopiainc"); |
149 | } | 160 | } |
150 | if ( project->isActiveConfig("x11") ) { | 161 | if ( project->isActiveConfig("qtopiainc") ) |
151 | if(configs.findIndex("x11lib") == -1) | 162 | project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QTOPIA"]; |
152 | configs.append("x11lib"); | 163 | if ( project->isActiveConfig("qtopialib") ) { |
153 | if(configs.findIndex("x11inc") == -1) | 164 | if(!project->isEmpty("QMAKE_LIBDIR_QTOPIA")) |
154 | configs.append("x11inc"); | 165 | project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_QTOPIA", "-L", " -L", ""); |
166 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QTOPIA"]; | ||
155 | } | 167 | } |
156 | if ( project->isActiveConfig("qt") ) { | 168 | if ( project->isActiveConfig("qt") ) { |
157 | if ( project->isActiveConfig("accessibility" ) ) | 169 | if ( project->isActiveConfig("accessibility" ) ) |
158 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT"); | 170 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT"); |
159 | if ( project->isActiveConfig("tablet") ) | 171 | if ( project->isActiveConfig("tablet") ) |
160 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT"); | 172 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT"); |
161 | if(configs.findIndex("moc")) configs.append("moc"); | 173 | if(configs.findIndex("moc")) configs.append("moc"); |
162 | project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QT"]; | 174 | project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QT"]; |
163 | if ( !project->isActiveConfig("debug") ) | 175 | if ( !project->isActiveConfig("debug") ) |
164 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG"); | 176 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG"); |
165 | if ( !is_qt ) { | 177 | if ( !is_qt ) { |
166 | if ( !project->isEmpty("QMAKE_LIBDIR_QT") ) { | 178 | if ( !project->isEmpty("QMAKE_RPATH") ) { |
167 | if ( !project->isEmpty("QMAKE_RPATH") ) | 179 | if ( !project->isEmpty("QMAKE_RTLDIR_QT") ) |
168 | project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_QT", " " + var("QMAKE_RPATH"), | 180 | project->variables()["QMAKE_LFLAGS"] += varGlue("QMAKE_RTLDIR_QT", " " + var("QMAKE_RPATH"), |
181 | " " + var("QMAKE_RPATH"), ""); | ||
182 | else if ( !project->isEmpty("QMAKE_LIBDIR_QT") ) | ||
183 | project->variables()["QMAKE_LFLAGS"] += varGlue("QMAKE_LIBDIR_QT", " " + var("QMAKE_RPATH"), | ||
169 | " " + var("QMAKE_RPATH"), ""); | 184 | " " + var("QMAKE_RPATH"), ""); |
170 | project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_QT", "-L", " -L", ""); | ||
171 | } | 185 | } |
186 | if ( !project->isEmpty("QMAKE_LIBDIR_QT") ) | ||
187 | project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_QT", "-L", " -L", ""); | ||
172 | if (project->isActiveConfig("thread") && !project->isEmpty("QMAKE_LIBS_QT_THREAD")) | 188 | if (project->isActiveConfig("thread") && !project->isEmpty("QMAKE_LIBS_QT_THREAD")) |
173 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; | 189 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; |
174 | else | 190 | else |
175 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; | 191 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; |
176 | } | 192 | } |
177 | } | 193 | } |
178 | if ( project->isActiveConfig("opengl") ) { | 194 | if ( project->isActiveConfig("opengl") && !project->isActiveConfig("dlopen_opengl")) { |
179 | project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_OPENGL"]; | 195 | project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_OPENGL"]; |
180 | if(!project->isEmpty("QMAKE_LIBDIR_OPENGL")) | 196 | if(!project->isEmpty("QMAKE_LIBDIR_OPENGL")) |
181 | project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_OPENGL", "-L", " -L", ""); | 197 | project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_OPENGL", "-L", " -L", ""); |
182 | if ( is_qt ) | 198 | if ( is_qt ) |
183 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL_QT"]; | 199 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL_QT"]; |
184 | else | 200 | else |
185 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; | 201 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; |
186 | } | 202 | } |
187 | if(project->isActiveConfig("global_init_link_order")) | 203 | if ( extern_libs && (project->isActiveConfig("qt") || project->isActiveConfig("opengl")) ) { |
188 | project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; | 204 | if(configs.findIndex("x11lib") == -1) |
205 | configs.append("x11lib"); | ||
206 | if ( project->isActiveConfig("opengl") && configs.findIndex("x11inc") == -1 ) | ||
207 | configs.append("x11inc"); | ||
208 | } | ||
209 | if ( project->isActiveConfig("x11") ) { | ||
210 | if(configs.findIndex("x11lib") == -1) | ||
211 | configs.append("x11lib"); | ||
212 | if(configs.findIndex("x11inc") == -1) | ||
213 | configs.append("x11inc"); | ||
214 | } | ||
189 | if ( project->isActiveConfig("x11inc") ) | 215 | if ( project->isActiveConfig("x11inc") ) |
190 | project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_X11"]; | 216 | project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_X11"]; |
191 | if ( project->isActiveConfig("x11lib") ) { | 217 | if ( project->isActiveConfig("x11lib") ) { |
192 | if(!project->isEmpty("QMAKE_LIBDIR_X11")) | 218 | if(!project->isEmpty("QMAKE_LIBDIR_X11")) |
193 | project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_X11", "-L", " -L", ""); | 219 | project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_X11", "-L", " -L", ""); |
194 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_X11"]; | 220 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_X11"]; |
195 | } | 221 | } |
196 | if ( project->isActiveConfig("x11sm") ) | 222 | if ( project->isActiveConfig("x11sm") ) |
197 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_X11SM"]; | 223 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_X11SM"]; |
198 | if ( project->isActiveConfig("dylib") ) | 224 | if ( project->isActiveConfig("dylib") ) |
199 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_DYNLOAD"]; | 225 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_DYNLOAD"]; |
200 | if ( project->isActiveConfig("thread") ) { | 226 | if ( project->isActiveConfig("thread") ) { |
201 | if(project->isActiveConfig("qt")) | 227 | if(project->isActiveConfig("qt")) |
202 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT"); | 228 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT"); |
203 | if ( !project->isEmpty("QMAKE_CFLAGS_THREAD")) | 229 | if ( !project->isEmpty("QMAKE_CFLAGS_THREAD")) { |
204 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_THREAD"]; | 230 | project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_THREAD"]; |
205 | if( !project->isEmpty("QMAKE_CXXFLAGS_THREAD")) | 231 | project->variables()["PRL_EXPORT_CFLAGS"] += project->variables()["QMAKE_CFLAGS_THREAD"]; |
232 | } | ||
233 | if( !project->isEmpty("QMAKE_CXXFLAGS_THREAD")) { | ||
206 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_THREAD"]; | 234 | project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_THREAD"]; |
235 | project->variables()["PRL_EXPORT_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_THREAD"]; | ||
236 | } | ||
207 | project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_THREAD"]; | 237 | project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_THREAD"]; |
208 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_THREAD"]; | 238 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_THREAD"]; |
209 | if(!project->isEmpty("QMAKE_LFLAGS_THREAD")) | 239 | if(!project->isEmpty("QMAKE_LFLAGS_THREAD")) |
210 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_THREAD"]; | 240 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_THREAD"]; |
211 | } | 241 | } |
212 | if ( project->isActiveConfig("moc") ) | 242 | if ( project->isActiveConfig("moc") ) |
213 | setMocAware(TRUE); | 243 | setMocAware(TRUE); |
214 | if ( project->isEmpty("QMAKE_RUN_CC") ) | 244 | QString compile_flag = var("QMAKE_COMPILE_FLAG"); |
215 | project->variables()["QMAKE_RUN_CC"].append("$(CC) -c $(CFLAGS) $(INCPATH) -o $obj $src"); | 245 | if(compile_flag.isEmpty()) |
216 | if ( project->isEmpty("QMAKE_RUN_CC_IMP") ) | 246 | compile_flag = "-c"; |
217 | project->variables()["QMAKE_RUN_CC_IMP"].append("$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<"); | 247 | if(doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER")) { |
218 | if ( project->isEmpty("QMAKE_RUN_CXX") ) | 248 | QString prefix_flags = project->first("QMAKE_CFLAGS_PREFIX_INCLUDE"); |
219 | project->variables()["QMAKE_RUN_CXX"].append("$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $obj $src"); | 249 | if(prefix_flags.isEmpty()) |
220 | if ( project->isEmpty("QMAKE_RUN_CXX_IMP") ) | 250 | prefix_flags = "-include"; |
221 | project->variables()["QMAKE_RUN_CXX_IMP"].append("$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<"); | 251 | compile_flag += " " + prefix_flags + " " + project->first("QMAKE_ORIG_TARGET"); |
222 | project->variables()["QMAKE_FILETAGS"] += QStringList::split("HEADERS SOURCES TARGET DESTDIR", " "); | 252 | } |
223 | if ( !project->isEmpty("PRECOMPH") ) { | 253 | if(!project->isEmpty("ALLMOC_HEADER")) { |
224 | initOutPaths(); // Need to fix MOC_DIR since we do this before init() | 254 | initOutPaths(); // Need to fix outdirs since we do this before init() (because we could add to SOURCES et al) |
225 | QString allmoc = fileFixify(project->first("MOC_DIR") + "/allmoc.cpp", QDir::currentDirPath(), Option::output_dir); | 255 | QString allmoc = fileFixify(project->first("MOC_DIR") + "/allmoc.cpp", QDir::currentDirPath(), Option::output_dir); |
226 | project->variables()["SOURCES"].prepend(allmoc); | 256 | project->variables()["SOURCES"].prepend(allmoc); |
227 | project->variables()["HEADERS_ORIG"] = project->variables()["HEADERS"]; | 257 | project->variables()["HEADERS_ORIG"] = project->variables()["HEADERS"]; |
228 | project->variables()["HEADERS"].clear(); | 258 | project->variables()["HEADERS"].clear(); |
229 | } | 259 | } |
260 | if ( project->isEmpty("QMAKE_RUN_CC") ) | ||
261 | project->variables()["QMAKE_RUN_CC"].append("$(CC) " + compile_flag + " $(CFLAGS) $(INCPATH) -o $obj $src"); | ||
262 | if ( project->isEmpty("QMAKE_RUN_CC_IMP") ) | ||
263 | project->variables()["QMAKE_RUN_CC_IMP"].append("$(CC) " + compile_flag + " $(CFLAGS) $(INCPATH) -o $@ $<"); | ||
264 | if ( project->isEmpty("QMAKE_RUN_CXX") ) | ||
265 | project->variables()["QMAKE_RUN_CXX"].append("$(CXX) " + compile_flag + " $(CXXFLAGS) $(INCPATH) -o $obj $src"); | ||
266 | if ( project->isEmpty("QMAKE_RUN_CXX_IMP") ) | ||
267 | project->variables()["QMAKE_RUN_CXX_IMP"].append("$(CXX) " + compile_flag + " $(CXXFLAGS) $(INCPATH) -o $@ $<"); | ||
268 | project->variables()["QMAKE_FILETAGS"] += QStringList::split("HEADERS SOURCES TARGET DESTDIR", " "); | ||
230 | if( project->isActiveConfig("GNUmake") && !project->isEmpty("QMAKE_CFLAGS_DEPS")) | 269 | if( project->isActiveConfig("GNUmake") && !project->isEmpty("QMAKE_CFLAGS_DEPS")) |
231 | include_deps = TRUE; //do not generate deps | 270 | include_deps = TRUE; //do not generate deps |
271 | if(project->isActiveConfig("compile_libtool")) | ||
272 | Option::obj_ext = ".lo"; //override the .o | ||
232 | 273 | ||
233 | MakefileGenerator::init(); | 274 | MakefileGenerator::init(); |
234 | if ( project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) { | 275 | if ( project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) { |
235 | if(!project->isEmpty("QMAKE_APP_FLAG")) { | 276 | if(!project->isEmpty("QMAKE_APP_FLAG")) { |
236 | if(project->isEmpty("DESTDIR")) | 277 | if(project->isEmpty("DESTDIR")) |
237 | project->values("DESTDIR").append(""); | 278 | project->values("DESTDIR").append(""); |
238 | project->variables()["DESTDIR"].first() += project->variables()["TARGET"].first() + | 279 | project->variables()["DESTDIR"].first() += project->variables()["TARGET"].first() + |
239 | ".app/Contents/MacOS/"; | 280 | ".app/Contents/MacOS/"; |
240 | project->variables()["QMAKE_PKGINFO"].append(project->first("DESTDIR") + "../PkgInfo"); | 281 | project->variables()["QMAKE_PKGINFO"].append(project->first("DESTDIR") + "../PkgInfo"); |
241 | project->variables()["ALL_DEPS"] += project->first("QMAKE_PKGINFO"); | 282 | project->variables()["ALL_DEPS"] += project->first("QMAKE_PKGINFO"); |
242 | 283 | ||
243 | QString plist = specdir() + QDir::separator() + "Info.plist." + | 284 | QString plist = fileFixify(project->first("QMAKE_INFO_PLIST")); |
244 | project->first("TEMPLATE"); | 285 | if(plist.isEmpty()) |
286 | plist = specdir() + QDir::separator() + "Info.plist." + project->first("TEMPLATE"); | ||
245 | if(QFile::exists(Option::fixPathToLocalOS(plist))) { | 287 | if(QFile::exists(Option::fixPathToLocalOS(plist))) { |
288 | if(project->isEmpty("QMAKE_INFO_PLIST")) | ||
246 | project->variables()["QMAKE_INFO_PLIST"].append(plist); | 289 | project->variables()["QMAKE_INFO_PLIST"].append(plist); |
247 | project->variables()["QMAKE_INFO_PLIST_OUT"].append(project->first("DESTDIR") + | 290 | project->variables()["QMAKE_INFO_PLIST_OUT"].append(project->first("DESTDIR") + |
248 | "../Info.plist"); | 291 | "../Info.plist"); |
249 | project->variables()["ALL_DEPS"] += project->first("QMAKE_INFO_PLIST_OUT"); | 292 | project->variables()["ALL_DEPS"] += project->first("QMAKE_INFO_PLIST_OUT"); |
250 | if(!project->isEmpty("RC_FILE")) | 293 | if(!project->isEmpty("RC_FILE")) |
251 | project->variables()["ALL_DEPS"] += project->first("DESTDIR") + | 294 | project->variables()["ALL_DEPS"] += project->first("DESTDIR") + |
252 | "../Resources/application.icns"; | 295 | "../Resources/application.icns"; |
253 | } | 296 | } |
@@ -278,89 +321,223 @@ UnixMakefileGenerator::init() | |||
278 | } | 321 | } |
279 | } | 322 | } |
280 | } | 323 | } |
281 | if(!ar_sublibs.isEmpty()) { | 324 | if(!ar_sublibs.isEmpty()) { |
282 | project->variables()["QMAKE_AR_SUBLIBS"] = ar_sublibs; | 325 | project->variables()["QMAKE_AR_SUBLIBS"] = ar_sublibs; |
283 | project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "QMAKE_AR_SUBLIBS"; | 326 | project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "QMAKE_AR_SUBLIBS"; |
284 | } | 327 | } |
285 | } | 328 | } |
329 | |||
330 | if(project->isActiveConfig("compile_libtool")) { | ||
331 | const QString libtoolify[] = { "QMAKE_RUN_CC", "QMAKE_RUN_CC_IMP", | ||
332 | "QMAKE_RUN_CXX", "QMAKE_RUN_CXX_IMP", | ||
333 | "QMAKE_LINK_THREAD", "QMAKE_LINK", "QMAKE_AR_CMD", "QMAKE_LINK_SHLIB_CMD", | ||
334 | QString::null }; | ||
335 | for(int i = 0; !libtoolify[i].isNull(); i++) { | ||
336 | QStringList &l = project->variables()[libtoolify[i]]; | ||
337 | if(!l.isEmpty()) { | ||
338 | QString libtool_flags, comp_flags; | ||
339 | if(libtoolify[i].startsWith("QMAKE_LINK") || libtoolify[i] == "QMAKE_AR_CMD") { | ||
340 | libtool_flags += " --mode=link"; | ||
341 | if(project->isActiveConfig("staticlib")) { | ||
342 | libtool_flags += " -static"; | ||
343 | } else { | ||
344 | if(!project->isEmpty("QMAKE_LIB_FLAG")) { | ||
345 | int maj = project->first("VER_MAJ").toInt(); | ||
346 | int min = project->first("VER_MIN").toInt(); | ||
347 | int pat = project->first("VER_PAT").toInt(); | ||
348 | comp_flags += " -version-info " + QString::number(10*maj + min) + | ||
349 | ":" + QString::number(pat) + ":0"; | ||
350 | if(libtoolify[i] != "QMAKE_AR_CMD") { | ||
351 | QString rpath = Option::output_dir; | ||
352 | if(!project->isEmpty("DESTDIR")) { | ||
353 | rpath = project->first("DESTDIR"); | ||
354 | if(QDir::isRelativePath(rpath)) | ||
355 | rpath.prepend(Option::output_dir + Option::dir_sep); | ||
356 | } | ||
357 | comp_flags += " -rpath " + Option::fixPathToTargetOS(rpath, FALSE); | ||
358 | } | ||
359 | } | ||
360 | } | ||
361 | if(project->isActiveConfig("plugin")) | ||
362 | libtool_flags += " -module"; | ||
363 | } else { | ||
364 | libtool_flags += " --mode=compile"; | ||
365 | } | ||
366 | l.first().prepend("$(LIBTOOL)" + libtool_flags + " "); | ||
367 | if(!comp_flags.isEmpty()) | ||
368 | l.first() += comp_flags; | ||
369 | } | ||
370 | } | ||
371 | } | ||
286 | } | 372 | } |
287 | 373 | ||
288 | QStringList | 374 | QStringList |
289 | UnixMakefileGenerator::uniqueSetLFlags(const QStringList &list1, QStringList &list2) | 375 | UnixMakefileGenerator::combineSetLFlags(const QStringList &list1, const QStringList &list2) |
290 | { | 376 | { |
377 | if(project->isActiveConfig("no_smart_library_merge")) | ||
378 | return list1 + list2; | ||
379 | |||
291 | QStringList ret; | 380 | QStringList ret; |
292 | for(QStringList::ConstIterator it = list1.begin(); it != list1.end(); ++it) { | 381 | for(int i = 0; i < 2; i++) { |
293 | bool unique = TRUE; | 382 | const QStringList *lst = i ? &list2 : &list1; |
383 | for(QStringList::ConstIterator it = lst->begin(); it != lst->end(); ++it) { | ||
294 | if((*it).startsWith("-")) { | 384 | if((*it).startsWith("-")) { |
295 | if((*it).startsWith("-l") || (*it).startsWith("-L")) { | 385 | if((*it).startsWith("-L")) { |
296 | unique = list2.findIndex((*it)) == -1; | 386 | if(ret.findIndex((*it)) == -1) |
387 | ret.append((*it)); | ||
388 | } else if((*it).startsWith("-l")) { | ||
389 | while(1) { | ||
390 | QStringList::Iterator idx = ret.find((*it)); | ||
391 | if(idx == ret.end()) | ||
392 | break; | ||
393 | ret.remove(idx); | ||
394 | } | ||
395 | ret.append((*it)); | ||
297 | } else if(project->isActiveConfig("macx") && (*it).startsWith("-framework")) { | 396 | } else if(project->isActiveConfig("macx") && (*it).startsWith("-framework")) { |
298 | int as_one = TRUE; | 397 | int as_one = TRUE; |
299 | QString framework_in; | 398 | QString framework_in; |
300 | if((*it).length() > 11) { | 399 | if((*it).length() > 11) { |
301 | framework_in = (*it).mid(11); | 400 | framework_in = (*it).mid(11); |
302 | } else { | 401 | } else { |
303 | if(it != list1.end()) { | 402 | if(it != lst->end()) { |
304 | ++it; | 403 | ++it; |
305 | as_one = FALSE; | 404 | as_one = FALSE; |
306 | framework_in = (*it); | 405 | framework_in = (*it); |
307 | } | 406 | } |
308 | } | 407 | } |
309 | if(!framework_in.isEmpty()) { | 408 | if(!framework_in.isEmpty()) { |
310 | for(QStringList::ConstIterator outit = list2.begin(); outit != list2.end(); ++outit) { | 409 | for(QStringList::Iterator outit = ret.begin(); outit != ret.end(); ++outit) { |
311 | if((*outit).startsWith("-framework")) { | 410 | if((*outit).startsWith("-framework")) { |
312 | QString framework_out; | 411 | int found = 0; |
313 | if((*outit).length() > 11) { | 412 | if((*outit).length() > 11) { |
314 | framework_out = (*outit).mid(11); | 413 | if(framework_in == (*outit).mid(11)) |
414 | found = 1; | ||
315 | } else { | 415 | } else { |
316 | if(it != list2.end()) { | 416 | if(it != lst->end()) { |
317 | ++outit; | 417 | ++outit; |
318 | framework_out = (*outit); | 418 | if(framework_in == (*outit)) { |
419 | --outit; | ||
420 | found = 2; | ||
319 | } | 421 | } |
320 | } | 422 | } |
321 | if(framework_out == framework_in) { | ||
322 | unique = FALSE; | ||
323 | break; | ||
324 | } | 423 | } |
424 | for(int i = 0; i < found; i++) | ||
425 | outit = ret.remove(outit); | ||
325 | } | 426 | } |
326 | } | 427 | } |
327 | if(unique) { | ||
328 | unique = FALSE; //because I'm about to just insert it myself | ||
329 | if(as_one) { | 428 | if(as_one) { |
330 | ret.append("-framework " + framework_in); | 429 | ret.append("-framework " + framework_in); |
331 | } else { | 430 | } else { |
332 | ret.append("-framework"); | 431 | ret.append("-framework"); |
333 | ret.append(framework_in); | 432 | ret.append(framework_in); |
334 | } | 433 | } |
335 | } | 434 | } |
336 | } | ||
337 | } else { | 435 | } else { |
338 | unique = (list2.findIndex((*it)) == -1); | 436 | #if 1 |
437 | while(1) { | ||
438 | QStringList::Iterator idx = ret.find((*it)); | ||
439 | if(idx == ret.end()) | ||
440 | break; | ||
441 | ret.remove(idx); | ||
339 | } | 442 | } |
340 | } else if(QFile::exists((*it))) { | 443 | #endif |
341 | unique = (list2.findIndex((*it)) == -1); | 444 | ret.append((*it)); |
445 | } | ||
446 | } else /*if(QFile::exists((*it)))*/ { | ||
447 | while(1) { | ||
448 | QStringList::Iterator idx = ret.find((*it)); | ||
449 | if(idx == ret.end()) | ||
450 | break; | ||
451 | ret.remove(idx); | ||
342 | } | 452 | } |
343 | if(unique) | ||
344 | ret.append((*it)); | 453 | ret.append((*it)); |
345 | } | 454 | } |
455 | } | ||
456 | } | ||
346 | return ret; | 457 | return ret; |
347 | } | 458 | } |
348 | 459 | ||
349 | |||
350 | void | 460 | void |
351 | UnixMakefileGenerator::processPrlVariable(const QString &var, const QStringList &l) | 461 | UnixMakefileGenerator::processPrlVariable(const QString &var, const QStringList &l) |
352 | { | 462 | { |
353 | if(var == "QMAKE_PRL_LIBS") | 463 | if(var == "QMAKE_PRL_LIBS") |
354 | project->variables()["QMAKE_CURRENT_PRL_LIBS"] += uniqueSetLFlags(l, project->variables()["QMAKE_LIBS"]); | 464 | project->variables()["QMAKE_CURRENT_PRL_LIBS"] = combineSetLFlags(project->variables()["QMAKE_CURRENT_PRL_LIBS"] + |
465 | project->variables()["QMAKE_LIBS"], l); | ||
355 | else | 466 | else |
356 | MakefileGenerator::processPrlVariable(var, l); | 467 | MakefileGenerator::processPrlVariable(var, l); |
357 | } | 468 | } |
358 | 469 | ||
470 | QString | ||
471 | UnixMakefileGenerator::findDependency(const QString &dep) | ||
472 | { | ||
473 | QStringList::Iterator it; | ||
474 | { | ||
475 | QStringList &qut = project->variables()["QMAKE_EXTRA_UNIX_TARGETS"]; | ||
476 | for(it = qut.begin(); it != qut.end(); ++it) { | ||
477 | QString targ = var((*it) + ".target"); | ||
478 | if(targ.isEmpty()) | ||
479 | targ = (*it); | ||
480 | if(targ.endsWith(dep)) | ||
481 | return targ; | ||
482 | } | ||
483 | } | ||
484 | { | ||
485 | QStringList &quc = project->variables()["QMAKE_EXTRA_UNIX_COMPILERS"]; | ||
486 | for(it = quc.begin(); it != quc.end(); ++it) { | ||
487 | QString tmp_out = project->variables()[(*it) + ".output"].first(); | ||
488 | QString tmp_cmd = project->variables()[(*it) + ".commands"].join(" "); | ||
489 | if(tmp_out.isEmpty() || tmp_cmd.isEmpty()) | ||
490 | continue; | ||
491 | QStringList &tmp = project->variables()[(*it) + ".input"]; | ||
492 | for(QStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) { | ||
493 | QStringList &inputs = project->variables()[(*it2)]; | ||
494 | for(QStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) { | ||
495 | QString out = tmp_out; | ||
496 | QFileInfo fi(Option::fixPathToLocalOS((*input))); | ||
497 | out.replace("${QMAKE_FILE_BASE}", fi.baseName()); | ||
498 | out.replace("${QMAKE_FILE_NAME}", fi.fileName()); | ||
499 | if(out.endsWith(dep)) | ||
500 | return out; | ||
501 | } | ||
502 | } | ||
503 | } | ||
504 | } | ||
505 | return MakefileGenerator::findDependency(dep); | ||
506 | } | ||
507 | |||
508 | QStringList | ||
509 | &UnixMakefileGenerator::findDependencies(const QString &file) | ||
510 | { | ||
511 | QStringList &ret = MakefileGenerator::findDependencies(file); | ||
512 | // Note: The QMAKE_IMAGE_COLLECTION file have all images | ||
513 | // as dependency, so don't add precompiled header then | ||
514 | if(doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER") | ||
515 | && file != project->first("QMAKE_IMAGE_COLLECTION")) { | ||
516 | QString header_prefix = project->first("QMAKE_ORIG_TARGET") + ".gch" + Option::dir_sep; | ||
517 | header_prefix += project->first("QMAKE_PRECOMP_PREFIX"); | ||
518 | if(file.endsWith(".c")) { | ||
519 | QString precomp_h = header_prefix + "c"; | ||
520 | if(!ret.contains(precomp_h)) | ||
521 | ret += precomp_h; | ||
522 | } else { | ||
523 | for(QStringList::Iterator it = Option::cpp_ext.begin(); it != Option::cpp_ext.end(); ++it) { | ||
524 | if(file.endsWith(*it)) { | ||
525 | QString precomp_h = header_prefix + "c++"; | ||
526 | if(!ret.contains(precomp_h)) | ||
527 | ret += precomp_h; | ||
528 | break; | ||
529 | } | ||
530 | } | ||
531 | } | ||
532 | } | ||
533 | return ret; | ||
534 | } | ||
535 | |||
359 | bool | 536 | bool |
360 | UnixMakefileGenerator::findLibraries() | 537 | UnixMakefileGenerator::findLibraries() |
361 | { | 538 | { |
362 | QPtrList<MakefileDependDir> libdirs; | 539 | QPtrList<MakefileDependDir> libdirs; |
363 | libdirs.setAutoDelete(TRUE); | 540 | libdirs.setAutoDelete(TRUE); |
364 | const QString lflags[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_LIBS", QString::null }; | 541 | const QString lflags[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_LIBS", QString::null }; |
365 | for(int i = 0; !lflags[i].isNull(); i++) { | 542 | for(int i = 0; !lflags[i].isNull(); i++) { |
366 | QStringList &l = project->variables()[lflags[i]]; | 543 | QStringList &l = project->variables()[lflags[i]]; |
@@ -395,17 +572,17 @@ UnixMakefileGenerator::findLibraries() | |||
395 | } | 572 | } |
396 | QRegExp stub_reg("^.*lib(" + stub + "[^./=]*)\\.(.*)$"); | 573 | QRegExp stub_reg("^.*lib(" + stub + "[^./=]*)\\.(.*)$"); |
397 | if(stub_reg.exactMatch(stub)) { | 574 | if(stub_reg.exactMatch(stub)) { |
398 | stub = stub_reg.cap(1); | 575 | stub = stub_reg.cap(1); |
399 | extn = stub_reg.cap(2); | 576 | extn = stub_reg.cap(2); |
400 | } | 577 | } |
401 | } | 578 | } |
402 | if(!stub.isEmpty()) { | 579 | if(!stub.isEmpty()) { |
403 | const QString modifs[] = { "-mt", QString::null }; | 580 | const QString modifs[] = { "", "-mt", QString::null }; |
404 | for(int modif = 0; !modifs[modif].isNull(); modif++) { | 581 | for(int modif = 0; !modifs[modif].isNull(); modif++) { |
405 | bool found = FALSE; | 582 | bool found = FALSE; |
406 | QStringList extens; | 583 | QStringList extens; |
407 | if(!extn.isNull()) | 584 | if(!extn.isNull()) |
408 | extens << extn; | 585 | extens << extn; |
409 | else | 586 | else |
410 | extens << project->variables()["QMAKE_EXTENSION_SHLIB"].first() << "a"; | 587 | extens << project->variables()["QMAKE_EXTENSION_SHLIB"].first() << "a"; |
411 | for(QStringList::Iterator extit = extens.begin(); extit != extens.end(); ++extit) { | 588 | for(QStringList::Iterator extit = extens.begin(); extit != extens.end(); ++extit) { |
@@ -426,85 +603,114 @@ UnixMakefileGenerator::findLibraries() | |||
426 | } else { | 603 | } else { |
427 | if(QFile::exists("lib" + stub + modifs[modif] + "." + (*extit))) { | 604 | if(QFile::exists("lib" + stub + modifs[modif] + "." + (*extit))) { |
428 | (*it) = "lib" + stub + modifs[modif] + "." + (*extit); | 605 | (*it) = "lib" + stub + modifs[modif] + "." + (*extit); |
429 | found = TRUE; | 606 | found = TRUE; |
430 | break; | 607 | break; |
431 | } | 608 | } |
432 | } | 609 | } |
433 | } | 610 | } |
611 | if(!found && project->isActiveConfig("compile_libtool")) { | ||
612 | for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) { | ||
613 | if(QFile::exists(mdd->local_dir + Option::dir_sep + "lib" + stub + modifs[modif] + Option::libtool_ext)) { | ||
614 | (*it) = mdd->real_dir + Option::dir_sep + "lib" + stub + modifs[modif] + Option::libtool_ext; | ||
615 | found = TRUE; | ||
616 | break; | ||
617 | } | ||
618 | } | ||
619 | } | ||
434 | if(found) | 620 | if(found) |
435 | break; | 621 | break; |
622 | |||
436 | } | 623 | } |
437 | } | 624 | } |
438 | } | 625 | } |
439 | } | 626 | } |
440 | return FALSE; | 627 | return FALSE; |
441 | } | 628 | } |
442 | 629 | ||
630 | QString linkLib(const QString &file, const QString &libName) { | ||
631 | QString ret; | ||
632 | QRegExp reg("^.*lib(" + libName + "[^./=]*).*$"); | ||
633 | if(reg.exactMatch(file)) | ||
634 | ret = "-l" + reg.cap(1); | ||
635 | return ret; | ||
636 | } | ||
637 | |||
443 | void | 638 | void |
444 | UnixMakefileGenerator::processPrlFiles() | 639 | UnixMakefileGenerator::processPrlFiles() |
445 | { | 640 | { |
446 | QDict<void> processed; | 641 | QDict<void> processed; |
447 | QPtrList<MakefileDependDir> libdirs; | 642 | QPtrList<MakefileDependDir> libdirs; |
448 | libdirs.setAutoDelete(TRUE); | 643 | libdirs.setAutoDelete(TRUE); |
449 | const QString lflags[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_LIBS", QString::null }; | 644 | const QString lflags[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_LIBS", QString::null }; |
450 | for(int i = 0; !lflags[i].isNull(); i++) { | 645 | for(int i = 0; !lflags[i].isNull(); i++) { |
451 | for(bool ret = FALSE; TRUE; ret = FALSE) { | 646 | for(bool ret = FALSE; TRUE; ret = FALSE) { |
452 | QStringList l_out; | 647 | QStringList l_out; |
453 | QStringList &l = project->variables()[lflags[i]]; | 648 | QStringList &l = project->variables()[lflags[i]]; |
454 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { | 649 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { |
455 | project->variables()["QMAKE_CURRENT_PRL_LIBS"].clear(); | 650 | project->variables()["QMAKE_CURRENT_PRL_LIBS"].clear(); |
456 | QString opt = (*it).stripWhiteSpace();; | 651 | QString opt = (*it).stripWhiteSpace(); |
457 | if(opt.startsWith("-")) { | 652 | if(opt.startsWith("-")) { |
458 | if(opt.startsWith("-L")) { | 653 | if(opt.startsWith("-L")) { |
459 | QString r = opt.right(opt.length() - 2), l = r; | 654 | QString r = opt.right(opt.length() - 2), l = r; |
460 | fixEnvVariables(l); | 655 | fixEnvVariables(l); |
461 | libdirs.append(new MakefileDependDir(r.replace("\"",""), | 656 | libdirs.append(new MakefileDependDir(r.replace("\"",""), |
462 | l.replace("\"",""))); | 657 | l.replace("\"",""))); |
463 | } else if(opt.startsWith("-l") && !processed[opt]) { | 658 | } else if(opt.startsWith("-l") && !processed[opt]) { |
464 | QString lib = opt.right(opt.length() - 2), prl; | 659 | QString lib = opt.right(opt.length() - 2); |
465 | for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) { | 660 | for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) { |
466 | prl = mdd->local_dir + Option::dir_sep + "lib" + lib + Option::prl_ext; | 661 | if(!project->isActiveConfig("compile_libtool")) { //give them the .libs.. |
662 | QString la = mdd->local_dir + Option::dir_sep + "lib" + lib + Option::libtool_ext; | ||
663 | if(QFile::exists(la) && QFile::exists(mdd->local_dir + Option::dir_sep + ".libs")) { | ||
664 | l_out.append("-L" + mdd->real_dir + Option::dir_sep + ".libs"); | ||
665 | libdirs.append(new MakefileDependDir(mdd->real_dir + Option::dir_sep + ".libs", | ||
666 | mdd->local_dir + Option::dir_sep + ".libs")); | ||
667 | } | ||
668 | } | ||
669 | |||
670 | QString prl = mdd->local_dir + Option::dir_sep + "lib" + lib; | ||
467 | if(processPrlFile(prl)) { | 671 | if(processPrlFile(prl)) { |
468 | if(prl.startsWith(mdd->local_dir)) | 672 | if(prl.startsWith(mdd->local_dir)) |
469 | prl.replace(0, mdd->local_dir.length(), mdd->real_dir); | 673 | prl.replace(0, mdd->local_dir.length(), mdd->real_dir); |
470 | QRegExp reg("^.*lib(" + lib + "[^./=]*)\\..*$"); | 674 | opt = linkLib(prl, lib); |
471 | if(reg.exactMatch(prl)) | ||
472 | prl = "-l" + reg.cap(1); | ||
473 | opt = prl; | ||
474 | processed.insert(opt, (void*)1); | 675 | processed.insert(opt, (void*)1); |
475 | ret = TRUE; | 676 | ret = TRUE; |
476 | break; | 677 | break; |
477 | } | 678 | } |
478 | } | 679 | } |
479 | } else if(project->isActiveConfig("macx") && opt.startsWith("-framework")) { | 680 | } else if(project->isActiveConfig("macx") && opt.startsWith("-framework")) { |
480 | if(opt.length() > 11) { | 681 | if(opt.length() > 11) { |
481 | opt = opt.mid(11); | 682 | opt = opt.mid(11); |
482 | } else { | 683 | } else { |
483 | ++it; | 684 | ++it; |
484 | opt = (*it); | 685 | opt = (*it); |
485 | } | 686 | } |
486 | QString prl = "/System/Library/Frameworks/" + opt + | 687 | QString prl = "/System/Library/Frameworks/" + opt + |
487 | ".framework/" + opt + Option::prl_ext; | 688 | ".framework/" + opt; |
488 | if(processPrlFile(prl)) | 689 | if(processPrlFile(prl)) |
489 | ret = TRUE; | 690 | ret = TRUE; |
490 | l_out.append("-framework"); | 691 | l_out.append("-framework"); |
491 | } | 692 | } |
492 | if(!opt.isEmpty()) | 693 | if(!opt.isEmpty()) |
493 | l_out.append(opt); | 694 | l_out.append(opt); |
494 | l_out += uniqueSetLFlags(project->variables()["QMAKE_CURRENT_PRL_LIBS"], l_out); | 695 | l_out = combineSetLFlags(l_out, project->variables()["QMAKE_CURRENT_PRL_LIBS"]); |
495 | } else { | 696 | } else { |
496 | if(!processed[opt] && processPrlFile(opt)) { | 697 | QString lib = opt; |
497 | processed.insert(opt, (void*)1); | 698 | if(!processed[lib] && processPrlFile(lib)) { |
699 | processed.insert(lib, (void*)1); | ||
498 | ret = TRUE; | 700 | ret = TRUE; |
499 | } | 701 | } |
702 | #if 0 | ||
703 | if(ret) | ||
704 | opt = linkLib(lib, ""); | ||
705 | #endif | ||
500 | if(!opt.isEmpty()) | 706 | if(!opt.isEmpty()) |
501 | l_out.append(opt); | 707 | l_out.append(opt); |
502 | l_out += uniqueSetLFlags(project->variables()["QMAKE_CURRENT_PRL_LIBS"], l_out); | 708 | l_out = combineSetLFlags(l_out, project->variables()["QMAKE_CURRENT_PRL_LIBS"]); |
503 | } | 709 | } |
504 | } | 710 | } |
505 | if(ret && l != l_out) | 711 | if(ret && l != l_out) |
506 | l = l_out; | 712 | l = l_out; |
507 | else | 713 | else |
508 | break; | 714 | break; |
509 | } | 715 | } |
510 | } | 716 | } |
@@ -532,49 +738,116 @@ UnixMakefileGenerator::defaultInstall(const QString &t) | |||
532 | if(project->first("TEMPLATE") == "app") { | 738 | if(project->first("TEMPLATE") == "app") { |
533 | target = "$(QMAKE_TARGET)"; | 739 | target = "$(QMAKE_TARGET)"; |
534 | if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) { | 740 | if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) { |
535 | destdir += "../../../"; | 741 | destdir += "../../../"; |
536 | target += ".app"; | 742 | target += ".app"; |
537 | resource = TRUE; | 743 | resource = TRUE; |
538 | } | 744 | } |
539 | } else if(project->first("TEMPLATE") == "lib") { | 745 | } else if(project->first("TEMPLATE") == "lib") { |
540 | if(project->isActiveConfig("create_prl") && !project->isEmpty("QMAKE_INTERNAL_PRL_FILE")) { | 746 | if(project->isActiveConfig("create_prl") && !project->isActiveConfig("no_install_prl") && |
747 | !project->isEmpty("QMAKE_INTERNAL_PRL_FILE")) { | ||
541 | QString dst_prl = project->first("QMAKE_INTERNAL_PRL_FILE"); | 748 | QString dst_prl = project->first("QMAKE_INTERNAL_PRL_FILE"); |
542 | int slsh = dst_prl.findRev('/'); | 749 | int slsh = dst_prl.findRev('/'); |
543 | if(slsh != -1) | 750 | if(slsh != -1) |
544 | dst_prl = dst_prl.right(dst_prl.length() - slsh - 1); | 751 | dst_prl = dst_prl.right(dst_prl.length() - slsh - 1); |
545 | dst_prl = root + targetdir + dst_prl; | 752 | dst_prl = root + targetdir + dst_prl; |
546 | ret += "-$(COPY) \"" + project->first("QMAKE_INTERNAL_PRL_FILE") + "\" \"" + dst_prl + "\""; | 753 | ret += "-$(INSTALL_FILE) \"" + project->first("QMAKE_INTERNAL_PRL_FILE") + "\" \"" + dst_prl + "\""; |
547 | if(!uninst.isEmpty()) | 754 | if(!uninst.isEmpty()) |
548 | uninst.append("\n\t"); | 755 | uninst.append("\n\t"); |
549 | uninst.append("-$(DEL_FILE) \"" + dst_prl + "\""); | 756 | uninst.append("-$(DEL_FILE) \"" + dst_prl + "\""); |
550 | } | 757 | } |
758 | if(project->isActiveConfig("create_libtool") && !project->isActiveConfig("compile_libtool")) { | ||
759 | QString src_lt = var("QMAKE_ORIG_TARGET"); | ||
760 | int slsh = src_lt.findRev(Option::dir_sep); | ||
761 | if(slsh != -1) | ||
762 | src_lt = src_lt.right(src_lt.length() - slsh); | ||
763 | int dot = src_lt.find('.'); | ||
764 | if(dot != -1) | ||
765 | src_lt = src_lt.left(dot); | ||
766 | src_lt += Option::libtool_ext; | ||
767 | src_lt.prepend("lib"); | ||
768 | QString dst_lt = root + targetdir + src_lt; | ||
769 | if(!project->isEmpty("DESTDIR")) { | ||
770 | src_lt.prepend(var("DESTDIR")); | ||
771 | src_lt = Option::fixPathToLocalOS(fileFixify(src_lt, | ||
772 | QDir::currentDirPath(), Option::output_dir)); | ||
773 | } | ||
774 | if(!ret.isEmpty()) | ||
775 | ret += "\n\t"; | ||
776 | ret += "-$(INSTALL_FILE) \"" + src_lt + "\" \"" + dst_lt + "\""; | ||
777 | if(!uninst.isEmpty()) | ||
778 | uninst.append("\n\t"); | ||
779 | uninst.append("-$(DEL_FILE) \"" + dst_lt + "\""); | ||
780 | } | ||
781 | if(project->isActiveConfig("create_pc")) { | ||
782 | QString src_pc = var("QMAKE_ORIG_TARGET"); | ||
783 | int slsh = src_pc.findRev(Option::dir_sep); | ||
784 | if(slsh != -1) | ||
785 | src_pc = src_pc.right(src_pc.length() - slsh); | ||
786 | int dot = src_pc.find('.'); | ||
787 | if(dot != -1) | ||
788 | src_pc = src_pc.left(dot); | ||
789 | src_pc += ".pc"; | ||
790 | QString d = root + targetdir + "pkgconfig" + Option::dir_sep; | ||
791 | QString dst_pc = d + src_pc; | ||
792 | if(!project->isEmpty("DESTDIR")) { | ||
793 | src_pc.prepend(var("DESTDIR")); | ||
794 | src_pc = Option::fixPathToLocalOS(fileFixify(src_pc, | ||
795 | QDir::currentDirPath(), Option::output_dir)); | ||
796 | } | ||
797 | if(!ret.isEmpty()) | ||
798 | ret += "\n\t"; | ||
799 | ret += mkdir_p_asstring(d) + "\n\t"; | ||
800 | ret += "-$(INSTALL_FILE) \"" + src_pc + "\" \"" + dst_pc + "\""; | ||
801 | if(!uninst.isEmpty()) | ||
802 | uninst.append("\n\t"); | ||
803 | uninst.append("-$(DEL_FILE) \"" + dst_pc + "\""); | ||
804 | } | ||
551 | if ( project->isEmpty("QMAKE_CYGWIN_SHLIB") ) { | 805 | if ( project->isEmpty("QMAKE_CYGWIN_SHLIB") ) { |
552 | if ( !project->isActiveConfig("staticlib") && !project->isActiveConfig("plugin") ) { | 806 | if ( !project->isActiveConfig("staticlib") && !project->isActiveConfig("plugin") ) { |
553 | if ( project->isEmpty("QMAKE_HPUX_SHLIB") ) { | 807 | if ( project->isEmpty("QMAKE_HPUX_SHLIB") ) { |
554 | links << "$(TARGET0)" << "$(TARGET1)" << "$(TARGET2)"; | 808 | links << "$(TARGET0)" << "$(TARGET1)" << "$(TARGET2)"; |
555 | } else { | 809 | } else { |
556 | links << "$(TARGET0)"; | 810 | links << "$(TARGET0)"; |
557 | } | 811 | } |
558 | } | 812 | } |
559 | } | 813 | } |
560 | } | 814 | } |
815 | |||
816 | if(!resource && project->isActiveConfig("compile_libtool")) { | ||
817 | QString src_targ = target; | ||
818 | if(src_targ == "$(TARGET)") | ||
819 | src_targ = "$(TARGETL)"; | ||
820 | QString dst_dir = fileFixify(targetdir); | ||
821 | if(QDir::isRelativePath(dst_dir)) | ||
822 | dst_dir = Option::fixPathToTargetOS(Option::output_dir + Option::dir_sep + dst_dir); | ||
823 | ret = "-$(LIBTOOL) --mode=install cp \"" + src_targ + "\" \"" + root + dst_dir + "\""; | ||
824 | uninst.append("-$(LIBTOOL) --mode=uninstall \"" + src_targ + "\""); | ||
825 | } else { | ||
561 | QString src_targ = target; | 826 | QString src_targ = target; |
562 | if(!destdir.isEmpty()) | 827 | if(!destdir.isEmpty()) |
563 | src_targ = Option::fixPathToTargetOS(destdir + target, FALSE); | 828 | src_targ = Option::fixPathToTargetOS(destdir + target, FALSE); |
564 | QString dst_targ = root + fileFixify(targetdir + target); | 829 | QString dst_targ = root + fileFixify(targetdir + target, |
830 | QDir::currentDirPath(), Option::output_dir); | ||
565 | if(!ret.isEmpty()) | 831 | if(!ret.isEmpty()) |
566 | ret += "\n\t"; | 832 | ret += "\n\t"; |
567 | ret += QString(resource ? "-$(COPY_DIR)" : "-$(COPY)") + " \"" + | 833 | if(resource) |
834 | ret += "$(DEL_FILE) -r \"" + dst_targ + "\"" + "\n\t"; | ||
835 | if(!ret.isEmpty()) | ||
836 | ret += "\n\t"; | ||
837 | ret += QString(resource ? "-$(INSTALL_DIR)" : "-$(INSTALL_FILE)") + " \"" + | ||
568 | src_targ + "\" \"" + dst_targ + "\""; | 838 | src_targ + "\" \"" + dst_targ + "\""; |
569 | if(!project->isActiveConfig("debug") && !project->isEmpty("QMAKE_STRIP")) { | 839 | if(!project->isActiveConfig("debug") && !project->isEmpty("QMAKE_STRIP") && |
840 | (project->first("TEMPLATE") != "lib" || !project->isActiveConfig("staticlib"))) { | ||
570 | ret += "\n\t-" + var("QMAKE_STRIP"); | 841 | ret += "\n\t-" + var("QMAKE_STRIP"); |
571 | if(!project->isEmpty("QMAKE_STRIPFLAGS_LIB") && project->first("TEMPLATE") == "lib") | 842 | if(project->first("TEMPLATE") == "lib" && !project->isEmpty("QMAKE_STRIPFLAGS_LIB")) |
572 | ret += " " + var("QMAKE_STRIPFLAGS_LIB"); | 843 | ret += " " + var("QMAKE_STRIPFLAGS_LIB"); |
844 | else if(project->first("TEMPLATE") == "app" && !project->isEmpty("QMAKE_STRIPFLAGS_APP")) | ||
845 | ret += " " + var("QMAKE_STRIPFLAGS_APP"); | ||
573 | if(resource) | 846 | if(resource) |
574 | ret = " \"" + dst_targ + "/Contents/MacOS/$(QMAKE_TARGET)\""; | 847 | ret = " \"" + dst_targ + "/Contents/MacOS/$(QMAKE_TARGET)\""; |
575 | else | 848 | else |
576 | ret += " \"" + dst_targ + "\""; | 849 | ret += " \"" + dst_targ + "\""; |
577 | } | 850 | } |
578 | if(!uninst.isEmpty()) | 851 | if(!uninst.isEmpty()) |
579 | uninst.append("\n\t"); | 852 | uninst.append("\n\t"); |
580 | if(resource) | 853 | if(resource) |
@@ -586,19 +859,19 @@ UnixMakefileGenerator::defaultInstall(const QString &t) | |||
586 | if(Option::target_mode == Option::TARG_WIN_MODE || | 859 | if(Option::target_mode == Option::TARG_WIN_MODE || |
587 | Option::target_mode == Option::TARG_MAC9_MODE) { | 860 | Option::target_mode == Option::TARG_MAC9_MODE) { |
588 | } else if(Option::target_mode == Option::TARG_UNIX_MODE || | 861 | } else if(Option::target_mode == Option::TARG_UNIX_MODE || |
589 | Option::target_mode == Option::TARG_MACX_MODE) { | 862 | Option::target_mode == Option::TARG_MACX_MODE) { |
590 | QString link = Option::fixPathToTargetOS(destdir + (*it), FALSE); | 863 | QString link = Option::fixPathToTargetOS(destdir + (*it), FALSE); |
591 | int lslash = link.findRev(Option::dir_sep); | 864 | int lslash = link.findRev(Option::dir_sep); |
592 | if(lslash != -1) | 865 | if(lslash != -1) |
593 | link = link.right(link.length() - (lslash + 1)); | 866 | link = link.right(link.length() - (lslash + 1)); |
594 | QString dst_link = root + fileFixify(targetdir + link); | 867 | QString dst_link = root + targetdir + link; |
595 | ret += "\n\t-$(SYMLINK) \"$(TARGET)\" \"" + dst_link + "\""; | 868 | ret += "\n\t-$(SYMLINK) \"$(TARGET)\" \"" + dst_link + "\""; |
596 | if(!uninst.isEmpty()) | 869 | if(!uninst.isEmpty()) |
597 | uninst.append("\n\t"); | 870 | uninst.append("\n\t"); |
598 | uninst.append("-$(DEL_FILE) \"" + dst_link + "\""); | 871 | uninst.append("-$(DEL_FILE) \"" + dst_link + "\""); |
599 | } | 872 | } |
600 | } | 873 | } |
601 | } | 874 | } |
875 | } | ||
602 | return ret; | 876 | return ret; |
603 | } | 877 | } |
604 | |||