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