Blame ltmain.sh

<
Packit a4058c
#! /bin/sh
Packit a4058c
## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
Packit a4058c
##               by inline-source v2014-01-03.01
Packit a4058c
Packit a4058c
# libtool (GNU libtool) 2.4.6
Packit a4058c
# Provide generalized library-building support services.
Packit a4058c
# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
Packit a4058c
Packit a4058c
# Copyright (C) 1996-2015 Free Software Foundation, Inc.
Packit a4058c
# This is free software; see the source for copying conditions.  There is NO
Packit a4058c
# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Packit a4058c
Packit a4058c
# GNU Libtool is free software; you can redistribute it and/or modify
Packit a4058c
# it under the terms of the GNU General Public License as published by
Packit a4058c
# the Free Software Foundation; either version 2 of the License, or
Packit a4058c
# (at your option) any later version.
Packit a4058c
#
Packit a4058c
# As a special exception to the GNU General Public License,
Packit a4058c
# if you distribute this file as part of a program or library that
Packit a4058c
# is built using GNU Libtool, you may include this file under the
Packit a4058c
# same distribution terms that you use for the rest of that program.
Packit a4058c
#
Packit a4058c
# GNU Libtool is distributed in the hope that it will be useful, but
Packit a4058c
# WITHOUT ANY WARRANTY; without even the implied warranty of
Packit a4058c
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit a4058c
# General Public License for more details.
Packit a4058c
#
Packit a4058c
# You should have received a copy of the GNU General Public License
Packit a4058c
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit a4058c
Packit a4058c
Packit a4058c
PROGRAM=libtool
Packit a4058c
PACKAGE=libtool
Packit a4058c
VERSION=2.4.6
Packit a4058c
package_revision=2.4.6
Packit a4058c
Packit a4058c
Packit a4058c
## ------ ##
Packit a4058c
## Usage. ##
Packit a4058c
## ------ ##
Packit a4058c
Packit a4058c
# Run './libtool --help' for help with using this script from the
Packit a4058c
# command line.
Packit a4058c
Packit a4058c
Packit a4058c
## ------------------------------- ##
Packit a4058c
## User overridable command paths. ##
Packit a4058c
## ------------------------------- ##
Packit a4058c
Packit a4058c
# After configure completes, it has a better idea of some of the
Packit a4058c
# shell tools we need than the defaults used by the functions shared
Packit a4058c
# with bootstrap, so set those here where they can still be over-
Packit a4058c
# ridden by the user, but otherwise take precedence.
Packit a4058c
Packit a4058c
: ${AUTOCONF="autoconf"}
Packit a4058c
: ${AUTOMAKE="automake"}
Packit a4058c
Packit a4058c
Packit a4058c
## -------------------------- ##
Packit a4058c
## Source external libraries. ##
Packit a4058c
## -------------------------- ##
Packit a4058c
Packit a4058c
# Much of our low-level functionality needs to be sourced from external
Packit a4058c
# libraries, which are installed to $pkgauxdir.
Packit a4058c
Packit a4058c
# Set a version string for this script.
Packit a4058c
scriptversion=2015-01-20.17; # UTC
Packit a4058c
Packit a4058c
# General shell script boiler plate, and helper functions.
Packit a4058c
# Written by Gary V. Vaughan, 2004
Packit a4058c
Packit a4058c
# Copyright (C) 2004-2015 Free Software Foundation, Inc.
Packit a4058c
# This is free software; see the source for copying conditions.  There is NO
Packit a4058c
# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Packit a4058c
Packit a4058c
# This program is free software; you can redistribute it and/or modify
Packit a4058c
# it under the terms of the GNU General Public License as published by
Packit a4058c
# the Free Software Foundation; either version 3 of the License, or
Packit a4058c
# (at your option) any later version.
Packit a4058c
Packit a4058c
# As a special exception to the GNU General Public License, if you distribute
Packit a4058c
# this file as part of a program or library that is built using GNU Libtool,
Packit a4058c
# you may include this file under the same distribution terms that you use
Packit a4058c
# for the rest of that program.
Packit a4058c
Packit a4058c
# This program is distributed in the hope that it will be useful,
Packit a4058c
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit a4058c
# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
Packit a4058c
# General Public License for more details.
Packit a4058c
Packit a4058c
# You should have received a copy of the GNU General Public License
Packit a4058c
# along with this program. If not, see <http://www.gnu.org/licenses/>.
Packit a4058c
Packit a4058c
# Please report bugs or propose patches to gary@gnu.org.
Packit a4058c
Packit a4058c
Packit a4058c
## ------ ##
Packit a4058c
## Usage. ##
Packit a4058c
## ------ ##
Packit a4058c
Packit a4058c
# Evaluate this file near the top of your script to gain access to
Packit a4058c
# the functions and variables defined here:
Packit a4058c
#
Packit a4058c
#   . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
Packit a4058c
#
Packit a4058c
# If you need to override any of the default environment variable
Packit a4058c
# settings, do that before evaluating this file.
Packit a4058c
Packit a4058c
Packit a4058c
## -------------------- ##
Packit a4058c
## Shell normalisation. ##
Packit a4058c
## -------------------- ##
Packit a4058c
Packit a4058c
# Some shells need a little help to be as Bourne compatible as possible.
Packit a4058c
# Before doing anything else, make sure all that help has been provided!
Packit a4058c
Packit a4058c
DUALCASE=1; export DUALCASE # for MKS sh
Packit a4058c
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
Packit a4058c
  emulate sh
Packit a4058c
  NULLCMD=:
Packit a4058c
  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
Packit a4058c
  # is contrary to our usage.  Disable this feature.
Packit a4058c
  alias -g '${1+"$@"}'='"$@"'
Packit a4058c
  setopt NO_GLOB_SUBST
Packit a4058c
else
Packit a4058c
  case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
Packit a4058c
fi
Packit a4058c
Packit a4058c
# NLS nuisances: We save the old values in case they are required later.
Packit a4058c
_G_user_locale=
Packit a4058c
_G_safe_locale=
Packit a4058c
for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
Packit a4058c
do
Packit a4058c
  eval "if test set = \"\${$_G_var+set}\"; then
Packit a4058c
          save_$_G_var=\$$_G_var
Packit a4058c
          $_G_var=C
Packit a4058c
	  export $_G_var
Packit a4058c
	  _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
Packit a4058c
	  _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
Packit a4058c
	fi"
Packit a4058c
done
Packit a4058c
Packit a4058c
# CDPATH.
Packit a4058c
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
Packit a4058c
Packit a4058c
# Make sure IFS has a sensible default
Packit a4058c
sp=' '
Packit a4058c
nl='
Packit a4058c
'
Packit a4058c
IFS="$sp	$nl"
Packit a4058c
Packit a4058c
# There are apparently some retarded systems that use ';' as a PATH separator!
Packit a4058c
if test "${PATH_SEPARATOR+set}" != set; then
Packit a4058c
  PATH_SEPARATOR=:
Packit a4058c
  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
Packit a4058c
    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
Packit a4058c
      PATH_SEPARATOR=';'
Packit a4058c
  }
Packit a4058c
fi
Packit a4058c
Packit a4058c
Packit a4058c
Packit a4058c
## ------------------------- ##
Packit a4058c
## Locate command utilities. ##
Packit a4058c
## ------------------------- ##
Packit a4058c
Packit a4058c
Packit a4058c
# func_executable_p FILE
Packit a4058c
# ----------------------
Packit a4058c
# Check that FILE is an executable regular file.
Packit a4058c
func_executable_p ()
Packit a4058c
{
Packit a4058c
    test -f "$1" && test -x "$1"
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_path_progs PROGS_LIST CHECK_FUNC [PATH]
Packit a4058c
# --------------------------------------------
Packit a4058c
# Search for either a program that responds to --version with output
Packit a4058c
# containing "GNU", or else returned by CHECK_FUNC otherwise, by
Packit a4058c
# trying all the directories in PATH with each of the elements of
Packit a4058c
# PROGS_LIST.
Packit a4058c
#
Packit a4058c
# CHECK_FUNC should accept the path to a candidate program, and
Packit a4058c
# set $func_check_prog_result if it truncates its output less than
Packit a4058c
# $_G_path_prog_max characters.
Packit a4058c
func_path_progs ()
Packit a4058c
{
Packit a4058c
    _G_progs_list=$1
Packit a4058c
    _G_check_func=$2
Packit a4058c
    _G_PATH=${3-"$PATH"}
Packit a4058c
Packit a4058c
    _G_path_prog_max=0
Packit a4058c
    _G_path_prog_found=false
Packit a4058c
    _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
Packit a4058c
    for _G_dir in $_G_PATH; do
Packit a4058c
      IFS=$_G_save_IFS
Packit a4058c
      test -z "$_G_dir" && _G_dir=.
Packit a4058c
      for _G_prog_name in $_G_progs_list; do
Packit a4058c
        for _exeext in '' .EXE; do
Packit a4058c
          _G_path_prog=$_G_dir/$_G_prog_name$_exeext
Packit a4058c
          func_executable_p "$_G_path_prog" || continue
Packit a4058c
          case `"$_G_path_prog" --version 2>&1` in
Packit a4058c
            *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
Packit a4058c
            *)     $_G_check_func $_G_path_prog
Packit a4058c
		   func_path_progs_result=$func_check_prog_result
Packit a4058c
		   ;;
Packit a4058c
          esac
Packit a4058c
          $_G_path_prog_found && break 3
Packit a4058c
        done
Packit a4058c
      done
Packit a4058c
    done
Packit a4058c
    IFS=$_G_save_IFS
Packit a4058c
    test -z "$func_path_progs_result" && {
Packit a4058c
      echo "no acceptable sed could be found in \$PATH" >&2
Packit a4058c
      exit 1
Packit a4058c
    }
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# We want to be able to use the functions in this file before configure
Packit a4058c
# has figured out where the best binaries are kept, which means we have
Packit a4058c
# to search for them ourselves - except when the results are already set
Packit a4058c
# where we skip the searches.
Packit a4058c
Packit a4058c
# Unless the user overrides by setting SED, search the path for either GNU
Packit a4058c
# sed, or the sed that truncates its output the least.
Packit a4058c
test -z "$SED" && {
Packit a4058c
  _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
Packit a4058c
  for _G_i in 1 2 3 4 5 6 7; do
Packit a4058c
    _G_sed_script=$_G_sed_script$nl$_G_sed_script
Packit a4058c
  done
Packit a4058c
  echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
Packit a4058c
  _G_sed_script=
Packit a4058c
Packit a4058c
  func_check_prog_sed ()
Packit a4058c
  {
Packit a4058c
    _G_path_prog=$1
Packit a4058c
Packit a4058c
    _G_count=0
Packit a4058c
    printf 0123456789 >conftest.in
Packit a4058c
    while :
Packit a4058c
    do
Packit a4058c
      cat conftest.in conftest.in >conftest.tmp
Packit a4058c
      mv conftest.tmp conftest.in
Packit a4058c
      cp conftest.in conftest.nl
Packit a4058c
      echo '' >> conftest.nl
Packit a4058c
      "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
Packit a4058c
      diff conftest.out conftest.nl >/dev/null 2>&1 || break
Packit a4058c
      _G_count=`expr $_G_count + 1`
Packit a4058c
      if test "$_G_count" -gt "$_G_path_prog_max"; then
Packit a4058c
        # Best one so far, save it but keep looking for a better one
Packit a4058c
        func_check_prog_result=$_G_path_prog
Packit a4058c
        _G_path_prog_max=$_G_count
Packit a4058c
      fi
Packit a4058c
      # 10*(2^10) chars as input seems more than enough
Packit a4058c
      test 10 -lt "$_G_count" && break
Packit a4058c
    done
Packit a4058c
    rm -f conftest.in conftest.tmp conftest.nl conftest.out
Packit a4058c
  }
Packit a4058c
Packit a4058c
  func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
Packit a4058c
  rm -f conftest.sed
Packit a4058c
  SED=$func_path_progs_result
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# Unless the user overrides by setting GREP, search the path for either GNU
Packit a4058c
# grep, or the grep that truncates its output the least.
Packit a4058c
test -z "$GREP" && {
Packit a4058c
  func_check_prog_grep ()
Packit a4058c
  {
Packit a4058c
    _G_path_prog=$1
Packit a4058c
Packit a4058c
    _G_count=0
Packit a4058c
    _G_path_prog_max=0
Packit a4058c
    printf 0123456789 >conftest.in
Packit a4058c
    while :
Packit a4058c
    do
Packit a4058c
      cat conftest.in conftest.in >conftest.tmp
Packit a4058c
      mv conftest.tmp conftest.in
Packit a4058c
      cp conftest.in conftest.nl
Packit a4058c
      echo 'GREP' >> conftest.nl
Packit a4058c
      "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
Packit a4058c
      diff conftest.out conftest.nl >/dev/null 2>&1 || break
Packit a4058c
      _G_count=`expr $_G_count + 1`
Packit a4058c
      if test "$_G_count" -gt "$_G_path_prog_max"; then
Packit a4058c
        # Best one so far, save it but keep looking for a better one
Packit a4058c
        func_check_prog_result=$_G_path_prog
Packit a4058c
        _G_path_prog_max=$_G_count
Packit a4058c
      fi
Packit a4058c
      # 10*(2^10) chars as input seems more than enough
Packit a4058c
      test 10 -lt "$_G_count" && break
Packit a4058c
    done
Packit a4058c
    rm -f conftest.in conftest.tmp conftest.nl conftest.out
Packit a4058c
  }
Packit a4058c
Packit a4058c
  func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
Packit a4058c
  GREP=$func_path_progs_result
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
## ------------------------------- ##
Packit a4058c
## User overridable command paths. ##
Packit a4058c
## ------------------------------- ##
Packit a4058c
Packit a4058c
# All uppercase variable names are used for environment variables.  These
Packit a4058c
# variables can be overridden by the user before calling a script that
Packit a4058c
# uses them if a suitable command of that name is not already available
Packit a4058c
# in the command search PATH.
Packit a4058c
Packit a4058c
: ${CP="cp -f"}
Packit a4058c
: ${ECHO="printf %s\n"}
Packit a4058c
: ${EGREP="$GREP -E"}
Packit a4058c
: ${FGREP="$GREP -F"}
Packit a4058c
: ${LN_S="ln -s"}
Packit a4058c
: ${MAKE="make"}
Packit a4058c
: ${MKDIR="mkdir"}
Packit a4058c
: ${MV="mv -f"}
Packit a4058c
: ${RM="rm -f"}
Packit a4058c
: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
Packit a4058c
Packit a4058c
Packit a4058c
## -------------------- ##
Packit a4058c
## Useful sed snippets. ##
Packit a4058c
## -------------------- ##
Packit a4058c
Packit a4058c
sed_dirname='s|/[^/]*$||'
Packit a4058c
sed_basename='s|^.*/||'
Packit a4058c
Packit a4058c
# Sed substitution that helps us do robust quoting.  It backslashifies
Packit a4058c
# metacharacters that are still active within double-quoted strings.
Packit a4058c
sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
Packit a4058c
Packit a4058c
# Same as above, but do not quote variable references.
Packit a4058c
sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
Packit a4058c
Packit a4058c
# Sed substitution that turns a string into a regex matching for the
Packit a4058c
# string literally.
Packit a4058c
sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
Packit a4058c
Packit a4058c
# Sed substitution that converts a w32 file name or path
Packit a4058c
# that contains forward slashes, into one that contains
Packit a4058c
# (escaped) backslashes.  A very naive implementation.
Packit a4058c
sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
Packit a4058c
Packit a4058c
# Re-'\' parameter expansions in output of sed_double_quote_subst that
Packit a4058c
# were '\'-ed in input to the same.  If an odd number of '\' preceded a
Packit a4058c
# '$' in input to sed_double_quote_subst, that '$' was protected from
Packit a4058c
# expansion.  Since each input '\' is now two '\'s, look for any number
Packit a4058c
# of runs of four '\'s followed by two '\'s and then a '$'.  '\' that '$'.
Packit a4058c
_G_bs='\\'
Packit a4058c
_G_bs2='\\\\'
Packit a4058c
_G_bs4='\\\\\\\\'
Packit a4058c
_G_dollar='\$'
Packit a4058c
sed_double_backslash="\
Packit a4058c
  s/$_G_bs4/&\\
Packit a4058c
/g
Packit a4058c
  s/^$_G_bs2$_G_dollar/$_G_bs&/
Packit a4058c
  s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
Packit a4058c
  s/\n//g"
Packit a4058c
Packit a4058c
Packit a4058c
## ----------------- ##
Packit a4058c
## Global variables. ##
Packit a4058c
## ----------------- ##
Packit a4058c
Packit a4058c
# Except for the global variables explicitly listed below, the following
Packit a4058c
# functions in the '^func_' namespace, and the '^require_' namespace
Packit a4058c
# variables initialised in the 'Resource management' section, sourcing
Packit a4058c
# this file will not pollute your global namespace with anything
Packit a4058c
# else. There's no portable way to scope variables in Bourne shell
Packit a4058c
# though, so actually running these functions will sometimes place
Packit a4058c
# results into a variable named after the function, and often use
Packit a4058c
# temporary variables in the '^_G_' namespace. If you are careful to
Packit a4058c
# avoid using those namespaces casually in your sourcing script, things
Packit a4058c
# should continue to work as you expect. And, of course, you can freely
Packit a4058c
# overwrite any of the functions or variables defined here before
Packit a4058c
# calling anything to customize them.
Packit a4058c
Packit a4058c
EXIT_SUCCESS=0
Packit a4058c
EXIT_FAILURE=1
Packit a4058c
EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
Packit a4058c
EXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
Packit a4058c
Packit a4058c
# Allow overriding, eg assuming that you follow the convention of
Packit a4058c
# putting '$debug_cmd' at the start of all your functions, you can get
Packit a4058c
# bash to show function call trace with:
Packit a4058c
#
Packit a4058c
#    debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
Packit a4058c
debug_cmd=${debug_cmd-":"}
Packit a4058c
exit_cmd=:
Packit a4058c
Packit a4058c
# By convention, finish your script with:
Packit a4058c
#
Packit a4058c
#    exit $exit_status
Packit a4058c
#
Packit a4058c
# so that you can set exit_status to non-zero if you want to indicate
Packit a4058c
# something went wrong during execution without actually bailing out at
Packit a4058c
# the point of failure.
Packit a4058c
exit_status=$EXIT_SUCCESS
Packit a4058c
Packit a4058c
# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
Packit a4058c
# is ksh but when the shell is invoked as "sh" and the current value of
Packit a4058c
# the _XPG environment variable is not equal to 1 (one), the special
Packit a4058c
# positional parameter $0, within a function call, is the name of the
Packit a4058c
# function.
Packit a4058c
progpath=$0
Packit a4058c
Packit a4058c
# The name of this program.
Packit a4058c
progname=`$ECHO "$progpath" |$SED "$sed_basename"`
Packit a4058c
Packit a4058c
# Make sure we have an absolute progpath for reexecution:
Packit a4058c
case $progpath in
Packit a4058c
  [\\/]*|[A-Za-z]:\\*) ;;
Packit a4058c
  *[\\/]*)
Packit a4058c
     progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
Packit a4058c
     progdir=`cd "$progdir" && pwd`
Packit a4058c
     progpath=$progdir/$progname
Packit a4058c
     ;;
Packit a4058c
  *)
