]> git.saurik.com Git - wxWidgets.git/blob - wx-config.in
Some cleanup
[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
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 CXX="@CXX@"
33 LD="@SHARED_LD@"
34 srcdir="@top_srcdir@"
35 builddir="@top_builddir_wxconfig@"
36 basename_nogui="@WX_LIBRARY_BASENAME_NOGUI@"
37 basename_gui="@WX_LIBRARY_BASENAME_GUI@"
38
39 TOOLCHAIN_NAME="@TOOLCHAIN_NAME@"
40 LDFLAGS="@LDFLAGS@"
41 WXCONFIG_RPATH="@WXCONFIG_RPATH@"
42 DMALLOC_LIBS="@DMALLOC_LIBS@"
43 WXCONFIG_LIBS="@WXCONFIG_LIBS@"
44 WXCONFIG_LIBS_STATIC="@WXCONFIG_LIBS_STATIC@"
45 WXDEBUG_DEFINE="@WXDEBUG_DEFINE@"
46 TOOLCHAIN_DEFS="@TOOLCHAIN_DEFS@"
47 TOOLCHAIN_DLL_DEFS="@TOOLCHAIN_DLL_DEFS@"
48 WXCONFIG_INCLUDE="@WXCONFIG_INCLUDE@"
49 WX_LARGEFILE_FLAGS="@WX_LARGEFILE_FLAGS@"
50 CODE_GEN_FLAGS="@CODE_GEN_FLAGS@"
51 CODE_GEN_FLAGS_CXX="@CODE_GEN_FLAGS_CXX@"
52 LDFLAGS_EXE="@LDFLAGS_EXE@"
53 MACRESWXCONFIG="@MACRESWXCONFIG@"
54 EXTRALIBS_GUI="@EXTRALIBS_GUI@"
55 LIBS="@LIBS@"
56 WXCONFIG_LDFLAGS_GUI="@WXCONFIG_LDFLAGS_GUI@"
57
58
59 # Linker flags for sublibraries:
60
61 CORE_BASE_LIBS="@CORE_BASE_LIBS@"
62 CORE_GUI_LIBS="@CORE_GUI_LIBS@"
63
64 ldlibs_base="@WXCONFIG_EXTRALIBS@"
65 ldlibs_core="@EXTRALIBS_GUI@"
66 ldlibs_xml="@EXTRALIBS_XML@"
67 ldlibs_odbc="@EXTRALIBS_ODBC@"
68
69 ldflags_gl="@LDFLAGS_GL@"
70 ldlibs_gl="@OPENGL_LIBS@"
71
72
73
74 # -------------------------------------------------------------------------
75 # Script code:
76 # -------------------------------------------------------------------------
77
78 exec_prefix_set=no
79
80 # is $1 among the rest of arguments?
81 isinlist()
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):
94 output_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:
132 get_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
144 makeabs()
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
160 usage()
161 {
162 cat <<EOF
163 Usage: 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
168 wx-config returns configuration information about the installed
169 version of wxWindows. It may be used to query its version and
170 installation directories and also retrieve the C and C++ compilers
171 and linker which were used for its building and the corresponding
172 flags.
173
174 Ordinarily it should be installed to the appropriate system location
175 along with the headers and library files, but it is also possible to
176 use it to enable builds with an uninstalled wxWindows version for
177 package building and bleeding edge developers. To do so, use it like
178 this:
179
180 \${wx_builddir}/wx-config --prefix=\${wx_srcdir} --exec-prefix=\${wx_builddir}
181
182 Note that any other options supplied must come *after* the prefix
183 specification 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
188 wxWindows libraries to link against. This list can include both core
189 and contrib libraries.
190
191 --gl-libs option is deprecated, used --libs=gl instead.
192
193 EOF
194
195 exit $1
196 }
197
198 cppflags()
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
234 if test $# -eq 0; then
235 usage 1 1>&2
236 fi
237
238 while 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
363 done
364