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