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