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