Packit a4058c
     _G_IFS=$IFS
Packit a4058c
     IFS=${PATH_SEPARATOR-:}
Packit a4058c
     for progdir in $PATH; do
Packit a4058c
       IFS=$_G_IFS
Packit a4058c
       test -x "$progdir/$progname" && break
Packit a4058c
     done
Packit a4058c
     IFS=$_G_IFS
Packit a4058c
     test -n "$progdir" || progdir=`pwd`
Packit a4058c
     progpath=$progdir/$progname
Packit a4058c
     ;;
Packit a4058c
esac
Packit a4058c
Packit a4058c
Packit a4058c
## ----------------- ##
Packit a4058c
## Standard options. ##
Packit a4058c
## ----------------- ##
Packit a4058c
Packit a4058c
# The following options affect the operation of the functions defined
Packit a4058c
# below, and should be set appropriately depending on run-time para-
Packit a4058c
# meters passed on the command line.
Packit a4058c
Packit a4058c
opt_dry_run=false
Packit a4058c
opt_quiet=false
Packit a4058c
opt_verbose=false
Packit a4058c
Packit a4058c
# Categories 'all' and 'none' are always available.  Append any others
Packit a4058c
# you will pass as the first argument to func_warning from your own
Packit a4058c
# code.
Packit a4058c
warning_categories=
Packit a4058c
Packit a4058c
# By default, display warnings according to 'opt_warning_types'.  Set
Packit a4058c
# 'warning_func'  to ':' to elide all warnings, or func_fatal_error to
Packit a4058c
# treat the next displayed warning as a fatal error.
Packit a4058c
warning_func=func_warn_and_continue
Packit a4058c
Packit a4058c
# Set to 'all' to display all warnings, 'none' to suppress all
Packit a4058c
# warnings, or a space delimited list of some subset of
Packit a4058c
# 'warning_categories' to display only the listed warnings.
Packit a4058c
opt_warning_types=all
Packit a4058c
Packit a4058c
Packit a4058c
## -------------------- ##
Packit a4058c
## Resource management. ##
Packit a4058c
## -------------------- ##
Packit a4058c
Packit a4058c
# This section contains definitions for functions that each ensure a
Packit a4058c
# particular resource (a file, or a non-empty configuration variable for
Packit a4058c
# example) is available, and if appropriate to extract default values
Packit a4058c
# from pertinent package files. Call them using their associated
Packit a4058c
# 'require_*' variable to ensure that they are executed, at most, once.
Packit a4058c
#
Packit a4058c
# It's entirely deliberate that calling these functions can set
Packit a4058c
# variables that don't obey the namespace limitations obeyed by the rest
Packit a4058c
# of this file, in order that that they be as useful as possible to
Packit a4058c
# callers.
Packit a4058c
Packit a4058c
Packit a4058c
# require_term_colors
Packit a4058c
# -------------------
Packit a4058c
# Allow display of bold text on terminals that support it.
Packit a4058c
require_term_colors=func_require_term_colors
Packit a4058c
func_require_term_colors ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    test -t 1 && {
Packit a4058c
      # COLORTERM and USE_ANSI_COLORS environment variables take
Packit a4058c
      # precedence, because most terminfo databases neglect to describe
Packit a4058c
      # whether color sequences are supported.
Packit a4058c
      test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
Packit a4058c
Packit a4058c
      if test 1 = "$USE_ANSI_COLORS"; then
Packit a4058c
        # Standard ANSI escape sequences
Packit a4058c
        tc_reset='?[0m'
Packit a4058c
        tc_bold='?[1m';   tc_standout='?[7m'
Packit a4058c
        tc_red='?[31m';   tc_green='?[32m'
Packit a4058c
        tc_blue='?[34m';  tc_cyan='?[36m'
Packit a4058c
      else
Packit a4058c
        # Otherwise trust the terminfo database after all.
Packit a4058c
        test -n "`tput sgr0 2>/dev/null`" && {
Packit a4058c
          tc_reset=`tput sgr0`
Packit a4058c
          test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
Packit a4058c
          tc_standout=$tc_bold
Packit a4058c
          test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
Packit a4058c
          test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
Packit a4058c
          test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
Packit a4058c
          test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
Packit a4058c
          test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
Packit a4058c
        }
Packit a4058c
      fi
Packit a4058c
    }
Packit a4058c
Packit a4058c
    require_term_colors=:
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
## ----------------- ##
Packit a4058c
## Function library. ##
Packit a4058c
## ----------------- ##
Packit a4058c
Packit a4058c
# This section contains a variety of useful functions to call in your
Packit a4058c
# scripts. Take note of the portable wrappers for features provided by
Packit a4058c
# some modern shells, which will fall back to slower equivalents on
Packit a4058c
# less featureful shells.
Packit a4058c
Packit a4058c
Packit a4058c
# func_append VAR VALUE
Packit a4058c
# ---------------------
Packit a4058c
# Append VALUE onto the existing contents of VAR.
Packit a4058c
Packit a4058c
  # We should try to minimise forks, especially on Windows where they are
Packit a4058c
  # unreasonably slow, so skip the feature probes when bash or zsh are
Packit a4058c
  # being used:
Packit a4058c
  if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
Packit a4058c
    : ${_G_HAVE_ARITH_OP="yes"}
Packit a4058c
    : ${_G_HAVE_XSI_OPS="yes"}
Packit a4058c
    # The += operator was introduced in bash 3.1
Packit a4058c
    case $BASH_VERSION in
Packit a4058c
      [12].* | 3.0 | 3.0*) ;;
Packit a4058c
      *)
Packit a4058c
        : ${_G_HAVE_PLUSEQ_OP="yes"}
Packit a4058c
        ;;
Packit a4058c
    esac
Packit a4058c
  fi
Packit a4058c
Packit a4058c
  # _G_HAVE_PLUSEQ_OP
Packit a4058c
  # Can be empty, in which case the shell is probed, "yes" if += is
Packit a4058c
  # useable or anything else if it does not work.
Packit a4058c
  test -z "$_G_HAVE_PLUSEQ_OP" \
Packit a4058c
    && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
Packit a4058c
    && _G_HAVE_PLUSEQ_OP=yes
Packit a4058c
Packit a4058c
if test yes = "$_G_HAVE_PLUSEQ_OP"
Packit a4058c
then
Packit a4058c
  # This is an XSI compatible shell, allowing a faster implementation...
Packit a4058c
  eval 'func_append ()
Packit a4058c
  {
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    eval "$1+=\$2"
Packit a4058c
  }'
Packit a4058c
else
Packit a4058c
  # ...otherwise fall back to using expr, which is often a shell builtin.
Packit a4058c
  func_append ()
Packit a4058c
  {
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    eval "$1=\$$1\$2"
Packit a4058c
  }
Packit a4058c
fi
Packit a4058c
Packit a4058c
Packit a4058c
# func_append_quoted VAR VALUE
Packit a4058c
# ----------------------------
Packit a4058c
# Quote VALUE and append to the end of shell variable VAR, separated
Packit a4058c
# by a space.
Packit a4058c
if test yes = "$_G_HAVE_PLUSEQ_OP"; then
Packit a4058c
  eval 'func_append_quoted ()
Packit a4058c
  {
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    func_quote_for_eval "$2"
Packit a4058c
    eval "$1+=\\ \$func_quote_for_eval_result"
Packit a4058c
  }'
Packit a4058c
else
Packit a4058c
  func_append_quoted ()
Packit a4058c
  {
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    func_quote_for_eval "$2"
Packit a4058c
    eval "$1=\$$1\\ \$func_quote_for_eval_result"
Packit a4058c
  }
Packit a4058c
fi
Packit a4058c
Packit a4058c
Packit a4058c
# func_append_uniq VAR VALUE
Packit a4058c
# --------------------------
Packit a4058c
# Append unique VALUE onto the existing contents of VAR, assuming
Packit a4058c
# entries are delimited by the first character of VALUE.  For example:
Packit a4058c
#
Packit a4058c
#   func_append_uniq options " --another-option option-argument"
Packit a4058c
#
Packit a4058c
# will only append to $options if " --another-option option-argument "
Packit a4058c
# is not already present somewhere in $options already (note spaces at
Packit a4058c
# each end implied by leading space in second argument).
Packit a4058c
func_append_uniq ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    eval _G_current_value='`$ECHO $'$1'`'
Packit a4058c
    _G_delim=`expr "$2" : '\(.\)'`
Packit a4058c
Packit a4058c
    case $_G_delim$_G_current_value$_G_delim in
Packit a4058c
      *"$2$_G_delim"*) ;;
Packit a4058c
      *) func_append "$@" ;;
Packit a4058c
    esac
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_arith TERM...
Packit a4058c
# ------------------
Packit a4058c
# Set func_arith_result to the result of evaluating TERMs.
Packit a4058c
  test -z "$_G_HAVE_ARITH_OP" \
Packit a4058c
    && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
Packit a4058c
    && _G_HAVE_ARITH_OP=yes
Packit a4058c
Packit a4058c
if test yes = "$_G_HAVE_ARITH_OP"; then
Packit a4058c
  eval 'func_arith ()
Packit a4058c
  {
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    func_arith_result=$(( $* ))
Packit a4058c
  }'
Packit a4058c
else
Packit a4058c
  func_arith ()
Packit a4058c
  {
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    func_arith_result=`expr "$@"`
Packit a4058c
  }
Packit a4058c
fi
Packit a4058c
Packit a4058c
Packit a4058c
# func_basename FILE
Packit a4058c
# ------------------
Packit a4058c
# Set func_basename_result to FILE with everything up to and including
Packit a4058c
# the last / stripped.
Packit a4058c
if test yes = "$_G_HAVE_XSI_OPS"; then
Packit a4058c
  # If this shell supports suffix pattern removal, then use it to avoid
Packit a4058c
  # forking. Hide the definitions single quotes in case the shell chokes
Packit a4058c
  # on unsupported syntax...
Packit a4058c
  _b='func_basename_result=${1##*/}'
Packit a4058c
  _d='case $1 in
Packit a4058c
        */*) func_dirname_result=${1%/*}$2 ;;
Packit a4058c
        *  ) func_dirname_result=$3        ;;
Packit a4058c
      esac'
Packit a4058c
Packit a4058c
else
Packit a4058c
  # ...otherwise fall back to using sed.
Packit a4058c
  _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
Packit a4058c
  _d='func_dirname_result=`$ECHO "$1"  |$SED "$sed_dirname"`
Packit a4058c
      if test "X$func_dirname_result" = "X$1"; then
Packit a4058c
        func_dirname_result=$3
Packit a4058c
      else
Packit a4058c
        func_append func_dirname_result "$2"
Packit a4058c
      fi'
Packit a4058c
fi
Packit a4058c
Packit a4058c
eval 'func_basename ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    '"$_b"'
Packit a4058c
}'
Packit a4058c
Packit a4058c
Packit a4058c
# func_dirname FILE APPEND NONDIR_REPLACEMENT
Packit a4058c
# -------------------------------------------
Packit a4058c
# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
Packit a4058c
# otherwise set result to NONDIR_REPLACEMENT.
Packit a4058c
eval 'func_dirname ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    '"$_d"'
Packit a4058c
}'
Packit a4058c
Packit a4058c
Packit a4058c
# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
Packit a4058c
# --------------------------------------------------------
Packit a4058c
# Perform func_basename and func_dirname in a single function
Packit a4058c
# call:
Packit a4058c
#   dirname:  Compute the dirname of FILE.  If nonempty,
Packit a4058c
#             add APPEND to the result, otherwise set result
Packit a4058c
#             to NONDIR_REPLACEMENT.
Packit a4058c
#             value returned in "$func_dirname_result"
Packit a4058c
#   basename: Compute filename of FILE.
Packit a4058c
#             value retuned in "$func_basename_result"
Packit a4058c
# For efficiency, we do not delegate to the functions above but instead
Packit a4058c
# duplicate the functionality here.
Packit a4058c
eval 'func_dirname_and_basename ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    '"$_b"'
Packit a4058c
    '"$_d"'
Packit a4058c
}'
Packit a4058c
Packit a4058c
Packit a4058c
# func_echo ARG...
Packit a4058c
# ----------------
Packit a4058c
# Echo program name prefixed message.
Packit a4058c
func_echo ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    _G_message=$*
Packit a4058c
Packit a4058c
    func_echo_IFS=$IFS
Packit a4058c
    IFS=$nl
Packit a4058c
    for _G_line in $_G_message; do
Packit a4058c
      IFS=$func_echo_IFS
Packit a4058c
      $ECHO "$progname: $_G_line"
Packit a4058c
    done
Packit a4058c
    IFS=$func_echo_IFS
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_echo_all ARG...
Packit a4058c
# --------------------
Packit a4058c
# Invoke $ECHO with all args, space-separated.
Packit a4058c
func_echo_all ()
Packit a4058c
{
Packit a4058c
    $ECHO "$*"
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_echo_infix_1 INFIX ARG...
Packit a4058c
# ------------------------------
Packit a4058c
# Echo program name, followed by INFIX on the first line, with any
Packit a4058c
# additional lines not showing INFIX.
Packit a4058c
func_echo_infix_1 ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    $require_term_colors
Packit a4058c
Packit a4058c
    _G_infix=$1; shift
Packit a4058c
    _G_indent=$_G_infix
Packit a4058c
    _G_prefix="$progname: $_G_infix: "
Packit a4058c
    _G_message=$*
Packit a4058c
Packit a4058c
    # Strip color escape sequences before counting printable length
Packit a4058c
    for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
Packit a4058c
    do
Packit a4058c
      test -n "$_G_tc" && {
Packit a4058c
        _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
Packit a4058c
        _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
Packit a4058c
      }
Packit a4058c
    done
Packit a4058c
    _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`"  " ## exclude from sc_prohibit_nested_quotes
Packit a4058c
Packit a4058c
    func_echo_infix_1_IFS=$IFS
Packit a4058c
    IFS=$nl
Packit a4058c
    for _G_line in $_G_message; do
Packit a4058c
      IFS=$func_echo_infix_1_IFS
Packit a4058c
      $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
Packit a4058c
      _G_prefix=$_G_indent
Packit a4058c
    done
Packit a4058c
    IFS=$func_echo_infix_1_IFS
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_error ARG...
Packit a4058c
# -----------------
Packit a4058c
# Echo program name prefixed message to standard error.
Packit a4058c
func_error ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    $require_term_colors
Packit a4058c
Packit a4058c
    func_echo_infix_1 "  $tc_standout${tc_red}error$tc_reset" "$*" >&2
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_fatal_error ARG...
Packit a4058c
# -----------------------
Packit a4058c
# Echo program name prefixed message to standard error, and exit.
Packit a4058c
func_fatal_error ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    func_error "$*"
Packit a4058c
    exit $EXIT_FAILURE
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_grep EXPRESSION FILENAME
Packit a4058c
# -----------------------------
Packit a4058c
# Check whether EXPRESSION matches any line of FILENAME, without output.
Packit a4058c
func_grep ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    $GREP "$1" "$2" >/dev/null 2>&1
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_len STRING
Packit a4058c
# ---------------
Packit a4058c
# Set func_len_result to the length of STRING. STRING may not
Packit a4058c
# start with a hyphen.
Packit a4058c
  test -z "$_G_HAVE_XSI_OPS" \
Packit a4058c
    && (eval 'x=a/b/c;
Packit a4058c
      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
Packit a4058c
    && _G_HAVE_XSI_OPS=yes
Packit a4058c
Packit a4058c
if test yes = "$_G_HAVE_XSI_OPS"; then
Packit a4058c
  eval 'func_len ()
Packit a4058c
  {
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    func_len_result=${#1}
Packit a4058c
  }'
Packit a4058c
else
Packit a4058c
  func_len ()
Packit a4058c
  {
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
Packit a4058c
  }
Packit a4058c
fi
Packit a4058c
Packit a4058c
Packit a4058c
# func_mkdir_p DIRECTORY-PATH
Packit a4058c
# ---------------------------
Packit a4058c
# Make sure the entire path to DIRECTORY-PATH is available.
Packit a4058c
func_mkdir_p ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    _G_directory_path=$1
Packit a4058c
    _G_dir_list=
Packit a4058c
Packit a4058c
    if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
Packit a4058c
Packit a4058c
      # Protect directory names starting with '-'
Packit a4058c
      case $_G_directory_path in
Packit a4058c
        -*) _G_directory_path=./$_G_directory_path ;;
Packit a4058c
      esac
Packit a4058c
Packit a4058c
      # While some portion of DIR does not yet exist...
Packit a4058c
      while test ! -d "$_G_directory_path"; do
Packit a4058c
        # ...make a list in topmost first order.  Use a colon delimited
Packit a4058c
	# list incase some portion of path contains whitespace.
Packit a4058c
        _G_dir_list=$_G_directory_path:$_G_dir_list
Packit a4058c
Packit a4058c
        # If the last portion added has no slash in it, the list is done
Packit a4058c
        case $_G_directory_path in */*) ;; *) break ;; esac
