183e03a40Smrg
283e03a40Smrg# libtool (GNU libtool) 2.4
383e03a40Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
483e03a40Smrg
55d713044Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
683e03a40Smrg# 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
783e03a40Smrg# This is free software; see the source for copying conditions.  There is NO
883e03a40Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
983e03a40Smrg
1083e03a40Smrg# GNU Libtool is free software; you can redistribute it and/or modify
11357bfbb2Smrg# it under the terms of the GNU General Public License as published by
12357bfbb2Smrg# the Free Software Foundation; either version 2 of the License, or
13357bfbb2Smrg# (at your option) any later version.
14357bfbb2Smrg#
1583e03a40Smrg# As a special exception to the GNU General Public License,
1683e03a40Smrg# if you distribute this file as part of a program or library that
1783e03a40Smrg# is built using GNU Libtool, you may include this file under the
1883e03a40Smrg# same distribution terms that you use for the rest of that program.
1983e03a40Smrg#
2083e03a40Smrg# GNU Libtool is distributed in the hope that it will be useful, but
21357bfbb2Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
22357bfbb2Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23357bfbb2Smrg# General Public License for more details.
24357bfbb2Smrg#
25357bfbb2Smrg# You should have received a copy of the GNU General Public License
2683e03a40Smrg# along with GNU Libtool; see the file COPYING.  If not, a copy
2783e03a40Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html,
2883e03a40Smrg# or obtained by writing to the Free Software Foundation, Inc.,
2983e03a40Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30357bfbb2Smrg
3183e03a40Smrg# Usage: $progname [OPTION]... [MODE-ARG]...
3283e03a40Smrg#
3383e03a40Smrg# Provide generalized library-building support services.
3483e03a40Smrg#
3583e03a40Smrg#       --config             show all configuration variables
3683e03a40Smrg#       --debug              enable verbose shell tracing
3783e03a40Smrg#   -n, --dry-run            display commands without modifying any files
3883e03a40Smrg#       --features           display basic configuration information and exit
3983e03a40Smrg#       --mode=MODE          use operation mode MODE
4083e03a40Smrg#       --preserve-dup-deps  don't remove duplicate dependency libraries
4183e03a40Smrg#       --quiet, --silent    don't print informational messages
4283e03a40Smrg#       --no-quiet, --no-silent
4383e03a40Smrg#                            print informational messages (default)
4483e03a40Smrg#       --tag=TAG            use configuration variables from tag TAG
4583e03a40Smrg#   -v, --verbose            print more informational messages than default
4683e03a40Smrg#       --no-verbose         don't print the extra informational messages
4783e03a40Smrg#       --version            print version information
4883e03a40Smrg#   -h, --help, --help-all   print short, long, or detailed help message
4983e03a40Smrg#
5083e03a40Smrg# MODE must be one of the following:
5183e03a40Smrg#
5283e03a40Smrg#         clean              remove files from the build directory
5383e03a40Smrg#         compile            compile a source file into a libtool object
5483e03a40Smrg#         execute            automatically set library path, then run a program
5583e03a40Smrg#         finish             complete the installation of libtool libraries
5683e03a40Smrg#         install            install libraries or executables
5783e03a40Smrg#         link               create a library or an executable
5883e03a40Smrg#         uninstall          remove libraries from an installed directory
5983e03a40Smrg#
6083e03a40Smrg# MODE-ARGS vary depending on the MODE.  When passed as first option,
6183e03a40Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
6283e03a40Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
6383e03a40Smrg#
6483e03a40Smrg# When reporting a bug, please describe a test case to reproduce it and
6583e03a40Smrg# include the following information:
6683e03a40Smrg#
6783e03a40Smrg#         host-triplet:	$host
6883e03a40Smrg#         shell:		$SHELL
6983e03a40Smrg#         compiler:		$LTCC
7083e03a40Smrg#         compiler flags:		$LTCFLAGS
7183e03a40Smrg#         linker:		$LD (gnu? $with_gnu_ld)
7283e03a40Smrg#         $progname:	(GNU libtool) 2.4 Debian-2.4-2ubuntu1
7383e03a40Smrg#         automake:	$automake_version
7483e03a40Smrg#         autoconf:	$autoconf_version
7583e03a40Smrg#
7683e03a40Smrg# Report bugs to <bug-libtool@gnu.org>.
7783e03a40Smrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
7883e03a40Smrg# General help using GNU software: <http://www.gnu.org/gethelp/>.
79357bfbb2Smrg
8083e03a40SmrgPROGRAM=libtool
81357bfbb2SmrgPACKAGE=libtool
8283e03a40SmrgVERSION="2.4 Debian-2.4-2ubuntu1"
8383e03a40SmrgTIMESTAMP=""
8483e03a40Smrgpackage_revision=1.3293
855d713044Smrg
8683e03a40Smrg# Be Bourne compatible
875d713044Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
885d713044Smrg  emulate sh
895d713044Smrg  NULLCMD=:
905d713044Smrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
915d713044Smrg  # is contrary to our usage.  Disable this feature.
925d713044Smrg  alias -g '${1+"$@"}'='"$@"'
93357bfbb2Smrg  setopt NO_GLOB_SUBST
945d713044Smrgelse
955d713044Smrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
96357bfbb2Smrgfi
975d713044SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
985d713044SmrgDUALCASE=1; export DUALCASE # for MKS sh
99357bfbb2Smrg
10083e03a40Smrg# A function that is used when there is no print builtin or printf.
10183e03a40Smrgfunc_fallback_echo ()
10283e03a40Smrg{
10383e03a40Smrg  eval 'cat <<_LTECHO_EOF
10483e03a40Smrg$1
10583e03a40Smrg_LTECHO_EOF'
10683e03a40Smrg}
107357bfbb2Smrg
10883e03a40Smrg# NLS nuisances: We save the old values to restore during execute mode.
10983e03a40Smrglt_user_locale=
11083e03a40Smrglt_safe_locale=
1115d713044Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1125d713044Smrgdo
1135d713044Smrg  eval "if test \"\${$lt_var+set}\" = set; then
11483e03a40Smrg          save_$lt_var=\$$lt_var
11583e03a40Smrg          $lt_var=C
1165d713044Smrg	  export $lt_var
11783e03a40Smrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
11883e03a40Smrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
1195d713044Smrg	fi"
1205d713044Smrgdone
12183e03a40SmrgLC_ALL=C
12283e03a40SmrgLANGUAGE=C
12383e03a40Smrgexport LANGUAGE LC_ALL
12483e03a40Smrg
12583e03a40Smrg$lt_unset CDPATH
1265d713044Smrg
12783e03a40Smrg
12883e03a40Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
12983e03a40Smrg# is ksh but when the shell is invoked as "sh" and the current value of
13083e03a40Smrg# the _XPG environment variable is not equal to 1 (one), the special
13183e03a40Smrg# positional parameter $0, within a function call, is the name of the
13283e03a40Smrg# function.
13383e03a40Smrgprogpath="$0"
13483e03a40Smrg
13583e03a40Smrg
13683e03a40Smrg
13783e03a40Smrg: ${CP="cp -f"}
13883e03a40Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
13983e03a40Smrg: ${EGREP="/bin/grep -E"}
14083e03a40Smrg: ${FGREP="/bin/grep -F"}
14183e03a40Smrg: ${GREP="/bin/grep"}
14283e03a40Smrg: ${LN_S="ln -s"}
14383e03a40Smrg: ${MAKE="make"}
14483e03a40Smrg: ${MKDIR="mkdir"}
14583e03a40Smrg: ${MV="mv -f"}
14683e03a40Smrg: ${RM="rm -f"}
14783e03a40Smrg: ${SED="/bin/sed"}
14883e03a40Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
14983e03a40Smrg: ${Xsed="$SED -e 1s/^X//"}
15083e03a40Smrg
15183e03a40Smrg# Global variables:
15283e03a40SmrgEXIT_SUCCESS=0
15383e03a40SmrgEXIT_FAILURE=1
15483e03a40SmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
15583e03a40SmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
15683e03a40Smrg
15783e03a40Smrgexit_status=$EXIT_SUCCESS
158357bfbb2Smrg
159357bfbb2Smrg# Make sure IFS has a sensible default
160357bfbb2Smrglt_nl='
161357bfbb2Smrg'
162357bfbb2SmrgIFS=" 	$lt_nl"
163357bfbb2Smrg
16483e03a40Smrgdirname="s,/[^/]*$,,"
16583e03a40Smrgbasename="s,^.*/,,"
166357bfbb2Smrg
16783e03a40Smrg# func_dirname file append nondir_replacement
16883e03a40Smrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
16983e03a40Smrg# otherwise set result to NONDIR_REPLACEMENT.
17083e03a40Smrgfunc_dirname ()
17183e03a40Smrg{
17283e03a40Smrg    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
17383e03a40Smrg    if test "X$func_dirname_result" = "X${1}"; then
17483e03a40Smrg      func_dirname_result="${3}"
17583e03a40Smrg    else
17683e03a40Smrg      func_dirname_result="$func_dirname_result${2}"
17783e03a40Smrg    fi
17883e03a40Smrg} # func_dirname may be replaced by extended shell implementation
17983e03a40Smrg
18083e03a40Smrg
18183e03a40Smrg# func_basename file
18283e03a40Smrgfunc_basename ()
18383e03a40Smrg{
18483e03a40Smrg    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
18583e03a40Smrg} # func_basename may be replaced by extended shell implementation
18683e03a40Smrg
18783e03a40Smrg
18883e03a40Smrg# func_dirname_and_basename file append nondir_replacement
18983e03a40Smrg# perform func_basename and func_dirname in a single function
19083e03a40Smrg# call:
19183e03a40Smrg#   dirname:  Compute the dirname of FILE.  If nonempty,
19283e03a40Smrg#             add APPEND to the result, otherwise set result
19383e03a40Smrg#             to NONDIR_REPLACEMENT.
19483e03a40Smrg#             value returned in "$func_dirname_result"
19583e03a40Smrg#   basename: Compute filename of FILE.
19683e03a40Smrg#             value retuned in "$func_basename_result"
19783e03a40Smrg# Implementation must be kept synchronized with func_dirname
19883e03a40Smrg# and func_basename. For efficiency, we do not delegate to
19983e03a40Smrg# those functions but instead duplicate the functionality here.
20083e03a40Smrgfunc_dirname_and_basename ()
20183e03a40Smrg{
20283e03a40Smrg    # Extract subdirectory from the argument.
20383e03a40Smrg    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
20483e03a40Smrg    if test "X$func_dirname_result" = "X${1}"; then
20583e03a40Smrg      func_dirname_result="${3}"
20683e03a40Smrg    else
20783e03a40Smrg      func_dirname_result="$func_dirname_result${2}"
20883e03a40Smrg    fi
20983e03a40Smrg    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
21083e03a40Smrg} # func_dirname_and_basename may be replaced by extended shell implementation
21183e03a40Smrg
21283e03a40Smrg
21383e03a40Smrg# func_stripname prefix suffix name
21483e03a40Smrg# strip PREFIX and SUFFIX off of NAME.
21583e03a40Smrg# PREFIX and SUFFIX must not contain globbing or regex special
21683e03a40Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading
21783e03a40Smrg# dot (in which case that matches only a dot).
21883e03a40Smrg# func_strip_suffix prefix name
21983e03a40Smrgfunc_stripname ()
22083e03a40Smrg{
22183e03a40Smrg    case ${2} in
22283e03a40Smrg      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
22383e03a40Smrg      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
22483e03a40Smrg    esac
22583e03a40Smrg} # func_stripname may be replaced by extended shell implementation
22683e03a40Smrg
22783e03a40Smrg
22883e03a40Smrg# These SED scripts presuppose an absolute path with a trailing slash.
22983e03a40Smrgpathcar='s,^/\([^/]*\).*$,\1,'
23083e03a40Smrgpathcdr='s,^/[^/]*,,'
23183e03a40Smrgremovedotparts=':dotsl
23283e03a40Smrg		s@/\./@/@g
23383e03a40Smrg		t dotsl
23483e03a40Smrg		s,/\.$,/,'
23583e03a40Smrgcollapseslashes='s@/\{1,\}@/@g'
23683e03a40Smrgfinalslash='s,/*$,/,'
23783e03a40Smrg
23883e03a40Smrg# func_normal_abspath PATH
23983e03a40Smrg# Remove doubled-up and trailing slashes, "." path components,
24083e03a40Smrg# and cancel out any ".." path components in PATH after making
24183e03a40Smrg# it an absolute path.
24283e03a40Smrg#             value returned in "$func_normal_abspath_result"
24383e03a40Smrgfunc_normal_abspath ()
24483e03a40Smrg{
24583e03a40Smrg  # Start from root dir and reassemble the path.
24683e03a40Smrg  func_normal_abspath_result=
24783e03a40Smrg  func_normal_abspath_tpath=$1
24883e03a40Smrg  func_normal_abspath_altnamespace=
24983e03a40Smrg  case $func_normal_abspath_tpath in
25083e03a40Smrg    "")
25183e03a40Smrg      # Empty path, that just means $cwd.
25283e03a40Smrg      func_stripname '' '/' "`pwd`"
25383e03a40Smrg      func_normal_abspath_result=$func_stripname_result
25483e03a40Smrg      return
25583e03a40Smrg    ;;
25683e03a40Smrg    # The next three entries are used to spot a run of precisely
25783e03a40Smrg    # two leading slashes without using negated character classes;
25883e03a40Smrg    # we take advantage of case's first-match behaviour.
25983e03a40Smrg    ///*)
26083e03a40Smrg      # Unusual form of absolute path, do nothing.
26183e03a40Smrg    ;;
26283e03a40Smrg    //*)
26383e03a40Smrg      # Not necessarily an ordinary path; POSIX reserves leading '//'
26483e03a40Smrg      # and for example Cygwin uses it to access remote file shares
26583e03a40Smrg      # over CIFS/SMB, so we conserve a leading double slash if found.
26683e03a40Smrg      func_normal_abspath_altnamespace=/
26783e03a40Smrg    ;;
26883e03a40Smrg    /*)
26983e03a40Smrg      # Absolute path, do nothing.
27083e03a40Smrg    ;;
27183e03a40Smrg    *)
27283e03a40Smrg      # Relative path, prepend $cwd.
27383e03a40Smrg      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
27483e03a40Smrg    ;;
27583e03a40Smrg  esac
27683e03a40Smrg  # Cancel out all the simple stuff to save iterations.  We also want
27783e03a40Smrg  # the path to end with a slash for ease of parsing, so make sure
27883e03a40Smrg  # there is one (and only one) here.
27983e03a40Smrg  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
28083e03a40Smrg        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
28183e03a40Smrg  while :; do
28283e03a40Smrg    # Processed it all yet?
28383e03a40Smrg    if test "$func_normal_abspath_tpath" = / ; then
28483e03a40Smrg      # If we ascended to the root using ".." the result may be empty now.
28583e03a40Smrg      if test -z "$func_normal_abspath_result" ; then
28683e03a40Smrg        func_normal_abspath_result=/
28783e03a40Smrg      fi
28883e03a40Smrg      break
28983e03a40Smrg    fi
29083e03a40Smrg    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
29183e03a40Smrg        -e "$pathcar"`
29283e03a40Smrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
29383e03a40Smrg        -e "$pathcdr"`
29483e03a40Smrg    # Figure out what to do with it
29583e03a40Smrg    case $func_normal_abspath_tcomponent in
29683e03a40Smrg      "")
29783e03a40Smrg        # Trailing empty path component, ignore it.
29883e03a40Smrg      ;;
29983e03a40Smrg      ..)
30083e03a40Smrg        # Parent dir; strip last assembled component from result.
30183e03a40Smrg        func_dirname "$func_normal_abspath_result"
30283e03a40Smrg        func_normal_abspath_result=$func_dirname_result
30383e03a40Smrg      ;;
30483e03a40Smrg      *)
30583e03a40Smrg        # Actual path component, append it.
30683e03a40Smrg        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
30783e03a40Smrg      ;;
30883e03a40Smrg    esac
30983e03a40Smrg  done
31083e03a40Smrg  # Restore leading double-slash if one was found on entry.
31183e03a40Smrg  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
31283e03a40Smrg}
31383e03a40Smrg
31483e03a40Smrg# func_relative_path SRCDIR DSTDIR
31583e03a40Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing
31683e03a40Smrg# slash if non-empty, suitable for immediately appending a filename
31783e03a40Smrg# without needing to append a separator.
31883e03a40Smrg#             value returned in "$func_relative_path_result"
31983e03a40Smrgfunc_relative_path ()
32083e03a40Smrg{
32183e03a40Smrg  func_relative_path_result=
32283e03a40Smrg  func_normal_abspath "$1"
32383e03a40Smrg  func_relative_path_tlibdir=$func_normal_abspath_result
32483e03a40Smrg  func_normal_abspath "$2"
32583e03a40Smrg  func_relative_path_tbindir=$func_normal_abspath_result
32683e03a40Smrg
32783e03a40Smrg  # Ascend the tree starting from libdir
32883e03a40Smrg  while :; do
32983e03a40Smrg    # check if we have found a prefix of bindir
33083e03a40Smrg    case $func_relative_path_tbindir in
33183e03a40Smrg      $func_relative_path_tlibdir)
33283e03a40Smrg        # found an exact match
33383e03a40Smrg        func_relative_path_tcancelled=
33483e03a40Smrg        break
33583e03a40Smrg        ;;
33683e03a40Smrg      $func_relative_path_tlibdir*)
33783e03a40Smrg        # found a matching prefix
33883e03a40Smrg        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
33983e03a40Smrg        func_relative_path_tcancelled=$func_stripname_result
34083e03a40Smrg        if test -z "$func_relative_path_result"; then
34183e03a40Smrg          func_relative_path_result=.
34283e03a40Smrg        fi
34383e03a40Smrg        break
34483e03a40Smrg        ;;
34583e03a40Smrg      *)
34683e03a40Smrg        func_dirname $func_relative_path_tlibdir
34783e03a40Smrg        func_relative_path_tlibdir=${func_dirname_result}
34883e03a40Smrg        if test "x$func_relative_path_tlibdir" = x ; then
34983e03a40Smrg          # Have to descend all the way to the root!
35083e03a40Smrg          func_relative_path_result=../$func_relative_path_result
35183e03a40Smrg          func_relative_path_tcancelled=$func_relative_path_tbindir
35283e03a40Smrg          break
35383e03a40Smrg        fi
35483e03a40Smrg        func_relative_path_result=../$func_relative_path_result
35583e03a40Smrg        ;;
35683e03a40Smrg    esac
35783e03a40Smrg  done
35883e03a40Smrg
35983e03a40Smrg  # Now calculate path; take care to avoid doubling-up slashes.
36083e03a40Smrg  func_stripname '' '/' "$func_relative_path_result"
36183e03a40Smrg  func_relative_path_result=$func_stripname_result
36283e03a40Smrg  func_stripname '/' '/' "$func_relative_path_tcancelled"
36383e03a40Smrg  if test "x$func_stripname_result" != x ; then
36483e03a40Smrg    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
36583e03a40Smrg  fi
36683e03a40Smrg
36783e03a40Smrg  # Normalisation. If bindir is libdir, return empty string,
36883e03a40Smrg  # else relative path ending with a slash; either way, target
36983e03a40Smrg  # file name can be directly appended.
37083e03a40Smrg  if test ! -z "$func_relative_path_result"; then
37183e03a40Smrg    func_stripname './' '' "$func_relative_path_result/"
37283e03a40Smrg    func_relative_path_result=$func_stripname_result
37383e03a40Smrg  fi
37483e03a40Smrg}
37583e03a40Smrg
37683e03a40Smrg# The name of this program:
37783e03a40Smrgfunc_dirname_and_basename "$progpath"
37883e03a40Smrgprogname=$func_basename_result
37983e03a40Smrg
38083e03a40Smrg# Make sure we have an absolute path for reexecution:
38183e03a40Smrgcase $progpath in
38283e03a40Smrg  [\\/]*|[A-Za-z]:\\*) ;;
38383e03a40Smrg  *[\\/]*)
38483e03a40Smrg     progdir=$func_dirname_result
38583e03a40Smrg     progdir=`cd "$progdir" && pwd`
38683e03a40Smrg     progpath="$progdir/$progname"
38783e03a40Smrg     ;;
38883e03a40Smrg  *)
38983e03a40Smrg     save_IFS="$IFS"
39083e03a40Smrg     IFS=:
39183e03a40Smrg     for progdir in $PATH; do
39283e03a40Smrg       IFS="$save_IFS"
39383e03a40Smrg       test -x "$progdir/$progname" && break
39483e03a40Smrg     done
39583e03a40Smrg     IFS="$save_IFS"
39683e03a40Smrg     test -n "$progdir" || progdir=`pwd`
39783e03a40Smrg     progpath="$progdir/$progname"
39883e03a40Smrg     ;;
39983e03a40Smrgesac
40083e03a40Smrg
40183e03a40Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
40283e03a40Smrg# metacharacters that are still active within double-quoted strings.
40383e03a40SmrgXsed="${SED}"' -e 1s/^X//'
40483e03a40Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
40583e03a40Smrg
40683e03a40Smrg# Same as above, but do not quote variable references.
40783e03a40Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
40883e03a40Smrg
40983e03a40Smrg# Sed substitution that turns a string into a regex matching for the
41083e03a40Smrg# string literally.
41183e03a40Smrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
41283e03a40Smrg
41383e03a40Smrg# Sed substitution that converts a w32 file name or path
41483e03a40Smrg# which contains forward slashes, into one that contains
41583e03a40Smrg# (escaped) backslashes.  A very naive implementation.
41683e03a40Smrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
41783e03a40Smrg
41883e03a40Smrg# Re-`\' parameter expansions in output of double_quote_subst that were
41983e03a40Smrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
42083e03a40Smrg# in input to double_quote_subst, that '$' was protected from expansion.
42183e03a40Smrg# Since each input `\' is now two `\'s, look for any number of runs of
42283e03a40Smrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
42383e03a40Smrgbs='\\'
42483e03a40Smrgbs2='\\\\'
42583e03a40Smrgbs4='\\\\\\\\'
42683e03a40Smrgdollar='\$'
42783e03a40Smrgsed_double_backslash="\
42883e03a40Smrg  s/$bs4/&\\
42983e03a40Smrg/g
43083e03a40Smrg  s/^$bs2$dollar/$bs&/
43183e03a40Smrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
43283e03a40Smrg  s/\n//g"
43383e03a40Smrg
43483e03a40Smrg# Standard options:
43583e03a40Smrgopt_dry_run=false
43683e03a40Smrgopt_help=false
43783e03a40Smrgopt_quiet=false
43883e03a40Smrgopt_verbose=false
43983e03a40Smrgopt_warning=:
44083e03a40Smrg
44183e03a40Smrg# func_echo arg...
44283e03a40Smrg# Echo program name prefixed message, along with the current mode
44383e03a40Smrg# name if it has been set yet.
44483e03a40Smrgfunc_echo ()
44583e03a40Smrg{
44683e03a40Smrg    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
44783e03a40Smrg}
44883e03a40Smrg
44983e03a40Smrg# func_verbose arg...
45083e03a40Smrg# Echo program name prefixed message in verbose mode only.
45183e03a40Smrgfunc_verbose ()
45283e03a40Smrg{
45383e03a40Smrg    $opt_verbose && func_echo ${1+"$@"}
45483e03a40Smrg
45583e03a40Smrg    # A bug in bash halts the script if the last line of a function
45683e03a40Smrg    # fails when set -e is in force, so we need another command to
45783e03a40Smrg    # work around that:
45883e03a40Smrg    :
45983e03a40Smrg}
46083e03a40Smrg
46183e03a40Smrg# func_echo_all arg...
46283e03a40Smrg# Invoke $ECHO with all args, space-separated.
46383e03a40Smrgfunc_echo_all ()
46483e03a40Smrg{
46583e03a40Smrg    $ECHO "$*"
46683e03a40Smrg}
46783e03a40Smrg
46883e03a40Smrg# func_error arg...
46983e03a40Smrg# Echo program name prefixed message to standard error.
47083e03a40Smrgfunc_error ()
47183e03a40Smrg{
47283e03a40Smrg    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
47383e03a40Smrg}
47483e03a40Smrg
47583e03a40Smrg# func_warning arg...
47683e03a40Smrg# Echo program name prefixed warning message to standard error.
47783e03a40Smrgfunc_warning ()
47883e03a40Smrg{
47983e03a40Smrg    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
48083e03a40Smrg
48183e03a40Smrg    # bash bug again:
48283e03a40Smrg    :
48383e03a40Smrg}
48483e03a40Smrg
48583e03a40Smrg# func_fatal_error arg...
48683e03a40Smrg# Echo program name prefixed message to standard error, and exit.
48783e03a40Smrgfunc_fatal_error ()
48883e03a40Smrg{
48983e03a40Smrg    func_error ${1+"$@"}
49083e03a40Smrg    exit $EXIT_FAILURE
49183e03a40Smrg}
49283e03a40Smrg
49383e03a40Smrg# func_fatal_help arg...
49483e03a40Smrg# Echo program name prefixed message to standard error, followed by
49583e03a40Smrg# a help hint, and exit.
49683e03a40Smrgfunc_fatal_help ()
49783e03a40Smrg{
49883e03a40Smrg    func_error ${1+"$@"}
49983e03a40Smrg    func_fatal_error "$help"
50083e03a40Smrg}
50183e03a40Smrghelp="Try \`$progname --help' for more information."  ## default
50283e03a40Smrg
50383e03a40Smrg
50483e03a40Smrg# func_grep expression filename
50583e03a40Smrg# Check whether EXPRESSION matches any line of FILENAME, without output.
50683e03a40Smrgfunc_grep ()
50783e03a40Smrg{
50883e03a40Smrg    $GREP "$1" "$2" >/dev/null 2>&1
50983e03a40Smrg}
51083e03a40Smrg
51183e03a40Smrg
51283e03a40Smrg# func_mkdir_p directory-path
51383e03a40Smrg# Make sure the entire path to DIRECTORY-PATH is available.
51483e03a40Smrgfunc_mkdir_p ()
51583e03a40Smrg{
51683e03a40Smrg    my_directory_path="$1"
51783e03a40Smrg    my_dir_list=
51883e03a40Smrg
51983e03a40Smrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
52083e03a40Smrg
52183e03a40Smrg      # Protect directory names starting with `-'
52283e03a40Smrg      case $my_directory_path in
52383e03a40Smrg        -*) my_directory_path="./$my_directory_path" ;;
52483e03a40Smrg      esac
52583e03a40Smrg
52683e03a40Smrg      # While some portion of DIR does not yet exist...
52783e03a40Smrg      while test ! -d "$my_directory_path"; do
52883e03a40Smrg        # ...make a list in topmost first order.  Use a colon delimited
52983e03a40Smrg	# list incase some portion of path contains whitespace.
53083e03a40Smrg        my_dir_list="$my_directory_path:$my_dir_list"
53183e03a40Smrg
53283e03a40Smrg        # If the last portion added has no slash in it, the list is done
53383e03a40Smrg        case $my_directory_path in */*) ;; *) break ;; esac
53483e03a40Smrg
53583e03a40Smrg        # ...otherwise throw away the child directory and loop
53683e03a40Smrg        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
53783e03a40Smrg      done
53883e03a40Smrg      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
53983e03a40Smrg
54083e03a40Smrg      save_mkdir_p_IFS="$IFS"; IFS=':'
54183e03a40Smrg      for my_dir in $my_dir_list; do
54283e03a40Smrg	IFS="$save_mkdir_p_IFS"
54383e03a40Smrg        # mkdir can fail with a `File exist' error if two processes
54483e03a40Smrg        # try to create one of the directories concurrently.  Don't
54583e03a40Smrg        # stop in that case!
54683e03a40Smrg        $MKDIR "$my_dir" 2>/dev/null || :
54783e03a40Smrg      done
54883e03a40Smrg      IFS="$save_mkdir_p_IFS"
54983e03a40Smrg
55083e03a40Smrg      # Bail out if we (or some other process) failed to create a directory.
55183e03a40Smrg      test -d "$my_directory_path" || \
55283e03a40Smrg        func_fatal_error "Failed to create \`$1'"
55383e03a40Smrg    fi
55483e03a40Smrg}
555357bfbb2Smrg
556357bfbb2Smrg
557357bfbb2Smrg# func_mktempdir [string]
558357bfbb2Smrg# Make a temporary directory that won't clash with other running
559357bfbb2Smrg# libtool processes, and avoids race conditions if possible.  If
560357bfbb2Smrg# given, STRING is the basename for that directory.
561357bfbb2Smrgfunc_mktempdir ()
562357bfbb2Smrg{
563357bfbb2Smrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
564357bfbb2Smrg
56583e03a40Smrg    if test "$opt_dry_run" = ":"; then
566357bfbb2Smrg      # Return a directory name, but don't create it in dry-run mode
567357bfbb2Smrg      my_tmpdir="${my_template}-$$"
568357bfbb2Smrg    else
569357bfbb2Smrg
570357bfbb2Smrg      # If mktemp works, use that first and foremost
571357bfbb2Smrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
572357bfbb2Smrg
573357bfbb2Smrg      if test ! -d "$my_tmpdir"; then
57483e03a40Smrg        # Failing that, at least try and use $RANDOM to avoid a race
57583e03a40Smrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
576357bfbb2Smrg
57783e03a40Smrg        save_mktempdir_umask=`umask`
57883e03a40Smrg        umask 0077
57983e03a40Smrg        $MKDIR "$my_tmpdir"
58083e03a40Smrg        umask $save_mktempdir_umask
581357bfbb2Smrg      fi
582357bfbb2Smrg
583357bfbb2Smrg      # If we're not in dry-run mode, bomb out on failure
58483e03a40Smrg      test -d "$my_tmpdir" || \
58583e03a40Smrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
586357bfbb2Smrg    fi
587357bfbb2Smrg
58883e03a40Smrg    $ECHO "$my_tmpdir"
589357bfbb2Smrg}
590357bfbb2Smrg
591357bfbb2Smrg
59283e03a40Smrg# func_quote_for_eval arg
59383e03a40Smrg# Aesthetically quote ARG to be evaled later.
59483e03a40Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
59583e03a40Smrg# is double-quoted, suitable for a subsequent eval, whereas
59683e03a40Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
59783e03a40Smrg# which are still active within double quotes backslashified.
59883e03a40Smrgfunc_quote_for_eval ()
599357bfbb2Smrg{
60083e03a40Smrg    case $1 in
60183e03a40Smrg      *[\\\`\"\$]*)
60283e03a40Smrg	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
60383e03a40Smrg      *)
60483e03a40Smrg        func_quote_for_eval_unquoted_result="$1" ;;
60583e03a40Smrg    esac
60683e03a40Smrg
60783e03a40Smrg    case $func_quote_for_eval_unquoted_result in
60883e03a40Smrg      # Double-quote args containing shell metacharacters to delay
60983e03a40Smrg      # word splitting, command substitution and and variable
61083e03a40Smrg      # expansion for a subsequent eval.
61183e03a40Smrg      # Many Bourne shells cannot handle close brackets correctly
61283e03a40Smrg      # in scan sets, so we specify it separately.
61383e03a40Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
61483e03a40Smrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
61583e03a40Smrg        ;;
61683e03a40Smrg      *)
61783e03a40Smrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
61883e03a40Smrg    esac
61983e03a40Smrg}
62083e03a40Smrg
62183e03a40Smrg
62283e03a40Smrg# func_quote_for_expand arg
62383e03a40Smrg# Aesthetically quote ARG to be evaled later; same as above,
62483e03a40Smrg# but do not quote variable references.
62583e03a40Smrgfunc_quote_for_expand ()
62683e03a40Smrg{
62783e03a40Smrg    case $1 in
62883e03a40Smrg      *[\\\`\"]*)
62983e03a40Smrg	my_arg=`$ECHO "$1" | $SED \
63083e03a40Smrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
63183e03a40Smrg      *)
63283e03a40Smrg        my_arg="$1" ;;
63383e03a40Smrg    esac
63483e03a40Smrg
63583e03a40Smrg    case $my_arg in
63683e03a40Smrg      # Double-quote args containing shell metacharacters to delay
63783e03a40Smrg      # word splitting and command substitution for a subsequent eval.
63883e03a40Smrg      # Many Bourne shells cannot handle close brackets correctly
63983e03a40Smrg      # in scan sets, so we specify it separately.
64083e03a40Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
64183e03a40Smrg        my_arg="\"$my_arg\""
64283e03a40Smrg        ;;
64383e03a40Smrg    esac
64483e03a40Smrg
64583e03a40Smrg    func_quote_for_expand_result="$my_arg"
64683e03a40Smrg}
64783e03a40Smrg
64883e03a40Smrg
64983e03a40Smrg# func_show_eval cmd [fail_exp]
65083e03a40Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
65183e03a40Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
65283e03a40Smrg# is given, then evaluate it.
65383e03a40Smrgfunc_show_eval ()
65483e03a40Smrg{
65583e03a40Smrg    my_cmd="$1"
65683e03a40Smrg    my_fail_exp="${2-:}"
65783e03a40Smrg
65883e03a40Smrg    ${opt_silent-false} || {
65983e03a40Smrg      func_quote_for_expand "$my_cmd"
66083e03a40Smrg      eval "func_echo $func_quote_for_expand_result"
66183e03a40Smrg    }
66283e03a40Smrg
66383e03a40Smrg    if ${opt_dry_run-false}; then :; else
66483e03a40Smrg      eval "$my_cmd"
66583e03a40Smrg      my_status=$?
66683e03a40Smrg      if test "$my_status" -eq 0; then :; else
66783e03a40Smrg	eval "(exit $my_status); $my_fail_exp"
66883e03a40Smrg      fi
669357bfbb2Smrg    fi
67083e03a40Smrg}
67183e03a40Smrg
67283e03a40Smrg
67383e03a40Smrg# func_show_eval_locale cmd [fail_exp]
67483e03a40Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
67583e03a40Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
67683e03a40Smrg# is given, then evaluate it.  Use the saved locale for evaluation.
67783e03a40Smrgfunc_show_eval_locale ()
67883e03a40Smrg{
67983e03a40Smrg    my_cmd="$1"
68083e03a40Smrg    my_fail_exp="${2-:}"
68183e03a40Smrg
68283e03a40Smrg    ${opt_silent-false} || {
68383e03a40Smrg      func_quote_for_expand "$my_cmd"
68483e03a40Smrg      eval "func_echo $func_quote_for_expand_result"
68583e03a40Smrg    }
68683e03a40Smrg
68783e03a40Smrg    if ${opt_dry_run-false}; then :; else
68883e03a40Smrg      eval "$lt_user_locale
68983e03a40Smrg	    $my_cmd"
69083e03a40Smrg      my_status=$?
69183e03a40Smrg      eval "$lt_safe_locale"
69283e03a40Smrg      if test "$my_status" -eq 0; then :; else
69383e03a40Smrg	eval "(exit $my_status); $my_fail_exp"
69483e03a40Smrg      fi
69583e03a40Smrg    fi
69683e03a40Smrg}
69783e03a40Smrg
69883e03a40Smrg# func_tr_sh
69983e03a40Smrg# Turn $1 into a string suitable for a shell variable name.
70083e03a40Smrg# Result is stored in $func_tr_sh_result.  All characters
70183e03a40Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
70283e03a40Smrg# if $1 begins with a digit, a '_' is prepended as well.
70383e03a40Smrgfunc_tr_sh ()
70483e03a40Smrg{
70583e03a40Smrg  case $1 in
70683e03a40Smrg  [0-9]* | *[!a-zA-Z0-9_]*)
70783e03a40Smrg    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
708357bfbb2Smrg    ;;
70983e03a40Smrg  * )
71083e03a40Smrg    func_tr_sh_result=$1
711357bfbb2Smrg    ;;
712357bfbb2Smrg  esac
713357bfbb2Smrg}
714357bfbb2Smrg
715357bfbb2Smrg
71683e03a40Smrg# func_version
71783e03a40Smrg# Echo version message to standard output and exit.
71883e03a40Smrgfunc_version ()
719357bfbb2Smrg{
72083e03a40Smrg    $opt_debug
72183e03a40Smrg
72283e03a40Smrg    $SED -n '/(C)/!b go
72383e03a40Smrg	:more
72483e03a40Smrg	/\./!{
72583e03a40Smrg	  N
72683e03a40Smrg	  s/\n# / /
72783e03a40Smrg	  b more
72883e03a40Smrg	}
72983e03a40Smrg	:go
73083e03a40Smrg	/^# '$PROGRAM' (GNU /,/# warranty; / {
73183e03a40Smrg        s/^# //
73283e03a40Smrg	s/^# *$//
73383e03a40Smrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
73483e03a40Smrg        p
73583e03a40Smrg     }' < "$progpath"
73683e03a40Smrg     exit $?
737357bfbb2Smrg}
738357bfbb2Smrg
73983e03a40Smrg# func_usage
74083e03a40Smrg# Echo short help message to standard output and exit.
74183e03a40Smrgfunc_usage ()
742357bfbb2Smrg{
74383e03a40Smrg    $opt_debug
74483e03a40Smrg
74583e03a40Smrg    $SED -n '/^# Usage:/,/^#  *.*--help/ {
74683e03a40Smrg        s/^# //
74783e03a40Smrg	s/^# *$//
74883e03a40Smrg	s/\$progname/'$progname'/
74983e03a40Smrg	p
75083e03a40Smrg    }' < "$progpath"
75183e03a40Smrg    echo
75283e03a40Smrg    $ECHO "run \`$progname --help | more' for full usage"
75383e03a40Smrg    exit $?
754357bfbb2Smrg}
755357bfbb2Smrg
75683e03a40Smrg# func_help [NOEXIT]
75783e03a40Smrg# Echo long help message to standard output and exit,
75883e03a40Smrg# unless 'noexit' is passed as argument.
75983e03a40Smrgfunc_help ()
760357bfbb2Smrg{
76183e03a40Smrg    $opt_debug
76283e03a40Smrg
76383e03a40Smrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
76483e03a40Smrg	:print
76583e03a40Smrg        s/^# //
76683e03a40Smrg	s/^# *$//
76783e03a40Smrg	s*\$progname*'$progname'*
76883e03a40Smrg	s*\$host*'"$host"'*
76983e03a40Smrg	s*\$SHELL*'"$SHELL"'*
77083e03a40Smrg	s*\$LTCC*'"$LTCC"'*
77183e03a40Smrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
77283e03a40Smrg	s*\$LD*'"$LD"'*
77383e03a40Smrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
77483e03a40Smrg	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
77583e03a40Smrg	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
77683e03a40Smrg	p
77783e03a40Smrg	d
77883e03a40Smrg     }
77983e03a40Smrg     /^# .* home page:/b print
78083e03a40Smrg     /^# General help using/b print
78183e03a40Smrg     ' < "$progpath"
78283e03a40Smrg    ret=$?
78383e03a40Smrg    if test -z "$1"; then
78483e03a40Smrg      exit $ret
785357bfbb2Smrg    fi
78683e03a40Smrg}
787357bfbb2Smrg
78883e03a40Smrg# func_missing_arg argname
78983e03a40Smrg# Echo program name prefixed message to standard error and set global
79083e03a40Smrg# exit_cmd.
79183e03a40Smrgfunc_missing_arg ()
79283e03a40Smrg{
79383e03a40Smrg    $opt_debug
794357bfbb2Smrg
79583e03a40Smrg    func_error "missing argument for $1."
79683e03a40Smrg    exit_cmd=exit
797357bfbb2Smrg}
798357bfbb2Smrg
799357bfbb2Smrg
80083e03a40Smrg# func_split_short_opt shortopt
80183e03a40Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
80283e03a40Smrg# variables after splitting SHORTOPT after the 2nd character.
80383e03a40Smrgfunc_split_short_opt ()
80483e03a40Smrg{
80583e03a40Smrg    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
80683e03a40Smrg    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
80783e03a40Smrg
80883e03a40Smrg    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
80983e03a40Smrg    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
81083e03a40Smrg} # func_split_short_opt may be replaced by extended shell implementation
811357bfbb2Smrg
812357bfbb2Smrg
81383e03a40Smrg# func_split_long_opt longopt
81483e03a40Smrg# Set func_split_long_opt_name and func_split_long_opt_arg shell
81583e03a40Smrg# variables after splitting LONGOPT at the `=' sign.
81683e03a40Smrgfunc_split_long_opt ()
81783e03a40Smrg{
81883e03a40Smrg    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
81983e03a40Smrg    my_sed_long_arg='1s/^--[^=]*=//'
820357bfbb2Smrg
82183e03a40Smrg    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
82283e03a40Smrg    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
82383e03a40Smrg} # func_split_long_opt may be replaced by extended shell implementation
824357bfbb2Smrg
82583e03a40Smrgexit_cmd=:
826357bfbb2Smrg
827357bfbb2Smrg
828357bfbb2Smrg
8295d713044Smrg
830357bfbb2Smrg
83183e03a40Smrgmagic="%%%MAGIC variable%%%"
83283e03a40Smrgmagic_exe="%%%MAGIC EXE variable%%%"
83383e03a40Smrg
83483e03a40Smrg# Global variables.
83583e03a40Smrgnonopt=
83683e03a40Smrgpreserve_args=
83783e03a40Smrglo2o="s/\\.lo\$/.${objext}/"
83883e03a40Smrgo2lo="s/\\.${objext}\$/.lo/"
83983e03a40Smrgextracted_archives=
84083e03a40Smrgextracted_serial=0
84183e03a40Smrg
84283e03a40Smrg# If this variable is set in any of the actions, the command in it
84383e03a40Smrg# will be execed at the end.  This prevents here-documents from being
84483e03a40Smrg# left over by shells.
84583e03a40Smrgexec_cmd=
84683e03a40Smrg
84783e03a40Smrg# func_append var value
84883e03a40Smrg# Append VALUE to the end of shell variable VAR.
84983e03a40Smrgfunc_append ()
85083e03a40Smrg{
85183e03a40Smrg    eval "${1}=\$${1}\${2}"
85283e03a40Smrg} # func_append may be replaced by extended shell implementation
85383e03a40Smrg
85483e03a40Smrg# func_append_quoted var value
85583e03a40Smrg# Quote VALUE and append to the end of shell variable VAR, separated
85683e03a40Smrg# by a space.
85783e03a40Smrgfunc_append_quoted ()
85883e03a40Smrg{
85983e03a40Smrg    func_quote_for_eval "${2}"
86083e03a40Smrg    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
86183e03a40Smrg} # func_append_quoted may be replaced by extended shell implementation
86283e03a40Smrg
86383e03a40Smrg
86483e03a40Smrg# func_arith arithmetic-term...
86583e03a40Smrgfunc_arith ()
86683e03a40Smrg{
86783e03a40Smrg    func_arith_result=`expr "${@}"`
86883e03a40Smrg} # func_arith may be replaced by extended shell implementation
86983e03a40Smrg
87083e03a40Smrg
87183e03a40Smrg# func_len string
87283e03a40Smrg# STRING may not start with a hyphen.
87383e03a40Smrgfunc_len ()
87483e03a40Smrg{
87583e03a40Smrg    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
87683e03a40Smrg} # func_len may be replaced by extended shell implementation
87783e03a40Smrg
87883e03a40Smrg
87983e03a40Smrg# func_lo2o object
88083e03a40Smrgfunc_lo2o ()
88183e03a40Smrg{
88283e03a40Smrg    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
88383e03a40Smrg} # func_lo2o may be replaced by extended shell implementation
88483e03a40Smrg
88583e03a40Smrg
88683e03a40Smrg# func_xform libobj-or-source
88783e03a40Smrgfunc_xform ()
88883e03a40Smrg{
88983e03a40Smrg    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
89083e03a40Smrg} # func_xform may be replaced by extended shell implementation
89183e03a40Smrg
89283e03a40Smrg
89383e03a40Smrg# func_fatal_configuration arg...
89483e03a40Smrg# Echo program name prefixed message to standard error, followed by
89583e03a40Smrg# a configuration failure hint, and exit.
89683e03a40Smrgfunc_fatal_configuration ()
89783e03a40Smrg{
89883e03a40Smrg    func_error ${1+"$@"}
89983e03a40Smrg    func_error "See the $PACKAGE documentation for more information."
90083e03a40Smrg    func_fatal_error "Fatal configuration error."
90183e03a40Smrg}
90283e03a40Smrg
90383e03a40Smrg
90483e03a40Smrg# func_config
90583e03a40Smrg# Display the configuration for all the tags in this script.
90683e03a40Smrgfunc_config ()
90783e03a40Smrg{
90883e03a40Smrg    re_begincf='^# ### BEGIN LIBTOOL'
90983e03a40Smrg    re_endcf='^# ### END LIBTOOL'
91083e03a40Smrg
91183e03a40Smrg    # Default configuration.
91283e03a40Smrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
91383e03a40Smrg
914357bfbb2Smrg    # Now print the configurations for the tags.
915357bfbb2Smrg    for tagname in $taglist; do
91683e03a40Smrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
917357bfbb2Smrg    done
918357bfbb2Smrg
91983e03a40Smrg    exit $?
92083e03a40Smrg}
921357bfbb2Smrg
92283e03a40Smrg# func_features
92383e03a40Smrg# Display the features supported by this script.
92483e03a40Smrgfunc_features ()
92583e03a40Smrg{
92683e03a40Smrg    echo "host: $host"
927357bfbb2Smrg    if test "$build_libtool_libs" = yes; then
92883e03a40Smrg      echo "enable shared libraries"
929357bfbb2Smrg    else
93083e03a40Smrg      echo "disable shared libraries"
931357bfbb2Smrg    fi
932357bfbb2Smrg    if test "$build_old_libs" = yes; then
93383e03a40Smrg      echo "enable static libraries"
934357bfbb2Smrg    else
93583e03a40Smrg      echo "disable static libraries"
936357bfbb2Smrg    fi
937357bfbb2Smrg
93883e03a40Smrg    exit $?
93983e03a40Smrg}
940357bfbb2Smrg
94183e03a40Smrg# func_enable_tag tagname
94283e03a40Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or
94383e03a40Smrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
94483e03a40Smrg# variable here.
94583e03a40Smrgfunc_enable_tag ()
94683e03a40Smrg{
94783e03a40Smrg  # Global variable:
94883e03a40Smrg  tagname="$1"
949357bfbb2Smrg
95083e03a40Smrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
95183e03a40Smrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
95283e03a40Smrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
953357bfbb2Smrg
95483e03a40Smrg  # Validate tagname.
95583e03a40Smrg  case $tagname in
95683e03a40Smrg    *[!-_A-Za-z0-9,/]*)
95783e03a40Smrg      func_fatal_error "invalid tag name: $tagname"
95883e03a40Smrg      ;;
95983e03a40Smrg  esac
960357bfbb2Smrg
96183e03a40Smrg  # Don't test for the "default" C tag, as we know it's
96283e03a40Smrg  # there but not specially marked.
96383e03a40Smrg  case $tagname in
96483e03a40Smrg    CC) ;;
96583e03a40Smrg    *)
96683e03a40Smrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
96783e03a40Smrg	taglist="$taglist $tagname"
96883e03a40Smrg
96983e03a40Smrg	# Evaluate the configuration.  Be careful to quote the path
97083e03a40Smrg	# and the sed script, to avoid splitting on whitespace, but
97183e03a40Smrg	# also don't use non-portable quotes within backquotes within
97283e03a40Smrg	# quotes we have to do it in 2 steps:
97383e03a40Smrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
97483e03a40Smrg	eval "$extractedcf"
97583e03a40Smrg      else
97683e03a40Smrg	func_error "ignoring unknown tag $tagname"
97783e03a40Smrg      fi
97883e03a40Smrg      ;;
97983e03a40Smrg  esac
98083e03a40Smrg}
981357bfbb2Smrg
98283e03a40Smrg# func_check_version_match
98383e03a40Smrg# Ensure that we are using m4 macros, and libtool script from the same
98483e03a40Smrg# release of libtool.
98583e03a40Smrgfunc_check_version_match ()
98683e03a40Smrg{
98783e03a40Smrg  if test "$package_revision" != "$macro_revision"; then
98883e03a40Smrg    if test "$VERSION" != "$macro_version"; then
98983e03a40Smrg      if test -z "$macro_version"; then
99083e03a40Smrg        cat >&2 <<_LT_EOF
99183e03a40Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
99283e03a40Smrg$progname: definition of this LT_INIT comes from an older release.
99383e03a40Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
99483e03a40Smrg$progname: and run autoconf again.
99583e03a40Smrg_LT_EOF
99683e03a40Smrg      else
99783e03a40Smrg        cat >&2 <<_LT_EOF
99883e03a40Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
99983e03a40Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
100083e03a40Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
100183e03a40Smrg$progname: and run autoconf again.
100283e03a40Smrg_LT_EOF
100383e03a40Smrg      fi
100483e03a40Smrg    else
100583e03a40Smrg      cat >&2 <<_LT_EOF
100683e03a40Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
100783e03a40Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
100883e03a40Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
100983e03a40Smrg$progname: of $PACKAGE $VERSION and run autoconf again.
101083e03a40Smrg_LT_EOF
101183e03a40Smrg    fi
1012357bfbb2Smrg
101383e03a40Smrg    exit $EXIT_MISMATCH
101483e03a40Smrg  fi
101583e03a40Smrg}
1016357bfbb2Smrg
1017357bfbb2Smrg
101883e03a40Smrg# Shorthand for --mode=foo, only valid as the first argument
101983e03a40Smrgcase $1 in
102083e03a40Smrgclean|clea|cle|cl)
102183e03a40Smrg  shift; set dummy --mode clean ${1+"$@"}; shift
102283e03a40Smrg  ;;
102383e03a40Smrgcompile|compil|compi|comp|com|co|c)
102483e03a40Smrg  shift; set dummy --mode compile ${1+"$@"}; shift
102583e03a40Smrg  ;;
102683e03a40Smrgexecute|execut|execu|exec|exe|ex|e)
102783e03a40Smrg  shift; set dummy --mode execute ${1+"$@"}; shift
102883e03a40Smrg  ;;
102983e03a40Smrgfinish|finis|fini|fin|fi|f)
103083e03a40Smrg  shift; set dummy --mode finish ${1+"$@"}; shift
1031357bfbb2Smrg  ;;
103283e03a40Smrginstall|instal|insta|inst|ins|in|i)
103383e03a40Smrg  shift; set dummy --mode install ${1+"$@"}; shift
1034357bfbb2Smrg  ;;
103583e03a40Smrglink|lin|li|l)
103683e03a40Smrg  shift; set dummy --mode link ${1+"$@"}; shift
103783e03a40Smrg  ;;
103883e03a40Smrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
103983e03a40Smrg  shift; set dummy --mode uninstall ${1+"$@"}; shift
1040357bfbb2Smrg  ;;
1041357bfbb2Smrgesac
1042357bfbb2Smrg
1043357bfbb2Smrg
1044357bfbb2Smrg
104583e03a40Smrg# Option defaults:
104683e03a40Smrgopt_debug=:
104783e03a40Smrgopt_dry_run=false
104883e03a40Smrgopt_config=false
104983e03a40Smrgopt_preserve_dup_deps=false
105083e03a40Smrgopt_features=false
105183e03a40Smrgopt_finish=false
105283e03a40Smrgopt_help=false
105383e03a40Smrgopt_help_all=false
105483e03a40Smrgopt_silent=:
105583e03a40Smrgopt_verbose=:
105683e03a40Smrgopt_silent=false
105783e03a40Smrgopt_verbose=false
1058357bfbb2Smrg
105983e03a40Smrg
106083e03a40Smrg# Parse options once, thoroughly.  This comes as soon as possible in the
106183e03a40Smrg# script to make things like `--version' happen as quickly as we can.
106283e03a40Smrg{
106383e03a40Smrg  # this just eases exit handling
106483e03a40Smrg  while test $# -gt 0; do
106583e03a40Smrg    opt="$1"
106683e03a40Smrg    shift
106783e03a40Smrg    case $opt in
106883e03a40Smrg      --debug|-x)	opt_debug='set -x'
106983e03a40Smrg			func_echo "enabling shell trace mode"
107083e03a40Smrg			$opt_debug
107183e03a40Smrg			;;
107283e03a40Smrg      --dry-run|--dryrun|-n)
107383e03a40Smrg			opt_dry_run=:
107483e03a40Smrg			;;
107583e03a40Smrg      --config)
107683e03a40Smrg			opt_config=:
107783e03a40Smrgfunc_config
107883e03a40Smrg			;;
107983e03a40Smrg      --dlopen|-dlopen)
108083e03a40Smrg			optarg="$1"
108183e03a40Smrg			opt_dlopen="${opt_dlopen+$opt_dlopen
108283e03a40Smrg}$optarg"
108383e03a40Smrg			shift
108483e03a40Smrg			;;
108583e03a40Smrg      --preserve-dup-deps)
108683e03a40Smrg			opt_preserve_dup_deps=:
108783e03a40Smrg			;;
108883e03a40Smrg      --features)
108983e03a40Smrg			opt_features=:
109083e03a40Smrgfunc_features
109183e03a40Smrg			;;
109283e03a40Smrg      --finish)
109383e03a40Smrg			opt_finish=:
109483e03a40Smrgset dummy --mode finish ${1+"$@"}; shift
109583e03a40Smrg			;;
109683e03a40Smrg      --help)
109783e03a40Smrg			opt_help=:
109883e03a40Smrg			;;
109983e03a40Smrg      --help-all)
110083e03a40Smrg			opt_help_all=:
110183e03a40Smrgopt_help=': help-all'
110283e03a40Smrg			;;
110383e03a40Smrg      --mode)
110483e03a40Smrg			test $# = 0 && func_missing_arg $opt && break
110583e03a40Smrg			optarg="$1"
110683e03a40Smrg			opt_mode="$optarg"
110783e03a40Smrgcase $optarg in
110883e03a40Smrg  # Valid mode arguments:
110983e03a40Smrg  clean|compile|execute|finish|install|link|relink|uninstall) ;;
111083e03a40Smrg
111183e03a40Smrg  # Catch anything else as an error
111283e03a40Smrg  *) func_error "invalid argument for $opt"
111383e03a40Smrg     exit_cmd=exit
111483e03a40Smrg     break
111583e03a40Smrg     ;;
111683e03a40Smrgesac
111783e03a40Smrg			shift
111883e03a40Smrg			;;
111983e03a40Smrg      --no-silent|--no-quiet)
112083e03a40Smrg			opt_silent=false
112183e03a40Smrgfunc_append preserve_args " $opt"
112283e03a40Smrg			;;
112383e03a40Smrg      --no-verbose)
112483e03a40Smrg			opt_verbose=false
112583e03a40Smrgfunc_append preserve_args " $opt"
112683e03a40Smrg			;;
112783e03a40Smrg      --silent|--quiet)
112883e03a40Smrg			opt_silent=:
112983e03a40Smrgfunc_append preserve_args " $opt"
113083e03a40Smrg        opt_verbose=false
113183e03a40Smrg			;;
113283e03a40Smrg      --verbose|-v)
113383e03a40Smrg			opt_verbose=:
113483e03a40Smrgfunc_append preserve_args " $opt"
113583e03a40Smrgopt_silent=false
113683e03a40Smrg			;;
113783e03a40Smrg      --tag)
113883e03a40Smrg			test $# = 0 && func_missing_arg $opt && break
113983e03a40Smrg			optarg="$1"
114083e03a40Smrg			opt_tag="$optarg"
114183e03a40Smrgfunc_append preserve_args " $opt $optarg"
114283e03a40Smrgfunc_enable_tag "$optarg"
114383e03a40Smrg			shift
114483e03a40Smrg			;;
114583e03a40Smrg
114683e03a40Smrg      -\?|-h)		func_usage				;;
114783e03a40Smrg      --help)		func_help				;;
114883e03a40Smrg      --version)	func_version				;;
114983e03a40Smrg
115083e03a40Smrg      # Separate optargs to long options:
115183e03a40Smrg      --*=*)
115283e03a40Smrg			func_split_long_opt "$opt"
115383e03a40Smrg			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
115483e03a40Smrg			shift
115583e03a40Smrg			;;
115683e03a40Smrg
115783e03a40Smrg      # Separate non-argument short options:
115883e03a40Smrg      -\?*|-h*|-n*|-v*)
115983e03a40Smrg			func_split_short_opt "$opt"
116083e03a40Smrg			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
116183e03a40Smrg			shift
116283e03a40Smrg			;;
116383e03a40Smrg
116483e03a40Smrg      --)		break					;;
116583e03a40Smrg      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
116683e03a40Smrg      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
1167357bfbb2Smrg    esac
116883e03a40Smrg  done
1169357bfbb2Smrg
117083e03a40Smrg  # Validate options:
117183e03a40Smrg
117283e03a40Smrg  # save first non-option argument
117383e03a40Smrg  if test "$#" -gt 0; then
117483e03a40Smrg    nonopt="$opt"
117583e03a40Smrg    shift
1176357bfbb2Smrg  fi
1177357bfbb2Smrg
117883e03a40Smrg  # preserve --debug
117983e03a40Smrg  test "$opt_debug" = : || func_append preserve_args " --debug"
1180357bfbb2Smrg
118183e03a40Smrg  case $host in
118283e03a40Smrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
118383e03a40Smrg      # don't eliminate duplications in $postdeps and $predeps
118483e03a40Smrg      opt_duplicate_compiler_generated_deps=:
118583e03a40Smrg      ;;
118683e03a40Smrg    *)
118783e03a40Smrg      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
118883e03a40Smrg      ;;
118983e03a40Smrg  esac
1190357bfbb2Smrg
119183e03a40Smrg  $opt_help || {
119283e03a40Smrg    # Sanity checks first:
119383e03a40Smrg    func_check_version_match
1194357bfbb2Smrg
119583e03a40Smrg    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
119683e03a40Smrg      func_fatal_configuration "not configured to build any kind of library"
119783e03a40Smrg    fi
1198357bfbb2Smrg
119983e03a40Smrg    # Darwin sucks
120083e03a40Smrg    eval std_shrext=\"$shrext_cmds\"
1201357bfbb2Smrg
120283e03a40Smrg    # Only execute mode is allowed to have -dlopen flags.
120383e03a40Smrg    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
120483e03a40Smrg      func_error "unrecognized option \`-dlopen'"
120583e03a40Smrg      $ECHO "$help" 1>&2
120683e03a40Smrg      exit $EXIT_FAILURE
120783e03a40Smrg    fi
1208357bfbb2Smrg
120983e03a40Smrg    # Change the help message to a mode-specific one.
121083e03a40Smrg    generic_help="$help"
121183e03a40Smrg    help="Try \`$progname --help --mode=$opt_mode' for more information."
121283e03a40Smrg  }
1213357bfbb2Smrg
1214357bfbb2Smrg
121583e03a40Smrg  # Bail if the options were screwed
121683e03a40Smrg  $exit_cmd $EXIT_FAILURE
121783e03a40Smrg}
1218357bfbb2Smrg
1219357bfbb2Smrg
1220357bfbb2Smrg
1221357bfbb2Smrg
122283e03a40Smrg## ----------- ##
122383e03a40Smrg##    Main.    ##
122483e03a40Smrg## ----------- ##
1225357bfbb2Smrg
122683e03a40Smrg# func_lalib_p file
122783e03a40Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
122883e03a40Smrg# This function is only a basic sanity check; it will hardly flush out
122983e03a40Smrg# determined imposters.
123083e03a40Smrgfunc_lalib_p ()
123183e03a40Smrg{
123283e03a40Smrg    test -f "$1" &&
123383e03a40Smrg      $SED -e 4q "$1" 2>/dev/null \
123483e03a40Smrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
123583e03a40Smrg}
1236357bfbb2Smrg
123783e03a40Smrg# func_lalib_unsafe_p file
123883e03a40Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
123983e03a40Smrg# This function implements the same check as func_lalib_p without
124083e03a40Smrg# resorting to external programs.  To this end, it redirects stdin and
124183e03a40Smrg# closes it afterwards, without saving the original file descriptor.
124283e03a40Smrg# As a safety measure, use it only where a negative result would be
124383e03a40Smrg# fatal anyway.  Works if `file' does not exist.
124483e03a40Smrgfunc_lalib_unsafe_p ()
124583e03a40Smrg{
124683e03a40Smrg    lalib_p=no
124783e03a40Smrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
124883e03a40Smrg	for lalib_p_l in 1 2 3 4
124983e03a40Smrg	do
125083e03a40Smrg	    read lalib_p_line
125183e03a40Smrg	    case "$lalib_p_line" in
125283e03a40Smrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
125383e03a40Smrg	    esac
125483e03a40Smrg	done
125583e03a40Smrg	exec 0<&5 5<&-
125683e03a40Smrg    fi
125783e03a40Smrg    test "$lalib_p" = yes
125883e03a40Smrg}
1259357bfbb2Smrg
126083e03a40Smrg# func_ltwrapper_script_p file
126183e03a40Smrg# True iff FILE is a libtool wrapper script
126283e03a40Smrg# This function is only a basic sanity check; it will hardly flush out
126383e03a40Smrg# determined imposters.
126483e03a40Smrgfunc_ltwrapper_script_p ()
126583e03a40Smrg{
126683e03a40Smrg    func_lalib_p "$1"
126783e03a40Smrg}
1268357bfbb2Smrg
126983e03a40Smrg# func_ltwrapper_executable_p file
127083e03a40Smrg# True iff FILE is a libtool wrapper executable
127183e03a40Smrg# This function is only a basic sanity check; it will hardly flush out
127283e03a40Smrg# determined imposters.
127383e03a40Smrgfunc_ltwrapper_executable_p ()
127483e03a40Smrg{
127583e03a40Smrg    func_ltwrapper_exec_suffix=
127683e03a40Smrg    case $1 in
127783e03a40Smrg    *.exe) ;;
127883e03a40Smrg    *) func_ltwrapper_exec_suffix=.exe ;;
1279357bfbb2Smrg    esac
128083e03a40Smrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
128183e03a40Smrg}
1282357bfbb2Smrg
128383e03a40Smrg# func_ltwrapper_scriptname file
128483e03a40Smrg# Assumes file is an ltwrapper_executable
128583e03a40Smrg# uses $file to determine the appropriate filename for a
128683e03a40Smrg# temporary ltwrapper_script.
128783e03a40Smrgfunc_ltwrapper_scriptname ()
128883e03a40Smrg{
128983e03a40Smrg    func_dirname_and_basename "$1" "" "."
129083e03a40Smrg    func_stripname '' '.exe' "$func_basename_result"
129183e03a40Smrg    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
129283e03a40Smrg}
1293357bfbb2Smrg
129483e03a40Smrg# func_ltwrapper_p file
129583e03a40Smrg# True iff FILE is a libtool wrapper script or wrapper executable
129683e03a40Smrg# This function is only a basic sanity check; it will hardly flush out
129783e03a40Smrg# determined imposters.
129883e03a40Smrgfunc_ltwrapper_p ()
129983e03a40Smrg{
130083e03a40Smrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
130183e03a40Smrg}
1302357bfbb2Smrg
1303357bfbb2Smrg
130483e03a40Smrg# func_execute_cmds commands fail_cmd
130583e03a40Smrg# Execute tilde-delimited COMMANDS.
130683e03a40Smrg# If FAIL_CMD is given, eval that upon failure.
130783e03a40Smrg# FAIL_CMD may read-access the current command in variable CMD!
130883e03a40Smrgfunc_execute_cmds ()
130983e03a40Smrg{
131083e03a40Smrg    $opt_debug
131183e03a40Smrg    save_ifs=$IFS; IFS='~'
131283e03a40Smrg    for cmd in $1; do
131383e03a40Smrg      IFS=$save_ifs
131483e03a40Smrg      eval cmd=\"$cmd\"
131583e03a40Smrg      func_show_eval "$cmd" "${2-:}"
1316357bfbb2Smrg    done
131783e03a40Smrg    IFS=$save_ifs
131883e03a40Smrg}
1319357bfbb2Smrg
1320357bfbb2Smrg
132183e03a40Smrg# func_source file
132283e03a40Smrg# Source FILE, adding directory component if necessary.
132383e03a40Smrg# Note that it is not necessary on cygwin/mingw to append a dot to
132483e03a40Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
132583e03a40Smrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
132683e03a40Smrg# `FILE.' does not work on cygwin managed mounts.
132783e03a40Smrgfunc_source ()
132883e03a40Smrg{
132983e03a40Smrg    $opt_debug
133083e03a40Smrg    case $1 in
133183e03a40Smrg    */* | *\\*)	. "$1" ;;
133283e03a40Smrg    *)		. "./$1" ;;
133383e03a40Smrg    esac
133483e03a40Smrg}
1335357bfbb2Smrg
1336357bfbb2Smrg
133783e03a40Smrg# func_resolve_sysroot PATH
133883e03a40Smrg# Replace a leading = in PATH with a sysroot.  Store the result into
133983e03a40Smrg# func_resolve_sysroot_result
134083e03a40Smrgfunc_resolve_sysroot ()
134183e03a40Smrg{
134283e03a40Smrg  func_resolve_sysroot_result=$1
134383e03a40Smrg  case $func_resolve_sysroot_result in
134483e03a40Smrg  =*)
134583e03a40Smrg    func_stripname '=' '' "$func_resolve_sysroot_result"
134683e03a40Smrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
134783e03a40Smrg    ;;
134883e03a40Smrg  esac
134983e03a40Smrg}
1350357bfbb2Smrg
135183e03a40Smrg# func_replace_sysroot PATH
135283e03a40Smrg# If PATH begins with the sysroot, replace it with = and
135383e03a40Smrg# store the result into func_replace_sysroot_result.
135483e03a40Smrgfunc_replace_sysroot ()
135583e03a40Smrg{
135683e03a40Smrg  case "$lt_sysroot:$1" in
135783e03a40Smrg  ?*:"$lt_sysroot"*)
135883e03a40Smrg    func_stripname "$lt_sysroot" '' "$1"
135983e03a40Smrg    func_replace_sysroot_result="=$func_stripname_result"
136083e03a40Smrg    ;;
136183e03a40Smrg  *)
136283e03a40Smrg    # Including no sysroot.
136383e03a40Smrg    func_replace_sysroot_result=$1
136483e03a40Smrg    ;;
136583e03a40Smrg  esac
136683e03a40Smrg}
1367357bfbb2Smrg
136883e03a40Smrg# func_infer_tag arg
136983e03a40Smrg# Infer tagged configuration to use if any are available and
137083e03a40Smrg# if one wasn't chosen via the "--tag" command line option.
137183e03a40Smrg# Only attempt this if the compiler in the base compile
137283e03a40Smrg# command doesn't match the default compiler.
137383e03a40Smrg# arg is usually of the form 'gcc ...'
137483e03a40Smrgfunc_infer_tag ()
137583e03a40Smrg{
137683e03a40Smrg    $opt_debug
137783e03a40Smrg    if test -n "$available_tags" && test -z "$tagname"; then
137883e03a40Smrg      CC_quoted=
137983e03a40Smrg      for arg in $CC; do
138083e03a40Smrg	func_append_quoted CC_quoted "$arg"
138183e03a40Smrg      done
138283e03a40Smrg      CC_expanded=`func_echo_all $CC`
138383e03a40Smrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
138483e03a40Smrg      case $@ in
138583e03a40Smrg      # Blanks in the command may have been stripped by the calling shell,
138683e03a40Smrg      # but not from the CC environment variable when configure was run.
138783e03a40Smrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
138883e03a40Smrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
138983e03a40Smrg      # Blanks at the start of $base_compile will cause this to fail
139083e03a40Smrg      # if we don't check for them as well.
139183e03a40Smrg      *)
139283e03a40Smrg	for z in $available_tags; do
139383e03a40Smrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
139483e03a40Smrg	    # Evaluate the configuration.
139583e03a40Smrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
139683e03a40Smrg	    CC_quoted=
139783e03a40Smrg	    for arg in $CC; do
139883e03a40Smrg	      # Double-quote args containing other shell metacharacters.
139983e03a40Smrg	      func_append_quoted CC_quoted "$arg"
140083e03a40Smrg	    done
140183e03a40Smrg	    CC_expanded=`func_echo_all $CC`
140283e03a40Smrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
140383e03a40Smrg	    case "$@ " in
140483e03a40Smrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
140583e03a40Smrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
140683e03a40Smrg	      # The compiler in the base compile command matches
140783e03a40Smrg	      # the one in the tagged configuration.
140883e03a40Smrg	      # Assume this is the tagged configuration we want.
140983e03a40Smrg	      tagname=$z
141083e03a40Smrg	      break
141183e03a40Smrg	      ;;
141283e03a40Smrg	    esac
141383e03a40Smrg	  fi
141483e03a40Smrg	done
141583e03a40Smrg	# If $tagname still isn't set, then no tagged configuration
141683e03a40Smrg	# was found and let the user know that the "--tag" command
141783e03a40Smrg	# line option must be used.
141883e03a40Smrg	if test -z "$tagname"; then
141983e03a40Smrg	  func_echo "unable to infer tagged configuration"
142083e03a40Smrg	  func_fatal_error "specify a tag with \`--tag'"
142183e03a40Smrg#	else
142283e03a40Smrg#	  func_verbose "using $tagname tagged configuration"
142383e03a40Smrg	fi
142483e03a40Smrg	;;
142583e03a40Smrg      esac
1426357bfbb2Smrg    fi
142783e03a40Smrg}
1428357bfbb2Smrg
1429357bfbb2Smrg
1430357bfbb2Smrg
143183e03a40Smrg# func_write_libtool_object output_name pic_name nonpic_name
143283e03a40Smrg# Create a libtool object file (analogous to a ".la" file),
143383e03a40Smrg# but don't create it if we're doing a dry run.
143483e03a40Smrgfunc_write_libtool_object ()
143583e03a40Smrg{
143683e03a40Smrg    write_libobj=${1}
143783e03a40Smrg    if test "$build_libtool_libs" = yes; then
143883e03a40Smrg      write_lobj=\'${2}\'
143983e03a40Smrg    else
144083e03a40Smrg      write_lobj=none
1441357bfbb2Smrg    fi
1442357bfbb2Smrg
144383e03a40Smrg    if test "$build_old_libs" = yes; then
144483e03a40Smrg      write_oldobj=\'${3}\'
144583e03a40Smrg    else
144683e03a40Smrg      write_oldobj=none
1447357bfbb2Smrg    fi
1448357bfbb2Smrg
144983e03a40Smrg    $opt_dry_run || {
145083e03a40Smrg      cat >${write_libobj}T <<EOF
145183e03a40Smrg# $write_libobj - a libtool object file
145283e03a40Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1453357bfbb2Smrg#
1454357bfbb2Smrg# Please DO NOT delete this file!
1455357bfbb2Smrg# It is necessary for linking the library.
1456357bfbb2Smrg
1457357bfbb2Smrg# Name of the PIC object.
145883e03a40Smrgpic_object=$write_lobj
1459357bfbb2Smrg
146083e03a40Smrg# Name of the non-PIC object
146183e03a40Smrgnon_pic_object=$write_oldobj
1462357bfbb2Smrg
146383e03a40SmrgEOF
146483e03a40Smrg      $MV "${write_libobj}T" "${write_libobj}"
146583e03a40Smrg    }
146683e03a40Smrg}
1467357bfbb2Smrg
1468357bfbb2Smrg
146983e03a40Smrg##################################################
147083e03a40Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
147183e03a40Smrg##################################################
1472357bfbb2Smrg
147383e03a40Smrg# func_convert_core_file_wine_to_w32 ARG
147483e03a40Smrg# Helper function used by file name conversion functions when $build is *nix,
147583e03a40Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
147683e03a40Smrg# correctly configured wine environment available, with the winepath program
147783e03a40Smrg# in $build's $PATH.
147883e03a40Smrg#
147983e03a40Smrg# ARG is the $build file name to be converted to w32 format.
148083e03a40Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
148183e03a40Smrg# be empty on error (or when ARG is empty)
148283e03a40Smrgfunc_convert_core_file_wine_to_w32 ()
148383e03a40Smrg{
148483e03a40Smrg  $opt_debug
148583e03a40Smrg  func_convert_core_file_wine_to_w32_result="$1"
148683e03a40Smrg  if test -n "$1"; then
148783e03a40Smrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
148883e03a40Smrg    # are forced to check the contents of stdout. On the other hand, if the
148983e03a40Smrg    # command is not found, the shell will set an exit code of 127 and print
149083e03a40Smrg    # *an error message* to stdout. So we must check for both error code of
149183e03a40Smrg    # zero AND non-empty stdout, which explains the odd construction:
149283e03a40Smrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
149383e03a40Smrg    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
149483e03a40Smrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
149583e03a40Smrg        $SED -e "$lt_sed_naive_backslashify"`
149683e03a40Smrg    else
149783e03a40Smrg      func_convert_core_file_wine_to_w32_result=
149883e03a40Smrg    fi
149983e03a40Smrg  fi
150083e03a40Smrg}
150183e03a40Smrg# end: func_convert_core_file_wine_to_w32
1502357bfbb2Smrg
150383e03a40Smrg
150483e03a40Smrg# func_convert_core_path_wine_to_w32 ARG
150583e03a40Smrg# Helper function used by path conversion functions when $build is *nix, and
150683e03a40Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
150783e03a40Smrg# configured wine environment available, with the winepath program in $build's
150883e03a40Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
150983e03a40Smrg#
151083e03a40Smrg# ARG is path to be converted from $build format to win32.
151183e03a40Smrg# Result is available in $func_convert_core_path_wine_to_w32_result.
151283e03a40Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
151383e03a40Smrg# are convertible, then the result may be empty.
151483e03a40Smrgfunc_convert_core_path_wine_to_w32 ()
151583e03a40Smrg{
151683e03a40Smrg  $opt_debug
151783e03a40Smrg  # unfortunately, winepath doesn't convert paths, only file names
151883e03a40Smrg  func_convert_core_path_wine_to_w32_result=""
151983e03a40Smrg  if test -n "$1"; then
152083e03a40Smrg    oldIFS=$IFS
152183e03a40Smrg    IFS=:
152283e03a40Smrg    for func_convert_core_path_wine_to_w32_f in $1; do
152383e03a40Smrg      IFS=$oldIFS
152483e03a40Smrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
152583e03a40Smrg      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
152683e03a40Smrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
152783e03a40Smrg          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
152883e03a40Smrg        else
152983e03a40Smrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
153083e03a40Smrg        fi
1531357bfbb2Smrg      fi
153283e03a40Smrg    done
153383e03a40Smrg    IFS=$oldIFS
153483e03a40Smrg  fi
153583e03a40Smrg}
153683e03a40Smrg# end: func_convert_core_path_wine_to_w32
153783e03a40Smrg
153883e03a40Smrg
153983e03a40Smrg# func_cygpath ARGS...
154083e03a40Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
154183e03a40Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
154283e03a40Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
154383e03a40Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
154483e03a40Smrg# file name or path is assumed to be in w32 format, as previously converted
154583e03a40Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
154683e03a40Smrg# or path in func_cygpath_result (input file name or path is assumed to be in
154783e03a40Smrg# Cygwin format). Returns an empty string on error.
154883e03a40Smrg#
154983e03a40Smrg# ARGS are passed to cygpath, with the last one being the file name or path to
155083e03a40Smrg# be converted.
155183e03a40Smrg#
155283e03a40Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
155383e03a40Smrg# environment variable; do not put it in $PATH.
155483e03a40Smrgfunc_cygpath ()
155583e03a40Smrg{
155683e03a40Smrg  $opt_debug
155783e03a40Smrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
155883e03a40Smrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
155983e03a40Smrg    if test "$?" -ne 0; then
156083e03a40Smrg      # on failure, ensure result is empty
156183e03a40Smrg      func_cygpath_result=
156283e03a40Smrg    fi
156383e03a40Smrg  else
156483e03a40Smrg    func_cygpath_result=
156583e03a40Smrg    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
156683e03a40Smrg  fi
156783e03a40Smrg}
156883e03a40Smrg#end: func_cygpath
1569357bfbb2Smrg
1570357bfbb2Smrg
157183e03a40Smrg# func_convert_core_msys_to_w32 ARG
157283e03a40Smrg# Convert file name or path ARG from MSYS format to w32 format.  Return
157383e03a40Smrg# result in func_convert_core_msys_to_w32_result.
157483e03a40Smrgfunc_convert_core_msys_to_w32 ()
157583e03a40Smrg{
157683e03a40Smrg  $opt_debug
157783e03a40Smrg  # awkward: cmd appends spaces to result
157883e03a40Smrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
157983e03a40Smrg    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
158083e03a40Smrg}
158183e03a40Smrg#end: func_convert_core_msys_to_w32
1582357bfbb2Smrg
1583357bfbb2Smrg
158483e03a40Smrg# func_convert_file_check ARG1 ARG2
158583e03a40Smrg# Verify that ARG1 (a file name in $build format) was converted to $host
158683e03a40Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
158783e03a40Smrg# func_to_host_file_result to ARG1).
158883e03a40Smrgfunc_convert_file_check ()
158983e03a40Smrg{
159083e03a40Smrg  $opt_debug
159183e03a40Smrg  if test -z "$2" && test -n "$1" ; then
159283e03a40Smrg    func_error "Could not determine host file name corresponding to"
159383e03a40Smrg    func_error "  \`$1'"
159483e03a40Smrg    func_error "Continuing, but uninstalled executables may not work."
159583e03a40Smrg    # Fallback:
159683e03a40Smrg    func_to_host_file_result="$1"
159783e03a40Smrg  fi
159883e03a40Smrg}
159983e03a40Smrg# end func_convert_file_check
1600357bfbb2Smrg
1601357bfbb2Smrg
160283e03a40Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
160383e03a40Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host
160483e03a40Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
160583e03a40Smrg# func_to_host_file_result to a simplistic fallback value (see below).
160683e03a40Smrgfunc_convert_path_check ()
160783e03a40Smrg{
160883e03a40Smrg  $opt_debug
160983e03a40Smrg  if test -z "$4" && test -n "$3"; then
161083e03a40Smrg    func_error "Could not determine the host path corresponding to"
161183e03a40Smrg    func_error "  \`$3'"
161283e03a40Smrg    func_error "Continuing, but uninstalled executables may not work."
161383e03a40Smrg    # Fallback.  This is a deliberately simplistic "conversion" and
161483e03a40Smrg    # should not be "improved".  See libtool.info.
161583e03a40Smrg    if test "x$1" != "x$2"; then
161683e03a40Smrg      lt_replace_pathsep_chars="s|$1|$2|g"
161783e03a40Smrg      func_to_host_path_result=`echo "$3" |
161883e03a40Smrg        $SED -e "$lt_replace_pathsep_chars"`
161983e03a40Smrg    else
162083e03a40Smrg      func_to_host_path_result="$3"
162183e03a40Smrg    fi
162283e03a40Smrg  fi
162383e03a40Smrg}
162483e03a40Smrg# end func_convert_path_check
1625357bfbb2Smrg
1626357bfbb2Smrg
162783e03a40Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
162883e03a40Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
162983e03a40Smrg# and appending REPL if ORIG matches BACKPAT.
163083e03a40Smrgfunc_convert_path_front_back_pathsep ()
163183e03a40Smrg{
163283e03a40Smrg  $opt_debug
163383e03a40Smrg  case $4 in
163483e03a40Smrg  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
163583e03a40Smrg    ;;
163683e03a40Smrg  esac
163783e03a40Smrg  case $4 in
163883e03a40Smrg  $2 ) func_append func_to_host_path_result "$3"
163983e03a40Smrg    ;;
164083e03a40Smrg  esac
164183e03a40Smrg}
164283e03a40Smrg# end func_convert_path_front_back_pathsep
1643357bfbb2Smrg
1644357bfbb2Smrg
164583e03a40Smrg##################################################
164683e03a40Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
164783e03a40Smrg##################################################
164883e03a40Smrg# invoked via `$to_host_file_cmd ARG'
164983e03a40Smrg#
165083e03a40Smrg# In each case, ARG is the path to be converted from $build to $host format.
165183e03a40Smrg# Result will be available in $func_to_host_file_result.
1652357bfbb2Smrg
1653357bfbb2Smrg
165483e03a40Smrg# func_to_host_file ARG
165583e03a40Smrg# Converts the file name ARG from $build format to $host format. Return result
165683e03a40Smrg# in func_to_host_file_result.
165783e03a40Smrgfunc_to_host_file ()
165883e03a40Smrg{
165983e03a40Smrg  $opt_debug
166083e03a40Smrg  $to_host_file_cmd "$1"
166183e03a40Smrg}
166283e03a40Smrg# end func_to_host_file
1663357bfbb2Smrg
1664357bfbb2Smrg
166583e03a40Smrg# func_to_tool_file ARG LAZY
166683e03a40Smrg# converts the file name ARG from $build format to toolchain format. Return
166783e03a40Smrg# result in func_to_tool_file_result.  If the conversion in use is listed
166883e03a40Smrg# in (the comma separated) LAZY, no conversion takes place.
166983e03a40Smrgfunc_to_tool_file ()
167083e03a40Smrg{
167183e03a40Smrg  $opt_debug
167283e03a40Smrg  case ,$2, in
167383e03a40Smrg    *,"$to_tool_file_cmd",*)
167483e03a40Smrg      func_to_tool_file_result=$1
167583e03a40Smrg      ;;
167683e03a40Smrg    *)
167783e03a40Smrg      $to_tool_file_cmd "$1"
167883e03a40Smrg      func_to_tool_file_result=$func_to_host_file_result
167983e03a40Smrg      ;;
168083e03a40Smrg  esac
168183e03a40Smrg}
168283e03a40Smrg# end func_to_tool_file
1683357bfbb2Smrg
1684357bfbb2Smrg
168583e03a40Smrg# func_convert_file_noop ARG
168683e03a40Smrg# Copy ARG to func_to_host_file_result.
168783e03a40Smrgfunc_convert_file_noop ()
168883e03a40Smrg{
168983e03a40Smrg  func_to_host_file_result="$1"
169083e03a40Smrg}
169183e03a40Smrg# end func_convert_file_noop
1692357bfbb2Smrg
1693357bfbb2Smrg
169483e03a40Smrg# func_convert_file_msys_to_w32 ARG
169583e03a40Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
169683e03a40Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
169783e03a40Smrg# func_to_host_file_result.
169883e03a40Smrgfunc_convert_file_msys_to_w32 ()
169983e03a40Smrg{
170083e03a40Smrg  $opt_debug
170183e03a40Smrg  func_to_host_file_result="$1"
170283e03a40Smrg  if test -n "$1"; then
170383e03a40Smrg    func_convert_core_msys_to_w32 "$1"
170483e03a40Smrg    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
170583e03a40Smrg  fi
170683e03a40Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
170783e03a40Smrg}
170883e03a40Smrg# end func_convert_file_msys_to_w32
1709357bfbb2Smrg
1710357bfbb2Smrg
171183e03a40Smrg# func_convert_file_cygwin_to_w32 ARG
171283e03a40Smrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
171383e03a40Smrg# func_to_host_file_result.
171483e03a40Smrgfunc_convert_file_cygwin_to_w32 ()
171583e03a40Smrg{
171683e03a40Smrg  $opt_debug
171783e03a40Smrg  func_to_host_file_result="$1"
171883e03a40Smrg  if test -n "$1"; then
171983e03a40Smrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
172083e03a40Smrg    # LT_CYGPATH in this case.
172183e03a40Smrg    func_to_host_file_result=`cygpath -m "$1"`
172283e03a40Smrg  fi
172383e03a40Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
172483e03a40Smrg}
172583e03a40Smrg# end func_convert_file_cygwin_to_w32
1726357bfbb2Smrg
1727357bfbb2Smrg
172883e03a40Smrg# func_convert_file_nix_to_w32 ARG
172983e03a40Smrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
173083e03a40Smrg# and a working winepath. Returns result in func_to_host_file_result.
173183e03a40Smrgfunc_convert_file_nix_to_w32 ()
173283e03a40Smrg{
173383e03a40Smrg  $opt_debug
173483e03a40Smrg  func_to_host_file_result="$1"
173583e03a40Smrg  if test -n "$1"; then
173683e03a40Smrg    func_convert_core_file_wine_to_w32 "$1"
173783e03a40Smrg    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
173883e03a40Smrg  fi
173983e03a40Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
174083e03a40Smrg}
174183e03a40Smrg# end func_convert_file_nix_to_w32
1742357bfbb2Smrg
1743357bfbb2Smrg
174483e03a40Smrg# func_convert_file_msys_to_cygwin ARG
174583e03a40Smrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
174683e03a40Smrg# Returns result in func_to_host_file_result.
174783e03a40Smrgfunc_convert_file_msys_to_cygwin ()
174883e03a40Smrg{
174983e03a40Smrg  $opt_debug
175083e03a40Smrg  func_to_host_file_result="$1"
175183e03a40Smrg  if test -n "$1"; then
175283e03a40Smrg    func_convert_core_msys_to_w32 "$1"
175383e03a40Smrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
175483e03a40Smrg    func_to_host_file_result="$func_cygpath_result"
175583e03a40Smrg  fi
175683e03a40Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
175783e03a40Smrg}
175883e03a40Smrg# end func_convert_file_msys_to_cygwin
1759357bfbb2Smrg
1760357bfbb2Smrg
176183e03a40Smrg# func_convert_file_nix_to_cygwin ARG
176283e03a40Smrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
176383e03a40Smrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
176483e03a40Smrg# in func_to_host_file_result.
176583e03a40Smrgfunc_convert_file_nix_to_cygwin ()
176683e03a40Smrg{
176783e03a40Smrg  $opt_debug
176883e03a40Smrg  func_to_host_file_result="$1"
176983e03a40Smrg  if test -n "$1"; then
177083e03a40Smrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
177183e03a40Smrg    func_convert_core_file_wine_to_w32 "$1"
177283e03a40Smrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
177383e03a40Smrg    func_to_host_file_result="$func_cygpath_result"
177483e03a40Smrg  fi
177583e03a40Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
177683e03a40Smrg}
177783e03a40Smrg# end func_convert_file_nix_to_cygwin
1778357bfbb2Smrg
1779357bfbb2Smrg
178083e03a40Smrg#############################################
178183e03a40Smrg# $build to $host PATH CONVERSION FUNCTIONS #
178283e03a40Smrg#############################################
178383e03a40Smrg# invoked via `$to_host_path_cmd ARG'
178483e03a40Smrg#
178583e03a40Smrg# In each case, ARG is the path to be converted from $build to $host format.
178683e03a40Smrg# The result will be available in $func_to_host_path_result.
178783e03a40Smrg#
178883e03a40Smrg# Path separators are also converted from $build format to $host format.  If
178983e03a40Smrg# ARG begins or ends with a path separator character, it is preserved (but
179083e03a40Smrg# converted to $host format) on output.
179183e03a40Smrg#
179283e03a40Smrg# All path conversion functions are named using the following convention:
179383e03a40Smrg#   file name conversion function    : func_convert_file_X_to_Y ()
179483e03a40Smrg#   path conversion function         : func_convert_path_X_to_Y ()
179583e03a40Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the
179683e03a40Smrg# same.  If conversion functions are added for new $build/$host combinations,
179783e03a40Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
179883e03a40Smrg# will break.
179983e03a40Smrg
180083e03a40Smrg
180183e03a40Smrg# func_init_to_host_path_cmd
180283e03a40Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
180383e03a40Smrg# appropriate value, based on the value of $to_host_file_cmd.
180483e03a40Smrgto_host_path_cmd=
180583e03a40Smrgfunc_init_to_host_path_cmd ()
180683e03a40Smrg{
180783e03a40Smrg  $opt_debug
180883e03a40Smrg  if test -z "$to_host_path_cmd"; then
180983e03a40Smrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
181083e03a40Smrg    to_host_path_cmd="func_convert_path_${func_stripname_result}"
181183e03a40Smrg  fi
181283e03a40Smrg}
1813357bfbb2Smrg
1814357bfbb2Smrg
181583e03a40Smrg# func_to_host_path ARG
181683e03a40Smrg# Converts the path ARG from $build format to $host format. Return result
181783e03a40Smrg# in func_to_host_path_result.
181883e03a40Smrgfunc_to_host_path ()
181983e03a40Smrg{
182083e03a40Smrg  $opt_debug
182183e03a40Smrg  func_init_to_host_path_cmd
182283e03a40Smrg  $to_host_path_cmd "$1"
182383e03a40Smrg}
182483e03a40Smrg# end func_to_host_path
1825357bfbb2Smrg
1826357bfbb2Smrg
182783e03a40Smrg# func_convert_path_noop ARG
182883e03a40Smrg# Copy ARG to func_to_host_path_result.
182983e03a40Smrgfunc_convert_path_noop ()
183083e03a40Smrg{
183183e03a40Smrg  func_to_host_path_result="$1"
183283e03a40Smrg}
183383e03a40Smrg# end func_convert_path_noop
1834357bfbb2Smrg
1835357bfbb2Smrg
183683e03a40Smrg# func_convert_path_msys_to_w32 ARG
183783e03a40Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
183883e03a40Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
183983e03a40Smrg# func_to_host_path_result.
184083e03a40Smrgfunc_convert_path_msys_to_w32 ()
184183e03a40Smrg{
184283e03a40Smrg  $opt_debug
184383e03a40Smrg  func_to_host_path_result="$1"
184483e03a40Smrg  if test -n "$1"; then
184583e03a40Smrg    # Remove leading and trailing path separator characters from ARG.  MSYS
184683e03a40Smrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
184783e03a40Smrg    # and winepath ignores them completely.
184883e03a40Smrg    func_stripname : : "$1"
184983e03a40Smrg    func_to_host_path_tmp1=$func_stripname_result
185083e03a40Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
185183e03a40Smrg    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
185283e03a40Smrg    func_convert_path_check : ";" \
185383e03a40Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
185483e03a40Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
185583e03a40Smrg  fi
185683e03a40Smrg}
185783e03a40Smrg# end func_convert_path_msys_to_w32
1858357bfbb2Smrg
1859357bfbb2Smrg
186083e03a40Smrg# func_convert_path_cygwin_to_w32 ARG
186183e03a40Smrg# Convert path ARG from Cygwin to w32 format.  Returns result in
186283e03a40Smrg# func_to_host_file_result.
186383e03a40Smrgfunc_convert_path_cygwin_to_w32 ()
186483e03a40Smrg{
186583e03a40Smrg  $opt_debug
186683e03a40Smrg  func_to_host_path_result="$1"
186783e03a40Smrg  if test -n "$1"; then
186883e03a40Smrg    # See func_convert_path_msys_to_w32:
186983e03a40Smrg    func_stripname : : "$1"
187083e03a40Smrg    func_to_host_path_tmp1=$func_stripname_result
187183e03a40Smrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
187283e03a40Smrg    func_convert_path_check : ";" \
187383e03a40Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
187483e03a40Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
187583e03a40Smrg  fi
187683e03a40Smrg}
187783e03a40Smrg# end func_convert_path_cygwin_to_w32
1878357bfbb2Smrg
1879357bfbb2Smrg
188083e03a40Smrg# func_convert_path_nix_to_w32 ARG
188183e03a40Smrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
188283e03a40Smrg# a working winepath.  Returns result in func_to_host_file_result.
188383e03a40Smrgfunc_convert_path_nix_to_w32 ()
188483e03a40Smrg{
188583e03a40Smrg  $opt_debug
188683e03a40Smrg  func_to_host_path_result="$1"
188783e03a40Smrg  if test -n "$1"; then
188883e03a40Smrg    # See func_convert_path_msys_to_w32:
188983e03a40Smrg    func_stripname : : "$1"
189083e03a40Smrg    func_to_host_path_tmp1=$func_stripname_result
189183e03a40Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
189283e03a40Smrg    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
189383e03a40Smrg    func_convert_path_check : ";" \
189483e03a40Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
189583e03a40Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
189683e03a40Smrg  fi
189783e03a40Smrg}
189883e03a40Smrg# end func_convert_path_nix_to_w32
1899357bfbb2Smrg
1900357bfbb2Smrg
190183e03a40Smrg# func_convert_path_msys_to_cygwin ARG
190283e03a40Smrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
190383e03a40Smrg# Returns result in func_to_host_file_result.
190483e03a40Smrgfunc_convert_path_msys_to_cygwin ()
190583e03a40Smrg{
190683e03a40Smrg  $opt_debug
190783e03a40Smrg  func_to_host_path_result="$1"
190883e03a40Smrg  if test -n "$1"; then
190983e03a40Smrg    # See func_convert_path_msys_to_w32:
191083e03a40Smrg    func_stripname : : "$1"
191183e03a40Smrg    func_to_host_path_tmp1=$func_stripname_result
191283e03a40Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
191383e03a40Smrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
191483e03a40Smrg    func_to_host_path_result="$func_cygpath_result"
191583e03a40Smrg    func_convert_path_check : : \
191683e03a40Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
191783e03a40Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
191883e03a40Smrg  fi
191983e03a40Smrg}
192083e03a40Smrg# end func_convert_path_msys_to_cygwin
1921357bfbb2Smrg
1922357bfbb2Smrg
192383e03a40Smrg# func_convert_path_nix_to_cygwin ARG
192483e03a40Smrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
192583e03a40Smrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
192683e03a40Smrg# func_to_host_file_result.
192783e03a40Smrgfunc_convert_path_nix_to_cygwin ()
192883e03a40Smrg{
192983e03a40Smrg  $opt_debug
193083e03a40Smrg  func_to_host_path_result="$1"
193183e03a40Smrg  if test -n "$1"; then
193283e03a40Smrg    # Remove leading and trailing path separator characters from
193383e03a40Smrg    # ARG. msys behavior is inconsistent here, cygpath turns them
193483e03a40Smrg    # into '.;' and ';.', and winepath ignores them completely.
193583e03a40Smrg    func_stripname : : "$1"
193683e03a40Smrg    func_to_host_path_tmp1=$func_stripname_result
193783e03a40Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
193883e03a40Smrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
193983e03a40Smrg    func_to_host_path_result="$func_cygpath_result"
194083e03a40Smrg    func_convert_path_check : : \
194183e03a40Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
194283e03a40Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
194383e03a40Smrg  fi
194483e03a40Smrg}
194583e03a40Smrg# end func_convert_path_nix_to_cygwin
1946357bfbb2Smrg
1947357bfbb2Smrg
194883e03a40Smrg# func_mode_compile arg...
194983e03a40Smrgfunc_mode_compile ()
195083e03a40Smrg{
195183e03a40Smrg    $opt_debug
195283e03a40Smrg    # Get the compilation command and the source file.
195383e03a40Smrg    base_compile=
195483e03a40Smrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
195583e03a40Smrg    suppress_opt=yes
195683e03a40Smrg    suppress_output=
195783e03a40Smrg    arg_mode=normal
195883e03a40Smrg    libobj=
195983e03a40Smrg    later=
196083e03a40Smrg    pie_flag=
196183e03a40Smrg
196283e03a40Smrg    for arg
196383e03a40Smrg    do
196483e03a40Smrg      case $arg_mode in
196583e03a40Smrg      arg  )
196683e03a40Smrg	# do not "continue".  Instead, add this to base_compile
196783e03a40Smrg	lastarg="$arg"
196883e03a40Smrg	arg_mode=normal
196983e03a40Smrg	;;
197083e03a40Smrg
197183e03a40Smrg      target )
197283e03a40Smrg	libobj="$arg"
197383e03a40Smrg	arg_mode=normal
197483e03a40Smrg	continue
197583e03a40Smrg	;;
197683e03a40Smrg
197783e03a40Smrg      normal )
197883e03a40Smrg	# Accept any command-line options.
197983e03a40Smrg	case $arg in
198083e03a40Smrg	-o)
198183e03a40Smrg	  test -n "$libobj" && \
198283e03a40Smrg	    func_fatal_error "you cannot specify \`-o' more than once"
198383e03a40Smrg	  arg_mode=target
1984357bfbb2Smrg	  continue
1985357bfbb2Smrg	  ;;
198683e03a40Smrg
198783e03a40Smrg	-pie | -fpie | -fPIE)
198883e03a40Smrg          func_append pie_flag " $arg"
1989357bfbb2Smrg	  continue
1990357bfbb2Smrg	  ;;
199183e03a40Smrg
199283e03a40Smrg	-shared | -static | -prefer-pic | -prefer-non-pic)
199383e03a40Smrg	  func_append later " $arg"
1994357bfbb2Smrg	  continue
1995357bfbb2Smrg	  ;;
199683e03a40Smrg
199783e03a40Smrg	-no-suppress)
199883e03a40Smrg	  suppress_opt=no
1999357bfbb2Smrg	  continue
2000357bfbb2Smrg	  ;;
2001357bfbb2Smrg
200283e03a40Smrg	-Xcompiler)
200383e03a40Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
200483e03a40Smrg	  continue      #  The current "srcfile" will either be retained or
200583e03a40Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
2006357bfbb2Smrg
200783e03a40Smrg	-Wc,*)
200883e03a40Smrg	  func_stripname '-Wc,' '' "$arg"
200983e03a40Smrg	  args=$func_stripname_result
201083e03a40Smrg	  lastarg=
201183e03a40Smrg	  save_ifs="$IFS"; IFS=','
201283e03a40Smrg	  for arg in $args; do
201383e03a40Smrg	    IFS="$save_ifs"
201483e03a40Smrg	    func_append_quoted lastarg "$arg"
201583e03a40Smrg	  done
201683e03a40Smrg	  IFS="$save_ifs"
201783e03a40Smrg	  func_stripname ' ' '' "$lastarg"
201883e03a40Smrg	  lastarg=$func_stripname_result
2019357bfbb2Smrg
202083e03a40Smrg	  # Add the arguments to base_compile.
202183e03a40Smrg	  func_append base_compile " $lastarg"
202283e03a40Smrg	  continue
202383e03a40Smrg	  ;;
2024357bfbb2Smrg
202583e03a40Smrg	*)
202683e03a40Smrg	  # Accept the current argument as the source file.
202783e03a40Smrg	  # The previous "srcfile" becomes the current argument.
202883e03a40Smrg	  #
202983e03a40Smrg	  lastarg="$srcfile"
203083e03a40Smrg	  srcfile="$arg"
203183e03a40Smrg	  ;;
203283e03a40Smrg	esac  #  case $arg
2033357bfbb2Smrg	;;
203483e03a40Smrg      esac    #  case $arg_mode
2035357bfbb2Smrg
203683e03a40Smrg      # Aesthetically quote the previous argument.
203783e03a40Smrg      func_append_quoted base_compile "$lastarg"
203883e03a40Smrg    done # for arg
2039357bfbb2Smrg
204083e03a40Smrg    case $arg_mode in
204183e03a40Smrg    arg)
204283e03a40Smrg      func_fatal_error "you must specify an argument for -Xcompile"
204383e03a40Smrg      ;;
204483e03a40Smrg    target)
204583e03a40Smrg      func_fatal_error "you must specify a target with \`-o'"
204683e03a40Smrg      ;;
204783e03a40Smrg    *)
204883e03a40Smrg      # Get the name of the library object.
204983e03a40Smrg      test -z "$libobj" && {
205083e03a40Smrg	func_basename "$srcfile"
205183e03a40Smrg	libobj="$func_basename_result"
205283e03a40Smrg      }
205383e03a40Smrg      ;;
205483e03a40Smrg    esac
2055357bfbb2Smrg
205683e03a40Smrg    # Recognize several different file suffixes.
205783e03a40Smrg    # If the user specifies -o file.o, it is replaced with file.lo
205883e03a40Smrg    case $libobj in
205983e03a40Smrg    *.[cCFSifmso] | \
206083e03a40Smrg    *.ada | *.adb | *.ads | *.asm | \
206183e03a40Smrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
206283e03a40Smrg    *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup)
206383e03a40Smrg      func_xform "$libobj"
206483e03a40Smrg      libobj=$func_xform_result
206583e03a40Smrg      ;;
206683e03a40Smrg    esac
2067357bfbb2Smrg
206883e03a40Smrg    case $libobj in
206983e03a40Smrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
207083e03a40Smrg    *)
207183e03a40Smrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
207283e03a40Smrg      ;;
207383e03a40Smrg    esac
2074357bfbb2Smrg
207583e03a40Smrg    func_infer_tag $base_compile
2076357bfbb2Smrg
207783e03a40Smrg    for arg in $later; do
207883e03a40Smrg      case $arg in
207983e03a40Smrg      -shared)
208083e03a40Smrg	test "$build_libtool_libs" != yes && \
208183e03a40Smrg	  func_fatal_configuration "can not build a shared library"
208283e03a40Smrg	build_old_libs=no
2083357bfbb2Smrg	continue
2084357bfbb2Smrg	;;
2085357bfbb2Smrg
208683e03a40Smrg      -static)
208783e03a40Smrg	build_libtool_libs=no
208883e03a40Smrg	build_old_libs=yes
2089357bfbb2Smrg	continue
2090357bfbb2Smrg	;;
2091357bfbb2Smrg
209283e03a40Smrg      -prefer-pic)
209383e03a40Smrg	pic_mode=yes
2094357bfbb2Smrg	continue
2095357bfbb2Smrg	;;
2096357bfbb2Smrg
209783e03a40Smrg      -prefer-non-pic)
209883e03a40Smrg	pic_mode=no
2099357bfbb2Smrg	continue
2100357bfbb2Smrg	;;
210183e03a40Smrg      esac
210283e03a40Smrg    done
2103357bfbb2Smrg
210483e03a40Smrg    func_quote_for_eval "$libobj"
210583e03a40Smrg    test "X$libobj" != "X$func_quote_for_eval_result" \
210683e03a40Smrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
210783e03a40Smrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
210883e03a40Smrg    func_dirname_and_basename "$obj" "/" ""
210983e03a40Smrg    objname="$func_basename_result"
211083e03a40Smrg    xdir="$func_dirname_result"
211183e03a40Smrg    lobj=${xdir}$objdir/$objname
2112357bfbb2Smrg
211383e03a40Smrg    test -z "$base_compile" && \
211483e03a40Smrg      func_fatal_help "you must specify a compilation command"
21155d713044Smrg
211683e03a40Smrg    # Delete any leftover library objects.
211783e03a40Smrg    if test "$build_old_libs" = yes; then
211883e03a40Smrg      removelist="$obj $lobj $libobj ${libobj}T"
211983e03a40Smrg    else
212083e03a40Smrg      removelist="$lobj $libobj ${libobj}T"
212183e03a40Smrg    fi
2122357bfbb2Smrg
212383e03a40Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
212483e03a40Smrg    case $host_os in
212583e03a40Smrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
212683e03a40Smrg      pic_mode=default
212783e03a40Smrg      ;;
212883e03a40Smrg    esac
212983e03a40Smrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
213083e03a40Smrg      # non-PIC code in shared libraries is not supported
213183e03a40Smrg      pic_mode=default
213283e03a40Smrg    fi
2133357bfbb2Smrg
213483e03a40Smrg    # Calculate the filename of the output object if compiler does
213583e03a40Smrg    # not support -o with -c
213683e03a40Smrg    if test "$compiler_c_o" = no; then
213783e03a40Smrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
213883e03a40Smrg      lockfile="$output_obj.lock"
213983e03a40Smrg    else
214083e03a40Smrg      output_obj=
214183e03a40Smrg      need_locks=no
214283e03a40Smrg      lockfile=
214383e03a40Smrg    fi
2144357bfbb2Smrg
214583e03a40Smrg    # Lock this critical section if it is needed
214683e03a40Smrg    # We use this script file to make the link, it avoids creating a new file
214783e03a40Smrg    if test "$need_locks" = yes; then
214883e03a40Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
214983e03a40Smrg	func_echo "Waiting for $lockfile to be removed"
215083e03a40Smrg	sleep 2
215183e03a40Smrg      done
215283e03a40Smrg    elif test "$need_locks" = warn; then
215383e03a40Smrg      if test -f "$lockfile"; then
215483e03a40Smrg	$ECHO "\
215583e03a40Smrg*** ERROR, $lockfile exists and contains:
215683e03a40Smrg`cat $lockfile 2>/dev/null`
2157357bfbb2Smrg
215883e03a40SmrgThis indicates that another process is trying to use the same
215983e03a40Smrgtemporary object file, and libtool could not work around it because
216083e03a40Smrgyour compiler does not support \`-c' and \`-o' together.  If you
216183e03a40Smrgrepeat this compilation, it may succeed, by chance, but you had better
216283e03a40Smrgavoid parallel builds (make -j) in this platform, or get a better
216383e03a40Smrgcompiler."
2164357bfbb2Smrg
216583e03a40Smrg	$opt_dry_run || $RM $removelist
216683e03a40Smrg	exit $EXIT_FAILURE
216783e03a40Smrg      fi
216883e03a40Smrg      func_append removelist " $output_obj"
216983e03a40Smrg      $ECHO "$srcfile" > "$lockfile"
217083e03a40Smrg    fi
2171357bfbb2Smrg
217283e03a40Smrg    $opt_dry_run || $RM $removelist
217383e03a40Smrg    func_append removelist " $lockfile"
217483e03a40Smrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
2175357bfbb2Smrg
217683e03a40Smrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
217783e03a40Smrg    srcfile=$func_to_tool_file_result
217883e03a40Smrg    func_quote_for_eval "$srcfile"
217983e03a40Smrg    qsrcfile=$func_quote_for_eval_result
2180357bfbb2Smrg
218183e03a40Smrg    # Only build a PIC object if we are building libtool libraries.
218283e03a40Smrg    if test "$build_libtool_libs" = yes; then
218383e03a40Smrg      # Without this assignment, base_compile gets emptied.
218483e03a40Smrg      fbsd_hideous_sh_bug=$base_compile
2185357bfbb2Smrg
218683e03a40Smrg      if test "$pic_mode" != no; then
218783e03a40Smrg	command="$base_compile $qsrcfile $pic_flag"
218883e03a40Smrg      else
218983e03a40Smrg	# Don't build PIC code
219083e03a40Smrg	command="$base_compile $qsrcfile"
219183e03a40Smrg      fi
2192357bfbb2Smrg
219383e03a40Smrg      func_mkdir_p "$xdir$objdir"
2194357bfbb2Smrg
219583e03a40Smrg      if test -z "$output_obj"; then
219683e03a40Smrg	# Place PIC objects in $objdir
219783e03a40Smrg	func_append command " -o $lobj"
219883e03a40Smrg      fi
2199357bfbb2Smrg
220083e03a40Smrg      func_show_eval_locale "$command"	\
220183e03a40Smrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
2202357bfbb2Smrg
220383e03a40Smrg      if test "$need_locks" = warn &&
220483e03a40Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
220583e03a40Smrg	$ECHO "\
220683e03a40Smrg*** ERROR, $lockfile contains:
220783e03a40Smrg`cat $lockfile 2>/dev/null`
2208357bfbb2Smrg
220983e03a40Smrgbut it should contain:
221083e03a40Smrg$srcfile
2211357bfbb2Smrg
221283e03a40SmrgThis indicates that another process is trying to use the same
221383e03a40Smrgtemporary object file, and libtool could not work around it because
221483e03a40Smrgyour compiler does not support \`-c' and \`-o' together.  If you
221583e03a40Smrgrepeat this compilation, it may succeed, by chance, but you had better
221683e03a40Smrgavoid parallel builds (make -j) in this platform, or get a better
221783e03a40Smrgcompiler."
2218357bfbb2Smrg
221983e03a40Smrg	$opt_dry_run || $RM $removelist
222083e03a40Smrg	exit $EXIT_FAILURE
222183e03a40Smrg      fi
2222357bfbb2Smrg
222383e03a40Smrg      # Just move the object if needed, then go on to compile the next one
222483e03a40Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
222583e03a40Smrg	func_show_eval '$MV "$output_obj" "$lobj"' \
222683e03a40Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
222783e03a40Smrg      fi
2228357bfbb2Smrg
222983e03a40Smrg      # Allow error messages only from the first compilation.
223083e03a40Smrg      if test "$suppress_opt" = yes; then
223183e03a40Smrg	suppress_output=' >/dev/null 2>&1'
223283e03a40Smrg      fi
223383e03a40Smrg    fi
2234357bfbb2Smrg
223583e03a40Smrg    # Only build a position-dependent object if we build old libraries.
223683e03a40Smrg    if test "$build_old_libs" = yes; then
223783e03a40Smrg      if test "$pic_mode" != yes; then
223883e03a40Smrg	# Don't build PIC code
223983e03a40Smrg	command="$base_compile $qsrcfile$pie_flag"
224083e03a40Smrg      else
224183e03a40Smrg	command="$base_compile $qsrcfile $pic_flag"
224283e03a40Smrg      fi
224383e03a40Smrg      if test "$compiler_c_o" = yes; then
224483e03a40Smrg	func_append command " -o $obj"
224583e03a40Smrg      fi
2246357bfbb2Smrg
224783e03a40Smrg      # Suppress compiler output if we already did a PIC compilation.
224883e03a40Smrg      func_append command "$suppress_output"
224983e03a40Smrg      func_show_eval_locale "$command" \
225083e03a40Smrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
2251357bfbb2Smrg
225283e03a40Smrg      if test "$need_locks" = warn &&
225383e03a40Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
225483e03a40Smrg	$ECHO "\
225583e03a40Smrg*** ERROR, $lockfile contains:
225683e03a40Smrg`cat $lockfile 2>/dev/null`
2257357bfbb2Smrg
225883e03a40Smrgbut it should contain:
225983e03a40Smrg$srcfile
2260357bfbb2Smrg
226183e03a40SmrgThis indicates that another process is trying to use the same
226283e03a40Smrgtemporary object file, and libtool could not work around it because
226383e03a40Smrgyour compiler does not support \`-c' and \`-o' together.  If you
226483e03a40Smrgrepeat this compilation, it may succeed, by chance, but you had better
226583e03a40Smrgavoid parallel builds (make -j) in this platform, or get a better
226683e03a40Smrgcompiler."
2267357bfbb2Smrg
226883e03a40Smrg	$opt_dry_run || $RM $removelist
226983e03a40Smrg	exit $EXIT_FAILURE
227083e03a40Smrg      fi
2271357bfbb2Smrg
227283e03a40Smrg      # Just move the object if needed
227383e03a40Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
227483e03a40Smrg	func_show_eval '$MV "$output_obj" "$obj"' \
227583e03a40Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
227683e03a40Smrg      fi
227783e03a40Smrg    fi
2278357bfbb2Smrg
227983e03a40Smrg    $opt_dry_run || {
228083e03a40Smrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
2281357bfbb2Smrg
228283e03a40Smrg      # Unlock the critical section if it was locked
228383e03a40Smrg      if test "$need_locks" != no; then
228483e03a40Smrg	removelist=$lockfile
228583e03a40Smrg        $RM "$lockfile"
228683e03a40Smrg      fi
228783e03a40Smrg    }
2288357bfbb2Smrg
228983e03a40Smrg    exit $EXIT_SUCCESS
229083e03a40Smrg}
2291357bfbb2Smrg
229283e03a40Smrg$opt_help || {
229383e03a40Smrg  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
229483e03a40Smrg}
2295357bfbb2Smrg
229683e03a40Smrgfunc_mode_help ()
229783e03a40Smrg{
229883e03a40Smrg    # We need to display help for each of the modes.
229983e03a40Smrg    case $opt_mode in
230083e03a40Smrg      "")
230183e03a40Smrg        # Generic help is extracted from the usage comments
230283e03a40Smrg        # at the start of this file.
230383e03a40Smrg        func_help
230483e03a40Smrg        ;;
2305357bfbb2Smrg
230683e03a40Smrg      clean)
230783e03a40Smrg        $ECHO \
230883e03a40Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
2309357bfbb2Smrg
231083e03a40SmrgRemove files from the build directory.
2311357bfbb2Smrg
231283e03a40SmrgRM is the name of the program to use to delete files associated with each FILE
231383e03a40Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
231483e03a40Smrgto RM.
2315357bfbb2Smrg
231683e03a40SmrgIf FILE is a libtool library, object or program, all the files associated
231783e03a40Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
231883e03a40Smrg        ;;
2319357bfbb2Smrg
232083e03a40Smrg      compile)
232183e03a40Smrg      $ECHO \
232283e03a40Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
2323357bfbb2Smrg
232483e03a40SmrgCompile a source file into a libtool library object.
2325357bfbb2Smrg
232683e03a40SmrgThis mode accepts the following additional options:
2327357bfbb2Smrg
232883e03a40Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
232983e03a40Smrg  -no-suppress      do not suppress compiler output for multiple passes
233083e03a40Smrg  -prefer-pic       try to build PIC objects only
233183e03a40Smrg  -prefer-non-pic   try to build non-PIC objects only
233283e03a40Smrg  -shared           do not build a \`.o' file suitable for static linking
233383e03a40Smrg  -static           only build a \`.o' file suitable for static linking
233483e03a40Smrg  -Wc,FLAG          pass FLAG directly to the compiler
2335357bfbb2Smrg
233683e03a40SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
233783e03a40Smrgfrom the given SOURCEFILE.
2338357bfbb2Smrg
233983e03a40SmrgThe output file name is determined by removing the directory component from
234083e03a40SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
234183e03a40Smrglibrary object suffix, \`.lo'."
234283e03a40Smrg        ;;
2343357bfbb2Smrg
234483e03a40Smrg      execute)
234583e03a40Smrg        $ECHO \
234683e03a40Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
2347357bfbb2Smrg
234883e03a40SmrgAutomatically set library path, then run a program.
2349357bfbb2Smrg
235083e03a40SmrgThis mode accepts the following additional options:
2351357bfbb2Smrg
235283e03a40Smrg  -dlopen FILE      add the directory containing FILE to the library path
2353357bfbb2Smrg
235483e03a40SmrgThis mode sets the library path environment variable according to \`-dlopen'
235583e03a40Smrgflags.
2356357bfbb2Smrg
235783e03a40SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
235883e03a40Smrginto their corresponding uninstalled binary, and any of their required library
235983e03a40Smrgdirectories are added to the library path.
2360357bfbb2Smrg
236183e03a40SmrgThen, COMMAND is executed, with ARGS as arguments."
236283e03a40Smrg        ;;
2363357bfbb2Smrg
236483e03a40Smrg      finish)
236583e03a40Smrg        $ECHO \
236683e03a40Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
2367357bfbb2Smrg
236883e03a40SmrgComplete the installation of libtool libraries.
236983e03a40Smrg
237083e03a40SmrgEach LIBDIR is a directory that contains libtool libraries.
237183e03a40Smrg
237283e03a40SmrgThe commands that this mode executes may require superuser privileges.  Use
237383e03a40Smrgthe \`--dry-run' option if you just want to see what would be executed."
237483e03a40Smrg        ;;
237583e03a40Smrg
237683e03a40Smrg      install)
237783e03a40Smrg        $ECHO \
237883e03a40Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
237983e03a40Smrg
238083e03a40SmrgInstall executables or libraries.
238183e03a40Smrg
238283e03a40SmrgINSTALL-COMMAND is the installation command.  The first component should be
238383e03a40Smrgeither the \`install' or \`cp' program.
238483e03a40Smrg
238583e03a40SmrgThe following components of INSTALL-COMMAND are treated specially:
238683e03a40Smrg
238783e03a40Smrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
238883e03a40Smrg
238983e03a40SmrgThe rest of the components are interpreted as arguments to that command (only
239083e03a40SmrgBSD-compatible install options are recognized)."
239183e03a40Smrg        ;;
239283e03a40Smrg
239383e03a40Smrg      link)
239483e03a40Smrg        $ECHO \
239583e03a40Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
239683e03a40Smrg
239783e03a40SmrgLink object files or libraries together to form another library, or to
239883e03a40Smrgcreate an executable program.
239983e03a40Smrg
240083e03a40SmrgLINK-COMMAND is a command using the C compiler that you would use to create
240183e03a40Smrga program from several object files.
240283e03a40Smrg
240383e03a40SmrgThe following components of LINK-COMMAND are treated specially:
240483e03a40Smrg
240583e03a40Smrg  -all-static       do not do any dynamic linking at all
240683e03a40Smrg  -avoid-version    do not add a version suffix if possible
240783e03a40Smrg  -bindir BINDIR    specify path to binaries directory (for systems where
240883e03a40Smrg                    libraries must be found in the PATH setting at runtime)
240983e03a40Smrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
241083e03a40Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
241183e03a40Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
241283e03a40Smrg  -export-symbols SYMFILE
241383e03a40Smrg                    try to export only the symbols listed in SYMFILE
241483e03a40Smrg  -export-symbols-regex REGEX
241583e03a40Smrg                    try to export only the symbols matching REGEX
241683e03a40Smrg  -LLIBDIR          search LIBDIR for required installed libraries
241783e03a40Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
241883e03a40Smrg  -module           build a library that can dlopened
241983e03a40Smrg  -no-fast-install  disable the fast-install mode
242083e03a40Smrg  -no-install       link a not-installable executable
242183e03a40Smrg  -no-undefined     declare that a library does not refer to external symbols
242283e03a40Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
242383e03a40Smrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
242483e03a40Smrg  -precious-files-regex REGEX
242583e03a40Smrg                    don't remove output files matching REGEX
242683e03a40Smrg  -release RELEASE  specify package release information
242783e03a40Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
242883e03a40Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
242983e03a40Smrg  -shared           only do dynamic linking of libtool libraries
243083e03a40Smrg  -shrext SUFFIX    override the standard shared library file extension
243183e03a40Smrg  -static           do not do any dynamic linking of uninstalled libtool libraries
243283e03a40Smrg  -static-libtool-libs
243383e03a40Smrg                    do not do any dynamic linking of libtool libraries
243483e03a40Smrg  -version-info CURRENT[:REVISION[:AGE]]
243583e03a40Smrg                    specify library version info [each variable defaults to 0]
243683e03a40Smrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
243783e03a40Smrg  -Wc,FLAG
243883e03a40Smrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
243983e03a40Smrg  -Wl,FLAG
244083e03a40Smrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
244183e03a40Smrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
244283e03a40Smrg
244383e03a40SmrgAll other options (arguments beginning with \`-') are ignored.
244483e03a40Smrg
244583e03a40SmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
244683e03a40Smrgtreated as uninstalled libtool libraries, other files are standard or library
244783e03a40Smrgobject files.
244883e03a40Smrg
244983e03a40SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
245083e03a40Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
245183e03a40Smrgrequired, except when creating a convenience library.
245283e03a40Smrg
245383e03a40SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
245483e03a40Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
245583e03a40Smrg
245683e03a40SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
245783e03a40Smrgis created, otherwise an executable program is created."
245883e03a40Smrg        ;;
245983e03a40Smrg
246083e03a40Smrg      uninstall)
246183e03a40Smrg        $ECHO \
246283e03a40Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
246383e03a40Smrg
246483e03a40SmrgRemove libraries from an installation directory.
246583e03a40Smrg
246683e03a40SmrgRM is the name of the program to use to delete files associated with each FILE
246783e03a40Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
246883e03a40Smrgto RM.
246983e03a40Smrg
247083e03a40SmrgIf FILE is a libtool library, all the files associated with it are deleted.
247183e03a40SmrgOtherwise, only FILE itself is deleted using RM."
247283e03a40Smrg        ;;
247383e03a40Smrg
247483e03a40Smrg      *)
247583e03a40Smrg        func_fatal_help "invalid operation mode \`$opt_mode'"
247683e03a40Smrg        ;;
2477357bfbb2Smrg    esac
2478357bfbb2Smrg
247983e03a40Smrg    echo
248083e03a40Smrg    $ECHO "Try \`$progname --help' for more information about other modes."
248183e03a40Smrg}
2482357bfbb2Smrg
248383e03a40Smrg# Now that we've collected a possible --mode arg, show help if necessary
248483e03a40Smrgif $opt_help; then
248583e03a40Smrg  if test "$opt_help" = :; then
248683e03a40Smrg    func_mode_help
248783e03a40Smrg  else
248883e03a40Smrg    {
248983e03a40Smrg      func_help noexit
249083e03a40Smrg      for opt_mode in compile link execute install finish uninstall clean; do
249183e03a40Smrg	func_mode_help
249283e03a40Smrg      done
249383e03a40Smrg    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
249483e03a40Smrg    {
249583e03a40Smrg      func_help noexit
249683e03a40Smrg      for opt_mode in compile link execute install finish uninstall clean; do
249783e03a40Smrg	echo
249883e03a40Smrg	func_mode_help
249983e03a40Smrg      done
250083e03a40Smrg    } |
250183e03a40Smrg    sed '1d
250283e03a40Smrg      /^When reporting/,/^Report/{
250383e03a40Smrg	H
250483e03a40Smrg	d
250583e03a40Smrg      }
250683e03a40Smrg      $x
250783e03a40Smrg      /information about other modes/d
250883e03a40Smrg      /more detailed .*MODE/d
250983e03a40Smrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
251083e03a40Smrg  fi
251183e03a40Smrg  exit $?
251283e03a40Smrgfi
2513357bfbb2Smrg
2514357bfbb2Smrg
251583e03a40Smrg# func_mode_execute arg...
251683e03a40Smrgfunc_mode_execute ()
251783e03a40Smrg{
251883e03a40Smrg    $opt_debug
251983e03a40Smrg    # The first argument is the command name.
252083e03a40Smrg    cmd="$nonopt"
252183e03a40Smrg    test -z "$cmd" && \
252283e03a40Smrg      func_fatal_help "you must specify a COMMAND"
252383e03a40Smrg
252483e03a40Smrg    # Handle -dlopen flags immediately.
252583e03a40Smrg    for file in $opt_dlopen; do
252683e03a40Smrg      test -f "$file" \
252783e03a40Smrg	|| func_fatal_help "\`$file' is not a file"
252883e03a40Smrg
252983e03a40Smrg      dir=
253083e03a40Smrg      case $file in
253183e03a40Smrg      *.la)
253283e03a40Smrg	func_resolve_sysroot "$file"
253383e03a40Smrg	file=$func_resolve_sysroot_result
253483e03a40Smrg
253583e03a40Smrg	# Check to see that this really is a libtool archive.
253683e03a40Smrg	func_lalib_unsafe_p "$file" \
253783e03a40Smrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
253883e03a40Smrg
253983e03a40Smrg	# Read the libtool library.
254083e03a40Smrg	dlname=
254183e03a40Smrg	library_names=
254283e03a40Smrg	func_source "$file"
254383e03a40Smrg
254483e03a40Smrg	# Skip this library if it cannot be dlopened.
254583e03a40Smrg	if test -z "$dlname"; then
254683e03a40Smrg	  # Warn if it was a shared library.
254783e03a40Smrg	  test -n "$library_names" && \
254883e03a40Smrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
254983e03a40Smrg	  continue
255083e03a40Smrg	fi
255183e03a40Smrg
255283e03a40Smrg	func_dirname "$file" "" "."
255383e03a40Smrg	dir="$func_dirname_result"
255483e03a40Smrg
255583e03a40Smrg	if test -f "$dir/$objdir/$dlname"; then
255683e03a40Smrg	  func_append dir "/$objdir"
255783e03a40Smrg	else
255883e03a40Smrg	  if test ! -f "$dir/$dlname"; then
255983e03a40Smrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
256083e03a40Smrg	  fi
256183e03a40Smrg	fi
2562357bfbb2Smrg	;;
256383e03a40Smrg
256483e03a40Smrg      *.lo)
256583e03a40Smrg	# Just add the directory containing the .lo file.
256683e03a40Smrg	func_dirname "$file" "" "."
256783e03a40Smrg	dir="$func_dirname_result"
2568357bfbb2Smrg	;;
256983e03a40Smrg
257083e03a40Smrg      *)
257183e03a40Smrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
257283e03a40Smrg	continue
2573357bfbb2Smrg	;;
257483e03a40Smrg      esac
257583e03a40Smrg
257683e03a40Smrg      # Get the absolute pathname.
257783e03a40Smrg      absdir=`cd "$dir" && pwd`
257883e03a40Smrg      test -n "$absdir" && dir="$absdir"
257983e03a40Smrg
258083e03a40Smrg      # Now add the directory to shlibpath_var.
258183e03a40Smrg      if eval "test -z \"\$$shlibpath_var\""; then
258283e03a40Smrg	eval "$shlibpath_var=\"\$dir\""
258383e03a40Smrg      else
258483e03a40Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
2585357bfbb2Smrg      fi
258683e03a40Smrg    done
258783e03a40Smrg
258883e03a40Smrg    # This variable tells wrapper scripts just to set shlibpath_var
258983e03a40Smrg    # rather than running their programs.
259083e03a40Smrg    libtool_execute_magic="$magic"
259183e03a40Smrg
259283e03a40Smrg    # Check if any of the arguments is a wrapper script.
259383e03a40Smrg    args=
259483e03a40Smrg    for file
259583e03a40Smrg    do
259683e03a40Smrg      case $file in
259783e03a40Smrg      -* | *.la | *.lo ) ;;
259883e03a40Smrg      *)
259983e03a40Smrg	# Do a test to see if this is really a libtool program.
260083e03a40Smrg	if func_ltwrapper_script_p "$file"; then
260183e03a40Smrg	  func_source "$file"
260283e03a40Smrg	  # Transform arg to wrapped name.
260383e03a40Smrg	  file="$progdir/$program"
260483e03a40Smrg	elif func_ltwrapper_executable_p "$file"; then
260583e03a40Smrg	  func_ltwrapper_scriptname "$file"
260683e03a40Smrg	  func_source "$func_ltwrapper_scriptname_result"
260783e03a40Smrg	  # Transform arg to wrapped name.
260883e03a40Smrg	  file="$progdir/$program"
260983e03a40Smrg	fi
261083e03a40Smrg	;;
261183e03a40Smrg      esac
261283e03a40Smrg      # Quote arguments (to preserve shell metacharacters).
261383e03a40Smrg      func_append_quoted args "$file"
261483e03a40Smrg    done
261583e03a40Smrg
261683e03a40Smrg    if test "X$opt_dry_run" = Xfalse; then
261783e03a40Smrg      if test -n "$shlibpath_var"; then
261883e03a40Smrg	# Export the shlibpath_var.
261983e03a40Smrg	eval "export $shlibpath_var"
2620357bfbb2Smrg      fi
262183e03a40Smrg
262283e03a40Smrg      # Restore saved environment variables
262383e03a40Smrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
262483e03a40Smrg      do
262583e03a40Smrg	eval "if test \"\${save_$lt_var+set}\" = set; then
262683e03a40Smrg                $lt_var=\$save_$lt_var; export $lt_var
262783e03a40Smrg	      else
262883e03a40Smrg		$lt_unset $lt_var
262983e03a40Smrg	      fi"
263083e03a40Smrg      done
263183e03a40Smrg
263283e03a40Smrg      # Now prepare to actually exec the command.
263383e03a40Smrg      exec_cmd="\$cmd$args"
263483e03a40Smrg    else
263583e03a40Smrg      # Display what would be done.
263683e03a40Smrg      if test -n "$shlibpath_var"; then
263783e03a40Smrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
263883e03a40Smrg	echo "export $shlibpath_var"
2639357bfbb2Smrg      fi
264083e03a40Smrg      $ECHO "$cmd$args"
264183e03a40Smrg      exit $EXIT_SUCCESS
264283e03a40Smrg    fi
264383e03a40Smrg}
2644357bfbb2Smrg
264583e03a40Smrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"}
2646357bfbb2Smrg
2647357bfbb2Smrg
264883e03a40Smrg# func_mode_finish arg...
264983e03a40Smrgfunc_mode_finish ()
265083e03a40Smrg{
265183e03a40Smrg    $opt_debug
265283e03a40Smrg    libs=
265383e03a40Smrg    libdirs=
265483e03a40Smrg    admincmds=
2655357bfbb2Smrg
265683e03a40Smrg    for opt in "$nonopt" ${1+"$@"}
265783e03a40Smrg    do
265883e03a40Smrg      if test -d "$opt"; then
265983e03a40Smrg	func_append libdirs " $opt"
2660357bfbb2Smrg
266183e03a40Smrg      elif test -f "$opt"; then
266283e03a40Smrg	if func_lalib_unsafe_p "$opt"; then
266383e03a40Smrg	  func_append libs " $opt"
266483e03a40Smrg	else
266583e03a40Smrg	  func_warning "\`$opt' is not a valid libtool archive"
2666357bfbb2Smrg	fi
2667357bfbb2Smrg
266883e03a40Smrg      else
266983e03a40Smrg	func_fatal_error "invalid argument \`$opt'"
267083e03a40Smrg      fi
267183e03a40Smrg    done
2672357bfbb2Smrg
267383e03a40Smrg    if test -n "$libs"; then
267483e03a40Smrg      if test -n "$lt_sysroot"; then
267583e03a40Smrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
267683e03a40Smrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
267783e03a40Smrg      else
267883e03a40Smrg        sysroot_cmd=
267983e03a40Smrg      fi
2680357bfbb2Smrg
268183e03a40Smrg      # Remove sysroot references
268283e03a40Smrg      if $opt_dry_run; then
268383e03a40Smrg        for lib in $libs; do
268483e03a40Smrg          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
268583e03a40Smrg        done
268683e03a40Smrg      else
268783e03a40Smrg        tmpdir=`func_mktempdir`
268883e03a40Smrg        for lib in $libs; do
268983e03a40Smrg	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
269083e03a40Smrg	    > $tmpdir/tmp-la
269183e03a40Smrg	  mv -f $tmpdir/tmp-la $lib
2692357bfbb2Smrg	done
269383e03a40Smrg        ${RM}r "$tmpdir"
269483e03a40Smrg      fi
269583e03a40Smrg    fi
269683e03a40Smrg
269783e03a40Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
269883e03a40Smrg      for libdir in $libdirs; do
269983e03a40Smrg	if test -n "$finish_cmds"; then
270083e03a40Smrg	  # Do each command in the finish commands.
270183e03a40Smrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
270283e03a40Smrg'"$cmd"'"'
270383e03a40Smrg	fi
270483e03a40Smrg	if test -n "$finish_eval"; then
270583e03a40Smrg	  # Do the single finish_eval.
270683e03a40Smrg	  eval cmds=\"$finish_eval\"
270783e03a40Smrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
270883e03a40Smrg       $cmds"
2709357bfbb2Smrg	fi
271083e03a40Smrg      done
271183e03a40Smrg    fi
2712357bfbb2Smrg
271383e03a40Smrg    # Exit here if they wanted silent mode.
271483e03a40Smrg    $opt_silent && exit $EXIT_SUCCESS
2715357bfbb2Smrg
271683e03a40Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
271783e03a40Smrg      echo "----------------------------------------------------------------------"
271883e03a40Smrg      echo "Libraries have been installed in:"
271983e03a40Smrg      for libdir in $libdirs; do
272083e03a40Smrg	$ECHO "   $libdir"
272183e03a40Smrg      done
272283e03a40Smrg      echo
272383e03a40Smrg      echo "If you ever happen to want to link against installed libraries"
272483e03a40Smrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
272583e03a40Smrg      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
272683e03a40Smrg      echo "flag during linking and do at least one of the following:"
272783e03a40Smrg      if test -n "$shlibpath_var"; then
272883e03a40Smrg	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
272983e03a40Smrg	echo "     during execution"
273083e03a40Smrg      fi
273183e03a40Smrg      if test -n "$runpath_var"; then
273283e03a40Smrg	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
273383e03a40Smrg	echo "     during linking"
273483e03a40Smrg      fi
273583e03a40Smrg      if test -n "$hardcode_libdir_flag_spec"; then
273683e03a40Smrg	libdir=LIBDIR
273783e03a40Smrg	eval flag=\"$hardcode_libdir_flag_spec\"
273883e03a40Smrg
273983e03a40Smrg	$ECHO "   - use the \`$flag' linker flag"
274083e03a40Smrg      fi
274183e03a40Smrg      if test -n "$admincmds"; then
274283e03a40Smrg	$ECHO "   - have your system administrator run these commands:$admincmds"
274383e03a40Smrg      fi
274483e03a40Smrg      if test -f /etc/ld.so.conf; then
274583e03a40Smrg	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
274683e03a40Smrg      fi
274783e03a40Smrg      echo
274883e03a40Smrg
274983e03a40Smrg      echo "See any operating system documentation about shared libraries for"
275083e03a40Smrg      case $host in
275183e03a40Smrg	solaris2.[6789]|solaris2.1[0-9])
275283e03a40Smrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
275383e03a40Smrg	  echo "pages."
275483e03a40Smrg	  ;;
2755357bfbb2Smrg	*)
275683e03a40Smrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
2757357bfbb2Smrg	  ;;
275883e03a40Smrg      esac
275983e03a40Smrg      echo "----------------------------------------------------------------------"
276083e03a40Smrg    fi
276183e03a40Smrg    exit $EXIT_SUCCESS
276283e03a40Smrg}
2763357bfbb2Smrg
276483e03a40Smrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"}
2765357bfbb2Smrg
2766357bfbb2Smrg
276783e03a40Smrg# func_mode_install arg...
276883e03a40Smrgfunc_mode_install ()
276983e03a40Smrg{
277083e03a40Smrg    $opt_debug
277183e03a40Smrg    # There may be an optional sh(1) argument at the beginning of
277283e03a40Smrg    # install_prog (especially on Windows NT).
277383e03a40Smrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
277483e03a40Smrg       # Allow the use of GNU shtool's install command.
277583e03a40Smrg       case $nonopt in *shtool*) :;; *) false;; esac; then
277683e03a40Smrg      # Aesthetically quote it.
277783e03a40Smrg      func_quote_for_eval "$nonopt"
277883e03a40Smrg      install_prog="$func_quote_for_eval_result "
277983e03a40Smrg      arg=$1
278083e03a40Smrg      shift
278183e03a40Smrg    else
278283e03a40Smrg      install_prog=
278383e03a40Smrg      arg=$nonopt
278483e03a40Smrg    fi
278583e03a40Smrg
278683e03a40Smrg    # The real first argument should be the name of the installation program.
278783e03a40Smrg    # Aesthetically quote it.
278883e03a40Smrg    func_quote_for_eval "$arg"
278983e03a40Smrg    func_append install_prog "$func_quote_for_eval_result"
279083e03a40Smrg    install_shared_prog=$install_prog
279183e03a40Smrg    case " $install_prog " in
279283e03a40Smrg      *[\\\ /]cp\ *) install_cp=: ;;
279383e03a40Smrg      *) install_cp=false ;;
279483e03a40Smrg    esac
279583e03a40Smrg
279683e03a40Smrg    # We need to accept at least all the BSD install flags.
279783e03a40Smrg    dest=
279883e03a40Smrg    files=
279983e03a40Smrg    opts=
280083e03a40Smrg    prev=
280183e03a40Smrg    install_type=
280283e03a40Smrg    isdir=no
280383e03a40Smrg    stripme=
280483e03a40Smrg    no_mode=:
280583e03a40Smrg    for arg
280683e03a40Smrg    do
280783e03a40Smrg      arg2=
280883e03a40Smrg      if test -n "$dest"; then
280983e03a40Smrg	func_append files " $dest"
281083e03a40Smrg	dest=$arg
281183e03a40Smrg	continue
281283e03a40Smrg      fi
281383e03a40Smrg
281483e03a40Smrg      case $arg in
281583e03a40Smrg      -d) isdir=yes ;;
281683e03a40Smrg      -f)
281783e03a40Smrg	if $install_cp; then :; else
281883e03a40Smrg	  prev=$arg
281983e03a40Smrg	fi
282083e03a40Smrg	;;
282183e03a40Smrg      -g | -m | -o)
282283e03a40Smrg	prev=$arg
282383e03a40Smrg	;;
282483e03a40Smrg      -s)
282583e03a40Smrg	stripme=" -s"
282683e03a40Smrg	continue
282783e03a40Smrg	;;
282883e03a40Smrg      -*)
282983e03a40Smrg	;;
283083e03a40Smrg      *)
283183e03a40Smrg	# If the previous option needed an argument, then skip it.
283283e03a40Smrg	if test -n "$prev"; then
283383e03a40Smrg	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
283483e03a40Smrg	    arg2=$install_override_mode
283583e03a40Smrg	    no_mode=false
2836357bfbb2Smrg	  fi
283783e03a40Smrg	  prev=
283883e03a40Smrg	else
283983e03a40Smrg	  dest=$arg
2840357bfbb2Smrg	  continue
2841357bfbb2Smrg	fi
284283e03a40Smrg	;;
284383e03a40Smrg      esac
2844357bfbb2Smrg
284583e03a40Smrg      # Aesthetically quote the argument.
284683e03a40Smrg      func_quote_for_eval "$arg"
284783e03a40Smrg      func_append install_prog " $func_quote_for_eval_result"
284883e03a40Smrg      if test -n "$arg2"; then
284983e03a40Smrg	func_quote_for_eval "$arg2"
285083e03a40Smrg      fi
285183e03a40Smrg      func_append install_shared_prog " $func_quote_for_eval_result"
285283e03a40Smrg    done
2853357bfbb2Smrg
285483e03a40Smrg    test -z "$install_prog" && \
285583e03a40Smrg      func_fatal_help "you must specify an install program"
2856357bfbb2Smrg
285783e03a40Smrg    test -n "$prev" && \
285883e03a40Smrg      func_fatal_help "the \`$prev' option requires an argument"
2859357bfbb2Smrg
286083e03a40Smrg    if test -n "$install_override_mode" && $no_mode; then
286183e03a40Smrg      if $install_cp; then :; else
286283e03a40Smrg	func_quote_for_eval "$install_override_mode"
286383e03a40Smrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
286483e03a40Smrg      fi
286583e03a40Smrg    fi
2866357bfbb2Smrg
286783e03a40Smrg    if test -z "$files"; then
286883e03a40Smrg      if test -z "$dest"; then
286983e03a40Smrg	func_fatal_help "no file or destination specified"
287083e03a40Smrg      else
287183e03a40Smrg	func_fatal_help "you must specify a destination"
287283e03a40Smrg      fi
287383e03a40Smrg    fi
2874357bfbb2Smrg
287583e03a40Smrg    # Strip any trailing slash from the destination.
287683e03a40Smrg    func_stripname '' '/' "$dest"
287783e03a40Smrg    dest=$func_stripname_result
2878357bfbb2Smrg
287983e03a40Smrg    # Check to see that the destination is a directory.
288083e03a40Smrg    test -d "$dest" && isdir=yes
288183e03a40Smrg    if test "$isdir" = yes; then
288283e03a40Smrg      destdir="$dest"
288383e03a40Smrg      destname=
288483e03a40Smrg    else
288583e03a40Smrg      func_dirname_and_basename "$dest" "" "."
288683e03a40Smrg      destdir="$func_dirname_result"
288783e03a40Smrg      destname="$func_basename_result"
2888357bfbb2Smrg
288983e03a40Smrg      # Not a directory, so check to see that there is only one file specified.
289083e03a40Smrg      set dummy $files; shift
289183e03a40Smrg      test "$#" -gt 1 && \
289283e03a40Smrg	func_fatal_help "\`$dest' is not a directory"
289383e03a40Smrg    fi
289483e03a40Smrg    case $destdir in
289583e03a40Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
289683e03a40Smrg    *)
289783e03a40Smrg      for file in $files; do
289883e03a40Smrg	case $file in
289983e03a40Smrg	*.lo) ;;
290083e03a40Smrg	*)
290183e03a40Smrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
290283e03a40Smrg	  ;;
290383e03a40Smrg	esac
290483e03a40Smrg      done
290583e03a40Smrg      ;;
290683e03a40Smrg    esac
2907357bfbb2Smrg
290883e03a40Smrg    # This variable tells wrapper scripts just to set variables rather
290983e03a40Smrg    # than running their programs.
291083e03a40Smrg    libtool_install_magic="$magic"
2911357bfbb2Smrg
291283e03a40Smrg    staticlibs=
291383e03a40Smrg    future_libdirs=
291483e03a40Smrg    current_libdirs=
291583e03a40Smrg    for file in $files; do
2916357bfbb2Smrg
291783e03a40Smrg      # Do each installation.
291883e03a40Smrg      case $file in
291983e03a40Smrg      *.$libext)
292083e03a40Smrg	# Do the static libraries later.
292183e03a40Smrg	func_append staticlibs " $file"
292283e03a40Smrg	;;
2923357bfbb2Smrg
292483e03a40Smrg      *.la)
292583e03a40Smrg	func_resolve_sysroot "$file"
292683e03a40Smrg	file=$func_resolve_sysroot_result
2927357bfbb2Smrg
292883e03a40Smrg	# Check to see that this really is a libtool archive.
292983e03a40Smrg	func_lalib_unsafe_p "$file" \
293083e03a40Smrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
2931357bfbb2Smrg
293283e03a40Smrg	library_names=
293383e03a40Smrg	old_library=
293483e03a40Smrg	relink_command=
293583e03a40Smrg	func_source "$file"
2936357bfbb2Smrg
293783e03a40Smrg	# Add the libdir to current_libdirs if it is the destination.
293883e03a40Smrg	if test "X$destdir" = "X$libdir"; then
293983e03a40Smrg	  case "$current_libdirs " in
294083e03a40Smrg	  *" $libdir "*) ;;
294183e03a40Smrg	  *) func_append current_libdirs " $libdir" ;;
294283e03a40Smrg	  esac
294383e03a40Smrg	else
294483e03a40Smrg	  # Note the libdir as a future libdir.
294583e03a40Smrg	  case "$future_libdirs " in
294683e03a40Smrg	  *" $libdir "*) ;;
294783e03a40Smrg	  *) func_append future_libdirs " $libdir" ;;
294883e03a40Smrg	  esac
294983e03a40Smrg	fi
2950357bfbb2Smrg
295183e03a40Smrg	func_dirname "$file" "/" ""
295283e03a40Smrg	dir="$func_dirname_result"
295383e03a40Smrg	func_append dir "$objdir"
2954357bfbb2Smrg
295583e03a40Smrg	if test -n "$relink_command"; then
295683e03a40Smrg	  # Determine the prefix the user has applied to our future dir.
295783e03a40Smrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
2958357bfbb2Smrg
295983e03a40Smrg	  # Don't allow the user to place us outside of our expected
296083e03a40Smrg	  # location b/c this prevents finding dependent libraries that
296183e03a40Smrg	  # are installed to the same prefix.
296283e03a40Smrg	  # At present, this check doesn't affect windows .dll's that
296383e03a40Smrg	  # are installed into $libdir/../bin (currently, that works fine)
296483e03a40Smrg	  # but it's something to keep an eye on.
296583e03a40Smrg	  test "$inst_prefix_dir" = "$destdir" && \
296683e03a40Smrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
296783e03a40Smrg
296883e03a40Smrg	  if test -n "$inst_prefix_dir"; then
296983e03a40Smrg	    # Stick the inst_prefix_dir data into the link command.
297083e03a40Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2971357bfbb2Smrg	  else
297283e03a40Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
2973357bfbb2Smrg	  fi
2974357bfbb2Smrg
297583e03a40Smrg	  func_warning "relinking \`$file'"
297683e03a40Smrg	  func_show_eval "$relink_command" \
297783e03a40Smrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
297883e03a40Smrg	fi
297983e03a40Smrg
298083e03a40Smrg	# See the names of the shared library.
298183e03a40Smrg	set dummy $library_names; shift
298283e03a40Smrg	if test -n "$1"; then
298383e03a40Smrg	  realname="$1"
298483e03a40Smrg	  shift
298583e03a40Smrg
298683e03a40Smrg	  srcname="$realname"
298783e03a40Smrg	  test -n "$relink_command" && srcname="$realname"T
298883e03a40Smrg
298983e03a40Smrg	  # Install the shared library and build the symlinks.
299083e03a40Smrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
299183e03a40Smrg	      'exit $?'
299283e03a40Smrg	  tstripme="$stripme"
299383e03a40Smrg	  case $host_os in
299483e03a40Smrg	  cygwin* | mingw* | pw32* | cegcc*)
299583e03a40Smrg	    case $realname in
299683e03a40Smrg	    *.dll.a)
299783e03a40Smrg	      tstripme=""
299883e03a40Smrg	      ;;
299983e03a40Smrg	    esac
300083e03a40Smrg	    ;;
300183e03a40Smrg	  esac
300283e03a40Smrg	  if test -n "$tstripme" && test -n "$striplib"; then
300383e03a40Smrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
3004357bfbb2Smrg	  fi
3005357bfbb2Smrg
300683e03a40Smrg	  if test "$#" -gt 0; then
300783e03a40Smrg	    # Delete the old symlinks, and create new ones.
300883e03a40Smrg	    # Try `ln -sf' first, because the `ln' binary might depend on
300983e03a40Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
301083e03a40Smrg	    # so we also need to try rm && ln -s.
301183e03a40Smrg	    for linkname
301283e03a40Smrg	    do
301383e03a40Smrg	      test "$linkname" != "$realname" \
301483e03a40Smrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
3015357bfbb2Smrg	    done
3016357bfbb2Smrg	  fi
3017357bfbb2Smrg
301883e03a40Smrg	  # Do each command in the postinstall commands.
301983e03a40Smrg	  lib="$destdir/$realname"
302083e03a40Smrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
302183e03a40Smrg	fi
3022357bfbb2Smrg
302383e03a40Smrg	# Install the pseudo-library for information purposes.
302483e03a40Smrg	func_basename "$file"
302583e03a40Smrg	name="$func_basename_result"
302683e03a40Smrg	instname="$dir/$name"i
302783e03a40Smrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
3028357bfbb2Smrg
302983e03a40Smrg	# Maybe install the static library, too.
303083e03a40Smrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
303183e03a40Smrg	;;
303283e03a40Smrg
303383e03a40Smrg      *.lo)
303483e03a40Smrg	# Install (i.e. copy) a libtool object.
303583e03a40Smrg
303683e03a40Smrg	# Figure out destination file name, if it wasn't already specified.
303783e03a40Smrg	if test -n "$destname"; then
303883e03a40Smrg	  destfile="$destdir/$destname"
3039357bfbb2Smrg	else
304083e03a40Smrg	  func_basename "$file"
304183e03a40Smrg	  destfile="$func_basename_result"
304283e03a40Smrg	  destfile="$destdir/$destfile"
3043357bfbb2Smrg	fi
304483e03a40Smrg
304583e03a40Smrg	# Deduce the name of the destination old-style object file.
304683e03a40Smrg	case $destfile in
304783e03a40Smrg	*.lo)
304883e03a40Smrg	  func_lo2o "$destfile"
304983e03a40Smrg	  staticdest=$func_lo2o_result
305083e03a40Smrg	  ;;
305183e03a40Smrg	*.$objext)
305283e03a40Smrg	  staticdest="$destfile"
305383e03a40Smrg	  destfile=
305483e03a40Smrg	  ;;
305583e03a40Smrg	*)
305683e03a40Smrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
3057357bfbb2Smrg	  ;;
3058357bfbb2Smrg	esac
3059357bfbb2Smrg
306083e03a40Smrg	# Install the libtool object if requested.
306183e03a40Smrg	test -n "$destfile" && \
306283e03a40Smrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
3063357bfbb2Smrg
306483e03a40Smrg	# Install the old object if enabled.
306583e03a40Smrg	if test "$build_old_libs" = yes; then
306683e03a40Smrg	  # Deduce the name of the old-style object file.
306783e03a40Smrg	  func_lo2o "$file"
306883e03a40Smrg	  staticobj=$func_lo2o_result
306983e03a40Smrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
307083e03a40Smrg	fi
307183e03a40Smrg	exit $EXIT_SUCCESS
307283e03a40Smrg	;;
3073357bfbb2Smrg
307483e03a40Smrg      *)
307583e03a40Smrg	# Figure out destination file name, if it wasn't already specified.
307683e03a40Smrg	if test -n "$destname"; then
307783e03a40Smrg	  destfile="$destdir/$destname"
307883e03a40Smrg	else
307983e03a40Smrg	  func_basename "$file"
308083e03a40Smrg	  destfile="$func_basename_result"
308183e03a40Smrg	  destfile="$destdir/$destfile"
308283e03a40Smrg	fi
3083357bfbb2Smrg
308483e03a40Smrg	# If the file is missing, and there is a .exe on the end, strip it
308583e03a40Smrg	# because it is most likely a libtool script we actually want to
308683e03a40Smrg	# install
308783e03a40Smrg	stripped_ext=""
308883e03a40Smrg	case $file in
308983e03a40Smrg	  *.exe)
309083e03a40Smrg	    if test ! -f "$file"; then
309183e03a40Smrg	      func_stripname '' '.exe' "$file"
309283e03a40Smrg	      file=$func_stripname_result
309383e03a40Smrg	      stripped_ext=".exe"
309483e03a40Smrg	    fi
309583e03a40Smrg	    ;;
309683e03a40Smrg	esac
3097357bfbb2Smrg
309883e03a40Smrg	# Do a test to see if this is really a libtool program.
309983e03a40Smrg	case $host in
310083e03a40Smrg	*cygwin* | *mingw*)
310183e03a40Smrg	    if func_ltwrapper_executable_p "$file"; then
310283e03a40Smrg	      func_ltwrapper_scriptname "$file"
310383e03a40Smrg	      wrapper=$func_ltwrapper_scriptname_result
310483e03a40Smrg	    else
310583e03a40Smrg	      func_stripname '' '.exe' "$file"
310683e03a40Smrg	      wrapper=$func_stripname_result
310783e03a40Smrg	    fi
310883e03a40Smrg	    ;;
310983e03a40Smrg	*)
311083e03a40Smrg	    wrapper=$file
311183e03a40Smrg	    ;;
311283e03a40Smrg	esac
311383e03a40Smrg	if func_ltwrapper_script_p "$wrapper"; then
311483e03a40Smrg	  notinst_deplibs=
311583e03a40Smrg	  relink_command=
3116357bfbb2Smrg
311783e03a40Smrg	  func_source "$wrapper"
3118357bfbb2Smrg
311983e03a40Smrg	  # Check the variables that should have been set.
312083e03a40Smrg	  test -z "$generated_by_libtool_version" && \
312183e03a40Smrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
3122357bfbb2Smrg
312383e03a40Smrg	  finalize=yes
312483e03a40Smrg	  for lib in $notinst_deplibs; do
312583e03a40Smrg	    # Check to see that each library is installed.
312683e03a40Smrg	    libdir=
312783e03a40Smrg	    if test -f "$lib"; then
312883e03a40Smrg	      func_source "$lib"
312983e03a40Smrg	    fi
313083e03a40Smrg	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
313183e03a40Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
313283e03a40Smrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
313383e03a40Smrg	      finalize=no
313483e03a40Smrg	    fi
313583e03a40Smrg	  done
3136357bfbb2Smrg
313783e03a40Smrg	  relink_command=
313883e03a40Smrg	  func_source "$wrapper"
313983e03a40Smrg
314083e03a40Smrg	  outputname=
314183e03a40Smrg	  if test "$fast_install" = no && test -n "$relink_command"; then
314283e03a40Smrg	    $opt_dry_run || {
314383e03a40Smrg	      if test "$finalize" = yes; then
314483e03a40Smrg	        tmpdir=`func_mktempdir`
314583e03a40Smrg		func_basename "$file$stripped_ext"
314683e03a40Smrg		file="$func_basename_result"
314783e03a40Smrg	        outputname="$tmpdir/$file"
314883e03a40Smrg	        # Replace the output file specification.
314983e03a40Smrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
315083e03a40Smrg
315183e03a40Smrg	        $opt_silent || {
315283e03a40Smrg	          func_quote_for_expand "$relink_command"
315383e03a40Smrg		  eval "func_echo $func_quote_for_expand_result"
315483e03a40Smrg	        }
315583e03a40Smrg	        if eval "$relink_command"; then :
315683e03a40Smrg	          else
315783e03a40Smrg		  func_error "error: relink \`$file' with the above command before installing it"
315883e03a40Smrg		  $opt_dry_run || ${RM}r "$tmpdir"
315983e03a40Smrg		  continue
316083e03a40Smrg	        fi
316183e03a40Smrg	        file="$outputname"
316283e03a40Smrg	      else
316383e03a40Smrg	        func_warning "cannot relink \`$file'"
316483e03a40Smrg	      fi
316583e03a40Smrg	    }
316683e03a40Smrg	  else
316783e03a40Smrg	    # Install the binary that we compiled earlier.
316883e03a40Smrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
316983e03a40Smrg	  fi
3170357bfbb2Smrg	fi
317183e03a40Smrg
317283e03a40Smrg	# remove .exe since cygwin /usr/bin/install will append another
317383e03a40Smrg	# one anyway
317483e03a40Smrg	case $install_prog,$host in
317583e03a40Smrg	*/usr/bin/install*,*cygwin*)
317683e03a40Smrg	  case $file:$destfile in
317783e03a40Smrg	  *.exe:*.exe)
317883e03a40Smrg	    # this is ok
317983e03a40Smrg	    ;;
318083e03a40Smrg	  *.exe:*)
318183e03a40Smrg	    destfile=$destfile.exe
318283e03a40Smrg	    ;;
318383e03a40Smrg	  *:*.exe)
318483e03a40Smrg	    func_stripname '' '.exe' "$destfile"
318583e03a40Smrg	    destfile=$func_stripname_result
318683e03a40Smrg	    ;;
318783e03a40Smrg	  esac
318883e03a40Smrg	  ;;
318983e03a40Smrg	esac
319083e03a40Smrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
319183e03a40Smrg	$opt_dry_run || if test -n "$outputname"; then
319283e03a40Smrg	  ${RM}r "$tmpdir"
3193357bfbb2Smrg	fi
3194357bfbb2Smrg	;;
3195357bfbb2Smrg      esac
319683e03a40Smrg    done
3197357bfbb2Smrg
319883e03a40Smrg    for file in $staticlibs; do
319983e03a40Smrg      func_basename "$file"
320083e03a40Smrg      name="$func_basename_result"
3201357bfbb2Smrg
320283e03a40Smrg      # Set up the ranlib parameters.
320383e03a40Smrg      oldlib="$destdir/$name"
3204357bfbb2Smrg
320583e03a40Smrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
320683e03a40Smrg
320783e03a40Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
320883e03a40Smrg	func_show_eval "$old_striplib $oldlib" 'exit $?'
3209357bfbb2Smrg      fi
3210357bfbb2Smrg
321183e03a40Smrg      # Do each command in the postinstall commands.
321283e03a40Smrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
321383e03a40Smrg    done
3214357bfbb2Smrg
321583e03a40Smrg    test -n "$future_libdirs" && \
321683e03a40Smrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
3217357bfbb2Smrg
321883e03a40Smrg    if test -n "$current_libdirs"; then
321983e03a40Smrg      # Maybe just do a dry run.
322083e03a40Smrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
322183e03a40Smrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
322283e03a40Smrg    else
322383e03a40Smrg      exit $EXIT_SUCCESS
322483e03a40Smrg    fi
322583e03a40Smrg}
3226357bfbb2Smrg
322783e03a40Smrgtest "$opt_mode" = install && func_mode_install ${1+"$@"}
3228357bfbb2Smrg
3229357bfbb2Smrg
323083e03a40Smrg# func_generate_dlsyms outputname originator pic_p
323183e03a40Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with
323283e03a40Smrg# a dlpreopen symbol table.
323383e03a40Smrgfunc_generate_dlsyms ()
323483e03a40Smrg{
323583e03a40Smrg    $opt_debug
323683e03a40Smrg    my_outputname="$1"
323783e03a40Smrg    my_originator="$2"
323883e03a40Smrg    my_pic_p="${3-no}"
323983e03a40Smrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
324083e03a40Smrg    my_dlsyms=
324183e03a40Smrg
324283e03a40Smrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
324383e03a40Smrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
324483e03a40Smrg	my_dlsyms="${my_outputname}S.c"
324583e03a40Smrg      else
324683e03a40Smrg	func_error "not configured to extract global symbols from dlpreopened files"
324783e03a40Smrg      fi
324883e03a40Smrg    fi
3249357bfbb2Smrg
325083e03a40Smrg    if test -n "$my_dlsyms"; then
325183e03a40Smrg      case $my_dlsyms in
325283e03a40Smrg      "") ;;
325383e03a40Smrg      *.c)
325483e03a40Smrg	# Discover the nlist of each of the dlfiles.
325583e03a40Smrg	nlist="$output_objdir/${my_outputname}.nm"
3256357bfbb2Smrg
325783e03a40Smrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
3258357bfbb2Smrg
325983e03a40Smrg	# Parse the name list into a source file.
326083e03a40Smrg	func_verbose "creating $output_objdir/$my_dlsyms"
3261357bfbb2Smrg
326283e03a40Smrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
326383e03a40Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
326483e03a40Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
3265357bfbb2Smrg
326683e03a40Smrg#ifdef __cplusplus
326783e03a40Smrgextern \"C\" {
326883e03a40Smrg#endif
3269357bfbb2Smrg
327083e03a40Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
327183e03a40Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
327283e03a40Smrg#endif
3273357bfbb2Smrg
327483e03a40Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
327583e03a40Smrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
327683e03a40Smrg/* DATA imports from DLLs on WIN32 con't be const, because runtime
327783e03a40Smrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
327883e03a40Smrg# define LT_DLSYM_CONST
327983e03a40Smrg#elif defined(__osf__)
328083e03a40Smrg/* This system does not cope well with relocations in const data.  */
328183e03a40Smrg# define LT_DLSYM_CONST
328283e03a40Smrg#else
328383e03a40Smrg# define LT_DLSYM_CONST const
328483e03a40Smrg#endif
3285357bfbb2Smrg
328683e03a40Smrg/* External symbol declarations for the compiler. */\
328783e03a40Smrg"
3288357bfbb2Smrg
328983e03a40Smrg	if test "$dlself" = yes; then
329083e03a40Smrg	  func_verbose "generating symbol list for \`$output'"
3291357bfbb2Smrg
329283e03a40Smrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
3293357bfbb2Smrg
329483e03a40Smrg	  # Add our own program objects to the symbol list.
329583e03a40Smrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
329683e03a40Smrg	  for progfile in $progfiles; do
329783e03a40Smrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
329883e03a40Smrg	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
329983e03a40Smrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
3300357bfbb2Smrg	  done
3301357bfbb2Smrg
330283e03a40Smrg	  if test -n "$exclude_expsyms"; then
330383e03a40Smrg	    $opt_dry_run || {
330483e03a40Smrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
330583e03a40Smrg	      eval '$MV "$nlist"T "$nlist"'
330683e03a40Smrg	    }
330783e03a40Smrg	  fi
3308357bfbb2Smrg
330983e03a40Smrg	  if test -n "$export_symbols_regex"; then
331083e03a40Smrg	    $opt_dry_run || {
331183e03a40Smrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
331283e03a40Smrg	      eval '$MV "$nlist"T "$nlist"'
331383e03a40Smrg	    }
331483e03a40Smrg	  fi
3315357bfbb2Smrg
331683e03a40Smrg	  # Prepare the list of exported symbols
331783e03a40Smrg	  if test -z "$export_symbols"; then
331883e03a40Smrg	    export_symbols="$output_objdir/$outputname.exp"
331983e03a40Smrg	    $opt_dry_run || {
332083e03a40Smrg	      $RM $export_symbols
332183e03a40Smrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
332283e03a40Smrg	      case $host in
332383e03a40Smrg	      *cygwin* | *mingw* | *cegcc* )
332483e03a40Smrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
332583e03a40Smrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
332683e03a40Smrg	        ;;
332783e03a40Smrg	      esac
332883e03a40Smrg	    }
332983e03a40Smrg	  else
333083e03a40Smrg	    $opt_dry_run || {
333183e03a40Smrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
333283e03a40Smrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
333383e03a40Smrg	      eval '$MV "$nlist"T "$nlist"'
333483e03a40Smrg	      case $host in
333583e03a40Smrg	        *cygwin* | *mingw* | *cegcc* )
333683e03a40Smrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
333783e03a40Smrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
333883e03a40Smrg	          ;;
333983e03a40Smrg	      esac
334083e03a40Smrg	    }
334183e03a40Smrg	  fi
334283e03a40Smrg	fi
3343357bfbb2Smrg
334483e03a40Smrg	for dlprefile in $dlprefiles; do
334583e03a40Smrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
334683e03a40Smrg	  func_basename "$dlprefile"
334783e03a40Smrg	  name="$func_basename_result"
334883e03a40Smrg          case $host in
334983e03a40Smrg	    *cygwin* | *mingw* | *cegcc* )
335083e03a40Smrg	      # if an import library, we need to obtain dlname
335183e03a40Smrg	      if func_win32_import_lib_p "$dlprefile"; then
335283e03a40Smrg	        func_tr_sh "$dlprefile"
335383e03a40Smrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
335483e03a40Smrg	        dlprefile_dlbasename=""
335583e03a40Smrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
335683e03a40Smrg	          # Use subshell, to avoid clobbering current variable values
335783e03a40Smrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
335883e03a40Smrg	          if test -n "$dlprefile_dlname" ; then
335983e03a40Smrg	            func_basename "$dlprefile_dlname"
336083e03a40Smrg	            dlprefile_dlbasename="$func_basename_result"
336183e03a40Smrg	          else
336283e03a40Smrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
336383e03a40Smrg	            $sharedlib_from_linklib_cmd "$dlprefile"
336483e03a40Smrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
336583e03a40Smrg	          fi
336683e03a40Smrg	        fi
336783e03a40Smrg	        $opt_dry_run || {
336883e03a40Smrg	          if test -n "$dlprefile_dlbasename" ; then
336983e03a40Smrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
337083e03a40Smrg	          else
337183e03a40Smrg	            func_warning "Could not compute DLL name from $name"
337283e03a40Smrg	            eval '$ECHO ": $name " >> "$nlist"'
337383e03a40Smrg	          fi
337483e03a40Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
337583e03a40Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
337683e03a40Smrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
337783e03a40Smrg	        }
337883e03a40Smrg	      else # not an import lib
337983e03a40Smrg	        $opt_dry_run || {
338083e03a40Smrg	          eval '$ECHO ": $name " >> "$nlist"'
338183e03a40Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
338283e03a40Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
338383e03a40Smrg	        }
338483e03a40Smrg	      fi
338583e03a40Smrg	    ;;
338683e03a40Smrg	    *)
338783e03a40Smrg	      $opt_dry_run || {
338883e03a40Smrg	        eval '$ECHO ": $name " >> "$nlist"'
338983e03a40Smrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
339083e03a40Smrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
339183e03a40Smrg	      }
339283e03a40Smrg	    ;;
339383e03a40Smrg          esac
339483e03a40Smrg	done
3395357bfbb2Smrg
339683e03a40Smrg	$opt_dry_run || {
339783e03a40Smrg	  # Make sure we have at least an empty file.
339883e03a40Smrg	  test -f "$nlist" || : > "$nlist"
3399357bfbb2Smrg
340083e03a40Smrg	  if test -n "$exclude_expsyms"; then
340183e03a40Smrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
340283e03a40Smrg	    $MV "$nlist"T "$nlist"
340383e03a40Smrg	  fi
3404357bfbb2Smrg
340583e03a40Smrg	  # Try sorting and uniquifying the output.
340683e03a40Smrg	  if $GREP -v "^: " < "$nlist" |
340783e03a40Smrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
340883e03a40Smrg		sort -k 3
340983e03a40Smrg	      else
341083e03a40Smrg		sort +2
341183e03a40Smrg	      fi |
341283e03a40Smrg	      uniq > "$nlist"S; then
341383e03a40Smrg	    :
341483e03a40Smrg	  else
341583e03a40Smrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
341683e03a40Smrg	  fi
3417357bfbb2Smrg
341883e03a40Smrg	  if test -f "$nlist"S; then
341983e03a40Smrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
342083e03a40Smrg	  else
342183e03a40Smrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
342283e03a40Smrg	  fi
3423357bfbb2Smrg
342483e03a40Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
342583e03a40Smrg
342683e03a40Smrg/* The mapping between symbol names and symbols.  */
342783e03a40Smrgtypedef struct {
342883e03a40Smrg  const char *name;
342983e03a40Smrg  void *address;
343083e03a40Smrg} lt_dlsymlist;
343183e03a40Smrgextern LT_DLSYM_CONST lt_dlsymlist
343283e03a40Smrglt_${my_prefix}_LTX_preloaded_symbols[];
343383e03a40SmrgLT_DLSYM_CONST lt_dlsymlist
343483e03a40Smrglt_${my_prefix}_LTX_preloaded_symbols[] =
343583e03a40Smrg{\
343683e03a40Smrg  { \"$my_originator\", (void *) 0 },"
343783e03a40Smrg
343883e03a40Smrg	  case $need_lib_prefix in
343983e03a40Smrg	  no)
344083e03a40Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
3441357bfbb2Smrg	    ;;
3442357bfbb2Smrg	  *)
344383e03a40Smrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
3444357bfbb2Smrg	    ;;
3445357bfbb2Smrg	  esac
344683e03a40Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
344783e03a40Smrg  {0, (void *) 0}
344883e03a40Smrg};
3449357bfbb2Smrg
345083e03a40Smrg/* This works around a problem in FreeBSD linker */
345183e03a40Smrg#ifdef FREEBSD_WORKAROUND
345283e03a40Smrgstatic const void *lt_preloaded_setup() {
345383e03a40Smrg  return lt_${my_prefix}_LTX_preloaded_symbols;
345483e03a40Smrg}
345583e03a40Smrg#endif
3456357bfbb2Smrg
345783e03a40Smrg#ifdef __cplusplus
345883e03a40Smrg}
345983e03a40Smrg#endif\
346083e03a40Smrg"
346183e03a40Smrg	} # !$opt_dry_run
3462357bfbb2Smrg
346383e03a40Smrg	pic_flag_for_symtable=
346483e03a40Smrg	case "$compile_command " in
346583e03a40Smrg	*" -static "*) ;;
346683e03a40Smrg	*)
346783e03a40Smrg	  case $host in
346883e03a40Smrg	  # compiling the symbol table file with pic_flag works around
346983e03a40Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
347083e03a40Smrg	  # linked before any other PIC object.  But we must not use
347183e03a40Smrg	  # pic_flag when linking with -static.  The problem exists in
347283e03a40Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
347383e03a40Smrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
347483e03a40Smrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
347583e03a40Smrg	  *-*-hpux*)
347683e03a40Smrg	    pic_flag_for_symtable=" $pic_flag"  ;;
347783e03a40Smrg	  *)
347883e03a40Smrg	    if test "X$my_pic_p" != Xno; then
347983e03a40Smrg	      pic_flag_for_symtable=" $pic_flag"
348083e03a40Smrg	    fi
348183e03a40Smrg	    ;;
348283e03a40Smrg	  esac
348383e03a40Smrg	  ;;
348483e03a40Smrg	esac
348583e03a40Smrg	symtab_cflags=
348683e03a40Smrg	for arg in $LTCFLAGS; do
348783e03a40Smrg	  case $arg in
348883e03a40Smrg	  -pie | -fpie | -fPIE) ;;
348983e03a40Smrg	  *) func_append symtab_cflags " $arg" ;;
3490357bfbb2Smrg	  esac
3491357bfbb2Smrg	done
3492357bfbb2Smrg
349383e03a40Smrg	# Now compile the dynamic symbol file.
349483e03a40Smrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
3495357bfbb2Smrg
349683e03a40Smrg	# Clean up the generated files.
349783e03a40Smrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
3498357bfbb2Smrg
349983e03a40Smrg	# Transform the symbol file into the correct name.
350083e03a40Smrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
350183e03a40Smrg	case $host in
350283e03a40Smrg	*cygwin* | *mingw* | *cegcc* )
350383e03a40Smrg	  if test -f "$output_objdir/$my_outputname.def"; then
350483e03a40Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
350583e03a40Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
350683e03a40Smrg	  else
350783e03a40Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
350883e03a40Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
350983e03a40Smrg	  fi
351083e03a40Smrg	  ;;
351183e03a40Smrg	*)
351283e03a40Smrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
351383e03a40Smrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
351483e03a40Smrg	  ;;
351583e03a40Smrg	esac
351683e03a40Smrg	;;
351783e03a40Smrg      *)
351883e03a40Smrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
351983e03a40Smrg	;;
352083e03a40Smrg      esac
352183e03a40Smrg    else
352283e03a40Smrg      # We keep going just in case the user didn't refer to
352383e03a40Smrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
352483e03a40Smrg      # really was required.
3525357bfbb2Smrg
352683e03a40Smrg      # Nullify the symbol file.
352783e03a40Smrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
352883e03a40Smrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
352983e03a40Smrg    fi
353083e03a40Smrg}
3531357bfbb2Smrg
353283e03a40Smrg# func_win32_libid arg
353383e03a40Smrg# return the library type of file 'arg'
353483e03a40Smrg#
353583e03a40Smrg# Need a lot of goo to handle *both* DLLs and import libs
353683e03a40Smrg# Has to be a shell function in order to 'eat' the argument
353783e03a40Smrg# that is supplied when $file_magic_command is called.
353883e03a40Smrg# Despite the name, also deal with 64 bit binaries.
353983e03a40Smrgfunc_win32_libid ()
354083e03a40Smrg{
354183e03a40Smrg  $opt_debug
354283e03a40Smrg  win32_libid_type="unknown"
354383e03a40Smrg  win32_fileres=`file -L $1 2>/dev/null`
354483e03a40Smrg  case $win32_fileres in
354583e03a40Smrg  *ar\ archive\ import\ library*) # definitely import
354683e03a40Smrg    win32_libid_type="x86 archive import"
354783e03a40Smrg    ;;
354883e03a40Smrg  *ar\ archive*) # could be an import, or static
354983e03a40Smrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
355083e03a40Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
355183e03a40Smrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
355283e03a40Smrg      func_to_tool_file "$1" func_convert_file_msys_to_w32
355383e03a40Smrg      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
355483e03a40Smrg	$SED -n -e '
355583e03a40Smrg	    1,100{
355683e03a40Smrg		/ I /{
355783e03a40Smrg		    s,.*,import,
355883e03a40Smrg		    p
355983e03a40Smrg		    q
356083e03a40Smrg		}
356183e03a40Smrg	    }'`
356283e03a40Smrg      case $win32_nmres in
356383e03a40Smrg      import*)  win32_libid_type="x86 archive import";;
356483e03a40Smrg      *)        win32_libid_type="x86 archive static";;
356583e03a40Smrg      esac
356683e03a40Smrg    fi
356783e03a40Smrg    ;;
356883e03a40Smrg  *DLL*)
356983e03a40Smrg    win32_libid_type="x86 DLL"
357083e03a40Smrg    ;;
357183e03a40Smrg  *executable*) # but shell scripts are "executable" too...
357283e03a40Smrg    case $win32_fileres in
357383e03a40Smrg    *MS\ Windows\ PE\ Intel*)
357483e03a40Smrg      win32_libid_type="x86 DLL"
357583e03a40Smrg      ;;
357683e03a40Smrg    esac
357783e03a40Smrg    ;;
357883e03a40Smrg  esac
357983e03a40Smrg  $ECHO "$win32_libid_type"
358083e03a40Smrg}
358183e03a40Smrg
358283e03a40Smrg# func_cygming_dll_for_implib ARG
358383e03a40Smrg#
358483e03a40Smrg# Platform-specific function to extract the
358583e03a40Smrg# name of the DLL associated with the specified
358683e03a40Smrg# import library ARG.
358783e03a40Smrg# Invoked by eval'ing the libtool variable
358883e03a40Smrg#    $sharedlib_from_linklib_cmd
358983e03a40Smrg# Result is available in the variable
359083e03a40Smrg#    $sharedlib_from_linklib_result
359183e03a40Smrgfunc_cygming_dll_for_implib ()
359283e03a40Smrg{
359383e03a40Smrg  $opt_debug
359483e03a40Smrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
359583e03a40Smrg}
359683e03a40Smrg
359783e03a40Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
359883e03a40Smrg#
359983e03a40Smrg# The is the core of a fallback implementation of a
360083e03a40Smrg# platform-specific function to extract the name of the
360183e03a40Smrg# DLL associated with the specified import library LIBNAME.
360283e03a40Smrg#
360383e03a40Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending
360483e03a40Smrg# on the platform and compiler that created the implib.
360583e03a40Smrg#
360683e03a40Smrg# Echos the name of the DLL associated with the
360783e03a40Smrg# specified import library.
360883e03a40Smrgfunc_cygming_dll_for_implib_fallback_core ()
360983e03a40Smrg{
361083e03a40Smrg  $opt_debug
361183e03a40Smrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
361283e03a40Smrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
361383e03a40Smrg    $SED '/^Contents of section '"$match_literal"':/{
361483e03a40Smrg      # Place marker at beginning of archive member dllname section
361583e03a40Smrg      s/.*/====MARK====/
361683e03a40Smrg      p
361783e03a40Smrg      d
361883e03a40Smrg    }
361983e03a40Smrg    # These lines can sometimes be longer than 43 characters, but
362083e03a40Smrg    # are always uninteresting
362183e03a40Smrg    /:[	 ]*file format pe[i]\{,1\}-/d
362283e03a40Smrg    /^In archive [^:]*:/d
362383e03a40Smrg    # Ensure marker is printed
362483e03a40Smrg    /^====MARK====/p
362583e03a40Smrg    # Remove all lines with less than 43 characters
362683e03a40Smrg    /^.\{43\}/!d
362783e03a40Smrg    # From remaining lines, remove first 43 characters
362883e03a40Smrg    s/^.\{43\}//' |
362983e03a40Smrg    $SED -n '
363083e03a40Smrg      # Join marker and all lines until next marker into a single line
363183e03a40Smrg      /^====MARK====/ b para
363283e03a40Smrg      H
363383e03a40Smrg      $ b para
363483e03a40Smrg      b
363583e03a40Smrg      :para
363683e03a40Smrg      x
363783e03a40Smrg      s/\n//g
363883e03a40Smrg      # Remove the marker
363983e03a40Smrg      s/^====MARK====//
364083e03a40Smrg      # Remove trailing dots and whitespace
364183e03a40Smrg      s/[\. \t]*$//
364283e03a40Smrg      # Print
364383e03a40Smrg      /./p' |
364483e03a40Smrg    # we now have a list, one entry per line, of the stringified
364583e03a40Smrg    # contents of the appropriate section of all members of the
364683e03a40Smrg    # archive which possess that section. Heuristic: eliminate
364783e03a40Smrg    # all those which have a first or second character that is
364883e03a40Smrg    # a '.' (that is, objdump's representation of an unprintable
364983e03a40Smrg    # character.) This should work for all archives with less than
365083e03a40Smrg    # 0x302f exports -- but will fail for DLLs whose name actually
365183e03a40Smrg    # begins with a literal '.' or a single character followed by
365283e03a40Smrg    # a '.'.
365383e03a40Smrg    #
365483e03a40Smrg    # Of those that remain, print the first one.
365583e03a40Smrg    $SED -e '/^\./d;/^.\./d;q'
365683e03a40Smrg}
365783e03a40Smrg
365883e03a40Smrg# func_cygming_gnu_implib_p ARG
365983e03a40Smrg# This predicate returns with zero status (TRUE) if
366083e03a40Smrg# ARG is a GNU/binutils-style import library. Returns
366183e03a40Smrg# with nonzero status (FALSE) otherwise.
366283e03a40Smrgfunc_cygming_gnu_implib_p ()
366383e03a40Smrg{
366483e03a40Smrg  $opt_debug
366583e03a40Smrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
366683e03a40Smrg  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)$'`
366783e03a40Smrg  test -n "$func_cygming_gnu_implib_tmp"
366883e03a40Smrg}
366983e03a40Smrg
367083e03a40Smrg# func_cygming_ms_implib_p ARG
367183e03a40Smrg# This predicate returns with zero status (TRUE) if
367283e03a40Smrg# ARG is an MS-style import library. Returns
367383e03a40Smrg# with nonzero status (FALSE) otherwise.
367483e03a40Smrgfunc_cygming_ms_implib_p ()
367583e03a40Smrg{
367683e03a40Smrg  $opt_debug
367783e03a40Smrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
367883e03a40Smrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
367983e03a40Smrg  test -n "$func_cygming_ms_implib_tmp"
368083e03a40Smrg}
368183e03a40Smrg
368283e03a40Smrg# func_cygming_dll_for_implib_fallback ARG
368383e03a40Smrg# Platform-specific function to extract the
368483e03a40Smrg# name of the DLL associated with the specified
368583e03a40Smrg# import library ARG.
368683e03a40Smrg#
368783e03a40Smrg# This fallback implementation is for use when $DLLTOOL
368883e03a40Smrg# does not support the --identify-strict option.
368983e03a40Smrg# Invoked by eval'ing the libtool variable
369083e03a40Smrg#    $sharedlib_from_linklib_cmd
369183e03a40Smrg# Result is available in the variable
369283e03a40Smrg#    $sharedlib_from_linklib_result
369383e03a40Smrgfunc_cygming_dll_for_implib_fallback ()
369483e03a40Smrg{
369583e03a40Smrg  $opt_debug
369683e03a40Smrg  if func_cygming_gnu_implib_p "$1" ; then
369783e03a40Smrg    # binutils import library
369883e03a40Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
369983e03a40Smrg  elif func_cygming_ms_implib_p "$1" ; then
370083e03a40Smrg    # ms-generated import library
370183e03a40Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
370283e03a40Smrg  else
370383e03a40Smrg    # unknown
370483e03a40Smrg    sharedlib_from_linklib_result=""
370583e03a40Smrg  fi
370683e03a40Smrg}
370783e03a40Smrg
370883e03a40Smrg
370983e03a40Smrg# func_extract_an_archive dir oldlib
371083e03a40Smrgfunc_extract_an_archive ()
371183e03a40Smrg{
371283e03a40Smrg    $opt_debug
371383e03a40Smrg    f_ex_an_ar_dir="$1"; shift
371483e03a40Smrg    f_ex_an_ar_oldlib="$1"
371583e03a40Smrg    if test "$lock_old_archive_extraction" = yes; then
371683e03a40Smrg      lockfile=$f_ex_an_ar_oldlib.lock
371783e03a40Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
371883e03a40Smrg	func_echo "Waiting for $lockfile to be removed"
371983e03a40Smrg	sleep 2
3720357bfbb2Smrg      done
372183e03a40Smrg    fi
372283e03a40Smrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
372383e03a40Smrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
372483e03a40Smrg    if test "$lock_old_archive_extraction" = yes; then
372583e03a40Smrg      $opt_dry_run || rm -f "$lockfile"
372683e03a40Smrg    fi
372783e03a40Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
372883e03a40Smrg     :
372983e03a40Smrg    else
373083e03a40Smrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
373183e03a40Smrg    fi
373283e03a40Smrg}
3733357bfbb2Smrg
373483e03a40Smrg
373583e03a40Smrg# func_extract_archives gentop oldlib ...
373683e03a40Smrgfunc_extract_archives ()
373783e03a40Smrg{
373883e03a40Smrg    $opt_debug
373983e03a40Smrg    my_gentop="$1"; shift
374083e03a40Smrg    my_oldlibs=${1+"$@"}
374183e03a40Smrg    my_oldobjs=""
374283e03a40Smrg    my_xlib=""
374383e03a40Smrg    my_xabs=""
374483e03a40Smrg    my_xdir=""
374583e03a40Smrg
374683e03a40Smrg    for my_xlib in $my_oldlibs; do
374783e03a40Smrg      # Extract the objects.
374883e03a40Smrg      case $my_xlib in
374983e03a40Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
375083e03a40Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
375183e03a40Smrg      esac
375283e03a40Smrg      func_basename "$my_xlib"
375383e03a40Smrg      my_xlib="$func_basename_result"
375483e03a40Smrg      my_xlib_u=$my_xlib
375583e03a40Smrg      while :; do
375683e03a40Smrg        case " $extracted_archives " in
375783e03a40Smrg	*" $my_xlib_u "*)
375883e03a40Smrg	  func_arith $extracted_serial + 1
375983e03a40Smrg	  extracted_serial=$func_arith_result
376083e03a40Smrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
376183e03a40Smrg	*) break ;;
3762357bfbb2Smrg	esac
3763357bfbb2Smrg      done
376483e03a40Smrg      extracted_archives="$extracted_archives $my_xlib_u"
376583e03a40Smrg      my_xdir="$my_gentop/$my_xlib_u"
3766357bfbb2Smrg
376783e03a40Smrg      func_mkdir_p "$my_xdir"
3768357bfbb2Smrg
376983e03a40Smrg      case $host in
377083e03a40Smrg      *-darwin*)
377183e03a40Smrg	func_verbose "Extracting $my_xabs"
377283e03a40Smrg	# Do not bother doing anything if just a dry run
377383e03a40Smrg	$opt_dry_run || {
377483e03a40Smrg	  darwin_orig_dir=`pwd`
377583e03a40Smrg	  cd $my_xdir || exit $?
377683e03a40Smrg	  darwin_archive=$my_xabs
377783e03a40Smrg	  darwin_curdir=`pwd`
377883e03a40Smrg	  darwin_base_archive=`basename "$darwin_archive"`
377983e03a40Smrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
378083e03a40Smrg	  if test -n "$darwin_arches"; then
378183e03a40Smrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
378283e03a40Smrg	    darwin_arch=
378383e03a40Smrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
378483e03a40Smrg	    for darwin_arch in  $darwin_arches ; do
378583e03a40Smrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
378683e03a40Smrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
378783e03a40Smrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
378883e03a40Smrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
378983e03a40Smrg	      cd "$darwin_curdir"
379083e03a40Smrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
379183e03a40Smrg	    done # $darwin_arches
379283e03a40Smrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
379383e03a40Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
379483e03a40Smrg	    darwin_file=
379583e03a40Smrg	    darwin_files=
379683e03a40Smrg	    for darwin_file in $darwin_filelist; do
379783e03a40Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
379883e03a40Smrg	      $LIPO -create -output "$darwin_file" $darwin_files
379983e03a40Smrg	    done # $darwin_filelist
380083e03a40Smrg	    $RM -rf unfat-$$
380183e03a40Smrg	    cd "$darwin_orig_dir"
3802357bfbb2Smrg	  else
380383e03a40Smrg	    cd $darwin_orig_dir
380483e03a40Smrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
380583e03a40Smrg	  fi # $darwin_arches
380683e03a40Smrg	} # !$opt_dry_run
380783e03a40Smrg	;;
380883e03a40Smrg      *)
380983e03a40Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
381083e03a40Smrg	;;
381183e03a40Smrg      esac
381283e03a40Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
381383e03a40Smrg    done
3814357bfbb2Smrg
381583e03a40Smrg    func_extract_archives_result="$my_oldobjs"
381683e03a40Smrg}
3817357bfbb2Smrg
3818357bfbb2Smrg
381983e03a40Smrg# func_emit_wrapper [arg=no]
382083e03a40Smrg#
382183e03a40Smrg# Emit a libtool wrapper script on stdout.
382283e03a40Smrg# Don't directly open a file because we may want to
382383e03a40Smrg# incorporate the script contents within a cygwin/mingw
382483e03a40Smrg# wrapper executable.  Must ONLY be called from within
382583e03a40Smrg# func_mode_link because it depends on a number of variables
382683e03a40Smrg# set therein.
382783e03a40Smrg#
382883e03a40Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
382983e03a40Smrg# variable will take.  If 'yes', then the emitted script
383083e03a40Smrg# will assume that the directory in which it is stored is
383183e03a40Smrg# the $objdir directory.  This is a cygwin/mingw-specific
383283e03a40Smrg# behavior.
383383e03a40Smrgfunc_emit_wrapper ()
383483e03a40Smrg{
383583e03a40Smrg	func_emit_wrapper_arg1=${1-no}
3836357bfbb2Smrg
383783e03a40Smrg	$ECHO "\
383883e03a40Smrg#! $SHELL
3839357bfbb2Smrg
384083e03a40Smrg# $output - temporary wrapper script for $objdir/$outputname
384183e03a40Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
384283e03a40Smrg#
384383e03a40Smrg# The $output program cannot be directly executed until all the libtool
384483e03a40Smrg# libraries that it depends on are installed.
384583e03a40Smrg#
384683e03a40Smrg# This wrapper script should never be moved out of the build directory.
384783e03a40Smrg# If it is, it will not operate correctly.
3848357bfbb2Smrg
384983e03a40Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
385083e03a40Smrg# metacharacters that are still active within double-quoted strings.
385183e03a40Smrgsed_quote_subst='$sed_quote_subst'
3852357bfbb2Smrg
385383e03a40Smrg# Be Bourne compatible
385483e03a40Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
385583e03a40Smrg  emulate sh
385683e03a40Smrg  NULLCMD=:
385783e03a40Smrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
385883e03a40Smrg  # is contrary to our usage.  Disable this feature.
385983e03a40Smrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
386083e03a40Smrg  setopt NO_GLOB_SUBST
386183e03a40Smrgelse
386283e03a40Smrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
386383e03a40Smrgfi
386483e03a40SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
386583e03a40SmrgDUALCASE=1; export DUALCASE # for MKS sh
3866357bfbb2Smrg
386783e03a40Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
386883e03a40Smrg# if CDPATH is set.
386983e03a40Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
3870357bfbb2Smrg
387183e03a40Smrgrelink_command=\"$relink_command\"
3872357bfbb2Smrg
387383e03a40Smrg# This environment variable determines our operation mode.
387483e03a40Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
387583e03a40Smrg  # install mode needs the following variables:
387683e03a40Smrg  generated_by_libtool_version='$macro_version'
387783e03a40Smrg  notinst_deplibs='$notinst_deplibs'
387883e03a40Smrgelse
387983e03a40Smrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
388083e03a40Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
388183e03a40Smrg    file=\"\$0\""
3882357bfbb2Smrg
388383e03a40Smrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
388483e03a40Smrg    $ECHO "\
3885357bfbb2Smrg
388683e03a40Smrg# A function that is used when there is no print builtin or printf.
388783e03a40Smrgfunc_fallback_echo ()
388883e03a40Smrg{
388983e03a40Smrg  eval 'cat <<_LTECHO_EOF
389083e03a40Smrg\$1
389183e03a40Smrg_LTECHO_EOF'
389283e03a40Smrg}
389383e03a40Smrg    ECHO=\"$qECHO\"
389483e03a40Smrg  fi
3895357bfbb2Smrg
389683e03a40Smrg# Very basic option parsing. These options are (a) specific to
389783e03a40Smrg# the libtool wrapper, (b) are identical between the wrapper
389883e03a40Smrg# /script/ and the wrapper /executable/ which is used only on
389983e03a40Smrg# windows platforms, and (c) all begin with the string "--lt-"
390083e03a40Smrg# (application programs are unlikely to have options which match
390183e03a40Smrg# this pattern).
390283e03a40Smrg#
390383e03a40Smrg# There are only two supported options: --lt-debug and
390483e03a40Smrg# --lt-dump-script. There is, deliberately, no --lt-help.
390583e03a40Smrg#
390683e03a40Smrg# The first argument to this parsing function should be the
390783e03a40Smrg# script's $0 value, followed by "$@".
390883e03a40Smrglt_option_debug=
390983e03a40Smrgfunc_parse_lt_options ()
391083e03a40Smrg{
391183e03a40Smrg  lt_script_arg0=\$0
391283e03a40Smrg  shift
391383e03a40Smrg  for lt_opt
391483e03a40Smrg  do
391583e03a40Smrg    case \"\$lt_opt\" in
391683e03a40Smrg    --lt-debug) lt_option_debug=1 ;;
391783e03a40Smrg    --lt-dump-script)
391883e03a40Smrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
391983e03a40Smrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
392083e03a40Smrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
392183e03a40Smrg        cat \"\$lt_dump_D/\$lt_dump_F\"
392283e03a40Smrg        exit 0
392383e03a40Smrg      ;;
392483e03a40Smrg    --lt-*)
392583e03a40Smrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
392683e03a40Smrg        exit 1
392783e03a40Smrg      ;;
392883e03a40Smrg    esac
392983e03a40Smrg  done
3930357bfbb2Smrg
393183e03a40Smrg  # Print the debug banner immediately:
393283e03a40Smrg  if test -n \"\$lt_option_debug\"; then
393383e03a40Smrg    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
393483e03a40Smrg  fi
393583e03a40Smrg}
3936357bfbb2Smrg
393783e03a40Smrg# Used when --lt-debug. Prints its arguments to stdout
393883e03a40Smrg# (redirection is the responsibility of the caller)
393983e03a40Smrgfunc_lt_dump_args ()
394083e03a40Smrg{
394183e03a40Smrg  lt_dump_args_N=1;
394283e03a40Smrg  for lt_arg
394383e03a40Smrg  do
394483e03a40Smrg    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
394583e03a40Smrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
394683e03a40Smrg  done
394783e03a40Smrg}
3948357bfbb2Smrg
394983e03a40Smrg# Core function for launching the target application
395083e03a40Smrgfunc_exec_program_core ()
395183e03a40Smrg{
395283e03a40Smrg"
395383e03a40Smrg  case $host in
395483e03a40Smrg  # Backslashes separate directories on plain windows
395583e03a40Smrg  *-*-mingw | *-*-os2* | *-cegcc*)
395683e03a40Smrg    $ECHO "\
395783e03a40Smrg      if test -n \"\$lt_option_debug\"; then
395883e03a40Smrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
395983e03a40Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
396083e03a40Smrg      fi
396183e03a40Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
396283e03a40Smrg"
396383e03a40Smrg    ;;
3964357bfbb2Smrg
396583e03a40Smrg  *)
396683e03a40Smrg    $ECHO "\
396783e03a40Smrg      if test -n \"\$lt_option_debug\"; then
396883e03a40Smrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
396983e03a40Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
397083e03a40Smrg      fi
397183e03a40Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
397283e03a40Smrg"
397383e03a40Smrg    ;;
397483e03a40Smrg  esac
397583e03a40Smrg  $ECHO "\
397683e03a40Smrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
397783e03a40Smrg      exit 1
397883e03a40Smrg}
3979357bfbb2Smrg
398083e03a40Smrg# A function to encapsulate launching the target application
398183e03a40Smrg# Strips options in the --lt-* namespace from \$@ and
398283e03a40Smrg# launches target application with the remaining arguments.
398383e03a40Smrgfunc_exec_program ()
398483e03a40Smrg{
398583e03a40Smrg  for lt_wr_arg
398683e03a40Smrg  do
398783e03a40Smrg    case \$lt_wr_arg in
398883e03a40Smrg    --lt-*) ;;
398983e03a40Smrg    *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
399083e03a40Smrg    esac
399183e03a40Smrg    shift
399283e03a40Smrg  done
399383e03a40Smrg  func_exec_program_core \${1+\"\$@\"}
399483e03a40Smrg}
3995357bfbb2Smrg
399683e03a40Smrg  # Parse options
399783e03a40Smrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
3998357bfbb2Smrg
399983e03a40Smrg  # Find the directory that this script lives in.
400083e03a40Smrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
400183e03a40Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
4002357bfbb2Smrg
400383e03a40Smrg  # Follow symbolic links until we get to the real thisdir.
400483e03a40Smrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
400583e03a40Smrg  while test -n \"\$file\"; do
400683e03a40Smrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
4007357bfbb2Smrg
400883e03a40Smrg    # If there was a directory component, then change thisdir.
400983e03a40Smrg    if test \"x\$destdir\" != \"x\$file\"; then
401083e03a40Smrg      case \"\$destdir\" in
401183e03a40Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
401283e03a40Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
401383e03a40Smrg      esac
401483e03a40Smrg    fi
4015357bfbb2Smrg
401683e03a40Smrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
401783e03a40Smrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
401883e03a40Smrg  done
4019357bfbb2Smrg
402083e03a40Smrg  # Usually 'no', except on cygwin/mingw when embedded into
402183e03a40Smrg  # the cwrapper.
402283e03a40Smrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
402383e03a40Smrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
402483e03a40Smrg    # special case for '.'
402583e03a40Smrg    if test \"\$thisdir\" = \".\"; then
402683e03a40Smrg      thisdir=\`pwd\`
402783e03a40Smrg    fi
402883e03a40Smrg    # remove .libs from thisdir
402983e03a40Smrg    case \"\$thisdir\" in
403083e03a40Smrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
403183e03a40Smrg    $objdir )   thisdir=. ;;
403283e03a40Smrg    esac
403383e03a40Smrg  fi
4034357bfbb2Smrg
403583e03a40Smrg  # Try to get the absolute directory name.
403683e03a40Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
403783e03a40Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
403883e03a40Smrg"
4039357bfbb2Smrg
404083e03a40Smrg	if test "$fast_install" = yes; then
404183e03a40Smrg	  $ECHO "\
404283e03a40Smrg  program=lt-'$outputname'$exeext
404383e03a40Smrg  progdir=\"\$thisdir/$objdir\"
4044357bfbb2Smrg
404583e03a40Smrg  if test ! -f \"\$progdir/\$program\" ||
404683e03a40Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
404783e03a40Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
4048357bfbb2Smrg
404983e03a40Smrg    file=\"\$\$-\$program\"
4050357bfbb2Smrg
405183e03a40Smrg    if test ! -d \"\$progdir\"; then
405283e03a40Smrg      $MKDIR \"\$progdir\"
405383e03a40Smrg    else
405483e03a40Smrg      $RM \"\$progdir/\$file\"
405583e03a40Smrg    fi"
4056357bfbb2Smrg
405783e03a40Smrg	  $ECHO "\
4058357bfbb2Smrg
405983e03a40Smrg    # relink executable if necessary
406083e03a40Smrg    if test -n \"\$relink_command\"; then
406183e03a40Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
406283e03a40Smrg      else
406383e03a40Smrg	$ECHO \"\$relink_command_output\" >&2
406483e03a40Smrg	$RM \"\$progdir/\$file\"
406583e03a40Smrg	exit 1
406683e03a40Smrg      fi
406783e03a40Smrg    fi
4068357bfbb2Smrg
406983e03a40Smrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
407083e03a40Smrg    { $RM \"\$progdir/\$program\";
407183e03a40Smrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
407283e03a40Smrg    $RM \"\$progdir/\$file\"
407383e03a40Smrg  fi"
407483e03a40Smrg	else
407583e03a40Smrg	  $ECHO "\
407683e03a40Smrg  program='$outputname'
407783e03a40Smrg  progdir=\"\$thisdir/$objdir\"
407883e03a40Smrg"
4079357bfbb2Smrg	fi
4080357bfbb2Smrg
408183e03a40Smrg	$ECHO "\
4082357bfbb2Smrg
408383e03a40Smrg  if test -f \"\$progdir/\$program\"; then"
408483e03a40Smrg
408583e03a40Smrg	# fixup the dll searchpath if we need to.
408683e03a40Smrg	#
408783e03a40Smrg	# Fix the DLL searchpath if we need to.  Do this before prepending
408883e03a40Smrg	# to shlibpath, because on Windows, both are PATH and uninstalled
408983e03a40Smrg	# libraries must come first.
409083e03a40Smrg	if test -n "$dllsearchpath"; then
409183e03a40Smrg	  $ECHO "\
409283e03a40Smrg    # Add the dll search path components to the executable PATH
409383e03a40Smrg    PATH=$dllsearchpath:\$PATH
409483e03a40Smrg"
4095357bfbb2Smrg	fi
4096357bfbb2Smrg
409783e03a40Smrg	# Export our shlibpath_var if we have one.
409883e03a40Smrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
409983e03a40Smrg	  $ECHO "\
410083e03a40Smrg    # Add our own library path to $shlibpath_var
410183e03a40Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
4102357bfbb2Smrg
410383e03a40Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
410483e03a40Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
410583e03a40Smrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
4106357bfbb2Smrg
410783e03a40Smrg    export $shlibpath_var
410883e03a40Smrg"
410983e03a40Smrg	fi
4110357bfbb2Smrg
411183e03a40Smrg	$ECHO "\
411283e03a40Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
411383e03a40Smrg      # Run the actual program with our arguments.
411483e03a40Smrg      func_exec_program \${1+\"\$@\"}
411583e03a40Smrg    fi
411683e03a40Smrg  else
411783e03a40Smrg    # The program doesn't exist.
411883e03a40Smrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
411983e03a40Smrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
412083e03a40Smrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
412183e03a40Smrg    exit 1
412283e03a40Smrg  fi
412383e03a40Smrgfi\
412483e03a40Smrg"
412583e03a40Smrg}
4126357bfbb2Smrg
4127357bfbb2Smrg
412883e03a40Smrg# func_emit_cwrapperexe_src
412983e03a40Smrg# emit the source code for a wrapper executable on stdout
413083e03a40Smrg# Must ONLY be called from within func_mode_link because
413183e03a40Smrg# it depends on a number of variable set therein.
413283e03a40Smrgfunc_emit_cwrapperexe_src ()
413383e03a40Smrg{
413483e03a40Smrg	cat <<EOF
4135357bfbb2Smrg
413683e03a40Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
413783e03a40Smrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
4138357bfbb2Smrg
413983e03a40Smrg   The $output program cannot be directly executed until all the libtool
414083e03a40Smrg   libraries that it depends on are installed.
4141357bfbb2Smrg
414283e03a40Smrg   This wrapper executable should never be moved out of the build directory.
414383e03a40Smrg   If it is, it will not operate correctly.
414483e03a40Smrg*/
414583e03a40SmrgEOF
414683e03a40Smrg	    cat <<"EOF"
414783e03a40Smrg#ifdef _MSC_VER
414883e03a40Smrg# define _CRT_SECURE_NO_DEPRECATE 1
414983e03a40Smrg#endif
415083e03a40Smrg#include <stdio.h>
415183e03a40Smrg#include <stdlib.h>
415283e03a40Smrg#ifdef _MSC_VER
415383e03a40Smrg# include <direct.h>
415483e03a40Smrg# include <process.h>
415583e03a40Smrg# include <io.h>
415683e03a40Smrg#else
415783e03a40Smrg# include <unistd.h>
415883e03a40Smrg# include <stdint.h>
415983e03a40Smrg# ifdef __CYGWIN__
416083e03a40Smrg#  include <io.h>
416183e03a40Smrg# endif
416283e03a40Smrg#endif
416383e03a40Smrg#include <malloc.h>
416483e03a40Smrg#include <stdarg.h>
416583e03a40Smrg#include <assert.h>
416683e03a40Smrg#include <string.h>
416783e03a40Smrg#include <ctype.h>
416883e03a40Smrg#include <errno.h>
416983e03a40Smrg#include <fcntl.h>
417083e03a40Smrg#include <sys/stat.h>
4171357bfbb2Smrg
417283e03a40Smrg/* declarations of non-ANSI functions */
417383e03a40Smrg#if defined(__MINGW32__)
417483e03a40Smrg# ifdef __STRICT_ANSI__
417583e03a40Smrgint _putenv (const char *);
417683e03a40Smrg# endif
417783e03a40Smrg#elif defined(__CYGWIN__)
417883e03a40Smrg# ifdef __STRICT_ANSI__
417983e03a40Smrgchar *realpath (const char *, char *);
418083e03a40Smrgint putenv (char *);
418183e03a40Smrgint setenv (const char *, const char *, int);
418283e03a40Smrg# endif
418383e03a40Smrg/* #elif defined (other platforms) ... */
418483e03a40Smrg#endif
4185357bfbb2Smrg
418683e03a40Smrg/* portability defines, excluding path handling macros */
418783e03a40Smrg#if defined(_MSC_VER)
418883e03a40Smrg# define setmode _setmode
418983e03a40Smrg# define stat    _stat
419083e03a40Smrg# define chmod   _chmod
419183e03a40Smrg# define getcwd  _getcwd
419283e03a40Smrg# define putenv  _putenv
419383e03a40Smrg# define S_IXUSR _S_IEXEC
419483e03a40Smrg# ifndef _INTPTR_T_DEFINED
419583e03a40Smrg#  define _INTPTR_T_DEFINED
419683e03a40Smrg#  define intptr_t int
419783e03a40Smrg# endif
419883e03a40Smrg#elif defined(__MINGW32__)
419983e03a40Smrg# define setmode _setmode
420083e03a40Smrg# define stat    _stat
420183e03a40Smrg# define chmod   _chmod
420283e03a40Smrg# define getcwd  _getcwd
420383e03a40Smrg# define putenv  _putenv
420483e03a40Smrg#elif defined(__CYGWIN__)
420583e03a40Smrg# define HAVE_SETENV
420683e03a40Smrg# define FOPEN_WB "wb"
420783e03a40Smrg/* #elif defined (other platforms) ... */
420883e03a40Smrg#endif
4209357bfbb2Smrg
421083e03a40Smrg#if defined(PATH_MAX)
421183e03a40Smrg# define LT_PATHMAX PATH_MAX
421283e03a40Smrg#elif defined(MAXPATHLEN)
421383e03a40Smrg# define LT_PATHMAX MAXPATHLEN
421483e03a40Smrg#else
421583e03a40Smrg# define LT_PATHMAX 1024
421683e03a40Smrg#endif
4217357bfbb2Smrg
421883e03a40Smrg#ifndef S_IXOTH
421983e03a40Smrg# define S_IXOTH 0
422083e03a40Smrg#endif
422183e03a40Smrg#ifndef S_IXGRP
422283e03a40Smrg# define S_IXGRP 0
422383e03a40Smrg#endif
4224357bfbb2Smrg
422583e03a40Smrg/* path handling portability macros */
422683e03a40Smrg#ifndef DIR_SEPARATOR
422783e03a40Smrg# define DIR_SEPARATOR '/'
422883e03a40Smrg# define PATH_SEPARATOR ':'
422983e03a40Smrg#endif
4230357bfbb2Smrg
423183e03a40Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
423283e03a40Smrg  defined (__OS2__)
423383e03a40Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
423483e03a40Smrg# define FOPEN_WB "wb"
423583e03a40Smrg# ifndef DIR_SEPARATOR_2
423683e03a40Smrg#  define DIR_SEPARATOR_2 '\\'
423783e03a40Smrg# endif
423883e03a40Smrg# ifndef PATH_SEPARATOR_2
423983e03a40Smrg#  define PATH_SEPARATOR_2 ';'
424083e03a40Smrg# endif
424183e03a40Smrg#endif
4242357bfbb2Smrg
424383e03a40Smrg#ifndef DIR_SEPARATOR_2
424483e03a40Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
424583e03a40Smrg#else /* DIR_SEPARATOR_2 */
424683e03a40Smrg# define IS_DIR_SEPARATOR(ch) \
424783e03a40Smrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
424883e03a40Smrg#endif /* DIR_SEPARATOR_2 */
4249357bfbb2Smrg
425083e03a40Smrg#ifndef PATH_SEPARATOR_2
425183e03a40Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
425283e03a40Smrg#else /* PATH_SEPARATOR_2 */
425383e03a40Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
425483e03a40Smrg#endif /* PATH_SEPARATOR_2 */
4255357bfbb2Smrg
425683e03a40Smrg#ifndef FOPEN_WB
425783e03a40Smrg# define FOPEN_WB "w"
425883e03a40Smrg#endif
425983e03a40Smrg#ifndef _O_BINARY
426083e03a40Smrg# define _O_BINARY 0
426183e03a40Smrg#endif
4262357bfbb2Smrg
426383e03a40Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
426483e03a40Smrg#define XFREE(stale) do { \
426583e03a40Smrg  if (stale) { free ((void *) stale); stale = 0; } \
426683e03a40Smrg} while (0)
4267357bfbb2Smrg
426883e03a40Smrg#if defined(LT_DEBUGWRAPPER)
426983e03a40Smrgstatic int lt_debug = 1;
427083e03a40Smrg#else
427183e03a40Smrgstatic int lt_debug = 0;
427283e03a40Smrg#endif
4273357bfbb2Smrg
427483e03a40Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
427583e03a40Smrg
427683e03a40Smrgvoid *xmalloc (size_t num);
427783e03a40Smrgchar *xstrdup (const char *string);
427883e03a40Smrgconst char *base_name (const char *name);
427983e03a40Smrgchar *find_executable (const char *wrapper);
428083e03a40Smrgchar *chase_symlinks (const char *pathspec);
428183e03a40Smrgint make_executable (const char *path);
428283e03a40Smrgint check_executable (const char *path);
428383e03a40Smrgchar *strendzap (char *str, const char *pat);
428483e03a40Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
428583e03a40Smrgvoid lt_fatal (const char *file, int line, const char *message, ...);
428683e03a40Smrgstatic const char *nonnull (const char *s);
428783e03a40Smrgstatic const char *nonempty (const char *s);
428883e03a40Smrgvoid lt_setenv (const char *name, const char *value);
428983e03a40Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
429083e03a40Smrgvoid lt_update_exe_path (const char *name, const char *value);
429183e03a40Smrgvoid lt_update_lib_path (const char *name, const char *value);
429283e03a40Smrgchar **prepare_spawn (char **argv);
429383e03a40Smrgvoid lt_dump_script (FILE *f);
429483e03a40SmrgEOF
4295357bfbb2Smrg
429683e03a40Smrg	    cat <<EOF
429783e03a40Smrgvolatile const char * MAGIC_EXE = "$magic_exe";
429883e03a40Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
429983e03a40SmrgEOF
4300357bfbb2Smrg
430183e03a40Smrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
430283e03a40Smrg              func_to_host_path "$temp_rpath"
430383e03a40Smrg	      cat <<EOF
430483e03a40Smrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
430583e03a40SmrgEOF
430683e03a40Smrg	    else
430783e03a40Smrg	      cat <<"EOF"
430883e03a40Smrgconst char * LIB_PATH_VALUE   = "";
430983e03a40SmrgEOF
431083e03a40Smrg	    fi
4311357bfbb2Smrg
431283e03a40Smrg	    if test -n "$dllsearchpath"; then
431383e03a40Smrg              func_to_host_path "$dllsearchpath:"
431483e03a40Smrg	      cat <<EOF
431583e03a40Smrgconst char * EXE_PATH_VARNAME = "PATH";
431683e03a40Smrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
431783e03a40SmrgEOF
431883e03a40Smrg	    else
431983e03a40Smrg	      cat <<"EOF"
432083e03a40Smrgconst char * EXE_PATH_VARNAME = "";
432183e03a40Smrgconst char * EXE_PATH_VALUE   = "";
432283e03a40SmrgEOF
432383e03a40Smrg	    fi
4324357bfbb2Smrg
432583e03a40Smrg	    if test "$fast_install" = yes; then
432683e03a40Smrg	      cat <<EOF
432783e03a40Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
432883e03a40SmrgEOF
432983e03a40Smrg	    else
433083e03a40Smrg	      cat <<EOF
433183e03a40Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
433283e03a40SmrgEOF
433383e03a40Smrg	    fi
4334357bfbb2Smrg
4335357bfbb2Smrg
433683e03a40Smrg	    cat <<"EOF"
4337357bfbb2Smrg
433883e03a40Smrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
4339357bfbb2Smrg
434083e03a40Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
434183e03a40Smrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
434283e03a40Smrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
4343357bfbb2Smrg
434483e03a40Smrgint
434583e03a40Smrgmain (int argc, char *argv[])
434683e03a40Smrg{
434783e03a40Smrg  char **newargz;
434883e03a40Smrg  int  newargc;
434983e03a40Smrg  char *tmp_pathspec;
435083e03a40Smrg  char *actual_cwrapper_path;
435183e03a40Smrg  char *actual_cwrapper_name;
435283e03a40Smrg  char *target_name;
435383e03a40Smrg  char *lt_argv_zero;
435483e03a40Smrg  intptr_t rval = 127;
4355357bfbb2Smrg
435683e03a40Smrg  int i;
435783e03a40Smrg
435883e03a40Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
435983e03a40Smrg  newargz = XMALLOC (char *, argc + 1);
436083e03a40Smrg
436183e03a40Smrg  /* very simple arg parsing; don't want to rely on getopt
436283e03a40Smrg   * also, copy all non cwrapper options to newargz, except
436383e03a40Smrg   * argz[0], which is handled differently
436483e03a40Smrg   */
436583e03a40Smrg  newargc=0;
436683e03a40Smrg  for (i = 1; i < argc; i++)
436783e03a40Smrg    {
436883e03a40Smrg      if (strcmp (argv[i], dumpscript_opt) == 0)
436983e03a40Smrg	{
437083e03a40SmrgEOF
437183e03a40Smrg	    case "$host" in
437283e03a40Smrg	      *mingw* | *cygwin* )
437383e03a40Smrg		# make stdout use "unix" line endings
437483e03a40Smrg		echo "          setmode(1,_O_BINARY);"
4375357bfbb2Smrg		;;
4376357bfbb2Smrg	      esac
4377357bfbb2Smrg
437883e03a40Smrg	    cat <<"EOF"
437983e03a40Smrg	  lt_dump_script (stdout);
438083e03a40Smrg	  return 0;
438183e03a40Smrg	}
438283e03a40Smrg      if (strcmp (argv[i], debug_opt) == 0)
438383e03a40Smrg	{
438483e03a40Smrg          lt_debug = 1;
438583e03a40Smrg          continue;
438683e03a40Smrg	}
438783e03a40Smrg      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
438883e03a40Smrg        {
438983e03a40Smrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
439083e03a40Smrg             namespace, but it is not one of the ones we know about and
439183e03a40Smrg             have already dealt with, above (inluding dump-script), then
439283e03a40Smrg             report an error. Otherwise, targets might begin to believe
439383e03a40Smrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
439483e03a40Smrg             namespace. The first time any user complains about this, we'll
439583e03a40Smrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
439683e03a40Smrg             or a configure.ac-settable value.
439783e03a40Smrg           */
439883e03a40Smrg          lt_fatal (__FILE__, __LINE__,
439983e03a40Smrg		    "unrecognized %s option: '%s'",
440083e03a40Smrg                    ltwrapper_option_prefix, argv[i]);
440183e03a40Smrg        }
440283e03a40Smrg      /* otherwise ... */
440383e03a40Smrg      newargz[++newargc] = xstrdup (argv[i]);
440483e03a40Smrg    }
440583e03a40Smrg  newargz[++newargc] = NULL;
4406357bfbb2Smrg
440783e03a40SmrgEOF
440883e03a40Smrg	    cat <<EOF
440983e03a40Smrg  /* The GNU banner must be the first non-error debug message */
441083e03a40Smrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
441183e03a40SmrgEOF
441283e03a40Smrg	    cat <<"EOF"
441383e03a40Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
441483e03a40Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
441583e03a40Smrg
441683e03a40Smrg  tmp_pathspec = find_executable (argv[0]);
441783e03a40Smrg  if (tmp_pathspec == NULL)
441883e03a40Smrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
441983e03a40Smrg  lt_debugprintf (__FILE__, __LINE__,
442083e03a40Smrg                  "(main) found exe (before symlink chase) at: %s\n",
442183e03a40Smrg		  tmp_pathspec);
442283e03a40Smrg
442383e03a40Smrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
442483e03a40Smrg  lt_debugprintf (__FILE__, __LINE__,
442583e03a40Smrg                  "(main) found exe (after symlink chase) at: %s\n",
442683e03a40Smrg		  actual_cwrapper_path);
442783e03a40Smrg  XFREE (tmp_pathspec);
442883e03a40Smrg
442983e03a40Smrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
443083e03a40Smrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
443183e03a40Smrg
443283e03a40Smrg  /* wrapper name transforms */
443383e03a40Smrg  strendzap (actual_cwrapper_name, ".exe");
443483e03a40Smrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
443583e03a40Smrg  XFREE (actual_cwrapper_name);
443683e03a40Smrg  actual_cwrapper_name = tmp_pathspec;
443783e03a40Smrg  tmp_pathspec = 0;
443883e03a40Smrg
443983e03a40Smrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
444083e03a40Smrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
444183e03a40Smrg  strendzap (target_name, ".exe");
444283e03a40Smrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
444383e03a40Smrg  XFREE (target_name);
444483e03a40Smrg  target_name = tmp_pathspec;
444583e03a40Smrg  tmp_pathspec = 0;
444683e03a40Smrg
444783e03a40Smrg  lt_debugprintf (__FILE__, __LINE__,
444883e03a40Smrg		  "(main) libtool target name: %s\n",
444983e03a40Smrg		  target_name);
445083e03a40SmrgEOF
4451357bfbb2Smrg
445283e03a40Smrg	    cat <<EOF
445383e03a40Smrg  newargz[0] =
445483e03a40Smrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
445583e03a40Smrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
445683e03a40Smrg  strcpy (newargz[0], actual_cwrapper_path);
445783e03a40Smrg  strcat (newargz[0], "$objdir");
445883e03a40Smrg  strcat (newargz[0], "/");
445983e03a40SmrgEOF
4460357bfbb2Smrg
446183e03a40Smrg	    cat <<"EOF"
446283e03a40Smrg  /* stop here, and copy so we don't have to do this twice */
446383e03a40Smrg  tmp_pathspec = xstrdup (newargz[0]);
4464357bfbb2Smrg
446583e03a40Smrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
446683e03a40Smrg  strcat (newargz[0], actual_cwrapper_name);
4467357bfbb2Smrg
446883e03a40Smrg  /* DO want the lt- prefix here if it exists, so use target_name */
446983e03a40Smrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
447083e03a40Smrg  XFREE (tmp_pathspec);
447183e03a40Smrg  tmp_pathspec = NULL;
447283e03a40SmrgEOF
4473357bfbb2Smrg
447483e03a40Smrg	    case $host_os in
447583e03a40Smrg	      mingw*)
447683e03a40Smrg	    cat <<"EOF"
447783e03a40Smrg  {
447883e03a40Smrg    char* p;
447983e03a40Smrg    while ((p = strchr (newargz[0], '\\')) != NULL)
448083e03a40Smrg      {
448183e03a40Smrg	*p = '/';
448283e03a40Smrg      }
448383e03a40Smrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
448483e03a40Smrg      {
448583e03a40Smrg	*p = '/';
448683e03a40Smrg      }
448783e03a40Smrg  }
448883e03a40SmrgEOF
448983e03a40Smrg	    ;;
449083e03a40Smrg	    esac
4491357bfbb2Smrg
449283e03a40Smrg	    cat <<"EOF"
449383e03a40Smrg  XFREE (target_name);
449483e03a40Smrg  XFREE (actual_cwrapper_path);
449583e03a40Smrg  XFREE (actual_cwrapper_name);
449683e03a40Smrg
449783e03a40Smrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
449883e03a40Smrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
449983e03a40Smrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
450083e03a40Smrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
450183e03a40Smrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
450283e03a40Smrg     libraries must come first. */
450383e03a40Smrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
450483e03a40Smrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
450583e03a40Smrg
450683e03a40Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
450783e03a40Smrg		  nonnull (lt_argv_zero));
450883e03a40Smrg  for (i = 0; i < newargc; i++)
450983e03a40Smrg    {
451083e03a40Smrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
451183e03a40Smrg		      i, nonnull (newargz[i]));
451283e03a40Smrg    }
4513357bfbb2Smrg
451483e03a40SmrgEOF
4515357bfbb2Smrg
451683e03a40Smrg	    case $host_os in
451783e03a40Smrg	      mingw*)
451883e03a40Smrg		cat <<"EOF"
451983e03a40Smrg  /* execv doesn't actually work on mingw as expected on unix */
452083e03a40Smrg  newargz = prepare_spawn (newargz);
452183e03a40Smrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
452283e03a40Smrg  if (rval == -1)
452383e03a40Smrg    {
452483e03a40Smrg      /* failed to start process */
452583e03a40Smrg      lt_debugprintf (__FILE__, __LINE__,
452683e03a40Smrg		      "(main) failed to launch target \"%s\": %s\n",
452783e03a40Smrg		      lt_argv_zero, nonnull (strerror (errno)));
452883e03a40Smrg      return 127;
452983e03a40Smrg    }
453083e03a40Smrg  return rval;
453183e03a40SmrgEOF
453283e03a40Smrg		;;
453383e03a40Smrg	      *)
453483e03a40Smrg		cat <<"EOF"
453583e03a40Smrg  execv (lt_argv_zero, newargz);
453683e03a40Smrg  return rval; /* =127, but avoids unused variable warning */
453783e03a40SmrgEOF
453883e03a40Smrg		;;
453983e03a40Smrg	    esac
4540357bfbb2Smrg
454183e03a40Smrg	    cat <<"EOF"
454283e03a40Smrg}
4543357bfbb2Smrg
454483e03a40Smrgvoid *
454583e03a40Smrgxmalloc (size_t num)
454683e03a40Smrg{
454783e03a40Smrg  void *p = (void *) malloc (num);
454883e03a40Smrg  if (!p)
454983e03a40Smrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
4550357bfbb2Smrg
455183e03a40Smrg  return p;
455283e03a40Smrg}
4553357bfbb2Smrg
455483e03a40Smrgchar *
455583e03a40Smrgxstrdup (const char *string)
455683e03a40Smrg{
455783e03a40Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
455883e03a40Smrg			  string) : NULL;
455983e03a40Smrg}
4560357bfbb2Smrg
456183e03a40Smrgconst char *
456283e03a40Smrgbase_name (const char *name)
456383e03a40Smrg{
456483e03a40Smrg  const char *base;
4565357bfbb2Smrg
456683e03a40Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
456783e03a40Smrg  /* Skip over the disk name in MSDOS pathnames. */
456883e03a40Smrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
456983e03a40Smrg    name += 2;
457083e03a40Smrg#endif
4571357bfbb2Smrg
457283e03a40Smrg  for (base = name; *name; name++)
457383e03a40Smrg    if (IS_DIR_SEPARATOR (*name))
457483e03a40Smrg      base = name + 1;
457583e03a40Smrg  return base;
457683e03a40Smrg}
4577357bfbb2Smrg
457883e03a40Smrgint
457983e03a40Smrgcheck_executable (const char *path)
458083e03a40Smrg{
458183e03a40Smrg  struct stat st;
4582357bfbb2Smrg
458383e03a40Smrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
458483e03a40Smrg                  nonempty (path));
458583e03a40Smrg  if ((!path) || (!*path))
458683e03a40Smrg    return 0;
4587357bfbb2Smrg
458883e03a40Smrg  if ((stat (path, &st) >= 0)
458983e03a40Smrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
459083e03a40Smrg    return 1;
459183e03a40Smrg  else
459283e03a40Smrg    return 0;
459383e03a40Smrg}
4594357bfbb2Smrg
459583e03a40Smrgint
459683e03a40Smrgmake_executable (const char *path)
459783e03a40Smrg{
459883e03a40Smrg  int rval = 0;
459983e03a40Smrg  struct stat st;
4600357bfbb2Smrg
460183e03a40Smrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
460283e03a40Smrg                  nonempty (path));
460383e03a40Smrg  if ((!path) || (!*path))
460483e03a40Smrg    return 0;
4605357bfbb2Smrg
460683e03a40Smrg  if (stat (path, &st) >= 0)
460783e03a40Smrg    {
460883e03a40Smrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
460983e03a40Smrg    }
461083e03a40Smrg  return rval;
461183e03a40Smrg}
4612357bfbb2Smrg
461383e03a40Smrg/* Searches for the full path of the wrapper.  Returns
461483e03a40Smrg   newly allocated full path name if found, NULL otherwise
461583e03a40Smrg   Does not chase symlinks, even on platforms that support them.
461683e03a40Smrg*/
461783e03a40Smrgchar *
461883e03a40Smrgfind_executable (const char *wrapper)
461983e03a40Smrg{
462083e03a40Smrg  int has_slash = 0;
462183e03a40Smrg  const char *p;
462283e03a40Smrg  const char *p_next;
462383e03a40Smrg  /* static buffer for getcwd */
462483e03a40Smrg  char tmp[LT_PATHMAX + 1];
462583e03a40Smrg  int tmp_len;
462683e03a40Smrg  char *concat_name;
4627357bfbb2Smrg
462883e03a40Smrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
462983e03a40Smrg                  nonempty (wrapper));
4630357bfbb2Smrg
463183e03a40Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
463283e03a40Smrg    return NULL;
4633357bfbb2Smrg
463483e03a40Smrg  /* Absolute path? */
463583e03a40Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
463683e03a40Smrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
463783e03a40Smrg    {
463883e03a40Smrg      concat_name = xstrdup (wrapper);
463983e03a40Smrg      if (check_executable (concat_name))
464083e03a40Smrg	return concat_name;
464183e03a40Smrg      XFREE (concat_name);
464283e03a40Smrg    }
464383e03a40Smrg  else
464483e03a40Smrg    {
464583e03a40Smrg#endif
464683e03a40Smrg      if (IS_DIR_SEPARATOR (wrapper[0]))
464783e03a40Smrg	{
464883e03a40Smrg	  concat_name = xstrdup (wrapper);
464983e03a40Smrg	  if (check_executable (concat_name))
465083e03a40Smrg	    return concat_name;
465183e03a40Smrg	  XFREE (concat_name);
465283e03a40Smrg	}
465383e03a40Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
465483e03a40Smrg    }
465583e03a40Smrg#endif
4656357bfbb2Smrg
465783e03a40Smrg  for (p = wrapper; *p; p++)
465883e03a40Smrg    if (*p == '/')
465983e03a40Smrg      {
466083e03a40Smrg	has_slash = 1;
466183e03a40Smrg	break;
466283e03a40Smrg      }
466383e03a40Smrg  if (!has_slash)
466483e03a40Smrg    {
466583e03a40Smrg      /* no slashes; search PATH */
466683e03a40Smrg      const char *path = getenv ("PATH");
466783e03a40Smrg      if (path != NULL)
466883e03a40Smrg	{
466983e03a40Smrg	  for (p = path; *p; p = p_next)
467083e03a40Smrg	    {
467183e03a40Smrg	      const char *q;
467283e03a40Smrg	      size_t p_len;
467383e03a40Smrg	      for (q = p; *q; q++)
467483e03a40Smrg		if (IS_PATH_SEPARATOR (*q))
467583e03a40Smrg		  break;
467683e03a40Smrg	      p_len = q - p;
467783e03a40Smrg	      p_next = (*q == '\0' ? q : q + 1);
467883e03a40Smrg	      if (p_len == 0)
467983e03a40Smrg		{
468083e03a40Smrg		  /* empty path: current directory */
468183e03a40Smrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
468283e03a40Smrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
468383e03a40Smrg                              nonnull (strerror (errno)));
468483e03a40Smrg		  tmp_len = strlen (tmp);
468583e03a40Smrg		  concat_name =
468683e03a40Smrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
468783e03a40Smrg		  memcpy (concat_name, tmp, tmp_len);
468883e03a40Smrg		  concat_name[tmp_len] = '/';
468983e03a40Smrg		  strcpy (concat_name + tmp_len + 1, wrapper);
469083e03a40Smrg		}
469183e03a40Smrg	      else
469283e03a40Smrg		{
469383e03a40Smrg		  concat_name =
469483e03a40Smrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
469583e03a40Smrg		  memcpy (concat_name, p, p_len);
469683e03a40Smrg		  concat_name[p_len] = '/';
469783e03a40Smrg		  strcpy (concat_name + p_len + 1, wrapper);
469883e03a40Smrg		}
469983e03a40Smrg	      if (check_executable (concat_name))
470083e03a40Smrg		return concat_name;
470183e03a40Smrg	      XFREE (concat_name);
470283e03a40Smrg	    }
470383e03a40Smrg	}
470483e03a40Smrg      /* not found in PATH; assume curdir */
470583e03a40Smrg    }
470683e03a40Smrg  /* Relative path | not found in path: prepend cwd */
470783e03a40Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
470883e03a40Smrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
470983e03a40Smrg              nonnull (strerror (errno)));
471083e03a40Smrg  tmp_len = strlen (tmp);
471183e03a40Smrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
471283e03a40Smrg  memcpy (concat_name, tmp, tmp_len);
471383e03a40Smrg  concat_name[tmp_len] = '/';
471483e03a40Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
471583e03a40Smrg
471683e03a40Smrg  if (check_executable (concat_name))
471783e03a40Smrg    return concat_name;
471883e03a40Smrg  XFREE (concat_name);
471983e03a40Smrg  return NULL;
4720357bfbb2Smrg}
4721357bfbb2Smrg
472283e03a40Smrgchar *
472383e03a40Smrgchase_symlinks (const char *pathspec)
472483e03a40Smrg{
472583e03a40Smrg#ifndef S_ISLNK
472683e03a40Smrg  return xstrdup (pathspec);
472783e03a40Smrg#else
472883e03a40Smrg  char buf[LT_PATHMAX];
472983e03a40Smrg  struct stat s;
473083e03a40Smrg  char *tmp_pathspec = xstrdup (pathspec);
473183e03a40Smrg  char *p;
473283e03a40Smrg  int has_symlinks = 0;
473383e03a40Smrg  while (strlen (tmp_pathspec) && !has_symlinks)
473483e03a40Smrg    {
473583e03a40Smrg      lt_debugprintf (__FILE__, __LINE__,
473683e03a40Smrg		      "checking path component for symlinks: %s\n",
473783e03a40Smrg		      tmp_pathspec);
473883e03a40Smrg      if (lstat (tmp_pathspec, &s) == 0)
473983e03a40Smrg	{
474083e03a40Smrg	  if (S_ISLNK (s.st_mode) != 0)
474183e03a40Smrg	    {
474283e03a40Smrg	      has_symlinks = 1;
474383e03a40Smrg	      break;
474483e03a40Smrg	    }
4745357bfbb2Smrg
474683e03a40Smrg	  /* search backwards for last DIR_SEPARATOR */
474783e03a40Smrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
474883e03a40Smrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
474983e03a40Smrg	    p--;
475083e03a40Smrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
475183e03a40Smrg	    {
475283e03a40Smrg	      /* no more DIR_SEPARATORS left */
475383e03a40Smrg	      break;
475483e03a40Smrg	    }
475583e03a40Smrg	  *p = '\0';
475683e03a40Smrg	}
475783e03a40Smrg      else
475883e03a40Smrg	{
475983e03a40Smrg	  lt_fatal (__FILE__, __LINE__,
476083e03a40Smrg		    "error accessing file \"%s\": %s",
476183e03a40Smrg		    tmp_pathspec, nonnull (strerror (errno)));
476283e03a40Smrg	}
476383e03a40Smrg    }
476483e03a40Smrg  XFREE (tmp_pathspec);
4765357bfbb2Smrg
476683e03a40Smrg  if (!has_symlinks)
476783e03a40Smrg    {
476883e03a40Smrg      return xstrdup (pathspec);
476983e03a40Smrg    }
4770357bfbb2Smrg
477183e03a40Smrg  tmp_pathspec = realpath (pathspec, buf);
477283e03a40Smrg  if (tmp_pathspec == 0)
477383e03a40Smrg    {
477483e03a40Smrg      lt_fatal (__FILE__, __LINE__,
477583e03a40Smrg		"could not follow symlinks for %s", pathspec);
477683e03a40Smrg    }
477783e03a40Smrg  return xstrdup (tmp_pathspec);
477883e03a40Smrg#endif
4779357bfbb2Smrg}
4780357bfbb2Smrg
478183e03a40Smrgchar *
478283e03a40Smrgstrendzap (char *str, const char *pat)
478383e03a40Smrg{
478483e03a40Smrg  size_t len, patlen;
4785357bfbb2Smrg
478683e03a40Smrg  assert (str != NULL);
478783e03a40Smrg  assert (pat != NULL);
4788357bfbb2Smrg
478983e03a40Smrg  len = strlen (str);
479083e03a40Smrg  patlen = strlen (pat);
4791357bfbb2Smrg
479283e03a40Smrg  if (patlen <= len)
479383e03a40Smrg    {
479483e03a40Smrg      str += len - patlen;
479583e03a40Smrg      if (strcmp (str, pat) == 0)
479683e03a40Smrg	*str = '\0';
479783e03a40Smrg    }
479883e03a40Smrg  return str;
479983e03a40Smrg}
4800357bfbb2Smrg
480183e03a40Smrgvoid
480283e03a40Smrglt_debugprintf (const char *file, int line, const char *fmt, ...)
480383e03a40Smrg{
480483e03a40Smrg  va_list args;
480583e03a40Smrg  if (lt_debug)
480683e03a40Smrg    {
480783e03a40Smrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
480883e03a40Smrg      va_start (args, fmt);
480983e03a40Smrg      (void) vfprintf (stderr, fmt, args);
481083e03a40Smrg      va_end (args);
481183e03a40Smrg    }
481283e03a40Smrg}
4813357bfbb2Smrg
481483e03a40Smrgstatic void
481583e03a40Smrglt_error_core (int exit_status, const char *file,
481683e03a40Smrg	       int line, const char *mode,
481783e03a40Smrg	       const char *message, va_list ap)
481883e03a40Smrg{
481983e03a40Smrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
482083e03a40Smrg  vfprintf (stderr, message, ap);
482183e03a40Smrg  fprintf (stderr, ".\n");
4822357bfbb2Smrg
482383e03a40Smrg  if (exit_status >= 0)
482483e03a40Smrg    exit (exit_status);
482583e03a40Smrg}
4826357bfbb2Smrg
482783e03a40Smrgvoid
482883e03a40Smrglt_fatal (const char *file, int line, const char *message, ...)
482983e03a40Smrg{
483083e03a40Smrg  va_list ap;
483183e03a40Smrg  va_start (ap, message);
483283e03a40Smrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
483383e03a40Smrg  va_end (ap);
483483e03a40Smrg}
4835357bfbb2Smrg
483683e03a40Smrgstatic const char *
483783e03a40Smrgnonnull (const char *s)
483883e03a40Smrg{
483983e03a40Smrg  return s ? s : "(null)";
484083e03a40Smrg}
4841357bfbb2Smrg
484283e03a40Smrgstatic const char *
484383e03a40Smrgnonempty (const char *s)
484483e03a40Smrg{
484583e03a40Smrg  return (s && !*s) ? "(empty)" : nonnull (s);
484683e03a40Smrg}
4847357bfbb2Smrg
484883e03a40Smrgvoid
484983e03a40Smrglt_setenv (const char *name, const char *value)
485083e03a40Smrg{
485183e03a40Smrg  lt_debugprintf (__FILE__, __LINE__,
485283e03a40Smrg		  "(lt_setenv) setting '%s' to '%s'\n",
485383e03a40Smrg                  nonnull (name), nonnull (value));
485483e03a40Smrg  {
485583e03a40Smrg#ifdef HAVE_SETENV
485683e03a40Smrg    /* always make a copy, for consistency with !HAVE_SETENV */
485783e03a40Smrg    char *str = xstrdup (value);
485883e03a40Smrg    setenv (name, str, 1);
4859357bfbb2Smrg#else
486083e03a40Smrg    int len = strlen (name) + 1 + strlen (value) + 1;
486183e03a40Smrg    char *str = XMALLOC (char, len);
486283e03a40Smrg    sprintf (str, "%s=%s", name, value);
486383e03a40Smrg    if (putenv (str) != EXIT_SUCCESS)
486483e03a40Smrg      {
486583e03a40Smrg        XFREE (str);
486683e03a40Smrg      }
4867357bfbb2Smrg#endif
486883e03a40Smrg  }
486983e03a40Smrg}
4870357bfbb2Smrg
487183e03a40Smrgchar *
487283e03a40Smrglt_extend_str (const char *orig_value, const char *add, int to_end)
487383e03a40Smrg{
487483e03a40Smrg  char *new_value;
487583e03a40Smrg  if (orig_value && *orig_value)
487683e03a40Smrg    {
487783e03a40Smrg      int orig_value_len = strlen (orig_value);
487883e03a40Smrg      int add_len = strlen (add);
487983e03a40Smrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
488083e03a40Smrg      if (to_end)
488183e03a40Smrg        {
488283e03a40Smrg          strcpy (new_value, orig_value);
488383e03a40Smrg          strcpy (new_value + orig_value_len, add);
488483e03a40Smrg        }
488583e03a40Smrg      else
488683e03a40Smrg        {
488783e03a40Smrg          strcpy (new_value, add);
488883e03a40Smrg          strcpy (new_value + add_len, orig_value);
488983e03a40Smrg        }
489083e03a40Smrg    }
489183e03a40Smrg  else
489283e03a40Smrg    {
489383e03a40Smrg      new_value = xstrdup (add);
489483e03a40Smrg    }
489583e03a40Smrg  return new_value;
489683e03a40Smrg}
4897357bfbb2Smrg
489883e03a40Smrgvoid
489983e03a40Smrglt_update_exe_path (const char *name, const char *value)
490083e03a40Smrg{
490183e03a40Smrg  lt_debugprintf (__FILE__, __LINE__,
490283e03a40Smrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
490383e03a40Smrg                  nonnull (name), nonnull (value));
4904357bfbb2Smrg
490583e03a40Smrg  if (name && *name && value && *value)
490683e03a40Smrg    {
490783e03a40Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
490883e03a40Smrg      /* some systems can't cope with a ':'-terminated path #' */
490983e03a40Smrg      int len = strlen (new_value);
491083e03a40Smrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
491183e03a40Smrg        {
491283e03a40Smrg          new_value[len-1] = '\0';
491383e03a40Smrg        }
491483e03a40Smrg      lt_setenv (name, new_value);
491583e03a40Smrg      XFREE (new_value);
491683e03a40Smrg    }
491783e03a40Smrg}
4918357bfbb2Smrg
491983e03a40Smrgvoid
492083e03a40Smrglt_update_lib_path (const char *name, const char *value)
4921357bfbb2Smrg{
492283e03a40Smrg  lt_debugprintf (__FILE__, __LINE__,
492383e03a40Smrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
492483e03a40Smrg                  nonnull (name), nonnull (value));
4925357bfbb2Smrg
492683e03a40Smrg  if (name && *name && value && *value)
492783e03a40Smrg    {
492883e03a40Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
492983e03a40Smrg      lt_setenv (name, new_value);
493083e03a40Smrg      XFREE (new_value);
493183e03a40Smrg    }
493283e03a40Smrg}
4933357bfbb2Smrg
4934357bfbb2SmrgEOF
493583e03a40Smrg	    case $host_os in
493683e03a40Smrg	      mingw*)
493783e03a40Smrg		cat <<"EOF"
493883e03a40Smrg
493983e03a40Smrg/* Prepares an argument vector before calling spawn().
494083e03a40Smrg   Note that spawn() does not by itself call the command interpreter
494183e03a40Smrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
494283e03a40Smrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
494383e03a40Smrg         GetVersionEx(&v);
494483e03a40Smrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
494583e03a40Smrg      }) ? "cmd.exe" : "command.com").
494683e03a40Smrg   Instead it simply concatenates the arguments, separated by ' ', and calls
494783e03a40Smrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
494883e03a40Smrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
494983e03a40Smrg   special way:
495083e03a40Smrg   - Space and tab are interpreted as delimiters. They are not treated as
495183e03a40Smrg     delimiters if they are surrounded by double quotes: "...".
495283e03a40Smrg   - Unescaped double quotes are removed from the input. Their only effect is
495383e03a40Smrg     that within double quotes, space and tab are treated like normal
495483e03a40Smrg     characters.
495583e03a40Smrg   - Backslashes not followed by double quotes are not special.
495683e03a40Smrg   - But 2*n+1 backslashes followed by a double quote become
495783e03a40Smrg     n backslashes followed by a double quote (n >= 0):
495883e03a40Smrg       \" -> "
495983e03a40Smrg       \\\" -> \"
496083e03a40Smrg       \\\\\" -> \\"
496183e03a40Smrg */
496283e03a40Smrg#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"
496383e03a40Smrg#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"
496483e03a40Smrgchar **
496583e03a40Smrgprepare_spawn (char **argv)
496683e03a40Smrg{
496783e03a40Smrg  size_t argc;
496883e03a40Smrg  char **new_argv;
496983e03a40Smrg  size_t i;
4970357bfbb2Smrg
497183e03a40Smrg  /* Count number of arguments.  */
497283e03a40Smrg  for (argc = 0; argv[argc] != NULL; argc++)
4973357bfbb2Smrg    ;
4974357bfbb2Smrg
497583e03a40Smrg  /* Allocate new argument vector.  */
497683e03a40Smrg  new_argv = XMALLOC (char *, argc + 1);
4977357bfbb2Smrg
497883e03a40Smrg  /* Put quoted arguments into the new argument vector.  */
497983e03a40Smrg  for (i = 0; i < argc; i++)
498083e03a40Smrg    {
498183e03a40Smrg      const char *string = argv[i];
498283e03a40Smrg
498383e03a40Smrg      if (string[0] == '\0')
498483e03a40Smrg	new_argv[i] = xstrdup ("\"\"");
498583e03a40Smrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
498683e03a40Smrg	{
498783e03a40Smrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
498883e03a40Smrg	  size_t length;
498983e03a40Smrg	  unsigned int backslashes;
499083e03a40Smrg	  const char *s;
499183e03a40Smrg	  char *quoted_string;
499283e03a40Smrg	  char *p;
499383e03a40Smrg
499483e03a40Smrg	  length = 0;
499583e03a40Smrg	  backslashes = 0;
499683e03a40Smrg	  if (quote_around)
499783e03a40Smrg	    length++;
499883e03a40Smrg	  for (s = string; *s != '\0'; s++)
499983e03a40Smrg	    {
500083e03a40Smrg	      char c = *s;
500183e03a40Smrg	      if (c == '"')
500283e03a40Smrg		length += backslashes + 1;
500383e03a40Smrg	      length++;
500483e03a40Smrg	      if (c == '\\')
500583e03a40Smrg		backslashes++;
500683e03a40Smrg	      else
500783e03a40Smrg		backslashes = 0;
500883e03a40Smrg	    }
500983e03a40Smrg	  if (quote_around)
501083e03a40Smrg	    length += backslashes + 1;
501183e03a40Smrg
501283e03a40Smrg	  quoted_string = XMALLOC (char, length + 1);
501383e03a40Smrg
501483e03a40Smrg	  p = quoted_string;
501583e03a40Smrg	  backslashes = 0;
501683e03a40Smrg	  if (quote_around)
501783e03a40Smrg	    *p++ = '"';
501883e03a40Smrg	  for (s = string; *s != '\0'; s++)
501983e03a40Smrg	    {
502083e03a40Smrg	      char c = *s;
502183e03a40Smrg	      if (c == '"')
502283e03a40Smrg		{
502383e03a40Smrg		  unsigned int j;
502483e03a40Smrg		  for (j = backslashes + 1; j > 0; j--)
502583e03a40Smrg		    *p++ = '\\';
502683e03a40Smrg		}
502783e03a40Smrg	      *p++ = c;
502883e03a40Smrg	      if (c == '\\')
502983e03a40Smrg		backslashes++;
503083e03a40Smrg	      else
503183e03a40Smrg		backslashes = 0;
503283e03a40Smrg	    }
503383e03a40Smrg	  if (quote_around)
503483e03a40Smrg	    {
503583e03a40Smrg	      unsigned int j;
503683e03a40Smrg	      for (j = backslashes; j > 0; j--)
503783e03a40Smrg		*p++ = '\\';
503883e03a40Smrg	      *p++ = '"';
503983e03a40Smrg	    }
504083e03a40Smrg	  *p = '\0';
5041357bfbb2Smrg
504283e03a40Smrg	  new_argv[i] = quoted_string;
504383e03a40Smrg	}
504483e03a40Smrg      else
504583e03a40Smrg	new_argv[i] = (char *) string;
504683e03a40Smrg    }
504783e03a40Smrg  new_argv[argc] = NULL;
504883e03a40Smrg
504983e03a40Smrg  return new_argv;
5050357bfbb2Smrg}
505183e03a40SmrgEOF
505283e03a40Smrg		;;
505383e03a40Smrg	    esac
5054357bfbb2Smrg
505583e03a40Smrg            cat <<"EOF"
505683e03a40Smrgvoid lt_dump_script (FILE* f)
5057357bfbb2Smrg{
505883e03a40SmrgEOF
505983e03a40Smrg	    func_emit_wrapper yes |
506083e03a40Smrg              $SED -e 's/\([\\"]\)/\\\1/g' \
506183e03a40Smrg	           -e 's/^/  fputs ("/' -e 's/$/\\n", f);/'
5062357bfbb2Smrg
506383e03a40Smrg            cat <<"EOF"
5064357bfbb2Smrg}
506583e03a40SmrgEOF
5066357bfbb2Smrg}
506783e03a40Smrg# end: func_emit_cwrapperexe_src
5068357bfbb2Smrg
506983e03a40Smrg# func_win32_import_lib_p ARG
507083e03a40Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd
507183e03a40Smrgfunc_win32_import_lib_p ()
5072357bfbb2Smrg{
507383e03a40Smrg    $opt_debug
507483e03a40Smrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
507583e03a40Smrg    *import*) : ;;
507683e03a40Smrg    *) false ;;
507783e03a40Smrg    esac
5078357bfbb2Smrg}
5079357bfbb2Smrg
508083e03a40Smrg# func_mode_link arg...
508183e03a40Smrgfunc_mode_link ()
5082357bfbb2Smrg{
508383e03a40Smrg    $opt_debug
508483e03a40Smrg    case $host in
508583e03a40Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
508683e03a40Smrg      # It is impossible to link a dll without this setting, and
508783e03a40Smrg      # we shouldn't force the makefile maintainer to figure out
508883e03a40Smrg      # which system we are compiling for in order to pass an extra
508983e03a40Smrg      # flag for every libtool invocation.
509083e03a40Smrg      # allow_undefined=no
5091357bfbb2Smrg
509283e03a40Smrg      # FIXME: Unfortunately, there are problems with the above when trying
509383e03a40Smrg      # to make a dll which has undefined symbols, in which case not
509483e03a40Smrg      # even a static library is built.  For now, we need to specify
509583e03a40Smrg      # -no-undefined on the libtool link line when we can be certain
509683e03a40Smrg      # that all symbols are satisfied, otherwise we get a static library.
509783e03a40Smrg      allow_undefined=yes
509883e03a40Smrg      ;;
509983e03a40Smrg    *)
510083e03a40Smrg      allow_undefined=yes
510183e03a40Smrg      ;;
510283e03a40Smrg    esac
510383e03a40Smrg    libtool_args=$nonopt
510483e03a40Smrg    base_compile="$nonopt $@"
510583e03a40Smrg    compile_command=$nonopt
510683e03a40Smrg    finalize_command=$nonopt
5107357bfbb2Smrg
510883e03a40Smrg    compile_rpath=
510983e03a40Smrg    finalize_rpath=
511083e03a40Smrg    compile_shlibpath=
511183e03a40Smrg    finalize_shlibpath=
511283e03a40Smrg    convenience=
511383e03a40Smrg    old_convenience=
511483e03a40Smrg    deplibs=
511583e03a40Smrg    old_deplibs=
511683e03a40Smrg    compiler_flags=
511783e03a40Smrg    linker_flags=
511883e03a40Smrg    dllsearchpath=
511983e03a40Smrg    lib_search_path=`pwd`
512083e03a40Smrg    inst_prefix_dir=
512183e03a40Smrg    new_inherited_linker_flags=
5122357bfbb2Smrg
512383e03a40Smrg    avoid_version=no
512483e03a40Smrg    bindir=
512583e03a40Smrg    dlfiles=
512683e03a40Smrg    dlprefiles=
512783e03a40Smrg    dlself=no
512883e03a40Smrg    export_dynamic=no
512983e03a40Smrg    export_symbols=
513083e03a40Smrg    export_symbols_regex=
513183e03a40Smrg    generated=
513283e03a40Smrg    libobjs=
513383e03a40Smrg    ltlibs=
513483e03a40Smrg    module=no
513583e03a40Smrg    no_install=no
513683e03a40Smrg    objs=
513783e03a40Smrg    non_pic_objects=
513883e03a40Smrg    precious_files_regex=
513983e03a40Smrg    prefer_static_libs=no
514083e03a40Smrg    preload=no
514183e03a40Smrg    prev=
514283e03a40Smrg    prevarg=
514383e03a40Smrg    release=
514483e03a40Smrg    rpath=
514583e03a40Smrg    xrpath=
514683e03a40Smrg    perm_rpath=
514783e03a40Smrg    temp_rpath=
514883e03a40Smrg    thread_safe=no
514983e03a40Smrg    vinfo=
515083e03a40Smrg    vinfo_number=no
515183e03a40Smrg    weak_libs=
515283e03a40Smrg    single_module="${wl}-single_module"
515383e03a40Smrg    func_infer_tag $base_compile
5154357bfbb2Smrg
515583e03a40Smrg    # We need to know -static, to get the right output filenames.
515683e03a40Smrg    for arg
515783e03a40Smrg    do
515883e03a40Smrg      case $arg in
515983e03a40Smrg      -shared)
516083e03a40Smrg	test "$build_libtool_libs" != yes && \
516183e03a40Smrg	  func_fatal_configuration "can not build a shared library"
516283e03a40Smrg	build_old_libs=no
516383e03a40Smrg	break
516483e03a40Smrg	;;
516583e03a40Smrg      -all-static | -static | -static-libtool-libs)
516683e03a40Smrg	case $arg in
516783e03a40Smrg	-all-static)
516883e03a40Smrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
516983e03a40Smrg	    func_warning "complete static linking is impossible in this configuration"
517083e03a40Smrg	  fi
517183e03a40Smrg	  if test -n "$link_static_flag"; then
517283e03a40Smrg	    dlopen_self=$dlopen_self_static
517383e03a40Smrg	  fi
517483e03a40Smrg	  prefer_static_libs=yes
517583e03a40Smrg	  ;;
517683e03a40Smrg	-static)
517783e03a40Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
517883e03a40Smrg	    dlopen_self=$dlopen_self_static
517983e03a40Smrg	  fi
518083e03a40Smrg	  prefer_static_libs=built
518183e03a40Smrg	  ;;
518283e03a40Smrg	-static-libtool-libs)
518383e03a40Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
518483e03a40Smrg	    dlopen_self=$dlopen_self_static
518583e03a40Smrg	  fi
518683e03a40Smrg	  prefer_static_libs=yes
518783e03a40Smrg	  ;;
518883e03a40Smrg	esac
518983e03a40Smrg	build_libtool_libs=no
519083e03a40Smrg	build_old_libs=yes
519183e03a40Smrg	break
519283e03a40Smrg	;;
519383e03a40Smrg      esac
519483e03a40Smrg    done
5195357bfbb2Smrg
519683e03a40Smrg    # See if our shared archives depend on static archives.
519783e03a40Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
5198357bfbb2Smrg
519983e03a40Smrg    # Go through the arguments, transforming them on the way.
520083e03a40Smrg    while test "$#" -gt 0; do
520183e03a40Smrg      arg="$1"
520283e03a40Smrg      shift
520383e03a40Smrg      func_quote_for_eval "$arg"
520483e03a40Smrg      qarg=$func_quote_for_eval_unquoted_result
520583e03a40Smrg      func_append libtool_args " $func_quote_for_eval_result"
5206357bfbb2Smrg
520783e03a40Smrg      # If the previous option needs an argument, assign it.
520883e03a40Smrg      if test -n "$prev"; then
520983e03a40Smrg	case $prev in
521083e03a40Smrg	output)
521183e03a40Smrg	  func_append compile_command " @OUTPUT@"
521283e03a40Smrg	  func_append finalize_command " @OUTPUT@"
521383e03a40Smrg	  ;;
521483e03a40Smrg	esac
5215357bfbb2Smrg
521683e03a40Smrg	case $prev in
521783e03a40Smrg	bindir)
521883e03a40Smrg	  bindir="$arg"
521983e03a40Smrg	  prev=
522083e03a40Smrg	  continue
522183e03a40Smrg	  ;;
522283e03a40Smrg	dlfiles|dlprefiles)
522383e03a40Smrg	  if test "$preload" = no; then
522483e03a40Smrg	    # Add the symbol object into the linking commands.
522583e03a40Smrg	    func_append compile_command " @SYMFILE@"
522683e03a40Smrg	    func_append finalize_command " @SYMFILE@"
522783e03a40Smrg	    preload=yes
522883e03a40Smrg	  fi
522983e03a40Smrg	  case $arg in
523083e03a40Smrg	  *.la | *.lo) ;;  # We handle these cases below.
523183e03a40Smrg	  force)
523283e03a40Smrg	    if test "$dlself" = no; then
523383e03a40Smrg	      dlself=needless
523483e03a40Smrg	      export_dynamic=yes
523583e03a40Smrg	    fi
523683e03a40Smrg	    prev=
523783e03a40Smrg	    continue
523883e03a40Smrg	    ;;
523983e03a40Smrg	  self)
524083e03a40Smrg	    if test "$prev" = dlprefiles; then
524183e03a40Smrg	      dlself=yes
524283e03a40Smrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
524383e03a40Smrg	      dlself=yes
524483e03a40Smrg	    else
524583e03a40Smrg	      dlself=needless
524683e03a40Smrg	      export_dynamic=yes
524783e03a40Smrg	    fi
524883e03a40Smrg	    prev=
524983e03a40Smrg	    continue
525083e03a40Smrg	    ;;
525183e03a40Smrg	  *)
525283e03a40Smrg	    if test "$prev" = dlfiles; then
525383e03a40Smrg	      func_append dlfiles " $arg"
525483e03a40Smrg	    else
525583e03a40Smrg	      func_append dlprefiles " $arg"
525683e03a40Smrg	    fi
525783e03a40Smrg	    prev=
525883e03a40Smrg	    continue
525983e03a40Smrg	    ;;
526083e03a40Smrg	  esac
526183e03a40Smrg	  ;;
526283e03a40Smrg	expsyms)
526383e03a40Smrg	  export_symbols="$arg"
526483e03a40Smrg	  test -f "$arg" \
526583e03a40Smrg	    || func_fatal_error "symbol file \`$arg' does not exist"
526683e03a40Smrg	  prev=
526783e03a40Smrg	  continue
526883e03a40Smrg	  ;;
526983e03a40Smrg	expsyms_regex)
527083e03a40Smrg	  export_symbols_regex="$arg"
527183e03a40Smrg	  prev=
527283e03a40Smrg	  continue
527383e03a40Smrg	  ;;
527483e03a40Smrg	framework)
527583e03a40Smrg	  case $host in
527683e03a40Smrg	    *-*-darwin*)
527783e03a40Smrg	      case "$deplibs " in
527883e03a40Smrg		*" $qarg.ltframework "*) ;;
527983e03a40Smrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
528083e03a40Smrg		   ;;
528183e03a40Smrg	      esac
528283e03a40Smrg	      ;;
528383e03a40Smrg	  esac
528483e03a40Smrg	  prev=
528583e03a40Smrg	  continue
528683e03a40Smrg	  ;;
528783e03a40Smrg	inst_prefix)
528883e03a40Smrg	  inst_prefix_dir="$arg"
528983e03a40Smrg	  prev=
529083e03a40Smrg	  continue
529183e03a40Smrg	  ;;
529283e03a40Smrg	objectlist)
529383e03a40Smrg	  if test -f "$arg"; then
529483e03a40Smrg	    save_arg=$arg
529583e03a40Smrg	    moreargs=
529683e03a40Smrg	    for fil in `cat "$save_arg"`
529783e03a40Smrg	    do
529883e03a40Smrg#	      func_append moreargs " $fil"
529983e03a40Smrg	      arg=$fil
530083e03a40Smrg	      # A libtool-controlled object.
5301357bfbb2Smrg
530283e03a40Smrg	      # Check to see that this really is a libtool object.
530383e03a40Smrg	      if func_lalib_unsafe_p "$arg"; then
530483e03a40Smrg		pic_object=
530583e03a40Smrg		non_pic_object=
5306357bfbb2Smrg
530783e03a40Smrg		# Read the .lo file
530883e03a40Smrg		func_source "$arg"
5309357bfbb2Smrg
531083e03a40Smrg		if test -z "$pic_object" ||
531183e03a40Smrg		   test -z "$non_pic_object" ||
531283e03a40Smrg		   test "$pic_object" = none &&
531383e03a40Smrg		   test "$non_pic_object" = none; then
531483e03a40Smrg		  func_fatal_error "cannot find name of object for \`$arg'"
531583e03a40Smrg		fi
5316357bfbb2Smrg
531783e03a40Smrg		# Extract subdirectory from the argument.
531883e03a40Smrg		func_dirname "$arg" "/" ""
531983e03a40Smrg		xdir="$func_dirname_result"
5320357bfbb2Smrg
532183e03a40Smrg		if test "$pic_object" != none; then
532283e03a40Smrg		  # Prepend the subdirectory the object is found in.
532383e03a40Smrg		  pic_object="$xdir$pic_object"
5324357bfbb2Smrg
532583e03a40Smrg		  if test "$prev" = dlfiles; then
532683e03a40Smrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
532783e03a40Smrg		      func_append dlfiles " $pic_object"
532883e03a40Smrg		      prev=
532983e03a40Smrg		      continue
533083e03a40Smrg		    else
533183e03a40Smrg		      # If libtool objects are unsupported, then we need to preload.
533283e03a40Smrg		      prev=dlprefiles
533383e03a40Smrg		    fi
533483e03a40Smrg		  fi
5335357bfbb2Smrg
533683e03a40Smrg		  # CHECK ME:  I think I busted this.  -Ossama
533783e03a40Smrg		  if test "$prev" = dlprefiles; then
533883e03a40Smrg		    # Preload the old-style object.
533983e03a40Smrg		    func_append dlprefiles " $pic_object"
534083e03a40Smrg		    prev=
534183e03a40Smrg		  fi
5342357bfbb2Smrg
534383e03a40Smrg		  # A PIC object.
534483e03a40Smrg		  func_append libobjs " $pic_object"
534583e03a40Smrg		  arg="$pic_object"
534683e03a40Smrg		fi
53475d713044Smrg
534883e03a40Smrg		# Non-PIC object.
534983e03a40Smrg		if test "$non_pic_object" != none; then
535083e03a40Smrg		  # Prepend the subdirectory the object is found in.
535183e03a40Smrg		  non_pic_object="$xdir$non_pic_object"
5352357bfbb2Smrg
535383e03a40Smrg		  # A standard non-PIC object
535483e03a40Smrg		  func_append non_pic_objects " $non_pic_object"
535583e03a40Smrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
535683e03a40Smrg		    arg="$non_pic_object"
535783e03a40Smrg		  fi
535883e03a40Smrg		else
535983e03a40Smrg		  # If the PIC object exists, use it instead.
536083e03a40Smrg		  # $xdir was prepended to $pic_object above.
536183e03a40Smrg		  non_pic_object="$pic_object"
536283e03a40Smrg		  func_append non_pic_objects " $non_pic_object"
536383e03a40Smrg		fi
536483e03a40Smrg	      else
536583e03a40Smrg		# Only an error if not doing a dry-run.
536683e03a40Smrg		if $opt_dry_run; then
536783e03a40Smrg		  # Extract subdirectory from the argument.
536883e03a40Smrg		  func_dirname "$arg" "/" ""
536983e03a40Smrg		  xdir="$func_dirname_result"
537083e03a40Smrg
537183e03a40Smrg		  func_lo2o "$arg"
537283e03a40Smrg		  pic_object=$xdir$objdir/$func_lo2o_result
537383e03a40Smrg		  non_pic_object=$xdir$func_lo2o_result
537483e03a40Smrg		  func_append libobjs " $pic_object"
537583e03a40Smrg		  func_append non_pic_objects " $non_pic_object"
537683e03a40Smrg	        else
537783e03a40Smrg		  func_fatal_error "\`$arg' is not a valid libtool object"
537883e03a40Smrg		fi
537983e03a40Smrg	      fi
538083e03a40Smrg	    done
538183e03a40Smrg	  else
538283e03a40Smrg	    func_fatal_error "link input file \`$arg' does not exist"
538383e03a40Smrg	  fi
538483e03a40Smrg	  arg=$save_arg
538583e03a40Smrg	  prev=
538683e03a40Smrg	  continue
538783e03a40Smrg	  ;;
538883e03a40Smrg	precious_regex)
538983e03a40Smrg	  precious_files_regex="$arg"
539083e03a40Smrg	  prev=
539183e03a40Smrg	  continue
539283e03a40Smrg	  ;;
539383e03a40Smrg	release)
539483e03a40Smrg	  release="-$arg"
539583e03a40Smrg	  prev=
539683e03a40Smrg	  continue
539783e03a40Smrg	  ;;
539883e03a40Smrg	rpath | xrpath)
539983e03a40Smrg	  # We need an absolute path.
540083e03a40Smrg	  case $arg in
540183e03a40Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
540283e03a40Smrg	  *)
540383e03a40Smrg	    func_fatal_error "only absolute run-paths are allowed"
540483e03a40Smrg	    ;;
540583e03a40Smrg	  esac
540683e03a40Smrg	  if test "$prev" = rpath; then
540783e03a40Smrg	    case "$rpath " in
540883e03a40Smrg	    *" $arg "*) ;;
540983e03a40Smrg	    *) func_append rpath " $arg" ;;
541083e03a40Smrg	    esac
541183e03a40Smrg	  else
541283e03a40Smrg	    case "$xrpath " in
541383e03a40Smrg	    *" $arg "*) ;;
541483e03a40Smrg	    *) func_append xrpath " $arg" ;;
541583e03a40Smrg	    esac
541683e03a40Smrg	  fi
541783e03a40Smrg	  prev=
541883e03a40Smrg	  continue
541983e03a40Smrg	  ;;
542083e03a40Smrg	shrext)
542183e03a40Smrg	  shrext_cmds="$arg"
542283e03a40Smrg	  prev=
542383e03a40Smrg	  continue
542483e03a40Smrg	  ;;
542583e03a40Smrg	weak)
542683e03a40Smrg	  func_append weak_libs " $arg"
542783e03a40Smrg	  prev=
542883e03a40Smrg	  continue
542983e03a40Smrg	  ;;
543083e03a40Smrg	xcclinker)
543183e03a40Smrg	  func_append linker_flags " $qarg"
543283e03a40Smrg	  func_append compiler_flags " $qarg"
543383e03a40Smrg	  prev=
543483e03a40Smrg	  func_append compile_command " $qarg"
543583e03a40Smrg	  func_append finalize_command " $qarg"
543683e03a40Smrg	  continue
543783e03a40Smrg	  ;;
543883e03a40Smrg	xcompiler)
543983e03a40Smrg	  func_append compiler_flags " $qarg"
544083e03a40Smrg	  prev=
544183e03a40Smrg	  func_append compile_command " $qarg"
544283e03a40Smrg	  func_append finalize_command " $qarg"
544383e03a40Smrg	  continue
544483e03a40Smrg	  ;;
544583e03a40Smrg	xlinker)
544683e03a40Smrg	  func_append linker_flags " $qarg"
544783e03a40Smrg	  func_append compiler_flags " $wl$qarg"
544883e03a40Smrg	  prev=
544983e03a40Smrg	  func_append compile_command " $wl$qarg"
545083e03a40Smrg	  func_append finalize_command " $wl$qarg"
545183e03a40Smrg	  continue
545283e03a40Smrg	  ;;
545383e03a40Smrg	*)
545483e03a40Smrg	  eval "$prev=\"\$arg\""
545583e03a40Smrg	  prev=
545683e03a40Smrg	  continue
545783e03a40Smrg	  ;;
545883e03a40Smrg	esac
545983e03a40Smrg      fi # test -n "$prev"
5460357bfbb2Smrg
546183e03a40Smrg      prevarg="$arg"
5462357bfbb2Smrg
546383e03a40Smrg      case $arg in
546483e03a40Smrg      -all-static)
546583e03a40Smrg	if test -n "$link_static_flag"; then
546683e03a40Smrg	  # See comment for -static flag below, for more details.
546783e03a40Smrg	  func_append compile_command " $link_static_flag"
546883e03a40Smrg	  func_append finalize_command " $link_static_flag"
546983e03a40Smrg	fi
547083e03a40Smrg	continue
547183e03a40Smrg	;;
5472357bfbb2Smrg
547383e03a40Smrg      -allow-undefined)
547483e03a40Smrg	# FIXME: remove this flag sometime in the future.
547583e03a40Smrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
547683e03a40Smrg	;;
5477357bfbb2Smrg
547883e03a40Smrg      -avoid-version)
547983e03a40Smrg	avoid_version=yes
548083e03a40Smrg	continue
548183e03a40Smrg	;;
5482357bfbb2Smrg
548383e03a40Smrg      -bindir)
548483e03a40Smrg	prev=bindir
548583e03a40Smrg	continue
548683e03a40Smrg	;;
5487357bfbb2Smrg
548883e03a40Smrg      -dlopen)
548983e03a40Smrg	prev=dlfiles
549083e03a40Smrg	continue
549183e03a40Smrg	;;
5492357bfbb2Smrg
549383e03a40Smrg      -dlpreopen)
549483e03a40Smrg	prev=dlprefiles
549583e03a40Smrg	continue
549683e03a40Smrg	;;
5497357bfbb2Smrg
549883e03a40Smrg      -export-dynamic)
549983e03a40Smrg	export_dynamic=yes
550083e03a40Smrg	continue
550183e03a40Smrg	;;
5502357bfbb2Smrg
550383e03a40Smrg      -export-symbols | -export-symbols-regex)
550483e03a40Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
550583e03a40Smrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
550683e03a40Smrg	fi
550783e03a40Smrg	if test "X$arg" = "X-export-symbols"; then
550883e03a40Smrg	  prev=expsyms
550983e03a40Smrg	else
551083e03a40Smrg	  prev=expsyms_regex
551183e03a40Smrg	fi
551283e03a40Smrg	continue
551383e03a40Smrg	;;
5514357bfbb2Smrg
551583e03a40Smrg      -framework)
551683e03a40Smrg	prev=framework
551783e03a40Smrg	continue
551883e03a40Smrg	;;
551983e03a40Smrg
552083e03a40Smrg      -inst-prefix-dir)
552183e03a40Smrg	prev=inst_prefix
552283e03a40Smrg	continue
552383e03a40Smrg	;;
552483e03a40Smrg
552583e03a40Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
552683e03a40Smrg      # so, if we see these flags be careful not to treat them like -L
552783e03a40Smrg      -L[A-Z][A-Z]*:*)
552883e03a40Smrg	case $with_gcc/$host in
552983e03a40Smrg	no/*-*-irix* | /*-*-irix*)
553083e03a40Smrg	  func_append compile_command " $arg"
553183e03a40Smrg	  func_append finalize_command " $arg"
553283e03a40Smrg	  ;;
553383e03a40Smrg	esac
553483e03a40Smrg	continue
553583e03a40Smrg	;;
553683e03a40Smrg
553783e03a40Smrg      -L*)
553883e03a40Smrg	func_stripname "-L" '' "$arg"
553983e03a40Smrg	if test -z "$func_stripname_result"; then
554083e03a40Smrg	  if test "$#" -gt 0; then
554183e03a40Smrg	    func_fatal_error "require no space between \`-L' and \`$1'"
554283e03a40Smrg	  else
554383e03a40Smrg	    func_fatal_error "need path for \`-L' option"
554483e03a40Smrg	  fi
554583e03a40Smrg	fi
554683e03a40Smrg	func_resolve_sysroot "$func_stripname_result"
554783e03a40Smrg	dir=$func_resolve_sysroot_result
554883e03a40Smrg	# We need an absolute path.
554983e03a40Smrg	case $dir in
555083e03a40Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
555183e03a40Smrg	*)
555283e03a40Smrg	  absdir=`cd "$dir" && pwd`
555383e03a40Smrg	  test -z "$absdir" && \
555483e03a40Smrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
555583e03a40Smrg	  dir="$absdir"
555683e03a40Smrg	  ;;
555783e03a40Smrg	esac
555883e03a40Smrg	case "$deplibs " in
555983e03a40Smrg	*" -L$dir "* | *" $arg "*)
556083e03a40Smrg	  # Will only happen for absolute or sysroot arguments
556183e03a40Smrg	  ;;
556283e03a40Smrg	*)
556383e03a40Smrg	  # Preserve sysroot, but never include relative directories
556483e03a40Smrg	  case $dir in
556583e03a40Smrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
556683e03a40Smrg	    *) func_append deplibs " -L$dir" ;;
556783e03a40Smrg	  esac
556883e03a40Smrg	  func_append lib_search_path " $dir"
556983e03a40Smrg	  ;;
557083e03a40Smrg	esac
557183e03a40Smrg	case $host in
557283e03a40Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
557383e03a40Smrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
557483e03a40Smrg	  case :$dllsearchpath: in
557583e03a40Smrg	  *":$dir:"*) ;;
557683e03a40Smrg	  ::) dllsearchpath=$dir;;
557783e03a40Smrg	  *) func_append dllsearchpath ":$dir";;
557883e03a40Smrg	  esac
557983e03a40Smrg	  case :$dllsearchpath: in
558083e03a40Smrg	  *":$testbindir:"*) ;;
558183e03a40Smrg	  ::) dllsearchpath=$testbindir;;
558283e03a40Smrg	  *) func_append dllsearchpath ":$testbindir";;
558383e03a40Smrg	  esac
558483e03a40Smrg	  ;;
558583e03a40Smrg	esac
558683e03a40Smrg	continue
558783e03a40Smrg	;;
558883e03a40Smrg
558983e03a40Smrg      -l*)
559083e03a40Smrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
559183e03a40Smrg	  case $host in
559283e03a40Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
559383e03a40Smrg	    # These systems don't actually have a C or math library (as such)
559483e03a40Smrg	    continue
559583e03a40Smrg	    ;;
559683e03a40Smrg	  *-*-os2*)
559783e03a40Smrg	    # These systems don't actually have a C library (as such)
559883e03a40Smrg	    test "X$arg" = "X-lc" && continue
559983e03a40Smrg	    ;;
560083e03a40Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
560183e03a40Smrg	    # Do not include libc due to us having libc/libc_r.
560283e03a40Smrg	    test "X$arg" = "X-lc" && continue
560383e03a40Smrg	    ;;
560483e03a40Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
560583e03a40Smrg	    # Rhapsody C and math libraries are in the System framework
560683e03a40Smrg	    func_append deplibs " System.ltframework"
560783e03a40Smrg	    continue
560883e03a40Smrg	    ;;
560983e03a40Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
561083e03a40Smrg	    # Causes problems with __ctype
561183e03a40Smrg	    test "X$arg" = "X-lc" && continue
561283e03a40Smrg	    ;;
561383e03a40Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
561483e03a40Smrg	    # Compiler inserts libc in the correct place for threads to work
561583e03a40Smrg	    test "X$arg" = "X-lc" && continue
561683e03a40Smrg	    ;;
561783e03a40Smrg	  esac
561883e03a40Smrg	elif test "X$arg" = "X-lc_r"; then
561983e03a40Smrg	 case $host in
562083e03a40Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
562183e03a40Smrg	   # Do not include libc_r directly, use -pthread flag.
562283e03a40Smrg	   continue
562383e03a40Smrg	   ;;
562483e03a40Smrg	 esac
562583e03a40Smrg	fi
562683e03a40Smrg	func_append deplibs " $arg"
562783e03a40Smrg	continue
562883e03a40Smrg	;;
562983e03a40Smrg
563083e03a40Smrg      -module)
563183e03a40Smrg	module=yes
563283e03a40Smrg	continue
563383e03a40Smrg	;;
563483e03a40Smrg
563583e03a40Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
563683e03a40Smrg      # classes, name mangling, and exception handling.
563783e03a40Smrg      # Darwin uses the -arch flag to determine output architecture.
563883e03a40Smrg      -model|-arch|-isysroot|--sysroot)
563983e03a40Smrg	func_append compiler_flags " $arg"
564083e03a40Smrg	func_append compile_command " $arg"
564183e03a40Smrg	func_append finalize_command " $arg"
564283e03a40Smrg	prev=xcompiler
564383e03a40Smrg	continue
564483e03a40Smrg	;;
564583e03a40Smrg
564683e03a40Smrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
564783e03a40Smrg	func_append compiler_flags " $arg"
564883e03a40Smrg	func_append compile_command " $arg"
564983e03a40Smrg	func_append finalize_command " $arg"
565083e03a40Smrg	case "$new_inherited_linker_flags " in
565183e03a40Smrg	    *" $arg "*) ;;
565283e03a40Smrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
565383e03a40Smrg	esac
565483e03a40Smrg	continue
565583e03a40Smrg	;;
565683e03a40Smrg
565783e03a40Smrg      -multi_module)
565883e03a40Smrg	single_module="${wl}-multi_module"
565983e03a40Smrg	continue
566083e03a40Smrg	;;
566183e03a40Smrg
566283e03a40Smrg      -no-fast-install)
566383e03a40Smrg	fast_install=no
566483e03a40Smrg	continue
566583e03a40Smrg	;;
566683e03a40Smrg
566783e03a40Smrg      -no-install)
566883e03a40Smrg	case $host in
566983e03a40Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
567083e03a40Smrg	  # The PATH hackery in wrapper scripts is required on Windows
567183e03a40Smrg	  # and Darwin in order for the loader to find any dlls it needs.
567283e03a40Smrg	  func_warning "\`-no-install' is ignored for $host"
567383e03a40Smrg	  func_warning "assuming \`-no-fast-install' instead"
567483e03a40Smrg	  fast_install=no
567583e03a40Smrg	  ;;
567683e03a40Smrg	*) no_install=yes ;;
567783e03a40Smrg	esac
567883e03a40Smrg	continue
567983e03a40Smrg	;;
568083e03a40Smrg
568183e03a40Smrg      -no-undefined)
568283e03a40Smrg	allow_undefined=no
568383e03a40Smrg	continue
568483e03a40Smrg	;;
568583e03a40Smrg
568683e03a40Smrg      -objectlist)
568783e03a40Smrg	prev=objectlist
568883e03a40Smrg	continue
568983e03a40Smrg	;;
569083e03a40Smrg
569183e03a40Smrg      -o) prev=output ;;
569283e03a40Smrg
569383e03a40Smrg      -precious-files-regex)
569483e03a40Smrg	prev=precious_regex
569583e03a40Smrg	continue
569683e03a40Smrg	;;
569783e03a40Smrg
569883e03a40Smrg      -release)
569983e03a40Smrg	prev=release
570083e03a40Smrg	continue
570183e03a40Smrg	;;
570283e03a40Smrg
570383e03a40Smrg      -rpath)
570483e03a40Smrg	prev=rpath
570583e03a40Smrg	continue
570683e03a40Smrg	;;
570783e03a40Smrg
570883e03a40Smrg      -R)
570983e03a40Smrg	prev=xrpath
571083e03a40Smrg	continue
571183e03a40Smrg	;;
571283e03a40Smrg
571383e03a40Smrg      -R*)
571483e03a40Smrg	func_stripname '-R' '' "$arg"
571583e03a40Smrg	dir=$func_stripname_result
571683e03a40Smrg	# We need an absolute path.
571783e03a40Smrg	case $dir in
571883e03a40Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
571983e03a40Smrg	=*)
572083e03a40Smrg	  func_stripname '=' '' "$dir"
572183e03a40Smrg	  dir=$lt_sysroot$func_stripname_result
572283e03a40Smrg	  ;;
572383e03a40Smrg	*)
572483e03a40Smrg	  func_fatal_error "only absolute run-paths are allowed"
572583e03a40Smrg	  ;;
572683e03a40Smrg	esac
572783e03a40Smrg	case "$xrpath " in
572883e03a40Smrg	*" $dir "*) ;;
572983e03a40Smrg	*) func_append xrpath " $dir" ;;
573083e03a40Smrg	esac
573183e03a40Smrg	continue
573283e03a40Smrg	;;
573383e03a40Smrg
573483e03a40Smrg      -shared)
573583e03a40Smrg	# The effects of -shared are defined in a previous loop.
573683e03a40Smrg	continue
573783e03a40Smrg	;;
573883e03a40Smrg
573983e03a40Smrg      -shrext)
574083e03a40Smrg	prev=shrext
574183e03a40Smrg	continue
574283e03a40Smrg	;;
574383e03a40Smrg
574483e03a40Smrg      -static | -static-libtool-libs)
574583e03a40Smrg	# The effects of -static are defined in a previous loop.
574683e03a40Smrg	# We used to do the same as -all-static on platforms that
574783e03a40Smrg	# didn't have a PIC flag, but the assumption that the effects
574883e03a40Smrg	# would be equivalent was wrong.  It would break on at least
574983e03a40Smrg	# Digital Unix and AIX.
575083e03a40Smrg	continue
575183e03a40Smrg	;;
575283e03a40Smrg
575383e03a40Smrg      -thread-safe)
575483e03a40Smrg	thread_safe=yes
575583e03a40Smrg	continue
575683e03a40Smrg	;;
575783e03a40Smrg
575883e03a40Smrg      -version-info)
575983e03a40Smrg	prev=vinfo
576083e03a40Smrg	continue
576183e03a40Smrg	;;
576283e03a40Smrg
576383e03a40Smrg      -version-number)
576483e03a40Smrg	prev=vinfo
576583e03a40Smrg	vinfo_number=yes
576683e03a40Smrg	continue
576783e03a40Smrg	;;
576883e03a40Smrg
576983e03a40Smrg      -weak)
577083e03a40Smrg        prev=weak
577183e03a40Smrg	continue
577283e03a40Smrg	;;
577383e03a40Smrg
577483e03a40Smrg      -Wc,*)
577583e03a40Smrg	func_stripname '-Wc,' '' "$arg"
577683e03a40Smrg	args=$func_stripname_result
577783e03a40Smrg	arg=
577883e03a40Smrg	save_ifs="$IFS"; IFS=','
577983e03a40Smrg	for flag in $args; do
578083e03a40Smrg	  IFS="$save_ifs"
578183e03a40Smrg          func_quote_for_eval "$flag"
578283e03a40Smrg	  func_append arg " $func_quote_for_eval_result"
578383e03a40Smrg	  func_append compiler_flags " $func_quote_for_eval_result"
578483e03a40Smrg	done
578583e03a40Smrg	IFS="$save_ifs"
578683e03a40Smrg	func_stripname ' ' '' "$arg"
578783e03a40Smrg	arg=$func_stripname_result
578883e03a40Smrg	;;
578983e03a40Smrg
579083e03a40Smrg      -Wl,*)
579183e03a40Smrg	func_stripname '-Wl,' '' "$arg"
579283e03a40Smrg	args=$func_stripname_result
579383e03a40Smrg	arg=
579483e03a40Smrg	save_ifs="$IFS"; IFS=','
579583e03a40Smrg	for flag in $args; do
579683e03a40Smrg	  IFS="$save_ifs"
579783e03a40Smrg          func_quote_for_eval "$flag"
579883e03a40Smrg	  func_append arg " $wl$func_quote_for_eval_result"
579983e03a40Smrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
580083e03a40Smrg	  func_append linker_flags " $func_quote_for_eval_result"
580183e03a40Smrg	done
580283e03a40Smrg	IFS="$save_ifs"
580383e03a40Smrg	func_stripname ' ' '' "$arg"
580483e03a40Smrg	arg=$func_stripname_result
580583e03a40Smrg	;;
580683e03a40Smrg
580783e03a40Smrg      -Xcompiler)
580883e03a40Smrg	prev=xcompiler
580983e03a40Smrg	continue
581083e03a40Smrg	;;
581183e03a40Smrg
581283e03a40Smrg      -Xlinker)
581383e03a40Smrg	prev=xlinker
581483e03a40Smrg	continue
581583e03a40Smrg	;;
581683e03a40Smrg
581783e03a40Smrg      -XCClinker)
581883e03a40Smrg	prev=xcclinker
581983e03a40Smrg	continue
582083e03a40Smrg	;;
582183e03a40Smrg
582283e03a40Smrg      # -msg_* for osf cc
582383e03a40Smrg      -msg_*)
582483e03a40Smrg	func_quote_for_eval "$arg"
582583e03a40Smrg	arg="$func_quote_for_eval_result"
582683e03a40Smrg	;;
582783e03a40Smrg
582883e03a40Smrg      # Flags to be passed through unchanged, with rationale:
582983e03a40Smrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
583083e03a40Smrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
583183e03a40Smrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
583283e03a40Smrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
583383e03a40Smrg      # -q*                  compiler args for the IBM compiler
583483e03a40Smrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
583583e03a40Smrg      # -F/path              path to uninstalled frameworks, gcc on darwin
583683e03a40Smrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
583783e03a40Smrg      # @file                GCC response files
583883e03a40Smrg      # -tp=*                Portland pgcc target processor selection
583983e03a40Smrg      # --sysroot=*          for sysroot support
584083e03a40Smrg      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
584183e03a40Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
584283e03a40Smrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
584383e03a40Smrg      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
584483e03a40Smrg        func_quote_for_eval "$arg"
584583e03a40Smrg	arg="$func_quote_for_eval_result"
584683e03a40Smrg        func_append compile_command " $arg"
584783e03a40Smrg        func_append finalize_command " $arg"
584883e03a40Smrg        func_append compiler_flags " $arg"
584983e03a40Smrg        continue
585083e03a40Smrg        ;;
585183e03a40Smrg
585283e03a40Smrg      # Some other compiler flag.
585383e03a40Smrg      -* | +*)
585483e03a40Smrg        func_quote_for_eval "$arg"
585583e03a40Smrg	arg="$func_quote_for_eval_result"
585683e03a40Smrg	;;
585783e03a40Smrg
585883e03a40Smrg      *.$objext)
585983e03a40Smrg	# A standard object.
586083e03a40Smrg	func_append objs " $arg"
586183e03a40Smrg	;;
586283e03a40Smrg
586383e03a40Smrg      *.lo)
586483e03a40Smrg	# A libtool-controlled object.
586583e03a40Smrg
586683e03a40Smrg	# Check to see that this really is a libtool object.
586783e03a40Smrg	if func_lalib_unsafe_p "$arg"; then
586883e03a40Smrg	  pic_object=
586983e03a40Smrg	  non_pic_object=
587083e03a40Smrg
587183e03a40Smrg	  # Read the .lo file
587283e03a40Smrg	  func_source "$arg"
587383e03a40Smrg
587483e03a40Smrg	  if test -z "$pic_object" ||
587583e03a40Smrg	     test -z "$non_pic_object" ||
587683e03a40Smrg	     test "$pic_object" = none &&
587783e03a40Smrg	     test "$non_pic_object" = none; then
587883e03a40Smrg	    func_fatal_error "cannot find name of object for \`$arg'"
587983e03a40Smrg	  fi
588083e03a40Smrg
588183e03a40Smrg	  # Extract subdirectory from the argument.
588283e03a40Smrg	  func_dirname "$arg" "/" ""
588383e03a40Smrg	  xdir="$func_dirname_result"
588483e03a40Smrg
588583e03a40Smrg	  if test "$pic_object" != none; then
588683e03a40Smrg	    # Prepend the subdirectory the object is found in.
588783e03a40Smrg	    pic_object="$xdir$pic_object"
588883e03a40Smrg
588983e03a40Smrg	    if test "$prev" = dlfiles; then
589083e03a40Smrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
589183e03a40Smrg		func_append dlfiles " $pic_object"
589283e03a40Smrg		prev=
589383e03a40Smrg		continue
589483e03a40Smrg	      else
589583e03a40Smrg		# If libtool objects are unsupported, then we need to preload.
589683e03a40Smrg		prev=dlprefiles
589783e03a40Smrg	      fi
589883e03a40Smrg	    fi
589983e03a40Smrg
590083e03a40Smrg	    # CHECK ME:  I think I busted this.  -Ossama
590183e03a40Smrg	    if test "$prev" = dlprefiles; then
590283e03a40Smrg	      # Preload the old-style object.
590383e03a40Smrg	      func_append dlprefiles " $pic_object"
590483e03a40Smrg	      prev=
590583e03a40Smrg	    fi
590683e03a40Smrg
590783e03a40Smrg	    # A PIC object.
590883e03a40Smrg	    func_append libobjs " $pic_object"
590983e03a40Smrg	    arg="$pic_object"
591083e03a40Smrg	  fi
591183e03a40Smrg
591283e03a40Smrg	  # Non-PIC object.
591383e03a40Smrg	  if test "$non_pic_object" != none; then
591483e03a40Smrg	    # Prepend the subdirectory the object is found in.
591583e03a40Smrg	    non_pic_object="$xdir$non_pic_object"
591683e03a40Smrg
591783e03a40Smrg	    # A standard non-PIC object
591883e03a40Smrg	    func_append non_pic_objects " $non_pic_object"
591983e03a40Smrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
592083e03a40Smrg	      arg="$non_pic_object"
592183e03a40Smrg	    fi
592283e03a40Smrg	  else
592383e03a40Smrg	    # If the PIC object exists, use it instead.
592483e03a40Smrg	    # $xdir was prepended to $pic_object above.
592583e03a40Smrg	    non_pic_object="$pic_object"
592683e03a40Smrg	    func_append non_pic_objects " $non_pic_object"
592783e03a40Smrg	  fi
592883e03a40Smrg	else
592983e03a40Smrg	  # Only an error if not doing a dry-run.
593083e03a40Smrg	  if $opt_dry_run; then
593183e03a40Smrg	    # Extract subdirectory from the argument.
593283e03a40Smrg	    func_dirname "$arg" "/" ""
593383e03a40Smrg	    xdir="$func_dirname_result"
593483e03a40Smrg
593583e03a40Smrg	    func_lo2o "$arg"
593683e03a40Smrg	    pic_object=$xdir$objdir/$func_lo2o_result
593783e03a40Smrg	    non_pic_object=$xdir$func_lo2o_result
593883e03a40Smrg	    func_append libobjs " $pic_object"
593983e03a40Smrg	    func_append non_pic_objects " $non_pic_object"
594083e03a40Smrg	  else
594183e03a40Smrg	    func_fatal_error "\`$arg' is not a valid libtool object"
594283e03a40Smrg	  fi
594383e03a40Smrg	fi
594483e03a40Smrg	;;
594583e03a40Smrg
594683e03a40Smrg      *.$libext)
594783e03a40Smrg	# An archive.
594883e03a40Smrg	func_append deplibs " $arg"
594983e03a40Smrg	func_append old_deplibs " $arg"
595083e03a40Smrg	continue
595183e03a40Smrg	;;
595283e03a40Smrg
595383e03a40Smrg      *.la)
595483e03a40Smrg	# A libtool-controlled library.
595583e03a40Smrg
595683e03a40Smrg	func_resolve_sysroot "$arg"
595783e03a40Smrg	if test "$prev" = dlfiles; then
595883e03a40Smrg	  # This library was specified with -dlopen.
595983e03a40Smrg	  func_append dlfiles " $func_resolve_sysroot_result"
596083e03a40Smrg	  prev=
596183e03a40Smrg	elif test "$prev" = dlprefiles; then
596283e03a40Smrg	  # The library was specified with -dlpreopen.
596383e03a40Smrg	  func_append dlprefiles " $func_resolve_sysroot_result"
596483e03a40Smrg	  prev=
596583e03a40Smrg	else
596683e03a40Smrg	  func_append deplibs " $func_resolve_sysroot_result"
596783e03a40Smrg	fi
596883e03a40Smrg	continue
596983e03a40Smrg	;;
597083e03a40Smrg
597183e03a40Smrg      # Some other compiler argument.
597283e03a40Smrg      *)
597383e03a40Smrg	# Unknown arguments in both finalize_command and compile_command need
597483e03a40Smrg	# to be aesthetically quoted because they are evaled later.
597583e03a40Smrg	func_quote_for_eval "$arg"
597683e03a40Smrg	arg="$func_quote_for_eval_result"
597783e03a40Smrg	;;
597883e03a40Smrg      esac # arg
597983e03a40Smrg
598083e03a40Smrg      # Now actually substitute the argument into the commands.
598183e03a40Smrg      if test -n "$arg"; then
598283e03a40Smrg	func_append compile_command " $arg"
598383e03a40Smrg	func_append finalize_command " $arg"
598483e03a40Smrg      fi
598583e03a40Smrg    done # argument parsing loop
598683e03a40Smrg
598783e03a40Smrg    test -n "$prev" && \
598883e03a40Smrg      func_fatal_help "the \`$prevarg' option requires an argument"
598983e03a40Smrg
599083e03a40Smrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
599183e03a40Smrg      eval arg=\"$export_dynamic_flag_spec\"
599283e03a40Smrg      func_append compile_command " $arg"
599383e03a40Smrg      func_append finalize_command " $arg"
599483e03a40Smrg    fi
599583e03a40Smrg
599683e03a40Smrg    oldlibs=
599783e03a40Smrg    # calculate the name of the file, without its directory
599883e03a40Smrg    func_basename "$output"
599983e03a40Smrg    outputname="$func_basename_result"
600083e03a40Smrg    libobjs_save="$libobjs"
600183e03a40Smrg
600283e03a40Smrg    if test -n "$shlibpath_var"; then
600383e03a40Smrg      # get the directories listed in $shlibpath_var
600483e03a40Smrg      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
600583e03a40Smrg    else
600683e03a40Smrg      shlib_search_path=
600783e03a40Smrg    fi
600883e03a40Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
600983e03a40Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
601083e03a40Smrg
601183e03a40Smrg    func_dirname "$output" "/" ""
601283e03a40Smrg    output_objdir="$func_dirname_result$objdir"
601383e03a40Smrg    func_to_tool_file "$output_objdir/"
601483e03a40Smrg    tool_output_objdir=$func_to_tool_file_result
601583e03a40Smrg    # Create the object directory.
601683e03a40Smrg    func_mkdir_p "$output_objdir"
601783e03a40Smrg
601883e03a40Smrg    # Determine the type of output
601983e03a40Smrg    case $output in
602083e03a40Smrg    "")
602183e03a40Smrg      func_fatal_help "you must specify an output file"
602283e03a40Smrg      ;;
602383e03a40Smrg    *.$libext) linkmode=oldlib ;;
602483e03a40Smrg    *.lo | *.$objext) linkmode=obj ;;
602583e03a40Smrg    *.la) linkmode=lib ;;
602683e03a40Smrg    *) linkmode=prog ;; # Anything else should be a program.
602783e03a40Smrg    esac
602883e03a40Smrg
602983e03a40Smrg    specialdeplibs=
603083e03a40Smrg
603183e03a40Smrg    libs=
603283e03a40Smrg    # Find all interdependent deplibs by searching for libraries
603383e03a40Smrg    # that are linked more than once (e.g. -la -lb -la)
603483e03a40Smrg    for deplib in $deplibs; do
603583e03a40Smrg      if $opt_preserve_dup_deps ; then
603683e03a40Smrg	case "$libs " in
603783e03a40Smrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
603883e03a40Smrg	esac
603983e03a40Smrg      fi
604083e03a40Smrg      func_append libs " $deplib"
604183e03a40Smrg    done
604283e03a40Smrg
604383e03a40Smrg    if test "$linkmode" = lib; then
604483e03a40Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
604583e03a40Smrg
604683e03a40Smrg      # Compute libraries that are listed more than once in $predeps
604783e03a40Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
604883e03a40Smrg      # not to be eliminated).
604983e03a40Smrg      pre_post_deps=
605083e03a40Smrg      if $opt_duplicate_compiler_generated_deps; then
605183e03a40Smrg	for pre_post_dep in $predeps $postdeps; do
605283e03a40Smrg	  case "$pre_post_deps " in
605383e03a40Smrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
605483e03a40Smrg	  esac
605583e03a40Smrg	  func_append pre_post_deps " $pre_post_dep"
605683e03a40Smrg	done
605783e03a40Smrg      fi
605883e03a40Smrg      pre_post_deps=
605983e03a40Smrg    fi
606083e03a40Smrg
606183e03a40Smrg    deplibs=
606283e03a40Smrg    newdependency_libs=
606383e03a40Smrg    newlib_search_path=
606483e03a40Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
606583e03a40Smrg    notinst_deplibs= # not-installed libtool libraries
606683e03a40Smrg    notinst_path= # paths that contain not-installed libtool libraries
606783e03a40Smrg
606883e03a40Smrg    case $linkmode in
606983e03a40Smrg    lib)
607083e03a40Smrg	passes="conv dlpreopen link"
607183e03a40Smrg	for file in $dlfiles $dlprefiles; do
607283e03a40Smrg	  case $file in
607383e03a40Smrg	  *.la) ;;
607483e03a40Smrg	  *)
607583e03a40Smrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
607683e03a40Smrg	    ;;
607783e03a40Smrg	  esac
607883e03a40Smrg	done
607983e03a40Smrg	;;
608083e03a40Smrg    prog)
608183e03a40Smrg	compile_deplibs=
608283e03a40Smrg	finalize_deplibs=
608383e03a40Smrg	alldeplibs=no
608483e03a40Smrg	newdlfiles=
608583e03a40Smrg	newdlprefiles=
608683e03a40Smrg	passes="conv scan dlopen dlpreopen link"
608783e03a40Smrg	;;
608883e03a40Smrg    *)  passes="conv"
608983e03a40Smrg	;;
609083e03a40Smrg    esac
609183e03a40Smrg
609283e03a40Smrg    for pass in $passes; do
609383e03a40Smrg      # The preopen pass in lib mode reverses $deplibs; put it back here
609483e03a40Smrg      # so that -L comes before libs that need it for instance...
609583e03a40Smrg      if test "$linkmode,$pass" = "lib,link"; then
609683e03a40Smrg	## FIXME: Find the place where the list is rebuilt in the wrong
609783e03a40Smrg	##        order, and fix it there properly
609883e03a40Smrg        tmp_deplibs=
609983e03a40Smrg	for deplib in $deplibs; do
610083e03a40Smrg	  tmp_deplibs="$deplib $tmp_deplibs"
610183e03a40Smrg	done
610283e03a40Smrg	deplibs="$tmp_deplibs"
610383e03a40Smrg      fi
610483e03a40Smrg
610583e03a40Smrg      if test "$linkmode,$pass" = "lib,link" ||
610683e03a40Smrg	 test "$linkmode,$pass" = "prog,scan"; then
610783e03a40Smrg	libs="$deplibs"
610883e03a40Smrg	deplibs=
610983e03a40Smrg      fi
611083e03a40Smrg      if test "$linkmode" = prog; then
611183e03a40Smrg	case $pass in
611283e03a40Smrg	dlopen) libs="$dlfiles" ;;
611383e03a40Smrg	dlpreopen) libs="$dlprefiles" ;;
611483e03a40Smrg	link)
611583e03a40Smrg	  libs="$deplibs %DEPLIBS%"
611683e03a40Smrg	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
611783e03a40Smrg	  ;;
611883e03a40Smrg	esac
611983e03a40Smrg      fi
612083e03a40Smrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
612183e03a40Smrg	# Collect and forward deplibs of preopened libtool libs
612283e03a40Smrg	for lib in $dlprefiles; do
612383e03a40Smrg	  # Ignore non-libtool-libs
612483e03a40Smrg	  dependency_libs=
612583e03a40Smrg	  func_resolve_sysroot "$lib"
612683e03a40Smrg	  case $lib in
612783e03a40Smrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
612883e03a40Smrg	  esac
612983e03a40Smrg
613083e03a40Smrg	  # Collect preopened libtool deplibs, except any this library
613183e03a40Smrg	  # has declared as weak libs
613283e03a40Smrg	  for deplib in $dependency_libs; do
613383e03a40Smrg	    func_basename "$deplib"
613483e03a40Smrg            deplib_base=$func_basename_result
613583e03a40Smrg	    case " $weak_libs " in
613683e03a40Smrg	    *" $deplib_base "*) ;;
613783e03a40Smrg	    *) func_append deplibs " $deplib" ;;
613883e03a40Smrg	    esac
613983e03a40Smrg	  done
614083e03a40Smrg	done
614183e03a40Smrg	libs="$dlprefiles"
614283e03a40Smrg      fi
614383e03a40Smrg      if test "$pass" = dlopen; then
614483e03a40Smrg	# Collect dlpreopened libraries
614583e03a40Smrg	save_deplibs="$deplibs"
614683e03a40Smrg	deplibs=
614783e03a40Smrg      fi
614883e03a40Smrg
614983e03a40Smrg      for deplib in $libs; do
615083e03a40Smrg	lib=
615183e03a40Smrg	found=no
615283e03a40Smrg	case $deplib in
615383e03a40Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
615483e03a40Smrg	  if test "$linkmode,$pass" = "prog,link"; then
615583e03a40Smrg	    compile_deplibs="$deplib $compile_deplibs"
615683e03a40Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
615783e03a40Smrg	  else
615883e03a40Smrg	    func_append compiler_flags " $deplib"
615983e03a40Smrg	    if test "$linkmode" = lib ; then
616083e03a40Smrg		case "$new_inherited_linker_flags " in
616183e03a40Smrg		    *" $deplib "*) ;;
616283e03a40Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
616383e03a40Smrg		esac
616483e03a40Smrg	    fi
616583e03a40Smrg	  fi
616683e03a40Smrg	  continue
616783e03a40Smrg	  ;;
616883e03a40Smrg	-l*)
616983e03a40Smrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
617083e03a40Smrg	    func_warning "\`-l' is ignored for archives/objects"
617183e03a40Smrg	    continue
617283e03a40Smrg	  fi
617383e03a40Smrg	  func_stripname '-l' '' "$deplib"
617483e03a40Smrg	  name=$func_stripname_result
617583e03a40Smrg	  if test "$linkmode" = lib; then
617683e03a40Smrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
617783e03a40Smrg	  else
617883e03a40Smrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
617983e03a40Smrg	  fi
618083e03a40Smrg	  for searchdir in $searchdirs; do
618183e03a40Smrg	    for search_ext in .la $std_shrext .so .a; do
618283e03a40Smrg	      # Search the libtool library
618383e03a40Smrg	      lib="$searchdir/lib${name}${search_ext}"
618483e03a40Smrg	      if test -f "$lib"; then
618583e03a40Smrg		if test "$search_ext" = ".la"; then
618683e03a40Smrg		  found=yes
618783e03a40Smrg		else
618883e03a40Smrg		  found=no
618983e03a40Smrg		fi
619083e03a40Smrg		break 2
619183e03a40Smrg	      fi
619283e03a40Smrg	    done
619383e03a40Smrg	  done
619483e03a40Smrg	  if test "$found" != yes; then
619583e03a40Smrg	    # deplib doesn't seem to be a libtool library
619683e03a40Smrg	    if test "$linkmode,$pass" = "prog,link"; then
619783e03a40Smrg	      compile_deplibs="$deplib $compile_deplibs"
619883e03a40Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
619983e03a40Smrg	    else
620083e03a40Smrg	      deplibs="$deplib $deplibs"
620183e03a40Smrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
620283e03a40Smrg	    fi
620383e03a40Smrg	    continue
620483e03a40Smrg	  else # deplib is a libtool library
620583e03a40Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
620683e03a40Smrg	    # We need to do some special things here, and not later.
620783e03a40Smrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
620883e03a40Smrg	      case " $predeps $postdeps " in
620983e03a40Smrg	      *" $deplib "*)
621083e03a40Smrg		if func_lalib_p "$lib"; then
621183e03a40Smrg		  library_names=
621283e03a40Smrg		  old_library=
621383e03a40Smrg		  func_source "$lib"
621483e03a40Smrg		  for l in $old_library $library_names; do
621583e03a40Smrg		    ll="$l"
621683e03a40Smrg		  done
621783e03a40Smrg		  if test "X$ll" = "X$old_library" ; then # only static version available
621883e03a40Smrg		    found=no
621983e03a40Smrg		    func_dirname "$lib" "" "."
622083e03a40Smrg		    ladir="$func_dirname_result"
622183e03a40Smrg		    lib=$ladir/$old_library
622283e03a40Smrg		    if test "$linkmode,$pass" = "prog,link"; then
622383e03a40Smrg		      compile_deplibs="$deplib $compile_deplibs"
622483e03a40Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
622583e03a40Smrg		    else
622683e03a40Smrg		      deplibs="$deplib $deplibs"
622783e03a40Smrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
622883e03a40Smrg		    fi
622983e03a40Smrg		    continue
623083e03a40Smrg		  fi
623183e03a40Smrg		fi
623283e03a40Smrg		;;
623383e03a40Smrg	      *) ;;
623483e03a40Smrg	      esac
623583e03a40Smrg	    fi
623683e03a40Smrg	  fi
623783e03a40Smrg	  ;; # -l
623883e03a40Smrg	*.ltframework)
623983e03a40Smrg	  if test "$linkmode,$pass" = "prog,link"; then
624083e03a40Smrg	    compile_deplibs="$deplib $compile_deplibs"
624183e03a40Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
624283e03a40Smrg	  else
624383e03a40Smrg	    deplibs="$deplib $deplibs"
624483e03a40Smrg	    if test "$linkmode" = lib ; then
624583e03a40Smrg		case "$new_inherited_linker_flags " in
624683e03a40Smrg		    *" $deplib "*) ;;
624783e03a40Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
624883e03a40Smrg		esac
624983e03a40Smrg	    fi
625083e03a40Smrg	  fi
625183e03a40Smrg	  continue
625283e03a40Smrg	  ;;
625383e03a40Smrg	-L*)
625483e03a40Smrg	  case $linkmode in
625583e03a40Smrg	  lib)
625683e03a40Smrg	    deplibs="$deplib $deplibs"
625783e03a40Smrg	    test "$pass" = conv && continue
625883e03a40Smrg	    newdependency_libs="$deplib $newdependency_libs"
625983e03a40Smrg	    func_stripname '-L' '' "$deplib"
626083e03a40Smrg	    func_resolve_sysroot "$func_stripname_result"
626183e03a40Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
626283e03a40Smrg	    ;;
626383e03a40Smrg	  prog)
626483e03a40Smrg	    if test "$pass" = conv; then
626583e03a40Smrg	      deplibs="$deplib $deplibs"
626683e03a40Smrg	      continue
626783e03a40Smrg	    fi
626883e03a40Smrg	    if test "$pass" = scan; then
626983e03a40Smrg	      deplibs="$deplib $deplibs"
627083e03a40Smrg	    else
627183e03a40Smrg	      compile_deplibs="$deplib $compile_deplibs"
627283e03a40Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
627383e03a40Smrg	    fi
627483e03a40Smrg	    func_stripname '-L' '' "$deplib"
627583e03a40Smrg	    func_resolve_sysroot "$func_stripname_result"
627683e03a40Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
627783e03a40Smrg	    ;;
627883e03a40Smrg	  *)
627983e03a40Smrg	    func_warning "\`-L' is ignored for archives/objects"
628083e03a40Smrg	    ;;
628183e03a40Smrg	  esac # linkmode
628283e03a40Smrg	  continue
628383e03a40Smrg	  ;; # -L
628483e03a40Smrg	-R*)
628583e03a40Smrg	  if test "$pass" = link; then
628683e03a40Smrg	    func_stripname '-R' '' "$deplib"
628783e03a40Smrg	    func_resolve_sysroot "$func_stripname_result"
628883e03a40Smrg	    dir=$func_resolve_sysroot_result
628983e03a40Smrg	    # Make sure the xrpath contains only unique directories.
629083e03a40Smrg	    case "$xrpath " in
629183e03a40Smrg	    *" $dir "*) ;;
629283e03a40Smrg	    *) func_append xrpath " $dir" ;;
629383e03a40Smrg	    esac
629483e03a40Smrg	  fi
629583e03a40Smrg	  deplibs="$deplib $deplibs"
629683e03a40Smrg	  continue
629783e03a40Smrg	  ;;
629883e03a40Smrg	*.la)
629983e03a40Smrg	  func_resolve_sysroot "$deplib"
630083e03a40Smrg	  lib=$func_resolve_sysroot_result
630183e03a40Smrg	  ;;
630283e03a40Smrg	*.$libext)
630383e03a40Smrg	  if test "$pass" = conv; then
630483e03a40Smrg	    deplibs="$deplib $deplibs"
630583e03a40Smrg	    continue
630683e03a40Smrg	  fi
630783e03a40Smrg	  case $linkmode in
630883e03a40Smrg	  lib)
630983e03a40Smrg	    # Linking convenience modules into shared libraries is allowed,
631083e03a40Smrg	    # but linking other static libraries is non-portable.
631183e03a40Smrg	    case " $dlpreconveniencelibs " in
631283e03a40Smrg	    *" $deplib "*) ;;
631383e03a40Smrg	    *)
631483e03a40Smrg	      valid_a_lib=no
631583e03a40Smrg	      case $deplibs_check_method in
631683e03a40Smrg		match_pattern*)
631783e03a40Smrg		  set dummy $deplibs_check_method; shift
631883e03a40Smrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
631983e03a40Smrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
632083e03a40Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
632183e03a40Smrg		    valid_a_lib=yes
632283e03a40Smrg		  fi
632383e03a40Smrg		;;
632483e03a40Smrg		pass_all)
632583e03a40Smrg		  valid_a_lib=yes
632683e03a40Smrg		;;
632783e03a40Smrg	      esac
632883e03a40Smrg	      if test "$valid_a_lib" != yes; then
632983e03a40Smrg		echo
633083e03a40Smrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
633183e03a40Smrg		echo "*** I have the capability to make that library automatically link in when"
633283e03a40Smrg		echo "*** you link to this library.  But I can only do this if you have a"
633383e03a40Smrg		echo "*** shared version of the library, which you do not appear to have"
633483e03a40Smrg		echo "*** because the file extensions .$libext of this argument makes me believe"
633583e03a40Smrg		echo "*** that it is just a static archive that I should not use here."
633683e03a40Smrg	      else
633783e03a40Smrg		echo
633883e03a40Smrg		$ECHO "*** Warning: Linking the shared library $output against the"
633983e03a40Smrg		$ECHO "*** static library $deplib is not portable!"
634083e03a40Smrg		deplibs="$deplib $deplibs"
634183e03a40Smrg	      fi
634283e03a40Smrg	      ;;
634383e03a40Smrg	    esac
634483e03a40Smrg	    continue
634583e03a40Smrg	    ;;
634683e03a40Smrg	  prog)
634783e03a40Smrg	    if test "$pass" != link; then
634883e03a40Smrg	      deplibs="$deplib $deplibs"
634983e03a40Smrg	    else
635083e03a40Smrg	      compile_deplibs="$deplib $compile_deplibs"
635183e03a40Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
635283e03a40Smrg	    fi
635383e03a40Smrg	    continue
635483e03a40Smrg	    ;;
635583e03a40Smrg	  esac # linkmode
635683e03a40Smrg	  ;; # *.$libext
635783e03a40Smrg	*.lo | *.$objext)
635883e03a40Smrg	  if test "$pass" = conv; then
635983e03a40Smrg	    deplibs="$deplib $deplibs"
636083e03a40Smrg	  elif test "$linkmode" = prog; then
636183e03a40Smrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
636283e03a40Smrg	      # If there is no dlopen support or we're linking statically,
636383e03a40Smrg	      # we need to preload.
636483e03a40Smrg	      func_append newdlprefiles " $deplib"
636583e03a40Smrg	      compile_deplibs="$deplib $compile_deplibs"
636683e03a40Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
636783e03a40Smrg	    else
636883e03a40Smrg	      func_append newdlfiles " $deplib"
636983e03a40Smrg	    fi
637083e03a40Smrg	  fi
637183e03a40Smrg	  continue
637283e03a40Smrg	  ;;
637383e03a40Smrg	%DEPLIBS%)
637483e03a40Smrg	  alldeplibs=yes
637583e03a40Smrg	  continue
637683e03a40Smrg	  ;;
637783e03a40Smrg	esac # case $deplib
637883e03a40Smrg
637983e03a40Smrg	if test "$found" = yes || test -f "$lib"; then :
638083e03a40Smrg	else
638183e03a40Smrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
638283e03a40Smrg	fi
638383e03a40Smrg
638483e03a40Smrg	# Check to see that this really is a libtool archive.
638583e03a40Smrg	func_lalib_unsafe_p "$lib" \
638683e03a40Smrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
638783e03a40Smrg
638883e03a40Smrg	func_dirname "$lib" "" "."
638983e03a40Smrg	ladir="$func_dirname_result"
639083e03a40Smrg
639183e03a40Smrg	dlname=
639283e03a40Smrg	dlopen=
639383e03a40Smrg	dlpreopen=
639483e03a40Smrg	libdir=
639583e03a40Smrg	library_names=
639683e03a40Smrg	old_library=
639783e03a40Smrg	inherited_linker_flags=
639883e03a40Smrg	# If the library was installed with an old release of libtool,
639983e03a40Smrg	# it will not redefine variables installed, or shouldnotlink
640083e03a40Smrg	installed=yes
640183e03a40Smrg	shouldnotlink=no
640283e03a40Smrg	avoidtemprpath=
640383e03a40Smrg
640483e03a40Smrg
640583e03a40Smrg	# Read the .la file
640683e03a40Smrg	func_source "$lib"
640783e03a40Smrg
640883e03a40Smrg	# Convert "-framework foo" to "foo.ltframework"
640983e03a40Smrg	if test -n "$inherited_linker_flags"; then
641083e03a40Smrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
641183e03a40Smrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
641283e03a40Smrg	    case " $new_inherited_linker_flags " in
641383e03a40Smrg	      *" $tmp_inherited_linker_flag "*) ;;
641483e03a40Smrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
641583e03a40Smrg	    esac
641683e03a40Smrg	  done
641783e03a40Smrg	fi
641883e03a40Smrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
641983e03a40Smrg	if test "$linkmode,$pass" = "lib,link" ||
642083e03a40Smrg	   test "$linkmode,$pass" = "prog,scan" ||
642183e03a40Smrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
642283e03a40Smrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
642383e03a40Smrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
642483e03a40Smrg	fi
642583e03a40Smrg
642683e03a40Smrg	if test "$pass" = conv; then
642783e03a40Smrg	  # Only check for convenience libraries
642883e03a40Smrg	  deplibs="$lib $deplibs"
642983e03a40Smrg	  if test -z "$libdir"; then
643083e03a40Smrg	    if test -z "$old_library"; then
643183e03a40Smrg	      func_fatal_error "cannot find name of link library for \`$lib'"
643283e03a40Smrg	    fi
643383e03a40Smrg	    # It is a libtool convenience library, so add in its objects.
643483e03a40Smrg	    func_append convenience " $ladir/$objdir/$old_library"
643583e03a40Smrg	    func_append old_convenience " $ladir/$objdir/$old_library"
643683e03a40Smrg	    tmp_libs=
643783e03a40Smrg	    for deplib in $dependency_libs; do
643883e03a40Smrg	      deplibs="$deplib $deplibs"
643983e03a40Smrg	      if $opt_preserve_dup_deps ; then
644083e03a40Smrg		case "$tmp_libs " in
644183e03a40Smrg		*" $deplib "*) func_append specialdeplibs " $deplib" ;;
644283e03a40Smrg		esac
644383e03a40Smrg	      fi
644483e03a40Smrg	      func_append tmp_libs " $deplib"
644583e03a40Smrg	    done
644683e03a40Smrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
644783e03a40Smrg	    func_fatal_error "\`$lib' is not a convenience library"
644883e03a40Smrg	  fi
644983e03a40Smrg	  continue
645083e03a40Smrg	fi # $pass = conv
645183e03a40Smrg
645283e03a40Smrg
645383e03a40Smrg	# Get the name of the library we link against.
645483e03a40Smrg	linklib=
645583e03a40Smrg	if test -n "$old_library" &&
645683e03a40Smrg	   { test "$prefer_static_libs" = yes ||
645783e03a40Smrg	     test "$prefer_static_libs,$installed" = "built,no"; }; then
645883e03a40Smrg	  linklib=$old_library
645983e03a40Smrg	else
646083e03a40Smrg	  for l in $old_library $library_names; do
646183e03a40Smrg	    linklib="$l"
646283e03a40Smrg	  done
646383e03a40Smrg	fi
646483e03a40Smrg	if test -z "$linklib"; then
646583e03a40Smrg	  func_fatal_error "cannot find name of link library for \`$lib'"
646683e03a40Smrg	fi
646783e03a40Smrg
646883e03a40Smrg	# This library was specified with -dlopen.
646983e03a40Smrg	if test "$pass" = dlopen; then
647083e03a40Smrg	  if test -z "$libdir"; then
647183e03a40Smrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
647283e03a40Smrg	  fi
647383e03a40Smrg	  if test -z "$dlname" ||
647483e03a40Smrg	     test "$dlopen_support" != yes ||
647583e03a40Smrg	     test "$build_libtool_libs" = no; then
647683e03a40Smrg	    # If there is no dlname, no dlopen support or we're linking
647783e03a40Smrg	    # statically, we need to preload.  We also need to preload any
647883e03a40Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
647983e03a40Smrg	    # bomb out in the load deplibs phase.
648083e03a40Smrg	    func_append dlprefiles " $lib $dependency_libs"
648183e03a40Smrg	  else
648283e03a40Smrg	    func_append newdlfiles " $lib"
648383e03a40Smrg	  fi
648483e03a40Smrg	  continue
648583e03a40Smrg	fi # $pass = dlopen
648683e03a40Smrg
648783e03a40Smrg	# We need an absolute path.
648883e03a40Smrg	case $ladir in
648983e03a40Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
649083e03a40Smrg	*)
649183e03a40Smrg	  abs_ladir=`cd "$ladir" && pwd`
649283e03a40Smrg	  if test -z "$abs_ladir"; then
649383e03a40Smrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
649483e03a40Smrg	    func_warning "passing it literally to the linker, although it might fail"
649583e03a40Smrg	    abs_ladir="$ladir"
649683e03a40Smrg	  fi
649783e03a40Smrg	  ;;
649883e03a40Smrg	esac
649983e03a40Smrg	func_basename "$lib"
650083e03a40Smrg	laname="$func_basename_result"
650183e03a40Smrg
650283e03a40Smrg	# Find the relevant object directory and library name.
650383e03a40Smrg	if test "X$installed" = Xyes; then
650483e03a40Smrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
650583e03a40Smrg	    func_warning "library \`$lib' was moved."
650683e03a40Smrg	    dir="$ladir"
650783e03a40Smrg	    absdir="$abs_ladir"
650883e03a40Smrg	    libdir="$abs_ladir"
650983e03a40Smrg	  else
651083e03a40Smrg	    dir="$lt_sysroot$libdir"
651183e03a40Smrg	    absdir="$lt_sysroot$libdir"
651283e03a40Smrg	  fi
651383e03a40Smrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
651483e03a40Smrg	else
651583e03a40Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
651683e03a40Smrg	    dir="$ladir"
651783e03a40Smrg	    absdir="$abs_ladir"
651883e03a40Smrg	    # Remove this search path later
651983e03a40Smrg	    func_append notinst_path " $abs_ladir"
652083e03a40Smrg	  else
652183e03a40Smrg	    dir="$ladir/$objdir"
652283e03a40Smrg	    absdir="$abs_ladir/$objdir"
652383e03a40Smrg	    # Remove this search path later
652483e03a40Smrg	    func_append notinst_path " $abs_ladir"
652583e03a40Smrg	  fi
652683e03a40Smrg	fi # $installed = yes
652783e03a40Smrg	func_stripname 'lib' '.la' "$laname"
652883e03a40Smrg	name=$func_stripname_result
652983e03a40Smrg
653083e03a40Smrg	# This library was specified with -dlpreopen.
653183e03a40Smrg	if test "$pass" = dlpreopen; then
653283e03a40Smrg	  if test -z "$libdir" && test "$linkmode" = prog; then
653383e03a40Smrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
653483e03a40Smrg	  fi
653583e03a40Smrg	  case "$host" in
653683e03a40Smrg	    # special handling for platforms with PE-DLLs.
653783e03a40Smrg	    *cygwin* | *mingw* | *cegcc* )
653883e03a40Smrg	      # Linker will automatically link against shared library if both
653983e03a40Smrg	      # static and shared are present.  Therefore, ensure we extract
654083e03a40Smrg	      # symbols from the import library if a shared library is present
654183e03a40Smrg	      # (otherwise, the dlopen module name will be incorrect).  We do
654283e03a40Smrg	      # this by putting the import library name into $newdlprefiles.
654383e03a40Smrg	      # We recover the dlopen module name by 'saving' the la file
654483e03a40Smrg	      # name in a special purpose variable, and (later) extracting the
654583e03a40Smrg	      # dlname from the la file.
654683e03a40Smrg	      if test -n "$dlname"; then
654783e03a40Smrg	        func_tr_sh "$dir/$linklib"
654883e03a40Smrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
654983e03a40Smrg	        func_append newdlprefiles " $dir/$linklib"
655083e03a40Smrg	      else
655183e03a40Smrg	        func_append newdlprefiles " $dir/$old_library"
655283e03a40Smrg	        # Keep a list of preopened convenience libraries to check
655383e03a40Smrg	        # that they are being used correctly in the link pass.
655483e03a40Smrg	        test -z "$libdir" && \
655583e03a40Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
655683e03a40Smrg	      fi
655783e03a40Smrg	    ;;
655883e03a40Smrg	    * )
655983e03a40Smrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
656083e03a40Smrg	      # are required to link).
656183e03a40Smrg	      if test -n "$old_library"; then
656283e03a40Smrg	        func_append newdlprefiles " $dir/$old_library"
656383e03a40Smrg	        # Keep a list of preopened convenience libraries to check
656483e03a40Smrg	        # that they are being used correctly in the link pass.
656583e03a40Smrg	        test -z "$libdir" && \
656683e03a40Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
656783e03a40Smrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
656883e03a40Smrg	      elif test -n "$dlname"; then
656983e03a40Smrg	        func_append newdlprefiles " $dir/$dlname"
657083e03a40Smrg	      else
657183e03a40Smrg	        func_append newdlprefiles " $dir/$linklib"
657283e03a40Smrg	      fi
657383e03a40Smrg	    ;;
657483e03a40Smrg	  esac
657583e03a40Smrg	fi # $pass = dlpreopen
657683e03a40Smrg
657783e03a40Smrg	if test -z "$libdir"; then
657883e03a40Smrg	  # Link the convenience library
657983e03a40Smrg	  if test "$linkmode" = lib; then
658083e03a40Smrg	    deplibs="$dir/$old_library $deplibs"
658183e03a40Smrg	  elif test "$linkmode,$pass" = "prog,link"; then
658283e03a40Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
658383e03a40Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
658483e03a40Smrg	  else
658583e03a40Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
658683e03a40Smrg	  fi
658783e03a40Smrg	  continue
658883e03a40Smrg	fi
658983e03a40Smrg
659083e03a40Smrg
659183e03a40Smrg	if test "$linkmode" = prog && test "$pass" != link; then
659283e03a40Smrg	  func_append newlib_search_path " $ladir"
659383e03a40Smrg	  deplibs="$lib $deplibs"
659483e03a40Smrg
659583e03a40Smrg	  linkalldeplibs=no
659683e03a40Smrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
659783e03a40Smrg	     test "$build_libtool_libs" = no; then
659883e03a40Smrg	    linkalldeplibs=yes
659983e03a40Smrg	  fi
660083e03a40Smrg
660183e03a40Smrg	  tmp_libs=
660283e03a40Smrg	  for deplib in $dependency_libs; do
660383e03a40Smrg	    case $deplib in
660483e03a40Smrg	    -L*) func_stripname '-L' '' "$deplib"
660583e03a40Smrg	         func_resolve_sysroot "$func_stripname_result"
660683e03a40Smrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
660783e03a40Smrg		 ;;
660883e03a40Smrg	    esac
660983e03a40Smrg	    # Need to link against all dependency_libs?
661083e03a40Smrg	    if test "$linkalldeplibs" = yes; then
661183e03a40Smrg	      deplibs="$deplib $deplibs"
661283e03a40Smrg	    else
661383e03a40Smrg	      # Need to hardcode shared library paths
661483e03a40Smrg	      # or/and link against static libraries
661583e03a40Smrg	      newdependency_libs="$deplib $newdependency_libs"
661683e03a40Smrg	    fi
661783e03a40Smrg	    if $opt_preserve_dup_deps ; then
661883e03a40Smrg	      case "$tmp_libs " in
661983e03a40Smrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
662083e03a40Smrg	      esac
662183e03a40Smrg	    fi
662283e03a40Smrg	    func_append tmp_libs " $deplib"
662383e03a40Smrg	  done # for deplib
662483e03a40Smrg	  continue
662583e03a40Smrg	fi # $linkmode = prog...
662683e03a40Smrg
662783e03a40Smrg	if test "$linkmode,$pass" = "prog,link"; then
662883e03a40Smrg	  if test -n "$library_names" &&
662983e03a40Smrg	     { { test "$prefer_static_libs" = no ||
663083e03a40Smrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
663183e03a40Smrg	       test -z "$old_library"; }; then
663283e03a40Smrg	    # We need to hardcode the library path
663383e03a40Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
663483e03a40Smrg	      # Make sure the rpath contains only unique directories.
663583e03a40Smrg	      case "$temp_rpath:" in
663683e03a40Smrg	      *"$absdir:"*) ;;
663783e03a40Smrg	      *) func_append temp_rpath "$absdir:" ;;
663883e03a40Smrg	      esac
663983e03a40Smrg	    fi
664083e03a40Smrg
664183e03a40Smrg	    # Hardcode the library path.
664283e03a40Smrg	    # Skip directories that are in the system default run-time
664383e03a40Smrg	    # search path.
664483e03a40Smrg	    case " $sys_lib_dlsearch_path " in
664583e03a40Smrg	    *" $absdir "*) ;;
664683e03a40Smrg	    *)
664783e03a40Smrg	      case "$compile_rpath " in
664883e03a40Smrg	      *" $absdir "*) ;;
664983e03a40Smrg	      *) func_append compile_rpath " $absdir" ;;
665083e03a40Smrg	      esac
665183e03a40Smrg	      ;;
665283e03a40Smrg	    esac
665383e03a40Smrg	    case " $sys_lib_dlsearch_path " in
665483e03a40Smrg	    *" $libdir "*) ;;
665583e03a40Smrg	    *)
665683e03a40Smrg	      case "$finalize_rpath " in
665783e03a40Smrg	      *" $libdir "*) ;;
665883e03a40Smrg	      *) func_append finalize_rpath " $libdir" ;;
665983e03a40Smrg	      esac
666083e03a40Smrg	      ;;
666183e03a40Smrg	    esac
666283e03a40Smrg	  fi # $linkmode,$pass = prog,link...
666383e03a40Smrg
666483e03a40Smrg	  if test "$alldeplibs" = yes &&
666583e03a40Smrg	     { test "$deplibs_check_method" = pass_all ||
666683e03a40Smrg	       { test "$build_libtool_libs" = yes &&
666783e03a40Smrg		 test -n "$library_names"; }; }; then
666883e03a40Smrg	    # We only need to search for static libraries
666983e03a40Smrg	    continue
667083e03a40Smrg	  fi
667183e03a40Smrg	fi
667283e03a40Smrg
667383e03a40Smrg	link_static=no # Whether the deplib will be linked statically
667483e03a40Smrg	use_static_libs=$prefer_static_libs
667583e03a40Smrg	if test "$use_static_libs" = built && test "$installed" = yes; then
667683e03a40Smrg	  use_static_libs=no
667783e03a40Smrg	fi
667883e03a40Smrg	if test -n "$library_names" &&
667983e03a40Smrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
668083e03a40Smrg	  case $host in
668183e03a40Smrg	  *cygwin* | *mingw* | *cegcc*)
668283e03a40Smrg	      # No point in relinking DLLs because paths are not encoded
668383e03a40Smrg	      func_append notinst_deplibs " $lib"
668483e03a40Smrg	      need_relink=no
668583e03a40Smrg	    ;;
668683e03a40Smrg	  *)
668783e03a40Smrg	    if test "$installed" = no; then
668883e03a40Smrg	      func_append notinst_deplibs " $lib"
668983e03a40Smrg	      need_relink=yes
669083e03a40Smrg	    fi
669183e03a40Smrg	    ;;
669283e03a40Smrg	  esac
669383e03a40Smrg	  # This is a shared library
669483e03a40Smrg
669583e03a40Smrg	  # Warn about portability, can't link against -module's on some
669683e03a40Smrg	  # systems (darwin).  Don't bleat about dlopened modules though!
669783e03a40Smrg	  dlopenmodule=""
669883e03a40Smrg	  for dlpremoduletest in $dlprefiles; do
669983e03a40Smrg	    if test "X$dlpremoduletest" = "X$lib"; then
670083e03a40Smrg	      dlopenmodule="$dlpremoduletest"
670183e03a40Smrg	      break
670283e03a40Smrg	    fi
670383e03a40Smrg	  done
670483e03a40Smrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
670583e03a40Smrg	    echo
670683e03a40Smrg	    if test "$linkmode" = prog; then
670783e03a40Smrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
670883e03a40Smrg	    else
670983e03a40Smrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
671083e03a40Smrg	    fi
671183e03a40Smrg	    $ECHO "*** $linklib is not portable!"
671283e03a40Smrg	  fi
671383e03a40Smrg	  if test "$linkmode" = lib &&
671483e03a40Smrg	     test "$hardcode_into_libs" = yes; then
671583e03a40Smrg	    # Hardcode the library path.
671683e03a40Smrg	    # Skip directories that are in the system default run-time
671783e03a40Smrg	    # search path.
671883e03a40Smrg	    case " $sys_lib_dlsearch_path " in
671983e03a40Smrg	    *" $absdir "*) ;;
672083e03a40Smrg	    *)
672183e03a40Smrg	      case "$compile_rpath " in
672283e03a40Smrg	      *" $absdir "*) ;;
672383e03a40Smrg	      *) func_append compile_rpath " $absdir" ;;
672483e03a40Smrg	      esac
672583e03a40Smrg	      ;;
672683e03a40Smrg	    esac
672783e03a40Smrg	    case " $sys_lib_dlsearch_path " in
672883e03a40Smrg	    *" $libdir "*) ;;
672983e03a40Smrg	    *)
673083e03a40Smrg	      case "$finalize_rpath " in
673183e03a40Smrg	      *" $libdir "*) ;;
673283e03a40Smrg	      *) func_append finalize_rpath " $libdir" ;;
673383e03a40Smrg	      esac
673483e03a40Smrg	      ;;
673583e03a40Smrg	    esac
673683e03a40Smrg	  fi
673783e03a40Smrg
673883e03a40Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
673983e03a40Smrg	    # figure out the soname
674083e03a40Smrg	    set dummy $library_names
674183e03a40Smrg	    shift
674283e03a40Smrg	    realname="$1"
674383e03a40Smrg	    shift
674483e03a40Smrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
674583e03a40Smrg	    # use dlname if we got it. it's perfectly good, no?
674683e03a40Smrg	    if test -n "$dlname"; then
674783e03a40Smrg	      soname="$dlname"
674883e03a40Smrg	    elif test -n "$soname_spec"; then
674983e03a40Smrg	      # bleh windows
675083e03a40Smrg	      case $host in
675183e03a40Smrg	      *cygwin* | mingw* | *cegcc*)
675283e03a40Smrg	        func_arith $current - $age
675383e03a40Smrg		major=$func_arith_result
675483e03a40Smrg		versuffix="-$major"
675583e03a40Smrg		;;
675683e03a40Smrg	      esac
675783e03a40Smrg	      eval soname=\"$soname_spec\"
675883e03a40Smrg	    else
675983e03a40Smrg	      soname="$realname"
676083e03a40Smrg	    fi
676183e03a40Smrg
676283e03a40Smrg	    # Make a new name for the extract_expsyms_cmds to use
676383e03a40Smrg	    soroot="$soname"
676483e03a40Smrg	    func_basename "$soroot"
676583e03a40Smrg	    soname="$func_basename_result"
676683e03a40Smrg	    func_stripname 'lib' '.dll' "$soname"
676783e03a40Smrg	    newlib=libimp-$func_stripname_result.a
676883e03a40Smrg
676983e03a40Smrg	    # If the library has no export list, then create one now
677083e03a40Smrg	    if test -f "$output_objdir/$soname-def"; then :
677183e03a40Smrg	    else
677283e03a40Smrg	      func_verbose "extracting exported symbol list from \`$soname'"
677383e03a40Smrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
677483e03a40Smrg	    fi
677583e03a40Smrg
677683e03a40Smrg	    # Create $newlib
677783e03a40Smrg	    if test -f "$output_objdir/$newlib"; then :; else
677883e03a40Smrg	      func_verbose "generating import library for \`$soname'"
677983e03a40Smrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
678083e03a40Smrg	    fi
678183e03a40Smrg	    # make sure the library variables are pointing to the new library
678283e03a40Smrg	    dir=$output_objdir
678383e03a40Smrg	    linklib=$newlib
678483e03a40Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
678583e03a40Smrg
678683e03a40Smrg	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
678783e03a40Smrg	    add_shlibpath=
678883e03a40Smrg	    add_dir=
678983e03a40Smrg	    add=
679083e03a40Smrg	    lib_linked=yes
679183e03a40Smrg	    case $hardcode_action in
679283e03a40Smrg	    immediate | unsupported)
679383e03a40Smrg	      if test "$hardcode_direct" = no; then
679483e03a40Smrg		add="$dir/$linklib"
679583e03a40Smrg		case $host in
679683e03a40Smrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
679783e03a40Smrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
679883e03a40Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
679983e03a40Smrg		    *-*-unixware7*) add_dir="-L$dir" ;;
680083e03a40Smrg		  *-*-darwin* )
680183e03a40Smrg		    # if the lib is a (non-dlopened) module then we can not
680283e03a40Smrg		    # link against it, someone is ignoring the earlier warnings
680383e03a40Smrg		    if /usr/bin/file -L $add 2> /dev/null |
680483e03a40Smrg			 $GREP ": [^:]* bundle" >/dev/null ; then
680583e03a40Smrg		      if test "X$dlopenmodule" != "X$lib"; then
680683e03a40Smrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
680783e03a40Smrg			if test -z "$old_library" ; then
680883e03a40Smrg			  echo
680983e03a40Smrg			  echo "*** And there doesn't seem to be a static archive available"
681083e03a40Smrg			  echo "*** The link will probably fail, sorry"
681183e03a40Smrg			else
681283e03a40Smrg			  add="$dir/$old_library"
681383e03a40Smrg			fi
681483e03a40Smrg		      elif test -n "$old_library"; then
681583e03a40Smrg			add="$dir/$old_library"
681683e03a40Smrg		      fi
681783e03a40Smrg		    fi
681883e03a40Smrg		esac
681983e03a40Smrg	      elif test "$hardcode_minus_L" = no; then
682083e03a40Smrg		case $host in
682183e03a40Smrg		*-*-sunos*) add_shlibpath="$dir" ;;
682283e03a40Smrg		esac
682383e03a40Smrg		add_dir="-L$dir"
682483e03a40Smrg		add="-l$name"
682583e03a40Smrg	      elif test "$hardcode_shlibpath_var" = no; then
682683e03a40Smrg		add_shlibpath="$dir"
682783e03a40Smrg		add="-l$name"
682883e03a40Smrg	      else
682983e03a40Smrg		lib_linked=no
683083e03a40Smrg	      fi
683183e03a40Smrg	      ;;
683283e03a40Smrg	    relink)
683383e03a40Smrg	      if test "$hardcode_direct" = yes &&
683483e03a40Smrg	         test "$hardcode_direct_absolute" = no; then
683583e03a40Smrg		add="$dir/$linklib"
683683e03a40Smrg	      elif test "$hardcode_minus_L" = yes; then
683783e03a40Smrg		add_dir="-L$dir"
683883e03a40Smrg		# Try looking first in the location we're being installed to.
683983e03a40Smrg		if test -n "$inst_prefix_dir"; then
684083e03a40Smrg		  case $libdir in
684183e03a40Smrg		    [\\/]*)
684283e03a40Smrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
684383e03a40Smrg		      ;;
684483e03a40Smrg		  esac
684583e03a40Smrg		fi
684683e03a40Smrg		add="-l$name"
684783e03a40Smrg	      elif test "$hardcode_shlibpath_var" = yes; then
684883e03a40Smrg		add_shlibpath="$dir"
684983e03a40Smrg		add="-l$name"
685083e03a40Smrg	      else
685183e03a40Smrg		lib_linked=no
685283e03a40Smrg	      fi
685383e03a40Smrg	      ;;
685483e03a40Smrg	    *) lib_linked=no ;;
685583e03a40Smrg	    esac
685683e03a40Smrg
685783e03a40Smrg	    if test "$lib_linked" != yes; then
685883e03a40Smrg	      func_fatal_configuration "unsupported hardcode properties"
685983e03a40Smrg	    fi
686083e03a40Smrg
686183e03a40Smrg	    if test -n "$add_shlibpath"; then
686283e03a40Smrg	      case :$compile_shlibpath: in
686383e03a40Smrg	      *":$add_shlibpath:"*) ;;
686483e03a40Smrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
686583e03a40Smrg	      esac
686683e03a40Smrg	    fi
686783e03a40Smrg	    if test "$linkmode" = prog; then
686883e03a40Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
686983e03a40Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
687083e03a40Smrg	    else
687183e03a40Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
687283e03a40Smrg	      test -n "$add" && deplibs="$add $deplibs"
687383e03a40Smrg	      if test "$hardcode_direct" != yes &&
687483e03a40Smrg		 test "$hardcode_minus_L" != yes &&
687583e03a40Smrg		 test "$hardcode_shlibpath_var" = yes; then
687683e03a40Smrg		case :$finalize_shlibpath: in
687783e03a40Smrg		*":$libdir:"*) ;;
687883e03a40Smrg		*) func_append finalize_shlibpath "$libdir:" ;;
687983e03a40Smrg		esac
688083e03a40Smrg	      fi
688183e03a40Smrg	    fi
688283e03a40Smrg	  fi
688383e03a40Smrg
688483e03a40Smrg	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
688583e03a40Smrg	    add_shlibpath=
688683e03a40Smrg	    add_dir=
688783e03a40Smrg	    add=
688883e03a40Smrg	    # Finalize command for both is simple: just hardcode it.
688983e03a40Smrg	    if test "$hardcode_direct" = yes &&
689083e03a40Smrg	       test "$hardcode_direct_absolute" = no; then
689183e03a40Smrg	      add="$libdir/$linklib"
689283e03a40Smrg	    elif test "$hardcode_minus_L" = yes; then
689383e03a40Smrg	      add_dir="-L$libdir"
689483e03a40Smrg	      add="-l$name"
689583e03a40Smrg	    elif test "$hardcode_shlibpath_var" = yes; then
689683e03a40Smrg	      case :$finalize_shlibpath: in
689783e03a40Smrg	      *":$libdir:"*) ;;
689883e03a40Smrg	      *) func_append finalize_shlibpath "$libdir:" ;;
689983e03a40Smrg	      esac
690083e03a40Smrg	      add="-l$name"
690183e03a40Smrg	    elif test "$hardcode_automatic" = yes; then
690283e03a40Smrg	      if test -n "$inst_prefix_dir" &&
690383e03a40Smrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
690483e03a40Smrg		add="$inst_prefix_dir$libdir/$linklib"
690583e03a40Smrg	      else
690683e03a40Smrg		add="$libdir/$linklib"
690783e03a40Smrg	      fi
690883e03a40Smrg	    else
690983e03a40Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
691083e03a40Smrg	      add_dir="-L$libdir"
691183e03a40Smrg	      # Try looking first in the location we're being installed to.
691283e03a40Smrg	      if test -n "$inst_prefix_dir"; then
691383e03a40Smrg		case $libdir in
691483e03a40Smrg		  [\\/]*)
691583e03a40Smrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
691683e03a40Smrg		    ;;
691783e03a40Smrg		esac
691883e03a40Smrg	      fi
691983e03a40Smrg	      add="-l$name"
692083e03a40Smrg	    fi
692183e03a40Smrg
692283e03a40Smrg	    if test "$linkmode" = prog; then
692383e03a40Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
692483e03a40Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
692583e03a40Smrg	    else
692683e03a40Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
692783e03a40Smrg	      test -n "$add" && deplibs="$add $deplibs"
692883e03a40Smrg	    fi
692983e03a40Smrg	  fi
693083e03a40Smrg	elif test "$linkmode" = prog; then
693183e03a40Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
693283e03a40Smrg	  # is not unsupported.  This is valid on all known static and
693383e03a40Smrg	  # shared platforms.
693483e03a40Smrg	  if test "$hardcode_direct" != unsupported; then
693583e03a40Smrg	    test -n "$old_library" && linklib="$old_library"
693683e03a40Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
693783e03a40Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
693883e03a40Smrg	  else
693983e03a40Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
694083e03a40Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
694183e03a40Smrg	  fi
694283e03a40Smrg	elif test "$build_libtool_libs" = yes; then
694383e03a40Smrg	  # Not a shared library
694483e03a40Smrg	  if test "$deplibs_check_method" != pass_all; then
694583e03a40Smrg	    # We're trying link a shared library against a static one
694683e03a40Smrg	    # but the system doesn't support it.
694783e03a40Smrg
694883e03a40Smrg	    # Just print a warning and add the library to dependency_libs so
694983e03a40Smrg	    # that the program can be linked against the static library.
695083e03a40Smrg	    echo
695183e03a40Smrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
695283e03a40Smrg	    echo "*** I have the capability to make that library automatically link in when"
695383e03a40Smrg	    echo "*** you link to this library.  But I can only do this if you have a"
695483e03a40Smrg	    echo "*** shared version of the library, which you do not appear to have."
695583e03a40Smrg	    if test "$module" = yes; then
695683e03a40Smrg	      echo "*** But as you try to build a module library, libtool will still create "
695783e03a40Smrg	      echo "*** a static module, that should work as long as the dlopening application"
695883e03a40Smrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
695983e03a40Smrg	      if test -z "$global_symbol_pipe"; then
696083e03a40Smrg		echo
696183e03a40Smrg		echo "*** However, this would only work if libtool was able to extract symbol"
696283e03a40Smrg		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
696383e03a40Smrg		echo "*** not find such a program.  So, this module is probably useless."
696483e03a40Smrg		echo "*** \`nm' from GNU binutils and a full rebuild may help."
696583e03a40Smrg	      fi
696683e03a40Smrg	      if test "$build_old_libs" = no; then
696783e03a40Smrg		build_libtool_libs=module
696883e03a40Smrg		build_old_libs=yes
696983e03a40Smrg	      else
697083e03a40Smrg		build_libtool_libs=no
697183e03a40Smrg	      fi
697283e03a40Smrg	    fi
697383e03a40Smrg	  else
697483e03a40Smrg	    deplibs="$dir/$old_library $deplibs"
697583e03a40Smrg	    link_static=yes
697683e03a40Smrg	  fi
697783e03a40Smrg	fi # link shared/static library?
697883e03a40Smrg
697983e03a40Smrg	if test "$linkmode" = lib; then
698083e03a40Smrg	  if test -n "$dependency_libs" &&
698183e03a40Smrg	     { test "$hardcode_into_libs" != yes ||
698283e03a40Smrg	       test "$build_old_libs" = yes ||
698383e03a40Smrg	       test "$link_static" = yes; }; then
698483e03a40Smrg	    # Extract -R from dependency_libs
698583e03a40Smrg	    temp_deplibs=
698683e03a40Smrg	    for libdir in $dependency_libs; do
698783e03a40Smrg	      case $libdir in
698883e03a40Smrg	      -R*) func_stripname '-R' '' "$libdir"
698983e03a40Smrg	           temp_xrpath=$func_stripname_result
699083e03a40Smrg		   case " $xrpath " in
699183e03a40Smrg		   *" $temp_xrpath "*) ;;
699283e03a40Smrg		   *) func_append xrpath " $temp_xrpath";;
699383e03a40Smrg		   esac;;
699483e03a40Smrg	      *) func_append temp_deplibs " $libdir";;
699583e03a40Smrg	      esac
699683e03a40Smrg	    done
699783e03a40Smrg	    dependency_libs="$temp_deplibs"
699883e03a40Smrg	  fi
699983e03a40Smrg
700083e03a40Smrg	  func_append newlib_search_path " $absdir"
700183e03a40Smrg	  # Link against this library
700283e03a40Smrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
700383e03a40Smrg	  # ... and its dependency_libs
700483e03a40Smrg	  tmp_libs=
700583e03a40Smrg	  for deplib in $dependency_libs; do
700683e03a40Smrg	    newdependency_libs="$deplib $newdependency_libs"
700783e03a40Smrg	    case $deplib in
700883e03a40Smrg              -L*) func_stripname '-L' '' "$deplib"
700983e03a40Smrg                   func_resolve_sysroot "$func_stripname_result";;
701083e03a40Smrg              *) func_resolve_sysroot "$deplib" ;;
701183e03a40Smrg            esac
701283e03a40Smrg	    if $opt_preserve_dup_deps ; then
701383e03a40Smrg	      case "$tmp_libs " in
701483e03a40Smrg	      *" $func_resolve_sysroot_result "*)
701583e03a40Smrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
701683e03a40Smrg	      esac
701783e03a40Smrg	    fi
701883e03a40Smrg	    func_append tmp_libs " $func_resolve_sysroot_result"
701983e03a40Smrg	  done
702083e03a40Smrg
702183e03a40Smrg	  if test "$link_all_deplibs" != no; then
702283e03a40Smrg	    # Add the search paths of all dependency libraries
702383e03a40Smrg	    for deplib in $dependency_libs; do
702483e03a40Smrg	      path=
702583e03a40Smrg	      case $deplib in
702683e03a40Smrg	      -L*) path="$deplib" ;;
702783e03a40Smrg	      *.la)
702883e03a40Smrg	        func_resolve_sysroot "$deplib"
702983e03a40Smrg	        deplib=$func_resolve_sysroot_result
703083e03a40Smrg	        func_dirname "$deplib" "" "."
703183e03a40Smrg		dir=$func_dirname_result
703283e03a40Smrg		# We need an absolute path.
703383e03a40Smrg		case $dir in
703483e03a40Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
703583e03a40Smrg		*)
703683e03a40Smrg		  absdir=`cd "$dir" && pwd`
703783e03a40Smrg		  if test -z "$absdir"; then
703883e03a40Smrg		    func_warning "cannot determine absolute directory name of \`$dir'"
703983e03a40Smrg		    absdir="$dir"
704083e03a40Smrg		  fi
704183e03a40Smrg		  ;;
704283e03a40Smrg		esac
704383e03a40Smrg		if $GREP "^installed=no" $deplib > /dev/null; then
704483e03a40Smrg		case $host in
704583e03a40Smrg		*-*-darwin*)
704683e03a40Smrg		  depdepl=
704783e03a40Smrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
704883e03a40Smrg		  if test -n "$deplibrary_names" ; then
704983e03a40Smrg		    for tmp in $deplibrary_names ; do
705083e03a40Smrg		      depdepl=$tmp
705183e03a40Smrg		    done
705283e03a40Smrg		    if test -f "$absdir/$objdir/$depdepl" ; then
705383e03a40Smrg		      depdepl="$absdir/$objdir/$depdepl"
705483e03a40Smrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
705583e03a40Smrg                      if test -z "$darwin_install_name"; then
705683e03a40Smrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
705783e03a40Smrg                      fi
705883e03a40Smrg		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
705983e03a40Smrg		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
706083e03a40Smrg		      path=
706183e03a40Smrg		    fi
706283e03a40Smrg		  fi
706383e03a40Smrg		  ;;
706483e03a40Smrg		*)
706583e03a40Smrg		  path="-L$absdir/$objdir"
706683e03a40Smrg		  ;;
706783e03a40Smrg		esac
706883e03a40Smrg		else
706983e03a40Smrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
707083e03a40Smrg		  test -z "$libdir" && \
707183e03a40Smrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
707283e03a40Smrg		  test "$absdir" != "$libdir" && \
707383e03a40Smrg		    func_warning "\`$deplib' seems to be moved"
707483e03a40Smrg
707583e03a40Smrg		  path="-L$absdir"
707683e03a40Smrg		fi
707783e03a40Smrg		;;
707883e03a40Smrg	      esac
707983e03a40Smrg	      case " $deplibs " in
708083e03a40Smrg	      *" $path "*) ;;
708183e03a40Smrg	      *) deplibs="$path $deplibs" ;;
708283e03a40Smrg	      esac
708383e03a40Smrg	    done
708483e03a40Smrg	  fi # link_all_deplibs != no
708583e03a40Smrg	fi # linkmode = lib
708683e03a40Smrg      done # for deplib in $libs
708783e03a40Smrg      if test "$pass" = link; then
708883e03a40Smrg	if test "$linkmode" = "prog"; then
708983e03a40Smrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
709083e03a40Smrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
709183e03a40Smrg	else
709283e03a40Smrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
709383e03a40Smrg	fi
709483e03a40Smrg      fi
709583e03a40Smrg      dependency_libs="$newdependency_libs"
709683e03a40Smrg      if test "$pass" = dlpreopen; then
709783e03a40Smrg	# Link the dlpreopened libraries before other libraries
709883e03a40Smrg	for deplib in $save_deplibs; do
709983e03a40Smrg	  deplibs="$deplib $deplibs"
710083e03a40Smrg	done
710183e03a40Smrg      fi
710283e03a40Smrg      if test "$pass" != dlopen; then
710383e03a40Smrg	if test "$pass" != conv; then
710483e03a40Smrg	  # Make sure lib_search_path contains only unique directories.
710583e03a40Smrg	  lib_search_path=
710683e03a40Smrg	  for dir in $newlib_search_path; do
710783e03a40Smrg	    case "$lib_search_path " in
710883e03a40Smrg	    *" $dir "*) ;;
710983e03a40Smrg	    *) func_append lib_search_path " $dir" ;;
711083e03a40Smrg	    esac
711183e03a40Smrg	  done
711283e03a40Smrg	  newlib_search_path=
711383e03a40Smrg	fi
711483e03a40Smrg
711583e03a40Smrg	if test "$linkmode,$pass" != "prog,link"; then
711683e03a40Smrg	  vars="deplibs"
711783e03a40Smrg	else
711883e03a40Smrg	  vars="compile_deplibs finalize_deplibs"
711983e03a40Smrg	fi
712083e03a40Smrg	for var in $vars dependency_libs; do
712183e03a40Smrg	  # Add libraries to $var in reverse order
712283e03a40Smrg	  eval tmp_libs=\"\$$var\"
712383e03a40Smrg	  new_libs=
712483e03a40Smrg	  for deplib in $tmp_libs; do
712583e03a40Smrg	    # FIXME: Pedantically, this is the right thing to do, so
712683e03a40Smrg	    #        that some nasty dependency loop isn't accidentally
712783e03a40Smrg	    #        broken:
712883e03a40Smrg	    #new_libs="$deplib $new_libs"
712983e03a40Smrg	    # Pragmatically, this seems to cause very few problems in
713083e03a40Smrg	    # practice:
713183e03a40Smrg	    case $deplib in
713283e03a40Smrg	    -L*) new_libs="$deplib $new_libs" ;;
713383e03a40Smrg	    -R*) ;;
713483e03a40Smrg	    *)
713583e03a40Smrg	      # And here is the reason: when a library appears more
713683e03a40Smrg	      # than once as an explicit dependence of a library, or
713783e03a40Smrg	      # is implicitly linked in more than once by the
713883e03a40Smrg	      # compiler, it is considered special, and multiple
713983e03a40Smrg	      # occurrences thereof are not removed.  Compare this
714083e03a40Smrg	      # with having the same library being listed as a
714183e03a40Smrg	      # dependency of multiple other libraries: in this case,
714283e03a40Smrg	      # we know (pedantically, we assume) the library does not
714383e03a40Smrg	      # need to be listed more than once, so we keep only the
714483e03a40Smrg	      # last copy.  This is not always right, but it is rare
714583e03a40Smrg	      # enough that we require users that really mean to play
714683e03a40Smrg	      # such unportable linking tricks to link the library
714783e03a40Smrg	      # using -Wl,-lname, so that libtool does not consider it
714883e03a40Smrg	      # for duplicate removal.
714983e03a40Smrg	      case " $specialdeplibs " in
715083e03a40Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
715183e03a40Smrg	      *)
715283e03a40Smrg		case " $new_libs " in
715383e03a40Smrg		*" $deplib "*) ;;
715483e03a40Smrg		*) new_libs="$deplib $new_libs" ;;
715583e03a40Smrg		esac
715683e03a40Smrg		;;
715783e03a40Smrg	      esac
715883e03a40Smrg	      ;;
715983e03a40Smrg	    esac
716083e03a40Smrg	  done
716183e03a40Smrg	  tmp_libs=
716283e03a40Smrg	  for deplib in $new_libs; do
716383e03a40Smrg	    case $deplib in
716483e03a40Smrg	    -L*)
716583e03a40Smrg	      case " $tmp_libs " in
716683e03a40Smrg	      *" $deplib "*) ;;
716783e03a40Smrg	      *) func_append tmp_libs " $deplib" ;;
716883e03a40Smrg	      esac
716983e03a40Smrg	      ;;
717083e03a40Smrg	    *) func_append tmp_libs " $deplib" ;;
717183e03a40Smrg	    esac
717283e03a40Smrg	  done
717383e03a40Smrg	  eval $var=\"$tmp_libs\"
717483e03a40Smrg	done # for var
717583e03a40Smrg      fi
717683e03a40Smrg      # Last step: remove runtime libs from dependency_libs
717783e03a40Smrg      # (they stay in deplibs)
717883e03a40Smrg      tmp_libs=
717983e03a40Smrg      for i in $dependency_libs ; do
718083e03a40Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
718183e03a40Smrg	*" $i "*)
718283e03a40Smrg	  i=""
718383e03a40Smrg	  ;;
718483e03a40Smrg	esac
718583e03a40Smrg	if test -n "$i" ; then
718683e03a40Smrg	  func_append tmp_libs " $i"
718783e03a40Smrg	fi
718883e03a40Smrg      done
718983e03a40Smrg      dependency_libs=$tmp_libs
719083e03a40Smrg    done # for pass
719183e03a40Smrg    if test "$linkmode" = prog; then
719283e03a40Smrg      dlfiles="$newdlfiles"
719383e03a40Smrg    fi
719483e03a40Smrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
719583e03a40Smrg      dlprefiles="$newdlprefiles"
719683e03a40Smrg    fi
719783e03a40Smrg
719883e03a40Smrg    case $linkmode in
719983e03a40Smrg    oldlib)
720083e03a40Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
720183e03a40Smrg	func_warning "\`-dlopen' is ignored for archives"
720283e03a40Smrg      fi
720383e03a40Smrg
720483e03a40Smrg      case " $deplibs" in
720583e03a40Smrg      *\ -l* | *\ -L*)
720683e03a40Smrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
720783e03a40Smrg      esac
720883e03a40Smrg
720983e03a40Smrg      test -n "$rpath" && \
721083e03a40Smrg	func_warning "\`-rpath' is ignored for archives"
721183e03a40Smrg
721283e03a40Smrg      test -n "$xrpath" && \
721383e03a40Smrg	func_warning "\`-R' is ignored for archives"
721483e03a40Smrg
721583e03a40Smrg      test -n "$vinfo" && \
721683e03a40Smrg	func_warning "\`-version-info/-version-number' is ignored for archives"
721783e03a40Smrg
721883e03a40Smrg      test -n "$release" && \
721983e03a40Smrg	func_warning "\`-release' is ignored for archives"
722083e03a40Smrg
722183e03a40Smrg      test -n "$export_symbols$export_symbols_regex" && \
722283e03a40Smrg	func_warning "\`-export-symbols' is ignored for archives"
722383e03a40Smrg
722483e03a40Smrg      # Now set the variables for building old libraries.
722583e03a40Smrg      build_libtool_libs=no
722683e03a40Smrg      oldlibs="$output"
722783e03a40Smrg      func_append objs "$old_deplibs"
722883e03a40Smrg      ;;
722983e03a40Smrg
723083e03a40Smrg    lib)
723183e03a40Smrg      # Make sure we only generate libraries of the form `libNAME.la'.
723283e03a40Smrg      case $outputname in
723383e03a40Smrg      lib*)
723483e03a40Smrg	func_stripname 'lib' '.la' "$outputname"
723583e03a40Smrg	name=$func_stripname_result
723683e03a40Smrg	eval shared_ext=\"$shrext_cmds\"
723783e03a40Smrg	eval libname=\"$libname_spec\"
723883e03a40Smrg	;;
723983e03a40Smrg      *)
724083e03a40Smrg	test "$module" = no && \
724183e03a40Smrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
724283e03a40Smrg
724383e03a40Smrg	if test "$need_lib_prefix" != no; then
724483e03a40Smrg	  # Add the "lib" prefix for modules if required
724583e03a40Smrg	  func_stripname '' '.la' "$outputname"
724683e03a40Smrg	  name=$func_stripname_result
724783e03a40Smrg	  eval shared_ext=\"$shrext_cmds\"
724883e03a40Smrg	  eval libname=\"$libname_spec\"
724983e03a40Smrg	else
725083e03a40Smrg	  func_stripname '' '.la' "$outputname"
725183e03a40Smrg	  libname=$func_stripname_result
725283e03a40Smrg	fi
725383e03a40Smrg	;;
725483e03a40Smrg      esac
725583e03a40Smrg
725683e03a40Smrg      if test -n "$objs"; then
725783e03a40Smrg	if test "$deplibs_check_method" != pass_all; then
725883e03a40Smrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
725983e03a40Smrg	else
726083e03a40Smrg	  echo
726183e03a40Smrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
726283e03a40Smrg	  $ECHO "*** objects $objs is not portable!"
726383e03a40Smrg	  func_append libobjs " $objs"
726483e03a40Smrg	fi
726583e03a40Smrg      fi
726683e03a40Smrg
726783e03a40Smrg      test "$dlself" != no && \
726883e03a40Smrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
726983e03a40Smrg
727083e03a40Smrg      set dummy $rpath
727183e03a40Smrg      shift
727283e03a40Smrg      test "$#" -gt 1 && \
727383e03a40Smrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
727483e03a40Smrg
727583e03a40Smrg      install_libdir="$1"
727683e03a40Smrg
727783e03a40Smrg      oldlibs=
727883e03a40Smrg      if test -z "$rpath"; then
727983e03a40Smrg	if test "$build_libtool_libs" = yes; then
728083e03a40Smrg	  # Building a libtool convenience library.
728183e03a40Smrg	  # Some compilers have problems with a `.al' extension so
728283e03a40Smrg	  # convenience libraries should have the same extension an
728383e03a40Smrg	  # archive normally would.
728483e03a40Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
728583e03a40Smrg	  build_libtool_libs=convenience
728683e03a40Smrg	  build_old_libs=yes
728783e03a40Smrg	fi
728883e03a40Smrg
728983e03a40Smrg	test -n "$vinfo" && \
729083e03a40Smrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
729183e03a40Smrg
729283e03a40Smrg	test -n "$release" && \
729383e03a40Smrg	  func_warning "\`-release' is ignored for convenience libraries"
729483e03a40Smrg      else
729583e03a40Smrg
729683e03a40Smrg	# Parse the version information argument.
729783e03a40Smrg	save_ifs="$IFS"; IFS=':'
729883e03a40Smrg	set dummy $vinfo 0 0 0
729983e03a40Smrg	shift
730083e03a40Smrg	IFS="$save_ifs"
730183e03a40Smrg
730283e03a40Smrg	test -n "$7" && \
730383e03a40Smrg	  func_fatal_help "too many parameters to \`-version-info'"
730483e03a40Smrg
730583e03a40Smrg	# convert absolute version numbers to libtool ages
730683e03a40Smrg	# this retains compatibility with .la files and attempts
730783e03a40Smrg	# to make the code below a bit more comprehensible
730883e03a40Smrg
730983e03a40Smrg	case $vinfo_number in
731083e03a40Smrg	yes)
731183e03a40Smrg	  number_major="$1"
731283e03a40Smrg	  number_minor="$2"
731383e03a40Smrg	  number_revision="$3"
731483e03a40Smrg	  #
731583e03a40Smrg	  # There are really only two kinds -- those that
731683e03a40Smrg	  # use the current revision as the major version
731783e03a40Smrg	  # and those that subtract age and use age as
731883e03a40Smrg	  # a minor version.  But, then there is irix
731983e03a40Smrg	  # which has an extra 1 added just for fun
732083e03a40Smrg	  #
732183e03a40Smrg	  case $version_type in
732283e03a40Smrg	  darwin|linux|osf|windows|none)
732383e03a40Smrg	    func_arith $number_major + $number_minor
732483e03a40Smrg	    current=$func_arith_result
732583e03a40Smrg	    age="$number_minor"
732683e03a40Smrg	    revision="$number_revision"
732783e03a40Smrg	    ;;
732883e03a40Smrg	  freebsd-aout|freebsd-elf|qnx|sunos)
732983e03a40Smrg	    current="$number_major"
733083e03a40Smrg	    revision="$number_minor"
733183e03a40Smrg	    age="0"
733283e03a40Smrg	    ;;
733383e03a40Smrg	  irix|nonstopux)
733483e03a40Smrg	    func_arith $number_major + $number_minor
733583e03a40Smrg	    current=$func_arith_result
733683e03a40Smrg	    age="$number_minor"
733783e03a40Smrg	    revision="$number_minor"
733883e03a40Smrg	    lt_irix_increment=no
733983e03a40Smrg	    ;;
734083e03a40Smrg	  *)
734183e03a40Smrg	    func_fatal_configuration "$modename: unknown library version type \`$version_type'"
734283e03a40Smrg	    ;;
734383e03a40Smrg	  esac
734483e03a40Smrg	  ;;
734583e03a40Smrg	no)
734683e03a40Smrg	  current="$1"
734783e03a40Smrg	  revision="$2"
734883e03a40Smrg	  age="$3"
734983e03a40Smrg	  ;;
735083e03a40Smrg	esac
735183e03a40Smrg
735283e03a40Smrg	# Check that each of the things are valid numbers.
735383e03a40Smrg	case $current in
735483e03a40Smrg	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]) ;;
735583e03a40Smrg	*)
735683e03a40Smrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
735783e03a40Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
735883e03a40Smrg	  ;;
735983e03a40Smrg	esac
736083e03a40Smrg
736183e03a40Smrg	case $revision in
736283e03a40Smrg	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]) ;;
736383e03a40Smrg	*)
736483e03a40Smrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
736583e03a40Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
736683e03a40Smrg	  ;;
736783e03a40Smrg	esac
736883e03a40Smrg
736983e03a40Smrg	case $age in
737083e03a40Smrg	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]) ;;
737183e03a40Smrg	*)
737283e03a40Smrg	  func_error "AGE \`$age' must be a nonnegative integer"
737383e03a40Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
737483e03a40Smrg	  ;;
737583e03a40Smrg	esac
737683e03a40Smrg
737783e03a40Smrg	if test "$age" -gt "$current"; then
737883e03a40Smrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
737983e03a40Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
738083e03a40Smrg	fi
738183e03a40Smrg
738283e03a40Smrg	# Calculate the version variables.
738383e03a40Smrg	major=
738483e03a40Smrg	versuffix=
738583e03a40Smrg	verstring=
738683e03a40Smrg	case $version_type in
738783e03a40Smrg	none) ;;
738883e03a40Smrg
738983e03a40Smrg	darwin)
739083e03a40Smrg	  # Like Linux, but with the current version available in
739183e03a40Smrg	  # verstring for coding it into the library header
739283e03a40Smrg	  func_arith $current - $age
739383e03a40Smrg	  major=.$func_arith_result
739483e03a40Smrg	  versuffix="$major.$age.$revision"
739583e03a40Smrg	  # Darwin ld doesn't like 0 for these options...
739683e03a40Smrg	  func_arith $current + 1
739783e03a40Smrg	  minor_current=$func_arith_result
739883e03a40Smrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
739983e03a40Smrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
740083e03a40Smrg	  ;;
740183e03a40Smrg
740283e03a40Smrg	freebsd-aout)
740383e03a40Smrg	  major=".$current"
740483e03a40Smrg	  versuffix=".$current.$revision";
740583e03a40Smrg	  ;;
740683e03a40Smrg
740783e03a40Smrg	freebsd-elf)
740883e03a40Smrg	  major=".$current"
740983e03a40Smrg	  versuffix=".$current"
741083e03a40Smrg	  ;;
741183e03a40Smrg
741283e03a40Smrg	irix | nonstopux)
741383e03a40Smrg	  if test "X$lt_irix_increment" = "Xno"; then
741483e03a40Smrg	    func_arith $current - $age
741583e03a40Smrg	  else
741683e03a40Smrg	    func_arith $current - $age + 1
741783e03a40Smrg	  fi
741883e03a40Smrg	  major=$func_arith_result
741983e03a40Smrg
742083e03a40Smrg	  case $version_type in
742183e03a40Smrg	    nonstopux) verstring_prefix=nonstopux ;;
742283e03a40Smrg	    *)         verstring_prefix=sgi ;;
742383e03a40Smrg	  esac
742483e03a40Smrg	  verstring="$verstring_prefix$major.$revision"
742583e03a40Smrg
742683e03a40Smrg	  # Add in all the interfaces that we are compatible with.
742783e03a40Smrg	  loop=$revision
742883e03a40Smrg	  while test "$loop" -ne 0; do
742983e03a40Smrg	    func_arith $revision - $loop
743083e03a40Smrg	    iface=$func_arith_result
743183e03a40Smrg	    func_arith $loop - 1
743283e03a40Smrg	    loop=$func_arith_result
743383e03a40Smrg	    verstring="$verstring_prefix$major.$iface:$verstring"
743483e03a40Smrg	  done
743583e03a40Smrg
743683e03a40Smrg	  # Before this point, $major must not contain `.'.
743783e03a40Smrg	  major=.$major
743883e03a40Smrg	  versuffix="$major.$revision"
743983e03a40Smrg	  ;;
744083e03a40Smrg
744183e03a40Smrg	linux)
744283e03a40Smrg	  func_arith $current - $age
744383e03a40Smrg	  major=.$func_arith_result
744483e03a40Smrg	  versuffix="$major.$age.$revision"
744583e03a40Smrg	  ;;
744683e03a40Smrg
744783e03a40Smrg	osf)
744883e03a40Smrg	  func_arith $current - $age
744983e03a40Smrg	  major=.$func_arith_result
745083e03a40Smrg	  versuffix=".$current.$age.$revision"
745183e03a40Smrg	  verstring="$current.$age.$revision"
745283e03a40Smrg
745383e03a40Smrg	  # Add in all the interfaces that we are compatible with.
745483e03a40Smrg	  loop=$age
745583e03a40Smrg	  while test "$loop" -ne 0; do
745683e03a40Smrg	    func_arith $current - $loop
745783e03a40Smrg	    iface=$func_arith_result
745883e03a40Smrg	    func_arith $loop - 1
745983e03a40Smrg	    loop=$func_arith_result
746083e03a40Smrg	    verstring="$verstring:${iface}.0"
746183e03a40Smrg	  done
746283e03a40Smrg
746383e03a40Smrg	  # Make executables depend on our current version.
746483e03a40Smrg	  func_append verstring ":${current}.0"
746583e03a40Smrg	  ;;
746683e03a40Smrg
746783e03a40Smrg	qnx)
746883e03a40Smrg	  major=".$current"
746983e03a40Smrg	  versuffix=".$current"
747083e03a40Smrg	  ;;
747183e03a40Smrg
747283e03a40Smrg	sunos)
747383e03a40Smrg	  major=".$current"
747483e03a40Smrg	  versuffix=".$current.$revision"
747583e03a40Smrg	  ;;
747683e03a40Smrg
747783e03a40Smrg	windows)
747883e03a40Smrg	  # Use '-' rather than '.', since we only want one
747983e03a40Smrg	  # extension on DOS 8.3 filesystems.
748083e03a40Smrg	  func_arith $current - $age
748183e03a40Smrg	  major=$func_arith_result
748283e03a40Smrg	  versuffix="-$major"
748383e03a40Smrg	  ;;
748483e03a40Smrg
748583e03a40Smrg	*)
748683e03a40Smrg	  func_fatal_configuration "unknown library version type \`$version_type'"
748783e03a40Smrg	  ;;
748883e03a40Smrg	esac
748983e03a40Smrg
749083e03a40Smrg	# Clear the version info if we defaulted, and they specified a release.
749183e03a40Smrg	if test -z "$vinfo" && test -n "$release"; then
749283e03a40Smrg	  major=
749383e03a40Smrg	  case $version_type in
749483e03a40Smrg	  darwin)
749583e03a40Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
749683e03a40Smrg	    # problems, so we reset it completely
749783e03a40Smrg	    verstring=
749883e03a40Smrg	    ;;
749983e03a40Smrg	  *)
750083e03a40Smrg	    verstring="0.0"
750183e03a40Smrg	    ;;
750283e03a40Smrg	  esac
750383e03a40Smrg	  if test "$need_version" = no; then
750483e03a40Smrg	    versuffix=
750583e03a40Smrg	  else
750683e03a40Smrg	    versuffix=".0.0"
750783e03a40Smrg	  fi
750883e03a40Smrg	fi
750983e03a40Smrg
751083e03a40Smrg	# Remove version info from name if versioning should be avoided
751183e03a40Smrg	if test "$avoid_version" = yes && test "$need_version" = no; then
751283e03a40Smrg	  major=
751383e03a40Smrg	  versuffix=
751483e03a40Smrg	  verstring=""
751583e03a40Smrg	fi
751683e03a40Smrg
751783e03a40Smrg	# Check to see if the archive will have undefined symbols.
751883e03a40Smrg	if test "$allow_undefined" = yes; then
751983e03a40Smrg	  if test "$allow_undefined_flag" = unsupported; then
752083e03a40Smrg	    func_warning "undefined symbols not allowed in $host shared libraries"
752183e03a40Smrg	    build_libtool_libs=no
752283e03a40Smrg	    build_old_libs=yes
752383e03a40Smrg	  fi
752483e03a40Smrg	else
752583e03a40Smrg	  # Don't allow undefined symbols.
752683e03a40Smrg	  allow_undefined_flag="$no_undefined_flag"
752783e03a40Smrg	fi
752883e03a40Smrg
752983e03a40Smrg      fi
753083e03a40Smrg
753183e03a40Smrg      func_generate_dlsyms "$libname" "$libname" "yes"
753283e03a40Smrg      func_append libobjs " $symfileobj"
753383e03a40Smrg      test "X$libobjs" = "X " && libobjs=
753483e03a40Smrg
753583e03a40Smrg      if test "$opt_mode" != relink; then
753683e03a40Smrg	# Remove our outputs, but don't remove object files since they
753783e03a40Smrg	# may have been created when compiling PIC objects.
753883e03a40Smrg	removelist=
753983e03a40Smrg	tempremovelist=`$ECHO "$output_objdir/*"`
754083e03a40Smrg	for p in $tempremovelist; do
754183e03a40Smrg	  case $p in
754283e03a40Smrg	    *.$objext | *.gcno)
754383e03a40Smrg	       ;;
754483e03a40Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
754583e03a40Smrg	       if test "X$precious_files_regex" != "X"; then
754683e03a40Smrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
754783e03a40Smrg		 then
754883e03a40Smrg		   continue
754983e03a40Smrg		 fi
755083e03a40Smrg	       fi
755183e03a40Smrg	       func_append removelist " $p"
755283e03a40Smrg	       ;;
755383e03a40Smrg	    *) ;;
755483e03a40Smrg	  esac
755583e03a40Smrg	done
755683e03a40Smrg	test -n "$removelist" && \
755783e03a40Smrg	  func_show_eval "${RM}r \$removelist"
755883e03a40Smrg      fi
755983e03a40Smrg
756083e03a40Smrg      # Now set the variables for building old libraries.
756183e03a40Smrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
756283e03a40Smrg	func_append oldlibs " $output_objdir/$libname.$libext"
756383e03a40Smrg
756483e03a40Smrg	# Transform .lo files to .o files.
756583e03a40Smrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
756683e03a40Smrg      fi
756783e03a40Smrg
756883e03a40Smrg      # Eliminate all temporary directories.
756983e03a40Smrg      #for path in $notinst_path; do
757083e03a40Smrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
757183e03a40Smrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
757283e03a40Smrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
757383e03a40Smrg      #done
757483e03a40Smrg
757583e03a40Smrg      if test -n "$xrpath"; then
757683e03a40Smrg	# If the user specified any rpath flags, then add them.
757783e03a40Smrg	temp_xrpath=
757883e03a40Smrg	for libdir in $xrpath; do
757983e03a40Smrg	  func_replace_sysroot "$libdir"
758083e03a40Smrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
758183e03a40Smrg	  case "$finalize_rpath " in
758283e03a40Smrg	  *" $libdir "*) ;;
758383e03a40Smrg	  *) func_append finalize_rpath " $libdir" ;;
758483e03a40Smrg	  esac
758583e03a40Smrg	done
758683e03a40Smrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
758783e03a40Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
758883e03a40Smrg	fi
758983e03a40Smrg      fi
759083e03a40Smrg
759183e03a40Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
759283e03a40Smrg      old_dlfiles="$dlfiles"
759383e03a40Smrg      dlfiles=
759483e03a40Smrg      for lib in $old_dlfiles; do
759583e03a40Smrg	case " $dlprefiles $dlfiles " in
759683e03a40Smrg	*" $lib "*) ;;
759783e03a40Smrg	*) func_append dlfiles " $lib" ;;
759883e03a40Smrg	esac
759983e03a40Smrg      done
760083e03a40Smrg
760183e03a40Smrg      # Make sure dlprefiles contains only unique files
760283e03a40Smrg      old_dlprefiles="$dlprefiles"
760383e03a40Smrg      dlprefiles=
760483e03a40Smrg      for lib in $old_dlprefiles; do
760583e03a40Smrg	case "$dlprefiles " in
760683e03a40Smrg	*" $lib "*) ;;
760783e03a40Smrg	*) func_append dlprefiles " $lib" ;;
760883e03a40Smrg	esac
760983e03a40Smrg      done
761083e03a40Smrg
761183e03a40Smrg      if test "$build_libtool_libs" = yes; then
761283e03a40Smrg	if test -n "$rpath"; then
761383e03a40Smrg	  case $host in
761483e03a40Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
761583e03a40Smrg	    # these systems don't actually have a c library (as such)!
761683e03a40Smrg	    ;;
761783e03a40Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
761883e03a40Smrg	    # Rhapsody C library is in the System framework
761983e03a40Smrg	    func_append deplibs " System.ltframework"
762083e03a40Smrg	    ;;
762183e03a40Smrg	  *-*-netbsd*)
762283e03a40Smrg	    # Don't link with libc until the a.out ld.so is fixed.
762383e03a40Smrg	    ;;
762483e03a40Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
762583e03a40Smrg	    # Do not include libc due to us having libc/libc_r.
762683e03a40Smrg	    ;;
762783e03a40Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
762883e03a40Smrg	    # Causes problems with __ctype
762983e03a40Smrg	    ;;
763083e03a40Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
763183e03a40Smrg	    # Compiler inserts libc in the correct place for threads to work
763283e03a40Smrg	    ;;
763383e03a40Smrg	  *)
763483e03a40Smrg	    # Add libc to deplibs on all other systems if necessary.
763583e03a40Smrg	    if test "$build_libtool_need_lc" = "yes"; then
763683e03a40Smrg	      func_append deplibs " -lc"
763783e03a40Smrg	    fi
763883e03a40Smrg	    ;;
763983e03a40Smrg	  esac
764083e03a40Smrg	fi
764183e03a40Smrg
764283e03a40Smrg	# Transform deplibs into only deplibs that can be linked in shared.
764383e03a40Smrg	name_save=$name
764483e03a40Smrg	libname_save=$libname
764583e03a40Smrg	release_save=$release
764683e03a40Smrg	versuffix_save=$versuffix
764783e03a40Smrg	major_save=$major
764883e03a40Smrg	# I'm not sure if I'm treating the release correctly.  I think
764983e03a40Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
765083e03a40Smrg	# add it in twice.  Is that correct?
765183e03a40Smrg	release=""
765283e03a40Smrg	versuffix=""
765383e03a40Smrg	major=""
765483e03a40Smrg	newdeplibs=
765583e03a40Smrg	droppeddeps=no
765683e03a40Smrg	case $deplibs_check_method in
765783e03a40Smrg	pass_all)
765883e03a40Smrg	  # Don't check for shared/static.  Everything works.
765983e03a40Smrg	  # This might be a little naive.  We might want to check
766083e03a40Smrg	  # whether the library exists or not.  But this is on
766183e03a40Smrg	  # osf3 & osf4 and I'm not really sure... Just
766283e03a40Smrg	  # implementing what was already the behavior.
766383e03a40Smrg	  newdeplibs=$deplibs
766483e03a40Smrg	  ;;
766583e03a40Smrg	test_compile)
766683e03a40Smrg	  # This code stresses the "libraries are programs" paradigm to its
766783e03a40Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
766883e03a40Smrg	  # against the deplibs as a proxy for the library.  Then we can check
766983e03a40Smrg	  # whether they linked in statically or dynamically with ldd.
767083e03a40Smrg	  $opt_dry_run || $RM conftest.c
767183e03a40Smrg	  cat > conftest.c <<EOF
767283e03a40Smrg	  int main() { return 0; }
767383e03a40SmrgEOF
767483e03a40Smrg	  $opt_dry_run || $RM conftest
767583e03a40Smrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
767683e03a40Smrg	    ldd_output=`ldd conftest`
767783e03a40Smrg	    for i in $deplibs; do
767883e03a40Smrg	      case $i in
767983e03a40Smrg	      -l*)
768083e03a40Smrg		func_stripname -l '' "$i"
768183e03a40Smrg		name=$func_stripname_result
768283e03a40Smrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
768383e03a40Smrg		  case " $predeps $postdeps " in
768483e03a40Smrg		  *" $i "*)
768583e03a40Smrg		    func_append newdeplibs " $i"
768683e03a40Smrg		    i=""
768783e03a40Smrg		    ;;
768883e03a40Smrg		  esac
768983e03a40Smrg		fi
769083e03a40Smrg		if test -n "$i" ; then
769183e03a40Smrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
769283e03a40Smrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
769383e03a40Smrg		  set dummy $deplib_matches; shift
769483e03a40Smrg		  deplib_match=$1
769583e03a40Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
769683e03a40Smrg		    func_append newdeplibs " $i"
769783e03a40Smrg		  else
769883e03a40Smrg		    droppeddeps=yes
769983e03a40Smrg		    echo
770083e03a40Smrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
770183e03a40Smrg		    echo "*** I have the capability to make that library automatically link in when"
770283e03a40Smrg		    echo "*** you link to this library.  But I can only do this if you have a"
770383e03a40Smrg		    echo "*** shared version of the library, which I believe you do not have"
770483e03a40Smrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
770583e03a40Smrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
770683e03a40Smrg		  fi
770783e03a40Smrg		fi
770883e03a40Smrg		;;
770983e03a40Smrg	      *)
771083e03a40Smrg		func_append newdeplibs " $i"
771183e03a40Smrg		;;
771283e03a40Smrg	      esac
771383e03a40Smrg	    done
771483e03a40Smrg	  else
771583e03a40Smrg	    # Error occurred in the first compile.  Let's try to salvage
771683e03a40Smrg	    # the situation: Compile a separate program for each library.
771783e03a40Smrg	    for i in $deplibs; do
771883e03a40Smrg	      case $i in
771983e03a40Smrg	      -l*)
772083e03a40Smrg		func_stripname -l '' "$i"
772183e03a40Smrg		name=$func_stripname_result
772283e03a40Smrg		$opt_dry_run || $RM conftest
772383e03a40Smrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
772483e03a40Smrg		  ldd_output=`ldd conftest`
772583e03a40Smrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
772683e03a40Smrg		    case " $predeps $postdeps " in
772783e03a40Smrg		    *" $i "*)
772883e03a40Smrg		      func_append newdeplibs " $i"
772983e03a40Smrg		      i=""
773083e03a40Smrg		      ;;
773183e03a40Smrg		    esac
773283e03a40Smrg		  fi
773383e03a40Smrg		  if test -n "$i" ; then
773483e03a40Smrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
773583e03a40Smrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
773683e03a40Smrg		    set dummy $deplib_matches; shift
773783e03a40Smrg		    deplib_match=$1
773883e03a40Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
773983e03a40Smrg		      func_append newdeplibs " $i"
774083e03a40Smrg		    else
774183e03a40Smrg		      droppeddeps=yes
774283e03a40Smrg		      echo
774383e03a40Smrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
774483e03a40Smrg		      echo "*** I have the capability to make that library automatically link in when"
774583e03a40Smrg		      echo "*** you link to this library.  But I can only do this if you have a"
774683e03a40Smrg		      echo "*** shared version of the library, which you do not appear to have"
774783e03a40Smrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
774883e03a40Smrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
774983e03a40Smrg		    fi
775083e03a40Smrg		  fi
775183e03a40Smrg		else
775283e03a40Smrg		  droppeddeps=yes
775383e03a40Smrg		  echo
775483e03a40Smrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
775583e03a40Smrg		  echo "*** make it link in!  You will probably need to install it or some"
775683e03a40Smrg		  echo "*** library that it depends on before this library will be fully"
775783e03a40Smrg		  echo "*** functional.  Installing it before continuing would be even better."
775883e03a40Smrg		fi
775983e03a40Smrg		;;
776083e03a40Smrg	      *)
776183e03a40Smrg		func_append newdeplibs " $i"
776283e03a40Smrg		;;
776383e03a40Smrg	      esac
776483e03a40Smrg	    done
776583e03a40Smrg	  fi
776683e03a40Smrg	  ;;
776783e03a40Smrg	file_magic*)
776883e03a40Smrg	  set dummy $deplibs_check_method; shift
776983e03a40Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
777083e03a40Smrg	  for a_deplib in $deplibs; do
777183e03a40Smrg	    case $a_deplib in
777283e03a40Smrg	    -l*)
777383e03a40Smrg	      func_stripname -l '' "$a_deplib"
777483e03a40Smrg	      name=$func_stripname_result
777583e03a40Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
777683e03a40Smrg		case " $predeps $postdeps " in
777783e03a40Smrg		*" $a_deplib "*)
777883e03a40Smrg		  func_append newdeplibs " $a_deplib"
777983e03a40Smrg		  a_deplib=""
778083e03a40Smrg		  ;;
778183e03a40Smrg		esac
778283e03a40Smrg	      fi
778383e03a40Smrg	      if test -n "$a_deplib" ; then
778483e03a40Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
778583e03a40Smrg		if test -n "$file_magic_glob"; then
778683e03a40Smrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
778783e03a40Smrg		else
778883e03a40Smrg		  libnameglob=$libname
778983e03a40Smrg		fi
779083e03a40Smrg		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
779183e03a40Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
779283e03a40Smrg		  if test "$want_nocaseglob" = yes; then
779383e03a40Smrg		    shopt -s nocaseglob
779483e03a40Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
779583e03a40Smrg		    $nocaseglob
779683e03a40Smrg		  else
779783e03a40Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
779883e03a40Smrg		  fi
779983e03a40Smrg		  for potent_lib in $potential_libs; do
780083e03a40Smrg		      # Follow soft links.
780183e03a40Smrg		      if ls -lLd "$potent_lib" 2>/dev/null |
780283e03a40Smrg			 $GREP " -> " >/dev/null; then
780383e03a40Smrg			continue
780483e03a40Smrg		      fi
780583e03a40Smrg		      # The statement above tries to avoid entering an
780683e03a40Smrg		      # endless loop below, in case of cyclic links.
780783e03a40Smrg		      # We might still enter an endless loop, since a link
780883e03a40Smrg		      # loop can be closed while we follow links,
780983e03a40Smrg		      # but so what?
781083e03a40Smrg		      potlib="$potent_lib"
781183e03a40Smrg		      while test -h "$potlib" 2>/dev/null; do
781283e03a40Smrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
781383e03a40Smrg			case $potliblink in
781483e03a40Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
781583e03a40Smrg			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
781683e03a40Smrg			esac
781783e03a40Smrg		      done
781883e03a40Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
781983e03a40Smrg			 $SED -e 10q |
782083e03a40Smrg			 $EGREP "$file_magic_regex" > /dev/null; then
782183e03a40Smrg			func_append newdeplibs " $a_deplib"
782283e03a40Smrg			a_deplib=""
782383e03a40Smrg			break 2
782483e03a40Smrg		      fi
782583e03a40Smrg		  done
782683e03a40Smrg		done
782783e03a40Smrg	      fi
782883e03a40Smrg	      if test -n "$a_deplib" ; then
782983e03a40Smrg		droppeddeps=yes
783083e03a40Smrg		echo
783183e03a40Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
783283e03a40Smrg		echo "*** I have the capability to make that library automatically link in when"
783383e03a40Smrg		echo "*** you link to this library.  But I can only do this if you have a"
783483e03a40Smrg		echo "*** shared version of the library, which you do not appear to have"
783583e03a40Smrg		echo "*** because I did check the linker path looking for a file starting"
783683e03a40Smrg		if test -z "$potlib" ; then
783783e03a40Smrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
783883e03a40Smrg		else
783983e03a40Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
784083e03a40Smrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
784183e03a40Smrg		fi
784283e03a40Smrg	      fi
784383e03a40Smrg	      ;;
784483e03a40Smrg	    *)
784583e03a40Smrg	      # Add a -L argument.
784683e03a40Smrg	      func_append newdeplibs " $a_deplib"
784783e03a40Smrg	      ;;
784883e03a40Smrg	    esac
784983e03a40Smrg	  done # Gone through all deplibs.
785083e03a40Smrg	  ;;
785183e03a40Smrg	match_pattern*)
785283e03a40Smrg	  set dummy $deplibs_check_method; shift
785383e03a40Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
785483e03a40Smrg	  for a_deplib in $deplibs; do
785583e03a40Smrg	    case $a_deplib in
785683e03a40Smrg	    -l*)
785783e03a40Smrg	      func_stripname -l '' "$a_deplib"
785883e03a40Smrg	      name=$func_stripname_result
785983e03a40Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
786083e03a40Smrg		case " $predeps $postdeps " in
786183e03a40Smrg		*" $a_deplib "*)
786283e03a40Smrg		  func_append newdeplibs " $a_deplib"
786383e03a40Smrg		  a_deplib=""
786483e03a40Smrg		  ;;
786583e03a40Smrg		esac
786683e03a40Smrg	      fi
786783e03a40Smrg	      if test -n "$a_deplib" ; then
786883e03a40Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
786983e03a40Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
787083e03a40Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
787183e03a40Smrg		  for potent_lib in $potential_libs; do
787283e03a40Smrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
787383e03a40Smrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
787483e03a40Smrg		       $EGREP "$match_pattern_regex" > /dev/null; then
787583e03a40Smrg		      func_append newdeplibs " $a_deplib"
787683e03a40Smrg		      a_deplib=""
787783e03a40Smrg		      break 2
787883e03a40Smrg		    fi
787983e03a40Smrg		  done
788083e03a40Smrg		done
788183e03a40Smrg	      fi
788283e03a40Smrg	      if test -n "$a_deplib" ; then
788383e03a40Smrg		droppeddeps=yes
788483e03a40Smrg		echo
788583e03a40Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
788683e03a40Smrg		echo "*** I have the capability to make that library automatically link in when"
788783e03a40Smrg		echo "*** you link to this library.  But I can only do this if you have a"
788883e03a40Smrg		echo "*** shared version of the library, which you do not appear to have"
788983e03a40Smrg		echo "*** because I did check the linker path looking for a file starting"
789083e03a40Smrg		if test -z "$potlib" ; then
789183e03a40Smrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
789283e03a40Smrg		else
789383e03a40Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
789483e03a40Smrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
789583e03a40Smrg		fi
789683e03a40Smrg	      fi
789783e03a40Smrg	      ;;
789883e03a40Smrg	    *)
789983e03a40Smrg	      # Add a -L argument.
790083e03a40Smrg	      func_append newdeplibs " $a_deplib"
790183e03a40Smrg	      ;;
790283e03a40Smrg	    esac
790383e03a40Smrg	  done # Gone through all deplibs.
790483e03a40Smrg	  ;;
790583e03a40Smrg	none | unknown | *)
790683e03a40Smrg	  newdeplibs=""
790783e03a40Smrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
790883e03a40Smrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
790983e03a40Smrg	    for i in $predeps $postdeps ; do
791083e03a40Smrg	      # can't use Xsed below, because $i might contain '/'
791183e03a40Smrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
791283e03a40Smrg	    done
791383e03a40Smrg	  fi
791483e03a40Smrg	  case $tmp_deplibs in
791583e03a40Smrg	  *[!\	\ ]*)
791683e03a40Smrg	    echo
791783e03a40Smrg	    if test "X$deplibs_check_method" = "Xnone"; then
791883e03a40Smrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
791983e03a40Smrg	    else
792083e03a40Smrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
792183e03a40Smrg	    fi
792283e03a40Smrg	    echo "*** All declared inter-library dependencies are being dropped."
792383e03a40Smrg	    droppeddeps=yes
792483e03a40Smrg	    ;;
792583e03a40Smrg	  esac
792683e03a40Smrg	  ;;
792783e03a40Smrg	esac
792883e03a40Smrg	versuffix=$versuffix_save
792983e03a40Smrg	major=$major_save
793083e03a40Smrg	release=$release_save
793183e03a40Smrg	libname=$libname_save
793283e03a40Smrg	name=$name_save
7933357bfbb2Smrg
793483e03a40Smrg	case $host in
793583e03a40Smrg	*-*-rhapsody* | *-*-darwin1.[012])
793683e03a40Smrg	  # On Rhapsody replace the C library with the System framework
793783e03a40Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
793883e03a40Smrg	  ;;
793983e03a40Smrg	esac
7940357bfbb2Smrg
794183e03a40Smrg	if test "$droppeddeps" = yes; then
794283e03a40Smrg	  if test "$module" = yes; then
794383e03a40Smrg	    echo
794483e03a40Smrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
794583e03a40Smrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
794683e03a40Smrg	    echo "*** a static module, that should work as long as the dlopening"
794783e03a40Smrg	    echo "*** application is linked with the -dlopen flag."
794883e03a40Smrg	    if test -z "$global_symbol_pipe"; then
794983e03a40Smrg	      echo
795083e03a40Smrg	      echo "*** However, this would only work if libtool was able to extract symbol"
795183e03a40Smrg	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
795283e03a40Smrg	      echo "*** not find such a program.  So, this module is probably useless."
795383e03a40Smrg	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
795483e03a40Smrg	    fi
795583e03a40Smrg	    if test "$build_old_libs" = no; then
795683e03a40Smrg	      oldlibs="$output_objdir/$libname.$libext"
795783e03a40Smrg	      build_libtool_libs=module
795883e03a40Smrg	      build_old_libs=yes
795983e03a40Smrg	    else
796083e03a40Smrg	      build_libtool_libs=no
796183e03a40Smrg	    fi
796283e03a40Smrg	  else
796383e03a40Smrg	    echo "*** The inter-library dependencies that have been dropped here will be"
796483e03a40Smrg	    echo "*** automatically added whenever a program is linked with this library"
796583e03a40Smrg	    echo "*** or is declared to -dlopen it."
7966357bfbb2Smrg
796783e03a40Smrg	    if test "$allow_undefined" = no; then
796883e03a40Smrg	      echo
796983e03a40Smrg	      echo "*** Since this library must not contain undefined symbols,"
797083e03a40Smrg	      echo "*** because either the platform does not support them or"
797183e03a40Smrg	      echo "*** it was explicitly requested with -no-undefined,"
797283e03a40Smrg	      echo "*** libtool will only create a static version of it."
797383e03a40Smrg	      if test "$build_old_libs" = no; then
797483e03a40Smrg		oldlibs="$output_objdir/$libname.$libext"
797583e03a40Smrg		build_libtool_libs=module
797683e03a40Smrg		build_old_libs=yes
797783e03a40Smrg	      else
797883e03a40Smrg		build_libtool_libs=no
797983e03a40Smrg	      fi
798083e03a40Smrg	    fi
798183e03a40Smrg	  fi
7982357bfbb2Smrg	fi
798383e03a40Smrg	# Done checking deplibs!
798483e03a40Smrg	deplibs=$newdeplibs
798583e03a40Smrg      fi
798683e03a40Smrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
798783e03a40Smrg      case $host in
798883e03a40Smrg	*-*-darwin*)
798983e03a40Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
799083e03a40Smrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
799183e03a40Smrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
799283e03a40Smrg	  ;;
799383e03a40Smrg      esac
7994357bfbb2Smrg
799583e03a40Smrg      # move library search paths that coincide with paths to not yet
799683e03a40Smrg      # installed libraries to the beginning of the library search list
799783e03a40Smrg      new_libs=
799883e03a40Smrg      for path in $notinst_path; do
799983e03a40Smrg	case " $new_libs " in
800083e03a40Smrg	*" -L$path/$objdir "*) ;;
800183e03a40Smrg	*)
800283e03a40Smrg	  case " $deplibs " in
800383e03a40Smrg	  *" -L$path/$objdir "*)
800483e03a40Smrg	    func_append new_libs " -L$path/$objdir" ;;
800583e03a40Smrg	  esac
800683e03a40Smrg	  ;;
800783e03a40Smrg	esac
800883e03a40Smrg      done
800983e03a40Smrg      for deplib in $deplibs; do
801083e03a40Smrg	case $deplib in
801183e03a40Smrg	-L*)
801283e03a40Smrg	  case " $new_libs " in
801383e03a40Smrg	  *" $deplib "*) ;;
801483e03a40Smrg	  *) func_append new_libs " $deplib" ;;
801583e03a40Smrg	  esac
801683e03a40Smrg	  ;;
801783e03a40Smrg	*) func_append new_libs " $deplib" ;;
801883e03a40Smrg	esac
801983e03a40Smrg      done
802083e03a40Smrg      deplibs="$new_libs"
8021357bfbb2Smrg
802283e03a40Smrg      # All the library-specific variables (install_libdir is set above).
802383e03a40Smrg      library_names=
802483e03a40Smrg      old_library=
802583e03a40Smrg      dlname=
8026357bfbb2Smrg
802783e03a40Smrg      # Test again, we may have decided not to build it any more
802883e03a40Smrg      if test "$build_libtool_libs" = yes; then
802983e03a40Smrg	if test "$hardcode_into_libs" = yes; then
803083e03a40Smrg	  # Hardcode the library paths
803183e03a40Smrg	  hardcode_libdirs=
803283e03a40Smrg	  dep_rpath=
803383e03a40Smrg	  rpath="$finalize_rpath"
803483e03a40Smrg	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
803583e03a40Smrg	  for libdir in $rpath; do
803683e03a40Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
803783e03a40Smrg	      if test -n "$hardcode_libdir_separator"; then
803883e03a40Smrg		func_replace_sysroot "$libdir"
803983e03a40Smrg		libdir=$func_replace_sysroot_result
804083e03a40Smrg		if test -z "$hardcode_libdirs"; then
804183e03a40Smrg		  hardcode_libdirs="$libdir"
804283e03a40Smrg		else
804383e03a40Smrg		  # Just accumulate the unique libdirs.
804483e03a40Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
804583e03a40Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
804683e03a40Smrg		    ;;
804783e03a40Smrg		  *)
804883e03a40Smrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
804983e03a40Smrg		    ;;
805083e03a40Smrg		  esac
805183e03a40Smrg		fi
805283e03a40Smrg	      else
805383e03a40Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
805483e03a40Smrg		func_append dep_rpath " $flag"
805583e03a40Smrg	      fi
805683e03a40Smrg	    elif test -n "$runpath_var"; then
805783e03a40Smrg	      case "$perm_rpath " in
805883e03a40Smrg	      *" $libdir "*) ;;
805983e03a40Smrg	      *) func_apped perm_rpath " $libdir" ;;
806083e03a40Smrg	      esac
806183e03a40Smrg	    fi
806283e03a40Smrg	  done
806383e03a40Smrg	  # Substitute the hardcoded libdirs into the rpath.
806483e03a40Smrg	  if test -n "$hardcode_libdir_separator" &&
806583e03a40Smrg	     test -n "$hardcode_libdirs"; then
806683e03a40Smrg	    libdir="$hardcode_libdirs"
806783e03a40Smrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
806883e03a40Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
806983e03a40Smrg	    else
807083e03a40Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
807183e03a40Smrg	    fi
807283e03a40Smrg	  fi
807383e03a40Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
807483e03a40Smrg	    # We should set the runpath_var.
807583e03a40Smrg	    rpath=
807683e03a40Smrg	    for dir in $perm_rpath; do
807783e03a40Smrg	      func_append rpath "$dir:"
807883e03a40Smrg	    done
807983e03a40Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
808083e03a40Smrg	  fi
808183e03a40Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
8082357bfbb2Smrg	fi
8083357bfbb2Smrg
808483e03a40Smrg	shlibpath="$finalize_shlibpath"
808583e03a40Smrg	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
808683e03a40Smrg	if test -n "$shlibpath"; then
808783e03a40Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
8088357bfbb2Smrg	fi
8089357bfbb2Smrg
809083e03a40Smrg	# Get the real and link names of the library.
809183e03a40Smrg	eval shared_ext=\"$shrext_cmds\"
809283e03a40Smrg	eval library_names=\"$library_names_spec\"
809383e03a40Smrg	set dummy $library_names
809483e03a40Smrg	shift
809583e03a40Smrg	realname="$1"
809683e03a40Smrg	shift
8097357bfbb2Smrg
809883e03a40Smrg	if test -n "$soname_spec"; then
809983e03a40Smrg	  eval soname=\"$soname_spec\"
8100357bfbb2Smrg	else
810183e03a40Smrg	  soname="$realname"
810283e03a40Smrg	fi
810383e03a40Smrg	if test -z "$dlname"; then
810483e03a40Smrg	  dlname=$soname
8105357bfbb2Smrg	fi
8106357bfbb2Smrg
810783e03a40Smrg	lib="$output_objdir/$realname"
810883e03a40Smrg	linknames=
810983e03a40Smrg	for link
811083e03a40Smrg	do
811183e03a40Smrg	  func_append linknames " $link"
811283e03a40Smrg	done
8113357bfbb2Smrg
811483e03a40Smrg	# Use standard objects if they are pic
811583e03a40Smrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
811683e03a40Smrg	test "X$libobjs" = "X " && libobjs=
8117357bfbb2Smrg
811883e03a40Smrg	delfiles=
811983e03a40Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
812083e03a40Smrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
812183e03a40Smrg	  export_symbols="$output_objdir/$libname.uexp"
812283e03a40Smrg	  func_append delfiles " $export_symbols"
812383e03a40Smrg	fi
8124357bfbb2Smrg
812583e03a40Smrg	orig_export_symbols=
812683e03a40Smrg	case $host_os in
812783e03a40Smrg	cygwin* | mingw* | cegcc*)
812883e03a40Smrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
812983e03a40Smrg	    # exporting using user supplied symfile
813083e03a40Smrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
813183e03a40Smrg	      # and it's NOT already a .def file. Must figure out
813283e03a40Smrg	      # which of the given symbols are data symbols and tag
813383e03a40Smrg	      # them as such. So, trigger use of export_symbols_cmds.
813483e03a40Smrg	      # export_symbols gets reassigned inside the "prepare
813583e03a40Smrg	      # the list of exported symbols" if statement, so the
813683e03a40Smrg	      # include_expsyms logic still works.
813783e03a40Smrg	      orig_export_symbols="$export_symbols"
813883e03a40Smrg	      export_symbols=
813983e03a40Smrg	      always_export_symbols=yes
8140357bfbb2Smrg	    fi
8141357bfbb2Smrg	  fi
814283e03a40Smrg	  ;;
814383e03a40Smrg	esac
8144357bfbb2Smrg
814583e03a40Smrg	# Prepare the list of exported symbols
814683e03a40Smrg	if test -z "$export_symbols"; then
814783e03a40Smrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
814883e03a40Smrg	    func_verbose "generating symbol list for \`$libname.la'"
814983e03a40Smrg	    export_symbols="$output_objdir/$libname.exp"
815083e03a40Smrg	    $opt_dry_run || $RM $export_symbols
815183e03a40Smrg	    cmds=$export_symbols_cmds
815283e03a40Smrg	    save_ifs="$IFS"; IFS='~'
815383e03a40Smrg	    for cmd1 in $cmds; do
815483e03a40Smrg	      IFS="$save_ifs"
815583e03a40Smrg	      # Take the normal branch if the nm_file_list_spec branch
815683e03a40Smrg	      # doesn't work or if tool conversion is not needed.
815783e03a40Smrg	      case $nm_file_list_spec~$to_tool_file_cmd in
815883e03a40Smrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
815983e03a40Smrg		  try_normal_branch=yes
816083e03a40Smrg		  eval cmd=\"$cmd1\"
816183e03a40Smrg		  func_len " $cmd"
816283e03a40Smrg		  len=$func_len_result
816383e03a40Smrg		  ;;
816483e03a40Smrg		*)
816583e03a40Smrg		  try_normal_branch=no
816683e03a40Smrg		  ;;
816783e03a40Smrg	      esac
816883e03a40Smrg	      if test "$try_normal_branch" = yes \
816983e03a40Smrg		 && { test "$len" -lt "$max_cmd_len" \
817083e03a40Smrg		      || test "$max_cmd_len" -le -1; }
817183e03a40Smrg	      then
817283e03a40Smrg		func_show_eval "$cmd" 'exit $?'
817383e03a40Smrg		skipped_export=false
817483e03a40Smrg	      elif test -n "$nm_file_list_spec"; then
817583e03a40Smrg		func_basename "$output"
817683e03a40Smrg		output_la=$func_basename_result
817783e03a40Smrg		save_libobjs=$libobjs
817883e03a40Smrg		save_output=$output
817983e03a40Smrg		output=${output_objdir}/${output_la}.nm
818083e03a40Smrg		func_to_tool_file "$output"
818183e03a40Smrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
818283e03a40Smrg		func_append delfiles " $output"
818383e03a40Smrg		func_verbose "creating $NM input file list: $output"
818483e03a40Smrg		for obj in $save_libobjs; do
818583e03a40Smrg		  func_to_tool_file "$obj"
818683e03a40Smrg		  $ECHO "$func_to_tool_file_result"
818783e03a40Smrg		done > "$output"
818883e03a40Smrg		eval cmd=\"$cmd1\"
818983e03a40Smrg		func_show_eval "$cmd" 'exit $?'
819083e03a40Smrg		output=$save_output
819183e03a40Smrg		libobjs=$save_libobjs
819283e03a40Smrg		skipped_export=false
819383e03a40Smrg	      else
819483e03a40Smrg		# The command line is too long to execute in one step.
819583e03a40Smrg		func_verbose "using reloadable object file for export list..."
819683e03a40Smrg		skipped_export=:
819783e03a40Smrg		# Break out early, otherwise skipped_export may be
819883e03a40Smrg		# set to false by a later but shorter cmd.
819983e03a40Smrg		break
820083e03a40Smrg	      fi
820183e03a40Smrg	    done
820283e03a40Smrg	    IFS="$save_ifs"
820383e03a40Smrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
820483e03a40Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
820583e03a40Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
820683e03a40Smrg	    fi
820783e03a40Smrg	  fi
820883e03a40Smrg	fi
820983e03a40Smrg
821083e03a40Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
821183e03a40Smrg	  tmp_export_symbols="$export_symbols"
821283e03a40Smrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
821383e03a40Smrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8214357bfbb2Smrg	fi
8215357bfbb2Smrg
821683e03a40Smrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
821783e03a40Smrg	  # The given exports_symbols file has to be filtered, so filter it.
821883e03a40Smrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
821983e03a40Smrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
822083e03a40Smrg	  # 's' commands which not all seds can handle. GNU sed should be fine
822183e03a40Smrg	  # though. Also, the filter scales superlinearly with the number of
822283e03a40Smrg	  # global variables. join(1) would be nice here, but unfortunately
822383e03a40Smrg	  # isn't a blessed tool.
822483e03a40Smrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
822583e03a40Smrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
822683e03a40Smrg	  export_symbols=$output_objdir/$libname.def
822783e03a40Smrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
822883e03a40Smrg	fi
8229357bfbb2Smrg
823083e03a40Smrg	tmp_deplibs=
823183e03a40Smrg	for test_deplib in $deplibs; do
823283e03a40Smrg	  case " $convenience " in
823383e03a40Smrg	  *" $test_deplib "*) ;;
823483e03a40Smrg	  *)
823583e03a40Smrg	    func_append tmp_deplibs " $test_deplib"
823683e03a40Smrg	    ;;
823783e03a40Smrg	  esac
823883e03a40Smrg	done
823983e03a40Smrg	deplibs="$tmp_deplibs"
8240357bfbb2Smrg
824183e03a40Smrg	if test -n "$convenience"; then
824283e03a40Smrg	  if test -n "$whole_archive_flag_spec" &&
824383e03a40Smrg	    test "$compiler_needs_object" = yes &&
824483e03a40Smrg	    test -z "$libobjs"; then
824583e03a40Smrg	    # extract the archives, so we have objects to list.
824683e03a40Smrg	    # TODO: could optimize this to just extract one archive.
824783e03a40Smrg	    whole_archive_flag_spec=
824883e03a40Smrg	  fi
824983e03a40Smrg	  if test -n "$whole_archive_flag_spec"; then
825083e03a40Smrg	    save_libobjs=$libobjs
825183e03a40Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
825283e03a40Smrg	    test "X$libobjs" = "X " && libobjs=
8253357bfbb2Smrg	  else
825483e03a40Smrg	    gentop="$output_objdir/${outputname}x"
825583e03a40Smrg	    func_append generated " $gentop"
825683e03a40Smrg
825783e03a40Smrg	    func_extract_archives $gentop $convenience
825883e03a40Smrg	    func_append libobjs " $func_extract_archives_result"
825983e03a40Smrg	    test "X$libobjs" = "X " && libobjs=
8260357bfbb2Smrg	  fi
8261357bfbb2Smrg	fi
8262357bfbb2Smrg
826383e03a40Smrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
826483e03a40Smrg	  eval flag=\"$thread_safe_flag_spec\"
826583e03a40Smrg	  func_append linker_flags " $flag"
826683e03a40Smrg	fi
8267357bfbb2Smrg
826883e03a40Smrg	# Make a backup of the uninstalled library when relinking
826983e03a40Smrg	if test "$opt_mode" = relink; then
827083e03a40Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
827183e03a40Smrg	fi
8272357bfbb2Smrg
827383e03a40Smrg	# Do each of the archive commands.
827483e03a40Smrg	if test "$module" = yes && test -n "$module_cmds" ; then
827583e03a40Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
827683e03a40Smrg	    eval test_cmds=\"$module_expsym_cmds\"
827783e03a40Smrg	    cmds=$module_expsym_cmds
827883e03a40Smrg	  else
827983e03a40Smrg	    eval test_cmds=\"$module_cmds\"
828083e03a40Smrg	    cmds=$module_cmds
828183e03a40Smrg	  fi
8282357bfbb2Smrg	else
828383e03a40Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
828483e03a40Smrg	    eval test_cmds=\"$archive_expsym_cmds\"
828583e03a40Smrg	    cmds=$archive_expsym_cmds
828683e03a40Smrg	  else
828783e03a40Smrg	    eval test_cmds=\"$archive_cmds\"
828883e03a40Smrg	    cmds=$archive_cmds
828983e03a40Smrg	  fi
8290357bfbb2Smrg	fi
8291357bfbb2Smrg
829283e03a40Smrg	if test "X$skipped_export" != "X:" &&
829383e03a40Smrg	   func_len " $test_cmds" &&
829483e03a40Smrg	   len=$func_len_result &&
829583e03a40Smrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
829683e03a40Smrg	  :
829783e03a40Smrg	else
829883e03a40Smrg	  # The command line is too long to link in one step, link piecewise
829983e03a40Smrg	  # or, if using GNU ld and skipped_export is not :, use a linker
830083e03a40Smrg	  # script.
8301357bfbb2Smrg
830283e03a40Smrg	  # Save the value of $output and $libobjs because we want to
830383e03a40Smrg	  # use them later.  If we have whole_archive_flag_spec, we
830483e03a40Smrg	  # want to use save_libobjs as it was before
830583e03a40Smrg	  # whole_archive_flag_spec was expanded, because we can't
830683e03a40Smrg	  # assume the linker understands whole_archive_flag_spec.
830783e03a40Smrg	  # This may have to be revisited, in case too many
830883e03a40Smrg	  # convenience libraries get linked in and end up exceeding
830983e03a40Smrg	  # the spec.
831083e03a40Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
831183e03a40Smrg	    save_libobjs=$libobjs
831283e03a40Smrg	  fi
831383e03a40Smrg	  save_output=$output
831483e03a40Smrg	  func_basename "$output"
831583e03a40Smrg	  output_la=$func_basename_result
831683e03a40Smrg
831783e03a40Smrg	  # Clear the reloadable object creation command queue and
831883e03a40Smrg	  # initialize k to one.
831983e03a40Smrg	  test_cmds=
832083e03a40Smrg	  concat_cmds=
832183e03a40Smrg	  objlist=
832283e03a40Smrg	  last_robj=
832383e03a40Smrg	  k=1
832483e03a40Smrg
832583e03a40Smrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
832683e03a40Smrg	    output=${output_objdir}/${output_la}.lnkscript
832783e03a40Smrg	    func_verbose "creating GNU ld script: $output"
832883e03a40Smrg	    echo 'INPUT (' > $output
832983e03a40Smrg	    for obj in $save_libobjs
833083e03a40Smrg	    do
833183e03a40Smrg	      func_to_tool_file "$obj"
833283e03a40Smrg	      $ECHO "$func_to_tool_file_result" >> $output
833383e03a40Smrg	    done
833483e03a40Smrg	    echo ')' >> $output
833583e03a40Smrg	    func_append delfiles " $output"
833683e03a40Smrg	    func_to_tool_file "$output"
833783e03a40Smrg	    output=$func_to_tool_file_result
833883e03a40Smrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
833983e03a40Smrg	    output=${output_objdir}/${output_la}.lnk
834083e03a40Smrg	    func_verbose "creating linker input file list: $output"
834183e03a40Smrg	    : > $output
834283e03a40Smrg	    set x $save_libobjs
834383e03a40Smrg	    shift
834483e03a40Smrg	    firstobj=
834583e03a40Smrg	    if test "$compiler_needs_object" = yes; then
834683e03a40Smrg	      firstobj="$1 "
834783e03a40Smrg	      shift
8348357bfbb2Smrg	    fi
834983e03a40Smrg	    for obj
835083e03a40Smrg	    do
835183e03a40Smrg	      func_to_tool_file "$obj"
835283e03a40Smrg	      $ECHO "$func_to_tool_file_result" >> $output
8353357bfbb2Smrg	    done
835483e03a40Smrg	    func_append delfiles " $output"
835583e03a40Smrg	    func_to_tool_file "$output"
835683e03a40Smrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
835783e03a40Smrg	  else
835883e03a40Smrg	    if test -n "$save_libobjs"; then
835983e03a40Smrg	      func_verbose "creating reloadable object files..."
836083e03a40Smrg	      output=$output_objdir/$output_la-${k}.$objext
836183e03a40Smrg	      eval test_cmds=\"$reload_cmds\"
836283e03a40Smrg	      func_len " $test_cmds"
836383e03a40Smrg	      len0=$func_len_result
836483e03a40Smrg	      len=$len0
836583e03a40Smrg
836683e03a40Smrg	      # Loop over the list of objects to be linked.
836783e03a40Smrg	      for obj in $save_libobjs
836883e03a40Smrg	      do
836983e03a40Smrg		func_len " $obj"
837083e03a40Smrg		func_arith $len + $func_len_result
837183e03a40Smrg		len=$func_arith_result
837283e03a40Smrg		if test "X$objlist" = X ||
837383e03a40Smrg		   test "$len" -lt "$max_cmd_len"; then
837483e03a40Smrg		  func_append objlist " $obj"
837583e03a40Smrg		else
837683e03a40Smrg		  # The command $test_cmds is almost too long, add a
837783e03a40Smrg		  # command to the queue.
837883e03a40Smrg		  if test "$k" -eq 1 ; then
837983e03a40Smrg		    # The first file doesn't have a previous command to add.
838083e03a40Smrg		    reload_objs=$objlist
838183e03a40Smrg		    eval concat_cmds=\"$reload_cmds\"
838283e03a40Smrg		  else
838383e03a40Smrg		    # All subsequent reloadable object files will link in
838483e03a40Smrg		    # the last one created.
838583e03a40Smrg		    reload_objs="$objlist $last_robj"
838683e03a40Smrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
838783e03a40Smrg		  fi
838883e03a40Smrg		  last_robj=$output_objdir/$output_la-${k}.$objext
838983e03a40Smrg		  func_arith $k + 1
839083e03a40Smrg		  k=$func_arith_result
839183e03a40Smrg		  output=$output_objdir/$output_la-${k}.$objext
839283e03a40Smrg		  objlist=" $obj"
839383e03a40Smrg		  func_len " $last_robj"
839483e03a40Smrg		  func_arith $len0 + $func_len_result
839583e03a40Smrg		  len=$func_arith_result
839683e03a40Smrg		fi
839783e03a40Smrg	      done
839883e03a40Smrg	      # Handle the remaining objects by creating one last
839983e03a40Smrg	      # reloadable object file.  All subsequent reloadable object
840083e03a40Smrg	      # files will link in the last one created.
840183e03a40Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
840283e03a40Smrg	      reload_objs="$objlist $last_robj"
840383e03a40Smrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
840483e03a40Smrg	      if test -n "$last_robj"; then
840583e03a40Smrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
8406357bfbb2Smrg	      fi
840783e03a40Smrg	      func_append delfiles " $output"
840883e03a40Smrg
840983e03a40Smrg	    else
841083e03a40Smrg	      output=
841183e03a40Smrg	    fi
841283e03a40Smrg
841383e03a40Smrg	    if ${skipped_export-false}; then
841483e03a40Smrg	      func_verbose "generating symbol list for \`$libname.la'"
841583e03a40Smrg	      export_symbols="$output_objdir/$libname.exp"
841683e03a40Smrg	      $opt_dry_run || $RM $export_symbols
841783e03a40Smrg	      libobjs=$output
841883e03a40Smrg	      # Append the command to create the export file.
841983e03a40Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
842083e03a40Smrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
842183e03a40Smrg	      if test -n "$last_robj"; then
842283e03a40Smrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
8423357bfbb2Smrg	      fi
842483e03a40Smrg	    fi
842583e03a40Smrg
842683e03a40Smrg	    test -n "$save_libobjs" &&
842783e03a40Smrg	      func_verbose "creating a temporary reloadable object file: $output"
842883e03a40Smrg
842983e03a40Smrg	    # Loop through the commands generated above and execute them.
843083e03a40Smrg	    save_ifs="$IFS"; IFS='~'
843183e03a40Smrg	    for cmd in $concat_cmds; do
843283e03a40Smrg	      IFS="$save_ifs"
843383e03a40Smrg	      $opt_silent || {
843483e03a40Smrg		  func_quote_for_expand "$cmd"
843583e03a40Smrg		  eval "func_echo $func_quote_for_expand_result"
843683e03a40Smrg	      }
843783e03a40Smrg	      $opt_dry_run || eval "$cmd" || {
843883e03a40Smrg		lt_exit=$?
843983e03a40Smrg
844083e03a40Smrg		# Restore the uninstalled library and exit
844183e03a40Smrg		if test "$opt_mode" = relink; then
844283e03a40Smrg		  ( cd "$output_objdir" && \
844383e03a40Smrg		    $RM "${realname}T" && \
844483e03a40Smrg		    $MV "${realname}U" "$realname" )
844583e03a40Smrg		fi
844683e03a40Smrg
844783e03a40Smrg		exit $lt_exit
844883e03a40Smrg	      }
8449357bfbb2Smrg	    done
845083e03a40Smrg	    IFS="$save_ifs"
845183e03a40Smrg
845283e03a40Smrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
845383e03a40Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
845483e03a40Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
845583e03a40Smrg	    fi
845683e03a40Smrg	  fi
845783e03a40Smrg
845883e03a40Smrg          if ${skipped_export-false}; then
845983e03a40Smrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
846083e03a40Smrg	      tmp_export_symbols="$export_symbols"
846183e03a40Smrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
846283e03a40Smrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
846383e03a40Smrg	    fi
846483e03a40Smrg
846583e03a40Smrg	    if test -n "$orig_export_symbols"; then
846683e03a40Smrg	      # The given exports_symbols file has to be filtered, so filter it.
846783e03a40Smrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
846883e03a40Smrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
846983e03a40Smrg	      # 's' commands which not all seds can handle. GNU sed should be fine
847083e03a40Smrg	      # though. Also, the filter scales superlinearly with the number of
847183e03a40Smrg	      # global variables. join(1) would be nice here, but unfortunately
847283e03a40Smrg	      # isn't a blessed tool.
847383e03a40Smrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
847483e03a40Smrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
847583e03a40Smrg	      export_symbols=$output_objdir/$libname.def
847683e03a40Smrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
847783e03a40Smrg	    fi
847883e03a40Smrg	  fi
847983e03a40Smrg
848083e03a40Smrg	  libobjs=$output
848183e03a40Smrg	  # Restore the value of output.
848283e03a40Smrg	  output=$save_output
848383e03a40Smrg
848483e03a40Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
848583e03a40Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
848683e03a40Smrg	    test "X$libobjs" = "X " && libobjs=
848783e03a40Smrg	  fi
848883e03a40Smrg	  # Expand the library linking commands again to reset the
848983e03a40Smrg	  # value of $libobjs for piecewise linking.
849083e03a40Smrg
849183e03a40Smrg	  # Do each of the archive commands.
849283e03a40Smrg	  if test "$module" = yes && test -n "$module_cmds" ; then
849383e03a40Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
849483e03a40Smrg	      cmds=$module_expsym_cmds
849583e03a40Smrg	    else
849683e03a40Smrg	      cmds=$module_cmds
849783e03a40Smrg	    fi
8498357bfbb2Smrg	  else
849983e03a40Smrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
850083e03a40Smrg	      cmds=$archive_expsym_cmds
850183e03a40Smrg	    else
850283e03a40Smrg	      cmds=$archive_cmds
850383e03a40Smrg	    fi
8504357bfbb2Smrg	  fi
850583e03a40Smrg	fi
8506357bfbb2Smrg
850783e03a40Smrg	if test -n "$delfiles"; then
850883e03a40Smrg	  # Append the command to remove temporary files to $cmds.
850983e03a40Smrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
851083e03a40Smrg	fi
8511357bfbb2Smrg
851283e03a40Smrg	# Add any objects from preloaded convenience libraries
851383e03a40Smrg	if test -n "$dlprefiles"; then
851483e03a40Smrg	  gentop="$output_objdir/${outputname}x"
851583e03a40Smrg	  func_append generated " $gentop"
8516357bfbb2Smrg
851783e03a40Smrg	  func_extract_archives $gentop $dlprefiles
851883e03a40Smrg	  func_append libobjs " $func_extract_archives_result"
851983e03a40Smrg	  test "X$libobjs" = "X " && libobjs=
852083e03a40Smrg	fi
8521357bfbb2Smrg
852283e03a40Smrg	save_ifs="$IFS"; IFS='~'
852383e03a40Smrg	for cmd in $cmds; do
852483e03a40Smrg	  IFS="$save_ifs"
852583e03a40Smrg	  eval cmd=\"$cmd\"
852683e03a40Smrg	  $opt_silent || {
852783e03a40Smrg	    func_quote_for_expand "$cmd"
852883e03a40Smrg	    eval "func_echo $func_quote_for_expand_result"
852983e03a40Smrg	  }
853083e03a40Smrg	  $opt_dry_run || eval "$cmd" || {
853183e03a40Smrg	    lt_exit=$?
8532357bfbb2Smrg
853383e03a40Smrg	    # Restore the uninstalled library and exit
853483e03a40Smrg	    if test "$opt_mode" = relink; then
853583e03a40Smrg	      ( cd "$output_objdir" && \
853683e03a40Smrg	        $RM "${realname}T" && \
853783e03a40Smrg		$MV "${realname}U" "$realname" )
853883e03a40Smrg	    fi
8539357bfbb2Smrg
854083e03a40Smrg	    exit $lt_exit
854183e03a40Smrg	  }
854283e03a40Smrg	done
854383e03a40Smrg	IFS="$save_ifs"
8544357bfbb2Smrg
854583e03a40Smrg	# Restore the uninstalled library and exit
854683e03a40Smrg	if test "$opt_mode" = relink; then
854783e03a40Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
8548357bfbb2Smrg
854983e03a40Smrg	  if test -n "$convenience"; then
855083e03a40Smrg	    if test -z "$whole_archive_flag_spec"; then
855183e03a40Smrg	      func_show_eval '${RM}r "$gentop"'
855283e03a40Smrg	    fi
855383e03a40Smrg	  fi
8554357bfbb2Smrg
855583e03a40Smrg	  exit $EXIT_SUCCESS
855683e03a40Smrg	fi
855783e03a40Smrg
855883e03a40Smrg	# Create links to the real library.
855983e03a40Smrg	for linkname in $linknames; do
856083e03a40Smrg	  if test "$realname" != "$linkname"; then
856183e03a40Smrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
8562357bfbb2Smrg	  fi
8563357bfbb2Smrg	done
8564357bfbb2Smrg
856583e03a40Smrg	# If -module or -export-dynamic was specified, set the dlname.
856683e03a40Smrg	if test "$module" = yes || test "$export_dynamic" = yes; then
856783e03a40Smrg	  # On all known operating systems, these are identical.
856883e03a40Smrg	  dlname="$soname"
856983e03a40Smrg	fi
857083e03a40Smrg      fi
8571357bfbb2Smrg      ;;
8572357bfbb2Smrg
857383e03a40Smrg    obj)
857483e03a40Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
857583e03a40Smrg	func_warning "\`-dlopen' is ignored for objects"
857683e03a40Smrg      fi
8577357bfbb2Smrg
857883e03a40Smrg      case " $deplibs" in
857983e03a40Smrg      *\ -l* | *\ -L*)
858083e03a40Smrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
8581357bfbb2Smrg      esac
8582357bfbb2Smrg
858383e03a40Smrg      test -n "$rpath" && \
858483e03a40Smrg	func_warning "\`-rpath' is ignored for objects"
8585357bfbb2Smrg
858683e03a40Smrg      test -n "$xrpath" && \
858783e03a40Smrg	func_warning "\`-R' is ignored for objects"
8588357bfbb2Smrg
858983e03a40Smrg      test -n "$vinfo" && \
859083e03a40Smrg	func_warning "\`-version-info' is ignored for objects"
859183e03a40Smrg
859283e03a40Smrg      test -n "$release" && \
859383e03a40Smrg	func_warning "\`-release' is ignored for objects"
859483e03a40Smrg
859583e03a40Smrg      case $output in
859683e03a40Smrg      *.lo)
859783e03a40Smrg	test -n "$objs$old_deplibs" && \
859883e03a40Smrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
859983e03a40Smrg
860083e03a40Smrg	libobj=$output
860183e03a40Smrg	func_lo2o "$libobj"
860283e03a40Smrg	obj=$func_lo2o_result
8603357bfbb2Smrg	;;
8604357bfbb2Smrg      *)
860583e03a40Smrg	libobj=
860683e03a40Smrg	obj="$output"
8607357bfbb2Smrg	;;
8608357bfbb2Smrg      esac
8609357bfbb2Smrg
861083e03a40Smrg      # Delete the old objects.
861183e03a40Smrg      $opt_dry_run || $RM $obj $libobj
8612357bfbb2Smrg
861383e03a40Smrg      # Objects from convenience libraries.  This assumes
861483e03a40Smrg      # single-version convenience libraries.  Whenever we create
861583e03a40Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
861683e03a40Smrg      # the extraction.
861783e03a40Smrg      reload_conv_objs=
861883e03a40Smrg      gentop=
861983e03a40Smrg      # reload_cmds runs $LD directly, so let us get rid of
862083e03a40Smrg      # -Wl from whole_archive_flag_spec and hope we can get by with
862183e03a40Smrg      # turning comma into space..
862283e03a40Smrg      wl=
8623357bfbb2Smrg
862483e03a40Smrg      if test -n "$convenience"; then
862583e03a40Smrg	if test -n "$whole_archive_flag_spec"; then
862683e03a40Smrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
862783e03a40Smrg	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
862883e03a40Smrg	else
862983e03a40Smrg	  gentop="$output_objdir/${obj}x"
863083e03a40Smrg	  func_append generated " $gentop"
8631357bfbb2Smrg
863283e03a40Smrg	  func_extract_archives $gentop $convenience
863383e03a40Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
863483e03a40Smrg	fi
8635357bfbb2Smrg      fi
8636357bfbb2Smrg
863783e03a40Smrg      # If we're not building shared, we need to use non_pic_objs
863883e03a40Smrg      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
8639357bfbb2Smrg
864083e03a40Smrg      # Create the old-style object.
864183e03a40Smrg      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
8642357bfbb2Smrg
864383e03a40Smrg      output="$obj"
864483e03a40Smrg      func_execute_cmds "$reload_cmds" 'exit $?'
864583e03a40Smrg
864683e03a40Smrg      # Exit if we aren't doing a library object file.
864783e03a40Smrg      if test -z "$libobj"; then
864883e03a40Smrg	if test -n "$gentop"; then
864983e03a40Smrg	  func_show_eval '${RM}r "$gentop"'
865083e03a40Smrg	fi
865183e03a40Smrg
865283e03a40Smrg	exit $EXIT_SUCCESS
8653357bfbb2Smrg      fi
865483e03a40Smrg
865583e03a40Smrg      if test "$build_libtool_libs" != yes; then
865683e03a40Smrg	if test -n "$gentop"; then
865783e03a40Smrg	  func_show_eval '${RM}r "$gentop"'
865883e03a40Smrg	fi
865983e03a40Smrg
866083e03a40Smrg	# Create an invalid libtool object if no PIC, so that we don't
866183e03a40Smrg	# accidentally link it into a program.
866283e03a40Smrg	# $show "echo timestamp > $libobj"
866383e03a40Smrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
866483e03a40Smrg	exit $EXIT_SUCCESS
866583e03a40Smrg      fi
866683e03a40Smrg
866783e03a40Smrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
866883e03a40Smrg	# Only do commands if we really have different PIC objects.
866983e03a40Smrg	reload_objs="$libobjs $reload_conv_objs"
867083e03a40Smrg	output="$libobj"
867183e03a40Smrg	func_execute_cmds "$reload_cmds" 'exit $?'
867283e03a40Smrg      fi
867383e03a40Smrg
867483e03a40Smrg      if test -n "$gentop"; then
867583e03a40Smrg	func_show_eval '${RM}r "$gentop"'
867683e03a40Smrg      fi
867783e03a40Smrg
867883e03a40Smrg      exit $EXIT_SUCCESS
8679357bfbb2Smrg      ;;
8680357bfbb2Smrg
868183e03a40Smrg    prog)
868283e03a40Smrg      case $host in
868383e03a40Smrg	*cygwin*) func_stripname '' '.exe' "$output"
868483e03a40Smrg	          output=$func_stripname_result.exe;;
868583e03a40Smrg      esac
868683e03a40Smrg      test -n "$vinfo" && \
868783e03a40Smrg	func_warning "\`-version-info' is ignored for programs"
8688357bfbb2Smrg
868983e03a40Smrg      test -n "$release" && \
869083e03a40Smrg	func_warning "\`-release' is ignored for programs"
8691357bfbb2Smrg
869283e03a40Smrg      test "$preload" = yes \
869383e03a40Smrg        && test "$dlopen_support" = unknown \
869483e03a40Smrg	&& test "$dlopen_self" = unknown \
869583e03a40Smrg	&& test "$dlopen_self_static" = unknown && \
869683e03a40Smrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
869783e03a40Smrg
869883e03a40Smrg      case $host in
869983e03a40Smrg      *-*-rhapsody* | *-*-darwin1.[012])
870083e03a40Smrg	# On Rhapsody replace the C library is the System framework
870183e03a40Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
870283e03a40Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
8703357bfbb2Smrg	;;
870483e03a40Smrg      esac
8705357bfbb2Smrg
870683e03a40Smrg      case $host in
870783e03a40Smrg      *-*-darwin*)
870883e03a40Smrg	# Don't allow lazy linking, it breaks C++ global constructors
870983e03a40Smrg	# But is supposedly fixed on 10.4 or later (yay!).
871083e03a40Smrg	if test "$tagname" = CXX ; then
871183e03a40Smrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
871283e03a40Smrg	    10.[0123])
871383e03a40Smrg	      func_append compile_command " ${wl}-bind_at_load"
871483e03a40Smrg	      func_append finalize_command " ${wl}-bind_at_load"
871583e03a40Smrg	    ;;
871683e03a40Smrg	  esac
8717357bfbb2Smrg	fi
871883e03a40Smrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
871983e03a40Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
872083e03a40Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
872183e03a40Smrg	;;
872283e03a40Smrg      esac
8723357bfbb2Smrg
872483e03a40Smrg
872583e03a40Smrg      # move library search paths that coincide with paths to not yet
872683e03a40Smrg      # installed libraries to the beginning of the library search list
872783e03a40Smrg      new_libs=
872883e03a40Smrg      for path in $notinst_path; do
872983e03a40Smrg	case " $new_libs " in
873083e03a40Smrg	*" -L$path/$objdir "*) ;;
873183e03a40Smrg	*)
873283e03a40Smrg	  case " $compile_deplibs " in
873383e03a40Smrg	  *" -L$path/$objdir "*)
873483e03a40Smrg	    func_append new_libs " -L$path/$objdir" ;;
873583e03a40Smrg	  esac
873683e03a40Smrg	  ;;
873783e03a40Smrg	esac
873883e03a40Smrg      done
873983e03a40Smrg      for deplib in $compile_deplibs; do
874083e03a40Smrg	case $deplib in
874183e03a40Smrg	-L*)
874283e03a40Smrg	  case " $new_libs " in
874383e03a40Smrg	  *" $deplib "*) ;;
874483e03a40Smrg	  *) func_append new_libs " $deplib" ;;
874583e03a40Smrg	  esac
874683e03a40Smrg	  ;;
874783e03a40Smrg	*) func_append new_libs " $deplib" ;;
8748357bfbb2Smrg	esac
874983e03a40Smrg      done
875083e03a40Smrg      compile_deplibs="$new_libs"
8751357bfbb2Smrg
875283e03a40Smrg
875383e03a40Smrg      func_append compile_command " $compile_deplibs"
875483e03a40Smrg      func_append finalize_command " $finalize_deplibs"
875583e03a40Smrg
875683e03a40Smrg      if test -n "$rpath$xrpath"; then
875783e03a40Smrg	# If the user specified any rpath flags, then add them.
875883e03a40Smrg	for libdir in $rpath $xrpath; do
875983e03a40Smrg	  # This is the magic to use -rpath.
876083e03a40Smrg	  case "$finalize_rpath " in
8761357bfbb2Smrg	  *" $libdir "*) ;;
876283e03a40Smrg	  *) func_append finalize_rpath " $libdir" ;;
8763357bfbb2Smrg	  esac
876483e03a40Smrg	done
876583e03a40Smrg      fi
876683e03a40Smrg
876783e03a40Smrg      # Now hardcode the library paths
876883e03a40Smrg      rpath=
876983e03a40Smrg      hardcode_libdirs=
877083e03a40Smrg      for libdir in $compile_rpath $finalize_rpath; do
877183e03a40Smrg	if test -n "$hardcode_libdir_flag_spec"; then
877283e03a40Smrg	  if test -n "$hardcode_libdir_separator"; then
877383e03a40Smrg	    if test -z "$hardcode_libdirs"; then
877483e03a40Smrg	      hardcode_libdirs="$libdir"
877583e03a40Smrg	    else
877683e03a40Smrg	      # Just accumulate the unique libdirs.
877783e03a40Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
877883e03a40Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
877983e03a40Smrg		;;
878083e03a40Smrg	      *)
878183e03a40Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
878283e03a40Smrg		;;
878383e03a40Smrg	      esac
878483e03a40Smrg	    fi
878583e03a40Smrg	  else
878683e03a40Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
878783e03a40Smrg	    func_append rpath " $flag"
878883e03a40Smrg	  fi
878983e03a40Smrg	elif test -n "$runpath_var"; then
879083e03a40Smrg	  case "$perm_rpath " in
8791357bfbb2Smrg	  *" $libdir "*) ;;
879283e03a40Smrg	  *) func_append perm_rpath " $libdir" ;;
8793357bfbb2Smrg	  esac
8794357bfbb2Smrg	fi
879583e03a40Smrg	case $host in
879683e03a40Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
879783e03a40Smrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
879883e03a40Smrg	  case :$dllsearchpath: in
879983e03a40Smrg	  *":$libdir:"*) ;;
880083e03a40Smrg	  ::) dllsearchpath=$libdir;;
880183e03a40Smrg	  *) func_append dllsearchpath ":$libdir";;
880283e03a40Smrg	  esac
880383e03a40Smrg	  case :$dllsearchpath: in
880483e03a40Smrg	  *":$testbindir:"*) ;;
880583e03a40Smrg	  ::) dllsearchpath=$testbindir;;
880683e03a40Smrg	  *) func_append dllsearchpath ":$testbindir";;
880783e03a40Smrg	  esac
880883e03a40Smrg	  ;;
880983e03a40Smrg	esac
881083e03a40Smrg      done
881183e03a40Smrg      # Substitute the hardcoded libdirs into the rpath.
881283e03a40Smrg      if test -n "$hardcode_libdir_separator" &&
881383e03a40Smrg	 test -n "$hardcode_libdirs"; then
881483e03a40Smrg	libdir="$hardcode_libdirs"
881583e03a40Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
881683e03a40Smrg      fi
881783e03a40Smrg      compile_rpath="$rpath"
8818357bfbb2Smrg
881983e03a40Smrg      rpath=
882083e03a40Smrg      hardcode_libdirs=
882183e03a40Smrg      for libdir in $finalize_rpath; do
882283e03a40Smrg	if test -n "$hardcode_libdir_flag_spec"; then
882383e03a40Smrg	  if test -n "$hardcode_libdir_separator"; then
882483e03a40Smrg	    if test -z "$hardcode_libdirs"; then
882583e03a40Smrg	      hardcode_libdirs="$libdir"
882683e03a40Smrg	    else
882783e03a40Smrg	      # Just accumulate the unique libdirs.
882883e03a40Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
882983e03a40Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
883083e03a40Smrg		;;
883183e03a40Smrg	      *)
883283e03a40Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
883383e03a40Smrg		;;
883483e03a40Smrg	      esac
883583e03a40Smrg	    fi
8836357bfbb2Smrg	  else
883783e03a40Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
883883e03a40Smrg	    func_append rpath " $flag"
8839357bfbb2Smrg	  fi
884083e03a40Smrg	elif test -n "$runpath_var"; then
884183e03a40Smrg	  case "$finalize_perm_rpath " in
884283e03a40Smrg	  *" $libdir "*) ;;
884383e03a40Smrg	  *) func_append finalize_perm_rpath " $libdir" ;;
884483e03a40Smrg	  esac
8845357bfbb2Smrg	fi
884683e03a40Smrg      done
884783e03a40Smrg      # Substitute the hardcoded libdirs into the rpath.
884883e03a40Smrg      if test -n "$hardcode_libdir_separator" &&
884983e03a40Smrg	 test -n "$hardcode_libdirs"; then
885083e03a40Smrg	libdir="$hardcode_libdirs"
885183e03a40Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
885283e03a40Smrg      fi
885383e03a40Smrg      finalize_rpath="$rpath"
8854357bfbb2Smrg
885583e03a40Smrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
885683e03a40Smrg	# Transform all the library objects into standard objects.
885783e03a40Smrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
885883e03a40Smrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
885983e03a40Smrg      fi
8860357bfbb2Smrg
886183e03a40Smrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
8862357bfbb2Smrg
886383e03a40Smrg      # template prelinking step
886483e03a40Smrg      if test -n "$prelink_cmds"; then
886583e03a40Smrg	func_execute_cmds "$prelink_cmds" 'exit $?'
886683e03a40Smrg      fi
8867357bfbb2Smrg
886883e03a40Smrg      wrappers_required=yes
886983e03a40Smrg      case $host in
887083e03a40Smrg      *cegcc* | *mingw32ce*)
887183e03a40Smrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
887283e03a40Smrg        wrappers_required=no
887383e03a40Smrg        ;;
887483e03a40Smrg      *cygwin* | *mingw* )
887583e03a40Smrg        if test "$build_libtool_libs" != yes; then
887683e03a40Smrg          wrappers_required=no
887783e03a40Smrg        fi
887883e03a40Smrg        ;;
887983e03a40Smrg      *)
888083e03a40Smrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
888183e03a40Smrg          wrappers_required=no
888283e03a40Smrg        fi
888383e03a40Smrg        ;;
888483e03a40Smrg      esac
888583e03a40Smrg      if test "$wrappers_required" = no; then
888683e03a40Smrg	# Replace the output file specification.
888783e03a40Smrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
888883e03a40Smrg	link_command="$compile_command$compile_rpath"
8889357bfbb2Smrg
889083e03a40Smrg	# We have no uninstalled library dependencies, so finalize right now.
889183e03a40Smrg	exit_status=0
889283e03a40Smrg	func_show_eval "$link_command" 'exit_status=$?'
8893357bfbb2Smrg
889483e03a40Smrg	if test -n "$postlink_cmds"; then
889583e03a40Smrg	  func_to_tool_file "$output"
889683e03a40Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
889783e03a40Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
8898357bfbb2Smrg	fi
8899357bfbb2Smrg
890083e03a40Smrg	# Delete the generated files.
890183e03a40Smrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
890283e03a40Smrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
890383e03a40Smrg	fi
8904357bfbb2Smrg
890583e03a40Smrg	exit $exit_status
890683e03a40Smrg      fi
8907357bfbb2Smrg
890883e03a40Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
890983e03a40Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
891083e03a40Smrg      fi
891183e03a40Smrg      if test -n "$finalize_shlibpath"; then
891283e03a40Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
891383e03a40Smrg      fi
8914357bfbb2Smrg
891583e03a40Smrg      compile_var=
891683e03a40Smrg      finalize_var=
891783e03a40Smrg      if test -n "$runpath_var"; then
891883e03a40Smrg	if test -n "$perm_rpath"; then
891983e03a40Smrg	  # We should set the runpath_var.
892083e03a40Smrg	  rpath=
892183e03a40Smrg	  for dir in $perm_rpath; do
892283e03a40Smrg	    func_append rpath "$dir:"
892383e03a40Smrg	  done
892483e03a40Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
8925357bfbb2Smrg	fi
892683e03a40Smrg	if test -n "$finalize_perm_rpath"; then
892783e03a40Smrg	  # We should set the runpath_var.
892883e03a40Smrg	  rpath=
892983e03a40Smrg	  for dir in $finalize_perm_rpath; do
893083e03a40Smrg	    func_append rpath "$dir:"
893183e03a40Smrg	  done
893283e03a40Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
8933357bfbb2Smrg	fi
893483e03a40Smrg      fi
8935357bfbb2Smrg
893683e03a40Smrg      if test "$no_install" = yes; then
893783e03a40Smrg	# We don't need to create a wrapper script.
893883e03a40Smrg	link_command="$compile_var$compile_command$compile_rpath"
893983e03a40Smrg	# Replace the output file specification.
894083e03a40Smrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
894183e03a40Smrg	# Delete the old output file.
894283e03a40Smrg	$opt_dry_run || $RM $output
894383e03a40Smrg	# Link the executable and exit
894483e03a40Smrg	func_show_eval "$link_command" 'exit $?'
8945357bfbb2Smrg
894683e03a40Smrg	if test -n "$postlink_cmds"; then
894783e03a40Smrg	  func_to_tool_file "$output"
894883e03a40Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
894983e03a40Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
8950357bfbb2Smrg	fi
895183e03a40Smrg
8952357bfbb2Smrg	exit $EXIT_SUCCESS
895383e03a40Smrg      fi
8954357bfbb2Smrg
895583e03a40Smrg      if test "$hardcode_action" = relink; then
895683e03a40Smrg	# Fast installation is not supported
895783e03a40Smrg	link_command="$compile_var$compile_command$compile_rpath"
895883e03a40Smrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
895983e03a40Smrg
896083e03a40Smrg	func_warning "this platform does not like uninstalled shared libraries"
896183e03a40Smrg	func_warning "\`$output' will be relinked during installation"
896283e03a40Smrg      else
896383e03a40Smrg	if test "$fast_install" != no; then
896483e03a40Smrg	  link_command="$finalize_var$compile_command$finalize_rpath"
896583e03a40Smrg	  if test "$fast_install" = yes; then
896683e03a40Smrg	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
896783e03a40Smrg	  else
896883e03a40Smrg	    # fast_install is set to needless
896983e03a40Smrg	    relink_command=
897083e03a40Smrg	  fi
8971357bfbb2Smrg	else
897283e03a40Smrg	  link_command="$compile_var$compile_command$compile_rpath"
897383e03a40Smrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
8974357bfbb2Smrg	fi
897583e03a40Smrg      fi
8976357bfbb2Smrg
897783e03a40Smrg      # Replace the output file specification.
897883e03a40Smrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
8979357bfbb2Smrg
898083e03a40Smrg      # Delete the old output files.
898183e03a40Smrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
8982357bfbb2Smrg
898383e03a40Smrg      func_show_eval "$link_command" 'exit $?'
8984357bfbb2Smrg
898583e03a40Smrg      if test -n "$postlink_cmds"; then
898683e03a40Smrg	func_to_tool_file "$output_objdir/$outputname"
898783e03a40Smrg	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'`
898883e03a40Smrg	func_execute_cmds "$postlink_cmds" 'exit $?'
898983e03a40Smrg      fi
8990357bfbb2Smrg
899183e03a40Smrg      # Now create the wrapper script.
899283e03a40Smrg      func_verbose "creating $output"
8993357bfbb2Smrg
899483e03a40Smrg      # Quote the relink command for shipping.
899583e03a40Smrg      if test -n "$relink_command"; then
899683e03a40Smrg	# Preserve any variables that may affect compiler behavior
899783e03a40Smrg	for var in $variables_saved_for_relink; do
899883e03a40Smrg	  if eval test -z \"\${$var+set}\"; then
899983e03a40Smrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
900083e03a40Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
900183e03a40Smrg	    relink_command="$var=; export $var; $relink_command"
900283e03a40Smrg	  else
900383e03a40Smrg	    func_quote_for_eval "$var_value"
900483e03a40Smrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
900583e03a40Smrg	  fi
900683e03a40Smrg	done
900783e03a40Smrg	relink_command="(cd `pwd`; $relink_command)"
900883e03a40Smrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
900983e03a40Smrg      fi
901083e03a40Smrg
901183e03a40Smrg      # Only actually do things if not in dry run mode.
901283e03a40Smrg      $opt_dry_run || {
901383e03a40Smrg	# win32 will think the script is a binary if it has
901483e03a40Smrg	# a .exe suffix, so we strip it off here.
901583e03a40Smrg	case $output in
901683e03a40Smrg	  *.exe) func_stripname '' '.exe' "$output"
901783e03a40Smrg	         output=$func_stripname_result ;;
901883e03a40Smrg	esac
901983e03a40Smrg	# test for cygwin because mv fails w/o .exe extensions
902083e03a40Smrg	case $host in
902183e03a40Smrg	  *cygwin*)
902283e03a40Smrg	    exeext=.exe
902383e03a40Smrg	    func_stripname '' '.exe' "$outputname"
902483e03a40Smrg	    outputname=$func_stripname_result ;;
902583e03a40Smrg	  *) exeext= ;;
902683e03a40Smrg	esac
902783e03a40Smrg	case $host in
902883e03a40Smrg	  *cygwin* | *mingw* )
902983e03a40Smrg	    func_dirname_and_basename "$output" "" "."
903083e03a40Smrg	    output_name=$func_basename_result
903183e03a40Smrg	    output_path=$func_dirname_result
903283e03a40Smrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
903383e03a40Smrg	    cwrapper="$output_path/$output_name.exe"
903483e03a40Smrg	    $RM $cwrappersource $cwrapper
903583e03a40Smrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
903683e03a40Smrg
903783e03a40Smrg	    func_emit_cwrapperexe_src > $cwrappersource
903883e03a40Smrg
903983e03a40Smrg	    # The wrapper executable is built using the $host compiler,
904083e03a40Smrg	    # because it contains $host paths and files. If cross-
904183e03a40Smrg	    # compiling, it, like the target executable, must be
904283e03a40Smrg	    # executed on the $host or under an emulation environment.
904383e03a40Smrg	    $opt_dry_run || {
904483e03a40Smrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
904583e03a40Smrg	      $STRIP $cwrapper
904683e03a40Smrg	    }
9047357bfbb2Smrg
904883e03a40Smrg	    # Now, create the wrapper script for func_source use:
904983e03a40Smrg	    func_ltwrapper_scriptname $cwrapper
905083e03a40Smrg	    $RM $func_ltwrapper_scriptname_result
905183e03a40Smrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
905283e03a40Smrg	    $opt_dry_run || {
905383e03a40Smrg	      # note: this script will not be executed, so do not chmod.
905483e03a40Smrg	      if test "x$build" = "x$host" ; then
905583e03a40Smrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
9056357bfbb2Smrg	      else
905783e03a40Smrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
9058357bfbb2Smrg	      fi
905983e03a40Smrg	    }
906083e03a40Smrg	  ;;
906183e03a40Smrg	  * )
906283e03a40Smrg	    $RM $output
906383e03a40Smrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
9064357bfbb2Smrg
906583e03a40Smrg	    func_emit_wrapper no > $output
906683e03a40Smrg	    chmod +x $output
9067357bfbb2Smrg	  ;;
9068357bfbb2Smrg	esac
906983e03a40Smrg      }
907083e03a40Smrg      exit $EXIT_SUCCESS
907183e03a40Smrg      ;;
907283e03a40Smrg    esac
9073357bfbb2Smrg
907483e03a40Smrg    # See if we need to build an old-fashioned archive.
907583e03a40Smrg    for oldlib in $oldlibs; do
9076357bfbb2Smrg
907783e03a40Smrg      if test "$build_libtool_libs" = convenience; then
907883e03a40Smrg	oldobjs="$libobjs_save $symfileobj"
907983e03a40Smrg	addlibs="$convenience"
908083e03a40Smrg	build_libtool_libs=no
908183e03a40Smrg      else
908283e03a40Smrg	if test "$build_libtool_libs" = module; then
908383e03a40Smrg	  oldobjs="$libobjs_save"
908483e03a40Smrg	  build_libtool_libs=no
908583e03a40Smrg	else
908683e03a40Smrg	  oldobjs="$old_deplibs $non_pic_objects"
908783e03a40Smrg	  if test "$preload" = yes && test -f "$symfileobj"; then
908883e03a40Smrg	    func_append oldobjs " $symfileobj"
908983e03a40Smrg	  fi
909083e03a40Smrg	fi
909183e03a40Smrg	addlibs="$old_convenience"
9092357bfbb2Smrg      fi
9093357bfbb2Smrg
909483e03a40Smrg      if test -n "$addlibs"; then
909583e03a40Smrg	gentop="$output_objdir/${outputname}x"
909683e03a40Smrg	func_append generated " $gentop"
9097357bfbb2Smrg
909883e03a40Smrg	func_extract_archives $gentop $addlibs
909983e03a40Smrg	func_append oldobjs " $func_extract_archives_result"
910083e03a40Smrg      fi
9101357bfbb2Smrg
910283e03a40Smrg      # Do each command in the archive commands.
910383e03a40Smrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
910483e03a40Smrg	cmds=$old_archive_from_new_cmds
910583e03a40Smrg      else
9106357bfbb2Smrg
910783e03a40Smrg	# Add any objects from preloaded convenience libraries
910883e03a40Smrg	if test -n "$dlprefiles"; then
910983e03a40Smrg	  gentop="$output_objdir/${outputname}x"
911083e03a40Smrg	  func_append generated " $gentop"
9111357bfbb2Smrg
911283e03a40Smrg	  func_extract_archives $gentop $dlprefiles
911383e03a40Smrg	  func_append oldobjs " $func_extract_archives_result"
911483e03a40Smrg	fi
9115357bfbb2Smrg
911683e03a40Smrg	# POSIX demands no paths to be encoded in archives.  We have
911783e03a40Smrg	# to avoid creating archives with duplicate basenames if we
911883e03a40Smrg	# might have to extract them afterwards, e.g., when creating a
911983e03a40Smrg	# static archive out of a convenience library, or when linking
912083e03a40Smrg	# the entirety of a libtool archive into another (currently
912183e03a40Smrg	# not supported by libtool).
912283e03a40Smrg	if (for obj in $oldobjs
912383e03a40Smrg	    do
912483e03a40Smrg	      func_basename "$obj"
912583e03a40Smrg	      $ECHO "$func_basename_result"
912683e03a40Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
912783e03a40Smrg	  :
912883e03a40Smrg	else
912983e03a40Smrg	  echo "copying selected object files to avoid basename conflicts..."
913083e03a40Smrg	  gentop="$output_objdir/${outputname}x"
913183e03a40Smrg	  func_append generated " $gentop"
913283e03a40Smrg	  func_mkdir_p "$gentop"
913383e03a40Smrg	  save_oldobjs=$oldobjs
913483e03a40Smrg	  oldobjs=
913583e03a40Smrg	  counter=1
913683e03a40Smrg	  for obj in $save_oldobjs
913783e03a40Smrg	  do
913883e03a40Smrg	    func_basename "$obj"
913983e03a40Smrg	    objbase="$func_basename_result"
914083e03a40Smrg	    case " $oldobjs " in
914183e03a40Smrg	    " ") oldobjs=$obj ;;
914283e03a40Smrg	    *[\ /]"$objbase "*)
914383e03a40Smrg	      while :; do
914483e03a40Smrg		# Make sure we don't pick an alternate name that also
914583e03a40Smrg		# overlaps.
914683e03a40Smrg		newobj=lt$counter-$objbase
914783e03a40Smrg		func_arith $counter + 1
914883e03a40Smrg		counter=$func_arith_result
914983e03a40Smrg		case " $oldobjs " in
915083e03a40Smrg		*[\ /]"$newobj "*) ;;
915183e03a40Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
915283e03a40Smrg		esac
915383e03a40Smrg	      done
915483e03a40Smrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
915583e03a40Smrg	      func_append oldobjs " $gentop/$newobj"
915683e03a40Smrg	      ;;
915783e03a40Smrg	    *) func_append oldobjs " $obj" ;;
915883e03a40Smrg	    esac
9159357bfbb2Smrg	  done
9160357bfbb2Smrg	fi
916183e03a40Smrg	eval cmds=\"$old_archive_cmds\"
9162357bfbb2Smrg
916383e03a40Smrg	func_len " $cmds"
916483e03a40Smrg	len=$func_len_result
916583e03a40Smrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
916683e03a40Smrg	  cmds=$old_archive_cmds
916783e03a40Smrg	elif test -n "$archiver_list_spec"; then
916883e03a40Smrg	  func_verbose "using command file archive linking..."
916983e03a40Smrg	  for obj in $oldobjs
917083e03a40Smrg	  do
917183e03a40Smrg	    func_to_tool_file "$obj"
917283e03a40Smrg	    $ECHO "$func_to_tool_file_result"
917383e03a40Smrg	  done > $output_objdir/$libname.libcmd
917483e03a40Smrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
917583e03a40Smrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
917683e03a40Smrg	  cmds=$old_archive_cmds
917783e03a40Smrg	else
917883e03a40Smrg	  # the command line is too long to link in one step, link in parts
917983e03a40Smrg	  func_verbose "using piecewise archive linking..."
918083e03a40Smrg	  save_RANLIB=$RANLIB
918183e03a40Smrg	  RANLIB=:
918283e03a40Smrg	  objlist=
918383e03a40Smrg	  concat_cmds=
918483e03a40Smrg	  save_oldobjs=$oldobjs
918583e03a40Smrg	  oldobjs=
918683e03a40Smrg	  # Is there a better way of finding the last object in the list?
918783e03a40Smrg	  for obj in $save_oldobjs
918883e03a40Smrg	  do
918983e03a40Smrg	    last_oldobj=$obj
919083e03a40Smrg	  done
919183e03a40Smrg	  eval test_cmds=\"$old_archive_cmds\"
919283e03a40Smrg	  func_len " $test_cmds"
919383e03a40Smrg	  len0=$func_len_result
919483e03a40Smrg	  len=$len0
919583e03a40Smrg	  for obj in $save_oldobjs
919683e03a40Smrg	  do
919783e03a40Smrg	    func_len " $obj"
919883e03a40Smrg	    func_arith $len + $func_len_result
919983e03a40Smrg	    len=$func_arith_result
920083e03a40Smrg	    func_append objlist " $obj"
920183e03a40Smrg	    if test "$len" -lt "$max_cmd_len"; then
920283e03a40Smrg	      :
920383e03a40Smrg	    else
920483e03a40Smrg	      # the above command should be used before it gets too long
920583e03a40Smrg	      oldobjs=$objlist
920683e03a40Smrg	      if test "$obj" = "$last_oldobj" ; then
920783e03a40Smrg		RANLIB=$save_RANLIB
920883e03a40Smrg	      fi
920983e03a40Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
921083e03a40Smrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
921183e03a40Smrg	      objlist=
921283e03a40Smrg	      len=$len0
921383e03a40Smrg	    fi
921483e03a40Smrg	  done
921583e03a40Smrg	  RANLIB=$save_RANLIB
921683e03a40Smrg	  oldobjs=$objlist
921783e03a40Smrg	  if test "X$oldobjs" = "X" ; then
921883e03a40Smrg	    eval cmds=\"\$concat_cmds\"
921983e03a40Smrg	  else
922083e03a40Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
922183e03a40Smrg	  fi
922283e03a40Smrg	fi
922383e03a40Smrg      fi
922483e03a40Smrg      func_execute_cmds "$cmds" 'exit $?'
922583e03a40Smrg    done
9226357bfbb2Smrg
922783e03a40Smrg    test -n "$generated" && \
922883e03a40Smrg      func_show_eval "${RM}r$generated"
9229357bfbb2Smrg
923083e03a40Smrg    # Now create the libtool archive.
923183e03a40Smrg    case $output in
923283e03a40Smrg    *.la)
923383e03a40Smrg      old_library=
923483e03a40Smrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
923583e03a40Smrg      func_verbose "creating $output"
9236357bfbb2Smrg
923783e03a40Smrg      # Preserve any variables that may affect compiler behavior
923883e03a40Smrg      for var in $variables_saved_for_relink; do
923983e03a40Smrg	if eval test -z \"\${$var+set}\"; then
924083e03a40Smrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
924183e03a40Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
924283e03a40Smrg	  relink_command="$var=; export $var; $relink_command"
9243357bfbb2Smrg	else
924483e03a40Smrg	  func_quote_for_eval "$var_value"
924583e03a40Smrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9246357bfbb2Smrg	fi
924783e03a40Smrg      done
924883e03a40Smrg      # Quote the link command for shipping.
924983e03a40Smrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
925083e03a40Smrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
925183e03a40Smrg      if test "$hardcode_automatic" = yes ; then
925283e03a40Smrg	relink_command=
925383e03a40Smrg      fi
9254357bfbb2Smrg
925583e03a40Smrg      # Only create the output if not a dry run.
925683e03a40Smrg      $opt_dry_run || {
925783e03a40Smrg	for installed in no yes; do
925883e03a40Smrg	  if test "$installed" = yes; then
925983e03a40Smrg	    if test -z "$install_libdir"; then
926083e03a40Smrg	      break
926183e03a40Smrg	    fi
926283e03a40Smrg	    output="$output_objdir/$outputname"i
926383e03a40Smrg	    # Replace all uninstalled libtool libraries with the installed ones
926483e03a40Smrg	    newdependency_libs=
926583e03a40Smrg	    for deplib in $dependency_libs; do
926683e03a40Smrg	      case $deplib in
926783e03a40Smrg	      *.la)
926883e03a40Smrg		func_basename "$deplib"
926983e03a40Smrg		name="$func_basename_result"
927083e03a40Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
927183e03a40Smrg		test -z "$libdir" && \
927283e03a40Smrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
927383e03a40Smrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
927483e03a40Smrg		;;
927583e03a40Smrg	      -L*)
927683e03a40Smrg		func_stripname -L '' "$deplib"
927783e03a40Smrg		func_replace_sysroot "$func_stripname_result"
927883e03a40Smrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
927983e03a40Smrg		;;
928083e03a40Smrg	      -R*)
928183e03a40Smrg		func_stripname -R '' "$deplib"
928283e03a40Smrg		func_replace_sysroot "$func_stripname_result"
928383e03a40Smrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
928483e03a40Smrg		;;
928583e03a40Smrg	      *) func_append newdependency_libs " $deplib" ;;
928683e03a40Smrg	      esac
928783e03a40Smrg	    done
928883e03a40Smrg	    dependency_libs="$newdependency_libs"
928983e03a40Smrg	    newdlfiles=
929083e03a40Smrg
929183e03a40Smrg	    for lib in $dlfiles; do
929283e03a40Smrg	      case $lib in
929383e03a40Smrg	      *.la)
929483e03a40Smrg	        func_basename "$lib"
929583e03a40Smrg		name="$func_basename_result"
929683e03a40Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
929783e03a40Smrg		test -z "$libdir" && \
929883e03a40Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
929983e03a40Smrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
930083e03a40Smrg		;;
930183e03a40Smrg	      *) func_append newdlfiles " $lib" ;;
930283e03a40Smrg	      esac
930383e03a40Smrg	    done
930483e03a40Smrg	    dlfiles="$newdlfiles"
930583e03a40Smrg	    newdlprefiles=
930683e03a40Smrg	    for lib in $dlprefiles; do
930783e03a40Smrg	      case $lib in
930883e03a40Smrg	      *.la)
930983e03a40Smrg		# Only pass preopened files to the pseudo-archive (for
931083e03a40Smrg		# eventual linking with the app. that links it) if we
931183e03a40Smrg		# didn't already link the preopened objects directly into
931283e03a40Smrg		# the library:
931383e03a40Smrg		func_basename "$lib"
931483e03a40Smrg		name="$func_basename_result"
931583e03a40Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
931683e03a40Smrg		test -z "$libdir" && \
931783e03a40Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
931883e03a40Smrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
931983e03a40Smrg		;;
932083e03a40Smrg	      esac
932183e03a40Smrg	    done
932283e03a40Smrg	    dlprefiles="$newdlprefiles"
932383e03a40Smrg	  else
932483e03a40Smrg	    newdlfiles=
932583e03a40Smrg	    for lib in $dlfiles; do
932683e03a40Smrg	      case $lib in
932783e03a40Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
932883e03a40Smrg		*) abs=`pwd`"/$lib" ;;
932983e03a40Smrg	      esac
933083e03a40Smrg	      func_append newdlfiles " $abs"
933183e03a40Smrg	    done
933283e03a40Smrg	    dlfiles="$newdlfiles"
933383e03a40Smrg	    newdlprefiles=
933483e03a40Smrg	    for lib in $dlprefiles; do
933583e03a40Smrg	      case $lib in
933683e03a40Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
933783e03a40Smrg		*) abs=`pwd`"/$lib" ;;
933883e03a40Smrg	      esac
933983e03a40Smrg	      func_append newdlprefiles " $abs"
934083e03a40Smrg	    done
934183e03a40Smrg	    dlprefiles="$newdlprefiles"
934283e03a40Smrg	  fi
934383e03a40Smrg	  $RM $output
934483e03a40Smrg	  # place dlname in correct position for cygwin
934583e03a40Smrg	  # In fact, it would be nice if we could use this code for all target
934683e03a40Smrg	  # systems that can't hard-code library paths into their executables
934783e03a40Smrg	  # and that have no shared library path variable independent of PATH,
934883e03a40Smrg	  # but it turns out we can't easily determine that from inspecting
934983e03a40Smrg	  # libtool variables, so we have to hard-code the OSs to which it
935083e03a40Smrg	  # applies here; at the moment, that means platforms that use the PE
935183e03a40Smrg	  # object format with DLL files.  See the long comment at the top of
935283e03a40Smrg	  # tests/bindir.at for full details.
935383e03a40Smrg	  tdlname=$dlname
935483e03a40Smrg	  case $host,$output,$installed,$module,$dlname in
935583e03a40Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
935683e03a40Smrg	      # If a -bindir argument was supplied, place the dll there.
935783e03a40Smrg	      if test "x$bindir" != x ;
935883e03a40Smrg	      then
935983e03a40Smrg		func_relative_path "$install_libdir" "$bindir"
936083e03a40Smrg		tdlname=$func_relative_path_result$dlname
936183e03a40Smrg	      else
936283e03a40Smrg		# Otherwise fall back on heuristic.
936383e03a40Smrg		tdlname=../bin/$dlname
936483e03a40Smrg	      fi
936583e03a40Smrg	      ;;
936683e03a40Smrg	  esac
936783e03a40Smrg	  $ECHO > $output "\
936883e03a40Smrg# $outputname - a libtool library file
936983e03a40Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
937083e03a40Smrg#
937183e03a40Smrg# Please DO NOT delete this file!
937283e03a40Smrg# It is necessary for linking the library.
9373357bfbb2Smrg
937483e03a40Smrg# The name that we can dlopen(3).
937583e03a40Smrgdlname='$tdlname'
9376357bfbb2Smrg
937783e03a40Smrg# Names of this library.
937883e03a40Smrglibrary_names='$library_names'
9379357bfbb2Smrg
938083e03a40Smrg# The name of the static archive.
938183e03a40Smrgold_library='$old_library'
9382357bfbb2Smrg
938383e03a40Smrg# Linker flags that can not go in dependency_libs.
938483e03a40Smrginherited_linker_flags='$new_inherited_linker_flags'
9385357bfbb2Smrg
938683e03a40Smrg# Libraries that this one depends upon.
938783e03a40Smrgdependency_libs='$dependency_libs'
9388357bfbb2Smrg
938983e03a40Smrg# Names of additional weak libraries provided by this library
939083e03a40Smrgweak_library_names='$weak_libs'
9391357bfbb2Smrg
939283e03a40Smrg# Version information for $libname.
939383e03a40Smrgcurrent=$current
939483e03a40Smrgage=$age
939583e03a40Smrgrevision=$revision
9396357bfbb2Smrg
939783e03a40Smrg# Is this an already installed library?
939883e03a40Smrginstalled=$installed
9399357bfbb2Smrg
940083e03a40Smrg# Should we warn about portability when linking against -modules?
940183e03a40Smrgshouldnotlink=$module
9402357bfbb2Smrg
940383e03a40Smrg# Files to dlopen/dlpreopen
940483e03a40Smrgdlopen='$dlfiles'
940583e03a40Smrgdlpreopen='$dlprefiles'
9406357bfbb2Smrg
940783e03a40Smrg# Directory that this library needs to be installed in:
940883e03a40Smrglibdir='$install_libdir'"
940983e03a40Smrg	  if test "$installed" = no && test "$need_relink" = yes; then
941083e03a40Smrg	    $ECHO >> $output "\
941183e03a40Smrgrelink_command=\"$relink_command\""
941283e03a40Smrg	  fi
941383e03a40Smrg	done
941483e03a40Smrg      }
9415357bfbb2Smrg
941683e03a40Smrg      # Do a symbolic link so that the libtool archive can be found in
941783e03a40Smrg      # LD_LIBRARY_PATH before the program is installed.
941883e03a40Smrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
941983e03a40Smrg      ;;
942083e03a40Smrg    esac
942183e03a40Smrg    exit $EXIT_SUCCESS
942283e03a40Smrg}
9423357bfbb2Smrg
942483e03a40Smrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
942583e03a40Smrg    func_mode_link ${1+"$@"}
9426357bfbb2Smrg
9427357bfbb2Smrg
942883e03a40Smrg# func_mode_uninstall arg...
942983e03a40Smrgfunc_mode_uninstall ()
943083e03a40Smrg{
943183e03a40Smrg    $opt_debug
943283e03a40Smrg    RM="$nonopt"
9433357bfbb2Smrg    files=
9434357bfbb2Smrg    rmforce=
9435357bfbb2Smrg    exit_status=0
9436357bfbb2Smrg
9437357bfbb2Smrg    # This variable tells wrapper scripts just to set variables rather
9438357bfbb2Smrg    # than running their programs.
9439357bfbb2Smrg    libtool_install_magic="$magic"
9440357bfbb2Smrg
9441357bfbb2Smrg    for arg
9442357bfbb2Smrg    do
9443357bfbb2Smrg      case $arg in
944483e03a40Smrg      -f) func_append RM " $arg"; rmforce=yes ;;
944583e03a40Smrg      -*) func_append RM " $arg" ;;
944683e03a40Smrg      *) func_append files " $arg" ;;
9447357bfbb2Smrg      esac
9448357bfbb2Smrg    done
9449357bfbb2Smrg
945083e03a40Smrg    test -z "$RM" && \
945183e03a40Smrg      func_fatal_help "you must specify an RM program"
9452357bfbb2Smrg
9453357bfbb2Smrg    rmdirs=
9454357bfbb2Smrg
9455357bfbb2Smrg    for file in $files; do
945683e03a40Smrg      func_dirname "$file" "" "."
945783e03a40Smrg      dir="$func_dirname_result"
945883e03a40Smrg      if test "X$dir" = X.; then
945983e03a40Smrg	odir="$objdir"
9460357bfbb2Smrg      else
946183e03a40Smrg	odir="$dir/$objdir"
9462357bfbb2Smrg      fi
946383e03a40Smrg      func_basename "$file"
946483e03a40Smrg      name="$func_basename_result"
946583e03a40Smrg      test "$opt_mode" = uninstall && odir="$dir"
9466357bfbb2Smrg
946783e03a40Smrg      # Remember odir for removal later, being careful to avoid duplicates
946883e03a40Smrg      if test "$opt_mode" = clean; then
9469357bfbb2Smrg	case " $rmdirs " in
947083e03a40Smrg	  *" $odir "*) ;;
947183e03a40Smrg	  *) func_append rmdirs " $odir" ;;
9472357bfbb2Smrg	esac
9473357bfbb2Smrg      fi
9474357bfbb2Smrg
9475357bfbb2Smrg      # Don't error if the file doesn't exist and rm -f was used.
947683e03a40Smrg      if { test -L "$file"; } >/dev/null 2>&1 ||
947783e03a40Smrg	 { test -h "$file"; } >/dev/null 2>&1 ||
947883e03a40Smrg	 test -f "$file"; then
9479357bfbb2Smrg	:
9480357bfbb2Smrg      elif test -d "$file"; then
9481357bfbb2Smrg	exit_status=1
9482357bfbb2Smrg	continue
9483357bfbb2Smrg      elif test "$rmforce" = yes; then
9484357bfbb2Smrg	continue
9485357bfbb2Smrg      fi
9486357bfbb2Smrg
9487357bfbb2Smrg      rmfiles="$file"
9488357bfbb2Smrg
9489357bfbb2Smrg      case $name in
9490357bfbb2Smrg      *.la)
9491357bfbb2Smrg	# Possibly a libtool archive, so verify it.
949283e03a40Smrg	if func_lalib_p "$file"; then
949383e03a40Smrg	  func_source $dir/$name
9494357bfbb2Smrg
9495357bfbb2Smrg	  # Delete the libtool libraries and symlinks.
9496357bfbb2Smrg	  for n in $library_names; do
949783e03a40Smrg	    func_append rmfiles " $odir/$n"
9498357bfbb2Smrg	  done
949983e03a40Smrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
9500357bfbb2Smrg
950183e03a40Smrg	  case "$opt_mode" in
9502357bfbb2Smrg	  clean)
950383e03a40Smrg	    case " $library_names " in
9504357bfbb2Smrg	    *" $dlname "*) ;;
950583e03a40Smrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
9506357bfbb2Smrg	    esac
950783e03a40Smrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
9508357bfbb2Smrg	    ;;
9509357bfbb2Smrg	  uninstall)
9510357bfbb2Smrg	    if test -n "$library_names"; then
9511357bfbb2Smrg	      # Do each command in the postuninstall commands.
951283e03a40Smrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9513357bfbb2Smrg	    fi
9514357bfbb2Smrg
9515357bfbb2Smrg	    if test -n "$old_library"; then
9516357bfbb2Smrg	      # Do each command in the old_postuninstall commands.
951783e03a40Smrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9518357bfbb2Smrg	    fi
9519357bfbb2Smrg	    # FIXME: should reinstall the best remaining shared library.
9520357bfbb2Smrg	    ;;
9521357bfbb2Smrg	  esac
9522357bfbb2Smrg	fi
9523357bfbb2Smrg	;;
9524357bfbb2Smrg
9525357bfbb2Smrg      *.lo)
9526357bfbb2Smrg	# Possibly a libtool object, so verify it.
952783e03a40Smrg	if func_lalib_p "$file"; then
9528357bfbb2Smrg
9529357bfbb2Smrg	  # Read the .lo file
953083e03a40Smrg	  func_source $dir/$name
9531357bfbb2Smrg
9532357bfbb2Smrg	  # Add PIC object to the list of files to remove.
953383e03a40Smrg	  if test -n "$pic_object" &&
953483e03a40Smrg	     test "$pic_object" != none; then
953583e03a40Smrg	    func_append rmfiles " $dir/$pic_object"
9536357bfbb2Smrg	  fi
9537357bfbb2Smrg
9538357bfbb2Smrg	  # Add non-PIC object to the list of files to remove.
953983e03a40Smrg	  if test -n "$non_pic_object" &&
954083e03a40Smrg	     test "$non_pic_object" != none; then
954183e03a40Smrg	    func_append rmfiles " $dir/$non_pic_object"
9542357bfbb2Smrg	  fi
9543357bfbb2Smrg	fi
9544357bfbb2Smrg	;;
9545357bfbb2Smrg
9546357bfbb2Smrg      *)
954783e03a40Smrg	if test "$opt_mode" = clean ; then
9548357bfbb2Smrg	  noexename=$name
9549357bfbb2Smrg	  case $file in
9550357bfbb2Smrg	  *.exe)
955183e03a40Smrg	    func_stripname '' '.exe' "$file"
955283e03a40Smrg	    file=$func_stripname_result
955383e03a40Smrg	    func_stripname '' '.exe' "$name"
955483e03a40Smrg	    noexename=$func_stripname_result
9555357bfbb2Smrg	    # $file with .exe has already been added to rmfiles,
9556357bfbb2Smrg	    # add $file without .exe
955783e03a40Smrg	    func_append rmfiles " $file"
9558357bfbb2Smrg	    ;;
9559357bfbb2Smrg	  esac
9560357bfbb2Smrg	  # Do a test to see if this is a libtool program.
956183e03a40Smrg	  if func_ltwrapper_p "$file"; then
956283e03a40Smrg	    if func_ltwrapper_executable_p "$file"; then
956383e03a40Smrg	      func_ltwrapper_scriptname "$file"
956483e03a40Smrg	      relink_command=
956583e03a40Smrg	      func_source $func_ltwrapper_scriptname_result
956683e03a40Smrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
956783e03a40Smrg	    else
956883e03a40Smrg	      relink_command=
956983e03a40Smrg	      func_source $dir/$noexename
957083e03a40Smrg	    fi
9571357bfbb2Smrg
9572357bfbb2Smrg	    # note $name still contains .exe if it was in $file originally
9573357bfbb2Smrg	    # as does the version of $file that was added into $rmfiles
957483e03a40Smrg	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
9575357bfbb2Smrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
957683e03a40Smrg	      func_append rmfiles " $odir/lt-$name"
9577357bfbb2Smrg	    fi
9578357bfbb2Smrg	    if test "X$noexename" != "X$name" ; then
957983e03a40Smrg	      func_append rmfiles " $odir/lt-${noexename}.c"
9580357bfbb2Smrg	    fi
9581357bfbb2Smrg	  fi
9582357bfbb2Smrg	fi
9583357bfbb2Smrg	;;
9584357bfbb2Smrg      esac
958583e03a40Smrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
9586357bfbb2Smrg    done
9587357bfbb2Smrg
9588357bfbb2Smrg    # Try to remove the ${objdir}s in the directories where we deleted files
9589357bfbb2Smrg    for dir in $rmdirs; do
9590357bfbb2Smrg      if test -d "$dir"; then
959183e03a40Smrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
9592357bfbb2Smrg      fi
9593357bfbb2Smrg    done
9594357bfbb2Smrg
9595357bfbb2Smrg    exit $exit_status
959683e03a40Smrg}
9597357bfbb2Smrg
959883e03a40Smrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
959983e03a40Smrg    func_mode_uninstall ${1+"$@"}
9600357bfbb2Smrg
960183e03a40Smrgtest -z "$opt_mode" && {
960283e03a40Smrg  help="$generic_help"
960383e03a40Smrg  func_fatal_help "you must specify a MODE"
960483e03a40Smrg}
960583e03a40Smrg
960683e03a40Smrgtest -z "$exec_cmd" && \
960783e03a40Smrg  func_fatal_help "invalid operation mode \`$opt_mode'"
9608357bfbb2Smrg
9609357bfbb2Smrgif test -n "$exec_cmd"; then
961083e03a40Smrg  eval exec "$exec_cmd"
9611357bfbb2Smrg  exit $EXIT_FAILURE
9612357bfbb2Smrgfi
9613357bfbb2Smrg
961483e03a40Smrgexit $exit_status
9615357bfbb2Smrg
9616357bfbb2Smrg
9617357bfbb2Smrg# The TAGs below are defined such that we never get into a situation
9618357bfbb2Smrg# in which we disable both kinds of libraries.  Given conflicting
9619357bfbb2Smrg# choices, we go for a static library, that is the most portable,
9620357bfbb2Smrg# since we can't tell whether shared libraries were disabled because
9621357bfbb2Smrg# the user asked for that or because the platform doesn't support
9622357bfbb2Smrg# them.  This is particularly important on AIX, because we don't
9623357bfbb2Smrg# support having both static and shared libraries enabled at the same
9624357bfbb2Smrg# time on that platform, so we default to a shared-only configuration.
9625357bfbb2Smrg# If a disable-shared tag is given, we'll fallback to a static-only
9626357bfbb2Smrg# configuration.  But we'll never go from static-only to shared-only.
9627357bfbb2Smrg
9628357bfbb2Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
962983e03a40Smrgbuild_libtool_libs=no
963083e03a40Smrgbuild_old_libs=yes
9631357bfbb2Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
9632357bfbb2Smrg
9633357bfbb2Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
963483e03a40Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
9635357bfbb2Smrg# ### END LIBTOOL TAG CONFIG: disable-static
9636357bfbb2Smrg
9637357bfbb2Smrg# Local Variables:
9638357bfbb2Smrg# mode:shell-script
9639357bfbb2Smrg# sh-indentation:2
9640357bfbb2Smrg# End:
964183e03a40Smrg# vi:sw=2
964283e03a40Smrg
9643