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