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