]>
Commit | Line | Data |
---|---|---|
9a98a854 | 1 | #!/bin/sh |
ceec2216 RL |
2 | # |
3 | # Name: wx-config{.in,} | |
4 | # Purpose: wx configuration search and query tool {template,} | |
5 | # Author: Ron <ron@debian.org> | |
6 | # Modified by: | |
7 | # Created: 8/9/2004 | |
8 | # RCS-ID: $Id$ | |
9 | # Copyright: (c) 2004 Ron <ron@debian.org> | |
10 | # Essentially a fresh start this time around, but for maximum | |
11 | # compatibility basic code was taken from, and heavy reference | |
12 | # made to, the previously unattributed wx-config from cvs. | |
13 | # All the usual suspects contributed to the dicussion that led | |
14 | # to this new work and likewise to the ideas and content in the | |
15 | # original (which was probably influenced by gtk), among them: | |
16 | # Robert Roebling, Vadim Zeitlin, Vaclav Slavik, Robin Dunn | |
17 | # Licence: wxWindows licence | |
18 | ############################################################################ | |
19 | ||
6758d3d3 | 20 | # Extra^2 debug mode, for if things ever get really weird. |
8ec45325 RL |
21 | [ -z "$WXDEBUG_X" ] || set -x |
22 | ||
68ca6f52 RL |
23 | |
24 | # On with some basic stuff, like the ability to die gracefully, | |
ceec2216 RL |
25 | # and to tell people what we are about. |
26 | # ------------------------------------------------------------------ | |
27 | ||
28 | # decho _message | |
29 | # Output a message to stderr. | |
30 | decho() { echo "$*" 1>&2; } | |
31 | ||
32 | # usage _exitcode | |
33 | # Outputs a usage message to stderr and exits with _exitcode. | |
63f018eb RL |
34 | # Try to keep this to a single page (ie. < 25 lines). We can add |
35 | # alternate or interactive help targets if people want more detail. | |
36 | # | |
37 | # Exit codes are now subject to a more strict interpretation. | |
38 | # wx-config should return 0 upon successful operation, 1 if the | |
39 | # reqested operation could not be completed successfully, and 2 | |
40 | # if the requested operation is not supported by this version of | |
41 | # wx-config. | |
ceec2216 RL |
42 | usage() |
43 | { | |
44 | cat 1>&2 <<EOF | |
45 | ||
46 | wx-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--release] [--version-full] | |
16837dc3 | 47 | [--list] [--selected-config] [--host=HOST] [--toolkit=TOOLKIT] |
89b1afb4 VZ |
48 | [--universal[=yes|no]] [--unicode[=yes|no]] [--static[=yes|no]] |
49 | [--version[=VERSION]] [--basename] [--cc] [--cxx] | |
50 | [--cppflags [base]] [--cxxflags [base]] [--cflags] | |
6bddfdbf | 51 | [--rescomp] [--linkdeps] [--ld] [--utility=UTIL] |
bd630206 | 52 | [--libs [LIBS...]] [--optional-libs [LIBS...]] |
16837dc3 VZ |
53 | |
54 | wx-config returns information about the wxWidgets libraries available on | |
55 | your system. It may be used to retrieve the information required to build | |
6bddfdbf | 56 | applications using these libraries using --cppflags, --cxxflags, --cflags, |
e5405b6b | 57 | and --libs options. And you may query the properties of this configuration |
89b1afb4 | 58 | using --query-{host,toolkit,widgetset,chartype,version,linkage}. |
16837dc3 VZ |
59 | |
60 | If multiple builds of wxWidgets are available, you can use the options | |
89b1afb4 VZ |
61 | --prefix, --host, --toolkit, --unicode, --static, --universal or --version |
62 | to select from them. The --selected-config option shows the name of the | |
63 | current configuration and --list shows available alternatives which match | |
64 | specified criteria. The --utility option returns the correct version of | |
65 | UTIL to use with the selected build. The --linkdeps option returns only | |
16837dc3 | 66 | static libraries for your makefile link rule dependencies. |
ceec2216 | 67 | |
bd630206 VZ |
68 | The LIBS arguments (comma or space separated) may be used to specify the |
69 | wxWidgets libraries that you wish to use. The "std" label may be used to | |
70 | import all libraries that would be used by default if none were specified | |
71 | explicitly, e.g. wx-config --libs core,base. The "all" label may be used | |
72 | to import all libraries that have been compiled which are shown in the | |
73 | list below. The --optional-libs parameter should be followed by a list | |
74 | of libs that should be linked to, but only if they are available. | |
75 | ||
de0573da FM |
76 | Available libraries in this build are: |
77 | @BUILT_WX_LIBS@ | |
9a98a854 | 78 | |
ceec2216 | 79 | EOF |
33380099 | 80 | |
ceec2216 RL |
81 | exit $1 |
82 | } | |
33380099 | 83 | |
ceec2216 RL |
84 | # Unfussy people are the easiest to deal with, get them out of the way now. |
85 | [ $# -gt 0 ] || usage 1 | |
33380099 | 86 | |
33380099 | 87 | |
8ec45325 RL |
88 | # Contentious tools determined by configure. |
89 | EGREP="@EGREP@" | |
90 | ||
cf615ebb | 91 | |
ceec2216 RL |
92 | # For the people who know what they want, or think they do: |
93 | # Divide the valid arguments into functional groups for later examination, | |
94 | # then parse all command line arguments completely, deferring action on | |
95 | # output options until all significant input has been processed and any | |
96 | # decision about delegation has been taken. | |
cf615ebb | 97 | |
ceec2216 RL |
98 | # Note early, that '-' is a complete no-no for use in option names below. |
99 | # It totally falls apart as soon as it becomes part of a variable name. | |
100 | # Use '_' instead, and by the magic of it all just being bits, you'll | |
101 | # be able to use --my-option or --my_option from the command line at | |
102 | # your discretion. They are synonymous as user input, but _ALWAYS_ use | |
103 | # underscores for compound names in the code here, never a dash. | |
104 | ||
105 | ||
106 | # The list of all options we recognise. If it is not in here, then | |
107 | # it is not something we want to handle. | |
108 | # ------------------------------------------------------------------ | |
109 | ||
110 | # Options that specify a distinct library build. | |
111 | # | |
112 | # Note also that order in this list is significant later on, as this sets | |
113 | # the precedence with which we will try to gauge the similarity of other | |
114 | # configs to this one. Options earlier in the list should be more crucial | |
115 | # to match well than those that follow. Options specified by the user will | |
116 | # always take precedence and are not subject to any partial ordering here. | |
89b1afb4 | 117 | wxconfig_schema="host toolkit widgetset chartype flavour version linkage" |
ceec2216 RL |
118 | |
119 | # Options that are expected to generate some output. | |
92ea30ce RL |
120 | wxconfig_output_options="prefix exec_prefix |
121 | list | |
122 | release version version_full | |
123 | basename | |
124 | cppflags cflags cxxflags | |
370d2fd7 | 125 | rescomp |
891ace05 | 126 | rezflags |
92ea30ce | 127 | libs |
bd630206 | 128 | optional_libs |
92ea30ce RL |
129 | linkdeps |
130 | cc cxx ld | |
ceec2216 RL |
131 | gl_libs" |
132 | ||
133 | # Options that permit the user to supply hints that may affect the output. | |
134 | # These options all accept arbitrary values, to interpret as they please. | |
63f018eb | 135 | wxconfig_input_options="prefix exec_prefix utility $wxconfig_schema" |
cf615ebb | 136 | |
ceec2216 | 137 | # Input options that accept only a yes or no argument. |
89b1afb4 VZ |
138 | # |
139 | # Notice that this includes "debug" but it is done only for compatibility, this | |
140 | # options (i.e. --debug[=yes] or --debug=no) is completely ignored as there is | |
141 | # no distinction between debug and release builds in wx any more | |
ceec2216 | 142 | wxconfig_yesno_options="universal unicode debug static" |
cf615ebb | 143 | |
ceec2216 | 144 | # Boolean options that do something or not. |
6758d3d3 | 145 | wxconfig_flag_options="$wxconfig_yesno_options selected_config no_rpath inplace" |
33380099 | 146 | |
33380099 | 147 | |
33380099 | 148 | |
ceec2216 RL |
149 | # Some simple sugar coating to keep things more readable below. |
150 | # -------------------------------------------------------------- | |
151 | ||
152 | # option_name _string | |
153 | # Returns NAME if _string is of the form: --NAME[=...] | |
154 | option_name() | |
155 | { | |
b2f55c8b | 156 | echo "$1" | sed 's/^--//;s/=.*//' | tr '-' '_' |
ceec2216 RL |
157 | } |
158 | ||
159 | # option_value _string | |
160 | # Returns FOO if _string is of the form: --option=FOO | |
161 | option_value() | |
162 | { | |
b2f55c8b | 163 | echo "$1" | sed 's/^[^=]*=//' |
ceec2216 RL |
164 | } |
165 | ||
166 | # match_field _value _list | |
167 | # Returns true if _value is a field in _list | |
168 | match_field() | |
169 | { | |
170 | _match_field_match="$1" | |
171 | shift | |
b2f55c8b | 172 | for _match_field_i do |
ceec2216 RL |
173 | [ "x$_match_field_i" != "x$_match_field_match" ] || return 0 |
174 | done | |
175 | false | |
176 | } | |
177 | ||
178 | # remove_field _value _list | |
179 | # Returns _list minus any field(s) that match _value. | |
180 | remove_field() | |
cf615ebb | 181 | { |
ceec2216 RL |
182 | _remf_value="$1" |
183 | _remf_list='' | |
cf615ebb | 184 | shift |
3950ea80 | 185 | if [ -n "$_remf_value" ]; then |
b2f55c8b | 186 | for _remf_item do |
92ea30ce | 187 | [ "x$_remf_item" = "x$_remf_value" ] || |
3950ea80 RL |
188 | _remf_list="${_remf_list:+$_remf_list }$_remf_item" |
189 | done | |
190 | echo "$_remf_list" | |
191 | else | |
192 | echo $* | |
193 | fi | |
cf615ebb VS |
194 | } |
195 | ||
ceec2216 | 196 | # validate_arg _domain _set _name _value |
cf63f3d3 | 197 | # Boilerplate to validate an argument and initialise a pseudo-hash. |
ceec2216 RL |
198 | # This one is almost reduction into absurdity, and perhaps makes the |
199 | # precise action of the argument parser below just a little more | |
200 | # obscure, but oh so neat and compact to use for multiple option | |
201 | # groups. It expands to replace repetitive clauses of the form: | |
202 | # | |
203 | # i="$(option_name $arg)" | |
204 | # if match_field "$i" $wxconfig_input_options; then | |
205 | # input_options="${input_options:+$input_options }$i" | |
206 | # eval "input_option_$i=$(option_value $arg)" | |
207 | # continue | |
208 | # fi | |
209 | # | |
210 | # with the one liners you see on the page below. | |
211 | validate_arg() | |
cf615ebb | 212 | { |
b2f55c8b | 213 | if match_field "$3" `eval echo \"\\\$$1_$2_options\"`; then |
ceec2216 RL |
214 | eval "$2_options=\"\${$2_options:+\$$2_options }$3\"" |
215 | eval "$2_option_$3=\"$4\"" | |
216 | return | |
67c13b6c | 217 | fi |
ceec2216 RL |
218 | false |
219 | } | |
220 | ||
221 | # check_yesno_option _ynoption _option _yesval _noval | |
222 | # This one might be made more generic and/or incorporated into | |
223 | # validate_arg above at some later stage, but right now we just | |
224 | # condition any specialist options into a generic one for later | |
225 | # handling. Once they are sanity checked there is no difference | |
226 | # in any case. | |
227 | check_yesno_option() | |
228 | { | |
92ea30ce RL |
229 | eval "case \${yesno_option_$1-\${flag_option_$1-unset}} in |
230 | unset) ;; | |
231 | y*|Y*) input_option_$2=\"$3\" ;; | |
232 | n*|N*) input_option_$2=\"$4\" ;; | |
233 | *) | |
234 | decho | |
235 | decho \" *** Error: Invalid request '--$1=\$yesno_option_$1'\" | |
236 | decho \" Valid arguments for --$1 are: [ yes, no ]\" | |
237 | decho | |
238 | exit 1 | |
239 | ;; | |
ceec2216 RL |
240 | esac" |
241 | } | |
67c13b6c | 242 | |
67c13b6c | 243 | |
ceec2216 RL |
244 | |
245 | # Now we are ready to find out what the user wants from us. | |
246 | # -------------------------------------------------------------- | |
247 | ||
248 | # With just a little more complexity here we could have shortest | |
249 | # unique string matching for options, but that is probably overkill | |
250 | # today, so lets just get the job done. | |
251 | # | |
252 | # The important thing now then is that we simply read all input from | |
253 | # the user and don't try to act prematurely on partial information. | |
254 | # --help or an illegal argument are the only shortcuts out of here | |
255 | # at this point, otherwise, it's time to just shut up and listen for | |
256 | # a moment. | |
257 | ||
b2f55c8b | 258 | for arg do |
ceec2216 RL |
259 | case "$arg" in |
260 | --help|-h) | |
261 | usage | |
262 | ;; | |
263 | ||
264 | --*=*) | |
b2f55c8b MW |
265 | _name=`option_name $arg` |
266 | _value=`option_value $arg` | |
92ea30ce RL |
267 | if validate_arg wxconfig input "$_name" "$_value" || |
268 | validate_arg wxconfig yesno "$_name" "$_value" | |
ceec2216 RL |
269 | then |
270 | continue | |
cf615ebb | 271 | fi |
ceec2216 RL |
272 | ;; |
273 | ||
e5405b6b VZ |
274 | --query-*) |
275 | _name=`echo $arg | sed 's/^--query-//'` | |
276 | if match_field "$_name" $wxconfig_schema | |
277 | then | |
278 | query_options="${query_options:+$query_options }$_name" | |
279 | continue | |
280 | fi | |
281 | ;; | |
282 | ||
ceec2216 | 283 | --*) |
b2f55c8b | 284 | _name=`option_name $arg` |
92ea30ce RL |
285 | if validate_arg wxconfig flag "$_name" yes || |
286 | validate_arg wxconfig output "$_name" yes | |
ceec2216 RL |
287 | then |
288 | continue | |
fef23dd4 | 289 | fi |
ceec2216 | 290 | ;; |
cf615ebb | 291 | |
ceec2216 | 292 | *) |
bd630206 | 293 | # We validate the parameters later ... |
6bddfdbf | 294 | |
ccde7008 | 295 | if [ "$_name" = "cxxflags" ] || [ "$_name" = "cppflags" ] || [ "$_name" = "cflags" ]; then |
6bddfdbf VZ |
296 | cxx_parameters="${cxx_parameters:+$cxx_parameters }$arg" |
297 | elif [ "$_name" = "libs" ]; then | |
bd630206 | 298 | libs_parameters="${libs_parameters:+$libs_parameters }$arg" |
6bddfdbf | 299 | elif [ "$_name" = "optional_libs" ]; then |
bd630206 VZ |
300 | optional_libs_parameters="${optional_libs_parameters:+$optional_libs_parameters }$arg" |
301 | else | |
1342e47c VZ |
302 | # normally anything here are unattached arguments and signify an |
303 | # error but for compatibility with the 2.8 wx-config and, | |
304 | # especially, configure scripts generated using 2.8 wxwin.m4 and | |
305 | # hence doing `wx-config --version base,std`, we ignore anything | |
306 | # following this option, just as 2.8 version used to do | |
307 | if [ "$_name" != "version" ]; then | |
308 | input_parameters="${input_parameters:+$input_parameters }$arg" | |
309 | fi | |
bd630206 | 310 | fi |
ceec2216 RL |
311 | continue |
312 | ;; | |
313 | esac | |
314 | decho " *** Error: Unrecognised option: '$arg'" | |
315 | decho "Use wx-config --help for information on command line options." | |
63f018eb | 316 | exit 2 |
ceec2216 RL |
317 | done |
318 | ||
319 | # validate_arg only checks and decomposes form. Sanity check the yes/no | |
320 | # options now too and push their respective mask values into place. | |
321 | ||
322 | check_yesno_option universal widgetset univ | |
323 | check_yesno_option unicode chartype unicode ansi | |
e5405b6b | 324 | check_yesno_option static linkage static |
ceec2216 | 325 | |
ceec2216 RL |
326 | # Dump everything we just read in debug mode. |
327 | if [ -n "$WXDEBUG" ]; then | |
328 | ||
329 | decho | |
bd630206 VZ |
330 | decho " input parameters = $input_parameters" |
331 | decho " libs parameters = $libs_parameters" | |
332 | decho " optional-libs parameters = $optional_libs_parameters" | |
ceec2216 RL |
333 | decho " input options = $input_options" |
334 | for i in $input_options; do | |
b2f55c8b | 335 | decho " $i = `eval echo \"\\\$input_option_$i\"`" |
ceec2216 RL |
336 | done |
337 | decho " yes/no options = $yesno_options" | |
338 | for y in $yesno_options; do | |
b2f55c8b | 339 | decho " $y = `eval echo \"\\\$yesno_option_$y\"`" |
ceec2216 RL |
340 | done |
341 | decho " flag options = $flag_options" | |
342 | for f in $flag_options; do | |
b2f55c8b | 343 | decho " $f = `eval echo \"\\\$flag_option_$f\"`" |
cf615ebb | 344 | done |
ceec2216 RL |
345 | decho " output options = $output_options" |
346 | for o in $output_options; do | |
b2f55c8b | 347 | decho " $o = `eval echo \"\\\$output_option_$o\"`" |
ceec2216 | 348 | done |
e5405b6b | 349 | decho " query options = $query_options" |
ceec2216 RL |
350 | |
351 | fi | |
352 | ||
cf615ebb | 353 | |
ceec2216 RL |
354 | |
355 | # Everything came in as a legal argument then, lets put some of | |
356 | # the pieces together with a little self knowledge to see what | |
357 | # we should do next. | |
358 | # -------------------------------------------------------------- | |
359 | ||
360 | # get_mask [ _hash ] | |
e5405b6b | 361 | # Construct a config filename mask from a pseudo-hash of component variables. |
ceec2216 RL |
362 | # The optional argument is the prefix of the hash to use. If not specified |
363 | # this will return a mask derived from the command line options that were used. | |
364 | get_mask() | |
365 | { | |
366 | [ $# -gt 0 ] || set m | |
89b1afb4 | 367 | eval echo "\${$1_host:+\$$1_host-}\${$1_toolkit}\${$1_widgetset}-\${$1_chartype}\${$1_linkage:+-\$$1_linkage}-\${$1_version}\${$1_flavour}" |
cf615ebb | 368 | } |
9a98a854 | 369 | |
d9809627 RL |
370 | # Returns true if this script is for a cross compiled config. |
371 | is_cross() { [ "x@cross_compiling@" = "xyes" ]; } | |
372 | ||
ceec2216 RL |
373 | |
374 | # Determine the base directories we require. | |
375 | prefix=${input_option_prefix-${this_prefix:-@prefix@}} | |
0506bbbf | 376 | exec_prefix=${input_option_exec_prefix-${input_option_prefix-${this_exec_prefix:-@exec_prefix@}}} |
ceec2216 RL |
377 | wxconfdir="@libdir@/wx/config" |
378 | ||
b2f55c8b | 379 | installed_configs=`cd "$wxconfdir" 2> /dev/null && ls | grep -v "^inplace-"` |
ceec2216 | 380 | |
d9809627 | 381 | is_cross && target="@host_alias@" |
ceec2216 RL |
382 | |
383 | # Define a pseudo-hash to contain the specification of this wx-config | |
384 | # instance and its associated library. | |
e5405b6b | 385 | this_host="${target:+${target}}" |
ceec2216 RL |
386 | this_toolkit="@TOOLKIT_DIR@@TOOLKIT_VERSION@" |
387 | this_widgetset="@WIDGET_SET@" | |
388 | this_chartype="@WX_CHARTYPE@" | |
ceec2216 RL |
389 | this_flavour="@WX_FLAVOUR@" |
390 | this_version="@WX_RELEASE@" | |
e5405b6b | 391 | this_linkage=`[ "x@SHARED@" = "x1" ] || echo 'static'` |
ceec2216 | 392 | |
b2f55c8b | 393 | this_config=`get_mask this` |
ceec2216 | 394 | |
e5405b6b | 395 | |
ceec2216 | 396 | # Extract the user specification from the options parsed. |
b2f55c8b | 397 | m_host=${input_option_host:+"${input_option_host}-?"} |
e5405b6b | 398 | m_host=${m_host:-$this_host} |
b2f55c8b MW |
399 | m_toolkit=${input_option_toolkit:-'[^-]+'} |
400 | m_widgetset=${input_option_widgetset-'(univ)?'} | |
401 | m_chartype=${input_option_chartype:-'(unicode|ansi)'} | |
ceec2216 | 402 | m_flavour=${input_option_flavour:+-$input_option_flavour} |
b2f55c8b MW |
403 | m_flavour=${m_flavour:-${input_option_flavour-'(-[^-]+)?'}} |
404 | m_version=${input_option_version:-'[0-9]+\.[0-9]+'} | |
e5405b6b | 405 | m_linkage=${input_option_linkage-'?(static)?'} |
ceec2216 | 406 | |
b2f55c8b | 407 | configmask="^`get_mask`$" |
ceec2216 RL |
408 | |
409 | ||
410 | # Dump the user specification in debug mode. | |
411 | if [ -n "$WXDEBUG" ]; then | |
412 | ||
413 | decho | |
414 | decho " prefix = '$prefix'" | |
415 | decho " exec_prefix = '$exec_prefix'" | |
416 | decho " wxconfdir = '$wxconfdir'" | |
417 | ||
418 | decho " m_host = '$m_host'" | |
419 | decho " m_toolkit = '$m_toolkit'" | |
420 | decho " m_widgetset = '$m_widgetset'" | |
421 | decho " m_chartype = '$m_chartype'" | |
ceec2216 RL |
422 | decho " m_flavour = '$m_flavour'" |
423 | decho " m_version = '$m_version'" | |
424 | decho " m_linkage = '$m_linkage'" | |
425 | ||
426 | decho " configmask = '$configmask'" | |
427 | decho " this config = '$this_config'" | |
428 | decho | |
429 | ||
430 | fi | |
431 | ||
432 | ||
433 | ||
9a09819a RL |
434 | # From here on, we'll need to be able to figure out a delegation target. |
435 | # ----------------------------------------------------------------------- | |
ceec2216 RL |
436 | |
437 | # The rules for delegation are: | |
438 | # | |
439 | # 1. If the specification is so general that it matches the default config | |
440 | # (ie. this one on a first pass), then the default config will be used | |
441 | # even if other installed libs would also match the spec. | |
442 | # | |
443 | # 2. If the default config does not match, find a list of all installed | |
444 | # libraries that do match. | |
445 | # a. If that list is empty, the specification is incompatible | |
446 | # with any installed lib. Warn and abort. | |
447 | # b. If that list contains exactly one candidate. Delegate to | |
448 | # that candidate. | |
449 | # c. If the list contains multiple candidates, pass on to step 3. | |
450 | # | |
451 | # 3. Attempt to discriminate among rival candidates by their similarity | |
452 | # to the default configuration (ie. this one). If we can find a unique | |
453 | # candidate in this way, delegate to it. If not, present a list of | |
454 | # options to the user and request that they disambiguate it with one or | |
455 | # more additional fields. | |
456 | # | |
457 | # To refine the specified pattern, we specialise each unbound field | |
458 | # using the default value from this config file. If that results in | |
459 | # no matches, we unbind it again and try the next field. If it still | |
460 | # results in multiple matches we try binding the next field as well | |
461 | # until a unique or null result again occurs. | |
462 | # | |
463 | # A more general way to look at this, is the feature specifiers are all | |
464 | # modifiers of the wx-config you are calling. If you supply none, the | |
465 | # default for that build configuration will be used. If you supply one | |
466 | # or more that the default build cannot satisfy, it will try to find the | |
467 | # config most like itself with the desired feature(s) enabled. | |
468 | # The features configured into the first wx-config called will be taken | |
469 | # as implicitly specified if it is necessary to disambiguate likely | |
470 | # candidates from the information that was explicitly provided. | |
471 | ||
472 | ||
473 | # But first, more sugar to keep what follows clear and legible. | |
474 | # -------------------------------------------------------------- | |
475 | ||
9a09819a RL |
476 | # find_eligible_delegates _mask |
477 | # Outputs all the config files installed which match the | |
478 | # (extended regex) _mask passed as an argument. | |
8ec45325 | 479 | find_eligible_delegates() { echo "$installed_configs" | $EGREP "$1" 2> /dev/null; } |
9a09819a RL |
480 | |
481 | # user_mask_fits _config | |
482 | # Returns true if the string _config satisfies the user specified mask. | |
8ec45325 | 483 | user_mask_fits() { echo "$1" | $EGREP "$configmask" > /dev/null 2>&1; } |
9a09819a | 484 | |
ceec2216 RL |
485 | # count_fields _word |
486 | # Returns the number of IFS split fields in _word | |
487 | count_fields() { return $#; } | |
488 | ||
489 | # count_delegates _mask | |
490 | # Return the number of eligible config files that match _mask | |
b2f55c8b | 491 | count_delegates() { count_fields `find_eligible_delegates $1`; } |
ceec2216 RL |
492 | |
493 | # is_set _variablename | |
494 | # Returns true if $_variablename is initialised. | |
b2f55c8b MW |
495 | is_set() { [ "x`eval echo \"\\\${$1-unset}\"`" != "xunset" ]; } |
496 | ||
497 | # not _cmd _args... | |
498 | # true iff _cmd is false | |
ac2e7107 | 499 | not() { if "$@"; then false; else true; fi; } |
ceec2216 RL |
500 | |
501 | # do_find_best_delegate _unbound-options | |
502 | # The real worker part of find_best_delegate below. Recurses though all | |
503 | # unbound options binding them one at a time to the default derived from | |
504 | # this file until a unique match is made or no alternatives remain that | |
505 | # may be sensibly guessed at. It will preferentially bind the unspecified | |
506 | # options in the order they are listed in wxconfig_schema. Using this | |
507 | # partial ordering it should find the first match with the most significant | |
508 | # similarity to this file that unambiguously meets the user specification. | |
509 | # If such a match exists it will be output to stdout. | |
510 | # | |
511 | # Be careful if you modify this function. If the pruning logic is rendered | |
512 | # inoperative it will simply recurse over every permutation in the search | |
513 | # space, which may still appear to work, but add a couple more options (or | |
514 | # explicitly specify a few less) and you may not live long enough to learn | |
515 | # the result. WXDEBUG=findprogress is your friend here, it will show you | |
516 | # how many nodes get searched before a result. If you start seeing | |
517 | # increases in that number for the same input, check your work. | |
518 | # Raising the number of discriminating options from 6 to 8 raised the worst | |
519 | # case time for this to run (without pruning) from 3 to nearly 15 seconds | |
520 | # and its downhill fast from here if we have to ride that boat. | |
521 | # Early pruning still gets that down to under half a second (up from about | |
522 | # .25), so we have some breathing space yet before a different search method | |
523 | # will be called for, but lets not squander it. | |
524 | do_find_best_delegate() | |
ffef10f6 | 525 | { |
ceec2216 RL |
526 | ( |
527 | if [ "x$WXDEBUG" = "xverbose" ]; then | |
528 | _fbd_indent="${_fbd_indent}. " | |
529 | decho " $_fbd_indent---> unbound options: $*" | |
530 | fi | |
531 | ||
b2f55c8b | 532 | for i do |
ceec2216 RL |
533 | |
534 | if [ "x$WXDEBUG" = "xverbose" ]; then | |
b2f55c8b | 535 | decho " ${_fbd_indent}binding '$i' with '`remove_field $i $*`' still free" |
ceec2216 RL |
536 | [ -z "$_pruned" ] || decho " ${_fbd_indent} --- pruned: $_pruned ---" |
537 | fi | |
538 | ||
539 | if ( | |
540 | eval m_$i=\$this_$i | |
b2f55c8b | 541 | _mask="^`get_mask`$" |
ceec2216 RL |
542 | |
543 | if [ "x$WXDEBUG" = "xverbose" ]; then | |
544 | decho " ${_fbd_indent} checking: $_mask" | |
545 | count_delegates "$_mask" | |
546 | decho " $_fbd_indent $? eligible delegates" | |
b2f55c8b | 547 | for d in `find_eligible_delegates "$_mask"`; do |
ceec2216 RL |
548 | decho " ${_fbd_indent} $d" |
549 | done | |
bd630206 | 550 | fi |
ceec2216 RL |
551 | |
552 | count_delegates "$_mask" | |
553 | _still_eligible=$? | |
554 | ||
555 | if [ $_still_eligible -eq 1 ]; then | |
b2f55c8b | 556 | echo `find_eligible_delegates "$_mask"` |
ceec2216 RL |
557 | return |
558 | fi | |
559 | ||
560 | [ "x$WXDEBUG" != "xfindprogress" ] || printf "." 1>&2 | |
561 | ||
92ea30ce | 562 | [ $_still_eligible -gt 1 ] && [ $# -gt 1 ] && |
b2f55c8b | 563 | do_find_best_delegate `remove_field $i $*` |
92ea30ce | 564 | ) |
ceec2216 RL |
565 | then |
566 | ||
567 | return | |
568 | ||
569 | elif [ $# -gt 1 ]; then | |
570 | ||
571 | if [ "x$WXDEBUG" = "xverbose" ]; then | |
572 | decho " ${_fbd_indent}pruning: $i" | |
573 | _pruned="${_pruned:+$_pruned }$i" | |
574 | fi | |
b2f55c8b | 575 | set `remove_field $i $*` |
ceec2216 | 576 | |
ffef10f6 | 577 | fi |
ceec2216 | 578 | |
ffef10f6 | 579 | done |
ceec2216 RL |
580 | false |
581 | ) | |
ffef10f6 VS |
582 | } |
583 | ||
ceec2216 RL |
584 | # find_best_delegate |
585 | # A simple wrapper around do_find_best_delegate that first determines | |
586 | # the unbound options (ie. the ones that the user did not explicitly | |
587 | # declare a preference for on the command line) | |
588 | find_best_delegate() | |
75f4be8a | 589 | { |
ceec2216 | 590 | for _fbdi in $wxconfig_schema; do |
92ea30ce | 591 | is_set input_option_$_fbdi || |
ceec2216 RL |
592 | _unbound_options="${_unbound_options:+$_unbound_options }$_fbdi" |
593 | done | |
594 | do_find_best_delegate $_unbound_options | |
595 | } | |
8708fa76 | 596 | |
75f4be8a | 597 | |
a13a7f89 RL |
598 | # Legacy wx-config helpers. |
599 | # ------------------------- | |
600 | ||
601 | # get_legacy_mask | |
602 | # Returns a mask in the format used by wx2.4. | |
603 | get_legacy_mask() | |
604 | { | |
605 | [ $# -gt 0 ] || set m | |
606 | eval [ "x\${$1_chartype}" != "xunicode" ] || _unicode_flag=u | |
89b1afb4 | 607 | eval echo "wx\${$1_toolkit}${_unicode_flag}-\${$1_version}\${$1_host}-config" |
a13a7f89 RL |
608 | } |
609 | ||
610 | # find_legacy_configs | |
611 | # Returns a list of configs installed by wx2.4 releases. | |
612 | find_legacy_configs() | |
613 | { | |
92ea30ce RL |
614 | ( |
615 | cd "$prefix/bin" && | |
616 | { | |
617 | ls wx*-2.4-config | grep -v ^wxbase | |
618 | ls wx*-2.4-config | grep ^wxbase | |
619 | } | |
620 | ) 2> /dev/null | |
a13a7f89 RL |
621 | } |
622 | ||
623 | # find_best_legacy_config | |
624 | # Returns the best legacy config for a given specification. | |
625 | # This assumes no matching new style config has been found. | |
626 | find_best_legacy_config() | |
627 | { | |
b2f55c8b | 628 | _legacy_configs=`find_legacy_configs` |
a13a7f89 | 629 | if [ -n "$_legacy_configs" ]; then |
b2f55c8b | 630 | _legacy_mask=`get_legacy_mask` |
a13a7f89 | 631 | for d in $_legacy_configs; do |
8ec45325 | 632 | if echo $d | $EGREP $_legacy_mask > /dev/null 2>&1 ; then |
a13a7f89 RL |
633 | echo "$d" |
634 | return | |
635 | fi | |
636 | done | |
637 | fi | |
638 | false | |
639 | } | |
640 | ||
641 | ||
642 | ||
9a09819a RL |
643 | # The only action we can perform authoritatively prior to delegation |
644 | # is to list all the possible delegates. | |
645 | # -------------------------------------------------------------- | |
646 | ||
647 | config_spec="$0 $*" | |
648 | [ -z "$WXDEBUG" ] || config_spec=$configmask | |
649 | ||
650 | # Next chance for another satisfied customer then | |
651 | # | |
652 | # If we want to get really polished here we can do plural checking, | |
653 | # but we should probably leave that until the day we gettextise it. | |
654 | if [ -n "$output_option_list" ]; then | |
655 | ||
656 | _remains_in_prefix=$installed_configs | |
b2f55c8b MW |
657 | _delegates=`find_eligible_delegates $configmask` |
658 | _best_delegate=`find_best_delegate` | |
9a09819a RL |
659 | |
660 | if [ "x$WXDEBUG" = "xverbose" ]; then | |
a13a7f89 RL |
661 | decho |
662 | decho " all = $_remains_in_prefix" | |
663 | decho " matching = $_delegates" | |
664 | decho " best = $_best_delegate" | |
665 | decho " this = $this_config" | |
9a09819a RL |
666 | fi |
667 | ||
668 | for d in $_delegates; do | |
b2f55c8b | 669 | _remains_in_prefix=`remove_field $d $_remains_in_prefix` |
9a09819a RL |
670 | done |
671 | ||
672 | echo | |
673 | echo " Default config is $this_config" | |
674 | echo | |
675 | ||
676 | if user_mask_fits "$this_config" ; then | |
677 | ||
678 | echo " Default config ${this_exec_prefix+in $this_exec_prefix }will be used for output" | |
679 | ||
680 | if match_field "$this_config" $_delegates ; then | |
b2f55c8b | 681 | _delegates=`remove_field $this_config $_delegates` |
9a09819a RL |
682 | else |
683 | echo " though it is not installed in: $prefix" | |
684 | if [ -n "$_best_delegate" ] && [ "x$_best_delegate" != "x$this_config" ]; then | |
685 | echo | |
686 | echo " Best alternate in $prefix:" | |
687 | echo " $_best_delegate" | |
688 | fi | |
689 | fi | |
690 | ||
691 | elif [ -n "$_best_delegate" ]; then | |
692 | ||
693 | echo " Specification best match: $_best_delegate" | |
694 | ||
1320281c | 695 | elif [ -z "$_delegates" ]; then |
9a09819a | 696 | |
b2f55c8b | 697 | _last_chance=`find_best_legacy_config` |
a13a7f89 RL |
698 | if [ -n "$_last_chance" ]; then |
699 | ||
700 | echo " Specification matches legacy config: $_last_chance" | |
701 | ||
702 | else | |
bd630206 | 703 | |
a13a7f89 | 704 | cat <<-EOF |
bd630206 VZ |
705 | No config found to match: $config_spec |
706 | in $wxconfdir | |
9a09819a | 707 | |
bd630206 VZ |
708 | Please install the desired library build, or specify a different |
709 | prefix where it may be found. If the library is not installed | |
710 | you may call its wx-config directly by specifying its full path. | |
9a09819a | 711 | |
bd630206 | 712 | EOF |
9a09819a | 713 | |
a13a7f89 RL |
714 | fi |
715 | ||
1320281c RL |
716 | else |
717 | echo " Specification was ambiguous. Use additional feature options" | |
718 | echo " to choose between alternate matches." | |
9a09819a RL |
719 | fi |
720 | ||
b2f55c8b | 721 | _delegates=`remove_field "$_best_delegate" $_delegates` |
9a09819a RL |
722 | |
723 | if [ -n "$_delegates" ]; then | |
724 | echo | |
725 | echo " Alternate matches:" | |
726 | for d in $_delegates; do | |
727 | echo " $d" | |
728 | done | |
729 | fi | |
730 | if [ -n "$_remains_in_prefix" ]; then | |
731 | echo | |
732 | echo " Also available in $prefix:" | |
733 | for d in $_remains_in_prefix; do | |
734 | echo " $d" | |
735 | done | |
736 | fi | |
737 | ||
b2f55c8b | 738 | _legacy_configs=`find_legacy_configs` |
a13a7f89 RL |
739 | if [ -n "$_legacy_configs" ]; then |
740 | echo | |
741 | echo " Legacy configs available in $prefix:" | |
742 | for d in $_legacy_configs; do | |
b2f55c8b | 743 | echo " $d" | sed 's/-config$//' |
a13a7f89 RL |
744 | done |
745 | fi | |
746 | ||
9a09819a RL |
747 | echo |
748 | exit | |
749 | fi | |
750 | ||
751 | ||
75f4be8a | 752 | |
9a09819a RL |
753 | # ... so if that wasn't what they wanted, then we need to know for |
754 | # certain, can this config satisfy the user specification? | |
ceec2216 | 755 | # -------------------------------------------------------------- |
00c81359 | 756 | |
b2f55c8b | 757 | if not user_mask_fits "$this_config" ; then |
ceec2216 RL |
758 | |
759 | # No? Then lets see if it knows anybody who can. | |
760 | # But first, just be sure someone hasn't typo'd us into a loop. | |
761 | # In present day wx, correct delegation should never need more | |
762 | # than one hop so this is trivial to detect. | |
763 | ||
764 | if [ -n "$WXCONFIG_DELEGATED" ]; then | |
765 | decho | |
766 | decho " *** Error: Bad config delegation" | |
767 | decho | |
768 | decho " to: $0" | |
769 | decho " ($this_config) cannot satisfy:" | |
9a09819a | 770 | decho " $config_spec" |
ceec2216 RL |
771 | decho " Someone has been terribly careless." |
772 | decho | |
773 | exit 1 | |
127e9080 VZ |
774 | fi |
775 | ||
ceec2216 RL |
776 | count_delegates "$configmask" |
777 | _numdelegates=$? | |
778 | ||
779 | if [ -n "$WXDEBUG" ]; then | |
780 | decho " must delegate to an alternate config" | |
781 | decho " potential delegates ($_numdelegates):" | |
b2f55c8b | 782 | for i in `find_eligible_delegates "$configmask"`; do |
ceec2216 RL |
783 | decho " $i" |
784 | done | |
00c81359 | 785 | fi |
a43ed08a | 786 | |
ceec2216 | 787 | if [ $_numdelegates -eq 0 ]; then |
a13a7f89 | 788 | |
b2f55c8b | 789 | _last_chance=`find_best_legacy_config` |
a13a7f89 RL |
790 | if [ -n "$_last_chance" ]; then |
791 | ||
b2f55c8b | 792 | for arg do |
22642fb2 RL |
793 | case "$arg" in |
794 | --prefix*|--exec-prefix*| \ | |
795 | --version|--release|--basename| \ | |
796 | --static|--libs|--gl_libs| \ | |
797 | --cppflags|--cflags|--cxxflags| \ | |
798 | --cc|--cxx|--ld| \ | |
799 | --rezflags|--inplace) | |
800 | _legacy_args="$_legacy_args $arg" | |
801 | ;; | |
bd630206 | 802 | |
22642fb2 RL |
803 | --static|--static=y*|--static=Y*) |
804 | _legacy_args="$_legacy_args --static" | |
805 | ;; | |
806 | esac | |
807 | done | |
808 | ||
a13a7f89 RL |
809 | if [ -n "$WXDEBUG" ]; then |
810 | decho " found a suitable legacy delegate: $_last_chance" | |
22642fb2 | 811 | decho "--> $prefix/bin/$_last_chance $_legacy_args" |
a13a7f89 RL |
812 | fi |
813 | ||
6ab7f778 SN |
814 | WXCONFIG_DELEGATED=yes |
815 | export WXCONFIG_DELEGATED | |
22642fb2 | 816 | $prefix/bin/$_last_chance $_legacy_args |
a13a7f89 RL |
817 | exit |
818 | ||
819 | else | |
d9809627 RL |
820 | |
821 | cat 1>&2 <<-EOF | |
822 | ||
bd630206 VZ |
823 | Warning: No config found to match: $config_spec |
824 | in $wxconfdir | |
825 | If you require this configuration, please install the desired | |
826 | library build. If this is part of an automated configuration | |
827 | test and no other errors occur, you may safely ignore it. | |
828 | You may use wx-config --list to see all configs available in | |
829 | the default prefix. | |
d9809627 | 830 | |
bd630206 | 831 | EOF |
d9809627 RL |
832 | |
833 | # PIPEDREAM: from here we are actually just a teensy step | |
834 | # from simply building the missing config for the user | |
835 | # on the fly if this is an in tree wx-config. | |
836 | ||
a13a7f89 RL |
837 | exit 1 |
838 | fi | |
a43ed08a VZ |
839 | fi |
840 | ||
ceec2216 RL |
841 | if [ $_numdelegates -gt 1 ]; then |
842 | ||
843 | [ -z "$WXDEBUG" ] || decho " must prune the list of eligible delegates" | |
844 | ||
b2f55c8b | 845 | best_delegate=`find_best_delegate` |
ceec2216 RL |
846 | |
847 | if [ -n "$best_delegate" ]; then | |
bd630206 | 848 | |
ceec2216 RL |
849 | if [ -n "$WXDEBUG" ]; then |
850 | decho " found a suitable delegate: $best_delegate" | |
851 | decho "--> $wxconfdir/$best_delegate $*" | |
852 | fi | |
853 | ||
6ab7f778 SN |
854 | WXCONFIG_DELEGATED=yes |
855 | export WXCONFIG_DELEGATED | |
ceec2216 RL |
856 | $wxconfdir/$best_delegate $* |
857 | exit | |
858 | fi | |
859 | ||
860 | decho | |
3950ea80 RL |
861 | decho " *** Error: Specification is ambiguous" |
862 | decho " as $config_spec" | |
ceec2216 | 863 | decho " Use additional feature options to choose between:" |
b2f55c8b | 864 | for i in `find_eligible_delegates "$configmask"`; do |
ceec2216 RL |
865 | decho " $i" |
866 | done | |
867 | decho | |
9a98a854 | 868 | |
ceec2216 RL |
869 | exit 1 |
870 | fi | |
871 | ||
872 | if [ -n "$WXDEBUG" ]; then | |
873 | decho " using the only suitable delegate" | |
b2f55c8b | 874 | decho "--> $wxconfdir/`find_eligible_delegates $configmask` $*" |
ceec2216 RL |
875 | fi |
876 | ||
6ab7f778 SN |
877 | WXCONFIG_DELEGATED=yes |
878 | export WXCONFIG_DELEGATED | |
b2f55c8b | 879 | $wxconfdir/`find_eligible_delegates $configmask` $* |
ceec2216 | 880 | exit |
9a98a854 VZ |
881 | fi |
882 | ||
251f47d1 | 883 | |
251f47d1 | 884 | |
ceec2216 RL |
885 | # If we are still here, then from now on we are responsible for |
886 | # all the user's needs. Time to rustle up some output for them. | |
887 | # -------------------------------------------------------------- | |
888 | ||
889 | [ -z "$WXDEBUG" ] || decho " using this config" | |
890 | ||
9103d280 RL |
891 | # If the user supplied a prefix, and the in tree config did not |
892 | # delegate out to anything in that prefix, then reset the build | |
893 | # tree prefix to provide the correct output for using this | |
894 | # uninstalled wx build. Or put more simply: | |
895 | prefix=${this_prefix-$prefix} | |
0506bbbf | 896 | exec_prefix=${this_exec_prefix-$exec_prefix} |
ceec2216 RL |
897 | |
898 | includedir="@includedir@" | |
899 | libdir="@libdir@" | |
ffa0583f | 900 | bindir="@bindir@" |
ceec2216 RL |
901 | |
902 | # Trivial queries we can answer now. | |
6758d3d3 RL |
903 | [ -z "$output_option_prefix" ] || echo $prefix |
904 | [ -z "$output_option_exec_prefix" ] || echo $exec_prefix | |
905 | [ -z "$output_option_release" ] || echo "@WX_RELEASE@" | |
906 | [ -z "$output_option_version" ] || echo "@WX_VERSION@" | |
907 | [ -z "$output_option_version_full" ] || echo "@WX_SUBVERSION@" | |
908 | [ -z "$output_option_basename" ] || echo "@WX_LIBRARY_BASENAME_GUI@" | |
6758d3d3 RL |
909 | [ -z "$output_option_cc" ] || echo "@CC@" |
910 | [ -z "$output_option_cxx" ] || echo "@CXX@" | |
99d4fdfd | 911 | [ -z "$output_option_ld" ] || echo "@CXX@ -o" |
6758d3d3 | 912 | [ -z "$flag_option_selected_config" ] || echo "$this_config" |
ceec2216 | 913 | |
e5405b6b VZ |
914 | for q in $query_options; do |
915 | eval echo "\$this_$q" | |
916 | done | |
a55d039a RL |
917 | |
918 | # --rezflags is deprecated and disabled (2005/11/29) | |
919 | if [ -n "$output_option_rezflags" ]; then | |
920 | echo "@true" | |
921 | decho "Warning: --rezflags, along with Mac OS classic resource building" \ | |
922 | "is deprecated. You should remove this from your Makefile and" \ | |
bd630206 | 923 | "build .app bundles instead." |
a55d039a | 924 | fi |
004ee6da | 925 | |
ceec2216 RL |
926 | |
927 | # The rest are going to need a little more work. | |
928 | # -------------------------------------------------------------- | |
929 | ||
ffa0583f RL |
930 | is_monolithic() { [ "x@MONOLITHIC@" = "x1" ]; } |
931 | is_static() { [ -n "$this_linkage" ]; } | |
932 | is_installed() { [ -z "$this_prefix" ]; } | |
ceec2216 RL |
933 | |
934 | ||
ffa0583f RL |
935 | # Is the user after a support utility? |
936 | # If this is a cross build, we need to find and return a suitable | |
937 | # native utility for the job, so we search: | |
938 | # | |
939 | # 1. local build dir (for native uninstalled builds only). | |
940 | # 2. (optional) user supplied prefix. | |
941 | # 3. configured install prefix. | |
942 | # 4. environment $PATH. | |
943 | # | |
944 | # and if such a thing still cannot be found, exit signalling an error. | |
945 | if [ -n "$input_option_utility" ]; then | |
946 | ||
947 | # This is dumb, in tree binaries should be in a standard location | |
948 | # like the libs, but work with what we've got for now. | |
949 | is_cross || _util="$exec_prefix/utils/$input_option_utility/$input_option_utility" | |
950 | ||
b2f55c8b | 951 | if not is_installed && [ -x "$_util" ]; then |
ffa0583f RL |
952 | is_static || _preload="eval LD_LIBRARY_PATH=$exec_prefix/lib" |
953 | echo $_preload $_util | |
954 | exit | |
955 | fi | |
956 | ||
957 | IFS=':' | |
958 | _user_prefix=${input_option_exec_prefix:-$input_option_prefix} | |
959 | ||
960 | for _util in "${input_option_utility}-@WX_RELEASE@@WX_FLAVOUR@" \ | |
961 | "${input_option_utility}-@WX_RELEASE@" \ | |
92ea30ce | 962 | "${input_option_utility}" |
ffa0583f RL |
963 | do |
964 | for p in ${_user_prefix:+$_user_prefix/bin} $bindir $PATH; do | |
965 | ||
966 | [ -z "$WXDEBUG" ] || decho " checking for: '$p/$_util'" | |
967 | ||
968 | if [ -x "$p/$_util" ]; then | |
969 | echo "$p/$_util" | |
970 | exit | |
971 | fi | |
972 | ||
973 | done | |
974 | done | |
975 | exit 1 | |
976 | ||
977 | fi | |
978 | ||
979 | ||
980 | # Still here? Then get the options together for building an app. | |
981 | # ---------------------------------------------------------------- | |
982 | ||
ceec2216 RL |
983 | # Additional configuration for individual library components. |
984 | ldflags_gl="@LDFLAGS_GL@" | |
985 | ||
5ff751d6 | 986 | ldlibs_base="@WXCONFIG_LIBS@" |
ceec2216 RL |
987 | ldlibs_core="@EXTRALIBS_GUI@" |
988 | ldlibs_gl="@OPENGL_LIBS@" | |
989 | ldlibs_html="@EXTRALIBS_HTML@" | |
990 | ldlibs_xml="@EXTRALIBS_XML@" | |
ceec2216 | 991 | ldlibs_adv="@EXTRALIBS_SDL@" |
cf63f3d3 | 992 | ldlibs_stc="@EXTRALIBS_STC@" |
ceec2216 | 993 | |
ffa0583f | 994 | |
ceec2216 RL |
995 | # lib_flags_for _liblist |
996 | # This function returns a list of flags suitable to return with the | |
997 | # output of --libs for all of the libraries in _liblist. You can | |
998 | # add support for a new library by adding an entry for it in the | |
999 | # psuedo-hashes above if it requires additional linker options. | |
1000 | lib_flags_for() | |
1001 | { | |
1002 | [ -z "$WXDEBUG" ] || decho " fetching lib flags for: '$*'" | |
1003 | ||
1004 | _all_ldflags='' | |
1005 | _all_libs='' | |
1006 | _wxlibs='' | |
1007 | ||
92ea30ce | 1008 | is_cross && _target="-${target}" |
ceec2216 | 1009 | |
b2f55c8b | 1010 | for lib do |
ceec2216 RL |
1011 | |
1012 | # We evidently can't trust people not to duplicate things in | |
1013 | # configure, or to keep them in any sort of sane order overall, | |
1014 | # so only add unique new fields here even if it takes us a while. | |
1015 | # In the case of libs, we bubble any duplicates to the end, | |
1016 | # because if multiple libs require it, static linking at least | |
1017 | # will require it to come after all of them. So long as local | |
1018 | # order is ok in configure then we should always be able to | |
1019 | # massage a correct result here like this. | |
1020 | # | |
1021 | # FIXME: ldlibs_core is totally bogus. Fix the duplication | |
1022 | # there independently of this. This covers for it, but we | |
1023 | # want to do this anyway because some libs may share common | |
1024 | # deps without a common ancestor in wx. This is not a licence | |
1025 | # for sloppy work elsewhere though and @GUI_TK_LIBRARY should | |
1026 | # be fixed. | |
1027 | ||
b2f55c8b | 1028 | for f in `eval echo \"\\\$ldflags_$lib\"`; do |
ceec2216 RL |
1029 | match_field "$f" $_all_ldflags || _all_ldflags="$_all_ldflags $f" |
1030 | done | |
1031 | ||
bd630206 | 1032 | if match_field "$lib" @STD_BASE_LIBS@ ; then |
ceec2216 RL |
1033 | _libname="@WX_LIBRARY_BASENAME_NOGUI@" |
1034 | else | |
1035 | _libname="@WX_LIBRARY_BASENAME_GUI@" | |
1036 | fi | |
1037 | [ $lib = base ] || _libname="${_libname}_$lib" | |
1038 | _libname="${_libname}-@WX_RELEASE@$_target" | |
1039 | ||
ffa0583f | 1040 | if is_static; then |
ceec2216 | 1041 | _wxlibs="$_wxlibs ${libdir}/lib${_libname}.a" |
b2f55c8b | 1042 | for f in `eval echo \"\\\$ldlibs_$lib\"`; do |
3838e2d3 RL |
1043 | |
1044 | # Only propagate duplicate -libraries to their latest | |
1045 | # possible position. Do not eliminate any other | |
1046 | # duplicates that might occur. They should be fixed | |
1047 | # in configure long before they get here. | |
1048 | # This started as a workaround for Mac -framework, | |
1049 | # but it seems like a better policy in general, which | |
1050 | # will let the more heinous bugs in configure shake out. | |
1051 | # We should maybe filter *.a here too, but not unless | |
1052 | # we have to. | |
eb57b07a | 1053 | case "$f" in |
b2f55c8b | 1054 | -l*) _all_libs="`remove_field $f $_all_libs` $f" ;; |
eb57b07a RL |
1055 | *) _all_libs="$_all_libs $f" ;; |
1056 | esac | |
3838e2d3 | 1057 | |
ceec2216 RL |
1058 | done |
1059 | else | |
1060 | _wxlibs="$_wxlibs -l${_libname}" | |
1061 | fi | |
1062 | ||
1063 | done | |
1064 | ||
1065 | if [ -n "$WXDEBUG" ]; then | |
1066 | decho " retrieved: ldflags = $_all_ldflags" | |
1067 | decho " wxlibs = $_wxlibs" | |
1068 | decho " alllibs = $_all_libs" | |
1069 | fi | |
1070 | ||
1071 | echo $_all_ldflags $_wxlibs $_all_libs | |
1072 | } | |
1073 | ||
fc2739d5 VZ |
1074 | # this is the strict subset of the above function which returns only the |
1075 | # (static) libraries themselves: this is used for linkdeps output which should | |
1076 | # output the list of libraries the main program should depend on | |
1077 | # | |
1078 | # of course, this duplication is bad but I'll leave to somebody else the care | |
3838e2d3 RL |
1079 | # of refactoring this as I don't see any way to do it - VZ. |
1080 | ||
1081 | # This (and the other cruft to support it) should be removed with | |
1082 | # reference to the FIXME above when configure stops piping us a slurry | |
1083 | # of options that need to be decomposed again for most practical uses - RL. | |
fc2739d5 VZ |
1084 | link_deps_for() |
1085 | { | |
1086 | _wxlibs='' | |
1087 | ||
92ea30ce | 1088 | is_cross && _target="-${target}" |
fc2739d5 | 1089 | |
b2f55c8b | 1090 | for lib do |
bd630206 | 1091 | if match_field "$lib" @STD_BASE_LIBS@ ; then |
fc2739d5 VZ |
1092 | _libname="@WX_LIBRARY_BASENAME_NOGUI@" |
1093 | else | |
1094 | _libname="@WX_LIBRARY_BASENAME_GUI@" | |
1095 | fi | |
1096 | [ $lib = base ] || _libname="${_libname}_$lib" | |
1097 | _libname="${_libname}-@WX_RELEASE@$_target" | |
1098 | ||
1099 | _wxlibs="$_wxlibs ${libdir}/lib${_libname}.a" | |
1100 | done | |
1101 | ||
1102 | echo $_wxlibs | |
1103 | } | |
ceec2216 RL |
1104 | |
1105 | # Sanity check the list of libs the user provided us, if any. | |
1106 | # -------------------------------------------------------------- | |
1107 | ||
bd630206 VZ |
1108 | wx_libs=`echo "$libs_parameters" | tr ',' ' '` |
1109 | wx_optional_libs=`echo "$optional_libs_parameters" | tr ',' ' '` | |
1110 | ||
1111 | # Add the --optional-libs, if they've been compiled and aren't already added | |
1112 | for i in $wx_optional_libs; do | |
1113 | if match_field $i @BUILT_WX_LIBS@; then | |
1114 | if not match_field $i $wx_libs; then | |
1115 | wx_libs="${wx_libs:+$wx_libs }$i" | |
1116 | fi | |
1117 | fi | |
1118 | done | |
ceec2216 RL |
1119 | |
1120 | [ -z "$WXDEBUG" ] || decho " user supplied libs: '$wx_libs'" | |
1121 | ||
6bddfdbf VZ |
1122 | # Assume we are using the GUI, unless --libs was specified with no GUI libs |
1123 | using_gui=yes | |
1124 | ||
ceec2216 RL |
1125 | if is_monolithic; then |
1126 | ||
bd630206 VZ |
1127 | # Only add additional info if --libs was specified and not just --optional-libs |
1128 | if [ -n "$output_option_libs" ]; then | |
1129 | # Core libs are already built into the blob. | |
1130 | for i in std @STD_GUI_LIBS@ @STD_BASE_LIBS@; do | |
1131 | wx_libs=`remove_field $i $wx_libs` | |
1132 | done | |
ceec2216 | 1133 | |
bd630206 | 1134 | wx_libs="@WXCONFIG_LDFLAGS_GUI@ `lib_flags_for $wx_libs`" |
ceec2216 | 1135 | |
bd630206 VZ |
1136 | # We still need the core lib deps for a static build though |
1137 | if is_static; then | |
1138 | link_deps="${libdir}/libwx_@TOOLCHAIN_NAME@.a" | |
1139 | wx_libs="$wx_libs $link_deps $ldlibs_core $ldlibs_base" | |
1140 | else | |
1141 | wx_libs="$wx_libs -lwx_@TOOLCHAIN_NAME@" | |
1142 | fi | |
bd630206 | 1143 | fi |
ceec2216 RL |
1144 | else # MONOLITHIC = 0 |
1145 | ||
bd630206 VZ |
1146 | # Import core libs by default, expand std if specified, or add base if omitted. |
1147 | if [ -n "$output_option_libs" ] && [ -z "$libs_parameters" ]; then | |
1148 | wx_libs="@STD_GUI_LIBS@ @STD_BASE_LIBS@" | |
1149 | elif match_field all $wx_libs; then | |
1150 | wx_libs="@BUILT_WX_LIBS@" | |
6a9046db RL |
1151 | elif match_field std $wx_libs; then |
1152 | # Bubble any libs that were already specified to the end | |
1153 | # of the list and ensure static linking order is retained. | |
b2f55c8b | 1154 | wx_libs=`remove_field std $wx_libs` |
bd630206 | 1155 | for i in @STD_GUI_LIBS@ @STD_BASE_LIBS@; do |
b2f55c8b | 1156 | wx_libs="`remove_field $i $wx_libs` $i" |
ceec2216 | 1157 | done |
b2f55c8b | 1158 | elif not match_field base $wx_libs ; then |
bd630206 VZ |
1159 | # Only add base if --libs was specified and not just --optional-libs |
1160 | if [ -n "$output_option_libs" ]; then | |
1161 | wx_libs="$wx_libs base" | |
1162 | fi | |
ceec2216 RL |
1163 | fi |
1164 | ||
6bddfdbf VZ |
1165 | if [ -n "$output_option_libs" ]; then |
1166 | using_gui=no | |
1167 | for i in $wx_libs ; do | |
1168 | if match_field "$i" @STD_GUI_LIBS@; then | |
1169 | _guildflags="@WXCONFIG_LDFLAGS_GUI@" | |
1170 | using_gui=yes | |
1171 | break | |
1172 | fi | |
1173 | match_field "$i" @STD_BASE_LIBS@ || using_gui=yes | |
1174 | done | |
1175 | fi | |
ceec2216 | 1176 | |
ffa0583f | 1177 | if is_static; then |
b2f55c8b | 1178 | link_deps=`link_deps_for $wx_libs` |
fc2739d5 | 1179 | fi |
b2f55c8b | 1180 | wx_libs="$_guildflags `lib_flags_for $wx_libs`" |
251f47d1 VS |
1181 | fi |
1182 | ||
ceec2216 | 1183 | |
6bddfdbf VZ |
1184 | # If they explicitly set "--cxx(pp)flags base" then they don't want the GUI |
1185 | if [ "$cxx_parameters" = "base" ]; then | |
1186 | using_gui=no | |
1187 | fi | |
1188 | ||
1189 | ||
ceec2216 RL |
1190 | if [ -n "$WXDEBUG" ]; then |
1191 | decho | |
1192 | decho " using libs: '$wx_libs'" | |
1193 | decho " using_gui = $using_gui" | |
1194 | decho | |
c39ee0ad | 1195 | fi |
251f47d1 VS |
1196 | |
1197 | ||
ceec2216 RL |
1198 | # Endgame. Nothing left to discover now. |
1199 | # -------------------------------------------------------------- | |
251f47d1 | 1200 | |
9103d280 | 1201 | [ "$using_gui" = "yes" ] || _gui_cppflags="-DwxUSE_GUI=0" |
ceec2216 | 1202 | |
ffa0583f | 1203 | if is_installed; then |
0506bbbf | 1204 | _include_cppflags="-I${includedir}/wx-@WX_RELEASE@@WX_FLAVOUR@" |
ffa0583f | 1205 | else |
aa1c09fe | 1206 | _include_cppflags="-I${includedir}" |
0506bbbf RL |
1207 | fi |
1208 | ||
b2f55c8b | 1209 | _cppflags=`echo "-I${libdir}/wx/include/@TOOLCHAIN_FULLNAME@" $_include_cppflags "@WXCONFIG_CPPFLAGS@" $_gui_cppflags` |
ceec2216 RL |
1210 | |
1211 | # now without further ado, we can answer these too. | |
9103d280 | 1212 | [ -z "$output_option_cppflags" ] || echo $_cppflags |
5ff751d6 VZ |
1213 | [ -z "$output_option_cflags" ] || echo $_cppflags "@WXCONFIG_CFLAGS@" |
1214 | [ -z "$output_option_cxxflags" ] || echo $_cppflags "@WXCONFIG_CXXFLAGS@" | |
b2f55c8b | 1215 | [ -z "$output_option_gl_libs" ] || echo `lib_flags_for gl` |
fc2739d5 | 1216 | [ -z "$output_option_linkdeps" ] || echo $link_deps |
ceec2216 RL |
1217 | |
1218 | if [ -n "$output_option_libs" ]; then | |
bd630206 | 1219 | # if --libs [--optional-libs] then output the full linker information |
ceec2216 | 1220 | |
92ea30ce RL |
1221 | is_cross && |
1222 | [ "x$libdir" = "x/usr/${target}/lib" ] || | |
1223 | [ "x$libdir" = "x/usr/lib" ] || | |
1224 | _ldflags="-L$libdir" | |
ceec2216 | 1225 | |
ffa0583f RL |
1226 | is_installed || [ -n "$flag_option_no_rpath" ] || _rpath="@WXCONFIG_RPATH@" |
1227 | ||
1228 | echo $_ldflags "@LDFLAGS@" $_rpath $wx_libs "@DMALLOC_LIBS@" | |
bd630206 VZ |
1229 | |
1230 | elif [ -n "$output_option_optional_libs" ]; then | |
1231 | # if only --optional-libs then output just the libs | |
1232 | ||
1233 | echo $wx_libs | |
ceec2216 RL |
1234 | fi |
1235 | ||
004ee6da | 1236 | |
a55d039a RL |
1237 | # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
1238 | # | |
1239 | # Beyond here reside only machine or tool specific workarounds | |
1240 | # that require knowlege not obtainable prior to this comment. | |
1241 | # | |
1242 | # Please. Avoid addding things here, wx-config should avoid | |
1243 | # hard coding tool specific details. Do not use things here | |
1244 | # as an example of other things that should be here, These | |
1245 | # shouldn't be here either. This is a place of last resort | |
1246 | # for interim workarounds. I can but stress as strongly as | |
1247 | # the censor will allow, there are only bad examples of things | |
1248 | # that belong at this level of abstraction to follow. It is | |
1249 | # a limbo for glitches awaiting the Next Design Repair. Ok. | |
1250 | # | |
1251 | # With that firmly in mind, our debut dilemma is: | |
3f97aec5 | 1252 | |
a55d039a | 1253 | # Resource compilers. An elusive term that covers some pretty |
004ee6da RL |
1254 | # dissimilar concepts on various platforms. The good news is, |
1255 | # each platform has only one definition of 'resource', compiled | |
1256 | # or not, and so we can abstract that neatly to return a platform | |
1257 | # specific invocation of the appropriate tool. The bad news is, | |
1258 | # windres (at least) requires knowledge of the wx header files | |
1259 | # location(s) that cannot be predicted reliably before the call to | |
1260 | # wx-config is made. Currently for all known resource compilers, | |
1261 | # we can simply return a command and some salient configuration | |
1262 | # options in response to a request for --rescomp. So here we | |
1263 | # top up the options for any tools that may require information | |
1264 | # that was only just determined in the last few machine cycles, | |
1265 | # then output the necessary incantation for the platform. | |
1266 | # | |
1267 | # Most things should already be constant by the time configure | |
1268 | # has run. Do not add anything here that is already known there. | |
1269 | ||
1270 | if [ -n "$output_option_rescomp" ]; then | |
1271 | ||
1272 | case "@RESCOMP@" in | |
1273 | *windres|wrc) | |
1274 | # Note that with late model windres, we could just insert | |
bd630206 VZ |
1275 | # _include_cppflags here, but use the old notation for now |
1276 | # as it is more universally accepted. | |
004ee6da RL |
1277 | if is_installed; then |
1278 | echo "@RESCOMP@ --include-dir" \ | |
1279 | "${includedir}/wx-@WX_RELEASE@@WX_FLAVOUR@" \ | |
1280 | "@WXCONFIG_RESFLAGS@" | |
1281 | else | |
1282 | echo "@RESCOMP@ --include-dir ${includedir}" \ | |
bd630206 | 1283 | "@WXCONFIG_RESFLAGS@" |
004ee6da RL |
1284 | fi |
1285 | ;; | |
1286 | ||
1287 | # neither rez not emxbind have any specific needs from | |
1288 | # us, so just output what was determined by configure. | |
1289 | *) | |
1290 | echo @RESCOMP@ @WXCONFIG_RESFLAGS@ | |
1291 | ;; | |
1292 | esac | |
1293 | ||
1294 | fi | |
1295 | ||
a55d039a RL |
1296 | # |
1297 | # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | |
004ee6da | 1298 | |
ceec2216 RL |
1299 | # And so that's it, we're done. Have a nice build. |
1300 | ||
1301 | exit 0 | |
9a98a854 | 1302 | |
9a98a854 | 1303 |