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