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