]>
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@" | |
224bf05c | 12 | WX_SUBRELEASE_NUMBER="@WX_SUBRELEASE_NUMBER@" |
33380099 VS |
13 | release="@WX_MAJOR_VERSION_NUMBER@.@WX_MINOR_VERSION_NUMBER@" |
14 | is_monolithic="@MONOLITHIC@" | |
15 | cross_compiling="@cross_compiling@" | |
16 | target="@host_alias@" | |
17 | static_flag="@STATIC_FLAG@" | |
127e9080 | 18 | inplace_flag="no" |
33380099 VS |
19 | |
20 | # Misc configuration variables: | |
21 | ||
0154f61a VS |
22 | update_prefixes() |
23 | { | |
24 | includedir="@includedir@" | |
25 | libdir="@libdir@" | |
26 | } | |
33380099 VS |
27 | prefix="@prefix@" |
28 | exec_prefix="@exec_prefix@" | |
0154f61a VS |
29 | update_prefixes |
30 | ||
6ce73557 | 31 | CC="@CC@" |
2b5f62a0 | 32 | GCC="@GCC@" |
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@" | |
74b84332 | 51 | GCC_PRAGMA_FLAGS="@GCC_PRAGMA_FLAGS@" |
33380099 VS |
52 | CODE_GEN_FLAGS="@CODE_GEN_FLAGS@" |
53 | CODE_GEN_FLAGS_CXX="@CODE_GEN_FLAGS_CXX@" | |
54 | LDFLAGS_EXE="@LDFLAGS_EXE@" | |
55 | MACRESWXCONFIG="@MACRESWXCONFIG@" | |
56 | EXTRALIBS_GUI="@EXTRALIBS_GUI@" | |
57 | LIBS="@LIBS@" | |
ffef10f6 | 58 | WXCONFIG_LDFLAGS_GUI="@WXCONFIG_LDFLAGS_GUI@" |
cf615ebb VS |
59 | |
60 | ||
61 | # Linker flags for sublibraries: | |
33380099 | 62 | |
edd891e2 VS |
63 | CORE_BASE_LIBS="@CORE_BASE_LIBS@" |
64 | CORE_GUI_LIBS="@CORE_GUI_LIBS@" | |
cf615ebb | 65 | |
67c13b6c | 66 | ldlibs_base="@WXCONFIG_EXTRALIBS@" |
cf615ebb VS |
67 | ldlibs_core="@EXTRALIBS_GUI@" |
68 | ldlibs_xml="@EXTRALIBS_XML@" | |
3527f29c | 69 | ldlibs_html="@EXTRALIBS_HTML@" |
bb41dcbe | 70 | ldlibs_odbc="@EXTRALIBS_ODBC@" |
f93ca9fd | 71 | ldlibs_adv="@EXTRALIBS_SDL@" |
cf615ebb VS |
72 | |
73 | ldflags_gl="@LDFLAGS_GL@" | |
74 | ldlibs_gl="@OPENGL_LIBS@" | |
75 | ||
76 | ||
33380099 VS |
77 | |
78 | # ------------------------------------------------------------------------- | |
79 | # Script code: | |
80 | # ------------------------------------------------------------------------- | |
81 | ||
82 | exec_prefix_set=no | |
83 | ||
cf615ebb VS |
84 | # is $1 among the rest of arguments? |
85 | isinlist() | |
86 | { | |
87 | value=$1 | |
88 | shift | |
89 | isin=no | |
90 | for iii in $* ; do | |
91 | if test $iii = $value ; then isin=yes ; fi | |
92 | done | |
93 | test $isin = yes | |
94 | } | |
95 | ||
96 | # output linker commands needed to link against libraries passed as arguments | |
97 | # (does not handle monolithic/multilib): | |
98 | output_libs() | |
99 | { | |
67c13b6c VS |
100 | if test "$cross_compiling" = "yes" ; then |
101 | target_tag="-${target}" | |
102 | fi | |
103 | ||
cf615ebb VS |
104 | all_libs="" |
105 | all_ldflags="" | |
106 | wxlibs="" | |
67c13b6c | 107 | |
cf615ebb VS |
108 | for lib in $* ; do |
109 | eval xlibs=\$ldlibs_$lib | |
110 | eval xflags=\$ldflags_$lib | |
111 | if isinlist $lib $CORE_BASE_LIBS ; then | |
112 | basename=$basename_nogui | |
113 | else | |
114 | basename=$basename_gui | |
115 | fi | |
fef23dd4 VS |
116 | if test $lib = "base" ; then |
117 | libname="$basename" | |
118 | else | |
119 | libname="${basename}_${lib}" | |
120 | fi | |
cf615ebb VS |
121 | |
122 | all_ldflags="$all_ldflags $xflags" | |
123 | if test $static_flag = yes ; then | |
33380099 | 124 | wxlibs="$wxlibs ${libdir}/lib${libname}-${release}${target_tag}.a" |
cf615ebb VS |
125 | all_libs="$all_libs $xlibs" |
126 | else | |
67c13b6c | 127 | wxlibs="$wxlibs -l${libname}-${release}${target_tag}" |
cf615ebb VS |
128 | fi |
129 | done | |
130 | ||
131 | echo $all_ldflags $wxlibs $all_libs | |
132 | } | |
9a98a854 | 133 | |
ffef10f6 VS |
134 | # output $(WXCONFIG_LDFLAGS_GUI) if any of libs passed as arguments is GUI |
135 | # library, nothing otherwise: | |
136 | get_ldflags_gui() | |
137 | { | |
138 | flags_to_ret="" | |
139 | for lib in $* ; do | |
140 | if isinlist $lib $CORE_GUI_LIBS ; then | |
141 | flags_to_ret="$WXCONFIG_LDFLAGS_GUI" | |
142 | fi | |
143 | done | |
144 | echo $flags_to_ret | |
145 | } | |
146 | ||
75f4be8a VZ |
147 | usage() |
148 | { | |
149 | cat <<EOF | |
89816e4f | 150 | Usage: wx-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--inplace] |
8708fa76 | 151 | [--toolkit=TOOLKIT] [--unicode[=yes|no]] [--debug[=yes|no]] |
48112931 | 152 | [--universal[=yes|no]] [--host=HOST] |
224bf05c | 153 | [--version[=VERSION]] [--version-full] [--release] |
8708fa76 | 154 | [--list] [--basename] [--static] [--libs] [--gl-libs] |
40f7145c | 155 | [--cppflags] [--cflags] [--cxxflags] [--ldflags] [--rezflags] |
89816e4f | 156 | [--cc] [--cxx] [--ld] [LIBRARIES] |
75f4be8a VZ |
157 | |
158 | wx-config returns configuration information about the installed | |
b63b07a8 | 159 | version of wxWidgets. It may be used to query its version and |
75f4be8a VZ |
160 | installation directories and also retrieve the C and C++ compilers |
161 | and linker which were used for its building and the corresponding | |
162 | flags. | |
2b5f62a0 | 163 | |
82a649b6 RL |
164 | Ordinarily it should be installed to the appropriate system location |
165 | along with the headers and library files, but it is also possible to | |
b63b07a8 | 166 | use it to enable builds with an uninstalled wxWidgets version for |
82a649b6 RL |
167 | package building and bleeding edge developers. To do so, use it like |
168 | this: | |
169 | ||
89816e4f | 170 | \${wx_builddir}/wx-config --inplace |
82a649b6 | 171 | |
89816e4f VS |
172 | Note that any other options supplied must come *after* --inplace |
173 | for it to take effect. | |
82a649b6 | 174 | |
efe6c06f | 175 | --static must come before --cppflags, --cflags, --cxxflags, |
a43ed08a | 176 | --libs and --gl-libs and --libs must come before the other ones. |
cf615ebb | 177 | |
838c9bd0 VS |
178 | wx-config can take optional argument that contains comma- or space-separated |
179 | list of wxWidgets libraries to compile and link against. This list can | |
180 | include both core and contrib libraries. Special value "std" stands for all | |
181 | libraries linked in by default. Examples: "wx-config --libs core,base" | |
182 | or "wx-config --cxxflags core,base". | |
cf615ebb | 183 | |
251f47d1 | 184 | --gl-libs option is deprecated, use "--libs gl" instead. |
67c13b6c | 185 | |
8708fa76 | 186 | If there are several different builds of wxWidgets installed in same prefix, |
48112931 VS |
187 | you can use --host, --toolkit, --unicode, --debug, --universal and --version |
188 | options to select one of them. Use --list option to show all available builds | |
189 | that match given criteria. | |
8708fa76 | 190 | |
75f4be8a VZ |
191 | EOF |
192 | ||
193 | exit $1 | |
194 | } | |
195 | ||
196 | cppflags() | |
197 | { | |
166bcebb | 198 | includes="-I${libdir}/wx/include/${TOOLCHAIN_NAME}" |
00c81359 | 199 | |
127e9080 | 200 | # in inplace case we need to also add path to contrib headers -- do it |
bc79eb4f | 201 | # unconditionally as they might be used and we have no way of knowing if |
127e9080 VZ |
202 | # they really are |
203 | if test $inplace_flag = yes ; then | |
166bcebb VS |
204 | includes="$includes -I${prefix}/include -I${prefix}/contrib/include" |
205 | else | |
206 | includes="$includes -I${includedir}/wx-${WX_MAJOR_VERSION_NUMBER}.${WX_MINOR_VERSION_NUMBER}" | |
127e9080 VZ |
207 | fi |
208 | ||
a43ed08a VZ |
209 | flags="$includes ${WXDEBUG_DEFINE} ${TOOLCHAIN_DEFS}" |
210 | if test $static_flag != yes ; then | |
211 | flags="$flags ${TOOLCHAIN_DLL_DEFS}" | |
00c81359 | 212 | fi |
a43ed08a | 213 | |
251f47d1 VS |
214 | if test $nogui_flag = "yes" ; then |
215 | flags="$flags -DwxUSE_GUI=0" | |
a43ed08a VZ |
216 | fi |
217 | ||
2001ecbc | 218 | echo "$flags ${WXCONFIG_INCLUDE} ${WX_LARGEFILE_FLAGS} ${GCC_PRAGMA_FLAGS}" |
75f4be8a | 219 | } |
9a98a854 VZ |
220 | |
221 | if test $# -eq 0; then | |
3a922bb4 | 222 | usage 1 1>&2 |
9a98a854 VZ |
223 | fi |
224 | ||
251f47d1 VS |
225 | |
226 | # handle libraries list: | |
227 | ||
228 | libs_list="" | |
229 | ||
230 | for arg in $*; do | |
231 | case "$arg" in | |
232 | -*) | |
233 | ;; | |
234 | *) | |
235 | libs_list="$libs_list `echo "$arg" | tr ',' ' '`" | |
236 | ;; | |
237 | esac | |
238 | done | |
239 | ||
240 | if test "x$libs_list" = "x" ; then | |
241 | if test "$is_monolithic" = "0" ; then | |
242 | # link against all libs if none given explicitly: | |
243 | libs_list="$CORE_GUI_LIBS $CORE_BASE_LIBS" | |
244 | fi | |
245 | else | |
246 | # always add wxBase, any wxApp needs it: | |
247 | libs_list="$libs_list base" | |
248 | fi | |
249 | ||
250 | # determine if at least one gui lib was used: | |
c39ee0ad VS |
251 | if test "$is_monolithic" = "0" ; then |
252 | nogui_flag="yes" | |
253 | for i in $libs_list; do | |
254 | case $i in | |
255 | base|net) | |
256 | ;; | |
257 | *) | |
258 | nogui_flag="no" | |
259 | ;; | |
260 | esac | |
261 | done | |
262 | else | |
263 | nogui_flag="no" | |
264 | fi | |
251f47d1 VS |
265 | |
266 | ||
267 | # handle options: | |
268 | ||
9a98a854 VZ |
269 | while test $# -gt 0; do |
270 | case "$1" in | |
271 | -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; | |
272 | *) optarg= ;; | |
273 | esac | |
274 | ||
275 | case $1 in | |
52c71b80 | 276 | --inplace) |
127e9080 | 277 | inplace_flag=yes |
52c71b80 | 278 | ;; |
9a98a854 VZ |
279 | --prefix=*) |
280 | prefix=$optarg | |
281 | if test $exec_prefix_set = no ; then | |
282 | exec_prefix=$optarg | |
283 | fi | |
0154f61a | 284 | update_prefixes |
9a98a854 VZ |
285 | ;; |
286 | --prefix) | |
287 | echo $prefix | |
288 | ;; | |
289 | --exec-prefix=*) | |
290 | exec_prefix=$optarg | |
291 | exec_prefix_set=yes | |
0154f61a | 292 | update_prefixes |
9a98a854 VZ |
293 | ;; |
294 | --exec-prefix) | |
295 | echo $exec_prefix | |
296 | ;; | |
297 | --version) | |
33380099 | 298 | echo ${WX_MAJOR_VERSION_NUMBER}.${WX_MINOR_VERSION_NUMBER}.${WX_RELEASE_NUMBER} |
9a98a854 | 299 | ;; |
224bf05c VZ |
300 | --version-full) |
301 | echo ${WX_MAJOR_VERSION_NUMBER}.${WX_MINOR_VERSION_NUMBER}.${WX_RELEASE_NUMBER}.${WX_SUBRELEASE_NUMBER} | |
302 | ;; | |
2f42e5b6 | 303 | --release) |
cf615ebb | 304 | echo $release |
2f42e5b6 VS |
305 | ;; |
306 | --basename) | |
9171d4b4 | 307 | echo $basename_gui |
2f42e5b6 | 308 | ;; |
3d63bc3a RL |
309 | --static) |
310 | static_flag=yes | |
311 | ;; | |
75f4be8a VZ |
312 | --cppflags) |
313 | cppflags | |
314 | ;; | |
9a98a854 | 315 | --cflags) |
33380099 | 316 | echo `cppflags` ${CODE_GEN_FLAGS} |
75f4be8a VZ |
317 | ;; |
318 | --cxxflags) | |
33380099 | 319 | echo `cppflags` ${CODE_GEN_FLAGS} ${CODE_GEN_FLAGS_CXX} |
9a98a854 | 320 | ;; |
40f7145c | 321 | --ldflags) |
33380099 | 322 | echo ${LDFLAGS_EXE} |
40f7145c | 323 | ;; |
2baaf735 | 324 | --rezflags) |
09d3439c | 325 | echo `eval echo ${MACRESWXCONFIG}` |
2baaf735 | 326 | ;; |
cf615ebb | 327 | |
251f47d1 | 328 | --libs) |
cf615ebb | 329 | # include install directory only if it is not default: |
33380099 | 330 | if test "${libdir}" != "/usr/lib" \ |
77e13408 | 331 | -a \( "${cross_compiling}" != "yes" \ |
33380099 | 332 | -o "${libdir}" != "/usr/${target}/lib" \) ; |
3a922bb4 | 333 | then |
33380099 | 334 | libs="-L${libdir}" |
9a98a854 | 335 | fi |
3d63bc3a | 336 | |
a43ed08a | 337 | # it's simpler to avoid handling "base" itself at all as we add it in the |
1d8864ac | 338 | # end to the list of libraries anyhow |
cf615ebb VS |
339 | # in monolithic build, link against the main library: |
340 | if test "$is_monolithic" = "1" ; then | |
341 | # filter out core libs, leave only contrib in libs_list: | |
342 | newlist= | |
343 | for i in $libs_list ; do | |
1d8864ac | 344 | if isinlist $i $CORE_GUI_LIBS $CORE_BASE_LIBS; then |
cf615ebb VS |
345 | libs_list="" # do nothing |
346 | else | |
347 | newlist="$newlist $i" | |
348 | fi | |
349 | done | |
350 | libs_list="$newlist" | |
9171d4b4 | 351 | |
cf615ebb VS |
352 | # output link flags: |
353 | contrib_libs=`output_libs $libs_list` | |
354 | if test $static_flag = yes ; then | |
ffef10f6 | 355 | echo "$libs ${LDFLAGS} ${WXCONFIG_LDFLAGS_GUI} ${WXCONFIG_RPATH} $contrib_libs ${libdir}/${WXCONFIG_LIBS_STATIC} ${EXTRALIBS_GUI} ${LIBS} ${DMALLOC_LIBS}" |
cf615ebb | 356 | else |
ffef10f6 | 357 | echo $libs ${LDFLAGS} ${WXCONFIG_LDFLAGS_GUI} ${WXCONFIG_RPATH} $contrib_libs ${WXCONFIG_LIBS} ${DMALLOC_LIBS} |
cf615ebb | 358 | fi |
3d63bc3a | 359 | else |
1d8864ac VZ |
360 | # we may need to replace "std" alias with its expansion |
361 | newlist= | |
362 | hadstd=0 | |
363 | for i in $libs_list; do | |
364 | case $i in | |
365 | std) | |
366 | hadstd=1 | |
367 | ;; | |
368 | ||
369 | base) | |
370 | # if we have std, we're going to add base anyhow, avoid | |
371 | # having it twice in the end | |
372 | if [ $hadstd = 0 ]; then | |
a43ed08a | 373 | newlist="$newlist $i" |
1d8864ac VZ |
374 | fi |
375 | ;; | |
376 | ||
377 | *) | |
378 | newlist="$newlist $i" | |
379 | ;; | |
380 | esac | |
381 | done | |
382 | libs_list="$newlist" | |
383 | if [ $hadstd = 1 ]; then | |
384 | libs_list="$libs_list $CORE_GUI_LIBS $CORE_BASE_LIBS" | |
385 | fi | |
386 | ||
cf615ebb VS |
387 | # in multilib mode, link against all sublibraries: |
388 | wxlibs=`output_libs $libs_list` | |
ffef10f6 VS |
389 | guildflags=`get_ldflags_gui $libs_list` |
390 | echo $libs ${LDFLAGS} ${guildflags} ${WXCONFIG_RPATH} $wxlibs ${DMALLOC_LIBS} | |
3d63bc3a RL |
391 | fi |
392 | ||
3a922bb4 RL |
393 | ;; |
394 | --gl-libs) | |
cf615ebb | 395 | output_libs gl |
9a98a854 | 396 | ;; |
6ce73557 VZ |
397 | --cc) |
398 | echo $CC | |
399 | ;; | |
400 | --cxx) | |
401 | echo $CXX | |
402 | ;; | |
403 | --ld) | |
404 | echo $LD | |
405 | ;; | |
251f47d1 | 406 | --help|-h) |
75f4be8a | 407 | usage 1 1>&2 |
9a98a854 | 408 | ;; |
14885f09 VS |
409 | -*) |
410 | # unrecognized flag is error | |
411 | usage 1 1>&2 | |
412 | ;; | |
9a98a854 VZ |
413 | esac |
414 | shift | |
415 | done | |
416 |