]> git.saurik.com Git - wxWidgets.git/blob - wx-config.in
wxUSE_STL/wxArrayString fixes.
[wxWidgets.git] / wx-config.in
1 #!/bin/sh
2
3 # -------------------------------------------------------------------------
4 # Configured settings:
5 # -------------------------------------------------------------------------
6
7 # Version and build type information:
8
9 WX_MAJOR_VERSION_NUMBER="@WX_MAJOR_VERSION_NUMBER@"
10 WX_MINOR_VERSION_NUMBER="@WX_MINOR_VERSION_NUMBER@"
11 WX_RELEASE_NUMBER="@WX_RELEASE_NUMBER@"
12 release="@WX_MAJOR_VERSION_NUMBER@.@WX_MINOR_VERSION_NUMBER@"
13 is_monolithic="@MONOLITHIC@"
14 cross_compiling="@cross_compiling@"
15 target="@host_alias@"
16 static_flag="@STATIC_FLAG@"
17 inplace_flag="no"
18
19 # Misc configuration variables:
20
21 update_prefixes()
22 {
23 includedir="@includedir@"
24 libdir="@libdir@"
25 }
26 prefix="@prefix@"
27 exec_prefix="@exec_prefix@"
28 update_prefixes
29
30 CC="@CC@"
31 GCC="@GCC@"
32 CXX="@CXX@"
33 LD="@SHARED_LD@"
34 srcdir="@top_srcdir@"
35 builddir="@top_builddir_wxconfig@"
36 basename_nogui="@WX_LIBRARY_BASENAME_NOGUI@"
37 basename_gui="@WX_LIBRARY_BASENAME_GUI@"
38
39 TOOLCHAIN_NAME="@TOOLCHAIN_NAME@"
40 LDFLAGS="@LDFLAGS@"
41 WXCONFIG_RPATH="@WXCONFIG_RPATH@"
42 DMALLOC_LIBS="@DMALLOC_LIBS@"
43 WXCONFIG_LIBS="@WXCONFIG_LIBS@"
44 WXCONFIG_LIBS_STATIC="@WXCONFIG_LIBS_STATIC@"
45 WXDEBUG_DEFINE="@WXDEBUG_DEFINE@"
46 TOOLCHAIN_DEFS="@TOOLCHAIN_DEFS@"
47 TOOLCHAIN_DLL_DEFS="@TOOLCHAIN_DLL_DEFS@"
48 WXCONFIG_INCLUDE="@WXCONFIG_INCLUDE@"
49 WX_LARGEFILE_FLAGS="@WX_LARGEFILE_FLAGS@"
50 GCC_PRAGMA_FLAGS="@GCC_PRAGMA_FLAGS@"
51 CODE_GEN_FLAGS="@CODE_GEN_FLAGS@"
52 CODE_GEN_FLAGS_CXX="@CODE_GEN_FLAGS_CXX@"
53 LDFLAGS_EXE="@LDFLAGS_EXE@"
54 MACRESWXCONFIG="@MACRESWXCONFIG@"
55 EXTRALIBS_GUI="@EXTRALIBS_GUI@"
56 LIBS="@LIBS@"
57 WXCONFIG_LDFLAGS_GUI="@WXCONFIG_LDFLAGS_GUI@"
58
59
60 # Linker flags for sublibraries:
61
62 CORE_BASE_LIBS="@CORE_BASE_LIBS@"
63 CORE_GUI_LIBS="@CORE_GUI_LIBS@"
64
65 ldlibs_base="@WXCONFIG_EXTRALIBS@"
66 ldlibs_core="@EXTRALIBS_GUI@"
67 ldlibs_xml="@EXTRALIBS_XML@"
68 ldlibs_html="@EXTRALIBS_HTML@"
69 ldlibs_odbc="@EXTRALIBS_ODBC@"
70 ldlibs_adv="@EXTRALIBS_SDL@"
71
72 ldflags_gl="@LDFLAGS_GL@"
73 ldlibs_gl="@OPENGL_LIBS@"
74
75
76
77 # -------------------------------------------------------------------------
78 # Script code:
79 # -------------------------------------------------------------------------
80
81 exec_prefix_set=no
82
83 # is $1 among the rest of arguments?
84 isinlist()
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):
97 output_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:
135 get_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 usage()
147 {
148 cat <<EOF
149 Usage: wx-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--inplace]
150 [--toolkit=TOOLKIT] [--unicode[=yes|no]] [--debug[=yes|no]]
151 [--universal[=yes|no]] [--host=HOST]
152 [--version[=VERSION]] [--release]
153 [--list] [--basename] [--static] [--libs] [--gl-libs]
154 [--cppflags] [--cflags] [--cxxflags] [--ldflags] [--rezflags]
155 [--cc] [--cxx] [--ld] [LIBRARIES]
156
157 wx-config returns configuration information about the installed
158 version of wxWidgets. It may be used to query its version and
159 installation directories and also retrieve the C and C++ compilers
160 and linker which were used for its building and the corresponding
161 flags.
162
163 Ordinarily it should be installed to the appropriate system location
164 along with the headers and library files, but it is also possible to
165 use it to enable builds with an uninstalled wxWidgets version for
166 package building and bleeding edge developers. To do so, use it like
167 this:
168
169 \${wx_builddir}/wx-config --inplace
170
171 Note that any other options supplied must come *after* --inplace
172 for it to take effect.
173
174 --static must come before --cppflags, --cflags, --cxxflags,
175 --libs and --gl-libs and --libs must come before the other ones.
176
177 --libs can take optional argument that contains comma-separated list of
178 wxWidgets libraries to link against. This list can include both core
179 and contrib libraries. Special value "std" stands for all libraries linked
180 in by default.
181
182 --gl-libs option is deprecated, use "--libs gl" instead.
183
184 If there are several different builds of wxWidgets installed in same prefix,
185 you can use --host, --toolkit, --unicode, --debug, --universal and --version
186 options to select one of them. Use --list option to show all available builds
187 that match given criteria.
188
189 EOF
190
191 exit $1
192 }
193
194 cppflags()
195 {
196 includes="-I${libdir}/wx/include/${TOOLCHAIN_NAME}"
197
198 # in inplace case we need to also add path to contrib headers -- do it
199 # unconditionally as they might be used and we have no way of knowing if
200 # they really are
201 if test $inplace_flag = yes ; then
202 includes="$includes -I${prefix}/include -I${prefix}/contrib/include"
203 else
204 includes="$includes -I${includedir}/wx-${WX_MAJOR_VERSION_NUMBER}.${WX_MINOR_VERSION_NUMBER}"
205 fi
206
207 flags="$includes ${WXDEBUG_DEFINE} ${TOOLCHAIN_DEFS}"
208 if test $static_flag != yes ; then
209 flags="$flags ${TOOLCHAIN_DLL_DEFS}"
210 fi
211
212 if test $nogui_flag = "yes" ; then
213 flags="$flags -DwxUSE_GUI=0"
214 fi
215
216 echo "$flags${WXCONFIG_INCLUDE} ${WX_LARGEFILE_FLAGS} ${GCC_PRAGMA_FLAGS}"
217 }
218
219 if test $# -eq 0; then
220 usage 1 1>&2
221 fi
222
223
224 # handle libraries list:
225
226 libs_list=""
227
228 for arg in $*; do
229 case "$arg" in
230 -*)
231 ;;
232 *)
233 libs_list="$libs_list `echo "$arg" | tr ',' ' '`"
234 ;;
235 esac
236 done
237
238 if test "x$libs_list" = "x" ; then
239 if test "$is_monolithic" = "0" ; then
240 # link against all libs if none given explicitly:
241 libs_list="$CORE_GUI_LIBS $CORE_BASE_LIBS"
242 fi
243 else
244 # always add wxBase, any wxApp needs it:
245 libs_list="$libs_list base"
246 fi
247
248 # determine if at least one gui lib was used:
249 nogui_flag="yes"
250 for i in $libs_list; do
251 case $i in
252 base|net)
253 ;;
254 *)
255 nogui_flag="no"
256 ;;
257 esac
258 done
259
260
261 # handle options:
262
263 while test $# -gt 0; do
264 case "$1" in
265 -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
266 *) optarg= ;;
267 esac
268
269 case $1 in
270 --inplace)
271 inplace_flag=yes
272 ;;
273 --prefix=*)
274 prefix=$optarg
275 if test $exec_prefix_set = no ; then
276 exec_prefix=$optarg
277 fi
278 update_prefixes
279 ;;
280 --prefix)
281 echo $prefix
282 ;;
283 --exec-prefix=*)
284 exec_prefix=$optarg
285 exec_prefix_set=yes
286 update_prefixes
287 ;;
288 --exec-prefix)
289 echo $exec_prefix
290 ;;
291 --version)
292 echo ${WX_MAJOR_VERSION_NUMBER}.${WX_MINOR_VERSION_NUMBER}.${WX_RELEASE_NUMBER}
293 ;;
294 --release)
295 echo $release
296 ;;
297 --basename)
298 echo $basename_gui
299 ;;
300 --static)
301 static_flag=yes
302 ;;
303 --cppflags)
304 cppflags
305 ;;
306 --cflags)
307 echo `cppflags` ${CODE_GEN_FLAGS}
308 ;;
309 --cxxflags)
310 echo `cppflags` ${CODE_GEN_FLAGS} ${CODE_GEN_FLAGS_CXX}
311 ;;
312 --ldflags)
313 echo ${LDFLAGS_EXE}
314 ;;
315 --rezflags)
316 echo `eval echo ${MACRESWXCONFIG}`
317 ;;
318
319 --libs)
320 # include install directory only if it is not default:
321 if test "${libdir}" != "/usr/lib" \
322 -a \( "${cross_compiling}" != "yes" \
323 -o "${libdir}" != "/usr/${target}/lib" \) ;
324 then
325 libs="-L${libdir}"
326 fi
327
328 # it's simpler to avoid handling "base" itself at all as we add it in the
329 # end to the list of libraries anyhow
330 # in monolithic build, link against the main library:
331 if test "$is_monolithic" = "1" ; then
332 # filter out core libs, leave only contrib in libs_list:
333 newlist=
334 for i in $libs_list ; do
335 if isinlist $i $CORE_GUI_LIBS $CORE_BASE_LIBS; then
336 libs_list="" # do nothing
337 else
338 newlist="$newlist $i"
339 fi
340 done
341 libs_list="$newlist"
342
343 # output link flags:
344 contrib_libs=`output_libs $libs_list`
345 if test $static_flag = yes ; then
346 echo "$libs ${LDFLAGS} ${WXCONFIG_LDFLAGS_GUI} ${WXCONFIG_RPATH} $contrib_libs ${libdir}/${WXCONFIG_LIBS_STATIC} ${EXTRALIBS_GUI} ${LIBS} ${DMALLOC_LIBS}"
347 else
348 echo $libs ${LDFLAGS} ${WXCONFIG_LDFLAGS_GUI} ${WXCONFIG_RPATH} $contrib_libs ${WXCONFIG_LIBS} ${DMALLOC_LIBS}
349 fi
350 else
351 # we may need to replace "std" alias with its expansion
352 newlist=
353 hadstd=0
354 for i in $libs_list; do
355 case $i in
356 std)
357 hadstd=1
358 ;;
359
360 base)
361 # if we have std, we're going to add base anyhow, avoid
362 # having it twice in the end
363 if [ $hadstd = 0 ]; then
364 newlist="$newlist $i"
365 fi
366 ;;
367
368 *)
369 newlist="$newlist $i"
370 ;;
371 esac
372 done
373 libs_list="$newlist"
374 if [ $hadstd = 1 ]; then
375 libs_list="$libs_list $CORE_GUI_LIBS $CORE_BASE_LIBS"
376 fi
377
378 # in multilib mode, link against all sublibraries:
379 wxlibs=`output_libs $libs_list`
380 guildflags=`get_ldflags_gui $libs_list`
381 echo $libs ${LDFLAGS} ${guildflags} ${WXCONFIG_RPATH} $wxlibs ${DMALLOC_LIBS}
382 fi
383
384 ;;
385 --gl-libs)
386 output_libs gl
387 ;;
388 --cc)
389 echo $CC
390 ;;
391 --cxx)
392 echo $CXX
393 ;;
394 --ld)
395 echo $LD
396 ;;
397 --help|-h)
398 usage 1 1>&2
399 ;;
400 -*)
401 # unrecognized flag is error
402 usage 1 1>&2
403 ;;
404 esac
405 shift
406 done
407