]> git.saurik.com Git - wxWidgets.git/blame - wx-config.in
size combobox/choices properly initially by considering the length of the strings...
[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@"
3527f29c 67ldlibs_html="@EXTRALIBS_HTML@"
bb41dcbe 68ldlibs_odbc="@EXTRALIBS_ODBC@"
f93ca9fd 69ldlibs_adv="@EXTRALIBS_SDL@"
cf615ebb
VS
70
71ldflags_gl="@LDFLAGS_GL@"
72ldlibs_gl="@OPENGL_LIBS@"
73
74
33380099
VS
75
76# -------------------------------------------------------------------------
77# Script code:
78# -------------------------------------------------------------------------
79
80exec_prefix_set=no
81
cf615ebb
VS
82# is $1 among the rest of arguments?
83isinlist()
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):
96output_libs()
97{
67c13b6c
VS
98 if test "$cross_compiling" = "yes" ; then
99 target_tag="-${target}"
100 fi
101
cf615ebb
VS
102 all_libs=""
103 all_ldflags=""
104 wxlibs=""
67c13b6c 105
cf615ebb
VS
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
fef23dd4
VS
114 if test $lib = "base" ; then
115 libname="$basename"
116 else
117 libname="${basename}_${lib}"
118 fi
cf615ebb
VS
119
120 all_ldflags="$all_ldflags $xflags"
121 if test $static_flag = yes ; then
33380099 122 wxlibs="$wxlibs ${libdir}/lib${libname}-${release}${target_tag}.a"
cf615ebb
VS
123 all_libs="$all_libs $xlibs"
124 else
67c13b6c 125 wxlibs="$wxlibs -l${libname}-${release}${target_tag}"
cf615ebb
VS
126 fi
127 done
128
129 echo $all_ldflags $wxlibs $all_libs
130}
9a98a854 131
ffef10f6
VS
132# output $(WXCONFIG_LDFLAGS_GUI) if any of libs passed as arguments is GUI
133# library, nothing otherwise:
134get_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
52c71b80
VZ
145# return the absolute path prepending builddir to it if needed
146makeabs()
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
75f4be8a
VZ
162usage()
163{
164 cat <<EOF
2f42e5b6 165Usage: wx-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--release]
cf615ebb 166 [--basename] [--static] [--libs[=LIBS]] [--gl-libs]
40f7145c 167 [--cppflags] [--cflags] [--cxxflags] [--ldflags] [--rezflags]
75f4be8a
VZ
168 [--cc] [--cxx] [--ld]
169
170wx-config returns configuration information about the installed
171version of wxWindows. It may be used to query its version and
172installation directories and also retrieve the C and C++ compilers
173and linker which were used for its building and the corresponding
174flags.
2b5f62a0 175
82a649b6
RL
176Ordinarily it should be installed to the appropriate system location
177along with the headers and library files, but it is also possible to
178use it to enable builds with an uninstalled wxWindows version for
179package building and bleeding edge developers. To do so, use it like
180this:
181
dc5e3b9e 182\${wx_builddir}/wx-config --prefix=\${wx_srcdir} --exec-prefix=\${wx_builddir}
82a649b6
RL
183
184Note that any other options supplied must come *after* the prefix
185specification for it to take effect.
186
cf615ebb
VS
187--static must come before --libs and --gl-libs.
188
189--libs can take optional argument that contains comma-separated list of
190wxWindows libraries to link against. This list can include both core
191and contrib libraries.
192
67c13b6c
VS
193--gl-libs option is deprecated, used --libs=gl instead.
194
75f4be8a
VZ
195EOF
196
197 exit $1
198}
199
200cppflags()
201{
2b5f62a0
VZ
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
33380099
VS
217 if test "${includedir}" != "/usr/include" \
218 -a "${includedir}" != "/usr/include/c++" \
2b5f62a0 219 -a \( "${GCC}" != "yes" \
33380099 220 -o "${includedir}" != "/usr/local/include" \) \
77e13408 221 -a \( "${cross_compiling}" != "yes" \
33380099 222 -o "${includedir}" != "/usr/${target}/include" \) ;
3a922bb4 223 then
33380099 224 includes=" -I${includedir}"
75f4be8a 225 fi
00c81359 226
33380099 227 includes="-I${libdir}/wx/include/${TOOLCHAIN_NAME}$includes"
00c81359
RL
228
229 if test $static_flag = yes ; then
33380099 230 echo $includes ${WXDEBUG_DEFINE} ${TOOLCHAIN_DEFS} ${WXCONFIG_INCLUDE} ${WX_LARGEFILE_FLAGS}
00c81359 231 else
33380099 232 echo $includes ${WXDEBUG_DEFINE} ${TOOLCHAIN_DEFS} ${TOOLCHAIN_DLL_DEFS} ${WXCONFIG_INCLUDE} ${WX_LARGEFILE_FLAGS}
00c81359 233 fi
75f4be8a 234}
9a98a854
VZ
235
236if test $# -eq 0; then
3a922bb4 237 usage 1 1>&2
9a98a854
VZ
238fi
239
240while 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
52c71b80
VZ
247 --inplace)
248 prefix=`makeabs $srcdir`
249 exec_prefix=`makeabs $builddir`
250 exec_prefix_set=yes
0154f61a 251 update_prefixes
52c71b80 252 ;;
9a98a854
VZ
253 --prefix=*)
254 prefix=$optarg
255 if test $exec_prefix_set = no ; then
256 exec_prefix=$optarg
257 fi
0154f61a 258 update_prefixes
9a98a854
VZ
259 ;;
260 --prefix)
261 echo $prefix
262 ;;
263 --exec-prefix=*)
264 exec_prefix=$optarg
265 exec_prefix_set=yes
0154f61a 266 update_prefixes
9a98a854
VZ
267 ;;
268 --exec-prefix)
269 echo $exec_prefix
270 ;;
271 --version)
33380099 272 echo ${WX_MAJOR_VERSION_NUMBER}.${WX_MINOR_VERSION_NUMBER}.${WX_RELEASE_NUMBER}
9a98a854 273 ;;
2f42e5b6 274 --release)
cf615ebb 275 echo $release
2f42e5b6
VS
276 ;;
277 --basename)
9171d4b4 278 echo $basename_gui
2f42e5b6 279 ;;
3d63bc3a
RL
280 --static)
281 static_flag=yes
282 ;;
75f4be8a
VZ
283 --cppflags)
284 cppflags
285 ;;
9a98a854 286 --cflags)
33380099 287 echo `cppflags` ${CODE_GEN_FLAGS}
75f4be8a
VZ
288 ;;
289 --cxxflags)
33380099 290 echo `cppflags` ${CODE_GEN_FLAGS} ${CODE_GEN_FLAGS_CXX}
9a98a854 291 ;;
40f7145c 292 --ldflags)
33380099 293 echo ${LDFLAGS_EXE}
40f7145c 294 ;;
2baaf735 295 --rezflags)
09d3439c 296 echo `eval echo ${MACRESWXCONFIG}`
2baaf735 297 ;;
cf615ebb
VS
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 ',' ' '`
67c13b6c
VS
308 # always add wxBase, any wxApp needs it:
309 libs_list="$libs_list base"
cf615ebb
VS
310 fi
311
312 # include install directory only if it is not default:
33380099 313 if test "${libdir}" != "/usr/lib" \
77e13408 314 -a \( "${cross_compiling}" != "yes" \
33380099 315 -o "${libdir}" != "/usr/${target}/lib" \) ;
3a922bb4 316 then
33380099 317 libs="-L${libdir}"
9a98a854 318 fi
3d63bc3a 319
cf615ebb
VS
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"
9171d4b4 332
cf615ebb
VS
333 # output link flags:
334 contrib_libs=`output_libs $libs_list`
335 if test $static_flag = yes ; then
ffef10f6 336 echo "$libs ${LDFLAGS} ${WXCONFIG_LDFLAGS_GUI} ${WXCONFIG_RPATH} $contrib_libs ${libdir}/${WXCONFIG_LIBS_STATIC} ${EXTRALIBS_GUI} ${LIBS} ${DMALLOC_LIBS}"
cf615ebb 337 else
ffef10f6 338 echo $libs ${LDFLAGS} ${WXCONFIG_LDFLAGS_GUI} ${WXCONFIG_RPATH} $contrib_libs ${WXCONFIG_LIBS} ${DMALLOC_LIBS}
cf615ebb 339 fi
3d63bc3a 340 else
cf615ebb
VS
341 # in multilib mode, link against all sublibraries:
342 wxlibs=`output_libs $libs_list`
ffef10f6
VS
343 guildflags=`get_ldflags_gui $libs_list`
344 echo $libs ${LDFLAGS} ${guildflags} ${WXCONFIG_RPATH} $wxlibs ${DMALLOC_LIBS}
3d63bc3a
RL
345 fi
346
3a922bb4
RL
347 ;;
348 --gl-libs)
cf615ebb 349 output_libs gl
9a98a854 350 ;;
6ce73557
VZ
351 --cc)
352 echo $CC
353 ;;
354 --cxx)
355 echo $CXX
356 ;;
357 --ld)
358 echo $LD
359 ;;
9a98a854 360 *)
75f4be8a 361 usage 1 1>&2
9a98a854
VZ
362 ;;
363 esac
364 shift
365done
366