]>
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@" |
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@" | |
74b84332 | 50 | GCC_PRAGMA_FLAGS="@GCC_PRAGMA_FLAGS@" |
33380099 VS |
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 | ||
75f4be8a VZ |
146 | usage() |
147 | { | |
148 | cat <<EOF | |
89816e4f | 149 | Usage: wx-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--inplace] |
8708fa76 | 150 | [--toolkit=TOOLKIT] [--unicode[=yes|no]] [--debug[=yes|no]] |
48112931 VS |
151 | [--universal[=yes|no]] [--host=HOST] |
152 | [--version[=VERSION]] [--release] | |
8708fa76 | 153 | [--list] [--basename] [--static] [--libs] [--gl-libs] |
40f7145c | 154 | [--cppflags] [--cflags] [--cxxflags] [--ldflags] [--rezflags] |
89816e4f | 155 | [--cc] [--cxx] [--ld] [LIBRARIES] |
75f4be8a VZ |
156 | |
157 | wx-config returns configuration information about the installed | |
b63b07a8 | 158 | version of wxWidgets. It may be used to query its version and |
75f4be8a VZ |
159 | installation directories and also retrieve the C and C++ compilers |
160 | and linker which were used for its building and the corresponding | |
161 | flags. | |
2b5f62a0 | 162 | |
82a649b6 RL |
163 | Ordinarily it should be installed to the appropriate system location |
164 | along with the headers and library files, but it is also possible to | |
b63b07a8 | 165 | use it to enable builds with an uninstalled wxWidgets version for |
82a649b6 RL |
166 | package building and bleeding edge developers. To do so, use it like |
167 | this: | |
168 | ||
89816e4f | 169 | \${wx_builddir}/wx-config --inplace |
82a649b6 | 170 | |
89816e4f VS |
171 | Note that any other options supplied must come *after* --inplace |
172 | for it to take effect. | |
82a649b6 | 173 | |
efe6c06f | 174 | --static must come before --cppflags, --cflags, --cxxflags, |
a43ed08a | 175 | --libs and --gl-libs and --libs must come before the other ones. |
cf615ebb | 176 | |
838c9bd0 VS |
177 | wx-config can take optional argument that contains comma- or space-separated |
178 | list of wxWidgets libraries to compile and link against. This list can | |
179 | include both core and contrib libraries. Special value "std" stands for all | |
180 | libraries linked in by default. Examples: "wx-config --libs core,base" | |
181 | or "wx-config --cxxflags core,base". | |
cf615ebb | 182 | |
251f47d1 | 183 | --gl-libs option is deprecated, use "--libs gl" instead. |
67c13b6c | 184 | |
8708fa76 | 185 | If there are several different builds of wxWidgets installed in same prefix, |
48112931 VS |
186 | you can use --host, --toolkit, --unicode, --debug, --universal and --version |
187 | options to select one of them. Use --list option to show all available builds | |
188 | that match given criteria. | |
8708fa76 | 189 | |
75f4be8a VZ |
190 | EOF |
191 | ||
192 | exit $1 | |
193 | } | |
194 | ||
195 | cppflags() | |
196 | { | |
166bcebb | 197 | includes="-I${libdir}/wx/include/${TOOLCHAIN_NAME}" |
00c81359 | 198 | |
127e9080 | 199 | # in inplace case we need to also add path to contrib headers -- do it |
bc79eb4f | 200 | # unconditionally as they might be used and we have no way of knowing if |
127e9080 VZ |
201 | # they really are |
202 | if test $inplace_flag = yes ; then | |
166bcebb VS |
203 | includes="$includes -I${prefix}/include -I${prefix}/contrib/include" |
204 | else | |
205 | includes="$includes -I${includedir}/wx-${WX_MAJOR_VERSION_NUMBER}.${WX_MINOR_VERSION_NUMBER}" | |
127e9080 VZ |
206 | fi |
207 | ||
a43ed08a VZ |
208 | flags="$includes ${WXDEBUG_DEFINE} ${TOOLCHAIN_DEFS}" |
209 | if test $static_flag != yes ; then | |
210 | flags="$flags ${TOOLCHAIN_DLL_DEFS}" | |
00c81359 | 211 | fi |
a43ed08a | 212 | |
251f47d1 VS |
213 | if test $nogui_flag = "yes" ; then |
214 | flags="$flags -DwxUSE_GUI=0" | |
a43ed08a VZ |
215 | fi |
216 | ||
217 | echo "$flags${WXCONFIG_INCLUDE} ${WX_LARGEFILE_FLAGS} ${GCC_PRAGMA_FLAGS}" | |
75f4be8a | 218 | } |
9a98a854 VZ |
219 | |
220 | if test $# -eq 0; then | |
3a922bb4 | 221 | usage 1 1>&2 |
9a98a854 VZ |
222 | fi |
223 | ||
251f47d1 VS |
224 | |
225 | # handle libraries list: | |
226 | ||
227 | libs_list="" | |
228 | ||
229 | for arg in $*; do | |
230 | case "$arg" in | |
231 | -*) | |
232 | ;; | |
233 | *) | |
234 | libs_list="$libs_list `echo "$arg" | tr ',' ' '`" | |
235 | ;; | |
236 | esac | |
237 | done | |
238 | ||
239 | if test "x$libs_list" = "x" ; then | |
240 | if test "$is_monolithic" = "0" ; then | |
241 | # link against all libs if none given explicitly: | |
242 | libs_list="$CORE_GUI_LIBS $CORE_BASE_LIBS" | |
243 | fi | |
244 | else | |
245 | # always add wxBase, any wxApp needs it: | |
246 | libs_list="$libs_list base" | |
247 | fi | |
248 | ||
249 | # determine if at least one gui lib was used: | |
250 | nogui_flag="yes" | |
251 | for i in $libs_list; do | |
252 | case $i in | |
253 | base|net) | |
254 | ;; | |
255 | *) | |
256 | nogui_flag="no" | |
257 | ;; | |
258 | esac | |
259 | done | |
260 | ||
261 | ||
262 | # handle options: | |
263 | ||
9a98a854 VZ |
264 | while test $# -gt 0; do |
265 | case "$1" in | |
266 | -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; | |
267 | *) optarg= ;; | |
268 | esac | |
269 | ||
270 | case $1 in | |
52c71b80 | 271 | --inplace) |
127e9080 | 272 | inplace_flag=yes |
52c71b80 | 273 | ;; |
9a98a854 VZ |
274 | --prefix=*) |
275 | prefix=$optarg | |
276 | if test $exec_prefix_set = no ; then | |
277 | exec_prefix=$optarg | |
278 | fi | |
0154f61a | 279 | update_prefixes |
9a98a854 VZ |
280 | ;; |
281 | --prefix) | |
282 | echo $prefix | |
283 | ;; | |
284 | --exec-prefix=*) | |
285 | exec_prefix=$optarg | |
286 | exec_prefix_set=yes | |
0154f61a | 287 | update_prefixes |
9a98a854 VZ |
288 | ;; |
289 | --exec-prefix) | |
290 | echo $exec_prefix | |
291 | ;; | |
292 | --version) | |
33380099 | 293 | echo ${WX_MAJOR_VERSION_NUMBER}.${WX_MINOR_VERSION_NUMBER}.${WX_RELEASE_NUMBER} |
9a98a854 | 294 | ;; |
2f42e5b6 | 295 | --release) |
cf615ebb | 296 | echo $release |
2f42e5b6 VS |
297 | ;; |
298 | --basename) | |
9171d4b4 | 299 | echo $basename_gui |
2f42e5b6 | 300 | ;; |
3d63bc3a RL |
301 | --static) |
302 | static_flag=yes | |
303 | ;; | |
75f4be8a VZ |
304 | --cppflags) |
305 | cppflags | |
306 | ;; | |
9a98a854 | 307 | --cflags) |
33380099 | 308 | echo `cppflags` ${CODE_GEN_FLAGS} |
75f4be8a VZ |
309 | ;; |
310 | --cxxflags) | |
33380099 | 311 | echo `cppflags` ${CODE_GEN_FLAGS} ${CODE_GEN_FLAGS_CXX} |
9a98a854 | 312 | ;; |
40f7145c | 313 | --ldflags) |
33380099 | 314 | echo ${LDFLAGS_EXE} |
40f7145c | 315 | ;; |
2baaf735 | 316 | --rezflags) |
09d3439c | 317 | echo `eval echo ${MACRESWXCONFIG}` |
2baaf735 | 318 | ;; |
cf615ebb | 319 | |
251f47d1 | 320 | --libs) |
cf615ebb | 321 | # include install directory only if it is not default: |
33380099 | 322 | if test "${libdir}" != "/usr/lib" \ |
77e13408 | 323 | -a \( "${cross_compiling}" != "yes" \ |
33380099 | 324 | -o "${libdir}" != "/usr/${target}/lib" \) ; |
3a922bb4 | 325 | then |
33380099 | 326 | libs="-L${libdir}" |
9a98a854 | 327 | fi |
3d63bc3a | 328 | |
a43ed08a | 329 | # it's simpler to avoid handling "base" itself at all as we add it in the |
1d8864ac | 330 | # end to the list of libraries anyhow |
cf615ebb VS |
331 | # in monolithic build, link against the main library: |
332 | if test "$is_monolithic" = "1" ; then | |
333 | # filter out core libs, leave only contrib in libs_list: | |
334 | newlist= | |
335 | for i in $libs_list ; do | |
1d8864ac | 336 | if isinlist $i $CORE_GUI_LIBS $CORE_BASE_LIBS; then |
cf615ebb VS |
337 | libs_list="" # do nothing |
338 | else | |
339 | newlist="$newlist $i" | |
340 | fi | |
341 | done | |
342 | libs_list="$newlist" | |
9171d4b4 | 343 | |
cf615ebb VS |
344 | # output link flags: |
345 | contrib_libs=`output_libs $libs_list` | |
346 | if test $static_flag = yes ; then | |
ffef10f6 | 347 | echo "$libs ${LDFLAGS} ${WXCONFIG_LDFLAGS_GUI} ${WXCONFIG_RPATH} $contrib_libs ${libdir}/${WXCONFIG_LIBS_STATIC} ${EXTRALIBS_GUI} ${LIBS} ${DMALLOC_LIBS}" |
cf615ebb | 348 | else |
ffef10f6 | 349 | echo $libs ${LDFLAGS} ${WXCONFIG_LDFLAGS_GUI} ${WXCONFIG_RPATH} $contrib_libs ${WXCONFIG_LIBS} ${DMALLOC_LIBS} |
cf615ebb | 350 | fi |
3d63bc3a | 351 | else |
1d8864ac VZ |
352 | # we may need to replace "std" alias with its expansion |
353 | newlist= | |
354 | hadstd=0 | |
355 | for i in $libs_list; do | |
356 | case $i in | |
357 | std) | |
358 | hadstd=1 | |
359 | ;; | |
360 | ||
361 | base) | |
362 | # if we have std, we're going to add base anyhow, avoid | |
363 | # having it twice in the end | |
364 | if [ $hadstd = 0 ]; then | |
a43ed08a | 365 | newlist="$newlist $i" |
1d8864ac VZ |
366 | fi |
367 | ;; | |
368 | ||
369 | *) | |
370 | newlist="$newlist $i" | |
371 | ;; | |
372 | esac | |
373 | done | |
374 | libs_list="$newlist" | |
375 | if [ $hadstd = 1 ]; then | |
376 | libs_list="$libs_list $CORE_GUI_LIBS $CORE_BASE_LIBS" | |
377 | fi | |
378 | ||
cf615ebb VS |
379 | # in multilib mode, link against all sublibraries: |
380 | wxlibs=`output_libs $libs_list` | |
ffef10f6 VS |
381 | guildflags=`get_ldflags_gui $libs_list` |
382 | echo $libs ${LDFLAGS} ${guildflags} ${WXCONFIG_RPATH} $wxlibs ${DMALLOC_LIBS} | |
3d63bc3a RL |
383 | fi |
384 | ||
3a922bb4 RL |
385 | ;; |
386 | --gl-libs) | |
cf615ebb | 387 | output_libs gl |
9a98a854 | 388 | ;; |
6ce73557 VZ |
389 | --cc) |
390 | echo $CC | |
391 | ;; | |
392 | --cxx) | |
393 | echo $CXX | |
394 | ;; | |
395 | --ld) | |
396 | echo $LD | |
397 | ;; | |
251f47d1 | 398 | --help|-h) |
75f4be8a | 399 | usage 1 1>&2 |
9a98a854 | 400 | ;; |
14885f09 VS |
401 | -*) |
402 | # unrecognized flag is error | |
403 | usage 1 1>&2 | |
404 | ;; | |
9a98a854 VZ |
405 | esac |
406 | shift | |
407 | done | |
408 |