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