⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wx-config.in

📁 A*算法 A*算法 A*算法 A*算法A*算法A*算法
💻 IN
📖 第 1 页 / 共 3 页
字号:
#!/bin/sh
#
# Name:        wx-config{.in,}
# Purpose:     wx configuration search and query tool {template,}
# Author:      Ron <ron@debian.org>
# Modified by:
# Created:     8/9/2004
# RCS-ID:      $Id: wx-config.in,v 1.122.2.1 2006/02/15 18:58:13 MW Exp $
# Copyright:   (c) 2004 Ron <ron@debian.org>
#              Essentially a fresh start this time around, but for maximum
#              compatibility basic code was taken from, and heavy reference
#              made to, the previously unattributed wx-config from cvs.
#              All the usual suspects contributed to the dicussion that led
#              to this new work and likewise to the ideas and content in the
#              original (which was probably influenced by gtk), among them:
#              Robert Roebling, Vadim Zeitlin, Vaclav Slavik, Robin Dunn
# Licence:     wxWindows licence
############################################################################

# Extra^2 debug mode, for if things ever get really weird.
[ -z "$WXDEBUG_X" ] || set -x

# We expect a posix shell, so if this is a Bourne shell,
# and apparently a few still exist, try for bash or ksh.

if [ ~ = '~' ]
then
    if (bash -c echo) >/dev/null 2>&1
    then
        exec bash "$0" "$@"
    fi
    if (ksh -c echo) >/dev/null 2>&1
    then
        exec ksh "$0" "$@"
    fi
    echo "$0: this script requires bash or ksh"
    exit 1
fi
 

# On with some basic stuff, like the ability to die gracefully,
# and to tell people what we are about.
# ------------------------------------------------------------------

# decho _message
# Output a message to stderr.
decho() { echo "$*" 1>&2; }

# usage _exitcode
# Outputs a usage message to stderr and exits with _exitcode.
# Try to keep this to a single page (ie. < 25 lines).  We can add
# alternate or interactive help targets if people want more detail.
#
# Exit codes are now subject to a more strict interpretation.
# wx-config should return 0 upon successful operation, 1 if the
# reqested operation could not be completed successfully, and 2
# if the requested operation is not supported by this version of
# wx-config.
usage()
{
    cat 1>&2 <<EOF

 wx-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--release] [--version-full]
           [--list] [--host=HOST] [--toolkit=TOOLKIT] [--universal[=yes|no]]
           [--unicode[=yes|no]] [--debug[=yes|no]] [--static[=yes|no]]
           [--version[=VERSION]] [--basename] [--cc] [--cppflags] [--cflags]
           [--cxxflags] [--rezflags] [--libs] [--cxx] [--ld] [--linkdeps]
           [--utility=UTIL] [LIB ...] 

   wx-config returns  information about  the wxWidgets libraries available
   on your system.  It may be used to retrieve the information you require
   to build applications using these libraries.

    If alternative builds of wxWidgets exist on the system, you can use the
  options:  --prefix,  --host,  --toolkit,  --unicode,  --debug,  --static,
  --version and --universal, to select from them.  Use the --list option to
  show alternatives available which match specified criteria.   The unicode,
  debug, and universal options  take an  optional yes or no  argument, while
  host and version  accept posix extended regex.   The --utility option will
  return the correct version of UTIL to use with the selected library build.
  --linkdeps returns only static libraries for your makefile link rule deps.

    Optional LIB arguments (comma or space separated) may be used to specify
  the wxWidgets libraries that  you wish  to use.  The magic "std" label may
  be used to import all libraries that would be used by default if none were
  specified explicitly.  eg. wx-config --libs core,base.

EOF

    exit $1
}

