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