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