Packit a4058c
Packit a4058c
        # ...otherwise throw away the child directory and loop
Packit a4058c
        _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
Packit a4058c
      done
Packit a4058c
      _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
Packit a4058c
Packit a4058c
      func_mkdir_p_IFS=$IFS; IFS=:
Packit a4058c
      for _G_dir in $_G_dir_list; do
Packit a4058c
	IFS=$func_mkdir_p_IFS
Packit a4058c
        # mkdir can fail with a 'File exist' error if two processes
Packit a4058c
        # try to create one of the directories concurrently.  Don't
Packit a4058c
        # stop in that case!
Packit a4058c
        $MKDIR "$_G_dir" 2>/dev/null || :
Packit a4058c
      done
Packit a4058c
      IFS=$func_mkdir_p_IFS
Packit a4058c
Packit a4058c
      # Bail out if we (or some other process) failed to create a directory.
Packit a4058c
      test -d "$_G_directory_path" || \
Packit a4058c
        func_fatal_error "Failed to create '$1'"
Packit a4058c
    fi
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_mktempdir [BASENAME]
Packit a4058c
# -------------------------
Packit a4058c
# Make a temporary directory that won't clash with other running
Packit a4058c
# libtool processes, and avoids race conditions if possible.  If
Packit a4058c
# given, BASENAME is the basename for that directory.
Packit a4058c
func_mktempdir ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    _G_template=${TMPDIR-/tmp}/${1-$progname}
Packit a4058c
Packit a4058c
    if test : = "$opt_dry_run"; then
Packit a4058c
      # Return a directory name, but don't create it in dry-run mode
Packit a4058c
      _G_tmpdir=$_G_template-$$
Packit a4058c
    else
Packit a4058c
Packit a4058c
      # If mktemp works, use that first and foremost
Packit a4058c
      _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
Packit a4058c
Packit a4058c
      if test ! -d "$_G_tmpdir"; then
Packit a4058c
        # Failing that, at least try and use $RANDOM to avoid a race
Packit a4058c
        _G_tmpdir=$_G_template-${RANDOM-0}$$
Packit a4058c
Packit a4058c
        func_mktempdir_umask=`umask`
Packit a4058c
        umask 0077
Packit a4058c
        $MKDIR "$_G_tmpdir"
Packit a4058c
        umask $func_mktempdir_umask
Packit a4058c
      fi
Packit a4058c
Packit a4058c
      # If we're not in dry-run mode, bomb out on failure
Packit a4058c
      test -d "$_G_tmpdir" || \
Packit a4058c
        func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
Packit a4058c
    fi
Packit a4058c
Packit a4058c
    $ECHO "$_G_tmpdir"
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_normal_abspath PATH
Packit a4058c
# ------------------------
Packit a4058c
# Remove doubled-up and trailing slashes, "." path components,
Packit a4058c
# and cancel out any ".." path components in PATH after making
Packit a4058c
# it an absolute path.
Packit a4058c
func_normal_abspath ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    # These SED scripts presuppose an absolute path with a trailing slash.
Packit a4058c
    _G_pathcar='s|^/\([^/]*\).*$|\1|'
Packit a4058c
    _G_pathcdr='s|^/[^/]*||'
Packit a4058c
    _G_removedotparts=':dotsl
Packit a4058c
		s|/\./|/|g
Packit a4058c
		t dotsl
Packit a4058c
		s|/\.$|/|'
Packit a4058c
    _G_collapseslashes='s|/\{1,\}|/|g'
Packit a4058c
    _G_finalslash='s|/*$|/|'
Packit a4058c
Packit a4058c
    # Start from root dir and reassemble the path.
Packit a4058c
    func_normal_abspath_result=
Packit a4058c
    func_normal_abspath_tpath=$1
Packit a4058c
    func_normal_abspath_altnamespace=
Packit a4058c
    case $func_normal_abspath_tpath in
Packit a4058c
      "")
Packit a4058c
        # Empty path, that just means $cwd.
Packit a4058c
        func_stripname '' '/' "`pwd`"
Packit a4058c
        func_normal_abspath_result=$func_stripname_result
Packit a4058c
        return
Packit a4058c
        ;;
Packit a4058c
      # The next three entries are used to spot a run of precisely
Packit a4058c
      # two leading slashes without using negated character classes;
Packit a4058c
      # we take advantage of case's first-match behaviour.
Packit a4058c
      ///*)
Packit a4058c
        # Unusual form of absolute path, do nothing.
Packit a4058c
        ;;
Packit a4058c
      //*)
Packit a4058c
        # Not necessarily an ordinary path; POSIX reserves leading '//'
Packit a4058c
        # and for example Cygwin uses it to access remote file shares
Packit a4058c
        # over CIFS/SMB, so we conserve a leading double slash if found.
Packit a4058c
        func_normal_abspath_altnamespace=/
Packit a4058c
        ;;
