]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | ||
3 | # ------------------------------------------------------------------------- | |
4 | # Configured settings: | |
5 | # ------------------------------------------------------------------------- | |
6 | ||
7 | # Version and build type information: | |
8 | ||
9 | WX_MAJOR_VERSION_NUMBER="@WX_MAJOR_VERSION_NUMBER@" | |
10 | WX_MINOR_VERSION_NUMBER="@WX_MINOR_VERSION_NUMBER@" | |
11 | WX_RELEASE_NUMBER="@WX_RELEASE_NUMBER@" | |
12 | release="@WX_MAJOR_VERSION_NUMBER@.@WX_MINOR_VERSION_NUMBER@" | |
13 | is_monolithic="@MONOLITHIC@" | |
14 | cross_compiling="@cross_compiling@" | |
15 | target="@host_alias@" | |
16 | static_flag="@STATIC_FLAG@" | |
17 | ||
18 | ||
19 | # Misc configuration variables: | |
20 | ||
21 | update_prefixes() | |
22 | { | |
23 | includedir="@includedir@" | |
24 | libdir="@libdir@" | |
25 | } | |
26 | prefix="@prefix@" | |
27 | exec_prefix="@exec_prefix@" | |
28 | update_prefixes | |
29 | ||
30 | CC="@CC@" | |
31 | GCC="@GCC@" | |
32 | CXX="@CXX@" | |
33 | LD="@SHARED_LD@" | |
34 | srcdir="@top_srcdir@" | |
35 | builddir="@top_builddir_wxconfig@" | |
36 | basename_nogui="@WX_LIBRARY_BASENAME_NOGUI@" | |
37 | basename_gui="@WX_LIBRARY_BASENAME_GUI@" | |
38 | ||
39 | TOOLCHAIN_NAME="@TOOLCHAIN_NAME@" | |
40 | LDFLAGS="@LDFLAGS@" | |
41 | WXCONFIG_RPATH="@WXCONFIG_RPATH@" | |
42 | DMALLOC_LIBS="@DMALLOC_LIBS@" | |
43 | WXCONFIG_LIBS="@WXCONFIG_LIBS@" | |
44 | WXCONFIG_LIBS_STATIC="@WXCONFIG_LIBS_STATIC@" | |
45 | WXDEBUG_DEFINE="@WXDEBUG_DEFINE@" | |
46 | TOOLCHAIN_DEFS="@TOOLCHAIN_DEFS@" | |
47 | TOOLCHAIN_DLL_DEFS="@TOOLCHAIN_DLL_DEFS@" | |
48 | WXCONFIG_INCLUDE="@WXCONFIG_INCLUDE@" | |
49 | WX_LARGEFILE_FLAGS="@WX_LARGEFILE_FLAGS@" | |
50 | CODE_GEN_FLAGS="@CODE_GEN_FLAGS@" | |
51 | CODE_GEN_FLAGS_CXX="@CODE_GEN_FLAGS_CXX@" | |
52 | LDFLAGS_EXE="@LDFLAGS_EXE@" | |
53 | MACRESWXCONFIG="@MACRESWXCONFIG@" | |
54 | EXTRALIBS_GUI="@EXTRALIBS_GUI@" | |
55 | LIBS="@LIBS@" | |
56 | WXCONFIG_LDFLAGS_GUI="@WXCONFIG_LDFLAGS_GUI@" | |
57 | ||
58 | ||
59 | # Linker flags for sublibraries: | |
60 | ||
61 | CORE_BASE_LIBS="@CORE_BASE_LIBS@" | |
62 | CORE_GUI_LIBS="@CORE_GUI_LIBS@" | |
63 | ||
64 | ldlibs_base="@WXCONFIG_EXTRALIBS@" | |
65 | ldlibs_core="@EXTRALIBS_GUI@" | |
66 | ldlibs_xml="@EXTRALIBS_XML@" | |
67 | ldlibs_html="@EXTRALIBS_HTML@" | |
68 | ldlibs_odbc="@EXTRALIBS_ODBC@" | |
69 | ldlibs_adv="@EXTRALIBS_SDL@" | |
70 | ||
71 | ldflags_gl="@LDFLAGS_GL@" | |
72 | ldlibs_gl="@OPENGL_LIBS@" | |
73 | ||
74 | ||
75 | ||
76 | # ------------------------------------------------------------------------- | |
77 | # Script code: | |
78 | # ------------------------------------------------------------------------- | |
79 | ||
80 | exec_prefix_set=no | |
81 | ||
82 | # is $1 among the rest of arguments? | |
83 | isinlist() | |
84 | { | |
85 | value=$1 | |
86 | shift | |
87 | isin=no | |
88 | for iii in $* ; do | |
89 | if test $iii = $value ; then isin=yes ; fi | |
90 | done | |
91 | test $isin = yes | |
92 | } | |
93 | ||
94 | # output linker commands needed to link against libraries passed as arguments | |
95 | # (does not handle monolithic/multilib): | |
96 | output_libs() | |
97 | { | |
98 | if test "$cross_compiling" = "yes" ; then | |
99 | target_tag="-${target}" | |
100 | fi | |
101 | ||
102 | all_libs="" | |
103 | all_ldflags="" | |
104 | wxlibs="" | |
105 | ||
106 | for lib in $* ; do | |
107 | eval xlibs=\$ldlibs_$lib | |
108 | eval xflags=\$ldflags_$lib | |
109 | if isinlist $lib $CORE_BASE_LIBS ; then | |
110 | basename=$basename_nogui | |
111 | else | |
112 | basename=$basename_gui | |
113 | fi | |
114 | if test $lib = "base" ; then | |
115 | libname="$basename" | |
116 | else | |
117 | libname="${basename}_${lib}" | |
118 | fi | |
119 | ||
120 | all_ldflags="$all_ldflags $xflags" | |
121 | if test $static_flag = yes ; then | |
122 | wxlibs="$wxlibs ${libdir}/lib${libname}-${release}${target_tag}.a" | |
123 | all_libs="$all_libs $xlibs" | |
124 | else | |
125 | wxlibs="$wxlibs -l${libname}-${release}${target_tag}" | |
126 | fi | |
127 | done | |
128 | ||
129 | echo $all_ldflags $wxlibs $all_libs | |
130 | } | |
131 | ||
132 | # output $(WXCONFIG_LDFLAGS_GUI) if any of libs passed as arguments is GUI | |
133 | # library, nothing otherwise: | |
134 | get_ldflags_gui() | |
135 | { | |
136 | flags_to_ret="" | |
137 | for lib in $* ; do | |
138 | if isinlist $lib $CORE_GUI_LIBS ; then | |
139 | flags_to_ret="$WXCONFIG_LDFLAGS_GUI" | |
140 | fi | |
141 | done | |
142 | echo $flags_to_ret | |
143 | } | |
144 | ||
145 | # return the absolute path prepending builddir to it if needed | |
146 | makeabs() | |
147 | { | |
148 | path=$1 | |
149 | # TODO: this only works under Unix and even there it could be | |
150 | # enhanced to remove ".." and "." | |
151 | if [ `echo $path | sed 's/^\(.\).*/\1/'` != "/" ]; then | |
152 | if [ $path = "." ]; then | |
153 | path=$builddir | |
154 | else | |
155 | path="$builddir/$path" | |
156 | fi | |
157 | fi | |
158 | ||
159 | echo $path | |
160 | } | |
161 | ||
162 | usage() | |
163 | { | |
164 | cat <<EOF | |
165 | Usage: wx-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--release] | |
166 | [--basename] [--static] [--libs[=LIBS]] [--gl-libs] | |
167 | [--cppflags] [--cflags] [--cxxflags] [--ldflags] [--rezflags] | |
168 | [--cc] [--cxx] [--ld] | |
169 | ||
170 | wx-config returns configuration information about the installed | |
171 | version of wxWindows. It may be used to query its version and | |
172 | installation directories and also retrieve the C and C++ compilers | |
173 | and linker which were used for its building and the corresponding | |
174 | flags. | |
175 | ||
176 | Ordinarily it should be installed to the appropriate system location | |
177 | along with the headers and library files, but it is also possible to | |
178 | use it to enable builds with an uninstalled wxWindows version for | |
179 | package building and bleeding edge developers. To do so, use it like | |
180 | this: | |
181 | ||
182 | \${wx_builddir}/wx-config --prefix=\${wx_srcdir} --exec-prefix=\${wx_builddir} | |
183 | ||
184 | Note that any other options supplied must come *after* the prefix | |
185 | specification for it to take effect. | |
186 | ||
187 | --static must come before --libs and --gl-libs. | |
188 | ||
189 | --libs can take optional argument that contains comma-separated list of | |
190 | wxWindows libraries to link against. This list can include both core | |
191 | and contrib libraries. | |
192 | ||
193 | --gl-libs option is deprecated, used --libs=gl instead. | |
194 | ||
195 | EOF | |
196 | ||
197 | exit $1 | |
198 | } | |
199 | ||
200 | cppflags() | |
201 | { | |
202 | # we should never specify -I/usr/include on the compiler command line: this | |
203 | # is at best useless and at worst breaks compilation on the systems where | |
204 | # the system headers are non-ANSI because gcc works around this by storing | |
205 | # the ANSI-fied versions of them in its private directory which is searched | |
206 | # after all the directories on the cmd line. | |
207 | # | |
208 | # the situation is a bit more complicated with -I/usr/local/include: again, | |
209 | # it shouldn't be specified with gcc which looks there by default anyhow | |
210 | # and gives warnings (at least 3.1 does) if it is specified explicitly -- | |
211 | # but this -I switch *is* needed for the other compilers | |
212 | # | |
213 | # note that we assume that if we use GNU cc we also use GNU c++ and vice | |
214 | # versa, i.e. this won't work (either for --cflags or --cxxflags) if GNU C | |
215 | # compiler and non-GNU C++ compiler are used or vice versa -- we'll fix | |
216 | # this when/if anybody complains about it | |
217 | if test "${includedir}" != "/usr/include" \ | |
218 | -a "${includedir}" != "/usr/include/c++" \ | |
219 | -a \( "${GCC}" != "yes" \ | |
220 | -o "${includedir}" != "/usr/local/include" \) \ | |
221 | -a \( "${cross_compiling}" != "yes" \ | |
222 | -o "${includedir}" != "/usr/${target}/include" \) ; | |
223 | then | |
224 | includes=" -I${includedir}" | |
225 | fi | |
226 | ||
227 | includes="-I${libdir}/wx/include/${TOOLCHAIN_NAME}$includes" | |
228 | ||
229 | if test $static_flag = yes ; then | |
230 | echo $includes ${WXDEBUG_DEFINE} ${TOOLCHAIN_DEFS} ${WXCONFIG_INCLUDE} ${WX_LARGEFILE_FLAGS} | |
231 | else | |
232 | echo $includes ${WXDEBUG_DEFINE} ${TOOLCHAIN_DEFS} ${TOOLCHAIN_DLL_DEFS} ${WXCONFIG_INCLUDE} ${WX_LARGEFILE_FLAGS} | |
233 | fi | |
234 | } | |
235 | ||
236 | if test $# -eq 0; then | |
237 | usage 1 1>&2 | |
238 | fi | |
239 | ||
240 | while test $# -gt 0; do | |
241 | case "$1" in | |
242 | -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; | |
243 | *) optarg= ;; | |
244 | esac | |
245 | ||
246 | case $1 in | |
247 | --inplace) | |
248 | prefix=`makeabs $srcdir` | |
249 | exec_prefix=`makeabs $builddir` | |
250 | exec_prefix_set=yes | |
251 | update_prefixes | |
252 | ;; | |
253 | --prefix=*) | |
254 | prefix=$optarg | |
255 | if test $exec_prefix_set = no ; then | |
256 | exec_prefix=$optarg | |
257 | fi | |
258 | update_prefixes | |
259 | ;; | |
260 | --prefix) | |
261 | echo $prefix | |
262 | ;; | |
263 | --exec-prefix=*) | |
264 | exec_prefix=$optarg | |
265 | exec_prefix_set=yes | |
266 | update_prefixes | |
267 | ;; | |
268 | --exec-prefix) | |
269 | echo $exec_prefix | |
270 | ;; | |
271 | --version) | |
272 | echo ${WX_MAJOR_VERSION_NUMBER}.${WX_MINOR_VERSION_NUMBER}.${WX_RELEASE_NUMBER} | |
273 | ;; | |
274 | --release) | |
275 | echo $release | |
276 | ;; | |
277 | --basename) | |
278 | echo $basename_gui | |
279 | ;; | |
280 | --static) | |
281 | static_flag=yes | |
282 | ;; | |
283 | --cppflags) | |
284 | cppflags | |
285 | ;; | |
286 | --cflags) | |
287 | echo `cppflags` ${CODE_GEN_FLAGS} | |
288 | ;; | |
289 | --cxxflags) | |
290 | echo `cppflags` ${CODE_GEN_FLAGS} ${CODE_GEN_FLAGS_CXX} | |
291 | ;; | |
292 | --ldflags) | |
293 | echo ${LDFLAGS_EXE} | |
294 | ;; | |
295 | --rezflags) | |
296 | echo `eval echo ${MACRESWXCONFIG}` | |
297 | ;; | |
298 | ||
299 | --libs*) | |
300 | # find if the argument was --libs=list,of,libs or --libs: | |
301 | if test "x$optarg" = "x" ; then | |
302 | if test "$is_monolithic" = "0" ; then | |
303 | # link against all libs if none given explicitly: | |
304 | libs_list="$CORE_GUI_LIBS $CORE_BASE_LIBS" | |
305 | fi | |
306 | else | |
307 | libs_list=`echo "$optarg" | tr ',' ' '` | |
308 | # always add wxBase, any wxApp needs it: | |
309 | libs_list="$libs_list base" | |
310 | fi | |
311 | ||
312 | # include install directory only if it is not default: | |
313 | if test "${libdir}" != "/usr/lib" \ | |
314 | -a \( "${cross_compiling}" != "yes" \ | |
315 | -o "${libdir}" != "/usr/${target}/lib" \) ; | |
316 | then | |
317 | libs="-L${libdir}" | |
318 | fi | |
319 | ||
320 | # in monolithic build, link against the main library: | |
321 | if test "$is_monolithic" = "1" ; then | |
322 | # filter out core libs, leave only contrib in libs_list: | |
323 | newlist= | |
324 | for i in $libs_list ; do | |
325 | if isinlist $i $CORE_BASE_LIBS $CORE_GUI_LIBS ; then | |
326 | libs_list="" # do nothing | |
327 | else | |
328 | newlist="$newlist $i" | |
329 | fi | |
330 | done | |
331 | libs_list="$newlist" | |
332 | ||
333 | # output link flags: | |
334 | contrib_libs=`output_libs $libs_list` | |
335 | if test $static_flag = yes ; then | |
336 | echo "$libs ${LDFLAGS} ${WXCONFIG_LDFLAGS_GUI} ${WXCONFIG_RPATH} $contrib_libs ${libdir}/${WXCONFIG_LIBS_STATIC} ${EXTRALIBS_GUI} ${LIBS} ${DMALLOC_LIBS}" | |
337 | else | |
338 | echo $libs ${LDFLAGS} ${WXCONFIG_LDFLAGS_GUI} ${WXCONFIG_RPATH} $contrib_libs ${WXCONFIG_LIBS} ${DMALLOC_LIBS} | |
339 | fi | |
340 | else | |
341 | # in multilib mode, link against all sublibraries: | |
342 | wxlibs=`output_libs $libs_list` | |
343 | guildflags=`get_ldflags_gui $libs_list` | |
344 | echo $libs ${LDFLAGS} ${guildflags} ${WXCONFIG_RPATH} $wxlibs ${DMALLOC_LIBS} | |
345 | fi | |
346 | ||
347 | ;; | |
348 | --gl-libs) | |
349 | output_libs gl | |
350 | ;; | |
351 | --cc) | |
352 | echo $CC | |
353 | ;; | |
354 | --cxx) | |
355 | echo $CXX | |
356 | ;; | |
357 | --ld) | |
358 | echo $LD | |
359 | ;; | |
360 | *) | |
361 | usage 1 1>&2 | |
362 | ;; | |
363 | esac | |
364 | shift | |
365 | done | |
366 |