]> git.saurik.com Git - wxWidgets.git/blob - wx-config.in
fixed --inplace
[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 usage()
148 {
149 cat <<EOF
150 Usage: wx-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--inplace]
151 [--toolkit=TOOLKIT] [--unicode[=yes|no]] [--debug[=yes|no]]
152 [--universal[=yes|no]] [--host=HOST]
153 [--version[=VERSION]] [--release]
154 [--list] [--basename] [--static] [--libs] [--gl-libs]
155 [--cppflags] [--cflags] [--cxxflags] [--ldflags] [--rezflags]
156 [--cc] [--cxx] [--ld] [LIBRARIES]
157
158 wx-config returns configuration information about the installed
159 version of wxWidgets. It may be used to query its version and
160 installation directories and also retrieve the C and C++ compilers
161 and linker which were used for its building and the corresponding
162 flags.
163
164 Ordinarily it should be installed to the appropriate system location
165 along with the headers and library files, but it is also possible to
166 use it to enable builds with an uninstalled wxWidgets version for
167 package building and bleeding edge developers. To do so, use it like
168 this:
169
170 \${wx_builddir}/wx-config --inplace
171
172 Note that any other options supplied must come *after* --inplace
173 for it to take effect.
174
175 --static must come before --cppflags, --cflags, --cxxflags,
176 --libs and --gl-libs and --libs must come before the other ones.
177
178 --libs can take optional argument that contains comma-separated list of
179 wxWidgets libraries to link against. This list can include both core
180 and contrib libraries. Special value "std" stands for all libraries linked
181 in by default.
182
183 --gl-libs option is deprecated, use "--libs gl" instead.
184
185 If there are several different builds of wxWidgets installed in same prefix,
186 you can use --host, --toolkit, --unicode, --debug, --universal and --version
187 options to select one of them. Use --list option to show all available builds
188 that match given criteria.
189
190 EOF
191
192 exit $1
193 }
194
195 cppflags()
196 {
197 # we should never specify -I/usr/include on the compiler command line: this
198 # is at best useless and at worst breaks compilation on the systems where
199 # the system headers are non-ANSI because gcc works around this by storing
200 # the ANSI-fied versions of them in its private directory which is searched
201 # after all the directories on the cmd line.
202 #
203 # the situation is a bit more complicated with -I/usr/local/include:
204 # it shouldn't be specified with some gcc installations which look there
205 # by default anyhow and give warnings (at least 3.1 does) if it is
206 # specified explicitly --
207 # but this -I switch *is* needed for other gcc installation and for
208 # the other compilers.
209 # So I put a suitable test into configure.in and reuse the result here.
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_SEARCHES_USR_LOCAL_INCLUDE}" != "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 # in inplace case we need to also add path to contrib headers -- do it
228 # unconditionally as they might be used and we have no way of knowing if
229 # they really are
230 if test $inplace_flag = yes ; then
231 includes="$includes -I${prefix}/contrib/include"
232 fi
233
234 flags="$includes ${WXDEBUG_DEFINE} ${TOOLCHAIN_DEFS}"
235 if test $static_flag != yes ; then
236 flags="$flags ${TOOLCHAIN_DLL_DEFS}"
237 fi
238
239 if test $nogui_flag = "yes" ; then
240 flags="$flags -DwxUSE_GUI=0"
241 fi
242
243 echo "$flags${WXCONFIG_INCLUDE} ${WX_LARGEFILE_FLAGS} ${GCC_PRAGMA_FLAGS}"
244 }
245
246 if test $# -eq 0; then
247 usage 1 1>&2
248 fi
249
250
251 # handle libraries list:
252
253 libs_list=""
254
255 for arg in $*; do
256 case "$arg" in
257 -*)
258 ;;
259 *)
260 libs_list="$libs_list `echo "$arg" | tr ',' ' '`"
261 ;;
262 esac
263 done
264
265 if test "x$libs_list" = "x" ; then
266 if test "$is_monolithic" = "0" ; then
267 # link against all libs if none given explicitly:
268 libs_list="$CORE_GUI_LIBS $CORE_BASE_LIBS"
269 fi
270 else
271 # always add wxBase, any wxApp needs it:
272 libs_list="$libs_list base"
273 fi
274
275 # determine if at least one gui lib was used:
276 nogui_flag="yes"
277 for i in $libs_list; do
278 case $i in
279 base|net)
280 ;;
281 *)
282 nogui_flag="no"
283 ;;
284 esac
285 done
286
287
288 # handle options:
289
290 while test $# -gt 0; do
291 case "$1" in
292 -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
293 *) optarg= ;;
294 esac
295
296 case $1 in
297 --inplace)
298 inplace_flag=yes
299 ;;
300 --prefix=*)
301 prefix=$optarg
302 if test $exec_prefix_set = no ; then
303 exec_prefix=$optarg
304 fi
305 update_prefixes
306 ;;
307 --prefix)
308 echo $prefix
309 ;;
310 --exec-prefix=*)
311 exec_prefix=$optarg
312 exec_prefix_set=yes
313 update_prefixes
314 ;;
315 --exec-prefix)
316 echo $exec_prefix
317 ;;
318 --version)
319 echo ${WX_MAJOR_VERSION_NUMBER}.${WX_MINOR_VERSION_NUMBER}.${WX_RELEASE_NUMBER}
320 ;;
321 --release)
322 echo $release
323 ;;
324 --basename)
325 echo $basename_gui
326 ;;
327 --static)
328 static_flag=yes
329 ;;
330 --cppflags)
331 cppflags
332 ;;
333 --cflags)
334 echo `cppflags` ${CODE_GEN_FLAGS}
335 ;;
336 --cxxflags)
337 echo `cppflags` ${CODE_GEN_FLAGS} ${CODE_GEN_FLAGS_CXX}
338 ;;
339 --ldflags)
340 echo ${LDFLAGS_EXE}
341 ;;
342 --rezflags)
343 echo `eval echo ${MACRESWXCONFIG}`
344 ;;
345
346 --libs)
347 # include install directory only if it is not default:
348 if test "${libdir}" != "/usr/lib" \
349 -a \( "${cross_compiling}" != "yes" \
350 -o "${libdir}" != "/usr/${target}/lib" \) ;
351 then
352 libs="-L${libdir}"
353 fi
354
355 # it's simpler to avoid handling "base" itself at all as we add it in the
356 # end to the list of libraries anyhow
357 # in monolithic build, link against the main library:
358 if test "$is_monolithic" = "1" ; then
359 # filter out core libs, leave only contrib in libs_list:
360 newlist=
361 for i in $libs_list ; do
362 if isinlist $i $CORE_GUI_LIBS $CORE_BASE_LIBS; then
363 libs_list="" # do nothing
364 else
365 newlist="$newlist $i"
366 fi
367 done
368 libs_list="$newlist"
369
370 # output link flags:
371 contrib_libs=`output_libs $libs_list`
372 if test $static_flag = yes ; then
373 echo "$libs ${LDFLAGS} ${WXCONFIG_LDFLAGS_GUI} ${WXCONFIG_RPATH} $contrib_libs ${libdir}/${WXCONFIG_LIBS_STATIC} ${EXTRALIBS_GUI} ${LIBS} ${DMALLOC_LIBS}"
374 else
375 echo $libs ${LDFLAGS} ${WXCONFIG_LDFLAGS_GUI} ${WXCONFIG_RPATH} $contrib_libs ${WXCONFIG_LIBS} ${DMALLOC_LIBS}
376 fi
377 else
378 # we may need to replace "std" alias with its expansion
379 newlist=
380 hadstd=0
381 for i in $libs_list; do
382 case $i in
383 std)
384 hadstd=1
385 ;;
386
387 base)
388 # if we have std, we're going to add base anyhow, avoid
389 # having it twice in the end
390 if [ $hadstd = 0 ]; then
391 newlist="$newlist $i"
392 fi
393 ;;
394
395 *)
396 newlist="$newlist $i"
397 ;;
398 esac
399 done
400 libs_list="$newlist"
401 if [ $hadstd = 1 ]; then
402 libs_list="$libs_list $CORE_GUI_LIBS $CORE_BASE_LIBS"
403 fi
404
405 # in multilib mode, link against all sublibraries:
406 wxlibs=`output_libs $libs_list`
407 guildflags=`get_ldflags_gui $libs_list`
408 echo $libs ${LDFLAGS} ${guildflags} ${WXCONFIG_RPATH} $wxlibs ${DMALLOC_LIBS}
409 fi
410
411 ;;
412 --gl-libs)
413 output_libs gl
414 ;;
415 --cc)
416 echo $CC
417 ;;
418 --cxx)
419 echo $CXX
420 ;;
421 --ld)
422 echo $LD
423 ;;
424 --help|-h)
425 usage 1 1>&2
426 ;;
427 -*)
428 # unrecognized flag is error
429 usage 1 1>&2
430 ;;
431 esac
432 shift
433 done
434