Packit a4058c
      /*)
Packit a4058c
        # Absolute path, do nothing.
Packit a4058c
        ;;
Packit a4058c
      *)
Packit a4058c
        # Relative path, prepend $cwd.
Packit a4058c
        func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
Packit a4058c
        ;;
Packit a4058c
    esac
Packit a4058c
Packit a4058c
    # Cancel out all the simple stuff to save iterations.  We also want
Packit a4058c
    # the path to end with a slash for ease of parsing, so make sure
Packit a4058c
    # there is one (and only one) here.
Packit a4058c
    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
Packit a4058c
          -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
Packit a4058c
    while :; do
Packit a4058c
      # Processed it all yet?
Packit a4058c
      if test / = "$func_normal_abspath_tpath"; then
Packit a4058c
        # If we ascended to the root using ".." the result may be empty now.
Packit a4058c
        if test -z "$func_normal_abspath_result"; then
Packit a4058c
          func_normal_abspath_result=/
Packit a4058c
        fi
Packit a4058c
        break
Packit a4058c
      fi
Packit a4058c
      func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
Packit a4058c
          -e "$_G_pathcar"`
Packit a4058c
      func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
Packit a4058c
          -e "$_G_pathcdr"`
Packit a4058c
      # Figure out what to do with it
Packit a4058c
      case $func_normal_abspath_tcomponent in
Packit a4058c
        "")
Packit a4058c
          # Trailing empty path component, ignore it.
Packit a4058c
          ;;
Packit a4058c
        ..)
Packit a4058c
          # Parent dir; strip last assembled component from result.
Packit a4058c
          func_dirname "$func_normal_abspath_result"
Packit a4058c
          func_normal_abspath_result=$func_dirname_result
Packit a4058c
          ;;
Packit a4058c
        *)
Packit a4058c
          # Actual path component, append it.
Packit a4058c
          func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
Packit a4058c
          ;;
Packit a4058c
      esac
Packit a4058c
    done
Packit a4058c
    # Restore leading double-slash if one was found on entry.
Packit a4058c
    func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_notquiet ARG...
Packit a4058c
# --------------------
Packit a4058c
# Echo program name prefixed message only when not in quiet mode.
Packit a4058c
func_notquiet ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    $opt_quiet || func_echo ${1+"$@"}
Packit a4058c
Packit a4058c
    # A bug in bash halts the script if the last line of a function
Packit a4058c
    # fails when set -e is in force, so we need another command to
Packit a4058c
    # work around that:
Packit a4058c
    :
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_relative_path SRCDIR DSTDIR
Packit a4058c
# --------------------------------
Packit a4058c
# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
Packit a4058c
func_relative_path ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    func_relative_path_result=
Packit a4058c
    func_normal_abspath "$1"
Packit a4058c
    func_relative_path_tlibdir=$func_normal_abspath_result
Packit a4058c
    func_normal_abspath "$2"
Packit a4058c
    func_relative_path_tbindir=$func_normal_abspath_result
Packit a4058c
Packit a4058c
    # Ascend the tree starting from libdir
Packit a4058c
    while :; do
Packit a4058c
      # check if we have found a prefix of bindir
Packit a4058c
      case $func_relative_path_tbindir in
Packit a4058c
        $func_relative_path_tlibdir)
Packit a4058c
          # found an exact match
Packit a4058c
          func_relative_path_tcancelled=
Packit a4058c
          break
Packit a4058c
          ;;
Packit a4058c
        $func_relative_path_tlibdir*)
Packit a4058c
          # found a matching prefix
Packit a4058c
          func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
Packit a4058c
          func_relative_path_tcancelled=$func_stripname_result
Packit a4058c
          if test -z "$func_relative_path_result"; then
Packit a4058c
            func_relative_path_result=.
Packit a4058c
          fi
Packit a4058c
          break
Packit a4058c
          ;;
Packit a4058c
        *)
Packit a4058c
          func_dirname $func_relative_path_tlibdir
Packit a4058c
          func_relative_path_tlibdir=$func_dirname_result
Packit a4058c
          if test -z "$func_relative_path_tlibdir"; then
Packit a4058c
            # Have to descend all the way to the root!
Packit a4058c
            func_relative_path_result=../$func_relative_path_result
Packit a4058c
            func_relative_path_tcancelled=$func_relative_path_tbindir
Packit a4058c
            break
Packit a4058c
          fi
Packit a4058c
          func_relative_path_result=../$func_relative_path_result
Packit a4058c
          ;;
Packit a4058c
      esac
Packit a4058c
    done
Packit a4058c
Packit a4058c
    # Now calculate path; take care to avoid doubling-up slashes.
Packit a4058c
    func_stripname '' '/' "$func_relative_path_result"
Packit a4058c
    func_relative_path_result=$func_stripname_result
Packit a4058c
    func_stripname '/' '/' "$func_relative_path_tcancelled"
Packit a4058c
    if test -n "$func_stripname_result"; then
Packit a4058c
      func_append func_relative_path_result "/$func_stripname_result"
Packit a4058c
    fi
Packit a4058c
Packit a4058c
    # Normalisation. If bindir is libdir, return '.' else relative path.
Packit a4058c
    if test -n "$func_relative_path_result"; then
Packit a4058c
      func_stripname './' '' "$func_relative_path_result"
Packit a4058c
      func_relative_path_result=$func_stripname_result
Packit a4058c
    fi
Packit a4058c
Packit a4058c
    test -n "$func_relative_path_result" || func_relative_path_result=.
Packit a4058c
Packit a4058c
    :
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_quote_for_eval ARG...
Packit a4058c
# --------------------------
Packit a4058c
# Aesthetically quote ARGs to be evaled later.
Packit a4058c
# This function returns two values:
Packit a4058c
#   i) func_quote_for_eval_result
Packit a4058c
#      double-quoted, suitable for a subsequent eval
Packit a4058c
#  ii) func_quote_for_eval_unquoted_result
Packit a4058c
#      has all characters that are still active within double
Packit a4058c
#      quotes backslashified.
Packit a4058c
func_quote_for_eval ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    func_quote_for_eval_unquoted_result=
Packit a4058c
    func_quote_for_eval_result=
Packit a4058c
    while test 0 -lt $#; do
Packit a4058c
      case $1 in
Packit a4058c
        *[\\\`\"\$]*)
Packit a4058c
	  _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
Packit a4058c
        *)
Packit a4058c
          _G_unquoted_arg=$1 ;;
Packit a4058c
      esac
Packit a4058c
      if test -n "$func_quote_for_eval_unquoted_result"; then
Packit a4058c
	func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
Packit a4058c
      else
Packit a4058c
        func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
Packit a4058c
      fi
Packit a4058c
Packit a4058c
      case $_G_unquoted_arg in
Packit a4058c
        # Double-quote args containing shell metacharacters to delay
Packit a4058c
        # word splitting, command substitution and variable expansion
Packit a4058c
        # for a subsequent eval.
Packit a4058c
        # Many Bourne shells cannot handle close brackets correctly
Packit a4058c
        # in scan sets, so we specify it separately.
Packit a4058c
        *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
Packit a4058c
          _G_quoted_arg=\"$_G_unquoted_arg\"
Packit a4058c
          ;;
Packit a4058c
        *)
Packit a4058c
          _G_quoted_arg=$_G_unquoted_arg
Packit a4058c
	  ;;
Packit a4058c
      esac
Packit a4058c
Packit a4058c
      if test -n "$func_quote_for_eval_result"; then
Packit a4058c
	func_append func_quote_for_eval_result " $_G_quoted_arg"
Packit a4058c
      else
Packit a4058c
        func_append func_quote_for_eval_result "$_G_quoted_arg"
Packit a4058c
      fi
Packit a4058c
      shift
Packit a4058c
    done
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_quote_for_expand ARG
Packit a4058c
# -------------------------
Packit a4058c
# Aesthetically quote ARG to be evaled later; same as above,
Packit a4058c
# but do not quote variable references.
Packit a4058c
func_quote_for_expand ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    case $1 in
Packit a4058c
      *[\\\`\"]*)
Packit a4058c
	_G_arg=`$ECHO "$1" | $SED \
Packit a4058c
	    -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
Packit a4058c
      *)
Packit a4058c
        _G_arg=$1 ;;
Packit a4058c
    esac
Packit a4058c
Packit a4058c
    case $_G_arg in
Packit a4058c
      # Double-quote args containing shell metacharacters to delay
Packit a4058c
      # word splitting and command substitution for a subsequent eval.
Packit a4058c
      # Many Bourne shells cannot handle close brackets correctly
Packit a4058c
      # in scan sets, so we specify it separately.
Packit a4058c
      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
Packit a4058c
        _G_arg=\"$_G_arg\"
Packit a4058c
        ;;
Packit a4058c
    esac
Packit a4058c
Packit a4058c
    func_quote_for_expand_result=$_G_arg
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_stripname PREFIX SUFFIX NAME
Packit a4058c
# ---------------------------------
Packit a4058c
# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
Packit a4058c
# PREFIX and SUFFIX must not contain globbing or regex special
Packit a4058c
# characters, hashes, percent signs, but SUFFIX may contain a leading
Packit a4058c
# dot (in which case that matches only a dot).
Packit a4058c
if test yes = "$_G_HAVE_XSI_OPS"; then
Packit a4058c
  eval 'func_stripname ()
Packit a4058c
  {
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
Packit a4058c
    # positional parameters, so assign one to ordinary variable first.
Packit a4058c
    func_stripname_result=$3
Packit a4058c
    func_stripname_result=${func_stripname_result#"$1"}
Packit a4058c
    func_stripname_result=${func_stripname_result%"$2"}
Packit a4058c
  }'
Packit a4058c
else
Packit a4058c
  func_stripname ()
Packit a4058c
  {
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    case $2 in
Packit a4058c
      .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
Packit a4058c
      *)  func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
Packit a4058c
    esac
Packit a4058c
  }
Packit a4058c
fi
Packit a4058c
Packit a4058c
Packit a4058c
# func_show_eval CMD [FAIL_EXP]
Packit a4058c
# -----------------------------
Packit a4058c
# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
Packit a4058c
# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
Packit a4058c
# is given, then evaluate it.
Packit a4058c
func_show_eval ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    _G_cmd=$1
Packit a4058c
    _G_fail_exp=${2-':'}
Packit a4058c
Packit a4058c
    func_quote_for_expand "$_G_cmd"
Packit a4058c
    eval "func_notquiet $func_quote_for_expand_result"
Packit a4058c
Packit a4058c
    $opt_dry_run || {
Packit a4058c
      eval "$_G_cmd"
Packit a4058c
      _G_status=$?
Packit a4058c
      if test 0 -ne "$_G_status"; then
Packit a4058c
	eval "(exit $_G_status); $_G_fail_exp"
Packit a4058c
      fi
Packit a4058c
    }
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_show_eval_locale CMD [FAIL_EXP]
Packit a4058c
# ------------------------------------
Packit a4058c
# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
Packit a4058c
# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
Packit a4058c
# is given, then evaluate it.  Use the saved locale for evaluation.
Packit a4058c
func_show_eval_locale ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    _G_cmd=$1
Packit a4058c
    _G_fail_exp=${2-':'}
Packit a4058c
Packit a4058c
    $opt_quiet || {
Packit a4058c
      func_quote_for_expand "$_G_cmd"
Packit a4058c
      eval "func_echo $func_quote_for_expand_result"
Packit a4058c
    }
Packit a4058c
Packit a4058c
    $opt_dry_run || {
Packit a4058c
      eval "$_G_user_locale
Packit a4058c
	    $_G_cmd"
Packit a4058c
      _G_status=$?
Packit a4058c
      eval "$_G_safe_locale"
Packit a4058c
      if test 0 -ne "$_G_status"; then
Packit a4058c
	eval "(exit $_G_status); $_G_fail_exp"
Packit a4058c
      fi
Packit a4058c
    }
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_tr_sh
Packit a4058c
# ----------
Packit a4058c
# Turn $1 into a string suitable for a shell variable name.
Packit a4058c
# Result is stored in $func_tr_sh_result.  All characters
Packit a4058c
# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
Packit a4058c
# if $1 begins with a digit, a '_' is prepended as well.
Packit a4058c
func_tr_sh ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    case $1 in
Packit a4058c
    [0-9]* | *[!a-zA-Z0-9_]*)
Packit a4058c
      func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
Packit a4058c
      ;;
Packit a4058c
    * )
Packit a4058c
      func_tr_sh_result=$1
Packit a4058c
      ;;
Packit a4058c
    esac
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_verbose ARG...
Packit a4058c
# -------------------
Packit a4058c
# Echo program name prefixed message in verbose mode only.
Packit a4058c
func_verbose ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    $opt_verbose && func_echo "$*"
Packit a4058c
Packit a4058c
    :
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_warn_and_continue ARG...
Packit a4058c
# -----------------------------
Packit a4058c
# Echo program name prefixed warning message to standard error.
Packit a4058c
func_warn_and_continue ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    $require_term_colors
Packit a4058c
Packit a4058c
    func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_warning CATEGORY ARG...
Packit a4058c
# ----------------------------
Packit a4058c
# Echo program name prefixed warning message to standard error. Warning
Packit a4058c
# messages can be filtered according to CATEGORY, where this function
Packit a4058c
# elides messages where CATEGORY is not listed in the global variable
Packit a4058c
# 'opt_warning_types'.
Packit a4058c
func_warning ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    # CATEGORY must be in the warning_categories list!
Packit a4058c
    case " $warning_categories " in
Packit a4058c
      *" $1 "*) ;;
Packit a4058c
      *) func_internal_error "invalid warning category '$1'" ;;
Packit a4058c
    esac
Packit a4058c
Packit a4058c
    _G_category=$1
Packit a4058c
    shift
Packit a4058c
Packit a4058c
    case " $opt_warning_types " in
Packit a4058c
      *" $_G_category "*) $warning_func ${1+"$@"} ;;
Packit a4058c
    esac
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_sort_ver VER1 VER2
Packit a4058c
# -----------------------
Packit a4058c
# 'sort -V' is not generally available.
Packit a4058c
# Note this deviates from the version comparison in automake
Packit a4058c
# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
Packit a4058c
# but this should suffice as we won't be specifying old
Packit a4058c
# version formats or redundant trailing .0 in bootstrap.conf.
Packit a4058c
# If we did want full compatibility then we should probably
Packit a4058c
# use m4_version_compare from autoconf.
Packit a4058c
func_sort_ver ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    printf '%s\n%s\n' "$1" "$2" \
Packit a4058c
      | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n
Packit a4058c
}
Packit a4058c
Packit a4058c
# func_lt_ver PREV CURR
Packit a4058c
# ---------------------
Packit a4058c
# Return true if PREV and CURR are in the correct order according to
Packit a4058c
# func_sort_ver, otherwise false.  Use it like this:
Packit a4058c
#
Packit a4058c
#  func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
Packit a4058c
func_lt_ver ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# Local variables:
Packit a4058c
# mode: shell-script
Packit a4058c
# sh-indentation: 2
Packit a4058c
# eval: (add-hook 'before-save-hook 'time-stamp)
Packit a4058c
# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
Packit a4058c
# time-stamp-time-zone: "UTC"
Packit a4058c
# End:
Packit a4058c
#! /bin/sh
Packit a4058c
Packit a4058c
# Set a version string for this script.
Packit a4058c
scriptversion=2014-01-07.03; # UTC
Packit a4058c
Packit a4058c
# A portable, pluggable option parser for Bourne shell.
Packit a4058c
# Written by Gary V. Vaughan, 2010
Packit a4058c
Packit a4058c
# Copyright (C) 2010-2015 Free Software Foundation, Inc.
Packit a4058c
# This is free software; see the source for copying conditions.  There is NO
Packit a4058c
# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Packit a4058c
Packit a4058c
# This program is free software: you can redistribute it and/or modify
Packit a4058c
# it under the terms of the GNU General Public License as published by
Packit a4058c
# the Free Software Foundation, either version 3 of the License, or
Packit a4058c
# (at your option) any later version.
Packit a4058c
Packit a4058c
# This program is distributed in the hope that it will be useful,
Packit a4058c
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit a4058c
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit a4058c
# GNU General Public License for more details.
Packit a4058c
Packit a4058c
# You should have received a copy of the GNU General Public License
Packit a4058c
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit a4058c
Packit a4058c
# Please report bugs or propose patches to gary@gnu.org.
Packit a4058c
Packit a4058c
Packit a4058c
## ------ ##
Packit a4058c
## Usage. ##
Packit a4058c
## ------ ##
Packit a4058c
Packit a4058c
# This file is a library for parsing options in your shell scripts along
Packit a4058c
# with assorted other useful supporting features that you can make use
Packit a4058c
# of too.
Packit a4058c
#
Packit a4058c
# For the simplest scripts you might need only:
Packit a4058c
#
Packit a4058c
#   #!/bin/sh
Packit a4058c
#   . relative/path/to/funclib.sh
Packit a4058c
#   . relative/path/to/options-parser
Packit a4058c
#   scriptversion=1.0
Packit a4058c
#   func_options ${1+"$@"}
Packit a4058c
#   eval set dummy "$func_options_result"; shift
Packit a4058c
#   ...rest of your script...
Packit a4058c
#
Packit a4058c
# In order for the '--version' option to work, you will need to have a
Packit a4058c
# suitably formatted comment like the one at the top of this file
Packit a4058c
# starting with '# Written by ' and ending with '# warranty; '.
Packit a4058c
#
Packit a4058c
# For '-h' and '--help' to work, you will also need a one line
Packit a4058c
# description of your script's purpose in a comment directly above the
Packit a4058c
# '# Written by ' line, like the one at the top of this file.
Packit a4058c
#
Packit a4058c
# The default options also support '--debug', which will turn on shell
Packit a4058c
# execution tracing (see the comment above debug_cmd below for another
Packit a4058c
# use), and '--verbose' and the func_verbose function to allow your script
Packit a4058c
# to display verbose messages only when your user has specified
Packit a4058c
# '--verbose'.
Packit a4058c
#
Packit a4058c
# After sourcing this file, you can plug processing for additional
Packit a4058c
# options by amending the variables from the 'Configuration' section
Packit a4058c
# below, and following the instructions in the 'Option parsing'
Packit a4058c
# section further down.
Packit a4058c
Packit a4058c
## -------------- ##
Packit a4058c
## Configuration. ##
Packit a4058c
## -------------- ##
Packit a4058c
Packit a4058c
# You should override these variables in your script after sourcing this
Packit a4058c
# file so that they reflect the customisations you have added to the
Packit a4058c
# option parser.
Packit a4058c
Packit a4058c
# The usage line for option parsing errors and the start of '-h' and
Packit a4058c
# '--help' output messages. You can embed shell variables for delayed
Packit a4058c
# expansion at the time the message is displayed, but you will need to
Packit a4058c
# quote other shell meta-characters carefully to prevent them being
Packit a4058c
# expanded when the contents are evaled.
Packit a4058c
usage='$progpath [OPTION]...'
Packit a4058c
Packit a4058c
# Short help message in response to '-h' and '--help'.  Add to this or
Packit a4058c
# override it after sourcing this library to reflect the full set of
Packit a4058c
# options your script accepts.
Packit a4058c
usage_message="\
Packit a4058c
       --debug        enable verbose shell tracing
Packit a4058c
   -W, --warnings=CATEGORY
Packit a4058c
                      report the warnings falling in CATEGORY [all]
Packit a4058c
   -v, --verbose      verbosely report processing
Packit a4058c
       --version      print version information and exit
Packit a4058c
   -h, --help         print short or long help message and exit
Packit a4058c
"
Packit a4058c
Packit a4058c
# Additional text appended to 'usage_message' in response to '--help'.
Packit a4058c
long_help_message="
Packit a4058c
Warning categories include:
Packit a4058c
       'all'          show all warnings
Packit a4058c
       'none'         turn off all the warnings
Packit a4058c
       'error'        warnings are treated as fatal errors"
Packit a4058c
Packit a4058c
# Help message printed before fatal option parsing errors.
Packit a4058c
fatal_help="Try '\$progname --help' for more information."
Packit a4058c
Packit a4058c
Packit a4058c
Packit a4058c
## ------------------------- ##
Packit a4058c
## Hook function management. ##
Packit a4058c
## ------------------------- ##
Packit a4058c
Packit a4058c
# This section contains functions for adding, removing, and running hooks
Packit a4058c
# to the main code.  A hook is just a named list of of function, that can
Packit a4058c
# be run in order later on.
Packit a4058c
Packit a4058c
# func_hookable FUNC_NAME
Packit a4058c
# -----------------------
Packit a4058c
# Declare that FUNC_NAME will run hooks added with
Packit a4058c
# 'func_add_hook FUNC_NAME ...'.
Packit a4058c
func_hookable ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    func_append hookable_fns " $1"
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_add_hook FUNC_NAME HOOK_FUNC
Packit a4058c
# ---------------------------------
Packit a4058c
# Request that FUNC_NAME call HOOK_FUNC before it returns.  FUNC_NAME must
Packit a4058c
# first have been declared "hookable" by a call to 'func_hookable'.
Packit a4058c
func_add_hook ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    case " $hookable_fns " in
Packit a4058c
      *" $1 "*) ;;
Packit a4058c
      *) func_fatal_error "'$1' does not accept hook functions." ;;
Packit a4058c
    esac
Packit a4058c
Packit a4058c
    eval func_append ${1}_hooks '" $2"'
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_remove_hook FUNC_NAME HOOK_FUNC
Packit a4058c
# ------------------------------------
Packit a4058c
# Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
Packit a4058c
func_remove_hook ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_run_hooks FUNC_NAME [ARG]...
Packit a4058c
# ---------------------------------
Packit a4058c
# Run all hook functions registered to FUNC_NAME.
Packit a4058c
# It is assumed that the list of hook functions contains nothing more
Packit a4058c
# than a whitespace-delimited list of legal shell function names, and
Packit a4058c
# no effort is wasted trying to catch shell meta-characters or preserve
Packit a4058c
# whitespace.
Packit a4058c
func_run_hooks ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    case " $hookable_fns " in
Packit a4058c
      *" $1 "*) ;;
Packit a4058c
      *) func_fatal_error "'$1' does not support hook funcions.n" ;;
Packit a4058c
    esac
Packit a4058c
Packit a4058c
    eval _G_hook_fns=\$$1_hooks; shift
Packit a4058c
Packit a4058c
    for _G_hook in $_G_hook_fns; do
Packit a4058c
      eval $_G_hook '"$@"'
Packit a4058c
Packit a4058c
      # store returned options list back into positional
Packit a4058c
      # parameters for next 'cmd' execution.
Packit a4058c
      eval _G_hook_result=\$${_G_hook}_result
Packit a4058c
      eval set dummy "$_G_hook_result"; shift
Packit a4058c
    done
Packit a4058c
Packit a4058c
    func_quote_for_eval ${1+"$@"}
Packit a4058c
    func_run_hooks_result=$func_quote_for_eval_result
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
Packit a4058c
## --------------- ##
Packit a4058c
## Option parsing. ##
Packit a4058c
## --------------- ##
Packit a4058c
Packit a4058c
# In order to add your own option parsing hooks, you must accept the
Packit a4058c
# full positional parameter list in your hook function, remove any
Packit a4058c
# options that you action, and then pass back the remaining unprocessed
Packit a4058c
# options in '<hooked_function_name>_result', escaped suitably for
Packit a4058c
# 'eval'.  Like this:
Packit a4058c
#
Packit a4058c
#    my_options_prep ()
Packit a4058c
#    {
Packit a4058c
#        $debug_cmd
Packit a4058c
#
Packit a4058c
#        # Extend the existing usage message.
Packit a4058c
#        usage_message=$usage_message'
Packit a4058c
#      -s, --silent       don'\''t print informational messages
Packit a4058c
#    '
Packit a4058c
#
Packit a4058c
#        func_quote_for_eval ${1+"$@"}
Packit a4058c
#        my_options_prep_result=$func_quote_for_eval_result
Packit a4058c
#    }
Packit a4058c
#    func_add_hook func_options_prep my_options_prep
Packit a4058c
#
Packit a4058c
#
Packit a4058c
#    my_silent_option ()
Packit a4058c
#    {
Packit a4058c
#        $debug_cmd
Packit a4058c
#
Packit a4058c
#        # Note that for efficiency, we parse as many options as we can
Packit a4058c
#        # recognise in a loop before passing the remainder back to the
Packit a4058c
#        # caller on the first unrecognised argument we encounter.
Packit a4058c
#        while test $# -gt 0; do
Packit a4058c
#          opt=$1; shift
Packit a4058c
#          case $opt in
Packit a4058c
#            --silent|-s) opt_silent=: ;;
Packit a4058c
#            # Separate non-argument short options:
Packit a4058c
#            -s*)         func_split_short_opt "$_G_opt"
Packit a4058c
#                         set dummy "$func_split_short_opt_name" \
Packit a4058c
#                             "-$func_split_short_opt_arg" ${1+"$@"}
Packit a4058c
#                         shift
Packit a4058c
#                         ;;
Packit a4058c
#            *)            set dummy "$_G_opt" "$*"; shift; break ;;
Packit a4058c
#          esac
Packit a4058c
#        done
Packit a4058c
#
Packit a4058c
#        func_quote_for_eval ${1+"$@"}
Packit a4058c
#        my_silent_option_result=$func_quote_for_eval_result
Packit a4058c
#    }
Packit a4058c
#    func_add_hook func_parse_options my_silent_option
Packit a4058c
#
Packit a4058c
#
Packit a4058c
#    my_option_validation ()
Packit a4058c
#    {
Packit a4058c
#        $debug_cmd
Packit a4058c
#
Packit a4058c
#        $opt_silent && $opt_verbose && func_fatal_help "\
Packit a4058c
#    '--silent' and '--verbose' options are mutually exclusive."
Packit a4058c
#
Packit a4058c
#        func_quote_for_eval ${1+"$@"}
Packit a4058c
#        my_option_validation_result=$func_quote_for_eval_result
Packit a4058c
#    }
Packit a4058c
#    func_add_hook func_validate_options my_option_validation
Packit a4058c
#
Packit a4058c
# You'll alse need to manually amend $usage_message to reflect the extra
Packit a4058c
# options you parse.  It's preferable to append if you can, so that
Packit a4058c
# multiple option parsing hooks can be added safely.
Packit a4058c
Packit a4058c
Packit a4058c
# func_options [ARG]...
Packit a4058c
# ---------------------
Packit a4058c
# All the functions called inside func_options are hookable. See the
Packit a4058c
# individual implementations for details.
Packit a4058c
func_hookable func_options
Packit a4058c
func_options ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    func_options_prep ${1+"$@"}
Packit a4058c
    eval func_parse_options \
Packit a4058c
        ${func_options_prep_result+"$func_options_prep_result"}
Packit a4058c
    eval func_validate_options \
Packit a4058c
        ${func_parse_options_result+"$func_parse_options_result"}
Packit a4058c
Packit a4058c
    eval func_run_hooks func_options \
Packit a4058c
        ${func_validate_options_result+"$func_validate_options_result"}
Packit a4058c
Packit a4058c
    # save modified positional parameters for caller
Packit a4058c
    func_options_result=$func_run_hooks_result
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_options_prep [ARG]...
Packit a4058c
# --------------------------
Packit a4058c
# All initialisations required before starting the option parse loop.
Packit a4058c
# Note that when calling hook functions, we pass through the list of
Packit a4058c
# positional parameters.  If a hook function modifies that list, and
Packit a4058c
# needs to propogate that back to rest of this script, then the complete
Packit a4058c
# modified list must be put in 'func_run_hooks_result' before
Packit a4058c
# returning.
Packit a4058c
func_hookable func_options_prep
Packit a4058c
func_options_prep ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    # Option defaults:
Packit a4058c
    opt_verbose=false
Packit a4058c
    opt_warning_types=
Packit a4058c
Packit a4058c
    func_run_hooks func_options_prep ${1+"$@"}
Packit a4058c
Packit a4058c
    # save modified positional parameters for caller
Packit a4058c
    func_options_prep_result=$func_run_hooks_result
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_parse_options [ARG]...
Packit a4058c
# ---------------------------
Packit a4058c
# The main option parsing loop.
Packit a4058c
func_hookable func_parse_options
Packit a4058c
func_parse_options ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    func_parse_options_result=
Packit a4058c
Packit a4058c
    # this just eases exit handling
Packit a4058c
    while test $# -gt 0; do
Packit a4058c
      # Defer to hook functions for initial option parsing, so they
Packit a4058c
      # get priority in the event of reusing an option name.
Packit a4058c
      func_run_hooks func_parse_options ${1+"$@"}
Packit a4058c
Packit a4058c
      # Adjust func_parse_options positional parameters to match
Packit a4058c
      eval set dummy "$func_run_hooks_result"; shift
Packit a4058c
Packit a4058c
      # Break out of the loop if we already parsed every option.
Packit a4058c
      test $# -gt 0 || break
Packit a4058c
Packit a4058c
      _G_opt=$1
Packit a4058c
      shift
Packit a4058c
      case $_G_opt in
Packit a4058c
        --debug|-x)   debug_cmd='set -x'
Packit a4058c
                      func_echo "enabling shell trace mode"
Packit a4058c
                      $debug_cmd
Packit a4058c
                      ;;
Packit a4058c
Packit a4058c
        --no-warnings|--no-warning|--no-warn)
Packit a4058c
                      set dummy --warnings none ${1+"$@"}
Packit a4058c
                      shift
Packit a4058c
		      ;;
Packit a4058c
Packit a4058c
        --warnings|--warning|-W)
Packit a4058c
                      test $# = 0 && func_missing_arg $_G_opt && break
Packit a4058c
                      case " $warning_categories $1" in
Packit a4058c
                        *" $1 "*)
Packit a4058c
                          # trailing space prevents matching last $1 above
Packit a4058c
                          func_append_uniq opt_warning_types " $1"
Packit a4058c
                          ;;
Packit a4058c
                        *all)
Packit a4058c
                          opt_warning_types=$warning_categories
Packit a4058c
                          ;;
Packit a4058c
                        *none)
Packit a4058c
                          opt_warning_types=none
Packit a4058c
                          warning_func=:
Packit a4058c
                          ;;
Packit a4058c
                        *error)
Packit a4058c
                          opt_warning_types=$warning_categories
Packit a4058c
                          warning_func=func_fatal_error
Packit a4058c
                          ;;
Packit a4058c
                        *)
Packit a4058c
                          func_fatal_error \
Packit a4058c
                             "unsupported warning category: '$1'"
Packit a4058c
                          ;;
Packit a4058c
                      esac
Packit a4058c
                      shift
Packit a4058c
                      ;;
Packit a4058c
Packit a4058c
        --verbose|-v) opt_verbose=: ;;
Packit a4058c
        --version)    func_version ;;
Packit a4058c
        -\?|-h)       func_usage ;;
Packit a4058c
        --help)       func_help ;;
Packit a4058c
Packit a4058c
	# Separate optargs to long options (plugins may need this):
Packit a4058c
	--*=*)        func_split_equals "$_G_opt"
Packit a4058c
	              set dummy "$func_split_equals_lhs" \
Packit a4058c
                          "$func_split_equals_rhs" ${1+"$@"}
Packit a4058c
                      shift
Packit a4058c
                      ;;
Packit a4058c
Packit a4058c
       # Separate optargs to short options:
Packit a4058c
        -W*)
Packit a4058c
                      func_split_short_opt "$_G_opt"
Packit a4058c
                      set dummy "$func_split_short_opt_name" \
Packit a4058c
                          "$func_split_short_opt_arg" ${1+"$@"}
Packit a4058c
                      shift
Packit a4058c
                      ;;
Packit a4058c
Packit a4058c
        # Separate non-argument short options:
Packit a4058c
        -\?*|-h*|-v*|-x*)
Packit a4058c
                      func_split_short_opt "$_G_opt"
Packit a4058c
                      set dummy "$func_split_short_opt_name" \
Packit a4058c
                          "-$func_split_short_opt_arg" ${1+"$@"}
Packit a4058c
                      shift
Packit a4058c
                      ;;
Packit a4058c
Packit a4058c
        --)           break ;;
Packit a4058c
        -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
Packit a4058c
        *)            set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
Packit a4058c
      esac
Packit a4058c
    done
Packit a4058c
Packit a4058c
    # save modified positional parameters for caller
Packit a4058c
    func_quote_for_eval ${1+"$@"}
Packit a4058c
    func_parse_options_result=$func_quote_for_eval_result
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_validate_options [ARG]...
Packit a4058c
# ------------------------------
Packit a4058c
# Perform any sanity checks on option settings and/or unconsumed
Packit a4058c
# arguments.
Packit a4058c
func_hookable func_validate_options
Packit a4058c
func_validate_options ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    # Display all warnings if -W was not given.
Packit a4058c
    test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
Packit a4058c
Packit a4058c
    func_run_hooks func_validate_options ${1+"$@"}
Packit a4058c
Packit a4058c
    # Bail if the options were screwed!
Packit a4058c
    $exit_cmd $EXIT_FAILURE
Packit a4058c
Packit a4058c
    # save modified positional parameters for caller
Packit a4058c
    func_validate_options_result=$func_run_hooks_result
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
Packit a4058c
## ----------------- ##
Packit a4058c
## Helper functions. ##
Packit a4058c
## ----------------- ##
Packit a4058c
Packit a4058c
# This section contains the helper functions used by the rest of the
Packit a4058c
# hookable option parser framework in ascii-betical order.
Packit a4058c
Packit a4058c
Packit a4058c
# func_fatal_help ARG...
Packit a4058c
# ----------------------
Packit a4058c
# Echo program name prefixed message to standard error, followed by
Packit a4058c
# a help hint, and exit.
Packit a4058c
func_fatal_help ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    eval \$ECHO \""Usage: $usage"\"
Packit a4058c
    eval \$ECHO \""$fatal_help"\"
Packit a4058c
    func_error ${1+"$@"}
Packit a4058c
    exit $EXIT_FAILURE
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_help
Packit a4058c
# ---------
Packit a4058c
# Echo long help message to standard output and exit.
Packit a4058c
func_help ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    func_usage_message
Packit a4058c
    $ECHO "$long_help_message"
Packit a4058c
    exit 0
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_missing_arg ARGNAME
Packit a4058c
# ------------------------
Packit a4058c
# Echo program name prefixed message to standard error and set global
Packit a4058c
# exit_cmd.
Packit a4058c
func_missing_arg ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    func_error "Missing argument for '$1'."
Packit a4058c
    exit_cmd=exit
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_split_equals STRING
Packit a4058c
# ------------------------
Packit a4058c
# Set func_split_equals_lhs and func_split_equals_rhs shell variables after
Packit a4058c
# splitting STRING at the '=' sign.
Packit a4058c
test -z "$_G_HAVE_XSI_OPS" \
Packit a4058c
    && (eval 'x=a/b/c;
Packit a4058c
      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
Packit a4058c
    && _G_HAVE_XSI_OPS=yes
Packit a4058c
Packit a4058c
if test yes = "$_G_HAVE_XSI_OPS"
Packit a4058c
then
Packit a4058c
  # This is an XSI compatible shell, allowing a faster implementation...
Packit a4058c
  eval 'func_split_equals ()
Packit a4058c
  {
Packit a4058c
      $debug_cmd
Packit a4058c
Packit a4058c
      func_split_equals_lhs=${1%%=*}
Packit a4058c
      func_split_equals_rhs=${1#*=}
Packit a4058c
      test "x$func_split_equals_lhs" = "x$1" \
Packit a4058c
        && func_split_equals_rhs=
Packit a4058c
  }'
Packit a4058c
else
Packit a4058c
  # ...otherwise fall back to using expr, which is often a shell builtin.
Packit a4058c
  func_split_equals ()
Packit a4058c
  {
Packit a4058c
      $debug_cmd
Packit a4058c
Packit a4058c
      func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
Packit a4058c
      func_split_equals_rhs=
Packit a4058c
      test "x$func_split_equals_lhs" = "x$1" \
Packit a4058c
        || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
Packit a4058c
  }
Packit a4058c
fi #func_split_equals
Packit a4058c
Packit a4058c
Packit a4058c
# func_split_short_opt SHORTOPT
Packit a4058c
# -----------------------------
Packit a4058c
# Set func_split_short_opt_name and func_split_short_opt_arg shell
Packit a4058c
# variables after splitting SHORTOPT after the 2nd character.
Packit a4058c
if test yes = "$_G_HAVE_XSI_OPS"
Packit a4058c
then
Packit a4058c
  # This is an XSI compatible shell, allowing a faster implementation...
Packit a4058c
  eval 'func_split_short_opt ()
Packit a4058c
  {
Packit a4058c
      $debug_cmd
Packit a4058c
Packit a4058c
      func_split_short_opt_arg=${1#??}
Packit a4058c
      func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
Packit a4058c
  }'
Packit a4058c
else
Packit a4058c
  # ...otherwise fall back to using expr, which is often a shell builtin.
Packit a4058c
  func_split_short_opt ()
Packit a4058c
  {
Packit a4058c
      $debug_cmd
Packit a4058c
Packit a4058c
      func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
Packit a4058c
      func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
Packit a4058c
  }
Packit a4058c
fi #func_split_short_opt
Packit a4058c
Packit a4058c
Packit a4058c
# func_usage
Packit a4058c
# ----------
Packit a4058c
# Echo short help message to standard output and exit.
Packit a4058c
func_usage ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    func_usage_message
Packit a4058c
    $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
Packit a4058c
    exit 0
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_usage_message
Packit a4058c
# ------------------
Packit a4058c
# Echo short help message to standard output.
Packit a4058c
func_usage_message ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    eval \$ECHO \""Usage: $usage"\"
Packit a4058c
    echo
Packit a4058c
    $SED -n 's|^# ||
Packit a4058c
        /^Written by/{
Packit a4058c
          x;p;x
Packit a4058c
        }
Packit a4058c
	h
Packit a4058c
	/^Written by/q' < "$progpath"
Packit a4058c
    echo
Packit a4058c
    eval \$ECHO \""$usage_message"\"
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_version
Packit a4058c
# ------------
Packit a4058c
# Echo version message to standard output and exit.
Packit a4058c
func_version ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    printf '%s\n' "$progname $scriptversion"
Packit a4058c
    $SED -n '
Packit a4058c
        /(C)/!b go
Packit a4058c
        :more
Packit a4058c
        /\./!{
Packit a4058c
          N
Packit a4058c
          s|\n# | |
Packit a4058c
          b more
Packit a4058c
        }
Packit a4058c
        :go
Packit a4058c
        /^# Written by /,/# warranty; / {
Packit a4058c
          s|^# ||
Packit a4058c
          s|^# *$||
Packit a4058c
          s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
Packit a4058c
          p
Packit a4058c
        }
Packit a4058c
        /^# Written by / {
Packit a4058c
          s|^# ||
Packit a4058c
          p
Packit a4058c
        }
Packit a4058c
        /^warranty; /q' < "$progpath"
Packit a4058c
Packit a4058c
    exit $?
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# Local variables:
Packit a4058c
# mode: shell-script
Packit a4058c
# sh-indentation: 2
Packit a4058c
# eval: (add-hook 'before-save-hook 'time-stamp)
Packit a4058c
# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
Packit a4058c
# time-stamp-time-zone: "UTC"
Packit a4058c
# End:
Packit a4058c
Packit a4058c
# Set a version string.
Packit a4058c
scriptversion='(GNU libtool) 2.4.6'
Packit a4058c
Packit a4058c
Packit a4058c
# func_echo ARG...
Packit a4058c
# ----------------
Packit a4058c
# Libtool also displays the current mode in messages, so override
Packit a4058c
# funclib.sh func_echo with this custom definition.
Packit a4058c
func_echo ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    _G_message=$*
Packit a4058c
Packit a4058c
    func_echo_IFS=$IFS
Packit a4058c
    IFS=$nl
Packit a4058c
    for _G_line in $_G_message; do
Packit a4058c
      IFS=$func_echo_IFS
Packit a4058c
      $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
Packit a4058c
    done
Packit a4058c
    IFS=$func_echo_IFS
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_warning ARG...
Packit a4058c
# -------------------
Packit a4058c
# Libtool warnings are not categorized, so override funclib.sh
Packit a4058c
# func_warning with this simpler definition.
Packit a4058c
func_warning ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    $warning_func ${1+"$@"}
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
## ---------------- ##
Packit a4058c
## Options parsing. ##
Packit a4058c
## ---------------- ##
Packit a4058c
Packit a4058c
# Hook in the functions to make sure our own options are parsed during
Packit a4058c
# the option parsing loop.
Packit a4058c
Packit a4058c
usage='$progpath [OPTION]... [MODE-ARG]...'
Packit a4058c
Packit a4058c
# Short help message in response to '-h'.
Packit a4058c
usage_message="Options:
Packit a4058c
       --config             show all configuration variables
Packit a4058c
       --debug              enable verbose shell tracing
Packit a4058c
   -n, --dry-run            display commands without modifying any files
Packit a4058c
       --features           display basic configuration information and exit
Packit a4058c
       --mode=MODE          use operation mode MODE
Packit a4058c
       --no-warnings        equivalent to '-Wnone'
Packit a4058c
       --preserve-dup-deps  don't remove duplicate dependency libraries
Packit a4058c
       --quiet, --silent    don't print informational messages
Packit a4058c
       --tag=TAG            use configuration variables from tag TAG
Packit a4058c
   -v, --verbose            print more informational messages than default
Packit a4058c
       --version            print version information
Packit a4058c
   -W, --warnings=CATEGORY  report the warnings falling in CATEGORY [all]
Packit a4058c
   -h, --help, --help-all   print short, long, or detailed help message
Packit a4058c
"
Packit a4058c
Packit a4058c
# Additional text appended to 'usage_message' in response to '--help'.
Packit a4058c
func_help ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    func_usage_message
Packit a4058c
    $ECHO "$long_help_message
Packit a4058c
Packit a4058c
MODE must be one of the following:
Packit a4058c
Packit a4058c
       clean           remove files from the build directory
Packit a4058c
       compile         compile a source file into a libtool object
Packit a4058c
       execute         automatically set library path, then run a program
Packit a4058c
       finish          complete the installation of libtool libraries
Packit a4058c
       install         install libraries or executables
Packit a4058c
       link            create a library or an executable
Packit a4058c
       uninstall       remove libraries from an installed directory
Packit a4058c
Packit a4058c
MODE-ARGS vary depending on the MODE.  When passed as first option,
Packit a4058c
'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
Packit a4058c
Try '$progname --help --mode=MODE' for a more detailed description of MODE.
Packit a4058c
Packit a4058c
When reporting a bug, please describe a test case to reproduce it and
Packit a4058c
include the following information:
Packit a4058c
Packit a4058c
       host-triplet:   $host
Packit a4058c
       shell:          $SHELL
Packit a4058c
       compiler:       $LTCC
Packit a4058c
       compiler flags: $LTCFLAGS
Packit a4058c
       linker:         $LD (gnu? $with_gnu_ld)
Packit a4058c
       version:        $progname (GNU libtool) 2.4.6
Packit a4058c
       automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
Packit a4058c
       autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
Packit a4058c
Packit a4058c
Report bugs to <bug-libtool@gnu.org>.
Packit a4058c
GNU libtool home page: <http://www.gnu.org/software/libtool/>.
Packit a4058c
General help using GNU software: <http://www.gnu.org/gethelp/>."
Packit a4058c
    exit 0
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_lo2o OBJECT-NAME
Packit a4058c
# ---------------------
Packit a4058c
# Transform OBJECT-NAME from a '.lo' suffix to the platform specific
Packit a4058c
# object suffix.
Packit a4058c
Packit a4058c
lo2o=s/\\.lo\$/.$objext/
Packit a4058c
o2lo=s/\\.$objext\$/.lo/
Packit a4058c
Packit a4058c
if test yes = "$_G_HAVE_XSI_OPS"; then
Packit a4058c
  eval 'func_lo2o ()
Packit a4058c
  {
Packit a4058c
    case $1 in
Packit a4058c
      *.lo) func_lo2o_result=${1%.lo}.$objext ;;
Packit a4058c
      *   ) func_lo2o_result=$1               ;;
Packit a4058c
    esac
Packit a4058c
  }'
Packit a4058c
Packit a4058c
  # func_xform LIBOBJ-OR-SOURCE
Packit a4058c
  # ---------------------------
Packit a4058c
  # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
Packit a4058c
  # suffix to a '.lo' libtool-object suffix.
Packit a4058c
  eval 'func_xform ()
Packit a4058c
  {
Packit a4058c
    func_xform_result=${1%.*}.lo
Packit a4058c
  }'
Packit a4058c
else
Packit a4058c
  # ...otherwise fall back to using sed.
Packit a4058c
  func_lo2o ()
Packit a4058c
  {
Packit a4058c
    func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
Packit a4058c
  }
Packit a4058c
Packit a4058c
  func_xform ()
Packit a4058c
  {
Packit a4058c
    func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
Packit a4058c
  }
Packit a4058c
fi
Packit a4058c
Packit a4058c
Packit a4058c
# func_fatal_configuration ARG...
Packit a4058c
# -------------------------------
Packit a4058c
# Echo program name prefixed message to standard error, followed by
Packit a4058c
# a configuration failure hint, and exit.
Packit a4058c
func_fatal_configuration ()
Packit a4058c
{
Packit a4058c
    func__fatal_error ${1+"$@"} \
Packit a4058c
      "See the $PACKAGE documentation for more information." \
Packit a4058c
      "Fatal configuration error."
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_config
Packit a4058c
# -----------
Packit a4058c
# Display the configuration for all the tags in this script.
Packit a4058c
func_config ()
Packit a4058c
{
Packit a4058c
    re_begincf='^# ### BEGIN LIBTOOL'
Packit a4058c
    re_endcf='^# ### END LIBTOOL'
Packit a4058c
Packit a4058c
    # Default configuration.
Packit a4058c
    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
Packit a4058c
Packit a4058c
    # Now print the configurations for the tags.
Packit a4058c
    for tagname in $taglist; do
Packit a4058c
      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
Packit a4058c
    done
Packit a4058c
Packit a4058c
    exit $?
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_features
Packit a4058c
# -------------
Packit a4058c
# Display the features supported by this script.
Packit a4058c
func_features ()
Packit a4058c
{
Packit a4058c
    echo "host: $host"
Packit a4058c
    if test yes = "$build_libtool_libs"; then
Packit a4058c
      echo "enable shared libraries"
Packit a4058c
    else
Packit a4058c
      echo "disable shared libraries"
Packit a4058c
    fi
Packit a4058c
    if test yes = "$build_old_libs"; then
Packit a4058c
      echo "enable static libraries"
Packit a4058c
    else
Packit a4058c
      echo "disable static libraries"
Packit a4058c
    fi
Packit a4058c
Packit a4058c
    exit $?
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_enable_tag TAGNAME
Packit a4058c
# -----------------------
Packit a4058c
# Verify that TAGNAME is valid, and either flag an error and exit, or
Packit a4058c
# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
Packit a4058c
# variable here.
Packit a4058c
func_enable_tag ()
Packit a4058c
{
Packit a4058c
    # Global variable:
Packit a4058c
    tagname=$1
Packit a4058c
Packit a4058c
    re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
Packit a4058c
    re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
Packit a4058c
    sed_extractcf=/$re_begincf/,/$re_endcf/p
Packit a4058c
Packit a4058c
    # Validate tagname.
Packit a4058c
    case $tagname in
Packit a4058c
      *[!-_A-Za-z0-9,/]*)
Packit a4058c
        func_fatal_error "invalid tag name: $tagname"
Packit a4058c
        ;;
Packit a4058c
    esac
Packit a4058c
Packit a4058c
    # Don't test for the "default" C tag, as we know it's
Packit a4058c
    # there but not specially marked.
Packit a4058c
    case $tagname in
Packit a4058c
        CC) ;;
Packit a4058c
    *)
Packit a4058c
        if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
Packit a4058c
	  taglist="$taglist $tagname"
Packit a4058c
Packit a4058c
	  # Evaluate the configuration.  Be careful to quote the path
Packit a4058c
	  # and the sed script, to avoid splitting on whitespace, but
Packit a4058c
	  # also don't use non-portable quotes within backquotes within
Packit a4058c
	  # quotes we have to do it in 2 steps:
Packit a4058c
	  extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
Packit a4058c
	  eval "$extractedcf"
Packit a4058c
        else
Packit a4058c
	  func_error "ignoring unknown tag $tagname"
Packit a4058c
        fi
Packit a4058c
        ;;
Packit a4058c
    esac
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_check_version_match
Packit a4058c
# ------------------------
Packit a4058c
# Ensure that we are using m4 macros, and libtool script from the same
Packit a4058c
# release of libtool.
Packit a4058c
func_check_version_match ()
Packit a4058c
{
Packit a4058c
    if test "$package_revision" != "$macro_revision"; then
Packit a4058c
      if test "$VERSION" != "$macro_version"; then
Packit a4058c
        if test -z "$macro_version"; then
Packit a4058c
          cat >&2 <<_LT_EOF
Packit a4058c
$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
Packit a4058c
$progname: definition of this LT_INIT comes from an older release.
Packit a4058c
$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
Packit a4058c
$progname: and run autoconf again.
Packit a4058c
_LT_EOF
Packit a4058c
        else
Packit a4058c
          cat >&2 <<_LT_EOF
Packit a4058c
$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
Packit a4058c
$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
Packit a4058c
$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
Packit a4058c
$progname: and run autoconf again.
Packit a4058c
_LT_EOF
Packit a4058c
        fi
Packit a4058c
      else
Packit a4058c
        cat >&2 <<_LT_EOF
Packit a4058c
$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
Packit a4058c
$progname: but the definition of this LT_INIT comes from revision $macro_revision.
Packit a4058c
$progname: You should recreate aclocal.m4 with macros from revision $package_revision
Packit a4058c
$progname: of $PACKAGE $VERSION and run autoconf again.
Packit a4058c
_LT_EOF
Packit a4058c
      fi
Packit a4058c
Packit a4058c
      exit $EXIT_MISMATCH
Packit a4058c
    fi
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# libtool_options_prep [ARG]...
Packit a4058c
# -----------------------------
Packit a4058c
# Preparation for options parsed by libtool.
Packit a4058c
libtool_options_prep ()
Packit a4058c
{
Packit a4058c
    $debug_mode
Packit a4058c
Packit a4058c
    # Option defaults:
Packit a4058c
    opt_config=false
Packit a4058c
    opt_dlopen=
Packit a4058c
    opt_dry_run=false
Packit a4058c
    opt_help=false
Packit a4058c
    opt_mode=
Packit a4058c
    opt_preserve_dup_deps=false
Packit a4058c
    opt_quiet=false
Packit a4058c
Packit a4058c
    nonopt=
Packit a4058c
    preserve_args=
Packit a4058c
Packit a4058c
    # Shorthand for --mode=foo, only valid as the first argument
Packit a4058c
    case $1 in
Packit a4058c
    clean|clea|cle|cl)
Packit a4058c
      shift; set dummy --mode clean ${1+"$@"}; shift
Packit a4058c
      ;;
Packit a4058c
    compile|compil|compi|comp|com|co|c)
Packit a4058c
      shift; set dummy --mode compile ${1+"$@"}; shift
Packit a4058c
      ;;
Packit a4058c
    execute|execut|execu|exec|exe|ex|e)
Packit a4058c
      shift; set dummy --mode execute ${1+"$@"}; shift
Packit a4058c
      ;;
Packit a4058c
    finish|finis|fini|fin|fi|f)
Packit a4058c
      shift; set dummy --mode finish ${1+"$@"}; shift
Packit a4058c
      ;;
Packit a4058c
    install|instal|insta|inst|ins|in|i)
Packit a4058c
      shift; set dummy --mode install ${1+"$@"}; shift
Packit a4058c
      ;;
Packit a4058c
    link|lin|li|l)
Packit a4058c
      shift; set dummy --mode link ${1+"$@"}; shift
Packit a4058c
      ;;
Packit a4058c
    uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
Packit a4058c
      shift; set dummy --mode uninstall ${1+"$@"}; shift
Packit a4058c
      ;;
Packit a4058c
    esac
Packit a4058c
Packit a4058c
    # Pass back the list of options.
Packit a4058c
    func_quote_for_eval ${1+"$@"}
Packit a4058c
    libtool_options_prep_result=$func_quote_for_eval_result
Packit a4058c
}
Packit a4058c
func_add_hook func_options_prep libtool_options_prep
Packit a4058c
Packit a4058c
Packit a4058c
# libtool_parse_options [ARG]...
Packit a4058c
# ---------------------------------
Packit a4058c
# Provide handling for libtool specific options.
Packit a4058c
libtool_parse_options ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    # Perform our own loop to consume as many options as possible in
Packit a4058c
    # each iteration.
Packit a4058c
    while test $# -gt 0; do
Packit a4058c
      _G_opt=$1
Packit a4058c
      shift
Packit a4058c
      case $_G_opt in
Packit a4058c
        --dry-run|--dryrun|-n)
Packit a4058c
                        opt_dry_run=:
Packit a4058c
                        ;;
Packit a4058c
Packit a4058c
        --config)       func_config ;;
Packit a4058c
Packit a4058c
        --dlopen|-dlopen)
Packit a4058c
                        opt_dlopen="${opt_dlopen+$opt_dlopen
Packit a4058c
}$1"
Packit a4058c
                        shift
Packit a4058c
                        ;;
Packit a4058c
Packit a4058c
        --preserve-dup-deps)
Packit a4058c
                        opt_preserve_dup_deps=: ;;
Packit a4058c
Packit a4058c
        --features)     func_features ;;
Packit a4058c
Packit a4058c
        --finish)       set dummy --mode finish ${1+"$@"}; shift ;;
Packit a4058c
Packit a4058c
        --help)         opt_help=: ;;
Packit a4058c
Packit a4058c
        --help-all)     opt_help=': help-all' ;;
Packit a4058c
Packit a4058c
        --mode)         test $# = 0 && func_missing_arg $_G_opt && break
Packit a4058c
                        opt_mode=$1
Packit a4058c
                        case $1 in
Packit a4058c
                          # Valid mode arguments:
Packit a4058c
                          clean|compile|execute|finish|install|link|relink|uninstall) ;;
Packit a4058c
Packit a4058c
                          # Catch anything else as an error
Packit a4058c
                          *) func_error "invalid argument for $_G_opt"
Packit a4058c
                             exit_cmd=exit
Packit a4058c
                             break
Packit a4058c
                             ;;
Packit a4058c
                        esac
Packit a4058c
                        shift
Packit a4058c
                        ;;
Packit a4058c
Packit a4058c
        --no-silent|--no-quiet)
Packit a4058c
                        opt_quiet=false
Packit a4058c
                        func_append preserve_args " $_G_opt"
Packit a4058c
                        ;;
Packit a4058c
Packit a4058c
        --no-warnings|--no-warning|--no-warn)
Packit a4058c
                        opt_warning=false
Packit a4058c
                        func_append preserve_args " $_G_opt"
Packit a4058c
                        ;;
Packit a4058c
Packit a4058c
        --no-verbose)
Packit a4058c
                        opt_verbose=false
Packit a4058c
                        func_append preserve_args " $_G_opt"
Packit a4058c
                        ;;
Packit a4058c
Packit a4058c
        --silent|--quiet)
Packit a4058c
                        opt_quiet=:
Packit a4058c
                        opt_verbose=false
Packit a4058c
                        func_append preserve_args " $_G_opt"
Packit a4058c
                        ;;
Packit a4058c
Packit a4058c
        --tag)          test $# = 0 && func_missing_arg $_G_opt && break
Packit a4058c
                        opt_tag=$1
Packit a4058c
                        func_append preserve_args " $_G_opt $1"
Packit a4058c
                        func_enable_tag "$1"
Packit a4058c
                        shift
Packit a4058c
                        ;;
Packit a4058c
Packit a4058c
        --verbose|-v)   opt_quiet=false
Packit a4058c
                        opt_verbose=:
Packit a4058c
                        func_append preserve_args " $_G_opt"
Packit a4058c
                        ;;
Packit a4058c
Packit a4058c
	# An option not handled by this hook function:
Packit a4058c
        *)		set dummy "$_G_opt" ${1+"$@"};	shift; break  ;;
Packit a4058c
      esac
Packit a4058c
    done
Packit a4058c
Packit a4058c
Packit a4058c
    # save modified positional parameters for caller
Packit a4058c
    func_quote_for_eval ${1+"$@"}
Packit a4058c
    libtool_parse_options_result=$func_quote_for_eval_result
Packit a4058c
}
Packit a4058c
func_add_hook func_parse_options libtool_parse_options
Packit a4058c
Packit a4058c
Packit a4058c
Packit a4058c
# libtool_validate_options [ARG]...
Packit a4058c
# ---------------------------------
Packit a4058c
# Perform any sanity checks on option settings and/or unconsumed
Packit a4058c
# arguments.
Packit a4058c
libtool_validate_options ()
Packit a4058c
{
Packit a4058c
    # save first non-option argument
Packit a4058c
    if test 0 -lt $#; then
Packit a4058c
      nonopt=$1
Packit a4058c
      shift
Packit a4058c
    fi
Packit a4058c
Packit a4058c
    # preserve --debug
Packit a4058c
    test : = "$debug_cmd" || func_append preserve_args " --debug"
Packit a4058c
Packit a4058c
    case $host in
Packit a4058c
      # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
Packit a4058c
      # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
Packit a4058c
      *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
Packit a4058c
        # don't eliminate duplications in $postdeps and $predeps
Packit a4058c
        opt_duplicate_compiler_generated_deps=:
Packit a4058c
        ;;
Packit a4058c
      *)
Packit a4058c
        opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
Packit a4058c
        ;;
Packit a4058c
    esac
Packit a4058c
Packit a4058c
    $opt_help || {
Packit a4058c
      # Sanity checks first:
Packit a4058c
      func_check_version_match
Packit a4058c
Packit a4058c
      test yes != "$build_libtool_libs" \
Packit a4058c
        && test yes != "$build_old_libs" \
Packit a4058c
        && func_fatal_configuration "not configured to build any kind of library"
Packit a4058c
Packit a4058c
      # Darwin sucks
Packit a4058c
      eval std_shrext=\"$shrext_cmds\"
Packit a4058c
Packit a4058c
      # Only execute mode is allowed to have -dlopen flags.
Packit a4058c
      if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
Packit a4058c
        func_error "unrecognized option '-dlopen'"
Packit a4058c
        $ECHO "$help" 1>&2
Packit a4058c
        exit $EXIT_FAILURE
Packit a4058c
      fi
Packit a4058c
Packit a4058c
      # Change the help message to a mode-specific one.
Packit a4058c
      generic_help=$help
Packit a4058c
      help="Try '$progname --help --mode=$opt_mode' for more information."
Packit a4058c
    }
Packit a4058c
Packit a4058c
    # Pass back the unparsed argument list
Packit a4058c
    func_quote_for_eval ${1+"$@"}
Packit a4058c
    libtool_validate_options_result=$func_quote_for_eval_result
Packit a4058c
}
Packit a4058c
func_add_hook func_validate_options libtool_validate_options
Packit a4058c
Packit a4058c
Packit a4058c
# Process options as early as possible so that --help and --version
Packit a4058c
# can return quickly.
Packit a4058c
func_options ${1+"$@"}
Packit a4058c
eval set dummy "$func_options_result"; shift
Packit a4058c
Packit a4058c
Packit a4058c
Packit a4058c
## ----------- ##
Packit a4058c
##    Main.    ##
Packit a4058c
## ----------- ##
Packit a4058c
Packit a4058c
magic='%%%MAGIC variable%%%'
Packit a4058c
magic_exe='%%%MAGIC EXE variable%%%'
Packit a4058c
Packit a4058c
# Global variables.
Packit a4058c
extracted_archives=
Packit a4058c
extracted_serial=0
Packit a4058c
Packit a4058c
# If this variable is set in any of the actions, the command in it
Packit a4058c
# will be execed at the end.  This prevents here-documents from being
Packit a4058c
# left over by shells.
Packit a4058c
exec_cmd=
Packit a4058c
Packit a4058c
Packit a4058c
# A function that is used when there is no print builtin or printf.
Packit a4058c
func_fallback_echo ()
Packit a4058c
{
Packit a4058c
  eval 'cat <<_LTECHO_EOF
Packit a4058c
$1
Packit a4058c
_LTECHO_EOF'
Packit a4058c
}
Packit a4058c
Packit a4058c
# func_generated_by_libtool
Packit a4058c
# True iff stdin has been generated by Libtool. This function is only
Packit a4058c
# a basic sanity check; it will hardly flush out determined imposters.
Packit a4058c
func_generated_by_libtool_p ()
Packit a4058c
{
Packit a4058c
  $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
Packit a4058c
}
Packit a4058c
Packit a4058c
# func_lalib_p file
Packit a4058c
# True iff FILE is a libtool '.la' library or '.lo' object file.
Packit a4058c
# This function is only a basic sanity check; it will hardly flush out
Packit a4058c
# determined imposters.
Packit a4058c
func_lalib_p ()
Packit a4058c
{
Packit a4058c
    test -f "$1" &&
Packit a4058c
      $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
Packit a4058c
}
Packit a4058c
Packit a4058c
# func_lalib_unsafe_p file
Packit a4058c
# True iff FILE is a libtool '.la' library or '.lo' object file.
Packit a4058c
# This function implements the same check as func_lalib_p without
Packit a4058c
# resorting to external programs.  To this end, it redirects stdin and
Packit a4058c
# closes it afterwards, without saving the original file descriptor.
Packit a4058c
# As a safety measure, use it only where a negative result would be
Packit a4058c
# fatal anyway.  Works if 'file' does not exist.
Packit a4058c
func_lalib_unsafe_p ()
Packit a4058c
{
Packit a4058c
    lalib_p=no
Packit a4058c
    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
Packit a4058c
	for lalib_p_l in 1 2 3 4
Packit a4058c
	do
Packit a4058c
	    read lalib_p_line
Packit a4058c
	    case $lalib_p_line in
Packit a4058c
		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
Packit a4058c
	    esac
Packit a4058c
	done
Packit a4058c
	exec 0<&5 5<&-
Packit a4058c
    fi
Packit a4058c
    test yes = "$lalib_p"
Packit a4058c
}
Packit a4058c
Packit a4058c
# func_ltwrapper_script_p file
Packit a4058c
# True iff FILE is a libtool wrapper script
Packit a4058c
# This function is only a basic sanity check; it will hardly flush out
Packit a4058c
# determined imposters.
Packit a4058c
func_ltwrapper_script_p ()
Packit a4058c
{
Packit a4058c
    test -f "$1" &&
Packit a4058c
      $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
Packit a4058c
}
Packit a4058c
Packit a4058c
# func_ltwrapper_executable_p file
Packit a4058c
# True iff FILE is a libtool wrapper executable
Packit a4058c
# This function is only a basic sanity check; it will hardly flush out
Packit a4058c
# determined imposters.
Packit a4058c
func_ltwrapper_executable_p ()
Packit a4058c
{
Packit a4058c
    func_ltwrapper_exec_suffix=
Packit a4058c
    case $1 in
Packit a4058c
    *.exe) ;;
Packit a4058c
    *) func_ltwrapper_exec_suffix=.exe ;;
Packit a4058c
    esac
Packit a4058c
    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
Packit a4058c
}
Packit a4058c
Packit a4058c
# func_ltwrapper_scriptname file
Packit a4058c
# Assumes file is an ltwrapper_executable
Packit a4058c
# uses $file to determine the appropriate filename for a
Packit a4058c
# temporary ltwrapper_script.
Packit a4058c
func_ltwrapper_scriptname ()
Packit a4058c
{
Packit a4058c
    func_dirname_and_basename "$1" "" "."
Packit a4058c
    func_stripname '' '.exe' "$func_basename_result"
Packit a4058c
    func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
Packit a4058c
}
Packit a4058c
Packit a4058c
# func_ltwrapper_p file
Packit a4058c
# True iff FILE is a libtool wrapper script or wrapper executable
Packit a4058c
# This function is only a basic sanity check; it will hardly flush out
Packit a4058c
# determined imposters.
Packit a4058c
func_ltwrapper_p ()
Packit a4058c
{
Packit a4058c
    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_execute_cmds commands fail_cmd
Packit a4058c
# Execute tilde-delimited COMMANDS.
Packit a4058c
# If FAIL_CMD is given, eval that upon failure.
Packit a4058c
# FAIL_CMD may read-access the current command in variable CMD!
Packit a4058c
func_execute_cmds ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    save_ifs=$IFS; IFS='~'
Packit a4058c
    for cmd in $1; do
Packit a4058c
      IFS=$sp$nl
Packit a4058c
      eval cmd=\"$cmd\"
Packit a4058c
      IFS=$save_ifs
Packit a4058c
      func_show_eval "$cmd" "${2-:}"
Packit a4058c
    done
Packit a4058c
    IFS=$save_ifs
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_source file
Packit a4058c
# Source FILE, adding directory component if necessary.
Packit a4058c
# Note that it is not necessary on cygwin/mingw to append a dot to
Packit a4058c
# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
Packit a4058c
# behavior happens only for exec(3), not for open(2)!  Also, sourcing
Packit a4058c
# 'FILE.' does not work on cygwin managed mounts.
Packit a4058c
func_source ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    case $1 in
Packit a4058c
    */* | *\\*)	. "$1" ;;