# Unfussy people are the easiest to deal with, get them out of the way now.
[ $# -gt 0 ] || usage 1


# Contentious tools determined by configure.
EGREP="@EGREP@"


# For the people who know what they want, or think they do:
# Divide the valid arguments into functional groups for later examination,
# then parse all command line arguments completely, deferring action on
# output options until all significant input has been processed and any
# decision about delegation has been taken.

# Note early, that '-' is a complete no-no for use in option names below.
# It totally falls apart as soon as it becomes part of a variable name.
# Use '_' instead, and by the magic of it all just being bits, you'll
# be able to use --my-option or --my_option from the command line at
# your discretion.  They are synonymous as user input, but _ALWAYS_ use
# underscores for compound names in the code here, never a dash.


# The list of all options we recognise.  If it is not in here, then
# it is not something we want to handle.
# ------------------------------------------------------------------

# Options that specify a distinct library build.
#
# Note also that order in this list is significant later on, as this sets
# the precedence with which we will try to gauge the similarity of other
# configs to this one.  Options earlier in the list should be more crucial
# to match well than those that follow.  Options specified by the user will
# always take precedence and are not subject to any partial ordering here.
wxconfig_schema="host toolkit widgetset chartype debugtype flavour version linkage"

# Options that are expected to generate some output.
wxconfig_output_options="prefix exec_prefix
                         list
                         release version version_full
                         basename
                         cppflags cflags cxxflags
                         rezflags
                         libs
                         linkdeps
                         cc cxx ld
                         gl_libs"

# Options that permit the user to supply hints that may affect the output.
# These options all accept arbitrary values, to interpret as they please.
wxconfig_input_options="prefix exec_prefix utility $wxconfig_schema"

# Input options that accept only a yes or no argument.
wxconfig_yesno_options="universal unicode debug static"

# Boolean options that do something or not.
wxconfig_flag_options="$wxconfig_yesno_options selected_config no_rpath inplace"



# Some simple sugar coating to keep things more readable below.
# --------------------------------------------------------------

# option_name _string
# Returns NAME if _string is of the form: --NAME[=...]
option_name()
{
    _option_name_temp=${1%%=*}
    echo ${_option_name_temp#--} | tr '-' '_'
}

# option_value _string
# Returns FOO if _string is of the form: --option=FOO
option_value()
{
    echo "${1#*=}"
}

# match_field _value _list
# Returns true if _value is a field in _list
match_field()
{
    _match_field_match="$1"
    shift
    for _match_field_i; do
        [ "x$_match_field_i" != "x$_match_field_match" ] || return 0
    done
    false
}

# remove_field _value _list
# Returns _list minus any field(s) that match _value.
remove_field()
{
    _remf_value="$1"
    _remf_list=''
    shift
    if [ -n "$_remf_value" ]; then
        for _remf_item; do
            [ "x$_remf_item" = "x$_remf_value" ] ||
                _remf_list="${_remf_list:+$_remf_list }$_remf_item"
        done
        echo "$_remf_list"
    else
        echo $*
    fi
}

# validate_arg _domain _set _name _value
# Boilerplate to validate an argument and initialise a psuedo-hash.
# This one is almost reduction into absurdity, and perhaps makes the
# precise action of the argument parser below just a little more
# obscure, but oh so neat and compact to use for multiple option
# groups.  It expands to replace repetitive clauses of the form:
#
#        i="$(option_name $arg)"
#        if match_field "$i" $wxconfig_input_options; then
#            input_options="${input_options:+$input_options }$i"
#            eval "input_option_$i=$(option_value $arg)"
#            continue
#        fi
#
# with the one liners you see on the page below.
validate_arg()
{
    if match_field "$3" $(eval echo \"\$$1_$2_options\"); then
        eval "$2_options=\"\${$2_options:+\$$2_options }$3\""
        eval "$2_option_$3=\"$4\""
        return
    fi
    false
}

# check_yesno_option _ynoption _option _yesval _noval
# This one might be made more generic and/or incorporated into
# validate_arg above at some later stage, but right now we just
# condition any specialist options into a generic one for later
# handling.  Once they are sanity checked there is no difference
# in any case.
check_yesno_option()
{
    eval "case \${yesno_option_$1-\${flag_option_$1-unset}} in
            unset)                          ;;
            y*|Y*)  input_option_$2=\"$3\"  ;;
            n*|N*)  input_option_$2=\"$4\"  ;;
            *)
                decho
                decho \" *** Error: Invalid request '--$1=\$yesno_option_$1'\"
                decho \" Valid arguments for --$1 are: [ yes, no ]\"
                decho
                exit 1
                ;;
         esac"
}



# Now we are ready to find out what the user wants from us.
# --------------------------------------------------------------

# With just a little more complexity here we could have shortest
# unique string matching for options, but that is probably overkill
# today, so lets just get the job done.
#
# The important thing now then is that we simply read all input from
# the user and don't try to act prematurely on partial information.
# --help or an illegal argument are the only shortcuts out of here
# at this point, otherwise, it's time to just shut up and listen for
# a moment.

