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