Packit a4058c
    *)		. "./$1" ;;
Packit a4058c
    esac
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_resolve_sysroot PATH
Packit a4058c
# Replace a leading = in PATH with a sysroot.  Store the result into
Packit a4058c
# func_resolve_sysroot_result
Packit a4058c
func_resolve_sysroot ()
Packit a4058c
{
Packit a4058c
  func_resolve_sysroot_result=$1
Packit a4058c
  case $func_resolve_sysroot_result in
Packit a4058c
  =*)
Packit a4058c
    func_stripname '=' '' "$func_resolve_sysroot_result"
Packit a4058c
    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
Packit a4058c
    ;;
Packit a4058c
  esac
Packit a4058c
}
Packit a4058c
Packit a4058c
# func_replace_sysroot PATH
Packit a4058c
# If PATH begins with the sysroot, replace it with = and
Packit a4058c
# store the result into func_replace_sysroot_result.
Packit a4058c
func_replace_sysroot ()
Packit a4058c
{
Packit a4058c
  case $lt_sysroot:$1 in
Packit a4058c
  ?*:"$lt_sysroot"*)
Packit a4058c
    func_stripname "$lt_sysroot" '' "$1"
Packit a4058c
    func_replace_sysroot_result='='$func_stripname_result
Packit a4058c
    ;;