for arg; do
  case "$arg" in
    --help|-h)
        usage
        ;;

    --*=*)
        _name=$(option_name $arg)
        _value=$(option_value $arg)
        if validate_arg wxconfig input "$_name" "$_value" ||
           validate_arg wxconfig yesno "$_name" "$_value"
        then
            continue
        fi
        ;;

    --*)
        _name=$(option_name $arg)
        if validate_arg wxconfig flag   "$_name" yes ||
           validate_arg wxconfig output "$_name" yes
        then
            continue
        fi
        ;;

    *)
        # FIXME Surely we can validate the parameters too ...
        input_parameters="${input_parameters:+$input_parameters }$arg"
        continue
        ;;
  esac
  decho "  *** Error: Unrecognised option: '$arg'"
  decho "Use wx-config --help for information on command line options."
  exit 2
done

# validate_arg only checks and decomposes form.  Sanity check the yes/no
# options now too and push their respective mask values into place.

check_yesno_option universal widgetset univ
check_yesno_option unicode chartype unicode ansi
check_yesno_option debug debugtype debug release
check_yesno_option static linkage '-static'


# Dump everything we just read in debug mode.
if [ -n "$WXDEBUG" ]; then

    decho
    decho "  input parameters  = $input_parameters"
    decho "  input options     = $input_options"
    for i in $input_options; do
        decho "    $i = $(eval echo \"\$input_option_$i\")"
    done
    decho "  yes/no options    = $yesno_options"
    for y in $yesno_options; do
        decho "    $y = $(eval echo \"\$yesno_option_$y\")"
    done
    decho "  flag options      = $flag_options"
    for f in $flag_options; do
        decho "    $f = $(eval echo \"\$flag_option_$f\")"
    done
    decho "  output options    = $output_options"
    for o in $output_options; do
        decho "    $o = $(eval echo \"\$output_option_$o\")"
    done

fi



# Everything came in as a legal argument then, lets put some of
# the pieces together with a little self knowledge to see what
# we should do next.
# --------------------------------------------------------------

# get_mask [ _hash ]
# Construct a config filename mask from a psuedo-hash of component variables.
# The optional argument is the prefix of the hash to use.  If not specified
# this will return a mask derived from the command line options that were used.
get_mask()
{
    [ $# -gt 0 ] || set m
    eval echo "\${$1_host}\${$1_toolkit}\${$1_widgetset}-\${$1_chartype}-\${$1_debugtype}\${$1_linkage}-\${$1_version}\${$1_flavour}"
}

# Returns true if this script is for a cross compiled config.
is_cross()  { [ "x@cross_compiling@" = "xyes" ]; }


# Determine the base directories we require.
prefix=${input_option_prefix-${this_prefix:-@prefix@}}
exec_prefix=${input_option_exec_prefix-${input_option_prefix-${this_exec_prefix:-@exec_prefix@}}}
wxconfdir="@libdir@/wx/config"

installed_configs=$( cd "$wxconfdir" 2> /dev/null && ls | grep -v "^inplace-" )

is_cross && target="@host_alias@"

# Define a pseudo-hash to contain the specification of this wx-config
# instance and its associated library.
this_host="${target:+${target}-}"
this_toolkit="@TOOLKIT_DIR@@TOOLKIT_VERSION@"
this_widgetset="@WIDGET_SET@"
this_chartype="@WX_CHARTYPE@"
this_debugtype="@WX_DEBUGTYPE@"
this_flavour="@WX_FLAVOUR@"
this_version="@WX_RELEASE@"
this_linkage=$( [ "x@SHARED@" = "x1" ] || echo '-static' )

this_config=$(get_mask this)

# Extract the user specification from the options parsed.
m_host=${input_option_host:+${input_option_host}-?}
m_host=${m_host:-${input_option_host-$this_host}}
m_toolkit=${input_option_toolkit:-[^-]+}
m_widgetset=${input_option_widgetset-(univ)?}
m_chartype=${input_option_chartype:-(unicode|ansi)}
m_debugtype=${input_option_debugtype:-(debug|release)}
m_flavour=${input_option_flavour:+-$input_option_flavour}
m_flavour=${m_flavour:-${input_option_flavour-(-[^-]+)?}}
m_version=${input_option_version:-[0-9]+\.[0-9]+}
m_linkage=${input_option_linkage-(-static)?}

configmask="^$(get_mask)$"


# Dump the user specification in debug mode.
if [ -n "$WXDEBUG" ]; then

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -