]> git.saurik.com Git - wxWidgets.git/blob - wx-config.in
Don't show focus rectangle if wxNO_BORDER specified
[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 GCC_SEARCHES_USR_LOCAL_INCLUDE="@GCC_SEARCHES_USR_LOCAL_INCLUDE@"
33 CXX="@CXX@"
34 LD="@SHARED_LD@"
35 srcdir="@top_srcdir@"
36 builddir="@top_builddir_wxconfig@"
37 basename_nogui="@WX_LIBRARY_BASENAME_NOGUI@"
38 basename_gui="@WX_LIBRARY_BASENAME_GUI@"
39
40 TOOLCHAIN_NAME="@TOOLCHAIN_NAME@"
41 LDFLAGS="@LDFLAGS@"
42 WXCONFIG_RPATH="@WXCONFIG_RPATH@"
43 DMALLOC_LIBS="@DMALLOC_LIBS@"
44 WXCONFIG_LIBS="@WXCONFIG_LIBS@"
45 WXCONFIG_LIBS_STATIC="@WXCONFIG_LIBS_STATIC@"
46 WXDEBUG_DEFINE="@WXDEBUG_DEFINE@"
47 TOOLCHAIN_DEFS="@TOOLCHAIN_DEFS@"
48 TOOLCHAIN_DLL_DEFS="@TOOLCHAIN_DLL_DEFS@"
49 WXCONFIG_INCLUDE="@WXCONFIG_INCLUDE@"
50 WX_LARGEFILE_FLAGS="@WX_LARGEFILE_FLAGS@"
51 GCC_PRAGMA_FLAGS="@GCC_PRAGMA_FLAGS@"
52 CODE_GEN_FLAGS="@CODE_GEN_FLAGS@"
53 CODE_GEN_FLAGS_CXX="@CODE_GEN_FLAGS_CXX@"
54 LDFLAGS_EXE="@LDFLAGS_EXE@"
55 MACRESWXCONFIG="@MACRESWXCONFIG@"
56 EXTRALIBS_GUI="@EXTRALIBS_GUI@"
57 LIBS="@LIBS@"
58 WXCONFIG_LDFLAGS_GUI="@WXCONFIG_LDFLAGS_GUI@"
59
60
61 # Linker flags for sublibraries:
62
63 CORE_BASE_LIBS="@CORE_BASE_LIBS@"
64 CORE_GUI_LIBS="@CORE_GUI_LIBS@"
65
66 ldlibs_base="@WXCONFIG_EXTRALIBS@"
67 ldlibs_core="@EXTRALIBS_GUI@"
68 ldlibs_xml="@EXTRALIBS_XML@"
69 ldlibs_html="@EXTRALIBS_HTML@"
70 ldlibs_odbc="@EXTRALIBS_ODBC@"
71 ldlibs_adv="@EXTRALIBS_SDL@"
72
73 ldflags_gl="@LDFLAGS_GL@"
74 ldlibs_gl="@OPENGL_LIBS@"
75
76
77
78 # -------------------------------------------------------------------------
79 # Script code:
80 # -------------------------------------------------------------------------
81
82 exec_prefix_set=no
83
84 # is $1 among the rest of arguments?
85 isinlist()
86 {
87 value=$1
88 shift
89 isin=no
90 for iii in $* ; do
91 if test $iii = $value ; then isin=yes ; fi
92 done
93 test $isin = yes
94 }
95
96 # output linker commands needed to link against libraries passed as arguments
97 # (does not handle monolithic/multilib):
98 output_libs()
99 {
100 if test "$cross_compiling" = "yes" ; then
101 target_tag="-${target}"
102 fi
103
104 all_libs=""
105 all_ldflags=""
106 wxlibs=""
107
108 for lib in $* ; do
109 eval xlibs=\$ldlibs_$lib
110 eval xflags=\$ldflags_$lib
111 if isinlist $lib $CORE_BASE_LIBS ; then
112 basename=$basename_nogui
113 else
114 basename=$basename_gui
115 fi
116 if test $lib = "base" ; then
117 libname="$basename"
118 else
119 libname="${basename}_${lib}"
120 fi
121
122 all_ldflags="$all_ldflags $xflags"
123 if test $static_flag = yes ; then
124 wxlibs="$wxlibs ${libdir}/lib${libname}-${release}${target_tag}.a"
125 all_libs="$all_libs $xlibs"
126 else
127 wxlibs="$wxlibs -l${libname}-${release}${target_tag}"
128 fi
129 done
130
131 echo $all_ldflags $wxlibs $all_libs
132 }
133
134 # output $(WXCONFIG_LDFLAGS_GUI) if any of libs passed as arguments is GUI
135 # library, nothing otherwise:
136 get_ldflags_gui()
137 {
138 flags_to_ret=""
139 for lib in $* ; do
140 if isinlist $lib $CORE_GUI_LIBS ; then
141 flags_to_ret="$WXCONFIG_LDFLAGS_GUI"
142 fi
143 done
144 echo $flags_to_ret
145 }
146
147 # return the absolute path prepending builddir to it if needed
148 makeabs()
149 {
150 path=$1
151 # TODO: this only works under Unix and even there it could be
152 # enhanced to remove ".." and "."
153 if [ `echo $path | sed 's/^\(.\).*/\1/'` != "/" ]; then
154 if [ $path = "." ]; then
155 path=$builddir
156 else
157 path="$builddir/$path"
158 fi
159 fi
160
161 echo $path
162 }
163
164 usage()
165 {
166 cat <<EOF
167 Usage: wx-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--inplace]
168 [--version] [--release]
169 [--basename] [--static] [--libs] [--gl-libs]
170 [--cppflags] [--cflags] [--cxxflags] [--ldflags] [--rezflags]
171 [--cc] [--cxx] [--ld] [LIBRARIES]
172
173 wx-config returns configuration information about the installed
174 version of wxWidgets. It may be used to query its version and
175 installation directories and also retrieve the C and C++ compilers
176 and linker which were used for its building and the corresponding
177 flags.
178
179 Ordinarily it should be installed to the appropriate system location
180 along with the headers and library files, but it is also possible to
181 use it to enable builds with an uninstalled wxWidgets version for
182 package building and bleeding edge developers. To do so, use it like
183 this:
184
185 \${wx_builddir}/wx-config --inplace
186
187 Note that any other options supplied must come *after* --inplace
188 for it to take effect.
189
190 --static must come before --cppflags, --cflags, --cxxflags,
191 --libs and --gl-libs and --libs must come before the other ones.
192
193 --libs can take optional argument that contains comma-separated list of
194 wxWidgets libraries to link against. This list can include both core
195 and contrib libraries. Special value "std" stands for all libraries linked
196 in by default.
197
198 --gl-libs option is deprecated, use "--libs gl" instead.
199
200 EOF
201
202 exit $1
203 }
204
205 cppflags()
206 {
207 # we should never specify -I/usr/include on the compiler command line: this
208 # is at best useless and at worst breaks compilation on the systems where
209 # the system headers are non-ANSI because gcc works around this by storing
210 # the ANSI-fied versions of them in its private directory which is searched
211 # after all the directories on the cmd line.
212 #
213 # the situation is a bit more complicated with -I/usr/local/include:
214 # it shouldn't be specified with some gcc installations which look there
215 # by default anyhow and give warnings (at least 3.1 does) if it is
216 # specified explicitly --
217 # but this -I switch *is* needed for other gcc installation and for
218 # the other compilers.
219 # So I put a suitable test into configure.in and reuse the result here.
220 #
221 # note that we assume that if we use GNU cc we also use GNU c++ and vice
222 # versa, i.e. this won't work (either for --cflags or --cxxflags) if GNU C
223 # compiler and non-GNU C++ compiler are used or vice versa -- we'll fix
224 # this when/if anybody complains about it
225 if test "${includedir}" != "/usr/include" \
226 -a "${includedir}" != "/usr/include/c++" \
227 -a \( "${GCC_SEARCHES_USR_LOCAL_INCLUDE}" != "yes" \
228 -o "${includedir}" != "/usr/local/include" \) \
229 -a \( "${cross_compiling}" != "yes" \
230 -o "${includedir}" != "/usr/${target}/include" \) ;
231 then
232 includes=" -I${includedir}"
233 fi
234
235 includes="-I${libdir}/wx/include/${TOOLCHAIN_NAME}$includes"
236
237 # in inplace case we need to also add path to contrib headers -- do it
238 # unconditionally as they might be used and we have no way of knowing if
239 # they really are
240 if test $inplace_flag = yes ; then
241 includes="$includes -I${prefix}/contrib/include"
242 fi
243
244 flags="$includes ${WXDEBUG_DEFINE} ${TOOLCHAIN_DEFS}"
245 if test $static_flag != yes ; then
246 flags="$flags ${TOOLCHAIN_DLL_DEFS}"
247 fi
248
249 if test $nogui_flag = "yes" ; then
250 flags="$flags -DwxUSE_GUI=0"
251 fi
252
253 echo "$flags${WXCONFIG_INCLUDE} ${WX_LARGEFILE_FLAGS} ${GCC_PRAGMA_FLAGS}"
254 }
255
256 if test $# -eq 0; then
257 usage 1 1>&2
258 fi
259
260
261 # handle libraries list:
262
263 libs_list=""
264
265 for arg in $*; do
266 case "$arg" in
267 -*)
268 ;;
269 *)
270 libs_list="$libs_list `echo "$arg" | tr ',' ' '`"
271 ;;
272 esac
273 done
274
275 if test "x$libs_list" = "x" ; then
276 if test "$is_monolithic" = "0" ; then
277 # link against all libs if none given explicitly:
278 libs_list="$CORE_GUI_LIBS $CORE_BASE_LIBS"
279 fi
280 else
281 # always add wxBase, any wxApp needs it:
282 libs_list="$libs_list base"
283 fi
284
285 # determine if at least one gui lib was used:
286 nogui_flag="yes"
287 for i in $libs_list; do
288 case $i in
289 base|net)
290 ;;
291 *)
292 nogui_flag="no"
293 ;;
294 esac
295 done
296
297
298 # handle options:
299
300 while test $# -gt 0; do
301 case "$1" in
302 -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
303 *) optarg= ;;
304 esac
305
306 case $1 in
307 --inplace)
308 prefix=`makeabs $srcdir`
309 exec_prefix=`makeabs $builddir`
310 exec_prefix_set=yes
311 inplace_flag=yes
312 update_prefixes
313 ;;
314 --prefix=*)
315 prefix=$optarg
316 if test $exec_prefix_set = no ; then
317 exec_prefix=$optarg
318 fi
319 update_prefixes
320 ;;
321 --prefix)
322 echo $prefix
323 ;;
324 --exec-prefix=*)
325 exec_prefix=$optarg
326 exec_prefix_set=yes
327 update_prefixes
328 ;;
329 --exec-prefix)
330 echo $exec_prefix
331 ;;
332 --version)
333 echo ${WX_MAJOR_VERSION_NUMBER}.${WX_MINOR_VERSION_NUMBER}.${WX_RELEASE_NUMBER}
334 ;;
335 --release)
336 echo $release
337 ;;
338 --basename)
339 echo $basename_gui
340 ;;
341 --static)
342 static_flag=yes
343 ;;
344 --cppflags)
345 cppflags
346 ;;
347 --cflags)
348 echo `cppflags` ${CODE_GEN_FLAGS}
349 ;;
350 --cxxflags)
351 echo `cppflags` ${CODE_GEN_FLAGS} ${CODE_GEN_FLAGS_CXX}
352 ;;
353 --ldflags)
354 echo ${LDFLAGS_EXE}
355 ;;
356 --rezflags)
357 echo `eval echo ${MACRESWXCONFIG}`
358 ;;
359
360 --libs)
361 # include install directory only if it is not default:
362 if test "${libdir}" != "/usr/lib" \
363 -a \( "${cross_compiling}" != "yes" \
364 -o "${libdir}" != "/usr/${target}/lib" \) ;
365 then
366 libs="-L${libdir}"
367 fi
368
369 # it's simpler to avoid handling "base" itself at all as we add it in the
370 # end to the list of libraries anyhow
371 # in monolithic build, link against the main library:
372 if test "$is_monolithic" = "1" ; then
373 # filter out core libs, leave only contrib in libs_list:
374 newlist=
375 for i in $libs_list ; do
376 if isinlist $i $CORE_GUI_LIBS $CORE_BASE_LIBS; then
377 libs_list="" # do nothing
378 else
379 newlist="$newlist $i"
380 fi
381 done
382 libs_list="$newlist"
383
384 # output link flags:
385 contrib_libs=`output_libs $libs_list`
386 if test $static_flag = yes ; then
387 echo "$libs ${LDFLAGS} ${WXCONFIG_LDFLAGS_GUI} ${WXCONFIG_RPATH} $contrib_libs ${libdir}/${WXCONFIG_LIBS_STATIC} ${EXTRALIBS_GUI} ${LIBS} ${DMALLOC_LIBS}"
388 else
389 echo $libs ${LDFLAGS} ${WXCONFIG_LDFLAGS_GUI} ${WXCONFIG_RPATH} $contrib_libs ${WXCONFIG_LIBS} ${DMALLOC_LIBS}
390 fi
391 else
392 # we may need to replace "std" alias with its expansion
393 newlist=
394 hadstd=0
395 for i in $libs_list; do
396 case $i in
397 std)
398 hadstd=1
399 ;;
400
401 base)
402 # if we have std, we're going to add base anyhow, avoid
403 # having it twice in the end
404 if [ $hadstd = 0 ]; then
405 newlist="$newlist $i"
406 fi
407 ;;
408
409 *)
410 newlist="$newlist $i"
411 ;;
412 esac
413 done
414 libs_list="$newlist"
415 if [ $hadstd = 1 ]; then
416 libs_list="$libs_list $CORE_GUI_LIBS $CORE_BASE_LIBS"
417 fi
418
419 # in multilib mode, link against all sublibraries:
420 wxlibs=`output_libs $libs_list`
421 guildflags=`get_ldflags_gui $libs_list`
422 echo $libs ${LDFLAGS} ${guildflags} ${WXCONFIG_RPATH} $wxlibs ${DMALLOC_LIBS}
423 fi
424
425 ;;
426 --gl-libs)
427 output_libs gl
428 ;;
429 --cc)
430 echo $CC
431 ;;
432 --cxx)
433 echo $CXX
434 ;;
435 --ld)
436 echo $LD
437 ;;
438 --help|-h)
439 usage 1 1>&2
440 ;;
441 esac
442 shift
443 done
444