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