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