Packit a4058c
  *)
Packit a4058c
    # Including no sysroot.
Packit a4058c
    func_replace_sysroot_result=$1
Packit a4058c
    ;;
Packit a4058c
  esac
Packit a4058c
}
Packit a4058c
Packit a4058c
# func_infer_tag arg
Packit a4058c
# Infer tagged configuration to use if any are available and
Packit a4058c
# if one wasn't chosen via the "--tag" command line option.
Packit a4058c
# Only attempt this if the compiler in the base compile
Packit a4058c
# command doesn't match the default compiler.
Packit a4058c
# arg is usually of the form 'gcc ...'
Packit a4058c
func_infer_tag ()
Packit a4058c
{
Packit a4058c
    $debug_cmd
Packit a4058c
Packit a4058c
    if test -n "$available_tags" && test -z "$tagname"; then
Packit a4058c
      CC_quoted=
Packit a4058c
      for arg in $CC; do
Packit a4058c
	func_append_quoted CC_quoted "$arg"
Packit a4058c
      done
Packit a4058c
      CC_expanded=`func_echo_all $CC`
Packit a4058c
      CC_quoted_expanded=`func_echo_all $CC_quoted`
Packit a4058c
      case $@ in
Packit a4058c
      # Blanks in the command may have been stripped by the calling shell,
Packit a4058c
      # but not from the CC environment variable when configure was run.
Packit a4058c
      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
Packit a4058c
      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
Packit a4058c
      # Blanks at the start of $base_compile will cause this to fail
Packit a4058c
      # if we don't check for them as well.
Packit a4058c
      *)
