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