]> git.saurik.com Git - wxWidgets.git/blob - wx-config.in
fix wxBase name
[wxWidgets.git] / wx-config.in
1 #!/bin/sh
2
3 # Generic configuration variables:
4 prefix=@prefix@
5 exec_prefix=@exec_prefix@
6 exec_prefix_set=no
7 CC="@CC@"
8 GCC="@GCC@"
9 CXX="@CXX@"
10 LD="@SHARED_LD@"
11 srcdir=@top_srcdir@
12 builddir=@top_builddir_wxconfig@
13 cross_compiling=@cross_compiling@
14 target=@host_alias@
15 static_flag=@STATIC_FLAG@
16 basename_nogui=@WX_LIBRARY_BASENAME_NOGUI@
17 basename_gui=@WX_LIBRARY_BASENAME_GUI@
18 release=@WX_MAJOR_VERSION_NUMBER@.@WX_MINOR_VERSION_NUMBER@
19 is_monolithic=@MONOLITHIC@
20
21
22 # Linker flags for sublibraries:
23 CORE_BASE_LIBS="xml net base"
24 CORE_GUI_LIBS="html core"
25
26 ldlibs_base="@LIBS@"
27 ldlibs_core="@EXTRALIBS_GUI@"
28 ldlibs_xml="@EXTRALIBS_XML@"
29
30 ldflags_gl="@LDFLAGS_GL@"
31 ldlibs_gl="@OPENGL_LIBS@"
32
33
34 # is $1 among the rest of arguments?
35 isinlist()
36 {
37 value=$1
38 shift
39 isin=no
40 for iii in $* ; do
41 if test $iii = $value ; then isin=yes ; fi
42 done
43 test $isin = yes
44 }
45
46 # output linker commands needed to link against libraries passed as arguments
47 # (does not handle monolithic/multilib):
48 output_libs()
49 {
50 all_libs=""
51 all_ldflags=""
52 wxlibs=""
53
54 for lib in $* ; do
55 eval xlibs=\$ldlibs_$lib
56 eval xflags=\$ldflags_$lib
57 if isinlist $lib $CORE_BASE_LIBS ; then
58 basename=$basename_nogui
59 else
60 basename=$basename_gui
61 fi
62 if test $lib = "base" ; then
63 libname="$basename"
64 else
65 libname="${basename}_${lib}"
66 fi
67
68 all_ldflags="$all_ldflags $xflags"
69 if test $static_flag = yes ; then
70 wxlibs="$wxlibs @libdir@/lib${libname}-${release}.a"
71 all_libs="$all_libs $xlibs"
72 else
73 wxlibs="$wxlibs -l${libname}-${release}"
74 fi
75 done
76
77 echo $all_ldflags $wxlibs $all_libs
78 }
79
80 # return the absolute path prepending builddir to it if needed
81 makeabs()
82 {
83 path=$1
84 # TODO: this only works under Unix and even there it could be
85 # enhanced to remove ".." and "."
86 if [ `echo $path | sed 's/^\(.\).*/\1/'` != "/" ]; then
87 if [ $path = "." ]; then
88 path=$builddir
89 else
90 path="$builddir/$path"
91 fi
92 fi
93
94 echo $path
95 }
96
97 usage()
98 {
99 cat <<EOF
100 Usage: wx-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--release]
101 [--basename] [--static] [--libs[=LIBS]] [--gl-libs]
102 [--cppflags] [--cflags] [--cxxflags] [--ldflags] [--rezflags]
103 [--cc] [--cxx] [--ld]
104
105 wx-config returns configuration information about the installed
106 version of wxWindows. It may be used to query its version and
107 installation directories and also retrieve the C and C++ compilers
108 and linker which were used for its building and the corresponding
109 flags.
110
111 Ordinarily it should be installed to the appropriate system location
112 along with the headers and library files, but it is also possible to
113 use it to enable builds with an uninstalled wxWindows version for
114 package building and bleeding edge developers. To do so, use it like
115 this:
116
117 \${wx_builddir}/wx-config --prefix=\${wx_srcdir} --exec-prefix=\${wx_builddir}
118
119 Note that any other options supplied must come *after* the prefix
120 specification for it to take effect.
121
122 --static must come before --libs and --gl-libs.
123
124 --libs can take optional argument that contains comma-separated list of
125 wxWindows libraries to link against. This list can include both core
126 and contrib libraries.
127
128 EOF
129
130 exit $1
131 }
132
133 cppflags()
134 {
135 # we should never specify -I/usr/include on the compiler command line: this
136 # is at best useless and at worst breaks compilation on the systems where
137 # the system headers are non-ANSI because gcc works around this by storing
138 # the ANSI-fied versions of them in its private directory which is searched
139 # after all the directories on the cmd line.
140 #
141 # the situation is a bit more complicated with -I/usr/local/include: again,
142 # it shouldn't be specified with gcc which looks there by default anyhow
143 # and gives warnings (at least 3.1 does) if it is specified explicitly --
144 # but this -I switch *is* needed for the other compilers
145 #
146 # note that we assume that if we use GNU cc we also use GNU c++ and vice
147 # versa, i.e. this won't work (either for --cflags or --cxxflags) if GNU C
148 # compiler and non-GNU C++ compiler are used or vice versa -- we'll fix
149 # this when/if anybody complains about it
150 if test "@includedir@" != "/usr/include" \
151 -a "@includedir@" != "/usr/include/c++" \
152 -a \( "${GCC}" != "yes" \
153 -o "@includedir@" != "/usr/local/include" \) \
154 -a \( "${cross_compiling}" != "yes" \
155 -o "@includedir@" != "/usr/${target}/include" \) ;
156 then
157 includes=" -I@includedir@"
158 fi
159
160 includes="-I@libdir@/wx/include/@TOOLCHAIN_NAME@$includes"
161
162 if test $static_flag = yes ; then
163 echo $includes @WXDEBUG_DEFINE@ @TOOLCHAIN_DEFS@ @WXCONFIG_INCLUDE@ @WX_LARGEFILE_FLAGS@
164 else
165 echo $includes @WXDEBUG_DEFINE@ @TOOLCHAIN_DEFS@ @TOOLCHAIN_DLL_DEFS@ @WXCONFIG_INCLUDE@ @WX_LARGEFILE_FLAGS@
166 fi
167 }
168
169 if test $# -eq 0; then
170 usage 1 1>&2
171 fi
172
173 while test $# -gt 0; do
174 case "$1" in
175 -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
176 *) optarg= ;;
177 esac
178
179 case $1 in
180 --inplace)
181 prefix=`makeabs $srcdir`
182 exec_prefix=`makeabs $builddir`
183 exec_prefix_set=yes
184 ;;
185 --prefix=*)
186 prefix=$optarg
187 if test $exec_prefix_set = no ; then
188 exec_prefix=$optarg
189 fi
190 ;;
191 --prefix)
192 echo $prefix
193 ;;
194 --exec-prefix=*)
195 exec_prefix=$optarg
196 exec_prefix_set=yes
197 ;;
198 --exec-prefix)
199 echo $exec_prefix
200 ;;
201 --version)
202 echo @WX_MAJOR_VERSION_NUMBER@.@WX_MINOR_VERSION_NUMBER@.@WX_RELEASE_NUMBER@
203 ;;
204 --release)
205 echo $release
206 ;;
207 --basename)
208 echo $basename
209 ;;
210 --static)
211 static_flag=yes
212 ;;
213 --cppflags)
214 cppflags
215 ;;
216 --cflags)
217 echo `cppflags` @CODE_GEN_FLAGS@
218 ;;
219 --cxxflags)
220 echo `cppflags` @CODE_GEN_FLAGS@ @CODE_GEN_FLAGS_CXX@
221 ;;
222 --ldflags)
223 echo @LDFLAGS_EXE@
224 ;;
225 --rezflags)
226 echo @MACRESWXCONFIG@
227 ;;
228
229 --libs*)
230 # find if the argument was --libs=list,of,libs or --libs:
231 if test "x$optarg" = "x" ; then
232 if test "$is_monolithic" = "0" ; then
233 # link against all libs if none given explicitly:
234 libs_list="$CORE_GUI_LIBS $CORE_BASE_LIBS"
235 fi
236 else
237 libs_list=`echo "$optarg" | tr ',' ' '`
238 fi
239
240 # include install directory only if it is not default:
241 if test "@libdir@" != "/usr/lib" \
242 -a \( "${cross_compiling}" != "yes" \
243 -o "@libdir@" != "/usr/${target}/lib" \) ;
244 then
245 libs="-L@libdir@"
246 fi
247
248 # in monolithic build, link against the main library:
249 if test "$is_monolithic" = "1" ; then
250 # filter out core libs, leave only contrib in libs_list:
251 newlist=
252 for i in $libs_list ; do
253 if isinlist $i $CORE_BASE_LIBS $CORE_GUI_LIBS ; then
254 libs_list="" # do nothing
255 else
256 newlist="$newlist $i"
257 fi
258 done
259 libs_list="$newlist"
260
261 # output link flags:
262 contrib_libs=`output_libs $libs_list`
263 if test $static_flag = yes ; then
264 echo "$libs @LDFLAGS@ @WXCONFIG_RPATH@ $contrib_libs @libdir@/@WXCONFIG_LIBS_STATIC@ @EXTRALIBS_GUI@ @LIBS@ @DMALLOC_LIBS@"
265 else
266 echo $libs @LDFLAGS@ @WXCONFIG_RPATH@ $contrib_libs @WXCONFIG_LIBS@ @DMALLOC_LIBS@
267 fi
268 else
269 # in multilib mode, link against all sublibraries:
270 wxlibs=`output_libs $libs_list`
271 echo $libs @LDFLAGS@ @WXCONFIG_RPATH@ $wxlibs @DMALLOC_LIBS@
272 fi
273
274 ;;
275 --gl-libs)
276 output_libs gl
277 ;;
278 --cc)
279 echo $CC
280 ;;
281 --cxx)
282 echo $CXX
283 ;;
284 --ld)
285 echo $LD
286 ;;
287 *)
288 usage 1 1>&2
289 ;;
290 esac
291 shift
292 done
293