Packit a4058c
	for z in $available_tags; do
Packit a4058c
	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
Packit a4058c
	    # Evaluate the configuration.
Packit a4058c
	    eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
Packit a4058c
	    CC_quoted=
Packit a4058c
	    for arg in $CC; do
Packit a4058c
	      # Double-quote args containing other shell metacharacters.
Packit a4058c
	      func_append_quoted CC_quoted "$arg"
Packit a4058c
	    done
Packit a4058c
	    CC_expanded=`func_echo_all $CC`
Packit a4058c
	    CC_quoted_expanded=`func_echo_all $CC_quoted`
Packit a4058c
	    case "$@ " in
Packit a4058c
	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
Packit a4058c
	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
Packit a4058c
	      # The compiler in the base compile command matches
Packit a4058c
	      # the one in the tagged configuration.
Packit a4058c
	      # Assume this is the tagged configuration we want.
Packit a4058c
	      tagname=$z
Packit a4058c
	      break
Packit a4058c
	      ;;
Packit a4058c
	    esac
Packit a4058c
	  fi
Packit a4058c
	done
Packit a4058c
	# If $tagname still isn't set, then no tagged configuration
Packit a4058c
	# was found and let the user know that the "--tag" command
Packit a4058c
	# line option must be used.
Packit a4058c
	if test -z "$tagname"; then
Packit a4058c
	  func_echo "unable to infer tagged configuration"
Packit a4058c
	  func_fatal_error "specify a tag with '--tag'"
Packit a4058c
#	else
Packit a4058c
#	  func_verbose "using $tagname tagged configuration"
Packit a4058c
	fi
Packit a4058c
	;;
Packit a4058c
      esac
