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