ltmain.sh revision 11a29bac
111a29bacSmrg# Generated from ltmain.m4sh.
211a29bacSmrg
311a29bacSmrg# libtool (GNU libtool) 2.2.10
411a29bacSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
511a29bacSmrg
611245024Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
711a29bacSmrg# 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
811a29bacSmrg# This is free software; see the source for copying conditions.  There is NO
911a29bacSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1011a29bacSmrg
1111a29bacSmrg# GNU Libtool is free software; you can redistribute it and/or modify
1241b2f0bdSmrg# it under the terms of the GNU General Public License as published by
1341b2f0bdSmrg# the Free Software Foundation; either version 2 of the License, or
1441b2f0bdSmrg# (at your option) any later version.
1541b2f0bdSmrg#
1611a29bacSmrg# As a special exception to the GNU General Public License,
1711a29bacSmrg# if you distribute this file as part of a program or library that
1811a29bacSmrg# is built using GNU Libtool, you may include this file under the
1911a29bacSmrg# same distribution terms that you use for the rest of that program.
2011a29bacSmrg#
2111a29bacSmrg# GNU Libtool is distributed in the hope that it will be useful, but
2241b2f0bdSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
2341b2f0bdSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2441b2f0bdSmrg# General Public License for more details.
2541b2f0bdSmrg#
2641b2f0bdSmrg# You should have received a copy of the GNU General Public License
2711a29bacSmrg# along with GNU Libtool; see the file COPYING.  If not, a copy
2811a29bacSmrg# can be downloaded from http://www.gnu.org/licenses/gpl.html,
2911a29bacSmrg# or obtained by writing to the Free Software Foundation, Inc.,
3011a29bacSmrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
3141b2f0bdSmrg
3211a29bacSmrg# Usage: $progname [OPTION]... [MODE-ARG]...
3311a29bacSmrg#
3411a29bacSmrg# Provide generalized library-building support services.
3511a29bacSmrg#
3611a29bacSmrg#       --config             show all configuration variables
3711a29bacSmrg#       --debug              enable verbose shell tracing
3811a29bacSmrg#   -n, --dry-run            display commands without modifying any files
3911a29bacSmrg#       --features           display basic configuration information and exit
4011a29bacSmrg#       --mode=MODE          use operation mode MODE
4111a29bacSmrg#       --preserve-dup-deps  don't remove duplicate dependency libraries
4211a29bacSmrg#       --quiet, --silent    don't print informational messages
4311a29bacSmrg#       --no-quiet, --no-silent
4411a29bacSmrg#                            print informational messages (default)
4511a29bacSmrg#       --tag=TAG            use configuration variables from tag TAG
4611a29bacSmrg#   -v, --verbose            print more informational messages than default
4711a29bacSmrg#       --no-verbose         don't print the extra informational messages
4811a29bacSmrg#       --version            print version information
4911a29bacSmrg#   -h, --help, --help-all   print short, long, or detailed help message
5011a29bacSmrg#
5111a29bacSmrg# MODE must be one of the following:
5211a29bacSmrg#
5311a29bacSmrg#         clean              remove files from the build directory
5411a29bacSmrg#         compile            compile a source file into a libtool object
5511a29bacSmrg#         execute            automatically set library path, then run a program
5611a29bacSmrg#         finish             complete the installation of libtool libraries
5711a29bacSmrg#         install            install libraries or executables
5811a29bacSmrg#         link               create a library or an executable
5911a29bacSmrg#         uninstall          remove libraries from an installed directory
6011a29bacSmrg#
6111a29bacSmrg# MODE-ARGS vary depending on the MODE.  When passed as first option,
6211a29bacSmrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
6311a29bacSmrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
6411a29bacSmrg#
6511a29bacSmrg# When reporting a bug, please describe a test case to reproduce it and
6611a29bacSmrg# include the following information:
6711a29bacSmrg#
6811a29bacSmrg#         host-triplet:	$host
6911a29bacSmrg#         shell:		$SHELL
7011a29bacSmrg#         compiler:		$LTCC
7111a29bacSmrg#         compiler flags:		$LTCFLAGS
7211a29bacSmrg#         linker:		$LD (gnu? $with_gnu_ld)
7311a29bacSmrg#         $progname:	(GNU libtool) 2.2.10
7411a29bacSmrg#         automake:	$automake_version
7511a29bacSmrg#         autoconf:	$autoconf_version
7611a29bacSmrg#
7711a29bacSmrg# Report bugs to <bug-libtool@gnu.org>.
7841b2f0bdSmrg
7911a29bacSmrgPROGRAM=libtool
8041b2f0bdSmrgPACKAGE=libtool
8111a29bacSmrgVERSION=2.2.10
8211a29bacSmrgTIMESTAMP=""
8311a29bacSmrgpackage_revision=1.3175
8411245024Smrg
8511a29bacSmrg# Be Bourne compatible
8611245024Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
8711245024Smrg  emulate sh
8811245024Smrg  NULLCMD=:
8911245024Smrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
9011245024Smrg  # is contrary to our usage.  Disable this feature.
9111245024Smrg  alias -g '${1+"$@"}'='"$@"'
9241b2f0bdSmrg  setopt NO_GLOB_SUBST
9311245024Smrgelse
9411245024Smrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
9541b2f0bdSmrgfi
9611245024SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
9711245024SmrgDUALCASE=1; export DUALCASE # for MKS sh
9841b2f0bdSmrg
9911a29bacSmrg# A function that is used when there is no print builtin or printf.
10011a29bacSmrgfunc_fallback_echo ()
10111a29bacSmrg{
10211a29bacSmrg  eval 'cat <<_LTECHO_EOF
10311a29bacSmrg$1
10411a29bacSmrg_LTECHO_EOF'
10511a29bacSmrg}
10641b2f0bdSmrg
10711a29bacSmrg# NLS nuisances: We save the old values to restore during execute mode.
10811a29bacSmrglt_user_locale=
10911a29bacSmrglt_safe_locale=
11011245024Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
11111245024Smrgdo
11211245024Smrg  eval "if test \"\${$lt_var+set}\" = set; then
11311a29bacSmrg          save_$lt_var=\$$lt_var
11411a29bacSmrg          $lt_var=C
11511245024Smrg	  export $lt_var
11611a29bacSmrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
11711a29bacSmrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
11811245024Smrg	fi"
11911245024Smrgdone
12011a29bacSmrgLC_ALL=C
12111a29bacSmrgLANGUAGE=C
12211a29bacSmrgexport LANGUAGE LC_ALL
12311245024Smrg
12411a29bacSmrg$lt_unset CDPATH
12511a29bacSmrg
12611a29bacSmrg
12711a29bacSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
12811a29bacSmrg# is ksh but when the shell is invoked as "sh" and the current value of
12911a29bacSmrg# the _XPG environment variable is not equal to 1 (one), the special
13011a29bacSmrg# positional parameter $0, within a function call, is the name of the
13111a29bacSmrg# function.
13211a29bacSmrgprogpath="$0"
13311a29bacSmrg
13411a29bacSmrg
13511a29bacSmrg
13611a29bacSmrg: ${CP="cp -f"}
13711a29bacSmrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
13811a29bacSmrg: ${EGREP="grep -E"}
13911a29bacSmrg: ${FGREP="grep -F"}
14011a29bacSmrg: ${GREP="grep"}
14111a29bacSmrg: ${LN_S="ln -s"}
14211a29bacSmrg: ${MAKE="make"}
14311a29bacSmrg: ${MKDIR="mkdir"}
14411a29bacSmrg: ${MV="mv -f"}
14511a29bacSmrg: ${RM="rm -f"}
14611a29bacSmrg: ${SED="sed"}
14711a29bacSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
14811a29bacSmrg: ${Xsed="$SED -e 1s/^X//"}
14911a29bacSmrg
15011a29bacSmrg# Global variables:
15111a29bacSmrgEXIT_SUCCESS=0
15211a29bacSmrgEXIT_FAILURE=1
15311a29bacSmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
15411a29bacSmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
15511a29bacSmrg
15611a29bacSmrgexit_status=$EXIT_SUCCESS
15741b2f0bdSmrg
15841b2f0bdSmrg# Make sure IFS has a sensible default
15941b2f0bdSmrglt_nl='
16041b2f0bdSmrg'
16141b2f0bdSmrgIFS=" 	$lt_nl"
16241b2f0bdSmrg
16311a29bacSmrgdirname="s,/[^/]*$,,"
16411a29bacSmrgbasename="s,^.*/,,"
16511a29bacSmrg
16611a29bacSmrg# func_dirname_and_basename file append nondir_replacement
16711a29bacSmrg# perform func_basename and func_dirname in a single function
16811a29bacSmrg# call:
16911a29bacSmrg#   dirname:  Compute the dirname of FILE.  If nonempty,
17011a29bacSmrg#             add APPEND to the result, otherwise set result
17111a29bacSmrg#             to NONDIR_REPLACEMENT.
17211a29bacSmrg#             value returned in "$func_dirname_result"
17311a29bacSmrg#   basename: Compute filename of FILE.
17411a29bacSmrg#             value retuned in "$func_basename_result"
17511a29bacSmrg# Implementation must be kept synchronized with func_dirname
17611a29bacSmrg# and func_basename. For efficiency, we do not delegate to
17711a29bacSmrg# those functions but instead duplicate the functionality here.
17811a29bacSmrgfunc_dirname_and_basename ()
17911a29bacSmrg{
18011a29bacSmrg  # Extract subdirectory from the argument.
18111a29bacSmrg  func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
18211a29bacSmrg  if test "X$func_dirname_result" = "X${1}"; then
18311a29bacSmrg    func_dirname_result="${3}"
18411a29bacSmrg  else
18511a29bacSmrg    func_dirname_result="$func_dirname_result${2}"
18611a29bacSmrg  fi
18711a29bacSmrg  func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
18811a29bacSmrg}
18941b2f0bdSmrg
19011a29bacSmrg# Generated shell functions inserted here.
19111a29bacSmrg
19211a29bacSmrg# These SED scripts presuppose an absolute path with a trailing slash.
19311a29bacSmrgpathcar='s,^/\([^/]*\).*$,\1,'
19411a29bacSmrgpathcdr='s,^/[^/]*,,'
19511a29bacSmrgremovedotparts=':dotsl
19611a29bacSmrg		s@/\./@/@g
19711a29bacSmrg		t dotsl
19811a29bacSmrg		s,/\.$,/,'
19911a29bacSmrgcollapseslashes='s@/\{1,\}@/@g'
20011a29bacSmrgfinalslash='s,/*$,/,'
20111a29bacSmrg
20211a29bacSmrg# func_normal_abspath PATH
20311a29bacSmrg# Remove doubled-up and trailing slashes, "." path components,
20411a29bacSmrg# and cancel out any ".." path components in PATH after making
20511a29bacSmrg# it an absolute path.
20611a29bacSmrg#             value returned in "$func_normal_abspath_result"
20711a29bacSmrgfunc_normal_abspath ()
20811a29bacSmrg{
20911a29bacSmrg  # Start from root dir and reassemble the path.
21011a29bacSmrg  func_normal_abspath_result=
21111a29bacSmrg  func_normal_abspath_tpath=$1
21211a29bacSmrg  func_normal_abspath_altnamespace=
21311a29bacSmrg  case $func_normal_abspath_tpath in
21411a29bacSmrg    "")
21511a29bacSmrg      # Empty path, that just means $cwd.
21611a29bacSmrg      func_stripname '' '/' "`pwd`"
21711a29bacSmrg      func_normal_abspath_result=$func_stripname_result
21811a29bacSmrg      return
21911a29bacSmrg    ;;
22011a29bacSmrg    # The next three entries are used to spot a run of precisely
22111a29bacSmrg    # two leading slashes without using negated character classes;
22211a29bacSmrg    # we take advantage of case's first-match behaviour.
22311a29bacSmrg    ///*)
22411a29bacSmrg      # Unusual form of absolute path, do nothing.
22511a29bacSmrg    ;;
22611a29bacSmrg    //*)
22711a29bacSmrg      # Not necessarily an ordinary path; POSIX reserves leading '//'
22811a29bacSmrg      # and for example Cygwin uses it to access remote file shares
22911a29bacSmrg      # over CIFS/SMB, so we conserve a leading double slash if found.
23011a29bacSmrg      func_normal_abspath_altnamespace=/
23111a29bacSmrg    ;;
23211a29bacSmrg    /*)
23311a29bacSmrg      # Absolute path, do nothing.
23411a29bacSmrg    ;;
23511a29bacSmrg    *)
23611a29bacSmrg      # Relative path, prepend $cwd.
23711a29bacSmrg      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
23811a29bacSmrg    ;;
23911a29bacSmrg  esac
24011a29bacSmrg  # Cancel out all the simple stuff to save iterations.  We also want
24111a29bacSmrg  # the path to end with a slash for ease of parsing, so make sure
24211a29bacSmrg  # there is one (and only one) here.
24311a29bacSmrg  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
24411a29bacSmrg        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
24511a29bacSmrg  while :; do
24611a29bacSmrg    # Processed it all yet?
24711a29bacSmrg    if test "$func_normal_abspath_tpath" = / ; then
24811a29bacSmrg      # If we ascended to the root using ".." the result may be empty now.
24911a29bacSmrg      if test -z "$func_normal_abspath_result" ; then
25011a29bacSmrg        func_normal_abspath_result=/
25111a29bacSmrg      fi
25211a29bacSmrg      break
25311a29bacSmrg    fi
25411a29bacSmrg    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
25511a29bacSmrg        -e "$pathcar"`
25611a29bacSmrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
25711a29bacSmrg        -e "$pathcdr"`
25811a29bacSmrg    # Figure out what to do with it
25911a29bacSmrg    case $func_normal_abspath_tcomponent in
26011a29bacSmrg      "")
26111a29bacSmrg        # Trailing empty path component, ignore it.
26211a29bacSmrg      ;;
26311a29bacSmrg      ..)
26411a29bacSmrg        # Parent dir; strip last assembled component from result.
26511a29bacSmrg        func_dirname "$func_normal_abspath_result"
26611a29bacSmrg        func_normal_abspath_result=$func_dirname_result
26711a29bacSmrg      ;;
26811a29bacSmrg      *)
26911a29bacSmrg        # Actual path component, append it.
27011a29bacSmrg        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
27111a29bacSmrg      ;;
27211a29bacSmrg    esac
27311a29bacSmrg  done
27411a29bacSmrg  # Restore leading double-slash if one was found on entry.
27511a29bacSmrg  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
27611a29bacSmrg}
27711a29bacSmrg
27811a29bacSmrg# func_relative_path SRCDIR DSTDIR
27911a29bacSmrg# generates a relative path from SRCDIR to DSTDIR, with a trailing
28011a29bacSmrg# slash if non-empty, suitable for immediately appending a filename
28111a29bacSmrg# without needing to append a separator.
28211a29bacSmrg#             value returned in "$func_relative_path_result"
28311a29bacSmrgfunc_relative_path ()
28411a29bacSmrg{
28511a29bacSmrg  func_relative_path_result=
28611a29bacSmrg  func_normal_abspath "$1"
28711a29bacSmrg  func_relative_path_tlibdir=$func_normal_abspath_result
28811a29bacSmrg  func_normal_abspath "$2"
28911a29bacSmrg  func_relative_path_tbindir=$func_normal_abspath_result
29011a29bacSmrg
29111a29bacSmrg  # Ascend the tree starting from libdir
29211a29bacSmrg  while :; do
29311a29bacSmrg    # check if we have found a prefix of bindir
29411a29bacSmrg    case $func_relative_path_tbindir in
29511a29bacSmrg      $func_relative_path_tlibdir)
29611a29bacSmrg        # found an exact match
29711a29bacSmrg        func_relative_path_tcancelled=
29811a29bacSmrg        break
29911a29bacSmrg        ;;
30011a29bacSmrg      $func_relative_path_tlibdir*)
30111a29bacSmrg        # found a matching prefix
30211a29bacSmrg        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
30311a29bacSmrg        func_relative_path_tcancelled=$func_stripname_result
30411a29bacSmrg        if test -z "$func_relative_path_result"; then
30511a29bacSmrg          func_relative_path_result=.
30611a29bacSmrg        fi
30711a29bacSmrg        break
30811a29bacSmrg        ;;
30911a29bacSmrg      *)
31011a29bacSmrg        func_dirname $func_relative_path_tlibdir
31111a29bacSmrg        func_relative_path_tlibdir=${func_dirname_result}
31211a29bacSmrg        if test "x$func_relative_path_tlibdir" = x ; then
31311a29bacSmrg          # Have to descend all the way to the root!
31411a29bacSmrg          func_relative_path_result=../$func_relative_path_result
31511a29bacSmrg          func_relative_path_tcancelled=$func_relative_path_tbindir
31611a29bacSmrg          break
31711a29bacSmrg        fi
31811a29bacSmrg        func_relative_path_result=../$func_relative_path_result
31911a29bacSmrg        ;;
32011a29bacSmrg    esac
32111a29bacSmrg  done
32211a29bacSmrg
32311a29bacSmrg  # Now calculate path; take care to avoid doubling-up slashes.
32411a29bacSmrg  func_stripname '' '/' "$func_relative_path_result"
32511a29bacSmrg  func_relative_path_result=$func_stripname_result
32611a29bacSmrg  func_stripname '/' '/' "$func_relative_path_tcancelled"
32711a29bacSmrg  if test "x$func_stripname_result" != x ; then
32811a29bacSmrg    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
32911a29bacSmrg  fi
33011a29bacSmrg
33111a29bacSmrg  # Normalisation. If bindir is libdir, return empty string,
33211a29bacSmrg  # else relative path ending with a slash; either way, target
33311a29bacSmrg  # file name can be directly appended.
33411a29bacSmrg  if test ! -z "$func_relative_path_result"; then
33511a29bacSmrg    func_stripname './' '' "$func_relative_path_result/"
33611a29bacSmrg    func_relative_path_result=$func_stripname_result
33711a29bacSmrg  fi
33811a29bacSmrg}
33911a29bacSmrg
34011a29bacSmrg# The name of this program:
34111a29bacSmrgfunc_dirname_and_basename "$progpath"
34211a29bacSmrgprogname=$func_basename_result
34311a29bacSmrg
34411a29bacSmrg# Make sure we have an absolute path for reexecution:
34511a29bacSmrgcase $progpath in
34611a29bacSmrg  [\\/]*|[A-Za-z]:\\*) ;;
34711a29bacSmrg  *[\\/]*)
34811a29bacSmrg     progdir=$func_dirname_result
34911a29bacSmrg     progdir=`cd "$progdir" && pwd`
35011a29bacSmrg     progpath="$progdir/$progname"
35111a29bacSmrg     ;;
35211a29bacSmrg  *)
35311a29bacSmrg     save_IFS="$IFS"
35411a29bacSmrg     IFS=:
35511a29bacSmrg     for progdir in $PATH; do
35611a29bacSmrg       IFS="$save_IFS"
35711a29bacSmrg       test -x "$progdir/$progname" && break
35811a29bacSmrg     done
35911a29bacSmrg     IFS="$save_IFS"
36011a29bacSmrg     test -n "$progdir" || progdir=`pwd`
36111a29bacSmrg     progpath="$progdir/$progname"
36211a29bacSmrg     ;;
36311a29bacSmrgesac
36411a29bacSmrg
36511a29bacSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
36611a29bacSmrg# metacharacters that are still active within double-quoted strings.
36711a29bacSmrgXsed="${SED}"' -e 1s/^X//'
36811a29bacSmrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
36911a29bacSmrg
37011a29bacSmrg# Same as above, but do not quote variable references.
37111a29bacSmrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
37211a29bacSmrg
37311a29bacSmrg# Re-`\' parameter expansions in output of double_quote_subst that were
37411a29bacSmrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
37511a29bacSmrg# in input to double_quote_subst, that '$' was protected from expansion.
37611a29bacSmrg# Since each input `\' is now two `\'s, look for any number of runs of
37711a29bacSmrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
37811a29bacSmrgbs='\\'
37911a29bacSmrgbs2='\\\\'
38011a29bacSmrgbs4='\\\\\\\\'
38111a29bacSmrgdollar='\$'
38211a29bacSmrgsed_double_backslash="\
38311a29bacSmrg  s/$bs4/&\\
38411a29bacSmrg/g
38511a29bacSmrg  s/^$bs2$dollar/$bs&/
38611a29bacSmrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
38711a29bacSmrg  s/\n//g"
38811a29bacSmrg
38911a29bacSmrg# Standard options:
39011a29bacSmrgopt_dry_run=false
39111a29bacSmrgopt_help=false
39211a29bacSmrgopt_quiet=false
39311a29bacSmrgopt_verbose=false
39411a29bacSmrgopt_warning=:
39511a29bacSmrg
39611a29bacSmrg# func_echo arg...
39711a29bacSmrg# Echo program name prefixed message, along with the current mode
39811a29bacSmrg# name if it has been set yet.
39911a29bacSmrgfunc_echo ()
40011a29bacSmrg{
40111a29bacSmrg    $ECHO "$progname${mode+: }$mode: $*"
40211a29bacSmrg}
40311a29bacSmrg
40411a29bacSmrg# func_verbose arg...
40511a29bacSmrg# Echo program name prefixed message in verbose mode only.
40611a29bacSmrgfunc_verbose ()
40711a29bacSmrg{
40811a29bacSmrg    $opt_verbose && func_echo ${1+"$@"}
40911a29bacSmrg
41011a29bacSmrg    # A bug in bash halts the script if the last line of a function
41111a29bacSmrg    # fails when set -e is in force, so we need another command to
41211a29bacSmrg    # work around that:
41311a29bacSmrg    :
41411a29bacSmrg}
41511a29bacSmrg
41611a29bacSmrg# func_echo_all arg...
41711a29bacSmrg# Invoke $ECHO with all args, space-separated.
41811a29bacSmrgfunc_echo_all ()
41911a29bacSmrg{
42011a29bacSmrg    $ECHO "$*"
42111a29bacSmrg}
42211a29bacSmrg
42311a29bacSmrg# func_error arg...
42411a29bacSmrg# Echo program name prefixed message to standard error.
42511a29bacSmrgfunc_error ()
42611a29bacSmrg{
42711a29bacSmrg    $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
42811a29bacSmrg}
42911a29bacSmrg
43011a29bacSmrg# func_warning arg...
43111a29bacSmrg# Echo program name prefixed warning message to standard error.
43211a29bacSmrgfunc_warning ()
43311a29bacSmrg{
43411a29bacSmrg    $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
43511a29bacSmrg
43611a29bacSmrg    # bash bug again:
43711a29bacSmrg    :
43811a29bacSmrg}
43911a29bacSmrg
44011a29bacSmrg# func_fatal_error arg...
44111a29bacSmrg# Echo program name prefixed message to standard error, and exit.
44211a29bacSmrgfunc_fatal_error ()
44311a29bacSmrg{
44411a29bacSmrg    func_error ${1+"$@"}
44511a29bacSmrg    exit $EXIT_FAILURE
44611a29bacSmrg}
44711a29bacSmrg
44811a29bacSmrg# func_fatal_help arg...
44911a29bacSmrg# Echo program name prefixed message to standard error, followed by
45011a29bacSmrg# a help hint, and exit.
45111a29bacSmrgfunc_fatal_help ()
45211a29bacSmrg{
45311a29bacSmrg    func_error ${1+"$@"}
45411a29bacSmrg    func_fatal_error "$help"
45511a29bacSmrg}
45611a29bacSmrghelp="Try \`$progname --help' for more information."  ## default
45711a29bacSmrg
45811a29bacSmrg
45911a29bacSmrg# func_grep expression filename
46011a29bacSmrg# Check whether EXPRESSION matches any line of FILENAME, without output.
46111a29bacSmrgfunc_grep ()
46211a29bacSmrg{
46311a29bacSmrg    $GREP "$1" "$2" >/dev/null 2>&1
46411a29bacSmrg}
46511a29bacSmrg
46611a29bacSmrg
46711a29bacSmrg# func_mkdir_p directory-path
46811a29bacSmrg# Make sure the entire path to DIRECTORY-PATH is available.
46911a29bacSmrgfunc_mkdir_p ()
47011a29bacSmrg{
47111a29bacSmrg    my_directory_path="$1"
47211a29bacSmrg    my_dir_list=
47311a29bacSmrg
47411a29bacSmrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
47511a29bacSmrg
47611a29bacSmrg      # Protect directory names starting with `-'
47711a29bacSmrg      case $my_directory_path in
47811a29bacSmrg        -*) my_directory_path="./$my_directory_path" ;;
47911a29bacSmrg      esac
48011a29bacSmrg
48111a29bacSmrg      # While some portion of DIR does not yet exist...
48211a29bacSmrg      while test ! -d "$my_directory_path"; do
48311a29bacSmrg        # ...make a list in topmost first order.  Use a colon delimited
48411a29bacSmrg	# list incase some portion of path contains whitespace.
48511a29bacSmrg        my_dir_list="$my_directory_path:$my_dir_list"
48611a29bacSmrg
48711a29bacSmrg        # If the last portion added has no slash in it, the list is done
48811a29bacSmrg        case $my_directory_path in */*) ;; *) break ;; esac
48911a29bacSmrg
49011a29bacSmrg        # ...otherwise throw away the child directory and loop
49111a29bacSmrg        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
49211a29bacSmrg      done
49311a29bacSmrg      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
49411a29bacSmrg
49511a29bacSmrg      save_mkdir_p_IFS="$IFS"; IFS=':'
49611a29bacSmrg      for my_dir in $my_dir_list; do
49711a29bacSmrg	IFS="$save_mkdir_p_IFS"
49811a29bacSmrg        # mkdir can fail with a `File exist' error if two processes
49911a29bacSmrg        # try to create one of the directories concurrently.  Don't
50011a29bacSmrg        # stop in that case!
50111a29bacSmrg        $MKDIR "$my_dir" 2>/dev/null || :
50211a29bacSmrg      done
50311a29bacSmrg      IFS="$save_mkdir_p_IFS"
50411a29bacSmrg
50511a29bacSmrg      # Bail out if we (or some other process) failed to create a directory.
50611a29bacSmrg      test -d "$my_directory_path" || \
50711a29bacSmrg        func_fatal_error "Failed to create \`$1'"
50811a29bacSmrg    fi
50911a29bacSmrg}
51041b2f0bdSmrg
51141b2f0bdSmrg
51241b2f0bdSmrg# func_mktempdir [string]
51341b2f0bdSmrg# Make a temporary directory that won't clash with other running
51441b2f0bdSmrg# libtool processes, and avoids race conditions if possible.  If
51541b2f0bdSmrg# given, STRING is the basename for that directory.
51641b2f0bdSmrgfunc_mktempdir ()
51741b2f0bdSmrg{
51841b2f0bdSmrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
51941b2f0bdSmrg
52011a29bacSmrg    if test "$opt_dry_run" = ":"; then
52141b2f0bdSmrg      # Return a directory name, but don't create it in dry-run mode
52241b2f0bdSmrg      my_tmpdir="${my_template}-$$"
52341b2f0bdSmrg    else
52441b2f0bdSmrg
52541b2f0bdSmrg      # If mktemp works, use that first and foremost
52641b2f0bdSmrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
52741b2f0bdSmrg
52841b2f0bdSmrg      if test ! -d "$my_tmpdir"; then
52911a29bacSmrg        # Failing that, at least try and use $RANDOM to avoid a race
53011a29bacSmrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
53141b2f0bdSmrg
53211a29bacSmrg        save_mktempdir_umask=`umask`
53311a29bacSmrg        umask 0077
53411a29bacSmrg        $MKDIR "$my_tmpdir"
53511a29bacSmrg        umask $save_mktempdir_umask
53641b2f0bdSmrg      fi
53741b2f0bdSmrg
53841b2f0bdSmrg      # If we're not in dry-run mode, bomb out on failure
53911a29bacSmrg      test -d "$my_tmpdir" || \
54011a29bacSmrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
54141b2f0bdSmrg    fi
54241b2f0bdSmrg
54311a29bacSmrg    $ECHO "$my_tmpdir"
54441b2f0bdSmrg}
54541b2f0bdSmrg
54641b2f0bdSmrg
54711a29bacSmrg# func_quote_for_eval arg
54811a29bacSmrg# Aesthetically quote ARG to be evaled later.
54911a29bacSmrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
55011a29bacSmrg# is double-quoted, suitable for a subsequent eval, whereas
55111a29bacSmrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
55211a29bacSmrg# which are still active within double quotes backslashified.
55311a29bacSmrgfunc_quote_for_eval ()
55441b2f0bdSmrg{
55511a29bacSmrg    case $1 in
55611a29bacSmrg      *[\\\`\"\$]*)
55711a29bacSmrg	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
55811a29bacSmrg      *)
55911a29bacSmrg        func_quote_for_eval_unquoted_result="$1" ;;
56011a29bacSmrg    esac
56111a29bacSmrg
56211a29bacSmrg    case $func_quote_for_eval_unquoted_result in
56311a29bacSmrg      # Double-quote args containing shell metacharacters to delay
56411a29bacSmrg      # word splitting, command substitution and and variable
56511a29bacSmrg      # expansion for a subsequent eval.
56611a29bacSmrg      # Many Bourne shells cannot handle close brackets correctly
56711a29bacSmrg      # in scan sets, so we specify it separately.
56811a29bacSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
56911a29bacSmrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
57011a29bacSmrg        ;;
57111a29bacSmrg      *)
57211a29bacSmrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
57341b2f0bdSmrg    esac
57441b2f0bdSmrg}
57541b2f0bdSmrg
57641b2f0bdSmrg
57711a29bacSmrg# func_quote_for_expand arg
57811a29bacSmrg# Aesthetically quote ARG to be evaled later; same as above,
57911a29bacSmrg# but do not quote variable references.
58011a29bacSmrgfunc_quote_for_expand ()
58141b2f0bdSmrg{
58211a29bacSmrg    case $1 in
58311a29bacSmrg      *[\\\`\"]*)
58411a29bacSmrg	my_arg=`$ECHO "$1" | $SED \
58511a29bacSmrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
58641b2f0bdSmrg      *)
58711a29bacSmrg        my_arg="$1" ;;
58811a29bacSmrg    esac
58911a29bacSmrg
59011a29bacSmrg    case $my_arg in
59111a29bacSmrg      # Double-quote args containing shell metacharacters to delay
59211a29bacSmrg      # word splitting and command substitution for a subsequent eval.
59311a29bacSmrg      # Many Bourne shells cannot handle close brackets correctly
59411a29bacSmrg      # in scan sets, so we specify it separately.
59511a29bacSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
59611a29bacSmrg        my_arg="\"$my_arg\""
59711a29bacSmrg        ;;
59811a29bacSmrg    esac
59911a29bacSmrg
60011a29bacSmrg    func_quote_for_expand_result="$my_arg"
60141b2f0bdSmrg}
60241b2f0bdSmrg
60341b2f0bdSmrg
60411a29bacSmrg# func_show_eval cmd [fail_exp]
60511a29bacSmrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
60611a29bacSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
60711a29bacSmrg# is given, then evaluate it.
60811a29bacSmrgfunc_show_eval ()
60941b2f0bdSmrg{
61011a29bacSmrg    my_cmd="$1"
61111a29bacSmrg    my_fail_exp="${2-:}"
61241b2f0bdSmrg
61311a29bacSmrg    ${opt_silent-false} || {
61411a29bacSmrg      func_quote_for_expand "$my_cmd"
61511a29bacSmrg      eval "func_echo $func_quote_for_expand_result"
61611a29bacSmrg    }
61711a29bacSmrg
61811a29bacSmrg    if ${opt_dry_run-false}; then :; else
61911a29bacSmrg      eval "$my_cmd"
62011a29bacSmrg      my_status=$?
62111a29bacSmrg      if test "$my_status" -eq 0; then :; else
62211a29bacSmrg	eval "(exit $my_status); $my_fail_exp"
62311a29bacSmrg      fi
62441b2f0bdSmrg    fi
62541b2f0bdSmrg}
62641b2f0bdSmrg
62711a29bacSmrg
62811a29bacSmrg# func_show_eval_locale cmd [fail_exp]
62911a29bacSmrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
63011a29bacSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
63111a29bacSmrg# is given, then evaluate it.  Use the saved locale for evaluation.
63211a29bacSmrgfunc_show_eval_locale ()
63341b2f0bdSmrg{
63411a29bacSmrg    my_cmd="$1"
63511a29bacSmrg    my_fail_exp="${2-:}"
63641b2f0bdSmrg
63711a29bacSmrg    ${opt_silent-false} || {
63811a29bacSmrg      func_quote_for_expand "$my_cmd"
63911a29bacSmrg      eval "func_echo $func_quote_for_expand_result"
64011a29bacSmrg    }
64141b2f0bdSmrg
64211a29bacSmrg    if ${opt_dry_run-false}; then :; else
64311a29bacSmrg      eval "$lt_user_locale
64411a29bacSmrg	    $my_cmd"
64511a29bacSmrg      my_status=$?
64611a29bacSmrg      eval "$lt_safe_locale"
64711a29bacSmrg      if test "$my_status" -eq 0; then :; else
64811a29bacSmrg	eval "(exit $my_status); $my_fail_exp"
64941b2f0bdSmrg      fi
65011a29bacSmrg    fi
65141b2f0bdSmrg}
65241b2f0bdSmrg
65341b2f0bdSmrg
65411a29bacSmrg# func_version
65511a29bacSmrg# Echo version message to standard output and exit.
65611a29bacSmrgfunc_version ()
65711a29bacSmrg{
65811a29bacSmrg    $SED -n '/(C)/!b go
65911a29bacSmrg	:more
66011a29bacSmrg	/\./!{
66111a29bacSmrg	  N
66211a29bacSmrg	  s/\n# / /
66311a29bacSmrg	  b more
66411a29bacSmrg	}
66511a29bacSmrg	:go
66611a29bacSmrg	/^# '$PROGRAM' (GNU /,/# warranty; / {
66711a29bacSmrg        s/^# //
66811a29bacSmrg	s/^# *$//
66911a29bacSmrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
67011a29bacSmrg        p
67111a29bacSmrg     }' < "$progpath"
67211a29bacSmrg     exit $?
67311a29bacSmrg}
67441b2f0bdSmrg
67511a29bacSmrg# func_usage
67611a29bacSmrg# Echo short help message to standard output and exit.
67711a29bacSmrgfunc_usage ()
67811a29bacSmrg{
67911a29bacSmrg    $SED -n '/^# Usage:/,/^#  *.*--help/ {
68011a29bacSmrg        s/^# //
68111a29bacSmrg	s/^# *$//
68211a29bacSmrg	s/\$progname/'$progname'/
68311a29bacSmrg	p
68411a29bacSmrg    }' < "$progpath"
68511a29bacSmrg    echo
68611a29bacSmrg    $ECHO "run \`$progname --help | more' for full usage"
68711a29bacSmrg    exit $?
68811a29bacSmrg}
68941b2f0bdSmrg
69011a29bacSmrg# func_help [NOEXIT]
69111a29bacSmrg# Echo long help message to standard output and exit,
69211a29bacSmrg# unless 'noexit' is passed as argument.
69311a29bacSmrgfunc_help ()
69411a29bacSmrg{
69511a29bacSmrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
69611a29bacSmrg        s/^# //
69711a29bacSmrg	s/^# *$//
69811a29bacSmrg	s*\$progname*'$progname'*
69911a29bacSmrg	s*\$host*'"$host"'*
70011a29bacSmrg	s*\$SHELL*'"$SHELL"'*
70111a29bacSmrg	s*\$LTCC*'"$LTCC"'*
70211a29bacSmrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
70311a29bacSmrg	s*\$LD*'"$LD"'*
70411a29bacSmrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
70511a29bacSmrg	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
70611a29bacSmrg	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
70711a29bacSmrg	p
70811a29bacSmrg     }' < "$progpath"
70911a29bacSmrg    ret=$?
71011a29bacSmrg    if test -z "$1"; then
71111a29bacSmrg      exit $ret
71211a29bacSmrg    fi
71311a29bacSmrg}
71441b2f0bdSmrg
71511a29bacSmrg# func_missing_arg argname
71611a29bacSmrg# Echo program name prefixed message to standard error and set global
71711a29bacSmrg# exit_cmd.
71811a29bacSmrgfunc_missing_arg ()
71911a29bacSmrg{
72011a29bacSmrg    func_error "missing argument for $1."
72111a29bacSmrg    exit_cmd=exit
72211a29bacSmrg}
72341b2f0bdSmrg
72411a29bacSmrgexit_cmd=:
72541b2f0bdSmrg
72641b2f0bdSmrg
72741b2f0bdSmrg
72811245024Smrg
72941b2f0bdSmrg
73011a29bacSmrg
73111a29bacSmrgmagic="%%%MAGIC variable%%%"
73211a29bacSmrgmagic_exe="%%%MAGIC EXE variable%%%"
73311a29bacSmrg
73411a29bacSmrg# Global variables.
73511a29bacSmrg# $mode is unset
73611a29bacSmrgnonopt=
73711a29bacSmrgexecute_dlfiles=
73811a29bacSmrgpreserve_args=
73911a29bacSmrglo2o="s/\\.lo\$/.${objext}/"
74011a29bacSmrgo2lo="s/\\.${objext}\$/.lo/"
74111a29bacSmrgextracted_archives=
74211a29bacSmrgextracted_serial=0
74311a29bacSmrg
74411a29bacSmrgopt_dry_run=false
74511a29bacSmrgopt_duplicate_deps=false
74611a29bacSmrgopt_silent=false
74711a29bacSmrgopt_debug=:
74811a29bacSmrg
74911a29bacSmrg# If this variable is set in any of the actions, the command in it
75011a29bacSmrg# will be execed at the end.  This prevents here-documents from being
75111a29bacSmrg# left over by shells.
75211a29bacSmrgexec_cmd=
75311a29bacSmrg
75411a29bacSmrg# func_fatal_configuration arg...
75511a29bacSmrg# Echo program name prefixed message to standard error, followed by
75611a29bacSmrg# a configuration failure hint, and exit.
75711a29bacSmrgfunc_fatal_configuration ()
75811a29bacSmrg{
75911a29bacSmrg    func_error ${1+"$@"}
76011a29bacSmrg    func_error "See the $PACKAGE documentation for more information."
76111a29bacSmrg    func_fatal_error "Fatal configuration error."
76211a29bacSmrg}
76311a29bacSmrg
76411a29bacSmrg
76511a29bacSmrg# func_config
76611a29bacSmrg# Display the configuration for all the tags in this script.
76711a29bacSmrgfunc_config ()
76811a29bacSmrg{
76911a29bacSmrg    re_begincf='^# ### BEGIN LIBTOOL'
77011a29bacSmrg    re_endcf='^# ### END LIBTOOL'
77111a29bacSmrg
77211a29bacSmrg    # Default configuration.
77311a29bacSmrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
77411a29bacSmrg
77541b2f0bdSmrg    # Now print the configurations for the tags.
77641b2f0bdSmrg    for tagname in $taglist; do
77711a29bacSmrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
77841b2f0bdSmrg    done
77941b2f0bdSmrg
78011a29bacSmrg    exit $?
78111a29bacSmrg}
78241b2f0bdSmrg
78311a29bacSmrg# func_features
78411a29bacSmrg# Display the features supported by this script.
78511a29bacSmrgfunc_features ()
78611a29bacSmrg{
78711a29bacSmrg    echo "host: $host"
78841b2f0bdSmrg    if test "$build_libtool_libs" = yes; then
78911a29bacSmrg      echo "enable shared libraries"
79041b2f0bdSmrg    else
79111a29bacSmrg      echo "disable shared libraries"
79241b2f0bdSmrg    fi
79341b2f0bdSmrg    if test "$build_old_libs" = yes; then
79411a29bacSmrg      echo "enable static libraries"
79541b2f0bdSmrg    else
79611a29bacSmrg      echo "disable static libraries"
79741b2f0bdSmrg    fi
79811a29bacSmrg
79941b2f0bdSmrg    exit $?
80011a29bacSmrg}
80141b2f0bdSmrg
80211a29bacSmrg# func_enable_tag tagname
80311a29bacSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or
80411a29bacSmrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
80511a29bacSmrg# variable here.
80611a29bacSmrgfunc_enable_tag ()
80711a29bacSmrg{
80811a29bacSmrg  # Global variable:
80911a29bacSmrg  tagname="$1"
81041b2f0bdSmrg
81111a29bacSmrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
81211a29bacSmrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
81311a29bacSmrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
81441b2f0bdSmrg
81511a29bacSmrg  # Validate tagname.
81611a29bacSmrg  case $tagname in
81711a29bacSmrg    *[!-_A-Za-z0-9,/]*)
81811a29bacSmrg      func_fatal_error "invalid tag name: $tagname"
81911a29bacSmrg      ;;
82011a29bacSmrg  esac
82141b2f0bdSmrg
82211a29bacSmrg  # Don't test for the "default" C tag, as we know it's
82311a29bacSmrg  # there but not specially marked.
82411a29bacSmrg  case $tagname in
82511a29bacSmrg    CC) ;;
82611a29bacSmrg    *)
82711a29bacSmrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
82811a29bacSmrg	taglist="$taglist $tagname"
82911a29bacSmrg
83011a29bacSmrg	# Evaluate the configuration.  Be careful to quote the path
83111a29bacSmrg	# and the sed script, to avoid splitting on whitespace, but
83211a29bacSmrg	# also don't use non-portable quotes within backquotes within
83311a29bacSmrg	# quotes we have to do it in 2 steps:
83411a29bacSmrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
83511a29bacSmrg	eval "$extractedcf"
83611a29bacSmrg      else
83711a29bacSmrg	func_error "ignoring unknown tag $tagname"
83811a29bacSmrg      fi
83911a29bacSmrg      ;;
84011a29bacSmrg  esac
84111a29bacSmrg}
84211a29bacSmrg
84311a29bacSmrg# Parse options once, thoroughly.  This comes as soon as possible in
84411a29bacSmrg# the script to make things like `libtool --version' happen quickly.
84511a29bacSmrg{
84641b2f0bdSmrg
84711a29bacSmrg  # Shorthand for --mode=foo, only valid as the first argument
84811a29bacSmrg  case $1 in
84911a29bacSmrg  clean|clea|cle|cl)
85011a29bacSmrg    shift; set dummy --mode clean ${1+"$@"}; shift
85141b2f0bdSmrg    ;;
85211a29bacSmrg  compile|compil|compi|comp|com|co|c)
85311a29bacSmrg    shift; set dummy --mode compile ${1+"$@"}; shift
85441b2f0bdSmrg    ;;
85511a29bacSmrg  execute|execut|execu|exec|exe|ex|e)
85611a29bacSmrg    shift; set dummy --mode execute ${1+"$@"}; shift
85741b2f0bdSmrg    ;;
85811a29bacSmrg  finish|finis|fini|fin|fi|f)
85911a29bacSmrg    shift; set dummy --mode finish ${1+"$@"}; shift
86041b2f0bdSmrg    ;;
86111a29bacSmrg  install|instal|insta|inst|ins|in|i)
86211a29bacSmrg    shift; set dummy --mode install ${1+"$@"}; shift
86311a29bacSmrg    ;;
86411a29bacSmrg  link|lin|li|l)
86511a29bacSmrg    shift; set dummy --mode link ${1+"$@"}; shift
86611a29bacSmrg    ;;
86711a29bacSmrg  uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
86811a29bacSmrg    shift; set dummy --mode uninstall ${1+"$@"}; shift
86941b2f0bdSmrg    ;;
87041b2f0bdSmrg  esac
87141b2f0bdSmrg
87211a29bacSmrg  # Parse non-mode specific arguments:
87311a29bacSmrg  while test "$#" -gt 0; do
87411a29bacSmrg    opt="$1"
87511a29bacSmrg    shift
87641b2f0bdSmrg
87711a29bacSmrg    case $opt in
87811a29bacSmrg      --config)		func_config					;;
87941b2f0bdSmrg
88011a29bacSmrg      --debug)		preserve_args="$preserve_args $opt"
88111a29bacSmrg			func_echo "enabling shell trace mode"
88211a29bacSmrg			opt_debug='set -x'
88311a29bacSmrg			$opt_debug
88411a29bacSmrg			;;
88541b2f0bdSmrg
88611a29bacSmrg      -dlopen)		test "$#" -eq 0 && func_missing_arg "$opt" && break
88711a29bacSmrg			execute_dlfiles="$execute_dlfiles $1"
88811a29bacSmrg			shift
88911a29bacSmrg			;;
89041b2f0bdSmrg
89111a29bacSmrg      --dry-run | -n)	opt_dry_run=:					;;
89211a29bacSmrg      --features)       func_features					;;
89311a29bacSmrg      --finish)		mode="finish"					;;
89411a29bacSmrg
89511a29bacSmrg      --mode)		test "$#" -eq 0 && func_missing_arg "$opt" && break
89611a29bacSmrg			case $1 in
89711a29bacSmrg			  # Valid mode arguments:
89811a29bacSmrg			  clean)	;;
89911a29bacSmrg			  compile)	;;
90011a29bacSmrg			  execute)	;;
90111a29bacSmrg			  finish)	;;
90211a29bacSmrg			  install)	;;
90311a29bacSmrg			  link)		;;
90411a29bacSmrg			  relink)	;;
90511a29bacSmrg			  uninstall)	;;
90611a29bacSmrg
90711a29bacSmrg			  # Catch anything else as an error
90811a29bacSmrg			  *) func_error "invalid argument for $opt"
90911a29bacSmrg			     exit_cmd=exit
91011a29bacSmrg			     break
91111a29bacSmrg			     ;;
91211a29bacSmrg		        esac
91311a29bacSmrg
91411a29bacSmrg			mode="$1"
91511a29bacSmrg			shift
91611a29bacSmrg			;;
91711a29bacSmrg
91811a29bacSmrg      --preserve-dup-deps)
91911a29bacSmrg			opt_duplicate_deps=:				;;
92011a29bacSmrg
92111a29bacSmrg      --quiet|--silent)	preserve_args="$preserve_args $opt"
92211a29bacSmrg			opt_silent=:
92311a29bacSmrg			opt_verbose=false
92411a29bacSmrg			;;
92511a29bacSmrg
92611a29bacSmrg      --no-quiet|--no-silent)
92711a29bacSmrg			preserve_args="$preserve_args $opt"
92811a29bacSmrg			opt_silent=false
92911a29bacSmrg			;;
93011a29bacSmrg
93111a29bacSmrg      --verbose| -v)	preserve_args="$preserve_args $opt"
93211a29bacSmrg			opt_silent=false
93311a29bacSmrg			opt_verbose=:
93411a29bacSmrg			;;
93511a29bacSmrg
93611a29bacSmrg      --no-verbose)	preserve_args="$preserve_args $opt"
93711a29bacSmrg			opt_verbose=false
93811a29bacSmrg			;;
93911a29bacSmrg
94011a29bacSmrg      --tag)		test "$#" -eq 0 && func_missing_arg "$opt" && break
94111a29bacSmrg			preserve_args="$preserve_args $opt $1"
94211a29bacSmrg			func_enable_tag "$1"	# tagname is set here
94311a29bacSmrg			shift
94411a29bacSmrg			;;
94511a29bacSmrg
94611a29bacSmrg      # Separate optargs to long options:
94711a29bacSmrg      -dlopen=*|--mode=*|--tag=*)
94811a29bacSmrg			func_opt_split "$opt"
94911a29bacSmrg			set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
95011a29bacSmrg			shift
95111a29bacSmrg			;;
95211a29bacSmrg
95311a29bacSmrg      -\?|-h)		func_usage					;;
95411a29bacSmrg      --help)		opt_help=:					;;
95511a29bacSmrg      --help-all)	opt_help=': help-all'				;;
95611a29bacSmrg      --version)	func_version					;;
95711a29bacSmrg
95811a29bacSmrg      -*)		func_fatal_help "unrecognized option \`$opt'"	;;
95911a29bacSmrg
96011a29bacSmrg      *)		nonopt="$opt"
96111a29bacSmrg			break
96211a29bacSmrg			;;
96311a29bacSmrg    esac
96411a29bacSmrg  done
96511a29bacSmrg
96611a29bacSmrg
96711a29bacSmrg  case $host in
96811a29bacSmrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
96911a29bacSmrg      # don't eliminate duplications in $postdeps and $predeps
97011a29bacSmrg      opt_duplicate_compiler_generated_deps=:
97141b2f0bdSmrg      ;;
97241b2f0bdSmrg    *)
97311a29bacSmrg      opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
97411a29bacSmrg      ;;
97511a29bacSmrg  esac
97641b2f0bdSmrg
97711a29bacSmrg  # Having warned about all mis-specified options, bail out if
97811a29bacSmrg  # anything was wrong.
97911a29bacSmrg  $exit_cmd $EXIT_FAILURE
98011a29bacSmrg}
98111a29bacSmrg
98211a29bacSmrg# func_check_version_match
98311a29bacSmrg# Ensure that we are using m4 macros, and libtool script from the same
98411a29bacSmrg# release of libtool.
98511a29bacSmrgfunc_check_version_match ()
98611a29bacSmrg{
98711a29bacSmrg  if test "$package_revision" != "$macro_revision"; then
98811a29bacSmrg    if test "$VERSION" != "$macro_version"; then
98911a29bacSmrg      if test -z "$macro_version"; then
99011a29bacSmrg        cat >&2 <<_LT_EOF
99111a29bacSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
99211a29bacSmrg$progname: definition of this LT_INIT comes from an older release.
99311a29bacSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
99411a29bacSmrg$progname: and run autoconf again.
99511a29bacSmrg_LT_EOF
99611a29bacSmrg      else
99711a29bacSmrg        cat >&2 <<_LT_EOF
99811a29bacSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
99911a29bacSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
100011a29bacSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
100111a29bacSmrg$progname: and run autoconf again.
100211a29bacSmrg_LT_EOF
100341b2f0bdSmrg      fi
100411a29bacSmrg    else
100511a29bacSmrg      cat >&2 <<_LT_EOF
100611a29bacSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
100711a29bacSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
100811a29bacSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
100911a29bacSmrg$progname: of $PACKAGE $VERSION and run autoconf again.
101011a29bacSmrg_LT_EOF
101111a29bacSmrg    fi
101211a29bacSmrg
101311a29bacSmrg    exit $EXIT_MISMATCH
101411a29bacSmrg  fi
101511a29bacSmrg}
101611a29bacSmrg
101711a29bacSmrg
101811a29bacSmrg## ----------- ##
101911a29bacSmrg##    Main.    ##
102011a29bacSmrg## ----------- ##
102111a29bacSmrg
102211a29bacSmrg$opt_help || {
102311a29bacSmrg  # Sanity checks first:
102411a29bacSmrg  func_check_version_match
102511a29bacSmrg
102611a29bacSmrg  if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
102711a29bacSmrg    func_fatal_configuration "not configured to build any kind of library"
102841b2f0bdSmrg  fi
102941b2f0bdSmrg
103011a29bacSmrg  test -z "$mode" && func_fatal_error "error: you must specify a MODE."
103111a29bacSmrg
103211a29bacSmrg
103311a29bacSmrg  # Darwin sucks
103411a29bacSmrg  eval std_shrext=\"$shrext_cmds\"
103511a29bacSmrg
103611a29bacSmrg
103741b2f0bdSmrg  # Only execute mode is allowed to have -dlopen flags.
103841b2f0bdSmrg  if test -n "$execute_dlfiles" && test "$mode" != execute; then
103911a29bacSmrg    func_error "unrecognized option \`-dlopen'"
104011a29bacSmrg    $ECHO "$help" 1>&2
104141b2f0bdSmrg    exit $EXIT_FAILURE
104241b2f0bdSmrg  fi
104341b2f0bdSmrg
104441b2f0bdSmrg  # Change the help message to a mode-specific one.
104541b2f0bdSmrg  generic_help="$help"
104611a29bacSmrg  help="Try \`$progname --help --mode=$mode' for more information."
104711a29bacSmrg}
104841b2f0bdSmrg
104941b2f0bdSmrg
105011a29bacSmrg# func_lalib_p file
105111a29bacSmrg# True iff FILE is a libtool `.la' library or `.lo' object file.
105211a29bacSmrg# This function is only a basic sanity check; it will hardly flush out
105311a29bacSmrg# determined imposters.
105411a29bacSmrgfunc_lalib_p ()
105511a29bacSmrg{
105611a29bacSmrg    test -f "$1" &&
105711a29bacSmrg      $SED -e 4q "$1" 2>/dev/null \
105811a29bacSmrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
105911a29bacSmrg}
106041b2f0bdSmrg
106111a29bacSmrg# func_lalib_unsafe_p file
106211a29bacSmrg# True iff FILE is a libtool `.la' library or `.lo' object file.
106311a29bacSmrg# This function implements the same check as func_lalib_p without
106411a29bacSmrg# resorting to external programs.  To this end, it redirects stdin and
106511a29bacSmrg# closes it afterwards, without saving the original file descriptor.
106611a29bacSmrg# As a safety measure, use it only where a negative result would be
106711a29bacSmrg# fatal anyway.  Works if `file' does not exist.
106811a29bacSmrgfunc_lalib_unsafe_p ()
106911a29bacSmrg{
107011a29bacSmrg    lalib_p=no
107111a29bacSmrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
107211a29bacSmrg	for lalib_p_l in 1 2 3 4
107311a29bacSmrg	do
107411a29bacSmrg	    read lalib_p_line
107511a29bacSmrg	    case "$lalib_p_line" in
107611a29bacSmrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
107711a29bacSmrg	    esac
107811a29bacSmrg	done
107911a29bacSmrg	exec 0<&5 5<&-
108011a29bacSmrg    fi
108111a29bacSmrg    test "$lalib_p" = yes
108211a29bacSmrg}
108341b2f0bdSmrg
108411a29bacSmrg# func_ltwrapper_script_p file
108511a29bacSmrg# True iff FILE is a libtool wrapper script
108611a29bacSmrg# This function is only a basic sanity check; it will hardly flush out
108711a29bacSmrg# determined imposters.
108811a29bacSmrgfunc_ltwrapper_script_p ()
108911a29bacSmrg{
109011a29bacSmrg    func_lalib_p "$1"
109111a29bacSmrg}
109241b2f0bdSmrg
109311a29bacSmrg# func_ltwrapper_executable_p file
109411a29bacSmrg# True iff FILE is a libtool wrapper executable
109511a29bacSmrg# This function is only a basic sanity check; it will hardly flush out
109611a29bacSmrg# determined imposters.
109711a29bacSmrgfunc_ltwrapper_executable_p ()
109811a29bacSmrg{
109911a29bacSmrg    func_ltwrapper_exec_suffix=
110011a29bacSmrg    case $1 in
110111a29bacSmrg    *.exe) ;;
110211a29bacSmrg    *) func_ltwrapper_exec_suffix=.exe ;;
110311a29bacSmrg    esac
110411a29bacSmrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
110511a29bacSmrg}
110611a29bacSmrg
110711a29bacSmrg# func_ltwrapper_scriptname file
110811a29bacSmrg# Assumes file is an ltwrapper_executable
110911a29bacSmrg# uses $file to determine the appropriate filename for a
111011a29bacSmrg# temporary ltwrapper_script.
111111a29bacSmrgfunc_ltwrapper_scriptname ()
111211a29bacSmrg{
111311a29bacSmrg    func_ltwrapper_scriptname_result=""
111411a29bacSmrg    if func_ltwrapper_executable_p "$1"; then
111511a29bacSmrg	func_dirname_and_basename "$1" "" "."
111611a29bacSmrg	func_stripname '' '.exe' "$func_basename_result"
111711a29bacSmrg	func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
111811a29bacSmrg    fi
111911a29bacSmrg}
112011a29bacSmrg
112111a29bacSmrg# func_ltwrapper_p file
112211a29bacSmrg# True iff FILE is a libtool wrapper script or wrapper executable
112311a29bacSmrg# This function is only a basic sanity check; it will hardly flush out
112411a29bacSmrg# determined imposters.
112511a29bacSmrgfunc_ltwrapper_p ()
112611a29bacSmrg{
112711a29bacSmrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
112811a29bacSmrg}
112911a29bacSmrg
113011a29bacSmrg
113111a29bacSmrg# func_execute_cmds commands fail_cmd
113211a29bacSmrg# Execute tilde-delimited COMMANDS.
113311a29bacSmrg# If FAIL_CMD is given, eval that upon failure.
113411a29bacSmrg# FAIL_CMD may read-access the current command in variable CMD!
113511a29bacSmrgfunc_execute_cmds ()
113611a29bacSmrg{
113711a29bacSmrg    $opt_debug
113811a29bacSmrg    save_ifs=$IFS; IFS='~'
113911a29bacSmrg    for cmd in $1; do
114011a29bacSmrg      IFS=$save_ifs
114111a29bacSmrg      eval cmd=\"$cmd\"
114211a29bacSmrg      func_show_eval "$cmd" "${2-:}"
114311a29bacSmrg    done
114411a29bacSmrg    IFS=$save_ifs
114511a29bacSmrg}
114611a29bacSmrg
114711a29bacSmrg
114811a29bacSmrg# func_source file
114911a29bacSmrg# Source FILE, adding directory component if necessary.
115011a29bacSmrg# Note that it is not necessary on cygwin/mingw to append a dot to
115111a29bacSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
115211a29bacSmrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
115311a29bacSmrg# `FILE.' does not work on cygwin managed mounts.
115411a29bacSmrgfunc_source ()
115511a29bacSmrg{
115611a29bacSmrg    $opt_debug
115711a29bacSmrg    case $1 in
115811a29bacSmrg    */* | *\\*)	. "$1" ;;
115911a29bacSmrg    *)		. "./$1" ;;
116011a29bacSmrg    esac
116111a29bacSmrg}
116211a29bacSmrg
116311a29bacSmrg
116411a29bacSmrg# func_infer_tag arg
116511a29bacSmrg# Infer tagged configuration to use if any are available and
116611a29bacSmrg# if one wasn't chosen via the "--tag" command line option.
116711a29bacSmrg# Only attempt this if the compiler in the base compile
116811a29bacSmrg# command doesn't match the default compiler.
116911a29bacSmrg# arg is usually of the form 'gcc ...'
117011a29bacSmrgfunc_infer_tag ()
117111a29bacSmrg{
117211a29bacSmrg    $opt_debug
117311a29bacSmrg    if test -n "$available_tags" && test -z "$tagname"; then
117411a29bacSmrg      CC_quoted=
117511a29bacSmrg      for arg in $CC; do
117611a29bacSmrg        func_quote_for_eval "$arg"
117711a29bacSmrg	CC_quoted="$CC_quoted $func_quote_for_eval_result"
117811a29bacSmrg      done
117911a29bacSmrg      CC_expanded=`func_echo_all $CC`
118011a29bacSmrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
118111a29bacSmrg      case $@ in
118211a29bacSmrg      # Blanks in the command may have been stripped by the calling shell,
118311a29bacSmrg      # but not from the CC environment variable when configure was run.
118411a29bacSmrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
118511a29bacSmrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
118611a29bacSmrg      # Blanks at the start of $base_compile will cause this to fail
118711a29bacSmrg      # if we don't check for them as well.
118811a29bacSmrg      *)
118911a29bacSmrg	for z in $available_tags; do
119011a29bacSmrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
119111a29bacSmrg	    # Evaluate the configuration.
119211a29bacSmrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
119311a29bacSmrg	    CC_quoted=
119411a29bacSmrg	    for arg in $CC; do
119511a29bacSmrg	      # Double-quote args containing other shell metacharacters.
119611a29bacSmrg	      func_quote_for_eval "$arg"
119711a29bacSmrg	      CC_quoted="$CC_quoted $func_quote_for_eval_result"
119811a29bacSmrg	    done
119911a29bacSmrg	    CC_expanded=`func_echo_all $CC`
120011a29bacSmrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
120111a29bacSmrg	    case "$@ " in
120211a29bacSmrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
120311a29bacSmrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
120411a29bacSmrg	      # The compiler in the base compile command matches
120511a29bacSmrg	      # the one in the tagged configuration.
120611a29bacSmrg	      # Assume this is the tagged configuration we want.
120711a29bacSmrg	      tagname=$z
120811a29bacSmrg	      break
120911a29bacSmrg	      ;;
121011a29bacSmrg	    esac
121111a29bacSmrg	  fi
121211a29bacSmrg	done
121311a29bacSmrg	# If $tagname still isn't set, then no tagged configuration
121411a29bacSmrg	# was found and let the user know that the "--tag" command
121511a29bacSmrg	# line option must be used.
121611a29bacSmrg	if test -z "$tagname"; then
121711a29bacSmrg	  func_echo "unable to infer tagged configuration"
121811a29bacSmrg	  func_fatal_error "specify a tag with \`--tag'"
121911a29bacSmrg#	else
122011a29bacSmrg#	  func_verbose "using $tagname tagged configuration"
122111a29bacSmrg	fi
122211a29bacSmrg	;;
122311a29bacSmrg      esac
122411a29bacSmrg    fi
122511a29bacSmrg}
122611a29bacSmrg
122711a29bacSmrg
122811a29bacSmrg
122911a29bacSmrg# func_write_libtool_object output_name pic_name nonpic_name
123011a29bacSmrg# Create a libtool object file (analogous to a ".la" file),
123111a29bacSmrg# but don't create it if we're doing a dry run.
123211a29bacSmrgfunc_write_libtool_object ()
123311a29bacSmrg{
123411a29bacSmrg    write_libobj=${1}
123511a29bacSmrg    if test "$build_libtool_libs" = yes; then
123611a29bacSmrg      write_lobj=\'${2}\'
123711a29bacSmrg    else
123811a29bacSmrg      write_lobj=none
123911a29bacSmrg    fi
124011a29bacSmrg
124111a29bacSmrg    if test "$build_old_libs" = yes; then
124211a29bacSmrg      write_oldobj=\'${3}\'
124311a29bacSmrg    else
124411a29bacSmrg      write_oldobj=none
124511a29bacSmrg    fi
124611a29bacSmrg
124711a29bacSmrg    $opt_dry_run || {
124811a29bacSmrg      cat >${write_libobj}T <<EOF
124911a29bacSmrg# $write_libobj - a libtool object file
125011a29bacSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
125111a29bacSmrg#
125211a29bacSmrg# Please DO NOT delete this file!
125311a29bacSmrg# It is necessary for linking the library.
125411a29bacSmrg
125511a29bacSmrg# Name of the PIC object.
125611a29bacSmrgpic_object=$write_lobj
125711a29bacSmrg
125811a29bacSmrg# Name of the non-PIC object
125911a29bacSmrgnon_pic_object=$write_oldobj
126011a29bacSmrg
126111a29bacSmrgEOF
126211a29bacSmrg      $MV "${write_libobj}T" "${write_libobj}"
126311a29bacSmrg    }
126411a29bacSmrg}
126511a29bacSmrg
126611a29bacSmrg# func_mode_compile arg...
126711a29bacSmrgfunc_mode_compile ()
126811a29bacSmrg{
126911a29bacSmrg    $opt_debug
127011a29bacSmrg    # Get the compilation command and the source file.
127111a29bacSmrg    base_compile=
127211a29bacSmrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
127311a29bacSmrg    suppress_opt=yes
127411a29bacSmrg    suppress_output=
127511a29bacSmrg    arg_mode=normal
127611a29bacSmrg    libobj=
127711a29bacSmrg    later=
127811a29bacSmrg    pie_flag=
127911a29bacSmrg
128011a29bacSmrg    for arg
128111a29bacSmrg    do
128211a29bacSmrg      case $arg_mode in
128311a29bacSmrg      arg  )
128411a29bacSmrg	# do not "continue".  Instead, add this to base_compile
128511a29bacSmrg	lastarg="$arg"
128611a29bacSmrg	arg_mode=normal
128711a29bacSmrg	;;
128811a29bacSmrg
128911a29bacSmrg      target )
129011a29bacSmrg	libobj="$arg"
129111a29bacSmrg	arg_mode=normal
129211a29bacSmrg	continue
129311a29bacSmrg	;;
129411a29bacSmrg
129511a29bacSmrg      normal )
129611a29bacSmrg	# Accept any command-line options.
129711a29bacSmrg	case $arg in
129811a29bacSmrg	-o)
129911a29bacSmrg	  test -n "$libobj" && \
130011a29bacSmrg	    func_fatal_error "you cannot specify \`-o' more than once"
130111a29bacSmrg	  arg_mode=target
130211a29bacSmrg	  continue
130311a29bacSmrg	  ;;
130411a29bacSmrg
130511a29bacSmrg	-pie | -fpie | -fPIE)
130611a29bacSmrg          pie_flag="$pie_flag $arg"
130711a29bacSmrg	  continue
130811a29bacSmrg	  ;;
130911a29bacSmrg
131011a29bacSmrg	-shared | -static | -prefer-pic | -prefer-non-pic)
131111a29bacSmrg	  later="$later $arg"
131211a29bacSmrg	  continue
131311a29bacSmrg	  ;;
131441b2f0bdSmrg
131541b2f0bdSmrg	-no-suppress)
131641b2f0bdSmrg	  suppress_opt=no
131741b2f0bdSmrg	  continue
131841b2f0bdSmrg	  ;;
131941b2f0bdSmrg
132041b2f0bdSmrg	-Xcompiler)
132141b2f0bdSmrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
132241b2f0bdSmrg	  continue      #  The current "srcfile" will either be retained or
132341b2f0bdSmrg	  ;;            #  replaced later.  I would guess that would be a bug.
132441b2f0bdSmrg
132541b2f0bdSmrg	-Wc,*)
132611a29bacSmrg	  func_stripname '-Wc,' '' "$arg"
132711a29bacSmrg	  args=$func_stripname_result
132841b2f0bdSmrg	  lastarg=
132941b2f0bdSmrg	  save_ifs="$IFS"; IFS=','
133011a29bacSmrg	  for arg in $args; do
133141b2f0bdSmrg	    IFS="$save_ifs"
133211a29bacSmrg	    func_quote_for_eval "$arg"
133311a29bacSmrg	    lastarg="$lastarg $func_quote_for_eval_result"
133441b2f0bdSmrg	  done
133541b2f0bdSmrg	  IFS="$save_ifs"
133611a29bacSmrg	  func_stripname ' ' '' "$lastarg"
133711a29bacSmrg	  lastarg=$func_stripname_result
133841b2f0bdSmrg
133941b2f0bdSmrg	  # Add the arguments to base_compile.
134041b2f0bdSmrg	  base_compile="$base_compile $lastarg"
134141b2f0bdSmrg	  continue
134241b2f0bdSmrg	  ;;
134341b2f0bdSmrg
134411a29bacSmrg	*)
134541b2f0bdSmrg	  # Accept the current argument as the source file.
134641b2f0bdSmrg	  # The previous "srcfile" becomes the current argument.
134741b2f0bdSmrg	  #
134841b2f0bdSmrg	  lastarg="$srcfile"
134941b2f0bdSmrg	  srcfile="$arg"
135041b2f0bdSmrg	  ;;
135141b2f0bdSmrg	esac  #  case $arg
135241b2f0bdSmrg	;;
135341b2f0bdSmrg      esac    #  case $arg_mode
135441b2f0bdSmrg
135541b2f0bdSmrg      # Aesthetically quote the previous argument.
135611a29bacSmrg      func_quote_for_eval "$lastarg"
135711a29bacSmrg      base_compile="$base_compile $func_quote_for_eval_result"
135841b2f0bdSmrg    done # for arg
135941b2f0bdSmrg
136041b2f0bdSmrg    case $arg_mode in
136141b2f0bdSmrg    arg)
136211a29bacSmrg      func_fatal_error "you must specify an argument for -Xcompile"
136341b2f0bdSmrg      ;;
136441b2f0bdSmrg    target)
136511a29bacSmrg      func_fatal_error "you must specify a target with \`-o'"
136641b2f0bdSmrg      ;;
136741b2f0bdSmrg    *)
136841b2f0bdSmrg      # Get the name of the library object.
136911a29bacSmrg      test -z "$libobj" && {
137011a29bacSmrg	func_basename "$srcfile"
137111a29bacSmrg	libobj="$func_basename_result"
137211a29bacSmrg      }
137341b2f0bdSmrg      ;;
137441b2f0bdSmrg    esac
137541b2f0bdSmrg
137641b2f0bdSmrg    # Recognize several different file suffixes.
137741b2f0bdSmrg    # If the user specifies -o file.o, it is replaced with file.lo
137841b2f0bdSmrg    case $libobj in
137911a29bacSmrg    *.[cCFSifmso] | \
138011a29bacSmrg    *.ada | *.adb | *.ads | *.asm | \
138111a29bacSmrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
138211a29bacSmrg    *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup)
138311a29bacSmrg      func_xform "$libobj"
138411a29bacSmrg      libobj=$func_xform_result
138511a29bacSmrg      ;;
138641b2f0bdSmrg    esac
138741b2f0bdSmrg
138841b2f0bdSmrg    case $libobj in
138911a29bacSmrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
139041b2f0bdSmrg    *)
139111a29bacSmrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
139241b2f0bdSmrg      ;;
139341b2f0bdSmrg    esac
139441b2f0bdSmrg
139541b2f0bdSmrg    func_infer_tag $base_compile
139641b2f0bdSmrg
139741b2f0bdSmrg    for arg in $later; do
139841b2f0bdSmrg      case $arg in
139911a29bacSmrg      -shared)
140011a29bacSmrg	test "$build_libtool_libs" != yes && \
140111a29bacSmrg	  func_fatal_configuration "can not build a shared library"
140211a29bacSmrg	build_old_libs=no
140311a29bacSmrg	continue
140411a29bacSmrg	;;
140511a29bacSmrg
140641b2f0bdSmrg      -static)
140711a29bacSmrg	build_libtool_libs=no
140841b2f0bdSmrg	build_old_libs=yes
140941b2f0bdSmrg	continue
141041b2f0bdSmrg	;;
141141b2f0bdSmrg
141241b2f0bdSmrg      -prefer-pic)
141341b2f0bdSmrg	pic_mode=yes
141441b2f0bdSmrg	continue
141541b2f0bdSmrg	;;
141641b2f0bdSmrg
141741b2f0bdSmrg      -prefer-non-pic)
141841b2f0bdSmrg	pic_mode=no
141941b2f0bdSmrg	continue
142041b2f0bdSmrg	;;
142141b2f0bdSmrg      esac
142241b2f0bdSmrg    done
142341b2f0bdSmrg
142411a29bacSmrg    func_quote_for_eval "$libobj"
142511a29bacSmrg    test "X$libobj" != "X$func_quote_for_eval_result" \
142611a29bacSmrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
142711a29bacSmrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
142811a29bacSmrg    func_dirname_and_basename "$obj" "/" ""
142911a29bacSmrg    objname="$func_basename_result"
143011a29bacSmrg    xdir="$func_dirname_result"
143141b2f0bdSmrg    lobj=${xdir}$objdir/$objname
143241b2f0bdSmrg
143311a29bacSmrg    test -z "$base_compile" && \
143411a29bacSmrg      func_fatal_help "you must specify a compilation command"
143541b2f0bdSmrg
143641b2f0bdSmrg    # Delete any leftover library objects.
143741b2f0bdSmrg    if test "$build_old_libs" = yes; then
143841b2f0bdSmrg      removelist="$obj $lobj $libobj ${libobj}T"
143941b2f0bdSmrg    else
144041b2f0bdSmrg      removelist="$lobj $libobj ${libobj}T"
144141b2f0bdSmrg    fi
144241b2f0bdSmrg
144341b2f0bdSmrg    # On Cygwin there's no "real" PIC flag so we must build both object types
144441b2f0bdSmrg    case $host_os in
144511a29bacSmrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
144641b2f0bdSmrg      pic_mode=default
144741b2f0bdSmrg      ;;
144841b2f0bdSmrg    esac
144941b2f0bdSmrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
145041b2f0bdSmrg      # non-PIC code in shared libraries is not supported
145141b2f0bdSmrg      pic_mode=default
145241b2f0bdSmrg    fi
145341b2f0bdSmrg
145441b2f0bdSmrg    # Calculate the filename of the output object if compiler does
145541b2f0bdSmrg    # not support -o with -c
145641b2f0bdSmrg    if test "$compiler_c_o" = no; then
145711a29bacSmrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
145841b2f0bdSmrg      lockfile="$output_obj.lock"
145941b2f0bdSmrg    else
146041b2f0bdSmrg      output_obj=
146141b2f0bdSmrg      need_locks=no
146241b2f0bdSmrg      lockfile=
146341b2f0bdSmrg    fi
146441b2f0bdSmrg
146541b2f0bdSmrg    # Lock this critical section if it is needed
146641b2f0bdSmrg    # We use this script file to make the link, it avoids creating a new file
146741b2f0bdSmrg    if test "$need_locks" = yes; then
146811a29bacSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
146911a29bacSmrg	func_echo "Waiting for $lockfile to be removed"
147041b2f0bdSmrg	sleep 2
147141b2f0bdSmrg      done
147241b2f0bdSmrg    elif test "$need_locks" = warn; then
147341b2f0bdSmrg      if test -f "$lockfile"; then
147411a29bacSmrg	$ECHO "\
147541b2f0bdSmrg*** ERROR, $lockfile exists and contains:
147641b2f0bdSmrg`cat $lockfile 2>/dev/null`
147741b2f0bdSmrg
147841b2f0bdSmrgThis indicates that another process is trying to use the same
147941b2f0bdSmrgtemporary object file, and libtool could not work around it because
148041b2f0bdSmrgyour compiler does not support \`-c' and \`-o' together.  If you
148141b2f0bdSmrgrepeat this compilation, it may succeed, by chance, but you had better
148241b2f0bdSmrgavoid parallel builds (make -j) in this platform, or get a better
148341b2f0bdSmrgcompiler."
148441b2f0bdSmrg
148511a29bacSmrg	$opt_dry_run || $RM $removelist
148641b2f0bdSmrg	exit $EXIT_FAILURE
148741b2f0bdSmrg      fi
148811a29bacSmrg      removelist="$removelist $output_obj"
148911a29bacSmrg      $ECHO "$srcfile" > "$lockfile"
149041b2f0bdSmrg    fi
149141b2f0bdSmrg
149211a29bacSmrg    $opt_dry_run || $RM $removelist
149311a29bacSmrg    removelist="$removelist $lockfile"
149411a29bacSmrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
149511a29bacSmrg
149641b2f0bdSmrg    if test -n "$fix_srcfile_path"; then
149741b2f0bdSmrg      eval srcfile=\"$fix_srcfile_path\"
149841b2f0bdSmrg    fi
149911a29bacSmrg    func_quote_for_eval "$srcfile"
150011a29bacSmrg    qsrcfile=$func_quote_for_eval_result
150141b2f0bdSmrg
150241b2f0bdSmrg    # Only build a PIC object if we are building libtool libraries.
150341b2f0bdSmrg    if test "$build_libtool_libs" = yes; then
150441b2f0bdSmrg      # Without this assignment, base_compile gets emptied.
150541b2f0bdSmrg      fbsd_hideous_sh_bug=$base_compile
150641b2f0bdSmrg
150741b2f0bdSmrg      if test "$pic_mode" != no; then
150841b2f0bdSmrg	command="$base_compile $qsrcfile $pic_flag"
150941b2f0bdSmrg      else
151041b2f0bdSmrg	# Don't build PIC code
151141b2f0bdSmrg	command="$base_compile $qsrcfile"
151241b2f0bdSmrg      fi
151341b2f0bdSmrg
151411a29bacSmrg      func_mkdir_p "$xdir$objdir"
151541b2f0bdSmrg
151641b2f0bdSmrg      if test -z "$output_obj"; then
151741b2f0bdSmrg	# Place PIC objects in $objdir
151841b2f0bdSmrg	command="$command -o $lobj"
151941b2f0bdSmrg      fi
152041b2f0bdSmrg
152111a29bacSmrg      func_show_eval_locale "$command"	\
152211a29bacSmrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
152341b2f0bdSmrg
152441b2f0bdSmrg      if test "$need_locks" = warn &&
152541b2f0bdSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
152611a29bacSmrg	$ECHO "\
152741b2f0bdSmrg*** ERROR, $lockfile contains:
152841b2f0bdSmrg`cat $lockfile 2>/dev/null`
152941b2f0bdSmrg
153041b2f0bdSmrgbut it should contain:
153141b2f0bdSmrg$srcfile
153241b2f0bdSmrg
153341b2f0bdSmrgThis indicates that another process is trying to use the same
153441b2f0bdSmrgtemporary object file, and libtool could not work around it because
153541b2f0bdSmrgyour compiler does not support \`-c' and \`-o' together.  If you
153641b2f0bdSmrgrepeat this compilation, it may succeed, by chance, but you had better
153741b2f0bdSmrgavoid parallel builds (make -j) in this platform, or get a better
153841b2f0bdSmrgcompiler."
153941b2f0bdSmrg
154011a29bacSmrg	$opt_dry_run || $RM $removelist
154141b2f0bdSmrg	exit $EXIT_FAILURE
154241b2f0bdSmrg      fi
154341b2f0bdSmrg
154441b2f0bdSmrg      # Just move the object if needed, then go on to compile the next one
154541b2f0bdSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
154611a29bacSmrg	func_show_eval '$MV "$output_obj" "$lobj"' \
154711a29bacSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
154841b2f0bdSmrg      fi
154941b2f0bdSmrg
155041b2f0bdSmrg      # Allow error messages only from the first compilation.
155141b2f0bdSmrg      if test "$suppress_opt" = yes; then
155211a29bacSmrg	suppress_output=' >/dev/null 2>&1'
155341b2f0bdSmrg      fi
155441b2f0bdSmrg    fi
155541b2f0bdSmrg
155641b2f0bdSmrg    # Only build a position-dependent object if we build old libraries.
155741b2f0bdSmrg    if test "$build_old_libs" = yes; then
155841b2f0bdSmrg      if test "$pic_mode" != yes; then
155941b2f0bdSmrg	# Don't build PIC code
156011a29bacSmrg	command="$base_compile $qsrcfile$pie_flag"
156141b2f0bdSmrg      else
156241b2f0bdSmrg	command="$base_compile $qsrcfile $pic_flag"
156341b2f0bdSmrg      fi
156441b2f0bdSmrg      if test "$compiler_c_o" = yes; then
156541b2f0bdSmrg	command="$command -o $obj"
156641b2f0bdSmrg      fi
156741b2f0bdSmrg
156841b2f0bdSmrg      # Suppress compiler output if we already did a PIC compilation.
156941b2f0bdSmrg      command="$command$suppress_output"
157011a29bacSmrg      func_show_eval_locale "$command" \
157111a29bacSmrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
157241b2f0bdSmrg
157341b2f0bdSmrg      if test "$need_locks" = warn &&
157441b2f0bdSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
157511a29bacSmrg	$ECHO "\
157641b2f0bdSmrg*** ERROR, $lockfile contains:
157741b2f0bdSmrg`cat $lockfile 2>/dev/null`
157841b2f0bdSmrg
157941b2f0bdSmrgbut it should contain:
158041b2f0bdSmrg$srcfile
158141b2f0bdSmrg
158241b2f0bdSmrgThis indicates that another process is trying to use the same
158341b2f0bdSmrgtemporary object file, and libtool could not work around it because
158441b2f0bdSmrgyour compiler does not support \`-c' and \`-o' together.  If you
158541b2f0bdSmrgrepeat this compilation, it may succeed, by chance, but you had better
158641b2f0bdSmrgavoid parallel builds (make -j) in this platform, or get a better
158741b2f0bdSmrgcompiler."
158841b2f0bdSmrg
158911a29bacSmrg	$opt_dry_run || $RM $removelist
159041b2f0bdSmrg	exit $EXIT_FAILURE
159141b2f0bdSmrg      fi
159241b2f0bdSmrg
159341b2f0bdSmrg      # Just move the object if needed
159441b2f0bdSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
159511a29bacSmrg	func_show_eval '$MV "$output_obj" "$obj"' \
159611a29bacSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
159741b2f0bdSmrg      fi
159841b2f0bdSmrg    fi
159941b2f0bdSmrg
160011a29bacSmrg    $opt_dry_run || {
160111a29bacSmrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
160241b2f0bdSmrg
160311a29bacSmrg      # Unlock the critical section if it was locked
160411a29bacSmrg      if test "$need_locks" != no; then
160511a29bacSmrg	removelist=$lockfile
160611a29bacSmrg        $RM "$lockfile"
160711a29bacSmrg      fi
160811a29bacSmrg    }
160941b2f0bdSmrg
161041b2f0bdSmrg    exit $EXIT_SUCCESS
161111a29bacSmrg}
161241b2f0bdSmrg
161311a29bacSmrg$opt_help || {
161411a29bacSmrg  test "$mode" = compile && func_mode_compile ${1+"$@"}
161511a29bacSmrg}
161641b2f0bdSmrg
161711a29bacSmrgfunc_mode_help ()
161811a29bacSmrg{
161911a29bacSmrg    # We need to display help for each of the modes.
162011a29bacSmrg    case $mode in
162111a29bacSmrg      "")
162211a29bacSmrg        # Generic help is extracted from the usage comments
162311a29bacSmrg        # at the start of this file.
162411a29bacSmrg        func_help
162511a29bacSmrg        ;;
162641b2f0bdSmrg
162711a29bacSmrg      clean)
162811a29bacSmrg        $ECHO \
162911a29bacSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
163041b2f0bdSmrg
163111a29bacSmrgRemove files from the build directory.
163241b2f0bdSmrg
163311a29bacSmrgRM is the name of the program to use to delete files associated with each FILE
163411a29bacSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
163511a29bacSmrgto RM.
163641b2f0bdSmrg
163711a29bacSmrgIf FILE is a libtool library, object or program, all the files associated
163811a29bacSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
163911a29bacSmrg        ;;
164041b2f0bdSmrg
164111a29bacSmrg      compile)
164211a29bacSmrg      $ECHO \
164311a29bacSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
164441b2f0bdSmrg
164511a29bacSmrgCompile a source file into a libtool library object.
164641b2f0bdSmrg
164711a29bacSmrgThis mode accepts the following additional options:
164841b2f0bdSmrg
164911a29bacSmrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
165011a29bacSmrg  -no-suppress      do not suppress compiler output for multiple passes
165111a29bacSmrg  -prefer-pic       try to build PIC objects only
165211a29bacSmrg  -prefer-non-pic   try to build non-PIC objects only
165311a29bacSmrg  -shared           do not build a \`.o' file suitable for static linking
165411a29bacSmrg  -static           only build a \`.o' file suitable for static linking
165511a29bacSmrg  -Wc,FLAG          pass FLAG directly to the compiler
165641b2f0bdSmrg
165711a29bacSmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
165811a29bacSmrgfrom the given SOURCEFILE.
165941b2f0bdSmrg
166011a29bacSmrgThe output file name is determined by removing the directory component from
166111a29bacSmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
166211a29bacSmrglibrary object suffix, \`.lo'."
166311a29bacSmrg        ;;
166441b2f0bdSmrg
166511a29bacSmrg      execute)
166611a29bacSmrg        $ECHO \
166711a29bacSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
166841b2f0bdSmrg
166911a29bacSmrgAutomatically set library path, then run a program.
167041b2f0bdSmrg
167111a29bacSmrgThis mode accepts the following additional options:
167241b2f0bdSmrg
167311a29bacSmrg  -dlopen FILE      add the directory containing FILE to the library path
167441b2f0bdSmrg
167511a29bacSmrgThis mode sets the library path environment variable according to \`-dlopen'
167611a29bacSmrgflags.
167741b2f0bdSmrg
167811a29bacSmrgIf any of the ARGS are libtool executable wrappers, then they are translated
167911a29bacSmrginto their corresponding uninstalled binary, and any of their required library
168011a29bacSmrgdirectories are added to the library path.
168141b2f0bdSmrg
168211a29bacSmrgThen, COMMAND is executed, with ARGS as arguments."
168311a29bacSmrg        ;;
168441b2f0bdSmrg
168511a29bacSmrg      finish)
168611a29bacSmrg        $ECHO \
168711a29bacSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
168841b2f0bdSmrg
168911a29bacSmrgComplete the installation of libtool libraries.
169041b2f0bdSmrg
169111a29bacSmrgEach LIBDIR is a directory that contains libtool libraries.
169241b2f0bdSmrg
169311a29bacSmrgThe commands that this mode executes may require superuser privileges.  Use
169411a29bacSmrgthe \`--dry-run' option if you just want to see what would be executed."
169511a29bacSmrg        ;;
169641b2f0bdSmrg
169711a29bacSmrg      install)
169811a29bacSmrg        $ECHO \
169911a29bacSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
170041b2f0bdSmrg
170111a29bacSmrgInstall executables or libraries.
170241b2f0bdSmrg
170311a29bacSmrgINSTALL-COMMAND is the installation command.  The first component should be
170411a29bacSmrgeither the \`install' or \`cp' program.
170541b2f0bdSmrg
170611a29bacSmrgThe following components of INSTALL-COMMAND are treated specially:
170741b2f0bdSmrg
170811a29bacSmrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
170941b2f0bdSmrg
171011a29bacSmrgThe rest of the components are interpreted as arguments to that command (only
171111a29bacSmrgBSD-compatible install options are recognized)."
171211a29bacSmrg        ;;
171341b2f0bdSmrg
171411a29bacSmrg      link)
171511a29bacSmrg        $ECHO \
171611a29bacSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
171741b2f0bdSmrg
171811a29bacSmrgLink object files or libraries together to form another library, or to
171911a29bacSmrgcreate an executable program.
172041b2f0bdSmrg
172111a29bacSmrgLINK-COMMAND is a command using the C compiler that you would use to create
172211a29bacSmrga program from several object files.
172341b2f0bdSmrg
172411a29bacSmrgThe following components of LINK-COMMAND are treated specially:
172541b2f0bdSmrg
172611a29bacSmrg  -all-static       do not do any dynamic linking at all
172711a29bacSmrg  -avoid-version    do not add a version suffix if possible
172811a29bacSmrg  -bindir BINDIR    specify path to binaries directory (for systems where
172911a29bacSmrg                    libraries must be found in the PATH setting at runtime)
173011a29bacSmrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
173111a29bacSmrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
173211a29bacSmrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
173311a29bacSmrg  -export-symbols SYMFILE
173411a29bacSmrg                    try to export only the symbols listed in SYMFILE
173511a29bacSmrg  -export-symbols-regex REGEX
173611a29bacSmrg                    try to export only the symbols matching REGEX
173711a29bacSmrg  -LLIBDIR          search LIBDIR for required installed libraries
173811a29bacSmrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
173911a29bacSmrg  -module           build a library that can dlopened
174011a29bacSmrg  -no-fast-install  disable the fast-install mode
174111a29bacSmrg  -no-install       link a not-installable executable
174211a29bacSmrg  -no-undefined     declare that a library does not refer to external symbols
174311a29bacSmrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
174411a29bacSmrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
174511a29bacSmrg  -precious-files-regex REGEX
174611a29bacSmrg                    don't remove output files matching REGEX
174711a29bacSmrg  -release RELEASE  specify package release information
174811a29bacSmrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
174911a29bacSmrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
175011a29bacSmrg  -shared           only do dynamic linking of libtool libraries
175111a29bacSmrg  -shrext SUFFIX    override the standard shared library file extension
175211a29bacSmrg  -static           do not do any dynamic linking of uninstalled libtool libraries
175311a29bacSmrg  -static-libtool-libs
175411a29bacSmrg                    do not do any dynamic linking of libtool libraries
175511a29bacSmrg  -version-info CURRENT[:REVISION[:AGE]]
175611a29bacSmrg                    specify library version info [each variable defaults to 0]
175711a29bacSmrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
175811a29bacSmrg  -Wc,FLAG
175911a29bacSmrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
176011a29bacSmrg  -Wl,FLAG
176111a29bacSmrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
176211a29bacSmrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
176341b2f0bdSmrg
176411a29bacSmrgAll other options (arguments beginning with \`-') are ignored.
176541b2f0bdSmrg
176611a29bacSmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
176711a29bacSmrgtreated as uninstalled libtool libraries, other files are standard or library
176811a29bacSmrgobject files.
176941b2f0bdSmrg
177011a29bacSmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
177111a29bacSmrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
177211a29bacSmrgrequired, except when creating a convenience library.
177341b2f0bdSmrg
177411a29bacSmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
177511a29bacSmrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
177611245024Smrg
177711a29bacSmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
177811a29bacSmrgis created, otherwise an executable program is created."
177911a29bacSmrg        ;;
178041b2f0bdSmrg
178111a29bacSmrg      uninstall)
178211a29bacSmrg        $ECHO \
178311a29bacSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
178441b2f0bdSmrg
178511a29bacSmrgRemove libraries from an installation directory.
178641b2f0bdSmrg
178711a29bacSmrgRM is the name of the program to use to delete files associated with each FILE
178811a29bacSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
178911a29bacSmrgto RM.
179041b2f0bdSmrg
179111a29bacSmrgIf FILE is a libtool library, all the files associated with it are deleted.
179211a29bacSmrgOtherwise, only FILE itself is deleted using RM."
179311a29bacSmrg        ;;
179441b2f0bdSmrg
179511a29bacSmrg      *)
179611a29bacSmrg        func_fatal_help "invalid operation mode \`$mode'"
179711a29bacSmrg        ;;
179811a29bacSmrg    esac
179941b2f0bdSmrg
180011a29bacSmrg    echo
180111a29bacSmrg    $ECHO "Try \`$progname --help' for more information about other modes."
180211a29bacSmrg}
180341b2f0bdSmrg
180411a29bacSmrg# Now that we've collected a possible --mode arg, show help if necessary
180511a29bacSmrgif $opt_help; then
180611a29bacSmrg  if test "$opt_help" = :; then
180711a29bacSmrg    func_mode_help
180811a29bacSmrg  else
180911a29bacSmrg    {
181011a29bacSmrg      func_help noexit
181111a29bacSmrg      for mode in compile link execute install finish uninstall clean; do
181211a29bacSmrg	func_mode_help
181311a29bacSmrg      done
181411a29bacSmrg    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
181511a29bacSmrg    {
181611a29bacSmrg      func_help noexit
181711a29bacSmrg      for mode in compile link execute install finish uninstall clean; do
181811a29bacSmrg	echo
181911a29bacSmrg	func_mode_help
182011a29bacSmrg      done
182111a29bacSmrg    } |
182211a29bacSmrg    sed '1d
182311a29bacSmrg      /^When reporting/,/^Report/{
182411a29bacSmrg	H
182511a29bacSmrg	d
182611a29bacSmrg      }
182711a29bacSmrg      $x
182811a29bacSmrg      /information about other modes/d
182911a29bacSmrg      /more detailed .*MODE/d
183011a29bacSmrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
183111a29bacSmrg  fi
183211a29bacSmrg  exit $?
183311a29bacSmrgfi
183441b2f0bdSmrg
183541b2f0bdSmrg
183611a29bacSmrg# func_mode_execute arg...
183711a29bacSmrgfunc_mode_execute ()
183811a29bacSmrg{
183911a29bacSmrg    $opt_debug
184011a29bacSmrg    # The first argument is the command name.
184111a29bacSmrg    cmd="$nonopt"
184211a29bacSmrg    test -z "$cmd" && \
184311a29bacSmrg      func_fatal_help "you must specify a COMMAND"
184441b2f0bdSmrg
184511a29bacSmrg    # Handle -dlopen flags immediately.
184611a29bacSmrg    for file in $execute_dlfiles; do
184711a29bacSmrg      test -f "$file" \
184811a29bacSmrg	|| func_fatal_help "\`$file' is not a file"
184941b2f0bdSmrg
185011a29bacSmrg      dir=
185111a29bacSmrg      case $file in
185211a29bacSmrg      *.la)
185311a29bacSmrg	# Check to see that this really is a libtool archive.
185411a29bacSmrg	func_lalib_unsafe_p "$file" \
185511a29bacSmrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
185641b2f0bdSmrg
185711a29bacSmrg	# Read the libtool library.
185811a29bacSmrg	dlname=
185911a29bacSmrg	library_names=
186011a29bacSmrg	func_source "$file"
186141b2f0bdSmrg
186211a29bacSmrg	# Skip this library if it cannot be dlopened.
186311a29bacSmrg	if test -z "$dlname"; then
186411a29bacSmrg	  # Warn if it was a shared library.
186511a29bacSmrg	  test -n "$library_names" && \
186611a29bacSmrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
186711a29bacSmrg	  continue
186811a29bacSmrg	fi
186941b2f0bdSmrg
187011a29bacSmrg	func_dirname "$file" "" "."
187111a29bacSmrg	dir="$func_dirname_result"
187241b2f0bdSmrg
187311a29bacSmrg	if test -f "$dir/$objdir/$dlname"; then
187411a29bacSmrg	  dir="$dir/$objdir"
187511a29bacSmrg	else
187611a29bacSmrg	  if test ! -f "$dir/$dlname"; then
187711a29bacSmrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
187811a29bacSmrg	  fi
187911a29bacSmrg	fi
188041b2f0bdSmrg	;;
188141b2f0bdSmrg
188211a29bacSmrg      *.lo)
188311a29bacSmrg	# Just add the directory containing the .lo file.
188411a29bacSmrg	func_dirname "$file" "" "."
188511a29bacSmrg	dir="$func_dirname_result"
188641b2f0bdSmrg	;;
188711a29bacSmrg
188811a29bacSmrg      *)
188911a29bacSmrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
189041b2f0bdSmrg	continue
189141b2f0bdSmrg	;;
189211a29bacSmrg      esac
189341b2f0bdSmrg
189411a29bacSmrg      # Get the absolute pathname.
189511a29bacSmrg      absdir=`cd "$dir" && pwd`
189611a29bacSmrg      test -n "$absdir" && dir="$absdir"
189741b2f0bdSmrg
189811a29bacSmrg      # Now add the directory to shlibpath_var.
189911a29bacSmrg      if eval "test -z \"\$$shlibpath_var\""; then
190011a29bacSmrg	eval "$shlibpath_var=\"\$dir\""
190111a29bacSmrg      else
190211a29bacSmrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
190311a29bacSmrg      fi
190411a29bacSmrg    done
190541b2f0bdSmrg
190611a29bacSmrg    # This variable tells wrapper scripts just to set shlibpath_var
190711a29bacSmrg    # rather than running their programs.
190811a29bacSmrg    libtool_execute_magic="$magic"
190941b2f0bdSmrg
191011a29bacSmrg    # Check if any of the arguments is a wrapper script.
191111a29bacSmrg    args=
191211a29bacSmrg    for file
191311a29bacSmrg    do
191411a29bacSmrg      case $file in
191511a29bacSmrg      -* | *.la | *.lo ) ;;
191611a29bacSmrg      *)
191711a29bacSmrg	# Do a test to see if this is really a libtool program.
191811a29bacSmrg	if func_ltwrapper_script_p "$file"; then
191911a29bacSmrg	  func_source "$file"
192011a29bacSmrg	  # Transform arg to wrapped name.
192111a29bacSmrg	  file="$progdir/$program"
192211a29bacSmrg	elif func_ltwrapper_executable_p "$file"; then
192311a29bacSmrg	  func_ltwrapper_scriptname "$file"
192411a29bacSmrg	  func_source "$func_ltwrapper_scriptname_result"
192511a29bacSmrg	  # Transform arg to wrapped name.
192611a29bacSmrg	  file="$progdir/$program"
192711a29bacSmrg	fi
192841b2f0bdSmrg	;;
192911a29bacSmrg      esac
193011a29bacSmrg      # Quote arguments (to preserve shell metacharacters).
193111a29bacSmrg      func_quote_for_eval "$file"
193211a29bacSmrg      args="$args $func_quote_for_eval_result"
193311a29bacSmrg    done
193441b2f0bdSmrg
193511a29bacSmrg    if test "X$opt_dry_run" = Xfalse; then
193611a29bacSmrg      if test -n "$shlibpath_var"; then
193711a29bacSmrg	# Export the shlibpath_var.
193811a29bacSmrg	eval "export $shlibpath_var"
193911a29bacSmrg      fi
194041b2f0bdSmrg
194111a29bacSmrg      # Restore saved environment variables
194211a29bacSmrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
194311a29bacSmrg      do
194411a29bacSmrg	eval "if test \"\${save_$lt_var+set}\" = set; then
194511a29bacSmrg                $lt_var=\$save_$lt_var; export $lt_var
194611a29bacSmrg	      else
194711a29bacSmrg		$lt_unset $lt_var
194811a29bacSmrg	      fi"
194911a29bacSmrg      done
195041b2f0bdSmrg
195111a29bacSmrg      # Now prepare to actually exec the command.
195211a29bacSmrg      exec_cmd="\$cmd$args"
195311a29bacSmrg    else
195411a29bacSmrg      # Display what would be done.
195511a29bacSmrg      if test -n "$shlibpath_var"; then
195611a29bacSmrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
195711a29bacSmrg	echo "export $shlibpath_var"
195811a29bacSmrg      fi
195911a29bacSmrg      $ECHO "$cmd$args"
196011a29bacSmrg      exit $EXIT_SUCCESS
196111a29bacSmrg    fi
196211a29bacSmrg}
196341b2f0bdSmrg
196411a29bacSmrgtest "$mode" = execute && func_mode_execute ${1+"$@"}
196541b2f0bdSmrg
196641b2f0bdSmrg
196711a29bacSmrg# func_mode_finish arg...
196811a29bacSmrgfunc_mode_finish ()
196911a29bacSmrg{
197011a29bacSmrg    $opt_debug
197111a29bacSmrg    libdirs="$nonopt"
197211a29bacSmrg    admincmds=
197341b2f0bdSmrg
197411a29bacSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
197511a29bacSmrg      for dir
197611a29bacSmrg      do
197711a29bacSmrg	libdirs="$libdirs $dir"
197811a29bacSmrg      done
197941b2f0bdSmrg
198011a29bacSmrg      for libdir in $libdirs; do
198111a29bacSmrg	if test -n "$finish_cmds"; then
198211a29bacSmrg	  # Do each command in the finish commands.
198311a29bacSmrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
198411a29bacSmrg'"$cmd"'"'
198511a29bacSmrg	fi
198611a29bacSmrg	if test -n "$finish_eval"; then
198711a29bacSmrg	  # Do the single finish_eval.
198811a29bacSmrg	  eval cmds=\"$finish_eval\"
198911a29bacSmrg	  $opt_dry_run || eval "$cmds" || admincmds="$admincmds
199011a29bacSmrg       $cmds"
199111a29bacSmrg	fi
199211a29bacSmrg      done
199311a29bacSmrg    fi
199441b2f0bdSmrg
199511a29bacSmrg    # Exit here if they wanted silent mode.
199611a29bacSmrg    $opt_silent && exit $EXIT_SUCCESS
199741b2f0bdSmrg
199811a29bacSmrg    echo "----------------------------------------------------------------------"
199911a29bacSmrg    echo "Libraries have been installed in:"
200011a29bacSmrg    for libdir in $libdirs; do
200111a29bacSmrg      $ECHO "   $libdir"
200211a29bacSmrg    done
200311a29bacSmrg    echo
200411a29bacSmrg    echo "If you ever happen to want to link against installed libraries"
200511a29bacSmrg    echo "in a given directory, LIBDIR, you must either use libtool, and"
200611a29bacSmrg    echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
200711a29bacSmrg    echo "flag during linking and do at least one of the following:"
200811a29bacSmrg    if test -n "$shlibpath_var"; then
200911a29bacSmrg      echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
201011a29bacSmrg      echo "     during execution"
201111a29bacSmrg    fi
201211a29bacSmrg    if test -n "$runpath_var"; then
201311a29bacSmrg      echo "   - add LIBDIR to the \`$runpath_var' environment variable"
201411a29bacSmrg      echo "     during linking"
201511a29bacSmrg    fi
201611a29bacSmrg    if test -n "$hardcode_libdir_flag_spec"; then
201711a29bacSmrg      libdir=LIBDIR
201811a29bacSmrg      eval flag=\"$hardcode_libdir_flag_spec\"
201941b2f0bdSmrg
202011a29bacSmrg      $ECHO "   - use the \`$flag' linker flag"
202111a29bacSmrg    fi
202211a29bacSmrg    if test -n "$admincmds"; then
202311a29bacSmrg      $ECHO "   - have your system administrator run these commands:$admincmds"
202411a29bacSmrg    fi
202511a29bacSmrg    if test -f /etc/ld.so.conf; then
202611a29bacSmrg      echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
202711a29bacSmrg    fi
202811a29bacSmrg    echo
202941b2f0bdSmrg
203011a29bacSmrg    echo "See any operating system documentation about shared libraries for"
203111a29bacSmrg    case $host in
203211a29bacSmrg      solaris2.[6789]|solaris2.1[0-9])
203311a29bacSmrg        echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
203411a29bacSmrg	echo "pages."
203511a29bacSmrg	;;
203611a29bacSmrg      *)
203711a29bacSmrg        echo "more information, such as the ld(1) and ld.so(8) manual pages."
203811a29bacSmrg        ;;
203911a29bacSmrg    esac
204011a29bacSmrg    echo "----------------------------------------------------------------------"
204111a29bacSmrg    exit $EXIT_SUCCESS
204211a29bacSmrg}
204341b2f0bdSmrg
204411a29bacSmrgtest "$mode" = finish && func_mode_finish ${1+"$@"}
204541b2f0bdSmrg
204641b2f0bdSmrg
204711a29bacSmrg# func_mode_install arg...
204811a29bacSmrgfunc_mode_install ()
204911a29bacSmrg{
205011a29bacSmrg    $opt_debug
205111a29bacSmrg    # There may be an optional sh(1) argument at the beginning of
205211a29bacSmrg    # install_prog (especially on Windows NT).
205311a29bacSmrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
205411a29bacSmrg       # Allow the use of GNU shtool's install command.
205511a29bacSmrg       case $nonopt in *shtool*) :;; *) false;; esac; then
205611a29bacSmrg      # Aesthetically quote it.
205711a29bacSmrg      func_quote_for_eval "$nonopt"
205811a29bacSmrg      install_prog="$func_quote_for_eval_result "
205911a29bacSmrg      arg=$1
206011a29bacSmrg      shift
206111a29bacSmrg    else
206211a29bacSmrg      install_prog=
206311a29bacSmrg      arg=$nonopt
206411a29bacSmrg    fi
206541b2f0bdSmrg
206611a29bacSmrg    # The real first argument should be the name of the installation program.
206711a29bacSmrg    # Aesthetically quote it.
206811a29bacSmrg    func_quote_for_eval "$arg"
206911a29bacSmrg    install_prog="$install_prog$func_quote_for_eval_result"
207011a29bacSmrg    install_shared_prog=$install_prog
207111a29bacSmrg    case " $install_prog " in
207211a29bacSmrg      *[\\\ /]cp\ *) install_cp=: ;;
207311a29bacSmrg      *) install_cp=false ;;
207411a29bacSmrg    esac
207541b2f0bdSmrg
207611a29bacSmrg    # We need to accept at least all the BSD install flags.
207711a29bacSmrg    dest=
207811a29bacSmrg    files=
207911a29bacSmrg    opts=
208011a29bacSmrg    prev=
208111a29bacSmrg    install_type=
208211a29bacSmrg    isdir=no
208311a29bacSmrg    stripme=
208411a29bacSmrg    no_mode=:
208511a29bacSmrg    for arg
208611a29bacSmrg    do
208711a29bacSmrg      arg2=
208811a29bacSmrg      if test -n "$dest"; then
208911a29bacSmrg	files="$files $dest"
209011a29bacSmrg	dest=$arg
209141b2f0bdSmrg	continue
209211a29bacSmrg      fi
209341b2f0bdSmrg
209411a29bacSmrg      case $arg in
209511a29bacSmrg      -d) isdir=yes ;;
209611a29bacSmrg      -f)
209711a29bacSmrg	if $install_cp; then :; else
209811a29bacSmrg	  prev=$arg
209941b2f0bdSmrg	fi
210011a29bacSmrg	;;
210111a29bacSmrg      -g | -m | -o)
210211a29bacSmrg	prev=$arg
210311a29bacSmrg	;;
210411a29bacSmrg      -s)
210511a29bacSmrg	stripme=" -s"
210641b2f0bdSmrg	continue
210741b2f0bdSmrg	;;
210811a29bacSmrg      -*)
210911a29bacSmrg	;;
211041b2f0bdSmrg      *)
211111a29bacSmrg	# If the previous option needed an argument, then skip it.
211211a29bacSmrg	if test -n "$prev"; then
211311a29bacSmrg	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
211411a29bacSmrg	    arg2=$install_override_mode
211511a29bacSmrg	    no_mode=false
211611a29bacSmrg	  fi
211711a29bacSmrg	  prev=
211811a29bacSmrg	else
211911a29bacSmrg	  dest=$arg
212011a29bacSmrg	  continue
212111a29bacSmrg	fi
212241b2f0bdSmrg	;;
212311a29bacSmrg      esac
212441b2f0bdSmrg
212511a29bacSmrg      # Aesthetically quote the argument.
212611a29bacSmrg      func_quote_for_eval "$arg"
212711a29bacSmrg      install_prog="$install_prog $func_quote_for_eval_result"
212811a29bacSmrg      if test -n "$arg2"; then
212911a29bacSmrg	func_quote_for_eval "$arg2"
213041b2f0bdSmrg      fi
213111a29bacSmrg      install_shared_prog="$install_shared_prog $func_quote_for_eval_result"
213211a29bacSmrg    done
213341b2f0bdSmrg
213411a29bacSmrg    test -z "$install_prog" && \
213511a29bacSmrg      func_fatal_help "you must specify an install program"
213641b2f0bdSmrg
213711a29bacSmrg    test -n "$prev" && \
213811a29bacSmrg      func_fatal_help "the \`$prev' option requires an argument"
213941b2f0bdSmrg
214011a29bacSmrg    if test -n "$install_override_mode" && $no_mode; then
214111a29bacSmrg      if $install_cp; then :; else
214211a29bacSmrg	func_quote_for_eval "$install_override_mode"
214311a29bacSmrg	install_shared_prog="$install_shared_prog -m $func_quote_for_eval_result"
214411a29bacSmrg      fi
214541b2f0bdSmrg    fi
214641b2f0bdSmrg
214711a29bacSmrg    if test -z "$files"; then
214811a29bacSmrg      if test -z "$dest"; then
214911a29bacSmrg	func_fatal_help "no file or destination specified"
215011a29bacSmrg      else
215111a29bacSmrg	func_fatal_help "you must specify a destination"
215241b2f0bdSmrg      fi
215341b2f0bdSmrg    fi
215441b2f0bdSmrg
215511a29bacSmrg    # Strip any trailing slash from the destination.
215611a29bacSmrg    func_stripname '' '/' "$dest"
215711a29bacSmrg    dest=$func_stripname_result
215841b2f0bdSmrg
215911a29bacSmrg    # Check to see that the destination is a directory.
216011a29bacSmrg    test -d "$dest" && isdir=yes
216111a29bacSmrg    if test "$isdir" = yes; then
216211a29bacSmrg      destdir="$dest"
216311a29bacSmrg      destname=
216411a29bacSmrg    else
216511a29bacSmrg      func_dirname_and_basename "$dest" "" "."
216611a29bacSmrg      destdir="$func_dirname_result"
216711a29bacSmrg      destname="$func_basename_result"
216811a29bacSmrg
216911a29bacSmrg      # Not a directory, so check to see that there is only one file specified.
217011a29bacSmrg      set dummy $files; shift
217111a29bacSmrg      test "$#" -gt 1 && \
217211a29bacSmrg	func_fatal_help "\`$dest' is not a directory"
217311a29bacSmrg    fi
217411a29bacSmrg    case $destdir in
217511a29bacSmrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
217641b2f0bdSmrg    *)
217711a29bacSmrg      for file in $files; do
217811a29bacSmrg	case $file in
217911a29bacSmrg	*.lo) ;;
218011a29bacSmrg	*)
218111a29bacSmrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
218211a29bacSmrg	  ;;
218311a29bacSmrg	esac
218411a29bacSmrg      done
218541b2f0bdSmrg      ;;
218641b2f0bdSmrg    esac
218741b2f0bdSmrg
218811a29bacSmrg    # This variable tells wrapper scripts just to set variables rather
218911a29bacSmrg    # than running their programs.
219011a29bacSmrg    libtool_install_magic="$magic"
219141b2f0bdSmrg
219211a29bacSmrg    staticlibs=
219311a29bacSmrg    future_libdirs=
219411a29bacSmrg    current_libdirs=
219511a29bacSmrg    for file in $files; do
219641b2f0bdSmrg
219711a29bacSmrg      # Do each installation.
219811a29bacSmrg      case $file in
219911a29bacSmrg      *.$libext)
220011a29bacSmrg	# Do the static libraries later.
220111a29bacSmrg	staticlibs="$staticlibs $file"
220211a29bacSmrg	;;
220311a29bacSmrg
220411a29bacSmrg      *.la)
220511a29bacSmrg	# Check to see that this really is a libtool archive.
220611a29bacSmrg	func_lalib_unsafe_p "$file" \
220711a29bacSmrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
220811a29bacSmrg
220911a29bacSmrg	library_names=
221011a29bacSmrg	old_library=
221111a29bacSmrg	relink_command=
221211a29bacSmrg	func_source "$file"
221311a29bacSmrg
221411a29bacSmrg	# Add the libdir to current_libdirs if it is the destination.
221511a29bacSmrg	if test "X$destdir" = "X$libdir"; then
221611a29bacSmrg	  case "$current_libdirs " in
221711a29bacSmrg	  *" $libdir "*) ;;
221811a29bacSmrg	  *) current_libdirs="$current_libdirs $libdir" ;;
221941b2f0bdSmrg	  esac
222011a29bacSmrg	else
222111a29bacSmrg	  # Note the libdir as a future libdir.
222211a29bacSmrg	  case "$future_libdirs " in
222311a29bacSmrg	  *" $libdir "*) ;;
222411a29bacSmrg	  *) future_libdirs="$future_libdirs $libdir" ;;
222511a29bacSmrg	  esac
222611a29bacSmrg	fi
222741b2f0bdSmrg
222811a29bacSmrg	func_dirname "$file" "/" ""
222911a29bacSmrg	dir="$func_dirname_result"
223011a29bacSmrg	dir="$dir$objdir"
223111a29bacSmrg
223211a29bacSmrg	if test -n "$relink_command"; then
223311a29bacSmrg	  # Determine the prefix the user has applied to our future dir.
223411a29bacSmrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
223511a29bacSmrg
223611a29bacSmrg	  # Don't allow the user to place us outside of our expected
223711a29bacSmrg	  # location b/c this prevents finding dependent libraries that
223811a29bacSmrg	  # are installed to the same prefix.
223911a29bacSmrg	  # At present, this check doesn't affect windows .dll's that
224011a29bacSmrg	  # are installed into $libdir/../bin (currently, that works fine)
224111a29bacSmrg	  # but it's something to keep an eye on.
224211a29bacSmrg	  test "$inst_prefix_dir" = "$destdir" && \
224311a29bacSmrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
224411a29bacSmrg
224511a29bacSmrg	  if test -n "$inst_prefix_dir"; then
224611a29bacSmrg	    # Stick the inst_prefix_dir data into the link command.
224711a29bacSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
224811a29bacSmrg	  else
224911a29bacSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
225011a29bacSmrg	  fi
225111a29bacSmrg
225211a29bacSmrg	  func_warning "relinking \`$file'"
225311a29bacSmrg	  func_show_eval "$relink_command" \
225411a29bacSmrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
225511a29bacSmrg	fi
225611a29bacSmrg
225711a29bacSmrg	# See the names of the shared library.
225811a29bacSmrg	set dummy $library_names; shift
225911a29bacSmrg	if test -n "$1"; then
226011a29bacSmrg	  realname="$1"
226111a29bacSmrg	  shift
226211a29bacSmrg
226311a29bacSmrg	  srcname="$realname"
226411a29bacSmrg	  test -n "$relink_command" && srcname="$realname"T
226511a29bacSmrg
226611a29bacSmrg	  # Install the shared library and build the symlinks.
226711a29bacSmrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
226811a29bacSmrg	      'exit $?'
226911a29bacSmrg	  tstripme="$stripme"
227011a29bacSmrg	  case $host_os in
227111a29bacSmrg	  cygwin* | mingw* | pw32* | cegcc*)
227211a29bacSmrg	    case $realname in
227311a29bacSmrg	    *.dll.a)
227411a29bacSmrg	      tstripme=""
227511a29bacSmrg	      ;;
227611a29bacSmrg	    esac
227741b2f0bdSmrg	    ;;
227841b2f0bdSmrg	  esac
227911a29bacSmrg	  if test -n "$tstripme" && test -n "$striplib"; then
228011a29bacSmrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
228111a29bacSmrg	  fi
228211a29bacSmrg
228311a29bacSmrg	  if test "$#" -gt 0; then
228411a29bacSmrg	    # Delete the old symlinks, and create new ones.
228511a29bacSmrg	    # Try `ln -sf' first, because the `ln' binary might depend on
228611a29bacSmrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
228711a29bacSmrg	    # so we also need to try rm && ln -s.
228811a29bacSmrg	    for linkname
228911a29bacSmrg	    do
229011a29bacSmrg	      test "$linkname" != "$realname" \
229111a29bacSmrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
229211a29bacSmrg	    done
229311a29bacSmrg	  fi
229411a29bacSmrg
229511a29bacSmrg	  # Do each command in the postinstall commands.
229611a29bacSmrg	  lib="$destdir/$realname"
229711a29bacSmrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
229811a29bacSmrg	fi
229911a29bacSmrg
230011a29bacSmrg	# Install the pseudo-library for information purposes.
230111a29bacSmrg	func_basename "$file"
230211a29bacSmrg	name="$func_basename_result"
230311a29bacSmrg	instname="$dir/$name"i
230411a29bacSmrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
230511a29bacSmrg
230611a29bacSmrg	# Maybe install the static library, too.
230711a29bacSmrg	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
230841b2f0bdSmrg	;;
230911a29bacSmrg
231011a29bacSmrg      *.lo)
231111a29bacSmrg	# Install (i.e. copy) a libtool object.
231211a29bacSmrg
231311a29bacSmrg	# Figure out destination file name, if it wasn't already specified.
231411a29bacSmrg	if test -n "$destname"; then
231511a29bacSmrg	  destfile="$destdir/$destname"
231611a29bacSmrg	else
231711a29bacSmrg	  func_basename "$file"
231811a29bacSmrg	  destfile="$func_basename_result"
231911a29bacSmrg	  destfile="$destdir/$destfile"
232011a29bacSmrg	fi
232111a29bacSmrg
232211a29bacSmrg	# Deduce the name of the destination old-style object file.
232311a29bacSmrg	case $destfile in
232411a29bacSmrg	*.lo)
232511a29bacSmrg	  func_lo2o "$destfile"
232611a29bacSmrg	  staticdest=$func_lo2o_result
232741b2f0bdSmrg	  ;;
232811a29bacSmrg	*.$objext)
232911a29bacSmrg	  staticdest="$destfile"
233011a29bacSmrg	  destfile=
233141b2f0bdSmrg	  ;;
233211a29bacSmrg	*)
233311a29bacSmrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
233441b2f0bdSmrg	  ;;
233511a29bacSmrg	esac
233611a29bacSmrg
233711a29bacSmrg	# Install the libtool object if requested.
233811a29bacSmrg	test -n "$destfile" && \
233911a29bacSmrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
234011a29bacSmrg
234111a29bacSmrg	# Install the old object if enabled.
234211a29bacSmrg	if test "$build_old_libs" = yes; then
234311a29bacSmrg	  # Deduce the name of the old-style object file.
234411a29bacSmrg	  func_lo2o "$file"
234511a29bacSmrg	  staticobj=$func_lo2o_result
234611a29bacSmrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
234741b2f0bdSmrg	fi
234811a29bacSmrg	exit $EXIT_SUCCESS
234911a29bacSmrg	;;
235041b2f0bdSmrg
235111a29bacSmrg      *)
235211a29bacSmrg	# Figure out destination file name, if it wasn't already specified.
235311a29bacSmrg	if test -n "$destname"; then
235411a29bacSmrg	  destfile="$destdir/$destname"
235541b2f0bdSmrg	else
235611a29bacSmrg	  func_basename "$file"
235711a29bacSmrg	  destfile="$func_basename_result"
235811a29bacSmrg	  destfile="$destdir/$destfile"
235941b2f0bdSmrg	fi
236041b2f0bdSmrg
236111a29bacSmrg	# If the file is missing, and there is a .exe on the end, strip it
236211a29bacSmrg	# because it is most likely a libtool script we actually want to
236311a29bacSmrg	# install
236411a29bacSmrg	stripped_ext=""
236511a29bacSmrg	case $file in
236611a29bacSmrg	  *.exe)
236711a29bacSmrg	    if test ! -f "$file"; then
236811a29bacSmrg	      func_stripname '' '.exe' "$file"
236911a29bacSmrg	      file=$func_stripname_result
237011a29bacSmrg	      stripped_ext=".exe"
237111a29bacSmrg	    fi
237211a29bacSmrg	    ;;
237311a29bacSmrg	esac
237441b2f0bdSmrg
237511a29bacSmrg	# Do a test to see if this is really a libtool program.
237611a29bacSmrg	case $host in
237711a29bacSmrg	*cygwin* | *mingw*)
237811a29bacSmrg	    if func_ltwrapper_executable_p "$file"; then
237911a29bacSmrg	      func_ltwrapper_scriptname "$file"
238011a29bacSmrg	      wrapper=$func_ltwrapper_scriptname_result
238111a29bacSmrg	    else
238211a29bacSmrg	      func_stripname '' '.exe' "$file"
238311a29bacSmrg	      wrapper=$func_stripname_result
238411a29bacSmrg	    fi
238511a29bacSmrg	    ;;
238611a29bacSmrg	*)
238711a29bacSmrg	    wrapper=$file
238811a29bacSmrg	    ;;
238911a29bacSmrg	esac
239011a29bacSmrg	if func_ltwrapper_script_p "$wrapper"; then
239111a29bacSmrg	  notinst_deplibs=
239211a29bacSmrg	  relink_command=
239341b2f0bdSmrg
239411a29bacSmrg	  func_source "$wrapper"
239541b2f0bdSmrg
239611a29bacSmrg	  # Check the variables that should have been set.
239711a29bacSmrg	  test -z "$generated_by_libtool_version" && \
239811a29bacSmrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
239941b2f0bdSmrg
240011a29bacSmrg	  finalize=yes
240111a29bacSmrg	  for lib in $notinst_deplibs; do
240211a29bacSmrg	    # Check to see that each library is installed.
240311a29bacSmrg	    libdir=
240411a29bacSmrg	    if test -f "$lib"; then
240511a29bacSmrg	      func_source "$lib"
240641b2f0bdSmrg	    fi
240711a29bacSmrg	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
240811a29bacSmrg	    if test -n "$libdir" && test ! -f "$libfile"; then
240911a29bacSmrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
241011a29bacSmrg	      finalize=no
241111a29bacSmrg	    fi
241211a29bacSmrg	  done
241341b2f0bdSmrg
241411a29bacSmrg	  relink_command=
241511a29bacSmrg	  func_source "$wrapper"
241641b2f0bdSmrg
241711a29bacSmrg	  outputname=
241811a29bacSmrg	  if test "$fast_install" = no && test -n "$relink_command"; then
241911a29bacSmrg	    $opt_dry_run || {
242011a29bacSmrg	      if test "$finalize" = yes; then
242111a29bacSmrg	        tmpdir=`func_mktempdir`
242211a29bacSmrg		func_basename "$file$stripped_ext"
242311a29bacSmrg		file="$func_basename_result"
242411a29bacSmrg	        outputname="$tmpdir/$file"
242511a29bacSmrg	        # Replace the output file specification.
242611a29bacSmrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
242711a29bacSmrg
242811a29bacSmrg	        $opt_silent || {
242911a29bacSmrg	          func_quote_for_expand "$relink_command"
243011a29bacSmrg		  eval "func_echo $func_quote_for_expand_result"
243111a29bacSmrg	        }
243211a29bacSmrg	        if eval "$relink_command"; then :
243311a29bacSmrg	          else
243411a29bacSmrg		  func_error "error: relink \`$file' with the above command before installing it"
243511a29bacSmrg		  $opt_dry_run || ${RM}r "$tmpdir"
243611a29bacSmrg		  continue
243711a29bacSmrg	        fi
243811a29bacSmrg	        file="$outputname"
243911a29bacSmrg	      else
244011a29bacSmrg	        func_warning "cannot relink \`$file'"
244111a29bacSmrg	      fi
244211a29bacSmrg	    }
244341b2f0bdSmrg	  else
244411a29bacSmrg	    # Install the binary that we compiled earlier.
244511a29bacSmrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
244641b2f0bdSmrg	  fi
244711a29bacSmrg	fi
244841b2f0bdSmrg
244911a29bacSmrg	# remove .exe since cygwin /usr/bin/install will append another
245011a29bacSmrg	# one anyway
245111a29bacSmrg	case $install_prog,$host in
245211a29bacSmrg	*/usr/bin/install*,*cygwin*)
245311a29bacSmrg	  case $file:$destfile in
245411a29bacSmrg	  *.exe:*.exe)
245511a29bacSmrg	    # this is ok
245611a29bacSmrg	    ;;
245711a29bacSmrg	  *.exe:*)
245811a29bacSmrg	    destfile=$destfile.exe
245911a29bacSmrg	    ;;
246011a29bacSmrg	  *:*.exe)
246111a29bacSmrg	    func_stripname '' '.exe' "$destfile"
246211a29bacSmrg	    destfile=$func_stripname_result
246311a29bacSmrg	    ;;
246411a29bacSmrg	  esac
246541b2f0bdSmrg	  ;;
246641b2f0bdSmrg	esac
246711a29bacSmrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
246811a29bacSmrg	$opt_dry_run || if test -n "$outputname"; then
246911a29bacSmrg	  ${RM}r "$tmpdir"
247011a29bacSmrg	fi
247111a29bacSmrg	;;
247211a29bacSmrg      esac
247311a29bacSmrg    done
247441b2f0bdSmrg
247511a29bacSmrg    for file in $staticlibs; do
247611a29bacSmrg      func_basename "$file"
247711a29bacSmrg      name="$func_basename_result"
247811a29bacSmrg
247911a29bacSmrg      # Set up the ranlib parameters.
248011a29bacSmrg      oldlib="$destdir/$name"
248111a29bacSmrg
248211a29bacSmrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
248311a29bacSmrg
248411a29bacSmrg      if test -n "$stripme" && test -n "$old_striplib"; then
248511a29bacSmrg	func_show_eval "$old_striplib $oldlib" 'exit $?'
248611a29bacSmrg      fi
248711a29bacSmrg
248811a29bacSmrg      # Do each command in the postinstall commands.
248911a29bacSmrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
249011a29bacSmrg    done
249111a29bacSmrg
249211a29bacSmrg    test -n "$future_libdirs" && \
249311a29bacSmrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
249411a29bacSmrg
249511a29bacSmrg    if test -n "$current_libdirs"; then
249611a29bacSmrg      # Maybe just do a dry run.
249711a29bacSmrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
249811a29bacSmrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
249911a29bacSmrg    else
250011a29bacSmrg      exit $EXIT_SUCCESS
250111a29bacSmrg    fi
250211a29bacSmrg}
250311a29bacSmrg
250411a29bacSmrgtest "$mode" = install && func_mode_install ${1+"$@"}
250511a29bacSmrg
250611a29bacSmrg
250711a29bacSmrg# func_generate_dlsyms outputname originator pic_p
250811a29bacSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with
250911a29bacSmrg# a dlpreopen symbol table.
251011a29bacSmrgfunc_generate_dlsyms ()
251111a29bacSmrg{
251211a29bacSmrg    $opt_debug
251311a29bacSmrg    my_outputname="$1"
251411a29bacSmrg    my_originator="$2"
251511a29bacSmrg    my_pic_p="${3-no}"
251611a29bacSmrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
251711a29bacSmrg    my_dlsyms=
251811a29bacSmrg
251911a29bacSmrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
252011a29bacSmrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
252111a29bacSmrg	my_dlsyms="${my_outputname}S.c"
252211a29bacSmrg      else
252311a29bacSmrg	func_error "not configured to extract global symbols from dlpreopened files"
252411a29bacSmrg      fi
252511a29bacSmrg    fi
252611a29bacSmrg
252711a29bacSmrg    if test -n "$my_dlsyms"; then
252811a29bacSmrg      case $my_dlsyms in
252911a29bacSmrg      "") ;;
253011a29bacSmrg      *.c)
253111a29bacSmrg	# Discover the nlist of each of the dlfiles.
253211a29bacSmrg	nlist="$output_objdir/${my_outputname}.nm"
253311a29bacSmrg
253411a29bacSmrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
253511a29bacSmrg
253611a29bacSmrg	# Parse the name list into a source file.
253711a29bacSmrg	func_verbose "creating $output_objdir/$my_dlsyms"
253811a29bacSmrg
253911a29bacSmrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
254011a29bacSmrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
254111a29bacSmrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
254211a29bacSmrg
254311a29bacSmrg#ifdef __cplusplus
254411a29bacSmrgextern \"C\" {
254511a29bacSmrg#endif
254611a29bacSmrg
254711a29bacSmrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
254811a29bacSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
254911a29bacSmrg#endif
255011a29bacSmrg
255111a29bacSmrg/* External symbol declarations for the compiler. */\
255211a29bacSmrg"
255311a29bacSmrg
255411a29bacSmrg	if test "$dlself" = yes; then
255511a29bacSmrg	  func_verbose "generating symbol list for \`$output'"
255611a29bacSmrg
255711a29bacSmrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
255811a29bacSmrg
255911a29bacSmrg	  # Add our own program objects to the symbol list.
256011a29bacSmrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
256111a29bacSmrg	  for progfile in $progfiles; do
256211a29bacSmrg	    func_verbose "extracting global C symbols from \`$progfile'"
256311a29bacSmrg	    $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
256411a29bacSmrg	  done
256511a29bacSmrg
256611a29bacSmrg	  if test -n "$exclude_expsyms"; then
256711a29bacSmrg	    $opt_dry_run || {
256811a29bacSmrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
256911a29bacSmrg	      eval '$MV "$nlist"T "$nlist"'
257011a29bacSmrg	    }
257141b2f0bdSmrg	  fi
257211a29bacSmrg
257311a29bacSmrg	  if test -n "$export_symbols_regex"; then
257411a29bacSmrg	    $opt_dry_run || {
257511a29bacSmrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
257611a29bacSmrg	      eval '$MV "$nlist"T "$nlist"'
257711a29bacSmrg	    }
257811a29bacSmrg	  fi
257911a29bacSmrg
258011a29bacSmrg	  # Prepare the list of exported symbols
258111a29bacSmrg	  if test -z "$export_symbols"; then
258211a29bacSmrg	    export_symbols="$output_objdir/$outputname.exp"
258311a29bacSmrg	    $opt_dry_run || {
258411a29bacSmrg	      $RM $export_symbols
258511a29bacSmrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
258611a29bacSmrg	      case $host in
258711a29bacSmrg	      *cygwin* | *mingw* | *cegcc* )
258811a29bacSmrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
258911a29bacSmrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
259011a29bacSmrg	        ;;
259111a29bacSmrg	      esac
259211a29bacSmrg	    }
259341b2f0bdSmrg	  else
259411a29bacSmrg	    $opt_dry_run || {
259511a29bacSmrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
259611a29bacSmrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
259711a29bacSmrg	      eval '$MV "$nlist"T "$nlist"'
259811a29bacSmrg	      case $host in
259911a29bacSmrg	        *cygwin* | *mingw* | *cegcc* )
260011a29bacSmrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
260111a29bacSmrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
260211a29bacSmrg	          ;;
260311a29bacSmrg	      esac
260411a29bacSmrg	    }
260541b2f0bdSmrg	  fi
260611a29bacSmrg	fi
260741b2f0bdSmrg
260811a29bacSmrg	for dlprefile in $dlprefiles; do
260911a29bacSmrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
261011a29bacSmrg	  func_basename "$dlprefile"
261111a29bacSmrg	  name="$func_basename_result"
261211a29bacSmrg	  $opt_dry_run || {
261311a29bacSmrg	    eval '$ECHO ": $name " >> "$nlist"'
261411a29bacSmrg	    eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
261511a29bacSmrg	  }
261611a29bacSmrg	done
261711a29bacSmrg
261811a29bacSmrg	$opt_dry_run || {
261911a29bacSmrg	  # Make sure we have at least an empty file.
262011a29bacSmrg	  test -f "$nlist" || : > "$nlist"
262111a29bacSmrg
262211a29bacSmrg	  if test -n "$exclude_expsyms"; then
262311a29bacSmrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
262411a29bacSmrg	    $MV "$nlist"T "$nlist"
262541b2f0bdSmrg	  fi
262611a29bacSmrg
262711a29bacSmrg	  # Try sorting and uniquifying the output.
262811a29bacSmrg	  if $GREP -v "^: " < "$nlist" |
262911a29bacSmrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
263011a29bacSmrg		sort -k 3
263111a29bacSmrg	      else
263211a29bacSmrg		sort +2
263311a29bacSmrg	      fi |
263411a29bacSmrg	      uniq > "$nlist"S; then
263511a29bacSmrg	    :
263641b2f0bdSmrg	  else
263711a29bacSmrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
263841b2f0bdSmrg	  fi
263941b2f0bdSmrg
264011a29bacSmrg	  if test -f "$nlist"S; then
264111a29bacSmrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
264241b2f0bdSmrg	  else
264311a29bacSmrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
264441b2f0bdSmrg	  fi
264541b2f0bdSmrg
264611a29bacSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
264741b2f0bdSmrg
264811a29bacSmrg/* The mapping between symbol names and symbols.  */
264911a29bacSmrgtypedef struct {
265011a29bacSmrg  const char *name;
265111a29bacSmrg  void *address;
265211a29bacSmrg} lt_dlsymlist;
265311a29bacSmrg"
265411a29bacSmrg	  case $host in
265511a29bacSmrg	  *cygwin* | *mingw* | *cegcc* )
265611a29bacSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
265711a29bacSmrg/* DATA imports from DLLs on WIN32 con't be const, because
265811a29bacSmrg   runtime relocations are performed -- see ld's documentation
265911a29bacSmrg   on pseudo-relocs.  */"
266011a29bacSmrg	    lt_dlsym_const= ;;
266111a29bacSmrg	  *osf5*)
266211a29bacSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
266311a29bacSmrg/* This system does not cope well with relocations in const data */"
266411a29bacSmrg	    lt_dlsym_const= ;;
266511a29bacSmrg	  *)
266611a29bacSmrg	    lt_dlsym_const=const ;;
266711a29bacSmrg	  esac
266841b2f0bdSmrg
266911a29bacSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
267011a29bacSmrgextern $lt_dlsym_const lt_dlsymlist
267111a29bacSmrglt_${my_prefix}_LTX_preloaded_symbols[];
267211a29bacSmrg$lt_dlsym_const lt_dlsymlist
267311a29bacSmrglt_${my_prefix}_LTX_preloaded_symbols[] =
267411a29bacSmrg{\
267511a29bacSmrg  { \"$my_originator\", (void *) 0 },"
267641b2f0bdSmrg
267711a29bacSmrg	  case $need_lib_prefix in
267811a29bacSmrg	  no)
267911a29bacSmrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
268011a29bacSmrg	    ;;
268111a29bacSmrg	  *)
268211a29bacSmrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
268311a29bacSmrg	    ;;
268411a29bacSmrg	  esac
268511a29bacSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
268611a29bacSmrg  {0, (void *) 0}
268711a29bacSmrg};
268841b2f0bdSmrg
268911a29bacSmrg/* This works around a problem in FreeBSD linker */
269011a29bacSmrg#ifdef FREEBSD_WORKAROUND
269111a29bacSmrgstatic const void *lt_preloaded_setup() {
269211a29bacSmrg  return lt_${my_prefix}_LTX_preloaded_symbols;
269311a29bacSmrg}
269411a29bacSmrg#endif
269541b2f0bdSmrg
269611a29bacSmrg#ifdef __cplusplus
269711a29bacSmrg}
269811a29bacSmrg#endif\
269911a29bacSmrg"
270011a29bacSmrg	} # !$opt_dry_run
270141b2f0bdSmrg
270211a29bacSmrg	pic_flag_for_symtable=
270311a29bacSmrg	case "$compile_command " in
270411a29bacSmrg	*" -static "*) ;;
270511a29bacSmrg	*)
270611a29bacSmrg	  case $host in
270711a29bacSmrg	  # compiling the symbol table file with pic_flag works around
270811a29bacSmrg	  # a FreeBSD bug that causes programs to crash when -lm is
270911a29bacSmrg	  # linked before any other PIC object.  But we must not use
271011a29bacSmrg	  # pic_flag when linking with -static.  The problem exists in
271111a29bacSmrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
271211a29bacSmrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
271311a29bacSmrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
271411a29bacSmrg	  *-*-hpux*)
271511a29bacSmrg	    pic_flag_for_symtable=" $pic_flag"  ;;
271611a29bacSmrg	  *)
271711a29bacSmrg	    if test "X$my_pic_p" != Xno; then
271811a29bacSmrg	      pic_flag_for_symtable=" $pic_flag"
271911a29bacSmrg	    fi
272011a29bacSmrg	    ;;
272111a29bacSmrg	  esac
272211a29bacSmrg	  ;;
272311a29bacSmrg	esac
272411a29bacSmrg	symtab_cflags=
272511a29bacSmrg	for arg in $LTCFLAGS; do
272611a29bacSmrg	  case $arg in
272711a29bacSmrg	  -pie | -fpie | -fPIE) ;;
272811a29bacSmrg	  *) symtab_cflags="$symtab_cflags $arg" ;;
272911a29bacSmrg	  esac
273011a29bacSmrg	done
273141b2f0bdSmrg
273211a29bacSmrg	# Now compile the dynamic symbol file.
273311a29bacSmrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
273441b2f0bdSmrg
273511a29bacSmrg	# Clean up the generated files.
273611a29bacSmrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
273741b2f0bdSmrg
273811a29bacSmrg	# Transform the symbol file into the correct name.
273911a29bacSmrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
274011a29bacSmrg	case $host in
274111a29bacSmrg	*cygwin* | *mingw* | *cegcc* )
274211a29bacSmrg	  if test -f "$output_objdir/$my_outputname.def"; then
274311a29bacSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
274411a29bacSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
274511a29bacSmrg	  else
274611a29bacSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
274711a29bacSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
274811a29bacSmrg	  fi
274911a29bacSmrg	  ;;
275011a29bacSmrg	*)
275111a29bacSmrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
275211a29bacSmrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
275311a29bacSmrg	  ;;
275411a29bacSmrg	esac
275511a29bacSmrg	;;
275611a29bacSmrg      *)
275711a29bacSmrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
275811a29bacSmrg	;;
275911a29bacSmrg      esac
276011a29bacSmrg    else
276111a29bacSmrg      # We keep going just in case the user didn't refer to
276211a29bacSmrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
276311a29bacSmrg      # really was required.
276441b2f0bdSmrg
276511a29bacSmrg      # Nullify the symbol file.
276611a29bacSmrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
276711a29bacSmrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
276811a29bacSmrg    fi
276911a29bacSmrg}
277041b2f0bdSmrg
277111a29bacSmrg# func_win32_libid arg
277211a29bacSmrg# return the library type of file 'arg'
277311a29bacSmrg#
277411a29bacSmrg# Need a lot of goo to handle *both* DLLs and import libs
277511a29bacSmrg# Has to be a shell function in order to 'eat' the argument
277611a29bacSmrg# that is supplied when $file_magic_command is called.
277711a29bacSmrg# Despite the name, also deal with 64 bit binaries.
277811a29bacSmrgfunc_win32_libid ()
277911a29bacSmrg{
278011a29bacSmrg  $opt_debug
278111a29bacSmrg  win32_libid_type="unknown"
278211a29bacSmrg  win32_fileres=`file -L $1 2>/dev/null`
278311a29bacSmrg  case $win32_fileres in
278411a29bacSmrg  *ar\ archive\ import\ library*) # definitely import
278511a29bacSmrg    win32_libid_type="x86 archive import"
278611a29bacSmrg    ;;
278711a29bacSmrg  *ar\ archive*) # could be an import, or static
278811a29bacSmrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
278911a29bacSmrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
279011a29bacSmrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
279111a29bacSmrg      win32_nmres=`eval $NM -f posix -A $1 |
279211a29bacSmrg	$SED -n -e '
279311a29bacSmrg	    1,100{
279411a29bacSmrg		/ I /{
279511a29bacSmrg		    s,.*,import,
279611a29bacSmrg		    p
279711a29bacSmrg		    q
279811a29bacSmrg		}
279911a29bacSmrg	    }'`
280011a29bacSmrg      case $win32_nmres in
280111a29bacSmrg      import*)  win32_libid_type="x86 archive import";;
280211a29bacSmrg      *)        win32_libid_type="x86 archive static";;
280311a29bacSmrg      esac
280411a29bacSmrg    fi
280511a29bacSmrg    ;;
280611a29bacSmrg  *DLL*)
280711a29bacSmrg    win32_libid_type="x86 DLL"
280811a29bacSmrg    ;;
280911a29bacSmrg  *executable*) # but shell scripts are "executable" too...
281011a29bacSmrg    case $win32_fileres in
281111a29bacSmrg    *MS\ Windows\ PE\ Intel*)
281211a29bacSmrg      win32_libid_type="x86 DLL"
281311a29bacSmrg      ;;
281411a29bacSmrg    esac
281511a29bacSmrg    ;;
281611a29bacSmrg  esac
281711a29bacSmrg  $ECHO "$win32_libid_type"
281811a29bacSmrg}
281941b2f0bdSmrg
282041b2f0bdSmrg
282141b2f0bdSmrg
282211a29bacSmrg# func_extract_an_archive dir oldlib
282311a29bacSmrgfunc_extract_an_archive ()
282411a29bacSmrg{
282511a29bacSmrg    $opt_debug
282611a29bacSmrg    f_ex_an_ar_dir="$1"; shift
282711a29bacSmrg    f_ex_an_ar_oldlib="$1"
282811a29bacSmrg    if test "$lock_old_archive_extraction" = yes; then
282911a29bacSmrg      lockfile=$f_ex_an_ar_oldlib.lock
283011a29bacSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
283111a29bacSmrg	func_echo "Waiting for $lockfile to be removed"
283211a29bacSmrg	sleep 2
283311a29bacSmrg      done
283411a29bacSmrg    fi
283511a29bacSmrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
283611a29bacSmrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
283711a29bacSmrg    if test "$lock_old_archive_extraction" = yes; then
283811a29bacSmrg      $opt_dry_run || rm -f "$lockfile"
283911a29bacSmrg    fi
284011a29bacSmrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
284111a29bacSmrg     :
284211a29bacSmrg    else
284311a29bacSmrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
284411a29bacSmrg    fi
284511a29bacSmrg}
284641b2f0bdSmrg
284741b2f0bdSmrg
284811a29bacSmrg# func_extract_archives gentop oldlib ...
284911a29bacSmrgfunc_extract_archives ()
285011a29bacSmrg{
285111a29bacSmrg    $opt_debug
285211a29bacSmrg    my_gentop="$1"; shift
285311a29bacSmrg    my_oldlibs=${1+"$@"}
285411a29bacSmrg    my_oldobjs=""
285511a29bacSmrg    my_xlib=""
285611a29bacSmrg    my_xabs=""
285711a29bacSmrg    my_xdir=""
285841b2f0bdSmrg
285911a29bacSmrg    for my_xlib in $my_oldlibs; do
286011a29bacSmrg      # Extract the objects.
286111a29bacSmrg      case $my_xlib in
286211a29bacSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
286311a29bacSmrg	*) my_xabs=`pwd`"/$my_xlib" ;;
286411a29bacSmrg      esac
286511a29bacSmrg      func_basename "$my_xlib"
286611a29bacSmrg      my_xlib="$func_basename_result"
286711a29bacSmrg      my_xlib_u=$my_xlib
286811a29bacSmrg      while :; do
286911a29bacSmrg        case " $extracted_archives " in
287011a29bacSmrg	*" $my_xlib_u "*)
287111a29bacSmrg	  func_arith $extracted_serial + 1
287211a29bacSmrg	  extracted_serial=$func_arith_result
287311a29bacSmrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
287411a29bacSmrg	*) break ;;
287511a29bacSmrg	esac
287611a29bacSmrg      done
287711a29bacSmrg      extracted_archives="$extracted_archives $my_xlib_u"
287811a29bacSmrg      my_xdir="$my_gentop/$my_xlib_u"
287941b2f0bdSmrg
288011a29bacSmrg      func_mkdir_p "$my_xdir"
288111a29bacSmrg
288211a29bacSmrg      case $host in
288311a29bacSmrg      *-darwin*)
288411a29bacSmrg	func_verbose "Extracting $my_xabs"
288511a29bacSmrg	# Do not bother doing anything if just a dry run
288611a29bacSmrg	$opt_dry_run || {
288711a29bacSmrg	  darwin_orig_dir=`pwd`
288811a29bacSmrg	  cd $my_xdir || exit $?
288911a29bacSmrg	  darwin_archive=$my_xabs
289011a29bacSmrg	  darwin_curdir=`pwd`
289111a29bacSmrg	  darwin_base_archive=`basename "$darwin_archive"`
289211a29bacSmrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
289311a29bacSmrg	  if test -n "$darwin_arches"; then
289411a29bacSmrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
289511a29bacSmrg	    darwin_arch=
289611a29bacSmrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
289711a29bacSmrg	    for darwin_arch in  $darwin_arches ; do
289811a29bacSmrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
289911a29bacSmrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
290011a29bacSmrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
290111a29bacSmrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
290211a29bacSmrg	      cd "$darwin_curdir"
290311a29bacSmrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
290411a29bacSmrg	    done # $darwin_arches
290511a29bacSmrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
290611a29bacSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
290711a29bacSmrg	    darwin_file=
290811a29bacSmrg	    darwin_files=
290911a29bacSmrg	    for darwin_file in $darwin_filelist; do
291011a29bacSmrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
291111a29bacSmrg	      $LIPO -create -output "$darwin_file" $darwin_files
291211a29bacSmrg	    done # $darwin_filelist
291311a29bacSmrg	    $RM -rf unfat-$$
291411a29bacSmrg	    cd "$darwin_orig_dir"
291541b2f0bdSmrg	  else
291611a29bacSmrg	    cd $darwin_orig_dir
291711a29bacSmrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
291811a29bacSmrg	  fi # $darwin_arches
291911a29bacSmrg	} # !$opt_dry_run
292011a29bacSmrg	;;
292111a29bacSmrg      *)
292211a29bacSmrg        func_extract_an_archive "$my_xdir" "$my_xabs"
292311a29bacSmrg	;;
292411a29bacSmrg      esac
292511a29bacSmrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
292611a29bacSmrg    done
292741b2f0bdSmrg
292811a29bacSmrg    func_extract_archives_result="$my_oldobjs"
292911a29bacSmrg}
293041b2f0bdSmrg
293141b2f0bdSmrg
293211a29bacSmrg# func_emit_wrapper [arg=no]
293311a29bacSmrg#
293411a29bacSmrg# Emit a libtool wrapper script on stdout.
293511a29bacSmrg# Don't directly open a file because we may want to
293611a29bacSmrg# incorporate the script contents within a cygwin/mingw
293711a29bacSmrg# wrapper executable.  Must ONLY be called from within
293811a29bacSmrg# func_mode_link because it depends on a number of variables
293911a29bacSmrg# set therein.
294011a29bacSmrg#
294111a29bacSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
294211a29bacSmrg# variable will take.  If 'yes', then the emitted script
294311a29bacSmrg# will assume that the directory in which it is stored is
294411a29bacSmrg# the $objdir directory.  This is a cygwin/mingw-specific
294511a29bacSmrg# behavior.
294611a29bacSmrgfunc_emit_wrapper ()
294711a29bacSmrg{
294811a29bacSmrg	func_emit_wrapper_arg1=${1-no}
294941b2f0bdSmrg
295011a29bacSmrg	$ECHO "\
295111a29bacSmrg#! $SHELL
295241b2f0bdSmrg
295311a29bacSmrg# $output - temporary wrapper script for $objdir/$outputname
295411a29bacSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
295511a29bacSmrg#
295611a29bacSmrg# The $output program cannot be directly executed until all the libtool
295711a29bacSmrg# libraries that it depends on are installed.
295811a29bacSmrg#
295911a29bacSmrg# This wrapper script should never be moved out of the build directory.
296011a29bacSmrg# If it is, it will not operate correctly.
296141b2f0bdSmrg
296211a29bacSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
296311a29bacSmrg# metacharacters that are still active within double-quoted strings.
296411a29bacSmrgsed_quote_subst='$sed_quote_subst'
296541b2f0bdSmrg
296611a29bacSmrg# Be Bourne compatible
296711a29bacSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
296811a29bacSmrg  emulate sh
296911a29bacSmrg  NULLCMD=:
297011a29bacSmrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
297111a29bacSmrg  # is contrary to our usage.  Disable this feature.
297211a29bacSmrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
297311a29bacSmrg  setopt NO_GLOB_SUBST
297411a29bacSmrgelse
297511a29bacSmrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
297611a29bacSmrgfi
297711a29bacSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
297811a29bacSmrgDUALCASE=1; export DUALCASE # for MKS sh
297941b2f0bdSmrg
298011a29bacSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout
298111a29bacSmrg# if CDPATH is set.
298211a29bacSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
298341b2f0bdSmrg
298411a29bacSmrgrelink_command=\"$relink_command\"
298541b2f0bdSmrg
298611a29bacSmrg# This environment variable determines our operation mode.
298711a29bacSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then
298811a29bacSmrg  # install mode needs the following variables:
298911a29bacSmrg  generated_by_libtool_version='$macro_version'
299011a29bacSmrg  notinst_deplibs='$notinst_deplibs'
299111a29bacSmrgelse
299211a29bacSmrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
299311a29bacSmrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
299411a29bacSmrg    file=\"\$0\""
299541b2f0bdSmrg
299611a29bacSmrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
299711a29bacSmrg    $ECHO "\
299841b2f0bdSmrg
299911a29bacSmrg# A function that is used when there is no print builtin or printf.
300011a29bacSmrgfunc_fallback_echo ()
300111a29bacSmrg{
300211a29bacSmrg  eval 'cat <<_LTECHO_EOF
300311a29bacSmrg\$1
300411a29bacSmrg_LTECHO_EOF'
300511a29bacSmrg}
300611a29bacSmrg    ECHO=\"$qECHO\"
300711a29bacSmrg  fi
300811a29bacSmrg
300911a29bacSmrg# Very basic option parsing. These options are (a) specific to
301011a29bacSmrg# the libtool wrapper, (b) are identical between the wrapper
301111a29bacSmrg# /script/ and the wrapper /executable/ which is used only on
301211a29bacSmrg# windows platforms, and (c) all begin with the string "--lt-"
301311a29bacSmrg# (application programs are unlikely to have options which match
301411a29bacSmrg# this pattern).
301511a29bacSmrg#
301611a29bacSmrg# There are only two supported options: --lt-debug and
301711a29bacSmrg# --lt-dump-script. There is, deliberately, no --lt-help.
301811a29bacSmrg#
301911a29bacSmrg# The first argument to this parsing function should be the
302011a29bacSmrg# script's $0 value, followed by "$@".
302111a29bacSmrglt_option_debug=
302211a29bacSmrgfunc_parse_lt_options ()
302311a29bacSmrg{
302411a29bacSmrg  lt_script_arg0=\$0
302511a29bacSmrg  shift
302611a29bacSmrg  for lt_opt
302711a29bacSmrg  do
302811a29bacSmrg    case \"\$lt_opt\" in
302911a29bacSmrg    --lt-debug) lt_option_debug=1 ;;
303011a29bacSmrg    --lt-dump-script)
303111a29bacSmrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
303211a29bacSmrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
303311a29bacSmrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
303411a29bacSmrg        cat \"\$lt_dump_D/\$lt_dump_F\"
303511a29bacSmrg        exit 0
303611a29bacSmrg      ;;
303711a29bacSmrg    --lt-*)
303811a29bacSmrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
303911a29bacSmrg        exit 1
304041b2f0bdSmrg      ;;
304111a29bacSmrg    esac
304211a29bacSmrg  done
304341b2f0bdSmrg
304411a29bacSmrg  # Print the debug banner immediately:
304511a29bacSmrg  if test -n \"\$lt_option_debug\"; then
304611a29bacSmrg    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
304711a29bacSmrg  fi
304811a29bacSmrg}
304941b2f0bdSmrg
305011a29bacSmrg# Used when --lt-debug. Prints its arguments to stdout
305111a29bacSmrg# (redirection is the responsibility of the caller)
305211a29bacSmrgfunc_lt_dump_args ()
305311a29bacSmrg{
305411a29bacSmrg  lt_dump_args_N=1;
305511a29bacSmrg  for lt_arg
305611a29bacSmrg  do
305711a29bacSmrg    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
305811a29bacSmrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
305911a29bacSmrg  done
306011a29bacSmrg}
306141b2f0bdSmrg
306211a29bacSmrg# Core function for launching the target application
306311a29bacSmrgfunc_exec_program_core ()
306411a29bacSmrg{
306511a29bacSmrg"
306611a29bacSmrg  case $host in
306711a29bacSmrg  # Backslashes separate directories on plain windows
306811a29bacSmrg  *-*-mingw | *-*-os2* | *-cegcc*)
306911a29bacSmrg    $ECHO "\
307011a29bacSmrg      if test -n \"\$lt_option_debug\"; then
307111a29bacSmrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
307211a29bacSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
307341b2f0bdSmrg      fi
307411a29bacSmrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
307511a29bacSmrg"
307611a29bacSmrg    ;;
307741b2f0bdSmrg
307811a29bacSmrg  *)
307911a29bacSmrg    $ECHO "\
308011a29bacSmrg      if test -n \"\$lt_option_debug\"; then
308111a29bacSmrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
308211a29bacSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
308341b2f0bdSmrg      fi
308411a29bacSmrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
308511a29bacSmrg"
308611a29bacSmrg    ;;
308711a29bacSmrg  esac
308811a29bacSmrg  $ECHO "\
308911a29bacSmrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
309011a29bacSmrg      exit 1
309111a29bacSmrg}
309241b2f0bdSmrg
309311a29bacSmrg# A function to encapsulate launching the target application
309411a29bacSmrg# Strips options in the --lt-* namespace from \$@ and
309511a29bacSmrg# launches target application with the remaining arguments.
309611a29bacSmrgfunc_exec_program ()
309711a29bacSmrg{
309811a29bacSmrg  for lt_wr_arg
309911a29bacSmrg  do
310011a29bacSmrg    case \$lt_wr_arg in
310111a29bacSmrg    --lt-*) ;;
310211a29bacSmrg    *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
310311a29bacSmrg    esac
310411a29bacSmrg    shift
310511a29bacSmrg  done
310611a29bacSmrg  func_exec_program_core \${1+\"\$@\"}
310711a29bacSmrg}
310841b2f0bdSmrg
310911a29bacSmrg  # Parse options
311011a29bacSmrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
311141b2f0bdSmrg
311211a29bacSmrg  # Find the directory that this script lives in.
311311a29bacSmrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
311411a29bacSmrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
311541b2f0bdSmrg
311611a29bacSmrg  # Follow symbolic links until we get to the real thisdir.
311711a29bacSmrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
311811a29bacSmrg  while test -n \"\$file\"; do
311911a29bacSmrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
312041b2f0bdSmrg
312111a29bacSmrg    # If there was a directory component, then change thisdir.
312211a29bacSmrg    if test \"x\$destdir\" != \"x\$file\"; then
312311a29bacSmrg      case \"\$destdir\" in
312411a29bacSmrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
312511a29bacSmrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
312611a29bacSmrg      esac
312711a29bacSmrg    fi
312841b2f0bdSmrg
312911a29bacSmrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
313011a29bacSmrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
313111a29bacSmrg  done
313241b2f0bdSmrg
313311a29bacSmrg  # Usually 'no', except on cygwin/mingw when embedded into
313411a29bacSmrg  # the cwrapper.
313511a29bacSmrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
313611a29bacSmrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
313711a29bacSmrg    # special case for '.'
313811a29bacSmrg    if test \"\$thisdir\" = \".\"; then
313911a29bacSmrg      thisdir=\`pwd\`
314011a29bacSmrg    fi
314111a29bacSmrg    # remove .libs from thisdir
314211a29bacSmrg    case \"\$thisdir\" in
314311a29bacSmrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
314411a29bacSmrg    $objdir )   thisdir=. ;;
314511a29bacSmrg    esac
314611a29bacSmrg  fi
314741b2f0bdSmrg
314811a29bacSmrg  # Try to get the absolute directory name.
314911a29bacSmrg  absdir=\`cd \"\$thisdir\" && pwd\`
315011a29bacSmrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
315111a29bacSmrg"
315241b2f0bdSmrg
315311a29bacSmrg	if test "$fast_install" = yes; then
315411a29bacSmrg	  $ECHO "\
315511a29bacSmrg  program=lt-'$outputname'$exeext
315611a29bacSmrg  progdir=\"\$thisdir/$objdir\"
315741b2f0bdSmrg
315811a29bacSmrg  if test ! -f \"\$progdir/\$program\" ||
315911a29bacSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
316011a29bacSmrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
316141b2f0bdSmrg
316211a29bacSmrg    file=\"\$\$-\$program\"
316341b2f0bdSmrg
316411a29bacSmrg    if test ! -d \"\$progdir\"; then
316511a29bacSmrg      $MKDIR \"\$progdir\"
316611a29bacSmrg    else
316711a29bacSmrg      $RM \"\$progdir/\$file\"
316811a29bacSmrg    fi"
316941b2f0bdSmrg
317011a29bacSmrg	  $ECHO "\
317141b2f0bdSmrg
317211a29bacSmrg    # relink executable if necessary
317311a29bacSmrg    if test -n \"\$relink_command\"; then
317411a29bacSmrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
317511a29bacSmrg      else
317611a29bacSmrg	$ECHO \"\$relink_command_output\" >&2
317711a29bacSmrg	$RM \"\$progdir/\$file\"
317811a29bacSmrg	exit 1
317911a29bacSmrg      fi
318011a29bacSmrg    fi
318141b2f0bdSmrg
318211a29bacSmrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
318311a29bacSmrg    { $RM \"\$progdir/\$program\";
318411a29bacSmrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
318511a29bacSmrg    $RM \"\$progdir/\$file\"
318611a29bacSmrg  fi"
318711a29bacSmrg	else
318811a29bacSmrg	  $ECHO "\
318911a29bacSmrg  program='$outputname'
319011a29bacSmrg  progdir=\"\$thisdir/$objdir\"
319111a29bacSmrg"
319211a29bacSmrg	fi
319341b2f0bdSmrg
319411a29bacSmrg	$ECHO "\
319541b2f0bdSmrg
319611a29bacSmrg  if test -f \"\$progdir/\$program\"; then"
319741b2f0bdSmrg
319811a29bacSmrg	# Export our shlibpath_var if we have one.
319911a29bacSmrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
320011a29bacSmrg	  $ECHO "\
320111a29bacSmrg    # Add our own library path to $shlibpath_var
320211a29bacSmrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
320341b2f0bdSmrg
320411a29bacSmrg    # Some systems cannot cope with colon-terminated $shlibpath_var
320511a29bacSmrg    # The second colon is a workaround for a bug in BeOS R4 sed
320611a29bacSmrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
320741b2f0bdSmrg
320811a29bacSmrg    export $shlibpath_var
320911a29bacSmrg"
321011a29bacSmrg	fi
321141b2f0bdSmrg
321211a29bacSmrg	# fixup the dll searchpath if we need to.
321311a29bacSmrg	if test -n "$dllsearchpath"; then
321411a29bacSmrg	  $ECHO "\
321511a29bacSmrg    # Add the dll search path components to the executable PATH
321611a29bacSmrg    PATH=$dllsearchpath:\$PATH
321711a29bacSmrg"
321811a29bacSmrg	fi
321941b2f0bdSmrg
322011a29bacSmrg	$ECHO "\
322111a29bacSmrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
322211a29bacSmrg      # Run the actual program with our arguments.
322311a29bacSmrg      func_exec_program \${1+\"\$@\"}
322411a29bacSmrg    fi
322511a29bacSmrg  else
322611a29bacSmrg    # The program doesn't exist.
322711a29bacSmrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
322811a29bacSmrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
322911a29bacSmrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
323011a29bacSmrg    exit 1
323111a29bacSmrg  fi
323211a29bacSmrgfi\
323311a29bacSmrg"
323411a29bacSmrg}
323541b2f0bdSmrg
323641b2f0bdSmrg
323711a29bacSmrg# func_to_host_path arg
323811a29bacSmrg#
323911a29bacSmrg# Convert paths to host format when used with build tools.
324011a29bacSmrg# Intended for use with "native" mingw (where libtool itself
324111a29bacSmrg# is running under the msys shell), or in the following cross-
324211a29bacSmrg# build environments:
324311a29bacSmrg#    $build          $host
324411a29bacSmrg#    mingw (msys)    mingw  [e.g. native]
324511a29bacSmrg#    cygwin          mingw
324611a29bacSmrg#    *nix + wine     mingw
324711a29bacSmrg# where wine is equipped with the `winepath' executable.
324811a29bacSmrg# In the native mingw case, the (msys) shell automatically
324911a29bacSmrg# converts paths for any non-msys applications it launches,
325011a29bacSmrg# but that facility isn't available from inside the cwrapper.
325111a29bacSmrg# Similar accommodations are necessary for $host mingw and
325211a29bacSmrg# $build cygwin.  Calling this function does no harm for other
325311a29bacSmrg# $host/$build combinations not listed above.
325411a29bacSmrg#
325511a29bacSmrg# ARG is the path (on $build) that should be converted to
325611a29bacSmrg# the proper representation for $host. The result is stored
325711a29bacSmrg# in $func_to_host_path_result.
325811a29bacSmrgfunc_to_host_path ()
325911a29bacSmrg{
326011a29bacSmrg  func_to_host_path_result="$1"
326111a29bacSmrg  if test -n "$1"; then
326211a29bacSmrg    case $host in
326311a29bacSmrg      *mingw* )
326411a29bacSmrg        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
326511a29bacSmrg        case $build in
326611a29bacSmrg          *mingw* ) # actually, msys
326711a29bacSmrg            # awkward: cmd appends spaces to result
326811a29bacSmrg            func_to_host_path_result=`( cmd //c echo "$1" ) 2>/dev/null |
326911a29bacSmrg              $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
327011a29bacSmrg            ;;
327111a29bacSmrg          *cygwin* )
327211a29bacSmrg            func_to_host_path_result=`cygpath -w "$1" |
327311a29bacSmrg	      $SED -e "$lt_sed_naive_backslashify"`
327411a29bacSmrg            ;;
327511a29bacSmrg          * )
327611a29bacSmrg            # Unfortunately, winepath does not exit with a non-zero
327711a29bacSmrg            # error code, so we are forced to check the contents of
327811a29bacSmrg            # stdout. On the other hand, if the command is not
327911a29bacSmrg            # found, the shell will set an exit code of 127 and print
328011a29bacSmrg            # *an error message* to stdout. So we must check for both
328111a29bacSmrg            # error code of zero AND non-empty stdout, which explains
328211a29bacSmrg            # the odd construction:
328311a29bacSmrg            func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
328411a29bacSmrg            if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then
328511a29bacSmrg              func_to_host_path_result=`$ECHO "$func_to_host_path_tmp1" |
328611a29bacSmrg                $SED -e "$lt_sed_naive_backslashify"`
328711a29bacSmrg            else
328811a29bacSmrg              # Allow warning below.
328911a29bacSmrg              func_to_host_path_result=
329011a29bacSmrg            fi
329111a29bacSmrg            ;;
329211a29bacSmrg        esac
329311a29bacSmrg        if test -z "$func_to_host_path_result" ; then
329411a29bacSmrg          func_error "Could not determine host path corresponding to"
329511a29bacSmrg          func_error "  \`$1'"
329611a29bacSmrg          func_error "Continuing, but uninstalled executables may not work."
329711a29bacSmrg          # Fallback:
329811a29bacSmrg          func_to_host_path_result="$1"
329911a29bacSmrg        fi
330011a29bacSmrg        ;;
330111a29bacSmrg    esac
330211a29bacSmrg  fi
330311a29bacSmrg}
330411a29bacSmrg# end: func_to_host_path
330541b2f0bdSmrg
330611a29bacSmrg# func_to_host_pathlist arg
330711a29bacSmrg#
330811a29bacSmrg# Convert pathlists to host format when used with build tools.
330911a29bacSmrg# See func_to_host_path(), above. This function supports the
331011a29bacSmrg# following $build/$host combinations (but does no harm for
331111a29bacSmrg# combinations not listed here):
331211a29bacSmrg#    $build          $host
331311a29bacSmrg#    mingw (msys)    mingw  [e.g. native]
331411a29bacSmrg#    cygwin          mingw
331511a29bacSmrg#    *nix + wine     mingw
331611a29bacSmrg#
331711a29bacSmrg# Path separators are also converted from $build format to
331811a29bacSmrg# $host format. If ARG begins or ends with a path separator
331911a29bacSmrg# character, it is preserved (but converted to $host format)
332011a29bacSmrg# on output.
332111a29bacSmrg#
332211a29bacSmrg# ARG is a pathlist (on $build) that should be converted to
332311a29bacSmrg# the proper representation on $host. The result is stored
332411a29bacSmrg# in $func_to_host_pathlist_result.
332511a29bacSmrgfunc_to_host_pathlist ()
332611a29bacSmrg{
332711a29bacSmrg  func_to_host_pathlist_result="$1"
332811a29bacSmrg  if test -n "$1"; then
332911a29bacSmrg    case $host in
333011a29bacSmrg      *mingw* )
333111a29bacSmrg        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
333211a29bacSmrg        # Remove leading and trailing path separator characters from
333311a29bacSmrg        # ARG. msys behavior is inconsistent here, cygpath turns them
333411a29bacSmrg        # into '.;' and ';.', and winepath ignores them completely.
333511a29bacSmrg	func_stripname : : "$1"
333611a29bacSmrg        func_to_host_pathlist_tmp1=$func_stripname_result
333711a29bacSmrg        case $build in
333811a29bacSmrg          *mingw* ) # Actually, msys.
333911a29bacSmrg            # Awkward: cmd appends spaces to result.
334011a29bacSmrg            func_to_host_pathlist_result=`
334111a29bacSmrg	      ( cmd //c echo "$func_to_host_pathlist_tmp1" ) 2>/dev/null |
334211a29bacSmrg	      $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
334311a29bacSmrg            ;;
334411a29bacSmrg          *cygwin* )
334511a29bacSmrg            func_to_host_pathlist_result=`cygpath -w -p "$func_to_host_pathlist_tmp1" |
334611a29bacSmrg              $SED -e "$lt_sed_naive_backslashify"`
334711a29bacSmrg            ;;
334811a29bacSmrg          * )
334911a29bacSmrg            # unfortunately, winepath doesn't convert pathlists
335011a29bacSmrg            func_to_host_pathlist_result=""
335111a29bacSmrg            func_to_host_pathlist_oldIFS=$IFS
335211a29bacSmrg            IFS=:
335311a29bacSmrg            for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do
335411a29bacSmrg              IFS=$func_to_host_pathlist_oldIFS
335511a29bacSmrg              if test -n "$func_to_host_pathlist_f" ; then
335611a29bacSmrg                func_to_host_path "$func_to_host_pathlist_f"
335711a29bacSmrg                if test -n "$func_to_host_path_result" ; then
335811a29bacSmrg                  if test -z "$func_to_host_pathlist_result" ; then
335911a29bacSmrg                    func_to_host_pathlist_result="$func_to_host_path_result"
336011a29bacSmrg                  else
336111a29bacSmrg                    func_append func_to_host_pathlist_result ";$func_to_host_path_result"
336211a29bacSmrg                  fi
336311a29bacSmrg                fi
336411a29bacSmrg              fi
336511a29bacSmrg            done
336611a29bacSmrg            IFS=$func_to_host_pathlist_oldIFS
336711a29bacSmrg            ;;
336811a29bacSmrg        esac
336911a29bacSmrg        if test -z "$func_to_host_pathlist_result"; then
337011a29bacSmrg          func_error "Could not determine the host path(s) corresponding to"
337111a29bacSmrg          func_error "  \`$1'"
337211a29bacSmrg          func_error "Continuing, but uninstalled executables may not work."
337311a29bacSmrg          # Fallback. This may break if $1 contains DOS-style drive
337411a29bacSmrg          # specifications. The fix is not to complicate the expression
337511a29bacSmrg          # below, but for the user to provide a working wine installation
337611a29bacSmrg          # with winepath so that path translation in the cross-to-mingw
337711a29bacSmrg          # case works properly.
337811a29bacSmrg          lt_replace_pathsep_nix_to_dos="s|:|;|g"
337911a29bacSmrg          func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\
338011a29bacSmrg            $SED -e "$lt_replace_pathsep_nix_to_dos"`
338111a29bacSmrg        fi
338211a29bacSmrg        # Now, add the leading and trailing path separators back
338311a29bacSmrg        case "$1" in
338411a29bacSmrg          :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result"
338511a29bacSmrg            ;;
338611a29bacSmrg        esac
338711a29bacSmrg        case "$1" in
338811a29bacSmrg          *: ) func_append func_to_host_pathlist_result ";"
338911a29bacSmrg            ;;
339011a29bacSmrg        esac
339111a29bacSmrg        ;;
339211a29bacSmrg    esac
339311a29bacSmrg  fi
339411a29bacSmrg}
339511a29bacSmrg# end: func_to_host_pathlist
339641b2f0bdSmrg
339711a29bacSmrg# func_emit_cwrapperexe_src
339811a29bacSmrg# emit the source code for a wrapper executable on stdout
339911a29bacSmrg# Must ONLY be called from within func_mode_link because
340011a29bacSmrg# it depends on a number of variable set therein.
340111a29bacSmrgfunc_emit_cwrapperexe_src ()
340211a29bacSmrg{
340311a29bacSmrg	cat <<EOF
340441b2f0bdSmrg
340511a29bacSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
340611a29bacSmrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
340741b2f0bdSmrg
340811a29bacSmrg   The $output program cannot be directly executed until all the libtool
340911a29bacSmrg   libraries that it depends on are installed.
341041b2f0bdSmrg
341111a29bacSmrg   This wrapper executable should never be moved out of the build directory.
341211a29bacSmrg   If it is, it will not operate correctly.
341311a29bacSmrg*/
341411a29bacSmrgEOF
341511a29bacSmrg	    cat <<"EOF"
341611a29bacSmrg#ifdef _MSC_VER
341711a29bacSmrg# define _CRT_SECURE_NO_DEPRECATE 1
341811a29bacSmrg#endif
341911a29bacSmrg#include <stdio.h>
342011a29bacSmrg#include <stdlib.h>
342111a29bacSmrg#ifdef _MSC_VER
342211a29bacSmrg# include <direct.h>
342311a29bacSmrg# include <process.h>
342411a29bacSmrg# include <io.h>
342511a29bacSmrg#else
342611a29bacSmrg# include <unistd.h>
342711a29bacSmrg# include <stdint.h>
342811a29bacSmrg# ifdef __CYGWIN__
342911a29bacSmrg#  include <io.h>
343011a29bacSmrg# endif
343111a29bacSmrg#endif
343211a29bacSmrg#include <malloc.h>
343311a29bacSmrg#include <stdarg.h>
343411a29bacSmrg#include <assert.h>
343511a29bacSmrg#include <string.h>
343611a29bacSmrg#include <ctype.h>
343711a29bacSmrg#include <errno.h>
343811a29bacSmrg#include <fcntl.h>
343911a29bacSmrg#include <sys/stat.h>
344041b2f0bdSmrg
344111a29bacSmrg/* declarations of non-ANSI functions */
344211a29bacSmrg#if defined(__MINGW32__)
344311a29bacSmrg# ifdef __STRICT_ANSI__
344411a29bacSmrgint _putenv (const char *);
344511a29bacSmrg# endif
344611a29bacSmrg#elif defined(__CYGWIN__)
344711a29bacSmrg# ifdef __STRICT_ANSI__
344811a29bacSmrgchar *realpath (const char *, char *);
344911a29bacSmrgint putenv (char *);
345011a29bacSmrgint setenv (const char *, const char *, int);
345111a29bacSmrg# endif
345211a29bacSmrg/* #elif defined (other platforms) ... */
345311a29bacSmrg#endif
345441b2f0bdSmrg
345511a29bacSmrg/* portability defines, excluding path handling macros */
345611a29bacSmrg#if defined(_MSC_VER)
345711a29bacSmrg# define setmode _setmode
345811a29bacSmrg# define stat    _stat
345911a29bacSmrg# define chmod   _chmod
346011a29bacSmrg# define getcwd  _getcwd
346111a29bacSmrg# define putenv  _putenv
346211a29bacSmrg# define S_IXUSR _S_IEXEC
346311a29bacSmrg# ifndef _INTPTR_T_DEFINED
346411a29bacSmrg#  define _INTPTR_T_DEFINED
346511a29bacSmrg#  define intptr_t int
346611a29bacSmrg# endif
346711a29bacSmrg#elif defined(__MINGW32__)
346811a29bacSmrg# define setmode _setmode
346911a29bacSmrg# define stat    _stat
347011a29bacSmrg# define chmod   _chmod
347111a29bacSmrg# define getcwd  _getcwd
347211a29bacSmrg# define putenv  _putenv
347311a29bacSmrg#elif defined(__CYGWIN__)
347411a29bacSmrg# define HAVE_SETENV
347511a29bacSmrg# define FOPEN_WB "wb"
347611a29bacSmrg/* #elif defined (other platforms) ... */
347711a29bacSmrg#endif
347841b2f0bdSmrg
347911a29bacSmrg#if defined(PATH_MAX)
348011a29bacSmrg# define LT_PATHMAX PATH_MAX
348111a29bacSmrg#elif defined(MAXPATHLEN)
348211a29bacSmrg# define LT_PATHMAX MAXPATHLEN
348311a29bacSmrg#else
348411a29bacSmrg# define LT_PATHMAX 1024
348511a29bacSmrg#endif
348641b2f0bdSmrg
348711a29bacSmrg#ifndef S_IXOTH
348811a29bacSmrg# define S_IXOTH 0
348911a29bacSmrg#endif
349011a29bacSmrg#ifndef S_IXGRP
349111a29bacSmrg# define S_IXGRP 0
349211a29bacSmrg#endif
349341b2f0bdSmrg
349411a29bacSmrg/* path handling portability macros */
349511a29bacSmrg#ifndef DIR_SEPARATOR
349611a29bacSmrg# define DIR_SEPARATOR '/'
349711a29bacSmrg# define PATH_SEPARATOR ':'
349811a29bacSmrg#endif
349941b2f0bdSmrg
350011a29bacSmrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
350111a29bacSmrg  defined (__OS2__)
350211a29bacSmrg# define HAVE_DOS_BASED_FILE_SYSTEM
350311a29bacSmrg# define FOPEN_WB "wb"
350411a29bacSmrg# ifndef DIR_SEPARATOR_2
350511a29bacSmrg#  define DIR_SEPARATOR_2 '\\'
350611a29bacSmrg# endif
350711a29bacSmrg# ifndef PATH_SEPARATOR_2
350811a29bacSmrg#  define PATH_SEPARATOR_2 ';'
350911a29bacSmrg# endif
351011a29bacSmrg#endif
351141b2f0bdSmrg
351211a29bacSmrg#ifndef DIR_SEPARATOR_2
351311a29bacSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
351411a29bacSmrg#else /* DIR_SEPARATOR_2 */
351511a29bacSmrg# define IS_DIR_SEPARATOR(ch) \
351611a29bacSmrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
351711a29bacSmrg#endif /* DIR_SEPARATOR_2 */
351841b2f0bdSmrg
351911a29bacSmrg#ifndef PATH_SEPARATOR_2
352011a29bacSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
352111a29bacSmrg#else /* PATH_SEPARATOR_2 */
352211a29bacSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
352311a29bacSmrg#endif /* PATH_SEPARATOR_2 */
352411a29bacSmrg
352511a29bacSmrg#ifndef FOPEN_WB
352611a29bacSmrg# define FOPEN_WB "w"
352711a29bacSmrg#endif
352811a29bacSmrg#ifndef _O_BINARY
352911a29bacSmrg# define _O_BINARY 0
353011a29bacSmrg#endif
353111a29bacSmrg
353211a29bacSmrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
353311a29bacSmrg#define XFREE(stale) do { \
353411a29bacSmrg  if (stale) { free ((void *) stale); stale = 0; } \
353511a29bacSmrg} while (0)
353611a29bacSmrg
353711a29bacSmrg#if defined(LT_DEBUGWRAPPER)
353811a29bacSmrgstatic int lt_debug = 1;
353911a29bacSmrg#else
354011a29bacSmrgstatic int lt_debug = 0;
354111a29bacSmrg#endif
354211a29bacSmrg
354311a29bacSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
354411a29bacSmrg
354511a29bacSmrgvoid *xmalloc (size_t num);
354611a29bacSmrgchar *xstrdup (const char *string);
354711a29bacSmrgconst char *base_name (const char *name);
354811a29bacSmrgchar *find_executable (const char *wrapper);
354911a29bacSmrgchar *chase_symlinks (const char *pathspec);
355011a29bacSmrgint make_executable (const char *path);
355111a29bacSmrgint check_executable (const char *path);
355211a29bacSmrgchar *strendzap (char *str, const char *pat);
355311a29bacSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
355411a29bacSmrgvoid lt_fatal (const char *file, int line, const char *message, ...);
355511a29bacSmrgstatic const char *nonnull (const char *s);
355611a29bacSmrgstatic const char *nonempty (const char *s);
355711a29bacSmrgvoid lt_setenv (const char *name, const char *value);
355811a29bacSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
355911a29bacSmrgvoid lt_update_exe_path (const char *name, const char *value);
356011a29bacSmrgvoid lt_update_lib_path (const char *name, const char *value);
356111a29bacSmrgchar **prepare_spawn (char **argv);
356211a29bacSmrgvoid lt_dump_script (FILE *f);
356311a29bacSmrgEOF
356411a29bacSmrg
356511a29bacSmrg	    cat <<EOF
356611a29bacSmrgconst char * MAGIC_EXE = "$magic_exe";
356711a29bacSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
356811a29bacSmrgEOF
356911a29bacSmrg
357011a29bacSmrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
357111a29bacSmrg              func_to_host_pathlist "$temp_rpath"
357211a29bacSmrg	      cat <<EOF
357311a29bacSmrgconst char * LIB_PATH_VALUE   = "$func_to_host_pathlist_result";
357441b2f0bdSmrgEOF
357541b2f0bdSmrg	    else
357611a29bacSmrg	      cat <<"EOF"
357711a29bacSmrgconst char * LIB_PATH_VALUE   = "";
357811a29bacSmrgEOF
357941b2f0bdSmrg	    fi
358011a29bacSmrg
358111a29bacSmrg	    if test -n "$dllsearchpath"; then
358211a29bacSmrg              func_to_host_pathlist "$dllsearchpath:"
358311a29bacSmrg	      cat <<EOF
358411a29bacSmrgconst char * EXE_PATH_VARNAME = "PATH";
358511a29bacSmrgconst char * EXE_PATH_VALUE   = "$func_to_host_pathlist_result";
358611a29bacSmrgEOF
358741b2f0bdSmrg	    else
358811a29bacSmrg	      cat <<"EOF"
358911a29bacSmrgconst char * EXE_PATH_VARNAME = "";
359011a29bacSmrgconst char * EXE_PATH_VALUE   = "";
359111a29bacSmrgEOF
359241b2f0bdSmrg	    fi
359311a29bacSmrg
359411a29bacSmrg	    if test "$fast_install" = yes; then
359511a29bacSmrg	      cat <<EOF
359611a29bacSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
359711a29bacSmrgEOF
359841b2f0bdSmrg	    else
359911a29bacSmrg	      cat <<EOF
360011a29bacSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
360111a29bacSmrgEOF
360241b2f0bdSmrg	    fi
360341b2f0bdSmrg
360441b2f0bdSmrg
360511a29bacSmrg	    cat <<"EOF"
360641b2f0bdSmrg
360711a29bacSmrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
360841b2f0bdSmrg
360911a29bacSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
361011a29bacSmrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
361111a29bacSmrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
361241b2f0bdSmrg
361311a29bacSmrgint
361411a29bacSmrgmain (int argc, char *argv[])
361511a29bacSmrg{
361611a29bacSmrg  char **newargz;
361711a29bacSmrg  int  newargc;
361811a29bacSmrg  char *tmp_pathspec;
361911a29bacSmrg  char *actual_cwrapper_path;
362011a29bacSmrg  char *actual_cwrapper_name;
362111a29bacSmrg  char *target_name;
362211a29bacSmrg  char *lt_argv_zero;
362311a29bacSmrg  intptr_t rval = 127;
362441b2f0bdSmrg
362511a29bacSmrg  int i;
362641b2f0bdSmrg
362711a29bacSmrg  program_name = (char *) xstrdup (base_name (argv[0]));
362811a29bacSmrg  newargz = XMALLOC (char *, argc + 1);
362941b2f0bdSmrg
363011a29bacSmrg  /* very simple arg parsing; don't want to rely on getopt
363111a29bacSmrg   * also, copy all non cwrapper options to newargz, except
363211a29bacSmrg   * argz[0], which is handled differently
363311a29bacSmrg   */
363411a29bacSmrg  newargc=0;
363511a29bacSmrg  for (i = 1; i < argc; i++)
363611a29bacSmrg    {
363711a29bacSmrg      if (strcmp (argv[i], dumpscript_opt) == 0)
363811a29bacSmrg	{
363911a29bacSmrgEOF
364011a29bacSmrg	    case "$host" in
364111a29bacSmrg	      *mingw* | *cygwin* )
364211a29bacSmrg		# make stdout use "unix" line endings
364311a29bacSmrg		echo "          setmode(1,_O_BINARY);"
364411a29bacSmrg		;;
364511245024Smrg	      esac
364641b2f0bdSmrg
364711a29bacSmrg	    cat <<"EOF"
364811a29bacSmrg	  lt_dump_script (stdout);
364911a29bacSmrg	  return 0;
365011a29bacSmrg	}
365111a29bacSmrg      if (strcmp (argv[i], debug_opt) == 0)
365211a29bacSmrg	{
365311a29bacSmrg          lt_debug = 1;
365411a29bacSmrg          continue;
365511a29bacSmrg	}
365611a29bacSmrg      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
365711a29bacSmrg        {
365811a29bacSmrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
365911a29bacSmrg             namespace, but it is not one of the ones we know about and
366011a29bacSmrg             have already dealt with, above (inluding dump-script), then
366111a29bacSmrg             report an error. Otherwise, targets might begin to believe
366211a29bacSmrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
366311a29bacSmrg             namespace. The first time any user complains about this, we'll
366411a29bacSmrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
366511a29bacSmrg             or a configure.ac-settable value.
366611a29bacSmrg           */
366711a29bacSmrg          lt_fatal (__FILE__, __LINE__,
366811a29bacSmrg		    "unrecognized %s option: '%s'",
366911a29bacSmrg                    ltwrapper_option_prefix, argv[i]);
367011a29bacSmrg        }
367111a29bacSmrg      /* otherwise ... */
367211a29bacSmrg      newargz[++newargc] = xstrdup (argv[i]);
367311a29bacSmrg    }
367411a29bacSmrg  newargz[++newargc] = NULL;
367541b2f0bdSmrg
367611a29bacSmrgEOF
367711a29bacSmrg	    cat <<EOF
367811a29bacSmrg  /* The GNU banner must be the first non-error debug message */
367911a29bacSmrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
368011a29bacSmrgEOF
368111a29bacSmrg	    cat <<"EOF"
368211a29bacSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
368311a29bacSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
368411a29bacSmrg
368511a29bacSmrg  tmp_pathspec = find_executable (argv[0]);
368611a29bacSmrg  if (tmp_pathspec == NULL)
368711a29bacSmrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
368811a29bacSmrg  lt_debugprintf (__FILE__, __LINE__,
368911a29bacSmrg                  "(main) found exe (before symlink chase) at: %s\n",
369011a29bacSmrg		  tmp_pathspec);
369111a29bacSmrg
369211a29bacSmrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
369311a29bacSmrg  lt_debugprintf (__FILE__, __LINE__,
369411a29bacSmrg                  "(main) found exe (after symlink chase) at: %s\n",
369511a29bacSmrg		  actual_cwrapper_path);
369611a29bacSmrg  XFREE (tmp_pathspec);
369711a29bacSmrg
369811a29bacSmrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
369911a29bacSmrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
370011a29bacSmrg
370111a29bacSmrg  /* wrapper name transforms */
370211a29bacSmrg  strendzap (actual_cwrapper_name, ".exe");
370311a29bacSmrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
370411a29bacSmrg  XFREE (actual_cwrapper_name);
370511a29bacSmrg  actual_cwrapper_name = tmp_pathspec;
370611a29bacSmrg  tmp_pathspec = 0;
370711a29bacSmrg
370811a29bacSmrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
370911a29bacSmrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
371011a29bacSmrg  strendzap (target_name, ".exe");
371111a29bacSmrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
371211a29bacSmrg  XFREE (target_name);
371311a29bacSmrg  target_name = tmp_pathspec;
371411a29bacSmrg  tmp_pathspec = 0;
371511a29bacSmrg
371611a29bacSmrg  lt_debugprintf (__FILE__, __LINE__,
371711a29bacSmrg		  "(main) libtool target name: %s\n",
371811a29bacSmrg		  target_name);
371911a29bacSmrgEOF
372041b2f0bdSmrg
372111a29bacSmrg	    cat <<EOF
372211a29bacSmrg  newargz[0] =
372311a29bacSmrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
372411a29bacSmrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
372511a29bacSmrg  strcpy (newargz[0], actual_cwrapper_path);
372611a29bacSmrg  strcat (newargz[0], "$objdir");
372711a29bacSmrg  strcat (newargz[0], "/");
372811a29bacSmrgEOF
372941b2f0bdSmrg
373011a29bacSmrg	    cat <<"EOF"
373111a29bacSmrg  /* stop here, and copy so we don't have to do this twice */
373211a29bacSmrg  tmp_pathspec = xstrdup (newargz[0]);
373341b2f0bdSmrg
373411a29bacSmrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
373511a29bacSmrg  strcat (newargz[0], actual_cwrapper_name);
373641b2f0bdSmrg
373711a29bacSmrg  /* DO want the lt- prefix here if it exists, so use target_name */
373811a29bacSmrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
373911a29bacSmrg  XFREE (tmp_pathspec);
374011a29bacSmrg  tmp_pathspec = NULL;
374111a29bacSmrgEOF
374241b2f0bdSmrg
374311a29bacSmrg	    case $host_os in
374411a29bacSmrg	      mingw*)
374511a29bacSmrg	    cat <<"EOF"
374611a29bacSmrg  {
374711a29bacSmrg    char* p;
374811a29bacSmrg    while ((p = strchr (newargz[0], '\\')) != NULL)
374911a29bacSmrg      {
375011a29bacSmrg	*p = '/';
375111a29bacSmrg      }
375211a29bacSmrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
375311a29bacSmrg      {
375411a29bacSmrg	*p = '/';
375511a29bacSmrg      }
375611a29bacSmrg  }
375711a29bacSmrgEOF
375811a29bacSmrg	    ;;
375911a29bacSmrg	    esac
376041b2f0bdSmrg
376111a29bacSmrg	    cat <<"EOF"
376211a29bacSmrg  XFREE (target_name);
376311a29bacSmrg  XFREE (actual_cwrapper_path);
376411a29bacSmrg  XFREE (actual_cwrapper_name);
376541b2f0bdSmrg
376611a29bacSmrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
376711a29bacSmrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
376811a29bacSmrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
376911a29bacSmrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
377041b2f0bdSmrg
377111a29bacSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
377211a29bacSmrg		  nonnull (lt_argv_zero));
377311a29bacSmrg  for (i = 0; i < newargc; i++)
377411a29bacSmrg    {
377511a29bacSmrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
377611a29bacSmrg		      i, nonnull (newargz[i]));
377711a29bacSmrg    }
377841b2f0bdSmrg
377911a29bacSmrgEOF
378041b2f0bdSmrg
378111a29bacSmrg	    case $host_os in
378211a29bacSmrg	      mingw*)
378311a29bacSmrg		cat <<"EOF"
378411a29bacSmrg  /* execv doesn't actually work on mingw as expected on unix */
378511a29bacSmrg  newargz = prepare_spawn (newargz);
378611a29bacSmrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
378711a29bacSmrg  if (rval == -1)
378811a29bacSmrg    {
378911a29bacSmrg      /* failed to start process */
379011a29bacSmrg      lt_debugprintf (__FILE__, __LINE__,
379111a29bacSmrg		      "(main) failed to launch target \"%s\": %s\n",
379211a29bacSmrg		      lt_argv_zero, nonnull (strerror (errno)));
379311a29bacSmrg      return 127;
379411a29bacSmrg    }
379511a29bacSmrg  return rval;
379611a29bacSmrgEOF
379711a29bacSmrg		;;
379811a29bacSmrg	      *)
379911a29bacSmrg		cat <<"EOF"
380011a29bacSmrg  execv (lt_argv_zero, newargz);
380111a29bacSmrg  return rval; /* =127, but avoids unused variable warning */
380211a29bacSmrgEOF
380311a29bacSmrg		;;
380411a29bacSmrg	    esac
380541b2f0bdSmrg
380611a29bacSmrg	    cat <<"EOF"
380711a29bacSmrg}
380841b2f0bdSmrg
380911a29bacSmrgvoid *
381011a29bacSmrgxmalloc (size_t num)
381111a29bacSmrg{
381211a29bacSmrg  void *p = (void *) malloc (num);
381311a29bacSmrg  if (!p)
381411a29bacSmrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
381541b2f0bdSmrg
381611a29bacSmrg  return p;
381711a29bacSmrg}
381841b2f0bdSmrg
381911a29bacSmrgchar *
382011a29bacSmrgxstrdup (const char *string)
382111a29bacSmrg{
382211a29bacSmrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
382311a29bacSmrg			  string) : NULL;
382411a29bacSmrg}
382541b2f0bdSmrg
382611a29bacSmrgconst char *
382711a29bacSmrgbase_name (const char *name)
382811a29bacSmrg{
382911a29bacSmrg  const char *base;
383041b2f0bdSmrg
383111a29bacSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
383211a29bacSmrg  /* Skip over the disk name in MSDOS pathnames. */
383311a29bacSmrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
383411a29bacSmrg    name += 2;
383511a29bacSmrg#endif
383641b2f0bdSmrg
383711a29bacSmrg  for (base = name; *name; name++)
383811a29bacSmrg    if (IS_DIR_SEPARATOR (*name))
383911a29bacSmrg      base = name + 1;
384011a29bacSmrg  return base;
384111a29bacSmrg}
384241b2f0bdSmrg
384311a29bacSmrgint
384411a29bacSmrgcheck_executable (const char *path)
384511a29bacSmrg{
384611a29bacSmrg  struct stat st;
384741b2f0bdSmrg
384811a29bacSmrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
384911a29bacSmrg                  nonempty (path));
385011a29bacSmrg  if ((!path) || (!*path))
385111a29bacSmrg    return 0;
385241b2f0bdSmrg
385311a29bacSmrg  if ((stat (path, &st) >= 0)
385411a29bacSmrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
385511a29bacSmrg    return 1;
385611a29bacSmrg  else
385711a29bacSmrg    return 0;
385811a29bacSmrg}
385941b2f0bdSmrg
386011a29bacSmrgint
386111a29bacSmrgmake_executable (const char *path)
386211a29bacSmrg{
386311a29bacSmrg  int rval = 0;
386411a29bacSmrg  struct stat st;
386541b2f0bdSmrg
386611a29bacSmrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
386711a29bacSmrg                  nonempty (path));
386811a29bacSmrg  if ((!path) || (!*path))
386911a29bacSmrg    return 0;
387041b2f0bdSmrg
387111a29bacSmrg  if (stat (path, &st) >= 0)
387211a29bacSmrg    {
387311a29bacSmrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
387411a29bacSmrg    }
387511a29bacSmrg  return rval;
387611a29bacSmrg}
387741b2f0bdSmrg
387811a29bacSmrg/* Searches for the full path of the wrapper.  Returns
387911a29bacSmrg   newly allocated full path name if found, NULL otherwise
388011a29bacSmrg   Does not chase symlinks, even on platforms that support them.
388111a29bacSmrg*/
388211a29bacSmrgchar *
388311a29bacSmrgfind_executable (const char *wrapper)
388411a29bacSmrg{
388511a29bacSmrg  int has_slash = 0;
388611a29bacSmrg  const char *p;
388711a29bacSmrg  const char *p_next;
388811a29bacSmrg  /* static buffer for getcwd */
388911a29bacSmrg  char tmp[LT_PATHMAX + 1];
389011a29bacSmrg  int tmp_len;
389111a29bacSmrg  char *concat_name;
389241b2f0bdSmrg
389311a29bacSmrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
389411a29bacSmrg                  nonempty (wrapper));
389541b2f0bdSmrg
389611a29bacSmrg  if ((wrapper == NULL) || (*wrapper == '\0'))
389711a29bacSmrg    return NULL;
389841b2f0bdSmrg
389911a29bacSmrg  /* Absolute path? */
390011a29bacSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
390111a29bacSmrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
390211a29bacSmrg    {
390311a29bacSmrg      concat_name = xstrdup (wrapper);
390411a29bacSmrg      if (check_executable (concat_name))
390511a29bacSmrg	return concat_name;
390611a29bacSmrg      XFREE (concat_name);
390711a29bacSmrg    }
390811a29bacSmrg  else
390911a29bacSmrg    {
391011a29bacSmrg#endif
391111a29bacSmrg      if (IS_DIR_SEPARATOR (wrapper[0]))
391211a29bacSmrg	{
391311a29bacSmrg	  concat_name = xstrdup (wrapper);
391411a29bacSmrg	  if (check_executable (concat_name))
391511a29bacSmrg	    return concat_name;
391611a29bacSmrg	  XFREE (concat_name);
391711a29bacSmrg	}
391811a29bacSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
391911a29bacSmrg    }
392011a29bacSmrg#endif
392141b2f0bdSmrg
392211a29bacSmrg  for (p = wrapper; *p; p++)
392311a29bacSmrg    if (*p == '/')
392411a29bacSmrg      {
392511a29bacSmrg	has_slash = 1;
392611a29bacSmrg	break;
392711a29bacSmrg      }
392811a29bacSmrg  if (!has_slash)
392911a29bacSmrg    {
393011a29bacSmrg      /* no slashes; search PATH */
393111a29bacSmrg      const char *path = getenv ("PATH");
393211a29bacSmrg      if (path != NULL)
393311a29bacSmrg	{
393411a29bacSmrg	  for (p = path; *p; p = p_next)
393511a29bacSmrg	    {
393611a29bacSmrg	      const char *q;
393711a29bacSmrg	      size_t p_len;
393811a29bacSmrg	      for (q = p; *q; q++)
393911a29bacSmrg		if (IS_PATH_SEPARATOR (*q))
394011a29bacSmrg		  break;
394111a29bacSmrg	      p_len = q - p;
394211a29bacSmrg	      p_next = (*q == '\0' ? q : q + 1);
394311a29bacSmrg	      if (p_len == 0)
394411a29bacSmrg		{
394511a29bacSmrg		  /* empty path: current directory */
394611a29bacSmrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
394711a29bacSmrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
394811a29bacSmrg                              nonnull (strerror (errno)));
394911a29bacSmrg		  tmp_len = strlen (tmp);
395011a29bacSmrg		  concat_name =
395111a29bacSmrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
395211a29bacSmrg		  memcpy (concat_name, tmp, tmp_len);
395311a29bacSmrg		  concat_name[tmp_len] = '/';
395411a29bacSmrg		  strcpy (concat_name + tmp_len + 1, wrapper);
395511a29bacSmrg		}
395611a29bacSmrg	      else
395711a29bacSmrg		{
395811a29bacSmrg		  concat_name =
395911a29bacSmrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
396011a29bacSmrg		  memcpy (concat_name, p, p_len);
396111a29bacSmrg		  concat_name[p_len] = '/';
396211a29bacSmrg		  strcpy (concat_name + p_len + 1, wrapper);
396311a29bacSmrg		}
396411a29bacSmrg	      if (check_executable (concat_name))
396511a29bacSmrg		return concat_name;
396611a29bacSmrg	      XFREE (concat_name);
396711a29bacSmrg	    }
396811a29bacSmrg	}
396911a29bacSmrg      /* not found in PATH; assume curdir */
397011a29bacSmrg    }
397111a29bacSmrg  /* Relative path | not found in path: prepend cwd */
397211a29bacSmrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
397311a29bacSmrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
397411a29bacSmrg              nonnull (strerror (errno)));
397511a29bacSmrg  tmp_len = strlen (tmp);
397611a29bacSmrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
397711a29bacSmrg  memcpy (concat_name, tmp, tmp_len);
397811a29bacSmrg  concat_name[tmp_len] = '/';
397911a29bacSmrg  strcpy (concat_name + tmp_len + 1, wrapper);
398041b2f0bdSmrg
398111a29bacSmrg  if (check_executable (concat_name))
398211a29bacSmrg    return concat_name;
398311a29bacSmrg  XFREE (concat_name);
398411a29bacSmrg  return NULL;
398511a29bacSmrg}
398641b2f0bdSmrg
398711a29bacSmrgchar *
398811a29bacSmrgchase_symlinks (const char *pathspec)
398911a29bacSmrg{
399011a29bacSmrg#ifndef S_ISLNK
399111a29bacSmrg  return xstrdup (pathspec);
399211a29bacSmrg#else
399311a29bacSmrg  char buf[LT_PATHMAX];
399411a29bacSmrg  struct stat s;
399511a29bacSmrg  char *tmp_pathspec = xstrdup (pathspec);
399611a29bacSmrg  char *p;
399711a29bacSmrg  int has_symlinks = 0;
399811a29bacSmrg  while (strlen (tmp_pathspec) && !has_symlinks)
399911a29bacSmrg    {
400011a29bacSmrg      lt_debugprintf (__FILE__, __LINE__,
400111a29bacSmrg		      "checking path component for symlinks: %s\n",
400211a29bacSmrg		      tmp_pathspec);
400311a29bacSmrg      if (lstat (tmp_pathspec, &s) == 0)
400411a29bacSmrg	{
400511a29bacSmrg	  if (S_ISLNK (s.st_mode) != 0)
400611a29bacSmrg	    {
400711a29bacSmrg	      has_symlinks = 1;
400811a29bacSmrg	      break;
400911a29bacSmrg	    }
401041b2f0bdSmrg
401111a29bacSmrg	  /* search backwards for last DIR_SEPARATOR */
401211a29bacSmrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
401311a29bacSmrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
401411a29bacSmrg	    p--;
401511a29bacSmrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
401611a29bacSmrg	    {
401711a29bacSmrg	      /* no more DIR_SEPARATORS left */
401811a29bacSmrg	      break;
401911a29bacSmrg	    }
402011a29bacSmrg	  *p = '\0';
402111a29bacSmrg	}
402211a29bacSmrg      else
402311a29bacSmrg	{
402411a29bacSmrg	  lt_fatal (__FILE__, __LINE__,
402511a29bacSmrg		    "error accessing file \"%s\": %s",
402611a29bacSmrg		    tmp_pathspec, nonnull (strerror (errno)));
402711a29bacSmrg	}
402811a29bacSmrg    }
402911a29bacSmrg  XFREE (tmp_pathspec);
403041b2f0bdSmrg
403111a29bacSmrg  if (!has_symlinks)
403211a29bacSmrg    {
403311a29bacSmrg      return xstrdup (pathspec);
403411a29bacSmrg    }
403541b2f0bdSmrg
403611a29bacSmrg  tmp_pathspec = realpath (pathspec, buf);
403711a29bacSmrg  if (tmp_pathspec == 0)
403811a29bacSmrg    {
403911a29bacSmrg      lt_fatal (__FILE__, __LINE__,
404011a29bacSmrg		"could not follow symlinks for %s", pathspec);
404111a29bacSmrg    }
404211a29bacSmrg  return xstrdup (tmp_pathspec);
404311a29bacSmrg#endif
404411a29bacSmrg}
404541b2f0bdSmrg
404611a29bacSmrgchar *
404711a29bacSmrgstrendzap (char *str, const char *pat)
404811a29bacSmrg{
404911a29bacSmrg  size_t len, patlen;
405041b2f0bdSmrg
405111a29bacSmrg  assert (str != NULL);
405211a29bacSmrg  assert (pat != NULL);
405341b2f0bdSmrg
405411a29bacSmrg  len = strlen (str);
405511a29bacSmrg  patlen = strlen (pat);
405641b2f0bdSmrg
405711a29bacSmrg  if (patlen <= len)
405811a29bacSmrg    {
405911a29bacSmrg      str += len - patlen;
406011a29bacSmrg      if (strcmp (str, pat) == 0)
406111a29bacSmrg	*str = '\0';
406211a29bacSmrg    }
406311a29bacSmrg  return str;
406411a29bacSmrg}
406541b2f0bdSmrg
406611a29bacSmrgvoid
406711a29bacSmrglt_debugprintf (const char *file, int line, const char *fmt, ...)
406811a29bacSmrg{
406911a29bacSmrg  va_list args;
407011a29bacSmrg  if (lt_debug)
407111a29bacSmrg    {
407211a29bacSmrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
407311a29bacSmrg      va_start (args, fmt);
407411a29bacSmrg      (void) vfprintf (stderr, fmt, args);
407511a29bacSmrg      va_end (args);
407611a29bacSmrg    }
407711a29bacSmrg}
407841b2f0bdSmrg
407911a29bacSmrgstatic void
408011a29bacSmrglt_error_core (int exit_status, const char *file,
408111a29bacSmrg	       int line, const char *mode,
408211a29bacSmrg	       const char *message, va_list ap)
408311a29bacSmrg{
408411a29bacSmrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
408511a29bacSmrg  vfprintf (stderr, message, ap);
408611a29bacSmrg  fprintf (stderr, ".\n");
408741b2f0bdSmrg
408811a29bacSmrg  if (exit_status >= 0)
408911a29bacSmrg    exit (exit_status);
409011a29bacSmrg}
409141b2f0bdSmrg
409211a29bacSmrgvoid
409311a29bacSmrglt_fatal (const char *file, int line, const char *message, ...)
409411a29bacSmrg{
409511a29bacSmrg  va_list ap;
409611a29bacSmrg  va_start (ap, message);
409711a29bacSmrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
409811a29bacSmrg  va_end (ap);
409911a29bacSmrg}
410041b2f0bdSmrg
410111a29bacSmrgstatic const char *
410211a29bacSmrgnonnull (const char *s)
410311a29bacSmrg{
410411a29bacSmrg  return s ? s : "(null)";
410511a29bacSmrg}
410641b2f0bdSmrg
410711a29bacSmrgstatic const char *
410811a29bacSmrgnonempty (const char *s)
410911a29bacSmrg{
411011a29bacSmrg  return (s && !*s) ? "(empty)" : nonnull (s);
411111a29bacSmrg}
411241b2f0bdSmrg
411311a29bacSmrgvoid
411411a29bacSmrglt_setenv (const char *name, const char *value)
411511a29bacSmrg{
411611a29bacSmrg  lt_debugprintf (__FILE__, __LINE__,
411711a29bacSmrg		  "(lt_setenv) setting '%s' to '%s'\n",
411811a29bacSmrg                  nonnull (name), nonnull (value));
411911a29bacSmrg  {
412011a29bacSmrg#ifdef HAVE_SETENV
412111a29bacSmrg    /* always make a copy, for consistency with !HAVE_SETENV */
412211a29bacSmrg    char *str = xstrdup (value);
412311a29bacSmrg    setenv (name, str, 1);
412411a29bacSmrg#else
412511a29bacSmrg    int len = strlen (name) + 1 + strlen (value) + 1;
412611a29bacSmrg    char *str = XMALLOC (char, len);
412711a29bacSmrg    sprintf (str, "%s=%s", name, value);
412811a29bacSmrg    if (putenv (str) != EXIT_SUCCESS)
412911a29bacSmrg      {
413011a29bacSmrg        XFREE (str);
413111a29bacSmrg      }
413211a29bacSmrg#endif
413311a29bacSmrg  }
413411a29bacSmrg}
413541b2f0bdSmrg
413611a29bacSmrgchar *
413711a29bacSmrglt_extend_str (const char *orig_value, const char *add, int to_end)
413811a29bacSmrg{
413911a29bacSmrg  char *new_value;
414011a29bacSmrg  if (orig_value && *orig_value)
414111a29bacSmrg    {
414211a29bacSmrg      int orig_value_len = strlen (orig_value);
414311a29bacSmrg      int add_len = strlen (add);
414411a29bacSmrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
414511a29bacSmrg      if (to_end)
414611a29bacSmrg        {
414711a29bacSmrg          strcpy (new_value, orig_value);
414811a29bacSmrg          strcpy (new_value + orig_value_len, add);
414911a29bacSmrg        }
415011a29bacSmrg      else
415111a29bacSmrg        {
415211a29bacSmrg          strcpy (new_value, add);
415311a29bacSmrg          strcpy (new_value + add_len, orig_value);
415411a29bacSmrg        }
415511a29bacSmrg    }
415611a29bacSmrg  else
415711a29bacSmrg    {
415811a29bacSmrg      new_value = xstrdup (add);
415911a29bacSmrg    }
416011a29bacSmrg  return new_value;
416111a29bacSmrg}
416241b2f0bdSmrg
416311a29bacSmrgvoid
416411a29bacSmrglt_update_exe_path (const char *name, const char *value)
416511a29bacSmrg{
416611a29bacSmrg  lt_debugprintf (__FILE__, __LINE__,
416711a29bacSmrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
416811a29bacSmrg                  nonnull (name), nonnull (value));
416941b2f0bdSmrg
417011a29bacSmrg  if (name && *name && value && *value)
417111a29bacSmrg    {
417211a29bacSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
417311a29bacSmrg      /* some systems can't cope with a ':'-terminated path #' */
417411a29bacSmrg      int len = strlen (new_value);
417511a29bacSmrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
417611a29bacSmrg        {
417711a29bacSmrg          new_value[len-1] = '\0';
417811a29bacSmrg        }
417911a29bacSmrg      lt_setenv (name, new_value);
418011a29bacSmrg      XFREE (new_value);
418111a29bacSmrg    }
418211a29bacSmrg}
418341b2f0bdSmrg
418411a29bacSmrgvoid
418511a29bacSmrglt_update_lib_path (const char *name, const char *value)
418611a29bacSmrg{
418711a29bacSmrg  lt_debugprintf (__FILE__, __LINE__,
418811a29bacSmrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
418911a29bacSmrg                  nonnull (name), nonnull (value));
419041b2f0bdSmrg
419111a29bacSmrg  if (name && *name && value && *value)
419211a29bacSmrg    {
419311a29bacSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
419411a29bacSmrg      lt_setenv (name, new_value);
419511a29bacSmrg      XFREE (new_value);
419611a29bacSmrg    }
419711a29bacSmrg}
419841b2f0bdSmrg
419911a29bacSmrgEOF
420011a29bacSmrg	    case $host_os in
420111a29bacSmrg	      mingw*)
420211a29bacSmrg		cat <<"EOF"
420311a29bacSmrg
420411a29bacSmrg/* Prepares an argument vector before calling spawn().
420511a29bacSmrg   Note that spawn() does not by itself call the command interpreter
420611a29bacSmrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
420711a29bacSmrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
420811a29bacSmrg         GetVersionEx(&v);
420911a29bacSmrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
421011a29bacSmrg      }) ? "cmd.exe" : "command.com").
421111a29bacSmrg   Instead it simply concatenates the arguments, separated by ' ', and calls
421211a29bacSmrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
421311a29bacSmrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
421411a29bacSmrg   special way:
421511a29bacSmrg   - Space and tab are interpreted as delimiters. They are not treated as
421611a29bacSmrg     delimiters if they are surrounded by double quotes: "...".
421711a29bacSmrg   - Unescaped double quotes are removed from the input. Their only effect is
421811a29bacSmrg     that within double quotes, space and tab are treated like normal
421911a29bacSmrg     characters.
422011a29bacSmrg   - Backslashes not followed by double quotes are not special.
422111a29bacSmrg   - But 2*n+1 backslashes followed by a double quote become
422211a29bacSmrg     n backslashes followed by a double quote (n >= 0):
422311a29bacSmrg       \" -> "
422411a29bacSmrg       \\\" -> \"
422511a29bacSmrg       \\\\\" -> \\"
422611a29bacSmrg */
422711a29bacSmrg#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"
422811a29bacSmrg#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"
422911a29bacSmrgchar **
423011a29bacSmrgprepare_spawn (char **argv)
423111a29bacSmrg{
423211a29bacSmrg  size_t argc;
423311a29bacSmrg  char **new_argv;
423411a29bacSmrg  size_t i;
423541b2f0bdSmrg
423611a29bacSmrg  /* Count number of arguments.  */
423711a29bacSmrg  for (argc = 0; argv[argc] != NULL; argc++)
423811a29bacSmrg    ;
423941b2f0bdSmrg
424011a29bacSmrg  /* Allocate new argument vector.  */
424111a29bacSmrg  new_argv = XMALLOC (char *, argc + 1);
424241b2f0bdSmrg
424311a29bacSmrg  /* Put quoted arguments into the new argument vector.  */
424411a29bacSmrg  for (i = 0; i < argc; i++)
424511a29bacSmrg    {
424611a29bacSmrg      const char *string = argv[i];
424711a29bacSmrg
424811a29bacSmrg      if (string[0] == '\0')
424911a29bacSmrg	new_argv[i] = xstrdup ("\"\"");
425011a29bacSmrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
425111a29bacSmrg	{
425211a29bacSmrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
425311a29bacSmrg	  size_t length;
425411a29bacSmrg	  unsigned int backslashes;
425511a29bacSmrg	  const char *s;
425611a29bacSmrg	  char *quoted_string;
425711a29bacSmrg	  char *p;
425811a29bacSmrg
425911a29bacSmrg	  length = 0;
426011a29bacSmrg	  backslashes = 0;
426111a29bacSmrg	  if (quote_around)
426211a29bacSmrg	    length++;
426311a29bacSmrg	  for (s = string; *s != '\0'; s++)
426411a29bacSmrg	    {
426511a29bacSmrg	      char c = *s;
426611a29bacSmrg	      if (c == '"')
426711a29bacSmrg		length += backslashes + 1;
426811a29bacSmrg	      length++;
426911a29bacSmrg	      if (c == '\\')
427011a29bacSmrg		backslashes++;
427111a29bacSmrg	      else
427211a29bacSmrg		backslashes = 0;
427311a29bacSmrg	    }
427411a29bacSmrg	  if (quote_around)
427511a29bacSmrg	    length += backslashes + 1;
427611a29bacSmrg
427711a29bacSmrg	  quoted_string = XMALLOC (char, length + 1);
427811a29bacSmrg
427911a29bacSmrg	  p = quoted_string;
428011a29bacSmrg	  backslashes = 0;
428111a29bacSmrg	  if (quote_around)
428211a29bacSmrg	    *p++ = '"';
428311a29bacSmrg	  for (s = string; *s != '\0'; s++)
428411a29bacSmrg	    {
428511a29bacSmrg	      char c = *s;
428611a29bacSmrg	      if (c == '"')
428711a29bacSmrg		{
428811a29bacSmrg		  unsigned int j;
428911a29bacSmrg		  for (j = backslashes + 1; j > 0; j--)
429011a29bacSmrg		    *p++ = '\\';
429111a29bacSmrg		}
429211a29bacSmrg	      *p++ = c;
429311a29bacSmrg	      if (c == '\\')
429411a29bacSmrg		backslashes++;
429511a29bacSmrg	      else
429611a29bacSmrg		backslashes = 0;
429711a29bacSmrg	    }
429811a29bacSmrg	  if (quote_around)
429911a29bacSmrg	    {
430011a29bacSmrg	      unsigned int j;
430111a29bacSmrg	      for (j = backslashes; j > 0; j--)
430211a29bacSmrg		*p++ = '\\';
430311a29bacSmrg	      *p++ = '"';
430411a29bacSmrg	    }
430511a29bacSmrg	  *p = '\0';
430641b2f0bdSmrg
430711a29bacSmrg	  new_argv[i] = quoted_string;
430811a29bacSmrg	}
430911a29bacSmrg      else
431011a29bacSmrg	new_argv[i] = (char *) string;
431111a29bacSmrg    }
431211a29bacSmrg  new_argv[argc] = NULL;
431341b2f0bdSmrg
431411a29bacSmrg  return new_argv;
431511a29bacSmrg}
431611a29bacSmrgEOF
431741b2f0bdSmrg		;;
431811a29bacSmrg	    esac
431941b2f0bdSmrg
432011a29bacSmrg            cat <<"EOF"
432111a29bacSmrgvoid lt_dump_script (FILE* f)
432211a29bacSmrg{
432311a29bacSmrgEOF
432411a29bacSmrg	    func_emit_wrapper yes |
432511a29bacSmrg              $SED -e 's/\([\\"]\)/\\\1/g' \
432611a29bacSmrg	           -e 's/^/  fputs ("/' -e 's/$/\\n", f);/'
432741b2f0bdSmrg
432811a29bacSmrg            cat <<"EOF"
432911a29bacSmrg}
433011a29bacSmrgEOF
433111a29bacSmrg}
433211a29bacSmrg# end: func_emit_cwrapperexe_src
433341b2f0bdSmrg
433411a29bacSmrg# func_win32_import_lib_p ARG
433511a29bacSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd
433611a29bacSmrgfunc_win32_import_lib_p ()
433711a29bacSmrg{
433811a29bacSmrg    $opt_debug
433911a29bacSmrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
434011a29bacSmrg    *import*) : ;;
434111a29bacSmrg    *) false ;;
434211a29bacSmrg    esac
434311a29bacSmrg}
434441b2f0bdSmrg
434511a29bacSmrg# func_mode_link arg...
434611a29bacSmrgfunc_mode_link ()
434711a29bacSmrg{
434811a29bacSmrg    $opt_debug
434911a29bacSmrg    case $host in
435011a29bacSmrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
435111a29bacSmrg      # It is impossible to link a dll without this setting, and
435211a29bacSmrg      # we shouldn't force the makefile maintainer to figure out
435311a29bacSmrg      # which system we are compiling for in order to pass an extra
435411a29bacSmrg      # flag for every libtool invocation.
435511a29bacSmrg      # allow_undefined=no
435641b2f0bdSmrg
435711a29bacSmrg      # FIXME: Unfortunately, there are problems with the above when trying
435811a29bacSmrg      # to make a dll which has undefined symbols, in which case not
435911a29bacSmrg      # even a static library is built.  For now, we need to specify
436011a29bacSmrg      # -no-undefined on the libtool link line when we can be certain
436111a29bacSmrg      # that all symbols are satisfied, otherwise we get a static library.
436211a29bacSmrg      allow_undefined=yes
436311a29bacSmrg      ;;
436411a29bacSmrg    *)
436511a29bacSmrg      allow_undefined=yes
436611a29bacSmrg      ;;
436711a29bacSmrg    esac
436811a29bacSmrg    libtool_args=$nonopt
436911a29bacSmrg    base_compile="$nonopt $@"
437011a29bacSmrg    compile_command=$nonopt
437111a29bacSmrg    finalize_command=$nonopt
437241b2f0bdSmrg
437311a29bacSmrg    compile_rpath=
437411a29bacSmrg    finalize_rpath=
437511a29bacSmrg    compile_shlibpath=
437611a29bacSmrg    finalize_shlibpath=
437711a29bacSmrg    convenience=
437811a29bacSmrg    old_convenience=
437911a29bacSmrg    deplibs=
438011a29bacSmrg    old_deplibs=
438111a29bacSmrg    compiler_flags=
438211a29bacSmrg    linker_flags=
438311a29bacSmrg    dllsearchpath=
438411a29bacSmrg    lib_search_path=`pwd`
438511a29bacSmrg    inst_prefix_dir=
438611a29bacSmrg    new_inherited_linker_flags=
438741b2f0bdSmrg
438811a29bacSmrg    avoid_version=no
438911a29bacSmrg    bindir=
439011a29bacSmrg    dlfiles=
439111a29bacSmrg    dlprefiles=
439211a29bacSmrg    dlself=no
439311a29bacSmrg    export_dynamic=no
439411a29bacSmrg    export_symbols=
439511a29bacSmrg    export_symbols_regex=
439611a29bacSmrg    generated=
439711a29bacSmrg    libobjs=
439811a29bacSmrg    ltlibs=
439911a29bacSmrg    module=no
440011a29bacSmrg    no_install=no
440111a29bacSmrg    objs=
440211a29bacSmrg    non_pic_objects=
440311a29bacSmrg    precious_files_regex=
440411a29bacSmrg    prefer_static_libs=no
440511a29bacSmrg    preload=no
440611a29bacSmrg    prev=
440711a29bacSmrg    prevarg=
440811a29bacSmrg    release=
440911a29bacSmrg    rpath=
441011a29bacSmrg    xrpath=
441111a29bacSmrg    perm_rpath=
441211a29bacSmrg    temp_rpath=
441311a29bacSmrg    thread_safe=no
441411a29bacSmrg    vinfo=
441511a29bacSmrg    vinfo_number=no
441611a29bacSmrg    weak_libs=
441711a29bacSmrg    single_module="${wl}-single_module"
441811a29bacSmrg    func_infer_tag $base_compile
441941b2f0bdSmrg
442011a29bacSmrg    # We need to know -static, to get the right output filenames.
442111a29bacSmrg    for arg
442211a29bacSmrg    do
442311a29bacSmrg      case $arg in
442411a29bacSmrg      -shared)
442511a29bacSmrg	test "$build_libtool_libs" != yes && \
442611a29bacSmrg	  func_fatal_configuration "can not build a shared library"
442711a29bacSmrg	build_old_libs=no
442811a29bacSmrg	break
442911a29bacSmrg	;;
443011a29bacSmrg      -all-static | -static | -static-libtool-libs)
443111a29bacSmrg	case $arg in
443211a29bacSmrg	-all-static)
443311a29bacSmrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
443411a29bacSmrg	    func_warning "complete static linking is impossible in this configuration"
443511a29bacSmrg	  fi
443611a29bacSmrg	  if test -n "$link_static_flag"; then
443711a29bacSmrg	    dlopen_self=$dlopen_self_static
443811a29bacSmrg	  fi
443911a29bacSmrg	  prefer_static_libs=yes
444011a29bacSmrg	  ;;
444111a29bacSmrg	-static)
444211a29bacSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
444311a29bacSmrg	    dlopen_self=$dlopen_self_static
444411a29bacSmrg	  fi
444511a29bacSmrg	  prefer_static_libs=built
444611a29bacSmrg	  ;;
444711a29bacSmrg	-static-libtool-libs)
444811a29bacSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
444911a29bacSmrg	    dlopen_self=$dlopen_self_static
445011a29bacSmrg	  fi
445111a29bacSmrg	  prefer_static_libs=yes
445211a29bacSmrg	  ;;
445311a29bacSmrg	esac
445411a29bacSmrg	build_libtool_libs=no
445511a29bacSmrg	build_old_libs=yes
445611a29bacSmrg	break
445711a29bacSmrg	;;
445811a29bacSmrg      esac
445911a29bacSmrg    done
446041b2f0bdSmrg
446111a29bacSmrg    # See if our shared archives depend on static archives.
446211a29bacSmrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
446341b2f0bdSmrg
446411a29bacSmrg    # Go through the arguments, transforming them on the way.
446511a29bacSmrg    while test "$#" -gt 0; do
446611a29bacSmrg      arg="$1"
446711a29bacSmrg      shift
446811a29bacSmrg      func_quote_for_eval "$arg"
446911a29bacSmrg      qarg=$func_quote_for_eval_unquoted_result
447011a29bacSmrg      func_append libtool_args " $func_quote_for_eval_result"
447141b2f0bdSmrg
447211a29bacSmrg      # If the previous option needs an argument, assign it.
447311a29bacSmrg      if test -n "$prev"; then
447411a29bacSmrg	case $prev in
447511a29bacSmrg	output)
447611a29bacSmrg	  func_append compile_command " @OUTPUT@"
447711a29bacSmrg	  func_append finalize_command " @OUTPUT@"
447811a29bacSmrg	  ;;
447911a29bacSmrg	esac
448041b2f0bdSmrg
448111a29bacSmrg	case $prev in
448211a29bacSmrg	bindir)
448311a29bacSmrg	  bindir="$arg"
448411a29bacSmrg	  prev=
448511a29bacSmrg	  continue
448611a29bacSmrg	  ;;
448711a29bacSmrg	dlfiles|dlprefiles)
448811a29bacSmrg	  if test "$preload" = no; then
448911a29bacSmrg	    # Add the symbol object into the linking commands.
449011a29bacSmrg	    func_append compile_command " @SYMFILE@"
449111a29bacSmrg	    func_append finalize_command " @SYMFILE@"
449211a29bacSmrg	    preload=yes
449341b2f0bdSmrg	  fi
449411a29bacSmrg	  case $arg in
449511a29bacSmrg	  *.la | *.lo) ;;  # We handle these cases below.
449611a29bacSmrg	  force)
449711a29bacSmrg	    if test "$dlself" = no; then
449811a29bacSmrg	      dlself=needless
449911a29bacSmrg	      export_dynamic=yes
450041b2f0bdSmrg	    fi
450111a29bacSmrg	    prev=
450211a29bacSmrg	    continue
450311a29bacSmrg	    ;;
450411a29bacSmrg	  self)
450511a29bacSmrg	    if test "$prev" = dlprefiles; then
450611a29bacSmrg	      dlself=yes
450711a29bacSmrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
450811a29bacSmrg	      dlself=yes
450941b2f0bdSmrg	    else
451011a29bacSmrg	      dlself=needless
451111a29bacSmrg	      export_dynamic=yes
451241b2f0bdSmrg	    fi
451311a29bacSmrg	    prev=
451411a29bacSmrg	    continue
451511a29bacSmrg	    ;;
451611a29bacSmrg	  *)
451711a29bacSmrg	    if test "$prev" = dlfiles; then
451811a29bacSmrg	      dlfiles="$dlfiles $arg"
451941b2f0bdSmrg	    else
452011a29bacSmrg	      dlprefiles="$dlprefiles $arg"
452141b2f0bdSmrg	    fi
452211a29bacSmrg	    prev=
452311a29bacSmrg	    continue
452411a29bacSmrg	    ;;
452511a29bacSmrg	  esac
452611a29bacSmrg	  ;;
452711a29bacSmrg	expsyms)
452811a29bacSmrg	  export_symbols="$arg"
452911a29bacSmrg	  test -f "$arg" \
453011a29bacSmrg	    || func_fatal_error "symbol file \`$arg' does not exist"
453111a29bacSmrg	  prev=
453211a29bacSmrg	  continue
453311a29bacSmrg	  ;;
453411a29bacSmrg	expsyms_regex)
453511a29bacSmrg	  export_symbols_regex="$arg"
453611a29bacSmrg	  prev=
453711a29bacSmrg	  continue
453811a29bacSmrg	  ;;
453911a29bacSmrg	framework)
454041b2f0bdSmrg	  case $host in
454111a29bacSmrg	    *-*-darwin*)
454211a29bacSmrg	      case "$deplibs " in
454311a29bacSmrg		*" $qarg.ltframework "*) ;;
454411a29bacSmrg		*) deplibs="$deplibs $qarg.ltframework" # this is fixed later
454511a29bacSmrg		   ;;
454611a29bacSmrg	      esac
454711a29bacSmrg	      ;;
454841b2f0bdSmrg	  esac
454911a29bacSmrg	  prev=
455011a29bacSmrg	  continue
455141b2f0bdSmrg	  ;;
455211a29bacSmrg	inst_prefix)
455311a29bacSmrg	  inst_prefix_dir="$arg"
455411a29bacSmrg	  prev=
455511a29bacSmrg	  continue
455641b2f0bdSmrg	  ;;
455711a29bacSmrg	objectlist)
455811a29bacSmrg	  if test -f "$arg"; then
455911a29bacSmrg	    save_arg=$arg
456011a29bacSmrg	    moreargs=
456111a29bacSmrg	    for fil in `cat "$save_arg"`
456211a29bacSmrg	    do
456311a29bacSmrg#	      moreargs="$moreargs $fil"
456411a29bacSmrg	      arg=$fil
456511a29bacSmrg	      # A libtool-controlled object.
456641b2f0bdSmrg
456711a29bacSmrg	      # Check to see that this really is a libtool object.
456811a29bacSmrg	      if func_lalib_unsafe_p "$arg"; then
456911a29bacSmrg		pic_object=
457011a29bacSmrg		non_pic_object=
457141b2f0bdSmrg
457211a29bacSmrg		# Read the .lo file
457311a29bacSmrg		func_source "$arg"
457441b2f0bdSmrg
457511a29bacSmrg		if test -z "$pic_object" ||
457611a29bacSmrg		   test -z "$non_pic_object" ||
457711a29bacSmrg		   test "$pic_object" = none &&
457811a29bacSmrg		   test "$non_pic_object" = none; then
457911a29bacSmrg		  func_fatal_error "cannot find name of object for \`$arg'"
458011a29bacSmrg		fi
458141b2f0bdSmrg
458211a29bacSmrg		# Extract subdirectory from the argument.
458311a29bacSmrg		func_dirname "$arg" "/" ""
458411a29bacSmrg		xdir="$func_dirname_result"
458541b2f0bdSmrg
458611a29bacSmrg		if test "$pic_object" != none; then
458711a29bacSmrg		  # Prepend the subdirectory the object is found in.
458811a29bacSmrg		  pic_object="$xdir$pic_object"
458941b2f0bdSmrg
459011a29bacSmrg		  if test "$prev" = dlfiles; then
459111a29bacSmrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
459211a29bacSmrg		      dlfiles="$dlfiles $pic_object"
459311a29bacSmrg		      prev=
459411a29bacSmrg		      continue
459511a29bacSmrg		    else
459611a29bacSmrg		      # If libtool objects are unsupported, then we need to preload.
459711a29bacSmrg		      prev=dlprefiles
459811a29bacSmrg		    fi
459911a29bacSmrg		  fi
460041b2f0bdSmrg
460111a29bacSmrg		  # CHECK ME:  I think I busted this.  -Ossama
460211a29bacSmrg		  if test "$prev" = dlprefiles; then
460311a29bacSmrg		    # Preload the old-style object.
460411a29bacSmrg		    dlprefiles="$dlprefiles $pic_object"
460511a29bacSmrg		    prev=
460611a29bacSmrg		  fi
460741b2f0bdSmrg
460811a29bacSmrg		  # A PIC object.
460911a29bacSmrg		  func_append libobjs " $pic_object"
461011a29bacSmrg		  arg="$pic_object"
461111a29bacSmrg		fi
461241b2f0bdSmrg
461311a29bacSmrg		# Non-PIC object.
461411a29bacSmrg		if test "$non_pic_object" != none; then
461511a29bacSmrg		  # Prepend the subdirectory the object is found in.
461611a29bacSmrg		  non_pic_object="$xdir$non_pic_object"
461741b2f0bdSmrg
461811a29bacSmrg		  # A standard non-PIC object
461911a29bacSmrg		  func_append non_pic_objects " $non_pic_object"
462011a29bacSmrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
462111a29bacSmrg		    arg="$non_pic_object"
462211a29bacSmrg		  fi
462311a29bacSmrg		else
462411a29bacSmrg		  # If the PIC object exists, use it instead.
462511a29bacSmrg		  # $xdir was prepended to $pic_object above.
462611a29bacSmrg		  non_pic_object="$pic_object"
462711a29bacSmrg		  func_append non_pic_objects " $non_pic_object"
462811a29bacSmrg		fi
462911a29bacSmrg	      else
463011a29bacSmrg		# Only an error if not doing a dry-run.
463111a29bacSmrg		if $opt_dry_run; then
463211a29bacSmrg		  # Extract subdirectory from the argument.
463311a29bacSmrg		  func_dirname "$arg" "/" ""
463411a29bacSmrg		  xdir="$func_dirname_result"
463511a29bacSmrg
463611a29bacSmrg		  func_lo2o "$arg"
463711a29bacSmrg		  pic_object=$xdir$objdir/$func_lo2o_result
463811a29bacSmrg		  non_pic_object=$xdir$func_lo2o_result
463911a29bacSmrg		  func_append libobjs " $pic_object"
464011a29bacSmrg		  func_append non_pic_objects " $non_pic_object"
464111a29bacSmrg	        else
464211a29bacSmrg		  func_fatal_error "\`$arg' is not a valid libtool object"
464311a29bacSmrg		fi
464411a29bacSmrg	      fi
464511a29bacSmrg	    done
464641b2f0bdSmrg	  else
464711a29bacSmrg	    func_fatal_error "link input file \`$arg' does not exist"
464841b2f0bdSmrg	  fi
464911a29bacSmrg	  arg=$save_arg
465011a29bacSmrg	  prev=
465111a29bacSmrg	  continue
465211a29bacSmrg	  ;;
465311a29bacSmrg	precious_regex)
465411a29bacSmrg	  precious_files_regex="$arg"
465511a29bacSmrg	  prev=
465611a29bacSmrg	  continue
465711a29bacSmrg	  ;;
465811a29bacSmrg	release)
465911a29bacSmrg	  release="-$arg"
466011a29bacSmrg	  prev=
466111a29bacSmrg	  continue
466211a29bacSmrg	  ;;
466311a29bacSmrg	rpath | xrpath)
466411a29bacSmrg	  # We need an absolute path.
466511a29bacSmrg	  case $arg in
466611a29bacSmrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
466711a29bacSmrg	  *)
466811a29bacSmrg	    func_fatal_error "only absolute run-paths are allowed"
466911a29bacSmrg	    ;;
467011a29bacSmrg	  esac
467111a29bacSmrg	  if test "$prev" = rpath; then
467211a29bacSmrg	    case "$rpath " in
467311a29bacSmrg	    *" $arg "*) ;;
467411a29bacSmrg	    *) rpath="$rpath $arg" ;;
467511a29bacSmrg	    esac
467641b2f0bdSmrg	  else
467711a29bacSmrg	    case "$xrpath " in
467811a29bacSmrg	    *" $arg "*) ;;
467911a29bacSmrg	    *) xrpath="$xrpath $arg" ;;
468011a29bacSmrg	    esac
468141b2f0bdSmrg	  fi
468211a29bacSmrg	  prev=
468311a29bacSmrg	  continue
468411a29bacSmrg	  ;;
468511a29bacSmrg	shrext)
468611a29bacSmrg	  shrext_cmds="$arg"
468711a29bacSmrg	  prev=
468811a29bacSmrg	  continue
468911a29bacSmrg	  ;;
469011a29bacSmrg	weak)
469111a29bacSmrg	  weak_libs="$weak_libs $arg"
469211a29bacSmrg	  prev=
469311a29bacSmrg	  continue
469411a29bacSmrg	  ;;
469511a29bacSmrg	xcclinker)
469611a29bacSmrg	  linker_flags="$linker_flags $qarg"
469711a29bacSmrg	  compiler_flags="$compiler_flags $qarg"
469811a29bacSmrg	  prev=
469911a29bacSmrg	  func_append compile_command " $qarg"
470011a29bacSmrg	  func_append finalize_command " $qarg"
470111a29bacSmrg	  continue
470211a29bacSmrg	  ;;
470311a29bacSmrg	xcompiler)
470411a29bacSmrg	  compiler_flags="$compiler_flags $qarg"
470511a29bacSmrg	  prev=
470611a29bacSmrg	  func_append compile_command " $qarg"
470711a29bacSmrg	  func_append finalize_command " $qarg"
470811a29bacSmrg	  continue
470911a29bacSmrg	  ;;
471011a29bacSmrg	xlinker)
471111a29bacSmrg	  linker_flags="$linker_flags $qarg"
471211a29bacSmrg	  compiler_flags="$compiler_flags $wl$qarg"
471311a29bacSmrg	  prev=
471411a29bacSmrg	  func_append compile_command " $wl$qarg"
471511a29bacSmrg	  func_append finalize_command " $wl$qarg"
471611a29bacSmrg	  continue
471711a29bacSmrg	  ;;
471811a29bacSmrg	*)
471911a29bacSmrg	  eval "$prev=\"\$arg\""
472011a29bacSmrg	  prev=
472111a29bacSmrg	  continue
472211a29bacSmrg	  ;;
472341b2f0bdSmrg	esac
472411a29bacSmrg      fi # test -n "$prev"
472541b2f0bdSmrg
472611a29bacSmrg      prevarg="$arg"
472741b2f0bdSmrg
472811a29bacSmrg      case $arg in
472911a29bacSmrg      -all-static)
473011a29bacSmrg	if test -n "$link_static_flag"; then
473111a29bacSmrg	  # See comment for -static flag below, for more details.
473211a29bacSmrg	  func_append compile_command " $link_static_flag"
473311a29bacSmrg	  func_append finalize_command " $link_static_flag"
473411a29bacSmrg	fi
473511a29bacSmrg	continue
473611a29bacSmrg	;;
473741b2f0bdSmrg
473811a29bacSmrg      -allow-undefined)
473911a29bacSmrg	# FIXME: remove this flag sometime in the future.
474011a29bacSmrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
474111a29bacSmrg	;;
474241b2f0bdSmrg
474311a29bacSmrg      -avoid-version)
474411a29bacSmrg	avoid_version=yes
474511a29bacSmrg	continue
474611a29bacSmrg	;;
474741b2f0bdSmrg
474811a29bacSmrg      -bindir)
474911a29bacSmrg	prev=bindir
475011a29bacSmrg	continue
475111a29bacSmrg	;;
475241b2f0bdSmrg
475311a29bacSmrg      -dlopen)
475411a29bacSmrg	prev=dlfiles
475511a29bacSmrg	continue
475611a29bacSmrg	;;
475741b2f0bdSmrg
475811a29bacSmrg      -dlpreopen)
475911a29bacSmrg	prev=dlprefiles
476011a29bacSmrg	continue
476111a29bacSmrg	;;
476241b2f0bdSmrg
476311a29bacSmrg      -export-dynamic)
476411a29bacSmrg	export_dynamic=yes
476511a29bacSmrg	continue
476611a29bacSmrg	;;
476741b2f0bdSmrg
476811a29bacSmrg      -export-symbols | -export-symbols-regex)
476911a29bacSmrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
477011a29bacSmrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
477111a29bacSmrg	fi
477211a29bacSmrg	if test "X$arg" = "X-export-symbols"; then
477311a29bacSmrg	  prev=expsyms
477411a29bacSmrg	else
477511a29bacSmrg	  prev=expsyms_regex
477611a29bacSmrg	fi
477711a29bacSmrg	continue
477811a29bacSmrg	;;
477941b2f0bdSmrg
478011a29bacSmrg      -framework)
478111a29bacSmrg	prev=framework
478211a29bacSmrg	continue
478311a29bacSmrg	;;
478441b2f0bdSmrg
478511a29bacSmrg      -inst-prefix-dir)
478611a29bacSmrg	prev=inst_prefix
478711a29bacSmrg	continue
478811a29bacSmrg	;;
478941b2f0bdSmrg
479011a29bacSmrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
479111a29bacSmrg      # so, if we see these flags be careful not to treat them like -L
479211a29bacSmrg      -L[A-Z][A-Z]*:*)
479311a29bacSmrg	case $with_gcc/$host in
479411a29bacSmrg	no/*-*-irix* | /*-*-irix*)
479511a29bacSmrg	  func_append compile_command " $arg"
479611a29bacSmrg	  func_append finalize_command " $arg"
479711a29bacSmrg	  ;;
479811a29bacSmrg	esac
479911a29bacSmrg	continue
480011a29bacSmrg	;;
480141b2f0bdSmrg
480211a29bacSmrg      -L*)
480311a29bacSmrg	func_stripname '-L' '' "$arg"
480411a29bacSmrg	dir=$func_stripname_result
480511a29bacSmrg	if test -z "$dir"; then
480611a29bacSmrg	  if test "$#" -gt 0; then
480711a29bacSmrg	    func_fatal_error "require no space between \`-L' and \`$1'"
480811a29bacSmrg	  else
480911a29bacSmrg	    func_fatal_error "need path for \`-L' option"
481011a29bacSmrg	  fi
481111a29bacSmrg	fi
481211a29bacSmrg	# We need an absolute path.
481311a29bacSmrg	case $dir in
481411a29bacSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
481511a29bacSmrg	*)
481611a29bacSmrg	  absdir=`cd "$dir" && pwd`
481711a29bacSmrg	  test -z "$absdir" && \
481811a29bacSmrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
481911a29bacSmrg	  dir="$absdir"
482011a29bacSmrg	  ;;
482111a29bacSmrg	esac
482211a29bacSmrg	case "$deplibs " in
482311a29bacSmrg	*" -L$dir "*) ;;
482411a29bacSmrg	*)
482511a29bacSmrg	  deplibs="$deplibs -L$dir"
482611a29bacSmrg	  lib_search_path="$lib_search_path $dir"
482711a29bacSmrg	  ;;
482811a29bacSmrg	esac
482911a29bacSmrg	case $host in
483011a29bacSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
483111a29bacSmrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
483211a29bacSmrg	  case :$dllsearchpath: in
483311a29bacSmrg	  *":$dir:"*) ;;
483411a29bacSmrg	  ::) dllsearchpath=$dir;;
483511a29bacSmrg	  *) dllsearchpath="$dllsearchpath:$dir";;
483611a29bacSmrg	  esac
483711a29bacSmrg	  case :$dllsearchpath: in
483811a29bacSmrg	  *":$testbindir:"*) ;;
483911a29bacSmrg	  ::) dllsearchpath=$testbindir;;
484011a29bacSmrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
484111a29bacSmrg	  esac
484211a29bacSmrg	  ;;
484311a29bacSmrg	esac
484411a29bacSmrg	continue
484511a29bacSmrg	;;
484641b2f0bdSmrg
484711a29bacSmrg      -l*)
484811a29bacSmrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
484911a29bacSmrg	  case $host in
485011a29bacSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
485111a29bacSmrg	    # These systems don't actually have a C or math library (as such)
485211a29bacSmrg	    continue
485311a29bacSmrg	    ;;
485411a29bacSmrg	  *-*-os2*)
485511a29bacSmrg	    # These systems don't actually have a C library (as such)
485611a29bacSmrg	    test "X$arg" = "X-lc" && continue
485711a29bacSmrg	    ;;
485811a29bacSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
485911a29bacSmrg	    # Do not include libc due to us having libc/libc_r.
486011a29bacSmrg	    test "X$arg" = "X-lc" && continue
486111a29bacSmrg	    ;;
486211a29bacSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
486311a29bacSmrg	    # Rhapsody C and math libraries are in the System framework
486411a29bacSmrg	    deplibs="$deplibs System.ltframework"
486511a29bacSmrg	    continue
486611a29bacSmrg	    ;;
486711a29bacSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
486811a29bacSmrg	    # Causes problems with __ctype
486911a29bacSmrg	    test "X$arg" = "X-lc" && continue
487011a29bacSmrg	    ;;
487111a29bacSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
487211a29bacSmrg	    # Compiler inserts libc in the correct place for threads to work
487311a29bacSmrg	    test "X$arg" = "X-lc" && continue
487411a29bacSmrg	    ;;
487511a29bacSmrg	  esac
487611a29bacSmrg	elif test "X$arg" = "X-lc_r"; then
487711a29bacSmrg	 case $host in
487811a29bacSmrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
487911a29bacSmrg	   # Do not include libc_r directly, use -pthread flag.
488011a29bacSmrg	   continue
488111a29bacSmrg	   ;;
488211a29bacSmrg	 esac
488311a29bacSmrg	fi
488411a29bacSmrg	deplibs="$deplibs $arg"
488511a29bacSmrg	continue
488611a29bacSmrg	;;
488741b2f0bdSmrg
488811a29bacSmrg      -module)
488911a29bacSmrg	module=yes
489011a29bacSmrg	continue
489111a29bacSmrg	;;
489241b2f0bdSmrg
489311a29bacSmrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
489411a29bacSmrg      # classes, name mangling, and exception handling.
489511a29bacSmrg      # Darwin uses the -arch flag to determine output architecture.
489611a29bacSmrg      -model|-arch|-isysroot)
489711a29bacSmrg	compiler_flags="$compiler_flags $arg"
489811a29bacSmrg	func_append compile_command " $arg"
489911a29bacSmrg	func_append finalize_command " $arg"
490011a29bacSmrg	prev=xcompiler
490111a29bacSmrg	continue
490211a29bacSmrg	;;
490341b2f0bdSmrg
490411a29bacSmrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
490511a29bacSmrg	compiler_flags="$compiler_flags $arg"
490611a29bacSmrg	func_append compile_command " $arg"
490711a29bacSmrg	func_append finalize_command " $arg"
490811a29bacSmrg	case "$new_inherited_linker_flags " in
490911a29bacSmrg	    *" $arg "*) ;;
491011a29bacSmrg	    * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
491111a29bacSmrg	esac
491211a29bacSmrg	continue
491311a29bacSmrg	;;
491441b2f0bdSmrg
491511a29bacSmrg      -multi_module)
491611a29bacSmrg	single_module="${wl}-multi_module"
491711a29bacSmrg	continue
491811a29bacSmrg	;;
491941b2f0bdSmrg
492011a29bacSmrg      -no-fast-install)
492111a29bacSmrg	fast_install=no
492211a29bacSmrg	continue
492311a29bacSmrg	;;
492441b2f0bdSmrg
492511a29bacSmrg      -no-install)
492611a29bacSmrg	case $host in
492711a29bacSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
492811a29bacSmrg	  # The PATH hackery in wrapper scripts is required on Windows
492911a29bacSmrg	  # and Darwin in order for the loader to find any dlls it needs.
493011a29bacSmrg	  func_warning "\`-no-install' is ignored for $host"
493111a29bacSmrg	  func_warning "assuming \`-no-fast-install' instead"
493211a29bacSmrg	  fast_install=no
493311a29bacSmrg	  ;;
493411a29bacSmrg	*) no_install=yes ;;
493511a29bacSmrg	esac
493611a29bacSmrg	continue
493711a29bacSmrg	;;
493841b2f0bdSmrg
493911a29bacSmrg      -no-undefined)
494011a29bacSmrg	allow_undefined=no
494111a29bacSmrg	continue
494211a29bacSmrg	;;
494341b2f0bdSmrg
494411a29bacSmrg      -objectlist)
494511a29bacSmrg	prev=objectlist
494611a29bacSmrg	continue
494711a29bacSmrg	;;
494841b2f0bdSmrg
494911a29bacSmrg      -o) prev=output ;;
495041b2f0bdSmrg
495111a29bacSmrg      -precious-files-regex)
495211a29bacSmrg	prev=precious_regex
495311a29bacSmrg	continue
495411a29bacSmrg	;;
495541b2f0bdSmrg
495611a29bacSmrg      -release)
495711a29bacSmrg	prev=release
495811a29bacSmrg	continue
495911a29bacSmrg	;;
496041b2f0bdSmrg
496111a29bacSmrg      -rpath)
496211a29bacSmrg	prev=rpath
496311a29bacSmrg	continue
496411a29bacSmrg	;;
496541b2f0bdSmrg
496611a29bacSmrg      -R)
496711a29bacSmrg	prev=xrpath
496811a29bacSmrg	continue
496911a29bacSmrg	;;
497041b2f0bdSmrg
497111a29bacSmrg      -R*)
497211a29bacSmrg	func_stripname '-R' '' "$arg"
497311a29bacSmrg	dir=$func_stripname_result
497411a29bacSmrg	# We need an absolute path.
497511a29bacSmrg	case $dir in
497611a29bacSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
497711a29bacSmrg	*)
497811a29bacSmrg	  func_fatal_error "only absolute run-paths are allowed"
497911a29bacSmrg	  ;;
498011a29bacSmrg	esac
498111a29bacSmrg	case "$xrpath " in
498211a29bacSmrg	*" $dir "*) ;;
498311a29bacSmrg	*) xrpath="$xrpath $dir" ;;
498411a29bacSmrg	esac
498511a29bacSmrg	continue
498611a29bacSmrg	;;
498741b2f0bdSmrg
498811a29bacSmrg      -shared)
498911a29bacSmrg	# The effects of -shared are defined in a previous loop.
499011a29bacSmrg	continue
499111a29bacSmrg	;;
499241b2f0bdSmrg
499311a29bacSmrg      -shrext)
499411a29bacSmrg	prev=shrext
499511a29bacSmrg	continue
499611a29bacSmrg	;;
499741b2f0bdSmrg
499811a29bacSmrg      -static | -static-libtool-libs)
499911a29bacSmrg	# The effects of -static are defined in a previous loop.
500011a29bacSmrg	# We used to do the same as -all-static on platforms that
500111a29bacSmrg	# didn't have a PIC flag, but the assumption that the effects
500211a29bacSmrg	# would be equivalent was wrong.  It would break on at least
500311a29bacSmrg	# Digital Unix and AIX.
500411a29bacSmrg	continue
500511a29bacSmrg	;;
500641b2f0bdSmrg
500711a29bacSmrg      -thread-safe)
500811a29bacSmrg	thread_safe=yes
500911a29bacSmrg	continue
501011a29bacSmrg	;;
501141b2f0bdSmrg
501211a29bacSmrg      -version-info)
501311a29bacSmrg	prev=vinfo
501411a29bacSmrg	continue
501511a29bacSmrg	;;
501641b2f0bdSmrg
501711a29bacSmrg      -version-number)
501811a29bacSmrg	prev=vinfo
501911a29bacSmrg	vinfo_number=yes
502011a29bacSmrg	continue
502111a29bacSmrg	;;
502241b2f0bdSmrg
502311a29bacSmrg      -weak)
502411a29bacSmrg        prev=weak
502511a29bacSmrg	continue
502611a29bacSmrg	;;
502741b2f0bdSmrg
502811a29bacSmrg      -Wc,*)
502911a29bacSmrg	func_stripname '-Wc,' '' "$arg"
503011a29bacSmrg	args=$func_stripname_result
503111a29bacSmrg	arg=
503211a29bacSmrg	save_ifs="$IFS"; IFS=','
503311a29bacSmrg	for flag in $args; do
503411a29bacSmrg	  IFS="$save_ifs"
503511a29bacSmrg          func_quote_for_eval "$flag"
503611a29bacSmrg	  arg="$arg $func_quote_for_eval_result"
503711a29bacSmrg	  compiler_flags="$compiler_flags $func_quote_for_eval_result"
503811a29bacSmrg	done
503911a29bacSmrg	IFS="$save_ifs"
504011a29bacSmrg	func_stripname ' ' '' "$arg"
504111a29bacSmrg	arg=$func_stripname_result
504211a29bacSmrg	;;
504341b2f0bdSmrg
504411a29bacSmrg      -Wl,*)
504511a29bacSmrg	func_stripname '-Wl,' '' "$arg"
504611a29bacSmrg	args=$func_stripname_result
504711a29bacSmrg	arg=
504811a29bacSmrg	save_ifs="$IFS"; IFS=','
504911a29bacSmrg	for flag in $args; do
505011a29bacSmrg	  IFS="$save_ifs"
505111a29bacSmrg          func_quote_for_eval "$flag"
505211a29bacSmrg	  arg="$arg $wl$func_quote_for_eval_result"
505311a29bacSmrg	  compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
505411a29bacSmrg	  linker_flags="$linker_flags $func_quote_for_eval_result"
505511a29bacSmrg	done
505611a29bacSmrg	IFS="$save_ifs"
505711a29bacSmrg	func_stripname ' ' '' "$arg"
505811a29bacSmrg	arg=$func_stripname_result
505911a29bacSmrg	;;
506041b2f0bdSmrg
506111a29bacSmrg      -Xcompiler)
506211a29bacSmrg	prev=xcompiler
506311a29bacSmrg	continue
506411a29bacSmrg	;;
506541b2f0bdSmrg
506611a29bacSmrg      -Xlinker)
506711a29bacSmrg	prev=xlinker
506811a29bacSmrg	continue
506911a29bacSmrg	;;
507041b2f0bdSmrg
507111a29bacSmrg      -XCClinker)
507211a29bacSmrg	prev=xcclinker
507311a29bacSmrg	continue
507411a29bacSmrg	;;
507541b2f0bdSmrg
507611a29bacSmrg      # -msg_* for osf cc
507711a29bacSmrg      -msg_*)
507811a29bacSmrg	func_quote_for_eval "$arg"
507911a29bacSmrg	arg="$func_quote_for_eval_result"
508011a29bacSmrg	;;
508141b2f0bdSmrg
508211a29bacSmrg      # Flags to be passed through unchanged, with rationale:
508311a29bacSmrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
508411a29bacSmrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
508511a29bacSmrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
508611a29bacSmrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
508711a29bacSmrg      # -q*                  compiler args for the IBM compiler
508811a29bacSmrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
508911a29bacSmrg      # -F/path              path to uninstalled frameworks, gcc on darwin
509011a29bacSmrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
509111a29bacSmrg      # @file                GCC response files
509211a29bacSmrg      # -tp=*                Portland pgcc target processor selection
509311a29bacSmrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
509411a29bacSmrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*)
509511a29bacSmrg        func_quote_for_eval "$arg"
509611a29bacSmrg	arg="$func_quote_for_eval_result"
509711a29bacSmrg        func_append compile_command " $arg"
509811a29bacSmrg        func_append finalize_command " $arg"
509911a29bacSmrg        compiler_flags="$compiler_flags $arg"
510011a29bacSmrg        continue
510111a29bacSmrg        ;;
510241b2f0bdSmrg
510311a29bacSmrg      # Some other compiler flag.
510411a29bacSmrg      -* | +*)
510511a29bacSmrg        func_quote_for_eval "$arg"
510611a29bacSmrg	arg="$func_quote_for_eval_result"
510711a29bacSmrg	;;
510841b2f0bdSmrg
510911a29bacSmrg      *.$objext)
511011a29bacSmrg	# A standard object.
511111a29bacSmrg	objs="$objs $arg"
511211a29bacSmrg	;;
511341b2f0bdSmrg
511411a29bacSmrg      *.lo)
511511a29bacSmrg	# A libtool-controlled object.
511641b2f0bdSmrg
511711a29bacSmrg	# Check to see that this really is a libtool object.
511811a29bacSmrg	if func_lalib_unsafe_p "$arg"; then
511911a29bacSmrg	  pic_object=
512011a29bacSmrg	  non_pic_object=
512141b2f0bdSmrg
512211a29bacSmrg	  # Read the .lo file
512311a29bacSmrg	  func_source "$arg"
512441b2f0bdSmrg
512511a29bacSmrg	  if test -z "$pic_object" ||
512611a29bacSmrg	     test -z "$non_pic_object" ||
512711a29bacSmrg	     test "$pic_object" = none &&
512811a29bacSmrg	     test "$non_pic_object" = none; then
512911a29bacSmrg	    func_fatal_error "cannot find name of object for \`$arg'"
513011a29bacSmrg	  fi
513111245024Smrg
513211a29bacSmrg	  # Extract subdirectory from the argument.
513311a29bacSmrg	  func_dirname "$arg" "/" ""
513411a29bacSmrg	  xdir="$func_dirname_result"
513541b2f0bdSmrg
513611a29bacSmrg	  if test "$pic_object" != none; then
513711a29bacSmrg	    # Prepend the subdirectory the object is found in.
513811a29bacSmrg	    pic_object="$xdir$pic_object"
513941b2f0bdSmrg
514011a29bacSmrg	    if test "$prev" = dlfiles; then
514111a29bacSmrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
514211a29bacSmrg		dlfiles="$dlfiles $pic_object"
514311a29bacSmrg		prev=
514411a29bacSmrg		continue
514511a29bacSmrg	      else
514611a29bacSmrg		# If libtool objects are unsupported, then we need to preload.
514711a29bacSmrg		prev=dlprefiles
514811a29bacSmrg	      fi
514911a29bacSmrg	    fi
515011a29bacSmrg
515111a29bacSmrg	    # CHECK ME:  I think I busted this.  -Ossama
515211a29bacSmrg	    if test "$prev" = dlprefiles; then
515311a29bacSmrg	      # Preload the old-style object.
515411a29bacSmrg	      dlprefiles="$dlprefiles $pic_object"
515511a29bacSmrg	      prev=
515611a29bacSmrg	    fi
515711a29bacSmrg
515811a29bacSmrg	    # A PIC object.
515911a29bacSmrg	    func_append libobjs " $pic_object"
516011a29bacSmrg	    arg="$pic_object"
516111a29bacSmrg	  fi
516211a29bacSmrg
516311a29bacSmrg	  # Non-PIC object.
516411a29bacSmrg	  if test "$non_pic_object" != none; then
516511a29bacSmrg	    # Prepend the subdirectory the object is found in.
516611a29bacSmrg	    non_pic_object="$xdir$non_pic_object"
516711a29bacSmrg
516811a29bacSmrg	    # A standard non-PIC object
516911a29bacSmrg	    func_append non_pic_objects " $non_pic_object"
517011a29bacSmrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
517111a29bacSmrg	      arg="$non_pic_object"
517211a29bacSmrg	    fi
517311a29bacSmrg	  else
517411a29bacSmrg	    # If the PIC object exists, use it instead.
517511a29bacSmrg	    # $xdir was prepended to $pic_object above.
517611a29bacSmrg	    non_pic_object="$pic_object"
517711a29bacSmrg	    func_append non_pic_objects " $non_pic_object"
517811a29bacSmrg	  fi
517911a29bacSmrg	else
518011a29bacSmrg	  # Only an error if not doing a dry-run.
518111a29bacSmrg	  if $opt_dry_run; then
518211a29bacSmrg	    # Extract subdirectory from the argument.
518311a29bacSmrg	    func_dirname "$arg" "/" ""
518411a29bacSmrg	    xdir="$func_dirname_result"
518511a29bacSmrg
518611a29bacSmrg	    func_lo2o "$arg"
518711a29bacSmrg	    pic_object=$xdir$objdir/$func_lo2o_result
518811a29bacSmrg	    non_pic_object=$xdir$func_lo2o_result
518911a29bacSmrg	    func_append libobjs " $pic_object"
519011a29bacSmrg	    func_append non_pic_objects " $non_pic_object"
519111a29bacSmrg	  else
519211a29bacSmrg	    func_fatal_error "\`$arg' is not a valid libtool object"
519311a29bacSmrg	  fi
519411a29bacSmrg	fi
519511a29bacSmrg	;;
519611a29bacSmrg
519711a29bacSmrg      *.$libext)
519811a29bacSmrg	# An archive.
519911a29bacSmrg	deplibs="$deplibs $arg"
520011a29bacSmrg	old_deplibs="$old_deplibs $arg"
520111a29bacSmrg	continue
520211a29bacSmrg	;;
520311a29bacSmrg
520411a29bacSmrg      *.la)
520511a29bacSmrg	# A libtool-controlled library.
520611a29bacSmrg
520711a29bacSmrg	if test "$prev" = dlfiles; then
520811a29bacSmrg	  # This library was specified with -dlopen.
520911a29bacSmrg	  dlfiles="$dlfiles $arg"
521011a29bacSmrg	  prev=
521111a29bacSmrg	elif test "$prev" = dlprefiles; then
521211a29bacSmrg	  # The library was specified with -dlpreopen.
521311a29bacSmrg	  dlprefiles="$dlprefiles $arg"
521411a29bacSmrg	  prev=
521511a29bacSmrg	else
521611a29bacSmrg	  deplibs="$deplibs $arg"
521711a29bacSmrg	fi
521811a29bacSmrg	continue
521911a29bacSmrg	;;
522011a29bacSmrg
522111a29bacSmrg      # Some other compiler argument.
522211a29bacSmrg      *)
522311a29bacSmrg	# Unknown arguments in both finalize_command and compile_command need
522411a29bacSmrg	# to be aesthetically quoted because they are evaled later.
522511a29bacSmrg	func_quote_for_eval "$arg"
522611a29bacSmrg	arg="$func_quote_for_eval_result"
522711a29bacSmrg	;;
522811a29bacSmrg      esac # arg
522911a29bacSmrg
523011a29bacSmrg      # Now actually substitute the argument into the commands.
523111a29bacSmrg      if test -n "$arg"; then
523211a29bacSmrg	func_append compile_command " $arg"
523311a29bacSmrg	func_append finalize_command " $arg"
523411a29bacSmrg      fi
523511a29bacSmrg    done # argument parsing loop
523611a29bacSmrg
523711a29bacSmrg    test -n "$prev" && \
523811a29bacSmrg      func_fatal_help "the \`$prevarg' option requires an argument"
523911a29bacSmrg
524011a29bacSmrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
524111a29bacSmrg      eval arg=\"$export_dynamic_flag_spec\"
524211a29bacSmrg      func_append compile_command " $arg"
524311a29bacSmrg      func_append finalize_command " $arg"
524411a29bacSmrg    fi
524511a29bacSmrg
524611a29bacSmrg    oldlibs=
524711a29bacSmrg    # calculate the name of the file, without its directory
524811a29bacSmrg    func_basename "$output"
524911a29bacSmrg    outputname="$func_basename_result"
525011a29bacSmrg    libobjs_save="$libobjs"
525111a29bacSmrg
525211a29bacSmrg    if test -n "$shlibpath_var"; then
525311a29bacSmrg      # get the directories listed in $shlibpath_var
525411a29bacSmrg      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
525541b2f0bdSmrg    else
525611a29bacSmrg      shlib_search_path=
525741b2f0bdSmrg    fi
525811a29bacSmrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
525911a29bacSmrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
526041b2f0bdSmrg
526111a29bacSmrg    func_dirname "$output" "/" ""
526211a29bacSmrg    output_objdir="$func_dirname_result$objdir"
526311a29bacSmrg    # Create the object directory.
526411a29bacSmrg    func_mkdir_p "$output_objdir"
526541b2f0bdSmrg
526611a29bacSmrg    # Determine the type of output
526711a29bacSmrg    case $output in
526811a29bacSmrg    "")
526911a29bacSmrg      func_fatal_help "you must specify an output file"
527011a29bacSmrg      ;;
527111a29bacSmrg    *.$libext) linkmode=oldlib ;;
527211a29bacSmrg    *.lo | *.$objext) linkmode=obj ;;
527311a29bacSmrg    *.la) linkmode=lib ;;
527411a29bacSmrg    *) linkmode=prog ;; # Anything else should be a program.
527511a29bacSmrg    esac
527611a29bacSmrg
527711a29bacSmrg    specialdeplibs=
527811a29bacSmrg
527911a29bacSmrg    libs=
528011a29bacSmrg    # Find all interdependent deplibs by searching for libraries
528111a29bacSmrg    # that are linked more than once (e.g. -la -lb -la)
528211a29bacSmrg    for deplib in $deplibs; do
528311a29bacSmrg      if $opt_duplicate_deps ; then
528411a29bacSmrg	case "$libs " in
528511a29bacSmrg	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
528611a29bacSmrg	esac
528711a29bacSmrg      fi
528811a29bacSmrg      libs="$libs $deplib"
528911a29bacSmrg    done
529011a29bacSmrg
529111a29bacSmrg    if test "$linkmode" = lib; then
529211a29bacSmrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
529311a29bacSmrg
529411a29bacSmrg      # Compute libraries that are listed more than once in $predeps
529511a29bacSmrg      # $postdeps and mark them as special (i.e., whose duplicates are
529611a29bacSmrg      # not to be eliminated).
529711a29bacSmrg      pre_post_deps=
529811a29bacSmrg      if $opt_duplicate_compiler_generated_deps; then
529911a29bacSmrg	for pre_post_dep in $predeps $postdeps; do
530011a29bacSmrg	  case "$pre_post_deps " in
530111a29bacSmrg	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
530211a29bacSmrg	  esac
530311a29bacSmrg	  pre_post_deps="$pre_post_deps $pre_post_dep"
530411a29bacSmrg	done
530511a29bacSmrg      fi
530611a29bacSmrg      pre_post_deps=
530711a29bacSmrg    fi
530811a29bacSmrg
530911a29bacSmrg    deplibs=
531011a29bacSmrg    newdependency_libs=
531111a29bacSmrg    newlib_search_path=
531211a29bacSmrg    need_relink=no # whether we're linking any uninstalled libtool libraries
531311a29bacSmrg    notinst_deplibs= # not-installed libtool libraries
531411a29bacSmrg    notinst_path= # paths that contain not-installed libtool libraries
531511a29bacSmrg
531611a29bacSmrg    case $linkmode in
531711a29bacSmrg    lib)
531811a29bacSmrg	passes="conv dlpreopen link"
531911a29bacSmrg	for file in $dlfiles $dlprefiles; do
532011a29bacSmrg	  case $file in
532111a29bacSmrg	  *.la) ;;
532211a29bacSmrg	  *)
532311a29bacSmrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
532411a29bacSmrg	    ;;
532511a29bacSmrg	  esac
532611a29bacSmrg	done
532711a29bacSmrg	;;
532811a29bacSmrg    prog)
532911a29bacSmrg	compile_deplibs=
533011a29bacSmrg	finalize_deplibs=
533111a29bacSmrg	alldeplibs=no
533211a29bacSmrg	newdlfiles=
533311a29bacSmrg	newdlprefiles=
533411a29bacSmrg	passes="conv scan dlopen dlpreopen link"
533511a29bacSmrg	;;
533611a29bacSmrg    *)  passes="conv"
533711a29bacSmrg	;;
533811a29bacSmrg    esac
533911a29bacSmrg
534011a29bacSmrg    for pass in $passes; do
534111a29bacSmrg      # The preopen pass in lib mode reverses $deplibs; put it back here
534211a29bacSmrg      # so that -L comes before libs that need it for instance...
534311a29bacSmrg      if test "$linkmode,$pass" = "lib,link"; then
534411a29bacSmrg	## FIXME: Find the place where the list is rebuilt in the wrong
534511a29bacSmrg	##        order, and fix it there properly
534611a29bacSmrg        tmp_deplibs=
534711a29bacSmrg	for deplib in $deplibs; do
534811a29bacSmrg	  tmp_deplibs="$deplib $tmp_deplibs"
534911a29bacSmrg	done
535011a29bacSmrg	deplibs="$tmp_deplibs"
535111a29bacSmrg      fi
535211a29bacSmrg
535311a29bacSmrg      if test "$linkmode,$pass" = "lib,link" ||
535411a29bacSmrg	 test "$linkmode,$pass" = "prog,scan"; then
535511a29bacSmrg	libs="$deplibs"
535611a29bacSmrg	deplibs=
535711a29bacSmrg      fi
535811a29bacSmrg      if test "$linkmode" = prog; then
535911a29bacSmrg	case $pass in
536011a29bacSmrg	dlopen) libs="$dlfiles" ;;
536111a29bacSmrg	dlpreopen) libs="$dlprefiles" ;;
536211a29bacSmrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
536311a29bacSmrg	esac
536411a29bacSmrg      fi
536511a29bacSmrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
536611a29bacSmrg	# Collect and forward deplibs of preopened libtool libs
536711a29bacSmrg	for lib in $dlprefiles; do
536811a29bacSmrg	  # Ignore non-libtool-libs
536911a29bacSmrg	  dependency_libs=
537011a29bacSmrg	  case $lib in
537111a29bacSmrg	  *.la)	func_source "$lib" ;;
537211a29bacSmrg	  esac
537311a29bacSmrg
537411a29bacSmrg	  # Collect preopened libtool deplibs, except any this library
537511a29bacSmrg	  # has declared as weak libs
537611a29bacSmrg	  for deplib in $dependency_libs; do
537711a29bacSmrg	    func_basename "$deplib"
537811a29bacSmrg            deplib_base=$func_basename_result
537911a29bacSmrg	    case " $weak_libs " in
538011a29bacSmrg	    *" $deplib_base "*) ;;
538111a29bacSmrg	    *) deplibs="$deplibs $deplib" ;;
538211a29bacSmrg	    esac
538311a29bacSmrg	  done
538411a29bacSmrg	done
538511a29bacSmrg	libs="$dlprefiles"
538611a29bacSmrg      fi
538711a29bacSmrg      if test "$pass" = dlopen; then
538811a29bacSmrg	# Collect dlpreopened libraries
538911a29bacSmrg	save_deplibs="$deplibs"
539011a29bacSmrg	deplibs=
539111a29bacSmrg      fi
539211a29bacSmrg
539311a29bacSmrg      for deplib in $libs; do
539411a29bacSmrg	lib=
539511a29bacSmrg	found=no
539611a29bacSmrg	case $deplib in
539711a29bacSmrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
539811a29bacSmrg	  if test "$linkmode,$pass" = "prog,link"; then
539911a29bacSmrg	    compile_deplibs="$deplib $compile_deplibs"
540011a29bacSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
540111a29bacSmrg	  else
540211a29bacSmrg	    compiler_flags="$compiler_flags $deplib"
540311a29bacSmrg	    if test "$linkmode" = lib ; then
540411a29bacSmrg		case "$new_inherited_linker_flags " in
540511a29bacSmrg		    *" $deplib "*) ;;
540611a29bacSmrg		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
540711a29bacSmrg		esac
540811a29bacSmrg	    fi
540911a29bacSmrg	  fi
541011a29bacSmrg	  continue
541111a29bacSmrg	  ;;
541211a29bacSmrg	-l*)
541311a29bacSmrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
541411a29bacSmrg	    func_warning "\`-l' is ignored for archives/objects"
541511a29bacSmrg	    continue
541611a29bacSmrg	  fi
541711a29bacSmrg	  func_stripname '-l' '' "$deplib"
541811a29bacSmrg	  name=$func_stripname_result
541911a29bacSmrg	  if test "$linkmode" = lib; then
542011a29bacSmrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
542111a29bacSmrg	  else
542211a29bacSmrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
542311a29bacSmrg	  fi
542411a29bacSmrg	  for searchdir in $searchdirs; do
542511a29bacSmrg	    for search_ext in .la $std_shrext .so .a; do
542611a29bacSmrg	      # Search the libtool library
542711a29bacSmrg	      lib="$searchdir/lib${name}${search_ext}"
542811a29bacSmrg	      if test -f "$lib"; then
542911a29bacSmrg		if test "$search_ext" = ".la"; then
543011a29bacSmrg		  found=yes
543111a29bacSmrg		else
543211a29bacSmrg		  found=no
543311a29bacSmrg		fi
543411a29bacSmrg		break 2
543511a29bacSmrg	      fi
543611a29bacSmrg	    done
543711a29bacSmrg	  done
543811a29bacSmrg	  if test "$found" != yes; then
543911a29bacSmrg	    # deplib doesn't seem to be a libtool library
544011a29bacSmrg	    if test "$linkmode,$pass" = "prog,link"; then
544111a29bacSmrg	      compile_deplibs="$deplib $compile_deplibs"
544211a29bacSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
544311a29bacSmrg	    else
544411a29bacSmrg	      deplibs="$deplib $deplibs"
544511a29bacSmrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
544611a29bacSmrg	    fi
544711a29bacSmrg	    continue
544811a29bacSmrg	  else # deplib is a libtool library
544911a29bacSmrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
545011a29bacSmrg	    # We need to do some special things here, and not later.
545111a29bacSmrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
545211a29bacSmrg	      case " $predeps $postdeps " in
545311a29bacSmrg	      *" $deplib "*)
545411a29bacSmrg		if func_lalib_p "$lib"; then
545511a29bacSmrg		  library_names=
545611a29bacSmrg		  old_library=
545711a29bacSmrg		  func_source "$lib"
545811a29bacSmrg		  for l in $old_library $library_names; do
545911a29bacSmrg		    ll="$l"
546011a29bacSmrg		  done
546111a29bacSmrg		  if test "X$ll" = "X$old_library" ; then # only static version available
546211a29bacSmrg		    found=no
546311a29bacSmrg		    func_dirname "$lib" "" "."
546411a29bacSmrg		    ladir="$func_dirname_result"
546511a29bacSmrg		    lib=$ladir/$old_library
546611a29bacSmrg		    if test "$linkmode,$pass" = "prog,link"; then
546711a29bacSmrg		      compile_deplibs="$deplib $compile_deplibs"
546811a29bacSmrg		      finalize_deplibs="$deplib $finalize_deplibs"
546911a29bacSmrg		    else
547011a29bacSmrg		      deplibs="$deplib $deplibs"
547111a29bacSmrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
547211a29bacSmrg		    fi
547311a29bacSmrg		    continue
547411a29bacSmrg		  fi
547511a29bacSmrg		fi
547611a29bacSmrg		;;
547711a29bacSmrg	      *) ;;
547811a29bacSmrg	      esac
547911a29bacSmrg	    fi
548011a29bacSmrg	  fi
548111a29bacSmrg	  ;; # -l
548211a29bacSmrg	*.ltframework)
548311a29bacSmrg	  if test "$linkmode,$pass" = "prog,link"; then
548411a29bacSmrg	    compile_deplibs="$deplib $compile_deplibs"
548511a29bacSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
548611a29bacSmrg	  else
548711a29bacSmrg	    deplibs="$deplib $deplibs"
548811a29bacSmrg	    if test "$linkmode" = lib ; then
548911a29bacSmrg		case "$new_inherited_linker_flags " in
549011a29bacSmrg		    *" $deplib "*) ;;
549111a29bacSmrg		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
549211a29bacSmrg		esac
549311a29bacSmrg	    fi
549411a29bacSmrg	  fi
549511a29bacSmrg	  continue
549611a29bacSmrg	  ;;
549711a29bacSmrg	-L*)
549811a29bacSmrg	  case $linkmode in
549911a29bacSmrg	  lib)
550011a29bacSmrg	    deplibs="$deplib $deplibs"
550111a29bacSmrg	    test "$pass" = conv && continue
550211a29bacSmrg	    newdependency_libs="$deplib $newdependency_libs"
550311a29bacSmrg	    func_stripname '-L' '' "$deplib"
550411a29bacSmrg	    newlib_search_path="$newlib_search_path $func_stripname_result"
550511a29bacSmrg	    ;;
550611a29bacSmrg	  prog)
550711a29bacSmrg	    if test "$pass" = conv; then
550811a29bacSmrg	      deplibs="$deplib $deplibs"
550911a29bacSmrg	      continue
551011a29bacSmrg	    fi
551111a29bacSmrg	    if test "$pass" = scan; then
551211a29bacSmrg	      deplibs="$deplib $deplibs"
551311a29bacSmrg	    else
551411a29bacSmrg	      compile_deplibs="$deplib $compile_deplibs"
551511a29bacSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
551611a29bacSmrg	    fi
551711a29bacSmrg	    func_stripname '-L' '' "$deplib"
551811a29bacSmrg	    newlib_search_path="$newlib_search_path $func_stripname_result"
551911a29bacSmrg	    ;;
552011a29bacSmrg	  *)
552111a29bacSmrg	    func_warning "\`-L' is ignored for archives/objects"
552211a29bacSmrg	    ;;
552311a29bacSmrg	  esac # linkmode
552411a29bacSmrg	  continue
552511a29bacSmrg	  ;; # -L
552611a29bacSmrg	-R*)
552711a29bacSmrg	  if test "$pass" = link; then
552811a29bacSmrg	    func_stripname '-R' '' "$deplib"
552911a29bacSmrg	    dir=$func_stripname_result
553011a29bacSmrg	    # Make sure the xrpath contains only unique directories.
553111a29bacSmrg	    case "$xrpath " in
553211a29bacSmrg	    *" $dir "*) ;;
553311a29bacSmrg	    *) xrpath="$xrpath $dir" ;;
553411a29bacSmrg	    esac
553511a29bacSmrg	  fi
553611a29bacSmrg	  deplibs="$deplib $deplibs"
553711a29bacSmrg	  continue
553811a29bacSmrg	  ;;
553911a29bacSmrg	*.la) lib="$deplib" ;;
554011a29bacSmrg	*.$libext)
554111a29bacSmrg	  if test "$pass" = conv; then
554211a29bacSmrg	    deplibs="$deplib $deplibs"
554311a29bacSmrg	    continue
554411a29bacSmrg	  fi
554511a29bacSmrg	  case $linkmode in
554611a29bacSmrg	  lib)
554711a29bacSmrg	    # Linking convenience modules into shared libraries is allowed,
554811a29bacSmrg	    # but linking other static libraries is non-portable.
554911a29bacSmrg	    case " $dlpreconveniencelibs " in
555011a29bacSmrg	    *" $deplib "*) ;;
555111a29bacSmrg	    *)
555211a29bacSmrg	      valid_a_lib=no
555311a29bacSmrg	      case $deplibs_check_method in
555411a29bacSmrg		match_pattern*)
555511a29bacSmrg		  set dummy $deplibs_check_method; shift
555611a29bacSmrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
555711a29bacSmrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
555811a29bacSmrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
555911a29bacSmrg		    valid_a_lib=yes
556011a29bacSmrg		  fi
556111a29bacSmrg		;;
556211a29bacSmrg		pass_all)
556311a29bacSmrg		  valid_a_lib=yes
556411a29bacSmrg		;;
556511a29bacSmrg	      esac
556611a29bacSmrg	      if test "$valid_a_lib" != yes; then
556711a29bacSmrg		echo
556811a29bacSmrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
556911a29bacSmrg		echo "*** I have the capability to make that library automatically link in when"
557011a29bacSmrg		echo "*** you link to this library.  But I can only do this if you have a"
557111a29bacSmrg		echo "*** shared version of the library, which you do not appear to have"
557211a29bacSmrg		echo "*** because the file extensions .$libext of this argument makes me believe"
557311a29bacSmrg		echo "*** that it is just a static archive that I should not use here."
557411a29bacSmrg	      else
557511a29bacSmrg		echo
557611a29bacSmrg		$ECHO "*** Warning: Linking the shared library $output against the"
557711a29bacSmrg		$ECHO "*** static library $deplib is not portable!"
557811a29bacSmrg		deplibs="$deplib $deplibs"
557911a29bacSmrg	      fi
558011a29bacSmrg	      ;;
558111a29bacSmrg	    esac
558211a29bacSmrg	    continue
558311a29bacSmrg	    ;;
558411a29bacSmrg	  prog)
558511a29bacSmrg	    if test "$pass" != link; then
558611a29bacSmrg	      deplibs="$deplib $deplibs"
558711a29bacSmrg	    else
558811a29bacSmrg	      compile_deplibs="$deplib $compile_deplibs"
558911a29bacSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
559011a29bacSmrg	    fi
559111a29bacSmrg	    continue
559211a29bacSmrg	    ;;
559311a29bacSmrg	  esac # linkmode
559411a29bacSmrg	  ;; # *.$libext
559511a29bacSmrg	*.lo | *.$objext)
559611a29bacSmrg	  if test "$pass" = conv; then
559711a29bacSmrg	    deplibs="$deplib $deplibs"
559811a29bacSmrg	  elif test "$linkmode" = prog; then
559911a29bacSmrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
560011a29bacSmrg	      # If there is no dlopen support or we're linking statically,
560111a29bacSmrg	      # we need to preload.
560211a29bacSmrg	      newdlprefiles="$newdlprefiles $deplib"
560311a29bacSmrg	      compile_deplibs="$deplib $compile_deplibs"
560411a29bacSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
560511a29bacSmrg	    else
560611a29bacSmrg	      newdlfiles="$newdlfiles $deplib"
560711a29bacSmrg	    fi
560811a29bacSmrg	  fi
560911a29bacSmrg	  continue
561011a29bacSmrg	  ;;
561111a29bacSmrg	%DEPLIBS%)
561211a29bacSmrg	  alldeplibs=yes
561311a29bacSmrg	  continue
561411a29bacSmrg	  ;;
561511a29bacSmrg	esac # case $deplib
561611a29bacSmrg
561711a29bacSmrg	if test "$found" = yes || test -f "$lib"; then :
561811a29bacSmrg	else
561911a29bacSmrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
562011a29bacSmrg	fi
562111a29bacSmrg
562211a29bacSmrg	# Check to see that this really is a libtool archive.
562311a29bacSmrg	func_lalib_unsafe_p "$lib" \
562411a29bacSmrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
562511a29bacSmrg
562611a29bacSmrg	func_dirname "$lib" "" "."
562711a29bacSmrg	ladir="$func_dirname_result"
562811a29bacSmrg
562911a29bacSmrg	dlname=
563011a29bacSmrg	dlopen=
563111a29bacSmrg	dlpreopen=
563211a29bacSmrg	libdir=
563311a29bacSmrg	library_names=
563411a29bacSmrg	old_library=
563511a29bacSmrg	inherited_linker_flags=
563611a29bacSmrg	# If the library was installed with an old release of libtool,
563711a29bacSmrg	# it will not redefine variables installed, or shouldnotlink
563811a29bacSmrg	installed=yes
563911a29bacSmrg	shouldnotlink=no
564011a29bacSmrg	avoidtemprpath=
564111a29bacSmrg
564211a29bacSmrg
564311a29bacSmrg	# Read the .la file
564411a29bacSmrg	func_source "$lib"
564511a29bacSmrg
564611a29bacSmrg	# Convert "-framework foo" to "foo.ltframework"
564711a29bacSmrg	if test -n "$inherited_linker_flags"; then
564811a29bacSmrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
564911a29bacSmrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
565011a29bacSmrg	    case " $new_inherited_linker_flags " in
565111a29bacSmrg	      *" $tmp_inherited_linker_flag "*) ;;
565211a29bacSmrg	      *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
565311a29bacSmrg	    esac
565411a29bacSmrg	  done
565511a29bacSmrg	fi
565611a29bacSmrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
565711a29bacSmrg	if test "$linkmode,$pass" = "lib,link" ||
565811a29bacSmrg	   test "$linkmode,$pass" = "prog,scan" ||
565911a29bacSmrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
566011a29bacSmrg	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
566111a29bacSmrg	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
566211a29bacSmrg	fi
566311a29bacSmrg
566411a29bacSmrg	if test "$pass" = conv; then
566511a29bacSmrg	  # Only check for convenience libraries
566611a29bacSmrg	  deplibs="$lib $deplibs"
566711a29bacSmrg	  if test -z "$libdir"; then
566811a29bacSmrg	    if test -z "$old_library"; then
566911a29bacSmrg	      func_fatal_error "cannot find name of link library for \`$lib'"
567011a29bacSmrg	    fi
567111a29bacSmrg	    # It is a libtool convenience library, so add in its objects.
567211a29bacSmrg	    convenience="$convenience $ladir/$objdir/$old_library"
567311a29bacSmrg	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
567411a29bacSmrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
567511a29bacSmrg	    func_fatal_error "\`$lib' is not a convenience library"
567611a29bacSmrg	  fi
567711a29bacSmrg	  tmp_libs=
567811a29bacSmrg	  for deplib in $dependency_libs; do
567911a29bacSmrg	    deplibs="$deplib $deplibs"
568011a29bacSmrg	    if $opt_duplicate_deps ; then
568111a29bacSmrg	      case "$tmp_libs " in
568211a29bacSmrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
568311a29bacSmrg	      esac
568411a29bacSmrg	    fi
568511a29bacSmrg	    tmp_libs="$tmp_libs $deplib"
568611a29bacSmrg	  done
568711a29bacSmrg	  continue
568811a29bacSmrg	fi # $pass = conv
568911a29bacSmrg
569011a29bacSmrg
569111a29bacSmrg	# Get the name of the library we link against.
569211a29bacSmrg	linklib=
569311a29bacSmrg	for l in $old_library $library_names; do
569411a29bacSmrg	  linklib="$l"
569511a29bacSmrg	done
569611a29bacSmrg	if test -z "$linklib"; then
569711a29bacSmrg	  func_fatal_error "cannot find name of link library for \`$lib'"
569811a29bacSmrg	fi
569911a29bacSmrg
570011a29bacSmrg	# This library was specified with -dlopen.
570111a29bacSmrg	if test "$pass" = dlopen; then
570211a29bacSmrg	  if test -z "$libdir"; then
570311a29bacSmrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
570411a29bacSmrg	  fi
570511a29bacSmrg	  if test -z "$dlname" ||
570611a29bacSmrg	     test "$dlopen_support" != yes ||
570711a29bacSmrg	     test "$build_libtool_libs" = no; then
570811a29bacSmrg	    # If there is no dlname, no dlopen support or we're linking
570911a29bacSmrg	    # statically, we need to preload.  We also need to preload any
571011a29bacSmrg	    # dependent libraries so libltdl's deplib preloader doesn't
571111a29bacSmrg	    # bomb out in the load deplibs phase.
571211a29bacSmrg	    dlprefiles="$dlprefiles $lib $dependency_libs"
571311a29bacSmrg	  else
571411a29bacSmrg	    newdlfiles="$newdlfiles $lib"
571511a29bacSmrg	  fi
571611a29bacSmrg	  continue
571711a29bacSmrg	fi # $pass = dlopen
571811a29bacSmrg
571911a29bacSmrg	# We need an absolute path.
572011a29bacSmrg	case $ladir in
572111a29bacSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
572211a29bacSmrg	*)
572311a29bacSmrg	  abs_ladir=`cd "$ladir" && pwd`
572411a29bacSmrg	  if test -z "$abs_ladir"; then
572511a29bacSmrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
572611a29bacSmrg	    func_warning "passing it literally to the linker, although it might fail"
572711a29bacSmrg	    abs_ladir="$ladir"
572811a29bacSmrg	  fi
572911a29bacSmrg	  ;;
573011a29bacSmrg	esac
573111a29bacSmrg	func_basename "$lib"
573211a29bacSmrg	laname="$func_basename_result"
573311a29bacSmrg
573411a29bacSmrg	# Find the relevant object directory and library name.
573511a29bacSmrg	if test "X$installed" = Xyes; then
573611a29bacSmrg	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
573711a29bacSmrg	    func_warning "library \`$lib' was moved."
573811a29bacSmrg	    dir="$ladir"
573911a29bacSmrg	    absdir="$abs_ladir"
574011a29bacSmrg	    libdir="$abs_ladir"
574111a29bacSmrg	  else
574211a29bacSmrg	    dir="$libdir"
574311a29bacSmrg	    absdir="$libdir"
574411a29bacSmrg	  fi
574511a29bacSmrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
574611a29bacSmrg	else
574711a29bacSmrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
574811a29bacSmrg	    dir="$ladir"
574911a29bacSmrg	    absdir="$abs_ladir"
575011a29bacSmrg	    # Remove this search path later
575111a29bacSmrg	    notinst_path="$notinst_path $abs_ladir"
575211a29bacSmrg	  else
575311a29bacSmrg	    dir="$ladir/$objdir"
575411a29bacSmrg	    absdir="$abs_ladir/$objdir"
575511a29bacSmrg	    # Remove this search path later
575611a29bacSmrg	    notinst_path="$notinst_path $abs_ladir"
575711a29bacSmrg	  fi
575811a29bacSmrg	fi # $installed = yes
575911a29bacSmrg	func_stripname 'lib' '.la' "$laname"
576011a29bacSmrg	name=$func_stripname_result
576111a29bacSmrg
576211a29bacSmrg	# This library was specified with -dlpreopen.
576311a29bacSmrg	if test "$pass" = dlpreopen; then
576411a29bacSmrg	  if test -z "$libdir" && test "$linkmode" = prog; then
576511a29bacSmrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
576611a29bacSmrg	  fi
576711a29bacSmrg	  # Prefer using a static library (so that no silly _DYNAMIC symbols
576811a29bacSmrg	  # are required to link).
576911a29bacSmrg	  if test -n "$old_library"; then
577011a29bacSmrg	    newdlprefiles="$newdlprefiles $dir/$old_library"
577111a29bacSmrg	    # Keep a list of preopened convenience libraries to check
577211a29bacSmrg	    # that they are being used correctly in the link pass.
577311a29bacSmrg	    test -z "$libdir" && \
577411a29bacSmrg		dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
577511a29bacSmrg	  # Otherwise, use the dlname, so that lt_dlopen finds it.
577611a29bacSmrg	  elif test -n "$dlname"; then
577711a29bacSmrg	    newdlprefiles="$newdlprefiles $dir/$dlname"
577811a29bacSmrg	  else
577911a29bacSmrg	    newdlprefiles="$newdlprefiles $dir/$linklib"
578011a29bacSmrg	  fi
578111a29bacSmrg	fi # $pass = dlpreopen
578211a29bacSmrg
578311a29bacSmrg	if test -z "$libdir"; then
578411a29bacSmrg	  # Link the convenience library
578511a29bacSmrg	  if test "$linkmode" = lib; then
578611a29bacSmrg	    deplibs="$dir/$old_library $deplibs"
578711a29bacSmrg	  elif test "$linkmode,$pass" = "prog,link"; then
578811a29bacSmrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
578911a29bacSmrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
579011a29bacSmrg	  else
579111a29bacSmrg	    deplibs="$lib $deplibs" # used for prog,scan pass
579211a29bacSmrg	  fi
579311a29bacSmrg	  continue
579411a29bacSmrg	fi
579511a29bacSmrg
579611a29bacSmrg
579711a29bacSmrg	if test "$linkmode" = prog && test "$pass" != link; then
579811a29bacSmrg	  newlib_search_path="$newlib_search_path $ladir"
579911a29bacSmrg	  deplibs="$lib $deplibs"
580011a29bacSmrg
580111a29bacSmrg	  linkalldeplibs=no
580211a29bacSmrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
580311a29bacSmrg	     test "$build_libtool_libs" = no; then
580411a29bacSmrg	    linkalldeplibs=yes
580511a29bacSmrg	  fi
580611a29bacSmrg
580711a29bacSmrg	  tmp_libs=
580811a29bacSmrg	  for deplib in $dependency_libs; do
580911a29bacSmrg	    case $deplib in
581011a29bacSmrg	    -L*) func_stripname '-L' '' "$deplib"
581111a29bacSmrg	         newlib_search_path="$newlib_search_path $func_stripname_result"
581211a29bacSmrg		 ;;
581311a29bacSmrg	    esac
581411a29bacSmrg	    # Need to link against all dependency_libs?
581511a29bacSmrg	    if test "$linkalldeplibs" = yes; then
581611a29bacSmrg	      deplibs="$deplib $deplibs"
581711a29bacSmrg	    else
581811a29bacSmrg	      # Need to hardcode shared library paths
581911a29bacSmrg	      # or/and link against static libraries
582011a29bacSmrg	      newdependency_libs="$deplib $newdependency_libs"
582111a29bacSmrg	    fi
582211a29bacSmrg	    if $opt_duplicate_deps ; then
582311a29bacSmrg	      case "$tmp_libs " in
582411a29bacSmrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
582511a29bacSmrg	      esac
582611a29bacSmrg	    fi
582711a29bacSmrg	    tmp_libs="$tmp_libs $deplib"
582811a29bacSmrg	  done # for deplib
582911a29bacSmrg	  continue
583011a29bacSmrg	fi # $linkmode = prog...
583111a29bacSmrg
583211a29bacSmrg	if test "$linkmode,$pass" = "prog,link"; then
583311a29bacSmrg	  if test -n "$library_names" &&
583411a29bacSmrg	     { { test "$prefer_static_libs" = no ||
583511a29bacSmrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
583611a29bacSmrg	       test -z "$old_library"; }; then
583711a29bacSmrg	    # We need to hardcode the library path
583811a29bacSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
583911a29bacSmrg	      # Make sure the rpath contains only unique directories.
584011a29bacSmrg	      case "$temp_rpath:" in
584111a29bacSmrg	      *"$absdir:"*) ;;
584211a29bacSmrg	      *) temp_rpath="$temp_rpath$absdir:" ;;
584311a29bacSmrg	      esac
584411a29bacSmrg	    fi
584511a29bacSmrg
584611a29bacSmrg	    # Hardcode the library path.
584711a29bacSmrg	    # Skip directories that are in the system default run-time
584811a29bacSmrg	    # search path.
584911a29bacSmrg	    case " $sys_lib_dlsearch_path " in
585011a29bacSmrg	    *" $absdir "*) ;;
585111a29bacSmrg	    *)
585211a29bacSmrg	      case "$compile_rpath " in
585311a29bacSmrg	      *" $absdir "*) ;;
585411a29bacSmrg	      *) compile_rpath="$compile_rpath $absdir"
585511a29bacSmrg	      esac
585611a29bacSmrg	      ;;
585711a29bacSmrg	    esac
585811a29bacSmrg	    case " $sys_lib_dlsearch_path " in
585911a29bacSmrg	    *" $libdir "*) ;;
586011a29bacSmrg	    *)
586111a29bacSmrg	      case "$finalize_rpath " in
586211a29bacSmrg	      *" $libdir "*) ;;
586311a29bacSmrg	      *) finalize_rpath="$finalize_rpath $libdir"
586411a29bacSmrg	      esac
586511a29bacSmrg	      ;;
586611a29bacSmrg	    esac
586711a29bacSmrg	  fi # $linkmode,$pass = prog,link...
586811a29bacSmrg
586911a29bacSmrg	  if test "$alldeplibs" = yes &&
587011a29bacSmrg	     { test "$deplibs_check_method" = pass_all ||
587111a29bacSmrg	       { test "$build_libtool_libs" = yes &&
587211a29bacSmrg		 test -n "$library_names"; }; }; then
587311a29bacSmrg	    # We only need to search for static libraries
587411a29bacSmrg	    continue
587511a29bacSmrg	  fi
587611a29bacSmrg	fi
587711a29bacSmrg
587811a29bacSmrg	link_static=no # Whether the deplib will be linked statically
587911a29bacSmrg	use_static_libs=$prefer_static_libs
588011a29bacSmrg	if test "$use_static_libs" = built && test "$installed" = yes; then
588111a29bacSmrg	  use_static_libs=no
588211a29bacSmrg	fi
588311a29bacSmrg	if test -n "$library_names" &&
588411a29bacSmrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
588511a29bacSmrg	  case $host in
588611a29bacSmrg	  *cygwin* | *mingw* | *cegcc*)
588711a29bacSmrg	      # No point in relinking DLLs because paths are not encoded
588811a29bacSmrg	      notinst_deplibs="$notinst_deplibs $lib"
588911a29bacSmrg	      need_relink=no
589011a29bacSmrg	    ;;
589111a29bacSmrg	  *)
589211a29bacSmrg	    if test "$installed" = no; then
589311a29bacSmrg	      notinst_deplibs="$notinst_deplibs $lib"
589411a29bacSmrg	      need_relink=yes
589511a29bacSmrg	    fi
589611a29bacSmrg	    ;;
589711a29bacSmrg	  esac
589811a29bacSmrg	  # This is a shared library
589911a29bacSmrg
590011a29bacSmrg	  # Warn about portability, can't link against -module's on some
590111a29bacSmrg	  # systems (darwin).  Don't bleat about dlopened modules though!
590211a29bacSmrg	  dlopenmodule=""
590311a29bacSmrg	  for dlpremoduletest in $dlprefiles; do
590411a29bacSmrg	    if test "X$dlpremoduletest" = "X$lib"; then
590511a29bacSmrg	      dlopenmodule="$dlpremoduletest"
590611a29bacSmrg	      break
590711a29bacSmrg	    fi
590811a29bacSmrg	  done
590911a29bacSmrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
591011a29bacSmrg	    echo
591111a29bacSmrg	    if test "$linkmode" = prog; then
591211a29bacSmrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
591311a29bacSmrg	    else
591411a29bacSmrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
591511a29bacSmrg	    fi
591611a29bacSmrg	    $ECHO "*** $linklib is not portable!"
591711a29bacSmrg	  fi
591811a29bacSmrg	  if test "$linkmode" = lib &&
591911a29bacSmrg	     test "$hardcode_into_libs" = yes; then
592011a29bacSmrg	    # Hardcode the library path.
592111a29bacSmrg	    # Skip directories that are in the system default run-time
592211a29bacSmrg	    # search path.
592311a29bacSmrg	    case " $sys_lib_dlsearch_path " in
592411a29bacSmrg	    *" $absdir "*) ;;
592511a29bacSmrg	    *)
592611a29bacSmrg	      case "$compile_rpath " in
592711a29bacSmrg	      *" $absdir "*) ;;
592811a29bacSmrg	      *) compile_rpath="$compile_rpath $absdir"
592911a29bacSmrg	      esac
593011a29bacSmrg	      ;;
593111a29bacSmrg	    esac
593211a29bacSmrg	    case " $sys_lib_dlsearch_path " in
593311a29bacSmrg	    *" $libdir "*) ;;
593411a29bacSmrg	    *)
593511a29bacSmrg	      case "$finalize_rpath " in
593611a29bacSmrg	      *" $libdir "*) ;;
593711a29bacSmrg	      *) finalize_rpath="$finalize_rpath $libdir"
593811a29bacSmrg	      esac
593911a29bacSmrg	      ;;
594011a29bacSmrg	    esac
594111a29bacSmrg	  fi
594211a29bacSmrg
594311a29bacSmrg	  if test -n "$old_archive_from_expsyms_cmds"; then
594411a29bacSmrg	    # figure out the soname
594511a29bacSmrg	    set dummy $library_names
594611a29bacSmrg	    shift
594711a29bacSmrg	    realname="$1"
594811a29bacSmrg	    shift
594911a29bacSmrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
595011a29bacSmrg	    # use dlname if we got it. it's perfectly good, no?
595111a29bacSmrg	    if test -n "$dlname"; then
595211a29bacSmrg	      soname="$dlname"
595311a29bacSmrg	    elif test -n "$soname_spec"; then
595411a29bacSmrg	      # bleh windows
595511a29bacSmrg	      case $host in
595611a29bacSmrg	      *cygwin* | mingw* | *cegcc*)
595711a29bacSmrg	        func_arith $current - $age
595811a29bacSmrg		major=$func_arith_result
595911a29bacSmrg		versuffix="-$major"
596011a29bacSmrg		;;
596111a29bacSmrg	      esac
596211a29bacSmrg	      eval soname=\"$soname_spec\"
596311a29bacSmrg	    else
596411a29bacSmrg	      soname="$realname"
596511a29bacSmrg	    fi
596611a29bacSmrg
596711a29bacSmrg	    # Make a new name for the extract_expsyms_cmds to use
596811a29bacSmrg	    soroot="$soname"
596911a29bacSmrg	    func_basename "$soroot"
597011a29bacSmrg	    soname="$func_basename_result"
597111a29bacSmrg	    func_stripname 'lib' '.dll' "$soname"
597211a29bacSmrg	    newlib=libimp-$func_stripname_result.a
597311a29bacSmrg
597411a29bacSmrg	    # If the library has no export list, then create one now
597511a29bacSmrg	    if test -f "$output_objdir/$soname-def"; then :
597611a29bacSmrg	    else
597711a29bacSmrg	      func_verbose "extracting exported symbol list from \`$soname'"
597811a29bacSmrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
597911a29bacSmrg	    fi
598011a29bacSmrg
598111a29bacSmrg	    # Create $newlib
598211a29bacSmrg	    if test -f "$output_objdir/$newlib"; then :; else
598311a29bacSmrg	      func_verbose "generating import library for \`$soname'"
598411a29bacSmrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
598511a29bacSmrg	    fi
598611a29bacSmrg	    # make sure the library variables are pointing to the new library
598711a29bacSmrg	    dir=$output_objdir
598811a29bacSmrg	    linklib=$newlib
598911a29bacSmrg	  fi # test -n "$old_archive_from_expsyms_cmds"
599011a29bacSmrg
599111a29bacSmrg	  if test "$linkmode" = prog || test "$mode" != relink; then
599211a29bacSmrg	    add_shlibpath=
599311a29bacSmrg	    add_dir=
599411a29bacSmrg	    add=
599511a29bacSmrg	    lib_linked=yes
599611a29bacSmrg	    case $hardcode_action in
599711a29bacSmrg	    immediate | unsupported)
599811a29bacSmrg	      if test "$hardcode_direct" = no; then
599911a29bacSmrg		add="$dir/$linklib"
600011a29bacSmrg		case $host in
600111a29bacSmrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
600211a29bacSmrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
600311a29bacSmrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
600411a29bacSmrg		    *-*-unixware7*) add_dir="-L$dir" ;;
600511a29bacSmrg		  *-*-darwin* )
600611a29bacSmrg		    # if the lib is a (non-dlopened) module then we can not
600711a29bacSmrg		    # link against it, someone is ignoring the earlier warnings
600811a29bacSmrg		    if /usr/bin/file -L $add 2> /dev/null |
600911a29bacSmrg			 $GREP ": [^:]* bundle" >/dev/null ; then
601011a29bacSmrg		      if test "X$dlopenmodule" != "X$lib"; then
601111a29bacSmrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
601211a29bacSmrg			if test -z "$old_library" ; then
601311a29bacSmrg			  echo
601411a29bacSmrg			  echo "*** And there doesn't seem to be a static archive available"
601511a29bacSmrg			  echo "*** The link will probably fail, sorry"
601611a29bacSmrg			else
601711a29bacSmrg			  add="$dir/$old_library"
601811a29bacSmrg			fi
601911a29bacSmrg		      elif test -n "$old_library"; then
602011a29bacSmrg			add="$dir/$old_library"
602111a29bacSmrg		      fi
602211a29bacSmrg		    fi
602311a29bacSmrg		esac
602411a29bacSmrg	      elif test "$hardcode_minus_L" = no; then
602511a29bacSmrg		case $host in
602611a29bacSmrg		*-*-sunos*) add_shlibpath="$dir" ;;
602711a29bacSmrg		esac
602811a29bacSmrg		add_dir="-L$dir"
602911a29bacSmrg		add="-l$name"
603011a29bacSmrg	      elif test "$hardcode_shlibpath_var" = no; then
603111a29bacSmrg		add_shlibpath="$dir"
603211a29bacSmrg		add="-l$name"
603311a29bacSmrg	      else
603411a29bacSmrg		lib_linked=no
603511a29bacSmrg	      fi
603611a29bacSmrg	      ;;
603711a29bacSmrg	    relink)
603811a29bacSmrg	      if test "$hardcode_direct" = yes &&
603911a29bacSmrg	         test "$hardcode_direct_absolute" = no; then
604011a29bacSmrg		add="$dir/$linklib"
604111a29bacSmrg	      elif test "$hardcode_minus_L" = yes; then
604211a29bacSmrg		add_dir="-L$dir"
604311a29bacSmrg		# Try looking first in the location we're being installed to.
604411a29bacSmrg		if test -n "$inst_prefix_dir"; then
604511a29bacSmrg		  case $libdir in
604611a29bacSmrg		    [\\/]*)
604711a29bacSmrg		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
604811a29bacSmrg		      ;;
604911a29bacSmrg		  esac
605011a29bacSmrg		fi
605111a29bacSmrg		add="-l$name"
605211a29bacSmrg	      elif test "$hardcode_shlibpath_var" = yes; then
605311a29bacSmrg		add_shlibpath="$dir"
605411a29bacSmrg		add="-l$name"
605511a29bacSmrg	      else
605611a29bacSmrg		lib_linked=no
605711a29bacSmrg	      fi
605811a29bacSmrg	      ;;
605911a29bacSmrg	    *) lib_linked=no ;;
606011a29bacSmrg	    esac
606111a29bacSmrg
606211a29bacSmrg	    if test "$lib_linked" != yes; then
606311a29bacSmrg	      func_fatal_configuration "unsupported hardcode properties"
606411a29bacSmrg	    fi
606511a29bacSmrg
606611a29bacSmrg	    if test -n "$add_shlibpath"; then
606711a29bacSmrg	      case :$compile_shlibpath: in
606811a29bacSmrg	      *":$add_shlibpath:"*) ;;
606911a29bacSmrg	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
607011a29bacSmrg	      esac
607111a29bacSmrg	    fi
607211a29bacSmrg	    if test "$linkmode" = prog; then
607311a29bacSmrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
607411a29bacSmrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
607511a29bacSmrg	    else
607611a29bacSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
607711a29bacSmrg	      test -n "$add" && deplibs="$add $deplibs"
607811a29bacSmrg	      if test "$hardcode_direct" != yes &&
607911a29bacSmrg		 test "$hardcode_minus_L" != yes &&
608011a29bacSmrg		 test "$hardcode_shlibpath_var" = yes; then
608111a29bacSmrg		case :$finalize_shlibpath: in
608211a29bacSmrg		*":$libdir:"*) ;;
608311a29bacSmrg		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
608411a29bacSmrg		esac
608511a29bacSmrg	      fi
608611a29bacSmrg	    fi
608711a29bacSmrg	  fi
608811a29bacSmrg
608911a29bacSmrg	  if test "$linkmode" = prog || test "$mode" = relink; then
609011a29bacSmrg	    add_shlibpath=
609111a29bacSmrg	    add_dir=
609211a29bacSmrg	    add=
609311a29bacSmrg	    # Finalize command for both is simple: just hardcode it.
609411a29bacSmrg	    if test "$hardcode_direct" = yes &&
609511a29bacSmrg	       test "$hardcode_direct_absolute" = no; then
609611a29bacSmrg	      add="$libdir/$linklib"
609711a29bacSmrg	    elif test "$hardcode_minus_L" = yes; then
609811a29bacSmrg	      add_dir="-L$libdir"
609911a29bacSmrg	      add="-l$name"
610011a29bacSmrg	    elif test "$hardcode_shlibpath_var" = yes; then
610111a29bacSmrg	      case :$finalize_shlibpath: in
610211a29bacSmrg	      *":$libdir:"*) ;;
610311a29bacSmrg	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
610411a29bacSmrg	      esac
610511a29bacSmrg	      add="-l$name"
610611a29bacSmrg	    elif test "$hardcode_automatic" = yes; then
610711a29bacSmrg	      if test -n "$inst_prefix_dir" &&
610811a29bacSmrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
610911a29bacSmrg		add="$inst_prefix_dir$libdir/$linklib"
611011a29bacSmrg	      else
611111a29bacSmrg		add="$libdir/$linklib"
611211a29bacSmrg	      fi
611311a29bacSmrg	    else
611411a29bacSmrg	      # We cannot seem to hardcode it, guess we'll fake it.
611511a29bacSmrg	      add_dir="-L$libdir"
611611a29bacSmrg	      # Try looking first in the location we're being installed to.
611711a29bacSmrg	      if test -n "$inst_prefix_dir"; then
611811a29bacSmrg		case $libdir in
611911a29bacSmrg		  [\\/]*)
612011a29bacSmrg		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
612111a29bacSmrg		    ;;
612211a29bacSmrg		esac
612311a29bacSmrg	      fi
612411a29bacSmrg	      add="-l$name"
612511a29bacSmrg	    fi
612611a29bacSmrg
612711a29bacSmrg	    if test "$linkmode" = prog; then
612811a29bacSmrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
612911a29bacSmrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
613011a29bacSmrg	    else
613111a29bacSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
613211a29bacSmrg	      test -n "$add" && deplibs="$add $deplibs"
613311a29bacSmrg	    fi
613411a29bacSmrg	  fi
613511a29bacSmrg	elif test "$linkmode" = prog; then
613611a29bacSmrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
613711a29bacSmrg	  # is not unsupported.  This is valid on all known static and
613811a29bacSmrg	  # shared platforms.
613911a29bacSmrg	  if test "$hardcode_direct" != unsupported; then
614011a29bacSmrg	    test -n "$old_library" && linklib="$old_library"
614111a29bacSmrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
614211a29bacSmrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
614311a29bacSmrg	  else
614411a29bacSmrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
614511a29bacSmrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
614611a29bacSmrg	  fi
614711a29bacSmrg	elif test "$build_libtool_libs" = yes; then
614811a29bacSmrg	  # Not a shared library
614911a29bacSmrg	  if test "$deplibs_check_method" != pass_all; then
615011a29bacSmrg	    # We're trying link a shared library against a static one
615111a29bacSmrg	    # but the system doesn't support it.
615211a29bacSmrg
615311a29bacSmrg	    # Just print a warning and add the library to dependency_libs so
615411a29bacSmrg	    # that the program can be linked against the static library.
615511a29bacSmrg	    echo
615611a29bacSmrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
615711a29bacSmrg	    echo "*** I have the capability to make that library automatically link in when"
615811a29bacSmrg	    echo "*** you link to this library.  But I can only do this if you have a"
615911a29bacSmrg	    echo "*** shared version of the library, which you do not appear to have."
616011a29bacSmrg	    if test "$module" = yes; then
616111a29bacSmrg	      echo "*** But as you try to build a module library, libtool will still create "
616211a29bacSmrg	      echo "*** a static module, that should work as long as the dlopening application"
616311a29bacSmrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
616411a29bacSmrg	      if test -z "$global_symbol_pipe"; then
616511a29bacSmrg		echo
616611a29bacSmrg		echo "*** However, this would only work if libtool was able to extract symbol"
616711a29bacSmrg		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
616811a29bacSmrg		echo "*** not find such a program.  So, this module is probably useless."
616911a29bacSmrg		echo "*** \`nm' from GNU binutils and a full rebuild may help."
617011a29bacSmrg	      fi
617111a29bacSmrg	      if test "$build_old_libs" = no; then
617211a29bacSmrg		build_libtool_libs=module
617311a29bacSmrg		build_old_libs=yes
617411a29bacSmrg	      else
617511a29bacSmrg		build_libtool_libs=no
617611a29bacSmrg	      fi
617711a29bacSmrg	    fi
617811a29bacSmrg	  else
617911a29bacSmrg	    deplibs="$dir/$old_library $deplibs"
618011a29bacSmrg	    link_static=yes
618111a29bacSmrg	  fi
618211a29bacSmrg	fi # link shared/static library?
618311a29bacSmrg
618411a29bacSmrg	if test "$linkmode" = lib; then
618511a29bacSmrg	  if test -n "$dependency_libs" &&
618611a29bacSmrg	     { test "$hardcode_into_libs" != yes ||
618711a29bacSmrg	       test "$build_old_libs" = yes ||
618811a29bacSmrg	       test "$link_static" = yes; }; then
618911a29bacSmrg	    # Extract -R from dependency_libs
619011a29bacSmrg	    temp_deplibs=
619111a29bacSmrg	    for libdir in $dependency_libs; do
619211a29bacSmrg	      case $libdir in
619311a29bacSmrg	      -R*) func_stripname '-R' '' "$libdir"
619411a29bacSmrg	           temp_xrpath=$func_stripname_result
619511a29bacSmrg		   case " $xrpath " in
619611a29bacSmrg		   *" $temp_xrpath "*) ;;
619711a29bacSmrg		   *) xrpath="$xrpath $temp_xrpath";;
619811a29bacSmrg		   esac;;
619911a29bacSmrg	      *) temp_deplibs="$temp_deplibs $libdir";;
620011a29bacSmrg	      esac
620111a29bacSmrg	    done
620211a29bacSmrg	    dependency_libs="$temp_deplibs"
620311a29bacSmrg	  fi
620411a29bacSmrg
620511a29bacSmrg	  newlib_search_path="$newlib_search_path $absdir"
620611a29bacSmrg	  # Link against this library
620711a29bacSmrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
620811a29bacSmrg	  # ... and its dependency_libs
620911a29bacSmrg	  tmp_libs=
621011a29bacSmrg	  for deplib in $dependency_libs; do
621111a29bacSmrg	    newdependency_libs="$deplib $newdependency_libs"
621211a29bacSmrg	    if $opt_duplicate_deps ; then
621311a29bacSmrg	      case "$tmp_libs " in
621411a29bacSmrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
621511a29bacSmrg	      esac
621611a29bacSmrg	    fi
621711a29bacSmrg	    tmp_libs="$tmp_libs $deplib"
621811a29bacSmrg	  done
621911a29bacSmrg
622011a29bacSmrg	  if test "$link_all_deplibs" != no; then
622111a29bacSmrg	    # Add the search paths of all dependency libraries
622211a29bacSmrg	    for deplib in $dependency_libs; do
622311a29bacSmrg	      path=
622411a29bacSmrg	      case $deplib in
622511a29bacSmrg	      -L*) path="$deplib" ;;
622611a29bacSmrg	      *.la)
622711a29bacSmrg	        func_dirname "$deplib" "" "."
622811a29bacSmrg		dir="$func_dirname_result"
622911a29bacSmrg		# We need an absolute path.
623011a29bacSmrg		case $dir in
623111a29bacSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
623211a29bacSmrg		*)
623311a29bacSmrg		  absdir=`cd "$dir" && pwd`
623411a29bacSmrg		  if test -z "$absdir"; then
623511a29bacSmrg		    func_warning "cannot determine absolute directory name of \`$dir'"
623611a29bacSmrg		    absdir="$dir"
623711a29bacSmrg		  fi
623811a29bacSmrg		  ;;
623911a29bacSmrg		esac
624011a29bacSmrg		if $GREP "^installed=no" $deplib > /dev/null; then
624111a29bacSmrg		case $host in
624211a29bacSmrg		*-*-darwin*)
624311a29bacSmrg		  depdepl=
624411a29bacSmrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
624511a29bacSmrg		  if test -n "$deplibrary_names" ; then
624611a29bacSmrg		    for tmp in $deplibrary_names ; do
624711a29bacSmrg		      depdepl=$tmp
624811a29bacSmrg		    done
624911a29bacSmrg		    if test -f "$absdir/$objdir/$depdepl" ; then
625011a29bacSmrg		      depdepl="$absdir/$objdir/$depdepl"
625111a29bacSmrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
625211a29bacSmrg                      if test -z "$darwin_install_name"; then
625311a29bacSmrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
625411a29bacSmrg                      fi
625511a29bacSmrg		      compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
625611a29bacSmrg		      linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
625711a29bacSmrg		      path=
625811a29bacSmrg		    fi
625911a29bacSmrg		  fi
626011a29bacSmrg		  ;;
626111a29bacSmrg		*)
626211a29bacSmrg		  path="-L$absdir/$objdir"
626311a29bacSmrg		  ;;
626411a29bacSmrg		esac
626511a29bacSmrg		else
626611a29bacSmrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
626711a29bacSmrg		  test -z "$libdir" && \
626811a29bacSmrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
626911a29bacSmrg		  test "$absdir" != "$libdir" && \
627011a29bacSmrg		    func_warning "\`$deplib' seems to be moved"
627111a29bacSmrg
627211a29bacSmrg		  path="-L$absdir"
627311a29bacSmrg		fi
627411a29bacSmrg		;;
627511a29bacSmrg	      esac
627611a29bacSmrg	      case " $deplibs " in
627711a29bacSmrg	      *" $path "*) ;;
627811a29bacSmrg	      *) deplibs="$path $deplibs" ;;
627911a29bacSmrg	      esac
628011a29bacSmrg	    done
628111a29bacSmrg	  fi # link_all_deplibs != no
628211a29bacSmrg	fi # linkmode = lib
628311a29bacSmrg      done # for deplib in $libs
628411a29bacSmrg      if test "$pass" = link; then
628511a29bacSmrg	if test "$linkmode" = "prog"; then
628611a29bacSmrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
628711a29bacSmrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
628811a29bacSmrg	else
628911a29bacSmrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
629011a29bacSmrg	fi
629111a29bacSmrg      fi
629211a29bacSmrg      dependency_libs="$newdependency_libs"
629311a29bacSmrg      if test "$pass" = dlpreopen; then
629411a29bacSmrg	# Link the dlpreopened libraries before other libraries
629511a29bacSmrg	for deplib in $save_deplibs; do
629611a29bacSmrg	  deplibs="$deplib $deplibs"
629711a29bacSmrg	done
629811a29bacSmrg      fi
629911a29bacSmrg      if test "$pass" != dlopen; then
630011a29bacSmrg	if test "$pass" != conv; then
630111a29bacSmrg	  # Make sure lib_search_path contains only unique directories.
630211a29bacSmrg	  lib_search_path=
630311a29bacSmrg	  for dir in $newlib_search_path; do
630411a29bacSmrg	    case "$lib_search_path " in
630511a29bacSmrg	    *" $dir "*) ;;
630611a29bacSmrg	    *) lib_search_path="$lib_search_path $dir" ;;
630711a29bacSmrg	    esac
630811a29bacSmrg	  done
630911a29bacSmrg	  newlib_search_path=
631011a29bacSmrg	fi
631111a29bacSmrg
631211a29bacSmrg	if test "$linkmode,$pass" != "prog,link"; then
631311a29bacSmrg	  vars="deplibs"
631411a29bacSmrg	else
631511a29bacSmrg	  vars="compile_deplibs finalize_deplibs"
631611a29bacSmrg	fi
631711a29bacSmrg	for var in $vars dependency_libs; do
631811a29bacSmrg	  # Add libraries to $var in reverse order
631911a29bacSmrg	  eval tmp_libs=\"\$$var\"
632011a29bacSmrg	  new_libs=
632111a29bacSmrg	  for deplib in $tmp_libs; do
632211a29bacSmrg	    # FIXME: Pedantically, this is the right thing to do, so
632311a29bacSmrg	    #        that some nasty dependency loop isn't accidentally
632411a29bacSmrg	    #        broken:
632511a29bacSmrg	    #new_libs="$deplib $new_libs"
632611a29bacSmrg	    # Pragmatically, this seems to cause very few problems in
632711a29bacSmrg	    # practice:
632811a29bacSmrg	    case $deplib in
632911a29bacSmrg	    -L*) new_libs="$deplib $new_libs" ;;
633011a29bacSmrg	    -R*) ;;
633111a29bacSmrg	    *)
633211a29bacSmrg	      # And here is the reason: when a library appears more
633311a29bacSmrg	      # than once as an explicit dependence of a library, or
633411a29bacSmrg	      # is implicitly linked in more than once by the
633511a29bacSmrg	      # compiler, it is considered special, and multiple
633611a29bacSmrg	      # occurrences thereof are not removed.  Compare this
633711a29bacSmrg	      # with having the same library being listed as a
633811a29bacSmrg	      # dependency of multiple other libraries: in this case,
633911a29bacSmrg	      # we know (pedantically, we assume) the library does not
634011a29bacSmrg	      # need to be listed more than once, so we keep only the
634111a29bacSmrg	      # last copy.  This is not always right, but it is rare
634211a29bacSmrg	      # enough that we require users that really mean to play
634311a29bacSmrg	      # such unportable linking tricks to link the library
634411a29bacSmrg	      # using -Wl,-lname, so that libtool does not consider it
634511a29bacSmrg	      # for duplicate removal.
634611a29bacSmrg	      case " $specialdeplibs " in
634711a29bacSmrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
634811a29bacSmrg	      *)
634911a29bacSmrg		case " $new_libs " in
635011a29bacSmrg		*" $deplib "*) ;;
635111a29bacSmrg		*) new_libs="$deplib $new_libs" ;;
635211a29bacSmrg		esac
635311a29bacSmrg		;;
635411a29bacSmrg	      esac
635511a29bacSmrg	      ;;
635611a29bacSmrg	    esac
635711a29bacSmrg	  done
635811a29bacSmrg	  tmp_libs=
635911a29bacSmrg	  for deplib in $new_libs; do
636011a29bacSmrg	    case $deplib in
636111a29bacSmrg	    -L*)
636211a29bacSmrg	      case " $tmp_libs " in
636311a29bacSmrg	      *" $deplib "*) ;;
636411a29bacSmrg	      *) tmp_libs="$tmp_libs $deplib" ;;
636511a29bacSmrg	      esac
636611a29bacSmrg	      ;;
636711a29bacSmrg	    *) tmp_libs="$tmp_libs $deplib" ;;
636811a29bacSmrg	    esac
636911a29bacSmrg	  done
637011a29bacSmrg	  eval $var=\"$tmp_libs\"
637111a29bacSmrg	done # for var
637211a29bacSmrg      fi
637311a29bacSmrg      # Last step: remove runtime libs from dependency_libs
637411a29bacSmrg      # (they stay in deplibs)
637511a29bacSmrg      tmp_libs=
637611a29bacSmrg      for i in $dependency_libs ; do
637711a29bacSmrg	case " $predeps $postdeps $compiler_lib_search_path " in
637811a29bacSmrg	*" $i "*)
637911a29bacSmrg	  i=""
638011a29bacSmrg	  ;;
638111a29bacSmrg	esac
638211a29bacSmrg	if test -n "$i" ; then
638311a29bacSmrg	  tmp_libs="$tmp_libs $i"
638411a29bacSmrg	fi
638511a29bacSmrg      done
638611a29bacSmrg      dependency_libs=$tmp_libs
638711a29bacSmrg    done # for pass
638811a29bacSmrg    if test "$linkmode" = prog; then
638911a29bacSmrg      dlfiles="$newdlfiles"
639011a29bacSmrg    fi
639111a29bacSmrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
639211a29bacSmrg      dlprefiles="$newdlprefiles"
639311a29bacSmrg    fi
639411a29bacSmrg
639511a29bacSmrg    case $linkmode in
639611a29bacSmrg    oldlib)
639711a29bacSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
639811a29bacSmrg	func_warning "\`-dlopen' is ignored for archives"
639911a29bacSmrg      fi
640011a29bacSmrg
640111a29bacSmrg      case " $deplibs" in
640211a29bacSmrg      *\ -l* | *\ -L*)
640311a29bacSmrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
640411a29bacSmrg      esac
640511a29bacSmrg
640611a29bacSmrg      test -n "$rpath" && \
640711a29bacSmrg	func_warning "\`-rpath' is ignored for archives"
640811a29bacSmrg
640911a29bacSmrg      test -n "$xrpath" && \
641011a29bacSmrg	func_warning "\`-R' is ignored for archives"
641111a29bacSmrg
641211a29bacSmrg      test -n "$vinfo" && \
641311a29bacSmrg	func_warning "\`-version-info/-version-number' is ignored for archives"
641411a29bacSmrg
641511a29bacSmrg      test -n "$release" && \
641611a29bacSmrg	func_warning "\`-release' is ignored for archives"
641711a29bacSmrg
641811a29bacSmrg      test -n "$export_symbols$export_symbols_regex" && \
641911a29bacSmrg	func_warning "\`-export-symbols' is ignored for archives"
642011a29bacSmrg
642111a29bacSmrg      # Now set the variables for building old libraries.
642211a29bacSmrg      build_libtool_libs=no
642311a29bacSmrg      oldlibs="$output"
642411a29bacSmrg      objs="$objs$old_deplibs"
642511a29bacSmrg      ;;
642611a29bacSmrg
642711a29bacSmrg    lib)
642811a29bacSmrg      # Make sure we only generate libraries of the form `libNAME.la'.
642911a29bacSmrg      case $outputname in
643011a29bacSmrg      lib*)
643111a29bacSmrg	func_stripname 'lib' '.la' "$outputname"
643211a29bacSmrg	name=$func_stripname_result
643311a29bacSmrg	eval shared_ext=\"$shrext_cmds\"
643411a29bacSmrg	eval libname=\"$libname_spec\"
643511a29bacSmrg	;;
643611a29bacSmrg      *)
643711a29bacSmrg	test "$module" = no && \
643811a29bacSmrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
643911a29bacSmrg
644011a29bacSmrg	if test "$need_lib_prefix" != no; then
644111a29bacSmrg	  # Add the "lib" prefix for modules if required
644211a29bacSmrg	  func_stripname '' '.la' "$outputname"
644311a29bacSmrg	  name=$func_stripname_result
644411a29bacSmrg	  eval shared_ext=\"$shrext_cmds\"
644511a29bacSmrg	  eval libname=\"$libname_spec\"
644611a29bacSmrg	else
644711a29bacSmrg	  func_stripname '' '.la' "$outputname"
644811a29bacSmrg	  libname=$func_stripname_result
644911a29bacSmrg	fi
645011a29bacSmrg	;;
645111a29bacSmrg      esac
645211a29bacSmrg
645311a29bacSmrg      if test -n "$objs"; then
645411a29bacSmrg	if test "$deplibs_check_method" != pass_all; then
645511a29bacSmrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
645611a29bacSmrg	else
645711a29bacSmrg	  echo
645811a29bacSmrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
645911a29bacSmrg	  $ECHO "*** objects $objs is not portable!"
646011a29bacSmrg	  libobjs="$libobjs $objs"
646111a29bacSmrg	fi
646211a29bacSmrg      fi
646311a29bacSmrg
646411a29bacSmrg      test "$dlself" != no && \
646511a29bacSmrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
646611a29bacSmrg
646711a29bacSmrg      set dummy $rpath
646811a29bacSmrg      shift
646911a29bacSmrg      test "$#" -gt 1 && \
647011a29bacSmrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
647111a29bacSmrg
647211a29bacSmrg      install_libdir="$1"
647311a29bacSmrg
647411a29bacSmrg      oldlibs=
647511a29bacSmrg      if test -z "$rpath"; then
647611a29bacSmrg	if test "$build_libtool_libs" = yes; then
647711a29bacSmrg	  # Building a libtool convenience library.
647811a29bacSmrg	  # Some compilers have problems with a `.al' extension so
647911a29bacSmrg	  # convenience libraries should have the same extension an
648011a29bacSmrg	  # archive normally would.
648111a29bacSmrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
648211a29bacSmrg	  build_libtool_libs=convenience
648311a29bacSmrg	  build_old_libs=yes
648411a29bacSmrg	fi
648511a29bacSmrg
648611a29bacSmrg	test -n "$vinfo" && \
648711a29bacSmrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
648811a29bacSmrg
648911a29bacSmrg	test -n "$release" && \
649011a29bacSmrg	  func_warning "\`-release' is ignored for convenience libraries"
649111a29bacSmrg      else
649211a29bacSmrg
649311a29bacSmrg	# Parse the version information argument.
649411a29bacSmrg	save_ifs="$IFS"; IFS=':'
649511a29bacSmrg	set dummy $vinfo 0 0 0
649611a29bacSmrg	shift
649711a29bacSmrg	IFS="$save_ifs"
649811a29bacSmrg
649911a29bacSmrg	test -n "$7" && \
650011a29bacSmrg	  func_fatal_help "too many parameters to \`-version-info'"
650111a29bacSmrg
650211a29bacSmrg	# convert absolute version numbers to libtool ages
650311a29bacSmrg	# this retains compatibility with .la files and attempts
650411a29bacSmrg	# to make the code below a bit more comprehensible
650511a29bacSmrg
650611a29bacSmrg	case $vinfo_number in
650711a29bacSmrg	yes)
650811a29bacSmrg	  number_major="$1"
650911a29bacSmrg	  number_minor="$2"
651011a29bacSmrg	  number_revision="$3"
651111a29bacSmrg	  #
651211a29bacSmrg	  # There are really only two kinds -- those that
651311a29bacSmrg	  # use the current revision as the major version
651411a29bacSmrg	  # and those that subtract age and use age as
651511a29bacSmrg	  # a minor version.  But, then there is irix
651611a29bacSmrg	  # which has an extra 1 added just for fun
651711a29bacSmrg	  #
651811a29bacSmrg	  case $version_type in
651911a29bacSmrg	  darwin|linux|osf|windows|none)
652011a29bacSmrg	    func_arith $number_major + $number_minor
652111a29bacSmrg	    current=$func_arith_result
652211a29bacSmrg	    age="$number_minor"
652311a29bacSmrg	    revision="$number_revision"
652411a29bacSmrg	    ;;
652511a29bacSmrg	  freebsd-aout|freebsd-elf|qnx|sunos)
652611a29bacSmrg	    current="$number_major"
652711a29bacSmrg	    revision="$number_minor"
652811a29bacSmrg	    age="0"
652911a29bacSmrg	    ;;
653011a29bacSmrg	  irix|nonstopux)
653111a29bacSmrg	    func_arith $number_major + $number_minor
653211a29bacSmrg	    current=$func_arith_result
653311a29bacSmrg	    age="$number_minor"
653411a29bacSmrg	    revision="$number_minor"
653511a29bacSmrg	    lt_irix_increment=no
653611a29bacSmrg	    ;;
653711a29bacSmrg	  esac
653811a29bacSmrg	  ;;
653911a29bacSmrg	no)
654011a29bacSmrg	  current="$1"
654111a29bacSmrg	  revision="$2"
654211a29bacSmrg	  age="$3"
654311a29bacSmrg	  ;;
654411a29bacSmrg	esac
654511a29bacSmrg
654611a29bacSmrg	# Check that each of the things are valid numbers.
654711a29bacSmrg	case $current in
654811a29bacSmrg	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]) ;;
654911a29bacSmrg	*)
655011a29bacSmrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
655111a29bacSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
655211a29bacSmrg	  ;;
655311a29bacSmrg	esac
655411a29bacSmrg
655511a29bacSmrg	case $revision in
655611a29bacSmrg	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]) ;;
655711a29bacSmrg	*)
655811a29bacSmrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
655911a29bacSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
656011a29bacSmrg	  ;;
656111a29bacSmrg	esac
656211a29bacSmrg
656311a29bacSmrg	case $age in
656411a29bacSmrg	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]) ;;
656511a29bacSmrg	*)
656611a29bacSmrg	  func_error "AGE \`$age' must be a nonnegative integer"
656711a29bacSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
656811a29bacSmrg	  ;;
656911a29bacSmrg	esac
657011a29bacSmrg
657111a29bacSmrg	if test "$age" -gt "$current"; then
657211a29bacSmrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
657311a29bacSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
657411a29bacSmrg	fi
657511a29bacSmrg
657611a29bacSmrg	# Calculate the version variables.
657711a29bacSmrg	major=
657811a29bacSmrg	versuffix=
657911a29bacSmrg	verstring=
658011a29bacSmrg	case $version_type in
658111a29bacSmrg	none) ;;
658211a29bacSmrg
658311a29bacSmrg	darwin)
658411a29bacSmrg	  # Like Linux, but with the current version available in
658511a29bacSmrg	  # verstring for coding it into the library header
658611a29bacSmrg	  func_arith $current - $age
658711a29bacSmrg	  major=.$func_arith_result
658811a29bacSmrg	  versuffix="$major.$age.$revision"
658911a29bacSmrg	  # Darwin ld doesn't like 0 for these options...
659011a29bacSmrg	  func_arith $current + 1
659111a29bacSmrg	  minor_current=$func_arith_result
659211a29bacSmrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
659311a29bacSmrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
659411a29bacSmrg	  ;;
659511a29bacSmrg
659611a29bacSmrg	freebsd-aout)
659711a29bacSmrg	  major=".$current"
659811a29bacSmrg	  versuffix=".$current.$revision";
659911a29bacSmrg	  ;;
660011a29bacSmrg
660111a29bacSmrg	freebsd-elf)
660211a29bacSmrg	  major=".$current"
660311a29bacSmrg	  versuffix=".$current"
660411a29bacSmrg	  ;;
660511a29bacSmrg
660611a29bacSmrg	irix | nonstopux)
660711a29bacSmrg	  if test "X$lt_irix_increment" = "Xno"; then
660811a29bacSmrg	    func_arith $current - $age
660911a29bacSmrg	  else
661011a29bacSmrg	    func_arith $current - $age + 1
661111a29bacSmrg	  fi
661211a29bacSmrg	  major=$func_arith_result
661311a29bacSmrg
661411a29bacSmrg	  case $version_type in
661511a29bacSmrg	    nonstopux) verstring_prefix=nonstopux ;;
661611a29bacSmrg	    *)         verstring_prefix=sgi ;;
661711a29bacSmrg	  esac
661811a29bacSmrg	  verstring="$verstring_prefix$major.$revision"
661911a29bacSmrg
662011a29bacSmrg	  # Add in all the interfaces that we are compatible with.
662111a29bacSmrg	  loop=$revision
662211a29bacSmrg	  while test "$loop" -ne 0; do
662311a29bacSmrg	    func_arith $revision - $loop
662411a29bacSmrg	    iface=$func_arith_result
662511a29bacSmrg	    func_arith $loop - 1
662611a29bacSmrg	    loop=$func_arith_result
662711a29bacSmrg	    verstring="$verstring_prefix$major.$iface:$verstring"
662811a29bacSmrg	  done
662911a29bacSmrg
663011a29bacSmrg	  # Before this point, $major must not contain `.'.
663111a29bacSmrg	  major=.$major
663211a29bacSmrg	  versuffix="$major.$revision"
663311a29bacSmrg	  ;;
663411a29bacSmrg
663511a29bacSmrg	linux)
663611a29bacSmrg	  func_arith $current - $age
663711a29bacSmrg	  major=.$func_arith_result
663811a29bacSmrg	  versuffix="$major.$age.$revision"
663911a29bacSmrg	  ;;
664011a29bacSmrg
664111a29bacSmrg	osf)
664211a29bacSmrg	  func_arith $current - $age
664311a29bacSmrg	  major=.$func_arith_result
664411a29bacSmrg	  versuffix=".$current.$age.$revision"
664511a29bacSmrg	  verstring="$current.$age.$revision"
664611a29bacSmrg
664711a29bacSmrg	  # Add in all the interfaces that we are compatible with.
664811a29bacSmrg	  loop=$age
664911a29bacSmrg	  while test "$loop" -ne 0; do
665011a29bacSmrg	    func_arith $current - $loop
665111a29bacSmrg	    iface=$func_arith_result
665211a29bacSmrg	    func_arith $loop - 1
665311a29bacSmrg	    loop=$func_arith_result
665411a29bacSmrg	    verstring="$verstring:${iface}.0"
665511a29bacSmrg	  done
665611a29bacSmrg
665711a29bacSmrg	  # Make executables depend on our current version.
665811a29bacSmrg	  verstring="$verstring:${current}.0"
665911a29bacSmrg	  ;;
666011a29bacSmrg
666111a29bacSmrg	qnx)
666211a29bacSmrg	  major=".$current"
666311a29bacSmrg	  versuffix=".$current"
666411a29bacSmrg	  ;;
666511a29bacSmrg
666611a29bacSmrg	sunos)
666711a29bacSmrg	  major=".$current"
666811a29bacSmrg	  versuffix=".$current.$revision"
666911a29bacSmrg	  ;;
667011a29bacSmrg
667111a29bacSmrg	windows)
667211a29bacSmrg	  # Use '-' rather than '.', since we only want one
667311a29bacSmrg	  # extension on DOS 8.3 filesystems.
667411a29bacSmrg	  func_arith $current - $age
667511a29bacSmrg	  major=$func_arith_result
667611a29bacSmrg	  versuffix="-$major"
667711a29bacSmrg	  ;;
667811a29bacSmrg
667911a29bacSmrg	*)
668011a29bacSmrg	  func_fatal_configuration "unknown library version type \`$version_type'"
668111a29bacSmrg	  ;;
668211a29bacSmrg	esac
668311a29bacSmrg
668411a29bacSmrg	# Clear the version info if we defaulted, and they specified a release.
668511a29bacSmrg	if test -z "$vinfo" && test -n "$release"; then
668611a29bacSmrg	  major=
668711a29bacSmrg	  case $version_type in
668811a29bacSmrg	  darwin)
668911a29bacSmrg	    # we can't check for "0.0" in archive_cmds due to quoting
669011a29bacSmrg	    # problems, so we reset it completely
669111a29bacSmrg	    verstring=
669211a29bacSmrg	    ;;
669311a29bacSmrg	  *)
669411a29bacSmrg	    verstring="0.0"
669511a29bacSmrg	    ;;
669611a29bacSmrg	  esac
669711a29bacSmrg	  if test "$need_version" = no; then
669811a29bacSmrg	    versuffix=
669911a29bacSmrg	  else
670011a29bacSmrg	    versuffix=".0.0"
670111a29bacSmrg	  fi
670211a29bacSmrg	fi
670311a29bacSmrg
670411a29bacSmrg	# Remove version info from name if versioning should be avoided
670511a29bacSmrg	if test "$avoid_version" = yes && test "$need_version" = no; then
670611a29bacSmrg	  major=
670711a29bacSmrg	  versuffix=
670811a29bacSmrg	  verstring=""
670911a29bacSmrg	fi
671011a29bacSmrg
671111a29bacSmrg	# Check to see if the archive will have undefined symbols.
671211a29bacSmrg	if test "$allow_undefined" = yes; then
671311a29bacSmrg	  if test "$allow_undefined_flag" = unsupported; then
671411a29bacSmrg	    func_warning "undefined symbols not allowed in $host shared libraries"
671511a29bacSmrg	    build_libtool_libs=no
671611a29bacSmrg	    build_old_libs=yes
671711a29bacSmrg	  fi
671811a29bacSmrg	else
671911a29bacSmrg	  # Don't allow undefined symbols.
672011a29bacSmrg	  allow_undefined_flag="$no_undefined_flag"
672111a29bacSmrg	fi
672211a29bacSmrg
672311a29bacSmrg      fi
672411a29bacSmrg
672511a29bacSmrg      func_generate_dlsyms "$libname" "$libname" "yes"
672611a29bacSmrg      libobjs="$libobjs $symfileobj"
672711a29bacSmrg      test "X$libobjs" = "X " && libobjs=
672811a29bacSmrg
672911a29bacSmrg      if test "$mode" != relink; then
673011a29bacSmrg	# Remove our outputs, but don't remove object files since they
673111a29bacSmrg	# may have been created when compiling PIC objects.
673211a29bacSmrg	removelist=
673311a29bacSmrg	tempremovelist=`$ECHO "$output_objdir/*"`
673411a29bacSmrg	for p in $tempremovelist; do
673511a29bacSmrg	  case $p in
673611a29bacSmrg	    *.$objext | *.gcno)
673711a29bacSmrg	       ;;
673811a29bacSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
673911a29bacSmrg	       if test "X$precious_files_regex" != "X"; then
674011a29bacSmrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
674111a29bacSmrg		 then
674211a29bacSmrg		   continue
674311a29bacSmrg		 fi
674411a29bacSmrg	       fi
674511a29bacSmrg	       removelist="$removelist $p"
674611a29bacSmrg	       ;;
674711a29bacSmrg	    *) ;;
674811a29bacSmrg	  esac
674911a29bacSmrg	done
675011a29bacSmrg	test -n "$removelist" && \
675111a29bacSmrg	  func_show_eval "${RM}r \$removelist"
675211a29bacSmrg      fi
675311a29bacSmrg
675411a29bacSmrg      # Now set the variables for building old libraries.
675511a29bacSmrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
675611a29bacSmrg	oldlibs="$oldlibs $output_objdir/$libname.$libext"
675711a29bacSmrg
675811a29bacSmrg	# Transform .lo files to .o files.
675911a29bacSmrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
676011a29bacSmrg      fi
676111a29bacSmrg
676211a29bacSmrg      # Eliminate all temporary directories.
676311a29bacSmrg      #for path in $notinst_path; do
676411a29bacSmrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
676511a29bacSmrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
676611a29bacSmrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
676711a29bacSmrg      #done
676811a29bacSmrg
676911a29bacSmrg      if test -n "$xrpath"; then
677011a29bacSmrg	# If the user specified any rpath flags, then add them.
677111a29bacSmrg	temp_xrpath=
677211a29bacSmrg	for libdir in $xrpath; do
677311a29bacSmrg	  temp_xrpath="$temp_xrpath -R$libdir"
677411a29bacSmrg	  case "$finalize_rpath " in
677511a29bacSmrg	  *" $libdir "*) ;;
677611a29bacSmrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
677711a29bacSmrg	  esac
677811a29bacSmrg	done
677911a29bacSmrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
678011a29bacSmrg	  dependency_libs="$temp_xrpath $dependency_libs"
678111a29bacSmrg	fi
678211a29bacSmrg      fi
678311a29bacSmrg
678411a29bacSmrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
678511a29bacSmrg      old_dlfiles="$dlfiles"
678611a29bacSmrg      dlfiles=
678711a29bacSmrg      for lib in $old_dlfiles; do
678811a29bacSmrg	case " $dlprefiles $dlfiles " in
678911a29bacSmrg	*" $lib "*) ;;
679011a29bacSmrg	*) dlfiles="$dlfiles $lib" ;;
679111a29bacSmrg	esac
679211a29bacSmrg      done
679311a29bacSmrg
679411a29bacSmrg      # Make sure dlprefiles contains only unique files
679511a29bacSmrg      old_dlprefiles="$dlprefiles"
679611a29bacSmrg      dlprefiles=
679711a29bacSmrg      for lib in $old_dlprefiles; do
679811a29bacSmrg	case "$dlprefiles " in
679911a29bacSmrg	*" $lib "*) ;;
680011a29bacSmrg	*) dlprefiles="$dlprefiles $lib" ;;
680111a29bacSmrg	esac
680211a29bacSmrg      done
680311a29bacSmrg
680411a29bacSmrg      if test "$build_libtool_libs" = yes; then
680511a29bacSmrg	if test -n "$rpath"; then
680611a29bacSmrg	  case $host in
680711a29bacSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
680811a29bacSmrg	    # these systems don't actually have a c library (as such)!
680911a29bacSmrg	    ;;
681011a29bacSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
681111a29bacSmrg	    # Rhapsody C library is in the System framework
681211a29bacSmrg	    deplibs="$deplibs System.ltframework"
681311a29bacSmrg	    ;;
681411a29bacSmrg	  *-*-netbsd*)
681511a29bacSmrg	    # Don't link with libc until the a.out ld.so is fixed.
681611a29bacSmrg	    ;;
681711a29bacSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
681811a29bacSmrg	    # Do not include libc due to us having libc/libc_r.
681911a29bacSmrg	    ;;
682011a29bacSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
682111a29bacSmrg	    # Causes problems with __ctype
682211a29bacSmrg	    ;;
682311a29bacSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
682411a29bacSmrg	    # Compiler inserts libc in the correct place for threads to work
682511a29bacSmrg	    ;;
682611a29bacSmrg	  *)
682711a29bacSmrg	    # Add libc to deplibs on all other systems if necessary.
682811a29bacSmrg	    if test "$build_libtool_need_lc" = "yes"; then
682911a29bacSmrg	      deplibs="$deplibs -lc"
683011a29bacSmrg	    fi
683111a29bacSmrg	    ;;
683211a29bacSmrg	  esac
683311a29bacSmrg	fi
683411a29bacSmrg
683511a29bacSmrg	# Transform deplibs into only deplibs that can be linked in shared.
683611a29bacSmrg	name_save=$name
683711a29bacSmrg	libname_save=$libname
683811a29bacSmrg	release_save=$release
683911a29bacSmrg	versuffix_save=$versuffix
684011a29bacSmrg	major_save=$major
684111a29bacSmrg	# I'm not sure if I'm treating the release correctly.  I think
684211a29bacSmrg	# release should show up in the -l (ie -lgmp5) so we don't want to
684311a29bacSmrg	# add it in twice.  Is that correct?
684411a29bacSmrg	release=""
684511a29bacSmrg	versuffix=""
684611a29bacSmrg	major=""
684711a29bacSmrg	newdeplibs=
684811a29bacSmrg	droppeddeps=no
684911a29bacSmrg	case $deplibs_check_method in
685011a29bacSmrg	pass_all)
685111a29bacSmrg	  # Don't check for shared/static.  Everything works.
685211a29bacSmrg	  # This might be a little naive.  We might want to check
685311a29bacSmrg	  # whether the library exists or not.  But this is on
685411a29bacSmrg	  # osf3 & osf4 and I'm not really sure... Just
685511a29bacSmrg	  # implementing what was already the behavior.
685611a29bacSmrg	  newdeplibs=$deplibs
685711a29bacSmrg	  ;;
685811a29bacSmrg	test_compile)
685911a29bacSmrg	  # This code stresses the "libraries are programs" paradigm to its
686011a29bacSmrg	  # limits. Maybe even breaks it.  We compile a program, linking it
686111a29bacSmrg	  # against the deplibs as a proxy for the library.  Then we can check
686211a29bacSmrg	  # whether they linked in statically or dynamically with ldd.
686311a29bacSmrg	  $opt_dry_run || $RM conftest.c
686411a29bacSmrg	  cat > conftest.c <<EOF
686511a29bacSmrg	  int main() { return 0; }
686611a29bacSmrgEOF
686711a29bacSmrg	  $opt_dry_run || $RM conftest
686811a29bacSmrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
686911a29bacSmrg	    ldd_output=`ldd conftest`
687011a29bacSmrg	    for i in $deplibs; do
687111a29bacSmrg	      case $i in
687211a29bacSmrg	      -l*)
687311a29bacSmrg		func_stripname -l '' "$i"
687411a29bacSmrg		name=$func_stripname_result
687511a29bacSmrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
687611a29bacSmrg		  case " $predeps $postdeps " in
687711a29bacSmrg		  *" $i "*)
687811a29bacSmrg		    newdeplibs="$newdeplibs $i"
687911a29bacSmrg		    i=""
688011a29bacSmrg		    ;;
688111a29bacSmrg		  esac
688211a29bacSmrg		fi
688311a29bacSmrg		if test -n "$i" ; then
688411a29bacSmrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
688511a29bacSmrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
688611a29bacSmrg		  set dummy $deplib_matches; shift
688711a29bacSmrg		  deplib_match=$1
688811a29bacSmrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
688911a29bacSmrg		    newdeplibs="$newdeplibs $i"
689011a29bacSmrg		  else
689111a29bacSmrg		    droppeddeps=yes
689211a29bacSmrg		    echo
689311a29bacSmrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
689411a29bacSmrg		    echo "*** I have the capability to make that library automatically link in when"
689511a29bacSmrg		    echo "*** you link to this library.  But I can only do this if you have a"
689611a29bacSmrg		    echo "*** shared version of the library, which I believe you do not have"
689711a29bacSmrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
689811a29bacSmrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
689911a29bacSmrg		  fi
690011a29bacSmrg		fi
690111a29bacSmrg		;;
690211a29bacSmrg	      *)
690311a29bacSmrg		newdeplibs="$newdeplibs $i"
690411a29bacSmrg		;;
690511a29bacSmrg	      esac
690611a29bacSmrg	    done
690711a29bacSmrg	  else
690811a29bacSmrg	    # Error occurred in the first compile.  Let's try to salvage
690911a29bacSmrg	    # the situation: Compile a separate program for each library.
691011a29bacSmrg	    for i in $deplibs; do
691111a29bacSmrg	      case $i in
691211a29bacSmrg	      -l*)
691311a29bacSmrg		func_stripname -l '' "$i"
691411a29bacSmrg		name=$func_stripname_result
691511a29bacSmrg		$opt_dry_run || $RM conftest
691611a29bacSmrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
691711a29bacSmrg		  ldd_output=`ldd conftest`
691811a29bacSmrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
691911a29bacSmrg		    case " $predeps $postdeps " in
692011a29bacSmrg		    *" $i "*)
692111a29bacSmrg		      newdeplibs="$newdeplibs $i"
692211a29bacSmrg		      i=""
692311a29bacSmrg		      ;;
692411a29bacSmrg		    esac
692511a29bacSmrg		  fi
692611a29bacSmrg		  if test -n "$i" ; then
692711a29bacSmrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
692811a29bacSmrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
692911a29bacSmrg		    set dummy $deplib_matches; shift
693011a29bacSmrg		    deplib_match=$1
693111a29bacSmrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
693211a29bacSmrg		      newdeplibs="$newdeplibs $i"
693311a29bacSmrg		    else
693411a29bacSmrg		      droppeddeps=yes
693511a29bacSmrg		      echo
693611a29bacSmrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
693711a29bacSmrg		      echo "*** I have the capability to make that library automatically link in when"
693811a29bacSmrg		      echo "*** you link to this library.  But I can only do this if you have a"
693911a29bacSmrg		      echo "*** shared version of the library, which you do not appear to have"
694011a29bacSmrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
694111a29bacSmrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
694211a29bacSmrg		    fi
694311a29bacSmrg		  fi
694411a29bacSmrg		else
694511a29bacSmrg		  droppeddeps=yes
694611a29bacSmrg		  echo
694711a29bacSmrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
694811a29bacSmrg		  echo "*** make it link in!  You will probably need to install it or some"
694911a29bacSmrg		  echo "*** library that it depends on before this library will be fully"
695011a29bacSmrg		  echo "*** functional.  Installing it before continuing would be even better."
695111a29bacSmrg		fi
695211a29bacSmrg		;;
695311a29bacSmrg	      *)
695411a29bacSmrg		newdeplibs="$newdeplibs $i"
695511a29bacSmrg		;;
695611a29bacSmrg	      esac
695711a29bacSmrg	    done
695811a29bacSmrg	  fi
695911a29bacSmrg	  ;;
696011a29bacSmrg	file_magic*)
696111a29bacSmrg	  set dummy $deplibs_check_method; shift
696211a29bacSmrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
696311a29bacSmrg	  for a_deplib in $deplibs; do
696411a29bacSmrg	    case $a_deplib in
696511a29bacSmrg	    -l*)
696611a29bacSmrg	      func_stripname -l '' "$a_deplib"
696711a29bacSmrg	      name=$func_stripname_result
696811a29bacSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
696911a29bacSmrg		case " $predeps $postdeps " in
697011a29bacSmrg		*" $a_deplib "*)
697111a29bacSmrg		  newdeplibs="$newdeplibs $a_deplib"
697211a29bacSmrg		  a_deplib=""
697311a29bacSmrg		  ;;
697411a29bacSmrg		esac
697511a29bacSmrg	      fi
697611a29bacSmrg	      if test -n "$a_deplib" ; then
697711a29bacSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
697811a29bacSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
697911a29bacSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
698011a29bacSmrg		  for potent_lib in $potential_libs; do
698111a29bacSmrg		      # Follow soft links.
698211a29bacSmrg		      if ls -lLd "$potent_lib" 2>/dev/null |
698311a29bacSmrg			 $GREP " -> " >/dev/null; then
698411a29bacSmrg			continue
698511a29bacSmrg		      fi
698611a29bacSmrg		      # The statement above tries to avoid entering an
698711a29bacSmrg		      # endless loop below, in case of cyclic links.
698811a29bacSmrg		      # We might still enter an endless loop, since a link
698911a29bacSmrg		      # loop can be closed while we follow links,
699011a29bacSmrg		      # but so what?
699111a29bacSmrg		      potlib="$potent_lib"
699211a29bacSmrg		      while test -h "$potlib" 2>/dev/null; do
699311a29bacSmrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
699411a29bacSmrg			case $potliblink in
699511a29bacSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
699611a29bacSmrg			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
699711a29bacSmrg			esac
699811a29bacSmrg		      done
699911a29bacSmrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
700011a29bacSmrg			 $SED -e 10q |
700111a29bacSmrg			 $EGREP "$file_magic_regex" > /dev/null; then
700211a29bacSmrg			newdeplibs="$newdeplibs $a_deplib"
700311a29bacSmrg			a_deplib=""
700411a29bacSmrg			break 2
700511a29bacSmrg		      fi
700611a29bacSmrg		  done
700711a29bacSmrg		done
700811a29bacSmrg	      fi
700911a29bacSmrg	      if test -n "$a_deplib" ; then
701011a29bacSmrg		droppeddeps=yes
701111a29bacSmrg		echo
701211a29bacSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
701311a29bacSmrg		echo "*** I have the capability to make that library automatically link in when"
701411a29bacSmrg		echo "*** you link to this library.  But I can only do this if you have a"
701511a29bacSmrg		echo "*** shared version of the library, which you do not appear to have"
701611a29bacSmrg		echo "*** because I did check the linker path looking for a file starting"
701711a29bacSmrg		if test -z "$potlib" ; then
701811a29bacSmrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
701911a29bacSmrg		else
702011a29bacSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
702111a29bacSmrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
702211a29bacSmrg		fi
702311a29bacSmrg	      fi
702411a29bacSmrg	      ;;
702511a29bacSmrg	    *)
702611a29bacSmrg	      # Add a -L argument.
702711a29bacSmrg	      newdeplibs="$newdeplibs $a_deplib"
702811a29bacSmrg	      ;;
702911a29bacSmrg	    esac
703011a29bacSmrg	  done # Gone through all deplibs.
703111a29bacSmrg	  ;;
703211a29bacSmrg	match_pattern*)
703311a29bacSmrg	  set dummy $deplibs_check_method; shift
703411a29bacSmrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
703511a29bacSmrg	  for a_deplib in $deplibs; do
703611a29bacSmrg	    case $a_deplib in
703711a29bacSmrg	    -l*)
703811a29bacSmrg	      func_stripname -l '' "$a_deplib"
703911a29bacSmrg	      name=$func_stripname_result
704011a29bacSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
704111a29bacSmrg		case " $predeps $postdeps " in
704211a29bacSmrg		*" $a_deplib "*)
704311a29bacSmrg		  newdeplibs="$newdeplibs $a_deplib"
704411a29bacSmrg		  a_deplib=""
704511a29bacSmrg		  ;;
704611a29bacSmrg		esac
704711a29bacSmrg	      fi
704811a29bacSmrg	      if test -n "$a_deplib" ; then
704911a29bacSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
705011a29bacSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
705111a29bacSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
705211a29bacSmrg		  for potent_lib in $potential_libs; do
705311a29bacSmrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
705411a29bacSmrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
705511a29bacSmrg		       $EGREP "$match_pattern_regex" > /dev/null; then
705611a29bacSmrg		      newdeplibs="$newdeplibs $a_deplib"
705711a29bacSmrg		      a_deplib=""
705811a29bacSmrg		      break 2
705911a29bacSmrg		    fi
706011a29bacSmrg		  done
706111a29bacSmrg		done
706211a29bacSmrg	      fi
706311a29bacSmrg	      if test -n "$a_deplib" ; then
706411a29bacSmrg		droppeddeps=yes
706511a29bacSmrg		echo
706611a29bacSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
706711a29bacSmrg		echo "*** I have the capability to make that library automatically link in when"
706811a29bacSmrg		echo "*** you link to this library.  But I can only do this if you have a"
706911a29bacSmrg		echo "*** shared version of the library, which you do not appear to have"
707011a29bacSmrg		echo "*** because I did check the linker path looking for a file starting"
707111a29bacSmrg		if test -z "$potlib" ; then
707211a29bacSmrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
707311a29bacSmrg		else
707411a29bacSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
707511a29bacSmrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
707611a29bacSmrg		fi
707711a29bacSmrg	      fi
707811a29bacSmrg	      ;;
707911a29bacSmrg	    *)
708011a29bacSmrg	      # Add a -L argument.
708111a29bacSmrg	      newdeplibs="$newdeplibs $a_deplib"
708211a29bacSmrg	      ;;
708311a29bacSmrg	    esac
708411a29bacSmrg	  done # Gone through all deplibs.
708511a29bacSmrg	  ;;
708611a29bacSmrg	none | unknown | *)
708711a29bacSmrg	  newdeplibs=""
708811a29bacSmrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
708911a29bacSmrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
709011a29bacSmrg	    for i in $predeps $postdeps ; do
709111a29bacSmrg	      # can't use Xsed below, because $i might contain '/'
709211a29bacSmrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
709311a29bacSmrg	    done
709411a29bacSmrg	  fi
709511a29bacSmrg	  case $tmp_deplibs in
709611a29bacSmrg	  *[!\	\ ]*)
709711a29bacSmrg	    echo
709811a29bacSmrg	    if test "X$deplibs_check_method" = "Xnone"; then
709911a29bacSmrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
710011a29bacSmrg	    else
710111a29bacSmrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
710211a29bacSmrg	    fi
710311a29bacSmrg	    echo "*** All declared inter-library dependencies are being dropped."
710411a29bacSmrg	    droppeddeps=yes
710511a29bacSmrg	    ;;
710611a29bacSmrg	  esac
710711a29bacSmrg	  ;;
710811a29bacSmrg	esac
710911a29bacSmrg	versuffix=$versuffix_save
711011a29bacSmrg	major=$major_save
711111a29bacSmrg	release=$release_save
711211a29bacSmrg	libname=$libname_save
711311a29bacSmrg	name=$name_save
711411a29bacSmrg
711511a29bacSmrg	case $host in
711611a29bacSmrg	*-*-rhapsody* | *-*-darwin1.[012])
711711a29bacSmrg	  # On Rhapsody replace the C library with the System framework
711811a29bacSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
711911a29bacSmrg	  ;;
712011a29bacSmrg	esac
712111a29bacSmrg
712211a29bacSmrg	if test "$droppeddeps" = yes; then
712311a29bacSmrg	  if test "$module" = yes; then
712411a29bacSmrg	    echo
712511a29bacSmrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
712611a29bacSmrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
712711a29bacSmrg	    echo "*** a static module, that should work as long as the dlopening"
712811a29bacSmrg	    echo "*** application is linked with the -dlopen flag."
712911a29bacSmrg	    if test -z "$global_symbol_pipe"; then
713011a29bacSmrg	      echo
713111a29bacSmrg	      echo "*** However, this would only work if libtool was able to extract symbol"
713211a29bacSmrg	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
713311a29bacSmrg	      echo "*** not find such a program.  So, this module is probably useless."
713411a29bacSmrg	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
713511a29bacSmrg	    fi
713611a29bacSmrg	    if test "$build_old_libs" = no; then
713711a29bacSmrg	      oldlibs="$output_objdir/$libname.$libext"
713811a29bacSmrg	      build_libtool_libs=module
713911a29bacSmrg	      build_old_libs=yes
714011a29bacSmrg	    else
714111a29bacSmrg	      build_libtool_libs=no
714211a29bacSmrg	    fi
714311a29bacSmrg	  else
714411a29bacSmrg	    echo "*** The inter-library dependencies that have been dropped here will be"
714511a29bacSmrg	    echo "*** automatically added whenever a program is linked with this library"
714611a29bacSmrg	    echo "*** or is declared to -dlopen it."
714711a29bacSmrg
714811a29bacSmrg	    if test "$allow_undefined" = no; then
714911a29bacSmrg	      echo
715011a29bacSmrg	      echo "*** Since this library must not contain undefined symbols,"
715111a29bacSmrg	      echo "*** because either the platform does not support them or"
715211a29bacSmrg	      echo "*** it was explicitly requested with -no-undefined,"
715311a29bacSmrg	      echo "*** libtool will only create a static version of it."
715411a29bacSmrg	      if test "$build_old_libs" = no; then
715511a29bacSmrg		oldlibs="$output_objdir/$libname.$libext"
715611a29bacSmrg		build_libtool_libs=module
715711a29bacSmrg		build_old_libs=yes
715811a29bacSmrg	      else
715911a29bacSmrg		build_libtool_libs=no
716011a29bacSmrg	      fi
716111a29bacSmrg	    fi
716211a29bacSmrg	  fi
716311a29bacSmrg	fi
716411a29bacSmrg	# Done checking deplibs!
716511a29bacSmrg	deplibs=$newdeplibs
716611a29bacSmrg      fi
716711a29bacSmrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
716811a29bacSmrg      case $host in
716911a29bacSmrg	*-*-darwin*)
717011a29bacSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
717111a29bacSmrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
717211a29bacSmrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
717311a29bacSmrg	  ;;
717411a29bacSmrg      esac
717511a29bacSmrg
717611a29bacSmrg      # move library search paths that coincide with paths to not yet
717711a29bacSmrg      # installed libraries to the beginning of the library search list
717811a29bacSmrg      new_libs=
717911a29bacSmrg      for path in $notinst_path; do
718011a29bacSmrg	case " $new_libs " in
718111a29bacSmrg	*" -L$path/$objdir "*) ;;
718211a29bacSmrg	*)
718311a29bacSmrg	  case " $deplibs " in
718411a29bacSmrg	  *" -L$path/$objdir "*)
718511a29bacSmrg	    new_libs="$new_libs -L$path/$objdir" ;;
718611a29bacSmrg	  esac
718711a29bacSmrg	  ;;
718811a29bacSmrg	esac
718911a29bacSmrg      done
719011a29bacSmrg      for deplib in $deplibs; do
719111a29bacSmrg	case $deplib in
719211a29bacSmrg	-L*)
719311a29bacSmrg	  case " $new_libs " in
719411a29bacSmrg	  *" $deplib "*) ;;
719511a29bacSmrg	  *) new_libs="$new_libs $deplib" ;;
719611a29bacSmrg	  esac
719711a29bacSmrg	  ;;
719811a29bacSmrg	*) new_libs="$new_libs $deplib" ;;
719911a29bacSmrg	esac
720011a29bacSmrg      done
720111a29bacSmrg      deplibs="$new_libs"
720211a29bacSmrg
720311a29bacSmrg      # All the library-specific variables (install_libdir is set above).
720411a29bacSmrg      library_names=
720511a29bacSmrg      old_library=
720611a29bacSmrg      dlname=
720711a29bacSmrg
720811a29bacSmrg      # Test again, we may have decided not to build it any more
720911a29bacSmrg      if test "$build_libtool_libs" = yes; then
721011a29bacSmrg	if test "$hardcode_into_libs" = yes; then
721111a29bacSmrg	  # Hardcode the library paths
721211a29bacSmrg	  hardcode_libdirs=
721311a29bacSmrg	  dep_rpath=
721411a29bacSmrg	  rpath="$finalize_rpath"
721511a29bacSmrg	  test "$mode" != relink && rpath="$compile_rpath$rpath"
721611a29bacSmrg	  for libdir in $rpath; do
721711a29bacSmrg	    if test -n "$hardcode_libdir_flag_spec"; then
721811a29bacSmrg	      if test -n "$hardcode_libdir_separator"; then
721911a29bacSmrg		if test -z "$hardcode_libdirs"; then
722011a29bacSmrg		  hardcode_libdirs="$libdir"
722111a29bacSmrg		else
722211a29bacSmrg		  # Just accumulate the unique libdirs.
722311a29bacSmrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
722411a29bacSmrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
722511a29bacSmrg		    ;;
722611a29bacSmrg		  *)
722711a29bacSmrg		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
722811a29bacSmrg		    ;;
722911a29bacSmrg		  esac
723011a29bacSmrg		fi
723111a29bacSmrg	      else
723211a29bacSmrg		eval flag=\"$hardcode_libdir_flag_spec\"
723311a29bacSmrg		dep_rpath="$dep_rpath $flag"
723411a29bacSmrg	      fi
723511a29bacSmrg	    elif test -n "$runpath_var"; then
723611a29bacSmrg	      case "$perm_rpath " in
723711a29bacSmrg	      *" $libdir "*) ;;
723811a29bacSmrg	      *) perm_rpath="$perm_rpath $libdir" ;;
723911a29bacSmrg	      esac
724011a29bacSmrg	    fi
724111a29bacSmrg	  done
724211a29bacSmrg	  # Substitute the hardcoded libdirs into the rpath.
724311a29bacSmrg	  if test -n "$hardcode_libdir_separator" &&
724411a29bacSmrg	     test -n "$hardcode_libdirs"; then
724511a29bacSmrg	    libdir="$hardcode_libdirs"
724611a29bacSmrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
724711a29bacSmrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
724811a29bacSmrg	    else
724911a29bacSmrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
725011a29bacSmrg	    fi
725111a29bacSmrg	  fi
725211a29bacSmrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
725311a29bacSmrg	    # We should set the runpath_var.
725411a29bacSmrg	    rpath=
725511a29bacSmrg	    for dir in $perm_rpath; do
725611a29bacSmrg	      rpath="$rpath$dir:"
725711a29bacSmrg	    done
725811a29bacSmrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
725911a29bacSmrg	  fi
726011a29bacSmrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
726111a29bacSmrg	fi
726241b2f0bdSmrg
726311a29bacSmrg	shlibpath="$finalize_shlibpath"
726411a29bacSmrg	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
726511a29bacSmrg	if test -n "$shlibpath"; then
726611a29bacSmrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
726711a29bacSmrg	fi
726841b2f0bdSmrg
726911a29bacSmrg	# Get the real and link names of the library.
727011a29bacSmrg	eval shared_ext=\"$shrext_cmds\"
727111a29bacSmrg	eval library_names=\"$library_names_spec\"
727211a29bacSmrg	set dummy $library_names
727311a29bacSmrg	shift
727411a29bacSmrg	realname="$1"
727511a29bacSmrg	shift
727641b2f0bdSmrg
727711a29bacSmrg	if test -n "$soname_spec"; then
727811a29bacSmrg	  eval soname=\"$soname_spec\"
727911a29bacSmrg	else
728011a29bacSmrg	  soname="$realname"
728111a29bacSmrg	fi
728211a29bacSmrg	if test -z "$dlname"; then
728311a29bacSmrg	  dlname=$soname
728411a29bacSmrg	fi
728541b2f0bdSmrg
728611a29bacSmrg	lib="$output_objdir/$realname"
728711a29bacSmrg	linknames=
728811a29bacSmrg	for link
728911a29bacSmrg	do
729011a29bacSmrg	  linknames="$linknames $link"
729111a29bacSmrg	done
729241b2f0bdSmrg
729311a29bacSmrg	# Use standard objects if they are pic
729411a29bacSmrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
729511a29bacSmrg	test "X$libobjs" = "X " && libobjs=
729641b2f0bdSmrg
729711a29bacSmrg	delfiles=
729811a29bacSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
729911a29bacSmrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
730011a29bacSmrg	  export_symbols="$output_objdir/$libname.uexp"
730111a29bacSmrg	  delfiles="$delfiles $export_symbols"
730211a29bacSmrg	fi
730341b2f0bdSmrg
730411a29bacSmrg	orig_export_symbols=
730511a29bacSmrg	case $host_os in
730611a29bacSmrg	cygwin* | mingw* | cegcc*)
730711a29bacSmrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
730811a29bacSmrg	    # exporting using user supplied symfile
730911a29bacSmrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
731011a29bacSmrg	      # and it's NOT already a .def file. Must figure out
731111a29bacSmrg	      # which of the given symbols are data symbols and tag
731211a29bacSmrg	      # them as such. So, trigger use of export_symbols_cmds.
731311a29bacSmrg	      # export_symbols gets reassigned inside the "prepare
731411a29bacSmrg	      # the list of exported symbols" if statement, so the
731511a29bacSmrg	      # include_expsyms logic still works.
731611a29bacSmrg	      orig_export_symbols="$export_symbols"
731711a29bacSmrg	      export_symbols=
731811a29bacSmrg	      always_export_symbols=yes
731911a29bacSmrg	    fi
732011a29bacSmrg	  fi
732111a29bacSmrg	  ;;
732211a29bacSmrg	esac
732341b2f0bdSmrg
732411a29bacSmrg	# Prepare the list of exported symbols
732511a29bacSmrg	if test -z "$export_symbols"; then
732611a29bacSmrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
732711a29bacSmrg	    func_verbose "generating symbol list for \`$libname.la'"
732811a29bacSmrg	    export_symbols="$output_objdir/$libname.exp"
732911a29bacSmrg	    $opt_dry_run || $RM $export_symbols
733011a29bacSmrg	    cmds=$export_symbols_cmds
733111a29bacSmrg	    save_ifs="$IFS"; IFS='~'
733211a29bacSmrg	    for cmd in $cmds; do
733311a29bacSmrg	      IFS="$save_ifs"
733411a29bacSmrg	      eval cmd=\"$cmd\"
733511a29bacSmrg	      func_len " $cmd"
733611a29bacSmrg	      len=$func_len_result
733711a29bacSmrg	      if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
733811a29bacSmrg		func_show_eval "$cmd" 'exit $?'
733911a29bacSmrg		skipped_export=false
734011a29bacSmrg	      else
734111a29bacSmrg		# The command line is too long to execute in one step.
734211a29bacSmrg		func_verbose "using reloadable object file for export list..."
734311a29bacSmrg		skipped_export=:
734411a29bacSmrg		# Break out early, otherwise skipped_export may be
734511a29bacSmrg		# set to false by a later but shorter cmd.
734611a29bacSmrg		break
734711a29bacSmrg	      fi
734811a29bacSmrg	    done
734911a29bacSmrg	    IFS="$save_ifs"
735011a29bacSmrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
735111a29bacSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
735211a29bacSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
735311a29bacSmrg	    fi
735411a29bacSmrg	  fi
735511a29bacSmrg	fi
735641b2f0bdSmrg
735711a29bacSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
735811a29bacSmrg	  tmp_export_symbols="$export_symbols"
735911a29bacSmrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
736011a29bacSmrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
736111a29bacSmrg	fi
736241b2f0bdSmrg
736311a29bacSmrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
736411a29bacSmrg	  # The given exports_symbols file has to be filtered, so filter it.
736511a29bacSmrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
736611a29bacSmrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
736711a29bacSmrg	  # 's' commands which not all seds can handle. GNU sed should be fine
736811a29bacSmrg	  # though. Also, the filter scales superlinearly with the number of
736911a29bacSmrg	  # global variables. join(1) would be nice here, but unfortunately
737011a29bacSmrg	  # isn't a blessed tool.
737111a29bacSmrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
737211a29bacSmrg	  delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
737311a29bacSmrg	  export_symbols=$output_objdir/$libname.def
737411a29bacSmrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
737541b2f0bdSmrg	fi
737641b2f0bdSmrg
737711a29bacSmrg	tmp_deplibs=
737811a29bacSmrg	for test_deplib in $deplibs; do
737911a29bacSmrg	  case " $convenience " in
738011a29bacSmrg	  *" $test_deplib "*) ;;
738111a29bacSmrg	  *)
738211a29bacSmrg	    tmp_deplibs="$tmp_deplibs $test_deplib"
738311a29bacSmrg	    ;;
738411a29bacSmrg	  esac
738511a29bacSmrg	done
738611a29bacSmrg	deplibs="$tmp_deplibs"
738741b2f0bdSmrg
738811a29bacSmrg	if test -n "$convenience"; then
738911a29bacSmrg	  if test -n "$whole_archive_flag_spec" &&
739011a29bacSmrg	    test "$compiler_needs_object" = yes &&
739111a29bacSmrg	    test -z "$libobjs"; then
739211a29bacSmrg	    # extract the archives, so we have objects to list.
739311a29bacSmrg	    # TODO: could optimize this to just extract one archive.
739411a29bacSmrg	    whole_archive_flag_spec=
739511a29bacSmrg	  fi
739611a29bacSmrg	  if test -n "$whole_archive_flag_spec"; then
739711a29bacSmrg	    save_libobjs=$libobjs
739811a29bacSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
739911a29bacSmrg	    test "X$libobjs" = "X " && libobjs=
740011a29bacSmrg	  else
740111a29bacSmrg	    gentop="$output_objdir/${outputname}x"
740211a29bacSmrg	    generated="$generated $gentop"
740341b2f0bdSmrg
740411a29bacSmrg	    func_extract_archives $gentop $convenience
740511a29bacSmrg	    libobjs="$libobjs $func_extract_archives_result"
740611a29bacSmrg	    test "X$libobjs" = "X " && libobjs=
740711a29bacSmrg	  fi
740811a29bacSmrg	fi
740941b2f0bdSmrg
741011a29bacSmrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
741111a29bacSmrg	  eval flag=\"$thread_safe_flag_spec\"
741211a29bacSmrg	  linker_flags="$linker_flags $flag"
741311a29bacSmrg	fi
741441b2f0bdSmrg
741511a29bacSmrg	# Make a backup of the uninstalled library when relinking
741611a29bacSmrg	if test "$mode" = relink; then
741711a29bacSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
741841b2f0bdSmrg	fi
741941b2f0bdSmrg
742011a29bacSmrg	# Do each of the archive commands.
742111a29bacSmrg	if test "$module" = yes && test -n "$module_cmds" ; then
742211a29bacSmrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
742311a29bacSmrg	    eval test_cmds=\"$module_expsym_cmds\"
742411a29bacSmrg	    cmds=$module_expsym_cmds
742511a29bacSmrg	  else
742611a29bacSmrg	    eval test_cmds=\"$module_cmds\"
742711a29bacSmrg	    cmds=$module_cmds
742811a29bacSmrg	  fi
742911a29bacSmrg	else
743011a29bacSmrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
743111a29bacSmrg	    eval test_cmds=\"$archive_expsym_cmds\"
743211a29bacSmrg	    cmds=$archive_expsym_cmds
743311a29bacSmrg	  else
743411a29bacSmrg	    eval test_cmds=\"$archive_cmds\"
743511a29bacSmrg	    cmds=$archive_cmds
743611a29bacSmrg	  fi
743741b2f0bdSmrg	fi
743841b2f0bdSmrg
743911a29bacSmrg	if test "X$skipped_export" != "X:" &&
744011a29bacSmrg	   func_len " $test_cmds" &&
744111a29bacSmrg	   len=$func_len_result &&
744211a29bacSmrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
744311a29bacSmrg	  :
744411a29bacSmrg	else
744511a29bacSmrg	  # The command line is too long to link in one step, link piecewise
744611a29bacSmrg	  # or, if using GNU ld and skipped_export is not :, use a linker
744711a29bacSmrg	  # script.
744841b2f0bdSmrg
744911a29bacSmrg	  # Save the value of $output and $libobjs because we want to
745011a29bacSmrg	  # use them later.  If we have whole_archive_flag_spec, we
745111a29bacSmrg	  # want to use save_libobjs as it was before
745211a29bacSmrg	  # whole_archive_flag_spec was expanded, because we can't
745311a29bacSmrg	  # assume the linker understands whole_archive_flag_spec.
745411a29bacSmrg	  # This may have to be revisited, in case too many
745511a29bacSmrg	  # convenience libraries get linked in and end up exceeding
745611a29bacSmrg	  # the spec.
745711a29bacSmrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
745811a29bacSmrg	    save_libobjs=$libobjs
745911a29bacSmrg	  fi
746011a29bacSmrg	  save_output=$output
746111a29bacSmrg	  func_basename "$output"
746211a29bacSmrg	  output_la=$func_basename_result
746341b2f0bdSmrg
746411a29bacSmrg	  # Clear the reloadable object creation command queue and
746511a29bacSmrg	  # initialize k to one.
746611a29bacSmrg	  test_cmds=
746711a29bacSmrg	  concat_cmds=
746811a29bacSmrg	  objlist=
746911a29bacSmrg	  last_robj=
747011a29bacSmrg	  k=1
747141b2f0bdSmrg
747211a29bacSmrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
747311a29bacSmrg	    output=${output_objdir}/${output_la}.lnkscript
747411a29bacSmrg	    func_verbose "creating GNU ld script: $output"
747511a29bacSmrg	    echo 'INPUT (' > $output
747611a29bacSmrg	    for obj in $save_libobjs
747711a29bacSmrg	    do
747811a29bacSmrg	      $ECHO "$obj" >> $output
747911a29bacSmrg	    done
748011a29bacSmrg	    echo ')' >> $output
748111a29bacSmrg	    delfiles="$delfiles $output"
748211a29bacSmrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
748311a29bacSmrg	    output=${output_objdir}/${output_la}.lnk
748411a29bacSmrg	    func_verbose "creating linker input file list: $output"
748511a29bacSmrg	    : > $output
748611a29bacSmrg	    set x $save_libobjs
748711a29bacSmrg	    shift
748811a29bacSmrg	    firstobj=
748911a29bacSmrg	    if test "$compiler_needs_object" = yes; then
749011a29bacSmrg	      firstobj="$1 "
749111a29bacSmrg	      shift
749211a29bacSmrg	    fi
749311a29bacSmrg	    for obj
749411a29bacSmrg	    do
749511a29bacSmrg	      $ECHO "$obj" >> $output
749611a29bacSmrg	    done
749711a29bacSmrg	    delfiles="$delfiles $output"
749811a29bacSmrg	    output=$firstobj\"$file_list_spec$output\"
749911a29bacSmrg	  else
750011a29bacSmrg	    if test -n "$save_libobjs"; then
750111a29bacSmrg	      func_verbose "creating reloadable object files..."
750211a29bacSmrg	      output=$output_objdir/$output_la-${k}.$objext
750311a29bacSmrg	      eval test_cmds=\"$reload_cmds\"
750411a29bacSmrg	      func_len " $test_cmds"
750511a29bacSmrg	      len0=$func_len_result
750611a29bacSmrg	      len=$len0
750711a29bacSmrg
750811a29bacSmrg	      # Loop over the list of objects to be linked.
750911a29bacSmrg	      for obj in $save_libobjs
751011a29bacSmrg	      do
751111a29bacSmrg		func_len " $obj"
751211a29bacSmrg		func_arith $len + $func_len_result
751311a29bacSmrg		len=$func_arith_result
751411a29bacSmrg		if test "X$objlist" = X ||
751511a29bacSmrg		   test "$len" -lt "$max_cmd_len"; then
751611a29bacSmrg		  func_append objlist " $obj"
751711a29bacSmrg		else
751811a29bacSmrg		  # The command $test_cmds is almost too long, add a
751911a29bacSmrg		  # command to the queue.
752011a29bacSmrg		  if test "$k" -eq 1 ; then
752111a29bacSmrg		    # The first file doesn't have a previous command to add.
752211a29bacSmrg		    reload_objs=$objlist
752311a29bacSmrg		    eval concat_cmds=\"$reload_cmds\"
752411a29bacSmrg		  else
752511a29bacSmrg		    # All subsequent reloadable object files will link in
752611a29bacSmrg		    # the last one created.
752711a29bacSmrg		    reload_objs="$objlist $last_robj"
752811a29bacSmrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
752911a29bacSmrg		  fi
753011a29bacSmrg		  last_robj=$output_objdir/$output_la-${k}.$objext
753111a29bacSmrg		  func_arith $k + 1
753211a29bacSmrg		  k=$func_arith_result
753311a29bacSmrg		  output=$output_objdir/$output_la-${k}.$objext
753411a29bacSmrg		  objlist=" $obj"
753511a29bacSmrg		  func_len " $last_robj"
753611a29bacSmrg		  func_arith $len0 + $func_len_result
753711a29bacSmrg		  len=$func_arith_result
753811a29bacSmrg		fi
753911a29bacSmrg	      done
754011a29bacSmrg	      # Handle the remaining objects by creating one last
754111a29bacSmrg	      # reloadable object file.  All subsequent reloadable object
754211a29bacSmrg	      # files will link in the last one created.
754311a29bacSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
754411a29bacSmrg	      reload_objs="$objlist $last_robj"
754511a29bacSmrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
754611a29bacSmrg	      if test -n "$last_robj"; then
754711a29bacSmrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
754811a29bacSmrg	      fi
754911a29bacSmrg	      delfiles="$delfiles $output"
755011a29bacSmrg
755111a29bacSmrg	    else
755211a29bacSmrg	      output=
755311a29bacSmrg	    fi
755441b2f0bdSmrg
755511a29bacSmrg	    if ${skipped_export-false}; then
755611a29bacSmrg	      func_verbose "generating symbol list for \`$libname.la'"
755711a29bacSmrg	      export_symbols="$output_objdir/$libname.exp"
755811a29bacSmrg	      $opt_dry_run || $RM $export_symbols
755911a29bacSmrg	      libobjs=$output
756011a29bacSmrg	      # Append the command to create the export file.
756111a29bacSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
756211a29bacSmrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
756311a29bacSmrg	      if test -n "$last_robj"; then
756411a29bacSmrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
756511a29bacSmrg	      fi
756611a29bacSmrg	    fi
756741b2f0bdSmrg
756811a29bacSmrg	    test -n "$save_libobjs" &&
756911a29bacSmrg	      func_verbose "creating a temporary reloadable object file: $output"
757041b2f0bdSmrg
757111a29bacSmrg	    # Loop through the commands generated above and execute them.
757211a29bacSmrg	    save_ifs="$IFS"; IFS='~'
757311a29bacSmrg	    for cmd in $concat_cmds; do
757411a29bacSmrg	      IFS="$save_ifs"
757511a29bacSmrg	      $opt_silent || {
757611a29bacSmrg		  func_quote_for_expand "$cmd"
757711a29bacSmrg		  eval "func_echo $func_quote_for_expand_result"
757811a29bacSmrg	      }
757911a29bacSmrg	      $opt_dry_run || eval "$cmd" || {
758011a29bacSmrg		lt_exit=$?
758111a29bacSmrg
758211a29bacSmrg		# Restore the uninstalled library and exit
758311a29bacSmrg		if test "$mode" = relink; then
758411a29bacSmrg		  ( cd "$output_objdir" && \
758511a29bacSmrg		    $RM "${realname}T" && \
758611a29bacSmrg		    $MV "${realname}U" "$realname" )
758711a29bacSmrg		fi
758841b2f0bdSmrg
758911a29bacSmrg		exit $lt_exit
759011a29bacSmrg	      }
759111a29bacSmrg	    done
759211a29bacSmrg	    IFS="$save_ifs"
759341b2f0bdSmrg
759411a29bacSmrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
759511a29bacSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
759611a29bacSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
759741b2f0bdSmrg	    fi
759841b2f0bdSmrg	  fi
759941b2f0bdSmrg
760011a29bacSmrg          if ${skipped_export-false}; then
760111a29bacSmrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
760211a29bacSmrg	      tmp_export_symbols="$export_symbols"
760311a29bacSmrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
760411a29bacSmrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
760511a29bacSmrg	    fi
760641b2f0bdSmrg
760711a29bacSmrg	    if test -n "$orig_export_symbols"; then
760811a29bacSmrg	      # The given exports_symbols file has to be filtered, so filter it.
760911a29bacSmrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
761011a29bacSmrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
761111a29bacSmrg	      # 's' commands which not all seds can handle. GNU sed should be fine
761211a29bacSmrg	      # though. Also, the filter scales superlinearly with the number of
761311a29bacSmrg	      # global variables. join(1) would be nice here, but unfortunately
761411a29bacSmrg	      # isn't a blessed tool.
761511a29bacSmrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
761611a29bacSmrg	      delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
761711a29bacSmrg	      export_symbols=$output_objdir/$libname.def
761811a29bacSmrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
761911a29bacSmrg	    fi
762011a29bacSmrg	  fi
762141b2f0bdSmrg
762211a29bacSmrg	  libobjs=$output
762311a29bacSmrg	  # Restore the value of output.
762411a29bacSmrg	  output=$save_output
762541b2f0bdSmrg
762611a29bacSmrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
762711a29bacSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
762811a29bacSmrg	    test "X$libobjs" = "X " && libobjs=
762911a29bacSmrg	  fi
763011a29bacSmrg	  # Expand the library linking commands again to reset the
763111a29bacSmrg	  # value of $libobjs for piecewise linking.
763211a29bacSmrg
763311a29bacSmrg	  # Do each of the archive commands.
763411a29bacSmrg	  if test "$module" = yes && test -n "$module_cmds" ; then
763511a29bacSmrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
763611a29bacSmrg	      cmds=$module_expsym_cmds
763741b2f0bdSmrg	    else
763811a29bacSmrg	      cmds=$module_cmds
763941b2f0bdSmrg	    fi
764041b2f0bdSmrg	  else
764111a29bacSmrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
764211a29bacSmrg	      cmds=$archive_expsym_cmds
764311a29bacSmrg	    else
764411a29bacSmrg	      cmds=$archive_cmds
764511a29bacSmrg	    fi
764641b2f0bdSmrg	  fi
764741b2f0bdSmrg	fi
764841b2f0bdSmrg
764911a29bacSmrg	if test -n "$delfiles"; then
765011a29bacSmrg	  # Append the command to remove temporary files to $cmds.
765111a29bacSmrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
765211a29bacSmrg	fi
765341b2f0bdSmrg
765411a29bacSmrg	# Add any objects from preloaded convenience libraries
765511a29bacSmrg	if test -n "$dlprefiles"; then
765611a29bacSmrg	  gentop="$output_objdir/${outputname}x"
765711a29bacSmrg	  generated="$generated $gentop"
765841b2f0bdSmrg
765911a29bacSmrg	  func_extract_archives $gentop $dlprefiles
766011a29bacSmrg	  libobjs="$libobjs $func_extract_archives_result"
766111a29bacSmrg	  test "X$libobjs" = "X " && libobjs=
766241b2f0bdSmrg	fi
766341b2f0bdSmrg
766411a29bacSmrg	save_ifs="$IFS"; IFS='~'
766511a29bacSmrg	for cmd in $cmds; do
766611a29bacSmrg	  IFS="$save_ifs"
766711a29bacSmrg	  eval cmd=\"$cmd\"
766811a29bacSmrg	  $opt_silent || {
766911a29bacSmrg	    func_quote_for_expand "$cmd"
767011a29bacSmrg	    eval "func_echo $func_quote_for_expand_result"
767111a29bacSmrg	  }
767211a29bacSmrg	  $opt_dry_run || eval "$cmd" || {
767311a29bacSmrg	    lt_exit=$?
767441b2f0bdSmrg
767511a29bacSmrg	    # Restore the uninstalled library and exit
767611a29bacSmrg	    if test "$mode" = relink; then
767711a29bacSmrg	      ( cd "$output_objdir" && \
767811a29bacSmrg	        $RM "${realname}T" && \
767911a29bacSmrg		$MV "${realname}U" "$realname" )
768041b2f0bdSmrg	    fi
768141b2f0bdSmrg
768211a29bacSmrg	    exit $lt_exit
768311a29bacSmrg	  }
768411a29bacSmrg	done
768511a29bacSmrg	IFS="$save_ifs"
768641b2f0bdSmrg
768711a29bacSmrg	# Restore the uninstalled library and exit
768811a29bacSmrg	if test "$mode" = relink; then
768911a29bacSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
769041b2f0bdSmrg
769111a29bacSmrg	  if test -n "$convenience"; then
769211a29bacSmrg	    if test -z "$whole_archive_flag_spec"; then
769311a29bacSmrg	      func_show_eval '${RM}r "$gentop"'
769411a29bacSmrg	    fi
769511a29bacSmrg	  fi
769641b2f0bdSmrg
769711a29bacSmrg	  exit $EXIT_SUCCESS
769811a29bacSmrg	fi
769941b2f0bdSmrg
770011a29bacSmrg	# Create links to the real library.
770111a29bacSmrg	for linkname in $linknames; do
770211a29bacSmrg	  if test "$realname" != "$linkname"; then
770311a29bacSmrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
770411a29bacSmrg	  fi
770511a29bacSmrg	done
770641b2f0bdSmrg
770711a29bacSmrg	# If -module or -export-dynamic was specified, set the dlname.
770811a29bacSmrg	if test "$module" = yes || test "$export_dynamic" = yes; then
770911a29bacSmrg	  # On all known operating systems, these are identical.
771011a29bacSmrg	  dlname="$soname"
771111a29bacSmrg	fi
771211a29bacSmrg      fi
771311a29bacSmrg      ;;
771441b2f0bdSmrg
771511a29bacSmrg    obj)
771611a29bacSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
771711a29bacSmrg	func_warning "\`-dlopen' is ignored for objects"
771811a29bacSmrg      fi
771941b2f0bdSmrg
772011a29bacSmrg      case " $deplibs" in
772111a29bacSmrg      *\ -l* | *\ -L*)
772211a29bacSmrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
772311a29bacSmrg      esac
772441b2f0bdSmrg
772511a29bacSmrg      test -n "$rpath" && \
772611a29bacSmrg	func_warning "\`-rpath' is ignored for objects"
772741b2f0bdSmrg
772811a29bacSmrg      test -n "$xrpath" && \
772911a29bacSmrg	func_warning "\`-R' is ignored for objects"
773011a29bacSmrg
773111a29bacSmrg      test -n "$vinfo" && \
773211a29bacSmrg	func_warning "\`-version-info' is ignored for objects"
773341b2f0bdSmrg
773411a29bacSmrg      test -n "$release" && \
773511a29bacSmrg	func_warning "\`-release' is ignored for objects"
773641b2f0bdSmrg
773711a29bacSmrg      case $output in
773811a29bacSmrg      *.lo)
773911a29bacSmrg	test -n "$objs$old_deplibs" && \
774011a29bacSmrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
774111a29bacSmrg
774211a29bacSmrg	libobj=$output
774311a29bacSmrg	func_lo2o "$libobj"
774411a29bacSmrg	obj=$func_lo2o_result
774511a29bacSmrg	;;
774611a29bacSmrg      *)
774711a29bacSmrg	libobj=
774811a29bacSmrg	obj="$output"
774941b2f0bdSmrg	;;
775041b2f0bdSmrg      esac
775141b2f0bdSmrg
775211a29bacSmrg      # Delete the old objects.
775311a29bacSmrg      $opt_dry_run || $RM $obj $libobj
775441b2f0bdSmrg
775511a29bacSmrg      # Objects from convenience libraries.  This assumes
775611a29bacSmrg      # single-version convenience libraries.  Whenever we create
775711a29bacSmrg      # different ones for PIC/non-PIC, this we'll have to duplicate
775811a29bacSmrg      # the extraction.
775911a29bacSmrg      reload_conv_objs=
776011a29bacSmrg      gentop=
776111a29bacSmrg      # reload_cmds runs $LD directly, so let us get rid of
776211a29bacSmrg      # -Wl from whole_archive_flag_spec and hope we can get by with
776311a29bacSmrg      # turning comma into space..
776411a29bacSmrg      wl=
776541b2f0bdSmrg
776611a29bacSmrg      if test -n "$convenience"; then
776711a29bacSmrg	if test -n "$whole_archive_flag_spec"; then
776811a29bacSmrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
776911a29bacSmrg	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
777041b2f0bdSmrg	else
777111a29bacSmrg	  gentop="$output_objdir/${obj}x"
777211a29bacSmrg	  generated="$generated $gentop"
777311a29bacSmrg
777411a29bacSmrg	  func_extract_archives $gentop $convenience
777511a29bacSmrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
777641b2f0bdSmrg	fi
777711a29bacSmrg      fi
777841b2f0bdSmrg
777911a29bacSmrg      # Create the old-style object.
778011a29bacSmrg      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
778141b2f0bdSmrg
778211a29bacSmrg      output="$obj"
778311a29bacSmrg      func_execute_cmds "$reload_cmds" 'exit $?'
778441b2f0bdSmrg
778511a29bacSmrg      # Exit if we aren't doing a library object file.
778611a29bacSmrg      if test -z "$libobj"; then
778711a29bacSmrg	if test -n "$gentop"; then
778811a29bacSmrg	  func_show_eval '${RM}r "$gentop"'
778911a29bacSmrg	fi
779041b2f0bdSmrg
779111a29bacSmrg	exit $EXIT_SUCCESS
779241b2f0bdSmrg      fi
779341b2f0bdSmrg
779411a29bacSmrg      if test "$build_libtool_libs" != yes; then
779511a29bacSmrg	if test -n "$gentop"; then
779611a29bacSmrg	  func_show_eval '${RM}r "$gentop"'
779711a29bacSmrg	fi
779841b2f0bdSmrg
779911a29bacSmrg	# Create an invalid libtool object if no PIC, so that we don't
780011a29bacSmrg	# accidentally link it into a program.
780111a29bacSmrg	# $show "echo timestamp > $libobj"
780211a29bacSmrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
780311a29bacSmrg	exit $EXIT_SUCCESS
780411a29bacSmrg      fi
780541b2f0bdSmrg
780611a29bacSmrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
780711a29bacSmrg	# Only do commands if we really have different PIC objects.
780811a29bacSmrg	reload_objs="$libobjs $reload_conv_objs"
780911a29bacSmrg	output="$libobj"
781011a29bacSmrg	func_execute_cmds "$reload_cmds" 'exit $?'
781141b2f0bdSmrg      fi
781211a29bacSmrg
781311a29bacSmrg      if test -n "$gentop"; then
781411a29bacSmrg	func_show_eval '${RM}r "$gentop"'
781511a29bacSmrg      fi
781611a29bacSmrg
781711a29bacSmrg      exit $EXIT_SUCCESS
781841b2f0bdSmrg      ;;
781941b2f0bdSmrg
782011a29bacSmrg    prog)
782111a29bacSmrg      case $host in
782211a29bacSmrg	*cygwin*) func_stripname '' '.exe' "$output"
782311a29bacSmrg	          output=$func_stripname_result.exe;;
782411a29bacSmrg      esac
782511a29bacSmrg      test -n "$vinfo" && \
782611a29bacSmrg	func_warning "\`-version-info' is ignored for programs"
782741b2f0bdSmrg
782811a29bacSmrg      test -n "$release" && \
782911a29bacSmrg	func_warning "\`-release' is ignored for programs"
783041b2f0bdSmrg
783111a29bacSmrg      test "$preload" = yes \
783211a29bacSmrg        && test "$dlopen_support" = unknown \
783311a29bacSmrg	&& test "$dlopen_self" = unknown \
783411a29bacSmrg	&& test "$dlopen_self_static" = unknown && \
783511a29bacSmrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
783611a29bacSmrg
783711a29bacSmrg      case $host in
783811a29bacSmrg      *-*-rhapsody* | *-*-darwin1.[012])
783911a29bacSmrg	# On Rhapsody replace the C library is the System framework
784011a29bacSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
784111a29bacSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
784241b2f0bdSmrg	;;
784311a29bacSmrg      esac
784441b2f0bdSmrg
784511a29bacSmrg      case $host in
784611a29bacSmrg      *-*-darwin*)
784711a29bacSmrg	# Don't allow lazy linking, it breaks C++ global constructors
784811a29bacSmrg	# But is supposedly fixed on 10.4 or later (yay!).
784911a29bacSmrg	if test "$tagname" = CXX ; then
785011a29bacSmrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
785111a29bacSmrg	    10.[0123])
785211a29bacSmrg	      compile_command="$compile_command ${wl}-bind_at_load"
785311a29bacSmrg	      finalize_command="$finalize_command ${wl}-bind_at_load"
785411a29bacSmrg	    ;;
785511a29bacSmrg	  esac
785641b2f0bdSmrg	fi
785711a29bacSmrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
785811a29bacSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
785911a29bacSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
786011a29bacSmrg	;;
786111a29bacSmrg      esac
786241b2f0bdSmrg
786341b2f0bdSmrg
786411a29bacSmrg      # move library search paths that coincide with paths to not yet
786511a29bacSmrg      # installed libraries to the beginning of the library search list
786611a29bacSmrg      new_libs=
786711a29bacSmrg      for path in $notinst_path; do
786811a29bacSmrg	case " $new_libs " in
786911a29bacSmrg	*" -L$path/$objdir "*) ;;
787011a29bacSmrg	*)
787111a29bacSmrg	  case " $compile_deplibs " in
787211a29bacSmrg	  *" -L$path/$objdir "*)
787311a29bacSmrg	    new_libs="$new_libs -L$path/$objdir" ;;
787441b2f0bdSmrg	  esac
787511a29bacSmrg	  ;;
787611a29bacSmrg	esac
787711a29bacSmrg      done
787811a29bacSmrg      for deplib in $compile_deplibs; do
787911a29bacSmrg	case $deplib in
788011a29bacSmrg	-L*)
788111a29bacSmrg	  case " $new_libs " in
788211a29bacSmrg	  *" $deplib "*) ;;
788311a29bacSmrg	  *) new_libs="$new_libs $deplib" ;;
788441b2f0bdSmrg	  esac
788511a29bacSmrg	  ;;
788611a29bacSmrg	*) new_libs="$new_libs $deplib" ;;
788711a29bacSmrg	esac
788811a29bacSmrg      done
788911a29bacSmrg      compile_deplibs="$new_libs"
789041b2f0bdSmrg
789141b2f0bdSmrg
789211a29bacSmrg      compile_command="$compile_command $compile_deplibs"
789311a29bacSmrg      finalize_command="$finalize_command $finalize_deplibs"
789441b2f0bdSmrg
789511a29bacSmrg      if test -n "$rpath$xrpath"; then
789611a29bacSmrg	# If the user specified any rpath flags, then add them.
789711a29bacSmrg	for libdir in $rpath $xrpath; do
789811a29bacSmrg	  # This is the magic to use -rpath.
789911a29bacSmrg	  case "$finalize_rpath " in
790011a29bacSmrg	  *" $libdir "*) ;;
790111a29bacSmrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
790211a29bacSmrg	  esac
790311a29bacSmrg	done
790411a29bacSmrg      fi
790541b2f0bdSmrg
790611a29bacSmrg      # Now hardcode the library paths
790711a29bacSmrg      rpath=
790811a29bacSmrg      hardcode_libdirs=
790911a29bacSmrg      for libdir in $compile_rpath $finalize_rpath; do
791011a29bacSmrg	if test -n "$hardcode_libdir_flag_spec"; then
791111a29bacSmrg	  if test -n "$hardcode_libdir_separator"; then
791211a29bacSmrg	    if test -z "$hardcode_libdirs"; then
791311a29bacSmrg	      hardcode_libdirs="$libdir"
791411a29bacSmrg	    else
791511a29bacSmrg	      # Just accumulate the unique libdirs.
791611a29bacSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
791711a29bacSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
791811a29bacSmrg		;;
791911a29bacSmrg	      *)
792011a29bacSmrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
792111a29bacSmrg		;;
792211a29bacSmrg	      esac
792311a29bacSmrg	    fi
792441b2f0bdSmrg	  else
792511a29bacSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
792611a29bacSmrg	    rpath="$rpath $flag"
792741b2f0bdSmrg	  fi
792811a29bacSmrg	elif test -n "$runpath_var"; then
792911a29bacSmrg	  case "$perm_rpath " in
793011a29bacSmrg	  *" $libdir "*) ;;
793111a29bacSmrg	  *) perm_rpath="$perm_rpath $libdir" ;;
793211a29bacSmrg	  esac
793311a29bacSmrg	fi
793411a29bacSmrg	case $host in
793511a29bacSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
793611a29bacSmrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
793711a29bacSmrg	  case :$dllsearchpath: in
793811a29bacSmrg	  *":$libdir:"*) ;;
793911a29bacSmrg	  ::) dllsearchpath=$libdir;;
794011a29bacSmrg	  *) dllsearchpath="$dllsearchpath:$libdir";;
794111a29bacSmrg	  esac
794211a29bacSmrg	  case :$dllsearchpath: in
794311a29bacSmrg	  *":$testbindir:"*) ;;
794411a29bacSmrg	  ::) dllsearchpath=$testbindir;;
794511a29bacSmrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
794611a29bacSmrg	  esac
794711a29bacSmrg	  ;;
794811a29bacSmrg	esac
794911a29bacSmrg      done
795011a29bacSmrg      # Substitute the hardcoded libdirs into the rpath.
795111a29bacSmrg      if test -n "$hardcode_libdir_separator" &&
795211a29bacSmrg	 test -n "$hardcode_libdirs"; then
795311a29bacSmrg	libdir="$hardcode_libdirs"
795411a29bacSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
795511a29bacSmrg      fi
795611a29bacSmrg      compile_rpath="$rpath"
795741b2f0bdSmrg
795811a29bacSmrg      rpath=
795911a29bacSmrg      hardcode_libdirs=
796011a29bacSmrg      for libdir in $finalize_rpath; do
796111a29bacSmrg	if test -n "$hardcode_libdir_flag_spec"; then
796211a29bacSmrg	  if test -n "$hardcode_libdir_separator"; then
796311a29bacSmrg	    if test -z "$hardcode_libdirs"; then
796411a29bacSmrg	      hardcode_libdirs="$libdir"
796511a29bacSmrg	    else
796611a29bacSmrg	      # Just accumulate the unique libdirs.
796711a29bacSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
796811a29bacSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
796911a29bacSmrg		;;
797011a29bacSmrg	      *)
797111a29bacSmrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
797211a29bacSmrg		;;
797311a29bacSmrg	      esac
797411a29bacSmrg	    fi
797541b2f0bdSmrg	  else
797611a29bacSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
797711a29bacSmrg	    rpath="$rpath $flag"
797841b2f0bdSmrg	  fi
797911a29bacSmrg	elif test -n "$runpath_var"; then
798011a29bacSmrg	  case "$finalize_perm_rpath " in
798111a29bacSmrg	  *" $libdir "*) ;;
798211a29bacSmrg	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
798311a29bacSmrg	  esac
798441b2f0bdSmrg	fi
798511a29bacSmrg      done
798611a29bacSmrg      # Substitute the hardcoded libdirs into the rpath.
798711a29bacSmrg      if test -n "$hardcode_libdir_separator" &&
798811a29bacSmrg	 test -n "$hardcode_libdirs"; then
798911a29bacSmrg	libdir="$hardcode_libdirs"
799011a29bacSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
799111a29bacSmrg      fi
799211a29bacSmrg      finalize_rpath="$rpath"
799341b2f0bdSmrg
799411a29bacSmrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
799511a29bacSmrg	# Transform all the library objects into standard objects.
799611a29bacSmrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
799711a29bacSmrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
799811a29bacSmrg      fi
799941b2f0bdSmrg
800011a29bacSmrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
800141b2f0bdSmrg
800211a29bacSmrg      # template prelinking step
800311a29bacSmrg      if test -n "$prelink_cmds"; then
800411a29bacSmrg	func_execute_cmds "$prelink_cmds" 'exit $?'
800511a29bacSmrg      fi
800641b2f0bdSmrg
800711a29bacSmrg      wrappers_required=yes
800811a29bacSmrg      case $host in
800911a29bacSmrg      *cegcc* | *mingw32ce*)
801011a29bacSmrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
801111a29bacSmrg        wrappers_required=no
801211a29bacSmrg        ;;
801311a29bacSmrg      *cygwin* | *mingw* )
801411a29bacSmrg        if test "$build_libtool_libs" != yes; then
801511a29bacSmrg          wrappers_required=no
801611a29bacSmrg        fi
801711a29bacSmrg        ;;
801811a29bacSmrg      *)
801911a29bacSmrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
802011a29bacSmrg          wrappers_required=no
802111a29bacSmrg        fi
802211a29bacSmrg        ;;
802311a29bacSmrg      esac
802411a29bacSmrg      if test "$wrappers_required" = no; then
802511a29bacSmrg	# Replace the output file specification.
802611a29bacSmrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
802711a29bacSmrg	link_command="$compile_command$compile_rpath"
802841b2f0bdSmrg
802911a29bacSmrg	# We have no uninstalled library dependencies, so finalize right now.
803011a29bacSmrg	exit_status=0
803111a29bacSmrg	func_show_eval "$link_command" 'exit_status=$?'
803241b2f0bdSmrg
803311a29bacSmrg	# Delete the generated files.
803411a29bacSmrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
803511a29bacSmrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
803641b2f0bdSmrg	fi
803741b2f0bdSmrg
803811a29bacSmrg	exit $exit_status
803911a29bacSmrg      fi
804041b2f0bdSmrg
804111a29bacSmrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
804211a29bacSmrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
804311a29bacSmrg      fi
804411a29bacSmrg      if test -n "$finalize_shlibpath"; then
804511a29bacSmrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
804611a29bacSmrg      fi
804741b2f0bdSmrg
804811a29bacSmrg      compile_var=
804911a29bacSmrg      finalize_var=
805011a29bacSmrg      if test -n "$runpath_var"; then
805111a29bacSmrg	if test -n "$perm_rpath"; then
805211a29bacSmrg	  # We should set the runpath_var.
805311a29bacSmrg	  rpath=
805411a29bacSmrg	  for dir in $perm_rpath; do
805511a29bacSmrg	    rpath="$rpath$dir:"
805611a29bacSmrg	  done
805711a29bacSmrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
805841b2f0bdSmrg	fi
805911a29bacSmrg	if test -n "$finalize_perm_rpath"; then
806011a29bacSmrg	  # We should set the runpath_var.
806111a29bacSmrg	  rpath=
806211a29bacSmrg	  for dir in $finalize_perm_rpath; do
806311a29bacSmrg	    rpath="$rpath$dir:"
806411a29bacSmrg	  done
806511a29bacSmrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
806641b2f0bdSmrg	fi
806711a29bacSmrg      fi
806841b2f0bdSmrg
806911a29bacSmrg      if test "$no_install" = yes; then
807011a29bacSmrg	# We don't need to create a wrapper script.
807111a29bacSmrg	link_command="$compile_var$compile_command$compile_rpath"
807211a29bacSmrg	# Replace the output file specification.
807311a29bacSmrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
807411a29bacSmrg	# Delete the old output file.
807511a29bacSmrg	$opt_dry_run || $RM $output
807611a29bacSmrg	# Link the executable and exit
807711a29bacSmrg	func_show_eval "$link_command" 'exit $?'
807841b2f0bdSmrg	exit $EXIT_SUCCESS
807911a29bacSmrg      fi
808041b2f0bdSmrg
808111a29bacSmrg      if test "$hardcode_action" = relink; then
808211a29bacSmrg	# Fast installation is not supported
808311a29bacSmrg	link_command="$compile_var$compile_command$compile_rpath"
808411a29bacSmrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
808511a29bacSmrg
808611a29bacSmrg	func_warning "this platform does not like uninstalled shared libraries"
808711a29bacSmrg	func_warning "\`$output' will be relinked during installation"
808811a29bacSmrg      else
808911a29bacSmrg	if test "$fast_install" != no; then
809011a29bacSmrg	  link_command="$finalize_var$compile_command$finalize_rpath"
809111a29bacSmrg	  if test "$fast_install" = yes; then
809211a29bacSmrg	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
809311a29bacSmrg	  else
809411a29bacSmrg	    # fast_install is set to needless
809511a29bacSmrg	    relink_command=
809611a29bacSmrg	  fi
809741b2f0bdSmrg	else
809811a29bacSmrg	  link_command="$compile_var$compile_command$compile_rpath"
809911a29bacSmrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
810041b2f0bdSmrg	fi
810111a29bacSmrg      fi
810241b2f0bdSmrg
810311a29bacSmrg      # Replace the output file specification.
810411a29bacSmrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
810541b2f0bdSmrg
810611a29bacSmrg      # Delete the old output files.
810711a29bacSmrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
810841b2f0bdSmrg
810911a29bacSmrg      func_show_eval "$link_command" 'exit $?'
811041b2f0bdSmrg
811111a29bacSmrg      # Now create the wrapper script.
811211a29bacSmrg      func_verbose "creating $output"
811341b2f0bdSmrg
811411a29bacSmrg      # Quote the relink command for shipping.
811511a29bacSmrg      if test -n "$relink_command"; then
811611a29bacSmrg	# Preserve any variables that may affect compiler behavior
811711a29bacSmrg	for var in $variables_saved_for_relink; do
811811a29bacSmrg	  if eval test -z \"\${$var+set}\"; then
811911a29bacSmrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
812011a29bacSmrg	  elif eval var_value=\$$var; test -z "$var_value"; then
812111a29bacSmrg	    relink_command="$var=; export $var; $relink_command"
812241b2f0bdSmrg	  else
812311a29bacSmrg	    func_quote_for_eval "$var_value"
812411a29bacSmrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
812541b2f0bdSmrg	  fi
812611a29bacSmrg	done
812711a29bacSmrg	relink_command="(cd `pwd`; $relink_command)"
812811a29bacSmrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
812911a29bacSmrg      fi
813041b2f0bdSmrg
813111a29bacSmrg      # Only actually do things if not in dry run mode.
813211a29bacSmrg      $opt_dry_run || {
813311a29bacSmrg	# win32 will think the script is a binary if it has
813411a29bacSmrg	# a .exe suffix, so we strip it off here.
813511a29bacSmrg	case $output in
813611a29bacSmrg	  *.exe) func_stripname '' '.exe' "$output"
813711a29bacSmrg	         output=$func_stripname_result ;;
813811a29bacSmrg	esac
813911a29bacSmrg	# test for cygwin because mv fails w/o .exe extensions
814011a29bacSmrg	case $host in
814111a29bacSmrg	  *cygwin*)
814211a29bacSmrg	    exeext=.exe
814311a29bacSmrg	    func_stripname '' '.exe' "$outputname"
814411a29bacSmrg	    outputname=$func_stripname_result ;;
814511a29bacSmrg	  *) exeext= ;;
814641b2f0bdSmrg	esac
814711a29bacSmrg	case $host in
814811a29bacSmrg	  *cygwin* | *mingw* )
814911a29bacSmrg	    func_dirname_and_basename "$output" "" "."
815011a29bacSmrg	    output_name=$func_basename_result
815111a29bacSmrg	    output_path=$func_dirname_result
815211a29bacSmrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
815311a29bacSmrg	    cwrapper="$output_path/$output_name.exe"
815411a29bacSmrg	    $RM $cwrappersource $cwrapper
815511a29bacSmrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
815611a29bacSmrg
815711a29bacSmrg	    func_emit_cwrapperexe_src > $cwrappersource
815811a29bacSmrg
815911a29bacSmrg	    # The wrapper executable is built using the $host compiler,
816011a29bacSmrg	    # because it contains $host paths and files. If cross-
816111a29bacSmrg	    # compiling, it, like the target executable, must be
816211a29bacSmrg	    # executed on the $host or under an emulation environment.
816311a29bacSmrg	    $opt_dry_run || {
816411a29bacSmrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
816511a29bacSmrg	      $STRIP $cwrapper
816611a29bacSmrg	    }
816741b2f0bdSmrg
816811a29bacSmrg	    # Now, create the wrapper script for func_source use:
816911a29bacSmrg	    func_ltwrapper_scriptname $cwrapper
817011a29bacSmrg	    $RM $func_ltwrapper_scriptname_result
817111a29bacSmrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
817211a29bacSmrg	    $opt_dry_run || {
817311a29bacSmrg	      # note: this script will not be executed, so do not chmod.
817411a29bacSmrg	      if test "x$build" = "x$host" ; then
817511a29bacSmrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
817611a29bacSmrg	      else
817711a29bacSmrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
817811a29bacSmrg	      fi
817911a29bacSmrg	    }
818011a29bacSmrg	  ;;
818111a29bacSmrg	  * )
818211a29bacSmrg	    $RM $output
818311a29bacSmrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
818441b2f0bdSmrg
818511a29bacSmrg	    func_emit_wrapper no > $output
818611a29bacSmrg	    chmod +x $output
818711a29bacSmrg	  ;;
818811a29bacSmrg	esac
818911a29bacSmrg      }
819011a29bacSmrg      exit $EXIT_SUCCESS
819111a29bacSmrg      ;;
819211a29bacSmrg    esac
819341b2f0bdSmrg
819411a29bacSmrg    # See if we need to build an old-fashioned archive.
819511a29bacSmrg    for oldlib in $oldlibs; do
819641b2f0bdSmrg
819711a29bacSmrg      if test "$build_libtool_libs" = convenience; then
819811a29bacSmrg	oldobjs="$libobjs_save $symfileobj"
819911a29bacSmrg	addlibs="$convenience"
820011a29bacSmrg	build_libtool_libs=no
820111a29bacSmrg      else
820211a29bacSmrg	if test "$build_libtool_libs" = module; then
820311a29bacSmrg	  oldobjs="$libobjs_save"
820411a29bacSmrg	  build_libtool_libs=no
820511a29bacSmrg	else
820611a29bacSmrg	  oldobjs="$old_deplibs $non_pic_objects"
820711a29bacSmrg	  if test "$preload" = yes && test -f "$symfileobj"; then
820811a29bacSmrg	    oldobjs="$oldobjs $symfileobj"
820911a29bacSmrg	  fi
821011a29bacSmrg	fi
821111a29bacSmrg	addlibs="$old_convenience"
821241b2f0bdSmrg      fi
821341b2f0bdSmrg
821411a29bacSmrg      if test -n "$addlibs"; then
821511a29bacSmrg	gentop="$output_objdir/${outputname}x"
821611a29bacSmrg	generated="$generated $gentop"
821741b2f0bdSmrg
821811a29bacSmrg	func_extract_archives $gentop $addlibs
821911a29bacSmrg	oldobjs="$oldobjs $func_extract_archives_result"
822011a29bacSmrg      fi
822141b2f0bdSmrg
822211a29bacSmrg      # Do each command in the archive commands.
822311a29bacSmrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
822411a29bacSmrg	cmds=$old_archive_from_new_cmds
822511a29bacSmrg      else
822641b2f0bdSmrg
822711a29bacSmrg	# Add any objects from preloaded convenience libraries
822811a29bacSmrg	if test -n "$dlprefiles"; then
822911a29bacSmrg	  gentop="$output_objdir/${outputname}x"
823011a29bacSmrg	  generated="$generated $gentop"
823141b2f0bdSmrg
823211a29bacSmrg	  func_extract_archives $gentop $dlprefiles
823311a29bacSmrg	  oldobjs="$oldobjs $func_extract_archives_result"
823411a29bacSmrg	fi
823541b2f0bdSmrg
823611a29bacSmrg	# POSIX demands no paths to be encoded in archives.  We have
823711a29bacSmrg	# to avoid creating archives with duplicate basenames if we
823811a29bacSmrg	# might have to extract them afterwards, e.g., when creating a
823911a29bacSmrg	# static archive out of a convenience library, or when linking
824011a29bacSmrg	# the entirety of a libtool archive into another (currently
824111a29bacSmrg	# not supported by libtool).
824211a29bacSmrg	if (for obj in $oldobjs
824311a29bacSmrg	    do
824411a29bacSmrg	      func_basename "$obj"
824511a29bacSmrg	      $ECHO "$func_basename_result"
824611a29bacSmrg	    done | sort | sort -uc >/dev/null 2>&1); then
824711a29bacSmrg	  :
824811a29bacSmrg	else
824911a29bacSmrg	  echo "copying selected object files to avoid basename conflicts..."
825011a29bacSmrg	  gentop="$output_objdir/${outputname}x"
825111a29bacSmrg	  generated="$generated $gentop"
825211a29bacSmrg	  func_mkdir_p "$gentop"
825311a29bacSmrg	  save_oldobjs=$oldobjs
825411a29bacSmrg	  oldobjs=
825511a29bacSmrg	  counter=1
825611a29bacSmrg	  for obj in $save_oldobjs
825711a29bacSmrg	  do
825811a29bacSmrg	    func_basename "$obj"
825911a29bacSmrg	    objbase="$func_basename_result"
826011a29bacSmrg	    case " $oldobjs " in
826111a29bacSmrg	    " ") oldobjs=$obj ;;
826211a29bacSmrg	    *[\ /]"$objbase "*)
826311a29bacSmrg	      while :; do
826411a29bacSmrg		# Make sure we don't pick an alternate name that also
826511a29bacSmrg		# overlaps.
826611a29bacSmrg		newobj=lt$counter-$objbase
826711a29bacSmrg		func_arith $counter + 1
826811a29bacSmrg		counter=$func_arith_result
826911a29bacSmrg		case " $oldobjs " in
827011a29bacSmrg		*[\ /]"$newobj "*) ;;
827111a29bacSmrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
827211a29bacSmrg		esac
827311a29bacSmrg	      done
827411a29bacSmrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
827511a29bacSmrg	      oldobjs="$oldobjs $gentop/$newobj"
827611a29bacSmrg	      ;;
827711a29bacSmrg	    *) oldobjs="$oldobjs $obj" ;;
827811a29bacSmrg	    esac
827941b2f0bdSmrg	  done
828041b2f0bdSmrg	fi
828111a29bacSmrg	eval cmds=\"$old_archive_cmds\"
828241b2f0bdSmrg
828311a29bacSmrg	func_len " $cmds"
828411a29bacSmrg	len=$func_len_result
828511a29bacSmrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
828611a29bacSmrg	  cmds=$old_archive_cmds
828711a29bacSmrg	else
828811a29bacSmrg	  # the command line is too long to link in one step, link in parts
828911a29bacSmrg	  func_verbose "using piecewise archive linking..."
829011a29bacSmrg	  save_RANLIB=$RANLIB
829111a29bacSmrg	  RANLIB=:
829211a29bacSmrg	  objlist=
829311a29bacSmrg	  concat_cmds=
829411a29bacSmrg	  save_oldobjs=$oldobjs
829511a29bacSmrg	  oldobjs=
829611a29bacSmrg	  # Is there a better way of finding the last object in the list?
829711a29bacSmrg	  for obj in $save_oldobjs
829811a29bacSmrg	  do
829911a29bacSmrg	    last_oldobj=$obj
830011a29bacSmrg	  done
830111a29bacSmrg	  eval test_cmds=\"$old_archive_cmds\"
830211a29bacSmrg	  func_len " $test_cmds"
830311a29bacSmrg	  len0=$func_len_result
830411a29bacSmrg	  len=$len0
830511a29bacSmrg	  for obj in $save_oldobjs
830611a29bacSmrg	  do
830711a29bacSmrg	    func_len " $obj"
830811a29bacSmrg	    func_arith $len + $func_len_result
830911a29bacSmrg	    len=$func_arith_result
831011a29bacSmrg	    func_append objlist " $obj"
831111a29bacSmrg	    if test "$len" -lt "$max_cmd_len"; then
831211a29bacSmrg	      :
831311a29bacSmrg	    else
831411a29bacSmrg	      # the above command should be used before it gets too long
831511a29bacSmrg	      oldobjs=$objlist
831611a29bacSmrg	      if test "$obj" = "$last_oldobj" ; then
831711a29bacSmrg		RANLIB=$save_RANLIB
831811a29bacSmrg	      fi
831911a29bacSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
832011a29bacSmrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
832111a29bacSmrg	      objlist=
832211a29bacSmrg	      len=$len0
832311a29bacSmrg	    fi
832411a29bacSmrg	  done
832511a29bacSmrg	  RANLIB=$save_RANLIB
832611a29bacSmrg	  oldobjs=$objlist
832711a29bacSmrg	  if test "X$oldobjs" = "X" ; then
832811a29bacSmrg	    eval cmds=\"\$concat_cmds\"
832911a29bacSmrg	  else
833011a29bacSmrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
833111a29bacSmrg	  fi
833211a29bacSmrg	fi
833311a29bacSmrg      fi
833411a29bacSmrg      func_execute_cmds "$cmds" 'exit $?'
833541b2f0bdSmrg    done
833641b2f0bdSmrg
833711a29bacSmrg    test -n "$generated" && \
833811a29bacSmrg      func_show_eval "${RM}r$generated"
833941b2f0bdSmrg
834011a29bacSmrg    # Now create the libtool archive.
834111a29bacSmrg    case $output in
834211a29bacSmrg    *.la)
834311a29bacSmrg      old_library=
834411a29bacSmrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
834511a29bacSmrg      func_verbose "creating $output"
834641b2f0bdSmrg
834711a29bacSmrg      # Preserve any variables that may affect compiler behavior
834811a29bacSmrg      for var in $variables_saved_for_relink; do
834911a29bacSmrg	if eval test -z \"\${$var+set}\"; then
835011a29bacSmrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
835111a29bacSmrg	elif eval var_value=\$$var; test -z "$var_value"; then
835211a29bacSmrg	  relink_command="$var=; export $var; $relink_command"
835341b2f0bdSmrg	else
835411a29bacSmrg	  func_quote_for_eval "$var_value"
835511a29bacSmrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
835641b2f0bdSmrg	fi
835711a29bacSmrg      done
835811a29bacSmrg      # Quote the link command for shipping.
835911a29bacSmrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
836011a29bacSmrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
836111a29bacSmrg      if test "$hardcode_automatic" = yes ; then
836211a29bacSmrg	relink_command=
836311a29bacSmrg      fi
836441b2f0bdSmrg
836511a29bacSmrg      # Only create the output if not a dry run.
836611a29bacSmrg      $opt_dry_run || {
836711a29bacSmrg	for installed in no yes; do
836811a29bacSmrg	  if test "$installed" = yes; then
836911a29bacSmrg	    if test -z "$install_libdir"; then
837011a29bacSmrg	      break
837111a29bacSmrg	    fi
837211a29bacSmrg	    output="$output_objdir/$outputname"i
837311a29bacSmrg	    # Replace all uninstalled libtool libraries with the installed ones
837411a29bacSmrg	    newdependency_libs=
837511a29bacSmrg	    for deplib in $dependency_libs; do
837611a29bacSmrg	      case $deplib in
837711a29bacSmrg	      *.la)
837811a29bacSmrg		func_basename "$deplib"
837911a29bacSmrg		name="$func_basename_result"
838011a29bacSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
838111a29bacSmrg		test -z "$libdir" && \
838211a29bacSmrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
838311a29bacSmrg		newdependency_libs="$newdependency_libs $libdir/$name"
838411a29bacSmrg		;;
838511a29bacSmrg	      *) newdependency_libs="$newdependency_libs $deplib" ;;
838611a29bacSmrg	      esac
838711a29bacSmrg	    done
838811a29bacSmrg	    dependency_libs="$newdependency_libs"
838911a29bacSmrg	    newdlfiles=
839011a29bacSmrg
839111a29bacSmrg	    for lib in $dlfiles; do
839211a29bacSmrg	      case $lib in
839311a29bacSmrg	      *.la)
839411a29bacSmrg	        func_basename "$lib"
839511a29bacSmrg		name="$func_basename_result"
839611a29bacSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
839711a29bacSmrg		test -z "$libdir" && \
839811a29bacSmrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
839911a29bacSmrg		newdlfiles="$newdlfiles $libdir/$name"
840011a29bacSmrg		;;
840111a29bacSmrg	      *) newdlfiles="$newdlfiles $lib" ;;
840211a29bacSmrg	      esac
840311a29bacSmrg	    done
840411a29bacSmrg	    dlfiles="$newdlfiles"
840511a29bacSmrg	    newdlprefiles=
840611a29bacSmrg	    for lib in $dlprefiles; do
840711a29bacSmrg	      case $lib in
840811a29bacSmrg	      *.la)
840911a29bacSmrg		# Only pass preopened files to the pseudo-archive (for
841011a29bacSmrg		# eventual linking with the app. that links it) if we
841111a29bacSmrg		# didn't already link the preopened objects directly into
841211a29bacSmrg		# the library:
841311a29bacSmrg		func_basename "$lib"
841411a29bacSmrg		name="$func_basename_result"
841511a29bacSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
841611a29bacSmrg		test -z "$libdir" && \
841711a29bacSmrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
841811a29bacSmrg		newdlprefiles="$newdlprefiles $libdir/$name"
841911a29bacSmrg		;;
842011a29bacSmrg	      esac
842111a29bacSmrg	    done
842211a29bacSmrg	    dlprefiles="$newdlprefiles"
842311a29bacSmrg	  else
842411a29bacSmrg	    newdlfiles=
842511a29bacSmrg	    for lib in $dlfiles; do
842611a29bacSmrg	      case $lib in
842711a29bacSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
842811a29bacSmrg		*) abs=`pwd`"/$lib" ;;
842911a29bacSmrg	      esac
843011a29bacSmrg	      newdlfiles="$newdlfiles $abs"
843111a29bacSmrg	    done
843211a29bacSmrg	    dlfiles="$newdlfiles"
843311a29bacSmrg	    newdlprefiles=
843411a29bacSmrg	    for lib in $dlprefiles; do
843511a29bacSmrg	      case $lib in
843611a29bacSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
843711a29bacSmrg		*) abs=`pwd`"/$lib" ;;
843811a29bacSmrg	      esac
843911a29bacSmrg	      newdlprefiles="$newdlprefiles $abs"
844011a29bacSmrg	    done
844111a29bacSmrg	    dlprefiles="$newdlprefiles"
844211a29bacSmrg	  fi
844311a29bacSmrg	  $RM $output
844411a29bacSmrg	  # place dlname in correct position for cygwin
844511a29bacSmrg	  # In fact, it would be nice if we could use this code for all target
844611a29bacSmrg	  # systems that can't hard-code library paths into their executables
844711a29bacSmrg	  # and that have no shared library path variable independent of PATH,
844811a29bacSmrg	  # but it turns out we can't easily determine that from inspecting
844911a29bacSmrg	  # libtool variables, so we have to hard-code the OSs to which it
845011a29bacSmrg	  # applies here; at the moment, that means platforms that use the PE
845111a29bacSmrg	  # object format with DLL files.  See the long comment at the top of
845211a29bacSmrg	  # tests/bindir.at for full details.
845311a29bacSmrg	  tdlname=$dlname
845411a29bacSmrg	  case $host,$output,$installed,$module,$dlname in
845511a29bacSmrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
845611a29bacSmrg	      # If a -bindir argument was supplied, place the dll there.
845711a29bacSmrg	      if test "x$bindir" != x ;
845811a29bacSmrg	      then
845911a29bacSmrg		func_relative_path "$install_libdir" "$bindir"
846011a29bacSmrg		tdlname=$func_relative_path_result$dlname
846111a29bacSmrg	      else
846211a29bacSmrg		# Otherwise fall back on heuristic.
846311a29bacSmrg		tdlname=../bin/$dlname
846411a29bacSmrg	      fi
846511a29bacSmrg	      ;;
846611a29bacSmrg	  esac
846711a29bacSmrg	  $ECHO > $output "\
846811a29bacSmrg# $outputname - a libtool library file
846911a29bacSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
847011a29bacSmrg#
847111a29bacSmrg# Please DO NOT delete this file!
847211a29bacSmrg# It is necessary for linking the library.
847341b2f0bdSmrg
847411a29bacSmrg# The name that we can dlopen(3).
847511a29bacSmrgdlname='$tdlname'
847641b2f0bdSmrg
847711a29bacSmrg# Names of this library.
847811a29bacSmrglibrary_names='$library_names'
847941b2f0bdSmrg
848011a29bacSmrg# The name of the static archive.
848111a29bacSmrgold_library='$old_library'
848241b2f0bdSmrg
848311a29bacSmrg# Linker flags that can not go in dependency_libs.
848411a29bacSmrginherited_linker_flags='$new_inherited_linker_flags'
848541b2f0bdSmrg
848611a29bacSmrg# Libraries that this one depends upon.
848711a29bacSmrgdependency_libs='$dependency_libs'
848841b2f0bdSmrg
848911a29bacSmrg# Names of additional weak libraries provided by this library
849011a29bacSmrgweak_library_names='$weak_libs'
849141b2f0bdSmrg
849211a29bacSmrg# Version information for $libname.
849311a29bacSmrgcurrent=$current
849411a29bacSmrgage=$age
849511a29bacSmrgrevision=$revision
849641b2f0bdSmrg
849711a29bacSmrg# Is this an already installed library?
849811a29bacSmrginstalled=$installed
849941b2f0bdSmrg
850011a29bacSmrg# Should we warn about portability when linking against -modules?
850111a29bacSmrgshouldnotlink=$module
850241b2f0bdSmrg
850311a29bacSmrg# Files to dlopen/dlpreopen
850411a29bacSmrgdlopen='$dlfiles'
850511a29bacSmrgdlpreopen='$dlprefiles'
850641b2f0bdSmrg
850711a29bacSmrg# Directory that this library needs to be installed in:
850811a29bacSmrglibdir='$install_libdir'"
850911a29bacSmrg	  if test "$installed" = no && test "$need_relink" = yes; then
851011a29bacSmrg	    $ECHO >> $output "\
851111a29bacSmrgrelink_command=\"$relink_command\""
851211a29bacSmrg	  fi
851311a29bacSmrg	done
851411a29bacSmrg      }
851541b2f0bdSmrg
851611a29bacSmrg      # Do a symbolic link so that the libtool archive can be found in
851711a29bacSmrg      # LD_LIBRARY_PATH before the program is installed.
851811a29bacSmrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
851911a29bacSmrg      ;;
852011a29bacSmrg    esac
852111a29bacSmrg    exit $EXIT_SUCCESS
852211a29bacSmrg}
852341b2f0bdSmrg
852411a29bacSmrg{ test "$mode" = link || test "$mode" = relink; } &&
852511a29bacSmrg    func_mode_link ${1+"$@"}
852641b2f0bdSmrg
852741b2f0bdSmrg
852811a29bacSmrg# func_mode_uninstall arg...
852911a29bacSmrgfunc_mode_uninstall ()
853011a29bacSmrg{
853111a29bacSmrg    $opt_debug
853211a29bacSmrg    RM="$nonopt"
853341b2f0bdSmrg    files=
853441b2f0bdSmrg    rmforce=
853541b2f0bdSmrg    exit_status=0
853641b2f0bdSmrg
853741b2f0bdSmrg    # This variable tells wrapper scripts just to set variables rather
853841b2f0bdSmrg    # than running their programs.
853941b2f0bdSmrg    libtool_install_magic="$magic"
854041b2f0bdSmrg
854141b2f0bdSmrg    for arg
854241b2f0bdSmrg    do
854341b2f0bdSmrg      case $arg in
854411a29bacSmrg      -f) RM="$RM $arg"; rmforce=yes ;;
854511a29bacSmrg      -*) RM="$RM $arg" ;;
854641b2f0bdSmrg      *) files="$files $arg" ;;
854741b2f0bdSmrg      esac
854841b2f0bdSmrg    done
854941b2f0bdSmrg
855011a29bacSmrg    test -z "$RM" && \
855111a29bacSmrg      func_fatal_help "you must specify an RM program"
855241b2f0bdSmrg
855341b2f0bdSmrg    rmdirs=
855441b2f0bdSmrg
855541b2f0bdSmrg    origobjdir="$objdir"
855641b2f0bdSmrg    for file in $files; do
855711a29bacSmrg      func_dirname "$file" "" "."
855811a29bacSmrg      dir="$func_dirname_result"
855911a29bacSmrg      if test "X$dir" = X.; then
856041b2f0bdSmrg	objdir="$origobjdir"
856141b2f0bdSmrg      else
856241b2f0bdSmrg	objdir="$dir/$origobjdir"
856341b2f0bdSmrg      fi
856411a29bacSmrg      func_basename "$file"
856511a29bacSmrg      name="$func_basename_result"
856641b2f0bdSmrg      test "$mode" = uninstall && objdir="$dir"
856741b2f0bdSmrg
856841b2f0bdSmrg      # Remember objdir for removal later, being careful to avoid duplicates
856941b2f0bdSmrg      if test "$mode" = clean; then
857041b2f0bdSmrg	case " $rmdirs " in
857141b2f0bdSmrg	  *" $objdir "*) ;;
857241b2f0bdSmrg	  *) rmdirs="$rmdirs $objdir" ;;
857341b2f0bdSmrg	esac
857441b2f0bdSmrg      fi
857541b2f0bdSmrg
857641b2f0bdSmrg      # Don't error if the file doesn't exist and rm -f was used.
857711a29bacSmrg      if { test -L "$file"; } >/dev/null 2>&1 ||
857811a29bacSmrg	 { test -h "$file"; } >/dev/null 2>&1 ||
857911a29bacSmrg	 test -f "$file"; then
858041b2f0bdSmrg	:
858141b2f0bdSmrg      elif test -d "$file"; then
858241b2f0bdSmrg	exit_status=1
858341b2f0bdSmrg	continue
858441b2f0bdSmrg      elif test "$rmforce" = yes; then
858541b2f0bdSmrg	continue
858641b2f0bdSmrg      fi
858741b2f0bdSmrg
858841b2f0bdSmrg      rmfiles="$file"
858941b2f0bdSmrg
859041b2f0bdSmrg      case $name in
859141b2f0bdSmrg      *.la)
859241b2f0bdSmrg	# Possibly a libtool archive, so verify it.
859311a29bacSmrg	if func_lalib_p "$file"; then
859411a29bacSmrg	  func_source $dir/$name
859541b2f0bdSmrg
859641b2f0bdSmrg	  # Delete the libtool libraries and symlinks.
859741b2f0bdSmrg	  for n in $library_names; do
859841b2f0bdSmrg	    rmfiles="$rmfiles $objdir/$n"
859941b2f0bdSmrg	  done
860041b2f0bdSmrg	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
860141b2f0bdSmrg
860241b2f0bdSmrg	  case "$mode" in
860341b2f0bdSmrg	  clean)
860441b2f0bdSmrg	    case "  $library_names " in
860541b2f0bdSmrg	    # "  " in the beginning catches empty $dlname
860641b2f0bdSmrg	    *" $dlname "*) ;;
860741b2f0bdSmrg	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
860841b2f0bdSmrg	    esac
860911a29bacSmrg	    test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
861041b2f0bdSmrg	    ;;
861141b2f0bdSmrg	  uninstall)
861241b2f0bdSmrg	    if test -n "$library_names"; then
861341b2f0bdSmrg	      # Do each command in the postuninstall commands.
861411a29bacSmrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
861541b2f0bdSmrg	    fi
861641b2f0bdSmrg
861741b2f0bdSmrg	    if test -n "$old_library"; then
861841b2f0bdSmrg	      # Do each command in the old_postuninstall commands.
861911a29bacSmrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
862041b2f0bdSmrg	    fi
862141b2f0bdSmrg	    # FIXME: should reinstall the best remaining shared library.
862241b2f0bdSmrg	    ;;
862341b2f0bdSmrg	  esac
862441b2f0bdSmrg	fi
862541b2f0bdSmrg	;;
862641b2f0bdSmrg
862741b2f0bdSmrg      *.lo)
862841b2f0bdSmrg	# Possibly a libtool object, so verify it.
862911a29bacSmrg	if func_lalib_p "$file"; then
863041b2f0bdSmrg
863141b2f0bdSmrg	  # Read the .lo file
863211a29bacSmrg	  func_source $dir/$name
863341b2f0bdSmrg
863441b2f0bdSmrg	  # Add PIC object to the list of files to remove.
863511a29bacSmrg	  if test -n "$pic_object" &&
863611a29bacSmrg	     test "$pic_object" != none; then
863741b2f0bdSmrg	    rmfiles="$rmfiles $dir/$pic_object"
863841b2f0bdSmrg	  fi
863941b2f0bdSmrg
864041b2f0bdSmrg	  # Add non-PIC object to the list of files to remove.
864111a29bacSmrg	  if test -n "$non_pic_object" &&
864211a29bacSmrg	     test "$non_pic_object" != none; then
864341b2f0bdSmrg	    rmfiles="$rmfiles $dir/$non_pic_object"
864441b2f0bdSmrg	  fi
864541b2f0bdSmrg	fi
864641b2f0bdSmrg	;;
864741b2f0bdSmrg
864841b2f0bdSmrg      *)
864941b2f0bdSmrg	if test "$mode" = clean ; then
865041b2f0bdSmrg	  noexename=$name
865141b2f0bdSmrg	  case $file in
865241b2f0bdSmrg	  *.exe)
865311a29bacSmrg	    func_stripname '' '.exe' "$file"
865411a29bacSmrg	    file=$func_stripname_result
865511a29bacSmrg	    func_stripname '' '.exe' "$name"
865611a29bacSmrg	    noexename=$func_stripname_result
865741b2f0bdSmrg	    # $file with .exe has already been added to rmfiles,
865841b2f0bdSmrg	    # add $file without .exe
865941b2f0bdSmrg	    rmfiles="$rmfiles $file"
866041b2f0bdSmrg	    ;;
866141b2f0bdSmrg	  esac
866241b2f0bdSmrg	  # Do a test to see if this is a libtool program.
866311a29bacSmrg	  if func_ltwrapper_p "$file"; then
866411a29bacSmrg	    if func_ltwrapper_executable_p "$file"; then
866511a29bacSmrg	      func_ltwrapper_scriptname "$file"
866611a29bacSmrg	      relink_command=
866711a29bacSmrg	      func_source $func_ltwrapper_scriptname_result
866811a29bacSmrg	      rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
866911a29bacSmrg	    else
867011a29bacSmrg	      relink_command=
867111a29bacSmrg	      func_source $dir/$noexename
867211a29bacSmrg	    fi
867341b2f0bdSmrg
867441b2f0bdSmrg	    # note $name still contains .exe if it was in $file originally
867541b2f0bdSmrg	    # as does the version of $file that was added into $rmfiles
867641b2f0bdSmrg	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
867741b2f0bdSmrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
867841b2f0bdSmrg	      rmfiles="$rmfiles $objdir/lt-$name"
867941b2f0bdSmrg	    fi
868041b2f0bdSmrg	    if test "X$noexename" != "X$name" ; then
868141b2f0bdSmrg	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
868241b2f0bdSmrg	    fi
868341b2f0bdSmrg	  fi
868441b2f0bdSmrg	fi
868541b2f0bdSmrg	;;
868641b2f0bdSmrg      esac
868711a29bacSmrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
868841b2f0bdSmrg    done
868941b2f0bdSmrg    objdir="$origobjdir"
869041b2f0bdSmrg
869141b2f0bdSmrg    # Try to remove the ${objdir}s in the directories where we deleted files
869241b2f0bdSmrg    for dir in $rmdirs; do
869341b2f0bdSmrg      if test -d "$dir"; then
869411a29bacSmrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
869541b2f0bdSmrg      fi
869641b2f0bdSmrg    done
869741b2f0bdSmrg
869841b2f0bdSmrg    exit $exit_status
869911a29bacSmrg}
870041b2f0bdSmrg
870111a29bacSmrg{ test "$mode" = uninstall || test "$mode" = clean; } &&
870211a29bacSmrg    func_mode_uninstall ${1+"$@"}
870341b2f0bdSmrg
870411a29bacSmrgtest -z "$mode" && {
870511a29bacSmrg  help="$generic_help"
870611a29bacSmrg  func_fatal_help "you must specify a MODE"
870711a29bacSmrg}
870811a29bacSmrg
870911a29bacSmrgtest -z "$exec_cmd" && \
871011a29bacSmrg  func_fatal_help "invalid operation mode \`$mode'"
871141b2f0bdSmrg
871241b2f0bdSmrgif test -n "$exec_cmd"; then
871311a29bacSmrg  eval exec "$exec_cmd"
871441b2f0bdSmrg  exit $EXIT_FAILURE
871541b2f0bdSmrgfi
871641b2f0bdSmrg
871711a29bacSmrgexit $exit_status
871841b2f0bdSmrg
871941b2f0bdSmrg
872041b2f0bdSmrg# The TAGs below are defined such that we never get into a situation
872141b2f0bdSmrg# in which we disable both kinds of libraries.  Given conflicting
872241b2f0bdSmrg# choices, we go for a static library, that is the most portable,
872341b2f0bdSmrg# since we can't tell whether shared libraries were disabled because
872441b2f0bdSmrg# the user asked for that or because the platform doesn't support
872541b2f0bdSmrg# them.  This is particularly important on AIX, because we don't
872641b2f0bdSmrg# support having both static and shared libraries enabled at the same
872741b2f0bdSmrg# time on that platform, so we default to a shared-only configuration.
872841b2f0bdSmrg# If a disable-shared tag is given, we'll fallback to a static-only
872941b2f0bdSmrg# configuration.  But we'll never go from static-only to shared-only.
873041b2f0bdSmrg
873141b2f0bdSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
873211a29bacSmrgbuild_libtool_libs=no
873311a29bacSmrgbuild_old_libs=yes
873441b2f0bdSmrg# ### END LIBTOOL TAG CONFIG: disable-shared
873541b2f0bdSmrg
873641b2f0bdSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
873711a29bacSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
873841b2f0bdSmrg# ### END LIBTOOL TAG CONFIG: disable-static
873941b2f0bdSmrg
874041b2f0bdSmrg# Local Variables:
874141b2f0bdSmrg# mode:shell-script
874241b2f0bdSmrg# sh-indentation:2
874341b2f0bdSmrg# End:
874411a29bacSmrg# vi:sw=2
874511a29bacSmrg
8746