]> git.saurik.com Git - wxWidgets.git/blame - wx-config.in
adapted to wx-config libraries list changes
[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@"
127e9080 17inplace_flag="no"
33380099
VS
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@"
31414f4c 32GCC_SEARCHES_USR_LOCAL_INCLUDE="@GCC_SEARCHES_USR_LOCAL_INCLUDE@"
6ce73557
VZ
33CXX="@CXX@"
34LD="@SHARED_LD@"
33380099
VS
35srcdir="@top_srcdir@"
36builddir="@top_builddir_wxconfig@"
37basename_nogui="@WX_LIBRARY_BASENAME_NOGUI@"
38basename_gui="@WX_LIBRARY_BASENAME_GUI@"
39
40TOOLCHAIN_NAME="@TOOLCHAIN_NAME@"
41LDFLAGS="@LDFLAGS@"
42WXCONFIG_RPATH="@WXCONFIG_RPATH@"
43DMALLOC_LIBS="@DMALLOC_LIBS@"
44WXCONFIG_LIBS="@WXCONFIG_LIBS@"
45WXCONFIG_LIBS_STATIC="@WXCONFIG_LIBS_STATIC@"
46WXDEBUG_DEFINE="@WXDEBUG_DEFINE@"
47TOOLCHAIN_DEFS="@TOOLCHAIN_DEFS@"
48TOOLCHAIN_DLL_DEFS="@TOOLCHAIN_DLL_DEFS@"
49WXCONFIG_INCLUDE="@WXCONFIG_INCLUDE@"
50WX_LARGEFILE_FLAGS="@WX_LARGEFILE_FLAGS@"
74b84332 51GCC_PRAGMA_FLAGS="@GCC_PRAGMA_FLAGS@"
33380099
VS
52CODE_GEN_FLAGS="@CODE_GEN_FLAGS@"
53CODE_GEN_FLAGS_CXX="@CODE_GEN_FLAGS_CXX@"
54LDFLAGS_EXE="@LDFLAGS_EXE@"
55MACRESWXCONFIG="@MACRESWXCONFIG@"
56EXTRALIBS_GUI="@EXTRALIBS_GUI@"
57LIBS="@LIBS@"
ffef10f6 58WXCONFIG_LDFLAGS_GUI="@WXCONFIG_LDFLAGS_GUI@"
cf615ebb
VS
59
60
61# Linker flags for sublibraries:
33380099 62
edd891e2
VS
63CORE_BASE_LIBS="@CORE_BASE_LIBS@"
64CORE_GUI_LIBS="@CORE_GUI_LIBS@"
cf615ebb 65
67c13b6c 66ldlibs_base="@WXCONFIG_EXTRALIBS@"
cf615ebb
VS
67ldlibs_core="@EXTRALIBS_GUI@"
68ldlibs_xml="@EXTRALIBS_XML@"
3527f29c 69ldlibs_html="@EXTRALIBS_HTML@"
bb41dcbe 70ldlibs_odbc="@EXTRALIBS_ODBC@"
f93ca9fd 71ldlibs_adv="@EXTRALIBS_SDL@"
cf615ebb
VS
72
73ldflags_gl="@LDFLAGS_GL@"
74ldlibs_gl="@OPENGL_LIBS@"
75
76
33380099
VS
77
78# -------------------------------------------------------------------------
79# Script code:
80# -------------------------------------------------------------------------
81
82exec_prefix_set=no
83
cf615ebb
VS
84# is $1 among the rest of arguments?
85isinlist()
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):
98output_libs()
99{
67c13b6c
VS
100 if test "$cross_compiling" = "yes" ; then
101 target_tag="-${target}"
102 fi
103
cf615ebb
VS
104 all_libs=""
105 all_ldflags=""
106 wxlibs=""
67c13b6c 107
cf615ebb
VS
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
fef23dd4
VS
116 if test $lib = "base" ; then
117 libname="$basename"
118 else
119 libname="${basename}_${lib}"
120 fi
cf615ebb
VS
121
122 all_ldflags="$all_ldflags $xflags"
123 if test $static_flag = yes ; then
33380099 124 wxlibs="$wxlibs ${libdir}/lib${libname}-${release}${target_tag}.a"
cf615ebb
VS
125 all_libs="$all_libs $xlibs"
126 else
67c13b6c 127 wxlibs="$wxlibs -l${libname}-${release}${target_tag}"
cf615ebb
VS
128 fi
129 done
130
131 echo $all_ldflags $wxlibs $all_libs
132}
9a98a854 133
ffef10f6
VS
134# output $(WXCONFIG_LDFLAGS_GUI) if any of libs passed as arguments is GUI
135# library, nothing otherwise:
136get_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
52c71b80
VZ
147# return the absolute path prepending builddir to it if needed
148makeabs()
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
75f4be8a
VZ
164usage()
165{
166 cat <<EOF
89816e4f
VS
167Usage: wx-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--inplace]
168 [--version] [--release]
251f47d1 169 [--basename] [--static] [--libs] [--gl-libs]
40f7145c 170 [--cppflags] [--cflags] [--cxxflags] [--ldflags] [--rezflags]
89816e4f 171 [--cc] [--cxx] [--ld] [LIBRARIES]
75f4be8a
VZ
172
173wx-config returns configuration information about the installed
b63b07a8 174version of wxWidgets. It may be used to query its version and
75f4be8a
VZ
175installation directories and also retrieve the C and C++ compilers
176and linker which were used for its building and the corresponding
177flags.
2b5f62a0 178
82a649b6
RL
179Ordinarily it should be installed to the appropriate system location
180along with the headers and library files, but it is also possible to
b63b07a8 181use it to enable builds with an uninstalled wxWidgets version for
82a649b6
RL
182package building and bleeding edge developers. To do so, use it like
183this:
184
89816e4f 185\${wx_builddir}/wx-config --inplace
82a649b6 186
89816e4f
VS
187Note that any other options supplied must come *after* --inplace
188for it to take effect.
82a649b6 189
efe6c06f 190--static must come before --cppflags, --cflags, --cxxflags,
a43ed08a 191--libs and --gl-libs and --libs must come before the other ones.
cf615ebb
VS
192
193--libs can take optional argument that contains comma-separated list of
b63b07a8 194wxWidgets libraries to link against. This list can include both core
1d8864ac
VZ
195and contrib libraries. Special value "std" stands for all libraries linked
196in by default.
cf615ebb 197
251f47d1 198--gl-libs option is deprecated, use "--libs gl" instead.
67c13b6c 199
75f4be8a
VZ
200EOF
201
202 exit $1
203}
204
205cppflags()
206{
2b5f62a0
VZ
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 #
31414f4c
SN
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.
2b5f62a0
VZ
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
33380099
VS
225 if test "${includedir}" != "/usr/include" \
226 -a "${includedir}" != "/usr/include/c++" \
31414f4c 227 -a \( "${GCC_SEARCHES_USR_LOCAL_INCLUDE}" != "yes" \
33380099 228 -o "${includedir}" != "/usr/local/include" \) \
77e13408 229 -a \( "${cross_compiling}" != "yes" \
33380099 230 -o "${includedir}" != "/usr/${target}/include" \) ;
3a922bb4 231 then
33380099 232 includes=" -I${includedir}"
75f4be8a 233 fi
00c81359 234
33380099 235 includes="-I${libdir}/wx/include/${TOOLCHAIN_NAME}$includes"
00c81359 236
127e9080 237 # in inplace case we need to also add path to contrib headers -- do it
bc79eb4f 238 # unconditionally as they might be used and we have no way of knowing if
127e9080
VZ
239 # they really are
240 if test $inplace_flag = yes ; then
241 includes="$includes -I${prefix}/contrib/include"
242 fi
243
a43ed08a
VZ
244 flags="$includes ${WXDEBUG_DEFINE} ${TOOLCHAIN_DEFS}"
245 if test $static_flag != yes ; then
246 flags="$flags ${TOOLCHAIN_DLL_DEFS}"
00c81359 247 fi
a43ed08a 248
251f47d1
VS
249 if test $nogui_flag = "yes" ; then
250 flags="$flags -DwxUSE_GUI=0"
a43ed08a
VZ
251 fi
252
253 echo "$flags${WXCONFIG_INCLUDE} ${WX_LARGEFILE_FLAGS} ${GCC_PRAGMA_FLAGS}"
75f4be8a 254}
9a98a854
VZ
255
256if test $# -eq 0; then
3a922bb4 257 usage 1 1>&2
9a98a854
VZ
258fi
259
251f47d1
VS
260
261# handle libraries list:
262
263libs_list=""
264
265for arg in $*; do
266 case "$arg" in
267 -*)
268 ;;
269 *)
270 libs_list="$libs_list `echo "$arg" | tr ',' ' '`"
271 ;;
272 esac
273done
274
275if 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
280else
281 # always add wxBase, any wxApp needs it:
282 libs_list="$libs_list base"
283fi
284
285# determine if at least one gui lib was used:
286nogui_flag="yes"
287for i in $libs_list; do
288 case $i in
289 base|net)
290 ;;
291 *)
292 nogui_flag="no"
293 ;;
294 esac
295done
296
297
298# handle options:
299
9a98a854
VZ
300while 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
52c71b80
VZ
307 --inplace)
308 prefix=`makeabs $srcdir`
309 exec_prefix=`makeabs $builddir`
310 exec_prefix_set=yes
127e9080 311 inplace_flag=yes
0154f61a 312 update_prefixes
52c71b80 313 ;;
9a98a854
VZ
314 --prefix=*)
315 prefix=$optarg
316 if test $exec_prefix_set = no ; then
317 exec_prefix=$optarg
318 fi
0154f61a 319 update_prefixes
9a98a854
VZ
320 ;;
321 --prefix)
322 echo $prefix
323 ;;
324 --exec-prefix=*)
325 exec_prefix=$optarg
326 exec_prefix_set=yes
0154f61a 327 update_prefixes
9a98a854
VZ
328 ;;
329 --exec-prefix)
330 echo $exec_prefix
331 ;;
332 --version)
33380099 333 echo ${WX_MAJOR_VERSION_NUMBER}.${WX_MINOR_VERSION_NUMBER}.${WX_RELEASE_NUMBER}
9a98a854 334 ;;
2f42e5b6 335 --release)
cf615ebb 336 echo $release
2f42e5b6
VS
337 ;;
338 --basename)
9171d4b4 339 echo $basename_gui
2f42e5b6 340 ;;
3d63bc3a
RL
341 --static)
342 static_flag=yes
343 ;;
75f4be8a
VZ
344 --cppflags)
345 cppflags
346 ;;
9a98a854 347 --cflags)
33380099 348 echo `cppflags` ${CODE_GEN_FLAGS}
75f4be8a
VZ
349 ;;
350 --cxxflags)
33380099 351 echo `cppflags` ${CODE_GEN_FLAGS} ${CODE_GEN_FLAGS_CXX}
9a98a854 352 ;;
40f7145c 353 --ldflags)
33380099 354 echo ${LDFLAGS_EXE}
40f7145c 355 ;;
2baaf735 356 --rezflags)
09d3439c 357 echo `eval echo ${MACRESWXCONFIG}`
2baaf735 358 ;;
cf615ebb 359
251f47d1 360 --libs)
cf615ebb 361 # include install directory only if it is not default:
33380099 362 if test "${libdir}" != "/usr/lib" \
77e13408 363 -a \( "${cross_compiling}" != "yes" \
33380099 364 -o "${libdir}" != "/usr/${target}/lib" \) ;
3a922bb4 365 then
33380099 366 libs="-L${libdir}"
9a98a854 367 fi
3d63bc3a 368
a43ed08a 369 # it's simpler to avoid handling "base" itself at all as we add it in the
1d8864ac 370 # end to the list of libraries anyhow
cf615ebb
VS
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
1d8864ac 376 if isinlist $i $CORE_GUI_LIBS $CORE_BASE_LIBS; then
cf615ebb
VS
377 libs_list="" # do nothing
378 else
379 newlist="$newlist $i"
380 fi
381 done
382 libs_list="$newlist"
9171d4b4 383
cf615ebb
VS
384 # output link flags:
385 contrib_libs=`output_libs $libs_list`
386 if test $static_flag = yes ; then
ffef10f6 387 echo "$libs ${LDFLAGS} ${WXCONFIG_LDFLAGS_GUI} ${WXCONFIG_RPATH} $contrib_libs ${libdir}/${WXCONFIG_LIBS_STATIC} ${EXTRALIBS_GUI} ${LIBS} ${DMALLOC_LIBS}"
cf615ebb 388 else
ffef10f6 389 echo $libs ${LDFLAGS} ${WXCONFIG_LDFLAGS_GUI} ${WXCONFIG_RPATH} $contrib_libs ${WXCONFIG_LIBS} ${DMALLOC_LIBS}
cf615ebb 390 fi
3d63bc3a 391 else
1d8864ac
VZ
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
a43ed08a 405 newlist="$newlist $i"
1d8864ac
VZ
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
cf615ebb
VS
419 # in multilib mode, link against all sublibraries:
420 wxlibs=`output_libs $libs_list`
ffef10f6
VS
421 guildflags=`get_ldflags_gui $libs_list`
422 echo $libs ${LDFLAGS} ${guildflags} ${WXCONFIG_RPATH} $wxlibs ${DMALLOC_LIBS}
3d63bc3a
RL
423 fi
424
3a922bb4
RL
425 ;;
426 --gl-libs)
cf615ebb 427 output_libs gl
9a98a854 428 ;;
6ce73557
VZ
429 --cc)
430 echo $CC
431 ;;
432 --cxx)
433 echo $CXX
434 ;;
435 --ld)
436 echo $LD
437 ;;
251f47d1 438 --help|-h)
75f4be8a 439 usage 1 1>&2
9a98a854 440 ;;
14885f09
VS
441 -*)
442 # unrecognized flag is error
443 usage 1 1>&2
444 ;;
9a98a854
VZ
445 esac
446 shift
447done
448