"Fossies" - the Fresh Open Source Software Archive

Member "pcre-8.42/ltmain.sh" (20 Mar 2018, 331232 Bytes) of package /linux/misc/pcre-8.42.tar.bz2:


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. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "ltmain.sh": 8.41_vs_8.42.

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