Packit a4058c
    fi
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
Packit a4058c
# func_write_libtool_object output_name pic_name nonpic_name
Packit a4058c
# Create a libtool object file (analogous to a ".la" file),
Packit a4058c
# but don't create it if we're doing a dry run.
Packit a4058c
func_write_libtool_object ()
Packit a4058c
{
Packit a4058c
    write_libobj=$1
Packit a4058c
    if test yes = "$build_libtool_libs"; then
Packit a4058c
      write_lobj=\'$2\'
Packit a4058c
    else
Packit a4058c
      write_lobj=none
Packit a4058c
    fi
Packit a4058c
Packit a4058c
    if test yes = "$build_old_libs"; then
Packit a4058c
      write_oldobj=\'$3\'
Packit a4058c
    else
Packit a4058c
      write_oldobj=none
Packit a4058c
    fi
Packit a4058c
Packit a4058c
    $opt_dry_run || {
Packit a4058c
      cat >${write_libobj}T <
Packit a4058c
# $write_libobj - a libtool object file
Packit a4058c
# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
Packit a4058c
#
Packit a4058c
# Please DO NOT delete this file!
Packit a4058c
# It is necessary for linking the library.
Packit a4058c
Packit a4058c
# Name of the PIC object.
Packit a4058c
pic_object=$write_lobj
Packit a4058c
Packit a4058c
# Name of the non-PIC object
Packit a4058c
non_pic_object=$write_oldobj
Packit a4058c
Packit a4058c
EOF
Packit a4058c
      $MV "${write_libobj}T" "$write_libobj"
Packit a4058c
    }
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
##################################################
Packit a4058c
# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
Packit a4058c
##################################################
Packit a4058c
Packit a4058c
# func_convert_core_file_wine_to_w32 ARG
Packit a4058c
# Helper function used by file name conversion functions when $build is *nix,
Packit a4058c
# and $host is mingw, cygwin, or some other w32 environment. Relies on a
Packit a4058c
# correctly configured wine environment available, with the winepath program
Packit a4058c
# in $build's $PATH.
Packit a4058c
#
Packit a4058c
# ARG is the $build file name to be converted to w32 format.
Packit a4058c
# Result is available in $func_convert_core_file_wine_to_w32_result, and will
Packit a4058c
# be empty on error (or when ARG is empty)
Packit a4058c
func_convert_core_file_wine_to_w32 ()
Packit a4058c
{
Packit a4058c
  $debug_cmd
Packit a4058c
Packit a4058c
  func_convert_core_file_wine_to_w32_result=$1
Packit a4058c
  if test -n "$1"; then
Packit a4058c
    # Unfortunately, winepath does not exit with a non-zero error code, so we
Packit a4058c
    # are forced to check the contents of stdout. On the other hand, if the
Packit a4058c
    # command is not found, the shell will set an exit code of 127 and print
Packit a4058c
    # *an error message* to stdout. So we must check for both error code of
Packit a4058c
    # zero AND non-empty stdout, which explains the odd construction:
Packit a4058c
    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
Packit a4058c
    if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
Packit a4058c
      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
Packit a4058c
        $SED -e "$sed_naive_backslashify"`
Packit a4058c
    else
Packit a4058c
      func_convert_core_file_wine_to_w32_result=
Packit a4058c
    fi
Packit a4058c
  fi
Packit a4058c
}
Packit a4058c
# end: func_convert_core_file_wine_to_w32
Packit a4058c
Packit a4058c
Packit a4058c
# func_convert_core_path_wine_to_w32 ARG
Packit a4058c
# Helper function used by path conversion functions when $build is *nix, and
Packit a4058c
# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
Packit a4058c
# configured wine environment available, with the winepath program in $build's
Packit a4058c
# $PATH. Assumes ARG has no leading or trailing path separator characters.
Packit a4058c
#
Packit a4058c
# ARG is path to be converted from $build format to win32.
Packit a4058c
# Result is available in $func_convert_core_path_wine_to_w32_result.
Packit a4058c
# Unconvertible file (directory) names in ARG are skipped; if no directory names
Packit a4058c
# are convertible, then the result may be empty.
Packit a4058c
func_convert_core_path_wine_to_w32 ()
Packit a4058c
{
Packit a4058c
  $debug_cmd
Packit a4058c
Packit a4058c
  # unfortunately, winepath doesn't convert paths, only file names
Packit a4058c
  func_convert_core_path_wine_to_w32_result=
Packit a4058c
  if test -n "$1"; then
Packit a4058c
    oldIFS=$IFS
Packit a4058c
    IFS=:
Packit a4058c
    for func_convert_core_path_wine_to_w32_f in $1; do
Packit a4058c
      IFS=$oldIFS
Packit a4058c
      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
Packit a4058c
      if test -n "$func_convert_core_file_wine_to_w32_result"; then
Packit a4058c
        if test -z "$func_convert_core_path_wine_to_w32_result"; then
Packit a4058c
          func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
Packit a4058c
        else
Packit a4058c
          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
Packit a4058c
        fi
Packit a4058c
      fi
Packit a4058c
    done
Packit a4058c
    IFS=$oldIFS
Packit a4058c
  fi
Packit a4058c
}
Packit a4058c
# end: func_convert_core_path_wine_to_w32
Packit a4058c
Packit a4058c
Packit a4058c
# func_cygpath ARGS...
Packit a4058c
# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
Packit a4058c
# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
Packit a4058c
# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
Packit a4058c
# (2), returns the Cygwin file name or path in func_cygpath_result (input
Packit a4058c
# file name or path is assumed to be in w32 format, as previously converted
Packit a4058c
# from $build's *nix or MSYS format). In case (3), returns the w32 file name
Packit a4058c
# or path in func_cygpath_result (input file name or path is assumed to be in
Packit a4058c
# Cygwin format). Returns an empty string on error.
Packit a4058c
#
Packit a4058c
# ARGS are passed to cygpath, with the last one being the file name or path to
Packit a4058c
# be converted.
Packit a4058c
#
Packit a4058c
# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
Packit a4058c
# environment variable; do not put it in $PATH.
Packit a4058c
func_cygpath ()
Packit a4058c
{
Packit a4058c
  $debug_cmd
Packit a4058c
Packit a4058c
  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
Packit a4058c
    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
Packit a4058c
    if test "$?" -ne 0; then
Packit a4058c
      # on failure, ensure result is empty
Packit a4058c
      func_cygpath_result=
Packit a4058c
    fi
Packit a4058c
  else
Packit a4058c
    func_cygpath_result=
Packit a4058c
    func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
Packit a4058c
  fi
Packit a4058c
}
Packit a4058c
#end: func_cygpath
Packit a4058c
Packit a4058c
Packit a4058c
# func_convert_core_msys_to_w32 ARG
Packit a4058c
# Convert file name or path ARG from MSYS format to w32 format.  Return
Packit a4058c
# result in func_convert_core_msys_to_w32_result.
Packit a4058c
func_convert_core_msys_to_w32 ()
Packit a4058c
{
Packit a4058c
  $debug_cmd
Packit a4058c
Packit a4058c
  # awkward: cmd appends spaces to result
Packit a4058c
  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
Packit a4058c
    $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
Packit a4058c
}
Packit a4058c
#end: func_convert_core_msys_to_w32
Packit a4058c
Packit a4058c
Packit a4058c
# func_convert_file_check ARG1 ARG2
Packit a4058c
# Verify that ARG1 (a file name in $build format) was converted to $host
Packit a4058c
# format in ARG2. Otherwise, emit an error message, but continue (resetting
Packit a4058c
# func_to_host_file_result to ARG1).
Packit a4058c
func_convert_file_check ()
Packit a4058c
{
Packit a4058c
  $debug_cmd
Packit a4058c
Packit a4058c
  if test -z "$2" && test -n "$1"; then
Packit a4058c
    func_error "Could not determine host file name corresponding to"
Packit a4058c
    func_error "  '$1'"
Packit a4058c
    func_error "Continuing, but uninstalled executables may not work."
Packit a4058c
    # Fallback:
Packit a4058c
    func_to_host_file_result=$1
Packit a4058c
  fi
Packit a4058c
}
Packit a4058c
# end func_convert_file_check
Packit a4058c
Packit a4058c
Packit a4058c
# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
Packit a4058c
# Verify that FROM_PATH (a path in $build format) was converted to $host
Packit a4058c
# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
Packit a4058c
# func_to_host_file_result to a simplistic fallback value (see below).
Packit a4058c
func_convert_path_check ()
Packit a4058c
{
Packit a4058c
  $debug_cmd
Packit a4058c
Packit a4058c
  if test -z "$4" && test -n "$3"; then
Packit a4058c
    func_error "Could not determine the host path corresponding to"
Packit a4058c
    func_error "  '$3'"
Packit a4058c
    func_error "Continuing, but uninstalled executables may not work."
Packit a4058c
    # Fallback.  This is a deliberately simplistic "conversion" and
Packit a4058c
    # should not be "improved".  See libtool.info.
Packit a4058c
    if test "x$1" != "x$2"; then
Packit a4058c
      lt_replace_pathsep_chars="s|$1|$2|g"
Packit a4058c
      func_to_host_path_result=`echo "$3" |
Packit a4058c
        $SED -e "$lt_replace_pathsep_chars"`
Packit a4058c
    else
Packit a4058c
      func_to_host_path_result=$3
Packit a4058c
    fi
Packit a4058c
  fi
Packit a4058c
}
Packit a4058c
# end func_convert_path_check
Packit a4058c
Packit a4058c
Packit a4058c
# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
Packit a4058c
# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
Packit a4058c
# and appending REPL if ORIG matches BACKPAT.
Packit a4058c
func_convert_path_front_back_pathsep ()
Packit a4058c
{
Packit a4058c
  $debug_cmd
Packit a4058c
Packit a4058c
  case $4 in
Packit a4058c
  $1 ) func_to_host_path_result=$3$func_to_host_path_result
Packit a4058c
    ;;
Packit a4058c
  esac
Packit a4058c
  case $4 in
Packit a4058c
  $2 ) func_append func_to_host_path_result "$3"
Packit a4058c
    ;;
Packit a4058c
  esac
Packit a4058c
}
Packit a4058c
# end func_convert_path_front_back_pathsep
Packit a4058c
Packit a4058c
Packit a4058c
##################################################
Packit a4058c
# $build to $host FILE NAME CONVERSION FUNCTIONS #
Packit a4058c
##################################################
Packit a4058c
# invoked via '$to_host_file_cmd ARG'
Packit a4058c
#
Packit a4058c
# In each case, ARG is the path to be converted from $build to $host format.
Packit a4058c
# Result will be available in $func_to_host_file_result.
Packit a4058c
Packit a4058c
Packit a4058c
# func_to_host_file ARG
Packit a4058c
# Converts the file name ARG from $build format to $host format. Return result
Packit a4058c
# in func_to_host_file_result.
Packit a4058c
func_to_host_file ()
Packit a4058c
{
Packit a4058c
  $debug_cmd
Packit a4058c
Packit a4058c
  $to_host_file_cmd "$1"
Packit a4058c
}
Packit a4058c
# end func_to_host_file
Packit a4058c
Packit a4058c
Packit a4058c
# func_to_tool_file ARG LAZY
Packit a4058c
# converts the file name ARG from $build format to toolchain format. Return
Packit a4058c
# result in func_to_tool_file_result.  If the conversion in use is listed
Packit a4058c
# in (the comma separated) LAZY, no conversion takes place.
Packit a4058c
func_to_tool_file ()
Packit a4058c
{
Packit a4058c
  $debug_cmd
Packit a4058c
Packit a4058c
  case ,$2, in
Packit a4058c
    *,"$to_tool_file_cmd",*)
Packit a4058c
      func_to_tool_file_result=$1
Packit a4058c
      ;;
Packit a4058c
    *)
Packit a4058c
      $to_tool_file_cmd "$1"
Packit a4058c
      func_to_tool_file_result=$func_to_host_file_result
Packit a4058c
      ;;
Packit a4058c
  esac
Packit a4058c
}
Packit a4058c
# end func_to_tool_file
Packit a4058c
Packit a4058c
Packit a4058c
# func_convert_file_noop ARG
Packit a4058c
# Copy ARG to func_to_host_file_result.
Packit a4058c
func_convert_file_noop ()
Packit a4058c
{
Packit a4058c
  func_to_host_file_result=$1
Packit a4058c
}
Packit a4058c
# end func_convert_file_noop
Packit a4058c
Packit a4058c
Packit a4058c
# func_convert_file_msys_to_w32 ARG
Packit a4058c
# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
Packit a4058c
# conversion to w32 is not available inside the cwrapper.  Returns result in
Packit a4058c
# func_to_host_file_result.
Packit a4058c
func_convert_file_msys_to_w32 ()
Packit a4058c
{
Packit a4058c
  $debug_cmd
Packit a4058c
Packit a4058c
  func_to_host_file_result=$1
Packit a4058c
  if test -n "$1"; then
Packit a4058c
    func_convert_core_msys_to_w32 "$1"
Packit a4058c
    func_to_host_file_result=$func_convert_core_msys_to_w32_result
Packit a4058c
  fi
Packit a4058c
  func_convert_file_check "$1" "$func_to_host_file_result"
Packit a4058c
}
Packit a4058c
# end func_convert_file_msys_to_w32
Packit a4058c
Packit a4058c
Packit a4058c
# func_convert_file_cygwin_to_w32 ARG
Packit a4058c
# Convert file name ARG from Cygwin to w32 format.  Returns result in
Packit a4058c
# func_to_host_file_result.
Packit a4058c
func_convert_file_cygwin_to_w32 ()
Packit a4058c
{
Packit a4058c
  $debug_cmd
Packit a4058c
Packit a4058c
  func_to_host_file_result=$1
Packit a4058c
  if test -n "$1"; then
Packit a4058c
    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
Packit a4058c
    # LT_CYGPATH in this case.
Packit a4058c
    func_to_host_file_result=`cygpath -m "$1"`
Packit a4058c
  fi
Packit a4058c
  func_convert_file_check "$1" "$func_to_host_file_result"
Packit a4058c
}
Packit a4058c
# end func_convert_file_cygwin_to_w32
Packit a4058c
Packit a4058c
Packit a4058c
# func_convert_file_nix_to_w32 ARG
Packit a4058c
# Convert file name ARG from *nix to w32 format.  Requires a wine environment
Packit a4058c
# and a working winepath. Returns result in func_to_host_file_result.
Packit a4058c
func_convert_file_nix_to_w32 ()
Packit a4058c
{
Packit a4058c
  $debug_cmd
Packit a4058c
Packit a4058c
  func_to_host_file_result=$1
Packit a4058c
  if test -n "$1"; then
Packit a4058c
    func_convert_core_file_wine_to_w32 "$1"
Packit a4058c
    func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
Packit a4058c
  fi
Packit a4058c
  func_convert_file_check "$1" "$func_to_host_file_result"
Packit a4058c
}
Packit a4058c
# end func_convert_file_nix_to_w32
Packit a4058c
Packit a4058c
Packit a4058c
# func_convert_file_msys_to_cygwin ARG
Packit a4058c
# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
Packit a4058c
# Returns result in func_to_host_file_result.
Packit a4058c
func_convert_file_msys_to_cygwin ()
Packit a4058c
{
Packit a4058c
  $debug_cmd
Packit a4058c
Packit a4058c
  func_to_host_file_result=$1
Packit a4058c
  if test -n "$1"; then
Packit a4058c
    func_convert_core_msys_to_w32 "$1"
Packit a4058c
    func_cygpath -u "$func_convert_core_msys_to_w32_result"
Packit a4058c
    func_to_host_file_result=$func_cygpath_result
Packit a4058c
  fi
Packit a4058c
  func_convert_file_check "$1" "$func_to_host_file_result"
Packit a4058c
}
Packit a4058c
# end func_convert_file_msys_to_cygwin
Packit a4058c
Packit a4058c
Packit a4058c
# func_convert_file_nix_to_cygwin ARG
Packit a4058c
# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
Packit a4058c
# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
Packit a4058c
# in func_to_host_file_result.
Packit a4058c
func_convert_file_nix_to_cygwin ()
Packit a4058c
{
Packit a4058c
  $debug_cmd
Packit a4058c
Packit a4058c
  func_to_host_file_result=$1
Packit a4058c
  if test -n "$1"; then
Packit a4058c
    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
Packit a4058c
    func_convert_core_file_wine_to_w32 "$1"
Packit a4058c
    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
Packit a4058c
    func_to_host_file_result=$func_cygpath_result
Packit a4058c
  fi
Packit a4058c
  func_convert_file_check "$1" "$func_to_host_file_result"
Packit a4058c
}
Packit a4058c
# end func_convert_file_nix_to_cygwin
Packit a4058c
Packit a4058c
Packit a4058c
#############################################
Packit a4058c
# $build to $host PATH CONVERSION FUNCTIONS #
Packit a4058c
#############################################
Packit a4058c
# invoked via '$to_host_path_cmd ARG'
Packit a4058c
#
Packit a4058c
# In each case, ARG is the path to be converted from $build to $host format.
Packit a4058c
# The result will be available in $func_to_host_path_result.
Packit a4058c
#
Packit a4058c
# Path separators are also converted from $build format to $host format.  If
Packit a4058c
# ARG begins or ends with a path separator character, it is preserved (but
Packit a4058c
# converted to $host format) on output.
Packit a4058c
#
Packit a4058c
# All path conversion functions are named using the following convention:
Packit a4058c
#   file name conversion function    : func_convert_file_X_to_Y ()
Packit a4058c
#   path conversion function         : func_convert_path_X_to_Y ()
Packit a4058c
# where, for any given $build/$host combination the 'X_to_Y' value is the
Packit a4058c
# same.  If conversion functions are added for new $build/$host combinations,
Packit a4058c
# the two new functions must follow this pattern, or func_init_to_host_path_cmd
Packit a4058c
# will break.
Packit a4058c
Packit a4058c
Packit a4058c
# func_init_to_host_path_cmd
Packit a4058c
# Ensures that function "pointer" variable $to_host_path_cmd is set to the
Packit a4058c
# appropriate value, based on the value of $to_host_file_cmd.
Packit a4058c
to_host_path_cmd=
Packit a4058c
func_init_to_host_path_cmd ()
Packit a4058c
{
Packit a4058c
  $debug_cmd
Packit a4058c
Packit a4058c
  if test -z "$to_host_path_cmd"; then
Packit a4058c
    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
Packit a4058c
    to_host_path_cmd=func_convert_path_$func_stripname_result
Packit a4058c
  fi
Packit a4058c
}
Packit a4058c
Packit a4058c
Packit a4058c
# func_to_host_path ARG
Packit a4058c
# Converts the path ARG from $build format to $host format. Return result
Packit a4058c
# in func_to_host_path_result.
Packit a4058c
func_to_host_path ()
Packit a4058c
{
Packit a4058c
  $debug_cmd
Packit a4058c
Packit a4058c
  func_init_to_host_path_cmd
Packit a4058c
  $to_host_path_cmd "$1"
Packit a4058c
}
Packit a4058c
# end func_to_host_path
Packit a4058c
Packit a4058c
Packit a4058c
# func_convert_path_noop ARG
Packit a4058c
# Copy ARG to func_to_host_path_result.
Packit a4058c
func_convert_path_noop ()
Packit a4058c
{
Packit a4058c
  func_to_host_path_result=$1
Packit a4058c
}
Packit a4058c
# end func_convert_path_noop
Packit a4058c
Packit a4058c
Packit a4058c
# func_convert_path_msys_to_w32 ARG
Packit a4058c
# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
Packit a4058c
# conversion to w32 is not available inside the cwrapper.  Returns result in
Packit a4058c
# func_to_host_path_result.
Packit a4058c
func_convert_path_msys_to_w32 ()
Packit a4058c
{
Packit a4058c
  $debug_cmd
Packit a4058c
Packit a4058c
  func_to_host_path_result=$1
Packit a4058c
  if test -n "$1"; then
Packit a4058c
    # Remove leading and trailing path separator characters from ARG.  MSYS
Packit a4058c
    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
Packit a4058c
    # and winepath ignores them completely.
Packit a4058c
    func_stripname : : "$1"
Packit a4058c
    func_to_host_path_tmp1=$func_stripname_result
Packit a4058c
    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
Packit a4058c
    func_to_host_path_result=$func_convert_core_msys_to_w32_result
Packit a4058c
    func_convert_path_check : ";" \
Packit a4058c
      "$func_to_host_path_tmp1" "$func_to_host_path_result"
Packit a4058c
    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
Packit a4058c
  fi
Packit a4058c
}
Packit a4058c
# end func_convert_path_msys_to_w32
Packit a4058c
Packit a4058c
Packit a4058c
# func_convert_path_cygwin_to_w32 ARG
Packit a4058c
# Convert path ARG from Cygwin to w32 format.  Returns result in
Packit a4058c
# func_to_host_file_result.
Packit a4058c
func_convert_path_cygwin_to_w32 ()
Packit a4058c
{
Packit a4058c
  $debug_cmd
Packit a4058c
Packit a4058c
  func_to_host_path_result=$1
Packit a4058c
  if test -n "$1"; then
Packit a4058c
    # See func_convert_path_msys_to_w32:
Packit a4058c
    func_stripname : : "$1"
Packit a4058c
    func_to_host_path_tmp1=$func_stripname_result
Packit a4058c
    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
Packit a4058c
    func_convert_path_check : ";" \
Packit a4058c
      "$func_to_host_path_tmp1" "$func_to_host_path_result"
Packit a4058c
    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
Packit a4058c
  fi
Packit a4058c
}
Packit a4058c
# end func_convert_path_cygwin_to_w32
Packit a4058c
Packit a4058c
Packit a4058c
# func_convert_path_nix_to_w32 ARG
Packit a4058c
# Convert path ARG from *nix to w32 format.  Requires a wine environment and
Packit a4058c
# a working winepath.  Returns result in func_to_host_file_result.
Packit a4058c
func_convert_path_nix_to_w32 ()
Packit a4058c
{
Packit a4058c
  $debug_cmd
Packit a4058c
Packit a4058c
  func_to_host_path_result=$1
Packit a4058c
  if test -n "$1"; then
Packit a4058c
    # See func_convert_path_msys_to_w32:
Packit a4058c
    func_stripname : : "$1"
Packit a4058c
    func_to_host_path_tmp1=$func_stripname_result
Packit a4058c
    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
Packit a4058c
    func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
Packit a4058c
    func_convert_path_check : ";" \
Packit a4058c
      "$func_to_host_path_tmp1" "$func_to_host_path_result"
Packit a4058c
    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
Packit a4058c
  fi
Packit a4058c
}
Packit a4058c
# end func_convert_path_nix_to_w32
Packit a4058c
Packit a4058c
Packit a4058c
# func_convert_path_msys_to_cygwin ARG
Packit a4058c
# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
Packit a4058c
# Returns result in func_to_host_file_result.
Packit a4058c
func_convert_path_msys_to_cygwin ()
Packit a4058c
{
Packit a4058c
  $debug_cmd
Packit a4058c
Packit a4058c
  func_to_host_path_result=$1
Packit a4058c
  if test -n "$1"; then
Packit a4058c
    # See func_convert_path_msys_to_w32:
Packit a4058c
    func_stripname : : "$1"
Packit a4058c
    func_to_host_path_tmp1=$func_stripname_result
Packit a4058c
    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
Packit a4058c
    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
Packit a4058c
    func_to_host_path_result=$func_cygpath_result
Packit a4058c
    func_convert_path_check : : \
Packit a4058c
      "$func_to_host_path_tmp1" "$func_to_host_path_result"
Packit a4058c
    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
Packit a4058c
  fi
Packit a4058c
}
Packit a4058c
# end func_convert_path_msys_to_cygwin
Packit a4058c
Packit a4058c
Packit a4058c
# func_convert_path_nix_to_cygwin ARG
Packit a4058c
# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
Packit a4058c
# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
Packit a4058c
# func_to_host_file_result.
Packit a4058c
func_convert_path_nix_to_cygwin ()
Packit a4058c
{
Packit a4058c
  $debug_cmd
Packit a4058c
Packit a4058c
  func_to_host_path_result=$1
Packit a4058c
  if test -n "$1"; then
Packit a4058c
    # Remove leading and trailing path separator characters from
Packit a4058c
    # ARG. msys behavior is inconsistent here, cygpath turns them
Packit a4058c
    # into '.;' and ';.', and winepath ignores them completely.
Packit a4058c
    func_stripname : : "$1"
Packit a4058c
    func_to_host_path_tmp1=$func_stripname_result
Packit a4058c
    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
Packit a4058c
    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
Packit a4058c
    func_to_host_path_result=$func_cygpath_result
Packit a4058c
    func_convert_path_check : : \
Packit a4058c
      "$func_to_host_path_tmp1" "$func_to_host_path_result"
Packit a4058c
    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
Packit a4058c
  fi
Packit a4058c
}
Packit a4058c
# end func_convert_path_nix_to_cygwin
Packit a4058c
Packit a4058c
Packit a4058c
# func_dll_def_p FILE
Packit a4058c
# True iff FILE is a Windows DLL '.def' file.
Packit a4058c
# Keep in sync with _LT_DLL_DEF_P in libtool.m4
Packit a4058c
func_dll_def_p ()
Packit a4058c
{
Packit a4058c
  $debug_cmd
Packit a4058c
Packit a4058c
  func_dll_def_p_tmp=`$SED -n \
Packit a4058c
    -e 's/^[	 ]*//' \
Packit a4058c
    -e '/^\(;.*\)*$/d' \
Packit a4058c
    -e 's/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p' \
Packit a4058c
    -e q \