"Fossies" - the Fresh Open Source Software Archive

Member "libextractor-1.11/ltmain.sh" (12 Jul 2018, 330179 Bytes) of package /linux/privat/libextractor-1.11.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "ltmain.sh": 1.6_vs_1.7.

    1 #! /bin/sh
    2 ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
    3 ##               by inline-source v2014-01-03.01
    4 
    5 # libtool (GNU libtool) 2.4.6
    6 # Provide generalized library-building support services.
    7 # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
    8 
    9 # Copyright (C) 1996-2015 Free Software Foundation, Inc.
   10 # This is free software; see the source for copying conditions.  There is NO
   11 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   12 
   13 # GNU Libtool is free software; you can redistribute it and/or modify
   14 # it under the terms of the GNU General Public License as published by
   15 # the Free Software Foundation; either version 2 of the License, or
   16 # (at your option) any later version.
   17 #
   18 # As a special exception to the GNU General Public License,
   19 # if you distribute this file as part of a program or library that
   20 # is built using GNU Libtool, you may include this file under the
   21 # same distribution terms that you use for the rest of that program.
   22 #
   23 # GNU Libtool is distributed in the hope that it will be useful, but
   24 # WITHOUT ANY WARRANTY; without even the implied warranty of
   25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   26 # General Public License for more details.
   27 #
   28 # You should have received a copy of the GNU General Public License
   29 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
   30 
   31 
   32 PROGRAM=libtool
   33 PACKAGE=libtool
   34 VERSION="2.4.6 Debian-2.4.6-2.1"
   35 package_revision=2.4.6
   36 
   37 
   38 ## ------ ##
   39 ## Usage. ##
   40 ## ------ ##
   41 
   42 # Run './libtool --help' for help with using this script from the
   43 # command line.
   44 
   45 
   46 ## ------------------------------- ##
   47 ## User overridable command paths. ##
   48 ## ------------------------------- ##
   49 
   50 # After configure completes, it has a better idea of some of the
   51 # shell tools we need than the defaults used by the functions shared
   52 # with bootstrap, so set those here where they can still be over-
   53 # ridden by the user, but otherwise take precedence.
   54 
   55 : ${AUTOCONF="autoconf"}
   56 : ${AUTOMAKE="automake"}
   57 
   58 
   59 ## -------------------------- ##
   60 ## Source external libraries. ##
   61 ## -------------------------- ##
   62 
   63 # Much of our low-level functionality needs to be sourced from external
   64 # libraries, which are installed to $pkgauxdir.
   65 
   66 # Set a version string for this script.
   67 scriptversion=2015-10-12.13; # UTC
   68 
   69 # General shell script boiler plate, and helper functions.
   70 # Written by Gary V. Vaughan, 2004
   71 
   72 # Copyright (C) 2004-2015 Free Software Foundation, Inc.
   73 # This is free software; see the source for copying conditions.  There is NO
   74 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   75 
   76 # This program is free software; you can redistribute it and/or modify
   77 # it under the terms of the GNU General Public License as published by
   78 # the Free Software Foundation; either version 3 of the License, or
   79 # (at your option) any later version.
   80 
   81 # As a special exception to the GNU General Public License, if you distribute
   82 # this file as part of a program or library that is built using GNU Libtool,
   83 # you may include this file under the same distribution terms that you use
   84 # for the rest of that program.
   85 
   86 # This program is distributed in the hope that it will be useful,
   87 # but WITHOUT ANY WARRANTY; without even the implied warranty of
   88 # MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
   89 # General Public License for more details.
   90 
   91 # You should have received a copy of the GNU General Public License
   92 # along with this program. If not, see <http://www.gnu.org/licenses/>.
   93 
   94 # Please report bugs or propose patches to gary@gnu.org.
   95 
   96 
   97 ## ------ ##
   98 ## Usage. ##
   99 ## ------ ##
  100 
  101 # Evaluate this file near the top of your script to gain access to
  102 # the functions and variables defined here:
  103 #
  104 #   . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
  105 #
  106 # If you need to override any of the default environment variable
  107 # settings, do that before evaluating this file.
  108 
  109 
  110 ## -------------------- ##
  111 ## Shell normalisation. ##
  112 ## -------------------- ##
  113 
  114 # Some shells need a little help to be as Bourne compatible as possible.
  115 # Before doing anything else, make sure all that help has been provided!
  116 
  117 DUALCASE=1; export DUALCASE # for MKS sh
  118 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
  119   emulate sh
  120   NULLCMD=:
  121   # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
  122   # is contrary to our usage.  Disable this feature.
  123   alias -g '${1+"$@"}'='"$@"'
  124   setopt NO_GLOB_SUBST
  125 else
  126   case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
  127 fi
  128 
  129 # NLS nuisances: We save the old values in case they are required later.
  130 _G_user_locale=
  131 _G_safe_locale=
  132 for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
  133 do
  134   eval "if test set = \"\${$_G_var+set}\"; then
  135           save_$_G_var=\$$_G_var
  136           $_G_var=C
  137       export $_G_var
  138       _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
  139       _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
  140     fi"
  141 done
  142 
  143 # CDPATH.
  144 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
  145 
  146 # Make sure IFS has a sensible default
  147 sp=' '
  148 nl='
  149 '
  150 IFS="$sp    $nl"
  151 
  152 # There are apparently some retarded systems that use ';' as a PATH separator!
  153 if test "${PATH_SEPARATOR+set}" != set; then
  154   PATH_SEPARATOR=:
  155   (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
  156     (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
  157       PATH_SEPARATOR=';'
  158   }
  159 fi
  160 
  161 
  162 
  163 ## ------------------------- ##
  164 ## Locate command utilities. ##
  165 ## ------------------------- ##
  166 
  167 
  168 # func_executable_p FILE
  169 # ----------------------
  170 # Check that FILE is an executable regular file.
  171 func_executable_p ()
  172 {
  173     test -f "$1" && test -x "$1"
  174 }
  175 
  176 
  177 # func_path_progs PROGS_LIST CHECK_FUNC [PATH]
  178 # --------------------------------------------
  179 # Search for either a program that responds to --version with output
  180 # containing "GNU", or else returned by CHECK_FUNC otherwise, by
  181 # trying all the directories in PATH with each of the elements of
  182 # PROGS_LIST.
  183 #
  184 # CHECK_FUNC should accept the path to a candidate program, and
  185 # set $func_check_prog_result if it truncates its output less than
  186 # $_G_path_prog_max characters.
  187 func_path_progs ()
  188 {
  189     _G_progs_list=$1
  190     _G_check_func=$2
  191     _G_PATH=${3-"$PATH"}
  192 
  193     _G_path_prog_max=0
  194     _G_path_prog_found=false
  195     _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
  196     for _G_dir in $_G_PATH; do
  197       IFS=$_G_save_IFS
  198       test -z "$_G_dir" && _G_dir=.
  199       for _G_prog_name in $_G_progs_list; do
  200         for _exeext in '' .EXE; do
  201           _G_path_prog=$_G_dir/$_G_prog_name$_exeext
  202           func_executable_p "$_G_path_prog" || continue
  203           case `"$_G_path_prog" --version 2>&1` in
  204             *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
  205             *)     $_G_check_func $_G_path_prog
  206            func_path_progs_result=$func_check_prog_result
  207            ;;
  208           esac
  209           $_G_path_prog_found && break 3
  210         done
  211       done
  212     done
  213     IFS=$_G_save_IFS
  214     test -z "$func_path_progs_result" && {
  215       echo "no acceptable sed could be found in \$PATH" >&2
  216       exit 1
  217     }
  218 }
  219 
  220 
  221 # We want to be able to use the functions in this file before configure
  222 # has figured out where the best binaries are kept, which means we have
  223 # to search for them ourselves - except when the results are already set
  224 # where we skip the searches.
  225 
  226 # Unless the user overrides by setting SED, search the path for either GNU
  227 # sed, or the sed that truncates its output the least.
  228 test -z "$SED" && {
  229   _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
  230   for _G_i in 1 2 3 4 5 6 7; do
  231     _G_sed_script=$_G_sed_script$nl$_G_sed_script
  232   done
  233   echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
  234   _G_sed_script=
  235 
  236   func_check_prog_sed ()
  237   {
  238     _G_path_prog=$1
  239 
  240     _G_count=0
  241     printf 0123456789 >conftest.in
  242     while :
  243     do
  244       cat conftest.in conftest.in >conftest.tmp
  245       mv conftest.tmp conftest.in
  246       cp conftest.in conftest.nl
  247       echo '' >> conftest.nl
  248       "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
  249       diff conftest.out conftest.nl >/dev/null 2>&1 || break
  250       _G_count=`expr $_G_count + 1`
  251       if test "$_G_count" -gt "$_G_path_prog_max"; then
  252         # Best one so far, save it but keep looking for a better one
  253         func_check_prog_result=$_G_path_prog
  254         _G_path_prog_max=$_G_count
  255       fi
  256       # 10*(2^10) chars as input seems more than enough
  257       test 10 -lt "$_G_count" && break
  258     done
  259     rm -f conftest.in conftest.tmp conftest.nl conftest.out
  260   }
  261 
  262   func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
  263   rm -f conftest.sed
  264   SED=$func_path_progs_result
  265 }
  266 
  267 
  268 # Unless the user overrides by setting GREP, search the path for either GNU
  269 # grep, or the grep that truncates its output the least.
  270 test -z "$GREP" && {
  271   func_check_prog_grep ()
  272   {
  273     _G_path_prog=$1
  274 
  275     _G_count=0
  276     _G_path_prog_max=0
  277     printf 0123456789 >conftest.in
  278     while :
  279     do
  280       cat conftest.in conftest.in >conftest.tmp
  281       mv conftest.tmp conftest.in
  282       cp conftest.in conftest.nl
  283       echo 'GREP' >> conftest.nl
  284       "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
  285       diff conftest.out conftest.nl >/dev/null 2>&1 || break
  286       _G_count=`expr $_G_count + 1`
  287       if test "$_G_count" -gt "$_G_path_prog_max"; then
  288         # Best one so far, save it but keep looking for a better one
  289         func_check_prog_result=$_G_path_prog
  290         _G_path_prog_max=$_G_count
  291       fi
  292       # 10*(2^10) chars as input seems more than enough
  293       test 10 -lt "$_G_count" && break
  294     done
  295     rm -f conftest.in conftest.tmp conftest.nl conftest.out
  296   }
  297 
  298   func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
  299   GREP=$func_path_progs_result
  300 }
  301 
  302 
  303 ## ------------------------------- ##
  304 ## User overridable command paths. ##
  305 ## ------------------------------- ##
  306 
  307 # All uppercase variable names are used for environment variables.  These
  308 # variables can be overridden by the user before calling a script that
  309 # uses them if a suitable command of that name is not already available
  310 # in the command search PATH.
  311 
  312 : ${CP="cp -f"}
  313 : ${ECHO="printf %s\n"}
  314 : ${EGREP="$GREP -E"}
  315 : ${FGREP="$GREP -F"}
  316 : ${LN_S="ln -s"}
  317 : ${MAKE="make"}
  318 : ${MKDIR="mkdir"}
  319 : ${MV="mv -f"}
  320 : ${RM="rm -f"}
  321 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
  322 
  323 
  324 ## -------------------- ##
  325 ## Useful sed snippets. ##
  326 ## -------------------- ##
  327 
  328 sed_dirname='s|/[^/]*$||'
  329 sed_basename='s|^.*/||'
  330 
  331 # Sed substitution that helps us do robust quoting.  It backslashifies
  332 # metacharacters that are still active within double-quoted strings.
  333 sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
  334 
  335 # Same as above, but do not quote variable references.
  336 sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
  337 
  338 # Sed substitution that turns a string into a regex matching for the
  339 # string literally.
  340 sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
  341 
  342 # Sed substitution that converts a w32 file name or path
  343 # that contains forward slashes, into one that contains
  344 # (escaped) backslashes.  A very naive implementation.
  345 sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
  346 
  347 # Re-'\' parameter expansions in output of sed_double_quote_subst that
  348 # were '\'-ed in input to the same.  If an odd number of '\' preceded a
  349 # '$' in input to sed_double_quote_subst, that '$' was protected from
  350 # expansion.  Since each input '\' is now two '\'s, look for any number
  351 # of runs of four '\'s followed by two '\'s and then a '$'.  '\' that '$'.
  352 _G_bs='\\'
  353 _G_bs2='\\\\'
  354 _G_bs4='\\\\\\\\'
  355 _G_dollar='\$'
  356 sed_double_backslash="\
  357   s/$_G_bs4/&\\
  358 /g
  359   s/^$_G_bs2$_G_dollar/$_G_bs&/
  360   s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
  361   s/\n//g"
  362 
  363 
  364 ## ----------------- ##
  365 ## Global variables. ##
  366 ## ----------------- ##
  367 
  368 # Except for the global variables explicitly listed below, the following
  369 # functions in the '^func_' namespace, and the '^require_' namespace
  370 # variables initialised in the 'Resource management' section, sourcing
  371 # this file will not pollute your global namespace with anything
  372 # else. There's no portable way to scope variables in Bourne shell
  373 # though, so actually running these functions will sometimes place
  374 # results into a variable named after the function, and often use
  375 # temporary variables in the '^_G_' namespace. If you are careful to
  376 # avoid using those namespaces casually in your sourcing script, things
  377 # should continue to work as you expect. And, of course, you can freely
  378 # overwrite any of the functions or variables defined here before
  379 # calling anything to customize them.
  380 
  381 EXIT_SUCCESS=0
  382 EXIT_FAILURE=1
  383 EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
  384 EXIT_SKIP=77      # $? = 77 is used to indicate a skipped test to automake.
  385 
  386 # Allow overriding, eg assuming that you follow the convention of
  387 # putting '$debug_cmd' at the start of all your functions, you can get
  388 # bash to show function call trace with:
  389 #
  390 #    debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
  391 debug_cmd=${debug_cmd-":"}
  392 exit_cmd=:
  393 
  394 # By convention, finish your script with:
  395 #
  396 #    exit $exit_status
  397 #
  398 # so that you can set exit_status to non-zero if you want to indicate
  399 # something went wrong during execution without actually bailing out at
  400 # the point of failure.
  401 exit_status=$EXIT_SUCCESS
  402 
  403 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
  404 # is ksh but when the shell is invoked as "sh" and the current value of
  405 # the _XPG environment variable is not equal to 1 (one), the special
  406 # positional parameter $0, within a function call, is the name of the
  407 # function.
  408 progpath=$0
  409 
  410 # The name of this program.
  411 progname=`$ECHO "$progpath" |$SED "$sed_basename"`
  412 
  413 # Make sure we have an absolute progpath for reexecution:
  414 case $progpath in
  415   [\\/]*|[A-Za-z]:\\*) ;;
  416   *[\\/]*)
  417      progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
  418      progdir=`cd "$progdir" && pwd`
  419      progpath=$progdir/$progname
  420      ;;
  421   *)
  422      _G_IFS=$IFS
  423      IFS=${PATH_SEPARATOR-:}
  424      for progdir in $PATH; do
  425        IFS=$_G_IFS
  426        test -x "$progdir/$progname" && break
  427      done
  428      IFS=$_G_IFS
  429      test -n "$progdir" || progdir=`pwd`
  430      progpath=$progdir/$progname
  431      ;;
  432 esac
  433 
  434 
  435 ## ----------------- ##
  436 ## Standard options. ##
  437 ## ----------------- ##
  438 
  439 # The following options affect the operation of the functions defined
  440 # below, and should be set appropriately depending on run-time para-
  441 # meters passed on the command line.
  442 
  443 opt_dry_run=false
  444 opt_quiet=false
  445 opt_verbose=false
  446 
  447 # Categories 'all' and 'none' are always available.  Append any others
  448 # you will pass as the first argument to func_warning from your own
  449 # code.
  450 warning_categories=
  451 
  452 # By default, display warnings according to 'opt_warning_types'.  Set
  453 # 'warning_func'  to ':' to elide all warnings, or func_fatal_error to
  454 # treat the next displayed warning as a fatal error.
  455 warning_func=func_warn_and_continue
  456 
  457 # Set to 'all' to display all warnings, 'none' to suppress all
  458 # warnings, or a space delimited list of some subset of
  459 # 'warning_categories' to display only the listed warnings.
  460 opt_warning_types=all
  461 
  462 
  463 ## -------------------- ##
  464 ## Resource management. ##
  465 ## -------------------- ##
  466 
  467 # This section contains definitions for functions that each ensure a
  468 # particular resource (a file, or a non-empty configuration variable for
  469 # example) is available, and if appropriate to extract default values
  470 # from pertinent package files. Call them using their associated
  471 # 'require_*' variable to ensure that they are executed, at most, once.
  472 #
  473 # It's entirely deliberate that calling these functions can set
  474 # variables that don't obey the namespace limitations obeyed by the rest
  475 # of this file, in order that that they be as useful as possible to
  476 # callers.
  477 
  478 
  479 # require_term_colors
  480 # -------------------
  481 # Allow display of bold text on terminals that support it.
  482 require_term_colors=func_require_term_colors
  483 func_require_term_colors ()
  484 {
  485     $debug_cmd
  486 
  487     test -t 1 && {
  488       # COLORTERM and USE_ANSI_COLORS environment variables take
  489       # precedence, because most terminfo databases neglect to describe
  490       # whether color sequences are supported.
  491       test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
  492 
  493       if test 1 = "$USE_ANSI_COLORS"; then
  494         # Standard ANSI escape sequences
  495         tc_reset=''
  496         tc_bold='';   tc_standout=''
  497         tc_red='';   tc_green=''
  498         tc_blue='';  tc_cyan=''
  499       else
  500         # Otherwise trust the terminfo database after all.
  501         test -n "`tput sgr0 2>/dev/null`" && {
  502           tc_reset=`tput sgr0`
  503           test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
  504           tc_standout=$tc_bold
  505           test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
  506           test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
  507           test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
  508           test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
  509           test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
  510         }
  511       fi
  512     }
  513 
  514     require_term_colors=:
  515 }
  516 
  517 
  518 ## ----------------- ##
  519 ## Function library. ##
  520 ## ----------------- ##
  521 
  522 # This section contains a variety of useful functions to call in your
  523 # scripts. Take note of the portable wrappers for features provided by
  524 # some modern shells, which will fall back to slower equivalents on
  525 # less featureful shells.
  526 
  527 
  528 # func_append VAR VALUE
  529 # ---------------------
  530 # Append VALUE onto the existing contents of VAR.
  531 
  532   # We should try to minimise forks, especially on Windows where they are
  533   # unreasonably slow, so skip the feature probes when bash or zsh are
  534   # being used:
  535   if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
  536     : ${_G_HAVE_ARITH_OP="yes"}
  537     : ${_G_HAVE_XSI_OPS="yes"}
  538     # The += operator was introduced in bash 3.1
  539     case $BASH_VERSION in
  540       [12].* | 3.0 | 3.0*) ;;
  541       *)
  542         : ${_G_HAVE_PLUSEQ_OP="yes"}
  543         ;;
  544     esac
  545   fi
  546 
  547   # _G_HAVE_PLUSEQ_OP
  548   # Can be empty, in which case the shell is probed, "yes" if += is
  549   # useable or anything else if it does not work.
  550   test -z "$_G_HAVE_PLUSEQ_OP" \
  551     && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
  552     && _G_HAVE_PLUSEQ_OP=yes
  553 
  554 if test yes = "$_G_HAVE_PLUSEQ_OP"
  555 then
  556   # This is an XSI compatible shell, allowing a faster implementation...
  557   eval 'func_append ()
  558   {
  559     $debug_cmd
  560 
  561     eval "$1+=\$2"
  562   }'
  563 else
  564   # ...otherwise fall back to using expr, which is often a shell builtin.
  565   func_append ()
  566   {
  567     $debug_cmd
  568 
  569     eval "$1=\$$1\$2"
  570   }
  571 fi
  572 
  573 
  574 # func_append_quoted VAR VALUE
  575 # ----------------------------
  576 # Quote VALUE and append to the end of shell variable VAR, separated
  577 # by a space.
  578 if test yes = "$_G_HAVE_PLUSEQ_OP"; then
  579   eval 'func_append_quoted ()
  580   {
  581     $debug_cmd
  582 
  583     func_quote_arg pretty "$2"
  584     eval "$1+=\\ \$func_quote_arg_result"
  585   }'
  586 else
  587   func_append_quoted ()
  588   {
  589     $debug_cmd
  590 
  591     func_quote_arg pretty "$2"
  592     eval "$1=\$$1\\ \$func_quote_arg_result"
  593   }
  594 fi
  595 
  596 
  597 # func_append_uniq VAR VALUE
  598 # --------------------------
  599 # Append unique VALUE onto the existing contents of VAR, assuming
  600 # entries are delimited by the first character of VALUE.  For example:
  601 #
  602 #   func_append_uniq options " --another-option option-argument"
  603 #
  604 # will only append to $options if " --another-option option-argument "
  605 # is not already present somewhere in $options already (note spaces at
  606 # each end implied by leading space in second argument).
  607 func_append_uniq ()
  608 {
  609     $debug_cmd
  610 
  611     eval _G_current_value='`$ECHO $'$1'`'
  612     _G_delim=`expr "$2" : '\(.\)'`
  613 
  614     case $_G_delim$_G_current_value$_G_delim in
  615       *"$2$_G_delim"*) ;;
  616       *) func_append "$@" ;;
  617     esac
  618 }
  619 
  620 
  621 # func_arith TERM...
  622 # ------------------
  623 # Set func_arith_result to the result of evaluating TERMs.
  624   test -z "$_G_HAVE_ARITH_OP" \
  625     && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
  626     && _G_HAVE_ARITH_OP=yes
  627 
  628 if test yes = "$_G_HAVE_ARITH_OP"; then
  629   eval 'func_arith ()
  630   {
  631     $debug_cmd
  632 
  633     func_arith_result=$(( $* ))
  634   }'
  635 else
  636   func_arith ()
  637   {
  638     $debug_cmd
  639 
  640     func_arith_result=`expr "$@"`
  641   }
  642 fi
  643 
  644 
  645 # func_basename FILE
  646 # ------------------
  647 # Set func_basename_result to FILE with everything up to and including
  648 # the last / stripped.
  649 if test yes = "$_G_HAVE_XSI_OPS"; then
  650   # If this shell supports suffix pattern removal, then use it to avoid
  651   # forking. Hide the definitions single quotes in case the shell chokes
  652   # on unsupported syntax...
  653   _b='func_basename_result=${1##*/}'
  654   _d='case $1 in
  655         */*) func_dirname_result=${1%/*}$2 ;;
  656         *  ) func_dirname_result=$3        ;;
  657       esac'
  658 
  659 else
  660   # ...otherwise fall back to using sed.
  661   _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
  662   _d='func_dirname_result=`$ECHO "$1"  |$SED "$sed_dirname"`
  663       if test "X$func_dirname_result" = "X$1"; then
  664         func_dirname_result=$3
  665       else
  666         func_append func_dirname_result "$2"
  667       fi'
  668 fi
  669 
  670 eval 'func_basename ()
  671 {
  672     $debug_cmd
  673 
  674     '"$_b"'
  675 }'
  676 
  677 
  678 # func_dirname FILE APPEND NONDIR_REPLACEMENT
  679 # -------------------------------------------
  680 # Compute the dirname of FILE.  If nonempty, add APPEND to the result,
  681 # otherwise set result to NONDIR_REPLACEMENT.
  682 eval 'func_dirname ()
  683 {
  684     $debug_cmd
  685 
  686     '"$_d"'
  687 }'
  688 
  689 
  690 # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
  691 # --------------------------------------------------------
  692 # Perform func_basename and func_dirname in a single function
  693 # call:
  694 #   dirname:  Compute the dirname of FILE.  If nonempty,
  695 #             add APPEND to the result, otherwise set result
  696 #             to NONDIR_REPLACEMENT.
  697 #             value returned in "$func_dirname_result"
  698 #   basename: Compute filename of FILE.
  699 #             value retuned in "$func_basename_result"
  700 # For efficiency, we do not delegate to the functions above but instead
  701 # duplicate the functionality here.
  702 eval 'func_dirname_and_basename ()
  703 {
  704     $debug_cmd
  705 
  706     '"$_b"'
  707     '"$_d"'
  708 }'
  709 
  710 
  711 # func_echo ARG...
  712 # ----------------
  713 # Echo program name prefixed message.
  714 func_echo ()
  715 {
  716     $debug_cmd
  717 
  718     _G_message=$*
  719 
  720     func_echo_IFS=$IFS
  721     IFS=$nl
  722     for _G_line in $_G_message; do
  723       IFS=$func_echo_IFS
  724       $ECHO "$progname: $_G_line"
  725     done
  726     IFS=$func_echo_IFS
  727 }
  728 
  729 
  730 # func_echo_all ARG...
  731 # --------------------
  732 # Invoke $ECHO with all args, space-separated.
  733 func_echo_all ()
  734 {
  735     $ECHO "$*"
  736 }
  737 
  738 
  739 # func_echo_infix_1 INFIX ARG...
  740 # ------------------------------
  741 # Echo program name, followed by INFIX on the first line, with any
  742 # additional lines not showing INFIX.
  743 func_echo_infix_1 ()
  744 {
  745     $debug_cmd
  746 
  747     $require_term_colors
  748 
  749     _G_infix=$1; shift
  750     _G_indent=$_G_infix
  751     _G_prefix="$progname: $_G_infix: "
  752     _G_message=$*
  753 
  754     # Strip color escape sequences before counting printable length
  755     for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
  756     do
  757       test -n "$_G_tc" && {
  758         _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
  759         _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
  760       }
  761     done
  762     _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`"  " ## exclude from sc_prohibit_nested_quotes
  763 
  764     func_echo_infix_1_IFS=$IFS
  765     IFS=$nl
  766     for _G_line in $_G_message; do
  767       IFS=$func_echo_infix_1_IFS
  768       $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
  769       _G_prefix=$_G_indent
  770     done
  771     IFS=$func_echo_infix_1_IFS
  772 }
  773 
  774 
  775 # func_error ARG...
  776 # -----------------
  777 # Echo program name prefixed message to standard error.
  778 func_error ()
  779 {
  780     $debug_cmd
  781 
  782     $require_term_colors
  783 
  784     func_echo_infix_1 "  $tc_standout${tc_red}error$tc_reset" "$*" >&2
  785 }
  786 
  787 
  788 # func_fatal_error ARG...
  789 # -----------------------
  790 # Echo program name prefixed message to standard error, and exit.
  791 func_fatal_error ()
  792 {
  793     $debug_cmd
  794 
  795     func_error "$*"
  796     exit $EXIT_FAILURE
  797 }
  798 
  799 
  800 # func_grep EXPRESSION FILENAME
  801 # -----------------------------
  802 # Check whether EXPRESSION matches any line of FILENAME, without output.
  803 func_grep ()
  804 {
  805     $debug_cmd
  806 
  807     $GREP "$1" "$2" >/dev/null 2>&1
  808 }
  809 
  810 
  811 # func_len STRING
  812 # ---------------
  813 # Set func_len_result to the length of STRING. STRING may not
  814 # start with a hyphen.
  815   test -z "$_G_HAVE_XSI_OPS" \
  816     && (eval 'x=a/b/c;
  817       test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
  818     && _G_HAVE_XSI_OPS=yes
  819 
  820 if test yes = "$_G_HAVE_XSI_OPS"; then
  821   eval 'func_len ()
  822   {
  823     $debug_cmd
  824 
  825     func_len_result=${#1}
  826   }'
  827 else
  828   func_len ()
  829   {
  830     $debug_cmd
  831 
  832     func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
  833   }
  834 fi
  835 
  836 
  837 # func_mkdir_p DIRECTORY-PATH
  838 # ---------------------------
  839 # Make sure the entire path to DIRECTORY-PATH is available.
  840 func_mkdir_p ()
  841 {
  842     $debug_cmd
  843 
  844     _G_directory_path=$1
  845     _G_dir_list=
  846 
  847     if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
  848 
  849       # Protect directory names starting with '-'
  850       case $_G_directory_path in
  851         -*) _G_directory_path=./$_G_directory_path ;;
  852       esac
  853 
  854       # While some portion of DIR does not yet exist...
  855       while test ! -d "$_G_directory_path"; do
  856         # ...make a list in topmost first order.  Use a colon delimited
  857     # list incase some portion of path contains whitespace.
  858         _G_dir_list=$_G_directory_path:$_G_dir_list
  859 
  860         # If the last portion added has no slash in it, the list is done
  861         case $_G_directory_path in */*) ;; *) break ;; esac
  862 
  863         # ...otherwise throw away the child directory and loop
  864         _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
  865       done
  866       _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
  867 
  868       func_mkdir_p_IFS=$IFS; IFS=:
  869       for _G_dir in $_G_dir_list; do
  870     IFS=$func_mkdir_p_IFS
  871         # mkdir can fail with a 'File exist' error if two processes
  872         # try to create one of the directories concurrently.  Don't
  873         # stop in that case!
  874         $MKDIR "$_G_dir" 2>/dev/null || :
  875       done
  876       IFS=$func_mkdir_p_IFS
  877 
  878       # Bail out if we (or some other process) failed to create a directory.
  879       test -d "$_G_directory_path" || \
  880         func_fatal_error "Failed to create '$1'"
  881     fi
  882 }
  883 
  884 
  885 # func_mktempdir [BASENAME]
  886 # -------------------------
  887 # Make a temporary directory that won't clash with other running
  888 # libtool processes, and avoids race conditions if possible.  If
  889 # given, BASENAME is the basename for that directory.
  890 func_mktempdir ()
  891 {
  892     $debug_cmd
  893 
  894     _G_template=${TMPDIR-/tmp}/${1-$progname}
  895 
  896     if test : = "$opt_dry_run"; then
  897       # Return a directory name, but don't create it in dry-run mode
  898       _G_tmpdir=$_G_template-$$
  899     else
  900 
  901       # If mktemp works, use that first and foremost
  902       _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
  903 
  904       if test ! -d "$_G_tmpdir"; then
  905         # Failing that, at least try and use $RANDOM to avoid a race
  906         _G_tmpdir=$_G_template-${RANDOM-0}$$
  907 
  908         func_mktempdir_umask=`umask`
  909         umask 0077
  910         $MKDIR "$_G_tmpdir"
  911         umask $func_mktempdir_umask
  912       fi
  913 
  914       # If we're not in dry-run mode, bomb out on failure
  915       test -d "$_G_tmpdir" || \
  916         func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
  917     fi
  918 
  919     $ECHO "$_G_tmpdir"
  920 }
  921 
  922 
  923 # func_normal_abspath PATH
  924 # ------------------------
  925 # Remove doubled-up and trailing slashes, "." path components,
  926 # and cancel out any ".." path components in PATH after making
  927 # it an absolute path.
  928 func_normal_abspath ()
  929 {
  930     $debug_cmd
  931 
  932     # These SED scripts presuppose an absolute path with a trailing slash.
  933     _G_pathcar='s|^/\([^/]*\).*$|\1|'
  934     _G_pathcdr='s|^/[^/]*||'
  935     _G_removedotparts=':dotsl
  936         s|/\./|/|g
  937         t dotsl
  938         s|/\.$|/|'
  939     _G_collapseslashes='s|/\{1,\}|/|g'
  940     _G_finalslash='s|/*$|/|'
  941 
  942     # Start from root dir and reassemble the path.
  943     func_normal_abspath_result=
  944     func_normal_abspath_tpath=$1
  945     func_normal_abspath_altnamespace=
  946     case $func_normal_abspath_tpath in
  947       "")
  948         # Empty path, that just means $cwd.
  949         func_stripname '' '/' "`pwd`"
  950         func_normal_abspath_result=$func_stripname_result
  951         return
  952         ;;
  953       # The next three entries are used to spot a run of precisely
  954       # two leading slashes without using negated character classes;
  955       # we take advantage of case's first-match behaviour.
  956       ///*)
  957         # Unusual form of absolute path, do nothing.
  958         ;;
  959       //*)
  960         # Not necessarily an ordinary path; POSIX reserves leading '//'
  961         # and for example Cygwin uses it to access remote file shares
  962         # over CIFS/SMB, so we conserve a leading double slash if found.
  963         func_normal_abspath_altnamespace=/
  964         ;;
  965       /*)
  966         # Absolute path, do nothing.
  967         ;;
  968       *)
  969         # Relative path, prepend $cwd.
  970         func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
  971         ;;
  972     esac
  973 
  974     # Cancel out all the simple stuff to save iterations.  We also want
  975     # the path to end with a slash for ease of parsing, so make sure
  976     # there is one (and only one) here.
  977     func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
  978           -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
  979     while :; do
  980       # Processed it all yet?
  981       if test / = "$func_normal_abspath_tpath"; then
  982         # If we ascended to the root using ".." the result may be empty now.
  983         if test -z "$func_normal_abspath_result"; then
  984           func_normal_abspath_result=/
  985         fi
  986         break
  987       fi
  988       func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
  989           -e "$_G_pathcar"`
  990       func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
  991           -e "$_G_pathcdr"`
  992       # Figure out what to do with it
  993       case $func_normal_abspath_tcomponent in
  994         "")
  995           # Trailing empty path component, ignore it.
  996           ;;
  997         ..)
  998           # Parent dir; strip last assembled component from result.
  999           func_dirname "$func_normal_abspath_result"
 1000           func_normal_abspath_result=$func_dirname_result
 1001           ;;
 1002         *)
 1003           # Actual path component, append it.
 1004           func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
 1005           ;;
 1006       esac
 1007     done
 1008     # Restore leading double-slash if one was found on entry.
 1009     func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
 1010 }
 1011 
 1012 
 1013 # func_notquiet ARG...
 1014 # --------------------
 1015 # Echo program name prefixed message only when not in quiet mode.
 1016 func_notquiet ()
 1017 {
 1018     $debug_cmd
 1019 
 1020     $opt_quiet || func_echo ${1+"$@"}
 1021 
 1022     # A bug in bash halts the script if the last line of a function
 1023     # fails when set -e is in force, so we need another command to
 1024     # work around that:
 1025     :
 1026 }
 1027 
 1028 
 1029 # func_relative_path SRCDIR DSTDIR
 1030 # --------------------------------
 1031 # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
 1032 func_relative_path ()
 1033 {
 1034     $debug_cmd
 1035 
 1036     func_relative_path_result=
 1037     func_normal_abspath "$1"
 1038     func_relative_path_tlibdir=$func_normal_abspath_result
 1039     func_normal_abspath "$2"
 1040     func_relative_path_tbindir=$func_normal_abspath_result
 1041 
 1042     # Ascend the tree starting from libdir
 1043     while :; do
 1044       # check if we have found a prefix of bindir
 1045       case $func_relative_path_tbindir in
 1046         $func_relative_path_tlibdir)
 1047           # found an exact match
 1048           func_relative_path_tcancelled=
 1049           break
 1050           ;;
 1051         $func_relative_path_tlibdir*)
 1052           # found a matching prefix
 1053           func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
 1054           func_relative_path_tcancelled=$func_stripname_result
 1055           if test -z "$func_relative_path_result"; then
 1056             func_relative_path_result=.
 1057           fi
 1058           break
 1059           ;;
 1060         *)
 1061           func_dirname $func_relative_path_tlibdir
 1062           func_relative_path_tlibdir=$func_dirname_result
 1063           if test -z "$func_relative_path_tlibdir"; then
 1064             # Have to descend all the way to the root!
 1065             func_relative_path_result=../$func_relative_path_result
 1066             func_relative_path_tcancelled=$func_relative_path_tbindir
 1067             break
 1068           fi
 1069           func_relative_path_result=../$func_relative_path_result
 1070           ;;
 1071       esac
 1072     done
 1073 
 1074     # Now calculate path; take care to avoid doubling-up slashes.
 1075     func_stripname '' '/' "$func_relative_path_result"
 1076     func_relative_path_result=$func_stripname_result
 1077     func_stripname '/' '/' "$func_relative_path_tcancelled"
 1078     if test -n "$func_stripname_result"; then
 1079       func_append func_relative_path_result "/$func_stripname_result"
 1080     fi
 1081 
 1082     # Normalisation. If bindir is libdir, return '.' else relative path.
 1083     if test -n "$func_relative_path_result"; then
 1084       func_stripname './' '' "$func_relative_path_result"
 1085       func_relative_path_result=$func_stripname_result
 1086     fi
 1087 
 1088     test -n "$func_relative_path_result" || func_relative_path_result=.
 1089 
 1090     :
 1091 }
 1092 
 1093 
 1094 # func_quote_portable EVAL ARG
 1095 # ----------------------------
 1096 # Internal function to portably implement func_quote_arg.  Note that we still
 1097 # keep attention to performance here so we as much as possible try to avoid
 1098 # calling sed binary (so far O(N) complexity as long as func_append is O(1)).
 1099 func_quote_portable ()
 1100 {
 1101     $debug_cmd
 1102 
 1103     func_quote_portable_result=$2
 1104 
 1105     # one-time-loop (easy break)
 1106     while true
 1107     do
 1108       if $1; then
 1109         func_quote_portable_result=`$ECHO "$2" | $SED \
 1110           -e "$sed_double_quote_subst" -e "$sed_double_backslash"`
 1111         break
 1112       fi
 1113 
 1114       # Quote for eval.
 1115       case $func_quote_portable_result in
 1116         *[\\\`\"\$]*)
 1117           case $func_quote_portable_result in
 1118             *[\[\*\?]*)
 1119               func_quote_portable_result=`$ECHO "$func_quote_portable_result" | $SED "$sed_quote_subst"`
 1120               break
 1121               ;;
 1122           esac
 1123 
 1124           func_quote_portable_old_IFS=$IFS
 1125           for _G_char in '\' '`' '"' '$'
 1126           do
 1127             # STATE($1) PREV($2) SEPARATOR($3)
 1128             set start "" ""
 1129             func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy
 1130             IFS=$_G_char
 1131             for _G_part in $func_quote_portable_result
 1132             do
 1133               case $1 in
 1134               quote)
 1135                 func_append func_quote_portable_result "$3$2"
 1136                 set quote "$_G_part" "\\$_G_char"
 1137                 ;;
 1138               start)
 1139                 set first "" ""
 1140                 func_quote_portable_result=
 1141                 ;;
 1142               first)
 1143                 set quote "$_G_part" ""
 1144                 ;;
 1145               esac
 1146             done
 1147           done
 1148           IFS=$func_quote_portable_old_IFS
 1149           ;;
 1150         *) ;;
 1151       esac
 1152       break
 1153     done
 1154 
 1155     func_quote_portable_unquoted_result=$func_quote_portable_result
 1156     case $func_quote_portable_result in
 1157       # double-quote args containing shell metacharacters to delay
 1158       # word splitting, command substitution and variable expansion
 1159       # for a subsequent eval.
 1160       # many bourne shells cannot handle close brackets correctly
 1161       # in scan sets, so we specify it separately.
 1162       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
 1163         func_quote_portable_result=\"$func_quote_portable_result\"
 1164         ;;
 1165     esac
 1166 }
 1167 
 1168 
 1169 # func_quotefast_eval ARG
 1170 # -----------------------
 1171 # Quote one ARG (internal).  This is equivalent to 'func_quote_arg eval ARG',
 1172 # but optimized for speed.  Result is stored in $func_quotefast_eval.
 1173 if test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then
 1174   func_quotefast_eval ()
 1175   {
 1176     printf -v func_quotefast_eval_result %q "$1"
 1177   }
 1178 else
 1179   func_quotefast_eval ()
 1180   {
 1181     func_quote_portable false "$1"
 1182     func_quotefast_eval_result=$func_quote_portable_result
 1183   }
 1184 fi
 1185 
 1186 
 1187 # func_quote_arg MODEs ARG
 1188 # ------------------------
 1189 # Quote one ARG to be evaled later.  MODEs argument may contain zero ore more
 1190 # specifiers listed below separated by ',' character.  This function returns two
 1191 # values:
 1192 #   i) func_quote_arg_result
 1193 #      double-quoted (when needed), suitable for a subsequent eval
 1194 #  ii) func_quote_arg_unquoted_result
 1195 #      has all characters that are still active within double
 1196 #      quotes backslashified.  Available only if 'unquoted' is specified.
 1197 #
 1198 # Available modes:
 1199 # ----------------
 1200 # 'eval' (default)
 1201 #       - escape shell special characters
 1202 # 'expand'
 1203 #       - the same as 'eval';  but do not quote variable references
 1204 # 'pretty'
 1205 #       - request aesthetic output, i.e. '"a b"' instead of 'a\ b'.  This might
 1206 #         later used in func_quote to get output like: 'echo "a b"' instead of
 1207 #         'echo a\ b'.  This is slower than default on some shells.
 1208 # 'unquoted'
 1209 #       - produce also $func_quote_arg_unquoted_result which does not contain
 1210 #         wrapping double-quotes.
 1211 #
 1212 # Examples for 'func_quote_arg pretty,unquoted string':
 1213 #
 1214 #   string      | *_result              | *_unquoted_result
 1215 #   ------------+-----------------------+-------------------
 1216 #   "           | \"                    | \"
 1217 #   a b         | "a b"                 | a b
 1218 #   "a b"       | "\"a b\""             | \"a b\"
 1219 #   *           | "*"                   | *
 1220 #   z="${x-$y}" | "z=\"\${x-\$y}\""     | z=\"\${x-\$y}\"
 1221 #
 1222 # Examples for 'func_quote_arg pretty,unquoted,expand string':
 1223 #
 1224 #   string        |   *_result          |  *_unquoted_result
 1225 #   --------------+---------------------+--------------------
 1226 #   z="${x-$y}"   | "z=\"${x-$y}\""     | z=\"${x-$y}\"
 1227 func_quote_arg ()
 1228 {
 1229     _G_quote_expand=false
 1230     case ,$1, in
 1231       *,expand,*)
 1232         _G_quote_expand=:
 1233         ;;
 1234     esac
 1235 
 1236     case ,$1, in
 1237       *,pretty,*|*,expand,*|*,unquoted,*)
 1238         func_quote_portable $_G_quote_expand "$2"
 1239         func_quote_arg_result=$func_quote_portable_result
 1240         func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result
 1241         ;;
 1242       *)
 1243         # Faster quote-for-eval for some shells.
 1244         func_quotefast_eval "$2"
 1245         func_quote_arg_result=$func_quotefast_eval_result
 1246         ;;
 1247     esac
 1248 }
 1249 
 1250 
 1251 # func_quote MODEs ARGs...
 1252 # ------------------------
 1253 # Quote all ARGs to be evaled later and join them into single command.  See
 1254 # func_quote_arg's description for more info.
 1255 func_quote ()
 1256 {
 1257     $debug_cmd
 1258     _G_func_quote_mode=$1 ; shift
 1259     func_quote_result=
 1260     while test 0 -lt $#; do
 1261       func_quote_arg "$_G_func_quote_mode" "$1"
 1262       if test -n "$func_quote_result"; then
 1263         func_append func_quote_result " $func_quote_arg_result"
 1264       else
 1265         func_append func_quote_result "$func_quote_arg_result"
 1266       fi
 1267       shift
 1268     done
 1269 }
 1270 
 1271 
 1272 # func_stripname PREFIX SUFFIX NAME
 1273 # ---------------------------------
 1274 # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
 1275 # PREFIX and SUFFIX must not contain globbing or regex special
 1276 # characters, hashes, percent signs, but SUFFIX may contain a leading
 1277 # dot (in which case that matches only a dot).
 1278 if test yes = "$_G_HAVE_XSI_OPS"; then
 1279   eval 'func_stripname ()
 1280   {
 1281     $debug_cmd
 1282 
 1283     # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
 1284     # positional parameters, so assign one to ordinary variable first.
 1285     func_stripname_result=$3
 1286     func_stripname_result=${func_stripname_result#"$1"}
 1287     func_stripname_result=${func_stripname_result%"$2"}
 1288   }'
 1289 else
 1290   func_stripname ()
 1291   {
 1292     $debug_cmd
 1293 
 1294     case $2 in
 1295       .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
 1296       *)  func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
 1297     esac
 1298   }
 1299 fi
 1300 
 1301 
 1302 # func_show_eval CMD [FAIL_EXP]
 1303 # -----------------------------
 1304 # Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
 1305 # not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
 1306 # is given, then evaluate it.
 1307 func_show_eval ()
 1308 {
 1309     $debug_cmd
 1310 
 1311     _G_cmd=$1
 1312     _G_fail_exp=${2-':'}
 1313 
 1314     func_quote_arg pretty,expand "$_G_cmd"
 1315     eval "func_notquiet $func_quote_arg_result"
 1316 
 1317     $opt_dry_run || {
 1318       eval "$_G_cmd"
 1319       _G_status=$?
 1320       if test 0 -ne "$_G_status"; then
 1321     eval "(exit $_G_status); $_G_fail_exp"
 1322       fi
 1323     }
 1324 }
 1325 
 1326 
 1327 # func_show_eval_locale CMD [FAIL_EXP]
 1328 # ------------------------------------
 1329 # Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
 1330 # not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
 1331 # is given, then evaluate it.  Use the saved locale for evaluation.
 1332 func_show_eval_locale ()
 1333 {
 1334     $debug_cmd
 1335 
 1336     _G_cmd=$1
 1337     _G_fail_exp=${2-':'}
 1338 
 1339     $opt_quiet || {
 1340       func_quote_arg expand,pretty "$_G_cmd"
 1341       eval "func_echo $func_quote_arg_result"
 1342     }
 1343 
 1344     $opt_dry_run || {
 1345       eval "$_G_user_locale
 1346         $_G_cmd"
 1347       _G_status=$?
 1348       eval "$_G_safe_locale"
 1349       if test 0 -ne "$_G_status"; then
 1350     eval "(exit $_G_status); $_G_fail_exp"
 1351       fi
 1352     }
 1353 }
 1354 
 1355 
 1356 # func_tr_sh
 1357 # ----------
 1358 # Turn $1 into a string suitable for a shell variable name.
 1359 # Result is stored in $func_tr_sh_result.  All characters
 1360 # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
 1361 # if $1 begins with a digit, a '_' is prepended as well.
 1362 func_tr_sh ()
 1363 {
 1364     $debug_cmd
 1365 
 1366     case $1 in
 1367     [0-9]* | *[!a-zA-Z0-9_]*)
 1368       func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
 1369       ;;
 1370     * )
 1371       func_tr_sh_result=$1
 1372       ;;
 1373     esac
 1374 }
 1375 
 1376 
 1377 # func_verbose ARG...
 1378 # -------------------
 1379 # Echo program name prefixed message in verbose mode only.
 1380 func_verbose ()
 1381 {
 1382     $debug_cmd
 1383 
 1384     $opt_verbose && func_echo "$*"
 1385 
 1386     :
 1387 }
 1388 
 1389 
 1390 # func_warn_and_continue ARG...
 1391 # -----------------------------
 1392 # Echo program name prefixed warning message to standard error.
 1393 func_warn_and_continue ()
 1394 {
 1395     $debug_cmd
 1396 
 1397     $require_term_colors
 1398 
 1399     func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
 1400 }
 1401 
 1402 
 1403 # func_warning CATEGORY ARG...
 1404 # ----------------------------
 1405 # Echo program name prefixed warning message to standard error. Warning
 1406 # messages can be filtered according to CATEGORY, where this function
 1407 # elides messages where CATEGORY is not listed in the global variable
 1408 # 'opt_warning_types'.
 1409 func_warning ()
 1410 {
 1411     $debug_cmd
 1412 
 1413     # CATEGORY must be in the warning_categories list!
 1414     case " $warning_categories " in
 1415       *" $1 "*) ;;
 1416       *) func_internal_error "invalid warning category '$1'" ;;
 1417     esac
 1418 
 1419     _G_category=$1
 1420     shift
 1421 
 1422     case " $opt_warning_types " in
 1423       *" $_G_category "*) $warning_func ${1+"$@"} ;;
 1424     esac
 1425 }
 1426 
 1427 
 1428 # func_sort_ver VER1 VER2
 1429 # -----------------------
 1430 # 'sort -V' is not generally available.
 1431 # Note this deviates from the version comparison in automake
 1432 # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
 1433 # but this should suffice as we won't be specifying old
 1434 # version formats or redundant trailing .0 in bootstrap.conf.
 1435 # If we did want full compatibility then we should probably
 1436 # use m4_version_compare from autoconf.
 1437 func_sort_ver ()
 1438 {
 1439     $debug_cmd
 1440 
 1441     printf '%s\n%s\n' "$1" "$2" \
 1442       | 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
 1443 }
 1444 
 1445 # func_lt_ver PREV CURR
 1446 # ---------------------
 1447 # Return true if PREV and CURR are in the correct order according to
 1448 # func_sort_ver, otherwise false.  Use it like this:
 1449 #
 1450 #  func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
 1451 func_lt_ver ()
 1452 {
 1453     $debug_cmd
 1454 
 1455     test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
 1456 }
 1457 
 1458 
 1459 # Local variables:
 1460 # mode: shell-script
 1461 # sh-indentation: 2
 1462 # eval: (add-hook 'before-save-hook 'time-stamp)
 1463 # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
 1464 # time-stamp-time-zone: "UTC"
 1465 # End:
 1466 #! /bin/sh
 1467 
 1468 # Set a version string for this script.
 1469 scriptversion=2015-10-12.13; # UTC
 1470 
 1471 # A portable, pluggable option parser for Bourne shell.
 1472 # Written by Gary V. Vaughan, 2010
 1473 
 1474 # Copyright (C) 2010-2015 Free Software Foundation, Inc.
 1475 # This is free software; see the source for copying conditions.  There is NO
 1476 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 1477 
 1478 # This program is free software: you can redistribute it and/or modify
 1479 # it under the terms of the GNU General Public License as published by
 1480 # the Free Software Foundation, either version 3 of the License, or
 1481 # (at your option) any later version.
 1482 
 1483 # This program is distributed in the hope that it will be useful,
 1484 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 1485 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 1486 # GNU General Public License for more details.
 1487 
 1488 # You should have received a copy of the GNU General Public License
 1489 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 1490 
 1491 # Please report bugs or propose patches to gary@gnu.org.
 1492 
 1493 
 1494 ## ------ ##
 1495 ## Usage. ##
 1496 ## ------ ##
 1497 
 1498 # This file is a library for parsing options in your shell scripts along
 1499 # with assorted other useful supporting features that you can make use
 1500 # of too.
 1501 #
 1502 # For the simplest scripts you might need only:
 1503 #
 1504 #   #!/bin/sh
 1505 #   . relative/path/to/funclib.sh
 1506 #   . relative/path/to/options-parser
 1507 #   scriptversion=1.0
 1508 #   func_options ${1+"$@"}
 1509 #   eval set dummy "$func_options_result"; shift
 1510 #   ...rest of your script...
 1511 #
 1512 # In order for the '--version' option to work, you will need to have a
 1513 # suitably formatted comment like the one at the top of this file
 1514 # starting with '# Written by ' and ending with '# warranty; '.
 1515 #
 1516 # For '-h' and '--help' to work, you will also need a one line
 1517 # description of your script's purpose in a comment directly above the
 1518 # '# Written by ' line, like the one at the top of this file.
 1519 #
 1520 # The default options also support '--debug', which will turn on shell
 1521 # execution tracing (see the comment above debug_cmd below for another
 1522 # use), and '--verbose' and the func_verbose function to allow your script
 1523 # to display verbose messages only when your user has specified
 1524 # '--verbose'.
 1525 #
 1526 # After sourcing this file, you can plug processing for additional
 1527 # options by amending the variables from the 'Configuration' section
 1528 # below, and following the instructions in the 'Option parsing'
 1529 # section further down.
 1530 
 1531 ## -------------- ##
 1532 ## Configuration. ##
 1533 ## -------------- ##
 1534 
 1535 # You should override these variables in your script after sourcing this
 1536 # file so that they reflect the customisations you have added to the
 1537 # option parser.
 1538 
 1539 # The usage line for option parsing errors and the start of '-h' and
 1540 # '--help' output messages. You can embed shell variables for delayed
 1541 # expansion at the time the message is displayed, but you will need to
 1542 # quote other shell meta-characters carefully to prevent them being
 1543 # expanded when the contents are evaled.
 1544 usage='$progpath [OPTION]...'
 1545 
 1546 # Short help message in response to '-h' and '--help'.  Add to this or
 1547 # override it after sourcing this library to reflect the full set of
 1548 # options your script accepts.
 1549 usage_message="\
 1550        --debug        enable verbose shell tracing
 1551    -W, --warnings=CATEGORY
 1552                       report the warnings falling in CATEGORY [all]
 1553    -v, --verbose      verbosely report processing
 1554        --version      print version information and exit
 1555    -h, --help         print short or long help message and exit
 1556 "
 1557 
 1558 # Additional text appended to 'usage_message' in response to '--help'.
 1559 long_help_message="
 1560 Warning categories include:
 1561        'all'          show all warnings
 1562        'none'         turn off all the warnings
 1563        'error'        warnings are treated as fatal errors"
 1564 
 1565 # Help message printed before fatal option parsing errors.
 1566 fatal_help="Try '\$progname --help' for more information."
 1567 
 1568 
 1569 
 1570 ## ------------------------- ##
 1571 ## Hook function management. ##
 1572 ## ------------------------- ##
 1573 
 1574 # This section contains functions for adding, removing, and running hooks
 1575 # to the main code.  A hook is just a named list of of function, that can
 1576 # be run in order later on.
 1577 
 1578 # func_hookable FUNC_NAME
 1579 # -----------------------
 1580 # Declare that FUNC_NAME will run hooks added with
 1581 # 'func_add_hook FUNC_NAME ...'.
 1582 func_hookable ()
 1583 {
 1584     $debug_cmd
 1585 
 1586     func_append hookable_fns " $1"
 1587 }
 1588 
 1589 
 1590 # func_add_hook FUNC_NAME HOOK_FUNC
 1591 # ---------------------------------
 1592 # Request that FUNC_NAME call HOOK_FUNC before it returns.  FUNC_NAME must
 1593 # first have been declared "hookable" by a call to 'func_hookable'.
 1594 func_add_hook ()
 1595 {
 1596     $debug_cmd
 1597 
 1598     case " $hookable_fns " in
 1599       *" $1 "*) ;;
 1600       *) func_fatal_error "'$1' does not accept hook functions." ;;
 1601     esac
 1602 
 1603     eval func_append ${1}_hooks '" $2"'
 1604 }
 1605 
 1606 
 1607 # func_remove_hook FUNC_NAME HOOK_FUNC
 1608 # ------------------------------------
 1609 # Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
 1610 func_remove_hook ()
 1611 {
 1612     $debug_cmd
 1613 
 1614     eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
 1615 }
 1616 
 1617 
 1618 # func_run_hooks FUNC_NAME [ARG]...
 1619 # ---------------------------------
 1620 # Run all hook functions registered to FUNC_NAME.
 1621 # It is assumed that the list of hook functions contains nothing more
 1622 # than a whitespace-delimited list of legal shell function names, and
 1623 # no effort is wasted trying to catch shell meta-characters or preserve
 1624 # whitespace.
 1625 func_run_hooks ()
 1626 {
 1627     $debug_cmd
 1628 
 1629     _G_rc_run_hooks=false
 1630 
 1631     case " $hookable_fns " in
 1632       *" $1 "*) ;;
 1633       *) func_fatal_error "'$1' does not support hook funcions.n" ;;
 1634     esac
 1635 
 1636     eval _G_hook_fns=\$$1_hooks; shift
 1637 
 1638     for _G_hook in $_G_hook_fns; do
 1639       if eval $_G_hook '"$@"'; then
 1640         # store returned options list back into positional
 1641         # parameters for next 'cmd' execution.
 1642         eval _G_hook_result=\$${_G_hook}_result
 1643         eval set dummy "$_G_hook_result"; shift
 1644         _G_rc_run_hooks=:
 1645       fi
 1646     done
 1647 
 1648     $_G_rc_run_hooks && func_run_hooks_result=$_G_hook_result
 1649 }
 1650 
 1651 
 1652 
 1653 ## --------------- ##
 1654 ## Option parsing. ##
 1655 ## --------------- ##
 1656 
 1657 # In order to add your own option parsing hooks, you must accept the
 1658 # full positional parameter list in your hook function, you may remove/edit
 1659 # any options that you action, and then pass back the remaining unprocessed
 1660 # options in '<hooked_function_name>_result', escaped suitably for
 1661 # 'eval'.  In this case you also must return $EXIT_SUCCESS to let the
 1662 # hook's caller know that it should pay attention to
 1663 # '<hooked_function_name>_result'.  Returning $EXIT_FAILURE signalizes that
 1664 # arguments are left untouched by the hook and therefore caller will ignore the
 1665 # result variable.
 1666 #
 1667 # Like this:
 1668 #
 1669 #    my_options_prep ()
 1670 #    {
 1671 #        $debug_cmd
 1672 #
 1673 #        # Extend the existing usage message.
 1674 #        usage_message=$usage_message'
 1675 #      -s, --silent       don'\''t print informational messages
 1676 #    '
 1677 #        # No change in '$@' (ignored completely by this hook).  There is
 1678 #        # no need to do the equivalent (but slower) action:
 1679 #        # func_quote eval ${1+"$@"}
 1680 #        # my_options_prep_result=$func_quote_result
 1681 #        false
 1682 #    }
 1683 #    func_add_hook func_options_prep my_options_prep
 1684 #
 1685 #
 1686 #    my_silent_option ()
 1687 #    {
 1688 #        $debug_cmd
 1689 #
 1690 #        args_changed=false
 1691 #
 1692 #        # Note that for efficiency, we parse as many options as we can
 1693 #        # recognise in a loop before passing the remainder back to the
 1694 #        # caller on the first unrecognised argument we encounter.
 1695 #        while test $# -gt 0; do
 1696 #          opt=$1; shift
 1697 #          case $opt in
 1698 #            --silent|-s) opt_silent=:
 1699 #                         args_changed=:
 1700 #                         ;;
 1701 #            # Separate non-argument short options:
 1702 #            -s*)         func_split_short_opt "$_G_opt"
 1703 #                         set dummy "$func_split_short_opt_name" \
 1704 #                             "-$func_split_short_opt_arg" ${1+"$@"}
 1705 #                         shift
 1706 #                         args_changed=:
 1707 #                         ;;
 1708 #            *)           # Make sure the first unrecognised option "$_G_opt"
 1709 #                         # is added back to "$@", we could need that later
 1710 #                         # if $args_changed is true.
 1711 #                         set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
 1712 #          esac
 1713 #        done
 1714 #
 1715 #        if $args_changed; then
 1716 #          func_quote eval ${1+"$@"}
 1717 #          my_silent_option_result=$func_quote_result
 1718 #        fi
 1719 #
 1720 #        $args_changed
 1721 #    }
 1722 #    func_add_hook func_parse_options my_silent_option
 1723 #
 1724 #
 1725 #    my_option_validation ()
 1726 #    {
 1727 #        $debug_cmd
 1728 #
 1729 #        $opt_silent && $opt_verbose && func_fatal_help "\
 1730 #    '--silent' and '--verbose' options are mutually exclusive."
 1731 #
 1732 #        false
 1733 #    }
 1734 #    func_add_hook func_validate_options my_option_validation
 1735 #
 1736 # You'll also need to manually amend $usage_message to reflect the extra
 1737 # options you parse.  It's preferable to append if you can, so that
 1738 # multiple option parsing hooks can be added safely.
 1739 
 1740 
 1741 # func_options_finish [ARG]...
 1742 # ----------------------------
 1743 # Finishing the option parse loop (call 'func_options' hooks ATM).
 1744 func_options_finish ()
 1745 {
 1746     $debug_cmd
 1747 
 1748     _G_func_options_finish_exit=false
 1749     if func_run_hooks func_options ${1+"$@"}; then
 1750       func_options_finish_result=$func_run_hooks_result
 1751       _G_func_options_finish_exit=:
 1752     fi
 1753 
 1754     $_G_func_options_finish_exit
 1755 }
 1756 
 1757 
 1758 # func_options [ARG]...
 1759 # ---------------------
 1760 # All the functions called inside func_options are hookable. See the
 1761 # individual implementations for details.
 1762 func_hookable func_options
 1763 func_options ()
 1764 {
 1765     $debug_cmd
 1766 
 1767     _G_rc_options=false
 1768 
 1769     for my_func in options_prep parse_options validate_options options_finish
 1770     do
 1771       if eval func_$my_func '${1+"$@"}'; then
 1772         eval _G_res_var='$'"func_${my_func}_result"
 1773         eval set dummy "$_G_res_var" ; shift
 1774         _G_rc_options=:
 1775       fi
 1776     done
 1777 
 1778     # Save modified positional parameters for caller.  As a top-level
 1779     # options-parser function we always need to set the 'func_options_result'
 1780     # variable (regardless the $_G_rc_options value).
 1781     if $_G_rc_options; then
 1782       func_options_result=$_G_res_var
 1783     else
 1784       func_quote eval ${1+"$@"}
 1785       func_options_result=$func_quote_result
 1786     fi
 1787 
 1788     $_G_rc_options
 1789 }
 1790 
 1791 
 1792 # func_options_prep [ARG]...
 1793 # --------------------------
 1794 # All initialisations required before starting the option parse loop.
 1795 # Note that when calling hook functions, we pass through the list of
 1796 # positional parameters.  If a hook function modifies that list, and
 1797 # needs to propagate that back to rest of this script, then the complete
 1798 # modified list must be put in 'func_run_hooks_result' before
 1799 # returning $EXIT_SUCCESS (otherwise $EXIT_FAILURE is returned).
 1800 func_hookable func_options_prep
 1801 func_options_prep ()
 1802 {
 1803     $debug_cmd
 1804 
 1805     # Option defaults:
 1806     opt_verbose=false
 1807     opt_warning_types=
 1808 
 1809     _G_rc_options_prep=false
 1810     if func_run_hooks func_options_prep ${1+"$@"}; then
 1811       _G_rc_options_prep=:
 1812       # save modified positional parameters for caller
 1813       func_options_prep_result=$func_run_hooks_result
 1814     fi
 1815 
 1816     $_G_rc_options_prep
 1817 }
 1818 
 1819 
 1820 # func_parse_options [ARG]...
 1821 # ---------------------------
 1822 # The main option parsing loop.
 1823 func_hookable func_parse_options
 1824 func_parse_options ()
 1825 {
 1826     $debug_cmd
 1827 
 1828     func_parse_options_result=
 1829 
 1830     _G_rc_parse_options=false
 1831     # this just eases exit handling
 1832     while test $# -gt 0; do
 1833       # Defer to hook functions for initial option parsing, so they
 1834       # get priority in the event of reusing an option name.
 1835       if func_run_hooks func_parse_options ${1+"$@"}; then
 1836         eval set dummy "$func_run_hooks_result"; shift
 1837         _G_rc_parse_options=:
 1838       fi
 1839 
 1840       # Break out of the loop if we already parsed every option.
 1841       test $# -gt 0 || break
 1842 
 1843       _G_match_parse_options=:
 1844       _G_opt=$1
 1845       shift
 1846       case $_G_opt in
 1847         --debug|-x)   debug_cmd='set -x'
 1848                       func_echo "enabling shell trace mode"
 1849                       $debug_cmd
 1850                       ;;
 1851 
 1852         --no-warnings|--no-warning|--no-warn)
 1853                       set dummy --warnings none ${1+"$@"}
 1854                       shift
 1855               ;;
 1856 
 1857         --warnings|--warning|-W)
 1858                       if test $# = 0 && func_missing_arg $_G_opt; then
 1859                         _G_rc_parse_options=:
 1860                         break
 1861                       fi
 1862                       case " $warning_categories $1" in
 1863                         *" $1 "*)
 1864                           # trailing space prevents matching last $1 above
 1865                           func_append_uniq opt_warning_types " $1"
 1866                           ;;
 1867                         *all)
 1868                           opt_warning_types=$warning_categories
 1869                           ;;
 1870                         *none)
 1871                           opt_warning_types=none
 1872                           warning_func=:
 1873                           ;;
 1874                         *error)
 1875                           opt_warning_types=$warning_categories
 1876                           warning_func=func_fatal_error
 1877                           ;;
 1878                         *)
 1879                           func_fatal_error \
 1880                              "unsupported warning category: '$1'"
 1881                           ;;
 1882                       esac
 1883                       shift
 1884                       ;;
 1885 
 1886         --verbose|-v) opt_verbose=: ;;
 1887         --version)    func_version ;;
 1888         -\?|-h)       func_usage ;;
 1889         --help)       func_help ;;
 1890 
 1891     # Separate optargs to long options (plugins may need this):
 1892     --*=*)        func_split_equals "$_G_opt"
 1893                   set dummy "$func_split_equals_lhs" \
 1894                           "$func_split_equals_rhs" ${1+"$@"}
 1895                       shift
 1896                       ;;
 1897 
 1898        # Separate optargs to short options:
 1899         -W*)
 1900                       func_split_short_opt "$_G_opt"
 1901                       set dummy "$func_split_short_opt_name" \
 1902                           "$func_split_short_opt_arg" ${1+"$@"}
 1903                       shift
 1904                       ;;
 1905 
 1906         # Separate non-argument short options:
 1907         -\?*|-h*|-v*|-x*)
 1908                       func_split_short_opt "$_G_opt"
 1909                       set dummy "$func_split_short_opt_name" \
 1910                           "-$func_split_short_opt_arg" ${1+"$@"}
 1911                       shift
 1912                       ;;
 1913 
 1914         --)           _G_rc_parse_options=: ; break ;;
 1915         -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
 1916         *)            set dummy "$_G_opt" ${1+"$@"}; shift
 1917                       _G_match_parse_options=false
 1918                       break
 1919                       ;;
 1920       esac
 1921 
 1922       $_G_match_parse_options && _G_rc_parse_options=:
 1923     done
 1924 
 1925 
 1926     if $_G_rc_parse_options; then
 1927       # save modified positional parameters for caller
 1928       func_quote eval ${1+"$@"}
 1929       func_parse_options_result=$func_quote_result
 1930     fi
 1931 
 1932     $_G_rc_parse_options
 1933 }
 1934 
 1935 
 1936 # func_validate_options [ARG]...
 1937 # ------------------------------
 1938 # Perform any sanity checks on option settings and/or unconsumed
 1939 # arguments.
 1940 func_hookable func_validate_options
 1941 func_validate_options ()
 1942 {
 1943     $debug_cmd
 1944 
 1945     _G_rc_validate_options=false
 1946 
 1947     # Display all warnings if -W was not given.
 1948     test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
 1949 
 1950     if func_run_hooks func_validate_options ${1+"$@"}; then
 1951       # save modified positional parameters for caller
 1952       func_validate_options_result=$func_run_hooks_result
 1953       _G_rc_validate_options=:
 1954     fi
 1955 
 1956     # Bail if the options were screwed!
 1957     $exit_cmd $EXIT_FAILURE
 1958 
 1959     $_G_rc_validate_options
 1960 }
 1961 
 1962 
 1963 
 1964 ## ----------------- ##
 1965 ## Helper functions. ##
 1966 ## ----------------- ##
 1967 
 1968 # This section contains the helper functions used by the rest of the
 1969 # hookable option parser framework in ascii-betical order.
 1970 
 1971 
 1972 # func_fatal_help ARG...
 1973 # ----------------------
 1974 # Echo program name prefixed message to standard error, followed by
 1975 # a help hint, and exit.
 1976 func_fatal_help ()
 1977 {
 1978     $debug_cmd
 1979 
 1980     eval \$ECHO \""Usage: $usage"\"
 1981     eval \$ECHO \""$fatal_help"\"
 1982     func_error ${1+"$@"}
 1983     exit $EXIT_FAILURE
 1984 }
 1985 
 1986 
 1987 # func_help
 1988 # ---------
 1989 # Echo long help message to standard output and exit.
 1990 func_help ()
 1991 {
 1992     $debug_cmd
 1993 
 1994     func_usage_message
 1995     $ECHO "$long_help_message"
 1996     exit 0
 1997 }
 1998 
 1999 
 2000 # func_missing_arg ARGNAME
 2001 # ------------------------
 2002 # Echo program name prefixed message to standard error and set global
 2003 # exit_cmd.
 2004 func_missing_arg ()
 2005 {
 2006     $debug_cmd
 2007 
 2008     func_error "Missing argument for '$1'."
 2009     exit_cmd=exit
 2010 }
 2011 
 2012 
 2013 # func_split_equals STRING
 2014 # ------------------------
 2015 # Set func_split_equals_lhs and func_split_equals_rhs shell variables after
 2016 # splitting STRING at the '=' sign.
 2017 test -z "$_G_HAVE_XSI_OPS" \
 2018     && (eval 'x=a/b/c;
 2019       test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
 2020     && _G_HAVE_XSI_OPS=yes
 2021 
 2022 if test yes = "$_G_HAVE_XSI_OPS"
 2023 then
 2024   # This is an XSI compatible shell, allowing a faster implementation...
 2025   eval 'func_split_equals ()
 2026   {
 2027       $debug_cmd
 2028 
 2029       func_split_equals_lhs=${1%%=*}
 2030       func_split_equals_rhs=${1#*=}
 2031       test "x$func_split_equals_lhs" = "x$1" \
 2032         && func_split_equals_rhs=
 2033   }'
 2034 else
 2035   # ...otherwise fall back to using expr, which is often a shell builtin.
 2036   func_split_equals ()
 2037   {
 2038       $debug_cmd
 2039 
 2040       func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
 2041       func_split_equals_rhs=
 2042       test "x$func_split_equals_lhs" = "x$1" \
 2043         || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
 2044   }
 2045 fi #func_split_equals
 2046 
 2047 
 2048 # func_split_short_opt SHORTOPT
 2049 # -----------------------------
 2050 # Set func_split_short_opt_name and func_split_short_opt_arg shell
 2051 # variables after splitting SHORTOPT after the 2nd character.
 2052 if test yes = "$_G_HAVE_XSI_OPS"
 2053 then
 2054   # This is an XSI compatible shell, allowing a faster implementation...
 2055   eval 'func_split_short_opt ()
 2056   {
 2057       $debug_cmd
 2058 
 2059       func_split_short_opt_arg=${1#??}
 2060       func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
 2061   }'
 2062 else
 2063   # ...otherwise fall back to using expr, which is often a shell builtin.
 2064   func_split_short_opt ()
 2065   {
 2066       $debug_cmd
 2067 
 2068       func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
 2069       func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
 2070   }
 2071 fi #func_split_short_opt
 2072 
 2073 
 2074 # func_usage
 2075 # ----------
 2076 # Echo short help message to standard output and exit.
 2077 func_usage ()
 2078 {
 2079     $debug_cmd
 2080 
 2081     func_usage_message
 2082     $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
 2083     exit 0
 2084 }
 2085 
 2086 
 2087 # func_usage_message
 2088 # ------------------
 2089 # Echo short help message to standard output.
 2090 func_usage_message ()
 2091 {
 2092     $debug_cmd
 2093 
 2094     eval \$ECHO \""Usage: $usage"\"
 2095     echo
 2096     $SED -n 's|^# ||
 2097         /^Written by/{
 2098           x;p;x
 2099         }
 2100     h
 2101     /^Written by/q' < "$progpath"
 2102     echo
 2103     eval \$ECHO \""$usage_message"\"
 2104 }
 2105 
 2106 
 2107 # func_version
 2108 # ------------
 2109 # Echo version message to standard output and exit.
 2110 func_version ()
 2111 {
 2112     $debug_cmd
 2113 
 2114     printf '%s\n' "$progname $scriptversion"
 2115     $SED -n '
 2116         /(C)/!b go
 2117         :more
 2118         /\./!{
 2119           N
 2120           s|\n# | |
 2121           b more
 2122         }
 2123         :go
 2124         /^# Written by /,/# warranty; / {
 2125           s|^# ||
 2126           s|^# *$||
 2127           s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
 2128           p
 2129         }
 2130         /^# Written by / {
 2131           s|^# ||
 2132           p
 2133         }
 2134         /^warranty; /q' < "$progpath"
 2135 
 2136     exit $?
 2137 }
 2138 
 2139 
 2140 # Local variables:
 2141 # mode: shell-script
 2142 # sh-indentation: 2
 2143 # eval: (add-hook 'before-save-hook 'time-stamp)
 2144 # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
 2145 # time-stamp-time-zone: "UTC"
 2146 # End:
 2147 
 2148 # Set a version string.
 2149 scriptversion='(GNU libtool) 2.4.6'
 2150 
 2151 
 2152 # func_echo ARG...
 2153 # ----------------
 2154 # Libtool also displays the current mode in messages, so override
 2155 # funclib.sh func_echo with this custom definition.
 2156 func_echo ()
 2157 {
 2158     $debug_cmd
 2159 
 2160     _G_message=$*
 2161 
 2162     func_echo_IFS=$IFS
 2163     IFS=$nl
 2164     for _G_line in $_G_message; do
 2165       IFS=$func_echo_IFS
 2166       $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
 2167     done
 2168     IFS=$func_echo_IFS
 2169 }
 2170 
 2171 
 2172 # func_warning ARG...
 2173 # -------------------
 2174 # Libtool warnings are not categorized, so override funclib.sh
 2175 # func_warning with this simpler definition.
 2176 func_warning ()
 2177 {
 2178     $debug_cmd
 2179 
 2180     $warning_func ${1+"$@"}
 2181 }
 2182 
 2183 
 2184 ## ---------------- ##
 2185 ## Options parsing. ##
 2186 ## ---------------- ##
 2187 
 2188 # Hook in the functions to make sure our own options are parsed during
 2189 # the option parsing loop.
 2190 
 2191 usage='$progpath [OPTION]... [MODE-ARG]...'
 2192 
 2193 # Short help message in response to '-h'.
 2194 usage_message="Options:
 2195        --config             show all configuration variables
 2196        --debug              enable verbose shell tracing
 2197    -n, --dry-run            display commands without modifying any files
 2198        --features           display basic configuration information and exit
 2199        --mode=MODE          use operation mode MODE
 2200        --no-warnings        equivalent to '-Wnone'
 2201        --preserve-dup-deps  don't remove duplicate dependency libraries
 2202        --quiet, --silent    don't print informational messages
 2203        --tag=TAG            use configuration variables from tag TAG
 2204    -v, --verbose            print more informational messages than default
 2205        --version            print version information
 2206    -W, --warnings=CATEGORY  report the warnings falling in CATEGORY [all]
 2207    -h, --help, --help-all   print short, long, or detailed help message
 2208 "
 2209 
 2210 # Additional text appended to 'usage_message' in response to '--help'.
 2211 func_help ()
 2212 {
 2213     $debug_cmd
 2214 
 2215     func_usage_message
 2216     $ECHO "$long_help_message
 2217 
 2218 MODE must be one of the following:
 2219 
 2220        clean           remove files from the build directory
 2221        compile         compile a source file into a libtool object
 2222        execute         automatically set library path, then run a program
 2223        finish          complete the installation of libtool libraries
 2224        install         install libraries or executables
 2225        link            create a library or an executable
 2226        uninstall       remove libraries from an installed directory
 2227 
 2228 MODE-ARGS vary depending on the MODE.  When passed as first option,
 2229 '--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
 2230 Try '$progname --help --mode=MODE' for a more detailed description of MODE.
 2231 
 2232 When reporting a bug, please describe a test case to reproduce it and
 2233 include the following information:
 2234 
 2235        host-triplet:   $host
 2236        shell:          $SHELL
 2237        compiler:       $LTCC
 2238        compiler flags: $LTCFLAGS
 2239        linker:         $LD (gnu? $with_gnu_ld)
 2240        version:        $progname $scriptversion Debian-2.4.6-2.1
 2241        automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
 2242        autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
 2243 
 2244 Report bugs to <bug-libtool@gnu.org>.
 2245 GNU libtool home page: <http://www.gnu.org/s/libtool/>.
 2246 General help using GNU software: <http://www.gnu.org/gethelp/>."
 2247     exit 0
 2248 }
 2249 
 2250 
 2251 # func_lo2o OBJECT-NAME
 2252 # ---------------------
 2253 # Transform OBJECT-NAME from a '.lo' suffix to the platform specific
 2254 # object suffix.
 2255 
 2256 lo2o=s/\\.lo\$/.$objext/
 2257 o2lo=s/\\.$objext\$/.lo/
 2258 
 2259 if test yes = "$_G_HAVE_XSI_OPS"; then
 2260   eval 'func_lo2o ()
 2261   {
 2262     case $1 in
 2263       *.lo) func_lo2o_result=${1%.lo}.$objext ;;
 2264       *   ) func_lo2o_result=$1               ;;
 2265     esac
 2266   }'
 2267 
 2268   # func_xform LIBOBJ-OR-SOURCE
 2269   # ---------------------------
 2270   # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
 2271   # suffix to a '.lo' libtool-object suffix.
 2272   eval 'func_xform ()
 2273   {
 2274     func_xform_result=${1%.*}.lo
 2275   }'
 2276 else
 2277   # ...otherwise fall back to using sed.
 2278   func_lo2o ()
 2279   {
 2280     func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
 2281   }
 2282 
 2283   func_xform ()
 2284   {
 2285     func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
 2286   }
 2287 fi
 2288 
 2289 
 2290 # func_fatal_configuration ARG...
 2291 # -------------------------------
 2292 # Echo program name prefixed message to standard error, followed by
 2293 # a configuration failure hint, and exit.
 2294 func_fatal_configuration ()
 2295 {
 2296     func__fatal_error ${1+"$@"} \
 2297       "See the $PACKAGE documentation for more information." \
 2298       "Fatal configuration error."
 2299 }
 2300 
 2301 
 2302 # func_config
 2303 # -----------
 2304 # Display the configuration for all the tags in this script.
 2305 func_config ()
 2306 {
 2307     re_begincf='^# ### BEGIN LIBTOOL'
 2308     re_endcf='^# ### END LIBTOOL'
 2309 
 2310     # Default configuration.
 2311     $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
 2312 
 2313     # Now print the configurations for the tags.
 2314     for tagname in $taglist; do
 2315       $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
 2316     done
 2317 
 2318     exit $?
 2319 }
 2320 
 2321 
 2322 # func_features
 2323 # -------------
 2324 # Display the features supported by this script.
 2325 func_features ()
 2326 {
 2327     echo "host: $host"
 2328     if test yes = "$build_libtool_libs"; then
 2329       echo "enable shared libraries"
 2330     else
 2331       echo "disable shared libraries"
 2332     fi
 2333     if test yes = "$build_old_libs"; then
 2334       echo "enable static libraries"
 2335     else
 2336       echo "disable static libraries"
 2337     fi
 2338 
 2339     exit $?
 2340 }
 2341 
 2342 
 2343 # func_enable_tag TAGNAME
 2344 # -----------------------
 2345 # Verify that TAGNAME is valid, and either flag an error and exit, or
 2346 # enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
 2347 # variable here.
 2348 func_enable_tag ()
 2349 {
 2350     # Global variable:
 2351     tagname=$1
 2352 
 2353     re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
 2354     re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
 2355     sed_extractcf=/$re_begincf/,/$re_endcf/p
 2356 
 2357     # Validate tagname.
 2358     case $tagname in
 2359       *[!-_A-Za-z0-9,/]*)
 2360         func_fatal_error "invalid tag name: $tagname"
 2361         ;;
 2362     esac
 2363 
 2364     # Don't test for the "default" C tag, as we know it's
 2365     # there but not specially marked.
 2366     case $tagname in
 2367         CC) ;;
 2368     *)
 2369         if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
 2370       taglist="$taglist $tagname"
 2371 
 2372       # Evaluate the configuration.  Be careful to quote the path
 2373       # and the sed script, to avoid splitting on whitespace, but
 2374       # also don't use non-portable quotes within backquotes within
 2375       # quotes we have to do it in 2 steps:
 2376       extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
 2377       eval "$extractedcf"
 2378         else
 2379       func_error "ignoring unknown tag $tagname"
 2380         fi
 2381         ;;
 2382     esac
 2383 }
 2384 
 2385 
 2386 # func_check_version_match
 2387 # ------------------------
 2388 # Ensure that we are using m4 macros, and libtool script from the same
 2389 # release of libtool.
 2390 func_check_version_match ()
 2391 {
 2392     if test "$package_revision" != "$macro_revision"; then
 2393       if test "$VERSION" != "$macro_version"; then
 2394         if test -z "$macro_version"; then
 2395           cat >&2 <<_LT_EOF
 2396 $progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
 2397 $progname: definition of this LT_INIT comes from an older release.
 2398 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
 2399 $progname: and run autoconf again.
 2400 _LT_EOF
 2401         else
 2402           cat >&2 <<_LT_EOF
 2403 $progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
 2404 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
 2405 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
 2406 $progname: and run autoconf again.
 2407 _LT_EOF
 2408         fi
 2409       else
 2410         cat >&2 <<_LT_EOF
 2411 $progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
 2412 $progname: but the definition of this LT_INIT comes from revision $macro_revision.
 2413 $progname: You should recreate aclocal.m4 with macros from revision $package_revision
 2414 $progname: of $PACKAGE $VERSION and run autoconf again.
 2415 _LT_EOF
 2416       fi
 2417 
 2418       exit $EXIT_MISMATCH
 2419     fi
 2420 }
 2421 
 2422 
 2423 # libtool_options_prep [ARG]...
 2424 # -----------------------------
 2425 # Preparation for options parsed by libtool.
 2426 libtool_options_prep ()
 2427 {
 2428     $debug_mode
 2429 
 2430     # Option defaults:
 2431     opt_config=false
 2432     opt_dlopen=
 2433     opt_dry_run=false
 2434     opt_help=false
 2435     opt_mode=
 2436     opt_preserve_dup_deps=false
 2437     opt_quiet=false
 2438 
 2439     nonopt=
 2440     preserve_args=
 2441 
 2442     _G_rc_lt_options_prep=:
 2443 
 2444     # Shorthand for --mode=foo, only valid as the first argument
 2445     case $1 in
 2446     clean|clea|cle|cl)
 2447       shift; set dummy --mode clean ${1+"$@"}; shift
 2448       ;;
 2449     compile|compil|compi|comp|com|co|c)
 2450       shift; set dummy --mode compile ${1+"$@"}; shift
 2451       ;;
 2452     execute|execut|execu|exec|exe|ex|e)
 2453       shift; set dummy --mode execute ${1+"$@"}; shift
 2454       ;;
 2455     finish|finis|fini|fin|fi|f)
 2456       shift; set dummy --mode finish ${1+"$@"}; shift
 2457       ;;
 2458     install|instal|insta|inst|ins|in|i)
 2459       shift; set dummy --mode install ${1+"$@"}; shift
 2460       ;;
 2461     link|lin|li|l)
 2462       shift; set dummy --mode link ${1+"$@"}; shift
 2463       ;;
 2464     uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
 2465       shift; set dummy --mode uninstall ${1+"$@"}; shift
 2466       ;;
 2467     *)
 2468       _G_rc_lt_options_prep=false
 2469       ;;
 2470     esac
 2471 
 2472     if $_G_rc_lt_options_prep; then
 2473       # Pass back the list of options.
 2474       func_quote eval ${1+"$@"}
 2475       libtool_options_prep_result=$func_quote_result
 2476     fi
 2477 
 2478     $_G_rc_lt_options_prep
 2479 }
 2480 func_add_hook func_options_prep libtool_options_prep
 2481 
 2482 
 2483 # libtool_parse_options [ARG]...
 2484 # ---------------------------------
 2485 # Provide handling for libtool specific options.
 2486 libtool_parse_options ()
 2487 {
 2488     $debug_cmd
 2489 
 2490     _G_rc_lt_parse_options=false
 2491 
 2492     # Perform our own loop to consume as many options as possible in
 2493     # each iteration.
 2494     while test $# -gt 0; do
 2495       _G_match_lt_parse_options=:
 2496       _G_opt=$1
 2497       shift
 2498       case $_G_opt in
 2499         --dry-run|--dryrun|-n)
 2500                         opt_dry_run=:
 2501                         ;;
 2502 
 2503         --config)       func_config ;;
 2504 
 2505         --dlopen|-dlopen)
 2506                         opt_dlopen="${opt_dlopen+$opt_dlopen
 2507 }$1"
 2508                         shift
 2509                         ;;
 2510 
 2511         --preserve-dup-deps)
 2512                         opt_preserve_dup_deps=: ;;
 2513 
 2514         --features)     func_features ;;
 2515 
 2516         --finish)       set dummy --mode finish ${1+"$@"}; shift ;;
 2517 
 2518         --help)         opt_help=: ;;
 2519 
 2520         --help-all)     opt_help=': help-all' ;;
 2521 
 2522         --mode)         test $# = 0 && func_missing_arg $_G_opt && break
 2523                         opt_mode=$1
 2524                         case $1 in
 2525                           # Valid mode arguments:
 2526                           clean|compile|execute|finish|install|link|relink|uninstall) ;;
 2527 
 2528                           # Catch anything else as an error
 2529                           *) func_error "invalid argument for $_G_opt"
 2530                              exit_cmd=exit
 2531                              break
 2532                              ;;
 2533                         esac
 2534                         shift
 2535                         ;;
 2536 
 2537         --no-silent|--no-quiet)
 2538                         opt_quiet=false
 2539                         func_append preserve_args " $_G_opt"
 2540                         ;;
 2541 
 2542         --no-warnings|--no-warning|--no-warn)
 2543                         opt_warning=false
 2544                         func_append preserve_args " $_G_opt"
 2545                         ;;
 2546 
 2547         --no-verbose)
 2548                         opt_verbose=false
 2549                         func_append preserve_args " $_G_opt"
 2550                         ;;
 2551 
 2552         --silent|--quiet)
 2553                         opt_quiet=:
 2554                         opt_verbose=false
 2555                         func_append preserve_args " $_G_opt"
 2556                         ;;
 2557 
 2558         --tag)          test $# = 0 && func_missing_arg $_G_opt && break
 2559                         opt_tag=$1
 2560                         func_append preserve_args " $_G_opt $1"
 2561                         func_enable_tag "$1"
 2562                         shift
 2563                         ;;
 2564 
 2565         --verbose|-v)   opt_quiet=false
 2566                         opt_verbose=:
 2567                         func_append preserve_args " $_G_opt"
 2568                         ;;
 2569 
 2570         # An option not handled by this hook function:
 2571         *)              set dummy "$_G_opt" ${1+"$@"} ; shift
 2572                         _G_match_lt_parse_options=false
 2573                         break
 2574                         ;;
 2575       esac
 2576       $_G_match_lt_parse_options && _G_rc_lt_parse_options=:
 2577     done
 2578 
 2579     if $_G_rc_lt_parse_options; then
 2580       # save modified positional parameters for caller
 2581       func_quote eval ${1+"$@"}
 2582       libtool_parse_options_result=$func_quote_result
 2583     fi
 2584 
 2585     $_G_rc_lt_parse_options
 2586 }
 2587 func_add_hook func_parse_options libtool_parse_options
 2588 
 2589 
 2590 
 2591 # libtool_validate_options [ARG]...
 2592 # ---------------------------------
 2593 # Perform any sanity checks on option settings and/or unconsumed
 2594 # arguments.
 2595 libtool_validate_options ()
 2596 {
 2597     # save first non-option argument
 2598     if test 0 -lt $#; then
 2599       nonopt=$1
 2600       shift
 2601     fi
 2602 
 2603     # preserve --debug
 2604     test : = "$debug_cmd" || func_append preserve_args " --debug"
 2605 
 2606     case $host in
 2607       # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
 2608       # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
 2609       *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
 2610         # don't eliminate duplications in $postdeps and $predeps
 2611         opt_duplicate_compiler_generated_deps=:
 2612         ;;
 2613       *)
 2614         opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
 2615         ;;
 2616     esac
 2617 
 2618     $opt_help || {
 2619       # Sanity checks first:
 2620       func_check_version_match
 2621 
 2622       test yes != "$build_libtool_libs" \
 2623         && test yes != "$build_old_libs" \
 2624         && func_fatal_configuration "not configured to build any kind of library"
 2625 
 2626       # Darwin sucks
 2627       eval std_shrext=\"$shrext_cmds\"
 2628 
 2629       # Only execute mode is allowed to have -dlopen flags.
 2630       if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
 2631         func_error "unrecognized option '-dlopen'"
 2632         $ECHO "$help" 1>&2
 2633         exit $EXIT_FAILURE
 2634       fi
 2635 
 2636       # Change the help message to a mode-specific one.
 2637       generic_help=$help
 2638       help="Try '$progname --help --mode=$opt_mode' for more information."
 2639     }
 2640 
 2641     # Pass back the unparsed argument list
 2642     func_quote eval ${1+"$@"}
 2643     libtool_validate_options_result=$func_quote_result
 2644 }
 2645 func_add_hook func_validate_options libtool_validate_options
 2646 
 2647 
 2648 # Process options as early as possible so that --help and --version
 2649 # can return quickly.
 2650 func_options ${1+"$@"}
 2651 eval set dummy "$func_options_result"; shift
 2652 
 2653 
 2654 
 2655 ## ----------- ##
 2656 ##    Main.    ##
 2657 ## ----------- ##
 2658 
 2659 magic='%%%MAGIC variable%%%'
 2660 magic_exe='%%%MAGIC EXE variable%%%'
 2661 
 2662 # Global variables.
 2663 extracted_archives=
 2664 extracted_serial=0
 2665 
 2666 # If this variable is set in any of the actions, the command in it
 2667 # will be execed at the end.  This prevents here-documents from being
 2668 # left over by shells.
 2669 exec_cmd=
 2670 
 2671 
 2672 # A function that is used when there is no print builtin or printf.
 2673 func_fallback_echo ()
 2674 {
 2675   eval 'cat <<_LTECHO_EOF
 2676 $1
 2677 _LTECHO_EOF'
 2678 }
 2679 
 2680 # func_generated_by_libtool
 2681 # True iff stdin has been generated by Libtool. This function is only
 2682 # a basic sanity check; it will hardly flush out determined imposters.
 2683 func_generated_by_libtool_p ()
 2684 {
 2685   $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
 2686 }
 2687 
 2688 # func_lalib_p file
 2689 # True iff FILE is a libtool '.la' library or '.lo' object file.
 2690 # This function is only a basic sanity check; it will hardly flush out
 2691 # determined imposters.
 2692 func_lalib_p ()
 2693 {
 2694     test -f "$1" &&
 2695       $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
 2696 }
 2697 
 2698 # func_lalib_unsafe_p file
 2699 # True iff FILE is a libtool '.la' library or '.lo' object file.
 2700 # This function implements the same check as func_lalib_p without
 2701 # resorting to external programs.  To this end, it redirects stdin and
 2702 # closes it afterwards, without saving the original file descriptor.
 2703 # As a safety measure, use it only where a negative result would be
 2704 # fatal anyway.  Works if 'file' does not exist.
 2705 func_lalib_unsafe_p ()
 2706 {
 2707     lalib_p=no
 2708     if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
 2709     for lalib_p_l in 1 2 3 4
 2710     do
 2711         read lalib_p_line
 2712         case $lalib_p_line in
 2713         \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
 2714         esac
 2715     done
 2716     exec 0<&5 5<&-
 2717     fi
 2718     test yes = "$lalib_p"
 2719 }
 2720 
 2721 # func_ltwrapper_script_p file
 2722 # True iff FILE is a libtool wrapper script
 2723 # This function is only a basic sanity check; it will hardly flush out
 2724 # determined imposters.
 2725 func_ltwrapper_script_p ()
 2726 {
 2727     test -f "$1" &&
 2728       $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
 2729 }
 2730 
 2731 # func_ltwrapper_executable_p file
 2732 # True iff FILE is a libtool wrapper executable
 2733 # This function is only a basic sanity check; it will hardly flush out
 2734 # determined imposters.
 2735 func_ltwrapper_executable_p ()
 2736 {
 2737     func_ltwrapper_exec_suffix=
 2738     case $1 in
 2739     *.exe) ;;
 2740     *) func_ltwrapper_exec_suffix=.exe ;;
 2741     esac
 2742     $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
 2743 }
 2744 
 2745 # func_ltwrapper_scriptname file
 2746 # Assumes file is an ltwrapper_executable
 2747 # uses $file to determine the appropriate filename for a
 2748 # temporary ltwrapper_script.
 2749 func_ltwrapper_scriptname ()
 2750 {
 2751     func_dirname_and_basename "$1" "" "."
 2752     func_stripname '' '.exe' "$func_basename_result"
 2753     func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
 2754 }
 2755 
 2756 # func_ltwrapper_p file
 2757 # True iff FILE is a libtool wrapper script or wrapper executable
 2758 # This function is only a basic sanity check; it will hardly flush out
 2759 # determined imposters.
 2760 func_ltwrapper_p ()
 2761 {
 2762     func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
 2763 }
 2764 
 2765 
 2766 # func_execute_cmds commands fail_cmd
 2767 # Execute tilde-delimited COMMANDS.
 2768 # If FAIL_CMD is given, eval that upon failure.
 2769 # FAIL_CMD may read-access the current command in variable CMD!
 2770 func_execute_cmds ()
 2771 {
 2772     $debug_cmd
 2773 
 2774     save_ifs=$IFS; IFS='~'
 2775     for cmd in $1; do
 2776       IFS=$sp$nl
 2777       eval cmd=\"$cmd\"
 2778       IFS=$save_ifs
 2779       func_show_eval "$cmd" "${2-:}"
 2780     done
 2781     IFS=$save_ifs
 2782 }
 2783 
 2784 
 2785 # func_source file
 2786 # Source FILE, adding directory component if necessary.
 2787 # Note that it is not necessary on cygwin/mingw to append a dot to
 2788 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
 2789 # behavior happens only for exec(3), not for open(2)!  Also, sourcing
 2790 # 'FILE.' does not work on cygwin managed mounts.
 2791 func_source ()
 2792 {
 2793     $debug_cmd
 2794 
 2795     case $1 in
 2796     */* | *\\*) . "$1" ;;
 2797     *)      . "./$1" ;;
 2798     esac
 2799 }
 2800 
 2801 
 2802 # func_resolve_sysroot PATH
 2803 # Replace a leading = in PATH with a sysroot.  Store the result into
 2804 # func_resolve_sysroot_result
 2805 func_resolve_sysroot ()
 2806 {
 2807   func_resolve_sysroot_result=$1
 2808   case $func_resolve_sysroot_result in
 2809   =*)
 2810     func_stripname '=' '' "$func_resolve_sysroot_result"
 2811     func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
 2812     ;;
 2813   esac
 2814 }
 2815 
 2816 # func_replace_sysroot PATH
 2817 # If PATH begins with the sysroot, replace it with = and
 2818 # store the result into func_replace_sysroot_result.
 2819 func_replace_sysroot ()
 2820 {
 2821   case $lt_sysroot:$1 in
 2822   ?*:"$lt_sysroot"*)
 2823     func_stripname "$lt_sysroot" '' "$1"
 2824     func_replace_sysroot_result='='$func_stripname_result
 2825     ;;
 2826   *)
 2827     # Including no sysroot.
 2828     func_replace_sysroot_result=$1
 2829     ;;
 2830   esac
 2831 }
 2832 
 2833 # func_infer_tag arg
 2834 # Infer tagged configuration to use if any are available and
 2835 # if one wasn't chosen via the "--tag" command line option.
 2836 # Only attempt this if the compiler in the base compile
 2837 # command doesn't match the default compiler.
 2838 # arg is usually of the form 'gcc ...'
 2839 func_infer_tag ()
 2840 {
 2841     $debug_cmd
 2842 
 2843     if test -n "$available_tags" && test -z "$tagname"; then
 2844       CC_quoted=
 2845       for arg in $CC; do
 2846     func_append_quoted CC_quoted "$arg"
 2847       done
 2848       CC_expanded=`func_echo_all $CC`
 2849       CC_quoted_expanded=`func_echo_all $CC_quoted`
 2850       case $@ in
 2851       # Blanks in the command may have been stripped by the calling shell,
 2852       # but not from the CC environment variable when configure was run.
 2853       " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
 2854       " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
 2855       # Blanks at the start of $base_compile will cause this to fail
 2856       # if we don't check for them as well.
 2857       *)
 2858     for z in $available_tags; do
 2859       if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
 2860         # Evaluate the configuration.
 2861         eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
 2862         CC_quoted=
 2863         for arg in $CC; do
 2864           # Double-quote args containing other shell metacharacters.
 2865           func_append_quoted CC_quoted "$arg"
 2866         done
 2867         CC_expanded=`func_echo_all $CC`
 2868         CC_quoted_expanded=`func_echo_all $CC_quoted`
 2869         case "$@ " in
 2870         " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
 2871         " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
 2872           # The compiler in the base compile command matches
 2873           # the one in the tagged configuration.
 2874           # Assume this is the tagged configuration we want.
 2875           tagname=$z
 2876           break
 2877           ;;
 2878         esac
 2879       fi
 2880     done
 2881     # If $tagname still isn't set, then no tagged configuration
 2882     # was found and let the user know that the "--tag" command
 2883     # line option must be used.
 2884     if test -z "$tagname"; then
 2885       func_echo "unable to infer tagged configuration"
 2886       func_fatal_error "specify a tag with '--tag'"
 2887 #   else
 2888 #     func_verbose "using $tagname tagged configuration"
 2889     fi
 2890     ;;
 2891       esac
 2892     fi
 2893 }
 2894 
 2895 
 2896 
 2897 # func_write_libtool_object output_name pic_name nonpic_name
 2898 # Create a libtool object file (analogous to a ".la" file),
 2899 # but don't create it if we're doing a dry run.
 2900 func_write_libtool_object ()
 2901 {
 2902     write_libobj=$1
 2903     if test yes = "$build_libtool_libs"; then
 2904       write_lobj=\'$2\'
 2905     else
 2906       write_lobj=none
 2907     fi
 2908 
 2909     if test yes = "$build_old_libs"; then
 2910       write_oldobj=\'$3\'
 2911     else
 2912       write_oldobj=none
 2913     fi
 2914 
 2915     $opt_dry_run || {
 2916       cat >${write_libobj}T <<EOF
 2917 # $write_libobj - a libtool object file
 2918 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
 2919 #
 2920 # Please DO NOT delete this file!
 2921 # It is necessary for linking the library.
 2922 
 2923 # Name of the PIC object.
 2924 pic_object=$write_lobj
 2925 
 2926 # Name of the non-PIC object
 2927 non_pic_object=$write_oldobj
 2928 
 2929 EOF
 2930       $MV "${write_libobj}T" "$write_libobj"
 2931     }
 2932 }
 2933 
 2934 
 2935 ##################################################
 2936 # FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
 2937 ##################################################
 2938 
 2939 # func_convert_core_file_wine_to_w32 ARG
 2940 # Helper function used by file name conversion functions when $build is *nix,
 2941 # and $host is mingw, cygwin, or some other w32 environment. Relies on a
 2942 # correctly configured wine environment available, with the winepath program
 2943 # in $build's $PATH.
 2944 #
 2945 # ARG is the $build file name to be converted to w32 format.
 2946 # Result is available in $func_convert_core_file_wine_to_w32_result, and will
 2947 # be empty on error (or when ARG is empty)
 2948 func_convert_core_file_wine_to_w32 ()
 2949 {
 2950   $debug_cmd
 2951 
 2952   func_convert_core_file_wine_to_w32_result=$1
 2953   if test -n "$1"; then
 2954     # Unfortunately, winepath does not exit with a non-zero error code, so we
 2955     # are forced to check the contents of stdout. On the other hand, if the
 2956     # command is not found, the shell will set an exit code of 127 and print
 2957     # *an error message* to stdout. So we must check for both error code of
 2958     # zero AND non-empty stdout, which explains the odd construction:
 2959     func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
 2960     if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
 2961       func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
 2962         $SED -e "$sed_naive_backslashify"`
 2963     else
 2964       func_convert_core_file_wine_to_w32_result=
 2965     fi
 2966   fi
 2967 }
 2968 # end: func_convert_core_file_wine_to_w32
 2969 
 2970 
 2971 # func_convert_core_path_wine_to_w32 ARG
 2972 # Helper function used by path conversion functions when $build is *nix, and
 2973 # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
 2974 # configured wine environment available, with the winepath program in $build's
 2975 # $PATH. Assumes ARG has no leading or trailing path separator characters.
 2976 #
 2977 # ARG is path to be converted from $build format to win32.
 2978 # Result is available in $func_convert_core_path_wine_to_w32_result.
 2979 # Unconvertible file (directory) names in ARG are skipped; if no directory names
 2980 # are convertible, then the result may be empty.
 2981 func_convert_core_path_wine_to_w32 ()
 2982 {
 2983   $debug_cmd
 2984 
 2985   # unfortunately, winepath doesn't convert paths, only file names
 2986   func_convert_core_path_wine_to_w32_result=
 2987   if test -n "$1"; then
 2988     oldIFS=$IFS
 2989     IFS=:
 2990     for func_convert_core_path_wine_to_w32_f in $1; do
 2991       IFS=$oldIFS
 2992       func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
 2993       if test -n "$func_convert_core_file_wine_to_w32_result"; then
 2994         if test -z "$func_convert_core_path_wine_to_w32_result"; then
 2995           func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
 2996         else
 2997           func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
 2998         fi
 2999       fi
 3000     done
 3001     IFS=$oldIFS
 3002   fi
 3003 }
 3004 # end: func_convert_core_path_wine_to_w32
 3005 
 3006 
 3007 # func_cygpath ARGS...
 3008 # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
 3009 # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
 3010 # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
 3011 # (2), returns the Cygwin file name or path in func_cygpath_result (input
 3012 # file name or path is assumed to be in w32 format, as previously converted
 3013 # from $build's *nix or MSYS format). In case (3), returns the w32 file name
 3014 # or path in func_cygpath_result (input file name or path is assumed to be in
 3015 # Cygwin format). Returns an empty string on error.
 3016 #
 3017 # ARGS are passed to cygpath, with the last one being the file name or path to
 3018 # be converted.
 3019 #
 3020 # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
 3021 # environment variable; do not put it in $PATH.
 3022 func_cygpath ()
 3023 {
 3024   $debug_cmd
 3025 
 3026   if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
 3027     func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
 3028     if test "$?" -ne 0; then
 3029       # on failure, ensure result is empty
 3030       func_cygpath_result=
 3031     fi
 3032   else
 3033     func_cygpath_result=
 3034     func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
 3035   fi
 3036 }
 3037 #end: func_cygpath
 3038 
 3039 
 3040 # func_convert_core_msys_to_w32 ARG
 3041 # Convert file name or path ARG from MSYS format to w32 format.  Return
 3042 # result in func_convert_core_msys_to_w32_result.
 3043 func_convert_core_msys_to_w32 ()
 3044 {
 3045   $debug_cmd
 3046 
 3047   # awkward: cmd appends spaces to result
 3048   func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
 3049     $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
 3050 }
 3051 #end: func_convert_core_msys_to_w32
 3052 
 3053 
 3054 # func_convert_file_check ARG1 ARG2
 3055 # Verify that ARG1 (a file name in $build format) was converted to $host
 3056 # format in ARG2. Otherwise, emit an error message, but continue (resetting
 3057 # func_to_host_file_result to ARG1).
 3058 func_convert_file_check ()
 3059 {
 3060   $debug_cmd
 3061 
 3062   if test -z "$2" && test -n "$1"; then
 3063     func_error "Could not determine host file name corresponding to"
 3064     func_error "  '$1'"
 3065     func_error "Continuing, but uninstalled executables may not work."
 3066     # Fallback:
 3067     func_to_host_file_result=$1
 3068   fi
 3069 }
 3070 # end func_convert_file_check
 3071 
 3072 
 3073 # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
 3074 # Verify that FROM_PATH (a path in $build format) was converted to $host
 3075 # format in TO_PATH. Otherwise, emit an error message, but continue, resetting
 3076 # func_to_host_file_result to a simplistic fallback value (see below).
 3077 func_convert_path_check ()
 3078 {
 3079   $debug_cmd
 3080 
 3081   if test -z "$4" && test -n "$3"; then
 3082     func_error "Could not determine the host path corresponding to"
 3083     func_error "  '$3'"
 3084     func_error "Continuing, but uninstalled executables may not work."
 3085     # Fallback.  This is a deliberately simplistic "conversion" and
 3086     # should not be "improved".  See libtool.info.
 3087     if test "x$1" != "x$2"; then
 3088       lt_replace_pathsep_chars="s|$1|$2|g"
 3089       func_to_host_path_result=`echo "$3" |
 3090         $SED -e "$lt_replace_pathsep_chars"`
 3091     else
 3092       func_to_host_path_result=$3
 3093     fi
 3094   fi
 3095 }
 3096 # end func_convert_path_check
 3097 
 3098 
 3099 # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
 3100 # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
 3101 # and appending REPL if ORIG matches BACKPAT.
 3102 func_convert_path_front_back_pathsep ()
 3103 {
 3104   $debug_cmd
 3105 
 3106   case $4 in
 3107   $1 ) func_to_host_path_result=$3$func_to_host_path_result
 3108     ;;
 3109   esac
 3110   case $4 in
 3111   $2 ) func_append func_to_host_path_result "$3"
 3112     ;;
 3113   esac
 3114 }
 3115 # end func_convert_path_front_back_pathsep
 3116 
 3117 
 3118 ##################################################
 3119 # $build to $host FILE NAME CONVERSION FUNCTIONS #
 3120 ##################################################
 3121 # invoked via '$to_host_file_cmd ARG'
 3122 #
 3123 # In each case, ARG is the path to be converted from $build to $host format.
 3124 # Result will be available in $func_to_host_file_result.
 3125 
 3126 
 3127 # func_to_host_file ARG
 3128 # Converts the file name ARG from $build format to $host format. Return result
 3129 # in func_to_host_file_result.
 3130 func_to_host_file ()
 3131 {
 3132   $debug_cmd
 3133 
 3134   $to_host_file_cmd "$1"
 3135 }
 3136 # end func_to_host_file
 3137 
 3138 
 3139 # func_to_tool_file ARG LAZY
 3140 # converts the file name ARG from $build format to toolchain format. Return
 3141 # result in func_to_tool_file_result.  If the conversion in use is listed
 3142 # in (the comma separated) LAZY, no conversion takes place.
 3143 func_to_tool_file ()
 3144 {
 3145   $debug_cmd
 3146 
 3147   case ,$2, in
 3148     *,"$to_tool_file_cmd",*)
 3149       func_to_tool_file_result=$1
 3150       ;;
 3151     *)
 3152       $to_tool_file_cmd "$1"
 3153       func_to_tool_file_result=$func_to_host_file_result
 3154       ;;
 3155   esac
 3156 }
 3157 # end func_to_tool_file
 3158 
 3159 
 3160 # func_convert_file_noop ARG
 3161 # Copy ARG to func_to_host_file_result.
 3162 func_convert_file_noop ()
 3163 {
 3164   func_to_host_file_result=$1
 3165 }
 3166 # end func_convert_file_noop
 3167 
 3168 
 3169 # func_convert_file_msys_to_w32 ARG
 3170 # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
 3171 # conversion to w32 is not available inside the cwrapper.  Returns result in
 3172 # func_to_host_file_result.
 3173 func_convert_file_msys_to_w32 ()
 3174 {
 3175   $debug_cmd
 3176 
 3177   func_to_host_file_result=$1
 3178   if test -n "$1"; then
 3179     func_convert_core_msys_to_w32 "$1"
 3180     func_to_host_file_result=$func_convert_core_msys_to_w32_result
 3181   fi
 3182   func_convert_file_check "$1" "$func_to_host_file_result"
 3183 }
 3184 # end func_convert_file_msys_to_w32
 3185 
 3186 
 3187 # func_convert_file_cygwin_to_w32 ARG
 3188 # Convert file name ARG from Cygwin to w32 format.  Returns result in
 3189 # func_to_host_file_result.
 3190 func_convert_file_cygwin_to_w32 ()
 3191 {
 3192   $debug_cmd
 3193 
 3194   func_to_host_file_result=$1
 3195   if test -n "$1"; then
 3196     # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
 3197     # LT_CYGPATH in this case.
 3198     func_to_host_file_result=`cygpath -m "$1"`
 3199   fi
 3200   func_convert_file_check "$1" "$func_to_host_file_result"
 3201 }
 3202 # end func_convert_file_cygwin_to_w32
 3203 
 3204 
 3205 # func_convert_file_nix_to_w32 ARG
 3206 # Convert file name ARG from *nix to w32 format.  Requires a wine environment
 3207 # and a working winepath. Returns result in func_to_host_file_result.
 3208 func_convert_file_nix_to_w32 ()
 3209 {
 3210   $debug_cmd
 3211 
 3212   func_to_host_file_result=$1
 3213   if test -n "$1"; then
 3214     func_convert_core_file_wine_to_w32 "$1"
 3215     func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
 3216   fi
 3217   func_convert_file_check "$1" "$func_to_host_file_result"
 3218 }
 3219 # end func_convert_file_nix_to_w32
 3220 
 3221 
 3222 # func_convert_file_msys_to_cygwin ARG
 3223 # Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
 3224 # Returns result in func_to_host_file_result.
 3225 func_convert_file_msys_to_cygwin ()
 3226 {
 3227   $debug_cmd
 3228 
 3229   func_to_host_file_result=$1
 3230   if test -n "$1"; then
 3231     func_convert_core_msys_to_w32 "$1"
 3232     func_cygpath -u "$func_convert_core_msys_to_w32_result"
 3233     func_to_host_file_result=$func_cygpath_result
 3234   fi
 3235   func_convert_file_check "$1" "$func_to_host_file_result"
 3236 }
 3237 # end func_convert_file_msys_to_cygwin
 3238 
 3239 
 3240 # func_convert_file_nix_to_cygwin ARG
 3241 # Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
 3242 # in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
 3243 # in func_to_host_file_result.
 3244 func_convert_file_nix_to_cygwin ()
 3245 {
 3246   $debug_cmd
 3247 
 3248   func_to_host_file_result=$1
 3249   if test -n "$1"; then
 3250     # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
 3251     func_convert_core_file_wine_to_w32 "$1"
 3252     func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
 3253     func_to_host_file_result=$func_cygpath_result
 3254   fi
 3255   func_convert_file_check "$1" "$func_to_host_file_result"
 3256 }
 3257 # end func_convert_file_nix_to_cygwin
 3258 
 3259 
 3260 #############################################
 3261 # $build to $host PATH CONVERSION FUNCTIONS #
 3262 #############################################
 3263 # invoked via '$to_host_path_cmd ARG'
 3264 #
 3265 # In each case, ARG is the path to be converted from $build to $host format.
 3266 # The result will be available in $func_to_host_path_result.
 3267 #
 3268 # Path separators are also converted from $build format to $host format.  If
 3269 # ARG begins or ends with a path separator character, it is preserved (but
 3270 # converted to $host format) on output.
 3271 #
 3272 # All path conversion functions are named using the following convention:
 3273 #   file name conversion function    : func_convert_file_X_to_Y ()
 3274 #   path conversion function         : func_convert_path_X_to_Y ()
 3275 # where, for any given $build/$host combination the 'X_to_Y' value is the
 3276 # same.  If conversion functions are added for new $build/$host combinations,
 3277 # the two new functions must follow this pattern, or func_init_to_host_path_cmd
 3278 # will break.
 3279 
 3280 
 3281 # func_init_to_host_path_cmd
 3282 # Ensures that function "pointer" variable $to_host_path_cmd is set to the
 3283 # appropriate value, based on the value of $to_host_file_cmd.
 3284 to_host_path_cmd=
 3285 func_init_to_host_path_cmd ()
 3286 {
 3287   $debug_cmd
 3288 
 3289   if test -z "$to_host_path_cmd"; then
 3290     func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
 3291     to_host_path_cmd=func_convert_path_$func_stripname_result
 3292   fi
 3293 }
 3294 
 3295 
 3296 # func_to_host_path ARG
 3297 # Converts the path ARG from $build format to $host format. Return result
 3298 # in func_to_host_path_result.
 3299 func_to_host_path ()
 3300 {
 3301   $debug_cmd
 3302 
 3303   func_init_to_host_path_cmd
 3304   $to_host_path_cmd "$1"
 3305 }
 3306 # end func_to_host_path
 3307 
 3308 
 3309 # func_convert_path_noop ARG
 3310 # Copy ARG to func_to_host_path_result.
 3311 func_convert_path_noop ()
 3312 {
 3313   func_to_host_path_result=$1
 3314 }
 3315 # end func_convert_path_noop
 3316 
 3317 
 3318 # func_convert_path_msys_to_w32 ARG
 3319 # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
 3320 # conversion to w32 is not available inside the cwrapper.  Returns result in
 3321 # func_to_host_path_result.
 3322 func_convert_path_msys_to_w32 ()
 3323 {
 3324   $debug_cmd
 3325 
 3326   func_to_host_path_result=$1
 3327   if test -n "$1"; then
 3328     # Remove leading and trailing path separator characters from ARG.  MSYS
 3329     # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
 3330     # and winepath ignores them completely.
 3331     func_stripname : : "$1"
 3332     func_to_host_path_tmp1=$func_stripname_result
 3333     func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
 3334     func_to_host_path_result=$func_convert_core_msys_to_w32_result
 3335     func_convert_path_check : ";" \
 3336       "$func_to_host_path_tmp1" "$func_to_host_path_result"
 3337     func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
 3338   fi
 3339 }
 3340 # end func_convert_path_msys_to_w32
 3341 
 3342 
 3343 # func_convert_path_cygwin_to_w32 ARG
 3344 # Convert path ARG from Cygwin to w32 format.  Returns result in
 3345 # func_to_host_file_result.
 3346 func_convert_path_cygwin_to_w32 ()
 3347 {
 3348   $debug_cmd
 3349 
 3350   func_to_host_path_result=$1
 3351   if test -n "$1"; then
 3352     # See func_convert_path_msys_to_w32:
 3353     func_stripname : : "$1"
 3354     func_to_host_path_tmp1=$func_stripname_result
 3355     func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
 3356     func_convert_path_check : ";" \
 3357       "$func_to_host_path_tmp1" "$func_to_host_path_result"
 3358     func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
 3359   fi
 3360 }
 3361 # end func_convert_path_cygwin_to_w32
 3362 
 3363 
 3364 # func_convert_path_nix_to_w32 ARG
 3365 # Convert path ARG from *nix to w32 format.  Requires a wine environment and
 3366 # a working winepath.  Returns result in func_to_host_file_result.
 3367 func_convert_path_nix_to_w32 ()
 3368 {
 3369   $debug_cmd
 3370 
 3371   func_to_host_path_result=$1
 3372   if test -n "$1"; then
 3373     # See func_convert_path_msys_to_w32:
 3374     func_stripname : : "$1"
 3375     func_to_host_path_tmp1=$func_stripname_result
 3376     func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
 3377     func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
 3378     func_convert_path_check : ";" \
 3379       "$func_to_host_path_tmp1" "$func_to_host_path_result"
 3380     func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
 3381   fi
 3382 }
 3383 # end func_convert_path_nix_to_w32
 3384 
 3385 
 3386 # func_convert_path_msys_to_cygwin ARG
 3387 # Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
 3388 # Returns result in func_to_host_file_result.
 3389 func_convert_path_msys_to_cygwin ()
 3390 {
 3391   $debug_cmd
 3392 
 3393   func_to_host_path_result=$1
 3394   if test -n "$1"; then
 3395     # See func_convert_path_msys_to_w32:
 3396     func_stripname : : "$1"
 3397     func_to_host_path_tmp1=$func_stripname_result
 3398     func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
 3399     func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
 3400     func_to_host_path_result=$func_cygpath_result
 3401     func_convert_path_check : : \
 3402       "$func_to_host_path_tmp1" "$func_to_host_path_result"
 3403     func_convert_path_front_back_pathsep ":*" "*:" : "$1"
 3404   fi
 3405 }
 3406 # end func_convert_path_msys_to_cygwin
 3407 
 3408 
 3409 # func_convert_path_nix_to_cygwin ARG
 3410 # Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
 3411 # a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
 3412 # func_to_host_file_result.
 3413 func_convert_path_nix_to_cygwin ()
 3414 {
 3415   $debug_cmd
 3416 
 3417   func_to_host_path_result=$1
 3418   if test -n "$1"; then
 3419     # Remove leading and trailing path separator characters from
 3420     # ARG. msys behavior is inconsistent here, cygpath turns them
 3421     # into '.;' and ';.', and winepath ignores them completely.
 3422     func_stripname : : "$1"
 3423     func_to_host_path_tmp1=$func_stripname_result
 3424     func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
 3425     func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
 3426     func_to_host_path_result=$func_cygpath_result
 3427     func_convert_path_check : : \
 3428       "$func_to_host_path_tmp1" "$func_to_host_path_result"
 3429     func_convert_path_front_back_pathsep ":*" "*:" : "$1"
 3430   fi
 3431 }
 3432 # end func_convert_path_nix_to_cygwin
 3433 
 3434 
 3435 # func_dll_def_p FILE
 3436 # True iff FILE is a Windows DLL '.def' file.
 3437 # Keep in sync with _LT_DLL_DEF_P in libtool.m4
 3438 func_dll_def_p ()
 3439 {
 3440   $debug_cmd
 3441 
 3442   func_dll_def_p_tmp=`$SED -n \
 3443     -e 's/^[     ]*//' \
 3444     -e '/^\(;.*\)*$/d' \
 3445     -e 's/^\(EXPORTS\|LIBRARY\)\([   ].*\)*$/DEF/p' \
 3446     -e q \
 3447     "$1"`
 3448   test DEF = "$func_dll_def_p_tmp"
 3449 }
 3450 
 3451 
 3452 # func_mode_compile arg...
 3453 func_mode_compile ()
 3454 {
 3455     $debug_cmd
 3456 
 3457     # Get the compilation command and the source file.
 3458     base_compile=
 3459     srcfile=$nonopt  #  always keep a non-empty value in "srcfile"
 3460     suppress_opt=yes
 3461     suppress_output=
 3462     arg_mode=normal
 3463     libobj=
 3464     later=
 3465     pie_flag=
 3466 
 3467     for arg
 3468     do
 3469       case $arg_mode in
 3470       arg  )
 3471     # do not "continue".  Instead, add this to base_compile
 3472     lastarg=$arg
 3473     arg_mode=normal
 3474     ;;
 3475 
 3476       target )
 3477     libobj=$arg
 3478     arg_mode=normal
 3479     continue
 3480     ;;
 3481 
 3482       normal )
 3483     # Accept any command-line options.
 3484     case $arg in
 3485     -o)
 3486       test -n "$libobj" && \
 3487         func_fatal_error "you cannot specify '-o' more than once"
 3488       arg_mode=target
 3489       continue
 3490       ;;
 3491 
 3492     -pie | -fpie | -fPIE)
 3493           func_append pie_flag " $arg"
 3494       continue
 3495       ;;
 3496 
 3497     -shared | -static | -prefer-pic | -prefer-non-pic)
 3498       func_append later " $arg"
 3499       continue
 3500       ;;
 3501 
 3502     -no-suppress)
 3503       suppress_opt=no
 3504       continue
 3505       ;;
 3506 
 3507     -Xcompiler)
 3508       arg_mode=arg  #  the next one goes into the "base_compile" arg list
 3509       continue      #  The current "srcfile" will either be retained or
 3510       ;;            #  replaced later.  I would guess that would be a bug.
 3511 
 3512     -Wc,*)
 3513       func_stripname '-Wc,' '' "$arg"
 3514       args=$func_stripname_result
 3515       lastarg=
 3516       save_ifs=$IFS; IFS=,
 3517       for arg in $args; do
 3518         IFS=$save_ifs
 3519         func_append_quoted lastarg "$arg"
 3520       done
 3521       IFS=$save_ifs
 3522       func_stripname ' ' '' "$lastarg"
 3523       lastarg=$func_stripname_result
 3524 
 3525       # Add the arguments to base_compile.
 3526       func_append base_compile " $lastarg"
 3527       continue
 3528       ;;
 3529 
 3530     *)
 3531       # Accept the current argument as the source file.
 3532       # The previous "srcfile" becomes the current argument.
 3533       #
 3534       lastarg=$srcfile
 3535       srcfile=$arg
 3536       ;;
 3537     esac  #  case $arg
 3538     ;;
 3539       esac    #  case $arg_mode
 3540 
 3541       # Aesthetically quote the previous argument.
 3542       func_append_quoted base_compile "$lastarg"
 3543     done # for arg
 3544 
 3545     case $arg_mode in
 3546     arg)
 3547       func_fatal_error "you must specify an argument for -Xcompile"
 3548       ;;
 3549     target)
 3550       func_fatal_error "you must specify a target with '-o'"
 3551       ;;
 3552     *)
 3553       # Get the name of the library object.
 3554       test -z "$libobj" && {
 3555     func_basename "$srcfile"
 3556     libobj=$func_basename_result
 3557       }
 3558       ;;
 3559     esac
 3560 
 3561     # Recognize several different file suffixes.
 3562     # If the user specifies -o file.o, it is replaced with file.lo
 3563     case $libobj in
 3564     *.[cCFSifmso] | \
 3565     *.ada | *.adb | *.ads | *.asm | \
 3566     *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
 3567     *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
 3568       func_xform "$libobj"
 3569       libobj=$func_xform_result
 3570       ;;
 3571     esac
 3572 
 3573     case $libobj in
 3574     *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
 3575     *)
 3576       func_fatal_error "cannot determine name of library object from '$libobj'"
 3577       ;;
 3578     esac
 3579 
 3580     func_infer_tag $base_compile
 3581 
 3582     for arg in $later; do
 3583       case $arg in
 3584       -shared)
 3585     test yes = "$build_libtool_libs" \
 3586       || func_fatal_configuration "cannot build a shared library"
 3587     build_old_libs=no
 3588     continue
 3589     ;;
 3590 
 3591       -static)
 3592     build_libtool_libs=no
 3593     build_old_libs=yes
 3594     continue
 3595     ;;
 3596 
 3597       -prefer-pic)
 3598     pic_mode=yes
 3599     continue
 3600     ;;
 3601 
 3602       -prefer-non-pic)
 3603     pic_mode=no
 3604     continue
 3605     ;;
 3606       esac
 3607     done
 3608 
 3609     func_quote_arg pretty "$libobj"
 3610     test "X$libobj" != "X$func_quote_arg_result" \
 3611       && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'    &()|`$[]' \
 3612       && func_warning "libobj name '$libobj' may not contain shell special characters."
 3613     func_dirname_and_basename "$obj" "/" ""
 3614     objname=$func_basename_result
 3615     xdir=$func_dirname_result
 3616     lobj=$xdir$objdir/$objname
 3617 
 3618     test -z "$base_compile" && \
 3619       func_fatal_help "you must specify a compilation command"
 3620 
 3621     # Delete any leftover library objects.
 3622     if test yes = "$build_old_libs"; then
 3623       removelist="$obj $lobj $libobj ${libobj}T"
 3624     else
 3625       removelist="$lobj $libobj ${libobj}T"
 3626     fi
 3627 
 3628     # On Cygwin there's no "real" PIC flag so we must build both object types
 3629     case $host_os in
 3630     cygwin* | mingw* | pw32* | os2* | cegcc*)
 3631       pic_mode=default
 3632       ;;
 3633     esac
 3634     if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
 3635       # non-PIC code in shared libraries is not supported
 3636       pic_mode=default
 3637     fi
 3638 
 3639     # Calculate the filename of the output object if compiler does
 3640     # not support -o with -c
 3641     if test no = "$compiler_c_o"; then
 3642       output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
 3643       lockfile=$output_obj.lock
 3644     else
 3645       output_obj=
 3646       need_locks=no
 3647       lockfile=
 3648     fi
 3649 
 3650     # Lock this critical section if it is needed
 3651     # We use this script file to make the link, it avoids creating a new file
 3652     if test yes = "$need_locks"; then
 3653       until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
 3654     func_echo "Waiting for $lockfile to be removed"
 3655     sleep 2
 3656       done
 3657     elif test warn = "$need_locks"; then
 3658       if test -f "$lockfile"; then
 3659     $ECHO "\
 3660 *** ERROR, $lockfile exists and contains:
 3661 `cat $lockfile 2>/dev/null`
 3662 
 3663 This indicates that another process is trying to use the same
 3664 temporary object file, and libtool could not work around it because
 3665 your compiler does not support '-c' and '-o' together.  If you
 3666 repeat this compilation, it may succeed, by chance, but you had better
 3667 avoid parallel builds (make -j) in this platform, or get a better
 3668 compiler."
 3669 
 3670     $opt_dry_run || $RM $removelist
 3671     exit $EXIT_FAILURE
 3672       fi
 3673       func_append removelist " $output_obj"
 3674       $ECHO "$srcfile" > "$lockfile"
 3675     fi
 3676 
 3677     $opt_dry_run || $RM $removelist
 3678     func_append removelist " $lockfile"
 3679     trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
 3680 
 3681     func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
 3682     srcfile=$func_to_tool_file_result
 3683     func_quote_arg pretty "$srcfile"
 3684     qsrcfile=$func_quote_arg_result
 3685 
 3686     # Only build a PIC object if we are building libtool libraries.
 3687     if test yes = "$build_libtool_libs"; then
 3688       # Without this assignment, base_compile gets emptied.
 3689       fbsd_hideous_sh_bug=$base_compile
 3690 
 3691       if test no != "$pic_mode"; then
 3692     command="$base_compile $qsrcfile $pic_flag"
 3693       else
 3694     # Don't build PIC code
 3695     command="$base_compile $qsrcfile"
 3696       fi
 3697 
 3698       func_mkdir_p "$xdir$objdir"
 3699 
 3700       if test -z "$output_obj"; then
 3701     # Place PIC objects in $objdir
 3702     func_append command " -o $lobj"
 3703       fi
 3704 
 3705       func_show_eval_locale "$command"  \
 3706           'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
 3707 
 3708       if test warn = "$need_locks" &&
 3709      test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
 3710     $ECHO "\
 3711 *** ERROR, $lockfile contains:
 3712 `cat $lockfile 2>/dev/null`
 3713 
 3714 but it should contain:
 3715 $srcfile
 3716 
 3717 This indicates that another process is trying to use the same
 3718 temporary object file, and libtool could not work around it because
 3719 your compiler does not support '-c' and '-o' together.  If you
 3720 repeat this compilation, it may succeed, by chance, but you had better
 3721 avoid parallel builds (make -j) in this platform, or get a better
 3722 compiler."
 3723 
 3724     $opt_dry_run || $RM $removelist
 3725     exit $EXIT_FAILURE
 3726       fi
 3727 
 3728       # Just move the object if needed, then go on to compile the next one
 3729       if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
 3730     func_show_eval '$MV "$output_obj" "$lobj"' \
 3731       'error=$?; $opt_dry_run || $RM $removelist; exit $error'
 3732       fi
 3733 
 3734       # Allow error messages only from the first compilation.
 3735       if test yes = "$suppress_opt"; then
 3736     suppress_output=' >/dev/null 2>&1'
 3737       fi
 3738     fi
 3739 
 3740     # Only build a position-dependent object if we build old libraries.
 3741     if test yes = "$build_old_libs"; then
 3742       if test yes != "$pic_mode"; then
 3743     # Don't build PIC code
 3744     command="$base_compile $qsrcfile$pie_flag"
 3745       else
 3746     command="$base_compile $qsrcfile $pic_flag"
 3747       fi
 3748       if test yes = "$compiler_c_o"; then
 3749     func_append command " -o $obj"
 3750       fi
 3751 
 3752       # Suppress compiler output if we already did a PIC compilation.
 3753       func_append command "$suppress_output"
 3754       func_show_eval_locale "$command" \
 3755         '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
 3756 
 3757       if test warn = "$need_locks" &&
 3758      test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
 3759     $ECHO "\
 3760 *** ERROR, $lockfile contains:
 3761 `cat $lockfile 2>/dev/null`
 3762 
 3763 but it should contain:
 3764 $srcfile
 3765 
 3766 This indicates that another process is trying to use the same
 3767 temporary object file, and libtool could not work around it because
 3768 your compiler does not support '-c' and '-o' together.  If you
 3769 repeat this compilation, it may succeed, by chance, but you had better
 3770 avoid parallel builds (make -j) in this platform, or get a better
 3771 compiler."
 3772 
 3773     $opt_dry_run || $RM $removelist
 3774     exit $EXIT_FAILURE
 3775       fi
 3776 
 3777       # Just move the object if needed
 3778       if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
 3779     func_show_eval '$MV "$output_obj" "$obj"' \
 3780       'error=$?; $opt_dry_run || $RM $removelist; exit $error'
 3781       fi
 3782     fi
 3783 
 3784     $opt_dry_run || {
 3785       func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
 3786 
 3787       # Unlock the critical section if it was locked
 3788       if test no != "$need_locks"; then
 3789     removelist=$lockfile
 3790         $RM "$lockfile"
 3791       fi
 3792     }
 3793 
 3794     exit $EXIT_SUCCESS
 3795 }
 3796 
 3797 $opt_help || {
 3798   test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
 3799 }
 3800 
 3801 func_mode_help ()
 3802 {
 3803     # We need to display help for each of the modes.
 3804     case $opt_mode in
 3805       "")
 3806         # Generic help is extracted from the usage comments
 3807         # at the start of this file.
 3808         func_help
 3809         ;;
 3810 
 3811       clean)
 3812         $ECHO \
 3813 "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
 3814 
 3815 Remove files from the build directory.
 3816 
 3817 RM is the name of the program to use to delete files associated with each FILE
 3818 (typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
 3819 to RM.
 3820 
 3821 If FILE is a libtool library, object or program, all the files associated
 3822 with it are deleted. Otherwise, only FILE itself is deleted using RM."
 3823         ;;
 3824 
 3825       compile)
 3826       $ECHO \
 3827 "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
 3828 
 3829 Compile a source file into a libtool library object.
 3830 
 3831 This mode accepts the following additional options:
 3832 
 3833   -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
 3834   -no-suppress      do not suppress compiler output for multiple passes
 3835   -prefer-pic       try to build PIC objects only
 3836   -prefer-non-pic   try to build non-PIC objects only
 3837   -shared           do not build a '.o' file suitable for static linking
 3838   -static           only build a '.o' file suitable for static linking
 3839   -Wc,FLAG          pass FLAG directly to the compiler
 3840 
 3841 COMPILE-COMMAND is a command to be used in creating a 'standard' object file
 3842 from the given SOURCEFILE.
 3843 
 3844 The output file name is determined by removing the directory component from
 3845 SOURCEFILE, then substituting the C source code suffix '.c' with the
 3846 library object suffix, '.lo'."
 3847         ;;
 3848 
 3849       execute)
 3850         $ECHO \
 3851 "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
 3852 
 3853 Automatically set library path, then run a program.
 3854 
 3855 This mode accepts the following additional options:
 3856 
 3857   -dlopen FILE      add the directory containing FILE to the library path
 3858 
 3859 This mode sets the library path environment variable according to '-dlopen'
 3860 flags.
 3861 
 3862 If any of the ARGS are libtool executable wrappers, then they are translated
 3863 into their corresponding uninstalled binary, and any of their required library
 3864 directories are added to the library path.
 3865 
 3866 Then, COMMAND is executed, with ARGS as arguments."
 3867         ;;
 3868 
 3869       finish)
 3870         $ECHO \
 3871 "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
 3872 
 3873 Complete the installation of libtool libraries.
 3874 
 3875 Each LIBDIR is a directory that contains libtool libraries.
 3876 
 3877 The commands that this mode executes may require superuser privileges.  Use
 3878 the '--dry-run' option if you just want to see what would be executed."
 3879         ;;
 3880 
 3881       install)
 3882         $ECHO \
 3883 "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
 3884 
 3885 Install executables or libraries.
 3886 
 3887 INSTALL-COMMAND is the installation command.  The first component should be
 3888 either the 'install' or 'cp' program.
 3889 
 3890 The following components of INSTALL-COMMAND are treated specially:
 3891 
 3892   -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
 3893 
 3894 The rest of the components are interpreted as arguments to that command (only
 3895 BSD-compatible install options are recognized)."
 3896         ;;
 3897 
 3898       link)
 3899         $ECHO \
 3900 "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
 3901 
 3902 Link object files or libraries together to form another library, or to
 3903 create an executable program.
 3904 
 3905 LINK-COMMAND is a command using the C compiler that you would use to create
 3906 a program from several object files.
 3907 
 3908 The following components of LINK-COMMAND are treated specially:
 3909 
 3910   -all-static       do not do any dynamic linking at all
 3911   -avoid-version    do not add a version suffix if possible
 3912   -bindir BINDIR    specify path to binaries directory (for systems where
 3913                     libraries must be found in the PATH setting at runtime)
 3914   -dlopen FILE      '-dlpreopen' FILE if it cannot be dlopened at runtime
 3915   -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
 3916   -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
 3917   -export-symbols SYMFILE
 3918                     try to export only the symbols listed in SYMFILE
 3919   -export-symbols-regex REGEX
 3920                     try to export only the symbols matching REGEX
 3921   -LLIBDIR          search LIBDIR for required installed libraries
 3922   -lNAME            OUTPUT-FILE requires the installed library libNAME
 3923   -module           build a library that can dlopened
 3924   -no-fast-install  disable the fast-install mode
 3925   -no-install       link a not-installable executable
 3926   -no-undefined     declare that a library does not refer to external symbols
 3927   -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
 3928   -objectlist FILE  use a list of object files found in FILE to specify objects
 3929   -os2dllname NAME  force a short DLL name on OS/2 (no effect on other OSes)
 3930   -precious-files-regex REGEX
 3931                     don't remove output files matching REGEX
 3932   -release RELEASE  specify package release information
 3933   -rpath LIBDIR     the created library will eventually be installed in LIBDIR
 3934   -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
 3935   -shared           only do dynamic linking of libtool libraries
 3936   -shrext SUFFIX    override the standard shared library file extension
 3937   -static           do not do any dynamic linking of uninstalled libtool libraries
 3938   -static-libtool-libs
 3939                     do not do any dynamic linking of libtool libraries
 3940   -version-info CURRENT[:REVISION[:AGE]]
 3941                     specify library version info [each variable defaults to 0]
 3942   -weak LIBNAME     declare that the target provides the LIBNAME interface
 3943   -Wc,FLAG
 3944   -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
 3945   -Wl,FLAG
 3946   -Xlinker FLAG     pass linker-specific FLAG directly to the linker
 3947   -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
 3948 
 3949 All other options (arguments beginning with '-') are ignored.
 3950 
 3951 Every other argument is treated as a filename.  Files ending in '.la' are
 3952 treated as uninstalled libtool libraries, other files are standard or library
 3953 object files.
 3954 
 3955 If the OUTPUT-FILE ends in '.la', then a libtool library is created,
 3956 only library objects ('.lo' files) may be specified, and '-rpath' is
 3957 required, except when creating a convenience library.
 3958 
 3959 If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
 3960 using 'ar' and 'ranlib', or on Windows using 'lib'.
 3961 
 3962 If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
 3963 is created, otherwise an executable program is created."
 3964         ;;
 3965 
 3966       uninstall)
 3967         $ECHO \
 3968 "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
 3969 
 3970 Remove libraries from an installation directory.
 3971 
 3972 RM is the name of the program to use to delete files associated with each FILE
 3973 (typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
 3974 to RM.
 3975 
 3976 If FILE is a libtool library, all the files associated with it are deleted.
 3977 Otherwise, only FILE itself is deleted using RM."
 3978         ;;
 3979 
 3980       *)
 3981         func_fatal_help "invalid operation mode '$opt_mode'"
 3982         ;;
 3983     esac
 3984 
 3985     echo
 3986     $ECHO "Try '$progname --help' for more information about other modes."
 3987 }
 3988 
 3989 # Now that we've collected a possible --mode arg, show help if necessary
 3990 if $opt_help; then
 3991   if test : = "$opt_help"; then
 3992     func_mode_help
 3993   else
 3994     {
 3995       func_help noexit
 3996       for opt_mode in compile link execute install finish uninstall clean; do
 3997     func_mode_help
 3998       done
 3999     } | $SED -n '1p; 2,$s/^Usage:/  or: /p'
 4000     {
 4001       func_help noexit
 4002       for opt_mode in compile link execute install finish uninstall clean; do
 4003     echo
 4004     func_mode_help
 4005       done
 4006     } |
 4007     $SED '1d
 4008       /^When reporting/,/^Report/{
 4009     H
 4010     d
 4011       }
 4012       $x
 4013       /information about other modes/d
 4014       /more detailed .*MODE/d
 4015       s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
 4016   fi
 4017   exit $?
 4018 fi
 4019 
 4020 
 4021 # func_mode_execute arg...
 4022 func_mode_execute ()
 4023 {
 4024     $debug_cmd
 4025 
 4026     # The first argument is the command name.
 4027     cmd=$nonopt
 4028     test -z "$cmd" && \
 4029       func_fatal_help "you must specify a COMMAND"
 4030 
 4031     # Handle -dlopen flags immediately.
 4032     for file in $opt_dlopen; do
 4033       test -f "$file" \
 4034     || func_fatal_help "'$file' is not a file"
 4035 
 4036       dir=
 4037       case $file in
 4038       *.la)
 4039     func_resolve_sysroot "$file"
 4040     file=$func_resolve_sysroot_result
 4041 
 4042     # Check to see that this really is a libtool archive.
 4043     func_lalib_unsafe_p "$file" \
 4044       || func_fatal_help "'$lib' is not a valid libtool archive"
 4045 
 4046     # Read the libtool library.
 4047     dlname=
 4048     library_names=
 4049     func_source "$file"
 4050 
 4051     # Skip this library if it cannot be dlopened.
 4052     if test -z "$dlname"; then
 4053       # Warn if it was a shared library.
 4054       test -n "$library_names" && \
 4055         func_warning "'$file' was not linked with '-export-dynamic'"
 4056       continue
 4057     fi
 4058 
 4059     func_dirname "$file" "" "."
 4060     dir=$func_dirname_result
 4061 
 4062     if test -f "$dir/$objdir/$dlname"; then
 4063       func_append dir "/$objdir"
 4064     else
 4065       if test ! -f "$dir/$dlname"; then
 4066         func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
 4067       fi
 4068     fi
 4069     ;;
 4070 
 4071       *.lo)
 4072     # Just add the directory containing the .lo file.
 4073     func_dirname "$file" "" "."
 4074     dir=$func_dirname_result
 4075     ;;
 4076 
 4077       *)
 4078     func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
 4079     continue
 4080     ;;
 4081       esac
 4082 
 4083       # Get the absolute pathname.
 4084       absdir=`cd "$dir" && pwd`
 4085       test -n "$absdir" && dir=$absdir
 4086 
 4087       # Now add the directory to shlibpath_var.
 4088       if eval "test -z \"\$$shlibpath_var\""; then
 4089     eval "$shlibpath_var=\"\$dir\""
 4090       else
 4091     eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
 4092       fi
 4093     done
 4094 
 4095     # This variable tells wrapper scripts just to set shlibpath_var
 4096     # rather than running their programs.
 4097     libtool_execute_magic=$magic
 4098 
 4099     # Check if any of the arguments is a wrapper script.
 4100     args=
 4101     for file
 4102     do
 4103       case $file in
 4104       -* | *.la | *.lo ) ;;
 4105       *)
 4106     # Do a test to see if this is really a libtool program.
 4107     if func_ltwrapper_script_p "$file"; then
 4108       func_source "$file"
 4109       # Transform arg to wrapped name.
 4110       file=$progdir/$program
 4111     elif func_ltwrapper_executable_p "$file"; then
 4112       func_ltwrapper_scriptname "$file"
 4113       func_source "$func_ltwrapper_scriptname_result"
 4114       # Transform arg to wrapped name.
 4115       file=$progdir/$program
 4116     fi
 4117     ;;
 4118       esac
 4119       # Quote arguments (to preserve shell metacharacters).
 4120       func_append_quoted args "$file"
 4121     done
 4122 
 4123     if $opt_dry_run; then
 4124       # Display what would be done.
 4125       if test -n "$shlibpath_var"; then
 4126     eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
 4127     echo "export $shlibpath_var"
 4128       fi
 4129       $ECHO "$cmd$args"
 4130       exit $EXIT_SUCCESS
 4131     else
 4132       if test -n "$shlibpath_var"; then
 4133     # Export the shlibpath_var.
 4134     eval "export $shlibpath_var"
 4135       fi
 4136 
 4137       # Restore saved environment variables
 4138       for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
 4139       do
 4140     eval "if test \"\${save_$lt_var+set}\" = set; then
 4141                 $lt_var=\$save_$lt_var; export $lt_var
 4142           else
 4143         $lt_unset $lt_var
 4144           fi"
 4145       done
 4146 
 4147       # Now prepare to actually exec the command.
 4148       exec_cmd=\$cmd$args
 4149     fi
 4150 }
 4151 
 4152 test execute = "$opt_mode" && func_mode_execute ${1+"$@"}
 4153 
 4154 
 4155 # func_mode_finish arg...
 4156 func_mode_finish ()
 4157 {
 4158     $debug_cmd
 4159 
 4160     libs=
 4161     libdirs=
 4162     admincmds=
 4163 
 4164     for opt in "$nonopt" ${1+"$@"}
 4165     do
 4166       if test -d "$opt"; then
 4167     func_append libdirs " $opt"
 4168 
 4169       elif test -f "$opt"; then
 4170     if func_lalib_unsafe_p "$opt"; then
 4171       func_append libs " $opt"
 4172     else
 4173       func_warning "'$opt' is not a valid libtool archive"
 4174     fi
 4175 
 4176       else
 4177     func_fatal_error "invalid argument '$opt'"
 4178       fi
 4179     done
 4180 
 4181     if test -n "$libs"; then
 4182       if test -n "$lt_sysroot"; then
 4183         sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
 4184         sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
 4185       else
 4186         sysroot_cmd=
 4187       fi
 4188 
 4189       # Remove sysroot references
 4190       if $opt_dry_run; then
 4191         for lib in $libs; do
 4192           echo "removing references to $lt_sysroot and '=' prefixes from $lib"
 4193         done
 4194       else
 4195         tmpdir=`func_mktempdir`
 4196         for lib in $libs; do
 4197       $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
 4198         > $tmpdir/tmp-la
 4199       mv -f $tmpdir/tmp-la $lib
 4200     done
 4201         ${RM}r "$tmpdir"
 4202       fi
 4203     fi
 4204 
 4205     if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
 4206       for libdir in $libdirs; do
 4207     if test -n "$finish_cmds"; then
 4208       # Do each command in the finish commands.
 4209       func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
 4210 '"$cmd"'"'
 4211     fi
 4212     if test -n "$finish_eval"; then
 4213       # Do the single finish_eval.
 4214       eval cmds=\"$finish_eval\"
 4215       $opt_dry_run || eval "$cmds" || func_append admincmds "
 4216        $cmds"
 4217     fi
 4218       done
 4219     fi
 4220 
 4221     # Exit here if they wanted silent mode.
 4222     $opt_quiet && exit $EXIT_SUCCESS
 4223 
 4224     if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
 4225       echo "----------------------------------------------------------------------"
 4226       echo "Libraries have been installed in:"
 4227       for libdir in $libdirs; do
 4228     $ECHO "   $libdir"
 4229       done
 4230       echo
 4231       echo "If you ever happen to want to link against installed libraries"
 4232       echo "in a given directory, LIBDIR, you must either use libtool, and"
 4233       echo "specify the full pathname of the library, or use the '-LLIBDIR'"
 4234       echo "flag during linking and do at least one of the following:"
 4235       if test -n "$shlibpath_var"; then
 4236     echo "   - add LIBDIR to the '$shlibpath_var' environment variable"
 4237     echo "     during execution"
 4238       fi
 4239       if test -n "$runpath_var"; then
 4240     echo "   - add LIBDIR to the '$runpath_var' environment variable"
 4241     echo "     during linking"
 4242       fi
 4243       if test -n "$hardcode_libdir_flag_spec"; then
 4244     libdir=LIBDIR
 4245     eval flag=\"$hardcode_libdir_flag_spec\"
 4246 
 4247     $ECHO "   - use the '$flag' linker flag"
 4248       fi
 4249       if test -n "$admincmds"; then
 4250     $ECHO "   - have your system administrator run these commands:$admincmds"
 4251       fi
 4252       if test -f /etc/ld.so.conf; then
 4253     echo "   - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
 4254       fi
 4255       echo
 4256 
 4257       echo "See any operating system documentation about shared libraries for"
 4258       case $host in
 4259     solaris2.[6789]|solaris2.1[0-9])
 4260       echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
 4261       echo "pages."
 4262       ;;
 4263     *)
 4264       echo "more information, such as the ld(1) and ld.so(8) manual pages."
 4265       ;;
 4266       esac
 4267       echo "----------------------------------------------------------------------"
 4268     fi
 4269     exit $EXIT_SUCCESS
 4270 }
 4271 
 4272 test finish = "$opt_mode" && func_mode_finish ${1+"$@"}
 4273 
 4274 
 4275 # func_mode_install arg...
 4276 func_mode_install ()
 4277 {
 4278     $debug_cmd
 4279 
 4280     # There may be an optional sh(1) argument at the beginning of
 4281     # install_prog (especially on Windows NT).
 4282     if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
 4283        # Allow the use of GNU shtool's install command.
 4284        case $nonopt in *shtool*) :;; *) false;; esac
 4285     then
 4286       # Aesthetically quote it.
 4287       func_quote_arg pretty "$nonopt"
 4288       install_prog="$func_quote_arg_result "
 4289       arg=$1
 4290       shift
 4291     else
 4292       install_prog=
 4293       arg=$nonopt
 4294     fi
 4295 
 4296     # The real first argument should be the name of the installation program.
 4297     # Aesthetically quote it.
 4298     func_quote_arg pretty "$arg"
 4299     func_append install_prog "$func_quote_arg_result"
 4300     install_shared_prog=$install_prog
 4301     case " $install_prog " in
 4302       *[\\\ /]cp\ *) install_cp=: ;;
 4303       *) install_cp=false ;;
 4304     esac
 4305 
 4306     # We need to accept at least all the BSD install flags.
 4307     dest=
 4308     files=
 4309     opts=
 4310     prev=
 4311     install_type=
 4312     isdir=false
 4313     stripme=
 4314     no_mode=:
 4315     for arg
 4316     do
 4317       arg2=
 4318       if test -n "$dest"; then
 4319     func_append files " $dest"
 4320     dest=$arg
 4321     continue
 4322       fi
 4323 
 4324       case $arg in
 4325       -d) isdir=: ;;
 4326       -f)
 4327     if $install_cp; then :; else
 4328       prev=$arg
 4329     fi
 4330     ;;
 4331       -g | -m | -o)
 4332     prev=$arg
 4333     ;;
 4334       -s)
 4335     stripme=" -s"
 4336     continue
 4337     ;;
 4338       -*)
 4339     ;;
 4340       *)
 4341     # If the previous option needed an argument, then skip it.
 4342     if test -n "$prev"; then
 4343       if test X-m = "X$prev" && test -n "$install_override_mode"; then
 4344         arg2=$install_override_mode
 4345         no_mode=false
 4346       fi
 4347       prev=
 4348     else
 4349       dest=$arg
 4350       continue
 4351     fi
 4352     ;;
 4353       esac
 4354 
 4355       # Aesthetically quote the argument.
 4356       func_quote_arg pretty "$arg"
 4357       func_append install_prog " $func_quote_arg_result"
 4358       if test -n "$arg2"; then
 4359     func_quote_arg pretty "$arg2"
 4360       fi
 4361       func_append install_shared_prog " $func_quote_arg_result"
 4362     done
 4363 
 4364     test -z "$install_prog" && \
 4365       func_fatal_help "you must specify an install program"
 4366 
 4367     test -n "$prev" && \
 4368       func_fatal_help "the '$prev' option requires an argument"
 4369 
 4370     if test -n "$install_override_mode" && $no_mode; then
 4371       if $install_cp; then :; else
 4372     func_quote_arg pretty "$install_override_mode"
 4373     func_append install_shared_prog " -m $func_quote_arg_result"
 4374       fi
 4375     fi
 4376 
 4377     if test -z "$files"; then
 4378       if test -z "$dest"; then
 4379     func_fatal_help "no file or destination specified"
 4380       else
 4381     func_fatal_help "you must specify a destination"
 4382       fi
 4383     fi
 4384 
 4385     # Strip any trailing slash from the destination.
 4386     func_stripname '' '/' "$dest"
 4387     dest=$func_stripname_result
 4388 
 4389     # Check to see that the destination is a directory.
 4390     test -d "$dest" && isdir=:
 4391     if $isdir; then
 4392       destdir=$dest
 4393       destname=
 4394     else
 4395       func_dirname_and_basename "$dest" "" "."
 4396       destdir=$func_dirname_result
 4397       destname=$func_basename_result
 4398 
 4399       # Not a directory, so check to see that there is only one file specified.
 4400       set dummy $files; shift
 4401       test "$#" -gt 1 && \
 4402     func_fatal_help "'$dest' is not a directory"
 4403     fi
 4404     case $destdir in
 4405     [\\/]* | [A-Za-z]:[\\/]*) ;;
 4406     *)
 4407       for file in $files; do
 4408     case $file in
 4409     *.lo) ;;
 4410     *)
 4411       func_fatal_help "'$destdir' must be an absolute directory name"
 4412       ;;
 4413     esac
 4414       done
 4415       ;;
 4416     esac
 4417 
 4418     # This variable tells wrapper scripts just to set variables rather
 4419     # than running their programs.
 4420     libtool_install_magic=$magic
 4421 
 4422     staticlibs=
 4423     future_libdirs=
 4424     current_libdirs=
 4425     for file in $files; do
 4426 
 4427       # Do each installation.
 4428       case $file in
 4429       *.$libext)
 4430     # Do the static libraries later.
 4431     func_append staticlibs " $file"
 4432     ;;
 4433 
 4434       *.la)
 4435     func_resolve_sysroot "$file"
 4436     file=$func_resolve_sysroot_result
 4437 
 4438     # Check to see that this really is a libtool archive.
 4439     func_lalib_unsafe_p "$file" \
 4440       || func_fatal_help "'$file' is not a valid libtool archive"
 4441 
 4442     library_names=
 4443     old_library=
 4444     relink_command=
 4445     func_source "$file"
 4446 
 4447     # Add the libdir to current_libdirs if it is the destination.
 4448     if test "X$destdir" = "X$libdir"; then
 4449       case "$current_libdirs " in
 4450       *" $libdir "*) ;;
 4451       *) func_append current_libdirs " $libdir" ;;
 4452       esac
 4453     else
 4454       # Note the libdir as a future libdir.
 4455       case "$future_libdirs " in
 4456       *" $libdir "*) ;;
 4457       *) func_append future_libdirs " $libdir" ;;
 4458       esac
 4459     fi
 4460 
 4461     func_dirname "$file" "/" ""
 4462     dir=$func_dirname_result
 4463     func_append dir "$objdir"
 4464 
 4465     if test -n "$relink_command"; then
 4466       # Determine the prefix the user has applied to our future dir.
 4467       inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
 4468 
 4469       # Don't allow the user to place us outside of our expected
 4470       # location b/c this prevents finding dependent libraries that
 4471       # are installed to the same prefix.
 4472       # At present, this check doesn't affect windows .dll's that
 4473       # are installed into $libdir/../bin (currently, that works fine)
 4474       # but it's something to keep an eye on.
 4475       test "$inst_prefix_dir" = "$destdir" && \
 4476         func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
 4477 
 4478       if test -n "$inst_prefix_dir"; then
 4479         # Stick the inst_prefix_dir data into the link command.
 4480         relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
 4481       else
 4482         relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
 4483       fi
 4484 
 4485       func_warning "relinking '$file'"
 4486       func_show_eval "$relink_command" \
 4487         'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
 4488     fi
 4489 
 4490     # See the names of the shared library.
 4491     set dummy $library_names; shift
 4492     if test -n "$1"; then
 4493       realname=$1
 4494       shift
 4495 
 4496       srcname=$realname
 4497       test -n "$relink_command" && srcname=${realname}T
 4498 
 4499       # Install the shared library and build the symlinks.
 4500       func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
 4501           'exit $?'
 4502       tstripme=$stripme
 4503       case $host_os in
 4504       cygwin* | mingw* | pw32* | cegcc*)
 4505         case $realname in
 4506         *.dll.a)
 4507           tstripme=
 4508           ;;
 4509         esac
 4510         ;;
 4511       os2*)
 4512         case $realname in
 4513         *_dll.a)
 4514           tstripme=
 4515           ;;
 4516         esac
 4517         ;;
 4518       esac
 4519       if test -n "$tstripme" && test -n "$striplib"; then
 4520         func_show_eval "$striplib $destdir/$realname" 'exit $?'
 4521       fi
 4522 
 4523       if test "$#" -gt 0; then
 4524         # Delete the old symlinks, and create new ones.
 4525         # Try 'ln -sf' first, because the 'ln' binary might depend on
 4526         # the symlink we replace!  Solaris /bin/ln does not understand -f,
 4527         # so we also need to try rm && ln -s.
 4528         for linkname
 4529         do
 4530           test "$linkname" != "$realname" \
 4531         && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
 4532         done
 4533       fi
 4534 
 4535       # Do each command in the postinstall commands.
 4536       lib=$destdir/$realname
 4537       func_execute_cmds "$postinstall_cmds" 'exit $?'
 4538     fi
 4539 
 4540     # Install the pseudo-library for information purposes.
 4541     func_basename "$file"
 4542     name=$func_basename_result
 4543     instname=$dir/${name}i
 4544     func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
 4545 
 4546     # Maybe install the static library, too.
 4547     test -n "$old_library" && func_append staticlibs " $dir/$old_library"
 4548     ;;
 4549 
 4550       *.lo)
 4551     # Install (i.e. copy) a libtool object.
 4552 
 4553     # Figure out destination file name, if it wasn't already specified.
 4554     if test -n "$destname"; then
 4555       destfile=$destdir/$destname
 4556     else
 4557       func_basename "$file"
 4558       destfile=$func_basename_result
 4559       destfile=$destdir/$destfile
 4560     fi
 4561 
 4562     # Deduce the name of the destination old-style object file.
 4563     case $destfile in
 4564     *.lo)
 4565       func_lo2o "$destfile"
 4566       staticdest=$func_lo2o_result
 4567       ;;
 4568     *.$objext)
 4569       staticdest=$destfile
 4570       destfile=
 4571       ;;
 4572     *)
 4573       func_fatal_help "cannot copy a libtool object to '$destfile'"
 4574       ;;
 4575     esac
 4576 
 4577     # Install the libtool object if requested.
 4578     test -n "$destfile" && \
 4579       func_show_eval "$install_prog $file $destfile" 'exit $?'
 4580 
 4581     # Install the old object if enabled.
 4582     if test yes = "$build_old_libs"; then
 4583       # Deduce the name of the old-style object file.
 4584       func_lo2o "$file"
 4585       staticobj=$func_lo2o_result
 4586       func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
 4587     fi
 4588     exit $EXIT_SUCCESS
 4589     ;;
 4590 
 4591       *)
 4592     # Figure out destination file name, if it wasn't already specified.
 4593     if test -n "$destname"; then
 4594       destfile=$destdir/$destname
 4595     else
 4596       func_basename "$file"
 4597       destfile=$func_basename_result
 4598       destfile=$destdir/$destfile
 4599     fi
 4600 
 4601     # If the file is missing, and there is a .exe on the end, strip it
 4602     # because it is most likely a libtool script we actually want to
 4603     # install
 4604     stripped_ext=
 4605     case $file in
 4606       *.exe)
 4607         if test ! -f "$file"; then
 4608           func_stripname '' '.exe' "$file"
 4609           file=$func_stripname_result
 4610           stripped_ext=.exe
 4611         fi
 4612         ;;
 4613     esac
 4614 
 4615     # Do a test to see if this is really a libtool program.
 4616     case $host in
 4617     *cygwin* | *mingw*)
 4618         if func_ltwrapper_executable_p "$file"; then
 4619           func_ltwrapper_scriptname "$file"
 4620           wrapper=$func_ltwrapper_scriptname_result
 4621         else
 4622           func_stripname '' '.exe' "$file"
 4623           wrapper=$func_stripname_result
 4624         fi
 4625         ;;
 4626     *)
 4627         wrapper=$file
 4628         ;;
 4629     esac
 4630     if func_ltwrapper_script_p "$wrapper"; then
 4631       notinst_deplibs=
 4632       relink_command=
 4633 
 4634       func_source "$wrapper"
 4635 
 4636       # Check the variables that should have been set.
 4637       test -z "$generated_by_libtool_version" && \
 4638         func_fatal_error "invalid libtool wrapper script '$wrapper'"
 4639 
 4640       finalize=:
 4641       for lib in $notinst_deplibs; do
 4642         # Check to see that each library is installed.
 4643         libdir=
 4644         if test -f "$lib"; then
 4645           func_source "$lib"
 4646         fi
 4647         libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
 4648         if test -n "$libdir" && test ! -f "$libfile"; then
 4649           func_warning "'$lib' has not been installed in '$libdir'"
 4650           finalize=false
 4651         fi
 4652       done
 4653 
 4654       relink_command=
 4655       func_source "$wrapper"
 4656 
 4657       outputname=
 4658       if test no = "$fast_install" && test -n "$relink_command"; then
 4659         $opt_dry_run || {
 4660           if $finalize; then
 4661             tmpdir=`func_mktempdir`
 4662         func_basename "$file$stripped_ext"
 4663         file=$func_basename_result
 4664             outputname=$tmpdir/$file
 4665             # Replace the output file specification.
 4666             relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
 4667 
 4668             $opt_quiet || {
 4669               func_quote_arg expand,pretty "$relink_command"
 4670           eval "func_echo $func_quote_arg_result"
 4671             }
 4672             if eval "$relink_command"; then :
 4673               else
 4674           func_error "error: relink '$file' with the above command before installing it"
 4675           $opt_dry_run || ${RM}r "$tmpdir"
 4676           continue
 4677             fi
 4678             file=$outputname
 4679           else
 4680             func_warning "cannot relink '$file'"
 4681           fi
 4682         }
 4683       else
 4684         # Install the binary that we compiled earlier.
 4685         file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
 4686       fi
 4687     fi
 4688 
 4689     # remove .exe since cygwin /usr/bin/install will append another
 4690     # one anyway
 4691     case $install_prog,$host in
 4692     */usr/bin/install*,*cygwin*)
 4693       case $file:$destfile in
 4694       *.exe:*.exe)
 4695         # this is ok
 4696         ;;
 4697       *.exe:*)
 4698         destfile=$destfile.exe
 4699         ;;
 4700       *:*.exe)
 4701         func_stripname '' '.exe' "$destfile"
 4702         destfile=$func_stripname_result
 4703         ;;
 4704       esac
 4705       ;;
 4706     esac
 4707     func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
 4708     $opt_dry_run || if test -n "$outputname"; then
 4709       ${RM}r "$tmpdir"
 4710     fi
 4711     ;;
 4712       esac
 4713     done
 4714 
 4715     for file in $staticlibs; do
 4716       func_basename "$file"
 4717       name=$func_basename_result
 4718 
 4719       # Set up the ranlib parameters.
 4720       oldlib=$destdir/$name
 4721       func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
 4722       tool_oldlib=$func_to_tool_file_result
 4723 
 4724       func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
 4725 
 4726       if test -n "$stripme" && test -n "$old_striplib"; then
 4727     func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
 4728       fi
 4729 
 4730       # Do each command in the postinstall commands.
 4731       func_execute_cmds "$old_postinstall_cmds" 'exit $?'
 4732     done
 4733 
 4734     test -n "$future_libdirs" && \
 4735       func_warning "remember to run '$progname --finish$future_libdirs'"
 4736 
 4737     if test -n "$current_libdirs"; then
 4738       # Maybe just do a dry run.
 4739       $opt_dry_run && current_libdirs=" -n$current_libdirs"
 4740       exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
 4741     else
 4742       exit $EXIT_SUCCESS
 4743     fi
 4744 }
 4745 
 4746 test install = "$opt_mode" && func_mode_install ${1+"$@"}
 4747 
 4748 
 4749 # func_generate_dlsyms outputname originator pic_p
 4750 # Extract symbols from dlprefiles and create ${outputname}S.o with
 4751 # a dlpreopen symbol table.
 4752 func_generate_dlsyms ()
 4753 {
 4754     $debug_cmd
 4755 
 4756     my_outputname=$1
 4757     my_originator=$2
 4758     my_pic_p=${3-false}
 4759     my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
 4760     my_dlsyms=
 4761 
 4762     if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
 4763       if test -n "$NM" && test -n "$global_symbol_pipe"; then
 4764     my_dlsyms=${my_outputname}S.c
 4765       else
 4766     func_error "not configured to extract global symbols from dlpreopened files"
 4767       fi
 4768     fi
 4769 
 4770     if test -n "$my_dlsyms"; then
 4771       case $my_dlsyms in
 4772       "") ;;
 4773       *.c)
 4774     # Discover the nlist of each of the dlfiles.
 4775     nlist=$output_objdir/$my_outputname.nm
 4776 
 4777     func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
 4778 
 4779     # Parse the name list into a source file.
 4780     func_verbose "creating $output_objdir/$my_dlsyms"
 4781 
 4782     $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
 4783 /* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
 4784 /* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
 4785 
 4786 #ifdef __cplusplus
 4787 extern \"C\" {
 4788 #endif
 4789 
 4790 #if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
 4791 #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
 4792 #endif
 4793 
 4794 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
 4795 #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
 4796 /* DATA imports from DLLs on WIN32 can't be const, because runtime
 4797    relocations are performed -- see ld's documentation on pseudo-relocs.  */
 4798 # define LT_DLSYM_CONST
 4799 #elif defined __osf__
 4800 /* This system does not cope well with relocations in const data.  */
 4801 # define LT_DLSYM_CONST
 4802 #else
 4803 # define LT_DLSYM_CONST const
 4804 #endif
 4805 
 4806 #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
 4807 
 4808 /* External symbol declarations for the compiler. */\
 4809 "
 4810 
 4811     if test yes = "$dlself"; then
 4812       func_verbose "generating symbol list for '$output'"
 4813 
 4814       $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
 4815 
 4816       # Add our own program objects to the symbol list.
 4817       progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
 4818       for progfile in $progfiles; do
 4819         func_to_tool_file "$progfile" func_convert_file_msys_to_w32
 4820         func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
 4821         $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
 4822       done
 4823 
 4824       if test -n "$exclude_expsyms"; then
 4825         $opt_dry_run || {
 4826           eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
 4827           eval '$MV "$nlist"T "$nlist"'
 4828         }
 4829       fi
 4830 
 4831       if test -n "$export_symbols_regex"; then
 4832         $opt_dry_run || {
 4833           eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
 4834           eval '$MV "$nlist"T "$nlist"'
 4835         }
 4836       fi
 4837 
 4838       # Prepare the list of exported symbols
 4839       if test -z "$export_symbols"; then
 4840         export_symbols=$output_objdir/$outputname.exp
 4841         $opt_dry_run || {
 4842           $RM $export_symbols
 4843           eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
 4844           case $host in
 4845           *cygwin* | *mingw* | *cegcc* )
 4846                 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
 4847                 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
 4848             ;;
 4849           esac
 4850         }
 4851       else
 4852         $opt_dry_run || {
 4853           eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
 4854           eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
 4855           eval '$MV "$nlist"T "$nlist"'
 4856           case $host in
 4857             *cygwin* | *mingw* | *cegcc* )
 4858               eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
 4859               eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
 4860               ;;
 4861           esac
 4862         }
 4863       fi
 4864     fi
 4865 
 4866     for dlprefile in $dlprefiles; do
 4867       func_verbose "extracting global C symbols from '$dlprefile'"
 4868       func_basename "$dlprefile"
 4869       name=$func_basename_result
 4870           case $host in
 4871         *cygwin* | *mingw* | *cegcc* )
 4872           # if an import library, we need to obtain dlname
 4873           if func_win32_import_lib_p "$dlprefile"; then
 4874             func_tr_sh "$dlprefile"
 4875             eval "curr_lafile=\$libfile_$func_tr_sh_result"
 4876             dlprefile_dlbasename=
 4877             if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
 4878               # Use subshell, to avoid clobbering current variable values
 4879               dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
 4880               if test -n "$dlprefile_dlname"; then
 4881                 func_basename "$dlprefile_dlname"
 4882                 dlprefile_dlbasename=$func_basename_result
 4883               else
 4884                 # no lafile. user explicitly requested -dlpreopen <import library>.
 4885                 $sharedlib_from_linklib_cmd "$dlprefile"
 4886                 dlprefile_dlbasename=$sharedlib_from_linklib_result
 4887               fi
 4888             fi
 4889             $opt_dry_run || {
 4890               if test -n "$dlprefile_dlbasename"; then
 4891                 eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
 4892               else
 4893                 func_warning "Could not compute DLL name from $name"
 4894                 eval '$ECHO ": $name " >> "$nlist"'
 4895               fi
 4896               func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
 4897               eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
 4898                 $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
 4899             }
 4900           else # not an import lib
 4901             $opt_dry_run || {
 4902               eval '$ECHO ": $name " >> "$nlist"'
 4903               func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
 4904               eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
 4905             }
 4906           fi
 4907         ;;
 4908         *)
 4909           $opt_dry_run || {
 4910             eval '$ECHO ": $name " >> "$nlist"'
 4911             func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
 4912             eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
 4913           }
 4914         ;;
 4915           esac
 4916     done
 4917 
 4918     $opt_dry_run || {
 4919       # Make sure we have at least an empty file.
 4920       test -f "$nlist" || : > "$nlist"
 4921 
 4922       if test -n "$exclude_expsyms"; then
 4923         $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
 4924         $MV "$nlist"T "$nlist"
 4925       fi
 4926 
 4927       # Try sorting and uniquifying the output.
 4928       if $GREP -v "^: " < "$nlist" |
 4929           if sort -k 3 </dev/null >/dev/null 2>&1; then
 4930         sort -k 3
 4931           else
 4932         sort +2
 4933           fi |
 4934           uniq > "$nlist"S; then
 4935         :
 4936       else
 4937         $GREP -v "^: " < "$nlist" > "$nlist"S
 4938       fi
 4939 
 4940       if test -f "$nlist"S; then
 4941         eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
 4942       else
 4943         echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
 4944       fi
 4945 
 4946       func_show_eval '$RM "${nlist}I"'
 4947       if test -n "$global_symbol_to_import"; then
 4948         eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
 4949       fi
 4950 
 4951       echo >> "$output_objdir/$my_dlsyms" "\
 4952 
 4953 /* The mapping between symbol names and symbols.  */
 4954 typedef struct {
 4955   const char *name;
 4956   void *address;
 4957 } lt_dlsymlist;
 4958 extern LT_DLSYM_CONST lt_dlsymlist
 4959 lt_${my_prefix}_LTX_preloaded_symbols[];\
 4960 "
 4961 
 4962       if test -s "$nlist"I; then
 4963         echo >> "$output_objdir/$my_dlsyms" "\
 4964 static void lt_syminit(void)
 4965 {
 4966   LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
 4967   for (; symbol->name; ++symbol)
 4968     {"
 4969         $SED 's/.*/      if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
 4970         echo >> "$output_objdir/$my_dlsyms" "\
 4971     }
 4972 }"
 4973       fi
 4974       echo >> "$output_objdir/$my_dlsyms" "\
 4975 LT_DLSYM_CONST lt_dlsymlist
 4976 lt_${my_prefix}_LTX_preloaded_symbols[] =
 4977 { {\"$my_originator\", (void *) 0},"
 4978 
 4979       if test -s "$nlist"I; then
 4980         echo >> "$output_objdir/$my_dlsyms" "\
 4981   {\"@INIT@\", (void *) &lt_syminit},"
 4982       fi
 4983 
 4984       case $need_lib_prefix in
 4985       no)
 4986         eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
 4987         ;;
 4988       *)
 4989         eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
 4990         ;;
 4991       esac
 4992       echo >> "$output_objdir/$my_dlsyms" "\
 4993   {0, (void *) 0}
 4994 };
 4995 
 4996 /* This works around a problem in FreeBSD linker */
 4997 #ifdef FREEBSD_WORKAROUND
 4998 static const void *lt_preloaded_setup() {
 4999   return lt_${my_prefix}_LTX_preloaded_symbols;
 5000 }
 5001 #endif
 5002 
 5003 #ifdef __cplusplus
 5004 }
 5005 #endif\
 5006 "
 5007     } # !$opt_dry_run
 5008 
 5009     pic_flag_for_symtable=
 5010     case "$compile_command " in
 5011     *" -static "*) ;;
 5012     *)
 5013       case $host in
 5014       # compiling the symbol table file with pic_flag works around
 5015       # a FreeBSD bug that causes programs to crash when -lm is
 5016       # linked before any other PIC object.  But we must not use
 5017       # pic_flag when linking with -static.  The problem exists in
 5018       # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
 5019       *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
 5020         pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
 5021       *-*-hpux*)
 5022         pic_flag_for_symtable=" $pic_flag"  ;;
 5023       *)
 5024         $my_pic_p && pic_flag_for_symtable=" $pic_flag"
 5025         ;;
 5026       esac
 5027       ;;
 5028     esac
 5029     symtab_cflags=
 5030     for arg in $LTCFLAGS; do
 5031       case $arg in
 5032       -pie | -fpie | -fPIE) ;;
 5033       *) func_append symtab_cflags " $arg" ;;
 5034       esac
 5035     done
 5036 
 5037     # Now compile the dynamic symbol file.
 5038     func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
 5039 
 5040     # Clean up the generated files.
 5041     func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
 5042 
 5043     # Transform the symbol file into the correct name.
 5044     symfileobj=$output_objdir/${my_outputname}S.$objext
 5045     case $host in
 5046     *cygwin* | *mingw* | *cegcc* )
 5047       if test -f "$output_objdir/$my_outputname.def"; then
 5048         compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
 5049         finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
 5050       else
 5051         compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
 5052         finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
 5053       fi
 5054       ;;
 5055     *)
 5056       compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
 5057       finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
 5058       ;;
 5059     esac
 5060     ;;
 5061       *)
 5062     func_fatal_error "unknown suffix for '$my_dlsyms'"
 5063     ;;
 5064       esac
 5065     else
 5066       # We keep going just in case the user didn't refer to
 5067       # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
 5068       # really was required.
 5069 
 5070       # Nullify the symbol file.
 5071       compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
 5072       finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
 5073     fi
 5074 }
 5075 
 5076 # func_cygming_gnu_implib_p ARG
 5077 # This predicate returns with zero status (TRUE) if
 5078 # ARG is a GNU/binutils-style import library. Returns
 5079 # with nonzero status (FALSE) otherwise.
 5080 func_cygming_gnu_implib_p ()
 5081 {
 5082   $debug_cmd
 5083 
 5084   func_to_tool_file "$1" func_convert_file_msys_to_w32
 5085   func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
 5086   test -n "$func_cygming_gnu_implib_tmp"
 5087 }
 5088 
 5089 # func_cygming_ms_implib_p ARG
 5090 # This predicate returns with zero status (TRUE) if
 5091 # ARG is an MS-style import library. Returns
 5092 # with nonzero status (FALSE) otherwise.
 5093 func_cygming_ms_implib_p ()
 5094 {
 5095   $debug_cmd
 5096 
 5097   func_to_tool_file "$1" func_convert_file_msys_to_w32
 5098   func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
 5099   test -n "$func_cygming_ms_implib_tmp"
 5100 }
 5101 
 5102 # func_win32_libid arg
 5103 # return the library type of file 'arg'
 5104 #
 5105 # Need a lot of goo to handle *both* DLLs and import libs
 5106 # Has to be a shell function in order to 'eat' the argument
 5107 # that is supplied when $file_magic_command is called.
 5108 # Despite the name, also deal with 64 bit binaries.
 5109 func_win32_libid ()
 5110 {
 5111   $debug_cmd
 5112 
 5113   win32_libid_type=unknown
 5114   win32_fileres=`file -L $1 2>/dev/null`
 5115   case $win32_fileres in
 5116   *ar\ archive\ import\ library*) # definitely import
 5117     win32_libid_type="x86 archive import"
 5118     ;;
 5119   *ar\ archive*) # could be an import, or static
 5120     # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
 5121     if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
 5122        $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
 5123       case $nm_interface in
 5124       "MS dumpbin")
 5125     if func_cygming_ms_implib_p "$1" ||
 5126        func_cygming_gnu_implib_p "$1"
 5127     then
 5128       win32_nmres=import
 5129     else
 5130       win32_nmres=
 5131     fi
 5132     ;;
 5133       *)
 5134     func_to_tool_file "$1" func_convert_file_msys_to_w32
 5135     win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
 5136       $SED -n -e '
 5137         1,100{
 5138         / I /{
 5139             s|.*|import|
 5140             p
 5141             q
 5142         }
 5143         }'`
 5144     ;;
 5145       esac
 5146       case $win32_nmres in
 5147       import*)  win32_libid_type="x86 archive import";;
 5148       *)        win32_libid_type="x86 archive static";;
 5149       esac
 5150     fi
 5151     ;;
 5152   *DLL*)
 5153     win32_libid_type="x86 DLL"
 5154     ;;
 5155   *executable*) # but shell scripts are "executable" too...
 5156     case $win32_fileres in
 5157     *MS\ Windows\ PE\ Intel*)
 5158       win32_libid_type="x86 DLL"
 5159       ;;
 5160     esac
 5161     ;;
 5162   esac
 5163   $ECHO "$win32_libid_type"
 5164 }
 5165 
 5166 # func_cygming_dll_for_implib ARG
 5167 #
 5168 # Platform-specific function to extract the
 5169 # name of the DLL associated with the specified
 5170 # import library ARG.
 5171 # Invoked by eval'ing the libtool variable
 5172 #    $sharedlib_from_linklib_cmd
 5173 # Result is available in the variable
 5174 #    $sharedlib_from_linklib_result
 5175 func_cygming_dll_for_implib ()
 5176 {
 5177   $debug_cmd
 5178 
 5179   sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
 5180 }
 5181 
 5182 # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
 5183 #
 5184 # The is the core of a fallback implementation of a
 5185 # platform-specific function to extract the name of the
 5186 # DLL associated with the specified import library LIBNAME.
 5187 #
 5188 # SECTION_NAME is either .idata$6 or .idata$7, depending
 5189 # on the platform and compiler that created the implib.
 5190 #
 5191 # Echos the name of the DLL associated with the
 5192 # specified import library.
 5193 func_cygming_dll_for_implib_fallback_core ()
 5194 {
 5195   $debug_cmd
 5196 
 5197   match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
 5198   $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
 5199     $SED '/^Contents of section '"$match_literal"':/{
 5200       # Place marker at beginning of archive member dllname section
 5201       s/.*/====MARK====/
 5202       p
 5203       d
 5204     }
 5205     # These lines can sometimes be longer than 43 characters, but
 5206     # are always uninteresting
 5207     /:[  ]*file format pe[i]\{,1\}-/d
 5208     /^In archive [^:]*:/d
 5209     # Ensure marker is printed
 5210     /^====MARK====/p
 5211     # Remove all lines with less than 43 characters
 5212     /^.\{43\}/!d
 5213     # From remaining lines, remove first 43 characters
 5214     s/^.\{43\}//' |
 5215     $SED -n '
 5216       # Join marker and all lines until next marker into a single line
 5217       /^====MARK====/ b para
 5218       H
 5219       $ b para
 5220       b
 5221       :para
 5222       x
 5223       s/\n//g
 5224       # Remove the marker
 5225       s/^====MARK====//
 5226       # Remove trailing dots and whitespace
 5227       s/[\. \t]*$//
 5228       # Print
 5229       /./p' |
 5230     # we now have a list, one entry per line, of the stringified
 5231     # contents of the appropriate section of all members of the
 5232     # archive that possess that section. Heuristic: eliminate
 5233     # all those that have a first or second character that is
 5234     # a '.' (that is, objdump's representation of an unprintable
 5235     # character.) This should work for all archives with less than
 5236     # 0x302f exports -- but will fail for DLLs whose name actually
 5237     # begins with a literal '.' or a single character followed by
 5238     # a '.'.
 5239     #
 5240     # Of those that remain, print the first one.
 5241     $SED -e '/^\./d;/^.\./d;q'
 5242 }
 5243 
 5244 # func_cygming_dll_for_implib_fallback ARG
 5245 # Platform-specific function to extract the
 5246 # name of the DLL associated with the specified
 5247 # import library ARG.
 5248 #
 5249 # This fallback implementation is for use when $DLLTOOL
 5250 # does not support the --identify-strict option.
 5251 # Invoked by eval'ing the libtool variable
 5252 #    $sharedlib_from_linklib_cmd
 5253 # Result is available in the variable
 5254 #    $sharedlib_from_linklib_result
 5255 func_cygming_dll_for_implib_fallback ()
 5256 {
 5257   $debug_cmd
 5258 
 5259   if func_cygming_gnu_implib_p "$1"; then
 5260     # binutils import library
 5261     sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
 5262   elif func_cygming_ms_implib_p "$1"; then
 5263     # ms-generated import library
 5264     sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
 5265   else
 5266     # unknown
 5267     sharedlib_from_linklib_result=
 5268   fi
 5269 }
 5270 
 5271 
 5272 # func_extract_an_archive dir oldlib
 5273 func_extract_an_archive ()
 5274 {
 5275     $debug_cmd
 5276 
 5277     f_ex_an_ar_dir=$1; shift
 5278     f_ex_an_ar_oldlib=$1
 5279     if test yes = "$lock_old_archive_extraction"; then
 5280       lockfile=$f_ex_an_ar_oldlib.lock
 5281       until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
 5282     func_echo "Waiting for $lockfile to be removed"
 5283     sleep 2
 5284       done
 5285     fi
 5286     func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
 5287            'stat=$?; rm -f "$lockfile"; exit $stat'
 5288     if test yes = "$lock_old_archive_extraction"; then
 5289       $opt_dry_run || rm -f "$lockfile"
 5290     fi
 5291     if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
 5292      :
 5293     else
 5294       func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
 5295     fi
 5296 }
 5297 
 5298 
 5299 # func_extract_archives gentop oldlib ...
 5300 func_extract_archives ()
 5301 {
 5302     $debug_cmd
 5303 
 5304     my_gentop=$1; shift
 5305     my_oldlibs=${1+"$@"}
 5306     my_oldobjs=
 5307     my_xlib=
 5308     my_xabs=
 5309     my_xdir=
 5310 
 5311     for my_xlib in $my_oldlibs; do
 5312       # Extract the objects.
 5313       case $my_xlib in
 5314     [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
 5315     *) my_xabs=`pwd`"/$my_xlib" ;;
 5316       esac
 5317       func_basename "$my_xlib"
 5318       my_xlib=$func_basename_result
 5319       my_xlib_u=$my_xlib
 5320       while :; do
 5321         case " $extracted_archives " in
 5322     *" $my_xlib_u "*)
 5323       func_arith $extracted_serial + 1
 5324       extracted_serial=$func_arith_result
 5325       my_xlib_u=lt$extracted_serial-$my_xlib ;;
 5326     *) break ;;
 5327     esac
 5328       done
 5329       extracted_archives="$extracted_archives $my_xlib_u"
 5330       my_xdir=$my_gentop/$my_xlib_u
 5331 
 5332       func_mkdir_p "$my_xdir"
 5333 
 5334       case $host in
 5335       *-darwin*)
 5336     func_verbose "Extracting $my_xabs"
 5337     # Do not bother doing anything if just a dry run
 5338     $opt_dry_run || {
 5339       darwin_orig_dir=`pwd`
 5340       cd $my_xdir || exit $?
 5341       darwin_archive=$my_xabs
 5342       darwin_curdir=`pwd`
 5343       func_basename "$darwin_archive"
 5344       darwin_base_archive=$func_basename_result
 5345       darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
 5346       if test -n "$darwin_arches"; then
 5347         darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
 5348         darwin_arch=
 5349         func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
 5350         for darwin_arch in  $darwin_arches; do
 5351           func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
 5352           $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
 5353           cd "unfat-$$/$darwin_base_archive-$darwin_arch"
 5354           func_extract_an_archive "`pwd`" "$darwin_base_archive"
 5355           cd "$darwin_curdir"
 5356           $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
 5357         done # $darwin_arches
 5358             ## Okay now we've a bunch of thin objects, gotta fatten them up :)
 5359         darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
 5360         darwin_file=
 5361         darwin_files=
 5362         for darwin_file in $darwin_filelist; do
 5363           darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
 5364           $LIPO -create -output "$darwin_file" $darwin_files
 5365         done # $darwin_filelist
 5366         $RM -rf unfat-$$
 5367         cd "$darwin_orig_dir"
 5368       else
 5369         cd $darwin_orig_dir
 5370         func_extract_an_archive "$my_xdir" "$my_xabs"
 5371       fi # $darwin_arches
 5372     } # !$opt_dry_run
 5373     ;;
 5374       *)
 5375         func_extract_an_archive "$my_xdir" "$my_xabs"
 5376     ;;
 5377       esac
 5378       my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
 5379     done
 5380 
 5381     func_extract_archives_result=$my_oldobjs
 5382 }
 5383 
 5384 
 5385 # func_emit_wrapper [arg=no]
 5386 #
 5387 # Emit a libtool wrapper script on stdout.
 5388 # Don't directly open a file because we may want to
 5389 # incorporate the script contents within a cygwin/mingw
 5390 # wrapper executable.  Must ONLY be called from within
 5391 # func_mode_link because it depends on a number of variables
 5392 # set therein.
 5393 #
 5394 # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
 5395 # variable will take.  If 'yes', then the emitted script
 5396 # will assume that the directory where it is stored is
 5397 # the $objdir directory.  This is a cygwin/mingw-specific
 5398 # behavior.
 5399 func_emit_wrapper ()
 5400 {
 5401     func_emit_wrapper_arg1=${1-no}
 5402 
 5403     $ECHO "\
 5404 #! $SHELL
 5405 
 5406 # $output - temporary wrapper script for $objdir/$outputname
 5407 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
 5408 #
 5409 # The $output program cannot be directly executed until all the libtool
 5410 # libraries that it depends on are installed.
 5411 #
 5412 # This wrapper script should never be moved out of the build directory.
 5413 # If it is, it will not operate correctly.
 5414 
 5415 # Sed substitution that helps us do robust quoting.  It backslashifies
 5416 # metacharacters that are still active within double-quoted strings.
 5417 sed_quote_subst='$sed_quote_subst'
 5418 
 5419 # Be Bourne compatible
 5420 if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
 5421   emulate sh
 5422   NULLCMD=:
 5423   # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
 5424   # is contrary to our usage.  Disable this feature.
 5425   alias -g '\${1+\"\$@\"}'='\"\$@\"'
 5426   setopt NO_GLOB_SUBST
 5427 else
 5428   case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
 5429 fi
 5430 BIN_SH=xpg4; export BIN_SH # for Tru64
 5431 DUALCASE=1; export DUALCASE # for MKS sh
 5432 
 5433 # The HP-UX ksh and POSIX shell print the target directory to stdout
 5434 # if CDPATH is set.
 5435 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 5436 
 5437 relink_command=\"$relink_command\"
 5438 
 5439 # This environment variable determines our operation mode.
 5440 if test \"\$libtool_install_magic\" = \"$magic\"; then
 5441   # install mode needs the following variables:
 5442   generated_by_libtool_version='$macro_version'
 5443   notinst_deplibs='$notinst_deplibs'
 5444 else
 5445   # When we are sourced in execute mode, \$file and \$ECHO are already set.
 5446   if test \"\$libtool_execute_magic\" != \"$magic\"; then
 5447     file=\"\$0\""
 5448 
 5449     func_quote_arg pretty "$ECHO"
 5450     qECHO=$func_quote_arg_result
 5451     $ECHO "\
 5452 
 5453 # A function that is used when there is no print builtin or printf.
 5454 func_fallback_echo ()
 5455 {
 5456   eval 'cat <<_LTECHO_EOF
 5457 \$1
 5458 _LTECHO_EOF'
 5459 }
 5460     ECHO=$qECHO
 5461   fi
 5462 
 5463 # Very basic option parsing. These options are (a) specific to
 5464 # the libtool wrapper, (b) are identical between the wrapper
 5465 # /script/ and the wrapper /executable/ that is used only on
 5466 # windows platforms, and (c) all begin with the string "--lt-"
 5467 # (application programs are unlikely to have options that match
 5468 # this pattern).
 5469 #
 5470 # There are only two supported options: --lt-debug and
 5471 # --lt-dump-script. There is, deliberately, no --lt-help.
 5472 #
 5473 # The first argument to this parsing function should be the
 5474 # script's $0 value, followed by "$@".
 5475 lt_option_debug=
 5476 func_parse_lt_options ()
 5477 {
 5478   lt_script_arg0=\$0
 5479   shift
 5480   for lt_opt
 5481   do
 5482     case \"\$lt_opt\" in
 5483     --lt-debug) lt_option_debug=1 ;;
 5484     --lt-dump-script)
 5485         lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
 5486         test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
 5487         lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
 5488         cat \"\$lt_dump_D/\$lt_dump_F\"
 5489         exit 0
 5490       ;;
 5491     --lt-*)
 5492         \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
 5493         exit 1
 5494       ;;
 5495     esac
 5496   done
 5497 
 5498   # Print the debug banner immediately:
 5499   if test -n \"\$lt_option_debug\"; then
 5500     echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
 5501   fi
 5502 }
 5503 
 5504 # Used when --lt-debug. Prints its arguments to stdout
 5505 # (redirection is the responsibility of the caller)
 5506 func_lt_dump_args ()
 5507 {
 5508   lt_dump_args_N=1;
 5509   for lt_arg
 5510   do
 5511     \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
 5512     lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
 5513   done
 5514 }
 5515 
 5516 # Core function for launching the target application
 5517 func_exec_program_core ()
 5518 {
 5519 "
 5520   case $host in
 5521   # Backslashes separate directories on plain windows
 5522   *-*-mingw | *-*-os2* | *-cegcc*)
 5523     $ECHO "\
 5524       if test -n \"\$lt_option_debug\"; then
 5525         \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
 5526         func_lt_dump_args \${1+\"\$@\"} 1>&2
 5527       fi
 5528       exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
 5529 "
 5530     ;;
 5531 
 5532   *)
 5533     $ECHO "\
 5534       if test -n \"\$lt_option_debug\"; then
 5535         \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
 5536         func_lt_dump_args \${1+\"\$@\"} 1>&2
 5537       fi
 5538       exec \"\$progdir/\$program\" \${1+\"\$@\"}
 5539 "
 5540     ;;
 5541   esac
 5542   $ECHO "\
 5543       \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
 5544       exit 1
 5545 }
 5546 
 5547 # A function to encapsulate launching the target application
 5548 # Strips options in the --lt-* namespace from \$@ and
 5549 # launches target application with the remaining arguments.
 5550 func_exec_program ()
 5551 {
 5552   case \" \$* \" in
 5553   *\\ --lt-*)
 5554     for lt_wr_arg
 5555     do
 5556       case \$lt_wr_arg in
 5557       --lt-*) ;;
 5558       *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
 5559       esac
 5560       shift
 5561     done ;;
 5562   esac
 5563   func_exec_program_core \${1+\"\$@\"}
 5564 }
 5565 
 5566   # Parse options
 5567   func_parse_lt_options \"\$0\" \${1+\"\$@\"}
 5568 
 5569   # Find the directory that this script lives in.
 5570   thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
 5571   test \"x\$thisdir\" = \"x\$file\" && thisdir=.
 5572 
 5573   # Follow symbolic links until we get to the real thisdir.
 5574   file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
 5575   while test -n \"\$file\"; do
 5576     destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
 5577 
 5578     # If there was a directory component, then change thisdir.
 5579     if test \"x\$destdir\" != \"x\$file\"; then
 5580       case \"\$destdir\" in
 5581       [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
 5582       *) thisdir=\"\$thisdir/\$destdir\" ;;
 5583       esac
 5584     fi
 5585 
 5586     file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
 5587     file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
 5588   done
 5589 
 5590   # Usually 'no', except on cygwin/mingw when embedded into
 5591   # the cwrapper.
 5592   WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
 5593   if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
 5594     # special case for '.'
 5595     if test \"\$thisdir\" = \".\"; then
 5596       thisdir=\`pwd\`
 5597     fi
 5598     # remove .libs from thisdir
 5599     case \"\$thisdir\" in
 5600     *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
 5601     $objdir )   thisdir=. ;;
 5602     esac
 5603   fi
 5604 
 5605   # Try to get the absolute directory name.
 5606   absdir=\`cd \"\$thisdir\" && pwd\`
 5607   test -n \"\$absdir\" && thisdir=\"\$absdir\"
 5608 "
 5609 
 5610     if test yes = "$fast_install"; then
 5611       $ECHO "\
 5612   program=lt-'$outputname'$exeext
 5613   progdir=\"\$thisdir/$objdir\"
 5614 
 5615   if test ! -f \"\$progdir/\$program\" ||
 5616      { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
 5617        test \"X\$file\" != \"X\$progdir/\$program\"; }; then
 5618 
 5619     file=\"\$\$-\$program\"
 5620 
 5621     if test ! -d \"\$progdir\"; then
 5622       $MKDIR \"\$progdir\"
 5623     else
 5624       $RM \"\$progdir/\$file\"
 5625     fi"
 5626 
 5627       $ECHO "\
 5628 
 5629     # relink executable if necessary
 5630     if test -n \"\$relink_command\"; then
 5631       if relink_command_output=\`eval \$relink_command 2>&1\`; then :
 5632       else
 5633     \$ECHO \"\$relink_command_output\" >&2
 5634     $RM \"\$progdir/\$file\"
 5635     exit 1
 5636       fi
 5637     fi
 5638 
 5639     $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
 5640     { $RM \"\$progdir/\$program\";
 5641       $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
 5642     $RM \"\$progdir/\$file\"
 5643   fi"
 5644     else
 5645       $ECHO "\
 5646   program='$outputname'
 5647   progdir=\"\$thisdir/$objdir\"
 5648 "
 5649     fi
 5650 
 5651     $ECHO "\
 5652 
 5653   if test -f \"\$progdir/\$program\"; then"
 5654 
 5655     # fixup the dll searchpath if we need to.
 5656     #
 5657     # Fix the DLL searchpath if we need to.  Do this before prepending
 5658     # to shlibpath, because on Windows, both are PATH and uninstalled
 5659     # libraries must come first.
 5660     if test -n "$dllsearchpath"; then
 5661       $ECHO "\
 5662     # Add the dll search path components to the executable PATH
 5663     PATH=$dllsearchpath:\$PATH
 5664 "
 5665     fi
 5666 
 5667     # Export our shlibpath_var if we have one.
 5668     if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
 5669       $ECHO "\
 5670     # Add our own library path to $shlibpath_var
 5671     $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
 5672 
 5673     # Some systems cannot cope with colon-terminated $shlibpath_var
 5674     # The second colon is a workaround for a bug in BeOS R4 sed
 5675     $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
 5676 
 5677     export $shlibpath_var
 5678 "
 5679     fi
 5680 
 5681     $ECHO "\
 5682     if test \"\$libtool_execute_magic\" != \"$magic\"; then
 5683       # Run the actual program with our arguments.
 5684       func_exec_program \${1+\"\$@\"}
 5685     fi
 5686   else
 5687     # The program doesn't exist.
 5688     \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
 5689     \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
 5690     \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
 5691     exit 1
 5692   fi
 5693 fi\
 5694 "
 5695 }
 5696 
 5697 
 5698 # func_emit_cwrapperexe_src
 5699 # emit the source code for a wrapper executable on stdout
 5700 # Must ONLY be called from within func_mode_link because
 5701 # it depends on a number of variable set therein.
 5702 func_emit_cwrapperexe_src ()
 5703 {
 5704     cat <<EOF
 5705 
 5706 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
 5707    Generated by $PROGRAM (GNU $PACKAGE) $VERSION
 5708 
 5709    The $output program cannot be directly executed until all the libtool
 5710    libraries that it depends on are installed.
 5711 
 5712    This wrapper executable should never be moved out of the build directory.
 5713    If it is, it will not operate correctly.
 5714 */
 5715 EOF
 5716         cat <<"EOF"
 5717 #ifdef _MSC_VER
 5718 # define _CRT_SECURE_NO_DEPRECATE 1
 5719 #endif
 5720 #include <stdio.h>
 5721 #include <stdlib.h>
 5722 #ifdef _MSC_VER
 5723 # include <direct.h>
 5724 # include <process.h>
 5725 # include <io.h>
 5726 #else
 5727 # include <unistd.h>
 5728 # include <stdint.h>
 5729 # ifdef __CYGWIN__
 5730 #  include <io.h>
 5731 # endif
 5732 #endif
 5733 #include <malloc.h>
 5734 #include <stdarg.h>
 5735 #include <assert.h>
 5736 #include <string.h>
 5737 #include <ctype.h>
 5738 #include <errno.h>
 5739 #include <fcntl.h>
 5740 #include <sys/stat.h>
 5741 
 5742 #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
 5743 
 5744 /* declarations of non-ANSI functions */
 5745 #if defined __MINGW32__
 5746 # ifdef __STRICT_ANSI__
 5747 int _putenv (const char *);
 5748 # endif
 5749 #elif defined __CYGWIN__
 5750 # ifdef __STRICT_ANSI__
 5751 char *realpath (const char *, char *);
 5752 int putenv (char *);
 5753 int setenv (const char *, const char *, int);
 5754 # endif
 5755 /* #elif defined other_platform || defined ... */
 5756 #endif
 5757 
 5758 /* portability defines, excluding path handling macros */
 5759 #if defined _MSC_VER
 5760 # define setmode _setmode
 5761 # define stat    _stat
 5762 # define chmod   _chmod
 5763 # define getcwd  _getcwd
 5764 # define putenv  _putenv
 5765 # define S_IXUSR _S_IEXEC
 5766 #elif defined __MINGW32__
 5767 # define setmode _setmode
 5768 # define stat    _stat
 5769 # define chmod   _chmod
 5770 # define getcwd  _getcwd
 5771 # define putenv  _putenv
 5772 #elif defined __CYGWIN__
 5773 # define HAVE_SETENV
 5774 # define FOPEN_WB "wb"
 5775 /* #elif defined other platforms ... */
 5776 #endif
 5777 
 5778 #if defined PATH_MAX
 5779 # define LT_PATHMAX PATH_MAX
 5780 #elif defined MAXPATHLEN
 5781 # define LT_PATHMAX MAXPATHLEN
 5782 #else
 5783 # define LT_PATHMAX 1024
 5784 #endif
 5785 
 5786 #ifndef S_IXOTH
 5787 # define S_IXOTH 0
 5788 #endif
 5789 #ifndef S_IXGRP
 5790 # define S_IXGRP 0
 5791 #endif
 5792 
 5793 /* path handling portability macros */
 5794 #ifndef DIR_SEPARATOR
 5795 # define DIR_SEPARATOR '/'
 5796 # define PATH_SEPARATOR ':'
 5797 #endif
 5798 
 5799 #if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
 5800   defined __OS2__
 5801 # define HAVE_DOS_BASED_FILE_SYSTEM
 5802 # define FOPEN_WB "wb"
 5803 # ifndef DIR_SEPARATOR_2
 5804 #  define DIR_SEPARATOR_2 '\\'
 5805 # endif
 5806 # ifndef PATH_SEPARATOR_2
 5807 #  define PATH_SEPARATOR_2 ';'
 5808 # endif
 5809 #endif
 5810 
 5811 #ifndef DIR_SEPARATOR_2
 5812 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
 5813 #else /* DIR_SEPARATOR_2 */
 5814 # define IS_DIR_SEPARATOR(ch) \
 5815     (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
 5816 #endif /* DIR_SEPARATOR_2 */
 5817 
 5818 #ifndef PATH_SEPARATOR_2
 5819 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
 5820 #else /* PATH_SEPARATOR_2 */
 5821 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
 5822 #endif /* PATH_SEPARATOR_2 */
 5823 
 5824 #ifndef FOPEN_WB
 5825 # define FOPEN_WB "w"
 5826 #endif
 5827 #ifndef _O_BINARY
 5828 # define _O_BINARY 0
 5829 #endif
 5830 
 5831 #define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
 5832 #define XFREE(stale) do { \
 5833   if (stale) { free (stale); stale = 0; } \
 5834 } while (0)
 5835 
 5836 #if defined LT_DEBUGWRAPPER
 5837 static int lt_debug = 1;
 5838 #else
 5839 static int lt_debug = 0;
 5840 #endif
 5841 
 5842 const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
 5843 
 5844 void *xmalloc (size_t num);
 5845 char *xstrdup (const char *string);
 5846 const char *base_name (const char *name);
 5847 char *find_executable (const char *wrapper);
 5848 char *chase_symlinks (const char *pathspec);
 5849 int make_executable (const char *path);
 5850 int check_executable (const char *path);
 5851 char *strendzap (char *str, const char *pat);
 5852 void lt_debugprintf (const char *file, int line, const char *fmt, ...);
 5853 void lt_fatal (const char *file, int line, const char *message, ...);
 5854 static const char *nonnull (const char *s);
 5855 static const char *nonempty (const char *s);
 5856 void lt_setenv (const char *name, const char *value);
 5857 char *lt_extend_str (const char *orig_value, const char *add, int to_end);
 5858 void lt_update_exe_path (const char *name, const char *value);
 5859 void lt_update_lib_path (const char *name, const char *value);
 5860 char **prepare_spawn (char **argv);
 5861 void lt_dump_script (FILE *f);
 5862 EOF
 5863 
 5864         cat <<EOF
 5865 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
 5866 # define externally_visible volatile
 5867 #else
 5868 # define externally_visible __attribute__((externally_visible)) volatile
 5869 #endif
 5870 externally_visible const char * MAGIC_EXE = "$magic_exe";
 5871 const char * LIB_PATH_VARNAME = "$shlibpath_var";
 5872 EOF
 5873 
 5874         if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
 5875               func_to_host_path "$temp_rpath"
 5876           cat <<EOF
 5877 const char * LIB_PATH_VALUE   = "$func_to_host_path_result";
 5878 EOF
 5879         else
 5880           cat <<"EOF"
 5881 const char * LIB_PATH_VALUE   = "";
 5882 EOF
 5883         fi
 5884 
 5885         if test -n "$dllsearchpath"; then
 5886               func_to_host_path "$dllsearchpath:"
 5887           cat <<EOF
 5888 const char * EXE_PATH_VARNAME = "PATH";
 5889 const char * EXE_PATH_VALUE   = "$func_to_host_path_result";
 5890 EOF
 5891         else
 5892           cat <<"EOF"
 5893 const char * EXE_PATH_VARNAME = "";
 5894 const char * EXE_PATH_VALUE   = "";
 5895 EOF
 5896         fi
 5897 
 5898         if test yes = "$fast_install"; then
 5899           cat <<EOF
 5900 const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
 5901 EOF
 5902         else
 5903           cat <<EOF
 5904 const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
 5905 EOF
 5906         fi
 5907 
 5908 
 5909         cat <<"EOF"
 5910 
 5911 #define LTWRAPPER_OPTION_PREFIX         "--lt-"
 5912 
 5913 static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
 5914 static const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
 5915 static const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
 5916 
 5917 int
 5918 main (int argc, char *argv[])
 5919 {
 5920   char **newargz;
 5921   int  newargc;
 5922   char *tmp_pathspec;
 5923   char *actual_cwrapper_path;
 5924   char *actual_cwrapper_name;
 5925   char *target_name;
 5926   char *lt_argv_zero;
 5927   int rval = 127;
 5928 
 5929   int i;
 5930 
 5931   program_name = (char *) xstrdup (base_name (argv[0]));
 5932   newargz = XMALLOC (char *, (size_t) argc + 1);
 5933 
 5934   /* very simple arg parsing; don't want to rely on getopt
 5935    * also, copy all non cwrapper options to newargz, except
 5936    * argz[0], which is handled differently
 5937    */
 5938   newargc=0;
 5939   for (i = 1; i < argc; i++)
 5940     {
 5941       if (STREQ (argv[i], dumpscript_opt))
 5942     {
 5943 EOF
 5944         case $host in
 5945           *mingw* | *cygwin* )
 5946         # make stdout use "unix" line endings
 5947         echo "          setmode(1,_O_BINARY);"
 5948         ;;
 5949           esac
 5950 
 5951         cat <<"EOF"
 5952       lt_dump_script (stdout);
 5953       return 0;
 5954     }
 5955       if (STREQ (argv[i], debug_opt))
 5956     {
 5957           lt_debug = 1;
 5958           continue;
 5959     }
 5960       if (STREQ (argv[i], ltwrapper_option_prefix))
 5961         {
 5962           /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
 5963              namespace, but it is not one of the ones we know about and
 5964              have already dealt with, above (inluding dump-script), then
 5965              report an error. Otherwise, targets might begin to believe
 5966              they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
 5967              namespace. The first time any user complains about this, we'll
 5968              need to make LTWRAPPER_OPTION_PREFIX a configure-time option
 5969              or a configure.ac-settable value.
 5970            */
 5971           lt_fatal (__FILE__, __LINE__,
 5972             "unrecognized %s option: '%s'",
 5973                     ltwrapper_option_prefix, argv[i]);
 5974         }
 5975       /* otherwise ... */
 5976       newargz[++newargc] = xstrdup (argv[i]);
 5977     }
 5978   newargz[++newargc] = NULL;
 5979 
 5980 EOF
 5981         cat <<EOF
 5982   /* The GNU banner must be the first non-error debug message */
 5983   lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
 5984 EOF
 5985         cat <<"EOF"
 5986   lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
 5987   lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
 5988 
 5989   tmp_pathspec = find_executable (argv[0]);
 5990   if (tmp_pathspec == NULL)
 5991     lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
 5992   lt_debugprintf (__FILE__, __LINE__,
 5993                   "(main) found exe (before symlink chase) at: %s\n",
 5994           tmp_pathspec);
 5995 
 5996   actual_cwrapper_path = chase_symlinks (tmp_pathspec);
 5997   lt_debugprintf (__FILE__, __LINE__,
 5998                   "(main) found exe (after symlink chase) at: %s\n",
 5999           actual_cwrapper_path);
 6000   XFREE (tmp_pathspec);
 6001 
 6002   actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
 6003   strendzap (actual_cwrapper_path, actual_cwrapper_name);
 6004 
 6005   /* wrapper name transforms */
 6006   strendzap (actual_cwrapper_name, ".exe");
 6007   tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
 6008   XFREE (actual_cwrapper_name);
 6009   actual_cwrapper_name = tmp_pathspec;
 6010   tmp_pathspec = 0;
 6011 
 6012   /* target_name transforms -- use actual target program name; might have lt- prefix */
 6013   target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
 6014   strendzap (target_name, ".exe");
 6015   tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
 6016   XFREE (target_name);
 6017   target_name = tmp_pathspec;
 6018   tmp_pathspec = 0;
 6019 
 6020   lt_debugprintf (__FILE__, __LINE__,
 6021           "(main) libtool target name: %s\n",
 6022           target_name);
 6023 EOF
 6024 
 6025         cat <<EOF
 6026   newargz[0] =
 6027     XMALLOC (char, (strlen (actual_cwrapper_path) +
 6028             strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
 6029   strcpy (newargz[0], actual_cwrapper_path);
 6030   strcat (newargz[0], "$objdir");
 6031   strcat (newargz[0], "/");
 6032 EOF
 6033 
 6034         cat <<"EOF"
 6035   /* stop here, and copy so we don't have to do this twice */
 6036   tmp_pathspec = xstrdup (newargz[0]);
 6037 
 6038   /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
 6039   strcat (newargz[0], actual_cwrapper_name);
 6040 
 6041   /* DO want the lt- prefix here if it exists, so use target_name */
 6042   lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
 6043   XFREE (tmp_pathspec);
 6044   tmp_pathspec = NULL;
 6045 EOF
 6046 
 6047         case $host_os in
 6048           mingw*)
 6049         cat <<"EOF"
 6050   {
 6051     char* p;
 6052     while ((p = strchr (newargz[0], '\\')) != NULL)
 6053       {
 6054     *p = '/';
 6055       }
 6056     while ((p = strchr (lt_argv_zero, '\\')) != NULL)
 6057       {
 6058     *p = '/';
 6059       }
 6060   }
 6061 EOF
 6062         ;;
 6063         esac
 6064 
 6065         cat <<"EOF"
 6066   XFREE (target_name);
 6067   XFREE (actual_cwrapper_path);
 6068   XFREE (actual_cwrapper_name);
 6069 
 6070   lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
 6071   lt_setenv ("DUALCASE", "1");  /* for MSK sh */
 6072   /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
 6073      be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
 6074      because on Windows, both *_VARNAMEs are PATH but uninstalled
 6075      libraries must come first. */
 6076   lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
 6077   lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
 6078 
 6079   lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
 6080           nonnull (lt_argv_zero));
 6081   for (i = 0; i < newargc; i++)
 6082     {
 6083       lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
 6084               i, nonnull (newargz[i]));
 6085     }
 6086 
 6087 EOF
 6088 
 6089         case $host_os in
 6090           mingw*)
 6091         cat <<"EOF"
 6092   /* execv doesn't actually work on mingw as expected on unix */
 6093   newargz = prepare_spawn (newargz);
 6094   rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
 6095   if (rval == -1)
 6096     {
 6097       /* failed to start process */
 6098       lt_debugprintf (__FILE__, __LINE__,
 6099               "(main) failed to launch target \"%s\": %s\n",
 6100               lt_argv_zero, nonnull (strerror (errno)));
 6101       return 127;
 6102     }
 6103   return rval;
 6104 EOF
 6105         ;;
 6106           *)
 6107         cat <<"EOF"
 6108   execv (lt_argv_zero, newargz);
 6109   return rval; /* =127, but avoids unused variable warning */
 6110 EOF
 6111         ;;
 6112         esac
 6113 
 6114         cat <<"EOF"
 6115 }
 6116 
 6117 void *
 6118 xmalloc (size_t num)
 6119 {
 6120   void *p = (void *) malloc (num);
 6121   if (!p)
 6122     lt_fatal (__FILE__, __LINE__, "memory exhausted");
 6123 
 6124   return p;
 6125 }
 6126 
 6127 char *
 6128 xstrdup (const char *string)
 6129 {
 6130   return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
 6131               string) : NULL;
 6132 }
 6133 
 6134 const char *
 6135 base_name (const char *name)
 6136 {
 6137   const char *base;
 6138 
 6139 #if defined HAVE_DOS_BASED_FILE_SYSTEM
 6140   /* Skip over the disk name in MSDOS pathnames. */
 6141   if (isalpha ((unsigned char) name[0]) && name[1] == ':')
 6142     name += 2;
 6143 #endif
 6144 
 6145   for (base = name; *name; name++)
 6146     if (IS_DIR_SEPARATOR (*name))
 6147       base = name + 1;
 6148   return base;
 6149 }
 6150 
 6151 int
 6152 check_executable (const char *path)
 6153 {
 6154   struct stat st;
 6155 
 6156   lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
 6157                   nonempty (path));
 6158   if ((!path) || (!*path))
 6159     return 0;
 6160 
 6161   if ((stat (path, &st) >= 0)
 6162       && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
 6163     return 1;
 6164   else
 6165     return 0;
 6166 }
 6167 
 6168 int
 6169 make_executable (const char *path)
 6170 {
 6171   int rval = 0;
 6172   struct stat st;
 6173 
 6174   lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
 6175                   nonempty (path));
 6176   if ((!path) || (!*path))
 6177     return 0;
 6178 
 6179   if (stat (path, &st) >= 0)
 6180     {
 6181       rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
 6182     }
 6183   return rval;
 6184 }
 6185 
 6186 /* Searches for the full path of the wrapper.  Returns
 6187    newly allocated full path name if found, NULL otherwise
 6188    Does not chase symlinks, even on platforms that support them.
 6189 */
 6190 char *
 6191 find_executable (const char *wrapper)
 6192 {
 6193   int has_slash = 0;
 6194   const char *p;
 6195   const char *p_next;
 6196   /* static buffer for getcwd */
 6197   char tmp[LT_PATHMAX + 1];
 6198   size_t tmp_len;
 6199   char *concat_name;
 6200 
 6201   lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
 6202                   nonempty (wrapper));
 6203 
 6204   if ((wrapper == NULL) || (*wrapper == '\0'))
 6205     return NULL;
 6206 
 6207   /* Absolute path? */
 6208 #if defined HAVE_DOS_BASED_FILE_SYSTEM
 6209   if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
 6210     {
 6211       concat_name = xstrdup (wrapper);
 6212       if (check_executable (concat_name))
 6213     return concat_name;
 6214       XFREE (concat_name);
 6215     }
 6216   else
 6217     {
 6218 #endif
 6219       if (IS_DIR_SEPARATOR (wrapper[0]))
 6220     {
 6221       concat_name = xstrdup (wrapper);
 6222       if (check_executable (concat_name))
 6223         return concat_name;
 6224       XFREE (concat_name);
 6225     }
 6226 #if defined HAVE_DOS_BASED_FILE_SYSTEM
 6227     }
 6228 #endif
 6229 
 6230   for (p = wrapper; *p; p++)
 6231     if (*p == '/')
 6232       {
 6233     has_slash = 1;
 6234     break;
 6235       }
 6236   if (!has_slash)
 6237     {
 6238       /* no slashes; search PATH */
 6239       const char *path = getenv ("PATH");
 6240       if (path != NULL)
 6241     {
 6242       for (p = path; *p; p = p_next)
 6243         {
 6244           const char *q;
 6245           size_t p_len;
 6246           for (q = p; *q; q++)
 6247         if (IS_PATH_SEPARATOR (*q))
 6248           break;
 6249           p_len = (size_t) (q - p);
 6250           p_next = (*q == '\0' ? q : q + 1);
 6251           if (p_len == 0)
 6252         {
 6253           /* empty path: current directory */
 6254           if (getcwd (tmp, LT_PATHMAX) == NULL)
 6255             lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
 6256                               nonnull (strerror (errno)));
 6257           tmp_len = strlen (tmp);
 6258           concat_name =
 6259             XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
 6260           memcpy (concat_name, tmp, tmp_len);
 6261           concat_name[tmp_len] = '/';
 6262           strcpy (concat_name + tmp_len + 1, wrapper);
 6263         }
 6264           else
 6265         {
 6266           concat_name =
 6267             XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
 6268           memcpy (concat_name, p, p_len);
 6269           concat_name[p_len] = '/';
 6270           strcpy (concat_name + p_len + 1, wrapper);
 6271         }
 6272           if (check_executable (concat_name))
 6273         return concat_name;
 6274           XFREE (concat_name);
 6275         }
 6276     }
 6277       /* not found in PATH; assume curdir */
 6278     }
 6279   /* Relative path | not found in path: prepend cwd */
 6280   if (getcwd (tmp, LT_PATHMAX) == NULL)
 6281     lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
 6282               nonnull (strerror (errno)));
 6283   tmp_len = strlen (tmp);
 6284   concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
 6285   memcpy (concat_name, tmp, tmp_len);
 6286   concat_name[tmp_len] = '/';
 6287   strcpy (concat_name + tmp_len + 1, wrapper);
 6288 
 6289   if (check_executable (concat_name))
 6290     return concat_name;
 6291   XFREE (concat_name);
 6292   return NULL;
 6293 }
 6294 
 6295 char *
 6296 chase_symlinks (const char *pathspec)
 6297 {
 6298 #ifndef S_ISLNK
 6299   return xstrdup (pathspec);
 6300 #else
 6301   char buf[LT_PATHMAX];
 6302   struct stat s;
 6303   char *tmp_pathspec = xstrdup (pathspec);
 6304   char *p;
 6305   int has_symlinks = 0;
 6306   while (strlen (tmp_pathspec) && !has_symlinks)
 6307     {
 6308       lt_debugprintf (__FILE__, __LINE__,
 6309               "checking path component for symlinks: %s\n",
 6310               tmp_pathspec);
 6311       if (lstat (tmp_pathspec, &s) == 0)
 6312     {
 6313       if (S_ISLNK (s.st_mode) != 0)
 6314         {
 6315           has_symlinks = 1;
 6316           break;
 6317         }
 6318 
 6319       /* search backwards for last DIR_SEPARATOR */
 6320       p = tmp_pathspec + strlen (tmp_pathspec) - 1;
 6321       while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
 6322         p--;
 6323       if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
 6324         {
 6325           /* no more DIR_SEPARATORS left */
 6326           break;
 6327         }
 6328       *p = '\0';
 6329     }
 6330       else
 6331     {
 6332       lt_fatal (__FILE__, __LINE__,
 6333             "error accessing file \"%s\": %s",
 6334             tmp_pathspec, nonnull (strerror (errno)));
 6335     }
 6336     }
 6337   XFREE (tmp_pathspec);
 6338