"Fossies" - the Fresh Open Source Software Archive

Member "file-5.35/ltmain.sh" (18 Oct 2018, 283850 Bytes) of package /linux/misc/file-5.35.tar.gz:


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

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