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