+# Legacy wx-config helpers.
+# -------------------------
+
+# get_legacy_mask
+# Returns a mask in the format used by wx2.4.
+get_legacy_mask()
+{
+ [ $# -gt 0 ] || set m
+ eval [ "x\${$1_chartype}" != "xunicode" ] || _unicode_flag=u
+ eval echo "wx\${$1_toolkit}${_unicode_flag}-\${$1_version}\${$1_host}-config"
+}
+
+# find_legacy_configs
+# Returns a list of configs installed by wx2.4 releases.
+find_legacy_configs()
+{
+ (
+ cd "$prefix/bin" &&
+ {
+ ls wx*-2.4-config | grep -v ^wxbase
+ ls wx*-2.4-config | grep ^wxbase
+ }
+ ) 2> /dev/null
+}
+
+# find_best_legacy_config
+# Returns the best legacy config for a given specification.
+# This assumes no matching new style config has been found.
+find_best_legacy_config()
+{
+ _legacy_configs=`find_legacy_configs`
+ if [ -n "$_legacy_configs" ]; then
+ _legacy_mask=`get_legacy_mask`
+ for d in $_legacy_configs; do
+ if echo $d | $EGREP $_legacy_mask > /dev/null 2>&1 ; then
+ echo "$d"
+ return
+ fi
+ done
+ fi
+ false
+}
+
+
+
+# The only action we can perform authoritatively prior to delegation
+# is to list all the possible delegates.
+# --------------------------------------------------------------
+
+config_spec="$0 $*"
+[ -z "$WXDEBUG" ] || config_spec=$configmask
+
+# Next chance for another satisfied customer then
+#
+# If we want to get really polished here we can do plural checking,
+# but we should probably leave that until the day we gettextise it.
+if [ -n "$output_option_list" ]; then
+
+ _remains_in_prefix=$installed_configs
+ _delegates=`find_eligible_delegates $configmask`
+ _best_delegate=`find_best_delegate`
+
+ if [ "x$WXDEBUG" = "xverbose" ]; then
+ decho
+ decho " all = $_remains_in_prefix"
+ decho " matching = $_delegates"
+ decho " best = $_best_delegate"
+ decho " this = $this_config"
+ fi
+
+ for d in $_delegates; do
+ _remains_in_prefix=`remove_field $d $_remains_in_prefix`
+ done
+
+ echo
+ echo " Default config is $this_config"
+ echo
+
+ if user_mask_fits "$this_config" ; then
+
+ echo " Default config ${this_exec_prefix+in $this_exec_prefix }will be used for output"
+
+ if match_field "$this_config" $_delegates ; then
+ _delegates=`remove_field $this_config $_delegates`
+ else
+ echo " though it is not installed in: $prefix"
+ if [ -n "$_best_delegate" ] && [ "x$_best_delegate" != "x$this_config" ]; then
+ echo
+ echo " Best alternate in $prefix:"
+ echo " $_best_delegate"
+ fi
+ fi
+
+ elif [ -n "$_best_delegate" ]; then
+
+ echo " Specification best match: $_best_delegate"
+
+ elif [ -z "$_delegates" ]; then
+
+ _last_chance=`find_best_legacy_config`
+ if [ -n "$_last_chance" ]; then
+
+ echo " Specification matches legacy config: $_last_chance"
+
+ else
+
+ cat <<-EOF
+ No config found to match: $config_spec
+ in $wxconfdir
+
+ Please install the desired library build, or specify a different
+ prefix where it may be found. If the library is not installed
+ you may call its wx-config directly by specifying its full path.
+
+EOF