Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  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.  
  137.  
  138. : ${CP="cp -f"}
  139. test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
  140. : ${MAKE="make"}
  141. : ${MKDIR="mkdir"}
  142. : ${MV="mv -f"}
  143. : ${RM="rm -f"}
  144. : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
  145. : ${Xsed="$SED -e 1s/^X//"}
  146.  
  147. # Global variables:
  148. EXIT_SUCCESS=0
  149. EXIT_FAILURE=1
  150. EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
  151. EXIT_SKIP=77      # $? = 77 is used to indicate a skipped test to automake.
  152.  
  153. exit_status=$EXIT_SUCCESS
  154.  
  155. # Make sure IFS has a sensible default
  156. lt_nl='
  157. '
  158. IFS="   $lt_nl"
  159.  
  160. dirname="s,/[^/]*$,,"
  161. basename="s,^.*/,,"
  162.  
  163. # func_dirname file append nondir_replacement
  164. # Compute the dirname of FILE.  If nonempty, add APPEND to the result,
  165. # otherwise set result to NONDIR_REPLACEMENT.
  166. func_dirname ()
  167. {
  168.    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
  169.    if test "X$func_dirname_result" = "X${1}"; then
  170.      func_dirname_result="${3}"
  171.    else
  172.      func_dirname_result="$func_dirname_result${2}"
  173.    fi
  174. } # func_dirname may be replaced by extended shell implementation
  175.  
  176.  
  177. # func_basename file
  178. func_basename ()
  179. {
  180.    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
  181. } # func_basename may be replaced by extended shell implementation
  182.  
  183.  
  184. # func_dirname_and_basename file append nondir_replacement
  185. # perform func_basename and func_dirname in a single function
  186. # call:
  187. #   dirname:  Compute the dirname of FILE.  If nonempty,
  188. #             add APPEND to the result, otherwise set result
  189. #             to NONDIR_REPLACEMENT.
  190. #             value returned in "$func_dirname_result"
  191. #   basename: Compute filename of FILE.
  192. #             value retuned in "$func_basename_result"
  193. # Implementation must be kept synchronized with func_dirname
  194. # and func_basename. For efficiency, we do not delegate to
  195. # those functions but instead duplicate the functionality here.
  196. func_dirname_and_basename ()
  197. {
  198.    # Extract subdirectory from the argument.
  199.    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
  200.    if test "X$func_dirname_result" = "X${1}"; then
  201.      func_dirname_result="${3}"
  202.    else
  203.      func_dirname_result="$func_dirname_result${2}"
  204.    fi
  205.    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
  206. } # func_dirname_and_basename may be replaced by extended shell implementation
  207.  
  208.  
  209. # func_stripname prefix suffix name
  210. # strip PREFIX and SUFFIX off of NAME.
  211. # PREFIX and SUFFIX must not contain globbing or regex special
  212. # characters, hashes, percent signs, but SUFFIX may contain a leading
  213. # dot (in which case that matches only a dot).
  214. # func_strip_suffix prefix name
  215. func_stripname ()
  216. {
  217.    case ${2} in
  218.      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
  219.      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
  220.    esac
  221. } # func_stripname may be replaced by extended shell implementation
  222.  
  223.  
  224. # These SED scripts presuppose an absolute path with a trailing slash.
  225. pathcar='s,^/\([^/]*\).*$,\1,'
  226. pathcdr='s,^/[^/]*,,'
  227. removedotparts=':dotsl
  228.                 s@/\./@/@g
  229.                 t dotsl
  230.                 s,/\.$,/,'
  231. collapseslashes='s@/\{1,\}@/@g'
  232. finalslash='s,/*$,/,'
  233.  
  234. # func_normal_abspath PATH
  235. # Remove doubled-up and trailing slashes, "." path components,
  236. # and cancel out any ".." path components in PATH after making
  237. # it an absolute path.
  238. #             value returned in "$func_normal_abspath_result"
  239. func_normal_abspath ()
  240. {
  241.  # Start from root dir and reassemble the path.
  242.  func_normal_abspath_result=
  243.  func_normal_abspath_tpath=$1
  244.  func_normal_abspath_altnamespace=
  245.  case $func_normal_abspath_tpath in
  246.    "")
  247.      # Empty path, that just means $cwd.
  248.      func_stripname '' '/' "`pwd`"
  249.      func_normal_abspath_result=$func_stripname_result
  250.      return
  251.    ;;
  252.    # The next three entries are used to spot a run of precisely
  253.    # two leading slashes without using negated character classes;
  254.    # we take advantage of case's first-match behaviour.
  255.    ///*)
  256.      # Unusual form of absolute path, do nothing.
  257.    ;;
  258.    //*)
  259.      # Not necessarily an ordinary path; POSIX reserves leading '//'
  260.      # and for example Cygwin uses it to access remote file shares
  261.      # over CIFS/SMB, so we conserve a leading double slash if found.
  262.      func_normal_abspath_altnamespace=/
  263.    ;;
  264.    /*)
  265.      # Absolute path, do nothing.
  266.    ;;
  267.    *)
  268.      # Relative path, prepend $cwd.
  269.      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
  270.    ;;
  271.  esac
  272.  # Cancel out all the simple stuff to save iterations.  We also want
  273.  # the path to end with a slash for ease of parsing, so make sure
  274.  # there is one (and only one) here.
  275.  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
  276.        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
  277.  while :; do
  278.    # Processed it all yet?
  279.    if test "$func_normal_abspath_tpath" = / ; then
  280.      # If we ascended to the root using ".." the result may be empty now.
  281.      if test -z "$func_normal_abspath_result" ; then
  282.        func_normal_abspath_result=/
  283.      fi
  284.      break
  285.    fi
  286.    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
  287.        -e "$pathcar"`
  288.    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
  289.        -e "$pathcdr"`
  290.    # Figure out what to do with it
  291.    case $func_normal_abspath_tcomponent in
  292.      "")
  293.        # Trailing empty path component, ignore it.
  294.      ;;
  295.      ..)
  296.        # Parent dir; strip last assembled component from result.
  297.        func_dirname "$func_normal_abspath_result"
  298.        func_normal_abspath_result=$func_dirname_result
  299.      ;;
  300.      *)
  301.        # Actual path component, append it.
  302.        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
  303.      ;;
  304.    esac
  305.  done
  306.  # Restore leading double-slash if one was found on entry.
  307.  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
  308. }
  309.  
  310. # func_relative_path SRCDIR DSTDIR
  311. # generates a relative path from SRCDIR to DSTDIR, with a trailing
  312. # slash if non-empty, suitable for immediately appending a filename
  313. # without needing to append a separator.
  314. #             value returned in "$func_relative_path_result"
  315. func_relative_path ()
  316. {
  317.  func_relative_path_result=
  318.  func_normal_abspath "$1"
  319.  func_relative_path_tlibdir=$func_normal_abspath_result
  320.  func_normal_abspath "$2"
  321.  func_relative_path_tbindir=$func_normal_abspath_result
  322.  
  323.  # Ascend the tree starting from libdir
  324.  while :; do
  325.    # check if we have found a prefix of bindir
  326.    case $func_relative_path_tbindir in
  327.      $func_relative_path_tlibdir)
  328.        # found an exact match
  329.        func_relative_path_tcancelled=
  330.        break
  331.        ;;
  332.      $func_relative_path_tlibdir*)
  333.        # found a matching prefix
  334.        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
  335.        func_relative_path_tcancelled=$func_stripname_result
  336.        if test -z "$func_relative_path_result"; then
  337.          func_relative_path_result=.
  338.        fi
  339.        break
  340.        ;;
  341.      *)
  342.        func_dirname $func_relative_path_tlibdir
  343.        func_relative_path_tlibdir=${func_dirname_result}
  344.        if test "x$func_relative_path_tlibdir" = x ; then
  345.          # Have to descend all the way to the root!
  346.          func_relative_path_result=../$func_relative_path_result
  347.          func_relative_path_tcancelled=$func_relative_path_tbindir
  348.          break
  349.        fi
  350.        func_relative_path_result=../$func_relative_path_result
  351.        ;;
  352.    esac
  353.  done
  354.  
  355.  # Now calculate path; take care to avoid doubling-up slashes.
  356.  func_stripname '' '/' "$func_relative_path_result"
  357.  func_relative_path_result=$func_stripname_result
  358.  func_stripname '/' '/' "$func_relative_path_tcancelled"
  359.  if test "x$func_stripname_result" != x ; then
  360.    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
  361.  fi
  362.  
  363.  # Normalisation. If bindir is libdir, return empty string,
  364.  # else relative path ending with a slash; either way, target
  365.  # file name can be directly appended.
  366.  if test ! -z "$func_relative_path_result"; then
  367.    func_stripname './' '' "$func_relative_path_result/"
  368.    func_relative_path_result=$func_stripname_result
  369.  fi
  370. }
  371.  
  372. # The name of this program:
  373. func_dirname_and_basename "$progpath"
  374. progname=$func_basename_result
  375.  
  376. # Make sure we have an absolute path for reexecution:
  377. case $progpath in
  378.  [\\/]*|[A-Za-z]:\\*) ;;
  379.  *[\\/]*)
  380.     progdir=$func_dirname_result
  381.     progdir=`cd "$progdir" && pwd`
  382.     progpath="$progdir/$progname"
  383.     ;;
  384.  *)
  385.     save_IFS="$IFS"
  386.     IFS=${PATH_SEPARATOR-:}
  387.     for progdir in $PATH; do
  388.       IFS="$save_IFS"
  389.       test -x "$progdir/$progname" && break
  390.     done
  391.     IFS="$save_IFS"
  392.     test -n "$progdir" || progdir=`pwd`
  393.     progpath="$progdir/$progname"
  394.     ;;
  395. esac
  396.  
  397. # Sed substitution that helps us do robust quoting.  It backslashifies
  398. # metacharacters that are still active within double-quoted strings.
  399. Xsed="${SED}"' -e 1s/^X//'
  400. sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
  401.  
  402. # Same as above, but do not quote variable references.
  403. double_quote_subst='s/\(["`\\]\)/\\\1/g'
  404.  
  405. # Sed substitution that turns a string into a regex matching for the
  406. # string literally.
  407. sed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
  408.  
  409. # Sed substitution that converts a w32 file name or path
  410. # which contains forward slashes, into one that contains
  411. # (escaped) backslashes.  A very naive implementation.
  412. lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
  413.  
  414. # Re-`\' parameter expansions in output of double_quote_subst that were
  415. # `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
  416. # in input to double_quote_subst, that '$' was protected from expansion.
  417. # Since each input `\' is now two `\'s, look for any number of runs of
  418. # four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
  419. bs='\\'
  420. bs2='\\\\'
  421. bs4='\\\\\\\\'
  422. dollar='\$'
  423. sed_double_backslash="\
  424.   s/$bs4/&\\
  425. /g
  426.   s/^$bs2$dollar/$bs&/
  427.   s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
  428.   s/\n//g"
  429.  
  430. # Standard options:
  431. opt_dry_run=false
  432. opt_help=false
  433. opt_quiet=false
  434. opt_verbose=false
  435. opt_warning=:
  436.  
  437. # func_echo arg...
  438. # Echo program name prefixed message, along with the current mode
  439. # name if it has been set yet.
  440. func_echo ()
  441. {
  442.    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
  443. }
  444.  
  445. # func_verbose arg...
  446. # Echo program name prefixed message in verbose mode only.
  447. func_verbose ()
  448. {
  449.    $opt_verbose && func_echo ${1+"$@"}
  450.  
  451.    # A bug in bash halts the script if the last line of a function
  452.    # fails when set -e is in force, so we need another command to
  453.    # work around that:
  454.    :
  455. }
  456.  
  457. # func_echo_all arg...
  458. # Invoke $ECHO with all args, space-separated.
  459. func_echo_all ()
  460. {
  461.    $ECHO "$*"
  462. }
  463.  
  464. # func_error arg...
  465. # Echo program name prefixed message to standard error.
  466. func_error ()
  467. {
  468.    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
  469. }
  470.  
  471. # func_warning arg...
  472. # Echo program name prefixed warning message to standard error.
  473. func_warning ()
  474. {
  475.    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
  476.  
  477.    # bash bug again:
  478.    :
  479. }
  480.  
  481. # func_fatal_error arg...
  482. # Echo program name prefixed message to standard error, and exit.
  483. func_fatal_error ()
  484. {
  485.    func_error ${1+"$@"}
  486.    exit $EXIT_FAILURE
  487. }
  488.  
  489. # func_fatal_help arg...
  490. # Echo program name prefixed message to standard error, followed by
  491. # a help hint, and exit.
  492. func_fatal_help ()
  493. {
  494.    func_error ${1+"$@"}
  495.    func_fatal_error "$help"
  496. }
  497. help="Try \`$progname --help' for more information."  ## default
  498.  
  499.  
  500. # func_grep expression filename
  501. # Check whether EXPRESSION matches any line of FILENAME, without output.
  502. func_grep ()
  503. {
  504.    $GREP "$1" "$2" >/dev/null 2>&1
  505. }
  506.  
  507.  
  508. # func_mkdir_p directory-path
  509. # Make sure the entire path to DIRECTORY-PATH is available.
  510. func_mkdir_p ()
  511. {
  512.    my_directory_path="$1"
  513.    my_dir_list=
  514.  
  515.    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
  516.  
  517.      # Protect directory names starting with `-'
  518.       case $my_directory_path in
  519.         -*) my_directory_path="./$my_directory_path" ;;
  520.       esac
  521.  
  522.       # While some portion of DIR does not yet exist...
  523.       while test ! -d "$my_directory_path"; do
  524.         # ...make a list in topmost first order.  Use a colon delimited
  525.         # list incase some portion of path contains whitespace.
  526.         my_dir_list="$my_directory_path:$my_dir_list"
  527.  
  528.         # If the last portion added has no slash in it, the list is done
  529.         case $my_directory_path in */*) ;; *) break ;; esac
  530.  
  531.         # ...otherwise throw away the child directory and loop
  532.         my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
  533.       done
  534.       my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
  535.  
  536.       save_mkdir_p_IFS="$IFS"; IFS=':'
  537.       for my_dir in $my_dir_list; do
  538.         IFS="$save_mkdir_p_IFS"
  539.         # mkdir can fail with a `File exist' error if two processes
  540.         # try to create one of the directories concurrently.  Don't
  541.         # stop in that case!
  542.         $MKDIR "$my_dir" 2>/dev/null || :
  543.       done
  544.       IFS="$save_mkdir_p_IFS"
  545.  
  546.       # Bail out if we (or some other process) failed to create a directory.
  547.       test -d "$my_directory_path" || \
  548.         func_fatal_error "Failed to create \`$1'"
  549.    fi
  550. }
  551.  
  552.  
  553. # func_mktempdir [string]
  554. # Make a temporary directory that won't clash with other running
  555. # libtool processes, and avoids race conditions if possible.  If
  556. # given, STRING is the basename for that directory.
  557. func_mktempdir ()
  558. {
  559.    my_template="${TMPDIR-/tmp}/${1-$progname}"
  560.  
  561.    if test "$opt_dry_run" = ":"; then
  562.      # Return a directory name, but don't create it in dry-run mode
  563.      my_tmpdir="${my_template}-$$"
  564.    else
  565.  
  566.      # If mktemp works, use that first and foremost
  567.      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
  568.  
  569.      if test ! -d "$my_tmpdir"; then
  570.        # Failing that, at least try and use $RANDOM to avoid a race
  571.        my_tmpdir="${my_template}-${RANDOM-0}$$"
  572.  
  573.        save_mktempdir_umask=`umask`
  574.        umask 0077
  575.        $MKDIR "$my_tmpdir"
  576.        umask $save_mktempdir_umask
  577.      fi
  578.  
  579.      # If we're not in dry-run mode, bomb out on failure
  580.      test -d "$my_tmpdir" || \
  581.        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
  582.     fi
  583.  
  584.     $ECHO "$my_tmpdir"
  585. }
  586.  
  587.  
  588. # func_quote_for_eval arg
  589. # Aesthetically quote ARG to be evaled later.
  590. # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
  591. # is double-quoted, suitable for a subsequent eval, whereas
  592. # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
  593. # which are still active within double quotes backslashified.
  594. func_quote_for_eval ()
  595. {
  596.     case $1 in
  597.       *[\\\`\"\$]*)
  598.         func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
  599.       *)
  600.         func_quote_for_eval_unquoted_result="$1" ;;
  601.     esac
  602.  
  603.     case $func_quote_for_eval_unquoted_result in
  604.       # Double-quote args containing shell metacharacters to delay
  605.       # word splitting, command substitution and and variable
  606.       # expansion for a subsequent eval.
  607.       # Many Bourne shells cannot handle close brackets correctly
  608.       # in scan sets, so we specify it separately.
  609.       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
  610.         func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
  611.         ;;
  612.       *)
  613.         func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
  614.     esac
  615. }
  616.  
  617.  
  618. # func_quote_for_expand arg
  619. # Aesthetically quote ARG to be evaled later; same as above,
  620. # but do not quote variable references.
  621. func_quote_for_expand ()
  622. {
  623.     case $1 in
  624.       *[\\\`\"]*)
  625.         my_arg=`$ECHO "$1" | $SED \
  626.             -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
  627.       *)
  628.         my_arg="$1" ;;
  629.     esac
  630.  
  631.     case $my_arg in
  632.       # Double-quote args containing shell metacharacters to delay
  633.       # word splitting and command substitution for a subsequent eval.
  634.       # Many Bourne shells cannot handle close brackets correctly
  635.       # in scan sets, so we specify it separately.
  636.       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
  637.         my_arg="\"$my_arg\""
  638.         ;;
  639.     esac
  640.  
  641.     func_quote_for_expand_result="$my_arg"
  642. }
  643.  
  644.  
  645. # func_show_eval cmd [fail_exp]
  646. # Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
  647. # not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
  648. # is given, then evaluate it.
  649. func_show_eval ()
  650. {
  651.     my_cmd="$1"
  652.     my_fail_exp="${2-:}"
  653.  
  654.     ${opt_silent-false} || {
  655.       func_quote_for_expand "$my_cmd"
  656.       eval "func_echo $func_quote_for_expand_result"
  657.     }
  658.  
  659.     if ${opt_dry_run-false}; then :; else
  660.       eval "$my_cmd"
  661.       my_status=$?
  662.       if test "$my_status" -eq 0; then :; else
  663.         eval "(exit $my_status); $my_fail_exp"
  664.       fi
  665.     fi
  666. }
  667.  
  668.  
  669. # func_show_eval_locale cmd [fail_exp]
  670. # Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
  671. # not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
  672. # is given, then evaluate it.  Use the saved locale for evaluation.
  673. func_show_eval_locale ()
  674. {
  675.     my_cmd="$1"
  676.     my_fail_exp="${2-:}"
  677.  
  678.     ${opt_silent-false} || {
  679.       func_quote_for_expand "$my_cmd"
  680.       eval "func_echo $func_quote_for_expand_result"
  681.     }
  682.  
  683.     if ${opt_dry_run-false}; then :; else
  684.       eval "$lt_user_locale
  685.             $my_cmd"
  686.       my_status=$?
  687.       eval "$lt_safe_locale"
  688.       if test "$my_status" -eq 0; then :; else
  689.         eval "(exit $my_status); $my_fail_exp"
  690.       fi
  691.     fi
  692. }
  693.  
  694. # func_tr_sh
  695. # Turn $1 into a string suitable for a shell variable name.
  696. # Result is stored in $func_tr_sh_result.  All characters
  697. # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
  698. # if $1 begins with a digit, a '_' is prepended as well.
  699. func_tr_sh ()
  700. {
  701.   case $1 in
  702.   [0-9]* | *[!a-zA-Z0-9_]*)
  703.     func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
  704.     ;;
  705.   * )
  706.     func_tr_sh_result=$1
  707.     ;;
  708.   esac
  709. }
  710.  
  711.  
  712. # func_version
  713. # Echo version message to standard output and exit.
  714. func_version ()
  715. {
  716.     $opt_debug
  717.  
  718.     $SED -n '/(C)/!b go
  719.         :more
  720.         /\./!{
  721.           N
  722.           s/\n# / /
  723.           b more
  724.         }
  725.         :go
  726.         /^# '$PROGRAM' (GNU /,/# warranty; / {
  727.        s/^# //
  728.         s/^# *$//
  729.        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
  730.        p
  731.     }' < "$progpath"
  732.      exit $?
  733. }
  734.  
  735. # func_usage
  736. # Echo short help message to standard output and exit.
  737. func_usage ()
  738. {
  739.     $opt_debug
  740.  
  741.     $SED -n '/^# Usage:/,/^#  *.*--help/ {
  742.        s/^# //
  743.         s/^# *$//
  744.         s/\$progname/'$progname'/
  745.         p
  746.    }' < "$progpath"
  747.     echo
  748.     $ECHO "run \`$progname --help | more' for full usage"
  749.    exit $?
  750. }
  751.  
  752. # func_help [NOEXIT]
  753. # Echo long help message to standard output and exit,
  754. # unless 'noexit' is passed as argument.
  755. func_help ()
  756. {
  757.    $opt_debug
  758.  
  759.    $SED -n '/^# Usage:/,/# Report bugs to/ {
  760.         :print
  761.        s/^# //
  762.         s/^# *$//
  763.         s*\$progname*'$progname'*
  764.         s*\$host*'"$host"'*
  765.         s*\$SHELL*'"$SHELL"'*
  766.         s*\$LTCC*'"$LTCC"'*
  767.         s*\$LTCFLAGS*'"$LTCFLAGS"'*
  768.         s*\$LD*'"$LD"'*
  769.         s/\$with_gnu_ld/'"$with_gnu_ld"'/
  770.         s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
  771.         s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
  772.         p
  773.         d
  774.     }
  775.     /^# .* home page:/b print
  776.     /^# General help using/b print
  777.     ' < "$progpath"
  778.    ret=$?
  779.    if test -z "$1"; then
  780.      exit $ret
  781.    fi
  782. }
  783.  
  784. # func_missing_arg argname
  785. # Echo program name prefixed message to standard error and set global
  786. # exit_cmd.
  787. func_missing_arg ()
  788. {
  789.    $opt_debug
  790.  
  791.    func_error "missing argument for $1."
  792.    exit_cmd=exit
  793. }
  794.  
  795.  
  796. # func_split_short_opt shortopt
  797. # Set func_split_short_opt_name and func_split_short_opt_arg shell
  798. # variables after splitting SHORTOPT after the 2nd character.
  799. func_split_short_opt ()
  800. {
  801.    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
  802.    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
  803.  
  804.    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
  805.    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
  806. } # func_split_short_opt may be replaced by extended shell implementation
  807.  
  808.  
  809. # func_split_long_opt longopt
  810. # Set func_split_long_opt_name and func_split_long_opt_arg shell
  811. # variables after splitting LONGOPT at the `=' sign.
  812. func_split_long_opt ()
  813. {
  814.    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
  815.    my_sed_long_arg='1s/^--[^=]*=//'
  816.  
  817.    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
  818.    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
  819. } # func_split_long_opt may be replaced by extended shell implementation
  820.  
  821. exit_cmd=:
  822.  
  823.  
  824.  
  825.  
  826.  
  827. magic="%%%MAGIC variable%%%"
  828. magic_exe="%%%MAGIC EXE variable%%%"
  829.  
  830. # Global variables.
  831. nonopt=
  832. preserve_args=
  833. lo2o="s/\\.lo\$/.${objext}/"
  834. o2lo="s/\\.${objext}\$/.lo/"
  835. extracted_archives=
  836. extracted_serial=0
  837.  
  838. # If this variable is set in any of the actions, the command in it
  839. # will be execed at the end.  This prevents here-documents from being
  840. # left over by shells.
  841. exec_cmd=
  842.  
  843. # func_append var value
  844. # Append VALUE to the end of shell variable VAR.
  845. func_append ()
  846. {
  847.    eval "${1}=\$${1}\${2}"
  848. } # func_append may be replaced by extended shell implementation
  849.  
  850. # func_append_quoted var value
  851. # Quote VALUE and append to the end of shell variable VAR, separated
  852. # by a space.
  853. func_append_quoted ()
  854. {
  855.    func_quote_for_eval "${2}"
  856.    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
  857. } # func_append_quoted may be replaced by extended shell implementation
  858.  
  859.  
  860. # func_arith arithmetic-term...
  861. func_arith ()
  862. {
  863.    func_arith_result=`expr "${@}"`
  864. } # func_arith may be replaced by extended shell implementation
  865.  
  866.  
  867. # func_len string
  868. # STRING may not start with a hyphen.
  869. func_len ()
  870. {
  871.    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
  872. } # func_len may be replaced by extended shell implementation
  873.  
  874.  
  875. # func_lo2o object
  876. func_lo2o ()
  877. {
  878.    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
  879. } # func_lo2o may be replaced by extended shell implementation
  880.  
  881.  
  882. # func_xform libobj-or-source
  883. func_xform ()
  884. {
  885.    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
  886. } # func_xform may be replaced by extended shell implementation
  887.  
  888.  
  889. # func_fatal_configuration arg...
  890. # Echo program name prefixed message to standard error, followed by
  891. # a configuration failure hint, and exit.
  892. func_fatal_configuration ()
  893. {
  894.    func_error ${1+"$@"}
  895.    func_error "See the $PACKAGE documentation for more information."
  896.    func_fatal_error "Fatal configuration error."
  897. }
  898.  
  899.  
  900. # func_config
  901. # Display the configuration for all the tags in this script.
  902. func_config ()
  903. {
  904.    re_begincf='^# ### BEGIN LIBTOOL'
  905.    re_endcf='^# ### END LIBTOOL'
  906.  
  907.    # Default configuration.
  908.    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
  909.  
  910.    # Now print the configurations for the tags.
  911.    for tagname in $taglist; do
  912.      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
  913.    done
  914.  
  915.    exit $?
  916. }
  917.  
  918. # func_features
  919. # Display the features supported by this script.
  920. func_features ()
  921. {
  922.    echo "host: $host"
  923.    if test "$build_libtool_libs" = yes; then
  924.      echo "enable shared libraries"
  925.    else
  926.      echo "disable shared libraries"
  927.    fi
  928.    if test "$build_old_libs" = yes; then
  929.      echo "enable static libraries"
  930.    else
  931.      echo "disable static libraries"
  932.    fi
  933.  
  934.    exit $?
  935. }
  936.  
  937. # func_enable_tag tagname
  938. # Verify that TAGNAME is valid, and either flag an error and exit, or
  939. # enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
  940. # variable here.
  941. func_enable_tag ()
  942. {
  943.  # Global variable:
  944.  tagname="$1"
  945.  
  946.  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
  947.   re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
  948.   sed_extractcf="/$re_begincf/,/$re_endcf/p"
  949.  
  950.   # Validate tagname.
  951.   case $tagname in
  952.     *[!-_A-Za-z0-9,/]*)
  953.       func_fatal_error "invalid tag name: $tagname"
  954.       ;;
  955.   esac
  956.  
  957.   # Don't test for the "default" C tag, as we know it's
  958.   # there but not specially marked.
  959.   case $tagname in
  960.     CC) ;;
  961.     *)
  962.       if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
  963.         taglist="$taglist $tagname"
  964.  
  965.         # Evaluate the configuration.  Be careful to quote the path
  966.         # and the sed script, to avoid splitting on whitespace, but
  967.         # also don't use non-portable quotes within backquotes within
  968.         # quotes we have to do it in 2 steps:
  969.         extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
  970.         eval "$extractedcf"
  971.       else
  972.         func_error "ignoring unknown tag $tagname"
  973.       fi
  974.       ;;
  975.   esac
  976. }
  977.  
  978. # func_check_version_match
  979. # Ensure that we are using m4 macros, and libtool script from the same
  980. # release of libtool.
  981. func_check_version_match ()
  982. {
  983.   if test "$package_revision" != "$macro_revision"; then
  984.     if test "$VERSION" != "$macro_version"; then
  985.       if test -z "$macro_version"; then
  986.         cat >&2 <<_LT_EOF
  987. $progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
  988. $progname: definition of this LT_INIT comes from an older release.
  989. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
  990. $progname: and run autoconf again.
  991. _LT_EOF
  992.       else
  993.         cat >&2 <<_LT_EOF
  994. $progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
  995. $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
  996. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
  997. $progname: and run autoconf again.
  998. _LT_EOF
  999.       fi
  1000.     else
  1001.       cat >&2 <<_LT_EOF
  1002. $progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
  1003. $progname: but the definition of this LT_INIT comes from revision $macro_revision.
  1004. $progname: You should recreate aclocal.m4 with macros from revision $package_revision
  1005. $progname: of $PACKAGE $VERSION and run autoconf again.
  1006. _LT_EOF
  1007.     fi
  1008.  
  1009.     exit $EXIT_MISMATCH
  1010.   fi
  1011. }
  1012.  
  1013.  
  1014. # Shorthand for --mode=foo, only valid as the first argument
  1015. case $1 in
  1016. clean|clea|cle|cl)
  1017.   shift; set dummy --mode clean ${1+"$@"}; shift
  1018.   ;;
  1019. compile|compil|compi|comp|com|co|c)
  1020.   shift; set dummy --mode compile ${1+"$@"}; shift
  1021.   ;;
  1022. execute|execut|execu|exec|exe|ex|e)
  1023.   shift; set dummy --mode execute ${1+"$@"}; shift
  1024.   ;;
  1025. finish|finis|fini|fin|fi|f)
  1026.   shift; set dummy --mode finish ${1+"$@"}; shift
  1027.   ;;
  1028. install|instal|insta|inst|ins|in|i)
  1029.   shift; set dummy --mode install ${1+"$@"}; shift
  1030.   ;;
  1031. link|lin|li|l)
  1032.   shift; set dummy --mode link ${1+"$@"}; shift
  1033.   ;;
  1034. uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
  1035.   shift; set dummy --mode uninstall ${1+"$@"}; shift
  1036.   ;;
  1037. esac
  1038.  
  1039.  
  1040.  
  1041. # Option defaults:
  1042. opt_debug=:
  1043. opt_dry_run=false
  1044. opt_config=false
  1045. opt_preserve_dup_deps=false
  1046. opt_features=false
  1047. opt_finish=false
  1048. opt_help=false
  1049. opt_help_all=false
  1050. opt_silent=:
  1051. opt_warning=:
  1052. opt_verbose=:
  1053. opt_silent=false
  1054. opt_verbose=false
  1055.  
  1056.  
  1057. # Parse options once, thoroughly.  This comes as soon as possible in the
  1058. # script to make things like `--version' happen as quickly as we can.
  1059. {
  1060.   # this just eases exit handling
  1061.   while test $# -gt 0; do
  1062.     opt="$1"
  1063.     shift
  1064.     case $opt in
  1065.       --debug|-x)       opt_debug='set -x'
  1066.                         func_echo "enabling shell trace mode"
  1067.                         $opt_debug
  1068.                         ;;
  1069.       --dry-run|--dryrun|-n)
  1070.                         opt_dry_run=:
  1071.                         ;;
  1072.       --config)
  1073.                         opt_config=:
  1074. func_config
  1075.                         ;;
  1076.       --dlopen|-dlopen)
  1077.                         optarg="$1"
  1078.                         opt_dlopen="${opt_dlopen+$opt_dlopen
  1079. }$optarg"
  1080.                         shift
  1081.                         ;;
  1082.       --preserve-dup-deps)
  1083.                         opt_preserve_dup_deps=:
  1084.                         ;;
  1085.       --features)
  1086.                         opt_features=:
  1087. func_features
  1088.                         ;;
  1089.       --finish)
  1090.                         opt_finish=:
  1091. set dummy --mode finish ${1+"$@"}; shift
  1092.                         ;;
  1093.       --help)
  1094.                         opt_help=:
  1095.                         ;;
  1096.       --help-all)
  1097.                         opt_help_all=:
  1098. opt_help=': help-all'
  1099.                         ;;
  1100.       --mode)
  1101.                         test $# = 0 && func_missing_arg $opt && break
  1102.                         optarg="$1"
  1103.                         opt_mode="$optarg"
  1104. case $optarg in
  1105.   # Valid mode arguments:
  1106.   clean|compile|execute|finish|install|link|relink|uninstall) ;;
  1107.  
  1108.   # Catch anything else as an error
  1109.   *) func_error "invalid argument for $opt"
  1110.      exit_cmd=exit
  1111.      break
  1112.      ;;
  1113. esac
  1114.                         shift
  1115.                         ;;
  1116.       --no-silent|--no-quiet)
  1117.                         opt_silent=false
  1118. func_append preserve_args " $opt"
  1119.                         ;;
  1120.       --no-warning|--no-warn)
  1121.                         opt_warning=false
  1122. func_append preserve_args " $opt"
  1123.                         ;;
  1124.       --no-verbose)
  1125.                         opt_verbose=false
  1126. func_append preserve_args " $opt"
  1127.                         ;;
  1128.       --silent|--quiet)
  1129.                         opt_silent=:
  1130. func_append preserve_args " $opt"
  1131.         opt_verbose=false
  1132.                         ;;
  1133.       --verbose|-v)
  1134.                         opt_verbose=:
  1135. func_append preserve_args " $opt"
  1136. opt_silent=false
  1137.                         ;;
  1138.       --tag)
  1139.                         test $# = 0 && func_missing_arg $opt && break
  1140.                         optarg="$1"
  1141.                         opt_tag="$optarg"
  1142. func_append preserve_args " $opt $optarg"
  1143. func_enable_tag "$optarg"
  1144.                         shift
  1145.                         ;;
  1146.  
  1147.       -\?|-h)           func_usage                              ;;
  1148.       --help)           func_help                               ;;
  1149.       --version)        func_version                            ;;
  1150.  
  1151.       # Separate optargs to long options:
  1152.       --*=*)
  1153.                         func_split_long_opt "$opt"
  1154.                         set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
  1155.                         shift
  1156.                         ;;
  1157.  
  1158.       # Separate non-argument short options:
  1159.       -\?*|-h*|-n*|-v*)
  1160.                         func_split_short_opt "$opt"
  1161.                         set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
  1162.                         shift
  1163.                         ;;
  1164.  
  1165.       --)               break                                   ;;
  1166.       -*)               func_fatal_help "unrecognized option \`$opt'" ;;
  1167.       *)                set dummy "$opt" ${1+"$@"};     shift; break  ;;
  1168.    esac
  1169.  done
  1170.  
  1171.  # Validate options:
  1172.  
  1173.  # save first non-option argument
  1174.  if test "$#" -gt 0; then
  1175.    nonopt="$opt"
  1176.    shift
  1177.  fi
  1178.  
  1179.  # preserve --debug
  1180.  test "$opt_debug" = : || func_append preserve_args " --debug"
  1181.  
  1182.  case $host in
  1183.    *cygwin* | *mingw* | *pw32* | *cegcc*)
  1184.      # don't eliminate duplications in $postdeps and $predeps
  1185.      opt_duplicate_compiler_generated_deps=:
  1186.      ;;
  1187.    *)
  1188.      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
  1189.      ;;
  1190.  esac
  1191.  
  1192.  $opt_help || {
  1193.    # Sanity checks first:
  1194.    func_check_version_match
  1195.  
  1196.    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
  1197.      func_fatal_configuration "not configured to build any kind of library"
  1198.    fi
  1199.  
  1200.    # Darwin sucks
  1201.    eval std_shrext=\"$shrext_cmds\"
  1202.  
  1203.    # Only execute mode is allowed to have -dlopen flags.
  1204.    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
  1205.      func_error "unrecognized option \`-dlopen'"
  1206.       $ECHO "$help" 1>&2
  1207.       exit $EXIT_FAILURE
  1208.     fi
  1209.  
  1210.     # Change the help message to a mode-specific one.
  1211.     generic_help="$help"
  1212.     help="Try \`$progname --help --mode=$opt_mode' for more information."
  1213.  }
  1214.  
  1215.  
  1216.  # Bail if the options were screwed
  1217.  $exit_cmd $EXIT_FAILURE
  1218. }
  1219.  
  1220.  
  1221.  
  1222.  
  1223. ## ----------- ##
  1224. ##    Main.    ##
  1225. ## ----------- ##
  1226.  
  1227. # func_lalib_p file
  1228. # True iff FILE is a libtool `.la' library or `.lo' object file.
  1229. # This function is only a basic sanity check; it will hardly flush out
  1230. # determined imposters.
  1231. func_lalib_p ()
  1232. {
  1233.    test -f "$1" &&
  1234.      $SED -e 4q "$1" 2>/dev/null \
  1235.        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
  1236. }
  1237.  
  1238. # func_lalib_unsafe_p file
  1239. # True iff FILE is a libtool `.la' library or `.lo' object file.
  1240. # This function implements the same check as func_lalib_p without
  1241. # resorting to external programs.  To this end, it redirects stdin and
  1242. # closes it afterwards, without saving the original file descriptor.
  1243. # As a safety measure, use it only where a negative result would be
  1244. # fatal anyway.  Works if `file' does not exist.
  1245. func_lalib_unsafe_p ()
  1246. {
  1247.    lalib_p=no
  1248.    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
  1249.         for lalib_p_l in 1 2 3 4
  1250.         do
  1251.             read lalib_p_line
  1252.             case "$lalib_p_line" in
  1253.                 \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
  1254.             esac
  1255.         done
  1256.         exec 0<&5 5<&-
  1257.    fi
  1258.    test "$lalib_p" = yes
  1259. }
  1260.  
  1261. # func_ltwrapper_script_p file
  1262. # True iff FILE is a libtool wrapper script
  1263. # This function is only a basic sanity check; it will hardly flush out
  1264. # determined imposters.
  1265. func_ltwrapper_script_p ()
  1266. {
  1267.    func_lalib_p "$1"
  1268. }
  1269.  
  1270. # func_ltwrapper_executable_p file
  1271. # True iff FILE is a libtool wrapper executable
  1272. # This function is only a basic sanity check; it will hardly flush out
  1273. # determined imposters.
  1274. func_ltwrapper_executable_p ()
  1275. {
  1276.    func_ltwrapper_exec_suffix=
  1277.    case $1 in
  1278.    *.exe) ;;
  1279.    *) func_ltwrapper_exec_suffix=.exe ;;
  1280.    esac
  1281.    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
  1282. }
  1283.  
  1284. # func_ltwrapper_scriptname file
  1285. # Assumes file is an ltwrapper_executable
  1286. # uses $file to determine the appropriate filename for a
  1287. # temporary ltwrapper_script.
  1288. func_ltwrapper_scriptname ()
  1289. {
  1290.    func_dirname_and_basename "$1" "" "."
  1291.    func_stripname '' '.exe' "$func_basename_result"
  1292.    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
  1293. }
  1294.  
  1295. # func_ltwrapper_p file
  1296. # True iff FILE is a libtool wrapper script or wrapper executable
  1297. # This function is only a basic sanity check; it will hardly flush out
  1298. # determined imposters.
  1299. func_ltwrapper_p ()
  1300. {
  1301.    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
  1302. }
  1303.  
  1304.  
  1305. # func_execute_cmds commands fail_cmd
  1306. # Execute tilde-delimited COMMANDS.
  1307. # If FAIL_CMD is given, eval that upon failure.
  1308. # FAIL_CMD may read-access the current command in variable CMD!
  1309. func_execute_cmds ()
  1310. {
  1311.    $opt_debug
  1312.    save_ifs=$IFS; IFS='~'
  1313.    for cmd in $1; do
  1314.      IFS=$save_ifs
  1315.      eval cmd=\"$cmd\"
  1316.      func_show_eval "$cmd" "${2-:}"
  1317.    done
  1318.    IFS=$save_ifs
  1319. }
  1320.  
  1321.  
  1322. # func_source file
  1323. # Source FILE, adding directory component if necessary.
  1324. # Note that it is not necessary on cygwin/mingw to append a dot to
  1325. # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
  1326. # behavior happens only for exec(3), not for open(2)!  Also, sourcing
  1327. # `FILE.' does not work on cygwin managed mounts.
  1328. func_source ()
  1329. {
  1330.    $opt_debug
  1331.    case $1 in
  1332.     */* | *\\*) . "$1" ;;
  1333.     *)          . "./$1" ;;
  1334.    esac
  1335. }
  1336.  
  1337.  
  1338. # func_resolve_sysroot PATH
  1339. # Replace a leading = in PATH with a sysroot.  Store the result into
  1340. # func_resolve_sysroot_result
  1341. func_resolve_sysroot ()
  1342. {
  1343.  func_resolve_sysroot_result=$1
  1344.  case $func_resolve_sysroot_result in
  1345.  =*)
  1346.    func_stripname '=' '' "$func_resolve_sysroot_result"
  1347.    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
  1348.    ;;
  1349.  esac
  1350. }
  1351.  
  1352. # func_replace_sysroot PATH
  1353. # If PATH begins with the sysroot, replace it with = and
  1354. # store the result into func_replace_sysroot_result.
  1355. func_replace_sysroot ()
  1356. {
  1357.  case "$lt_sysroot:$1" in
  1358.  ?*:"$lt_sysroot"*)
  1359.    func_stripname "$lt_sysroot" '' "$1"
  1360.    func_replace_sysroot_result="=$func_stripname_result"
  1361.    ;;
  1362.  *)
  1363.    # Including no sysroot.
  1364.    func_replace_sysroot_result=$1
  1365.    ;;
  1366.  esac
  1367. }
  1368.  
  1369. # func_infer_tag arg
  1370. # Infer tagged configuration to use if any are available and
  1371. # if one wasn't chosen via the "--tag" command line option.
  1372. # Only attempt this if the compiler in the base compile
  1373. # command doesn't match the default compiler.
  1374. # arg is usually of the form 'gcc ...'
  1375. func_infer_tag ()
  1376. {
  1377.    $opt_debug
  1378.    if test -n "$available_tags" && test -z "$tagname"; then
  1379.      CC_quoted=
  1380.      for arg in $CC; do
  1381.         func_append_quoted CC_quoted "$arg"
  1382.      done
  1383.      CC_expanded=`func_echo_all $CC`
  1384.      CC_quoted_expanded=`func_echo_all $CC_quoted`
  1385.      case $@ in
  1386.      # Blanks in the command may have been stripped by the calling shell,
  1387.      # but not from the CC environment variable when configure was run.
  1388.      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
  1389.      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
  1390.      # Blanks at the start of $base_compile will cause this to fail
  1391.      # if we don't check for them as well.
  1392.      *)
  1393.         for z in $available_tags; do
  1394.           if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
  1395.             # Evaluate the configuration.
  1396.             eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
  1397.             CC_quoted=
  1398.             for arg in $CC; do
  1399.               # Double-quote args containing other shell metacharacters.
  1400.               func_append_quoted CC_quoted "$arg"
  1401.             done
  1402.             CC_expanded=`func_echo_all $CC`
  1403.             CC_quoted_expanded=`func_echo_all $CC_quoted`
  1404.             case "$@ " in
  1405.             " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
  1406.             " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
  1407.               # The compiler in the base compile command matches
  1408.               # the one in the tagged configuration.
  1409.               # Assume this is the tagged configuration we want.
  1410.               tagname=$z
  1411.               break
  1412.               ;;
  1413.             esac
  1414.           fi
  1415.         done
  1416.         # If $tagname still isn't set, then no tagged configuration
  1417.         # was found and let the user know that the "--tag" command
  1418.         # line option must be used.
  1419.         if test -z "$tagname"; then
  1420.           func_echo "unable to infer tagged configuration"
  1421.           func_fatal_error "specify a tag with \`--tag'"
  1422. #       else
  1423. #         func_verbose "using $tagname tagged configuration"
  1424.         fi
  1425.         ;;
  1426.       esac
  1427.     fi
  1428. }
  1429.  
  1430.  
  1431.  
  1432. # func_write_libtool_object output_name pic_name nonpic_name
  1433. # Create a libtool object file (analogous to a ".la" file),
  1434. # but don't create it if we're doing a dry run.
  1435. func_write_libtool_object ()
  1436. {
  1437.     write_libobj=${1}
  1438.     if test "$build_libtool_libs" = yes; then
  1439.       write_lobj=\'${2}\'
  1440.     else
  1441.       write_lobj=none
  1442.     fi
  1443.  
  1444.     if test "$build_old_libs" = yes; then
  1445.       write_oldobj=\'${3}\'
  1446.     else
  1447.       write_oldobj=none
  1448.     fi
  1449.  
  1450.     $opt_dry_run || {
  1451.       cat >${write_libobj}T <<EOF
  1452. # $write_libobj - a libtool object file
  1453. # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
  1454. #
  1455. # Please DO NOT delete this file!
  1456. # It is necessary for linking the library.
  1457.  
  1458. # Name of the PIC object.
  1459. pic_object=$write_lobj
  1460.  
  1461. # Name of the non-PIC object
  1462. non_pic_object=$write_oldobj
  1463.  
  1464. EOF
  1465.       $MV "${write_libobj}T" "${write_libobj}"
  1466.     }
  1467. }
  1468.  
  1469.  
  1470. ##################################################
  1471. # FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
  1472. ##################################################
  1473.  
  1474. # func_convert_core_file_wine_to_w32 ARG
  1475. # Helper function used by file name conversion functions when $build is *nix,
  1476. # and $host is mingw, cygwin, or some other w32 environment. Relies on a
  1477. # correctly configured wine environment available, with the winepath program
  1478. # in $build's $PATH.
  1479. #
  1480. # ARG is the $build file name to be converted to w32 format.
  1481. # Result is available in $func_convert_core_file_wine_to_w32_result, and will
  1482. # be empty on error (or when ARG is empty)
  1483. func_convert_core_file_wine_to_w32 ()
  1484. {
  1485.   $opt_debug
  1486.   func_convert_core_file_wine_to_w32_result="$1"
  1487.   if test -n "$1"; then
  1488.     # Unfortunately, winepath does not exit with a non-zero error code, so we
  1489.     # are forced to check the contents of stdout. On the other hand, if the
  1490.     # command is not found, the shell will set an exit code of 127 and print
  1491.     # *an error message* to stdout. So we must check for both error code of
  1492.     # zero AND non-empty stdout, which explains the odd construction:
  1493.     func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
  1494.     if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
  1495.       func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
  1496.         $SED -e "$lt_sed_naive_backslashify"`
  1497.     else
  1498.       func_convert_core_file_wine_to_w32_result=
  1499.     fi
  1500.   fi
  1501. }
  1502. # end: func_convert_core_file_wine_to_w32
  1503.  
  1504.  
  1505. # func_convert_core_path_wine_to_w32 ARG
  1506. # Helper function used by path conversion functions when $build is *nix, and
  1507. # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
  1508. # configured wine environment available, with the winepath program in $build's
  1509. # $PATH. Assumes ARG has no leading or trailing path separator characters.
  1510. #
  1511. # ARG is path to be converted from $build format to win32.
  1512. # Result is available in $func_convert_core_path_wine_to_w32_result.
  1513. # Unconvertible file (directory) names in ARG are skipped; if no directory names
  1514. # are convertible, then the result may be empty.
  1515. func_convert_core_path_wine_to_w32 ()
  1516. {
  1517.   $opt_debug
  1518.   # unfortunately, winepath doesn't convert paths, only file names
  1519.   func_convert_core_path_wine_to_w32_result=""
  1520.   if test -n "$1"; then
  1521.     oldIFS=$IFS
  1522.     IFS=:
  1523.     for func_convert_core_path_wine_to_w32_f in $1; do
  1524.       IFS=$oldIFS
  1525.       func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
  1526.       if test -n "$func_convert_core_file_wine_to_w32_result" ; then
  1527.         if test -z "$func_convert_core_path_wine_to_w32_result"; then
  1528.           func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
  1529.         else
  1530.           func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
  1531.         fi
  1532.       fi
  1533.     done
  1534.     IFS=$oldIFS
  1535.   fi
  1536. }
  1537. # end: func_convert_core_path_wine_to_w32
  1538.  
  1539.  
  1540. # func_cygpath ARGS...
  1541. # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
  1542. # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
  1543. # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
  1544. # (2), returns the Cygwin file name or path in func_cygpath_result (input
  1545. # file name or path is assumed to be in w32 format, as previously converted
  1546. # from $build's *nix or MSYS format). In case (3), returns the w32 file name
  1547. # or path in func_cygpath_result (input file name or path is assumed to be in
  1548. # Cygwin format). Returns an empty string on error.
  1549. #
  1550. # ARGS are passed to cygpath, with the last one being the file name or path to
  1551. # be converted.
  1552. #
  1553. # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
  1554. # environment variable; do not put it in $PATH.
  1555. func_cygpath ()
  1556. {
  1557.   $opt_debug
  1558.   if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
  1559.     func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
  1560.     if test "$?" -ne 0; then
  1561.       # on failure, ensure result is empty
  1562.       func_cygpath_result=
  1563.     fi
  1564.   else
  1565.     func_cygpath_result=
  1566.     func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
  1567.  fi
  1568. }
  1569. #end: func_cygpath
  1570.  
  1571.  
  1572. # func_convert_core_msys_to_w32 ARG
  1573. # Convert file name or path ARG from MSYS format to w32 format.  Return
  1574. # result in func_convert_core_msys_to_w32_result.
  1575. func_convert_core_msys_to_w32 ()
  1576. {
  1577.  $opt_debug
  1578.  # awkward: cmd appends spaces to result
  1579.  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
  1580.    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
  1581. }
  1582. #end: func_convert_core_msys_to_w32
  1583.  
  1584.  
  1585. # func_convert_file_check ARG1 ARG2
  1586. # Verify that ARG1 (a file name in $build format) was converted to $host
  1587. # format in ARG2. Otherwise, emit an error message, but continue (resetting
  1588. # func_to_host_file_result to ARG1).
  1589. func_convert_file_check ()
  1590. {
  1591.  $opt_debug
  1592.  if test -z "$2" && test -n "$1" ; then
  1593.    func_error "Could not determine host file name corresponding to"
  1594.    func_error "  \`$1'"
  1595.     func_error "Continuing, but uninstalled executables may not work."
  1596.     # Fallback:
  1597.     func_to_host_file_result="$1"
  1598.   fi
  1599. }
  1600. # end func_convert_file_check
  1601.  
  1602.  
  1603. # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
  1604. # Verify that FROM_PATH (a path in $build format) was converted to $host
  1605. # format in TO_PATH. Otherwise, emit an error message, but continue, resetting
  1606. # func_to_host_file_result to a simplistic fallback value (see below).
  1607. func_convert_path_check ()
  1608. {
  1609.   $opt_debug
  1610.   if test -z "$4" && test -n "$3"; then
  1611.     func_error "Could not determine the host path corresponding to"
  1612.     func_error "  \`$3'"
  1613.    func_error "Continuing, but uninstalled executables may not work."
  1614.    # Fallback.  This is a deliberately simplistic "conversion" and
  1615.    # should not be "improved".  See libtool.info.
  1616.    if test "x$1" != "x$2"; then
  1617.      lt_replace_pathsep_chars="s|$1|$2|g"
  1618.      func_to_host_path_result=`echo "$3" |
  1619.        $SED -e "$lt_replace_pathsep_chars"`
  1620.    else
  1621.      func_to_host_path_result="$3"
  1622.    fi
  1623.  fi
  1624. }
  1625. # end func_convert_path_check
  1626.  
  1627.  
  1628. # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
  1629. # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
  1630. # and appending REPL if ORIG matches BACKPAT.
  1631. func_convert_path_front_back_pathsep ()
  1632. {
  1633.  $opt_debug
  1634.  case $4 in
  1635.  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
  1636.    ;;
  1637.  esac
  1638.  case $4 in
  1639.  $2 ) func_append func_to_host_path_result "$3"
  1640.    ;;
  1641.  esac
  1642. }
  1643. # end func_convert_path_front_back_pathsep
  1644.  
  1645.  
  1646. ##################################################
  1647. # $build to $host FILE NAME CONVERSION FUNCTIONS #
  1648. ##################################################
  1649. # invoked via `$to_host_file_cmd ARG'
  1650. #
  1651. # In each case, ARG is the path to be converted from $build to $host format.
  1652. # Result will be available in $func_to_host_file_result.
  1653.  
  1654.  
  1655. # func_to_host_file ARG
  1656. # Converts the file name ARG from $build format to $host format. Return result
  1657. # in func_to_host_file_result.
  1658. func_to_host_file ()
  1659. {
  1660.  $opt_debug
  1661.  $to_host_file_cmd "$1"
  1662. }
  1663. # end func_to_host_file
  1664.  
  1665.  
  1666. # func_to_tool_file ARG LAZY
  1667. # converts the file name ARG from $build format to toolchain format. Return
  1668. # result in func_to_tool_file_result.  If the conversion in use is listed
  1669. # in (the comma separated) LAZY, no conversion takes place.
  1670. func_to_tool_file ()
  1671. {
  1672.  $opt_debug
  1673.  case ,$2, in
  1674.    *,"$to_tool_file_cmd",*)
  1675.      func_to_tool_file_result=$1
  1676.      ;;
  1677.    *)
  1678.      $to_tool_file_cmd "$1"
  1679.      func_to_tool_file_result=$func_to_host_file_result
  1680.      ;;
  1681.  esac
  1682. }
  1683. # end func_to_tool_file
  1684.  
  1685.  
  1686. # func_convert_file_noop ARG
  1687. # Copy ARG to func_to_host_file_result.
  1688. func_convert_file_noop ()
  1689. {
  1690.  func_to_host_file_result="$1"
  1691. }
  1692. # end func_convert_file_noop
  1693.  
  1694.  
  1695. # func_convert_file_msys_to_w32 ARG
  1696. # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
  1697. # conversion to w32 is not available inside the cwrapper.  Returns result in
  1698. # func_to_host_file_result.
  1699. func_convert_file_msys_to_w32 ()
  1700. {
  1701.  $opt_debug
  1702.  func_to_host_file_result="$1"
  1703.  if test -n "$1"; then
  1704.    func_convert_core_msys_to_w32 "$1"
  1705.    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
  1706.  fi
  1707.  func_convert_file_check "$1" "$func_to_host_file_result"
  1708. }
  1709. # end func_convert_file_msys_to_w32
  1710.  
  1711.  
  1712. # func_convert_file_cygwin_to_w32 ARG
  1713. # Convert file name ARG from Cygwin to w32 format.  Returns result in
  1714. # func_to_host_file_result.
  1715. func_convert_file_cygwin_to_w32 ()
  1716. {
  1717.  $opt_debug
  1718.  func_to_host_file_result="$1"
  1719.  if test -n "$1"; then
  1720.    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
  1721.    # LT_CYGPATH in this case.
  1722.    func_to_host_file_result=`cygpath -m "$1"`
  1723.  fi
  1724.  func_convert_file_check "$1" "$func_to_host_file_result"
  1725. }
  1726. # end func_convert_file_cygwin_to_w32
  1727.  
  1728.  
  1729. # func_convert_file_nix_to_w32 ARG
  1730. # Convert file name ARG from *nix to w32 format.  Requires a wine environment
  1731. # and a working winepath. Returns result in func_to_host_file_result.
  1732. func_convert_file_nix_to_w32 ()
  1733. {
  1734.  $opt_debug
  1735.  func_to_host_file_result="$1"
  1736.  if test -n "$1"; then
  1737.    func_convert_core_file_wine_to_w32 "$1"
  1738.    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
  1739.  fi
  1740.  func_convert_file_check "$1" "$func_to_host_file_result"
  1741. }
  1742. # end func_convert_file_nix_to_w32
  1743.  
  1744.  
  1745. # func_convert_file_msys_to_cygwin ARG
  1746. # Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
  1747. # Returns result in func_to_host_file_result.
  1748. func_convert_file_msys_to_cygwin ()
  1749. {
  1750.  $opt_debug
  1751.  func_to_host_file_result="$1"
  1752.  if test -n "$1"; then
  1753.    func_convert_core_msys_to_w32 "$1"
  1754.    func_cygpath -u "$func_convert_core_msys_to_w32_result"
  1755.    func_to_host_file_result="$func_cygpath_result"
  1756.  fi
  1757.  func_convert_file_check "$1" "$func_to_host_file_result"
  1758. }
  1759. # end func_convert_file_msys_to_cygwin
  1760.  
  1761.  
  1762. # func_convert_file_nix_to_cygwin ARG
  1763. # Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
  1764. # in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
  1765. # in func_to_host_file_result.
  1766. func_convert_file_nix_to_cygwin ()
  1767. {
  1768.  $opt_debug
  1769.  func_to_host_file_result="$1"
  1770.  if test -n "$1"; then
  1771.    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
  1772.    func_convert_core_file_wine_to_w32 "$1"
  1773.    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
  1774.    func_to_host_file_result="$func_cygpath_result"
  1775.  fi
  1776.  func_convert_file_check "$1" "$func_to_host_file_result"
  1777. }
  1778. # end func_convert_file_nix_to_cygwin
  1779.  
  1780.  
  1781. #############################################
  1782. # $build to $host PATH CONVERSION FUNCTIONS #
  1783. #############################################
  1784. # invoked via `$to_host_path_cmd ARG'
  1785. #
  1786. # In each case, ARG is the path to be converted from $build to $host format.
  1787. # The result will be available in $func_to_host_path_result.
  1788. #
  1789. # Path separators are also converted from $build format to $host format.  If
  1790. # ARG begins or ends with a path separator character, it is preserved (but
  1791. # converted to $host format) on output.
  1792. #
  1793. # All path conversion functions are named using the following convention:
  1794. #   file name conversion function    : func_convert_file_X_to_Y ()
  1795. #   path conversion function         : func_convert_path_X_to_Y ()
  1796. # where, for any given $build/$host combination the 'X_to_Y' value is the
  1797. # same.  If conversion functions are added for new $build/$host combinations,
  1798. # the two new functions must follow this pattern, or func_init_to_host_path_cmd
  1799. # will break.
  1800.  
  1801.  
  1802. # func_init_to_host_path_cmd
  1803. # Ensures that function "pointer" variable $to_host_path_cmd is set to the
  1804. # appropriate value, based on the value of $to_host_file_cmd.
  1805. to_host_path_cmd=
  1806. func_init_to_host_path_cmd ()
  1807. {
  1808.  $opt_debug
  1809.  if test -z "$to_host_path_cmd"; then
  1810.    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
  1811.    to_host_path_cmd="func_convert_path_${func_stripname_result}"
  1812.  fi
  1813. }
  1814.  
  1815.  
  1816. # func_to_host_path ARG
  1817. # Converts the path ARG from $build format to $host format. Return result
  1818. # in func_to_host_path_result.
  1819. func_to_host_path ()
  1820. {
  1821.  $opt_debug
  1822.  func_init_to_host_path_cmd
  1823.  $to_host_path_cmd "$1"
  1824. }
  1825. # end func_to_host_path
  1826.  
  1827.  
  1828. # func_convert_path_noop ARG
  1829. # Copy ARG to func_to_host_path_result.
  1830. func_convert_path_noop ()
  1831. {
  1832.  func_to_host_path_result="$1"
  1833. }
  1834. # end func_convert_path_noop
  1835.  
  1836.  
  1837. # func_convert_path_msys_to_w32 ARG
  1838. # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
  1839. # conversion to w32 is not available inside the cwrapper.  Returns result in
  1840. # func_to_host_path_result.
  1841. func_convert_path_msys_to_w32 ()
  1842. {
  1843.  $opt_debug
  1844.  func_to_host_path_result="$1"
  1845.  if test -n "$1"; then
  1846.    # Remove leading and trailing path separator characters from ARG.  MSYS
  1847.    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
  1848.    # and winepath ignores them completely.
  1849.    func_stripname : : "$1"
  1850.    func_to_host_path_tmp1=$func_stripname_result
  1851.    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
  1852.    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
  1853.    func_convert_path_check : ";" \
  1854.      "$func_to_host_path_tmp1" "$func_to_host_path_result"
  1855.    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
  1856.  fi
  1857. }
  1858. # end func_convert_path_msys_to_w32
  1859.  
  1860.  
  1861. # func_convert_path_cygwin_to_w32 ARG
  1862. # Convert path ARG from Cygwin to w32 format.  Returns result in
  1863. # func_to_host_file_result.
  1864. func_convert_path_cygwin_to_w32 ()
  1865. {
  1866.  $opt_debug
  1867.  func_to_host_path_result="$1"
  1868.  if test -n "$1"; then
  1869.    # See func_convert_path_msys_to_w32:
  1870.    func_stripname : : "$1"
  1871.    func_to_host_path_tmp1=$func_stripname_result
  1872.    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
  1873.    func_convert_path_check : ";" \
  1874.      "$func_to_host_path_tmp1" "$func_to_host_path_result"
  1875.    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
  1876.  fi
  1877. }
  1878. # end func_convert_path_cygwin_to_w32
  1879.  
  1880.  
  1881. # func_convert_path_nix_to_w32 ARG
  1882. # Convert path ARG from *nix to w32 format.  Requires a wine environment and
  1883. # a working winepath.  Returns result in func_to_host_file_result.
  1884. func_convert_path_nix_to_w32 ()
  1885. {
  1886.  $opt_debug
  1887.  func_to_host_path_result="$1"
  1888.  if test -n "$1"; then
  1889.    # See func_convert_path_msys_to_w32:
  1890.    func_stripname : : "$1"
  1891.    func_to_host_path_tmp1=$func_stripname_result
  1892.    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
  1893.    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
  1894.    func_convert_path_check : ";" \
  1895.      "$func_to_host_path_tmp1" "$func_to_host_path_result"
  1896.    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
  1897.  fi
  1898. }
  1899. # end func_convert_path_nix_to_w32
  1900.  
  1901.  
  1902. # func_convert_path_msys_to_cygwin ARG
  1903. # Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
  1904. # Returns result in func_to_host_file_result.
  1905. func_convert_path_msys_to_cygwin ()
  1906. {
  1907.  $opt_debug
  1908.  func_to_host_path_result="$1"
  1909.  if test -n "$1"; then
  1910.    # See func_convert_path_msys_to_w32:
  1911.    func_stripname : : "$1"
  1912.    func_to_host_path_tmp1=$func_stripname_result
  1913.    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
  1914.    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
  1915.    func_to_host_path_result="$func_cygpath_result"
  1916.    func_convert_path_check : : \
  1917.      "$func_to_host_path_tmp1" "$func_to_host_path_result"
  1918.    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
  1919.  fi
  1920. }
  1921. # end func_convert_path_msys_to_cygwin
  1922.  
  1923.  
  1924. # func_convert_path_nix_to_cygwin ARG
  1925. # Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
  1926. # a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
  1927. # func_to_host_file_result.
  1928. func_convert_path_nix_to_cygwin ()
  1929. {
  1930.  $opt_debug
  1931.  func_to_host_path_result="$1"
  1932.  if test -n "$1"; then
  1933.    # Remove leading and trailing path separator characters from
  1934.    # ARG. msys behavior is inconsistent here, cygpath turns them
  1935.    # into '.;' and ';.', and winepath ignores them completely.
  1936.    func_stripname : : "$1"
  1937.    func_to_host_path_tmp1=$func_stripname_result
  1938.    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
  1939.    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
  1940.    func_to_host_path_result="$func_cygpath_result"
  1941.    func_convert_path_check : : \
  1942.      "$func_to_host_path_tmp1" "$func_to_host_path_result"
  1943.    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
  1944.  fi
  1945. }
  1946. # end func_convert_path_nix_to_cygwin
  1947.  
  1948.  
  1949. # func_mode_compile arg...
  1950. func_mode_compile ()
  1951. {
  1952.    $opt_debug
  1953.    # Get the compilation command and the source file.
  1954.    base_compile=
  1955.    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
  1956.    suppress_opt=yes
  1957.    suppress_output=
  1958.    arg_mode=normal
  1959.    libobj=
  1960.    later=
  1961.    pie_flag=
  1962.  
  1963.    for arg
  1964.    do
  1965.      case $arg_mode in
  1966.      arg  )
  1967.         # do not "continue".  Instead, add this to base_compile
  1968.         lastarg="$arg"
  1969.         arg_mode=normal
  1970.         ;;
  1971.  
  1972.      target )
  1973.         libobj="$arg"
  1974.         arg_mode=normal
  1975.         continue
  1976.         ;;
  1977.  
  1978.      normal )
  1979.         # Accept any command-line options.
  1980.         case $arg in
  1981.         -o)
  1982.           test -n "$libobj" && \
  1983.             func_fatal_error "you cannot specify \`-o' more than once"
  1984.           arg_mode=target
  1985.           continue
  1986.           ;;
  1987.  
  1988.         -pie | -fpie | -fPIE)
  1989.           func_append pie_flag " $arg"
  1990.           continue
  1991.           ;;
  1992.  
  1993.         -shared | -static | -prefer-pic | -prefer-non-pic)
  1994.           func_append later " $arg"
  1995.           continue
  1996.           ;;
  1997.  
  1998.         -no-suppress)
  1999.           suppress_opt=no
  2000.           continue
  2001.           ;;
  2002.  
  2003.         -Xcompiler)
  2004.           arg_mode=arg  #  the next one goes into the "base_compile" arg list
  2005.           continue      #  The current "srcfile" will either be retained or
  2006.           ;;            #  replaced later.  I would guess that would be a bug.
  2007.  
  2008.         -Wc,*)
  2009.           func_stripname '-Wc,' '' "$arg"
  2010.           args=$func_stripname_result
  2011.           lastarg=
  2012.           save_ifs="$IFS"; IFS=','
  2013.           for arg in $args; do
  2014.             IFS="$save_ifs"
  2015.             func_append_quoted lastarg "$arg"
  2016.           done
  2017.           IFS="$save_ifs"
  2018.           func_stripname ' ' '' "$lastarg"
  2019.           lastarg=$func_stripname_result
  2020.  
  2021.           # Add the arguments to base_compile.
  2022.           func_append base_compile " $lastarg"
  2023.           continue
  2024.           ;;
  2025.  
  2026.         *)
  2027.           # Accept the current argument as the source file.
  2028.           # The previous "srcfile" becomes the current argument.
  2029.           #
  2030.           lastarg="$srcfile"
  2031.           srcfile="$arg"
  2032.           ;;
  2033.         esac  #  case $arg
  2034.         ;;
  2035.       esac    #  case $arg_mode
  2036.  
  2037.       # Aesthetically quote the previous argument.
  2038.       func_append_quoted base_compile "$lastarg"
  2039.     done # for arg
  2040.  
  2041.     case $arg_mode in
  2042.     arg)
  2043.       func_fatal_error "you must specify an argument for -Xcompile"
  2044.       ;;
  2045.     target)
  2046.       func_fatal_error "you must specify a target with \`-o'"
  2047.      ;;
  2048.    *)
  2049.      # Get the name of the library object.
  2050.      test -z "$libobj" && {
  2051.         func_basename "$srcfile"
  2052.         libobj="$func_basename_result"
  2053.      }
  2054.      ;;
  2055.    esac
  2056.  
  2057.    # Recognize several different file suffixes.
  2058.    # If the user specifies -o file.o, it is replaced with file.lo
  2059.    case $libobj in
  2060.    *.[cCFSifmso] | \
  2061.    *.ada | *.adb | *.ads | *.asm | \
  2062.    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
  2063.    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
  2064.      func_xform "$libobj"
  2065.      libobj=$func_xform_result
  2066.      ;;
  2067.    esac
  2068.  
  2069.    case $libobj in
  2070.    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
  2071.    *)
  2072.      func_fatal_error "cannot determine name of library object from \`$libobj'"
  2073.       ;;
  2074.     esac
  2075.  
  2076.     func_infer_tag $base_compile
  2077.  
  2078.     for arg in $later; do
  2079.       case $arg in
  2080.       -shared)
  2081.         test "$build_libtool_libs" != yes && \
  2082.           func_fatal_configuration "can not build a shared library"
  2083.         build_old_libs=no
  2084.         continue
  2085.         ;;
  2086.  
  2087.       -static)
  2088.         build_libtool_libs=no
  2089.         build_old_libs=yes
  2090.         continue
  2091.         ;;
  2092.  
  2093.       -prefer-pic)
  2094.         pic_mode=yes
  2095.         continue
  2096.         ;;
  2097.  
  2098.       -prefer-non-pic)
  2099.         pic_mode=no
  2100.         continue
  2101.         ;;
  2102.       esac
  2103.     done
  2104.  
  2105.     func_quote_for_eval "$libobj"
  2106.     test "X$libobj" != "X$func_quote_for_eval_result" \
  2107.       && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'    &()|`$[]' \
  2108.       && func_warning "libobj name \`$libobj' may not contain shell special characters."
  2109.    func_dirname_and_basename "$obj" "/" ""
  2110.    objname="$func_basename_result"
  2111.    xdir="$func_dirname_result"
  2112.    lobj=${xdir}$objdir/$objname
  2113.  
  2114.    test -z "$base_compile" && \
  2115.      func_fatal_help "you must specify a compilation command"
  2116.  
  2117.    # Delete any leftover library objects.
  2118.    if test "$build_old_libs" = yes; then
  2119.      removelist="$obj $lobj $libobj ${libobj}T"
  2120.    else
  2121.      removelist="$lobj $libobj ${libobj}T"
  2122.    fi
  2123.  
  2124.    # On Cygwin there's no "real" PIC flag so we must build both object types
  2125.    case $host_os in
  2126.    cygwin* | mingw* | pw32* | os2* | cegcc*)
  2127.      pic_mode=default
  2128.      ;;
  2129.    esac
  2130.    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
  2131.      # non-PIC code in shared libraries is not supported
  2132.      pic_mode=default
  2133.    fi
  2134.  
  2135.    # Calculate the filename of the output object if compiler does
  2136.    # not support -o with -c
  2137.    if test "$compiler_c_o" = no; then
  2138.      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
  2139.      lockfile="$output_obj.lock"
  2140.    else
  2141.      output_obj=
  2142.      need_locks=no
  2143.      lockfile=
  2144.    fi
  2145.  
  2146.    # Lock this critical section if it is needed
  2147.    # We use this script file to make the link, it avoids creating a new file
  2148.    if test "$need_locks" = yes; then
  2149.      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
  2150.         func_echo "Waiting for $lockfile to be removed"
  2151.         sleep 2
  2152.      done
  2153.    elif test "$need_locks" = warn; then
  2154.      if test -f "$lockfile"; then
  2155.         $ECHO "\
  2156. *** ERROR, $lockfile exists and contains:
  2157. `cat $lockfile 2>/dev/null`
  2158.  
  2159. This indicates that another process is trying to use the same
  2160. temporary object file, and libtool could not work around it because
  2161. your compiler does not support \`-c' and \`-o' together.  If you
  2162. repeat this compilation, it may succeed, by chance, but you had better
  2163. avoid parallel builds (make -j) in this platform, or get a better
  2164. compiler."
  2165.  
  2166.         $opt_dry_run || $RM $removelist
  2167.         exit $EXIT_FAILURE
  2168.      fi
  2169.      func_append removelist " $output_obj"
  2170.      $ECHO "$srcfile" > "$lockfile"
  2171.    fi
  2172.  
  2173.    $opt_dry_run || $RM $removelist
  2174.    func_append removelist " $lockfile"
  2175.    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
  2176.  
  2177.    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
  2178.    srcfile=$func_to_tool_file_result
  2179.    func_quote_for_eval "$srcfile"
  2180.    qsrcfile=$func_quote_for_eval_result
  2181.  
  2182.    # Only build a PIC object if we are building libtool libraries.
  2183.    if test "$build_libtool_libs" = yes; then
  2184.      # Without this assignment, base_compile gets emptied.
  2185.      fbsd_hideous_sh_bug=$base_compile
  2186.  
  2187.      if test "$pic_mode" != no; then
  2188.         command="$base_compile $qsrcfile $pic_flag"
  2189.      else
  2190.         # Don't build PIC code
  2191.         command="$base_compile $qsrcfile"
  2192.      fi
  2193.  
  2194.      func_mkdir_p "$xdir$objdir"
  2195.  
  2196.      if test -z "$output_obj"; then
  2197.         # Place PIC objects in $objdir
  2198.         func_append command " -o $lobj"
  2199.      fi
  2200.  
  2201.       func_show_eval_locale "$command"  \
  2202.          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
  2203.  
  2204.      if test "$need_locks" = warn &&
  2205.          test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
  2206.         $ECHO "\
  2207. *** ERROR, $lockfile contains:
  2208. `cat $lockfile 2>/dev/null`
  2209.  
  2210. but it should contain:
  2211. $srcfile
  2212.  
  2213. This indicates that another process is trying to use the same
  2214. temporary object file, and libtool could not work around it because
  2215. your compiler does not support \`-c' and \`-o' together.  If you
  2216. repeat this compilation, it may succeed, by chance, but you had better
  2217. avoid parallel builds (make -j) in this platform, or get a better
  2218. compiler."
  2219.  
  2220.         $opt_dry_run || $RM $removelist
  2221.         exit $EXIT_FAILURE
  2222.      fi
  2223.  
  2224.      # Just move the object if needed, then go on to compile the next one
  2225.      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
  2226.         func_show_eval '$MV "$output_obj" "$lobj"' \
  2227.           'error=$?; $opt_dry_run || $RM $removelist; exit $error'
  2228.      fi
  2229.  
  2230.      # Allow error messages only from the first compilation.
  2231.      if test "$suppress_opt" = yes; then
  2232.         suppress_output=' >/dev/null 2>&1'
  2233.      fi
  2234.    fi
  2235.  
  2236.    # Only build a position-dependent object if we build old libraries.
  2237.    if test "$build_old_libs" = yes; then
  2238.      if test "$pic_mode" != yes; then
  2239.         # Don't build PIC code
  2240.         command="$base_compile $qsrcfile$pie_flag"
  2241.      else
  2242.         command="$base_compile $qsrcfile $pic_flag"
  2243.      fi
  2244.      if test "$compiler_c_o" = yes; then
  2245.         func_append command " -o $obj"
  2246.      fi
  2247.  
  2248.      # Suppress compiler output if we already did a PIC compilation.
  2249.      func_append command "$suppress_output"
  2250.      func_show_eval_locale "$command" \
  2251.        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
  2252.  
  2253.      if test "$need_locks" = warn &&
  2254.          test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
  2255.         $ECHO "\
  2256. *** ERROR, $lockfile contains:
  2257. `cat $lockfile 2>/dev/null`
  2258.  
  2259. but it should contain:
  2260. $srcfile
  2261.  
  2262. This indicates that another process is trying to use the same
  2263. temporary object file, and libtool could not work around it because
  2264. your compiler does not support \`-c' and \`-o' together.  If you
  2265. repeat this compilation, it may succeed, by chance, but you had better
  2266. avoid parallel builds (make -j) in this platform, or get a better
  2267. compiler."
  2268.  
  2269.         $opt_dry_run || $RM $removelist
  2270.         exit $EXIT_FAILURE
  2271.      fi
  2272.  
  2273.      # Just move the object if needed
  2274.      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
  2275.         func_show_eval '$MV "$output_obj" "$obj"' \
  2276.           'error=$?; $opt_dry_run || $RM $removelist; exit $error'
  2277.      fi
  2278.    fi
  2279.  
  2280.    $opt_dry_run || {
  2281.      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
  2282.  
  2283.      # Unlock the critical section if it was locked
  2284.      if test "$need_locks" != no; then
  2285.         removelist=$lockfile
  2286.        $RM "$lockfile"
  2287.      fi
  2288.    }
  2289.  
  2290.    exit $EXIT_SUCCESS
  2291. }
  2292.  
  2293. $opt_help || {
  2294.  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
  2295. }
  2296.  
  2297. func_mode_help ()
  2298. {
  2299.    # We need to display help for each of the modes.
  2300.    case $opt_mode in
  2301.      "")
  2302.        # Generic help is extracted from the usage comments
  2303.        # at the start of this file.
  2304.        func_help
  2305.        ;;
  2306.  
  2307.      clean)
  2308.        $ECHO \
  2309. "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
  2310.  
  2311. Remove files from the build directory.
  2312.  
  2313. RM is the name of the program to use to delete files associated with each FILE
  2314. (typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
  2315. to RM.
  2316.  
  2317. If FILE is a libtool library, object or program, all the files associated
  2318. with it are deleted. Otherwise, only FILE itself is deleted using RM."
  2319.        ;;
  2320.  
  2321.      compile)
  2322.      $ECHO \
  2323. "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
  2324.  
  2325. Compile a source file into a libtool library object.
  2326.  
  2327. This mode accepts the following additional options:
  2328.  
  2329.  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
  2330.  -no-suppress      do not suppress compiler output for multiple passes
  2331.  -prefer-pic       try to build PIC objects only
  2332.  -prefer-non-pic   try to build non-PIC objects only
  2333.  -shared           do not build a \`.o' file suitable for static linking
  2334.  -static           only build a \`.o' file suitable for static linking
  2335.  -Wc,FLAG          pass FLAG directly to the compiler
  2336.  
  2337. COMPILE-COMMAND is a command to be used in creating a \`standard' object file
  2338. from the given SOURCEFILE.
  2339.  
  2340. The output file name is determined by removing the directory component from
  2341. SOURCEFILE, then substituting the C source code suffix \`.c' with the
  2342. library object suffix, \`.lo'."
  2343.         ;;
  2344.  
  2345.       execute)
  2346.         $ECHO \
  2347. "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
  2348.  
  2349. Automatically set library path, then run a program.
  2350.  
  2351. This mode accepts the following additional options:
  2352.  
  2353.  -dlopen FILE      add the directory containing FILE to the library path
  2354.  
  2355. This mode sets the library path environment variable according to \`-dlopen'
  2356. flags.
  2357.  
  2358. If any of the ARGS are libtool executable wrappers, then they are translated
  2359. into their corresponding uninstalled binary, and any of their required library
  2360. directories are added to the library path.
  2361.  
  2362. Then, COMMAND is executed, with ARGS as arguments."
  2363.        ;;
  2364.  
  2365.      finish)
  2366.        $ECHO \
  2367. "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
  2368.  
  2369. Complete the installation of libtool libraries.
  2370.  
  2371. Each LIBDIR is a directory that contains libtool libraries.
  2372.  
  2373. The commands that this mode executes may require superuser privileges.  Use
  2374. the \`--dry-run' option if you just want to see what would be executed."
  2375.         ;;
  2376.  
  2377.       install)
  2378.         $ECHO \
  2379. "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
  2380.  
  2381. Install executables or libraries.
  2382.  
  2383. INSTALL-COMMAND is the installation command.  The first component should be
  2384. either the \`install' or \`cp' program.
  2385.  
  2386. The following components of INSTALL-COMMAND are treated specially:
  2387.  
  2388.  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
  2389.  
  2390. The rest of the components are interpreted as arguments to that command (only
  2391. BSD-compatible install options are recognized)."
  2392.         ;;
  2393.  
  2394.       link)
  2395.         $ECHO \
  2396. "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
  2397.  
  2398. Link object files or libraries together to form another library, or to
  2399. create an executable program.
  2400.  
  2401. LINK-COMMAND is a command using the C compiler that you would use to create
  2402. a program from several object files.
  2403.  
  2404. The following components of LINK-COMMAND are treated specially:
  2405.  
  2406.  -all-static       do not do any dynamic linking at all
  2407.  -avoid-version    do not add a version suffix if possible
  2408.  -bindir BINDIR    specify path to binaries directory (for systems where
  2409.                    libraries must be found in the PATH setting at runtime)
  2410.  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
  2411.  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
  2412.  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
  2413.  -export-symbols SYMFILE
  2414.                    try to export only the symbols listed in SYMFILE
  2415.  -export-symbols-regex REGEX
  2416.                    try to export only the symbols matching REGEX
  2417.  -LLIBDIR          search LIBDIR for required installed libraries
  2418.  -lNAME            OUTPUT-FILE requires the installed library libNAME
  2419.  -module           build a library that can dlopened
  2420.  -no-fast-install  disable the fast-install mode
  2421.  -no-install       link a not-installable executable
  2422.  -no-undefined     declare that a library does not refer to external symbols
  2423.  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
  2424.  -objectlist FILE  Use a list of object files found in FILE to specify objects
  2425.  -precious-files-regex REGEX
  2426.                    don't remove output files matching REGEX
  2427.  -release RELEASE  specify package release information
  2428.  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
  2429.  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
  2430.  -shared           only do dynamic linking of libtool libraries
  2431.  -shrext SUFFIX    override the standard shared library file extension
  2432.  -static           do not do any dynamic linking of uninstalled libtool libraries
  2433.  -static-libtool-libs
  2434.                    do not do any dynamic linking of libtool libraries
  2435.  -version-info CURRENT[:REVISION[:AGE]]
  2436.                    specify library version info [each variable defaults to 0]
  2437.  -weak LIBNAME     declare that the target provides the LIBNAME interface
  2438.  -Wc,FLAG
  2439.  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
  2440.  -Wl,FLAG
  2441.  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
  2442.  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
  2443.  
  2444. All other options (arguments beginning with \`-') are ignored.
  2445.  
  2446. Every other argument is treated as a filename.  Files ending in \`.la' are
  2447. treated as uninstalled libtool libraries, other files are standard or library
  2448. object files.
  2449.  
  2450. If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
  2451. only library objects (\`.lo' files) may be specified, and \`-rpath' is
  2452. required, except when creating a convenience library.
  2453.  
  2454. If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
  2455. using \`ar' and \`ranlib', or on Windows using \`lib'.
  2456.  
  2457. If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
  2458. is created, otherwise an executable program is created."
  2459.        ;;
  2460.  
  2461.      uninstall)
  2462.        $ECHO \
  2463. "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
  2464.  
  2465. Remove libraries from an installation directory.
  2466.  
  2467. RM is the name of the program to use to delete files associated with each FILE
  2468. (typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
  2469. to RM.
  2470.  
  2471. If FILE is a libtool library, all the files associated with it are deleted.
  2472. Otherwise, only FILE itself is deleted using RM."
  2473.        ;;
  2474.  
  2475.      *)
  2476.        func_fatal_help "invalid operation mode \`$opt_mode'"
  2477.         ;;
  2478.     esac
  2479.  
  2480.     echo
  2481.     $ECHO "Try \`$progname --help' for more information about other modes."
  2482. }
  2483.  
  2484. # Now that we've collected a possible --mode arg, show help if necessary
  2485. if $opt_help; then
  2486.  if test "$opt_help" = :; then
  2487.    func_mode_help
  2488.  else
  2489.    {
  2490.      func_help noexit
  2491.      for opt_mode in compile link execute install finish uninstall clean; do
  2492.         func_mode_help
  2493.      done
  2494.    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
  2495.    {
  2496.      func_help noexit
  2497.      for opt_mode in compile link execute install finish uninstall clean; do
  2498.         echo
  2499.         func_mode_help
  2500.      done
  2501.    } |
  2502.    sed '1d
  2503.      /^When reporting/,/^Report/{
  2504.         H
  2505.         d
  2506.      }
  2507.      $x
  2508.      /information about other modes/d
  2509.      /more detailed .*MODE/d
  2510.      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
  2511.  fi
  2512.  exit $?
  2513. fi
  2514.  
  2515.  
  2516. # func_mode_execute arg...
  2517. func_mode_execute ()
  2518. {
  2519.    $opt_debug
  2520.    # The first argument is the command name.
  2521.    cmd="$nonopt"
  2522.    test -z "$cmd" && \
  2523.      func_fatal_help "you must specify a COMMAND"
  2524.  
  2525.    # Handle -dlopen flags immediately.
  2526.    for file in $opt_dlopen; do
  2527.      test -f "$file" \
  2528.         || func_fatal_help "\`$file' is not a file"
  2529.  
  2530.       dir=
  2531.       case $file in
  2532.       *.la)
  2533.         func_resolve_sysroot "$file"
  2534.         file=$func_resolve_sysroot_result
  2535.  
  2536.         # Check to see that this really is a libtool archive.
  2537.         func_lalib_unsafe_p "$file" \
  2538.           || func_fatal_help "\`$lib' is not a valid libtool archive"
  2539.  
  2540.         # Read the libtool library.
  2541.         dlname=
  2542.         library_names=
  2543.         func_source "$file"
  2544.  
  2545.         # Skip this library if it cannot be dlopened.
  2546.         if test -z "$dlname"; then
  2547.           # Warn if it was a shared library.
  2548.           test -n "$library_names" && \
  2549.             func_warning "\`$file' was not linked with \`-export-dynamic'"
  2550.           continue
  2551.         fi
  2552.  
  2553.         func_dirname "$file" "" "."
  2554.         dir="$func_dirname_result"
  2555.  
  2556.         if test -f "$dir/$objdir/$dlname"; then
  2557.           func_append dir "/$objdir"
  2558.         else
  2559.           if test ! -f "$dir/$dlname"; then
  2560.             func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
  2561.           fi
  2562.         fi
  2563.         ;;
  2564.  
  2565.       *.lo)
  2566.         # Just add the directory containing the .lo file.
  2567.         func_dirname "$file" "" "."
  2568.         dir="$func_dirname_result"
  2569.         ;;
  2570.  
  2571.       *)
  2572.         func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
  2573.         continue
  2574.         ;;
  2575.      esac
  2576.  
  2577.      # Get the absolute pathname.
  2578.      absdir=`cd "$dir" && pwd`
  2579.      test -n "$absdir" && dir="$absdir"
  2580.  
  2581.      # Now add the directory to shlibpath_var.
  2582.      if eval "test -z \"\$$shlibpath_var\""; then
  2583.         eval "$shlibpath_var=\"\$dir\""
  2584.      else
  2585.         eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
  2586.      fi
  2587.    done
  2588.  
  2589.    # This variable tells wrapper scripts just to set shlibpath_var
  2590.    # rather than running their programs.
  2591.    libtool_execute_magic="$magic"
  2592.  
  2593.    # Check if any of the arguments is a wrapper script.
  2594.    args=
  2595.    for file
  2596.    do
  2597.      case $file in
  2598.      -* | *.la | *.lo ) ;;
  2599.      *)
  2600.         # Do a test to see if this is really a libtool program.
  2601.         if func_ltwrapper_script_p "$file"; then
  2602.           func_source "$file"
  2603.           # Transform arg to wrapped name.
  2604.           file="$progdir/$program"
  2605.         elif func_ltwrapper_executable_p "$file"; then
  2606.           func_ltwrapper_scriptname "$file"
  2607.           func_source "$func_ltwrapper_scriptname_result"
  2608.           # Transform arg to wrapped name.
  2609.           file="$progdir/$program"
  2610.         fi
  2611.         ;;
  2612.      esac
  2613.      # Quote arguments (to preserve shell metacharacters).
  2614.      func_append_quoted args "$file"
  2615.    done
  2616.  
  2617.    if test "X$opt_dry_run" = Xfalse; then
  2618.      if test -n "$shlibpath_var"; then
  2619.         # Export the shlibpath_var.
  2620.         eval "export $shlibpath_var"
  2621.      fi
  2622.  
  2623.      # Restore saved environment variables
  2624.      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
  2625.      do
  2626.         eval "if test \"\${save_$lt_var+set}\" = set; then
  2627.                $lt_var=\$save_$lt_var; export $lt_var
  2628.               else
  2629.                 $lt_unset $lt_var
  2630.               fi"
  2631.      done
  2632.  
  2633.      # Now prepare to actually exec the command.
  2634.      exec_cmd="\$cmd$args"
  2635.    else
  2636.      # Display what would be done.
  2637.      if test -n "$shlibpath_var"; then
  2638.         eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
  2639.         echo "export $shlibpath_var"
  2640.      fi
  2641.      $ECHO "$cmd$args"
  2642.      exit $EXIT_SUCCESS
  2643.    fi
  2644. }
  2645.  
  2646. test "$opt_mode" = execute && func_mode_execute ${1+"$@"}
  2647.  
  2648.  
  2649. # func_mode_finish arg...
  2650. func_mode_finish ()
  2651. {
  2652.    $opt_debug
  2653.    libs=
  2654.    libdirs=
  2655.    admincmds=
  2656.  
  2657.    for opt in "$nonopt" ${1+"$@"}
  2658.    do
  2659.      if test -d "$opt"; then
  2660.         func_append libdirs " $opt"
  2661.  
  2662.      elif test -f "$opt"; then
  2663.         if func_lalib_unsafe_p "$opt"; then
  2664.           func_append libs " $opt"
  2665.         else
  2666.           func_warning "\`$opt' is not a valid libtool archive"
  2667.         fi
  2668.  
  2669.       else
  2670.         func_fatal_error "invalid argument \`$opt'"
  2671.      fi
  2672.    done
  2673.  
  2674.    if test -n "$libs"; then
  2675.      if test -n "$lt_sysroot"; then
  2676.        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
  2677.        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
  2678.      else
  2679.        sysroot_cmd=
  2680.      fi
  2681.  
  2682.      # Remove sysroot references
  2683.      if $opt_dry_run; then
  2684.        for lib in $libs; do
  2685.          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
  2686.         done
  2687.       else
  2688.         tmpdir=`func_mktempdir`
  2689.         for lib in $libs; do
  2690.           sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
  2691.             > $tmpdir/tmp-la
  2692.           mv -f $tmpdir/tmp-la $lib
  2693.         done
  2694.         ${RM}r "$tmpdir"
  2695.       fi
  2696.     fi
  2697.  
  2698.     if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
  2699.       for libdir in $libdirs; do
  2700.         if test -n "$finish_cmds"; then
  2701.           # Do each command in the finish commands.
  2702.           func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
  2703. '"$cmd"'"'
  2704.         fi
  2705.         if test -n "$finish_eval"; then
  2706.           # Do the single finish_eval.
  2707.           eval cmds=\"$finish_eval\"
  2708.           $opt_dry_run || eval "$cmds" || func_append admincmds "
  2709.       $cmds"
  2710.         fi
  2711.       done
  2712.     fi
  2713.  
  2714.     # Exit here if they wanted silent mode.
  2715.     $opt_silent && exit $EXIT_SUCCESS
  2716.  
  2717.     if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
  2718.       echo "----------------------------------------------------------------------"
  2719.       echo "Libraries have been installed in:"
  2720.       for libdir in $libdirs; do
  2721.         $ECHO "   $libdir"
  2722.       done
  2723.       echo
  2724.       echo "If you ever happen to want to link against installed libraries"
  2725.       echo "in a given directory, LIBDIR, you must either use libtool, and"
  2726.       echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
  2727.      echo "flag during linking and do at least one of the following:"
  2728.      if test -n "$shlibpath_var"; then
  2729.         echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
  2730.         echo "     during execution"
  2731.       fi
  2732.       if test -n "$runpath_var"; then
  2733.         echo "   - add LIBDIR to the \`$runpath_var' environment variable"
  2734.         echo "     during linking"
  2735.      fi
  2736.      if test -n "$hardcode_libdir_flag_spec"; then
  2737.         libdir=LIBDIR
  2738.         eval flag=\"$hardcode_libdir_flag_spec\"
  2739.  
  2740.         $ECHO "   - use the \`$flag' linker flag"
  2741.       fi
  2742.       if test -n "$admincmds"; then
  2743.         $ECHO "   - have your system administrator run these commands:$admincmds"
  2744.       fi
  2745.       if test -f /etc/ld.so.conf; then
  2746.         echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
  2747.      fi
  2748.      echo
  2749.  
  2750.      echo "See any operating system documentation about shared libraries for"
  2751.      case $host in
  2752.         solaris2.[6789]|solaris2.1[0-9])
  2753.           echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
  2754.           echo "pages."
  2755.           ;;
  2756.         *)
  2757.           echo "more information, such as the ld(1) and ld.so(8) manual pages."
  2758.           ;;
  2759.      esac
  2760.      echo "----------------------------------------------------------------------"
  2761.    fi
  2762.    exit $EXIT_SUCCESS
  2763. }
  2764.  
  2765. test "$opt_mode" = finish && func_mode_finish ${1+"$@"}
  2766.  
  2767.  
  2768. # func_mode_install arg...
  2769. func_mode_install ()
  2770. {
  2771.    $opt_debug
  2772.    # There may be an optional sh(1) argument at the beginning of
  2773.    # install_prog (especially on Windows NT).
  2774.    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
  2775.       # Allow the use of GNU shtool's install command.
  2776.       case $nonopt in *shtool*) :;; *) false;; esac; then
  2777.      # Aesthetically quote it.
  2778.      func_quote_for_eval "$nonopt"
  2779.      install_prog="$func_quote_for_eval_result "
  2780.      arg=$1
  2781.      shift
  2782.    else
  2783.      install_prog=
  2784.      arg=$nonopt
  2785.    fi
  2786.  
  2787.    # The real first argument should be the name of the installation program.
  2788.    # Aesthetically quote it.
  2789.    func_quote_for_eval "$arg"
  2790.    func_append install_prog "$func_quote_for_eval_result"
  2791.    install_shared_prog=$install_prog
  2792.    case " $install_prog " in
  2793.      *[\\\ /]cp\ *) install_cp=: ;;
  2794.      *) install_cp=false ;;
  2795.    esac
  2796.  
  2797.    # We need to accept at least all the BSD install flags.
  2798.    dest=
  2799.    files=
  2800.    opts=
  2801.    prev=
  2802.    install_type=
  2803.    isdir=no
  2804.    stripme=
  2805.    no_mode=:
  2806.    for arg
  2807.    do
  2808.      arg2=
  2809.      if test -n "$dest"; then
  2810.         func_append files " $dest"
  2811.         dest=$arg
  2812.         continue
  2813.      fi
  2814.  
  2815.      case $arg in
  2816.      -d) isdir=yes ;;
  2817.      -f)
  2818.         if $install_cp; then :; else
  2819.           prev=$arg
  2820.         fi
  2821.         ;;
  2822.      -g | -m | -o)
  2823.         prev=$arg
  2824.         ;;
  2825.      -s)
  2826.         stripme=" -s"
  2827.         continue
  2828.         ;;
  2829.      -*)
  2830.         ;;
  2831.      *)
  2832.         # If the previous option needed an argument, then skip it.
  2833.         if test -n "$prev"; then
  2834.           if test "x$prev" = x-m && test -n "$install_override_mode"; then
  2835.             arg2=$install_override_mode
  2836.             no_mode=false
  2837.           fi
  2838.           prev=
  2839.         else
  2840.           dest=$arg
  2841.           continue
  2842.         fi
  2843.         ;;
  2844.      esac
  2845.  
  2846.      # Aesthetically quote the argument.
  2847.      func_quote_for_eval "$arg"
  2848.      func_append install_prog " $func_quote_for_eval_result"
  2849.      if test -n "$arg2"; then
  2850.         func_quote_for_eval "$arg2"
  2851.      fi
  2852.      func_append install_shared_prog " $func_quote_for_eval_result"
  2853.    done
  2854.  
  2855.    test -z "$install_prog" && \
  2856.      func_fatal_help "you must specify an install program"
  2857.  
  2858.    test -n "$prev" && \
  2859.      func_fatal_help "the \`$prev' option requires an argument"
  2860.  
  2861.     if test -n "$install_override_mode" && $no_mode; then
  2862.       if $install_cp; then :; else
  2863.         func_quote_for_eval "$install_override_mode"
  2864.         func_append install_shared_prog " -m $func_quote_for_eval_result"
  2865.       fi
  2866.     fi
  2867.  
  2868.     if test -z "$files"; then
  2869.       if test -z "$dest"; then
  2870.         func_fatal_help "no file or destination specified"
  2871.       else
  2872.         func_fatal_help "you must specify a destination"
  2873.       fi
  2874.     fi
  2875.  
  2876.     # Strip any trailing slash from the destination.
  2877.     func_stripname '' '/' "$dest"
  2878.     dest=$func_stripname_result
  2879.  
  2880.     # Check to see that the destination is a directory.
  2881.     test -d "$dest" && isdir=yes
  2882.     if test "$isdir" = yes; then
  2883.       destdir="$dest"
  2884.       destname=
  2885.     else
  2886.       func_dirname_and_basename "$dest" "" "."
  2887.       destdir="$func_dirname_result"
  2888.       destname="$func_basename_result"
  2889.  
  2890.       # Not a directory, so check to see that there is only one file specified.
  2891.       set dummy $files; shift
  2892.       test "$#" -gt 1 && \
  2893.         func_fatal_help "\`$dest' is not a directory"
  2894.    fi
  2895.    case $destdir in
  2896.    [\\/]* | [A-Za-z]:[\\/]*) ;;
  2897.    *)
  2898.      for file in $files; do
  2899.         case $file in
  2900.         *.lo) ;;
  2901.         *)
  2902.           func_fatal_help "\`$destdir' must be an absolute directory name"
  2903.           ;;
  2904.         esac
  2905.       done
  2906.       ;;
  2907.     esac
  2908.  
  2909.     # This variable tells wrapper scripts just to set variables rather
  2910.     # than running their programs.
  2911.     libtool_install_magic="$magic"
  2912.  
  2913.     staticlibs=
  2914.     future_libdirs=
  2915.     current_libdirs=
  2916.     for file in $files; do
  2917.  
  2918.       # Do each installation.
  2919.       case $file in
  2920.       *.$libext)
  2921.         # Do the static libraries later.
  2922.         func_append staticlibs " $file"
  2923.         ;;
  2924.  
  2925.       *.la)
  2926.         func_resolve_sysroot "$file"
  2927.         file=$func_resolve_sysroot_result
  2928.  
  2929.         # Check to see that this really is a libtool archive.
  2930.         func_lalib_unsafe_p "$file" \
  2931.           || func_fatal_help "\`$file' is not a valid libtool archive"
  2932.  
  2933.         library_names=
  2934.         old_library=
  2935.         relink_command=
  2936.         func_source "$file"
  2937.  
  2938.         # Add the libdir to current_libdirs if it is the destination.
  2939.         if test "X$destdir" = "X$libdir"; then
  2940.           case "$current_libdirs " in
  2941.           *" $libdir "*) ;;
  2942.           *) func_append current_libdirs " $libdir" ;;
  2943.           esac
  2944.         else
  2945.           # Note the libdir as a future libdir.
  2946.           case "$future_libdirs " in
  2947.           *" $libdir "*) ;;
  2948.           *) func_append future_libdirs " $libdir" ;;
  2949.           esac
  2950.         fi
  2951.  
  2952.         func_dirname "$file" "/" ""
  2953.         dir="$func_dirname_result"
  2954.         func_append dir "$objdir"
  2955.  
  2956.         if test -n "$relink_command"; then
  2957.           # Determine the prefix the user has applied to our future dir.
  2958.           inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
  2959.  
  2960.           # Don't allow the user to place us outside of our expected
  2961.           # location b/c this prevents finding dependent libraries that
  2962.           # are installed to the same prefix.
  2963.           # At present, this check doesn't affect windows .dll's that
  2964.           # are installed into $libdir/../bin (currently, that works fine)
  2965.           # but it's something to keep an eye on.
  2966.           test "$inst_prefix_dir" = "$destdir" && \
  2967.             func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
  2968.  
  2969.           if test -n "$inst_prefix_dir"; then
  2970.             # Stick the inst_prefix_dir data into the link command.
  2971.             relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
  2972.           else
  2973.             relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
  2974.           fi
  2975.  
  2976.           func_warning "relinking \`$file'"
  2977.           func_show_eval "$relink_command" \
  2978.             'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
  2979.         fi
  2980.  
  2981.         # See the names of the shared library.
  2982.         set dummy $library_names; shift
  2983.         if test -n "$1"; then
  2984.           realname="$1"
  2985.           shift
  2986.  
  2987.           srcname="$realname"
  2988.           test -n "$relink_command" && srcname="$realname"T
  2989.  
  2990.           # Install the shared library and build the symlinks.
  2991.           func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
  2992.               'exit $?'
  2993.           tstripme="$stripme"
  2994.           case $host_os in
  2995.           cygwin* | mingw* | pw32* | cegcc*)
  2996.             case $realname in
  2997.             *.dll.a)
  2998.               tstripme=""
  2999.               ;;
  3000.             esac
  3001.             ;;
  3002.           esac
  3003.           if test -n "$tstripme" && test -n "$striplib"; then
  3004.             func_show_eval "$striplib $destdir/$realname" 'exit $?'
  3005.           fi
  3006.  
  3007.           if test "$#" -gt 0; then
  3008.             # Delete the old symlinks, and create new ones.
  3009.             # Try `ln -sf' first, because the `ln' binary might depend on
  3010.             # the symlink we replace!  Solaris /bin/ln does not understand -f,
  3011.             # so we also need to try rm && ln -s.
  3012.             for linkname
  3013.             do
  3014.               test "$linkname" != "$realname" \
  3015.                 && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
  3016.             done
  3017.           fi
  3018.  
  3019.           # Do each command in the postinstall commands.
  3020.           lib="$destdir/$realname"
  3021.           func_execute_cmds "$postinstall_cmds" 'exit $?'
  3022.         fi
  3023.  
  3024.         # Install the pseudo-library for information purposes.
  3025.         func_basename "$file"
  3026.         name="$func_basename_result"
  3027.         instname="$dir/$name"i
  3028.         func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
  3029.  
  3030.         # Maybe install the static library, too.
  3031.         test -n "$old_library" && func_append staticlibs " $dir/$old_library"
  3032.         ;;
  3033.  
  3034.      *.lo)
  3035.         # Install (i.e. copy) a libtool object.
  3036.  
  3037.         # Figure out destination file name, if it wasn't already specified.
  3038.         if test -n "$destname"; then
  3039.           destfile="$destdir/$destname"
  3040.         else
  3041.           func_basename "$file"
  3042.           destfile="$func_basename_result"
  3043.           destfile="$destdir/$destfile"
  3044.         fi
  3045.  
  3046.         # Deduce the name of the destination old-style object file.
  3047.         case $destfile in
  3048.         *.lo)
  3049.           func_lo2o "$destfile"
  3050.           staticdest=$func_lo2o_result
  3051.           ;;
  3052.         *.$objext)
  3053.           staticdest="$destfile"
  3054.           destfile=
  3055.           ;;
  3056.         *)
  3057.           func_fatal_help "cannot copy a libtool object to \`$destfile'"
  3058.           ;;
  3059.         esac
  3060.  
  3061.         # Install the libtool object if requested.
  3062.         test -n "$destfile" && \
  3063.           func_show_eval "$install_prog $file $destfile" 'exit $?'
  3064.  
  3065.         # Install the old object if enabled.
  3066.         if test "$build_old_libs" = yes; then
  3067.           # Deduce the name of the old-style object file.
  3068.           func_lo2o "$file"
  3069.           staticobj=$func_lo2o_result
  3070.           func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
  3071.         fi
  3072.         exit $EXIT_SUCCESS
  3073.         ;;
  3074.  
  3075.      *)
  3076.         # Figure out destination file name, if it wasn't already specified.
  3077.         if test -n "$destname"; then
  3078.           destfile="$destdir/$destname"
  3079.         else
  3080.           func_basename "$file"
  3081.           destfile="$func_basename_result"
  3082.           destfile="$destdir/$destfile"
  3083.         fi
  3084.  
  3085.         # If the file is missing, and there is a .exe on the end, strip it
  3086.         # because it is most likely a libtool script we actually want to
  3087.         # install
  3088.         stripped_ext=""
  3089.         case $file in
  3090.           *.exe)
  3091.             if test ! -f "$file"; then
  3092.               func_stripname '' '.exe' "$file"
  3093.               file=$func_stripname_result
  3094.               stripped_ext=".exe"
  3095.             fi
  3096.             ;;
  3097.         esac
  3098.  
  3099.         # Do a test to see if this is really a libtool program.
  3100.         case $host in
  3101.         *cygwin* | *mingw*)
  3102.             if func_ltwrapper_executable_p "$file"; then
  3103.               func_ltwrapper_scriptname "$file"
  3104.               wrapper=$func_ltwrapper_scriptname_result
  3105.             else
  3106.               func_stripname '' '.exe' "$file"
  3107.               wrapper=$func_stripname_result
  3108.             fi
  3109.             ;;
  3110.         *)
  3111.             wrapper=$file
  3112.             ;;
  3113.         esac
  3114.         if func_ltwrapper_script_p "$wrapper"; then
  3115.           notinst_deplibs=
  3116.           relink_command=
  3117.  
  3118.           func_source "$wrapper"
  3119.  
  3120.           # Check the variables that should have been set.
  3121.           test -z "$generated_by_libtool_version" && \
  3122.             func_fatal_error "invalid libtool wrapper script \`$wrapper'"
  3123.  
  3124.           finalize=yes
  3125.           for lib in $notinst_deplibs; do
  3126.             # Check to see that each library is installed.
  3127.             libdir=
  3128.             if test -f "$lib"; then
  3129.               func_source "$lib"
  3130.             fi
  3131.             libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
  3132.             if test -n "$libdir" && test ! -f "$libfile"; then
  3133.               func_warning "\`$lib' has not been installed in \`$libdir'"
  3134.               finalize=no
  3135.             fi
  3136.           done
  3137.  
  3138.           relink_command=
  3139.           func_source "$wrapper"
  3140.  
  3141.           outputname=
  3142.           if test "$fast_install" = no && test -n "$relink_command"; then
  3143.             $opt_dry_run || {
  3144.               if test "$finalize" = yes; then
  3145.                 tmpdir=`func_mktempdir`
  3146.                 func_basename "$file$stripped_ext"
  3147.                 file="$func_basename_result"
  3148.                 outputname="$tmpdir/$file"
  3149.                 # Replace the output file specification.
  3150.                 relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
  3151.  
  3152.                 $opt_silent || {
  3153.                   func_quote_for_expand "$relink_command"
  3154.                   eval "func_echo $func_quote_for_expand_result"
  3155.                 }
  3156.                 if eval "$relink_command"; then :
  3157.                   else
  3158.                   func_error "error: relink \`$file' with the above command before installing it"
  3159.                   $opt_dry_run || ${RM}r "$tmpdir"
  3160.                   continue
  3161.                 fi
  3162.                 file="$outputname"
  3163.               else
  3164.                 func_warning "cannot relink \`$file'"
  3165.               fi
  3166.             }
  3167.           else
  3168.             # Install the binary that we compiled earlier.
  3169.             file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
  3170.           fi
  3171.         fi
  3172.  
  3173.         # remove .exe since cygwin /usr/bin/install will append another
  3174.         # one anyway
  3175.         case $install_prog,$host in
  3176.         */usr/bin/install*,*cygwin*)
  3177.           case $file:$destfile in
  3178.           *.exe:*.exe)
  3179.             # this is ok
  3180.             ;;
  3181.           *.exe:*)
  3182.             destfile=$destfile.exe
  3183.             ;;
  3184.           *:*.exe)
  3185.             func_stripname '' '.exe' "$destfile"
  3186.             destfile=$func_stripname_result
  3187.             ;;
  3188.           esac
  3189.           ;;
  3190.         esac
  3191.         func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
  3192.         $opt_dry_run || if test -n "$outputname"; then
  3193.           ${RM}r "$tmpdir"
  3194.         fi
  3195.         ;;
  3196.       esac
  3197.     done
  3198.  
  3199.     for file in $staticlibs; do
  3200.       func_basename "$file"
  3201.       name="$func_basename_result"
  3202.  
  3203.       # Set up the ranlib parameters.
  3204.       oldlib="$destdir/$name"
  3205.       func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
  3206.       tool_oldlib=$func_to_tool_file_result
  3207.  
  3208.       func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
  3209.  
  3210.       if test -n "$stripme" && test -n "$old_striplib"; then
  3211.         func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
  3212.       fi
  3213.  
  3214.       # Do each command in the postinstall commands.
  3215.       func_execute_cmds "$old_postinstall_cmds" 'exit $?'
  3216.     done
  3217.  
  3218.     test -n "$future_libdirs" && \
  3219.       func_warning "remember to run \`$progname --finish$future_libdirs'"
  3220.  
  3221.    if test -n "$current_libdirs"; then
  3222.      # Maybe just do a dry run.
  3223.      $opt_dry_run && current_libdirs=" -n$current_libdirs"
  3224.      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
  3225.    else
  3226.      exit $EXIT_SUCCESS
  3227.    fi
  3228. }
  3229.  
  3230. test "$opt_mode" = install && func_mode_install ${1+"$@"}
  3231.  
  3232.  
  3233. # func_generate_dlsyms outputname originator pic_p
  3234. # Extract symbols from dlprefiles and create ${outputname}S.o with
  3235. # a dlpreopen symbol table.
  3236. func_generate_dlsyms ()
  3237. {
  3238.    $opt_debug
  3239.    my_outputname="$1"
  3240.    my_originator="$2"
  3241.    my_pic_p="${3-no}"
  3242.    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
  3243.    my_dlsyms=
  3244.  
  3245.    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
  3246.      if test -n "$NM" && test -n "$global_symbol_pipe"; then
  3247.         my_dlsyms="${my_outputname}S.c"
  3248.      else
  3249.         func_error "not configured to extract global symbols from dlpreopened files"
  3250.      fi
  3251.    fi
  3252.  
  3253.    if test -n "$my_dlsyms"; then
  3254.      case $my_dlsyms in
  3255.      "") ;;
  3256.      *.c)
  3257.         # Discover the nlist of each of the dlfiles.
  3258.         nlist="$output_objdir/${my_outputname}.nm"
  3259.  
  3260.         func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
  3261.  
  3262.         # Parse the name list into a source file.
  3263.         func_verbose "creating $output_objdir/$my_dlsyms"
  3264.  
  3265.         $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
  3266. /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
  3267. /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
  3268.  
  3269. #ifdef __cplusplus
  3270. extern \"C\" {
  3271. #endif
  3272.  
  3273. #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
  3274. #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
  3275. #endif
  3276.  
  3277. /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
  3278. #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
  3279. /* DATA imports from DLLs on WIN32 con't be const, because runtime
  3280.   relocations are performed -- see ld's documentation on pseudo-relocs.  */
  3281. # define LT_DLSYM_CONST
  3282. #elif defined(__osf__)
  3283. /* This system does not cope well with relocations in const data.  */
  3284. # define LT_DLSYM_CONST
  3285. #else
  3286. # define LT_DLSYM_CONST const
  3287. #endif
  3288.  
  3289. /* External symbol declarations for the compiler. */\
  3290. "
  3291.  
  3292.         if test "$dlself" = yes; then
  3293.           func_verbose "generating symbol list for \`$output'"
  3294.  
  3295.           $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
  3296.  
  3297.           # Add our own program objects to the symbol list.
  3298.           progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
  3299.           for progfile in $progfiles; do
  3300.             func_to_tool_file "$progfile" func_convert_file_msys_to_w32
  3301.             func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
  3302.             $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
  3303.           done
  3304.  
  3305.           if test -n "$exclude_expsyms"; then
  3306.             $opt_dry_run || {
  3307.               eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
  3308.               eval '$MV "$nlist"T "$nlist"'
  3309.             }
  3310.           fi
  3311.  
  3312.           if test -n "$export_symbols_regex"; then
  3313.             $opt_dry_run || {
  3314.               eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
  3315.               eval '$MV "$nlist"T "$nlist"'
  3316.             }
  3317.           fi
  3318.  
  3319.           # Prepare the list of exported symbols
  3320.           if test -z "$export_symbols"; then
  3321.             export_symbols="$output_objdir/$outputname.exp"
  3322.             $opt_dry_run || {
  3323.               $RM $export_symbols
  3324.               eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
  3325.               case $host in
  3326.               *cygwin* | *mingw* | *cegcc* )
  3327.                 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
  3328.                 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
  3329.                 ;;
  3330.               esac
  3331.             }
  3332.           else
  3333.             $opt_dry_run || {
  3334.               eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
  3335.               eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
  3336.               eval '$MV "$nlist"T "$nlist"'
  3337.               case $host in
  3338.                 *cygwin* | *mingw* | *cegcc* )
  3339.                   eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
  3340.                   eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
  3341.                   ;;
  3342.               esac
  3343.             }
  3344.           fi
  3345.         fi
  3346.  
  3347.         for dlprefile in $dlprefiles; do
  3348.           func_verbose "extracting global C symbols from \`$dlprefile'"
  3349.           func_basename "$dlprefile"
  3350.           name="$func_basename_result"
  3351.          case $host in
  3352.             *cygwin* | *mingw* | *cegcc* )
  3353.               # if an import library, we need to obtain dlname
  3354.               if func_win32_import_lib_p "$dlprefile"; then
  3355.                 func_tr_sh "$dlprefile"
  3356.                 eval "curr_lafile=\$libfile_$func_tr_sh_result"
  3357.                 dlprefile_dlbasename=""
  3358.                 if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
  3359.                   # Use subshell, to avoid clobbering current variable values
  3360.                   dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
  3361.                   if test -n "$dlprefile_dlname" ; then
  3362.                     func_basename "$dlprefile_dlname"
  3363.                     dlprefile_dlbasename="$func_basename_result"
  3364.                   else
  3365.                     # no lafile. user explicitly requested -dlpreopen <import library>.
  3366.                     $sharedlib_from_linklib_cmd "$dlprefile"
  3367.                     dlprefile_dlbasename=$sharedlib_from_linklib_result
  3368.                   fi
  3369.                 fi
  3370.                 $opt_dry_run || {
  3371.                   if test -n "$dlprefile_dlbasename" ; then
  3372.                     eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
  3373.                   else
  3374.                     func_warning "Could not compute DLL name from $name"
  3375.                     eval '$ECHO ": $name " >> "$nlist"'
  3376.                   fi
  3377.                   func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
  3378.                   eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
  3379.                     $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
  3380.                 }
  3381.               else # not an import lib
  3382.                 $opt_dry_run || {
  3383.                   eval '$ECHO ": $name " >> "$nlist"'
  3384.                   func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
  3385.                   eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
  3386.                 }
  3387.               fi
  3388.             ;;
  3389.             *)
  3390.               $opt_dry_run || {
  3391.                 eval '$ECHO ": $name " >> "$nlist"'
  3392.                 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
  3393.                 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
  3394.               }
  3395.             ;;
  3396.          esac
  3397.         done
  3398.  
  3399.         $opt_dry_run || {
  3400.           # Make sure we have at least an empty file.
  3401.           test -f "$nlist" || : > "$nlist"
  3402.  
  3403.           if test -n "$exclude_expsyms"; then
  3404.             $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
  3405.             $MV "$nlist"T "$nlist"
  3406.           fi
  3407.  
  3408.           # Try sorting and uniquifying the output.
  3409.           if $GREP -v "^: " < "$nlist" |
  3410.               if sort -k 3 </dev/null >/dev/null 2>&1; then
  3411.                 sort -k 3
  3412.               else
  3413.                 sort +2
  3414.               fi |
  3415.               uniq > "$nlist"S; then
  3416.             :
  3417.           else
  3418.             $GREP -v "^: " < "$nlist" > "$nlist"S
  3419.           fi
  3420.  
  3421.           if test -f "$nlist"S; then
  3422.             eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
  3423.           else
  3424.             echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
  3425.           fi
  3426.  
  3427.           echo >> "$output_objdir/$my_dlsyms" "\
  3428.  
  3429. /* The mapping between symbol names and symbols.  */
  3430. typedef struct {
  3431.  const char *name;
  3432.  void *address;
  3433. } lt_dlsymlist;
  3434. extern LT_DLSYM_CONST lt_dlsymlist
  3435. lt_${my_prefix}_LTX_preloaded_symbols[];
  3436. LT_DLSYM_CONST lt_dlsymlist
  3437. lt_${my_prefix}_LTX_preloaded_symbols[] =
  3438. {\
  3439.  { \"$my_originator\", (void *) 0 },"
  3440.  
  3441.           case $need_lib_prefix in
  3442.           no)
  3443.             eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
  3444.             ;;
  3445.           *)
  3446.             eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
  3447.             ;;
  3448.           esac
  3449.           echo >> "$output_objdir/$my_dlsyms" "\
  3450.  {0, (void *) 0}
  3451. };
  3452.  
  3453. /* This works around a problem in FreeBSD linker */
  3454. #ifdef FREEBSD_WORKAROUND
  3455. static const void *lt_preloaded_setup() {
  3456.  return lt_${my_prefix}_LTX_preloaded_symbols;
  3457. }
  3458. #endif
  3459.  
  3460. #ifdef __cplusplus
  3461. }
  3462. #endif\
  3463. "
  3464.         } # !$opt_dry_run
  3465.  
  3466.         pic_flag_for_symtable=
  3467.         case "$compile_command " in
  3468.         *" -static "*) ;;
  3469.         *)
  3470.           case $host in
  3471.           # compiling the symbol table file with pic_flag works around
  3472.           # a FreeBSD bug that causes programs to crash when -lm is
  3473.           # linked before any other PIC object.  But we must not use
  3474.           # pic_flag when linking with -static.  The problem exists in
  3475.           # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
  3476.           *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
  3477.             pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
  3478.           *-*-hpux*)
  3479.             pic_flag_for_symtable=" $pic_flag"  ;;
  3480.           *)
  3481.             if test "X$my_pic_p" != Xno; then
  3482.               pic_flag_for_symtable=" $pic_flag"
  3483.             fi
  3484.             ;;
  3485.           esac
  3486.           ;;
  3487.         esac
  3488.         symtab_cflags=
  3489.         for arg in $LTCFLAGS; do
  3490.           case $arg in
  3491.           -pie | -fpie | -fPIE) ;;
  3492.           *) func_append symtab_cflags " $arg" ;;
  3493.           esac
  3494.         done
  3495.  
  3496.         # Now compile the dynamic symbol file.
  3497.         func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
  3498.  
  3499.         # Clean up the generated files.
  3500.         func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
  3501.  
  3502.         # Transform the symbol file into the correct name.
  3503.         symfileobj="$output_objdir/${my_outputname}S.$objext"
  3504.         case $host in
  3505.         *cygwin* | *mingw* | *cegcc* )
  3506.           if test -f "$output_objdir/$my_outputname.def"; then
  3507.             compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
  3508.             finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
  3509.           else
  3510.             compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
  3511.             finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
  3512.           fi
  3513.           ;;
  3514.         *)
  3515.           compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
  3516.           finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
  3517.           ;;
  3518.         esac
  3519.         ;;
  3520.      *)
  3521.         func_fatal_error "unknown suffix for \`$my_dlsyms'"
  3522.         ;;
  3523.       esac
  3524.     else
  3525.       # We keep going just in case the user didn't refer to
  3526.       # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
  3527.       # really was required.
  3528.  
  3529.       # Nullify the symbol file.
  3530.       compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
  3531.       finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
  3532.     fi
  3533. }
  3534.  
  3535. # func_win32_libid arg
  3536. # return the library type of file 'arg'
  3537. #
  3538. # Need a lot of goo to handle *both* DLLs and import libs
  3539. # Has to be a shell function in order to 'eat' the argument
  3540. # that is supplied when $file_magic_command is called.
  3541. # Despite the name, also deal with 64 bit binaries.
  3542. func_win32_libid ()
  3543. {
  3544.   $opt_debug
  3545.   win32_libid_type="unknown"
  3546.   win32_fileres=`file -L $1 2>/dev/null`
  3547.   case $win32_fileres in
  3548.   *ar\ archive\ import\ library*) # definitely import
  3549.     win32_libid_type="x86 archive import"
  3550.     ;;
  3551.   *ar\ archive*) # could be an import, or static
  3552.     # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
  3553.     if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
  3554.        $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
  3555.       func_to_tool_file "$1" func_convert_file_msys_to_w32
  3556.       win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
  3557.         $SED -n -e '
  3558.             1,100{
  3559.                 / I /{
  3560.                     s,.*,import,
  3561.                     p
  3562.                     q
  3563.                 }
  3564.             }'`
  3565.       case $win32_nmres in
  3566.       import*)  win32_libid_type="x86 archive import";;
  3567.       *)        win32_libid_type="x86 archive static";;
  3568.       esac
  3569.     fi
  3570.     ;;
  3571.   *DLL*)
  3572.     win32_libid_type="x86 DLL"
  3573.     ;;
  3574.   *executable*) # but shell scripts are "executable" too...
  3575.     case $win32_fileres in
  3576.     *MS\ Windows\ PE\ Intel*)
  3577.       win32_libid_type="x86 DLL"
  3578.       ;;
  3579.     esac
  3580.     ;;
  3581.   esac
  3582.   $ECHO "$win32_libid_type"
  3583. }
  3584.  
  3585. # func_cygming_dll_for_implib ARG
  3586. #
  3587. # Platform-specific function to extract the
  3588. # name of the DLL associated with the specified
  3589. # import library ARG.
  3590. # Invoked by eval'ing the libtool variable
  3591. #    $sharedlib_from_linklib_cmd
  3592. # Result is available in the variable
  3593. #    $sharedlib_from_linklib_result
  3594. func_cygming_dll_for_implib ()
  3595. {
  3596.   $opt_debug
  3597.   sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
  3598. }
  3599.  
  3600. # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
  3601. #
  3602. # The is the core of a fallback implementation of a
  3603. # platform-specific function to extract the name of the
  3604. # DLL associated with the specified import library LIBNAME.
  3605. #
  3606. # SECTION_NAME is either .idata$6 or .idata$7, depending
  3607. # on the platform and compiler that created the implib.
  3608. #
  3609. # Echos the name of the DLL associated with the
  3610. # specified import library.
  3611. func_cygming_dll_for_implib_fallback_core ()
  3612. {
  3613.   $opt_debug
  3614.   match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
  3615.   $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
  3616.     $SED '/^Contents of section '"$match_literal"':/{
  3617.      # Place marker at beginning of archive member dllname section
  3618.      s/.*/====MARK====/
  3619.      p
  3620.      d
  3621.    }
  3622.    # These lines can sometimes be longer than 43 characters, but
  3623.    # are always uninteresting
  3624.     /:[  ]*file format pe[i]\{,1\}-/d
  3625.    /^In archive [^:]*:/d
  3626.    # Ensure marker is printed
  3627.    /^====MARK====/p
  3628.    # Remove all lines with less than 43 characters
  3629.    /^.\{43\}/!d
  3630.    # From remaining lines, remove first 43 characters
  3631.    s/^.\{43\}//' |
  3632.     $SED -n '
  3633.      # Join marker and all lines until next marker into a single line
  3634.      /^====MARK====/ b para
  3635.      H
  3636.      $ b para
  3637.      b
  3638.      :para
  3639.      x
  3640.      s/\n//g
  3641.      # Remove the marker
  3642.      s/^====MARK====//
  3643.      # Remove trailing dots and whitespace
  3644.      s/[\. \t]*$//
  3645.      # Print
  3646.      /./p' |
  3647.     # we now have a list, one entry per line, of the stringified
  3648.     # contents of the appropriate section of all members of the
  3649.     # archive which possess that section. Heuristic: eliminate
  3650.     # all those which have a first or second character that is
  3651.     # a '.' (that is, objdump's representation of an unprintable
  3652.     # character.) This should work for all archives with less than
  3653.     # 0x302f exports -- but will fail for DLLs whose name actually
  3654.     # begins with a literal '.' or a single character followed by
  3655.     # a '.'.
  3656.     #
  3657.     # Of those that remain, print the first one.
  3658.     $SED -e '/^\./d;/^.\./d;q'
  3659. }
  3660.  
  3661. # func_cygming_gnu_implib_p ARG
  3662. # This predicate returns with zero status (TRUE) if
  3663. # ARG is a GNU/binutils-style import library. Returns
  3664. # with nonzero status (FALSE) otherwise.
  3665. func_cygming_gnu_implib_p ()
  3666. {
  3667.   $opt_debug
  3668.   func_to_tool_file "$1" func_convert_file_msys_to_w32
  3669.   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)$'`
  3670.   test -n "$func_cygming_gnu_implib_tmp"
  3671. }
  3672.  
  3673. # func_cygming_ms_implib_p ARG
  3674. # This predicate returns with zero status (TRUE) if
  3675. # ARG is an MS-style import library. Returns
  3676. # with nonzero status (FALSE) otherwise.
  3677. func_cygming_ms_implib_p ()
  3678. {
  3679.   $opt_debug
  3680.   func_to_tool_file "$1" func_convert_file_msys_to_w32
  3681.   func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
  3682.   test -n "$func_cygming_ms_implib_tmp"
  3683. }
  3684.  
  3685. # func_cygming_dll_for_implib_fallback ARG
  3686. # Platform-specific function to extract the
  3687. # name of the DLL associated with the specified
  3688. # import library ARG.
  3689. #
  3690. # This fallback implementation is for use when $DLLTOOL
  3691. # does not support the --identify-strict option.
  3692. # Invoked by eval'ing the libtool variable
  3693. #    $sharedlib_from_linklib_cmd
  3694. # Result is available in the variable
  3695. #    $sharedlib_from_linklib_result
  3696. func_cygming_dll_for_implib_fallback ()
  3697. {
  3698.   $opt_debug
  3699.   if func_cygming_gnu_implib_p "$1" ; then
  3700.     # binutils import library
  3701.     sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
  3702.   elif func_cygming_ms_implib_p "$1" ; then
  3703.     # ms-generated import library
  3704.     sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
  3705.   else
  3706.     # unknown
  3707.     sharedlib_from_linklib_result=""
  3708.   fi
  3709. }
  3710.  
  3711.  
  3712. # func_extract_an_archive dir oldlib
  3713. func_extract_an_archive ()
  3714. {
  3715.     $opt_debug
  3716.     f_ex_an_ar_dir="$1"; shift
  3717.     f_ex_an_ar_oldlib="$1"
  3718.     if test "$lock_old_archive_extraction" = yes; then
  3719.       lockfile=$f_ex_an_ar_oldlib.lock
  3720.       until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
  3721.         func_echo "Waiting for $lockfile to be removed"
  3722.         sleep 2
  3723.       done
  3724.     fi
  3725.     func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
  3726.                    'stat=$?; rm -f "$lockfile"; exit $stat'
  3727.     if test "$lock_old_archive_extraction" = yes; then
  3728.       $opt_dry_run || rm -f "$lockfile"
  3729.     fi
  3730.     if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
  3731.      :
  3732.     else
  3733.       func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
  3734.     fi
  3735. }
  3736.  
  3737.  
  3738. # func_extract_archives gentop oldlib ...
  3739. func_extract_archives ()
  3740. {
  3741.     $opt_debug
  3742.     my_gentop="$1"; shift
  3743.     my_oldlibs=${1+"$@"}
  3744.     my_oldobjs=""
  3745.     my_xlib=""
  3746.     my_xabs=""
  3747.     my_xdir=""
  3748.  
  3749.     for my_xlib in $my_oldlibs; do
  3750.       # Extract the objects.
  3751.       case $my_xlib in
  3752.         [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
  3753.         *) my_xabs=`pwd`"/$my_xlib" ;;
  3754.       esac
  3755.       func_basename "$my_xlib"
  3756.       my_xlib="$func_basename_result"
  3757.       my_xlib_u=$my_xlib
  3758.       while :; do
  3759.         case " $extracted_archives " in
  3760.         *" $my_xlib_u "*)
  3761.           func_arith $extracted_serial + 1
  3762.           extracted_serial=$func_arith_result
  3763.           my_xlib_u=lt$extracted_serial-$my_xlib ;;
  3764.         *) break ;;
  3765.         esac
  3766.       done
  3767.       extracted_archives="$extracted_archives $my_xlib_u"
  3768.       my_xdir="$my_gentop/$my_xlib_u"
  3769.  
  3770.       func_mkdir_p "$my_xdir"
  3771.  
  3772.       case $host in
  3773.       *-darwin*)
  3774.         func_verbose "Extracting $my_xabs"
  3775.         # Do not bother doing anything if just a dry run
  3776.         $opt_dry_run || {
  3777.           darwin_orig_dir=`pwd`
  3778.           cd $my_xdir || exit $?
  3779.           darwin_archive=$my_xabs
  3780.           darwin_curdir=`pwd`
  3781.           darwin_base_archive=`basename "$darwin_archive"`
  3782.           darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
  3783.           if test -n "$darwin_arches"; then
  3784.             darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
  3785.             darwin_arch=
  3786.             func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
  3787.             for darwin_arch in  $darwin_arches ; do
  3788.               func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
  3789.               $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
  3790.               cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
  3791.               func_extract_an_archive "`pwd`" "${darwin_base_archive}"
  3792.               cd "$darwin_curdir"
  3793.               $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
  3794.             done # $darwin_arches
  3795.             ## Okay now we've a bunch of thin objects, gotta fatten them up :)
  3796.             darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
  3797.             darwin_file=
  3798.             darwin_files=
  3799.             for darwin_file in $darwin_filelist; do
  3800.               darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
  3801.               $LIPO -create -output "$darwin_file" $darwin_files
  3802.             done # $darwin_filelist
  3803.             $RM -rf unfat-$$
  3804.             cd "$darwin_orig_dir"
  3805.           else
  3806.             cd $darwin_orig_dir
  3807.             func_extract_an_archive "$my_xdir" "$my_xabs"
  3808.           fi # $darwin_arches
  3809.         } # !$opt_dry_run
  3810.         ;;
  3811.       *)
  3812.         func_extract_an_archive "$my_xdir" "$my_xabs"
  3813.         ;;
  3814.       esac
  3815.       my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
  3816.     done
  3817.  
  3818.     func_extract_archives_result="$my_oldobjs"
  3819. }
  3820.  
  3821.  
  3822. # func_emit_wrapper [arg=no]
  3823. #
  3824. # Emit a libtool wrapper script on stdout.
  3825. # Don't directly open a file because we may want to
  3826. # incorporate the script contents within a cygwin/mingw
  3827. # wrapper executable.  Must ONLY be called from within
  3828. # func_mode_link because it depends on a number of variables
  3829. # set therein.
  3830. #
  3831. # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
  3832. # variable will take.  If 'yes', then the emitted script
  3833. # will assume that the directory in which it is stored is
  3834. # the $objdir directory.  This is a cygwin/mingw-specific
  3835. # behavior.
  3836. func_emit_wrapper ()
  3837. {
  3838.         func_emit_wrapper_arg1=${1-no}
  3839.  
  3840.         $ECHO "\
  3841. #! $SHELL
  3842.  
  3843. # $output - temporary wrapper script for $objdir/$outputname
  3844. # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
  3845. #
  3846. # The $output program cannot be directly executed until all the libtool
  3847. # libraries that it depends on are installed.
  3848. #
  3849. # This wrapper script should never be moved out of the build directory.
  3850. # If it is, it will not operate correctly.
  3851.  
  3852. # Sed substitution that helps us do robust quoting.  It backslashifies
  3853. # metacharacters that are still active within double-quoted strings.
  3854. sed_quote_subst='$sed_quote_subst'
  3855.  
  3856. # Be Bourne compatible
  3857. if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
  3858.  emulate sh
  3859.  NULLCMD=:
  3860.  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
  3861.  # is contrary to our usage.  Disable this feature.
  3862.  alias -g '\${1+\"\$@\"}'='\"\$@\"'
  3863.  setopt NO_GLOB_SUBST
  3864. else
  3865.  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
  3866. fi
  3867. BIN_SH=xpg4; export BIN_SH # for Tru64
  3868. DUALCASE=1; export DUALCASE # for MKS sh
  3869.  
  3870. # The HP-UX ksh and POSIX shell print the target directory to stdout
  3871. # if CDPATH is set.
  3872. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
  3873.  
  3874. relink_command=\"$relink_command\"
  3875.  
  3876. # This environment variable determines our operation mode.
  3877. if test \"\$libtool_install_magic\" = \"$magic\"; then
  3878.  # install mode needs the following variables:
  3879.  generated_by_libtool_version='$macro_version'
  3880.  notinst_deplibs='$notinst_deplibs'
  3881. else
  3882.  # When we are sourced in execute mode, \$file and \$ECHO are already set.
  3883.  if test \"\$libtool_execute_magic\" != \"$magic\"; then
  3884.    file=\"\$0\""
  3885.  
  3886.     qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
  3887.     $ECHO "\
  3888. # A function that is used when there is no print builtin or printf.
  3889. func_fallback_echo ()
  3890. {
  3891.  eval 'cat <<_LTECHO_EOF
  3892. \$1
  3893. _LTECHO_EOF'
  3894. }
  3895.    ECHO=\"$qECHO\"
  3896.  fi
  3897.  
  3898. # Very basic option parsing. These options are (a) specific to
  3899. # the libtool wrapper, (b) are identical between the wrapper
  3900. # /script/ and the wrapper /executable/ which is used only on
  3901. # windows platforms, and (c) all begin with the string "--lt-"
  3902. # (application programs are unlikely to have options which match
  3903. # this pattern).
  3904. #
  3905. # There are only two supported options: --lt-debug and
  3906. # --lt-dump-script. There is, deliberately, no --lt-help.
  3907. #
  3908. # The first argument to this parsing function should be the
  3909. # script's $0 value, followed by "$@".
  3910. lt_option_debug=
  3911. func_parse_lt_options ()
  3912. {
  3913.  lt_script_arg0=\$0
  3914.  shift
  3915.  for lt_opt
  3916.  do
  3917.    case \"\$lt_opt\" in
  3918.    --lt-debug) lt_option_debug=1 ;;
  3919.    --lt-dump-script)
  3920.        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
  3921.        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
  3922.        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
  3923.        cat \"\$lt_dump_D/\$lt_dump_F\"
  3924.        exit 0
  3925.      ;;
  3926.    --lt-*)
  3927.        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
  3928.        exit 1
  3929.      ;;
  3930.    esac
  3931.  done
  3932.  
  3933.  # Print the debug banner immediately:
  3934.  if test -n \"\$lt_option_debug\"; then
  3935.    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
  3936.  fi
  3937. }
  3938.  
  3939. # Used when --lt-debug. Prints its arguments to stdout
  3940. # (redirection is the responsibility of the caller)
  3941. func_lt_dump_args ()
  3942. {
  3943.  lt_dump_args_N=1;
  3944.  for lt_arg
  3945.  do
  3946.    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
  3947.    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
  3948.  done
  3949. }
  3950.  
  3951. # Core function for launching the target application
  3952. func_exec_program_core ()
  3953. {
  3954. "
  3955.   case $host in
  3956.   # Backslashes separate directories on plain windows
  3957.   *-*-mingw | *-*-os2* | *-cegcc*)
  3958.     $ECHO "\
  3959.      if test -n \"\$lt_option_debug\"; then
  3960.        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
  3961.        func_lt_dump_args \${1+\"\$@\"} 1>&2
  3962.      fi
  3963.      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
  3964. "
  3965.     ;;
  3966.  
  3967.   *)
  3968.     $ECHO "\
  3969.      if test -n \"\$lt_option_debug\"; then
  3970.        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
  3971.        func_lt_dump_args \${1+\"\$@\"} 1>&2
  3972.      fi
  3973.      exec \"\$progdir/\$program\" \${1+\"\$@\"}
  3974. "
  3975.     ;;
  3976.   esac
  3977.   $ECHO "\
  3978.      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
  3979.      exit 1
  3980. }
  3981.  
  3982. # A function to encapsulate launching the target application
  3983. # Strips options in the --lt-* namespace from \$@ and
  3984. # launches target application with the remaining arguments.
  3985. func_exec_program ()
  3986. {
  3987.  case \" \$* \" in
  3988.  *\\ --lt-*)
  3989.    for lt_wr_arg
  3990.    do
  3991.      case \$lt_wr_arg in
  3992.      --lt-*) ;;
  3993.      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
  3994.      esac
  3995.      shift
  3996.    done ;;
  3997.  esac
  3998.  func_exec_program_core \${1+\"\$@\"}
  3999. }
  4000.  
  4001.  # Parse options
  4002.  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
  4003.  
  4004.  # Find the directory that this script lives in.
  4005.  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
  4006.  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
  4007.  
  4008.  # Follow symbolic links until we get to the real thisdir.
  4009.  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
  4010.  while test -n \"\$file\"; do
  4011.    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
  4012.  
  4013.    # If there was a directory component, then change thisdir.
  4014.    if test \"x\$destdir\" != \"x\$file\"; then
  4015.      case \"\$destdir\" in
  4016.      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
  4017.      *) thisdir=\"\$thisdir/\$destdir\" ;;
  4018.      esac
  4019.    fi
  4020.  
  4021.    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
  4022.    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
  4023.  done
  4024.  
  4025.  # Usually 'no', except on cygwin/mingw when embedded into
  4026.  # the cwrapper.
  4027.  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
  4028.  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
  4029.    # special case for '.'
  4030.    if test \"\$thisdir\" = \".\"; then
  4031.      thisdir=\`pwd\`
  4032.    fi
  4033.    # remove .libs from thisdir
  4034.    case \"\$thisdir\" in
  4035.    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
  4036.    $objdir )   thisdir=. ;;
  4037.    esac
  4038.  fi
  4039.  
  4040.  # Try to get the absolute directory name.
  4041.  absdir=\`cd \"\$thisdir\" && pwd\`
  4042.  test -n \"\$absdir\" && thisdir=\"\$absdir\"
  4043. "
  4044.  
  4045.         if test "$fast_install" = yes; then
  4046.           $ECHO "\
  4047.  program=lt-'$outputname'$exeext
  4048.  progdir=\"\$thisdir/$objdir\"
  4049.  
  4050.  if test ! -f \"\$progdir/\$program\" ||
  4051.     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
  4052.       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
  4053.  
  4054.    file=\"\$\$-\$program\"
  4055.  
  4056.    if test ! -d \"\$progdir\"; then
  4057.      $MKDIR \"\$progdir\"
  4058.    else
  4059.      $RM \"\$progdir/\$file\"
  4060.    fi"
  4061.  
  4062.           $ECHO "\
  4063.    # relink executable if necessary
  4064.    if test -n \"\$relink_command\"; then
  4065.      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
  4066.      else
  4067.         $ECHO \"\$relink_command_output\" >&2
  4068.         $RM \"\$progdir/\$file\"
  4069.         exit 1
  4070.      fi
  4071.    fi
  4072.  
  4073.    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
  4074.    { $RM \"\$progdir/\$program\";
  4075.      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
  4076.    $RM \"\$progdir/\$file\"
  4077.  fi"
  4078.         else
  4079.           $ECHO "\
  4080.  program='$outputname'
  4081.  progdir=\"\$thisdir/$objdir\"
  4082. "
  4083.         fi
  4084.  
  4085.         $ECHO "\
  4086.  if test -f \"\$progdir/\$program\"; then"
  4087.  
  4088.         # fixup the dll searchpath if we need to.
  4089.         #
  4090.         # Fix the DLL searchpath if we need to.  Do this before prepending
  4091.         # to shlibpath, because on Windows, both are PATH and uninstalled
  4092.         # libraries must come first.
  4093.         if test -n "$dllsearchpath"; then
  4094.           $ECHO "\
  4095.    # Add the dll search path components to the executable PATH
  4096.    PATH=$dllsearchpath:\$PATH
  4097. "
  4098.         fi
  4099.  
  4100.         # Export our shlibpath_var if we have one.
  4101.         if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
  4102.           $ECHO "\
  4103.    # Add our own library path to $shlibpath_var
  4104.    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
  4105.  
  4106.    # Some systems cannot cope with colon-terminated $shlibpath_var
  4107.    # The second colon is a workaround for a bug in BeOS R4 sed
  4108.    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
  4109.  
  4110.    export $shlibpath_var
  4111. "
  4112.         fi
  4113.  
  4114.         $ECHO "\
  4115.    if test \"\$libtool_execute_magic\" != \"$magic\"; then
  4116.      # Run the actual program with our arguments.
  4117.      func_exec_program \${1+\"\$@\"}
  4118.    fi
  4119.  else
  4120.    # The program doesn't exist.
  4121.    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
  4122.    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
  4123.    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
  4124.    exit 1
  4125.  fi
  4126. fi\
  4127. "
  4128. }
  4129.  
  4130.  
  4131. # func_emit_cwrapperexe_src
  4132. # emit the source code for a wrapper executable on stdout
  4133. # Must ONLY be called from within func_mode_link because
  4134. # it depends on a number of variable set therein.
  4135. func_emit_cwrapperexe_src ()
  4136. {
  4137.         cat <<EOF
  4138.  
  4139. /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
  4140.   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
  4141.  
  4142.   The $output program cannot be directly executed until all the libtool
  4143.   libraries that it depends on are installed.
  4144.  
  4145.   This wrapper executable should never be moved out of the build directory.
  4146.   If it is, it will not operate correctly.
  4147. */
  4148. EOF
  4149.             cat <<"EOF"
  4150. #ifdef _MSC_VER
  4151. # define _CRT_SECURE_NO_DEPRECATE 1
  4152. #endif
  4153. #include <stdio.h>
  4154. #include <stdlib.h>
  4155. #ifdef _MSC_VER
  4156. # include <direct.h>
  4157. # include <process.h>
  4158. # include <io.h>
  4159. #else
  4160. # include <unistd.h>
  4161. # include <stdint.h>
  4162. # ifdef __CYGWIN__
  4163. #  include <io.h>
  4164. # endif
  4165. #endif
  4166. #include <malloc.h>
  4167. #include <stdarg.h>
  4168. #include <assert.h>
  4169. #include <string.h>
  4170. #include <ctype.h>
  4171. #include <errno.h>
  4172. #include <fcntl.h>
  4173. #include <sys/stat.h>
  4174.  
  4175. /* declarations of non-ANSI functions */
  4176. #if defined(__MINGW32__)
  4177. # ifdef __STRICT_ANSI__
  4178. int _putenv (const char *);
  4179. # endif
  4180. #elif defined(__CYGWIN__)
  4181. # ifdef __STRICT_ANSI__
  4182. char *realpath (const char *, char *);
  4183. int putenv (char *);
  4184. int setenv (const char *, const char *, int);
  4185. # endif
  4186. /* #elif defined (other platforms) ... */
  4187. #endif
  4188.  
  4189. /* portability defines, excluding path handling macros */
  4190. #if defined(_MSC_VER)
  4191. # define setmode _setmode
  4192. # define stat    _stat
  4193. # define chmod   _chmod
  4194. # define getcwd  _getcwd
  4195. # define putenv  _putenv
  4196. # define S_IXUSR _S_IEXEC
  4197. # ifndef _INTPTR_T_DEFINED
  4198. #  define _INTPTR_T_DEFINED
  4199. #  define intptr_t int
  4200. # endif
  4201. #elif defined(__MINGW32__)
  4202. # define setmode _setmode
  4203. # define stat    _stat
  4204. # define chmod   _chmod
  4205. # define getcwd  _getcwd
  4206. # define putenv  _putenv
  4207. #elif defined(__CYGWIN__)
  4208. # define HAVE_SETENV
  4209. # define FOPEN_WB "wb"
  4210. /* #elif defined (other platforms) ... */
  4211. #endif
  4212.  
  4213. #if defined(PATH_MAX)
  4214. # define LT_PATHMAX PATH_MAX
  4215. #elif defined(MAXPATHLEN)
  4216. # define LT_PATHMAX MAXPATHLEN
  4217. #else
  4218. # define LT_PATHMAX 1024
  4219. #endif
  4220.  
  4221. #ifndef S_IXOTH
  4222. # define S_IXOTH 0
  4223. #endif
  4224. #ifndef S_IXGRP
  4225. # define S_IXGRP 0
  4226. #endif
  4227.  
  4228. /* path handling portability macros */
  4229. #ifndef DIR_SEPARATOR
  4230. # define DIR_SEPARATOR '/'
  4231. # define PATH_SEPARATOR ':'
  4232. #endif
  4233.  
  4234. #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
  4235.  defined (__OS2__)
  4236. # define HAVE_DOS_BASED_FILE_SYSTEM
  4237. # define FOPEN_WB "wb"
  4238. # ifndef DIR_SEPARATOR_2
  4239. #  define DIR_SEPARATOR_2 '\\'
  4240. # endif
  4241. # ifndef PATH_SEPARATOR_2
  4242. #  define PATH_SEPARATOR_2 ';'
  4243. # endif
  4244. #endif
  4245.  
  4246. #ifndef DIR_SEPARATOR_2
  4247. # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
  4248. #else /* DIR_SEPARATOR_2 */
  4249. # define IS_DIR_SEPARATOR(ch) \
  4250.         (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
  4251. #endif /* DIR_SEPARATOR_2 */
  4252.  
  4253. #ifndef PATH_SEPARATOR_2
  4254. # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
  4255. #else /* PATH_SEPARATOR_2 */
  4256. # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
  4257. #endif /* PATH_SEPARATOR_2 */
  4258.  
  4259. #ifndef FOPEN_WB
  4260. # define FOPEN_WB "w"
  4261. #endif
  4262. #ifndef _O_BINARY
  4263. # define _O_BINARY 0
  4264. #endif
  4265.  
  4266. #define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
  4267. #define XFREE(stale) do { \
  4268.  if (stale) { free ((void *) stale); stale = 0; } \
  4269. } while (0)
  4270.  
  4271. #if defined(LT_DEBUGWRAPPER)
  4272. static int lt_debug = 1;
  4273. #else
  4274. static int lt_debug = 0;
  4275. #endif
  4276.  
  4277. const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
  4278.  
  4279. void *xmalloc (size_t num);
  4280. char *xstrdup (const char *string);
  4281. const char *base_name (const char *name);
  4282. char *find_executable (const char *wrapper);
  4283. char *chase_symlinks (const char *pathspec);
  4284. int make_executable (const char *path);
  4285. int check_executable (const char *path);
  4286. char *strendzap (char *str, const char *pat);
  4287. void lt_debugprintf (const char *file, int line, const char *fmt, ...);
  4288. void lt_fatal (const char *file, int line, const char *message, ...);
  4289. static const char *nonnull (const char *s);
  4290. static const char *nonempty (const char *s);
  4291. void lt_setenv (const char *name, const char *value);
  4292. char *lt_extend_str (const char *orig_value, const char *add, int to_end);
  4293. void lt_update_exe_path (const char *name, const char *value);
  4294. void lt_update_lib_path (const char *name, const char *value);
  4295. char **prepare_spawn (char **argv);
  4296. void lt_dump_script (FILE *f);
  4297. EOF
  4298.  
  4299.             cat <<EOF
  4300. volatile const char * MAGIC_EXE = "$magic_exe";
  4301. const char * LIB_PATH_VARNAME = "$shlibpath_var";
  4302. EOF
  4303.  
  4304.             if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
  4305.              func_to_host_path "$temp_rpath"
  4306.               cat <<EOF
  4307. const char * LIB_PATH_VALUE   = "$func_to_host_path_result";
  4308. EOF
  4309.             else
  4310.               cat <<"EOF"
  4311. const char * LIB_PATH_VALUE   = "";
  4312. EOF
  4313.             fi
  4314.  
  4315.             if test -n "$dllsearchpath"; then
  4316.              func_to_host_path "$dllsearchpath:"
  4317.               cat <<EOF
  4318. const char * EXE_PATH_VARNAME = "PATH";
  4319. const char * EXE_PATH_VALUE   = "$func_to_host_path_result";
  4320. EOF
  4321.             else
  4322.               cat <<"EOF"
  4323. const char * EXE_PATH_VARNAME = "";
  4324. const char * EXE_PATH_VALUE   = "";
  4325. EOF
  4326.             fi
  4327.  
  4328.             if test "$fast_install" = yes; then
  4329.               cat <<EOF
  4330. const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
  4331. EOF
  4332.             else
  4333.               cat <<EOF
  4334. const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
  4335. EOF
  4336.             fi
  4337.  
  4338.  
  4339.             cat <<"EOF"
  4340.  
  4341. #define LTWRAPPER_OPTION_PREFIX         "--lt-"
  4342.  
  4343. static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
  4344. static const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
  4345. static const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
  4346.  
  4347. int
  4348. main (int argc, char *argv[])
  4349. {
  4350.  char **newargz;
  4351.  int  newargc;
  4352.  char *tmp_pathspec;
  4353.  char *actual_cwrapper_path;
  4354.  char *actual_cwrapper_name;
  4355.  char *target_name;
  4356.  char *lt_argv_zero;
  4357.  intptr_t rval = 127;
  4358.  
  4359.  int i;
  4360.  
  4361.  program_name = (char *) xstrdup (base_name (argv[0]));
  4362.  newargz = XMALLOC (char *, argc + 1);
  4363.  
  4364.  /* very simple arg parsing; don't want to rely on getopt
  4365.   * also, copy all non cwrapper options to newargz, except
  4366.   * argz[0], which is handled differently
  4367.   */
  4368.  newargc=0;
  4369.  for (i = 1; i < argc; i++)
  4370.    {
  4371.      if (strcmp (argv[i], dumpscript_opt) == 0)
  4372.         {
  4373. EOF
  4374.             case "$host" in
  4375.               *mingw* | *cygwin* )
  4376.                 # make stdout use "unix" line endings
  4377.                 echo "          setmode(1,_O_BINARY);"
  4378.                 ;;
  4379.               esac
  4380.  
  4381.             cat <<"EOF"
  4382.           lt_dump_script (stdout);
  4383.           return 0;
  4384.         }
  4385.      if (strcmp (argv[i], debug_opt) == 0)
  4386.         {
  4387.          lt_debug = 1;
  4388.          continue;
  4389.         }
  4390.      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
  4391.        {
  4392.          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
  4393.             namespace, but it is not one of the ones we know about and
  4394.             have already dealt with, above (inluding dump-script), then
  4395.             report an error. Otherwise, targets might begin to believe
  4396.             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
  4397.             namespace. The first time any user complains about this, we'll
  4398.             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
  4399.             or a configure.ac-settable value.
  4400.           */
  4401.          lt_fatal (__FILE__, __LINE__,
  4402.                     "unrecognized %s option: '%s'",
  4403.                    ltwrapper_option_prefix, argv[i]);
  4404.        }
  4405.      /* otherwise ... */
  4406.      newargz[++newargc] = xstrdup (argv[i]);
  4407.    }
  4408.  newargz[++newargc] = NULL;
  4409.  
  4410. EOF
  4411.             cat <<EOF
  4412.  /* The GNU banner must be the first non-error debug message */
  4413.  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
  4414. EOF
  4415.             cat <<"EOF"
  4416.  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
  4417.  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
  4418.  
  4419.  tmp_pathspec = find_executable (argv[0]);
  4420.  if (tmp_pathspec == NULL)
  4421.    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
  4422.  lt_debugprintf (__FILE__, __LINE__,
  4423.                  "(main) found exe (before symlink chase) at: %s\n",
  4424.                   tmp_pathspec);
  4425.  
  4426.  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
  4427.  lt_debugprintf (__FILE__, __LINE__,
  4428.                  "(main) found exe (after symlink chase) at: %s\n",
  4429.                   actual_cwrapper_path);
  4430.  XFREE (tmp_pathspec);
  4431.  
  4432.  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
  4433.  strendzap (actual_cwrapper_path, actual_cwrapper_name);
  4434.  
  4435.  /* wrapper name transforms */
  4436.  strendzap (actual_cwrapper_name, ".exe");
  4437.  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
  4438.  XFREE (actual_cwrapper_name);
  4439.  actual_cwrapper_name = tmp_pathspec;
  4440.  tmp_pathspec = 0;
  4441.  
  4442.  /* target_name transforms -- use actual target program name; might have lt- prefix */
  4443.  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
  4444.  strendzap (target_name, ".exe");
  4445.  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
  4446.  XFREE (target_name);
  4447.  target_name = tmp_pathspec;
  4448.  tmp_pathspec = 0;
  4449.  
  4450.  lt_debugprintf (__FILE__, __LINE__,
  4451.                   "(main) libtool target name: %s\n",
  4452.                   target_name);
  4453. EOF
  4454.  
  4455.             cat <<EOF
  4456.  newargz[0] =
  4457.    XMALLOC (char, (strlen (actual_cwrapper_path) +
  4458.                     strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
  4459.  strcpy (newargz[0], actual_cwrapper_path);
  4460.  strcat (newargz[0], "$objdir");
  4461.  strcat (newargz[0], "/");
  4462. EOF
  4463.  
  4464.             cat <<"EOF"
  4465.  /* stop here, and copy so we don't have to do this twice */
  4466.  tmp_pathspec = xstrdup (newargz[0]);
  4467.  
  4468.  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
  4469.  strcat (newargz[0], actual_cwrapper_name);
  4470.  
  4471.  /* DO want the lt- prefix here if it exists, so use target_name */
  4472.  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
  4473.  XFREE (tmp_pathspec);
  4474.  tmp_pathspec = NULL;
  4475. EOF
  4476.  
  4477.             case $host_os in
  4478.               mingw*)
  4479.             cat <<"EOF"
  4480.  {
  4481.    char* p;
  4482.    while ((p = strchr (newargz[0], '\\')) != NULL)
  4483.      {
  4484.         *p = '/';
  4485.      }
  4486.    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
  4487.      {
  4488.         *p = '/';
  4489.      }
  4490.  }
  4491. EOF
  4492.             ;;
  4493.             esac
  4494.  
  4495.             cat <<"EOF"
  4496.  XFREE (target_name);
  4497.  XFREE (actual_cwrapper_path);
  4498.  XFREE (actual_cwrapper_name);
  4499.  
  4500.  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
  4501.  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
  4502.  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
  4503.     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
  4504.     because on Windows, both *_VARNAMEs are PATH but uninstalled
  4505.     libraries must come first. */
  4506.  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
  4507.  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
  4508.  
  4509.  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
  4510.                   nonnull (lt_argv_zero));
  4511.  for (i = 0; i < newargc; i++)
  4512.    {
  4513.      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
  4514.                       i, nonnull (newargz[i]));
  4515.    }
  4516.  
  4517. EOF
  4518.  
  4519.             case $host_os in
  4520.               mingw*)
  4521.                 cat <<"EOF"
  4522.  /* execv doesn't actually work on mingw as expected on unix */
  4523.  newargz = prepare_spawn (newargz);
  4524.  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
  4525.  if (rval == -1)
  4526.    {
  4527.      /* failed to start process */
  4528.      lt_debugprintf (__FILE__, __LINE__,
  4529.                       "(main) failed to launch target \"%s\": %s\n",
  4530.                       lt_argv_zero, nonnull (strerror (errno)));
  4531.      return 127;
  4532.    }
  4533.  return rval;
  4534. EOF
  4535.                 ;;
  4536.               *)
  4537.                 cat <<"EOF"
  4538.  execv (lt_argv_zero, newargz);
  4539.  return rval; /* =127, but avoids unused variable warning */
  4540. EOF
  4541.                 ;;
  4542.             esac
  4543.  
  4544.             cat <<"EOF"
  4545. }
  4546.  
  4547. void *
  4548. xmalloc (size_t num)
  4549. {
  4550.  void *p = (void *) malloc (num);
  4551.  if (!p)
  4552.    lt_fatal (__FILE__, __LINE__, "memory exhausted");
  4553.  
  4554.  return p;
  4555. }
  4556.  
  4557. char *
  4558. xstrdup (const char *string)
  4559. {
  4560.  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
  4561.                           string) : NULL;
  4562. }
  4563.  
  4564. const char *
  4565. base_name (const char *name)
  4566. {
  4567.  const char *base;
  4568.  
  4569. #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
  4570.  /* Skip over the disk name in MSDOS pathnames. */
  4571.  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
  4572.    name += 2;
  4573. #endif
  4574.  
  4575.  for (base = name; *name; name++)
  4576.    if (IS_DIR_SEPARATOR (*name))
  4577.      base = name + 1;
  4578.  return base;
  4579. }
  4580.  
  4581. int
  4582. check_executable (const char *path)
  4583. {
  4584.  struct stat st;
  4585.  
  4586.  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
  4587.                  nonempty (path));
  4588.  if ((!path) || (!*path))
  4589.    return 0;
  4590.  
  4591.  if ((stat (path, &st) >= 0)
  4592.      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
  4593.    return 1;
  4594.  else
  4595.    return 0;
  4596. }
  4597.  
  4598. int
  4599. make_executable (const char *path)
  4600. {
  4601.  int rval = 0;
  4602.  struct stat st;
  4603.  
  4604.  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
  4605.                  nonempty (path));
  4606.  if ((!path) || (!*path))
  4607.    return 0;
  4608.  
  4609.  if (stat (path, &st) >= 0)
  4610.    {
  4611.      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
  4612.    }
  4613.  return rval;
  4614. }
  4615.  
  4616. /* Searches for the full path of the wrapper.  Returns
  4617.   newly allocated full path name if found, NULL otherwise
  4618.   Does not chase symlinks, even on platforms that support them.
  4619. */
  4620. char *
  4621. find_executable (const char *wrapper)
  4622. {
  4623.  int has_slash = 0;
  4624.  const char *p;
  4625.  const char *p_next;
  4626.  /* static buffer for getcwd */
  4627.  char tmp[LT_PATHMAX + 1];
  4628.  int tmp_len;
  4629.  char *concat_name;
  4630.  
  4631.  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
  4632.                  nonempty (wrapper));
  4633.  
  4634.  if ((wrapper == NULL) || (*wrapper == '\0'))
  4635.    return NULL;
  4636.  
  4637.  /* Absolute path? */
  4638. #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
  4639.  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
  4640.    {
  4641.      concat_name = xstrdup (wrapper);
  4642.      if (check_executable (concat_name))
  4643.         return concat_name;
  4644.      XFREE (concat_name);
  4645.    }
  4646.  else
  4647.    {
  4648. #endif
  4649.      if (IS_DIR_SEPARATOR (wrapper[0]))
  4650.         {
  4651.           concat_name = xstrdup (wrapper);
  4652.           if (check_executable (concat_name))
  4653.             return concat_name;
  4654.           XFREE (concat_name);
  4655.         }
  4656. #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
  4657.    }
  4658. #endif
  4659.  
  4660.  for (p = wrapper; *p; p++)
  4661.    if (*p == '/')
  4662.      {
  4663.         has_slash = 1;
  4664.         break;
  4665.      }
  4666.  if (!has_slash)
  4667.    {
  4668.      /* no slashes; search PATH */
  4669.      const char *path = getenv ("PATH");
  4670.      if (path != NULL)
  4671.         {
  4672.           for (p = path; *p; p = p_next)
  4673.             {
  4674.               const char *q;
  4675.               size_t p_len;
  4676.               for (q = p; *q; q++)
  4677.                 if (IS_PATH_SEPARATOR (*q))
  4678.                   break;
  4679.               p_len = q - p;
  4680.               p_next = (*q == '\0' ? q : q + 1);
  4681.               if (p_len == 0)
  4682.                 {
  4683.                   /* empty path: current directory */
  4684.                   if (getcwd (tmp, LT_PATHMAX) == NULL)
  4685.                     lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
  4686.                              nonnull (strerror (errno)));
  4687.                   tmp_len = strlen (tmp);
  4688.                   concat_name =
  4689.                     XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
  4690.                   memcpy (concat_name, tmp, tmp_len);
  4691.                   concat_name[tmp_len] = '/';
  4692.                   strcpy (concat_name + tmp_len + 1, wrapper);
  4693.                 }
  4694.               else
  4695.                 {
  4696.                   concat_name =
  4697.                     XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
  4698.                   memcpy (concat_name, p, p_len);
  4699.                   concat_name[p_len] = '/';
  4700.                   strcpy (concat_name + p_len + 1, wrapper);
  4701.                 }
  4702.               if (check_executable (concat_name))
  4703.                 return concat_name;
  4704.               XFREE (concat_name);
  4705.             }
  4706.         }
  4707.      /* not found in PATH; assume curdir */
  4708.    }
  4709.  /* Relative path | not found in path: prepend cwd */
  4710.  if (getcwd (tmp, LT_PATHMAX) == NULL)
  4711.    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
  4712.              nonnull (strerror (errno)));
  4713.  tmp_len = strlen (tmp);
  4714.  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
  4715.  memcpy (concat_name, tmp, tmp_len);
  4716.  concat_name[tmp_len] = '/';
  4717.  strcpy (concat_name + tmp_len + 1, wrapper);
  4718.  
  4719.  if (check_executable (concat_name))
  4720.    return concat_name;
  4721.  XFREE (concat_name);
  4722.  return NULL;
  4723. }
  4724.  
  4725. char *
  4726. chase_symlinks (const char *pathspec)
  4727. {
  4728. #ifndef S_ISLNK
  4729.  return xstrdup (pathspec);
  4730. #else
  4731.  char buf[LT_PATHMAX];
  4732.  struct stat s;
  4733.  char *tmp_pathspec = xstrdup (pathspec);
  4734.  char *p;
  4735.  int has_symlinks = 0;
  4736.  while (strlen (tmp_pathspec) && !has_symlinks)
  4737.    {
  4738.      lt_debugprintf (__FILE__, __LINE__,
  4739.                       "checking path component for symlinks: %s\n",
  4740.                       tmp_pathspec);
  4741.      if (lstat (tmp_pathspec, &s) == 0)
  4742.         {
  4743.           if (S_ISLNK (s.st_mode) != 0)
  4744.             {
  4745.               has_symlinks = 1;
  4746.               break;
  4747.             }
  4748.  
  4749.           /* search backwards for last DIR_SEPARATOR */
  4750.           p = tmp_pathspec + strlen (tmp_pathspec) - 1;
  4751.           while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
  4752.             p--;
  4753.           if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
  4754.             {
  4755.               /* no more DIR_SEPARATORS left */
  4756.               break;
  4757.             }
  4758.           *p = '\0';
  4759.         }
  4760.      else
  4761.         {
  4762.           lt_fatal (__FILE__, __LINE__,
  4763.                     "error accessing file \"%s\": %s",
  4764.                     tmp_pathspec, nonnull (strerror (errno)));
  4765.         }
  4766.    }
  4767.  XFREE (tmp_pathspec);
  4768.  
  4769.  if (!has_symlinks)
  4770.    {
  4771.      return xstrdup (pathspec);
  4772.    }
  4773.  
  4774.  tmp_pathspec = realpath (pathspec, buf);
  4775.  if (tmp_pathspec == 0)
  4776.    {
  4777.      lt_fatal (__FILE__, __LINE__,
  4778.                 "could not follow symlinks for %s", pathspec);
  4779.    }
  4780.  return xstrdup (tmp_pathspec);
  4781. #endif
  4782. }
  4783.  
  4784. char *
  4785. strendzap (char *str, const char *pat)
  4786. {
  4787.  size_t len, patlen;
  4788.  
  4789.  assert (str != NULL);
  4790.  assert (pat != NULL);
  4791.  
  4792.  len = strlen (str);
  4793.  patlen = strlen (pat);
  4794.  
  4795.  if (patlen <= len)
  4796.    {
  4797.      str += len - patlen;
  4798.      if (strcmp (str, pat) == 0)
  4799.         *str = '\0';
  4800.    }
  4801.  return str;
  4802. }
  4803.  
  4804. void
  4805. lt_debugprintf (const char *file, int line, const char *fmt, ...)
  4806. {
  4807.  va_list args;
  4808.  if (lt_debug)
  4809.    {
  4810.      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
  4811.      va_start (args, fmt);
  4812.      (void) vfprintf (stderr, fmt, args);
  4813.      va_end (args);
  4814.    }
  4815. }
  4816.  
  4817. static void
  4818. lt_error_core (int exit_status, const char *file,
  4819.                int line, const char *mode,
  4820.                const char *message, va_list ap)
  4821. {
  4822.  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
  4823.  vfprintf (stderr, message, ap);
  4824.  fprintf (stderr, ".\n");
  4825.  
  4826.  if (exit_status >= 0)
  4827.    exit (exit_status);
  4828. }
  4829.  
  4830. void
  4831. lt_fatal (const char *file, int line, const char *message, ...)
  4832. {
  4833.  va_list ap;
  4834.  va_start (ap, message);
  4835.  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
  4836.  va_end (ap);
  4837. }
  4838.  
  4839. static const char *
  4840. nonnull (const char *s)
  4841. {
  4842.  return s ? s : "(null)";
  4843. }
  4844.  
  4845. static const char *
  4846. nonempty (const char *s)
  4847. {
  4848.  return (s && !*s) ? "(empty)" : nonnull (s);
  4849. }
  4850.  
  4851. void
  4852. lt_setenv (const char *name, const char *value)
  4853. {
  4854.  lt_debugprintf (__FILE__, __LINE__,
  4855.                   "(lt_setenv) setting '%s' to '%s'\n",
  4856.                  nonnull (name), nonnull (value));
  4857.  {
  4858. #ifdef HAVE_SETENV
  4859.    /* always make a copy, for consistency with !HAVE_SETENV */
  4860.    char *str = xstrdup (value);
  4861.    setenv (name, str, 1);
  4862. #else
  4863.    int len = strlen (name) + 1 + strlen (value) + 1;
  4864.    char *str = XMALLOC (char, len);
  4865.    sprintf (str, "%s=%s", name, value);
  4866.    if (putenv (str) != EXIT_SUCCESS)
  4867.      {
  4868.        XFREE (str);
  4869.      }
  4870. #endif
  4871.  }
  4872. }
  4873.  
  4874. char *
  4875. lt_extend_str (const char *orig_value, const char *add, int to_end)
  4876. {
  4877.  char *new_value;
  4878.  if (orig_value && *orig_value)
  4879.    {
  4880.      int orig_value_len = strlen (orig_value);
  4881.      int add_len = strlen (add);
  4882.      new_value = XMALLOC (char, add_len + orig_value_len + 1);
  4883.      if (to_end)
  4884.        {
  4885.          strcpy (new_value, orig_value);
  4886.          strcpy (new_value + orig_value_len, add);
  4887.        }
  4888.      else
  4889.        {
  4890.          strcpy (new_value, add);
  4891.          strcpy (new_value + add_len, orig_value);
  4892.        }
  4893.    }
  4894.  else
  4895.    {
  4896.      new_value = xstrdup (add);
  4897.    }
  4898.  return new_value;
  4899. }
  4900.  
  4901. void
  4902. lt_update_exe_path (const char *name, const char *value)
  4903. {
  4904.  lt_debugprintf (__FILE__, __LINE__,
  4905.                   "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
  4906.                  nonnull (name), nonnull (value));
  4907.  
  4908.  if (name && *name && value && *value)
  4909.    {
  4910.      char *new_value = lt_extend_str (getenv (name), value, 0);
  4911.      /* some systems can't cope with a ':'-terminated path #' */
  4912.      int len = strlen (new_value);
  4913.      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
  4914.        {
  4915.          new_value[len-1] = '\0';
  4916.        }
  4917.      lt_setenv (name, new_value);
  4918.      XFREE (new_value);
  4919.    }
  4920. }
  4921.  
  4922. void
  4923. lt_update_lib_path (const char *name, const char *value)
  4924. {
  4925.  lt_debugprintf (__FILE__, __LINE__,
  4926.                   "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
  4927.                  nonnull (name), nonnull (value));
  4928.  
  4929.  if (name && *name && value && *value)
  4930.    {
  4931.      char *new_value = lt_extend_str (getenv (name), value, 0);
  4932.      lt_setenv (name, new_value);
  4933.      XFREE (new_value);
  4934.    }
  4935. }
  4936.  
  4937. EOF
  4938.             case $host_os in
  4939.               mingw*)
  4940.                 cat <<"EOF"
  4941.  
  4942. /* Prepares an argument vector before calling spawn().
  4943.   Note that spawn() does not by itself call the command interpreter
  4944.     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
  4945.      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  4946.         GetVersionEx(&v);
  4947.         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
  4948.      }) ? "cmd.exe" : "command.com").
  4949.   Instead it simply concatenates the arguments, separated by ' ', and calls
  4950.   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
  4951.   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
  4952.   special way:
  4953.   - Space and tab are interpreted as delimiters. They are not treated as
  4954.     delimiters if they are surrounded by double quotes: "...".
  4955.   - Unescaped double quotes are removed from the input. Their only effect is
  4956.     that within double quotes, space and tab are treated like normal
  4957.     characters.
  4958.   - Backslashes not followed by double quotes are not special.
  4959.   - But 2*n+1 backslashes followed by a double quote become
  4960.     n backslashes followed by a double quote (n >= 0):
  4961.       \" -> "
  4962.       \\\" -> \"
  4963.       \\\\\" -> \\"
  4964. */
  4965. #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"
  4966. #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"
  4967. char **
  4968. prepare_spawn (char **argv)
  4969. {
  4970.  size_t argc;
  4971.  char **new_argv;
  4972.  size_t i;
  4973.  
  4974.  /* Count number of arguments.  */
  4975.  for (argc = 0; argv[argc] != NULL; argc++)
  4976.    ;
  4977.  
  4978.  /* Allocate new argument vector.  */
  4979.  new_argv = XMALLOC (char *, argc + 1);
  4980.  
  4981.  /* Put quoted arguments into the new argument vector.  */
  4982.  for (i = 0; i < argc; i++)
  4983.    {
  4984.      const char *string = argv[i];
  4985.  
  4986.      if (string[0] == '\0')
  4987.         new_argv[i] = xstrdup ("\"\"");
  4988.      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
  4989.         {
  4990.           int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
  4991.           size_t length;
  4992.           unsigned int backslashes;
  4993.           const char *s;
  4994.           char *quoted_string;
  4995.           char *p;
  4996.  
  4997.           length = 0;
  4998.           backslashes = 0;
  4999.           if (quote_around)
  5000.             length++;
  5001.           for (s = string; *s != '\0'; s++)
  5002.             {
  5003.               char c = *s;
  5004.               if (c == '"')
  5005.                 length += backslashes + 1;
  5006.               length++;
  5007.               if (c == '\\')
  5008.                 backslashes++;
  5009.               else
  5010.                 backslashes = 0;
  5011.             }
  5012.           if (quote_around)
  5013.             length += backslashes + 1;
  5014.  
  5015.           quoted_string = XMALLOC (char, length + 1);
  5016.  
  5017.           p = quoted_string;
  5018.           backslashes = 0;
  5019.           if (quote_around)
  5020.             *p++ = '"';
  5021.           for (s = string; *s != '\0'; s++)
  5022.             {
  5023.               char c = *s;
  5024.               if (c == '"')
  5025.                 {
  5026.                   unsigned int j;
  5027.                   for (j = backslashes + 1; j > 0; j--)
  5028.                     *p++ = '\\';
  5029.                 }
  5030.               *p++ = c;
  5031.               if (c == '\\')
  5032.                 backslashes++;
  5033.               else
  5034.                 backslashes = 0;
  5035.             }
  5036.           if (quote_around)
  5037.             {
  5038.               unsigned int j;
  5039.               for (j = backslashes; j > 0; j--)
  5040.                 *p++ = '\\';
  5041.               *p++ = '"';
  5042.             }
  5043.           *p = '\0';
  5044.  
  5045.           new_argv[i] = quoted_string;
  5046.         }
  5047.      else
  5048.         new_argv[i] = (char *) string;
  5049.    }
  5050.  new_argv[argc] = NULL;
  5051.  
  5052.  return new_argv;
  5053. }
  5054. EOF
  5055.                 ;;
  5056.             esac
  5057.  
  5058.            cat <<"EOF"
  5059. void lt_dump_script (FILE* f)
  5060. {
  5061. EOF
  5062.             func_emit_wrapper yes |
  5063.               $SED -n -e '
  5064. s/^\(.\{79\}\)\(..*\)/\1\
  5065. \2/
  5066. h
  5067. s/\([\\"]\)/\\\1/g
  5068. s/$/\\n/
  5069. s/\([^\n]*\).*/  fputs ("\1", f);/p
  5070. g
  5071. D'
  5072.            cat <<"EOF"
  5073. }
  5074. EOF
  5075. }
  5076. # end: func_emit_cwrapperexe_src
  5077.  
  5078. # func_win32_import_lib_p ARG
  5079. # True if ARG is an import lib, as indicated by $file_magic_cmd
  5080. func_win32_import_lib_p ()
  5081. {
  5082.    $opt_debug
  5083.    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
  5084.    *import*) : ;;
  5085.    *) false ;;
  5086.    esac
  5087. }
  5088.  
  5089. # func_mode_link arg...
  5090. func_mode_link ()
  5091. {
  5092.    $opt_debug
  5093.    case $host in
  5094.    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
  5095.      # It is impossible to link a dll without this setting, and
  5096.      # we shouldn't force the makefile maintainer to figure out
  5097.      # which system we are compiling for in order to pass an extra
  5098.      # flag for every libtool invocation.
  5099.      # allow_undefined=no
  5100.  
  5101.      # FIXME: Unfortunately, there are problems with the above when trying
  5102.      # to make a dll which has undefined symbols, in which case not
  5103.      # even a static library is built.  For now, we need to specify
  5104.      # -no-undefined on the libtool link line when we can be certain
  5105.      # that all symbols are satisfied, otherwise we get a static library.
  5106.      allow_undefined=yes
  5107.      ;;
  5108.    *)
  5109.      allow_undefined=yes
  5110.      ;;
  5111.    esac
  5112.    libtool_args=$nonopt
  5113.    base_compile="$nonopt $@"
  5114.    compile_command=$nonopt
  5115.    finalize_command=$nonopt
  5116.  
  5117.    compile_rpath=
  5118.    finalize_rpath=
  5119.    compile_shlibpath=
  5120.    finalize_shlibpath=
  5121.    convenience=
  5122.    old_convenience=
  5123.    deplibs=
  5124.    old_deplibs=
  5125.    compiler_flags=
  5126.    linker_flags=
  5127.    dllsearchpath=
  5128.    lib_search_path=`pwd`
  5129.    inst_prefix_dir=
  5130.    new_inherited_linker_flags=
  5131.  
  5132.    avoid_version=no
  5133.    bindir=
  5134.    dlfiles=
  5135.    dlprefiles=
  5136.    dlself=no
  5137.    export_dynamic=no
  5138.    export_symbols=
  5139.    export_symbols_regex=
  5140.    generated=
  5141.    libobjs=
  5142.    ltlibs=
  5143.    module=no
  5144.    no_install=no
  5145.    objs=
  5146.    non_pic_objects=
  5147.    precious_files_regex=
  5148.    prefer_static_libs=no
  5149.    preload=no
  5150.    prev=
  5151.    prevarg=
  5152.    release=
  5153.    rpath=
  5154.    xrpath=
  5155.    perm_rpath=
  5156.    temp_rpath=
  5157.    thread_safe=no
  5158.    vinfo=
  5159.    vinfo_number=no
  5160.    weak_libs=
  5161.    single_module="${wl}-single_module"
  5162.    func_infer_tag $base_compile
  5163.  
  5164.    # We need to know -static, to get the right output filenames.
  5165.    for arg
  5166.    do
  5167.      case $arg in
  5168.      -shared)
  5169.         test "$build_libtool_libs" != yes && \
  5170.           func_fatal_configuration "can not build a shared library"
  5171.         build_old_libs=no
  5172.         break
  5173.         ;;
  5174.      -all-static | -static | -static-libtool-libs)
  5175.         case $arg in
  5176.         -all-static)
  5177.           if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
  5178.             func_warning "complete static linking is impossible in this configuration"
  5179.           fi
  5180.           if test -n "$link_static_flag"; then
  5181.             dlopen_self=$dlopen_self_static
  5182.           fi
  5183.           prefer_static_libs=yes
  5184.           ;;
  5185.         -static)
  5186.           if test -z "$pic_flag" && test -n "$link_static_flag"; then
  5187.             dlopen_self=$dlopen_self_static
  5188.           fi
  5189.           prefer_static_libs=built
  5190.           ;;
  5191.         -static-libtool-libs)
  5192.           if test -z "$pic_flag" && test -n "$link_static_flag"; then
  5193.             dlopen_self=$dlopen_self_static
  5194.           fi
  5195.           prefer_static_libs=yes
  5196.           ;;
  5197.         esac
  5198.         build_libtool_libs=no
  5199.         build_old_libs=yes
  5200.         break
  5201.         ;;
  5202.      esac
  5203.    done
  5204.  
  5205.    # See if our shared archives depend on static archives.
  5206.    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
  5207.  
  5208.    # Go through the arguments, transforming them on the way.
  5209.    while test "$#" -gt 0; do
  5210.      arg="$1"
  5211.      shift
  5212.      func_quote_for_eval "$arg"
  5213.      qarg=$func_quote_for_eval_unquoted_result
  5214.      func_append libtool_args " $func_quote_for_eval_result"
  5215.  
  5216.      # If the previous option needs an argument, assign it.
  5217.      if test -n "$prev"; then
  5218.         case $prev in
  5219.         output)
  5220.           func_append compile_command " @OUTPUT@"
  5221.           func_append finalize_command " @OUTPUT@"
  5222.           ;;
  5223.         esac
  5224.  
  5225.         case $prev in
  5226.         bindir)
  5227.           bindir="$arg"
  5228.           prev=
  5229.           continue
  5230.           ;;
  5231.         dlfiles|dlprefiles)
  5232.           if test "$preload" = no; then
  5233.             # Add the symbol object into the linking commands.
  5234.             func_append compile_command " @SYMFILE@"
  5235.             func_append finalize_command " @SYMFILE@"
  5236.             preload=yes
  5237.           fi
  5238.           case $arg in
  5239.           *.la | *.lo) ;;  # We handle these cases below.
  5240.           force)
  5241.             if test "$dlself" = no; then
  5242.               dlself=needless
  5243.               export_dynamic=yes
  5244.             fi
  5245.             prev=
  5246.             continue
  5247.             ;;
  5248.           self)
  5249.             if test "$prev" = dlprefiles; then
  5250.               dlself=yes
  5251.             elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
  5252.               dlself=yes
  5253.             else
  5254.               dlself=needless
  5255.               export_dynamic=yes
  5256.             fi
  5257.             prev=
  5258.             continue
  5259.             ;;
  5260.           *)
  5261.             if test "$prev" = dlfiles; then
  5262.               func_append dlfiles " $arg"
  5263.             else
  5264.               func_append dlprefiles " $arg"
  5265.             fi
  5266.             prev=
  5267.             continue
  5268.             ;;
  5269.           esac
  5270.           ;;
  5271.         expsyms)
  5272.           export_symbols="$arg"
  5273.           test -f "$arg" \
  5274.             || func_fatal_error "symbol file \`$arg' does not exist"
  5275.           prev=
  5276.           continue
  5277.           ;;
  5278.         expsyms_regex)
  5279.           export_symbols_regex="$arg"
  5280.           prev=
  5281.           continue
  5282.           ;;
  5283.         framework)
  5284.           case $host in
  5285.             *-*-darwin*)
  5286.               case "$deplibs " in
  5287.                 *" $qarg.ltframework "*) ;;
  5288.                 *) func_append deplibs " $qarg.ltframework" # this is fixed later
  5289.                    ;;
  5290.               esac
  5291.               ;;
  5292.           esac
  5293.           prev=
  5294.           continue
  5295.           ;;
  5296.         inst_prefix)
  5297.           inst_prefix_dir="$arg"
  5298.           prev=
  5299.           continue
  5300.           ;;
  5301.         objectlist)
  5302.           if test -f "$arg"; then
  5303.             save_arg=$arg
  5304.             moreargs=
  5305.             for fil in `cat "$save_arg"`
  5306.             do
  5307. #             func_append moreargs " $fil"
  5308.               arg=$fil
  5309.               # A libtool-controlled object.
  5310.  
  5311.               # Check to see that this really is a libtool object.
  5312.               if func_lalib_unsafe_p "$arg"; then
  5313.                 pic_object=
  5314.                 non_pic_object=
  5315.  
  5316.                 # Read the .lo file
  5317.                 func_source "$arg"
  5318.  
  5319.                 if test -z "$pic_object" ||
  5320.                    test -z "$non_pic_object" ||
  5321.                    test "$pic_object" = none &&
  5322.                    test "$non_pic_object" = none; then
  5323.                   func_fatal_error "cannot find name of object for \`$arg'"
  5324.                 fi
  5325.  
  5326.                 # Extract subdirectory from the argument.
  5327.                 func_dirname "$arg" "/" ""
  5328.                 xdir="$func_dirname_result"
  5329.  
  5330.                 if test "$pic_object" != none; then
  5331.                   # Prepend the subdirectory the object is found in.
  5332.                   pic_object="$xdir$pic_object"
  5333.  
  5334.                   if test "$prev" = dlfiles; then
  5335.                     if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
  5336.                       func_append dlfiles " $pic_object"
  5337.                       prev=
  5338.                       continue
  5339.                     else
  5340.                       # If libtool objects are unsupported, then we need to preload.
  5341.                       prev=dlprefiles
  5342.                     fi
  5343.                   fi
  5344.  
  5345.                   # CHECK ME:  I think I busted this.  -Ossama
  5346.                   if test "$prev" = dlprefiles; then
  5347.                     # Preload the old-style object.
  5348.                     func_append dlprefiles " $pic_object"
  5349.                     prev=
  5350.                   fi
  5351.  
  5352.                   # A PIC object.
  5353.                   func_append libobjs " $pic_object"
  5354.                   arg="$pic_object"
  5355.                 fi
  5356.  
  5357.                 # Non-PIC object.
  5358.                 if test "$non_pic_object" != none; then
  5359.                   # Prepend the subdirectory the object is found in.
  5360.                   non_pic_object="$xdir$non_pic_object"
  5361.  
  5362.                   # A standard non-PIC object
  5363.                   func_append non_pic_objects " $non_pic_object"
  5364.                   if test -z "$pic_object" || test "$pic_object" = none ; then
  5365.                     arg="$non_pic_object"
  5366.                   fi
  5367.                 else
  5368.                   # If the PIC object exists, use it instead.
  5369.                   # $xdir was prepended to $pic_object above.
  5370.                   non_pic_object="$pic_object"
  5371.                   func_append non_pic_objects " $non_pic_object"
  5372.                 fi
  5373.               else
  5374.                 # Only an error if not doing a dry-run.
  5375.                 if $opt_dry_run; then
  5376.                   # Extract subdirectory from the argument.
  5377.                   func_dirname "$arg" "/" ""
  5378.                   xdir="$func_dirname_result"
  5379.  
  5380.                   func_lo2o "$arg"
  5381.                   pic_object=$xdir$objdir/$func_lo2o_result
  5382.                   non_pic_object=$xdir$func_lo2o_result
  5383.                   func_append libobjs " $pic_object"
  5384.                   func_append non_pic_objects " $non_pic_object"
  5385.                 else
  5386.                   func_fatal_error "\`$arg' is not a valid libtool object"
  5387.                 fi
  5388.               fi
  5389.             done
  5390.           else
  5391.             func_fatal_error "link input file \`$arg' does not exist"
  5392.           fi
  5393.           arg=$save_arg
  5394.           prev=
  5395.           continue
  5396.           ;;
  5397.         precious_regex)
  5398.           precious_files_regex="$arg"
  5399.           prev=
  5400.           continue
  5401.           ;;
  5402.         release)
  5403.           release="-$arg"
  5404.           prev=
  5405.           continue
  5406.           ;;
  5407.         rpath | xrpath)
  5408.           # We need an absolute path.
  5409.           case $arg in
  5410.           [\\/]* | [A-Za-z]:[\\/]*) ;;
  5411.           *)
  5412.             func_fatal_error "only absolute run-paths are allowed"
  5413.             ;;
  5414.           esac
  5415.           if test "$prev" = rpath; then
  5416.             case "$rpath " in
  5417.             *" $arg "*) ;;
  5418.             *) func_append rpath " $arg" ;;
  5419.             esac
  5420.           else
  5421.             case "$xrpath " in
  5422.             *" $arg "*) ;;
  5423.             *) func_append xrpath " $arg" ;;
  5424.             esac
  5425.           fi
  5426.           prev=
  5427.           continue
  5428.           ;;
  5429.         shrext)
  5430.           shrext_cmds="$arg"
  5431.           prev=
  5432.           continue
  5433.           ;;
  5434.         weak)
  5435.           func_append weak_libs " $arg"
  5436.           prev=
  5437.           continue
  5438.           ;;
  5439.         xcclinker)
  5440.           func_append linker_flags " $qarg"
  5441.           func_append compiler_flags " $qarg"
  5442.           prev=
  5443.           func_append compile_command " $qarg"
  5444.           func_append finalize_command " $qarg"
  5445.           continue
  5446.           ;;
  5447.         xcompiler)
  5448.           func_append compiler_flags " $qarg"
  5449.           prev=
  5450.           func_append compile_command " $qarg"
  5451.           func_append finalize_command " $qarg"
  5452.           continue
  5453.           ;;
  5454.         xlinker)
  5455.           func_append linker_flags " $qarg"
  5456.           func_append compiler_flags " $wl$qarg"
  5457.           prev=
  5458.           func_append compile_command " $wl$qarg"
  5459.           func_append finalize_command " $wl$qarg"
  5460.           continue
  5461.           ;;
  5462.         *)
  5463.           eval "$prev=\"\$arg\""
  5464.           prev=
  5465.           continue
  5466.           ;;
  5467.         esac
  5468.      fi # test -n "$prev"
  5469.  
  5470.      prevarg="$arg"
  5471.  
  5472.      case $arg in
  5473.      -all-static)
  5474.         if test -n "$link_static_flag"; then
  5475.           # See comment for -static flag below, for more details.
  5476.           func_append compile_command " $link_static_flag"
  5477.           func_append finalize_command " $link_static_flag"
  5478.         fi
  5479.         continue
  5480.         ;;
  5481.  
  5482.      -allow-undefined)
  5483.         # FIXME: remove this flag sometime in the future.
  5484.         func_fatal_error "\`-allow-undefined' must not be used because it is the default"
  5485.         ;;
  5486.  
  5487.       -avoid-version)
  5488.         avoid_version=yes
  5489.         continue
  5490.         ;;
  5491.  
  5492.       -bindir)
  5493.         prev=bindir
  5494.         continue
  5495.         ;;
  5496.  
  5497.       -dlopen)
  5498.         prev=dlfiles
  5499.         continue
  5500.         ;;
  5501.  
  5502.       -dlpreopen)
  5503.         prev=dlprefiles
  5504.         continue
  5505.         ;;
  5506.  
  5507.       -export-dynamic)
  5508.         export_dynamic=yes
  5509.         continue
  5510.         ;;
  5511.  
  5512.       -export-symbols | -export-symbols-regex)
  5513.         if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
  5514.           func_fatal_error "more than one -exported-symbols argument is not allowed"
  5515.         fi
  5516.         if test "X$arg" = "X-export-symbols"; then
  5517.           prev=expsyms
  5518.         else
  5519.           prev=expsyms_regex
  5520.         fi
  5521.         continue
  5522.         ;;
  5523.  
  5524.       -framework)
  5525.         prev=framework
  5526.         continue
  5527.         ;;
  5528.  
  5529.       -inst-prefix-dir)
  5530.         prev=inst_prefix
  5531.         continue
  5532.         ;;
  5533.  
  5534.       # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
  5535.       # so, if we see these flags be careful not to treat them like -L
  5536.       -L[A-Z][A-Z]*:*)
  5537.         case $with_gcc/$host in
  5538.         no/*-*-irix* | /*-*-irix*)
  5539.           func_append compile_command " $arg"
  5540.           func_append finalize_command " $arg"
  5541.           ;;
  5542.         esac
  5543.         continue
  5544.         ;;
  5545.  
  5546.       -L*)
  5547.         func_stripname "-L" '' "$arg"
  5548.         if test -z "$func_stripname_result"; then
  5549.           if test "$#" -gt 0; then
  5550.             func_fatal_error "require no space between \`-L' and \`$1'"
  5551.           else
  5552.             func_fatal_error "need path for \`-L' option"
  5553.           fi
  5554.         fi
  5555.         func_resolve_sysroot "$func_stripname_result"
  5556.         dir=$func_resolve_sysroot_result
  5557.         # We need an absolute path.
  5558.         case $dir in
  5559.         [\\/]* | [A-Za-z]:[\\/]*) ;;
  5560.         *)
  5561.           absdir=`cd "$dir" && pwd`
  5562.           test -z "$absdir" && \
  5563.             func_fatal_error "cannot determine absolute directory name of \`$dir'"
  5564.           dir="$absdir"
  5565.           ;;
  5566.         esac
  5567.         case "$deplibs " in
  5568.         *" -L$dir "* | *" $arg "*)
  5569.           # Will only happen for absolute or sysroot arguments
  5570.           ;;
  5571.         *)
  5572.           # Preserve sysroot, but never include relative directories
  5573.           case $dir in
  5574.             [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
  5575.             *) func_append deplibs " -L$dir" ;;
  5576.           esac
  5577.           func_append lib_search_path " $dir"
  5578.           ;;
  5579.         esac
  5580.         case $host in
  5581.         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
  5582.           testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
  5583.           case :$dllsearchpath: in
  5584.           *":$dir:"*) ;;
  5585.           ::) dllsearchpath=$dir;;
  5586.           *) func_append dllsearchpath ":$dir";;
  5587.           esac
  5588.           case :$dllsearchpath: in
  5589.           *":$testbindir:"*) ;;
  5590.           ::) dllsearchpath=$testbindir;;
  5591.           *) func_append dllsearchpath ":$testbindir";;
  5592.           esac
  5593.           ;;
  5594.         esac
  5595.         continue
  5596.         ;;
  5597.  
  5598.       -l*)
  5599.         if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
  5600.           case $host in
  5601.           *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
  5602.             # These systems don't actually have a C or math library (as such)
  5603.             continue
  5604.             ;;
  5605.           *-*-os2*)
  5606.             # These systems don't actually have a C library (as such)
  5607.             test "X$arg" = "X-lc" && continue
  5608.             ;;
  5609.           *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
  5610.             # Do not include libc due to us having libc/libc_r.
  5611.             test "X$arg" = "X-lc" && continue
  5612.             ;;
  5613.           *-*-rhapsody* | *-*-darwin1.[012])
  5614.             # Rhapsody C and math libraries are in the System framework
  5615.             func_append deplibs " System.ltframework"
  5616.             continue
  5617.             ;;
  5618.           *-*-sco3.2v5* | *-*-sco5v6*)
  5619.             # Causes problems with __ctype
  5620.             test "X$arg" = "X-lc" && continue
  5621.             ;;
  5622.           *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
  5623.             # Compiler inserts libc in the correct place for threads to work
  5624.             test "X$arg" = "X-lc" && continue
  5625.             ;;
  5626.           esac
  5627.         elif test "X$arg" = "X-lc_r"; then
  5628.          case $host in
  5629.          *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
  5630.            # Do not include libc_r directly, use -pthread flag.
  5631.            continue
  5632.            ;;
  5633.          esac
  5634.         fi
  5635.         func_append deplibs " $arg"
  5636.         continue
  5637.         ;;
  5638.  
  5639.       -module)
  5640.         module=yes
  5641.         continue
  5642.         ;;
  5643.  
  5644.       # Tru64 UNIX uses -model [arg] to determine the layout of C++
  5645.       # classes, name mangling, and exception handling.
  5646.       # Darwin uses the -arch flag to determine output architecture.
  5647.       -model|-arch|-isysroot|--sysroot)
  5648.         func_append compiler_flags " $arg"
  5649.         func_append compile_command " $arg"
  5650.         func_append finalize_command " $arg"
  5651.         prev=xcompiler
  5652.         continue
  5653.         ;;
  5654.  
  5655.       -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
  5656.       |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
  5657.         func_append compiler_flags " $arg"
  5658.         func_append compile_command " $arg"
  5659.         func_append finalize_command " $arg"
  5660.         case "$new_inherited_linker_flags " in
  5661.             *" $arg "*) ;;
  5662.             * ) func_append new_inherited_linker_flags " $arg" ;;
  5663.         esac
  5664.         continue
  5665.         ;;
  5666.  
  5667.       -multi_module)
  5668.         single_module="${wl}-multi_module"
  5669.         continue
  5670.         ;;
  5671.  
  5672.       -no-fast-install)
  5673.         fast_install=no
  5674.         continue
  5675.         ;;
  5676.  
  5677.       -no-install)
  5678.         case $host in
  5679.         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
  5680.           # The PATH hackery in wrapper scripts is required on Windows
  5681.           # and Darwin in order for the loader to find any dlls it needs.
  5682.           func_warning "\`-no-install' is ignored for $host"
  5683.           func_warning "assuming \`-no-fast-install' instead"
  5684.           fast_install=no
  5685.           ;;
  5686.         *) no_install=yes ;;
  5687.         esac
  5688.         continue
  5689.         ;;
  5690.  
  5691.       -no-undefined)
  5692.         allow_undefined=no
  5693.         continue
  5694.         ;;
  5695.  
  5696.       -objectlist)
  5697.         prev=objectlist
  5698.         continue
  5699.         ;;
  5700.  
  5701.       -o) prev=output ;;
  5702.  
  5703.       -precious-files-regex)
  5704.         prev=precious_regex
  5705.         continue
  5706.         ;;
  5707.  
  5708.       -release)
  5709.         prev=release
  5710.         continue
  5711.         ;;
  5712.  
  5713.       -rpath)
  5714.         prev=rpath
  5715.         continue
  5716.         ;;
  5717.  
  5718.       -R)
  5719.         prev=xrpath
  5720.         continue
  5721.         ;;
  5722.  
  5723.       -R*)
  5724.         func_stripname '-R' '' "$arg"
  5725.         dir=$func_stripname_result
  5726.         # We need an absolute path.
  5727.         case $dir in
  5728.         [\\/]* | [A-Za-z]:[\\/]*) ;;
  5729.         =*)
  5730.           func_stripname '=' '' "$dir"
  5731.           dir=$lt_sysroot$func_stripname_result
  5732.           ;;
  5733.         *)
  5734.           func_fatal_error "only absolute run-paths are allowed"
  5735.           ;;
  5736.         esac
  5737.         case "$xrpath " in
  5738.         *" $dir "*) ;;
  5739.         *) func_append xrpath " $dir" ;;
  5740.         esac
  5741.         continue
  5742.         ;;
  5743.  
  5744.       -shared)
  5745.         # The effects of -shared are defined in a previous loop.
  5746.         continue
  5747.         ;;
  5748.  
  5749.       -shrext)
  5750.         prev=shrext
  5751.         continue
  5752.         ;;
  5753.  
  5754.       -static | -static-libtool-libs)
  5755.         # The effects of -static are defined in a previous loop.
  5756.         # We used to do the same as -all-static on platforms that
  5757.         # didn't have a PIC flag, but the assumption that the effects
  5758.         # would be equivalent was wrong.  It would break on at least
  5759.         # Digital Unix and AIX.
  5760.         continue
  5761.         ;;
  5762.  
  5763.       -thread-safe)
  5764.         thread_safe=yes
  5765.         continue
  5766.         ;;
  5767.  
  5768.       -version-info)
  5769.         prev=vinfo
  5770.         continue
  5771.         ;;
  5772.  
  5773.       -version-number)
  5774.         prev=vinfo
  5775.         vinfo_number=yes
  5776.         continue
  5777.         ;;
  5778.  
  5779.       -weak)
  5780.         prev=weak
  5781.         continue
  5782.         ;;
  5783.  
  5784.       -Wc,*)
  5785.         func_stripname '-Wc,' '' "$arg"
  5786.         args=$func_stripname_result
  5787.         arg=
  5788.         save_ifs="$IFS"; IFS=','
  5789.         for flag in $args; do
  5790.           IFS="$save_ifs"
  5791.           func_quote_for_eval "$flag"
  5792.           func_append arg " $func_quote_for_eval_result"
  5793.           func_append compiler_flags " $func_quote_for_eval_result"
  5794.         done
  5795.         IFS="$save_ifs"
  5796.         func_stripname ' ' '' "$arg"
  5797.         arg=$func_stripname_result
  5798.         ;;
  5799.  
  5800.       -Wl,*)
  5801.         func_stripname '-Wl,' '' "$arg"
  5802.         args=$func_stripname_result
  5803.         arg=
  5804.         save_ifs="$IFS"; IFS=','
  5805.         for flag in $args; do
  5806.           IFS="$save_ifs"
  5807.           func_quote_for_eval "$flag"
  5808.           func_append arg " $wl$func_quote_for_eval_result"
  5809.           func_append compiler_flags " $wl$func_quote_for_eval_result"
  5810.           func_append linker_flags " $func_quote_for_eval_result"
  5811.         done
  5812.         IFS="$save_ifs"
  5813.         func_stripname ' ' '' "$arg"
  5814.         arg=$func_stripname_result
  5815.         ;;
  5816.  
  5817.       -Xcompiler)
  5818.         prev=xcompiler
  5819.         continue
  5820.         ;;
  5821.  
  5822.       -Xlinker)
  5823.         prev=xlinker
  5824.         continue
  5825.         ;;
  5826.  
  5827.       -XCClinker)
  5828.         prev=xcclinker
  5829.         continue
  5830.         ;;
  5831.  
  5832.       # -msg_* for osf cc
  5833.       -msg_*)
  5834.         func_quote_for_eval "$arg"
  5835.         arg="$func_quote_for_eval_result"
  5836.         ;;
  5837.  
  5838.       # Flags to be passed through unchanged, with rationale:
  5839.       # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
  5840.       # -r[0-9][0-9]*        specify processor for the SGI compiler
  5841.       # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
  5842.       # +DA*, +DD*           enable 64-bit mode for the HP compiler
  5843.       # -q*                  compiler args for the IBM compiler
  5844.       # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
  5845.       # -F/path              path to uninstalled frameworks, gcc on darwin
  5846.       # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
  5847.       # @file                GCC response files
  5848.       # -tp=*                Portland pgcc target processor selection
  5849.       # --sysroot=*          for sysroot support
  5850.       # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
  5851.       -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
  5852.       -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
  5853.       -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
  5854.         func_quote_for_eval "$arg"
  5855.         arg="$func_quote_for_eval_result"
  5856.         func_append compile_command " $arg"
  5857.         func_append finalize_command " $arg"
  5858.         func_append compiler_flags " $arg"
  5859.         continue
  5860.         ;;
  5861.  
  5862.       # Some other compiler flag.
  5863.       -* | +*)
  5864.         func_quote_for_eval "$arg"
  5865.         arg="$func_quote_for_eval_result"
  5866.         ;;
  5867.  
  5868.       *.$objext)
  5869.         # A standard object.
  5870.         func_append objs " $arg"
  5871.         ;;
  5872.  
  5873.       *.lo)
  5874.         # A libtool-controlled object.
  5875.  
  5876.         # Check to see that this really is a libtool object.
  5877.         if func_lalib_unsafe_p "$arg"; then
  5878.           pic_object=
  5879.           non_pic_object=
  5880.  
  5881.           # Read the .lo file
  5882.           func_source "$arg"
  5883.  
  5884.           if test -z "$pic_object" ||
  5885.              test -z "$non_pic_object" ||
  5886.              test "$pic_object" = none &&
  5887.              test "$non_pic_object" = none; then
  5888.             func_fatal_error "cannot find name of object for \`$arg'"
  5889.           fi
  5890.  
  5891.           # Extract subdirectory from the argument.
  5892.           func_dirname "$arg" "/" ""
  5893.           xdir="$func_dirname_result"
  5894.  
  5895.           if test "$pic_object" != none; then
  5896.             # Prepend the subdirectory the object is found in.
  5897.             pic_object="$xdir$pic_object"
  5898.  
  5899.             if test "$prev" = dlfiles; then
  5900.               if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
  5901.                 func_append dlfiles " $pic_object"
  5902.                 prev=
  5903.                 continue
  5904.               else
  5905.                 # If libtool objects are unsupported, then we need to preload.
  5906.                 prev=dlprefiles
  5907.               fi
  5908.             fi
  5909.  
  5910.             # CHECK ME:  I think I busted this.  -Ossama
  5911.             if test "$prev" = dlprefiles; then
  5912.               # Preload the old-style object.
  5913.               func_append dlprefiles " $pic_object"
  5914.               prev=
  5915.             fi
  5916.  
  5917.             # A PIC object.
  5918.             func_append libobjs " $pic_object"
  5919.             arg="$pic_object"
  5920.           fi
  5921.  
  5922.           # Non-PIC object.
  5923.           if test "$non_pic_object" != none; then
  5924.             # Prepend the subdirectory the object is found in.
  5925.             non_pic_object="$xdir$non_pic_object"
  5926.  
  5927.             # A standard non-PIC object
  5928.             func_append non_pic_objects " $non_pic_object"
  5929.             if test -z "$pic_object" || test "$pic_object" = none ; then
  5930.               arg="$non_pic_object"
  5931.             fi
  5932.           else
  5933.             # If the PIC object exists, use it instead.
  5934.             # $xdir was prepended to $pic_object above.
  5935.             non_pic_object="$pic_object"
  5936.             func_append non_pic_objects " $non_pic_object"
  5937.           fi
  5938.         else
  5939.           # Only an error if not doing a dry-run.
  5940.           if $opt_dry_run; then
  5941.             # Extract subdirectory from the argument.
  5942.             func_dirname "$arg" "/" ""
  5943.             xdir="$func_dirname_result"
  5944.  
  5945.             func_lo2o "$arg"
  5946.             pic_object=$xdir$objdir/$func_lo2o_result
  5947.             non_pic_object=$xdir$func_lo2o_result
  5948.             func_append libobjs " $pic_object"
  5949.             func_append non_pic_objects " $non_pic_object"
  5950.           else
  5951.             func_fatal_error "\`$arg' is not a valid libtool object"
  5952.           fi
  5953.         fi
  5954.         ;;
  5955.  
  5956.       *.$libext)
  5957.         # An archive.
  5958.         func_append deplibs " $arg"
  5959.         func_append old_deplibs " $arg"
  5960.         continue
  5961.         ;;
  5962.  
  5963.       *.la)
  5964.         # A libtool-controlled library.
  5965.  
  5966.         func_resolve_sysroot "$arg"
  5967.         if test "$prev" = dlfiles; then
  5968.           # This library was specified with -dlopen.
  5969.           func_append dlfiles " $func_resolve_sysroot_result"
  5970.           prev=
  5971.         elif test "$prev" = dlprefiles; then
  5972.           # The library was specified with -dlpreopen.
  5973.           func_append dlprefiles " $func_resolve_sysroot_result"
  5974.           prev=
  5975.         else
  5976.           func_append deplibs " $func_resolve_sysroot_result"
  5977.         fi
  5978.         continue
  5979.         ;;
  5980.  
  5981.       # Some other compiler argument.
  5982.       *)
  5983.         # Unknown arguments in both finalize_command and compile_command need
  5984.         # to be aesthetically quoted because they are evaled later.
  5985.         func_quote_for_eval "$arg"
  5986.         arg="$func_quote_for_eval_result"
  5987.         ;;
  5988.       esac # arg
  5989.  
  5990.       # Now actually substitute the argument into the commands.
  5991.       if test -n "$arg"; then
  5992.         func_append compile_command " $arg"
  5993.         func_append finalize_command " $arg"
  5994.       fi
  5995.     done # argument parsing loop
  5996.  
  5997.     test -n "$prev" && \
  5998.       func_fatal_help "the \`$prevarg' option requires an argument"
  5999.  
  6000.    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
  6001.      eval arg=\"$export_dynamic_flag_spec\"
  6002.      func_append compile_command " $arg"
  6003.      func_append finalize_command " $arg"
  6004.    fi
  6005.  
  6006.    oldlibs=
  6007.    # calculate the name of the file, without its directory
  6008.    func_basename "$output"
  6009.    outputname="$func_basename_result"
  6010.    libobjs_save="$libobjs"
  6011.  
  6012.    if test -n "$shlibpath_var"; then
  6013.      # get the directories listed in $shlibpath_var
  6014.      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
  6015.    else
  6016.      shlib_search_path=
  6017.    fi
  6018.    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
  6019.    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
  6020.  
  6021.    func_dirname "$output" "/" ""
  6022.    output_objdir="$func_dirname_result$objdir"
  6023.    func_to_tool_file "$output_objdir/"
  6024.    tool_output_objdir=$func_to_tool_file_result
  6025.    # Create the object directory.
  6026.    func_mkdir_p "$output_objdir"
  6027.  
  6028.    # Determine the type of output
  6029.    case $output in
  6030.    "")
  6031.      func_fatal_help "you must specify an output file"
  6032.      ;;
  6033.    *.$libext) linkmode=oldlib ;;
  6034.    *.lo | *.$objext) linkmode=obj ;;
  6035.    *.la) linkmode=lib ;;
  6036.    *) linkmode=prog ;; # Anything else should be a program.
  6037.    esac
  6038.  
  6039.    specialdeplibs=
  6040.  
  6041.    libs=
  6042.    # Find all interdependent deplibs by searching for libraries
  6043.    # that are linked more than once (e.g. -la -lb -la)
  6044.    for deplib in $deplibs; do
  6045.      if $opt_preserve_dup_deps ; then
  6046.         case "$libs " in
  6047.         *" $deplib "*) func_append specialdeplibs " $deplib" ;;
  6048.         esac
  6049.      fi
  6050.      func_append libs " $deplib"
  6051.    done
  6052.  
  6053.    if test "$linkmode" = lib; then
  6054.      libs="$predeps $libs $compiler_lib_search_path $postdeps"
  6055.  
  6056.      # Compute libraries that are listed more than once in $predeps
  6057.      # $postdeps and mark them as special (i.e., whose duplicates are
  6058.      # not to be eliminated).
  6059.      pre_post_deps=
  6060.      if $opt_duplicate_compiler_generated_deps; then
  6061.         for pre_post_dep in $predeps $postdeps; do
  6062.           case "$pre_post_deps " in
  6063.           *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
  6064.           esac
  6065.           func_append pre_post_deps " $pre_post_dep"
  6066.         done
  6067.      fi
  6068.      pre_post_deps=
  6069.    fi
  6070.  
  6071.    deplibs=
  6072.    newdependency_libs=
  6073.    newlib_search_path=
  6074.    need_relink=no # whether we're linking any uninstalled libtool libraries
  6075.    notinst_deplibs= # not-installed libtool libraries
  6076.    notinst_path= # paths that contain not-installed libtool libraries
  6077.  
  6078.    case $linkmode in
  6079.    lib)
  6080.         passes="conv dlpreopen link"
  6081.         for file in $dlfiles $dlprefiles; do
  6082.           case $file in
  6083.           *.la) ;;
  6084.           *)
  6085.             func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
  6086.             ;;
  6087.           esac
  6088.         done
  6089.         ;;
  6090.     prog)
  6091.         compile_deplibs=
  6092.         finalize_deplibs=
  6093.         alldeplibs=no
  6094.         newdlfiles=
  6095.         newdlprefiles=
  6096.         passes="conv scan dlopen dlpreopen link"
  6097.         ;;
  6098.     *)  passes="conv"
  6099.         ;;
  6100.     esac
  6101.  
  6102.     for pass in $passes; do
  6103.       # The preopen pass in lib mode reverses $deplibs; put it back here
  6104.       # so that -L comes before libs that need it for instance...
  6105.       if test "$linkmode,$pass" = "lib,link"; then
  6106.         ## FIXME: Find the place where the list is rebuilt in the wrong
  6107.         ##        order, and fix it there properly
  6108.         tmp_deplibs=
  6109.         for deplib in $deplibs; do
  6110.           tmp_deplibs="$deplib $tmp_deplibs"
  6111.         done
  6112.         deplibs="$tmp_deplibs"
  6113.       fi
  6114.  
  6115.       if test "$linkmode,$pass" = "lib,link" ||
  6116.          test "$linkmode,$pass" = "prog,scan"; then
  6117.         libs="$deplibs"
  6118.         deplibs=
  6119.       fi
  6120.       if test "$linkmode" = prog; then
  6121.         case $pass in
  6122.         dlopen) libs="$dlfiles" ;;
  6123.         dlpreopen) libs="$dlprefiles" ;;
  6124.         link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
  6125.         esac
  6126.       fi
  6127.       if test "$linkmode,$pass" = "lib,dlpreopen"; then
  6128.         # Collect and forward deplibs of preopened libtool libs
  6129.         for lib in $dlprefiles; do
  6130.           # Ignore non-libtool-libs
  6131.           dependency_libs=
  6132.           func_resolve_sysroot "$lib"
  6133.           case $lib in
  6134.           *.la) func_source "$func_resolve_sysroot_result" ;;
  6135.           esac
  6136.  
  6137.           # Collect preopened libtool deplibs, except any this library
  6138.           # has declared as weak libs
  6139.           for deplib in $dependency_libs; do
  6140.             func_basename "$deplib"
  6141.             deplib_base=$func_basename_result
  6142.             case " $weak_libs " in
  6143.             *" $deplib_base "*) ;;
  6144.             *) func_append deplibs " $deplib" ;;
  6145.             esac
  6146.           done
  6147.         done
  6148.         libs="$dlprefiles"
  6149.       fi
  6150.       if test "$pass" = dlopen; then
  6151.         # Collect dlpreopened libraries
  6152.         save_deplibs="$deplibs"
  6153.         deplibs=
  6154.       fi
  6155.  
  6156.       for deplib in $libs; do
  6157.         lib=
  6158.         found=no
  6159.         case $deplib in
  6160.         -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
  6161.         |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
  6162.           if test "$linkmode,$pass" = "prog,link"; then
  6163.             compile_deplibs="$deplib $compile_deplibs"
  6164.             finalize_deplibs="$deplib $finalize_deplibs"
  6165.           else
  6166.             func_append compiler_flags " $deplib"
  6167.             if test "$linkmode" = lib ; then
  6168.                 case "$new_inherited_linker_flags " in
  6169.                     *" $deplib "*) ;;
  6170.                     * ) func_append new_inherited_linker_flags " $deplib" ;;
  6171.                 esac
  6172.             fi
  6173.           fi
  6174.           continue
  6175.           ;;
  6176.         -l*)
  6177.           if test "$linkmode" != lib && test "$linkmode" != prog; then
  6178.             func_warning "\`-l' is ignored for archives/objects"
  6179.             continue
  6180.           fi
  6181.           func_stripname '-l' '' "$deplib"
  6182.           name=$func_stripname_result
  6183.           if test "$linkmode" = lib; then
  6184.             searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
  6185.           else
  6186.             searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
  6187.           fi
  6188.           for searchdir in $searchdirs; do
  6189.             for search_ext in .la $std_shrext .so .a; do
  6190.               # Search the libtool library
  6191.               lib="$searchdir/lib${name}${search_ext}"
  6192.               if test -f "$lib"; then
  6193.                 if test "$search_ext" = ".la"; then
  6194.                   found=yes
  6195.                 else
  6196.                   found=no
  6197.                 fi
  6198.                 break 2
  6199.               fi
  6200.             done
  6201.           done
  6202.           if test "$found" != yes; then
  6203.             # deplib doesn't seem to be a libtool library
  6204.             if test "$linkmode,$pass" = "prog,link"; then
  6205.               compile_deplibs="$deplib $compile_deplibs"
  6206.               finalize_deplibs="$deplib $finalize_deplibs"
  6207.             else
  6208.               deplibs="$deplib $deplibs"
  6209.               test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
  6210.             fi
  6211.             continue
  6212.           else # deplib is a libtool library
  6213.             # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
  6214.             # We need to do some special things here, and not later.
  6215.             if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
  6216.               case " $predeps $postdeps " in
  6217.               *" $deplib "*)
  6218.                 if func_lalib_p "$lib"; then
  6219.                   library_names=
  6220.                   old_library=
  6221.                   func_source "$lib"
  6222.                   for l in $old_library $library_names; do
  6223.                     ll="$l"
  6224.                   done
  6225.                   if test "X$ll" = "X$old_library" ; then # only static version available
  6226.                     found=no
  6227.                     func_dirname "$lib" "" "."
  6228.                     ladir="$func_dirname_result"
  6229.                     lib=$ladir/$old_library
  6230.                     if test "$linkmode,$pass" = "prog,link"; then
  6231.                       compile_deplibs="$deplib $compile_deplibs"
  6232.                       finalize_deplibs="$deplib $finalize_deplibs"
  6233.                     else
  6234.                       deplibs="$deplib $deplibs"
  6235.                       test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
  6236.                     fi
  6237.                     continue
  6238.                   fi
  6239.                 fi
  6240.                 ;;
  6241.               *) ;;
  6242.               esac
  6243.             fi
  6244.           fi
  6245.           ;; # -l
  6246.         *.ltframework)
  6247.           if test "$linkmode,$pass" = "prog,link"; then
  6248.             compile_deplibs="$deplib $compile_deplibs"
  6249.             finalize_deplibs="$deplib $finalize_deplibs"
  6250.           else
  6251.             deplibs="$deplib $deplibs"
  6252.             if test "$linkmode" = lib ; then
  6253.                 case "$new_inherited_linker_flags " in
  6254.                     *" $deplib "*) ;;
  6255.                     * ) func_append new_inherited_linker_flags " $deplib" ;;
  6256.                 esac
  6257.             fi
  6258.           fi
  6259.           continue
  6260.           ;;
  6261.         -L*)
  6262.           case $linkmode in
  6263.           lib)
  6264.             deplibs="$deplib $deplibs"
  6265.             test "$pass" = conv && continue
  6266.             newdependency_libs="$deplib $newdependency_libs"
  6267.             func_stripname '-L' '' "$deplib"
  6268.             func_resolve_sysroot "$func_stripname_result"
  6269.             func_append newlib_search_path " $func_resolve_sysroot_result"
  6270.             ;;
  6271.           prog)
  6272.             if test "$pass" = conv; then
  6273.               deplibs="$deplib $deplibs"
  6274.               continue
  6275.             fi
  6276.             if test "$pass" = scan; then
  6277.               deplibs="$deplib $deplibs"
  6278.             else
  6279.               compile_deplibs="$deplib $compile_deplibs"
  6280.               finalize_deplibs="$deplib $finalize_deplibs"
  6281.             fi
  6282.             func_stripname '-L' '' "$deplib"
  6283.             func_resolve_sysroot "$func_stripname_result"
  6284.             func_append newlib_search_path " $func_resolve_sysroot_result"
  6285.             ;;
  6286.           *)
  6287.             func_warning "\`-L' is ignored for archives/objects"
  6288.             ;;
  6289.           esac # linkmode
  6290.           continue
  6291.           ;; # -L
  6292.         -R*)
  6293.           if test "$pass" = link; then
  6294.             func_stripname '-R' '' "$deplib"
  6295.             func_resolve_sysroot "$func_stripname_result"
  6296.             dir=$func_resolve_sysroot_result
  6297.             # Make sure the xrpath contains only unique directories.
  6298.             case "$xrpath " in
  6299.             *" $dir "*) ;;
  6300.             *) func_append xrpath " $dir" ;;
  6301.             esac
  6302.           fi
  6303.           deplibs="$deplib $deplibs"
  6304.           continue
  6305.           ;;
  6306.         *.la)
  6307.           func_resolve_sysroot "$deplib"
  6308.           lib=$func_resolve_sysroot_result
  6309.           ;;
  6310.         *.$libext)
  6311.           if test "$pass" = conv; then
  6312.             deplibs="$deplib $deplibs"
  6313.             continue
  6314.           fi
  6315.           case $linkmode in
  6316.           lib)
  6317.             # Linking convenience modules into shared libraries is allowed,
  6318.             # but linking other static libraries is non-portable.
  6319.             case " $dlpreconveniencelibs " in
  6320.             *" $deplib "*) ;;
  6321.             *)
  6322.               valid_a_lib=no
  6323.               case $deplibs_check_method in
  6324.                 match_pattern*)
  6325.                   set dummy $deplibs_check_method; shift
  6326.                   match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
  6327.                   if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
  6328.                     | $EGREP "$match_pattern_regex" > /dev/null; then
  6329.                     valid_a_lib=yes
  6330.                   fi
  6331.                 ;;
  6332.                 pass_all)
  6333.                   valid_a_lib=yes
  6334.                 ;;
  6335.               esac
  6336.               if test "$valid_a_lib" != yes; then
  6337.                 echo
  6338.                 $ECHO "*** Warning: Trying to link with static lib archive $deplib."
  6339.                 echo "*** I have the capability to make that library automatically link in when"
  6340.                 echo "*** you link to this library.  But I can only do this if you have a"
  6341.                 echo "*** shared version of the library, which you do not appear to have"
  6342.                 echo "*** because the file extensions .$libext of this argument makes me believe"
  6343.                 echo "*** that it is just a static archive that I should not use here."
  6344.               else
  6345.                 echo
  6346.                 $ECHO "*** Warning: Linking the shared library $output against the"
  6347.                 $ECHO "*** static library $deplib is not portable!"
  6348.                 deplibs="$deplib $deplibs"
  6349.               fi
  6350.               ;;
  6351.             esac
  6352.             continue
  6353.             ;;
  6354.           prog)
  6355.             if test "$pass" != link; then
  6356.               deplibs="$deplib $deplibs"
  6357.             else
  6358.               compile_deplibs="$deplib $compile_deplibs"
  6359.               finalize_deplibs="$deplib $finalize_deplibs"
  6360.             fi
  6361.             continue
  6362.             ;;
  6363.           esac # linkmode
  6364.           ;; # *.$libext
  6365.         *.lo | *.$objext)
  6366.           if test "$pass" = conv; then
  6367.             deplibs="$deplib $deplibs"
  6368.           elif test "$linkmode" = prog; then
  6369.             if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
  6370.               # If there is no dlopen support or we're linking statically,
  6371.               # we need to preload.
  6372.               func_append newdlprefiles " $deplib"
  6373.               compile_deplibs="$deplib $compile_deplibs"
  6374.               finalize_deplibs="$deplib $finalize_deplibs"
  6375.             else
  6376.               func_append newdlfiles " $deplib"
  6377.             fi
  6378.           fi
  6379.           continue
  6380.           ;;
  6381.         %DEPLIBS%)
  6382.           alldeplibs=yes
  6383.           continue
  6384.           ;;
  6385.         esac # case $deplib
  6386.  
  6387.         if test "$found" = yes || test -f "$lib"; then :
  6388.         else
  6389.           func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
  6390.         fi
  6391.  
  6392.         # Check to see that this really is a libtool archive.
  6393.         func_lalib_unsafe_p "$lib" \
  6394.           || func_fatal_error "\`$lib' is not a valid libtool archive"
  6395.  
  6396.         func_dirname "$lib" "" "."
  6397.         ladir="$func_dirname_result"
  6398.  
  6399.         dlname=
  6400.         dlopen=
  6401.         dlpreopen=
  6402.         libdir=
  6403.         library_names=
  6404.         old_library=
  6405.         inherited_linker_flags=
  6406.         # If the library was installed with an old release of libtool,
  6407.         # it will not redefine variables installed, or shouldnotlink
  6408.         installed=yes
  6409.         shouldnotlink=no
  6410.         avoidtemprpath=
  6411.  
  6412.  
  6413.         # Read the .la file
  6414.         func_source "$lib"
  6415.  
  6416.         # Convert "-framework foo" to "foo.ltframework"
  6417.         if test -n "$inherited_linker_flags"; then
  6418.           tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
  6419.           for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
  6420.             case " $new_inherited_linker_flags " in
  6421.               *" $tmp_inherited_linker_flag "*) ;;
  6422.               *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
  6423.             esac
  6424.           done
  6425.         fi
  6426.         dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
  6427.         if test "$linkmode,$pass" = "lib,link" ||
  6428.            test "$linkmode,$pass" = "prog,scan" ||
  6429.            { test "$linkmode" != prog && test "$linkmode" != lib; }; then
  6430.           test -n "$dlopen" && func_append dlfiles " $dlopen"
  6431.           test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
  6432.         fi
  6433.  
  6434.         if test "$pass" = conv; then
  6435.           # Only check for convenience libraries
  6436.           deplibs="$lib $deplibs"
  6437.           if test -z "$libdir"; then
  6438.             if test -z "$old_library"; then
  6439.               func_fatal_error "cannot find name of link library for \`$lib'"
  6440.             fi
  6441.             # It is a libtool convenience library, so add in its objects.
  6442.             func_append convenience " $ladir/$objdir/$old_library"
  6443.             func_append old_convenience " $ladir/$objdir/$old_library"
  6444.           elif test "$linkmode" != prog && test "$linkmode" != lib; then
  6445.             func_fatal_error "\`$lib' is not a convenience library"
  6446.           fi
  6447.           tmp_libs=
  6448.           for deplib in $dependency_libs; do
  6449.             deplibs="$deplib $deplibs"
  6450.             if $opt_preserve_dup_deps ; then
  6451.               case "$tmp_libs " in
  6452.               *" $deplib "*) func_append specialdeplibs " $deplib" ;;
  6453.               esac
  6454.             fi
  6455.             func_append tmp_libs " $deplib"
  6456.           done
  6457.           continue
  6458.         fi # $pass = conv
  6459.  
  6460.  
  6461.         # Get the name of the library we link against.
  6462.         linklib=
  6463.         if test -n "$old_library" &&
  6464.            { test "$prefer_static_libs" = yes ||
  6465.              test "$prefer_static_libs,$installed" = "built,no"; }; then
  6466.           linklib=$old_library
  6467.         else
  6468.           for l in $old_library $library_names; do
  6469.             linklib="$l"
  6470.           done
  6471.         fi
  6472.         if test -z "$linklib"; then
  6473.           func_fatal_error "cannot find name of link library for \`$lib'"
  6474.         fi
  6475.  
  6476.         # This library was specified with -dlopen.
  6477.         if test "$pass" = dlopen; then
  6478.           if test -z "$libdir"; then
  6479.             func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
  6480.           fi
  6481.           if test -z "$dlname" ||
  6482.              test "$dlopen_support" != yes ||
  6483.              test "$build_libtool_libs" = no; then
  6484.             # If there is no dlname, no dlopen support or we're linking
  6485.             # statically, we need to preload.  We also need to preload any
  6486.             # dependent libraries so libltdl's deplib preloader doesn't
  6487.             # bomb out in the load deplibs phase.
  6488.             func_append dlprefiles " $lib $dependency_libs"
  6489.           else
  6490.             func_append newdlfiles " $lib"
  6491.           fi
  6492.           continue
  6493.         fi # $pass = dlopen
  6494.  
  6495.         # We need an absolute path.
  6496.         case $ladir in
  6497.         [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
  6498.         *)
  6499.           abs_ladir=`cd "$ladir" && pwd`
  6500.           if test -z "$abs_ladir"; then
  6501.             func_warning "cannot determine absolute directory name of \`$ladir'"
  6502.             func_warning "passing it literally to the linker, although it might fail"
  6503.             abs_ladir="$ladir"
  6504.           fi
  6505.           ;;
  6506.         esac
  6507.         func_basename "$lib"
  6508.         laname="$func_basename_result"
  6509.  
  6510.         # Find the relevant object directory and library name.
  6511.         if test "X$installed" = Xyes; then
  6512.           if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
  6513.             func_warning "library \`$lib' was moved."
  6514.             dir="$ladir"
  6515.             absdir="$abs_ladir"
  6516.             libdir="$abs_ladir"
  6517.           else
  6518.             dir="$lt_sysroot$libdir"
  6519.             absdir="$lt_sysroot$libdir"
  6520.           fi
  6521.           test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
  6522.         else
  6523.           if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
  6524.             dir="$ladir"
  6525.             absdir="$abs_ladir"
  6526.             # Remove this search path later
  6527.             func_append notinst_path " $abs_ladir"
  6528.           else
  6529.             dir="$ladir/$objdir"
  6530.             absdir="$abs_ladir/$objdir"
  6531.             # Remove this search path later
  6532.             func_append notinst_path " $abs_ladir"
  6533.           fi
  6534.         fi # $installed = yes
  6535.         func_stripname 'lib' '.la' "$laname"
  6536.         name=$func_stripname_result
  6537.  
  6538.         # This library was specified with -dlpreopen.
  6539.         if test "$pass" = dlpreopen; then
  6540.           if test -z "$libdir" && test "$linkmode" = prog; then
  6541.             func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
  6542.           fi
  6543.           case "$host" in
  6544.             # special handling for platforms with PE-DLLs.
  6545.             *cygwin* | *mingw* | *cegcc* )
  6546.               # Linker will automatically link against shared library if both
  6547.               # static and shared are present.  Therefore, ensure we extract
  6548.               # symbols from the import library if a shared library is present
  6549.               # (otherwise, the dlopen module name will be incorrect).  We do
  6550.               # this by putting the import library name into $newdlprefiles.
  6551.               # We recover the dlopen module name by 'saving' the la file
  6552.               # name in a special purpose variable, and (later) extracting the
  6553.               # dlname from the la file.
  6554.               if test -n "$dlname"; then
  6555.                 func_tr_sh "$dir/$linklib"
  6556.                 eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
  6557.                 func_append newdlprefiles " $dir/$linklib"
  6558.               else
  6559.                 func_append newdlprefiles " $dir/$old_library"
  6560.                 # Keep a list of preopened convenience libraries to check
  6561.                 # that they are being used correctly in the link pass.
  6562.                 test -z "$libdir" && \
  6563.                   func_append dlpreconveniencelibs " $dir/$old_library"
  6564.               fi
  6565.             ;;
  6566.             * )
  6567.               # Prefer using a static library (so that no silly _DYNAMIC symbols
  6568.               # are required to link).
  6569.               if test -n "$old_library"; then
  6570.                 func_append newdlprefiles " $dir/$old_library"
  6571.                 # Keep a list of preopened convenience libraries to check
  6572.                 # that they are being used correctly in the link pass.
  6573.                 test -z "$libdir" && \
  6574.                   func_append dlpreconveniencelibs " $dir/$old_library"
  6575.               # Otherwise, use the dlname, so that lt_dlopen finds it.
  6576.               elif test -n "$dlname"; then
  6577.                 func_append newdlprefiles " $dir/$dlname"
  6578.               else
  6579.                 func_append newdlprefiles " $dir/$linklib"
  6580.               fi
  6581.             ;;
  6582.           esac
  6583.         fi # $pass = dlpreopen
  6584.  
  6585.         if test -z "$libdir"; then
  6586.           # Link the convenience library
  6587.           if test "$linkmode" = lib; then
  6588.             deplibs="$dir/$old_library $deplibs"
  6589.           elif test "$linkmode,$pass" = "prog,link"; then
  6590.             compile_deplibs="$dir/$old_library $compile_deplibs"
  6591.             finalize_deplibs="$dir/$old_library $finalize_deplibs"
  6592.           else
  6593.             deplibs="$lib $deplibs" # used for prog,scan pass
  6594.           fi
  6595.           continue
  6596.         fi
  6597.  
  6598.  
  6599.         if test "$linkmode" = prog && test "$pass" != link; then
  6600.           func_append newlib_search_path " $ladir"
  6601.           deplibs="$lib $deplibs"
  6602.  
  6603.           linkalldeplibs=no
  6604.           if test "$link_all_deplibs" != no || test -z "$library_names" ||
  6605.              test "$build_libtool_libs" = no; then
  6606.             linkalldeplibs=yes
  6607.           fi
  6608.  
  6609.           tmp_libs=
  6610.           for deplib in $dependency_libs; do
  6611.             case $deplib in
  6612.             -L*) func_stripname '-L' '' "$deplib"
  6613.                  func_resolve_sysroot "$func_stripname_result"
  6614.                  func_append newlib_search_path " $func_resolve_sysroot_result"
  6615.                  ;;
  6616.             esac
  6617.             # Need to link against all dependency_libs?
  6618.             if test "$linkalldeplibs" = yes; then
  6619.               deplibs="$deplib $deplibs"
  6620.             else
  6621.               # Need to hardcode shared library paths
  6622.               # or/and link against static libraries
  6623.               newdependency_libs="$deplib $newdependency_libs"
  6624.             fi
  6625.             if $opt_preserve_dup_deps ; then
  6626.               case "$tmp_libs " in
  6627.               *" $deplib "*) func_append specialdeplibs " $deplib" ;;
  6628.               esac
  6629.             fi
  6630.             func_append tmp_libs " $deplib"
  6631.           done # for deplib
  6632.           continue
  6633.         fi # $linkmode = prog...
  6634.  
  6635.         if test "$linkmode,$pass" = "prog,link"; then
  6636.           if test -n "$library_names" &&
  6637.              { { test "$prefer_static_libs" = no ||
  6638.                  test "$prefer_static_libs,$installed" = "built,yes"; } ||
  6639.                test -z "$old_library"; }; then
  6640.             # We need to hardcode the library path
  6641.             if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
  6642.               # Make sure the rpath contains only unique directories.
  6643.               case "$temp_rpath:" in
  6644.               *"$absdir:"*) ;;
  6645.               *) func_append temp_rpath "$absdir:" ;;
  6646.               esac
  6647.             fi
  6648.  
  6649.             # Hardcode the library path.
  6650.             # Skip directories that are in the system default run-time
  6651.             # search path.
  6652.             case " $sys_lib_dlsearch_path " in
  6653.             *" $absdir "*) ;;
  6654.             *)
  6655.               case "$compile_rpath " in
  6656.               *" $absdir "*) ;;
  6657.               *) func_append compile_rpath " $absdir" ;;
  6658.               esac
  6659.               ;;
  6660.             esac
  6661.             case " $sys_lib_dlsearch_path " in
  6662.             *" $libdir "*) ;;
  6663.             *)
  6664.               case "$finalize_rpath " in
  6665.               *" $libdir "*) ;;
  6666.               *) func_append finalize_rpath " $libdir" ;;
  6667.               esac
  6668.               ;;
  6669.             esac
  6670.           fi # $linkmode,$pass = prog,link...
  6671.  
  6672.           if test "$alldeplibs" = yes &&
  6673.              { test "$deplibs_check_method" = pass_all ||
  6674.                { test "$build_libtool_libs" = yes &&
  6675.                  test -n "$library_names"; }; }; then
  6676.             # We only need to search for static libraries
  6677.             continue
  6678.           fi
  6679.         fi
  6680.  
  6681.         link_static=no # Whether the deplib will be linked statically
  6682.         use_static_libs=$prefer_static_libs
  6683.         if test "$use_static_libs" = built && test "$installed" = yes; then
  6684.           use_static_libs=no
  6685.         fi
  6686.         if test -n "$library_names" &&
  6687.            { test "$use_static_libs" = no || test -z "$old_library"; }; then
  6688.           case $host in
  6689.           *cygwin* | *mingw* | *cegcc*)
  6690.               # No point in relinking DLLs because paths are not encoded
  6691.               func_append notinst_deplibs " $lib"
  6692.               need_relink=no
  6693.             ;;
  6694.           *)
  6695.             if test "$installed" = no; then
  6696.               func_append notinst_deplibs " $lib"
  6697.               need_relink=yes
  6698.             fi
  6699.             ;;
  6700.           esac
  6701.           # This is a shared library
  6702.  
  6703.           # Warn about portability, can't link against -module's on some
  6704.           # systems (darwin).  Don't bleat about dlopened modules though!
  6705.           dlopenmodule=""
  6706.           for dlpremoduletest in $dlprefiles; do
  6707.             if test "X$dlpremoduletest" = "X$lib"; then
  6708.               dlopenmodule="$dlpremoduletest"
  6709.               break
  6710.             fi
  6711.           done
  6712.           if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
  6713.             echo
  6714.             if test "$linkmode" = prog; then
  6715.               $ECHO "*** Warning: Linking the executable $output against the loadable module"
  6716.             else
  6717.               $ECHO "*** Warning: Linking the shared library $output against the loadable module"
  6718.             fi
  6719.             $ECHO "*** $linklib is not portable!"
  6720.           fi
  6721.           if test "$linkmode" = lib &&
  6722.              test "$hardcode_into_libs" = yes; then
  6723.             # Hardcode the library path.
  6724.             # Skip directories that are in the system default run-time
  6725.             # search path.
  6726.             case " $sys_lib_dlsearch_path " in
  6727.             *" $absdir "*) ;;
  6728.             *)
  6729.               case "$compile_rpath " in
  6730.               *" $absdir "*) ;;
  6731.               *) func_append compile_rpath " $absdir" ;;
  6732.               esac
  6733.               ;;
  6734.             esac
  6735.             case " $sys_lib_dlsearch_path " in
  6736.             *" $libdir "*) ;;
  6737.             *)
  6738.               case "$finalize_rpath " in
  6739.               *" $libdir "*) ;;
  6740.               *) func_append finalize_rpath " $libdir" ;;
  6741.               esac
  6742.               ;;
  6743.             esac
  6744.           fi
  6745.  
  6746.           if test -n "$old_archive_from_expsyms_cmds"; then
  6747.             # figure out the soname
  6748.             set dummy $library_names
  6749.             shift
  6750.             realname="$1"
  6751.             shift
  6752.             libname=`eval "\\$ECHO \"$libname_spec\""`
  6753.             # use dlname if we got it. it's perfectly good, no?
  6754.             if test -n "$dlname"; then
  6755.               soname="$dlname"
  6756.             elif test -n "$soname_spec"; then
  6757.               # bleh windows
  6758.               case $host in
  6759.               *cygwin* | mingw* | *cegcc*)
  6760.                 func_arith $current - $age
  6761.                 major=$func_arith_result
  6762.                 versuffix="-$major"
  6763.                 ;;
  6764.               esac
  6765.               eval soname=\"$soname_spec\"
  6766.             else
  6767.               soname="$realname"
  6768.             fi
  6769.  
  6770.             # Make a new name for the extract_expsyms_cmds to use
  6771.             soroot="$soname"
  6772.             func_basename "$soroot"
  6773.             soname="$func_basename_result"
  6774.             func_stripname 'lib' '.dll' "$soname"
  6775.             newlib=libimp-$func_stripname_result.a
  6776.  
  6777.             # If the library has no export list, then create one now
  6778.             if test -f "$output_objdir/$soname-def"; then :
  6779.             else
  6780.               func_verbose "extracting exported symbol list from \`$soname'"
  6781.               func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
  6782.             fi
  6783.  
  6784.             # Create $newlib
  6785.             if test -f "$output_objdir/$newlib"; then :; else
  6786.               func_verbose "generating import library for \`$soname'"
  6787.               func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
  6788.             fi
  6789.             # make sure the library variables are pointing to the new library
  6790.             dir=$output_objdir
  6791.             linklib=$newlib
  6792.           fi # test -n "$old_archive_from_expsyms_cmds"
  6793.  
  6794.           if test "$linkmode" = prog || test "$opt_mode" != relink; then
  6795.             add_shlibpath=
  6796.             add_dir=
  6797.             add=
  6798.             lib_linked=yes
  6799.             case $hardcode_action in
  6800.             immediate | unsupported)
  6801.               if test "$hardcode_direct" = no; then
  6802.                 add="$dir/$linklib"
  6803.                 case $host in
  6804.                   *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
  6805.                   *-*-sysv4*uw2*) add_dir="-L$dir" ;;
  6806.                   *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
  6807.                     *-*-unixware7*) add_dir="-L$dir" ;;
  6808.                   *-*-darwin* )
  6809.                     # if the lib is a (non-dlopened) module then we can not
  6810.                     # link against it, someone is ignoring the earlier warnings
  6811.                     if /usr/bin/file -L $add 2> /dev/null |
  6812.                          $GREP ": [^:]* bundle" >/dev/null ; then
  6813.                       if test "X$dlopenmodule" != "X$lib"; then
  6814.                         $ECHO "*** Warning: lib $linklib is a module, not a shared library"
  6815.                         if test -z "$old_library" ; then
  6816.                           echo
  6817.                           echo "*** And there doesn't seem to be a static archive available"
  6818.                           echo "*** The link will probably fail, sorry"
  6819.                         else
  6820.                           add="$dir/$old_library"
  6821.                         fi
  6822.                       elif test -n "$old_library"; then
  6823.                         add="$dir/$old_library"
  6824.                       fi
  6825.                     fi
  6826.                 esac
  6827.               elif test "$hardcode_minus_L" = no; then
  6828.                 case $host in
  6829.                 *-*-sunos*) add_shlibpath="$dir" ;;
  6830.                 esac
  6831.                 add_dir="-L$dir"
  6832.                 add="-l$name"
  6833.               elif test "$hardcode_shlibpath_var" = no; then
  6834.                 add_shlibpath="$dir"
  6835.                 add="-l$name"
  6836.               else
  6837.                 lib_linked=no
  6838.               fi
  6839.               ;;
  6840.             relink)
  6841.               if test "$hardcode_direct" = yes &&
  6842.                  test "$hardcode_direct_absolute" = no; then
  6843.                 add="$dir/$linklib"
  6844.               elif test "$hardcode_minus_L" = yes; then
  6845.                 add_dir="-L$absdir"
  6846.                 # Try looking first in the location we're being installed to.
  6847.                 if test -n "$inst_prefix_dir"; then
  6848.                   case $libdir in
  6849.                     [\\/]*)
  6850.                       func_append add_dir " -L$inst_prefix_dir$libdir"
  6851.                       ;;
  6852.                   esac
  6853.                 fi
  6854.                 add="-l$name"
  6855.               elif test "$hardcode_shlibpath_var" = yes; then
  6856.                 add_shlibpath="$dir"
  6857.                 add="-l$name"
  6858.               else
  6859.                 lib_linked=no
  6860.               fi
  6861.               ;;
  6862.             *) lib_linked=no ;;
  6863.             esac
  6864.  
  6865.             if test "$lib_linked" != yes; then
  6866.               func_fatal_configuration "unsupported hardcode properties"
  6867.             fi
  6868.  
  6869.             if test -n "$add_shlibpath"; then
  6870.               case :$compile_shlibpath: in
  6871.               *":$add_shlibpath:"*) ;;
  6872.               *) func_append compile_shlibpath "$add_shlibpath:" ;;
  6873.               esac
  6874.             fi
  6875.             if test "$linkmode" = prog; then
  6876.               test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
  6877.               test -n "$add" && compile_deplibs="$add $compile_deplibs"
  6878.             else
  6879.               test -n "$add_dir" && deplibs="$add_dir $deplibs"
  6880.               test -n "$add" && deplibs="$add $deplibs"
  6881.               if test "$hardcode_direct" != yes &&
  6882.                  test "$hardcode_minus_L" != yes &&
  6883.                  test "$hardcode_shlibpath_var" = yes; then
  6884.                 case :$finalize_shlibpath: in
  6885.                 *":$libdir:"*) ;;
  6886.                 *) func_append finalize_shlibpath "$libdir:" ;;
  6887.                 esac
  6888.               fi
  6889.             fi
  6890.           fi
  6891.  
  6892.           if test "$linkmode" = prog || test "$opt_mode" = relink; then
  6893.             add_shlibpath=
  6894.             add_dir=
  6895.             add=
  6896.             # Finalize command for both is simple: just hardcode it.
  6897.             if test "$hardcode_direct" = yes &&
  6898.                test "$hardcode_direct_absolute" = no; then
  6899.               add="$libdir/$linklib"
  6900.             elif test "$hardcode_minus_L" = yes; then
  6901.               add_dir="-L$libdir"
  6902.               add="-l$name"
  6903.             elif test "$hardcode_shlibpath_var" = yes; then
  6904.               case :$finalize_shlibpath: in
  6905.               *":$libdir:"*) ;;
  6906.               *) func_append finalize_shlibpath "$libdir:" ;;
  6907.               esac
  6908.               add="-l$name"
  6909.             elif test "$hardcode_automatic" = yes; then
  6910.               if test -n "$inst_prefix_dir" &&
  6911.                  test -f "$inst_prefix_dir$libdir/$linklib" ; then
  6912.                 add="$inst_prefix_dir$libdir/$linklib"
  6913.               else
  6914.                 add="$libdir/$linklib"
  6915.               fi
  6916.             else
  6917.               # We cannot seem to hardcode it, guess we'll fake it.
  6918.               add_dir="-L$libdir"
  6919.               # Try looking first in the location we're being installed to.
  6920.               if test -n "$inst_prefix_dir"; then
  6921.                 case $libdir in
  6922.                   [\\/]*)
  6923.                     func_append add_dir " -L$inst_prefix_dir$libdir"
  6924.                     ;;
  6925.                 esac
  6926.               fi
  6927.               add="-l$name"
  6928.             fi
  6929.  
  6930.             if test "$linkmode" = prog; then
  6931.               test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
  6932.               test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
  6933.             else
  6934.               test -n "$add_dir" && deplibs="$add_dir $deplibs"
  6935.               test -n "$add" && deplibs="$add $deplibs"
  6936.             fi
  6937.           fi
  6938.         elif test "$linkmode" = prog; then
  6939.           # Here we assume that one of hardcode_direct or hardcode_minus_L
  6940.           # is not unsupported.  This is valid on all known static and
  6941.           # shared platforms.
  6942.           if test "$hardcode_direct" != unsupported; then
  6943.             test -n "$old_library" && linklib="$old_library"
  6944.             compile_deplibs="$dir/$linklib $compile_deplibs"
  6945.             finalize_deplibs="$dir/$linklib $finalize_deplibs"
  6946.           else
  6947.             compile_deplibs="-l$name -L$dir $compile_deplibs"
  6948.             finalize_deplibs="-l$name -L$dir $finalize_deplibs"
  6949.           fi
  6950.         elif test "$build_libtool_libs" = yes; then
  6951.           # Not a shared library
  6952.           if test "$deplibs_check_method" != pass_all; then
  6953.             # We're trying link a shared library against a static one
  6954.             # but the system doesn't support it.
  6955.  
  6956.             # Just print a warning and add the library to dependency_libs so
  6957.             # that the program can be linked against the static library.
  6958.             echo
  6959.             $ECHO "*** Warning: This system can not link to static lib archive $lib."
  6960.             echo "*** I have the capability to make that library automatically link in when"
  6961.             echo "*** you link to this library.  But I can only do this if you have a"
  6962.             echo "*** shared version of the library, which you do not appear to have."
  6963.             if test "$module" = yes; then
  6964.               echo "*** But as you try to build a module library, libtool will still create "
  6965.               echo "*** a static module, that should work as long as the dlopening application"
  6966.               echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
  6967.               if test -z "$global_symbol_pipe"; then
  6968.                 echo
  6969.                 echo "*** However, this would only work if libtool was able to extract symbol"
  6970.                 echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
  6971.                 echo "*** not find such a program.  So, this module is probably useless."
  6972.                 echo "*** \`nm' from GNU binutils and a full rebuild may help."
  6973.               fi
  6974.               if test "$build_old_libs" = no; then
  6975.                 build_libtool_libs=module
  6976.                 build_old_libs=yes
  6977.               else
  6978.                 build_libtool_libs=no
  6979.               fi
  6980.             fi
  6981.           else
  6982.             deplibs="$dir/$old_library $deplibs"
  6983.             link_static=yes
  6984.           fi
  6985.         fi # link shared/static library?
  6986.  
  6987.         if test "$linkmode" = lib; then
  6988.           if test -n "$dependency_libs" &&
  6989.              { test "$hardcode_into_libs" != yes ||
  6990.                test "$build_old_libs" = yes ||
  6991.                test "$link_static" = yes; }; then
  6992.             # Extract -R from dependency_libs
  6993.             temp_deplibs=
  6994.             for libdir in $dependency_libs; do
  6995.               case $libdir in
  6996.               -R*) func_stripname '-R' '' "$libdir"
  6997.                    temp_xrpath=$func_stripname_result
  6998.                    case " $xrpath " in
  6999.                    *" $temp_xrpath "*) ;;
  7000.                    *) func_append xrpath " $temp_xrpath";;
  7001.                    esac;;
  7002.               *) func_append temp_deplibs " $libdir";;
  7003.               esac
  7004.             done
  7005.             dependency_libs="$temp_deplibs"
  7006.           fi
  7007.  
  7008.           func_append newlib_search_path " $absdir"
  7009.           # Link against this library
  7010.           test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
  7011.           # ... and its dependency_libs
  7012.           tmp_libs=
  7013.           for deplib in $dependency_libs; do
  7014.             newdependency_libs="$deplib $newdependency_libs"
  7015.             case $deplib in
  7016.               -L*) func_stripname '-L' '' "$deplib"
  7017.                    func_resolve_sysroot "$func_stripname_result";;
  7018.               *) func_resolve_sysroot "$deplib" ;;
  7019.             esac
  7020.             if $opt_preserve_dup_deps ; then
  7021.               case "$tmp_libs " in
  7022.               *" $func_resolve_sysroot_result "*)
  7023.                 func_append specialdeplibs " $func_resolve_sysroot_result" ;;
  7024.               esac
  7025.             fi
  7026.             func_append tmp_libs " $func_resolve_sysroot_result"
  7027.           done
  7028.  
  7029.           if test "$link_all_deplibs" != no; then
  7030.             # Add the search paths of all dependency libraries
  7031.             for deplib in $dependency_libs; do
  7032.               path=
  7033.               case $deplib in
  7034.               -L*) path="$deplib" ;;
  7035.               *.la)
  7036.                 func_resolve_sysroot "$deplib"
  7037.                 deplib=$func_resolve_sysroot_result
  7038.                 func_dirname "$deplib" "" "."
  7039.                 dir=$func_dirname_result
  7040.                 # We need an absolute path.
  7041.                 case $dir in
  7042.                 [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
  7043.                 *)
  7044.                   absdir=`cd "$dir" && pwd`
  7045.                   if test -z "$absdir"; then
  7046.                     func_warning "cannot determine absolute directory name of \`$dir'"
  7047.                     absdir="$dir"
  7048.                   fi
  7049.                   ;;
  7050.                 esac
  7051.                 if $GREP "^installed=no" $deplib > /dev/null; then
  7052.                 case $host in
  7053.                 *-*-darwin*)
  7054.                   depdepl=
  7055.                   eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
  7056.                   if test -n "$deplibrary_names" ; then
  7057.                     for tmp in $deplibrary_names ; do
  7058.                       depdepl=$tmp
  7059.                     done
  7060.                     if test -f "$absdir/$objdir/$depdepl" ; then
  7061.                       depdepl="$absdir/$objdir/$depdepl"
  7062.                       darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
  7063.                      if test -z "$darwin_install_name"; then
  7064.                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
  7065.                      fi
  7066.                       func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
  7067.                       func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
  7068.                       path=
  7069.                     fi
  7070.                   fi
  7071.                   ;;
  7072.                 *)
  7073.                   path="-L$absdir/$objdir"
  7074.                   ;;
  7075.                 esac
  7076.                 else
  7077.                   eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
  7078.                   test -z "$libdir" && \
  7079.                     func_fatal_error "\`$deplib' is not a valid libtool archive"
  7080.                   test "$absdir" != "$libdir" && \
  7081.                     func_warning "\`$deplib' seems to be moved"
  7082.  
  7083.                   path="-L$absdir"
  7084.                 fi
  7085.                 ;;
  7086.               esac
  7087.               case " $deplibs " in
  7088.               *" $path "*) ;;
  7089.               *) deplibs="$path $deplibs" ;;
  7090.               esac
  7091.             done
  7092.           fi # link_all_deplibs != no
  7093.         fi # linkmode = lib
  7094.      done # for deplib in $libs
  7095.      if test "$pass" = link; then
  7096.         if test "$linkmode" = "prog"; then
  7097.           compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
  7098.           finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
  7099.         else
  7100.           compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
  7101.         fi
  7102.      fi
  7103.      dependency_libs="$newdependency_libs"
  7104.      if test "$pass" = dlpreopen; then
  7105.         # Link the dlpreopened libraries before other libraries
  7106.         for deplib in $save_deplibs; do
  7107.           deplibs="$deplib $deplibs"
  7108.         done
  7109.      fi
  7110.      if test "$pass" != dlopen; then
  7111.         if test "$pass" != conv; then
  7112.           # Make sure lib_search_path contains only unique directories.
  7113.           lib_search_path=
  7114.           for dir in $newlib_search_path; do
  7115.             case "$lib_search_path " in
  7116.             *" $dir "*) ;;
  7117.             *) func_append lib_search_path " $dir" ;;
  7118.             esac
  7119.           done
  7120.           newlib_search_path=
  7121.         fi
  7122.  
  7123.         if test "$linkmode,$pass" != "prog,link"; then
  7124.           vars="deplibs"
  7125.         else
  7126.           vars="compile_deplibs finalize_deplibs"
  7127.         fi
  7128.         for var in $vars dependency_libs; do
  7129.           # Add libraries to $var in reverse order
  7130.           eval tmp_libs=\"\$$var\"
  7131.           new_libs=
  7132.           for deplib in $tmp_libs; do
  7133.             # FIXME: Pedantically, this is the right thing to do, so
  7134.             #        that some nasty dependency loop isn't accidentally
  7135.             #        broken:
  7136.             #new_libs="$deplib $new_libs"
  7137.             # Pragmatically, this seems to cause very few problems in
  7138.             # practice:
  7139.             case $deplib in
  7140.             -L*) new_libs="$deplib $new_libs" ;;
  7141.             -R*) ;;
  7142.             *)
  7143.               # And here is the reason: when a library appears more
  7144.               # than once as an explicit dependence of a library, or
  7145.               # is implicitly linked in more than once by the
  7146.               # compiler, it is considered special, and multiple
  7147.               # occurrences thereof are not removed.  Compare this
  7148.               # with having the same library being listed as a
  7149.               # dependency of multiple other libraries: in this case,
  7150.               # we know (pedantically, we assume) the library does not
  7151.               # need to be listed more than once, so we keep only the
  7152.               # last copy.  This is not always right, but it is rare
  7153.               # enough that we require users that really mean to play
  7154.               # such unportable linking tricks to link the library
  7155.               # using -Wl,-lname, so that libtool does not consider it
  7156.               # for duplicate removal.
  7157.               case " $specialdeplibs " in
  7158.               *" $deplib "*) new_libs="$deplib $new_libs" ;;
  7159.               *)
  7160.                 case " $new_libs " in
  7161.                 *" $deplib "*) ;;
  7162.                 *) new_libs="$deplib $new_libs" ;;
  7163.                 esac
  7164.                 ;;
  7165.               esac
  7166.               ;;
  7167.             esac
  7168.           done
  7169.           tmp_libs=
  7170.           for deplib in $new_libs; do
  7171.             case $deplib in
  7172.             -L*)
  7173.               case " $tmp_libs " in
  7174.               *" $deplib "*) ;;
  7175.               *) func_append tmp_libs " $deplib" ;;
  7176.               esac
  7177.               ;;
  7178.             *) func_append tmp_libs " $deplib" ;;
  7179.             esac
  7180.           done
  7181.           eval $var=\"$tmp_libs\"
  7182.         done # for var
  7183.      fi
  7184.      # Last step: remove runtime libs from dependency_libs
  7185.      # (they stay in deplibs)
  7186.      tmp_libs=
  7187.      for i in $dependency_libs ; do
  7188.         case " $predeps $postdeps $compiler_lib_search_path " in
  7189.         *" $i "*)
  7190.           i=""
  7191.           ;;
  7192.         esac
  7193.         if test -n "$i" ; then
  7194.           func_append tmp_libs " $i"
  7195.         fi
  7196.      done
  7197.      dependency_libs=$tmp_libs
  7198.    done # for pass
  7199.    if test "$linkmode" = prog; then
  7200.      dlfiles="$newdlfiles"
  7201.    fi
  7202.    if test "$linkmode" = prog || test "$linkmode" = lib; then
  7203.      dlprefiles="$newdlprefiles"
  7204.    fi
  7205.  
  7206.    case $linkmode in
  7207.    oldlib)
  7208.      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
  7209.         func_warning "\`-dlopen' is ignored for archives"
  7210.       fi
  7211.  
  7212.       case " $deplibs" in
  7213.       *\ -l* | *\ -L*)
  7214.         func_warning "\`-l' and \`-L' are ignored for archives" ;;
  7215.       esac
  7216.  
  7217.       test -n "$rpath" && \
  7218.         func_warning "\`-rpath' is ignored for archives"
  7219.  
  7220.      test -n "$xrpath" && \
  7221.         func_warning "\`-R' is ignored for archives"
  7222.  
  7223.       test -n "$vinfo" && \
  7224.         func_warning "\`-version-info/-version-number' is ignored for archives"
  7225.  
  7226.      test -n "$release" && \
  7227.         func_warning "\`-release' is ignored for archives"
  7228.  
  7229.       test -n "$export_symbols$export_symbols_regex" && \
  7230.         func_warning "\`-export-symbols' is ignored for archives"
  7231.  
  7232.      # Now set the variables for building old libraries.
  7233.      build_libtool_libs=no
  7234.      oldlibs="$output"
  7235.      func_append objs "$old_deplibs"
  7236.      ;;
  7237.  
  7238.    lib)
  7239.      # Make sure we only generate libraries of the form `libNAME.la'.
  7240.      case $outputname in
  7241.      lib*)
  7242.         func_stripname 'lib' '.la' "$outputname"
  7243.         name=$func_stripname_result
  7244.         eval shared_ext=\"$shrext_cmds\"
  7245.         eval libname=\"$libname_spec\"
  7246.         ;;
  7247.      *)
  7248.         test "$module" = no && \
  7249.           func_fatal_help "libtool library \`$output' must begin with \`lib'"
  7250.  
  7251.         if test "$need_lib_prefix" != no; then
  7252.           # Add the "lib" prefix for modules if required
  7253.           func_stripname '' '.la' "$outputname"
  7254.           name=$func_stripname_result
  7255.           eval shared_ext=\"$shrext_cmds\"
  7256.           eval libname=\"$libname_spec\"
  7257.         else
  7258.           func_stripname '' '.la' "$outputname"
  7259.           libname=$func_stripname_result
  7260.         fi
  7261.         ;;
  7262.      esac
  7263.  
  7264.      if test -n "$objs"; then
  7265.         if test "$deplibs_check_method" != pass_all; then
  7266.           func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
  7267.         else
  7268.           echo
  7269.           $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
  7270.           $ECHO "*** objects $objs is not portable!"
  7271.           func_append libobjs " $objs"
  7272.         fi
  7273.      fi
  7274.  
  7275.      test "$dlself" != no && \
  7276.         func_warning "\`-dlopen self' is ignored for libtool libraries"
  7277.  
  7278.      set dummy $rpath
  7279.      shift
  7280.      test "$#" -gt 1 && \
  7281.         func_warning "ignoring multiple \`-rpath's for a libtool library"
  7282.  
  7283.      install_libdir="$1"
  7284.  
  7285.      oldlibs=
  7286.      if test -z "$rpath"; then
  7287.         if test "$build_libtool_libs" = yes; then
  7288.           # Building a libtool convenience library.
  7289.           # Some compilers have problems with a `.al' extension so
  7290.           # convenience libraries should have the same extension an
  7291.           # archive normally would.
  7292.           oldlibs="$output_objdir/$libname.$libext $oldlibs"
  7293.           build_libtool_libs=convenience
  7294.           build_old_libs=yes
  7295.         fi
  7296.  
  7297.         test -n "$vinfo" && \
  7298.           func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
  7299.  
  7300.         test -n "$release" && \
  7301.           func_warning "\`-release' is ignored for convenience libraries"
  7302.       else
  7303.  
  7304.         # Parse the version information argument.
  7305.         save_ifs="$IFS"; IFS=':'
  7306.         set dummy $vinfo 0 0 0
  7307.         shift
  7308.         IFS="$save_ifs"
  7309.  
  7310.         test -n "$7" && \
  7311.           func_fatal_help "too many parameters to \`-version-info'"
  7312.  
  7313.         # convert absolute version numbers to libtool ages
  7314.         # this retains compatibility with .la files and attempts
  7315.         # to make the code below a bit more comprehensible
  7316.  
  7317.         case $vinfo_number in
  7318.         yes)
  7319.           number_major="$1"
  7320.           number_minor="$2"
  7321.           number_revision="$3"
  7322.           #
  7323.           # There are really only two kinds -- those that
  7324.           # use the current revision as the major version
  7325.           # and those that subtract age and use age as
  7326.           # a minor version.  But, then there is irix
  7327.           # which has an extra 1 added just for fun
  7328.           #
  7329.           case $version_type in
  7330.           # correct linux to gnu/linux during the next big refactor
  7331.           darwin|linux|osf|windows|none)
  7332.             func_arith $number_major + $number_minor
  7333.             current=$func_arith_result
  7334.             age="$number_minor"
  7335.             revision="$number_revision"
  7336.             ;;
  7337.           freebsd-aout|freebsd-elf|qnx|sunos)
  7338.             current="$number_major"
  7339.             revision="$number_minor"
  7340.             age="0"
  7341.             ;;
  7342.           irix|nonstopux)
  7343.             func_arith $number_major + $number_minor
  7344.             current=$func_arith_result
  7345.             age="$number_minor"
  7346.             revision="$number_minor"
  7347.             lt_irix_increment=no
  7348.             ;;
  7349.           esac
  7350.           ;;
  7351.         no)
  7352.           current="$1"
  7353.           revision="$2"
  7354.           age="$3"
  7355.           ;;
  7356.         esac
  7357.  
  7358.         # Check that each of the things are valid numbers.
  7359.         case $current in
  7360.         0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
  7361.         *)
  7362.           func_error "CURRENT \`$current' must be a nonnegative integer"
  7363.           func_fatal_error "\`$vinfo' is not valid version information"
  7364.           ;;
  7365.         esac
  7366.  
  7367.         case $revision in
  7368.         0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
  7369.         *)
  7370.           func_error "REVISION \`$revision' must be a nonnegative integer"
  7371.           func_fatal_error "\`$vinfo' is not valid version information"
  7372.           ;;
  7373.         esac
  7374.  
  7375.         case $age in
  7376.         0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
  7377.         *)
  7378.           func_error "AGE \`$age' must be a nonnegative integer"
  7379.           func_fatal_error "\`$vinfo' is not valid version information"
  7380.           ;;
  7381.         esac
  7382.  
  7383.         if test "$age" -gt "$current"; then
  7384.           func_error "AGE \`$age' is greater than the current interface number \`$current'"
  7385.           func_fatal_error "\`$vinfo' is not valid version information"
  7386.         fi
  7387.  
  7388.         # Calculate the version variables.
  7389.         major=
  7390.         versuffix=
  7391.         verstring=
  7392.         case $version_type in
  7393.         none) ;;
  7394.  
  7395.         darwin)
  7396.           # Like Linux, but with the current version available in
  7397.           # verstring for coding it into the library header
  7398.           func_arith $current - $age
  7399.           major=.$func_arith_result
  7400.           versuffix="$major.$age.$revision"
  7401.           # Darwin ld doesn't like 0 for these options...
  7402.           func_arith $current + 1
  7403.           minor_current=$func_arith_result
  7404.           xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
  7405.           verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
  7406.           ;;
  7407.  
  7408.         freebsd-aout)
  7409.           major=".$current"
  7410.           versuffix=".$current.$revision";
  7411.           ;;
  7412.  
  7413.         freebsd-elf)
  7414.           major=".$current"
  7415.           versuffix=".$current"
  7416.           ;;
  7417.  
  7418.         irix | nonstopux)
  7419.           if test "X$lt_irix_increment" = "Xno"; then
  7420.             func_arith $current - $age
  7421.           else
  7422.             func_arith $current - $age + 1
  7423.           fi
  7424.           major=$func_arith_result
  7425.  
  7426.           case $version_type in
  7427.             nonstopux) verstring_prefix=nonstopux ;;
  7428.             *)         verstring_prefix=sgi ;;
  7429.           esac
  7430.           verstring="$verstring_prefix$major.$revision"
  7431.  
  7432.           # Add in all the interfaces that we are compatible with.
  7433.           loop=$revision
  7434.           while test "$loop" -ne 0; do
  7435.             func_arith $revision - $loop
  7436.             iface=$func_arith_result
  7437.             func_arith $loop - 1
  7438.             loop=$func_arith_result
  7439.             verstring="$verstring_prefix$major.$iface:$verstring"
  7440.           done
  7441.  
  7442.           # Before this point, $major must not contain `.'.
  7443.           major=.$major
  7444.           versuffix="$major.$revision"
  7445.           ;;
  7446.  
  7447.         linux) # correct to gnu/linux during the next big refactor
  7448.           func_arith $current - $age
  7449.           major=.$func_arith_result
  7450.           versuffix="$major.$age.$revision"
  7451.           ;;
  7452.  
  7453.         osf)
  7454.           func_arith $current - $age
  7455.           major=.$func_arith_result
  7456.           versuffix=".$current.$age.$revision"
  7457.           verstring="$current.$age.$revision"
  7458.  
  7459.           # Add in all the interfaces that we are compatible with.
  7460.           loop=$age
  7461.           while test "$loop" -ne 0; do
  7462.             func_arith $current - $loop
  7463.             iface=$func_arith_result
  7464.             func_arith $loop - 1
  7465.             loop=$func_arith_result
  7466.             verstring="$verstring:${iface}.0"
  7467.           done
  7468.  
  7469.           # Make executables depend on our current version.
  7470.           func_append verstring ":${current}.0"
  7471.           ;;
  7472.  
  7473.         qnx)
  7474.           major=".$current"
  7475.           versuffix=".$current"
  7476.           ;;
  7477.  
  7478.         sunos)
  7479.           major=".$current"
  7480.           versuffix=".$current.$revision"
  7481.           ;;
  7482.  
  7483.         windows)
  7484.           # Use '-' rather than '.', since we only want one
  7485.           # extension on DOS 8.3 filesystems.
  7486.           func_arith $current - $age
  7487.           major=$func_arith_result
  7488.           versuffix="-$major"
  7489.           ;;
  7490.  
  7491.         *)
  7492.           func_fatal_configuration "unknown library version type \`$version_type'"
  7493.           ;;
  7494.         esac
  7495.  
  7496.         # Clear the version info if we defaulted, and they specified a release.
  7497.         if test -z "$vinfo" && test -n "$release"; then
  7498.           major=
  7499.           case $version_type in
  7500.           darwin)
  7501.             # we can't check for "0.0" in archive_cmds due to quoting
  7502.             # problems, so we reset it completely
  7503.             verstring=
  7504.             ;;
  7505.           *)
  7506.             verstring="0.0"
  7507.             ;;
  7508.           esac
  7509.           if test "$need_version" = no; then
  7510.             versuffix=
  7511.           else
  7512.             versuffix=".0.0"
  7513.           fi
  7514.         fi
  7515.  
  7516.         # Remove version info from name if versioning should be avoided
  7517.         if test "$avoid_version" = yes && test "$need_version" = no; then
  7518.           major=
  7519.           versuffix=
  7520.           verstring=""
  7521.         fi
  7522.  
  7523.         # Check to see if the archive will have undefined symbols.
  7524.         if test "$allow_undefined" = yes; then
  7525.           if test "$allow_undefined_flag" = unsupported; then
  7526.             func_warning "undefined symbols not allowed in $host shared libraries"
  7527.             build_libtool_libs=no
  7528.             build_old_libs=yes
  7529.           fi
  7530.         else
  7531.           # Don't allow undefined symbols.
  7532.           allow_undefined_flag="$no_undefined_flag"
  7533.         fi
  7534.  
  7535.      fi
  7536.  
  7537.      func_generate_dlsyms "$libname" "$libname" "yes"
  7538.      func_append libobjs " $symfileobj"
  7539.      test "X$libobjs" = "X " && libobjs=
  7540.  
  7541.      if test "$opt_mode" != relink; then
  7542.         # Remove our outputs, but don't remove object files since they
  7543.         # may have been created when compiling PIC objects.
  7544.         removelist=
  7545.         tempremovelist=`$ECHO "$output_objdir/*"`
  7546.         for p in $tempremovelist; do
  7547.           case $p in
  7548.             *.$objext | *.gcno)
  7549.                ;;
  7550.             $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
  7551.                if test "X$precious_files_regex" != "X"; then
  7552.                  if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
  7553.                  then
  7554.                    continue
  7555.                  fi
  7556.                fi
  7557.                func_append removelist " $p"
  7558.                ;;
  7559.             *) ;;
  7560.           esac
  7561.         done
  7562.         test -n "$removelist" && \
  7563.           func_show_eval "${RM}r \$removelist"
  7564.      fi
  7565.  
  7566.      # Now set the variables for building old libraries.
  7567.      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
  7568.         func_append oldlibs " $output_objdir/$libname.$libext"
  7569.  
  7570.         # Transform .lo files to .o files.
  7571.         oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
  7572.      fi
  7573.  
  7574.      # Eliminate all temporary directories.
  7575.      #for path in $notinst_path; do
  7576.       # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
  7577.       # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
  7578.       # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
  7579.      #done
  7580.  
  7581.      if test -n "$xrpath"; then
  7582.         # If the user specified any rpath flags, then add them.
  7583.         temp_xrpath=
  7584.         for libdir in $xrpath; do
  7585.           func_replace_sysroot "$libdir"
  7586.           func_append temp_xrpath " -R$func_replace_sysroot_result"
  7587.           case "$finalize_rpath " in
  7588.           *" $libdir "*) ;;
  7589.           *) func_append finalize_rpath " $libdir" ;;
  7590.           esac
  7591.         done
  7592.         if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
  7593.           dependency_libs="$temp_xrpath $dependency_libs"
  7594.         fi
  7595.      fi
  7596.  
  7597.      # Make sure dlfiles contains only unique files that won't be dlpreopened
  7598.      old_dlfiles="$dlfiles"
  7599.      dlfiles=
  7600.      for lib in $old_dlfiles; do
  7601.         case " $dlprefiles $dlfiles " in
  7602.         *" $lib "*) ;;
  7603.         *) func_append dlfiles " $lib" ;;
  7604.         esac
  7605.      done
  7606.  
  7607.      # Make sure dlprefiles contains only unique files
  7608.      old_dlprefiles="$dlprefiles"
  7609.      dlprefiles=
  7610.      for lib in $old_dlprefiles; do
  7611.         case "$dlprefiles " in
  7612.         *" $lib "*) ;;
  7613.         *) func_append dlprefiles " $lib" ;;
  7614.         esac
  7615.      done
  7616.  
  7617.      if test "$build_libtool_libs" = yes; then
  7618.         if test -n "$rpath"; then
  7619.           case $host in
  7620.           *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
  7621.             # these systems don't actually have a c library (as such)!
  7622.             ;;
  7623.           *-*-rhapsody* | *-*-darwin1.[012])
  7624.             # Rhapsody C library is in the System framework
  7625.             func_append deplibs " System.ltframework"
  7626.             ;;
  7627.           *-*-netbsd*)
  7628.             # Don't link with libc until the a.out ld.so is fixed.
  7629.             ;;
  7630.           *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
  7631.             # Do not include libc due to us having libc/libc_r.
  7632.             ;;
  7633.           *-*-sco3.2v5* | *-*-sco5v6*)
  7634.             # Causes problems with __ctype
  7635.             ;;
  7636.           *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
  7637.             # Compiler inserts libc in the correct place for threads to work
  7638.             ;;
  7639.           *)
  7640.             # Add libc to deplibs on all other systems if necessary.
  7641.             if test "$build_libtool_need_lc" = "yes"; then
  7642.               func_append deplibs " -lc"
  7643.             fi
  7644.             ;;
  7645.           esac
  7646.         fi
  7647.  
  7648.         # Transform deplibs into only deplibs that can be linked in shared.
  7649.         name_save=$name
  7650.         libname_save=$libname
  7651.         release_save=$release
  7652.         versuffix_save=$versuffix
  7653.         major_save=$major
  7654.         # I'm not sure if I'm treating the release correctly.  I think
  7655.         # release should show up in the -l (ie -lgmp5) so we don't want to
  7656.         # add it in twice.  Is that correct?
  7657.         release=""
  7658.         versuffix=""
  7659.         major=""
  7660.         newdeplibs=
  7661.         droppeddeps=no
  7662.         case $deplibs_check_method in
  7663.         pass_all)
  7664.           # Don't check for shared/static.  Everything works.
  7665.           # This might be a little naive.  We might want to check
  7666.           # whether the library exists or not.  But this is on
  7667.           # osf3 & osf4 and I'm not really sure... Just
  7668.           # implementing what was already the behavior.
  7669.           newdeplibs=$deplibs
  7670.           ;;
  7671.         test_compile)
  7672.           # This code stresses the "libraries are programs" paradigm to its
  7673.           # limits. Maybe even breaks it.  We compile a program, linking it
  7674.           # against the deplibs as a proxy for the library.  Then we can check
  7675.           # whether they linked in statically or dynamically with ldd.
  7676.           $opt_dry_run || $RM conftest.c
  7677.           cat > conftest.c <<EOF
  7678.           int main() { return 0; }
  7679. EOF
  7680.           $opt_dry_run || $RM conftest
  7681.           if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
  7682.             ldd_output=`ldd conftest`
  7683.             for i in $deplibs; do
  7684.               case $i in
  7685.               -l*)
  7686.                 func_stripname -l '' "$i"
  7687.                 name=$func_stripname_result
  7688.                 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
  7689.                   case " $predeps $postdeps " in
  7690.                   *" $i "*)
  7691.                     func_append newdeplibs " $i"
  7692.                     i=""
  7693.                     ;;
  7694.                   esac
  7695.                 fi
  7696.                 if test -n "$i" ; then
  7697.                   libname=`eval "\\$ECHO \"$libname_spec\""`
  7698.                   deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
  7699.                   set dummy $deplib_matches; shift
  7700.                   deplib_match=$1
  7701.                   if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
  7702.                     func_append newdeplibs " $i"
  7703.                   else
  7704.                     droppeddeps=yes
  7705.                     echo
  7706.                     $ECHO "*** Warning: dynamic linker does not accept needed library $i."
  7707.                     echo "*** I have the capability to make that library automatically link in when"
  7708.                     echo "*** you link to this library.  But I can only do this if you have a"
  7709.                     echo "*** shared version of the library, which I believe you do not have"
  7710.                     echo "*** because a test_compile did reveal that the linker did not use it for"
  7711.                     echo "*** its dynamic dependency list that programs get resolved with at runtime."
  7712.                   fi
  7713.                 fi
  7714.                 ;;
  7715.               *)
  7716.                 func_append newdeplibs " $i"
  7717.                 ;;
  7718.               esac
  7719.             done
  7720.           else
  7721.             # Error occurred in the first compile.  Let's try to salvage
  7722.             # the situation: Compile a separate program for each library.
  7723.             for i in $deplibs; do
  7724.               case $i in
  7725.               -l*)
  7726.                 func_stripname -l '' "$i"
  7727.                 name=$func_stripname_result
  7728.                 $opt_dry_run || $RM conftest
  7729.                 if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
  7730.                   ldd_output=`ldd conftest`
  7731.                   if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
  7732.                     case " $predeps $postdeps " in
  7733.                     *" $i "*)
  7734.                       func_append newdeplibs " $i"
  7735.                       i=""
  7736.                       ;;
  7737.                     esac
  7738.                   fi
  7739.                   if test -n "$i" ; then
  7740.                     libname=`eval "\\$ECHO \"$libname_spec\""`
  7741.                     deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
  7742.                     set dummy $deplib_matches; shift
  7743.                     deplib_match=$1
  7744.                     if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
  7745.                       func_append newdeplibs " $i"
  7746.                     else
  7747.                       droppeddeps=yes
  7748.                       echo
  7749.                       $ECHO "*** Warning: dynamic linker does not accept needed library $i."
  7750.                       echo "*** I have the capability to make that library automatically link in when"
  7751.                       echo "*** you link to this library.  But I can only do this if you have a"
  7752.                       echo "*** shared version of the library, which you do not appear to have"
  7753.                       echo "*** because a test_compile did reveal that the linker did not use this one"
  7754.                       echo "*** as a dynamic dependency that programs can get resolved with at runtime."
  7755.                     fi
  7756.                   fi
  7757.                 else
  7758.                   droppeddeps=yes
  7759.                   echo
  7760.                   $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
  7761.                   echo "*** make it link in!  You will probably need to install it or some"
  7762.                   echo "*** library that it depends on before this library will be fully"
  7763.                   echo "*** functional.  Installing it before continuing would be even better."
  7764.                 fi
  7765.                 ;;
  7766.               *)
  7767.                 func_append newdeplibs " $i"
  7768.                 ;;
  7769.               esac
  7770.             done
  7771.           fi
  7772.           ;;
  7773.         file_magic*)
  7774.           set dummy $deplibs_check_method; shift
  7775.           file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
  7776.           for a_deplib in $deplibs; do
  7777.             case $a_deplib in
  7778.             -l*)
  7779.               func_stripname -l '' "$a_deplib"
  7780.               name=$func_stripname_result
  7781.               if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
  7782.                 case " $predeps $postdeps " in
  7783.                 *" $a_deplib "*)
  7784.                   func_append newdeplibs " $a_deplib"
  7785.                   a_deplib=""
  7786.                   ;;
  7787.                 esac
  7788.               fi
  7789.               if test -n "$a_deplib" ; then
  7790.                 libname=`eval "\\$ECHO \"$libname_spec\""`
  7791.                 if test -n "$file_magic_glob"; then
  7792.                   libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
  7793.                 else
  7794.                   libnameglob=$libname
  7795.                 fi
  7796.                 test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
  7797.                 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
  7798.                   if test "$want_nocaseglob" = yes; then
  7799.                     shopt -s nocaseglob
  7800.                     potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
  7801.                     $nocaseglob
  7802.                   else
  7803.                     potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
  7804.                   fi
  7805.                   for potent_lib in $potential_libs; do
  7806.                       # Follow soft links.
  7807.                       if ls -lLd "$potent_lib" 2>/dev/null |
  7808.                          $GREP " -> " >/dev/null; then
  7809.                         continue
  7810.                       fi
  7811.                       # The statement above tries to avoid entering an
  7812.                       # endless loop below, in case of cyclic links.
  7813.                       # We might still enter an endless loop, since a link
  7814.                       # loop can be closed while we follow links,
  7815.                       # but so what?
  7816.                       potlib="$potent_lib"
  7817.                       while test -h "$potlib" 2>/dev/null; do
  7818.                         potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
  7819.                         case $potliblink in
  7820.                         [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
  7821.                         *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
  7822.                         esac
  7823.                       done
  7824.                       if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
  7825.                          $SED -e 10q |
  7826.                          $EGREP "$file_magic_regex" > /dev/null; then
  7827.                         func_append newdeplibs " $a_deplib"
  7828.                         a_deplib=""
  7829.                         break 2
  7830.                       fi
  7831.                   done
  7832.                 done
  7833.               fi
  7834.               if test -n "$a_deplib" ; then
  7835.                 droppeddeps=yes
  7836.                 echo
  7837.                 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
  7838.                 echo "*** I have the capability to make that library automatically link in when"
  7839.                 echo "*** you link to this library.  But I can only do this if you have a"
  7840.                 echo "*** shared version of the library, which you do not appear to have"
  7841.                 echo "*** because I did check the linker path looking for a file starting"
  7842.                 if test -z "$potlib" ; then
  7843.                   $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
  7844.                 else
  7845.                   $ECHO "*** with $libname and none of the candidates passed a file format test"
  7846.                   $ECHO "*** using a file magic. Last file checked: $potlib"
  7847.                 fi
  7848.               fi
  7849.               ;;
  7850.             *)
  7851.               # Add a -L argument.
  7852.               func_append newdeplibs " $a_deplib"
  7853.               ;;
  7854.             esac
  7855.           done # Gone through all deplibs.
  7856.           ;;
  7857.         match_pattern*)
  7858.           set dummy $deplibs_check_method; shift
  7859.           match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
  7860.           for a_deplib in $deplibs; do
  7861.             case $a_deplib in
  7862.             -l*)
  7863.               func_stripname -l '' "$a_deplib"
  7864.               name=$func_stripname_result
  7865.               if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
  7866.                 case " $predeps $postdeps " in
  7867.                 *" $a_deplib "*)
  7868.                   func_append newdeplibs " $a_deplib"
  7869.                   a_deplib=""
  7870.                   ;;
  7871.                 esac
  7872.               fi
  7873.               if test -n "$a_deplib" ; then
  7874.                 libname=`eval "\\$ECHO \"$libname_spec\""`
  7875.                 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
  7876.                   potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
  7877.                   for potent_lib in $potential_libs; do
  7878.                     potlib="$potent_lib" # see symlink-check above in file_magic test
  7879.                     if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
  7880.                        $EGREP "$match_pattern_regex" > /dev/null; then
  7881.                       func_append newdeplibs " $a_deplib"
  7882.                       a_deplib=""
  7883.                       break 2
  7884.                     fi
  7885.                   done
  7886.                 done
  7887.               fi
  7888.               if test -n "$a_deplib" ; then
  7889.                 droppeddeps=yes
  7890.                 echo
  7891.                 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
  7892.                 echo "*** I have the capability to make that library automatically link in when"
  7893.                 echo "*** you link to this library.  But I can only do this if you have a"
  7894.                 echo "*** shared version of the library, which you do not appear to have"
  7895.                 echo "*** because I did check the linker path looking for a file starting"
  7896.                 if test -z "$potlib" ; then
  7897.                   $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
  7898.                 else
  7899.                   $ECHO "*** with $libname and none of the candidates passed a file format test"
  7900.                   $ECHO "*** using a regex pattern. Last file checked: $potlib"
  7901.                 fi
  7902.               fi
  7903.               ;;
  7904.             *)
  7905.               # Add a -L argument.
  7906.               func_append newdeplibs " $a_deplib"
  7907.               ;;
  7908.             esac
  7909.           done # Gone through all deplibs.
  7910.           ;;
  7911.         none | unknown | *)
  7912.           newdeplibs=""
  7913.           tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
  7914.           if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
  7915.             for i in $predeps $postdeps ; do
  7916.               # can't use Xsed below, because $i might contain '/'
  7917.               tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
  7918.             done
  7919.           fi
  7920.           case $tmp_deplibs in
  7921.           *[!\  \ ]*)
  7922.             echo
  7923.             if test "X$deplibs_check_method" = "Xnone"; then
  7924.               echo "*** Warning: inter-library dependencies are not supported in this platform."
  7925.             else
  7926.               echo "*** Warning: inter-library dependencies are not known to be supported."
  7927.             fi
  7928.             echo "*** All declared inter-library dependencies are being dropped."
  7929.             droppeddeps=yes
  7930.             ;;
  7931.           esac
  7932.           ;;
  7933.         esac
  7934.         versuffix=$versuffix_save
  7935.         major=$major_save
  7936.         release=$release_save
  7937.         libname=$libname_save
  7938.         name=$name_save
  7939.  
  7940.         case $host in
  7941.         *-*-rhapsody* | *-*-darwin1.[012])
  7942.           # On Rhapsody replace the C library with the System framework
  7943.           newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
  7944.           ;;
  7945.         esac
  7946.  
  7947.         if test "$droppeddeps" = yes; then
  7948.           if test "$module" = yes; then
  7949.             echo
  7950.             echo "*** Warning: libtool could not satisfy all declared inter-library"
  7951.             $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
  7952.             echo "*** a static module, that should work as long as the dlopening"
  7953.             echo "*** application is linked with the -dlopen flag."
  7954.             if test -z "$global_symbol_pipe"; then
  7955.               echo
  7956.               echo "*** However, this would only work if libtool was able to extract symbol"
  7957.               echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
  7958.               echo "*** not find such a program.  So, this module is probably useless."
  7959.               echo "*** \`nm' from GNU binutils and a full rebuild may help."
  7960.             fi
  7961.             if test "$build_old_libs" = no; then
  7962.               oldlibs="$output_objdir/$libname.$libext"
  7963.               build_libtool_libs=module
  7964.               build_old_libs=yes
  7965.             else
  7966.               build_libtool_libs=no
  7967.             fi
  7968.           else
  7969.             echo "*** The inter-library dependencies that have been dropped here will be"
  7970.             echo "*** automatically added whenever a program is linked with this library"
  7971.             echo "*** or is declared to -dlopen it."
  7972.  
  7973.             if test "$allow_undefined" = no; then
  7974.               echo
  7975.               echo "*** Since this library must not contain undefined symbols,"
  7976.               echo "*** because either the platform does not support them or"
  7977.               echo "*** it was explicitly requested with -no-undefined,"
  7978.               echo "*** libtool will only create a static version of it."
  7979.               if test "$build_old_libs" = no; then
  7980.                 oldlibs="$output_objdir/$libname.$libext"
  7981.                 build_libtool_libs=module
  7982.                 build_old_libs=yes
  7983.               else
  7984.                 build_libtool_libs=no
  7985.               fi
  7986.             fi
  7987.           fi
  7988.         fi
  7989.         # Done checking deplibs!
  7990.         deplibs=$newdeplibs
  7991.      fi
  7992.      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
  7993.      case $host in
  7994.         *-*-darwin*)
  7995.           newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
  7996.           new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
  7997.           deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
  7998.           ;;
  7999.      esac
  8000.  
  8001.      # move library search paths that coincide with paths to not yet
  8002.      # installed libraries to the beginning of the library search list
  8003.      new_libs=
  8004.      for path in $notinst_path; do
  8005.         case " $new_libs " in
  8006.         *" -L$path/$objdir "*) ;;
  8007.         *)
  8008.           case " $deplibs " in
  8009.           *" -L$path/$objdir "*)
  8010.             func_append new_libs " -L$path/$objdir" ;;
  8011.           esac
  8012.           ;;
  8013.         esac
  8014.      done
  8015.      for deplib in $deplibs; do
  8016.         case $deplib in
  8017.         -L*)
  8018.           case " $new_libs " in
  8019.           *" $deplib "*) ;;
  8020.           *) func_append new_libs " $deplib" ;;
  8021.           esac
  8022.           ;;
  8023.         *) func_append new_libs " $deplib" ;;
  8024.         esac
  8025.      done
  8026.      deplibs="$new_libs"
  8027.  
  8028.      # All the library-specific variables (install_libdir is set above).
  8029.      library_names=
  8030.      old_library=
  8031.      dlname=
  8032.  
  8033.      # Test again, we may have decided not to build it any more
  8034.      if test "$build_libtool_libs" = yes; then
  8035.         # Remove ${wl} instances when linking with ld.
  8036.         # FIXME: should test the right _cmds variable.
  8037.         case $archive_cmds in
  8038.           *\$LD\ *) wl= ;;
  8039.        esac
  8040.         if test "$hardcode_into_libs" = yes; then
  8041.           # Hardcode the library paths
  8042.           hardcode_libdirs=
  8043.           dep_rpath=
  8044.           rpath="$finalize_rpath"
  8045.           test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
  8046.           for libdir in $rpath; do
  8047.             if test -n "$hardcode_libdir_flag_spec"; then
  8048.               if test -n "$hardcode_libdir_separator"; then
  8049.                 func_replace_sysroot "$libdir"
  8050.                 libdir=$func_replace_sysroot_result
  8051.                 if test -z "$hardcode_libdirs"; then
  8052.                   hardcode_libdirs="$libdir"
  8053.                 else
  8054.                   # Just accumulate the unique libdirs.
  8055.                   case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
  8056.                   *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
  8057.                     ;;
  8058.                   *)
  8059.                     func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
  8060.                     ;;
  8061.                   esac
  8062.                 fi
  8063.               else
  8064.                 eval flag=\"$hardcode_libdir_flag_spec\"
  8065.                 func_append dep_rpath " $flag"
  8066.               fi
  8067.             elif test -n "$runpath_var"; then
  8068.               case "$perm_rpath " in
  8069.               *" $libdir "*) ;;
  8070.               *) func_append perm_rpath " $libdir" ;;
  8071.               esac
  8072.             fi
  8073.           done
  8074.           # Substitute the hardcoded libdirs into the rpath.
  8075.           if test -n "$hardcode_libdir_separator" &&
  8076.              test -n "$hardcode_libdirs"; then
  8077.             libdir="$hardcode_libdirs"
  8078.             eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
  8079.           fi
  8080.           if test -n "$runpath_var" && test -n "$perm_rpath"; then
  8081.             # We should set the runpath_var.
  8082.             rpath=
  8083.             for dir in $perm_rpath; do
  8084.               func_append rpath "$dir:"
  8085.             done
  8086.             eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
  8087.           fi
  8088.           test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
  8089.         fi
  8090.  
  8091.         shlibpath="$finalize_shlibpath"
  8092.         test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
  8093.         if test -n "$shlibpath"; then
  8094.           eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
  8095.         fi
  8096.  
  8097.         # Get the real and link names of the library.
  8098.         eval shared_ext=\"$shrext_cmds\"
  8099.         eval library_names=\"$library_names_spec\"
  8100.         set dummy $library_names
  8101.         shift
  8102.         realname="$1"
  8103.         shift
  8104.  
  8105.         if test -n "$soname_spec"; then
  8106.           eval soname=\"$soname_spec\"
  8107.         else
  8108.           soname="$realname"
  8109.         fi
  8110.         if test -z "$dlname"; then
  8111.           dlname=$soname
  8112.         fi
  8113.  
  8114.         lib="$output_objdir/$realname"
  8115.         linknames=
  8116.         for link
  8117.         do
  8118.           func_append linknames " $link"
  8119.         done
  8120.  
  8121.         # Use standard objects if they are pic
  8122.         test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
  8123.         test "X$libobjs" = "X " && libobjs=
  8124.  
  8125.         delfiles=
  8126.         if test -n "$export_symbols" && test -n "$include_expsyms"; then
  8127.           $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
  8128.           export_symbols="$output_objdir/$libname.uexp"
  8129.           func_append delfiles " $export_symbols"
  8130.         fi
  8131.  
  8132.         orig_export_symbols=
  8133.         case $host_os in
  8134.         cygwin* | mingw* | cegcc*)
  8135.           if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
  8136.             # exporting using user supplied symfile
  8137.             if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
  8138.               # and it's NOT already a .def file. Must figure out
  8139.               # which of the given symbols are data symbols and tag
  8140.               # them as such. So, trigger use of export_symbols_cmds.
  8141.               # export_symbols gets reassigned inside the "prepare
  8142.               # the list of exported symbols" if statement, so the
  8143.               # include_expsyms logic still works.
  8144.               orig_export_symbols="$export_symbols"
  8145.               export_symbols=
  8146.               always_export_symbols=yes
  8147.             fi
  8148.           fi
  8149.           ;;
  8150.         esac
  8151.  
  8152.         # Prepare the list of exported symbols
  8153.         if test -z "$export_symbols"; then
  8154.           if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
  8155.             func_verbose "generating symbol list for \`$libname.la'"
  8156.             export_symbols="$output_objdir/$libname.exp"
  8157.             $opt_dry_run || $RM $export_symbols
  8158.             cmds=$export_symbols_cmds
  8159.             save_ifs="$IFS"; IFS='~'
  8160.             for cmd1 in $cmds; do
  8161.               IFS="$save_ifs"
  8162.               # Take the normal branch if the nm_file_list_spec branch
  8163.               # doesn't work or if tool conversion is not needed.
  8164.               case $nm_file_list_spec~$to_tool_file_cmd in
  8165.                 *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
  8166.                   try_normal_branch=yes
  8167.                   eval cmd=\"$cmd1\"
  8168.                   func_len " $cmd"
  8169.                   len=$func_len_result
  8170.                   ;;
  8171.                 *)
  8172.                   try_normal_branch=no
  8173.                   ;;
  8174.               esac
  8175.               if test "$try_normal_branch" = yes \
  8176.                  && { test "$len" -lt "$max_cmd_len" \
  8177.                       || test "$max_cmd_len" -le -1; }
  8178.               then
  8179.                 func_show_eval "$cmd" 'exit $?'
  8180.                 skipped_export=false
  8181.               elif test -n "$nm_file_list_spec"; then
  8182.                 func_basename "$output"
  8183.                 output_la=$func_basename_result
  8184.                 save_libobjs=$libobjs
  8185.                 save_output=$output
  8186.                 output=${output_objdir}/${output_la}.nm
  8187.                 func_to_tool_file "$output"
  8188.                 libobjs=$nm_file_list_spec$func_to_tool_file_result
  8189.                 func_append delfiles " $output"
  8190.                 func_verbose "creating $NM input file list: $output"
  8191.                 for obj in $save_libobjs; do
  8192.                   func_to_tool_file "$obj"
  8193.                   $ECHO "$func_to_tool_file_result"
  8194.                 done > "$output"
  8195.                 eval cmd=\"$cmd1\"
  8196.                 func_show_eval "$cmd" 'exit $?'
  8197.                 output=$save_output
  8198.                 libobjs=$save_libobjs
  8199.                 skipped_export=false
  8200.               else
  8201.                 # The command line is too long to execute in one step.
  8202.                 func_verbose "using reloadable object file for export list..."
  8203.                 skipped_export=:
  8204.                 # Break out early, otherwise skipped_export may be
  8205.                 # set to false by a later but shorter cmd.
  8206.                 break
  8207.               fi
  8208.             done
  8209.             IFS="$save_ifs"
  8210.             if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
  8211.               func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
  8212.               func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
  8213.             fi
  8214.           fi
  8215.         fi
  8216.  
  8217.         if test -n "$export_symbols" && test -n "$include_expsyms"; then
  8218.           tmp_export_symbols="$export_symbols"
  8219.           test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
  8220.           $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
  8221.         fi
  8222.  
  8223.         if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
  8224.           # The given exports_symbols file has to be filtered, so filter it.
  8225.           func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
  8226.           # FIXME: $output_objdir/$libname.filter potentially contains lots of
  8227.           # 's' commands which not all seds can handle. GNU sed should be fine
  8228.           # though. Also, the filter scales superlinearly with the number of
  8229.           # global variables. join(1) would be nice here, but unfortunately
  8230.           # isn't a blessed tool.
  8231.           $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
  8232.           func_append delfiles " $export_symbols $output_objdir/$libname.filter"
  8233.           export_symbols=$output_objdir/$libname.def
  8234.           $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
  8235.         fi
  8236.  
  8237.         tmp_deplibs=
  8238.         for test_deplib in $deplibs; do
  8239.           case " $convenience " in
  8240.           *" $test_deplib "*) ;;
  8241.           *)
  8242.             func_append tmp_deplibs " $test_deplib"
  8243.             ;;
  8244.           esac
  8245.         done
  8246.         deplibs="$tmp_deplibs"
  8247.  
  8248.         if test -n "$convenience"; then
  8249.           if test -n "$whole_archive_flag_spec" &&
  8250.             test "$compiler_needs_object" = yes &&
  8251.             test -z "$libobjs"; then
  8252.             # extract the archives, so we have objects to list.
  8253.             # TODO: could optimize this to just extract one archive.
  8254.             whole_archive_flag_spec=
  8255.           fi
  8256.           if test -n "$whole_archive_flag_spec"; then
  8257.             save_libobjs=$libobjs
  8258.             eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
  8259.             test "X$libobjs" = "X " && libobjs=
  8260.           else
  8261.             gentop="$output_objdir/${outputname}x"
  8262.             func_append generated " $gentop"
  8263.  
  8264.             func_extract_archives $gentop $convenience
  8265.             func_append libobjs " $func_extract_archives_result"
  8266.             test "X$libobjs" = "X " && libobjs=
  8267.           fi
  8268.         fi
  8269.  
  8270.         if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
  8271.           eval flag=\"$thread_safe_flag_spec\"
  8272.           func_append linker_flags " $flag"
  8273.         fi
  8274.  
  8275.         # Make a backup of the uninstalled library when relinking
  8276.         if test "$opt_mode" = relink; then
  8277.           $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
  8278.         fi
  8279.  
  8280.         # Do each of the archive commands.
  8281.         if test "$module" = yes && test -n "$module_cmds" ; then
  8282.           if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
  8283.             eval test_cmds=\"$module_expsym_cmds\"
  8284.             cmds=$module_expsym_cmds
  8285.           else
  8286.             eval test_cmds=\"$module_cmds\"
  8287.             cmds=$module_cmds
  8288.           fi
  8289.         else
  8290.           if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
  8291.             eval test_cmds=\"$archive_expsym_cmds\"
  8292.             cmds=$archive_expsym_cmds
  8293.           else
  8294.             eval test_cmds=\"$archive_cmds\"
  8295.             cmds=$archive_cmds
  8296.           fi
  8297.         fi
  8298.  
  8299.         if test "X$skipped_export" != "X:" &&
  8300.            func_len " $test_cmds" &&
  8301.            len=$func_len_result &&
  8302.            test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
  8303.           :
  8304.         else
  8305.           # The command line is too long to link in one step, link piecewise
  8306.           # or, if using GNU ld and skipped_export is not :, use a linker
  8307.           # script.
  8308.  
  8309.           # Save the value of $output and $libobjs because we want to
  8310.           # use them later.  If we have whole_archive_flag_spec, we
  8311.           # want to use save_libobjs as it was before
  8312.           # whole_archive_flag_spec was expanded, because we can't
  8313.           # assume the linker understands whole_archive_flag_spec.
  8314.           # This may have to be revisited, in case too many
  8315.           # convenience libraries get linked in and end up exceeding
  8316.           # the spec.
  8317.           if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
  8318.             save_libobjs=$libobjs
  8319.           fi
  8320.           save_output=$output
  8321.           func_basename "$output"
  8322.           output_la=$func_basename_result
  8323.  
  8324.           # Clear the reloadable object creation command queue and
  8325.           # initialize k to one.
  8326.           test_cmds=
  8327.           concat_cmds=
  8328.           objlist=
  8329.           last_robj=
  8330.           k=1
  8331.  
  8332.           if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
  8333.             output=${output_objdir}/${output_la}.lnkscript
  8334.             func_verbose "creating GNU ld script: $output"
  8335.             echo 'INPUT (' > $output
  8336.             for obj in $save_libobjs
  8337.             do
  8338.               func_to_tool_file "$obj"
  8339.               $ECHO "$func_to_tool_file_result" >> $output
  8340.             done
  8341.             echo ')' >> $output
  8342.             func_append delfiles " $output"
  8343.             func_to_tool_file "$output"
  8344.             output=$func_to_tool_file_result
  8345.           elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
  8346.             output=${output_objdir}/${output_la}.lnk
  8347.             func_verbose "creating linker input file list: $output"
  8348.             : > $output
  8349.             set x $save_libobjs
  8350.             shift
  8351.             firstobj=
  8352.             if test "$compiler_needs_object" = yes; then
  8353.               firstobj="$1 "
  8354.               shift
  8355.             fi
  8356.             for obj
  8357.             do
  8358.               func_to_tool_file "$obj"
  8359.               $ECHO "$func_to_tool_file_result" >> $output
  8360.             done
  8361.             func_append delfiles " $output"
  8362.             func_to_tool_file "$output"
  8363.             output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
  8364.           else
  8365.             if test -n "$save_libobjs"; then
  8366.               func_verbose "creating reloadable object files..."
  8367.               output=$output_objdir/$output_la-${k}.$objext
  8368.               eval test_cmds=\"$reload_cmds\"
  8369.               func_len " $test_cmds"
  8370.               len0=$func_len_result
  8371.               len=$len0
  8372.  
  8373.               # Loop over the list of objects to be linked.
  8374.               for obj in $save_libobjs
  8375.               do
  8376.                 func_len " $obj"
  8377.                 func_arith $len + $func_len_result
  8378.                 len=$func_arith_result
  8379.                 if test "X$objlist" = X ||
  8380.                    test "$len" -lt "$max_cmd_len"; then
  8381.                   func_append objlist " $obj"
  8382.                 else
  8383.                   # The command $test_cmds is almost too long, add a
  8384.                   # command to the queue.
  8385.                   if test "$k" -eq 1 ; then
  8386.                     # The first file doesn't have a previous command to add.
  8387.                     reload_objs=$objlist
  8388.                     eval concat_cmds=\"$reload_cmds\"
  8389.                   else
  8390.                     # All subsequent reloadable object files will link in
  8391.                     # the last one created.
  8392.                     reload_objs="$objlist $last_robj"
  8393.                     eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
  8394.                   fi
  8395.                   last_robj=$output_objdir/$output_la-${k}.$objext
  8396.                   func_arith $k + 1
  8397.                   k=$func_arith_result
  8398.                   output=$output_objdir/$output_la-${k}.$objext
  8399.                   objlist=" $obj"
  8400.                   func_len " $last_robj"
  8401.                   func_arith $len0 + $func_len_result
  8402.                   len=$func_arith_result
  8403.                 fi
  8404.               done
  8405.               # Handle the remaining objects by creating one last
  8406.               # reloadable object file.  All subsequent reloadable object
  8407.               # files will link in the last one created.
  8408.               test -z "$concat_cmds" || concat_cmds=$concat_cmds~
  8409.               reload_objs="$objlist $last_robj"
  8410.               eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
  8411.               if test -n "$last_robj"; then
  8412.                 eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
  8413.               fi
  8414.               func_append delfiles " $output"
  8415.  
  8416.             else
  8417.               output=
  8418.             fi
  8419.  
  8420.             if ${skipped_export-false}; then
  8421.               func_verbose "generating symbol list for \`$libname.la'"
  8422.               export_symbols="$output_objdir/$libname.exp"
  8423.               $opt_dry_run || $RM $export_symbols
  8424.               libobjs=$output
  8425.               # Append the command to create the export file.
  8426.               test -z "$concat_cmds" || concat_cmds=$concat_cmds~
  8427.               eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
  8428.               if test -n "$last_robj"; then
  8429.                 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
  8430.               fi
  8431.             fi
  8432.  
  8433.             test -n "$save_libobjs" &&
  8434.               func_verbose "creating a temporary reloadable object file: $output"
  8435.  
  8436.             # Loop through the commands generated above and execute them.
  8437.             save_ifs="$IFS"; IFS='~'
  8438.             for cmd in $concat_cmds; do
  8439.               IFS="$save_ifs"
  8440.               $opt_silent || {
  8441.                   func_quote_for_expand "$cmd"
  8442.                   eval "func_echo $func_quote_for_expand_result"
  8443.               }
  8444.               $opt_dry_run || eval "$cmd" || {
  8445.                 lt_exit=$?
  8446.  
  8447.                 # Restore the uninstalled library and exit
  8448.                 if test "$opt_mode" = relink; then
  8449.                   ( cd "$output_objdir" && \
  8450.                     $RM "${realname}T" && \
  8451.                     $MV "${realname}U" "$realname" )
  8452.                 fi
  8453.  
  8454.                 exit $lt_exit
  8455.               }
  8456.             done
  8457.             IFS="$save_ifs"
  8458.  
  8459.             if test -n "$export_symbols_regex" && ${skipped_export-false}; then
  8460.               func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
  8461.               func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
  8462.             fi
  8463.           fi
  8464.  
  8465.           if ${skipped_export-false}; then
  8466.             if test -n "$export_symbols" && test -n "$include_expsyms"; then
  8467.               tmp_export_symbols="$export_symbols"
  8468.               test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
  8469.               $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
  8470.             fi
  8471.  
  8472.             if test -n "$orig_export_symbols"; then
  8473.               # The given exports_symbols file has to be filtered, so filter it.
  8474.               func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
  8475.               # FIXME: $output_objdir/$libname.filter potentially contains lots of
  8476.               # 's' commands which not all seds can handle. GNU sed should be fine
  8477.               # though. Also, the filter scales superlinearly with the number of
  8478.               # global variables. join(1) would be nice here, but unfortunately
  8479.               # isn't a blessed tool.
  8480.               $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
  8481.               func_append delfiles " $export_symbols $output_objdir/$libname.filter"
  8482.               export_symbols=$output_objdir/$libname.def
  8483.               $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
  8484.             fi
  8485.           fi
  8486.  
  8487.           libobjs=$output
  8488.           # Restore the value of output.
  8489.           output=$save_output
  8490.  
  8491.           if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
  8492.             eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
  8493.             test "X$libobjs" = "X " && libobjs=
  8494.           fi
  8495.           # Expand the library linking commands again to reset the
  8496.           # value of $libobjs for piecewise linking.
  8497.  
  8498.           # Do each of the archive commands.
  8499.           if test "$module" = yes && test -n "$module_cmds" ; then
  8500.             if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
  8501.               cmds=$module_expsym_cmds
  8502.             else
  8503.               cmds=$module_cmds
  8504.             fi
  8505.           else
  8506.             if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
  8507.               cmds=$archive_expsym_cmds
  8508.             else
  8509.               cmds=$archive_cmds
  8510.             fi
  8511.           fi
  8512.         fi
  8513.  
  8514.         if test -n "$delfiles"; then
  8515.           # Append the command to remove temporary files to $cmds.
  8516.           eval cmds=\"\$cmds~\$RM $delfiles\"
  8517.         fi
  8518.  
  8519.         # Add any objects from preloaded convenience libraries
  8520.         if test -n "$dlprefiles"; then
  8521.           gentop="$output_objdir/${outputname}x"
  8522.           func_append generated " $gentop"
  8523.  
  8524.           func_extract_archives $gentop $dlprefiles
  8525.           func_append libobjs " $func_extract_archives_result"
  8526.           test "X$libobjs" = "X " && libobjs=
  8527.         fi
  8528.  
  8529.         save_ifs="$IFS"; IFS='~'
  8530.         for cmd in $cmds; do
  8531.           IFS="$save_ifs"
  8532.           eval cmd=\"$cmd\"
  8533.           $opt_silent || {
  8534.             func_quote_for_expand "$cmd"
  8535.             eval "func_echo $func_quote_for_expand_result"
  8536.           }
  8537.           $opt_dry_run || eval "$cmd" || {
  8538.             lt_exit=$?
  8539.  
  8540.             # Restore the uninstalled library and exit
  8541.             if test "$opt_mode" = relink; then
  8542.               ( cd "$output_objdir" && \
  8543.                 $RM "${realname}T" && \
  8544.                 $MV "${realname}U" "$realname" )
  8545.             fi
  8546.  
  8547.             exit $lt_exit
  8548.           }
  8549.         done
  8550.         IFS="$save_ifs"
  8551.  
  8552.         # Restore the uninstalled library and exit
  8553.         if test "$opt_mode" = relink; then
  8554.           $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
  8555.  
  8556.           if test -n "$convenience"; then
  8557.             if test -z "$whole_archive_flag_spec"; then
  8558.               func_show_eval '${RM}r "$gentop"'
  8559.             fi
  8560.           fi
  8561.  
  8562.           exit $EXIT_SUCCESS
  8563.         fi
  8564.  
  8565.         # Create links to the real library.
  8566.         for linkname in $linknames; do
  8567.           if test "$realname" != "$linkname"; then
  8568.             func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
  8569.           fi
  8570.         done
  8571.  
  8572.         # If -module or -export-dynamic was specified, set the dlname.
  8573.         if test "$module" = yes || test "$export_dynamic" = yes; then
  8574.           # On all known operating systems, these are identical.
  8575.           dlname="$soname"
  8576.         fi
  8577.      fi
  8578.      ;;
  8579.  
  8580.    obj)
  8581.      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
  8582.         func_warning "\`-dlopen' is ignored for objects"
  8583.       fi
  8584.  
  8585.       case " $deplibs" in
  8586.       *\ -l* | *\ -L*)
  8587.         func_warning "\`-l' and \`-L' are ignored for objects" ;;
  8588.       esac
  8589.  
  8590.       test -n "$rpath" && \
  8591.         func_warning "\`-rpath' is ignored for objects"
  8592.  
  8593.      test -n "$xrpath" && \
  8594.         func_warning "\`-R' is ignored for objects"
  8595.  
  8596.       test -n "$vinfo" && \
  8597.         func_warning "\`-version-info' is ignored for objects"
  8598.  
  8599.      test -n "$release" && \
  8600.         func_warning "\`-release' is ignored for objects"
  8601.  
  8602.       case $output in
  8603.       *.lo)
  8604.         test -n "$objs$old_deplibs" && \
  8605.           func_fatal_error "cannot build library object \`$output' from non-libtool objects"
  8606.  
  8607.         libobj=$output
  8608.         func_lo2o "$libobj"
  8609.         obj=$func_lo2o_result
  8610.         ;;
  8611.      *)
  8612.         libobj=
  8613.         obj="$output"
  8614.         ;;
  8615.      esac
  8616.  
  8617.      # Delete the old objects.
  8618.      $opt_dry_run || $RM $obj $libobj
  8619.  
  8620.      # Objects from convenience libraries.  This assumes
  8621.      # single-version convenience libraries.  Whenever we create
  8622.      # different ones for PIC/non-PIC, this we'll have to duplicate
  8623.      # the extraction.
  8624.      reload_conv_objs=
  8625.      gentop=
  8626.      # reload_cmds runs $LD directly, so let us get rid of
  8627.      # -Wl from whole_archive_flag_spec and hope we can get by with
  8628.      # turning comma into space..
  8629.      wl=
  8630.  
  8631.      if test -n "$convenience"; then
  8632.         if test -n "$whole_archive_flag_spec"; then
  8633.           eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
  8634.           reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
  8635.         else
  8636.           gentop="$output_objdir/${obj}x"
  8637.           func_append generated " $gentop"
  8638.  
  8639.           func_extract_archives $gentop $convenience
  8640.           reload_conv_objs="$reload_objs $func_extract_archives_result"
  8641.         fi
  8642.      fi
  8643.  
  8644.      # If we're not building shared, we need to use non_pic_objs
  8645.      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
  8646.  
  8647.      # Create the old-style object.
  8648.      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
  8649.  
  8650.      output="$obj"
  8651.      func_execute_cmds "$reload_cmds" 'exit $?'
  8652.  
  8653.      # Exit if we aren't doing a library object file.
  8654.      if test -z "$libobj"; then
  8655.         if test -n "$gentop"; then
  8656.           func_show_eval '${RM}r "$gentop"'
  8657.         fi
  8658.  
  8659.         exit $EXIT_SUCCESS
  8660.      fi
  8661.  
  8662.      if test "$build_libtool_libs" != yes; then
  8663.         if test -n "$gentop"; then
  8664.           func_show_eval '${RM}r "$gentop"'
  8665.         fi
  8666.  
  8667.         # Create an invalid libtool object if no PIC, so that we don't
  8668.         # accidentally link it into a program.
  8669.         # $show "echo timestamp > $libobj"
  8670.         # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
  8671.         exit $EXIT_SUCCESS
  8672.      fi
  8673.  
  8674.      if test -n "$pic_flag" || test "$pic_mode" != default; then
  8675.         # Only do commands if we really have different PIC objects.
  8676.         reload_objs="$libobjs $reload_conv_objs"
  8677.         output="$libobj"
  8678.         func_execute_cmds "$reload_cmds" 'exit $?'
  8679.      fi
  8680.  
  8681.      if test -n "$gentop"; then
  8682.         func_show_eval '${RM}r "$gentop"'
  8683.      fi
  8684.  
  8685.      exit $EXIT_SUCCESS
  8686.      ;;
  8687.  
  8688.    prog)
  8689.      case $host in
  8690.         *cygwin*) func_stripname '' '.exe' "$output"
  8691.                   output=$func_stripname_result.exe;;
  8692.      esac
  8693.      test -n "$vinfo" && \
  8694.         func_warning "\`-version-info' is ignored for programs"
  8695.  
  8696.       test -n "$release" && \
  8697.         func_warning "\`-release' is ignored for programs"
  8698.  
  8699.      test "$preload" = yes \
  8700.        && test "$dlopen_support" = unknown \
  8701.         && test "$dlopen_self" = unknown \
  8702.         && test "$dlopen_self_static" = unknown && \
  8703.           func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
  8704.  
  8705.       case $host in
  8706.       *-*-rhapsody* | *-*-darwin1.[012])
  8707.         # On Rhapsody replace the C library is the System framework
  8708.         compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
  8709.         finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
  8710.         ;;
  8711.       esac
  8712.  
  8713.       case $host in
  8714.       *-*-darwin*)
  8715.         # Don't allow lazy linking, it breaks C++ global constructors
  8716.         # But is supposedly fixed on 10.4 or later (yay!).
  8717.         if test "$tagname" = CXX ; then
  8718.           case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
  8719.             10.[0123])
  8720.               func_append compile_command " ${wl}-bind_at_load"
  8721.               func_append finalize_command " ${wl}-bind_at_load"
  8722.             ;;
  8723.           esac
  8724.         fi
  8725.         # Time to change all our "foo.ltframework" stuff back to "-framework foo"
  8726.         compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
  8727.         finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
  8728.         ;;
  8729.       esac
  8730.  
  8731.  
  8732.       # move library search paths that coincide with paths to not yet
  8733.       # installed libraries to the beginning of the library search list
  8734.       new_libs=
  8735.       for path in $notinst_path; do
  8736.         case " $new_libs " in
  8737.         *" -L$path/$objdir "*) ;;
  8738.         *)
  8739.           case " $compile_deplibs " in
  8740.           *" -L$path/$objdir "*)
  8741.             func_append new_libs " -L$path/$objdir" ;;
  8742.           esac
  8743.           ;;
  8744.         esac
  8745.       done
  8746.       for deplib in $compile_deplibs; do
  8747.         case $deplib in
  8748.         -L*)
  8749.           case " $new_libs " in
  8750.           *" $deplib "*) ;;
  8751.           *) func_append new_libs " $deplib" ;;
  8752.           esac
  8753.           ;;
  8754.         *) func_append new_libs " $deplib" ;;
  8755.         esac
  8756.       done
  8757.       compile_deplibs="$new_libs"
  8758.  
  8759.  
  8760.       func_append compile_command " $compile_deplibs"
  8761.       func_append finalize_command " $finalize_deplibs"
  8762.  
  8763.       if test -n "$rpath$xrpath"; then
  8764.         # If the user specified any rpath flags, then add them.
  8765.         for libdir in $rpath $xrpath; do
  8766.           # This is the magic to use -rpath.
  8767.           case "$finalize_rpath " in
  8768.           *" $libdir "*) ;;
  8769.           *) func_append finalize_rpath " $libdir" ;;
  8770.           esac
  8771.         done
  8772.       fi
  8773.  
  8774.       # Now hardcode the library paths
  8775.       rpath=
  8776.       hardcode_libdirs=
  8777.       for libdir in $compile_rpath $finalize_rpath; do
  8778.         if test -n "$hardcode_libdir_flag_spec"; then
  8779.           if test -n "$hardcode_libdir_separator"; then
  8780.             if test -z "$hardcode_libdirs"; then
  8781.               hardcode_libdirs="$libdir"
  8782.             else
  8783.               # Just accumulate the unique libdirs.
  8784.               case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
  8785.               *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
  8786.                 ;;
  8787.               *)
  8788.                 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
  8789.                 ;;
  8790.               esac
  8791.             fi
  8792.           else
  8793.             eval flag=\"$hardcode_libdir_flag_spec\"
  8794.             func_append rpath " $flag"
  8795.           fi
  8796.         elif test -n "$runpath_var"; then
  8797.           case "$perm_rpath " in
  8798.           *" $libdir "*) ;;
  8799.           *) func_append perm_rpath " $libdir" ;;
  8800.           esac
  8801.         fi
  8802.         case $host in
  8803.         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
  8804.           testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
  8805.           case :$dllsearchpath: in
  8806.           *":$libdir:"*) ;;
  8807.           ::) dllsearchpath=$libdir;;
  8808.           *) func_append dllsearchpath ":$libdir";;
  8809.           esac
  8810.           case :$dllsearchpath: in
  8811.           *":$testbindir:"*) ;;
  8812.           ::) dllsearchpath=$testbindir;;
  8813.           *) func_append dllsearchpath ":$testbindir";;
  8814.           esac
  8815.           ;;
  8816.         esac
  8817.       done
  8818.       # Substitute the hardcoded libdirs into the rpath.
  8819.       if test -n "$hardcode_libdir_separator" &&
  8820.          test -n "$hardcode_libdirs"; then
  8821.         libdir="$hardcode_libdirs"
  8822.         eval rpath=\" $hardcode_libdir_flag_spec\"
  8823.       fi
  8824.       compile_rpath="$rpath"
  8825.  
  8826.       rpath=
  8827.       hardcode_libdirs=
  8828.       for libdir in $finalize_rpath; do
  8829.         if test -n "$hardcode_libdir_flag_spec"; then
  8830.           if test -n "$hardcode_libdir_separator"; then
  8831.             if test -z "$hardcode_libdirs"; then
  8832.               hardcode_libdirs="$libdir"
  8833.             else
  8834.               # Just accumulate the unique libdirs.
  8835.               case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
  8836.               *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
  8837.                 ;;
  8838.               *)
  8839.                 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
  8840.                 ;;
  8841.               esac
  8842.             fi
  8843.           else
  8844.             eval flag=\"$hardcode_libdir_flag_spec\"
  8845.             func_append rpath " $flag"
  8846.           fi
  8847.         elif test -n "$runpath_var"; then
  8848.           case "$finalize_perm_rpath " in
  8849.           *" $libdir "*) ;;
  8850.           *) func_append finalize_perm_rpath " $libdir" ;;
  8851.           esac
  8852.         fi
  8853.       done
  8854.       # Substitute the hardcoded libdirs into the rpath.
  8855.       if test -n "$hardcode_libdir_separator" &&
  8856.          test -n "$hardcode_libdirs"; then
  8857.         libdir="$hardcode_libdirs"
  8858.         eval rpath=\" $hardcode_libdir_flag_spec\"
  8859.       fi
  8860.       finalize_rpath="$rpath"
  8861.  
  8862.       if test -n "$libobjs" && test "$build_old_libs" = yes; then
  8863.         # Transform all the library objects into standard objects.
  8864.         compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
  8865.         finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
  8866.       fi
  8867.  
  8868.       func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
  8869.  
  8870.       # template prelinking step
  8871.       if test -n "$prelink_cmds"; then
  8872.         func_execute_cmds "$prelink_cmds" 'exit $?'
  8873.       fi
  8874.  
  8875.       wrappers_required=yes
  8876.       case $host in
  8877.       *cegcc* | *mingw32ce*)
  8878.         # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
  8879.         wrappers_required=no
  8880.         ;;
  8881.       *cygwin* | *mingw* )
  8882.         if test "$build_libtool_libs" != yes; then
  8883.           wrappers_required=no
  8884.         fi
  8885.         ;;
  8886.       *)
  8887.         if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
  8888.           wrappers_required=no
  8889.         fi
  8890.         ;;
  8891.       esac
  8892.       if test "$wrappers_required" = no; then
  8893.         # Replace the output file specification.
  8894.         compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
  8895.         link_command="$compile_command$compile_rpath"
  8896.  
  8897.         # We have no uninstalled library dependencies, so finalize right now.
  8898.         exit_status=0
  8899.         func_show_eval "$link_command" 'exit_status=$?'
  8900.  
  8901.         if test -n "$postlink_cmds"; then
  8902.           func_to_tool_file "$output"
  8903.           postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
  8904.           func_execute_cmds "$postlink_cmds" 'exit $?'
  8905.         fi
  8906.  
  8907.         # Delete the generated files.
  8908.         if test -f "$output_objdir/${outputname}S.${objext}"; then
  8909.           func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
  8910.         fi
  8911.  
  8912.         exit $exit_status
  8913.       fi
  8914.  
  8915.       if test -n "$compile_shlibpath$finalize_shlibpath"; then
  8916.         compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
  8917.       fi
  8918.       if test -n "$finalize_shlibpath"; then
  8919.         finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
  8920.       fi
  8921.  
  8922.       compile_var=
  8923.       finalize_var=
  8924.       if test -n "$runpath_var"; then
  8925.         if test -n "$perm_rpath"; then
  8926.           # We should set the runpath_var.
  8927.           rpath=
  8928.           for dir in $perm_rpath; do
  8929.             func_append rpath "$dir:"
  8930.           done
  8931.           compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
  8932.         fi
  8933.         if test -n "$finalize_perm_rpath"; then
  8934.           # We should set the runpath_var.
  8935.           rpath=
  8936.           for dir in $finalize_perm_rpath; do
  8937.             func_append rpath "$dir:"
  8938.           done
  8939.           finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
  8940.         fi
  8941.       fi
  8942.  
  8943.       if test "$no_install" = yes; then
  8944.         # We don't need to create a wrapper script.
  8945.         link_command="$compile_var$compile_command$compile_rpath"
  8946.         # Replace the output file specification.
  8947.         link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
  8948.         # Delete the old output file.
  8949.         $opt_dry_run || $RM $output
  8950.         # Link the executable and exit
  8951.         func_show_eval "$link_command" 'exit $?'
  8952.  
  8953.         if test -n "$postlink_cmds"; then
  8954.           func_to_tool_file "$output"
  8955.           postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
  8956.           func_execute_cmds "$postlink_cmds" 'exit $?'
  8957.         fi
  8958.  
  8959.         exit $EXIT_SUCCESS
  8960.       fi
  8961.  
  8962.       if test "$hardcode_action" = relink; then
  8963.         # Fast installation is not supported
  8964.         link_command="$compile_var$compile_command$compile_rpath"
  8965.         relink_command="$finalize_var$finalize_command$finalize_rpath"
  8966.  
  8967.         func_warning "this platform does not like uninstalled shared libraries"
  8968.         func_warning "\`$output' will be relinked during installation"
  8969.      else
  8970.         if test "$fast_install" != no; then
  8971.           link_command="$finalize_var$compile_command$finalize_rpath"
  8972.           if test "$fast_install" = yes; then
  8973.             relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
  8974.           else
  8975.             # fast_install is set to needless
  8976.             relink_command=
  8977.           fi
  8978.         else
  8979.           link_command="$compile_var$compile_command$compile_rpath"
  8980.           relink_command="$finalize_var$finalize_command$finalize_rpath"
  8981.         fi
  8982.      fi
  8983.  
  8984.      # Replace the output file specification.
  8985.      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
  8986.  
  8987.      # Delete the old output files.
  8988.      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
  8989.  
  8990.      func_show_eval "$link_command" 'exit $?'
  8991.  
  8992.      if test -n "$postlink_cmds"; then
  8993.         func_to_tool_file "$output_objdir/$outputname"
  8994.         postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
  8995.         func_execute_cmds "$postlink_cmds" 'exit $?'
  8996.      fi
  8997.  
  8998.      # Now create the wrapper script.
  8999.      func_verbose "creating $output"
  9000.  
  9001.      # Quote the relink command for shipping.
  9002.      if test -n "$relink_command"; then
  9003.         # Preserve any variables that may affect compiler behavior
  9004.         for var in $variables_saved_for_relink; do
  9005.           if eval test -z \"\${$var+set}\"; then
  9006.             relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
  9007.           elif eval var_value=\$$var; test -z "$var_value"; then
  9008.             relink_command="$var=; export $var; $relink_command"
  9009.           else
  9010.             func_quote_for_eval "$var_value"
  9011.             relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
  9012.           fi
  9013.         done
  9014.         relink_command="(cd `pwd`; $relink_command)"
  9015.         relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
  9016.      fi
  9017.  
  9018.      # Only actually do things if not in dry run mode.
  9019.      $opt_dry_run || {
  9020.         # win32 will think the script is a binary if it has
  9021.         # a .exe suffix, so we strip it off here.
  9022.         case $output in
  9023.           *.exe) func_stripname '' '.exe' "$output"
  9024.                  output=$func_stripname_result ;;
  9025.         esac
  9026.         # test for cygwin because mv fails w/o .exe extensions
  9027.         case $host in
  9028.           *cygwin*)
  9029.             exeext=.exe
  9030.             func_stripname '' '.exe' "$outputname"
  9031.             outputname=$func_stripname_result ;;
  9032.           *) exeext= ;;
  9033.         esac
  9034.         case $host in
  9035.           *cygwin* | *mingw* )
  9036.             func_dirname_and_basename "$output" "" "."
  9037.             output_name=$func_basename_result
  9038.             output_path=$func_dirname_result
  9039.             cwrappersource="$output_path/$objdir/lt-$output_name.c"
  9040.             cwrapper="$output_path/$output_name.exe"
  9041.             $RM $cwrappersource $cwrapper
  9042.             trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
  9043.  
  9044.             func_emit_cwrapperexe_src > $cwrappersource
  9045.  
  9046.             # The wrapper executable is built using the $host compiler,
  9047.             # because it contains $host paths and files. If cross-
  9048.             # compiling, it, like the target executable, must be
  9049.             # executed on the $host or under an emulation environment.
  9050.             $opt_dry_run || {
  9051.               $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
  9052.               $STRIP $cwrapper
  9053.             }
  9054.  
  9055.             # Now, create the wrapper script for func_source use:
  9056.             func_ltwrapper_scriptname $cwrapper
  9057.             $RM $func_ltwrapper_scriptname_result
  9058.             trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
  9059.             $opt_dry_run || {
  9060.               # note: this script will not be executed, so do not chmod.
  9061.               if test "x$build" = "x$host" ; then
  9062.                 $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
  9063.               else
  9064.                 func_emit_wrapper no > $func_ltwrapper_scriptname_result
  9065.               fi
  9066.             }
  9067.           ;;
  9068.           * )
  9069.             $RM $output
  9070.             trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
  9071.  
  9072.             func_emit_wrapper no > $output
  9073.             chmod +x $output
  9074.           ;;
  9075.         esac
  9076.      }
  9077.      exit $EXIT_SUCCESS
  9078.      ;;
  9079.    esac
  9080.  
  9081.    # See if we need to build an old-fashioned archive.
  9082.    for oldlib in $oldlibs; do
  9083.  
  9084.      if test "$build_libtool_libs" = convenience; then
  9085.         oldobjs="$libobjs_save $symfileobj"
  9086.         addlibs="$convenience"
  9087.         build_libtool_libs=no
  9088.      else
  9089.         if test "$build_libtool_libs" = module; then
  9090.           oldobjs="$libobjs_save"
  9091.           build_libtool_libs=no
  9092.         else
  9093.           oldobjs="$old_deplibs $non_pic_objects"
  9094.           if test "$preload" = yes && test -f "$symfileobj"; then
  9095.             func_append oldobjs " $symfileobj"
  9096.           fi
  9097.         fi
  9098.         addlibs="$old_convenience"
  9099.      fi
  9100.  
  9101.      if test -n "$addlibs"; then
  9102.         gentop="$output_objdir/${outputname}x"
  9103.         func_append generated " $gentop"
  9104.  
  9105.         func_extract_archives $gentop $addlibs
  9106.         func_append oldobjs " $func_extract_archives_result"
  9107.      fi
  9108.  
  9109.      # Do each command in the archive commands.
  9110.      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
  9111.         cmds=$old_archive_from_new_cmds
  9112.      else
  9113.  
  9114.         # Add any objects from preloaded convenience libraries
  9115.         if test -n "$dlprefiles"; then
  9116.           gentop="$output_objdir/${outputname}x"
  9117.           func_append generated " $gentop"
  9118.  
  9119.           func_extract_archives $gentop $dlprefiles
  9120.           func_append oldobjs " $func_extract_archives_result"
  9121.         fi
  9122.  
  9123.         # POSIX demands no paths to be encoded in archives.  We have
  9124.         # to avoid creating archives with duplicate basenames if we
  9125.         # might have to extract them afterwards, e.g., when creating a
  9126.         # static archive out of a convenience library, or when linking
  9127.         # the entirety of a libtool archive into another (currently
  9128.         # not supported by libtool).
  9129.         if (for obj in $oldobjs
  9130.             do
  9131.               func_basename "$obj"
  9132.               $ECHO "$func_basename_result"
  9133.             done | sort | sort -uc >/dev/null 2>&1); then
  9134.           :
  9135.         else
  9136.           echo "copying selected object files to avoid basename conflicts..."
  9137.           gentop="$output_objdir/${outputname}x"
  9138.           func_append generated " $gentop"
  9139.           func_mkdir_p "$gentop"
  9140.           save_oldobjs=$oldobjs
  9141.           oldobjs=
  9142.           counter=1
  9143.           for obj in $save_oldobjs
  9144.           do
  9145.             func_basename "$obj"
  9146.             objbase="$func_basename_result"
  9147.             case " $oldobjs " in
  9148.             " ") oldobjs=$obj ;;
  9149.             *[\ /]"$objbase "*)
  9150.               while :; do
  9151.                 # Make sure we don't pick an alternate name that also
  9152.                 # overlaps.
  9153.                 newobj=lt$counter-$objbase
  9154.                 func_arith $counter + 1
  9155.                 counter=$func_arith_result
  9156.                 case " $oldobjs " in
  9157.                 *[\ /]"$newobj "*) ;;
  9158.                 *) if test ! -f "$gentop/$newobj"; then break; fi ;;
  9159.                 esac
  9160.               done
  9161.               func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
  9162.               func_append oldobjs " $gentop/$newobj"
  9163.               ;;
  9164.             *) func_append oldobjs " $obj" ;;
  9165.             esac
  9166.           done
  9167.         fi
  9168.         func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
  9169.         tool_oldlib=$func_to_tool_file_result
  9170.         eval cmds=\"$old_archive_cmds\"
  9171.  
  9172.         func_len " $cmds"
  9173.         len=$func_len_result
  9174.         if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
  9175.           cmds=$old_archive_cmds
  9176.         elif test -n "$archiver_list_spec"; then
  9177.           func_verbose "using command file archive linking..."
  9178.           for obj in $oldobjs
  9179.           do
  9180.             func_to_tool_file "$obj"
  9181.             $ECHO "$func_to_tool_file_result"
  9182.           done > $output_objdir/$libname.libcmd
  9183.           func_to_tool_file "$output_objdir/$libname.libcmd"
  9184.           oldobjs=" $archiver_list_spec$func_to_tool_file_result"
  9185.           cmds=$old_archive_cmds
  9186.         else
  9187.           # the command line is too long to link in one step, link in parts
  9188.           func_verbose "using piecewise archive linking..."
  9189.           save_RANLIB=$RANLIB
  9190.           RANLIB=:
  9191.           objlist=
  9192.           concat_cmds=
  9193.           save_oldobjs=$oldobjs
  9194.           oldobjs=
  9195.           # Is there a better way of finding the last object in the list?
  9196.           for obj in $save_oldobjs
  9197.           do
  9198.             last_oldobj=$obj
  9199.           done
  9200.           eval test_cmds=\"$old_archive_cmds\"
  9201.           func_len " $test_cmds"
  9202.           len0=$func_len_result
  9203.           len=$len0
  9204.           for obj in $save_oldobjs
  9205.           do
  9206.             func_len " $obj"
  9207.             func_arith $len + $func_len_result
  9208.             len=$func_arith_result
  9209.             func_append objlist " $obj"
  9210.             if test "$len" -lt "$max_cmd_len"; then
  9211.               :
  9212.             else
  9213.               # the above command should be used before it gets too long
  9214.               oldobjs=$objlist
  9215.               if test "$obj" = "$last_oldobj" ; then
  9216.                 RANLIB=$save_RANLIB
  9217.               fi
  9218.               test -z "$concat_cmds" || concat_cmds=$concat_cmds~
  9219.               eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
  9220.               objlist=
  9221.               len=$len0
  9222.             fi
  9223.           done
  9224.           RANLIB=$save_RANLIB
  9225.           oldobjs=$objlist
  9226.           if test "X$oldobjs" = "X" ; then
  9227.             eval cmds=\"\$concat_cmds\"
  9228.           else
  9229.             eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
  9230.           fi
  9231.         fi
  9232.      fi
  9233.      func_execute_cmds "$cmds" 'exit $?'
  9234.    done
  9235.  
  9236.    test -n "$generated" && \
  9237.      func_show_eval "${RM}r$generated"
  9238.  
  9239.    # Now create the libtool archive.
  9240.    case $output in
  9241.    *.la)
  9242.      old_library=
  9243.      test "$build_old_libs" = yes && old_library="$libname.$libext"
  9244.      func_verbose "creating $output"
  9245.  
  9246.      # Preserve any variables that may affect compiler behavior
  9247.      for var in $variables_saved_for_relink; do
  9248.         if eval test -z \"\${$var+set}\"; then
  9249.           relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
  9250.         elif eval var_value=\$$var; test -z "$var_value"; then
  9251.           relink_command="$var=; export $var; $relink_command"
  9252.         else
  9253.           func_quote_for_eval "$var_value"
  9254.           relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
  9255.         fi
  9256.      done
  9257.      # Quote the link command for shipping.
  9258.      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
  9259.      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
  9260.      if test "$hardcode_automatic" = yes ; then
  9261.         relink_command=
  9262.      fi
  9263.  
  9264.      # Only create the output if not a dry run.
  9265.      $opt_dry_run || {
  9266.         for installed in no yes; do
  9267.           if test "$installed" = yes; then
  9268.             if test -z "$install_libdir"; then
  9269.               break
  9270.             fi
  9271.             output="$output_objdir/$outputname"i
  9272.             # Replace all uninstalled libtool libraries with the installed ones
  9273.             newdependency_libs=
  9274.             for deplib in $dependency_libs; do
  9275.               case $deplib in
  9276.               *.la)
  9277.                 func_basename "$deplib"
  9278.                 name="$func_basename_result"
  9279.                 func_resolve_sysroot "$deplib"
  9280.                 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
  9281.                 test -z "$libdir" && \
  9282.                   func_fatal_error "\`$deplib' is not a valid libtool archive"
  9283.                 func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
  9284.                 ;;
  9285.               -L*)
  9286.                 func_stripname -L '' "$deplib"
  9287.                 func_replace_sysroot "$func_stripname_result"
  9288.                 func_append newdependency_libs " -L$func_replace_sysroot_result"
  9289.                 ;;
  9290.               -R*)
  9291.                 func_stripname -R '' "$deplib"
  9292.                 func_replace_sysroot "$func_stripname_result"
  9293.                 func_append newdependency_libs " -R$func_replace_sysroot_result"
  9294.                 ;;
  9295.               *) func_append newdependency_libs " $deplib" ;;
  9296.               esac
  9297.             done
  9298.             dependency_libs="$newdependency_libs"
  9299.             newdlfiles=
  9300.  
  9301.             for lib in $dlfiles; do
  9302.               case $lib in
  9303.               *.la)
  9304.                 func_basename "$lib"
  9305.                 name="$func_basename_result"
  9306.                 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
  9307.                 test -z "$libdir" && \
  9308.                   func_fatal_error "\`$lib' is not a valid libtool archive"
  9309.                 func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
  9310.                 ;;
  9311.               *) func_append newdlfiles " $lib" ;;
  9312.               esac
  9313.             done
  9314.             dlfiles="$newdlfiles"
  9315.             newdlprefiles=
  9316.             for lib in $dlprefiles; do
  9317.               case $lib in
  9318.               *.la)
  9319.                 # Only pass preopened files to the pseudo-archive (for
  9320.                 # eventual linking with the app. that links it) if we
  9321.                 # didn't already link the preopened objects directly into
  9322.                 # the library:
  9323.                 func_basename "$lib"
  9324.                 name="$func_basename_result"
  9325.                 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
  9326.                 test -z "$libdir" && \
  9327.                   func_fatal_error "\`$lib' is not a valid libtool archive"
  9328.                 func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
  9329.                 ;;
  9330.               esac
  9331.             done
  9332.             dlprefiles="$newdlprefiles"
  9333.           else
  9334.             newdlfiles=
  9335.             for lib in $dlfiles; do
  9336.               case $lib in
  9337.                 [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
  9338.                 *) abs=`pwd`"/$lib" ;;
  9339.               esac
  9340.               func_append newdlfiles " $abs"
  9341.             done
  9342.             dlfiles="$newdlfiles"
  9343.             newdlprefiles=
  9344.             for lib in $dlprefiles; do
  9345.               case $lib in
  9346.                 [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
  9347.                 *) abs=`pwd`"/$lib" ;;
  9348.               esac
  9349.               func_append newdlprefiles " $abs"
  9350.             done
  9351.             dlprefiles="$newdlprefiles"
  9352.           fi
  9353.           $RM $output
  9354.           # place dlname in correct position for cygwin
  9355.           # In fact, it would be nice if we could use this code for all target
  9356.           # systems that can't hard-code library paths into their executables
  9357.           # and that have no shared library path variable independent of PATH,
  9358.           # but it turns out we can't easily determine that from inspecting
  9359.           # libtool variables, so we have to hard-code the OSs to which it
  9360.           # applies here; at the moment, that means platforms that use the PE
  9361.           # object format with DLL files.  See the long comment at the top of
  9362.           # tests/bindir.at for full details.
  9363.           tdlname=$dlname
  9364.           case $host,$output,$installed,$module,$dlname in
  9365.             *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
  9366.               # If a -bindir argument was supplied, place the dll there.
  9367.               if test "x$bindir" != x ;
  9368.               then
  9369.                 func_relative_path "$install_libdir" "$bindir"
  9370.                 tdlname=$func_relative_path_result$dlname
  9371.               else
  9372.                 # Otherwise fall back on heuristic.
  9373.                 tdlname=../bin/$dlname
  9374.               fi
  9375.               ;;
  9376.           esac
  9377.           $ECHO > $output "\
  9378. # $outputname - a libtool library file
  9379. # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
  9380. #
  9381. # Please DO NOT delete this file!
  9382. # It is necessary for linking the library.
  9383.  
  9384. # The name that we can dlopen(3).
  9385. dlname='$tdlname'
  9386.  
  9387. # Names of this library.
  9388. library_names='$library_names'
  9389.  
  9390. # The name of the static archive.
  9391. old_library='$old_library'
  9392.  
  9393. # Linker flags that can not go in dependency_libs.
  9394. inherited_linker_flags='$new_inherited_linker_flags'
  9395.  
  9396. # Libraries that this one depends upon.
  9397. dependency_libs='$dependency_libs'
  9398.  
  9399. # Names of additional weak libraries provided by this library
  9400. weak_library_names='$weak_libs'
  9401.  
  9402. # Version information for $libname.
  9403. current=$current
  9404. age=$age
  9405. revision=$revision
  9406.  
  9407. # Is this an already installed library?
  9408. installed=$installed
  9409.  
  9410. # Should we warn about portability when linking against -modules?
  9411. shouldnotlink=$module
  9412.  
  9413. # Files to dlopen/dlpreopen
  9414. dlopen='$dlfiles'
  9415. dlpreopen='$dlprefiles'
  9416.  
  9417. # Directory that this library needs to be installed in:
  9418. libdir='$install_libdir'"
  9419.           if test "$installed" = no && test "$need_relink" = yes; then
  9420.             $ECHO >> $output "\
  9421. relink_command=\"$relink_command\""
  9422.           fi
  9423.         done
  9424.       }
  9425.  
  9426.       # Do a symbolic link so that the libtool archive can be found in
  9427.       # LD_LIBRARY_PATH before the program is installed.
  9428.       func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
  9429.       ;;
  9430.     esac
  9431.     exit $EXIT_SUCCESS
  9432. }
  9433.  
  9434. { test "$opt_mode" = link || test "$opt_mode" = relink; } &&
  9435.     func_mode_link ${1+"$@"}
  9436.  
  9437.  
  9438. # func_mode_uninstall arg...
  9439. func_mode_uninstall ()
  9440. {
  9441.     $opt_debug
  9442.     RM="$nonopt"
  9443.     files=
  9444.     rmforce=
  9445.     exit_status=0
  9446.  
  9447.     # This variable tells wrapper scripts just to set variables rather
  9448.     # than running their programs.
  9449.     libtool_install_magic="$magic"
  9450.  
  9451.     for arg
  9452.     do
  9453.       case $arg in
  9454.       -f) func_append RM " $arg"; rmforce=yes ;;
  9455.       -*) func_append RM " $arg" ;;
  9456.       *) func_append files " $arg" ;;
  9457.       esac
  9458.     done
  9459.  
  9460.     test -z "$RM" && \
  9461.       func_fatal_help "you must specify an RM program"
  9462.  
  9463.     rmdirs=
  9464.  
  9465.     for file in $files; do
  9466.       func_dirname "$file" "" "."
  9467.       dir="$func_dirname_result"
  9468.       if test "X$dir" = X.; then
  9469.         odir="$objdir"
  9470.       else
  9471.         odir="$dir/$objdir"
  9472.       fi
  9473.       func_basename "$file"
  9474.       name="$func_basename_result"
  9475.       test "$opt_mode" = uninstall && odir="$dir"
  9476.  
  9477.       # Remember odir for removal later, being careful to avoid duplicates
  9478.       if test "$opt_mode" = clean; then
  9479.         case " $rmdirs " in
  9480.           *" $odir "*) ;;
  9481.           *) func_append rmdirs " $odir" ;;
  9482.         esac
  9483.       fi
  9484.  
  9485.       # Don't error if the file doesn't exist and rm -f was used.
  9486.       if { test -L "$file"; } >/dev/null 2>&1 ||
  9487.          { test -h "$file"; } >/dev/null 2>&1 ||
  9488.          test -f "$file"; then
  9489.         :
  9490.       elif test -d "$file"; then
  9491.         exit_status=1
  9492.         continue
  9493.       elif test "$rmforce" = yes; then
  9494.         continue
  9495.       fi
  9496.  
  9497.       rmfiles="$file"
  9498.  
  9499.       case $name in
  9500.       *.la)
  9501.         # Possibly a libtool archive, so verify it.
  9502.         if func_lalib_p "$file"; then
  9503.           func_source $dir/$name
  9504.  
  9505.           # Delete the libtool libraries and symlinks.
  9506.           for n in $library_names; do
  9507.             func_append rmfiles " $odir/$n"
  9508.           done
  9509.           test -n "$old_library" && func_append rmfiles " $odir/$old_library"
  9510.  
  9511.           case "$opt_mode" in
  9512.           clean)
  9513.             case " $library_names " in
  9514.             *" $dlname "*) ;;
  9515.             *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
  9516.             esac
  9517.             test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
  9518.             ;;
  9519.           uninstall)
  9520.             if test -n "$library_names"; then
  9521.               # Do each command in the postuninstall commands.
  9522.               func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
  9523.             fi
  9524.  
  9525.             if test -n "$old_library"; then
  9526.               # Do each command in the old_postuninstall commands.
  9527.               func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
  9528.             fi
  9529.             # FIXME: should reinstall the best remaining shared library.
  9530.             ;;
  9531.           esac
  9532.         fi
  9533.         ;;
  9534.  
  9535.       *.lo)
  9536.         # Possibly a libtool object, so verify it.
  9537.         if func_lalib_p "$file"; then
  9538.  
  9539.           # Read the .lo file
  9540.           func_source $dir/$name
  9541.  
  9542.           # Add PIC object to the list of files to remove.
  9543.           if test -n "$pic_object" &&
  9544.              test "$pic_object" != none; then
  9545.             func_append rmfiles " $dir/$pic_object"
  9546.           fi
  9547.  
  9548.           # Add non-PIC object to the list of files to remove.
  9549.           if test -n "$non_pic_object" &&
  9550.              test "$non_pic_object" != none; then
  9551.             func_append rmfiles " $dir/$non_pic_object"
  9552.           fi
  9553.         fi
  9554.         ;;
  9555.  
  9556.       *)
  9557.         if test "$opt_mode" = clean ; then
  9558.           noexename=$name
  9559.           case $file in
  9560.           *.exe)
  9561.             func_stripname '' '.exe' "$file"
  9562.             file=$func_stripname_result
  9563.             func_stripname '' '.exe' "$name"
  9564.             noexename=$func_stripname_result
  9565.             # $file with .exe has already been added to rmfiles,
  9566.             # add $file without .exe
  9567.             func_append rmfiles " $file"
  9568.             ;;
  9569.           esac
  9570.           # Do a test to see if this is a libtool program.
  9571.           if func_ltwrapper_p "$file"; then
  9572.             if func_ltwrapper_executable_p "$file"; then
  9573.               func_ltwrapper_scriptname "$file"
  9574.               relink_command=
  9575.               func_source $func_ltwrapper_scriptname_result
  9576.               func_append rmfiles " $func_ltwrapper_scriptname_result"
  9577.             else
  9578.               relink_command=
  9579.               func_source $dir/$noexename
  9580.             fi
  9581.  
  9582.             # note $name still contains .exe if it was in $file originally
  9583.             # as does the version of $file that was added into $rmfiles
  9584.             func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
  9585.             if test "$fast_install" = yes && test -n "$relink_command"; then
  9586.               func_append rmfiles " $odir/lt-$name"
  9587.             fi
  9588.             if test "X$noexename" != "X$name" ; then
  9589.               func_append rmfiles " $odir/lt-${noexename}.c"
  9590.             fi
  9591.           fi
  9592.         fi
  9593.         ;;
  9594.       esac
  9595.       func_show_eval "$RM $rmfiles" 'exit_status=1'
  9596.     done
  9597.  
  9598.     # Try to remove the ${objdir}s in the directories where we deleted files
  9599.     for dir in $rmdirs; do
  9600.       if test -d "$dir"; then
  9601.         func_show_eval "rmdir $dir >/dev/null 2>&1"
  9602.       fi
  9603.     done
  9604.  
  9605.     exit $exit_status
  9606. }
  9607.  
  9608. { test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
  9609.     func_mode_uninstall ${1+"$@"}
  9610.  
  9611. test -z "$opt_mode" && {
  9612.   help="$generic_help"
  9613.   func_fatal_help "you must specify a MODE"
  9614. }
  9615.  
  9616. test -z "$exec_cmd" && \
  9617.   func_fatal_help "invalid operation mode \`$opt_mode'"
  9618.  
  9619. if test -n "$exec_cmd"; then
  9620.  eval exec "$exec_cmd"
  9621.  exit $EXIT_FAILURE
  9622. fi
  9623.  
  9624. exit $exit_status
  9625.  
  9626.  
  9627. # The TAGs below are defined such that we never get into a situation
  9628. # in which we disable both kinds of libraries.  Given conflicting
  9629. # choices, we go for a static library, that is the most portable,
  9630. # since we can't tell whether shared libraries were disabled because
  9631. # the user asked for that or because the platform doesn't support
  9632. # them.  This is particularly important on AIX, because we don't
  9633. # support having both static and shared libraries enabled at the same
  9634. # time on that platform, so we default to a shared-only configuration.
  9635. # If a disable-shared tag is given, we'll fallback to a static-only
  9636. # configuration.  But we'll never go from static-only to shared-only.
  9637.  
  9638. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
  9639. build_libtool_libs=no
  9640. build_old_libs=yes
  9641. # ### END LIBTOOL TAG CONFIG: disable-shared
  9642.  
  9643. # ### BEGIN LIBTOOL TAG CONFIG: disable-static
  9644. build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
  9645. # ### END LIBTOOL TAG CONFIG: disable-static
  9646.  
  9647. # Local Variables:
  9648. # mode:shell-script
  9649. # sh-indentation:2
  9650. # End:
  9651. # vi:sw=2
  9652.  
  9653.