ltmain.sh revision 32001f49
132001f49Smrg
232001f49Smrg# libtool (GNU libtool) 2.4.2
332001f49Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
432001f49Smrg
532001f49Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
632001f49Smrg# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
732001f49Smrg# This is free software; see the source for copying conditions.  There is NO
832001f49Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
932001f49Smrg
1032001f49Smrg# GNU Libtool is free software; you can redistribute it and/or modify
1132001f49Smrg# it under the terms of the GNU General Public License as published by
1232001f49Smrg# the Free Software Foundation; either version 2 of the License, or
1332001f49Smrg# (at your option) any later version.
1432001f49Smrg#
1532001f49Smrg# As a special exception to the GNU General Public License,
1632001f49Smrg# if you distribute this file as part of a program or library that
1732001f49Smrg# is built using GNU Libtool, you may include this file under the
1832001f49Smrg# same distribution terms that you use for the rest of that program.
1932001f49Smrg#
2032001f49Smrg# GNU Libtool is distributed in the hope that it will be useful, but
2132001f49Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
2232001f49Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2332001f49Smrg# General Public License for more details.
2432001f49Smrg#
2532001f49Smrg# You should have received a copy of the GNU General Public License
2632001f49Smrg# along with GNU Libtool; see the file COPYING.  If not, a copy
2732001f49Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html,
2832001f49Smrg# or obtained by writing to the Free Software Foundation, Inc.,
2932001f49Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
3032001f49Smrg
3132001f49Smrg# Usage: $progname [OPTION]... [MODE-ARG]...
3232001f49Smrg#
3332001f49Smrg# Provide generalized library-building support services.
3432001f49Smrg#
3532001f49Smrg#       --config             show all configuration variables
3632001f49Smrg#       --debug              enable verbose shell tracing
3732001f49Smrg#   -n, --dry-run            display commands without modifying any files
3832001f49Smrg#       --features           display basic configuration information and exit
3932001f49Smrg#       --mode=MODE          use operation mode MODE
4032001f49Smrg#       --preserve-dup-deps  don't remove duplicate dependency libraries
4132001f49Smrg#       --quiet, --silent    don't print informational messages
4232001f49Smrg#       --no-quiet, --no-silent
4332001f49Smrg#                            print informational messages (default)
4432001f49Smrg#       --no-warn            don't display warning messages
4532001f49Smrg#       --tag=TAG            use configuration variables from tag TAG
4632001f49Smrg#   -v, --verbose            print more informational messages than default
4732001f49Smrg#       --no-verbose         don't print the extra informational messages
4832001f49Smrg#       --version            print version information
4932001f49Smrg#   -h, --help, --help-all   print short, long, or detailed help message
5032001f49Smrg#
5132001f49Smrg# MODE must be one of the following:
5232001f49Smrg#
5332001f49Smrg#         clean              remove files from the build directory
5432001f49Smrg#         compile            compile a source file into a libtool object
5532001f49Smrg#         execute            automatically set library path, then run a program
5632001f49Smrg#         finish             complete the installation of libtool libraries
5732001f49Smrg#         install            install libraries or executables
5832001f49Smrg#         link               create a library or an executable
5932001f49Smrg#         uninstall          remove libraries from an installed directory
6032001f49Smrg#
6132001f49Smrg# MODE-ARGS vary depending on the MODE.  When passed as first option,
6232001f49Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
6332001f49Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
6432001f49Smrg#
6532001f49Smrg# When reporting a bug, please describe a test case to reproduce it and
6632001f49Smrg# include the following information:
6732001f49Smrg#
6832001f49Smrg#         host-triplet:	$host
6932001f49Smrg#         shell:		$SHELL
7032001f49Smrg#         compiler:		$LTCC
7132001f49Smrg#         compiler flags:		$LTCFLAGS
7232001f49Smrg#         linker:		$LD (gnu? $with_gnu_ld)
7332001f49Smrg#         $progname:	(GNU libtool) 2.4.2 Debian-2.4.2-1.7
7432001f49Smrg#         automake:	$automake_version
7532001f49Smrg#         autoconf:	$autoconf_version
7632001f49Smrg#
7732001f49Smrg# Report bugs to <bug-libtool@gnu.org>.
7832001f49Smrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
7932001f49Smrg# General help using GNU software: <http://www.gnu.org/gethelp/>.
8032001f49Smrg
8132001f49SmrgPROGRAM=libtool
8232001f49SmrgPACKAGE=libtool
8332001f49SmrgVERSION="2.4.2 Debian-2.4.2-1.7"
8432001f49SmrgTIMESTAMP=""
8532001f49Smrgpackage_revision=1.3337
8632001f49Smrg
8732001f49Smrg# Be Bourne compatible
8832001f49Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
8932001f49Smrg  emulate sh
9032001f49Smrg  NULLCMD=:
9132001f49Smrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
9232001f49Smrg  # is contrary to our usage.  Disable this feature.
9332001f49Smrg  alias -g '${1+"$@"}'='"$@"'
9432001f49Smrg  setopt NO_GLOB_SUBST
9532001f49Smrgelse
9632001f49Smrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
9732001f49Smrgfi
9832001f49SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
9932001f49SmrgDUALCASE=1; export DUALCASE # for MKS sh
10032001f49Smrg
10132001f49Smrg# A function that is used when there is no print builtin or printf.
10232001f49Smrgfunc_fallback_echo ()
10332001f49Smrg{
10432001f49Smrg  eval 'cat <<_LTECHO_EOF
10532001f49Smrg$1
10632001f49Smrg_LTECHO_EOF'
10732001f49Smrg}
10832001f49Smrg
10932001f49Smrg# NLS nuisances: We save the old values to restore during execute mode.
11032001f49Smrglt_user_locale=
11132001f49Smrglt_safe_locale=
11232001f49Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
11332001f49Smrgdo
11432001f49Smrg  eval "if test \"\${$lt_var+set}\" = set; then
11532001f49Smrg          save_$lt_var=\$$lt_var
11632001f49Smrg          $lt_var=C
11732001f49Smrg	  export $lt_var
11832001f49Smrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
11932001f49Smrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
12032001f49Smrg	fi"
12132001f49Smrgdone
12232001f49SmrgLC_ALL=C
12332001f49SmrgLANGUAGE=C
12432001f49Smrgexport LANGUAGE LC_ALL
12532001f49Smrg
12632001f49Smrg$lt_unset CDPATH
12732001f49Smrg
12832001f49Smrg
12932001f49Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
13032001f49Smrg# is ksh but when the shell is invoked as "sh" and the current value of
13132001f49Smrg# the _XPG environment variable is not equal to 1 (one), the special
13232001f49Smrg# positional parameter $0, within a function call, is the name of the
13332001f49Smrg# function.
13432001f49Smrgprogpath="$0"
13532001f49Smrg
13632001f49Smrg
13732001f49Smrg
13832001f49Smrg: ${CP="cp -f"}
13932001f49Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
14032001f49Smrg: ${MAKE="make"}
14132001f49Smrg: ${MKDIR="mkdir"}
14232001f49Smrg: ${MV="mv -f"}
14332001f49Smrg: ${RM="rm -f"}
14432001f49Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
14532001f49Smrg: ${Xsed="$SED -e 1s/^X//"}
14632001f49Smrg
14732001f49Smrg# Global variables:
14832001f49SmrgEXIT_SUCCESS=0
14932001f49SmrgEXIT_FAILURE=1
15032001f49SmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
15132001f49SmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
15232001f49Smrg
15332001f49Smrgexit_status=$EXIT_SUCCESS
15432001f49Smrg
15532001f49Smrg# Make sure IFS has a sensible default
15632001f49Smrglt_nl='
15732001f49Smrg'
15832001f49SmrgIFS=" 	$lt_nl"
15932001f49Smrg
16032001f49Smrgdirname="s,/[^/]*$,,"
16132001f49Smrgbasename="s,^.*/,,"
16232001f49Smrg
16332001f49Smrg# func_dirname file append nondir_replacement
16432001f49Smrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
16532001f49Smrg# otherwise set result to NONDIR_REPLACEMENT.
16632001f49Smrgfunc_dirname ()
16732001f49Smrg{
16832001f49Smrg    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
16932001f49Smrg    if test "X$func_dirname_result" = "X${1}"; then
17032001f49Smrg      func_dirname_result="${3}"
17132001f49Smrg    else
17232001f49Smrg      func_dirname_result="$func_dirname_result${2}"
17332001f49Smrg    fi
17432001f49Smrg} # func_dirname may be replaced by extended shell implementation
17532001f49Smrg
17632001f49Smrg
17732001f49Smrg# func_basename file
17832001f49Smrgfunc_basename ()
17932001f49Smrg{
18032001f49Smrg    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
18132001f49Smrg} # func_basename may be replaced by extended shell implementation
18232001f49Smrg
18332001f49Smrg
18432001f49Smrg# func_dirname_and_basename file append nondir_replacement
18532001f49Smrg# perform func_basename and func_dirname in a single function
18632001f49Smrg# call:
18732001f49Smrg#   dirname:  Compute the dirname of FILE.  If nonempty,
18832001f49Smrg#             add APPEND to the result, otherwise set result
18932001f49Smrg#             to NONDIR_REPLACEMENT.
19032001f49Smrg#             value returned in "$func_dirname_result"
19132001f49Smrg#   basename: Compute filename of FILE.
19232001f49Smrg#             value retuned in "$func_basename_result"
19332001f49Smrg# Implementation must be kept synchronized with func_dirname
19432001f49Smrg# and func_basename. For efficiency, we do not delegate to
19532001f49Smrg# those functions but instead duplicate the functionality here.
19632001f49Smrgfunc_dirname_and_basename ()
19732001f49Smrg{
19832001f49Smrg    # Extract subdirectory from the argument.
19932001f49Smrg    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
20032001f49Smrg    if test "X$func_dirname_result" = "X${1}"; then
20132001f49Smrg      func_dirname_result="${3}"
20232001f49Smrg    else
20332001f49Smrg      func_dirname_result="$func_dirname_result${2}"
20432001f49Smrg    fi
20532001f49Smrg    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
20632001f49Smrg} # func_dirname_and_basename may be replaced by extended shell implementation
20732001f49Smrg
20832001f49Smrg
20932001f49Smrg# func_stripname prefix suffix name
21032001f49Smrg# strip PREFIX and SUFFIX off of NAME.
21132001f49Smrg# PREFIX and SUFFIX must not contain globbing or regex special
21232001f49Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading
21332001f49Smrg# dot (in which case that matches only a dot).
21432001f49Smrg# func_strip_suffix prefix name
21532001f49Smrgfunc_stripname ()
21632001f49Smrg{
21732001f49Smrg    case ${2} in
21832001f49Smrg      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
21932001f49Smrg      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
22032001f49Smrg    esac
22132001f49Smrg} # func_stripname may be replaced by extended shell implementation
22232001f49Smrg
22332001f49Smrg
22432001f49Smrg# These SED scripts presuppose an absolute path with a trailing slash.
22532001f49Smrgpathcar='s,^/\([^/]*\).*$,\1,'
22632001f49Smrgpathcdr='s,^/[^/]*,,'
22732001f49Smrgremovedotparts=':dotsl
22832001f49Smrg		s@/\./@/@g
22932001f49Smrg		t dotsl
23032001f49Smrg		s,/\.$,/,'
23132001f49Smrgcollapseslashes='s@/\{1,\}@/@g'
23232001f49Smrgfinalslash='s,/*$,/,'
23332001f49Smrg
23432001f49Smrg# func_normal_abspath PATH
23532001f49Smrg# Remove doubled-up and trailing slashes, "." path components,
23632001f49Smrg# and cancel out any ".." path components in PATH after making
23732001f49Smrg# it an absolute path.
23832001f49Smrg#             value returned in "$func_normal_abspath_result"
23932001f49Smrgfunc_normal_abspath ()
24032001f49Smrg{
24132001f49Smrg  # Start from root dir and reassemble the path.
24232001f49Smrg  func_normal_abspath_result=
24332001f49Smrg  func_normal_abspath_tpath=$1
24432001f49Smrg  func_normal_abspath_altnamespace=
24532001f49Smrg  case $func_normal_abspath_tpath in
24632001f49Smrg    "")
24732001f49Smrg      # Empty path, that just means $cwd.
24832001f49Smrg      func_stripname '' '/' "`pwd`"
24932001f49Smrg      func_normal_abspath_result=$func_stripname_result
25032001f49Smrg      return
25132001f49Smrg    ;;
25232001f49Smrg    # The next three entries are used to spot a run of precisely
25332001f49Smrg    # two leading slashes without using negated character classes;
25432001f49Smrg    # we take advantage of case's first-match behaviour.
25532001f49Smrg    ///*)
25632001f49Smrg      # Unusual form of absolute path, do nothing.
25732001f49Smrg    ;;
25832001f49Smrg    //*)
25932001f49Smrg      # Not necessarily an ordinary path; POSIX reserves leading '//'
26032001f49Smrg      # and for example Cygwin uses it to access remote file shares
26132001f49Smrg      # over CIFS/SMB, so we conserve a leading double slash if found.
26232001f49Smrg      func_normal_abspath_altnamespace=/
26332001f49Smrg    ;;
26432001f49Smrg    /*)
26532001f49Smrg      # Absolute path, do nothing.
26632001f49Smrg    ;;
26732001f49Smrg    *)
26832001f49Smrg      # Relative path, prepend $cwd.
26932001f49Smrg      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
27032001f49Smrg    ;;
27132001f49Smrg  esac
27232001f49Smrg  # Cancel out all the simple stuff to save iterations.  We also want
27332001f49Smrg  # the path to end with a slash for ease of parsing, so make sure
27432001f49Smrg  # there is one (and only one) here.
27532001f49Smrg  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
27632001f49Smrg        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
27732001f49Smrg  while :; do
27832001f49Smrg    # Processed it all yet?
27932001f49Smrg    if test "$func_normal_abspath_tpath" = / ; then
28032001f49Smrg      # If we ascended to the root using ".." the result may be empty now.
28132001f49Smrg      if test -z "$func_normal_abspath_result" ; then
28232001f49Smrg        func_normal_abspath_result=/
28332001f49Smrg      fi
28432001f49Smrg      break
28532001f49Smrg    fi
28632001f49Smrg    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
28732001f49Smrg        -e "$pathcar"`
28832001f49Smrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
28932001f49Smrg        -e "$pathcdr"`
29032001f49Smrg    # Figure out what to do with it
29132001f49Smrg    case $func_normal_abspath_tcomponent in
29232001f49Smrg      "")
29332001f49Smrg        # Trailing empty path component, ignore it.
29432001f49Smrg      ;;
29532001f49Smrg      ..)
29632001f49Smrg        # Parent dir; strip last assembled component from result.
29732001f49Smrg        func_dirname "$func_normal_abspath_result"
29832001f49Smrg        func_normal_abspath_result=$func_dirname_result
29932001f49Smrg      ;;
30032001f49Smrg      *)
30132001f49Smrg        # Actual path component, append it.
30232001f49Smrg        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
30332001f49Smrg      ;;
30432001f49Smrg    esac
30532001f49Smrg  done
30632001f49Smrg  # Restore leading double-slash if one was found on entry.
30732001f49Smrg  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
30832001f49Smrg}
30932001f49Smrg
31032001f49Smrg# func_relative_path SRCDIR DSTDIR
31132001f49Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing
31232001f49Smrg# slash if non-empty, suitable for immediately appending a filename
31332001f49Smrg# without needing to append a separator.
31432001f49Smrg#             value returned in "$func_relative_path_result"
31532001f49Smrgfunc_relative_path ()
31632001f49Smrg{
31732001f49Smrg  func_relative_path_result=
31832001f49Smrg  func_normal_abspath "$1"
31932001f49Smrg  func_relative_path_tlibdir=$func_normal_abspath_result
32032001f49Smrg  func_normal_abspath "$2"
32132001f49Smrg  func_relative_path_tbindir=$func_normal_abspath_result
32232001f49Smrg
32332001f49Smrg  # Ascend the tree starting from libdir
32432001f49Smrg  while :; do
32532001f49Smrg    # check if we have found a prefix of bindir
32632001f49Smrg    case $func_relative_path_tbindir in
32732001f49Smrg      $func_relative_path_tlibdir)
32832001f49Smrg        # found an exact match
32932001f49Smrg        func_relative_path_tcancelled=
33032001f49Smrg        break
33132001f49Smrg        ;;
33232001f49Smrg      $func_relative_path_tlibdir*)
33332001f49Smrg        # found a matching prefix
33432001f49Smrg        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
33532001f49Smrg        func_relative_path_tcancelled=$func_stripname_result
33632001f49Smrg        if test -z "$func_relative_path_result"; then
33732001f49Smrg          func_relative_path_result=.
33832001f49Smrg        fi
33932001f49Smrg        break
34032001f49Smrg        ;;
34132001f49Smrg      *)
34232001f49Smrg        func_dirname $func_relative_path_tlibdir
34332001f49Smrg        func_relative_path_tlibdir=${func_dirname_result}
34432001f49Smrg        if test "x$func_relative_path_tlibdir" = x ; then
34532001f49Smrg          # Have to descend all the way to the root!
34632001f49Smrg          func_relative_path_result=../$func_relative_path_result
34732001f49Smrg          func_relative_path_tcancelled=$func_relative_path_tbindir
34832001f49Smrg          break
34932001f49Smrg        fi
35032001f49Smrg        func_relative_path_result=../$func_relative_path_result
35132001f49Smrg        ;;
35232001f49Smrg    esac
35332001f49Smrg  done
35432001f49Smrg
35532001f49Smrg  # Now calculate path; take care to avoid doubling-up slashes.
35632001f49Smrg  func_stripname '' '/' "$func_relative_path_result"
35732001f49Smrg  func_relative_path_result=$func_stripname_result
35832001f49Smrg  func_stripname '/' '/' "$func_relative_path_tcancelled"
35932001f49Smrg  if test "x$func_stripname_result" != x ; then
36032001f49Smrg    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
36132001f49Smrg  fi
36232001f49Smrg
36332001f49Smrg  # Normalisation. If bindir is libdir, return empty string,
36432001f49Smrg  # else relative path ending with a slash; either way, target
36532001f49Smrg  # file name can be directly appended.
36632001f49Smrg  if test ! -z "$func_relative_path_result"; then
36732001f49Smrg    func_stripname './' '' "$func_relative_path_result/"
36832001f49Smrg    func_relative_path_result=$func_stripname_result
36932001f49Smrg  fi
37032001f49Smrg}
37132001f49Smrg
37232001f49Smrg# The name of this program:
37332001f49Smrgfunc_dirname_and_basename "$progpath"
37432001f49Smrgprogname=$func_basename_result
37532001f49Smrg
37632001f49Smrg# Make sure we have an absolute path for reexecution:
37732001f49Smrgcase $progpath in
37832001f49Smrg  [\\/]*|[A-Za-z]:\\*) ;;
37932001f49Smrg  *[\\/]*)
38032001f49Smrg     progdir=$func_dirname_result
38132001f49Smrg     progdir=`cd "$progdir" && pwd`
38232001f49Smrg     progpath="$progdir/$progname"
38332001f49Smrg     ;;
38432001f49Smrg  *)
38532001f49Smrg     save_IFS="$IFS"
38632001f49Smrg     IFS=${PATH_SEPARATOR-:}
38732001f49Smrg     for progdir in $PATH; do
38832001f49Smrg       IFS="$save_IFS"
38932001f49Smrg       test -x "$progdir/$progname" && break
39032001f49Smrg     done
39132001f49Smrg     IFS="$save_IFS"
39232001f49Smrg     test -n "$progdir" || progdir=`pwd`
39332001f49Smrg     progpath="$progdir/$progname"
39432001f49Smrg     ;;
39532001f49Smrgesac
39632001f49Smrg
39732001f49Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
39832001f49Smrg# metacharacters that are still active within double-quoted strings.
39932001f49SmrgXsed="${SED}"' -e 1s/^X//'
40032001f49Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
40132001f49Smrg
40232001f49Smrg# Same as above, but do not quote variable references.
40332001f49Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
40432001f49Smrg
40532001f49Smrg# Sed substitution that turns a string into a regex matching for the
40632001f49Smrg# string literally.
40732001f49Smrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
40832001f49Smrg
40932001f49Smrg# Sed substitution that converts a w32 file name or path
41032001f49Smrg# which contains forward slashes, into one that contains
41132001f49Smrg# (escaped) backslashes.  A very naive implementation.
41232001f49Smrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
41332001f49Smrg
41432001f49Smrg# Re-`\' parameter expansions in output of double_quote_subst that were
41532001f49Smrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
41632001f49Smrg# in input to double_quote_subst, that '$' was protected from expansion.
41732001f49Smrg# Since each input `\' is now two `\'s, look for any number of runs of
41832001f49Smrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
41932001f49Smrgbs='\\'
42032001f49Smrgbs2='\\\\'
42132001f49Smrgbs4='\\\\\\\\'
42232001f49Smrgdollar='\$'
42332001f49Smrgsed_double_backslash="\
42432001f49Smrg  s/$bs4/&\\
42532001f49Smrg/g
42632001f49Smrg  s/^$bs2$dollar/$bs&/
42732001f49Smrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
42832001f49Smrg  s/\n//g"
42932001f49Smrg
43032001f49Smrg# Standard options:
43132001f49Smrgopt_dry_run=false
43232001f49Smrgopt_help=false
43332001f49Smrgopt_quiet=false
43432001f49Smrgopt_verbose=false
43532001f49Smrgopt_warning=:
43632001f49Smrg
43732001f49Smrg# func_echo arg...
43832001f49Smrg# Echo program name prefixed message, along with the current mode
43932001f49Smrg# name if it has been set yet.
44032001f49Smrgfunc_echo ()
44132001f49Smrg{
44232001f49Smrg    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
44332001f49Smrg}
44432001f49Smrg
44532001f49Smrg# func_verbose arg...
44632001f49Smrg# Echo program name prefixed message in verbose mode only.
44732001f49Smrgfunc_verbose ()
44832001f49Smrg{
44932001f49Smrg    $opt_verbose && func_echo ${1+"$@"}
45032001f49Smrg
45132001f49Smrg    # A bug in bash halts the script if the last line of a function
45232001f49Smrg    # fails when set -e is in force, so we need another command to
45332001f49Smrg    # work around that:
45432001f49Smrg    :
45532001f49Smrg}
45632001f49Smrg
45732001f49Smrg# func_echo_all arg...
45832001f49Smrg# Invoke $ECHO with all args, space-separated.
45932001f49Smrgfunc_echo_all ()
46032001f49Smrg{
46132001f49Smrg    $ECHO "$*"
46232001f49Smrg}
46332001f49Smrg
46432001f49Smrg# func_error arg...
46532001f49Smrg# Echo program name prefixed message to standard error.
46632001f49Smrgfunc_error ()
46732001f49Smrg{
46832001f49Smrg    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
46932001f49Smrg}
47032001f49Smrg
47132001f49Smrg# func_warning arg...
47232001f49Smrg# Echo program name prefixed warning message to standard error.
47332001f49Smrgfunc_warning ()
47432001f49Smrg{
47532001f49Smrg    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
47632001f49Smrg
47732001f49Smrg    # bash bug again:
47832001f49Smrg    :
47932001f49Smrg}
48032001f49Smrg
48132001f49Smrg# func_fatal_error arg...
48232001f49Smrg# Echo program name prefixed message to standard error, and exit.
48332001f49Smrgfunc_fatal_error ()
48432001f49Smrg{
48532001f49Smrg    func_error ${1+"$@"}
48632001f49Smrg    exit $EXIT_FAILURE
48732001f49Smrg}
48832001f49Smrg
48932001f49Smrg# func_fatal_help arg...
49032001f49Smrg# Echo program name prefixed message to standard error, followed by
49132001f49Smrg# a help hint, and exit.
49232001f49Smrgfunc_fatal_help ()
49332001f49Smrg{
49432001f49Smrg    func_error ${1+"$@"}
49532001f49Smrg    func_fatal_error "$help"
49632001f49Smrg}
49732001f49Smrghelp="Try \`$progname --help' for more information."  ## default
49832001f49Smrg
49932001f49Smrg
50032001f49Smrg# func_grep expression filename
50132001f49Smrg# Check whether EXPRESSION matches any line of FILENAME, without output.
50232001f49Smrgfunc_grep ()
50332001f49Smrg{
50432001f49Smrg    $GREP "$1" "$2" >/dev/null 2>&1
50532001f49Smrg}
50632001f49Smrg
50732001f49Smrg
50832001f49Smrg# func_mkdir_p directory-path
50932001f49Smrg# Make sure the entire path to DIRECTORY-PATH is available.
51032001f49Smrgfunc_mkdir_p ()
51132001f49Smrg{
51232001f49Smrg    my_directory_path="$1"
51332001f49Smrg    my_dir_list=
51432001f49Smrg
51532001f49Smrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
51632001f49Smrg
51732001f49Smrg      # Protect directory names starting with `-'
51832001f49Smrg      case $my_directory_path in
51932001f49Smrg        -*) my_directory_path="./$my_directory_path" ;;
52032001f49Smrg      esac
52132001f49Smrg
52232001f49Smrg      # While some portion of DIR does not yet exist...
52332001f49Smrg      while test ! -d "$my_directory_path"; do
52432001f49Smrg        # ...make a list in topmost first order.  Use a colon delimited
52532001f49Smrg	# list incase some portion of path contains whitespace.
52632001f49Smrg        my_dir_list="$my_directory_path:$my_dir_list"
52732001f49Smrg
52832001f49Smrg        # If the last portion added has no slash in it, the list is done
52932001f49Smrg        case $my_directory_path in */*) ;; *) break ;; esac
53032001f49Smrg
53132001f49Smrg        # ...otherwise throw away the child directory and loop
53232001f49Smrg        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
53332001f49Smrg      done
53432001f49Smrg      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
53532001f49Smrg
53632001f49Smrg      save_mkdir_p_IFS="$IFS"; IFS=':'
53732001f49Smrg      for my_dir in $my_dir_list; do
53832001f49Smrg	IFS="$save_mkdir_p_IFS"
53932001f49Smrg        # mkdir can fail with a `File exist' error if two processes
54032001f49Smrg        # try to create one of the directories concurrently.  Don't
54132001f49Smrg        # stop in that case!
54232001f49Smrg        $MKDIR "$my_dir" 2>/dev/null || :
54332001f49Smrg      done
54432001f49Smrg      IFS="$save_mkdir_p_IFS"
54532001f49Smrg
54632001f49Smrg      # Bail out if we (or some other process) failed to create a directory.
54732001f49Smrg      test -d "$my_directory_path" || \
54832001f49Smrg        func_fatal_error "Failed to create \`$1'"
54932001f49Smrg    fi
55032001f49Smrg}
55132001f49Smrg
55232001f49Smrg
55332001f49Smrg# func_mktempdir [string]
55432001f49Smrg# Make a temporary directory that won't clash with other running
55532001f49Smrg# libtool processes, and avoids race conditions if possible.  If
55632001f49Smrg# given, STRING is the basename for that directory.
55732001f49Smrgfunc_mktempdir ()
55832001f49Smrg{
55932001f49Smrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
56032001f49Smrg
56132001f49Smrg    if test "$opt_dry_run" = ":"; then
56232001f49Smrg      # Return a directory name, but don't create it in dry-run mode
56332001f49Smrg      my_tmpdir="${my_template}-$$"
56432001f49Smrg    else
56532001f49Smrg
56632001f49Smrg      # If mktemp works, use that first and foremost
56732001f49Smrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
56832001f49Smrg
56932001f49Smrg      if test ! -d "$my_tmpdir"; then
57032001f49Smrg        # Failing that, at least try and use $RANDOM to avoid a race
57132001f49Smrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
57232001f49Smrg
57332001f49Smrg        save_mktempdir_umask=`umask`
57432001f49Smrg        umask 0077
57532001f49Smrg        $MKDIR "$my_tmpdir"
57632001f49Smrg        umask $save_mktempdir_umask
57732001f49Smrg      fi
57832001f49Smrg
57932001f49Smrg      # If we're not in dry-run mode, bomb out on failure
58032001f49Smrg      test -d "$my_tmpdir" || \
58132001f49Smrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
58232001f49Smrg    fi
58332001f49Smrg
58432001f49Smrg    $ECHO "$my_tmpdir"
58532001f49Smrg}
58632001f49Smrg
58732001f49Smrg
58832001f49Smrg# func_quote_for_eval arg
58932001f49Smrg# Aesthetically quote ARG to be evaled later.
59032001f49Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
59132001f49Smrg# is double-quoted, suitable for a subsequent eval, whereas
59232001f49Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
59332001f49Smrg# which are still active within double quotes backslashified.
59432001f49Smrgfunc_quote_for_eval ()
59532001f49Smrg{
59632001f49Smrg    case $1 in
59732001f49Smrg      *[\\\`\"\$]*)
59832001f49Smrg	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
59932001f49Smrg      *)
60032001f49Smrg        func_quote_for_eval_unquoted_result="$1" ;;
60132001f49Smrg    esac
60232001f49Smrg
60332001f49Smrg    case $func_quote_for_eval_unquoted_result in
60432001f49Smrg      # Double-quote args containing shell metacharacters to delay
60532001f49Smrg      # word splitting, command substitution and and variable
60632001f49Smrg      # expansion for a subsequent eval.
60732001f49Smrg      # Many Bourne shells cannot handle close brackets correctly
60832001f49Smrg      # in scan sets, so we specify it separately.
60932001f49Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
61032001f49Smrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
61132001f49Smrg        ;;
61232001f49Smrg      *)
61332001f49Smrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
61432001f49Smrg    esac
61532001f49Smrg}
61632001f49Smrg
61732001f49Smrg
61832001f49Smrg# func_quote_for_expand arg
61932001f49Smrg# Aesthetically quote ARG to be evaled later; same as above,
62032001f49Smrg# but do not quote variable references.
62132001f49Smrgfunc_quote_for_expand ()
62232001f49Smrg{
62332001f49Smrg    case $1 in
62432001f49Smrg      *[\\\`\"]*)
62532001f49Smrg	my_arg=`$ECHO "$1" | $SED \
62632001f49Smrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
62732001f49Smrg      *)
62832001f49Smrg        my_arg="$1" ;;
62932001f49Smrg    esac
63032001f49Smrg
63132001f49Smrg    case $my_arg in
63232001f49Smrg      # Double-quote args containing shell metacharacters to delay
63332001f49Smrg      # word splitting and command substitution for a subsequent eval.
63432001f49Smrg      # Many Bourne shells cannot handle close brackets correctly
63532001f49Smrg      # in scan sets, so we specify it separately.
63632001f49Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
63732001f49Smrg        my_arg="\"$my_arg\""
63832001f49Smrg        ;;
63932001f49Smrg    esac
64032001f49Smrg
64132001f49Smrg    func_quote_for_expand_result="$my_arg"
64232001f49Smrg}
64332001f49Smrg
64432001f49Smrg
64532001f49Smrg# func_show_eval cmd [fail_exp]
64632001f49Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
64732001f49Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
64832001f49Smrg# is given, then evaluate it.
64932001f49Smrgfunc_show_eval ()
65032001f49Smrg{
65132001f49Smrg    my_cmd="$1"
65232001f49Smrg    my_fail_exp="${2-:}"
65332001f49Smrg
65432001f49Smrg    ${opt_silent-false} || {
65532001f49Smrg      func_quote_for_expand "$my_cmd"
65632001f49Smrg      eval "func_echo $func_quote_for_expand_result"
65732001f49Smrg    }
65832001f49Smrg
65932001f49Smrg    if ${opt_dry_run-false}; then :; else
66032001f49Smrg      eval "$my_cmd"
66132001f49Smrg      my_status=$?
66232001f49Smrg      if test "$my_status" -eq 0; then :; else
66332001f49Smrg	eval "(exit $my_status); $my_fail_exp"
66432001f49Smrg      fi
66532001f49Smrg    fi
66632001f49Smrg}
66732001f49Smrg
66832001f49Smrg
66932001f49Smrg# func_show_eval_locale cmd [fail_exp]
67032001f49Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
67132001f49Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
67232001f49Smrg# is given, then evaluate it.  Use the saved locale for evaluation.
67332001f49Smrgfunc_show_eval_locale ()
67432001f49Smrg{
67532001f49Smrg    my_cmd="$1"
67632001f49Smrg    my_fail_exp="${2-:}"
67732001f49Smrg
67832001f49Smrg    ${opt_silent-false} || {
67932001f49Smrg      func_quote_for_expand "$my_cmd"
68032001f49Smrg      eval "func_echo $func_quote_for_expand_result"
68132001f49Smrg    }
68232001f49Smrg
68332001f49Smrg    if ${opt_dry_run-false}; then :; else
68432001f49Smrg      eval "$lt_user_locale
68532001f49Smrg	    $my_cmd"
68632001f49Smrg      my_status=$?
68732001f49Smrg      eval "$lt_safe_locale"
68832001f49Smrg      if test "$my_status" -eq 0; then :; else
68932001f49Smrg	eval "(exit $my_status); $my_fail_exp"
69032001f49Smrg      fi
69132001f49Smrg    fi
69232001f49Smrg}
69332001f49Smrg
69432001f49Smrg# func_tr_sh
69532001f49Smrg# Turn $1 into a string suitable for a shell variable name.
69632001f49Smrg# Result is stored in $func_tr_sh_result.  All characters
69732001f49Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
69832001f49Smrg# if $1 begins with a digit, a '_' is prepended as well.
69932001f49Smrgfunc_tr_sh ()
70032001f49Smrg{
70132001f49Smrg  case $1 in
70232001f49Smrg  [0-9]* | *[!a-zA-Z0-9_]*)
70332001f49Smrg    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
70432001f49Smrg    ;;
70532001f49Smrg  * )
70632001f49Smrg    func_tr_sh_result=$1
70732001f49Smrg    ;;
70832001f49Smrg  esac
70932001f49Smrg}
71032001f49Smrg
71132001f49Smrg
71232001f49Smrg# func_version
71332001f49Smrg# Echo version message to standard output and exit.
71432001f49Smrgfunc_version ()
71532001f49Smrg{
71632001f49Smrg    $opt_debug
71732001f49Smrg
71832001f49Smrg    $SED -n '/(C)/!b go
71932001f49Smrg	:more
72032001f49Smrg	/\./!{
72132001f49Smrg	  N
72232001f49Smrg	  s/\n# / /
72332001f49Smrg	  b more
72432001f49Smrg	}
72532001f49Smrg	:go
72632001f49Smrg	/^# '$PROGRAM' (GNU /,/# warranty; / {
72732001f49Smrg        s/^# //
72832001f49Smrg	s/^# *$//
72932001f49Smrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
73032001f49Smrg        p
73132001f49Smrg     }' < "$progpath"
73232001f49Smrg     exit $?
73332001f49Smrg}
73432001f49Smrg
73532001f49Smrg# func_usage
73632001f49Smrg# Echo short help message to standard output and exit.
73732001f49Smrgfunc_usage ()
73832001f49Smrg{
73932001f49Smrg    $opt_debug
74032001f49Smrg
74132001f49Smrg    $SED -n '/^# Usage:/,/^#  *.*--help/ {
74232001f49Smrg        s/^# //
74332001f49Smrg	s/^# *$//
74432001f49Smrg	s/\$progname/'$progname'/
74532001f49Smrg	p
74632001f49Smrg    }' < "$progpath"
74732001f49Smrg    echo
74832001f49Smrg    $ECHO "run \`$progname --help | more' for full usage"
74932001f49Smrg    exit $?
75032001f49Smrg}
75132001f49Smrg
75232001f49Smrg# func_help [NOEXIT]
75332001f49Smrg# Echo long help message to standard output and exit,
75432001f49Smrg# unless 'noexit' is passed as argument.
75532001f49Smrgfunc_help ()
75632001f49Smrg{
75732001f49Smrg    $opt_debug
75832001f49Smrg
75932001f49Smrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
76032001f49Smrg	:print
76132001f49Smrg        s/^# //
76232001f49Smrg	s/^# *$//
76332001f49Smrg	s*\$progname*'$progname'*
76432001f49Smrg	s*\$host*'"$host"'*
76532001f49Smrg	s*\$SHELL*'"$SHELL"'*
76632001f49Smrg	s*\$LTCC*'"$LTCC"'*
76732001f49Smrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
76832001f49Smrg	s*\$LD*'"$LD"'*
76932001f49Smrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
77032001f49Smrg	s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
77132001f49Smrg	s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
77232001f49Smrg	p
77332001f49Smrg	d
77432001f49Smrg     }
77532001f49Smrg     /^# .* home page:/b print
77632001f49Smrg     /^# General help using/b print
77732001f49Smrg     ' < "$progpath"
77832001f49Smrg    ret=$?
77932001f49Smrg    if test -z "$1"; then
78032001f49Smrg      exit $ret
78132001f49Smrg    fi
78232001f49Smrg}
78332001f49Smrg
78432001f49Smrg# func_missing_arg argname
78532001f49Smrg# Echo program name prefixed message to standard error and set global
78632001f49Smrg# exit_cmd.
78732001f49Smrgfunc_missing_arg ()
78832001f49Smrg{
78932001f49Smrg    $opt_debug
79032001f49Smrg
79132001f49Smrg    func_error "missing argument for $1."
79232001f49Smrg    exit_cmd=exit
79332001f49Smrg}
79432001f49Smrg
79532001f49Smrg
79632001f49Smrg# func_split_short_opt shortopt
79732001f49Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
79832001f49Smrg# variables after splitting SHORTOPT after the 2nd character.
79932001f49Smrgfunc_split_short_opt ()
80032001f49Smrg{
80132001f49Smrg    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
80232001f49Smrg    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
80332001f49Smrg
80432001f49Smrg    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
80532001f49Smrg    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
80632001f49Smrg} # func_split_short_opt may be replaced by extended shell implementation
80732001f49Smrg
80832001f49Smrg
80932001f49Smrg# func_split_long_opt longopt
81032001f49Smrg# Set func_split_long_opt_name and func_split_long_opt_arg shell
81132001f49Smrg# variables after splitting LONGOPT at the `=' sign.
81232001f49Smrgfunc_split_long_opt ()
81332001f49Smrg{
81432001f49Smrg    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
81532001f49Smrg    my_sed_long_arg='1s/^--[^=]*=//'
81632001f49Smrg
81732001f49Smrg    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
81832001f49Smrg    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
81932001f49Smrg} # func_split_long_opt may be replaced by extended shell implementation
82032001f49Smrg
82132001f49Smrgexit_cmd=:
82232001f49Smrg
82332001f49Smrg
82432001f49Smrg
82532001f49Smrg
82632001f49Smrg
82732001f49Smrgmagic="%%%MAGIC variable%%%"
82832001f49Smrgmagic_exe="%%%MAGIC EXE variable%%%"
82932001f49Smrg
83032001f49Smrg# Global variables.
83132001f49Smrgnonopt=
83232001f49Smrgpreserve_args=
83332001f49Smrglo2o="s/\\.lo\$/.${objext}/"
83432001f49Smrgo2lo="s/\\.${objext}\$/.lo/"
83532001f49Smrgextracted_archives=
83632001f49Smrgextracted_serial=0
83732001f49Smrg
83832001f49Smrg# If this variable is set in any of the actions, the command in it
83932001f49Smrg# will be execed at the end.  This prevents here-documents from being
84032001f49Smrg# left over by shells.
84132001f49Smrgexec_cmd=
84232001f49Smrg
84332001f49Smrg# func_append var value
84432001f49Smrg# Append VALUE to the end of shell variable VAR.
84532001f49Smrgfunc_append ()
84632001f49Smrg{
84732001f49Smrg    eval "${1}=\$${1}\${2}"
84832001f49Smrg} # func_append may be replaced by extended shell implementation
84932001f49Smrg
85032001f49Smrg# func_append_quoted var value
85132001f49Smrg# Quote VALUE and append to the end of shell variable VAR, separated
85232001f49Smrg# by a space.
85332001f49Smrgfunc_append_quoted ()
85432001f49Smrg{
85532001f49Smrg    func_quote_for_eval "${2}"
85632001f49Smrg    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
85732001f49Smrg} # func_append_quoted may be replaced by extended shell implementation
85832001f49Smrg
85932001f49Smrg
86032001f49Smrg# func_arith arithmetic-term...
86132001f49Smrgfunc_arith ()
86232001f49Smrg{
86332001f49Smrg    func_arith_result=`expr "${@}"`
86432001f49Smrg} # func_arith may be replaced by extended shell implementation
86532001f49Smrg
86632001f49Smrg
86732001f49Smrg# func_len string
86832001f49Smrg# STRING may not start with a hyphen.
86932001f49Smrgfunc_len ()
87032001f49Smrg{
87132001f49Smrg    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
87232001f49Smrg} # func_len may be replaced by extended shell implementation
87332001f49Smrg
87432001f49Smrg
87532001f49Smrg# func_lo2o object
87632001f49Smrgfunc_lo2o ()
87732001f49Smrg{
87832001f49Smrg    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
87932001f49Smrg} # func_lo2o may be replaced by extended shell implementation
88032001f49Smrg
88132001f49Smrg
88232001f49Smrg# func_xform libobj-or-source
88332001f49Smrgfunc_xform ()
88432001f49Smrg{
88532001f49Smrg    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
88632001f49Smrg} # func_xform may be replaced by extended shell implementation
88732001f49Smrg
88832001f49Smrg
88932001f49Smrg# func_fatal_configuration arg...
89032001f49Smrg# Echo program name prefixed message to standard error, followed by
89132001f49Smrg# a configuration failure hint, and exit.
89232001f49Smrgfunc_fatal_configuration ()
89332001f49Smrg{
89432001f49Smrg    func_error ${1+"$@"}
89532001f49Smrg    func_error "See the $PACKAGE documentation for more information."
89632001f49Smrg    func_fatal_error "Fatal configuration error."
89732001f49Smrg}
89832001f49Smrg
89932001f49Smrg
90032001f49Smrg# func_config
90132001f49Smrg# Display the configuration for all the tags in this script.
90232001f49Smrgfunc_config ()
90332001f49Smrg{
90432001f49Smrg    re_begincf='^# ### BEGIN LIBTOOL'
90532001f49Smrg    re_endcf='^# ### END LIBTOOL'
90632001f49Smrg
90732001f49Smrg    # Default configuration.
90832001f49Smrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
90932001f49Smrg
91032001f49Smrg    # Now print the configurations for the tags.
91132001f49Smrg    for tagname in $taglist; do
91232001f49Smrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
91332001f49Smrg    done
91432001f49Smrg
91532001f49Smrg    exit $?
91632001f49Smrg}
91732001f49Smrg
91832001f49Smrg# func_features
91932001f49Smrg# Display the features supported by this script.
92032001f49Smrgfunc_features ()
92132001f49Smrg{
92232001f49Smrg    echo "host: $host"
92332001f49Smrg    if test "$build_libtool_libs" = yes; then
92432001f49Smrg      echo "enable shared libraries"
92532001f49Smrg    else
92632001f49Smrg      echo "disable shared libraries"
92732001f49Smrg    fi
92832001f49Smrg    if test "$build_old_libs" = yes; then
92932001f49Smrg      echo "enable static libraries"
93032001f49Smrg    else
93132001f49Smrg      echo "disable static libraries"
93232001f49Smrg    fi
93332001f49Smrg
93432001f49Smrg    exit $?
93532001f49Smrg}
93632001f49Smrg
93732001f49Smrg# func_enable_tag tagname
93832001f49Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or
93932001f49Smrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
94032001f49Smrg# variable here.
94132001f49Smrgfunc_enable_tag ()
94232001f49Smrg{
94332001f49Smrg  # Global variable:
94432001f49Smrg  tagname="$1"
94532001f49Smrg
94632001f49Smrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
94732001f49Smrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
94832001f49Smrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
94932001f49Smrg
95032001f49Smrg  # Validate tagname.
95132001f49Smrg  case $tagname in
95232001f49Smrg    *[!-_A-Za-z0-9,/]*)
95332001f49Smrg      func_fatal_error "invalid tag name: $tagname"
95432001f49Smrg      ;;
95532001f49Smrg  esac
95632001f49Smrg
95732001f49Smrg  # Don't test for the "default" C tag, as we know it's
95832001f49Smrg  # there but not specially marked.
95932001f49Smrg  case $tagname in
96032001f49Smrg    CC) ;;
96132001f49Smrg    *)
96232001f49Smrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
96332001f49Smrg	taglist="$taglist $tagname"
96432001f49Smrg
96532001f49Smrg	# Evaluate the configuration.  Be careful to quote the path
96632001f49Smrg	# and the sed script, to avoid splitting on whitespace, but
96732001f49Smrg	# also don't use non-portable quotes within backquotes within
96832001f49Smrg	# quotes we have to do it in 2 steps:
96932001f49Smrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
97032001f49Smrg	eval "$extractedcf"
97132001f49Smrg      else
97232001f49Smrg	func_error "ignoring unknown tag $tagname"
97332001f49Smrg      fi
97432001f49Smrg      ;;
97532001f49Smrg  esac
97632001f49Smrg}
97732001f49Smrg
97832001f49Smrg# func_check_version_match
97932001f49Smrg# Ensure that we are using m4 macros, and libtool script from the same
98032001f49Smrg# release of libtool.
98132001f49Smrgfunc_check_version_match ()
98232001f49Smrg{
98332001f49Smrg  if test "$package_revision" != "$macro_revision"; then
98432001f49Smrg    if test "$VERSION" != "$macro_version"; then
98532001f49Smrg      if test -z "$macro_version"; then
98632001f49Smrg        cat >&2 <<_LT_EOF
98732001f49Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
98832001f49Smrg$progname: definition of this LT_INIT comes from an older release.
98932001f49Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
99032001f49Smrg$progname: and run autoconf again.
99132001f49Smrg_LT_EOF
99232001f49Smrg      else
99332001f49Smrg        cat >&2 <<_LT_EOF
99432001f49Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
99532001f49Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
99632001f49Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
99732001f49Smrg$progname: and run autoconf again.
99832001f49Smrg_LT_EOF
99932001f49Smrg      fi
100032001f49Smrg    else
100132001f49Smrg      cat >&2 <<_LT_EOF
100232001f49Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
100332001f49Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
100432001f49Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
100532001f49Smrg$progname: of $PACKAGE $VERSION and run autoconf again.
100632001f49Smrg_LT_EOF
100732001f49Smrg    fi
100832001f49Smrg
100932001f49Smrg    exit $EXIT_MISMATCH
101032001f49Smrg  fi
101132001f49Smrg}
101232001f49Smrg
101332001f49Smrg
101432001f49Smrg# Shorthand for --mode=foo, only valid as the first argument
101532001f49Smrgcase $1 in
101632001f49Smrgclean|clea|cle|cl)
101732001f49Smrg  shift; set dummy --mode clean ${1+"$@"}; shift
101832001f49Smrg  ;;
101932001f49Smrgcompile|compil|compi|comp|com|co|c)
102032001f49Smrg  shift; set dummy --mode compile ${1+"$@"}; shift
102132001f49Smrg  ;;
102232001f49Smrgexecute|execut|execu|exec|exe|ex|e)
102332001f49Smrg  shift; set dummy --mode execute ${1+"$@"}; shift
102432001f49Smrg  ;;
102532001f49Smrgfinish|finis|fini|fin|fi|f)
102632001f49Smrg  shift; set dummy --mode finish ${1+"$@"}; shift
102732001f49Smrg  ;;
102832001f49Smrginstall|instal|insta|inst|ins|in|i)
102932001f49Smrg  shift; set dummy --mode install ${1+"$@"}; shift
103032001f49Smrg  ;;
103132001f49Smrglink|lin|li|l)
103232001f49Smrg  shift; set dummy --mode link ${1+"$@"}; shift
103332001f49Smrg  ;;
103432001f49Smrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
103532001f49Smrg  shift; set dummy --mode uninstall ${1+"$@"}; shift
103632001f49Smrg  ;;
103732001f49Smrgesac
103832001f49Smrg
103932001f49Smrg
104032001f49Smrg
104132001f49Smrg# Option defaults:
104232001f49Smrgopt_debug=:
104332001f49Smrgopt_dry_run=false
104432001f49Smrgopt_config=false
104532001f49Smrgopt_preserve_dup_deps=false
104632001f49Smrgopt_features=false
104732001f49Smrgopt_finish=false
104832001f49Smrgopt_help=false
104932001f49Smrgopt_help_all=false
105032001f49Smrgopt_silent=:
105132001f49Smrgopt_warning=:
105232001f49Smrgopt_verbose=:
105332001f49Smrgopt_silent=false
105432001f49Smrgopt_verbose=false
105532001f49Smrg
105632001f49Smrg
105732001f49Smrg# Parse options once, thoroughly.  This comes as soon as possible in the
105832001f49Smrg# script to make things like `--version' happen as quickly as we can.
105932001f49Smrg{
106032001f49Smrg  # this just eases exit handling
106132001f49Smrg  while test $# -gt 0; do
106232001f49Smrg    opt="$1"
106332001f49Smrg    shift
106432001f49Smrg    case $opt in
106532001f49Smrg      --debug|-x)	opt_debug='set -x'
106632001f49Smrg			func_echo "enabling shell trace mode"
106732001f49Smrg			$opt_debug
106832001f49Smrg			;;
106932001f49Smrg      --dry-run|--dryrun|-n)
107032001f49Smrg			opt_dry_run=:
107132001f49Smrg			;;
107232001f49Smrg      --config)
107332001f49Smrg			opt_config=:
107432001f49Smrgfunc_config
107532001f49Smrg			;;
107632001f49Smrg      --dlopen|-dlopen)
107732001f49Smrg			optarg="$1"
107832001f49Smrg			opt_dlopen="${opt_dlopen+$opt_dlopen
107932001f49Smrg}$optarg"
108032001f49Smrg			shift
108132001f49Smrg			;;
108232001f49Smrg      --preserve-dup-deps)
108332001f49Smrg			opt_preserve_dup_deps=:
108432001f49Smrg			;;
108532001f49Smrg      --features)
108632001f49Smrg			opt_features=:
108732001f49Smrgfunc_features
108832001f49Smrg			;;
108932001f49Smrg      --finish)
109032001f49Smrg			opt_finish=:
109132001f49Smrgset dummy --mode finish ${1+"$@"}; shift
109232001f49Smrg			;;
109332001f49Smrg      --help)
109432001f49Smrg			opt_help=:
109532001f49Smrg			;;
109632001f49Smrg      --help-all)
109732001f49Smrg			opt_help_all=:
109832001f49Smrgopt_help=': help-all'
109932001f49Smrg			;;
110032001f49Smrg      --mode)
110132001f49Smrg			test $# = 0 && func_missing_arg $opt && break
110232001f49Smrg			optarg="$1"
110332001f49Smrg			opt_mode="$optarg"
110432001f49Smrgcase $optarg in
110532001f49Smrg  # Valid mode arguments:
110632001f49Smrg  clean|compile|execute|finish|install|link|relink|uninstall) ;;
110732001f49Smrg
110832001f49Smrg  # Catch anything else as an error
110932001f49Smrg  *) func_error "invalid argument for $opt"
111032001f49Smrg     exit_cmd=exit
111132001f49Smrg     break
111232001f49Smrg     ;;
111332001f49Smrgesac
111432001f49Smrg			shift
111532001f49Smrg			;;
111632001f49Smrg      --no-silent|--no-quiet)
111732001f49Smrg			opt_silent=false
111832001f49Smrgfunc_append preserve_args " $opt"
111932001f49Smrg			;;
112032001f49Smrg      --no-warning|--no-warn)
112132001f49Smrg			opt_warning=false
112232001f49Smrgfunc_append preserve_args " $opt"
112332001f49Smrg			;;
112432001f49Smrg      --no-verbose)
112532001f49Smrg			opt_verbose=false
112632001f49Smrgfunc_append preserve_args " $opt"
112732001f49Smrg			;;
112832001f49Smrg      --silent|--quiet)
112932001f49Smrg			opt_silent=:
113032001f49Smrgfunc_append preserve_args " $opt"
113132001f49Smrg        opt_verbose=false
113232001f49Smrg			;;
113332001f49Smrg      --verbose|-v)
113432001f49Smrg			opt_verbose=:
113532001f49Smrgfunc_append preserve_args " $opt"
113632001f49Smrgopt_silent=false
113732001f49Smrg			;;
113832001f49Smrg      --tag)
113932001f49Smrg			test $# = 0 && func_missing_arg $opt && break
114032001f49Smrg			optarg="$1"
114132001f49Smrg			opt_tag="$optarg"
114232001f49Smrgfunc_append preserve_args " $opt $optarg"
114332001f49Smrgfunc_enable_tag "$optarg"
114432001f49Smrg			shift
114532001f49Smrg			;;
114632001f49Smrg
114732001f49Smrg      -\?|-h)		func_usage				;;
114832001f49Smrg      --help)		func_help				;;
114932001f49Smrg      --version)	func_version				;;
115032001f49Smrg
115132001f49Smrg      # Separate optargs to long options:
115232001f49Smrg      --*=*)
115332001f49Smrg			func_split_long_opt "$opt"
115432001f49Smrg			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
115532001f49Smrg			shift
115632001f49Smrg			;;
115732001f49Smrg
115832001f49Smrg      # Separate non-argument short options:
115932001f49Smrg      -\?*|-h*|-n*|-v*)
116032001f49Smrg			func_split_short_opt "$opt"
116132001f49Smrg			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
116232001f49Smrg			shift
116332001f49Smrg			;;
116432001f49Smrg
116532001f49Smrg      --)		break					;;
116632001f49Smrg      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
116732001f49Smrg      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
116832001f49Smrg    esac
116932001f49Smrg  done
117032001f49Smrg
117132001f49Smrg  # Validate options:
117232001f49Smrg
117332001f49Smrg  # save first non-option argument
117432001f49Smrg  if test "$#" -gt 0; then
117532001f49Smrg    nonopt="$opt"
117632001f49Smrg    shift
117732001f49Smrg  fi
117832001f49Smrg
117932001f49Smrg  # preserve --debug
118032001f49Smrg  test "$opt_debug" = : || func_append preserve_args " --debug"
118132001f49Smrg
118232001f49Smrg  case $host in
118332001f49Smrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
118432001f49Smrg      # don't eliminate duplications in $postdeps and $predeps
118532001f49Smrg      opt_duplicate_compiler_generated_deps=:
118632001f49Smrg      ;;
118732001f49Smrg    *)
118832001f49Smrg      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
118932001f49Smrg      ;;
119032001f49Smrg  esac
119132001f49Smrg
119232001f49Smrg  $opt_help || {
119332001f49Smrg    # Sanity checks first:
119432001f49Smrg    func_check_version_match
119532001f49Smrg
119632001f49Smrg    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
119732001f49Smrg      func_fatal_configuration "not configured to build any kind of library"
119832001f49Smrg    fi
119932001f49Smrg
120032001f49Smrg    # Darwin sucks
120132001f49Smrg    eval std_shrext=\"$shrext_cmds\"
120232001f49Smrg
120332001f49Smrg    # Only execute mode is allowed to have -dlopen flags.
120432001f49Smrg    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
120532001f49Smrg      func_error "unrecognized option \`-dlopen'"
120632001f49Smrg      $ECHO "$help" 1>&2
120732001f49Smrg      exit $EXIT_FAILURE
120832001f49Smrg    fi
120932001f49Smrg
121032001f49Smrg    # Change the help message to a mode-specific one.
121132001f49Smrg    generic_help="$help"
121232001f49Smrg    help="Try \`$progname --help --mode=$opt_mode' for more information."
121332001f49Smrg  }
121432001f49Smrg
121532001f49Smrg
121632001f49Smrg  # Bail if the options were screwed
121732001f49Smrg  $exit_cmd $EXIT_FAILURE
121832001f49Smrg}
121932001f49Smrg
122032001f49Smrg
122132001f49Smrg
122232001f49Smrg
122332001f49Smrg## ----------- ##
122432001f49Smrg##    Main.    ##
122532001f49Smrg## ----------- ##
122632001f49Smrg
122732001f49Smrg# func_lalib_p file
122832001f49Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
122932001f49Smrg# This function is only a basic sanity check; it will hardly flush out
123032001f49Smrg# determined imposters.
123132001f49Smrgfunc_lalib_p ()
123232001f49Smrg{
123332001f49Smrg    test -f "$1" &&
123432001f49Smrg      $SED -e 4q "$1" 2>/dev/null \
123532001f49Smrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
123632001f49Smrg}
123732001f49Smrg
123832001f49Smrg# func_lalib_unsafe_p file
123932001f49Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
124032001f49Smrg# This function implements the same check as func_lalib_p without
124132001f49Smrg# resorting to external programs.  To this end, it redirects stdin and
124232001f49Smrg# closes it afterwards, without saving the original file descriptor.
124332001f49Smrg# As a safety measure, use it only where a negative result would be
124432001f49Smrg# fatal anyway.  Works if `file' does not exist.
124532001f49Smrgfunc_lalib_unsafe_p ()
124632001f49Smrg{
124732001f49Smrg    lalib_p=no
124832001f49Smrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
124932001f49Smrg	for lalib_p_l in 1 2 3 4
125032001f49Smrg	do
125132001f49Smrg	    read lalib_p_line
125232001f49Smrg	    case "$lalib_p_line" in
125332001f49Smrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
125432001f49Smrg	    esac
125532001f49Smrg	done
125632001f49Smrg	exec 0<&5 5<&-
125732001f49Smrg    fi
125832001f49Smrg    test "$lalib_p" = yes
125932001f49Smrg}
126032001f49Smrg
126132001f49Smrg# func_ltwrapper_script_p file
126232001f49Smrg# True iff FILE is a libtool wrapper script
126332001f49Smrg# This function is only a basic sanity check; it will hardly flush out
126432001f49Smrg# determined imposters.
126532001f49Smrgfunc_ltwrapper_script_p ()
126632001f49Smrg{
126732001f49Smrg    func_lalib_p "$1"
126832001f49Smrg}
126932001f49Smrg
127032001f49Smrg# func_ltwrapper_executable_p file
127132001f49Smrg# True iff FILE is a libtool wrapper executable
127232001f49Smrg# This function is only a basic sanity check; it will hardly flush out
127332001f49Smrg# determined imposters.
127432001f49Smrgfunc_ltwrapper_executable_p ()
127532001f49Smrg{
127632001f49Smrg    func_ltwrapper_exec_suffix=
127732001f49Smrg    case $1 in
127832001f49Smrg    *.exe) ;;
127932001f49Smrg    *) func_ltwrapper_exec_suffix=.exe ;;
128032001f49Smrg    esac
128132001f49Smrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
128232001f49Smrg}
128332001f49Smrg
128432001f49Smrg# func_ltwrapper_scriptname file
128532001f49Smrg# Assumes file is an ltwrapper_executable
128632001f49Smrg# uses $file to determine the appropriate filename for a
128732001f49Smrg# temporary ltwrapper_script.
128832001f49Smrgfunc_ltwrapper_scriptname ()
128932001f49Smrg{
129032001f49Smrg    func_dirname_and_basename "$1" "" "."
129132001f49Smrg    func_stripname '' '.exe' "$func_basename_result"
129232001f49Smrg    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
129332001f49Smrg}
129432001f49Smrg
129532001f49Smrg# func_ltwrapper_p file
129632001f49Smrg# True iff FILE is a libtool wrapper script or wrapper executable
129732001f49Smrg# This function is only a basic sanity check; it will hardly flush out
129832001f49Smrg# determined imposters.
129932001f49Smrgfunc_ltwrapper_p ()
130032001f49Smrg{
130132001f49Smrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
130232001f49Smrg}
130332001f49Smrg
130432001f49Smrg
130532001f49Smrg# func_execute_cmds commands fail_cmd
130632001f49Smrg# Execute tilde-delimited COMMANDS.
130732001f49Smrg# If FAIL_CMD is given, eval that upon failure.
130832001f49Smrg# FAIL_CMD may read-access the current command in variable CMD!
130932001f49Smrgfunc_execute_cmds ()
131032001f49Smrg{
131132001f49Smrg    $opt_debug
131232001f49Smrg    save_ifs=$IFS; IFS='~'
131332001f49Smrg    for cmd in $1; do
131432001f49Smrg      IFS=$save_ifs
131532001f49Smrg      eval cmd=\"$cmd\"
131632001f49Smrg      func_show_eval "$cmd" "${2-:}"
131732001f49Smrg    done
131832001f49Smrg    IFS=$save_ifs
131932001f49Smrg}
132032001f49Smrg
132132001f49Smrg
132232001f49Smrg# func_source file
132332001f49Smrg# Source FILE, adding directory component if necessary.
132432001f49Smrg# Note that it is not necessary on cygwin/mingw to append a dot to
132532001f49Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
132632001f49Smrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
132732001f49Smrg# `FILE.' does not work on cygwin managed mounts.
132832001f49Smrgfunc_source ()
132932001f49Smrg{
133032001f49Smrg    $opt_debug
133132001f49Smrg    case $1 in
133232001f49Smrg    */* | *\\*)	. "$1" ;;
133332001f49Smrg    *)		. "./$1" ;;
133432001f49Smrg    esac
133532001f49Smrg}
133632001f49Smrg
133732001f49Smrg
133832001f49Smrg# func_resolve_sysroot PATH
133932001f49Smrg# Replace a leading = in PATH with a sysroot.  Store the result into
134032001f49Smrg# func_resolve_sysroot_result
134132001f49Smrgfunc_resolve_sysroot ()
134232001f49Smrg{
134332001f49Smrg  func_resolve_sysroot_result=$1
134432001f49Smrg  case $func_resolve_sysroot_result in
134532001f49Smrg  =*)
134632001f49Smrg    func_stripname '=' '' "$func_resolve_sysroot_result"
134732001f49Smrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
134832001f49Smrg    ;;
134932001f49Smrg  esac
135032001f49Smrg}
135132001f49Smrg
135232001f49Smrg# func_replace_sysroot PATH
135332001f49Smrg# If PATH begins with the sysroot, replace it with = and
135432001f49Smrg# store the result into func_replace_sysroot_result.
135532001f49Smrgfunc_replace_sysroot ()
135632001f49Smrg{
135732001f49Smrg  case "$lt_sysroot:$1" in
135832001f49Smrg  ?*:"$lt_sysroot"*)
135932001f49Smrg    func_stripname "$lt_sysroot" '' "$1"
136032001f49Smrg    func_replace_sysroot_result="=$func_stripname_result"
136132001f49Smrg    ;;
136232001f49Smrg  *)
136332001f49Smrg    # Including no sysroot.
136432001f49Smrg    func_replace_sysroot_result=$1
136532001f49Smrg    ;;
136632001f49Smrg  esac
136732001f49Smrg}
136832001f49Smrg
136932001f49Smrg# func_infer_tag arg
137032001f49Smrg# Infer tagged configuration to use if any are available and
137132001f49Smrg# if one wasn't chosen via the "--tag" command line option.
137232001f49Smrg# Only attempt this if the compiler in the base compile
137332001f49Smrg# command doesn't match the default compiler.
137432001f49Smrg# arg is usually of the form 'gcc ...'
137532001f49Smrgfunc_infer_tag ()
137632001f49Smrg{
137732001f49Smrg    $opt_debug
137832001f49Smrg    if test -n "$available_tags" && test -z "$tagname"; then
137932001f49Smrg      CC_quoted=
138032001f49Smrg      for arg in $CC; do
138132001f49Smrg	func_append_quoted CC_quoted "$arg"
138232001f49Smrg      done
138332001f49Smrg      CC_expanded=`func_echo_all $CC`
138432001f49Smrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
138532001f49Smrg      case $@ in
138632001f49Smrg      # Blanks in the command may have been stripped by the calling shell,
138732001f49Smrg      # but not from the CC environment variable when configure was run.
138832001f49Smrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
138932001f49Smrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
139032001f49Smrg      # Blanks at the start of $base_compile will cause this to fail
139132001f49Smrg      # if we don't check for them as well.
139232001f49Smrg      *)
139332001f49Smrg	for z in $available_tags; do
139432001f49Smrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
139532001f49Smrg	    # Evaluate the configuration.
139632001f49Smrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
139732001f49Smrg	    CC_quoted=
139832001f49Smrg	    for arg in $CC; do
139932001f49Smrg	      # Double-quote args containing other shell metacharacters.
140032001f49Smrg	      func_append_quoted CC_quoted "$arg"
140132001f49Smrg	    done
140232001f49Smrg	    CC_expanded=`func_echo_all $CC`
140332001f49Smrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
140432001f49Smrg	    case "$@ " in
140532001f49Smrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
140632001f49Smrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
140732001f49Smrg	      # The compiler in the base compile command matches
140832001f49Smrg	      # the one in the tagged configuration.
140932001f49Smrg	      # Assume this is the tagged configuration we want.
141032001f49Smrg	      tagname=$z
141132001f49Smrg	      break
141232001f49Smrg	      ;;
141332001f49Smrg	    esac
141432001f49Smrg	  fi
141532001f49Smrg	done
141632001f49Smrg	# If $tagname still isn't set, then no tagged configuration
141732001f49Smrg	# was found and let the user know that the "--tag" command
141832001f49Smrg	# line option must be used.
141932001f49Smrg	if test -z "$tagname"; then
142032001f49Smrg	  func_echo "unable to infer tagged configuration"
142132001f49Smrg	  func_fatal_error "specify a tag with \`--tag'"
142232001f49Smrg#	else
142332001f49Smrg#	  func_verbose "using $tagname tagged configuration"
142432001f49Smrg	fi
142532001f49Smrg	;;
142632001f49Smrg      esac
142732001f49Smrg    fi
142832001f49Smrg}
142932001f49Smrg
143032001f49Smrg
143132001f49Smrg
143232001f49Smrg# func_write_libtool_object output_name pic_name nonpic_name
143332001f49Smrg# Create a libtool object file (analogous to a ".la" file),
143432001f49Smrg# but don't create it if we're doing a dry run.
143532001f49Smrgfunc_write_libtool_object ()
143632001f49Smrg{
143732001f49Smrg    write_libobj=${1}
143832001f49Smrg    if test "$build_libtool_libs" = yes; then
143932001f49Smrg      write_lobj=\'${2}\'
144032001f49Smrg    else
144132001f49Smrg      write_lobj=none
144232001f49Smrg    fi
144332001f49Smrg
144432001f49Smrg    if test "$build_old_libs" = yes; then
144532001f49Smrg      write_oldobj=\'${3}\'
144632001f49Smrg    else
144732001f49Smrg      write_oldobj=none
144832001f49Smrg    fi
144932001f49Smrg
145032001f49Smrg    $opt_dry_run || {
145132001f49Smrg      cat >${write_libobj}T <<EOF
145232001f49Smrg# $write_libobj - a libtool object file
145332001f49Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
145432001f49Smrg#
145532001f49Smrg# Please DO NOT delete this file!
145632001f49Smrg# It is necessary for linking the library.
145732001f49Smrg
145832001f49Smrg# Name of the PIC object.
145932001f49Smrgpic_object=$write_lobj
146032001f49Smrg
146132001f49Smrg# Name of the non-PIC object
146232001f49Smrgnon_pic_object=$write_oldobj
146332001f49Smrg
146432001f49SmrgEOF
146532001f49Smrg      $MV "${write_libobj}T" "${write_libobj}"
146632001f49Smrg    }
146732001f49Smrg}
146832001f49Smrg
146932001f49Smrg
147032001f49Smrg##################################################
147132001f49Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
147232001f49Smrg##################################################
147332001f49Smrg
147432001f49Smrg# func_convert_core_file_wine_to_w32 ARG
147532001f49Smrg# Helper function used by file name conversion functions when $build is *nix,
147632001f49Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
147732001f49Smrg# correctly configured wine environment available, with the winepath program
147832001f49Smrg# in $build's $PATH.
147932001f49Smrg#
148032001f49Smrg# ARG is the $build file name to be converted to w32 format.
148132001f49Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
148232001f49Smrg# be empty on error (or when ARG is empty)
148332001f49Smrgfunc_convert_core_file_wine_to_w32 ()
148432001f49Smrg{
148532001f49Smrg  $opt_debug
148632001f49Smrg  func_convert_core_file_wine_to_w32_result="$1"
148732001f49Smrg  if test -n "$1"; then
148832001f49Smrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
148932001f49Smrg    # are forced to check the contents of stdout. On the other hand, if the
149032001f49Smrg    # command is not found, the shell will set an exit code of 127 and print
149132001f49Smrg    # *an error message* to stdout. So we must check for both error code of
149232001f49Smrg    # zero AND non-empty stdout, which explains the odd construction:
149332001f49Smrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
149432001f49Smrg    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
149532001f49Smrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
149632001f49Smrg        $SED -e "$lt_sed_naive_backslashify"`
149732001f49Smrg    else
149832001f49Smrg      func_convert_core_file_wine_to_w32_result=
149932001f49Smrg    fi
150032001f49Smrg  fi
150132001f49Smrg}
150232001f49Smrg# end: func_convert_core_file_wine_to_w32
150332001f49Smrg
150432001f49Smrg
150532001f49Smrg# func_convert_core_path_wine_to_w32 ARG
150632001f49Smrg# Helper function used by path conversion functions when $build is *nix, and
150732001f49Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
150832001f49Smrg# configured wine environment available, with the winepath program in $build's
150932001f49Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
151032001f49Smrg#
151132001f49Smrg# ARG is path to be converted from $build format to win32.
151232001f49Smrg# Result is available in $func_convert_core_path_wine_to_w32_result.
151332001f49Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
151432001f49Smrg# are convertible, then the result may be empty.
151532001f49Smrgfunc_convert_core_path_wine_to_w32 ()
151632001f49Smrg{
151732001f49Smrg  $opt_debug
151832001f49Smrg  # unfortunately, winepath doesn't convert paths, only file names
151932001f49Smrg  func_convert_core_path_wine_to_w32_result=""
152032001f49Smrg  if test -n "$1"; then
152132001f49Smrg    oldIFS=$IFS
152232001f49Smrg    IFS=:
152332001f49Smrg    for func_convert_core_path_wine_to_w32_f in $1; do
152432001f49Smrg      IFS=$oldIFS
152532001f49Smrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
152632001f49Smrg      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
152732001f49Smrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
152832001f49Smrg          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
152932001f49Smrg        else
153032001f49Smrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
153132001f49Smrg        fi
153232001f49Smrg      fi
153332001f49Smrg    done
153432001f49Smrg    IFS=$oldIFS
153532001f49Smrg  fi
153632001f49Smrg}
153732001f49Smrg# end: func_convert_core_path_wine_to_w32
153832001f49Smrg
153932001f49Smrg
154032001f49Smrg# func_cygpath ARGS...
154132001f49Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
154232001f49Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
154332001f49Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
154432001f49Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
154532001f49Smrg# file name or path is assumed to be in w32 format, as previously converted
154632001f49Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
154732001f49Smrg# or path in func_cygpath_result (input file name or path is assumed to be in
154832001f49Smrg# Cygwin format). Returns an empty string on error.
154932001f49Smrg#
155032001f49Smrg# ARGS are passed to cygpath, with the last one being the file name or path to
155132001f49Smrg# be converted.
155232001f49Smrg#
155332001f49Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
155432001f49Smrg# environment variable; do not put it in $PATH.
155532001f49Smrgfunc_cygpath ()
155632001f49Smrg{
155732001f49Smrg  $opt_debug
155832001f49Smrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
155932001f49Smrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
156032001f49Smrg    if test "$?" -ne 0; then
156132001f49Smrg      # on failure, ensure result is empty
156232001f49Smrg      func_cygpath_result=
156332001f49Smrg    fi
156432001f49Smrg  else
156532001f49Smrg    func_cygpath_result=
156632001f49Smrg    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
156732001f49Smrg  fi
156832001f49Smrg}
156932001f49Smrg#end: func_cygpath
157032001f49Smrg
157132001f49Smrg
157232001f49Smrg# func_convert_core_msys_to_w32 ARG
157332001f49Smrg# Convert file name or path ARG from MSYS format to w32 format.  Return
157432001f49Smrg# result in func_convert_core_msys_to_w32_result.
157532001f49Smrgfunc_convert_core_msys_to_w32 ()
157632001f49Smrg{
157732001f49Smrg  $opt_debug
157832001f49Smrg  # awkward: cmd appends spaces to result
157932001f49Smrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
158032001f49Smrg    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
158132001f49Smrg}
158232001f49Smrg#end: func_convert_core_msys_to_w32
158332001f49Smrg
158432001f49Smrg
158532001f49Smrg# func_convert_file_check ARG1 ARG2
158632001f49Smrg# Verify that ARG1 (a file name in $build format) was converted to $host
158732001f49Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
158832001f49Smrg# func_to_host_file_result to ARG1).
158932001f49Smrgfunc_convert_file_check ()
159032001f49Smrg{
159132001f49Smrg  $opt_debug
159232001f49Smrg  if test -z "$2" && test -n "$1" ; then
159332001f49Smrg    func_error "Could not determine host file name corresponding to"
159432001f49Smrg    func_error "  \`$1'"
159532001f49Smrg    func_error "Continuing, but uninstalled executables may not work."
159632001f49Smrg    # Fallback:
159732001f49Smrg    func_to_host_file_result="$1"
159832001f49Smrg  fi
159932001f49Smrg}
160032001f49Smrg# end func_convert_file_check
160132001f49Smrg
160232001f49Smrg
160332001f49Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
160432001f49Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host
160532001f49Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
160632001f49Smrg# func_to_host_file_result to a simplistic fallback value (see below).
160732001f49Smrgfunc_convert_path_check ()
160832001f49Smrg{
160932001f49Smrg  $opt_debug
161032001f49Smrg  if test -z "$4" && test -n "$3"; then
161132001f49Smrg    func_error "Could not determine the host path corresponding to"
161232001f49Smrg    func_error "  \`$3'"
161332001f49Smrg    func_error "Continuing, but uninstalled executables may not work."
161432001f49Smrg    # Fallback.  This is a deliberately simplistic "conversion" and
161532001f49Smrg    # should not be "improved".  See libtool.info.
161632001f49Smrg    if test "x$1" != "x$2"; then
161732001f49Smrg      lt_replace_pathsep_chars="s|$1|$2|g"
161832001f49Smrg      func_to_host_path_result=`echo "$3" |
161932001f49Smrg        $SED -e "$lt_replace_pathsep_chars"`
162032001f49Smrg    else
162132001f49Smrg      func_to_host_path_result="$3"
162232001f49Smrg    fi
162332001f49Smrg  fi
162432001f49Smrg}
162532001f49Smrg# end func_convert_path_check
162632001f49Smrg
162732001f49Smrg
162832001f49Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
162932001f49Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
163032001f49Smrg# and appending REPL if ORIG matches BACKPAT.
163132001f49Smrgfunc_convert_path_front_back_pathsep ()
163232001f49Smrg{
163332001f49Smrg  $opt_debug
163432001f49Smrg  case $4 in
163532001f49Smrg  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
163632001f49Smrg    ;;
163732001f49Smrg  esac
163832001f49Smrg  case $4 in
163932001f49Smrg  $2 ) func_append func_to_host_path_result "$3"
164032001f49Smrg    ;;
164132001f49Smrg  esac
164232001f49Smrg}
164332001f49Smrg# end func_convert_path_front_back_pathsep
164432001f49Smrg
164532001f49Smrg
164632001f49Smrg##################################################
164732001f49Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
164832001f49Smrg##################################################
164932001f49Smrg# invoked via `$to_host_file_cmd ARG'
165032001f49Smrg#
165132001f49Smrg# In each case, ARG is the path to be converted from $build to $host format.
165232001f49Smrg# Result will be available in $func_to_host_file_result.
165332001f49Smrg
165432001f49Smrg
165532001f49Smrg# func_to_host_file ARG
165632001f49Smrg# Converts the file name ARG from $build format to $host format. Return result
165732001f49Smrg# in func_to_host_file_result.
165832001f49Smrgfunc_to_host_file ()
165932001f49Smrg{
166032001f49Smrg  $opt_debug
166132001f49Smrg  $to_host_file_cmd "$1"
166232001f49Smrg}
166332001f49Smrg# end func_to_host_file
166432001f49Smrg
166532001f49Smrg
166632001f49Smrg# func_to_tool_file ARG LAZY
166732001f49Smrg# converts the file name ARG from $build format to toolchain format. Return
166832001f49Smrg# result in func_to_tool_file_result.  If the conversion in use is listed
166932001f49Smrg# in (the comma separated) LAZY, no conversion takes place.
167032001f49Smrgfunc_to_tool_file ()
167132001f49Smrg{
167232001f49Smrg  $opt_debug
167332001f49Smrg  case ,$2, in
167432001f49Smrg    *,"$to_tool_file_cmd",*)
167532001f49Smrg      func_to_tool_file_result=$1
167632001f49Smrg      ;;
167732001f49Smrg    *)
167832001f49Smrg      $to_tool_file_cmd "$1"
167932001f49Smrg      func_to_tool_file_result=$func_to_host_file_result
168032001f49Smrg      ;;
168132001f49Smrg  esac
168232001f49Smrg}
168332001f49Smrg# end func_to_tool_file
168432001f49Smrg
168532001f49Smrg
168632001f49Smrg# func_convert_file_noop ARG
168732001f49Smrg# Copy ARG to func_to_host_file_result.
168832001f49Smrgfunc_convert_file_noop ()
168932001f49Smrg{
169032001f49Smrg  func_to_host_file_result="$1"
169132001f49Smrg}
169232001f49Smrg# end func_convert_file_noop
169332001f49Smrg
169432001f49Smrg
169532001f49Smrg# func_convert_file_msys_to_w32 ARG
169632001f49Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
169732001f49Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
169832001f49Smrg# func_to_host_file_result.
169932001f49Smrgfunc_convert_file_msys_to_w32 ()
170032001f49Smrg{
170132001f49Smrg  $opt_debug
170232001f49Smrg  func_to_host_file_result="$1"
170332001f49Smrg  if test -n "$1"; then
170432001f49Smrg    func_convert_core_msys_to_w32 "$1"
170532001f49Smrg    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
170632001f49Smrg  fi
170732001f49Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
170832001f49Smrg}
170932001f49Smrg# end func_convert_file_msys_to_w32
171032001f49Smrg
171132001f49Smrg
171232001f49Smrg# func_convert_file_cygwin_to_w32 ARG
171332001f49Smrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
171432001f49Smrg# func_to_host_file_result.
171532001f49Smrgfunc_convert_file_cygwin_to_w32 ()
171632001f49Smrg{
171732001f49Smrg  $opt_debug
171832001f49Smrg  func_to_host_file_result="$1"
171932001f49Smrg  if test -n "$1"; then
172032001f49Smrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
172132001f49Smrg    # LT_CYGPATH in this case.
172232001f49Smrg    func_to_host_file_result=`cygpath -m "$1"`
172332001f49Smrg  fi
172432001f49Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
172532001f49Smrg}
172632001f49Smrg# end func_convert_file_cygwin_to_w32
172732001f49Smrg
172832001f49Smrg
172932001f49Smrg# func_convert_file_nix_to_w32 ARG
173032001f49Smrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
173132001f49Smrg# and a working winepath. Returns result in func_to_host_file_result.
173232001f49Smrgfunc_convert_file_nix_to_w32 ()
173332001f49Smrg{
173432001f49Smrg  $opt_debug
173532001f49Smrg  func_to_host_file_result="$1"
173632001f49Smrg  if test -n "$1"; then
173732001f49Smrg    func_convert_core_file_wine_to_w32 "$1"
173832001f49Smrg    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
173932001f49Smrg  fi
174032001f49Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
174132001f49Smrg}
174232001f49Smrg# end func_convert_file_nix_to_w32
174332001f49Smrg
174432001f49Smrg
174532001f49Smrg# func_convert_file_msys_to_cygwin ARG
174632001f49Smrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
174732001f49Smrg# Returns result in func_to_host_file_result.
174832001f49Smrgfunc_convert_file_msys_to_cygwin ()
174932001f49Smrg{
175032001f49Smrg  $opt_debug
175132001f49Smrg  func_to_host_file_result="$1"
175232001f49Smrg  if test -n "$1"; then
175332001f49Smrg    func_convert_core_msys_to_w32 "$1"
175432001f49Smrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
175532001f49Smrg    func_to_host_file_result="$func_cygpath_result"
175632001f49Smrg  fi
175732001f49Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
175832001f49Smrg}
175932001f49Smrg# end func_convert_file_msys_to_cygwin
176032001f49Smrg
176132001f49Smrg
176232001f49Smrg# func_convert_file_nix_to_cygwin ARG
176332001f49Smrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
176432001f49Smrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
176532001f49Smrg# in func_to_host_file_result.
176632001f49Smrgfunc_convert_file_nix_to_cygwin ()
176732001f49Smrg{
176832001f49Smrg  $opt_debug
176932001f49Smrg  func_to_host_file_result="$1"
177032001f49Smrg  if test -n "$1"; then
177132001f49Smrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
177232001f49Smrg    func_convert_core_file_wine_to_w32 "$1"
177332001f49Smrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
177432001f49Smrg    func_to_host_file_result="$func_cygpath_result"
177532001f49Smrg  fi
177632001f49Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
177732001f49Smrg}
177832001f49Smrg# end func_convert_file_nix_to_cygwin
177932001f49Smrg
178032001f49Smrg
178132001f49Smrg#############################################
178232001f49Smrg# $build to $host PATH CONVERSION FUNCTIONS #
178332001f49Smrg#############################################
178432001f49Smrg# invoked via `$to_host_path_cmd ARG'
178532001f49Smrg#
178632001f49Smrg# In each case, ARG is the path to be converted from $build to $host format.
178732001f49Smrg# The result will be available in $func_to_host_path_result.
178832001f49Smrg#
178932001f49Smrg# Path separators are also converted from $build format to $host format.  If
179032001f49Smrg# ARG begins or ends with a path separator character, it is preserved (but
179132001f49Smrg# converted to $host format) on output.
179232001f49Smrg#
179332001f49Smrg# All path conversion functions are named using the following convention:
179432001f49Smrg#   file name conversion function    : func_convert_file_X_to_Y ()
179532001f49Smrg#   path conversion function         : func_convert_path_X_to_Y ()
179632001f49Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the
179732001f49Smrg# same.  If conversion functions are added for new $build/$host combinations,
179832001f49Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
179932001f49Smrg# will break.
180032001f49Smrg
180132001f49Smrg
180232001f49Smrg# func_init_to_host_path_cmd
180332001f49Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
180432001f49Smrg# appropriate value, based on the value of $to_host_file_cmd.
180532001f49Smrgto_host_path_cmd=
180632001f49Smrgfunc_init_to_host_path_cmd ()
180732001f49Smrg{
180832001f49Smrg  $opt_debug
180932001f49Smrg  if test -z "$to_host_path_cmd"; then
181032001f49Smrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
181132001f49Smrg    to_host_path_cmd="func_convert_path_${func_stripname_result}"
181232001f49Smrg  fi
181332001f49Smrg}
181432001f49Smrg
181532001f49Smrg
181632001f49Smrg# func_to_host_path ARG
181732001f49Smrg# Converts the path ARG from $build format to $host format. Return result
181832001f49Smrg# in func_to_host_path_result.
181932001f49Smrgfunc_to_host_path ()
182032001f49Smrg{
182132001f49Smrg  $opt_debug
182232001f49Smrg  func_init_to_host_path_cmd
182332001f49Smrg  $to_host_path_cmd "$1"
182432001f49Smrg}
182532001f49Smrg# end func_to_host_path
182632001f49Smrg
182732001f49Smrg
182832001f49Smrg# func_convert_path_noop ARG
182932001f49Smrg# Copy ARG to func_to_host_path_result.
183032001f49Smrgfunc_convert_path_noop ()
183132001f49Smrg{
183232001f49Smrg  func_to_host_path_result="$1"
183332001f49Smrg}
183432001f49Smrg# end func_convert_path_noop
183532001f49Smrg
183632001f49Smrg
183732001f49Smrg# func_convert_path_msys_to_w32 ARG
183832001f49Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
183932001f49Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
184032001f49Smrg# func_to_host_path_result.
184132001f49Smrgfunc_convert_path_msys_to_w32 ()
184232001f49Smrg{
184332001f49Smrg  $opt_debug
184432001f49Smrg  func_to_host_path_result="$1"
184532001f49Smrg  if test -n "$1"; then
184632001f49Smrg    # Remove leading and trailing path separator characters from ARG.  MSYS
184732001f49Smrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
184832001f49Smrg    # and winepath ignores them completely.
184932001f49Smrg    func_stripname : : "$1"
185032001f49Smrg    func_to_host_path_tmp1=$func_stripname_result
185132001f49Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
185232001f49Smrg    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
185332001f49Smrg    func_convert_path_check : ";" \
185432001f49Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
185532001f49Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
185632001f49Smrg  fi
185732001f49Smrg}
185832001f49Smrg# end func_convert_path_msys_to_w32
185932001f49Smrg
186032001f49Smrg
186132001f49Smrg# func_convert_path_cygwin_to_w32 ARG
186232001f49Smrg# Convert path ARG from Cygwin to w32 format.  Returns result in
186332001f49Smrg# func_to_host_file_result.
186432001f49Smrgfunc_convert_path_cygwin_to_w32 ()
186532001f49Smrg{
186632001f49Smrg  $opt_debug
186732001f49Smrg  func_to_host_path_result="$1"
186832001f49Smrg  if test -n "$1"; then
186932001f49Smrg    # See func_convert_path_msys_to_w32:
187032001f49Smrg    func_stripname : : "$1"
187132001f49Smrg    func_to_host_path_tmp1=$func_stripname_result
187232001f49Smrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
187332001f49Smrg    func_convert_path_check : ";" \
187432001f49Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
187532001f49Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
187632001f49Smrg  fi
187732001f49Smrg}
187832001f49Smrg# end func_convert_path_cygwin_to_w32
187932001f49Smrg
188032001f49Smrg
188132001f49Smrg# func_convert_path_nix_to_w32 ARG
188232001f49Smrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
188332001f49Smrg# a working winepath.  Returns result in func_to_host_file_result.
188432001f49Smrgfunc_convert_path_nix_to_w32 ()
188532001f49Smrg{
188632001f49Smrg  $opt_debug
188732001f49Smrg  func_to_host_path_result="$1"
188832001f49Smrg  if test -n "$1"; then
188932001f49Smrg    # See func_convert_path_msys_to_w32:
189032001f49Smrg    func_stripname : : "$1"
189132001f49Smrg    func_to_host_path_tmp1=$func_stripname_result
189232001f49Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
189332001f49Smrg    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
189432001f49Smrg    func_convert_path_check : ";" \
189532001f49Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
189632001f49Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
189732001f49Smrg  fi
189832001f49Smrg}
189932001f49Smrg# end func_convert_path_nix_to_w32
190032001f49Smrg
190132001f49Smrg
190232001f49Smrg# func_convert_path_msys_to_cygwin ARG
190332001f49Smrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
190432001f49Smrg# Returns result in func_to_host_file_result.
190532001f49Smrgfunc_convert_path_msys_to_cygwin ()
190632001f49Smrg{
190732001f49Smrg  $opt_debug
190832001f49Smrg  func_to_host_path_result="$1"
190932001f49Smrg  if test -n "$1"; then
191032001f49Smrg    # See func_convert_path_msys_to_w32:
191132001f49Smrg    func_stripname : : "$1"
191232001f49Smrg    func_to_host_path_tmp1=$func_stripname_result
191332001f49Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
191432001f49Smrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
191532001f49Smrg    func_to_host_path_result="$func_cygpath_result"
191632001f49Smrg    func_convert_path_check : : \
191732001f49Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
191832001f49Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
191932001f49Smrg  fi
192032001f49Smrg}
192132001f49Smrg# end func_convert_path_msys_to_cygwin
192232001f49Smrg
192332001f49Smrg
192432001f49Smrg# func_convert_path_nix_to_cygwin ARG
192532001f49Smrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
192632001f49Smrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
192732001f49Smrg# func_to_host_file_result.
192832001f49Smrgfunc_convert_path_nix_to_cygwin ()
192932001f49Smrg{
193032001f49Smrg  $opt_debug
193132001f49Smrg  func_to_host_path_result="$1"
193232001f49Smrg  if test -n "$1"; then
193332001f49Smrg    # Remove leading and trailing path separator characters from
193432001f49Smrg    # ARG. msys behavior is inconsistent here, cygpath turns them
193532001f49Smrg    # into '.;' and ';.', and winepath ignores them completely.
193632001f49Smrg    func_stripname : : "$1"
193732001f49Smrg    func_to_host_path_tmp1=$func_stripname_result
193832001f49Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
193932001f49Smrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
194032001f49Smrg    func_to_host_path_result="$func_cygpath_result"
194132001f49Smrg    func_convert_path_check : : \
194232001f49Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
194332001f49Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
194432001f49Smrg  fi
194532001f49Smrg}
194632001f49Smrg# end func_convert_path_nix_to_cygwin
194732001f49Smrg
194832001f49Smrg
194932001f49Smrg# func_mode_compile arg...
195032001f49Smrgfunc_mode_compile ()
195132001f49Smrg{
195232001f49Smrg    $opt_debug
195332001f49Smrg    # Get the compilation command and the source file.
195432001f49Smrg    base_compile=
195532001f49Smrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
195632001f49Smrg    suppress_opt=yes
195732001f49Smrg    suppress_output=
195832001f49Smrg    arg_mode=normal
195932001f49Smrg    libobj=
196032001f49Smrg    later=
196132001f49Smrg    pie_flag=
196232001f49Smrg
196332001f49Smrg    for arg
196432001f49Smrg    do
196532001f49Smrg      case $arg_mode in
196632001f49Smrg      arg  )
196732001f49Smrg	# do not "continue".  Instead, add this to base_compile
196832001f49Smrg	lastarg="$arg"
196932001f49Smrg	arg_mode=normal
197032001f49Smrg	;;
197132001f49Smrg
197232001f49Smrg      target )
197332001f49Smrg	libobj="$arg"
197432001f49Smrg	arg_mode=normal
197532001f49Smrg	continue
197632001f49Smrg	;;
197732001f49Smrg
197832001f49Smrg      normal )
197932001f49Smrg	# Accept any command-line options.
198032001f49Smrg	case $arg in
198132001f49Smrg	-o)
198232001f49Smrg	  test -n "$libobj" && \
198332001f49Smrg	    func_fatal_error "you cannot specify \`-o' more than once"
198432001f49Smrg	  arg_mode=target
198532001f49Smrg	  continue
198632001f49Smrg	  ;;
198732001f49Smrg
198832001f49Smrg	-pie | -fpie | -fPIE)
198932001f49Smrg          func_append pie_flag " $arg"
199032001f49Smrg	  continue
199132001f49Smrg	  ;;
199232001f49Smrg
199332001f49Smrg	-shared | -static | -prefer-pic | -prefer-non-pic)
199432001f49Smrg	  func_append later " $arg"
199532001f49Smrg	  continue
199632001f49Smrg	  ;;
199732001f49Smrg
199832001f49Smrg	-no-suppress)
199932001f49Smrg	  suppress_opt=no
200032001f49Smrg	  continue
200132001f49Smrg	  ;;
200232001f49Smrg
200332001f49Smrg	-Xcompiler)
200432001f49Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
200532001f49Smrg	  continue      #  The current "srcfile" will either be retained or
200632001f49Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
200732001f49Smrg
200832001f49Smrg	-Wc,*)
200932001f49Smrg	  func_stripname '-Wc,' '' "$arg"
201032001f49Smrg	  args=$func_stripname_result
201132001f49Smrg	  lastarg=
201232001f49Smrg	  save_ifs="$IFS"; IFS=','
201332001f49Smrg	  for arg in $args; do
201432001f49Smrg	    IFS="$save_ifs"
201532001f49Smrg	    func_append_quoted lastarg "$arg"
201632001f49Smrg	  done
201732001f49Smrg	  IFS="$save_ifs"
201832001f49Smrg	  func_stripname ' ' '' "$lastarg"
201932001f49Smrg	  lastarg=$func_stripname_result
202032001f49Smrg
202132001f49Smrg	  # Add the arguments to base_compile.
202232001f49Smrg	  func_append base_compile " $lastarg"
202332001f49Smrg	  continue
202432001f49Smrg	  ;;
202532001f49Smrg
202632001f49Smrg	*)
202732001f49Smrg	  # Accept the current argument as the source file.
202832001f49Smrg	  # The previous "srcfile" becomes the current argument.
202932001f49Smrg	  #
203032001f49Smrg	  lastarg="$srcfile"
203132001f49Smrg	  srcfile="$arg"
203232001f49Smrg	  ;;
203332001f49Smrg	esac  #  case $arg
203432001f49Smrg	;;
203532001f49Smrg      esac    #  case $arg_mode
203632001f49Smrg
203732001f49Smrg      # Aesthetically quote the previous argument.
203832001f49Smrg      func_append_quoted base_compile "$lastarg"
203932001f49Smrg    done # for arg
204032001f49Smrg
204132001f49Smrg    case $arg_mode in
204232001f49Smrg    arg)
204332001f49Smrg      func_fatal_error "you must specify an argument for -Xcompile"
204432001f49Smrg      ;;
204532001f49Smrg    target)
204632001f49Smrg      func_fatal_error "you must specify a target with \`-o'"
204732001f49Smrg      ;;
204832001f49Smrg    *)
204932001f49Smrg      # Get the name of the library object.
205032001f49Smrg      test -z "$libobj" && {
205132001f49Smrg	func_basename "$srcfile"
205232001f49Smrg	libobj="$func_basename_result"
205332001f49Smrg      }
205432001f49Smrg      ;;
205532001f49Smrg    esac
205632001f49Smrg
205732001f49Smrg    # Recognize several different file suffixes.
205832001f49Smrg    # If the user specifies -o file.o, it is replaced with file.lo
205932001f49Smrg    case $libobj in
206032001f49Smrg    *.[cCFSifmso] | \
206132001f49Smrg    *.ada | *.adb | *.ads | *.asm | \
206232001f49Smrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
206332001f49Smrg    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
206432001f49Smrg      func_xform "$libobj"
206532001f49Smrg      libobj=$func_xform_result
206632001f49Smrg      ;;
206732001f49Smrg    esac
206832001f49Smrg
206932001f49Smrg    case $libobj in
207032001f49Smrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
207132001f49Smrg    *)
207232001f49Smrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
207332001f49Smrg      ;;
207432001f49Smrg    esac
207532001f49Smrg
207632001f49Smrg    func_infer_tag $base_compile
207732001f49Smrg
207832001f49Smrg    for arg in $later; do
207932001f49Smrg      case $arg in
208032001f49Smrg      -shared)
208132001f49Smrg	test "$build_libtool_libs" != yes && \
208232001f49Smrg	  func_fatal_configuration "can not build a shared library"
208332001f49Smrg	build_old_libs=no
208432001f49Smrg	continue
208532001f49Smrg	;;
208632001f49Smrg
208732001f49Smrg      -static)
208832001f49Smrg	build_libtool_libs=no
208932001f49Smrg	build_old_libs=yes
209032001f49Smrg	continue
209132001f49Smrg	;;
209232001f49Smrg
209332001f49Smrg      -prefer-pic)
209432001f49Smrg	pic_mode=yes
209532001f49Smrg	continue
209632001f49Smrg	;;
209732001f49Smrg
209832001f49Smrg      -prefer-non-pic)
209932001f49Smrg	pic_mode=no
210032001f49Smrg	continue
210132001f49Smrg	;;
210232001f49Smrg      esac
210332001f49Smrg    done
210432001f49Smrg
210532001f49Smrg    func_quote_for_eval "$libobj"
210632001f49Smrg    test "X$libobj" != "X$func_quote_for_eval_result" \
210732001f49Smrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
210832001f49Smrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
210932001f49Smrg    func_dirname_and_basename "$obj" "/" ""
211032001f49Smrg    objname="$func_basename_result"
211132001f49Smrg    xdir="$func_dirname_result"
211232001f49Smrg    lobj=${xdir}$objdir/$objname
211332001f49Smrg
211432001f49Smrg    test -z "$base_compile" && \
211532001f49Smrg      func_fatal_help "you must specify a compilation command"
211632001f49Smrg
211732001f49Smrg    # Delete any leftover library objects.
211832001f49Smrg    if test "$build_old_libs" = yes; then
211932001f49Smrg      removelist="$obj $lobj $libobj ${libobj}T"
212032001f49Smrg    else
212132001f49Smrg      removelist="$lobj $libobj ${libobj}T"
212232001f49Smrg    fi
212332001f49Smrg
212432001f49Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
212532001f49Smrg    case $host_os in
212632001f49Smrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
212732001f49Smrg      pic_mode=default
212832001f49Smrg      ;;
212932001f49Smrg    esac
213032001f49Smrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
213132001f49Smrg      # non-PIC code in shared libraries is not supported
213232001f49Smrg      pic_mode=default
213332001f49Smrg    fi
213432001f49Smrg
213532001f49Smrg    # Calculate the filename of the output object if compiler does
213632001f49Smrg    # not support -o with -c
213732001f49Smrg    if test "$compiler_c_o" = no; then
213832001f49Smrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
213932001f49Smrg      lockfile="$output_obj.lock"
214032001f49Smrg    else
214132001f49Smrg      output_obj=
214232001f49Smrg      need_locks=no
214332001f49Smrg      lockfile=
214432001f49Smrg    fi
214532001f49Smrg
214632001f49Smrg    # Lock this critical section if it is needed
214732001f49Smrg    # We use this script file to make the link, it avoids creating a new file
214832001f49Smrg    if test "$need_locks" = yes; then
214932001f49Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
215032001f49Smrg	func_echo "Waiting for $lockfile to be removed"
215132001f49Smrg	sleep 2
215232001f49Smrg      done
215332001f49Smrg    elif test "$need_locks" = warn; then
215432001f49Smrg      if test -f "$lockfile"; then
215532001f49Smrg	$ECHO "\
215632001f49Smrg*** ERROR, $lockfile exists and contains:
215732001f49Smrg`cat $lockfile 2>/dev/null`
215832001f49Smrg
215932001f49SmrgThis indicates that another process is trying to use the same
216032001f49Smrgtemporary object file, and libtool could not work around it because
216132001f49Smrgyour compiler does not support \`-c' and \`-o' together.  If you
216232001f49Smrgrepeat this compilation, it may succeed, by chance, but you had better
216332001f49Smrgavoid parallel builds (make -j) in this platform, or get a better
216432001f49Smrgcompiler."
216532001f49Smrg
216632001f49Smrg	$opt_dry_run || $RM $removelist
216732001f49Smrg	exit $EXIT_FAILURE
216832001f49Smrg      fi
216932001f49Smrg      func_append removelist " $output_obj"
217032001f49Smrg      $ECHO "$srcfile" > "$lockfile"
217132001f49Smrg    fi
217232001f49Smrg
217332001f49Smrg    $opt_dry_run || $RM $removelist
217432001f49Smrg    func_append removelist " $lockfile"
217532001f49Smrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
217632001f49Smrg
217732001f49Smrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
217832001f49Smrg    srcfile=$func_to_tool_file_result
217932001f49Smrg    func_quote_for_eval "$srcfile"
218032001f49Smrg    qsrcfile=$func_quote_for_eval_result
218132001f49Smrg
218232001f49Smrg    # Only build a PIC object if we are building libtool libraries.
218332001f49Smrg    if test "$build_libtool_libs" = yes; then
218432001f49Smrg      # Without this assignment, base_compile gets emptied.
218532001f49Smrg      fbsd_hideous_sh_bug=$base_compile
218632001f49Smrg
218732001f49Smrg      if test "$pic_mode" != no; then
218832001f49Smrg	command="$base_compile $qsrcfile $pic_flag"
218932001f49Smrg      else
219032001f49Smrg	# Don't build PIC code
219132001f49Smrg	command="$base_compile $qsrcfile"
219232001f49Smrg      fi
219332001f49Smrg
219432001f49Smrg      func_mkdir_p "$xdir$objdir"
219532001f49Smrg
219632001f49Smrg      if test -z "$output_obj"; then
219732001f49Smrg	# Place PIC objects in $objdir
219832001f49Smrg	func_append command " -o $lobj"
219932001f49Smrg      fi
220032001f49Smrg
220132001f49Smrg      func_show_eval_locale "$command"	\
220232001f49Smrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
220332001f49Smrg
220432001f49Smrg      if test "$need_locks" = warn &&
220532001f49Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
220632001f49Smrg	$ECHO "\
220732001f49Smrg*** ERROR, $lockfile contains:
220832001f49Smrg`cat $lockfile 2>/dev/null`
220932001f49Smrg
221032001f49Smrgbut it should contain:
221132001f49Smrg$srcfile
221232001f49Smrg
221332001f49SmrgThis indicates that another process is trying to use the same
221432001f49Smrgtemporary object file, and libtool could not work around it because
221532001f49Smrgyour compiler does not support \`-c' and \`-o' together.  If you
221632001f49Smrgrepeat this compilation, it may succeed, by chance, but you had better
221732001f49Smrgavoid parallel builds (make -j) in this platform, or get a better
221832001f49Smrgcompiler."
221932001f49Smrg
222032001f49Smrg	$opt_dry_run || $RM $removelist
222132001f49Smrg	exit $EXIT_FAILURE
222232001f49Smrg      fi
222332001f49Smrg
222432001f49Smrg      # Just move the object if needed, then go on to compile the next one
222532001f49Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
222632001f49Smrg	func_show_eval '$MV "$output_obj" "$lobj"' \
222732001f49Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
222832001f49Smrg      fi
222932001f49Smrg
223032001f49Smrg      # Allow error messages only from the first compilation.
223132001f49Smrg      if test "$suppress_opt" = yes; then
223232001f49Smrg	suppress_output=' >/dev/null 2>&1'
223332001f49Smrg      fi
223432001f49Smrg    fi
223532001f49Smrg
223632001f49Smrg    # Only build a position-dependent object if we build old libraries.
223732001f49Smrg    if test "$build_old_libs" = yes; then
223832001f49Smrg      if test "$pic_mode" != yes; then
223932001f49Smrg	# Don't build PIC code
224032001f49Smrg	command="$base_compile $qsrcfile$pie_flag"
224132001f49Smrg      else
224232001f49Smrg	command="$base_compile $qsrcfile $pic_flag"
224332001f49Smrg      fi
224432001f49Smrg      if test "$compiler_c_o" = yes; then
224532001f49Smrg	func_append command " -o $obj"
224632001f49Smrg      fi
224732001f49Smrg
224832001f49Smrg      # Suppress compiler output if we already did a PIC compilation.
224932001f49Smrg      func_append command "$suppress_output"
225032001f49Smrg      func_show_eval_locale "$command" \
225132001f49Smrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
225232001f49Smrg
225332001f49Smrg      if test "$need_locks" = warn &&
225432001f49Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
225532001f49Smrg	$ECHO "\
225632001f49Smrg*** ERROR, $lockfile contains:
225732001f49Smrg`cat $lockfile 2>/dev/null`
225832001f49Smrg
225932001f49Smrgbut it should contain:
226032001f49Smrg$srcfile
226132001f49Smrg
226232001f49SmrgThis indicates that another process is trying to use the same
226332001f49Smrgtemporary object file, and libtool could not work around it because
226432001f49Smrgyour compiler does not support \`-c' and \`-o' together.  If you
226532001f49Smrgrepeat this compilation, it may succeed, by chance, but you had better
226632001f49Smrgavoid parallel builds (make -j) in this platform, or get a better
226732001f49Smrgcompiler."
226832001f49Smrg
226932001f49Smrg	$opt_dry_run || $RM $removelist
227032001f49Smrg	exit $EXIT_FAILURE
227132001f49Smrg      fi
227232001f49Smrg
227332001f49Smrg      # Just move the object if needed
227432001f49Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
227532001f49Smrg	func_show_eval '$MV "$output_obj" "$obj"' \
227632001f49Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
227732001f49Smrg      fi
227832001f49Smrg    fi
227932001f49Smrg
228032001f49Smrg    $opt_dry_run || {
228132001f49Smrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
228232001f49Smrg
228332001f49Smrg      # Unlock the critical section if it was locked
228432001f49Smrg      if test "$need_locks" != no; then
228532001f49Smrg	removelist=$lockfile
228632001f49Smrg        $RM "$lockfile"
228732001f49Smrg      fi
228832001f49Smrg    }
228932001f49Smrg
229032001f49Smrg    exit $EXIT_SUCCESS
229132001f49Smrg}
229232001f49Smrg
229332001f49Smrg$opt_help || {
229432001f49Smrg  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
229532001f49Smrg}
229632001f49Smrg
229732001f49Smrgfunc_mode_help ()
229832001f49Smrg{
229932001f49Smrg    # We need to display help for each of the modes.
230032001f49Smrg    case $opt_mode in
230132001f49Smrg      "")
230232001f49Smrg        # Generic help is extracted from the usage comments
230332001f49Smrg        # at the start of this file.
230432001f49Smrg        func_help
230532001f49Smrg        ;;
230632001f49Smrg
230732001f49Smrg      clean)
230832001f49Smrg        $ECHO \
230932001f49Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
231032001f49Smrg
231132001f49SmrgRemove files from the build directory.
231232001f49Smrg
231332001f49SmrgRM is the name of the program to use to delete files associated with each FILE
231432001f49Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
231532001f49Smrgto RM.
231632001f49Smrg
231732001f49SmrgIf FILE is a libtool library, object or program, all the files associated
231832001f49Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
231932001f49Smrg        ;;
232032001f49Smrg
232132001f49Smrg      compile)
232232001f49Smrg      $ECHO \
232332001f49Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
232432001f49Smrg
232532001f49SmrgCompile a source file into a libtool library object.
232632001f49Smrg
232732001f49SmrgThis mode accepts the following additional options:
232832001f49Smrg
232932001f49Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
233032001f49Smrg  -no-suppress      do not suppress compiler output for multiple passes
233132001f49Smrg  -prefer-pic       try to build PIC objects only
233232001f49Smrg  -prefer-non-pic   try to build non-PIC objects only
233332001f49Smrg  -shared           do not build a \`.o' file suitable for static linking
233432001f49Smrg  -static           only build a \`.o' file suitable for static linking
233532001f49Smrg  -Wc,FLAG          pass FLAG directly to the compiler
233632001f49Smrg
233732001f49SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
233832001f49Smrgfrom the given SOURCEFILE.
233932001f49Smrg
234032001f49SmrgThe output file name is determined by removing the directory component from
234132001f49SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
234232001f49Smrglibrary object suffix, \`.lo'."
234332001f49Smrg        ;;
234432001f49Smrg
234532001f49Smrg      execute)
234632001f49Smrg        $ECHO \
234732001f49Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
234832001f49Smrg
234932001f49SmrgAutomatically set library path, then run a program.
235032001f49Smrg
235132001f49SmrgThis mode accepts the following additional options:
235232001f49Smrg
235332001f49Smrg  -dlopen FILE      add the directory containing FILE to the library path
235432001f49Smrg
235532001f49SmrgThis mode sets the library path environment variable according to \`-dlopen'
235632001f49Smrgflags.
235732001f49Smrg
235832001f49SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
235932001f49Smrginto their corresponding uninstalled binary, and any of their required library
236032001f49Smrgdirectories are added to the library path.
236132001f49Smrg
236232001f49SmrgThen, COMMAND is executed, with ARGS as arguments."
236332001f49Smrg        ;;
236432001f49Smrg
236532001f49Smrg      finish)
236632001f49Smrg        $ECHO \
236732001f49Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
236832001f49Smrg
236932001f49SmrgComplete the installation of libtool libraries.
237032001f49Smrg
237132001f49SmrgEach LIBDIR is a directory that contains libtool libraries.
237232001f49Smrg
237332001f49SmrgThe commands that this mode executes may require superuser privileges.  Use
237432001f49Smrgthe \`--dry-run' option if you just want to see what would be executed."
237532001f49Smrg        ;;
237632001f49Smrg
237732001f49Smrg      install)
237832001f49Smrg        $ECHO \
237932001f49Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
238032001f49Smrg
238132001f49SmrgInstall executables or libraries.
238232001f49Smrg
238332001f49SmrgINSTALL-COMMAND is the installation command.  The first component should be
238432001f49Smrgeither the \`install' or \`cp' program.
238532001f49Smrg
238632001f49SmrgThe following components of INSTALL-COMMAND are treated specially:
238732001f49Smrg
238832001f49Smrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
238932001f49Smrg
239032001f49SmrgThe rest of the components are interpreted as arguments to that command (only
239132001f49SmrgBSD-compatible install options are recognized)."
239232001f49Smrg        ;;
239332001f49Smrg
239432001f49Smrg      link)
239532001f49Smrg        $ECHO \
239632001f49Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
239732001f49Smrg
239832001f49SmrgLink object files or libraries together to form another library, or to
239932001f49Smrgcreate an executable program.
240032001f49Smrg
240132001f49SmrgLINK-COMMAND is a command using the C compiler that you would use to create
240232001f49Smrga program from several object files.
240332001f49Smrg
240432001f49SmrgThe following components of LINK-COMMAND are treated specially:
240532001f49Smrg
240632001f49Smrg  -all-static       do not do any dynamic linking at all
240732001f49Smrg  -avoid-version    do not add a version suffix if possible
240832001f49Smrg  -bindir BINDIR    specify path to binaries directory (for systems where
240932001f49Smrg                    libraries must be found in the PATH setting at runtime)
241032001f49Smrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
241132001f49Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
241232001f49Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
241332001f49Smrg  -export-symbols SYMFILE
241432001f49Smrg                    try to export only the symbols listed in SYMFILE
241532001f49Smrg  -export-symbols-regex REGEX
241632001f49Smrg                    try to export only the symbols matching REGEX
241732001f49Smrg  -LLIBDIR          search LIBDIR for required installed libraries
241832001f49Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
241932001f49Smrg  -module           build a library that can dlopened
242032001f49Smrg  -no-fast-install  disable the fast-install mode
242132001f49Smrg  -no-install       link a not-installable executable
242232001f49Smrg  -no-undefined     declare that a library does not refer to external symbols
242332001f49Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
242432001f49Smrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
242532001f49Smrg  -precious-files-regex REGEX
242632001f49Smrg                    don't remove output files matching REGEX
242732001f49Smrg  -release RELEASE  specify package release information
242832001f49Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
242932001f49Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
243032001f49Smrg  -shared           only do dynamic linking of libtool libraries
243132001f49Smrg  -shrext SUFFIX    override the standard shared library file extension
243232001f49Smrg  -static           do not do any dynamic linking of uninstalled libtool libraries
243332001f49Smrg  -static-libtool-libs
243432001f49Smrg                    do not do any dynamic linking of libtool libraries
243532001f49Smrg  -version-info CURRENT[:REVISION[:AGE]]
243632001f49Smrg                    specify library version info [each variable defaults to 0]
243732001f49Smrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
243832001f49Smrg  -Wc,FLAG
243932001f49Smrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
244032001f49Smrg  -Wl,FLAG
244132001f49Smrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
244232001f49Smrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
244332001f49Smrg
244432001f49SmrgAll other options (arguments beginning with \`-') are ignored.
244532001f49Smrg
244632001f49SmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
244732001f49Smrgtreated as uninstalled libtool libraries, other files are standard or library
244832001f49Smrgobject files.
244932001f49Smrg
245032001f49SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
245132001f49Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
245232001f49Smrgrequired, except when creating a convenience library.
245332001f49Smrg
245432001f49SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
245532001f49Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
245632001f49Smrg
245732001f49SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
245832001f49Smrgis created, otherwise an executable program is created."
245932001f49Smrg        ;;
246032001f49Smrg
246132001f49Smrg      uninstall)
246232001f49Smrg        $ECHO \
246332001f49Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
246432001f49Smrg
246532001f49SmrgRemove libraries from an installation directory.
246632001f49Smrg
246732001f49SmrgRM is the name of the program to use to delete files associated with each FILE
246832001f49Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
246932001f49Smrgto RM.
247032001f49Smrg
247132001f49SmrgIf FILE is a libtool library, all the files associated with it are deleted.
247232001f49SmrgOtherwise, only FILE itself is deleted using RM."
247332001f49Smrg        ;;
247432001f49Smrg
247532001f49Smrg      *)
247632001f49Smrg        func_fatal_help "invalid operation mode \`$opt_mode'"
247732001f49Smrg        ;;
247832001f49Smrg    esac
247932001f49Smrg
248032001f49Smrg    echo
248132001f49Smrg    $ECHO "Try \`$progname --help' for more information about other modes."
248232001f49Smrg}
248332001f49Smrg
248432001f49Smrg# Now that we've collected a possible --mode arg, show help if necessary
248532001f49Smrgif $opt_help; then
248632001f49Smrg  if test "$opt_help" = :; then
248732001f49Smrg    func_mode_help
248832001f49Smrg  else
248932001f49Smrg    {
249032001f49Smrg      func_help noexit
249132001f49Smrg      for opt_mode in compile link execute install finish uninstall clean; do
249232001f49Smrg	func_mode_help
249332001f49Smrg      done
249432001f49Smrg    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
249532001f49Smrg    {
249632001f49Smrg      func_help noexit
249732001f49Smrg      for opt_mode in compile link execute install finish uninstall clean; do
249832001f49Smrg	echo
249932001f49Smrg	func_mode_help
250032001f49Smrg      done
250132001f49Smrg    } |
250232001f49Smrg    sed '1d
250332001f49Smrg      /^When reporting/,/^Report/{
250432001f49Smrg	H
250532001f49Smrg	d
250632001f49Smrg      }
250732001f49Smrg      $x
250832001f49Smrg      /information about other modes/d
250932001f49Smrg      /more detailed .*MODE/d
251032001f49Smrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
251132001f49Smrg  fi
251232001f49Smrg  exit $?
251332001f49Smrgfi
251432001f49Smrg
251532001f49Smrg
251632001f49Smrg# func_mode_execute arg...
251732001f49Smrgfunc_mode_execute ()
251832001f49Smrg{
251932001f49Smrg    $opt_debug
252032001f49Smrg    # The first argument is the command name.
252132001f49Smrg    cmd="$nonopt"
252232001f49Smrg    test -z "$cmd" && \
252332001f49Smrg      func_fatal_help "you must specify a COMMAND"
252432001f49Smrg
252532001f49Smrg    # Handle -dlopen flags immediately.
252632001f49Smrg    for file in $opt_dlopen; do
252732001f49Smrg      test -f "$file" \
252832001f49Smrg	|| func_fatal_help "\`$file' is not a file"
252932001f49Smrg
253032001f49Smrg      dir=
253132001f49Smrg      case $file in
253232001f49Smrg      *.la)
253332001f49Smrg	func_resolve_sysroot "$file"
253432001f49Smrg	file=$func_resolve_sysroot_result
253532001f49Smrg
253632001f49Smrg	# Check to see that this really is a libtool archive.
253732001f49Smrg	func_lalib_unsafe_p "$file" \
253832001f49Smrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
253932001f49Smrg
254032001f49Smrg	# Read the libtool library.
254132001f49Smrg	dlname=
254232001f49Smrg	library_names=
254332001f49Smrg	func_source "$file"
254432001f49Smrg
254532001f49Smrg	# Skip this library if it cannot be dlopened.
254632001f49Smrg	if test -z "$dlname"; then
254732001f49Smrg	  # Warn if it was a shared library.
254832001f49Smrg	  test -n "$library_names" && \
254932001f49Smrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
255032001f49Smrg	  continue
255132001f49Smrg	fi
255232001f49Smrg
255332001f49Smrg	func_dirname "$file" "" "."
255432001f49Smrg	dir="$func_dirname_result"
255532001f49Smrg
255632001f49Smrg	if test -f "$dir/$objdir/$dlname"; then
255732001f49Smrg	  func_append dir "/$objdir"
255832001f49Smrg	else
255932001f49Smrg	  if test ! -f "$dir/$dlname"; then
256032001f49Smrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
256132001f49Smrg	  fi
256232001f49Smrg	fi
256332001f49Smrg	;;
256432001f49Smrg
256532001f49Smrg      *.lo)
256632001f49Smrg	# Just add the directory containing the .lo file.
256732001f49Smrg	func_dirname "$file" "" "."
256832001f49Smrg	dir="$func_dirname_result"
256932001f49Smrg	;;
257032001f49Smrg
257132001f49Smrg      *)
257232001f49Smrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
257332001f49Smrg	continue
257432001f49Smrg	;;
257532001f49Smrg      esac
257632001f49Smrg
257732001f49Smrg      # Get the absolute pathname.
257832001f49Smrg      absdir=`cd "$dir" && pwd`
257932001f49Smrg      test -n "$absdir" && dir="$absdir"
258032001f49Smrg
258132001f49Smrg      # Now add the directory to shlibpath_var.
258232001f49Smrg      if eval "test -z \"\$$shlibpath_var\""; then
258332001f49Smrg	eval "$shlibpath_var=\"\$dir\""
258432001f49Smrg      else
258532001f49Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
258632001f49Smrg      fi
258732001f49Smrg    done
258832001f49Smrg
258932001f49Smrg    # This variable tells wrapper scripts just to set shlibpath_var
259032001f49Smrg    # rather than running their programs.
259132001f49Smrg    libtool_execute_magic="$magic"
259232001f49Smrg
259332001f49Smrg    # Check if any of the arguments is a wrapper script.
259432001f49Smrg    args=
259532001f49Smrg    for file
259632001f49Smrg    do
259732001f49Smrg      case $file in
259832001f49Smrg      -* | *.la | *.lo ) ;;
259932001f49Smrg      *)
260032001f49Smrg	# Do a test to see if this is really a libtool program.
260132001f49Smrg	if func_ltwrapper_script_p "$file"; then
260232001f49Smrg	  func_source "$file"
260332001f49Smrg	  # Transform arg to wrapped name.
260432001f49Smrg	  file="$progdir/$program"
260532001f49Smrg	elif func_ltwrapper_executable_p "$file"; then
260632001f49Smrg	  func_ltwrapper_scriptname "$file"
260732001f49Smrg	  func_source "$func_ltwrapper_scriptname_result"
260832001f49Smrg	  # Transform arg to wrapped name.
260932001f49Smrg	  file="$progdir/$program"
261032001f49Smrg	fi
261132001f49Smrg	;;
261232001f49Smrg      esac
261332001f49Smrg      # Quote arguments (to preserve shell metacharacters).
261432001f49Smrg      func_append_quoted args "$file"
261532001f49Smrg    done
261632001f49Smrg
261732001f49Smrg    if test "X$opt_dry_run" = Xfalse; then
261832001f49Smrg      if test -n "$shlibpath_var"; then
261932001f49Smrg	# Export the shlibpath_var.
262032001f49Smrg	eval "export $shlibpath_var"
262132001f49Smrg      fi
262232001f49Smrg
262332001f49Smrg      # Restore saved environment variables
262432001f49Smrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
262532001f49Smrg      do
262632001f49Smrg	eval "if test \"\${save_$lt_var+set}\" = set; then
262732001f49Smrg                $lt_var=\$save_$lt_var; export $lt_var
262832001f49Smrg	      else
262932001f49Smrg		$lt_unset $lt_var
263032001f49Smrg	      fi"
263132001f49Smrg      done
263232001f49Smrg
263332001f49Smrg      # Now prepare to actually exec the command.
263432001f49Smrg      exec_cmd="\$cmd$args"
263532001f49Smrg    else
263632001f49Smrg      # Display what would be done.
263732001f49Smrg      if test -n "$shlibpath_var"; then
263832001f49Smrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
263932001f49Smrg	echo "export $shlibpath_var"
264032001f49Smrg      fi
264132001f49Smrg      $ECHO "$cmd$args"
264232001f49Smrg      exit $EXIT_SUCCESS
264332001f49Smrg    fi
264432001f49Smrg}
264532001f49Smrg
264632001f49Smrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"}
264732001f49Smrg
264832001f49Smrg
264932001f49Smrg# func_mode_finish arg...
265032001f49Smrgfunc_mode_finish ()
265132001f49Smrg{
265232001f49Smrg    $opt_debug
265332001f49Smrg    libs=
265432001f49Smrg    libdirs=
265532001f49Smrg    admincmds=
265632001f49Smrg
265732001f49Smrg    for opt in "$nonopt" ${1+"$@"}
265832001f49Smrg    do
265932001f49Smrg      if test -d "$opt"; then
266032001f49Smrg	func_append libdirs " $opt"
266132001f49Smrg
266232001f49Smrg      elif test -f "$opt"; then
266332001f49Smrg	if func_lalib_unsafe_p "$opt"; then
266432001f49Smrg	  func_append libs " $opt"
266532001f49Smrg	else
266632001f49Smrg	  func_warning "\`$opt' is not a valid libtool archive"
266732001f49Smrg	fi
266832001f49Smrg
266932001f49Smrg      else
267032001f49Smrg	func_fatal_error "invalid argument \`$opt'"
267132001f49Smrg      fi
267232001f49Smrg    done
267332001f49Smrg
267432001f49Smrg    if test -n "$libs"; then
267532001f49Smrg      if test -n "$lt_sysroot"; then
267632001f49Smrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
267732001f49Smrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
267832001f49Smrg      else
267932001f49Smrg        sysroot_cmd=
268032001f49Smrg      fi
268132001f49Smrg
268232001f49Smrg      # Remove sysroot references
268332001f49Smrg      if $opt_dry_run; then
268432001f49Smrg        for lib in $libs; do
268532001f49Smrg          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
268632001f49Smrg        done
268732001f49Smrg      else
268832001f49Smrg        tmpdir=`func_mktempdir`
268932001f49Smrg        for lib in $libs; do
269032001f49Smrg	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
269132001f49Smrg	    > $tmpdir/tmp-la
269232001f49Smrg	  mv -f $tmpdir/tmp-la $lib
269332001f49Smrg	done
269432001f49Smrg        ${RM}r "$tmpdir"
269532001f49Smrg      fi
269632001f49Smrg    fi
269732001f49Smrg
269832001f49Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
269932001f49Smrg      for libdir in $libdirs; do
270032001f49Smrg	if test -n "$finish_cmds"; then
270132001f49Smrg	  # Do each command in the finish commands.
270232001f49Smrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
270332001f49Smrg'"$cmd"'"'
270432001f49Smrg	fi
270532001f49Smrg	if test -n "$finish_eval"; then
270632001f49Smrg	  # Do the single finish_eval.
270732001f49Smrg	  eval cmds=\"$finish_eval\"
270832001f49Smrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
270932001f49Smrg       $cmds"
271032001f49Smrg	fi
271132001f49Smrg      done
271232001f49Smrg    fi
271332001f49Smrg
271432001f49Smrg    # Exit here if they wanted silent mode.
271532001f49Smrg    $opt_silent && exit $EXIT_SUCCESS
271632001f49Smrg
271732001f49Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
271832001f49Smrg      echo "----------------------------------------------------------------------"
271932001f49Smrg      echo "Libraries have been installed in:"
272032001f49Smrg      for libdir in $libdirs; do
272132001f49Smrg	$ECHO "   $libdir"
272232001f49Smrg      done
272332001f49Smrg      echo
272432001f49Smrg      echo "If you ever happen to want to link against installed libraries"
272532001f49Smrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
272632001f49Smrg      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
272732001f49Smrg      echo "flag during linking and do at least one of the following:"
272832001f49Smrg      if test -n "$shlibpath_var"; then
272932001f49Smrg	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
273032001f49Smrg	echo "     during execution"
273132001f49Smrg      fi
273232001f49Smrg      if test -n "$runpath_var"; then
273332001f49Smrg	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
273432001f49Smrg	echo "     during linking"
273532001f49Smrg      fi
273632001f49Smrg      if test -n "$hardcode_libdir_flag_spec"; then
273732001f49Smrg	libdir=LIBDIR
273832001f49Smrg	eval flag=\"$hardcode_libdir_flag_spec\"
273932001f49Smrg
274032001f49Smrg	$ECHO "   - use the \`$flag' linker flag"
274132001f49Smrg      fi
274232001f49Smrg      if test -n "$admincmds"; then
274332001f49Smrg	$ECHO "   - have your system administrator run these commands:$admincmds"
274432001f49Smrg      fi
274532001f49Smrg      if test -f /etc/ld.so.conf; then
274632001f49Smrg	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
274732001f49Smrg      fi
274832001f49Smrg      echo
274932001f49Smrg
275032001f49Smrg      echo "See any operating system documentation about shared libraries for"
275132001f49Smrg      case $host in
275232001f49Smrg	solaris2.[6789]|solaris2.1[0-9])
275332001f49Smrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
275432001f49Smrg	  echo "pages."
275532001f49Smrg	  ;;
275632001f49Smrg	*)
275732001f49Smrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
275832001f49Smrg	  ;;
275932001f49Smrg      esac
276032001f49Smrg      echo "----------------------------------------------------------------------"
276132001f49Smrg    fi
276232001f49Smrg    exit $EXIT_SUCCESS
276332001f49Smrg}
276432001f49Smrg
276532001f49Smrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"}
276632001f49Smrg
276732001f49Smrg
276832001f49Smrg# func_mode_install arg...
276932001f49Smrgfunc_mode_install ()
277032001f49Smrg{
277132001f49Smrg    $opt_debug
277232001f49Smrg    # There may be an optional sh(1) argument at the beginning of
277332001f49Smrg    # install_prog (especially on Windows NT).
277432001f49Smrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
277532001f49Smrg       # Allow the use of GNU shtool's install command.
277632001f49Smrg       case $nonopt in *shtool*) :;; *) false;; esac; then
277732001f49Smrg      # Aesthetically quote it.
277832001f49Smrg      func_quote_for_eval "$nonopt"
277932001f49Smrg      install_prog="$func_quote_for_eval_result "
278032001f49Smrg      arg=$1
278132001f49Smrg      shift
278232001f49Smrg    else
278332001f49Smrg      install_prog=
278432001f49Smrg      arg=$nonopt
278532001f49Smrg    fi
278632001f49Smrg
278732001f49Smrg    # The real first argument should be the name of the installation program.
278832001f49Smrg    # Aesthetically quote it.
278932001f49Smrg    func_quote_for_eval "$arg"
279032001f49Smrg    func_append install_prog "$func_quote_for_eval_result"
279132001f49Smrg    install_shared_prog=$install_prog
279232001f49Smrg    case " $install_prog " in
279332001f49Smrg      *[\\\ /]cp\ *) install_cp=: ;;
279432001f49Smrg      *) install_cp=false ;;
279532001f49Smrg    esac
279632001f49Smrg
279732001f49Smrg    # We need to accept at least all the BSD install flags.
279832001f49Smrg    dest=
279932001f49Smrg    files=
280032001f49Smrg    opts=
280132001f49Smrg    prev=
280232001f49Smrg    install_type=
280332001f49Smrg    isdir=no
280432001f49Smrg    stripme=
280532001f49Smrg    no_mode=:
280632001f49Smrg    for arg
280732001f49Smrg    do
280832001f49Smrg      arg2=
280932001f49Smrg      if test -n "$dest"; then
281032001f49Smrg	func_append files " $dest"
281132001f49Smrg	dest=$arg
281232001f49Smrg	continue
281332001f49Smrg      fi
281432001f49Smrg
281532001f49Smrg      case $arg in
281632001f49Smrg      -d) isdir=yes ;;
281732001f49Smrg      -f)
281832001f49Smrg	if $install_cp; then :; else
281932001f49Smrg	  prev=$arg
282032001f49Smrg	fi
282132001f49Smrg	;;
282232001f49Smrg      -g | -m | -o)
282332001f49Smrg	prev=$arg
282432001f49Smrg	;;
282532001f49Smrg      -s)
282632001f49Smrg	stripme=" -s"
282732001f49Smrg	continue
282832001f49Smrg	;;
282932001f49Smrg      -*)
283032001f49Smrg	;;
283132001f49Smrg      *)
283232001f49Smrg	# If the previous option needed an argument, then skip it.
283332001f49Smrg	if test -n "$prev"; then
283432001f49Smrg	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
283532001f49Smrg	    arg2=$install_override_mode
283632001f49Smrg	    no_mode=false
283732001f49Smrg	  fi
283832001f49Smrg	  prev=
283932001f49Smrg	else
284032001f49Smrg	  dest=$arg
284132001f49Smrg	  continue
284232001f49Smrg	fi
284332001f49Smrg	;;
284432001f49Smrg      esac
284532001f49Smrg
284632001f49Smrg      # Aesthetically quote the argument.
284732001f49Smrg      func_quote_for_eval "$arg"
284832001f49Smrg      func_append install_prog " $func_quote_for_eval_result"
284932001f49Smrg      if test -n "$arg2"; then
285032001f49Smrg	func_quote_for_eval "$arg2"
285132001f49Smrg      fi
285232001f49Smrg      func_append install_shared_prog " $func_quote_for_eval_result"
285332001f49Smrg    done
285432001f49Smrg
285532001f49Smrg    test -z "$install_prog" && \
285632001f49Smrg      func_fatal_help "you must specify an install program"
285732001f49Smrg
285832001f49Smrg    test -n "$prev" && \
285932001f49Smrg      func_fatal_help "the \`$prev' option requires an argument"
286032001f49Smrg
286132001f49Smrg    if test -n "$install_override_mode" && $no_mode; then
286232001f49Smrg      if $install_cp; then :; else
286332001f49Smrg	func_quote_for_eval "$install_override_mode"
286432001f49Smrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
286532001f49Smrg      fi
286632001f49Smrg    fi
286732001f49Smrg
286832001f49Smrg    if test -z "$files"; then
286932001f49Smrg      if test -z "$dest"; then
287032001f49Smrg	func_fatal_help "no file or destination specified"
287132001f49Smrg      else
287232001f49Smrg	func_fatal_help "you must specify a destination"
287332001f49Smrg      fi
287432001f49Smrg    fi
287532001f49Smrg
287632001f49Smrg    # Strip any trailing slash from the destination.
287732001f49Smrg    func_stripname '' '/' "$dest"
287832001f49Smrg    dest=$func_stripname_result
287932001f49Smrg
288032001f49Smrg    # Check to see that the destination is a directory.
288132001f49Smrg    test -d "$dest" && isdir=yes
288232001f49Smrg    if test "$isdir" = yes; then
288332001f49Smrg      destdir="$dest"
288432001f49Smrg      destname=
288532001f49Smrg    else
288632001f49Smrg      func_dirname_and_basename "$dest" "" "."
288732001f49Smrg      destdir="$func_dirname_result"
288832001f49Smrg      destname="$func_basename_result"
288932001f49Smrg
289032001f49Smrg      # Not a directory, so check to see that there is only one file specified.
289132001f49Smrg      set dummy $files; shift
289232001f49Smrg      test "$#" -gt 1 && \
289332001f49Smrg	func_fatal_help "\`$dest' is not a directory"
289432001f49Smrg    fi
289532001f49Smrg    case $destdir in
289632001f49Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
289732001f49Smrg    *)
289832001f49Smrg      for file in $files; do
289932001f49Smrg	case $file in
290032001f49Smrg	*.lo) ;;
290132001f49Smrg	*)
290232001f49Smrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
290332001f49Smrg	  ;;
290432001f49Smrg	esac
290532001f49Smrg      done
290632001f49Smrg      ;;
290732001f49Smrg    esac
290832001f49Smrg
290932001f49Smrg    # This variable tells wrapper scripts just to set variables rather
291032001f49Smrg    # than running their programs.
291132001f49Smrg    libtool_install_magic="$magic"
291232001f49Smrg
291332001f49Smrg    staticlibs=
291432001f49Smrg    future_libdirs=
291532001f49Smrg    current_libdirs=
291632001f49Smrg    for file in $files; do
291732001f49Smrg
291832001f49Smrg      # Do each installation.
291932001f49Smrg      case $file in
292032001f49Smrg      *.$libext)
292132001f49Smrg	# Do the static libraries later.
292232001f49Smrg	func_append staticlibs " $file"
292332001f49Smrg	;;
292432001f49Smrg
292532001f49Smrg      *.la)
292632001f49Smrg	func_resolve_sysroot "$file"
292732001f49Smrg	file=$func_resolve_sysroot_result
292832001f49Smrg
292932001f49Smrg	# Check to see that this really is a libtool archive.
293032001f49Smrg	func_lalib_unsafe_p "$file" \
293132001f49Smrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
293232001f49Smrg
293332001f49Smrg	library_names=
293432001f49Smrg	old_library=
293532001f49Smrg	relink_command=
293632001f49Smrg	func_source "$file"
293732001f49Smrg
293832001f49Smrg	# Add the libdir to current_libdirs if it is the destination.
293932001f49Smrg	if test "X$destdir" = "X$libdir"; then
294032001f49Smrg	  case "$current_libdirs " in
294132001f49Smrg	  *" $libdir "*) ;;
294232001f49Smrg	  *) func_append current_libdirs " $libdir" ;;
294332001f49Smrg	  esac
294432001f49Smrg	else
294532001f49Smrg	  # Note the libdir as a future libdir.
294632001f49Smrg	  case "$future_libdirs " in
294732001f49Smrg	  *" $libdir "*) ;;
294832001f49Smrg	  *) func_append future_libdirs " $libdir" ;;
294932001f49Smrg	  esac
295032001f49Smrg	fi
295132001f49Smrg
295232001f49Smrg	func_dirname "$file" "/" ""
295332001f49Smrg	dir="$func_dirname_result"
295432001f49Smrg	func_append dir "$objdir"
295532001f49Smrg
295632001f49Smrg	if test -n "$relink_command"; then
295732001f49Smrg	  # Determine the prefix the user has applied to our future dir.
295832001f49Smrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
295932001f49Smrg
296032001f49Smrg	  # Don't allow the user to place us outside of our expected
296132001f49Smrg	  # location b/c this prevents finding dependent libraries that
296232001f49Smrg	  # are installed to the same prefix.
296332001f49Smrg	  # At present, this check doesn't affect windows .dll's that
296432001f49Smrg	  # are installed into $libdir/../bin (currently, that works fine)
296532001f49Smrg	  # but it's something to keep an eye on.
296632001f49Smrg	  test "$inst_prefix_dir" = "$destdir" && \
296732001f49Smrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
296832001f49Smrg
296932001f49Smrg	  if test -n "$inst_prefix_dir"; then
297032001f49Smrg	    # Stick the inst_prefix_dir data into the link command.
297132001f49Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
297232001f49Smrg	  else
297332001f49Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
297432001f49Smrg	  fi
297532001f49Smrg
297632001f49Smrg	  func_warning "relinking \`$file'"
297732001f49Smrg	  func_show_eval "$relink_command" \
297832001f49Smrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
297932001f49Smrg	fi
298032001f49Smrg
298132001f49Smrg	# See the names of the shared library.
298232001f49Smrg	set dummy $library_names; shift
298332001f49Smrg	if test -n "$1"; then
298432001f49Smrg	  realname="$1"
298532001f49Smrg	  shift
298632001f49Smrg
298732001f49Smrg	  srcname="$realname"
298832001f49Smrg	  test -n "$relink_command" && srcname="$realname"T
298932001f49Smrg
299032001f49Smrg	  # Install the shared library and build the symlinks.
299132001f49Smrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
299232001f49Smrg	      'exit $?'
299332001f49Smrg	  tstripme="$stripme"
299432001f49Smrg	  case $host_os in
299532001f49Smrg	  cygwin* | mingw* | pw32* | cegcc*)
299632001f49Smrg	    case $realname in
299732001f49Smrg	    *.dll.a)
299832001f49Smrg	      tstripme=""
299932001f49Smrg	      ;;
300032001f49Smrg	    esac
300132001f49Smrg	    ;;
300232001f49Smrg	  esac
300332001f49Smrg	  if test -n "$tstripme" && test -n "$striplib"; then
300432001f49Smrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
300532001f49Smrg	  fi
300632001f49Smrg
300732001f49Smrg	  if test "$#" -gt 0; then
300832001f49Smrg	    # Delete the old symlinks, and create new ones.
300932001f49Smrg	    # Try `ln -sf' first, because the `ln' binary might depend on
301032001f49Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
301132001f49Smrg	    # so we also need to try rm && ln -s.
301232001f49Smrg	    for linkname
301332001f49Smrg	    do
301432001f49Smrg	      test "$linkname" != "$realname" \
301532001f49Smrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
301632001f49Smrg	    done
301732001f49Smrg	  fi
301832001f49Smrg
301932001f49Smrg	  # Do each command in the postinstall commands.
302032001f49Smrg	  lib="$destdir/$realname"
302132001f49Smrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
302232001f49Smrg	fi
302332001f49Smrg
302432001f49Smrg	# Install the pseudo-library for information purposes.
302532001f49Smrg	func_basename "$file"
302632001f49Smrg	name="$func_basename_result"
302732001f49Smrg	instname="$dir/$name"i
302832001f49Smrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
302932001f49Smrg
303032001f49Smrg	# Maybe install the static library, too.
303132001f49Smrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
303232001f49Smrg	;;
303332001f49Smrg
303432001f49Smrg      *.lo)
303532001f49Smrg	# Install (i.e. copy) a libtool object.
303632001f49Smrg
303732001f49Smrg	# Figure out destination file name, if it wasn't already specified.
303832001f49Smrg	if test -n "$destname"; then
303932001f49Smrg	  destfile="$destdir/$destname"
304032001f49Smrg	else
304132001f49Smrg	  func_basename "$file"
304232001f49Smrg	  destfile="$func_basename_result"
304332001f49Smrg	  destfile="$destdir/$destfile"
304432001f49Smrg	fi
304532001f49Smrg
304632001f49Smrg	# Deduce the name of the destination old-style object file.
304732001f49Smrg	case $destfile in
304832001f49Smrg	*.lo)
304932001f49Smrg	  func_lo2o "$destfile"
305032001f49Smrg	  staticdest=$func_lo2o_result
305132001f49Smrg	  ;;
305232001f49Smrg	*.$objext)
305332001f49Smrg	  staticdest="$destfile"
305432001f49Smrg	  destfile=
305532001f49Smrg	  ;;
305632001f49Smrg	*)
305732001f49Smrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
305832001f49Smrg	  ;;
305932001f49Smrg	esac
306032001f49Smrg
306132001f49Smrg	# Install the libtool object if requested.
306232001f49Smrg	test -n "$destfile" && \
306332001f49Smrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
306432001f49Smrg
306532001f49Smrg	# Install the old object if enabled.
306632001f49Smrg	if test "$build_old_libs" = yes; then
306732001f49Smrg	  # Deduce the name of the old-style object file.
306832001f49Smrg	  func_lo2o "$file"
306932001f49Smrg	  staticobj=$func_lo2o_result
307032001f49Smrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
307132001f49Smrg	fi
307232001f49Smrg	exit $EXIT_SUCCESS
307332001f49Smrg	;;
307432001f49Smrg
307532001f49Smrg      *)
307632001f49Smrg	# Figure out destination file name, if it wasn't already specified.
307732001f49Smrg	if test -n "$destname"; then
307832001f49Smrg	  destfile="$destdir/$destname"
307932001f49Smrg	else
308032001f49Smrg	  func_basename "$file"
308132001f49Smrg	  destfile="$func_basename_result"
308232001f49Smrg	  destfile="$destdir/$destfile"
308332001f49Smrg	fi
308432001f49Smrg
308532001f49Smrg	# If the file is missing, and there is a .exe on the end, strip it
308632001f49Smrg	# because it is most likely a libtool script we actually want to
308732001f49Smrg	# install
308832001f49Smrg	stripped_ext=""
308932001f49Smrg	case $file in
309032001f49Smrg	  *.exe)
309132001f49Smrg	    if test ! -f "$file"; then
309232001f49Smrg	      func_stripname '' '.exe' "$file"
309332001f49Smrg	      file=$func_stripname_result
309432001f49Smrg	      stripped_ext=".exe"
309532001f49Smrg	    fi
309632001f49Smrg	    ;;
309732001f49Smrg	esac
309832001f49Smrg
309932001f49Smrg	# Do a test to see if this is really a libtool program.
310032001f49Smrg	case $host in
310132001f49Smrg	*cygwin* | *mingw*)
310232001f49Smrg	    if func_ltwrapper_executable_p "$file"; then
310332001f49Smrg	      func_ltwrapper_scriptname "$file"
310432001f49Smrg	      wrapper=$func_ltwrapper_scriptname_result
310532001f49Smrg	    else
310632001f49Smrg	      func_stripname '' '.exe' "$file"
310732001f49Smrg	      wrapper=$func_stripname_result
310832001f49Smrg	    fi
310932001f49Smrg	    ;;
311032001f49Smrg	*)
311132001f49Smrg	    wrapper=$file
311232001f49Smrg	    ;;
311332001f49Smrg	esac
311432001f49Smrg	if func_ltwrapper_script_p "$wrapper"; then
311532001f49Smrg	  notinst_deplibs=
311632001f49Smrg	  relink_command=
311732001f49Smrg
311832001f49Smrg	  func_source "$wrapper"
311932001f49Smrg
312032001f49Smrg	  # Check the variables that should have been set.
312132001f49Smrg	  test -z "$generated_by_libtool_version" && \
312232001f49Smrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
312332001f49Smrg
312432001f49Smrg	  finalize=yes
312532001f49Smrg	  for lib in $notinst_deplibs; do
312632001f49Smrg	    # Check to see that each library is installed.
312732001f49Smrg	    libdir=
312832001f49Smrg	    if test -f "$lib"; then
312932001f49Smrg	      func_source "$lib"
313032001f49Smrg	    fi
313132001f49Smrg	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
313232001f49Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
313332001f49Smrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
313432001f49Smrg	      finalize=no
313532001f49Smrg	    fi
313632001f49Smrg	  done
313732001f49Smrg
313832001f49Smrg	  relink_command=
313932001f49Smrg	  func_source "$wrapper"
314032001f49Smrg
314132001f49Smrg	  outputname=
314232001f49Smrg	  if test "$fast_install" = no && test -n "$relink_command"; then
314332001f49Smrg	    $opt_dry_run || {
314432001f49Smrg	      if test "$finalize" = yes; then
314532001f49Smrg	        tmpdir=`func_mktempdir`
314632001f49Smrg		func_basename "$file$stripped_ext"
314732001f49Smrg		file="$func_basename_result"
314832001f49Smrg	        outputname="$tmpdir/$file"
314932001f49Smrg	        # Replace the output file specification.
315032001f49Smrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
315132001f49Smrg
315232001f49Smrg	        $opt_silent || {
315332001f49Smrg	          func_quote_for_expand "$relink_command"
315432001f49Smrg		  eval "func_echo $func_quote_for_expand_result"
315532001f49Smrg	        }
315632001f49Smrg	        if eval "$relink_command"; then :
315732001f49Smrg	          else
315832001f49Smrg		  func_error "error: relink \`$file' with the above command before installing it"
315932001f49Smrg		  $opt_dry_run || ${RM}r "$tmpdir"
316032001f49Smrg		  continue
316132001f49Smrg	        fi
316232001f49Smrg	        file="$outputname"
316332001f49Smrg	      else
316432001f49Smrg	        func_warning "cannot relink \`$file'"
316532001f49Smrg	      fi
316632001f49Smrg	    }
316732001f49Smrg	  else
316832001f49Smrg	    # Install the binary that we compiled earlier.
316932001f49Smrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
317032001f49Smrg	  fi
317132001f49Smrg	fi
317232001f49Smrg
317332001f49Smrg	# remove .exe since cygwin /usr/bin/install will append another
317432001f49Smrg	# one anyway
317532001f49Smrg	case $install_prog,$host in
317632001f49Smrg	*/usr/bin/install*,*cygwin*)
317732001f49Smrg	  case $file:$destfile in
317832001f49Smrg	  *.exe:*.exe)
317932001f49Smrg	    # this is ok
318032001f49Smrg	    ;;
318132001f49Smrg	  *.exe:*)
318232001f49Smrg	    destfile=$destfile.exe
318332001f49Smrg	    ;;
318432001f49Smrg	  *:*.exe)
318532001f49Smrg	    func_stripname '' '.exe' "$destfile"
318632001f49Smrg	    destfile=$func_stripname_result
318732001f49Smrg	    ;;
318832001f49Smrg	  esac
318932001f49Smrg	  ;;
319032001f49Smrg	esac
319132001f49Smrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
319232001f49Smrg	$opt_dry_run || if test -n "$outputname"; then
319332001f49Smrg	  ${RM}r "$tmpdir"
319432001f49Smrg	fi
319532001f49Smrg	;;
319632001f49Smrg      esac
319732001f49Smrg    done
319832001f49Smrg
319932001f49Smrg    for file in $staticlibs; do
320032001f49Smrg      func_basename "$file"
320132001f49Smrg      name="$func_basename_result"
320232001f49Smrg
320332001f49Smrg      # Set up the ranlib parameters.
320432001f49Smrg      oldlib="$destdir/$name"
320532001f49Smrg      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
320632001f49Smrg      tool_oldlib=$func_to_tool_file_result
320732001f49Smrg
320832001f49Smrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
320932001f49Smrg
321032001f49Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
321132001f49Smrg	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
321232001f49Smrg      fi
321332001f49Smrg
321432001f49Smrg      # Do each command in the postinstall commands.
321532001f49Smrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
321632001f49Smrg    done
321732001f49Smrg
321832001f49Smrg    test -n "$future_libdirs" && \
321932001f49Smrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
322032001f49Smrg
322132001f49Smrg    if test -n "$current_libdirs"; then
322232001f49Smrg      # Maybe just do a dry run.
322332001f49Smrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
322432001f49Smrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
322532001f49Smrg    else
322632001f49Smrg      exit $EXIT_SUCCESS
322732001f49Smrg    fi
322832001f49Smrg}
322932001f49Smrg
323032001f49Smrgtest "$opt_mode" = install && func_mode_install ${1+"$@"}
323132001f49Smrg
323232001f49Smrg
323332001f49Smrg# func_generate_dlsyms outputname originator pic_p
323432001f49Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with
323532001f49Smrg# a dlpreopen symbol table.
323632001f49Smrgfunc_generate_dlsyms ()
323732001f49Smrg{
323832001f49Smrg    $opt_debug
323932001f49Smrg    my_outputname="$1"
324032001f49Smrg    my_originator="$2"
324132001f49Smrg    my_pic_p="${3-no}"
324232001f49Smrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
324332001f49Smrg    my_dlsyms=
324432001f49Smrg
324532001f49Smrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
324632001f49Smrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
324732001f49Smrg	my_dlsyms="${my_outputname}S.c"
324832001f49Smrg      else
324932001f49Smrg	func_error "not configured to extract global symbols from dlpreopened files"
325032001f49Smrg      fi
325132001f49Smrg    fi
325232001f49Smrg
325332001f49Smrg    if test -n "$my_dlsyms"; then
325432001f49Smrg      case $my_dlsyms in
325532001f49Smrg      "") ;;
325632001f49Smrg      *.c)
325732001f49Smrg	# Discover the nlist of each of the dlfiles.
325832001f49Smrg	nlist="$output_objdir/${my_outputname}.nm"
325932001f49Smrg
326032001f49Smrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
326132001f49Smrg
326232001f49Smrg	# Parse the name list into a source file.
326332001f49Smrg	func_verbose "creating $output_objdir/$my_dlsyms"
326432001f49Smrg
326532001f49Smrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
326632001f49Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
326732001f49Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
326832001f49Smrg
326932001f49Smrg#ifdef __cplusplus
327032001f49Smrgextern \"C\" {
327132001f49Smrg#endif
327232001f49Smrg
327332001f49Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
327432001f49Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
327532001f49Smrg#endif
327632001f49Smrg
327732001f49Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
327832001f49Smrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
327932001f49Smrg/* DATA imports from DLLs on WIN32 con't be const, because runtime
328032001f49Smrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
328132001f49Smrg# define LT_DLSYM_CONST
328232001f49Smrg#elif defined(__osf__)
328332001f49Smrg/* This system does not cope well with relocations in const data.  */
328432001f49Smrg# define LT_DLSYM_CONST
328532001f49Smrg#else
328632001f49Smrg# define LT_DLSYM_CONST const
328732001f49Smrg#endif
328832001f49Smrg
328932001f49Smrg/* External symbol declarations for the compiler. */\
329032001f49Smrg"
329132001f49Smrg
329232001f49Smrg	if test "$dlself" = yes; then
329332001f49Smrg	  func_verbose "generating symbol list for \`$output'"
329432001f49Smrg
329532001f49Smrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
329632001f49Smrg
329732001f49Smrg	  # Add our own program objects to the symbol list.
329832001f49Smrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
329932001f49Smrg	  for progfile in $progfiles; do
330032001f49Smrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
330132001f49Smrg	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
330232001f49Smrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
330332001f49Smrg	  done
330432001f49Smrg
330532001f49Smrg	  if test -n "$exclude_expsyms"; then
330632001f49Smrg	    $opt_dry_run || {
330732001f49Smrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
330832001f49Smrg	      eval '$MV "$nlist"T "$nlist"'
330932001f49Smrg	    }
331032001f49Smrg	  fi
331132001f49Smrg
331232001f49Smrg	  if test -n "$export_symbols_regex"; then
331332001f49Smrg	    $opt_dry_run || {
331432001f49Smrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
331532001f49Smrg	      eval '$MV "$nlist"T "$nlist"'
331632001f49Smrg	    }
331732001f49Smrg	  fi
331832001f49Smrg
331932001f49Smrg	  # Prepare the list of exported symbols
332032001f49Smrg	  if test -z "$export_symbols"; then
332132001f49Smrg	    export_symbols="$output_objdir/$outputname.exp"
332232001f49Smrg	    $opt_dry_run || {
332332001f49Smrg	      $RM $export_symbols
332432001f49Smrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
332532001f49Smrg	      case $host in
332632001f49Smrg	      *cygwin* | *mingw* | *cegcc* )
332732001f49Smrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
332832001f49Smrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
332932001f49Smrg	        ;;
333032001f49Smrg	      esac
333132001f49Smrg	    }
333232001f49Smrg	  else
333332001f49Smrg	    $opt_dry_run || {
333432001f49Smrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
333532001f49Smrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
333632001f49Smrg	      eval '$MV "$nlist"T "$nlist"'
333732001f49Smrg	      case $host in
333832001f49Smrg	        *cygwin* | *mingw* | *cegcc* )
333932001f49Smrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
334032001f49Smrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
334132001f49Smrg	          ;;
334232001f49Smrg	      esac
334332001f49Smrg	    }
334432001f49Smrg	  fi
334532001f49Smrg	fi
334632001f49Smrg
334732001f49Smrg	for dlprefile in $dlprefiles; do
334832001f49Smrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
334932001f49Smrg	  func_basename "$dlprefile"
335032001f49Smrg	  name="$func_basename_result"
335132001f49Smrg          case $host in
335232001f49Smrg	    *cygwin* | *mingw* | *cegcc* )
335332001f49Smrg	      # if an import library, we need to obtain dlname
335432001f49Smrg	      if func_win32_import_lib_p "$dlprefile"; then
335532001f49Smrg	        func_tr_sh "$dlprefile"
335632001f49Smrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
335732001f49Smrg	        dlprefile_dlbasename=""
335832001f49Smrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
335932001f49Smrg	          # Use subshell, to avoid clobbering current variable values
336032001f49Smrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
336132001f49Smrg	          if test -n "$dlprefile_dlname" ; then
336232001f49Smrg	            func_basename "$dlprefile_dlname"
336332001f49Smrg	            dlprefile_dlbasename="$func_basename_result"
336432001f49Smrg	          else
336532001f49Smrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
336632001f49Smrg	            $sharedlib_from_linklib_cmd "$dlprefile"
336732001f49Smrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
336832001f49Smrg	          fi
336932001f49Smrg	        fi
337032001f49Smrg	        $opt_dry_run || {
337132001f49Smrg	          if test -n "$dlprefile_dlbasename" ; then
337232001f49Smrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
337332001f49Smrg	          else
337432001f49Smrg	            func_warning "Could not compute DLL name from $name"
337532001f49Smrg	            eval '$ECHO ": $name " >> "$nlist"'
337632001f49Smrg	          fi
337732001f49Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
337832001f49Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
337932001f49Smrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
338032001f49Smrg	        }
338132001f49Smrg	      else # not an import lib
338232001f49Smrg	        $opt_dry_run || {
338332001f49Smrg	          eval '$ECHO ": $name " >> "$nlist"'
338432001f49Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
338532001f49Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
338632001f49Smrg	        }
338732001f49Smrg	      fi
338832001f49Smrg	    ;;
338932001f49Smrg	    *)
339032001f49Smrg	      $opt_dry_run || {
339132001f49Smrg	        eval '$ECHO ": $name " >> "$nlist"'
339232001f49Smrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
339332001f49Smrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
339432001f49Smrg	      }
339532001f49Smrg	    ;;
339632001f49Smrg          esac
339732001f49Smrg	done
339832001f49Smrg
339932001f49Smrg	$opt_dry_run || {
340032001f49Smrg	  # Make sure we have at least an empty file.
340132001f49Smrg	  test -f "$nlist" || : > "$nlist"
340232001f49Smrg
340332001f49Smrg	  if test -n "$exclude_expsyms"; then
340432001f49Smrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
340532001f49Smrg	    $MV "$nlist"T "$nlist"
340632001f49Smrg	  fi
340732001f49Smrg
340832001f49Smrg	  # Try sorting and uniquifying the output.
340932001f49Smrg	  if $GREP -v "^: " < "$nlist" |
341032001f49Smrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
341132001f49Smrg		sort -k 3
341232001f49Smrg	      else
341332001f49Smrg		sort +2
341432001f49Smrg	      fi |
341532001f49Smrg	      uniq > "$nlist"S; then
341632001f49Smrg	    :
341732001f49Smrg	  else
341832001f49Smrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
341932001f49Smrg	  fi
342032001f49Smrg
342132001f49Smrg	  if test -f "$nlist"S; then
342232001f49Smrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
342332001f49Smrg	  else
342432001f49Smrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
342532001f49Smrg	  fi
342632001f49Smrg
342732001f49Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
342832001f49Smrg
342932001f49Smrg/* The mapping between symbol names and symbols.  */
343032001f49Smrgtypedef struct {
343132001f49Smrg  const char *name;
343232001f49Smrg  void *address;
343332001f49Smrg} lt_dlsymlist;
343432001f49Smrgextern LT_DLSYM_CONST lt_dlsymlist
343532001f49Smrglt_${my_prefix}_LTX_preloaded_symbols[];
343632001f49SmrgLT_DLSYM_CONST lt_dlsymlist
343732001f49Smrglt_${my_prefix}_LTX_preloaded_symbols[] =
343832001f49Smrg{\
343932001f49Smrg  { \"$my_originator\", (void *) 0 },"
344032001f49Smrg
344132001f49Smrg	  case $need_lib_prefix in
344232001f49Smrg	  no)
344332001f49Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
344432001f49Smrg	    ;;
344532001f49Smrg	  *)
344632001f49Smrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
344732001f49Smrg	    ;;
344832001f49Smrg	  esac
344932001f49Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
345032001f49Smrg  {0, (void *) 0}
345132001f49Smrg};
345232001f49Smrg
345332001f49Smrg/* This works around a problem in FreeBSD linker */
345432001f49Smrg#ifdef FREEBSD_WORKAROUND
345532001f49Smrgstatic const void *lt_preloaded_setup() {
345632001f49Smrg  return lt_${my_prefix}_LTX_preloaded_symbols;
345732001f49Smrg}
345832001f49Smrg#endif
345932001f49Smrg
346032001f49Smrg#ifdef __cplusplus
346132001f49Smrg}
346232001f49Smrg#endif\
346332001f49Smrg"
346432001f49Smrg	} # !$opt_dry_run
346532001f49Smrg
346632001f49Smrg	pic_flag_for_symtable=
346732001f49Smrg	case "$compile_command " in
346832001f49Smrg	*" -static "*) ;;
346932001f49Smrg	*)
347032001f49Smrg	  case $host in
347132001f49Smrg	  # compiling the symbol table file with pic_flag works around
347232001f49Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
347332001f49Smrg	  # linked before any other PIC object.  But we must not use
347432001f49Smrg	  # pic_flag when linking with -static.  The problem exists in
347532001f49Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
347632001f49Smrg	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
347732001f49Smrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
347832001f49Smrg	  *-*-hpux*)
347932001f49Smrg	    pic_flag_for_symtable=" $pic_flag"  ;;
348032001f49Smrg	  *)
348132001f49Smrg	    if test "X$my_pic_p" != Xno; then
348232001f49Smrg	      pic_flag_for_symtable=" $pic_flag"
348332001f49Smrg	    fi
348432001f49Smrg	    ;;
348532001f49Smrg	  esac
348632001f49Smrg	  ;;
348732001f49Smrg	esac
348832001f49Smrg	symtab_cflags=
348932001f49Smrg	for arg in $LTCFLAGS; do
349032001f49Smrg	  case $arg in
349132001f49Smrg	  -pie | -fpie | -fPIE) ;;
349232001f49Smrg	  *) func_append symtab_cflags " $arg" ;;
349332001f49Smrg	  esac
349432001f49Smrg	done
349532001f49Smrg
349632001f49Smrg	# Now compile the dynamic symbol file.
349732001f49Smrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
349832001f49Smrg
349932001f49Smrg	# Clean up the generated files.
350032001f49Smrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
350132001f49Smrg
350232001f49Smrg	# Transform the symbol file into the correct name.
350332001f49Smrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
350432001f49Smrg	case $host in
350532001f49Smrg	*cygwin* | *mingw* | *cegcc* )
350632001f49Smrg	  if test -f "$output_objdir/$my_outputname.def"; then
350732001f49Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
350832001f49Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
350932001f49Smrg	  else
351032001f49Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
351132001f49Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
351232001f49Smrg	  fi
351332001f49Smrg	  ;;
351432001f49Smrg	*)
351532001f49Smrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
351632001f49Smrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
351732001f49Smrg	  ;;
351832001f49Smrg	esac
351932001f49Smrg	;;
352032001f49Smrg      *)
352132001f49Smrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
352232001f49Smrg	;;
352332001f49Smrg      esac
352432001f49Smrg    else
352532001f49Smrg      # We keep going just in case the user didn't refer to
352632001f49Smrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
352732001f49Smrg      # really was required.
352832001f49Smrg
352932001f49Smrg      # Nullify the symbol file.
353032001f49Smrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
353132001f49Smrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
353232001f49Smrg    fi
353332001f49Smrg}
353432001f49Smrg
353532001f49Smrg# func_win32_libid arg
353632001f49Smrg# return the library type of file 'arg'
353732001f49Smrg#
353832001f49Smrg# Need a lot of goo to handle *both* DLLs and import libs
353932001f49Smrg# Has to be a shell function in order to 'eat' the argument
354032001f49Smrg# that is supplied when $file_magic_command is called.
354132001f49Smrg# Despite the name, also deal with 64 bit binaries.
354232001f49Smrgfunc_win32_libid ()
354332001f49Smrg{
354432001f49Smrg  $opt_debug
354532001f49Smrg  win32_libid_type="unknown"
354632001f49Smrg  win32_fileres=`file -L $1 2>/dev/null`
354732001f49Smrg  case $win32_fileres in
354832001f49Smrg  *ar\ archive\ import\ library*) # definitely import
354932001f49Smrg    win32_libid_type="x86 archive import"
355032001f49Smrg    ;;
355132001f49Smrg  *ar\ archive*) # could be an import, or static
355232001f49Smrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
355332001f49Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
355432001f49Smrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
355532001f49Smrg      func_to_tool_file "$1" func_convert_file_msys_to_w32
355632001f49Smrg      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
355732001f49Smrg	$SED -n -e '
355832001f49Smrg	    1,100{
355932001f49Smrg		/ I /{
356032001f49Smrg		    s,.*,import,
356132001f49Smrg		    p
356232001f49Smrg		    q
356332001f49Smrg		}
356432001f49Smrg	    }'`
356532001f49Smrg      case $win32_nmres in
356632001f49Smrg      import*)  win32_libid_type="x86 archive import";;
356732001f49Smrg      *)        win32_libid_type="x86 archive static";;
356832001f49Smrg      esac
356932001f49Smrg    fi
357032001f49Smrg    ;;
357132001f49Smrg  *DLL*)
357232001f49Smrg    win32_libid_type="x86 DLL"
357332001f49Smrg    ;;
357432001f49Smrg  *executable*) # but shell scripts are "executable" too...
357532001f49Smrg    case $win32_fileres in
357632001f49Smrg    *MS\ Windows\ PE\ Intel*)
357732001f49Smrg      win32_libid_type="x86 DLL"
357832001f49Smrg      ;;
357932001f49Smrg    esac
358032001f49Smrg    ;;
358132001f49Smrg  esac
358232001f49Smrg  $ECHO "$win32_libid_type"
358332001f49Smrg}
358432001f49Smrg
358532001f49Smrg# func_cygming_dll_for_implib ARG
358632001f49Smrg#
358732001f49Smrg# Platform-specific function to extract the
358832001f49Smrg# name of the DLL associated with the specified
358932001f49Smrg# import library ARG.
359032001f49Smrg# Invoked by eval'ing the libtool variable
359132001f49Smrg#    $sharedlib_from_linklib_cmd
359232001f49Smrg# Result is available in the variable
359332001f49Smrg#    $sharedlib_from_linklib_result
359432001f49Smrgfunc_cygming_dll_for_implib ()
359532001f49Smrg{
359632001f49Smrg  $opt_debug
359732001f49Smrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
359832001f49Smrg}
359932001f49Smrg
360032001f49Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
360132001f49Smrg#
360232001f49Smrg# The is the core of a fallback implementation of a
360332001f49Smrg# platform-specific function to extract the name of the
360432001f49Smrg# DLL associated with the specified import library LIBNAME.
360532001f49Smrg#
360632001f49Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending
360732001f49Smrg# on the platform and compiler that created the implib.
360832001f49Smrg#
360932001f49Smrg# Echos the name of the DLL associated with the
361032001f49Smrg# specified import library.
361132001f49Smrgfunc_cygming_dll_for_implib_fallback_core ()
361232001f49Smrg{
361332001f49Smrg  $opt_debug
361432001f49Smrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
361532001f49Smrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
361632001f49Smrg    $SED '/^Contents of section '"$match_literal"':/{
361732001f49Smrg      # Place marker at beginning of archive member dllname section
361832001f49Smrg      s/.*/====MARK====/
361932001f49Smrg      p
362032001f49Smrg      d
362132001f49Smrg    }
362232001f49Smrg    # These lines can sometimes be longer than 43 characters, but
362332001f49Smrg    # are always uninteresting
362432001f49Smrg    /:[	 ]*file format pe[i]\{,1\}-/d
362532001f49Smrg    /^In archive [^:]*:/d
362632001f49Smrg    # Ensure marker is printed
362732001f49Smrg    /^====MARK====/p
362832001f49Smrg    # Remove all lines with less than 43 characters
362932001f49Smrg    /^.\{43\}/!d
363032001f49Smrg    # From remaining lines, remove first 43 characters
363132001f49Smrg    s/^.\{43\}//' |
363232001f49Smrg    $SED -n '
363332001f49Smrg      # Join marker and all lines until next marker into a single line
363432001f49Smrg      /^====MARK====/ b para
363532001f49Smrg      H
363632001f49Smrg      $ b para
363732001f49Smrg      b
363832001f49Smrg      :para
363932001f49Smrg      x
364032001f49Smrg      s/\n//g
364132001f49Smrg      # Remove the marker
364232001f49Smrg      s/^====MARK====//
364332001f49Smrg      # Remove trailing dots and whitespace
364432001f49Smrg      s/[\. \t]*$//
364532001f49Smrg      # Print
364632001f49Smrg      /./p' |
364732001f49Smrg    # we now have a list, one entry per line, of the stringified
364832001f49Smrg    # contents of the appropriate section of all members of the
364932001f49Smrg    # archive which possess that section. Heuristic: eliminate
365032001f49Smrg    # all those which have a first or second character that is
365132001f49Smrg    # a '.' (that is, objdump's representation of an unprintable
365232001f49Smrg    # character.) This should work for all archives with less than
365332001f49Smrg    # 0x302f exports -- but will fail for DLLs whose name actually
365432001f49Smrg    # begins with a literal '.' or a single character followed by
365532001f49Smrg    # a '.'.
365632001f49Smrg    #
365732001f49Smrg    # Of those that remain, print the first one.
365832001f49Smrg    $SED -e '/^\./d;/^.\./d;q'
365932001f49Smrg}
366032001f49Smrg
366132001f49Smrg# func_cygming_gnu_implib_p ARG
366232001f49Smrg# This predicate returns with zero status (TRUE) if
366332001f49Smrg# ARG is a GNU/binutils-style import library. Returns
366432001f49Smrg# with nonzero status (FALSE) otherwise.
366532001f49Smrgfunc_cygming_gnu_implib_p ()
366632001f49Smrg{
366732001f49Smrg  $opt_debug
366832001f49Smrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
366932001f49Smrg  func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
367032001f49Smrg  test -n "$func_cygming_gnu_implib_tmp"
367132001f49Smrg}
367232001f49Smrg
367332001f49Smrg# func_cygming_ms_implib_p ARG
367432001f49Smrg# This predicate returns with zero status (TRUE) if
367532001f49Smrg# ARG is an MS-style import library. Returns
367632001f49Smrg# with nonzero status (FALSE) otherwise.
367732001f49Smrgfunc_cygming_ms_implib_p ()
367832001f49Smrg{
367932001f49Smrg  $opt_debug
368032001f49Smrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
368132001f49Smrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
368232001f49Smrg  test -n "$func_cygming_ms_implib_tmp"
368332001f49Smrg}
368432001f49Smrg
368532001f49Smrg# func_cygming_dll_for_implib_fallback ARG
368632001f49Smrg# Platform-specific function to extract the
368732001f49Smrg# name of the DLL associated with the specified
368832001f49Smrg# import library ARG.
368932001f49Smrg#
369032001f49Smrg# This fallback implementation is for use when $DLLTOOL
369132001f49Smrg# does not support the --identify-strict option.
369232001f49Smrg# Invoked by eval'ing the libtool variable
369332001f49Smrg#    $sharedlib_from_linklib_cmd
369432001f49Smrg# Result is available in the variable
369532001f49Smrg#    $sharedlib_from_linklib_result
369632001f49Smrgfunc_cygming_dll_for_implib_fallback ()
369732001f49Smrg{
369832001f49Smrg  $opt_debug
369932001f49Smrg  if func_cygming_gnu_implib_p "$1" ; then
370032001f49Smrg    # binutils import library
370132001f49Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
370232001f49Smrg  elif func_cygming_ms_implib_p "$1" ; then
370332001f49Smrg    # ms-generated import library
370432001f49Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
370532001f49Smrg  else
370632001f49Smrg    # unknown
370732001f49Smrg    sharedlib_from_linklib_result=""
370832001f49Smrg  fi
370932001f49Smrg}
371032001f49Smrg
371132001f49Smrg
371232001f49Smrg# func_extract_an_archive dir oldlib
371332001f49Smrgfunc_extract_an_archive ()
371432001f49Smrg{
371532001f49Smrg    $opt_debug
371632001f49Smrg    f_ex_an_ar_dir="$1"; shift
371732001f49Smrg    f_ex_an_ar_oldlib="$1"
371832001f49Smrg    if test "$lock_old_archive_extraction" = yes; then
371932001f49Smrg      lockfile=$f_ex_an_ar_oldlib.lock
372032001f49Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
372132001f49Smrg	func_echo "Waiting for $lockfile to be removed"
372232001f49Smrg	sleep 2
372332001f49Smrg      done
372432001f49Smrg    fi
372532001f49Smrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
372632001f49Smrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
372732001f49Smrg    if test "$lock_old_archive_extraction" = yes; then
372832001f49Smrg      $opt_dry_run || rm -f "$lockfile"
372932001f49Smrg    fi
373032001f49Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
373132001f49Smrg     :
373232001f49Smrg    else
373332001f49Smrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
373432001f49Smrg    fi
373532001f49Smrg}
373632001f49Smrg
373732001f49Smrg
373832001f49Smrg# func_extract_archives gentop oldlib ...
373932001f49Smrgfunc_extract_archives ()
374032001f49Smrg{
374132001f49Smrg    $opt_debug
374232001f49Smrg    my_gentop="$1"; shift
374332001f49Smrg    my_oldlibs=${1+"$@"}
374432001f49Smrg    my_oldobjs=""
374532001f49Smrg    my_xlib=""
374632001f49Smrg    my_xabs=""
374732001f49Smrg    my_xdir=""
374832001f49Smrg
374932001f49Smrg    for my_xlib in $my_oldlibs; do
375032001f49Smrg      # Extract the objects.
375132001f49Smrg      case $my_xlib in
375232001f49Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
375332001f49Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
375432001f49Smrg      esac
375532001f49Smrg      func_basename "$my_xlib"
375632001f49Smrg      my_xlib="$func_basename_result"
375732001f49Smrg      my_xlib_u=$my_xlib
375832001f49Smrg      while :; do
375932001f49Smrg        case " $extracted_archives " in
376032001f49Smrg	*" $my_xlib_u "*)
376132001f49Smrg	  func_arith $extracted_serial + 1
376232001f49Smrg	  extracted_serial=$func_arith_result
376332001f49Smrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
376432001f49Smrg	*) break ;;
376532001f49Smrg	esac
376632001f49Smrg      done
376732001f49Smrg      extracted_archives="$extracted_archives $my_xlib_u"
376832001f49Smrg      my_xdir="$my_gentop/$my_xlib_u"
376932001f49Smrg
377032001f49Smrg      func_mkdir_p "$my_xdir"
377132001f49Smrg
377232001f49Smrg      case $host in
377332001f49Smrg      *-darwin*)
377432001f49Smrg	func_verbose "Extracting $my_xabs"
377532001f49Smrg	# Do not bother doing anything if just a dry run
377632001f49Smrg	$opt_dry_run || {
377732001f49Smrg	  darwin_orig_dir=`pwd`
377832001f49Smrg	  cd $my_xdir || exit $?
377932001f49Smrg	  darwin_archive=$my_xabs
378032001f49Smrg	  darwin_curdir=`pwd`
378132001f49Smrg	  darwin_base_archive=`basename "$darwin_archive"`
378232001f49Smrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
378332001f49Smrg	  if test -n "$darwin_arches"; then
378432001f49Smrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
378532001f49Smrg	    darwin_arch=
378632001f49Smrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
378732001f49Smrg	    for darwin_arch in  $darwin_arches ; do
378832001f49Smrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
378932001f49Smrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
379032001f49Smrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
379132001f49Smrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
379232001f49Smrg	      cd "$darwin_curdir"
379332001f49Smrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
379432001f49Smrg	    done # $darwin_arches
379532001f49Smrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
379632001f49Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
379732001f49Smrg	    darwin_file=
379832001f49Smrg	    darwin_files=
379932001f49Smrg	    for darwin_file in $darwin_filelist; do
380032001f49Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
380132001f49Smrg	      $LIPO -create -output "$darwin_file" $darwin_files
380232001f49Smrg	    done # $darwin_filelist
380332001f49Smrg	    $RM -rf unfat-$$
380432001f49Smrg	    cd "$darwin_orig_dir"
380532001f49Smrg	  else
380632001f49Smrg	    cd $darwin_orig_dir
380732001f49Smrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
380832001f49Smrg	  fi # $darwin_arches
380932001f49Smrg	} # !$opt_dry_run
381032001f49Smrg	;;
381132001f49Smrg      *)
381232001f49Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
381332001f49Smrg	;;
381432001f49Smrg      esac
381532001f49Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
381632001f49Smrg    done
381732001f49Smrg
381832001f49Smrg    func_extract_archives_result="$my_oldobjs"
381932001f49Smrg}
382032001f49Smrg
382132001f49Smrg
382232001f49Smrg# func_emit_wrapper [arg=no]
382332001f49Smrg#
382432001f49Smrg# Emit a libtool wrapper script on stdout.
382532001f49Smrg# Don't directly open a file because we may want to
382632001f49Smrg# incorporate the script contents within a cygwin/mingw
382732001f49Smrg# wrapper executable.  Must ONLY be called from within
382832001f49Smrg# func_mode_link because it depends on a number of variables
382932001f49Smrg# set therein.
383032001f49Smrg#
383132001f49Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
383232001f49Smrg# variable will take.  If 'yes', then the emitted script
383332001f49Smrg# will assume that the directory in which it is stored is
383432001f49Smrg# the $objdir directory.  This is a cygwin/mingw-specific
383532001f49Smrg# behavior.
383632001f49Smrgfunc_emit_wrapper ()
383732001f49Smrg{
383832001f49Smrg	func_emit_wrapper_arg1=${1-no}
383932001f49Smrg
384032001f49Smrg	$ECHO "\
384132001f49Smrg#! $SHELL
384232001f49Smrg
384332001f49Smrg# $output - temporary wrapper script for $objdir/$outputname
384432001f49Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
384532001f49Smrg#
384632001f49Smrg# The $output program cannot be directly executed until all the libtool
384732001f49Smrg# libraries that it depends on are installed.
384832001f49Smrg#
384932001f49Smrg# This wrapper script should never be moved out of the build directory.
385032001f49Smrg# If it is, it will not operate correctly.
385132001f49Smrg
385232001f49Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
385332001f49Smrg# metacharacters that are still active within double-quoted strings.
385432001f49Smrgsed_quote_subst='$sed_quote_subst'
385532001f49Smrg
385632001f49Smrg# Be Bourne compatible
385732001f49Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
385832001f49Smrg  emulate sh
385932001f49Smrg  NULLCMD=:
386032001f49Smrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
386132001f49Smrg  # is contrary to our usage.  Disable this feature.
386232001f49Smrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
386332001f49Smrg  setopt NO_GLOB_SUBST
386432001f49Smrgelse
386532001f49Smrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
386632001f49Smrgfi
386732001f49SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
386832001f49SmrgDUALCASE=1; export DUALCASE # for MKS sh
386932001f49Smrg
387032001f49Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
387132001f49Smrg# if CDPATH is set.
387232001f49Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
387332001f49Smrg
387432001f49Smrgrelink_command=\"$relink_command\"
387532001f49Smrg
387632001f49Smrg# This environment variable determines our operation mode.
387732001f49Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
387832001f49Smrg  # install mode needs the following variables:
387932001f49Smrg  generated_by_libtool_version='$macro_version'
388032001f49Smrg  notinst_deplibs='$notinst_deplibs'
388132001f49Smrgelse
388232001f49Smrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
388332001f49Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
388432001f49Smrg    file=\"\$0\""
388532001f49Smrg
388632001f49Smrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
388732001f49Smrg    $ECHO "\
388832001f49Smrg
388932001f49Smrg# A function that is used when there is no print builtin or printf.
389032001f49Smrgfunc_fallback_echo ()
389132001f49Smrg{
389232001f49Smrg  eval 'cat <<_LTECHO_EOF
389332001f49Smrg\$1
389432001f49Smrg_LTECHO_EOF'
389532001f49Smrg}
389632001f49Smrg    ECHO=\"$qECHO\"
389732001f49Smrg  fi
389832001f49Smrg
389932001f49Smrg# Very basic option parsing. These options are (a) specific to
390032001f49Smrg# the libtool wrapper, (b) are identical between the wrapper
390132001f49Smrg# /script/ and the wrapper /executable/ which is used only on
390232001f49Smrg# windows platforms, and (c) all begin with the string "--lt-"
390332001f49Smrg# (application programs are unlikely to have options which match
390432001f49Smrg# this pattern).
390532001f49Smrg#
390632001f49Smrg# There are only two supported options: --lt-debug and
390732001f49Smrg# --lt-dump-script. There is, deliberately, no --lt-help.
390832001f49Smrg#
390932001f49Smrg# The first argument to this parsing function should be the
391032001f49Smrg# script's $0 value, followed by "$@".
391132001f49Smrglt_option_debug=
391232001f49Smrgfunc_parse_lt_options ()
391332001f49Smrg{
391432001f49Smrg  lt_script_arg0=\$0
391532001f49Smrg  shift
391632001f49Smrg  for lt_opt
391732001f49Smrg  do
391832001f49Smrg    case \"\$lt_opt\" in
391932001f49Smrg    --lt-debug) lt_option_debug=1 ;;
392032001f49Smrg    --lt-dump-script)
392132001f49Smrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
392232001f49Smrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
392332001f49Smrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
392432001f49Smrg        cat \"\$lt_dump_D/\$lt_dump_F\"
392532001f49Smrg        exit 0
392632001f49Smrg      ;;
392732001f49Smrg    --lt-*)
392832001f49Smrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
392932001f49Smrg        exit 1
393032001f49Smrg      ;;
393132001f49Smrg    esac
393232001f49Smrg  done
393332001f49Smrg
393432001f49Smrg  # Print the debug banner immediately:
393532001f49Smrg  if test -n \"\$lt_option_debug\"; then
393632001f49Smrg    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
393732001f49Smrg  fi
393832001f49Smrg}
393932001f49Smrg
394032001f49Smrg# Used when --lt-debug. Prints its arguments to stdout
394132001f49Smrg# (redirection is the responsibility of the caller)
394232001f49Smrgfunc_lt_dump_args ()
394332001f49Smrg{
394432001f49Smrg  lt_dump_args_N=1;
394532001f49Smrg  for lt_arg
394632001f49Smrg  do
394732001f49Smrg    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
394832001f49Smrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
394932001f49Smrg  done
395032001f49Smrg}
395132001f49Smrg
395232001f49Smrg# Core function for launching the target application
395332001f49Smrgfunc_exec_program_core ()
395432001f49Smrg{
395532001f49Smrg"
395632001f49Smrg  case $host in
395732001f49Smrg  # Backslashes separate directories on plain windows
395832001f49Smrg  *-*-mingw | *-*-os2* | *-cegcc*)
395932001f49Smrg    $ECHO "\
396032001f49Smrg      if test -n \"\$lt_option_debug\"; then
396132001f49Smrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
396232001f49Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
396332001f49Smrg      fi
396432001f49Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
396532001f49Smrg"
396632001f49Smrg    ;;
396732001f49Smrg
396832001f49Smrg  *)
396932001f49Smrg    $ECHO "\
397032001f49Smrg      if test -n \"\$lt_option_debug\"; then
397132001f49Smrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
397232001f49Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
397332001f49Smrg      fi
397432001f49Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
397532001f49Smrg"
397632001f49Smrg    ;;
397732001f49Smrg  esac
397832001f49Smrg  $ECHO "\
397932001f49Smrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
398032001f49Smrg      exit 1
398132001f49Smrg}
398232001f49Smrg
398332001f49Smrg# A function to encapsulate launching the target application
398432001f49Smrg# Strips options in the --lt-* namespace from \$@ and
398532001f49Smrg# launches target application with the remaining arguments.
398632001f49Smrgfunc_exec_program ()
398732001f49Smrg{
398832001f49Smrg  case \" \$* \" in
398932001f49Smrg  *\\ --lt-*)
399032001f49Smrg    for lt_wr_arg
399132001f49Smrg    do
399232001f49Smrg      case \$lt_wr_arg in
399332001f49Smrg      --lt-*) ;;
399432001f49Smrg      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
399532001f49Smrg      esac
399632001f49Smrg      shift
399732001f49Smrg    done ;;
399832001f49Smrg  esac
399932001f49Smrg  func_exec_program_core \${1+\"\$@\"}
400032001f49Smrg}
400132001f49Smrg
400232001f49Smrg  # Parse options
400332001f49Smrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
400432001f49Smrg
400532001f49Smrg  # Find the directory that this script lives in.
400632001f49Smrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
400732001f49Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
400832001f49Smrg
400932001f49Smrg  # Follow symbolic links until we get to the real thisdir.
401032001f49Smrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
401132001f49Smrg  while test -n \"\$file\"; do
401232001f49Smrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
401332001f49Smrg
401432001f49Smrg    # If there was a directory component, then change thisdir.
401532001f49Smrg    if test \"x\$destdir\" != \"x\$file\"; then
401632001f49Smrg      case \"\$destdir\" in
401732001f49Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
401832001f49Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
401932001f49Smrg      esac
402032001f49Smrg    fi
402132001f49Smrg
402232001f49Smrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
402332001f49Smrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
402432001f49Smrg  done
402532001f49Smrg
402632001f49Smrg  # Usually 'no', except on cygwin/mingw when embedded into
402732001f49Smrg  # the cwrapper.
402832001f49Smrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
402932001f49Smrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
403032001f49Smrg    # special case for '.'
403132001f49Smrg    if test \"\$thisdir\" = \".\"; then
403232001f49Smrg      thisdir=\`pwd\`
403332001f49Smrg    fi
403432001f49Smrg    # remove .libs from thisdir
403532001f49Smrg    case \"\$thisdir\" in
403632001f49Smrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
403732001f49Smrg    $objdir )   thisdir=. ;;
403832001f49Smrg    esac
403932001f49Smrg  fi
404032001f49Smrg
404132001f49Smrg  # Try to get the absolute directory name.
404232001f49Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
404332001f49Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
404432001f49Smrg"
404532001f49Smrg
404632001f49Smrg	if test "$fast_install" = yes; then
404732001f49Smrg	  $ECHO "\
404832001f49Smrg  program=lt-'$outputname'$exeext
404932001f49Smrg  progdir=\"\$thisdir/$objdir\"
405032001f49Smrg
405132001f49Smrg  if test ! -f \"\$progdir/\$program\" ||
405232001f49Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
405332001f49Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
405432001f49Smrg
405532001f49Smrg    file=\"\$\$-\$program\"
405632001f49Smrg
405732001f49Smrg    if test ! -d \"\$progdir\"; then
405832001f49Smrg      $MKDIR \"\$progdir\"
405932001f49Smrg    else
406032001f49Smrg      $RM \"\$progdir/\$file\"
406132001f49Smrg    fi"
406232001f49Smrg
406332001f49Smrg	  $ECHO "\
406432001f49Smrg
406532001f49Smrg    # relink executable if necessary
406632001f49Smrg    if test -n \"\$relink_command\"; then
406732001f49Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
406832001f49Smrg      else
406932001f49Smrg	$ECHO \"\$relink_command_output\" >&2
407032001f49Smrg	$RM \"\$progdir/\$file\"
407132001f49Smrg	exit 1
407232001f49Smrg      fi
407332001f49Smrg    fi
407432001f49Smrg
407532001f49Smrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
407632001f49Smrg    { $RM \"\$progdir/\$program\";
407732001f49Smrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
407832001f49Smrg    $RM \"\$progdir/\$file\"
407932001f49Smrg  fi"
408032001f49Smrg	else
408132001f49Smrg	  $ECHO "\
408232001f49Smrg  program='$outputname'
408332001f49Smrg  progdir=\"\$thisdir/$objdir\"
408432001f49Smrg"
408532001f49Smrg	fi
408632001f49Smrg
408732001f49Smrg	$ECHO "\
408832001f49Smrg
408932001f49Smrg  if test -f \"\$progdir/\$program\"; then"
409032001f49Smrg
409132001f49Smrg	# fixup the dll searchpath if we need to.
409232001f49Smrg	#
409332001f49Smrg	# Fix the DLL searchpath if we need to.  Do this before prepending
409432001f49Smrg	# to shlibpath, because on Windows, both are PATH and uninstalled
409532001f49Smrg	# libraries must come first.
409632001f49Smrg	if test -n "$dllsearchpath"; then
409732001f49Smrg	  $ECHO "\
409832001f49Smrg    # Add the dll search path components to the executable PATH
409932001f49Smrg    PATH=$dllsearchpath:\$PATH
410032001f49Smrg"
410132001f49Smrg	fi
410232001f49Smrg
410332001f49Smrg	# Export our shlibpath_var if we have one.
410432001f49Smrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
410532001f49Smrg	  $ECHO "\
410632001f49Smrg    # Add our own library path to $shlibpath_var
410732001f49Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
410832001f49Smrg
410932001f49Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
411032001f49Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
411132001f49Smrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
411232001f49Smrg
411332001f49Smrg    export $shlibpath_var
411432001f49Smrg"
411532001f49Smrg	fi
411632001f49Smrg
411732001f49Smrg	$ECHO "\
411832001f49Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
411932001f49Smrg      # Run the actual program with our arguments.
412032001f49Smrg      func_exec_program \${1+\"\$@\"}
412132001f49Smrg    fi
412232001f49Smrg  else
412332001f49Smrg    # The program doesn't exist.
412432001f49Smrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
412532001f49Smrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
412632001f49Smrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
412732001f49Smrg    exit 1
412832001f49Smrg  fi
412932001f49Smrgfi\
413032001f49Smrg"
413132001f49Smrg}
413232001f49Smrg
413332001f49Smrg
413432001f49Smrg# func_emit_cwrapperexe_src
413532001f49Smrg# emit the source code for a wrapper executable on stdout
413632001f49Smrg# Must ONLY be called from within func_mode_link because
413732001f49Smrg# it depends on a number of variable set therein.
413832001f49Smrgfunc_emit_cwrapperexe_src ()
413932001f49Smrg{
414032001f49Smrg	cat <<EOF
414132001f49Smrg
414232001f49Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
414332001f49Smrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
414432001f49Smrg
414532001f49Smrg   The $output program cannot be directly executed until all the libtool
414632001f49Smrg   libraries that it depends on are installed.
414732001f49Smrg
414832001f49Smrg   This wrapper executable should never be moved out of the build directory.
414932001f49Smrg   If it is, it will not operate correctly.
415032001f49Smrg*/
415132001f49SmrgEOF
415232001f49Smrg	    cat <<"EOF"
415332001f49Smrg#ifdef _MSC_VER
415432001f49Smrg# define _CRT_SECURE_NO_DEPRECATE 1
415532001f49Smrg#endif
415632001f49Smrg#include <stdio.h>
415732001f49Smrg#include <stdlib.h>
415832001f49Smrg#ifdef _MSC_VER
415932001f49Smrg# include <direct.h>
416032001f49Smrg# include <process.h>
416132001f49Smrg# include <io.h>
416232001f49Smrg#else
416332001f49Smrg# include <unistd.h>
416432001f49Smrg# include <stdint.h>
416532001f49Smrg# ifdef __CYGWIN__
416632001f49Smrg#  include <io.h>
416732001f49Smrg# endif
416832001f49Smrg#endif
416932001f49Smrg#include <malloc.h>
417032001f49Smrg#include <stdarg.h>
417132001f49Smrg#include <assert.h>
417232001f49Smrg#include <string.h>
417332001f49Smrg#include <ctype.h>
417432001f49Smrg#include <errno.h>
417532001f49Smrg#include <fcntl.h>
417632001f49Smrg#include <sys/stat.h>
417732001f49Smrg
417832001f49Smrg/* declarations of non-ANSI functions */
417932001f49Smrg#if defined(__MINGW32__)
418032001f49Smrg# ifdef __STRICT_ANSI__
418132001f49Smrgint _putenv (const char *);
418232001f49Smrg# endif
418332001f49Smrg#elif defined(__CYGWIN__)
418432001f49Smrg# ifdef __STRICT_ANSI__
418532001f49Smrgchar *realpath (const char *, char *);
418632001f49Smrgint putenv (char *);
418732001f49Smrgint setenv (const char *, const char *, int);
418832001f49Smrg# endif
418932001f49Smrg/* #elif defined (other platforms) ... */
419032001f49Smrg#endif
419132001f49Smrg
419232001f49Smrg/* portability defines, excluding path handling macros */
419332001f49Smrg#if defined(_MSC_VER)
419432001f49Smrg# define setmode _setmode
419532001f49Smrg# define stat    _stat
419632001f49Smrg# define chmod   _chmod
419732001f49Smrg# define getcwd  _getcwd
419832001f49Smrg# define putenv  _putenv
419932001f49Smrg# define S_IXUSR _S_IEXEC
420032001f49Smrg# ifndef _INTPTR_T_DEFINED
420132001f49Smrg#  define _INTPTR_T_DEFINED
420232001f49Smrg#  define intptr_t int
420332001f49Smrg# endif
420432001f49Smrg#elif defined(__MINGW32__)
420532001f49Smrg# define setmode _setmode
420632001f49Smrg# define stat    _stat
420732001f49Smrg# define chmod   _chmod
420832001f49Smrg# define getcwd  _getcwd
420932001f49Smrg# define putenv  _putenv
421032001f49Smrg#elif defined(__CYGWIN__)
421132001f49Smrg# define HAVE_SETENV
421232001f49Smrg# define FOPEN_WB "wb"
421332001f49Smrg/* #elif defined (other platforms) ... */
421432001f49Smrg#endif
421532001f49Smrg
421632001f49Smrg#if defined(PATH_MAX)
421732001f49Smrg# define LT_PATHMAX PATH_MAX
421832001f49Smrg#elif defined(MAXPATHLEN)
421932001f49Smrg# define LT_PATHMAX MAXPATHLEN
422032001f49Smrg#else
422132001f49Smrg# define LT_PATHMAX 1024
422232001f49Smrg#endif
422332001f49Smrg
422432001f49Smrg#ifndef S_IXOTH
422532001f49Smrg# define S_IXOTH 0
422632001f49Smrg#endif
422732001f49Smrg#ifndef S_IXGRP
422832001f49Smrg# define S_IXGRP 0
422932001f49Smrg#endif
423032001f49Smrg
423132001f49Smrg/* path handling portability macros */
423232001f49Smrg#ifndef DIR_SEPARATOR
423332001f49Smrg# define DIR_SEPARATOR '/'
423432001f49Smrg# define PATH_SEPARATOR ':'
423532001f49Smrg#endif
423632001f49Smrg
423732001f49Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
423832001f49Smrg  defined (__OS2__)
423932001f49Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
424032001f49Smrg# define FOPEN_WB "wb"
424132001f49Smrg# ifndef DIR_SEPARATOR_2
424232001f49Smrg#  define DIR_SEPARATOR_2 '\\'
424332001f49Smrg# endif
424432001f49Smrg# ifndef PATH_SEPARATOR_2
424532001f49Smrg#  define PATH_SEPARATOR_2 ';'
424632001f49Smrg# endif
424732001f49Smrg#endif
424832001f49Smrg
424932001f49Smrg#ifndef DIR_SEPARATOR_2
425032001f49Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
425132001f49Smrg#else /* DIR_SEPARATOR_2 */
425232001f49Smrg# define IS_DIR_SEPARATOR(ch) \
425332001f49Smrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
425432001f49Smrg#endif /* DIR_SEPARATOR_2 */
425532001f49Smrg
425632001f49Smrg#ifndef PATH_SEPARATOR_2
425732001f49Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
425832001f49Smrg#else /* PATH_SEPARATOR_2 */
425932001f49Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
426032001f49Smrg#endif /* PATH_SEPARATOR_2 */
426132001f49Smrg
426232001f49Smrg#ifndef FOPEN_WB
426332001f49Smrg# define FOPEN_WB "w"
426432001f49Smrg#endif
426532001f49Smrg#ifndef _O_BINARY
426632001f49Smrg# define _O_BINARY 0
426732001f49Smrg#endif
426832001f49Smrg
426932001f49Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
427032001f49Smrg#define XFREE(stale) do { \
427132001f49Smrg  if (stale) { free ((void *) stale); stale = 0; } \
427232001f49Smrg} while (0)
427332001f49Smrg
427432001f49Smrg#if defined(LT_DEBUGWRAPPER)
427532001f49Smrgstatic int lt_debug = 1;
427632001f49Smrg#else
427732001f49Smrgstatic int lt_debug = 0;
427832001f49Smrg#endif
427932001f49Smrg
428032001f49Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
428132001f49Smrg
428232001f49Smrgvoid *xmalloc (size_t num);
428332001f49Smrgchar *xstrdup (const char *string);
428432001f49Smrgconst char *base_name (const char *name);
428532001f49Smrgchar *find_executable (const char *wrapper);
428632001f49Smrgchar *chase_symlinks (const char *pathspec);
428732001f49Smrgint make_executable (const char *path);
428832001f49Smrgint check_executable (const char *path);
428932001f49Smrgchar *strendzap (char *str, const char *pat);
429032001f49Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
429132001f49Smrgvoid lt_fatal (const char *file, int line, const char *message, ...);
429232001f49Smrgstatic const char *nonnull (const char *s);
429332001f49Smrgstatic const char *nonempty (const char *s);
429432001f49Smrgvoid lt_setenv (const char *name, const char *value);
429532001f49Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
429632001f49Smrgvoid lt_update_exe_path (const char *name, const char *value);
429732001f49Smrgvoid lt_update_lib_path (const char *name, const char *value);
429832001f49Smrgchar **prepare_spawn (char **argv);
429932001f49Smrgvoid lt_dump_script (FILE *f);
430032001f49SmrgEOF
430132001f49Smrg
430232001f49Smrg	    cat <<EOF
430332001f49Smrgvolatile const char * MAGIC_EXE = "$magic_exe";
430432001f49Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
430532001f49SmrgEOF
430632001f49Smrg
430732001f49Smrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
430832001f49Smrg              func_to_host_path "$temp_rpath"
430932001f49Smrg	      cat <<EOF
431032001f49Smrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
431132001f49SmrgEOF
431232001f49Smrg	    else
431332001f49Smrg	      cat <<"EOF"
431432001f49Smrgconst char * LIB_PATH_VALUE   = "";
431532001f49SmrgEOF
431632001f49Smrg	    fi
431732001f49Smrg
431832001f49Smrg	    if test -n "$dllsearchpath"; then
431932001f49Smrg              func_to_host_path "$dllsearchpath:"
432032001f49Smrg	      cat <<EOF
432132001f49Smrgconst char * EXE_PATH_VARNAME = "PATH";
432232001f49Smrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
432332001f49SmrgEOF
432432001f49Smrg	    else
432532001f49Smrg	      cat <<"EOF"
432632001f49Smrgconst char * EXE_PATH_VARNAME = "";
432732001f49Smrgconst char * EXE_PATH_VALUE   = "";
432832001f49SmrgEOF
432932001f49Smrg	    fi
433032001f49Smrg
433132001f49Smrg	    if test "$fast_install" = yes; then
433232001f49Smrg	      cat <<EOF
433332001f49Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
433432001f49SmrgEOF
433532001f49Smrg	    else
433632001f49Smrg	      cat <<EOF
433732001f49Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
433832001f49SmrgEOF
433932001f49Smrg	    fi
434032001f49Smrg
434132001f49Smrg
434232001f49Smrg	    cat <<"EOF"
434332001f49Smrg
434432001f49Smrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
434532001f49Smrg
434632001f49Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
434732001f49Smrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
434832001f49Smrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
434932001f49Smrg
435032001f49Smrgint
435132001f49Smrgmain (int argc, char *argv[])
435232001f49Smrg{
435332001f49Smrg  char **newargz;
435432001f49Smrg  int  newargc;
435532001f49Smrg  char *tmp_pathspec;
435632001f49Smrg  char *actual_cwrapper_path;
435732001f49Smrg  char *actual_cwrapper_name;
435832001f49Smrg  char *target_name;
435932001f49Smrg  char *lt_argv_zero;
436032001f49Smrg  intptr_t rval = 127;
436132001f49Smrg
436232001f49Smrg  int i;
436332001f49Smrg
436432001f49Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
436532001f49Smrg  newargz = XMALLOC (char *, argc + 1);
436632001f49Smrg
436732001f49Smrg  /* very simple arg parsing; don't want to rely on getopt
436832001f49Smrg   * also, copy all non cwrapper options to newargz, except
436932001f49Smrg   * argz[0], which is handled differently
437032001f49Smrg   */
437132001f49Smrg  newargc=0;
437232001f49Smrg  for (i = 1; i < argc; i++)
437332001f49Smrg    {
437432001f49Smrg      if (strcmp (argv[i], dumpscript_opt) == 0)
437532001f49Smrg	{
437632001f49SmrgEOF
437732001f49Smrg	    case "$host" in
437832001f49Smrg	      *mingw* | *cygwin* )
437932001f49Smrg		# make stdout use "unix" line endings
438032001f49Smrg		echo "          setmode(1,_O_BINARY);"
438132001f49Smrg		;;
438232001f49Smrg	      esac
438332001f49Smrg
438432001f49Smrg	    cat <<"EOF"
438532001f49Smrg	  lt_dump_script (stdout);
438632001f49Smrg	  return 0;
438732001f49Smrg	}
438832001f49Smrg      if (strcmp (argv[i], debug_opt) == 0)
438932001f49Smrg	{
439032001f49Smrg          lt_debug = 1;
439132001f49Smrg          continue;
439232001f49Smrg	}
439332001f49Smrg      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
439432001f49Smrg        {
439532001f49Smrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
439632001f49Smrg             namespace, but it is not one of the ones we know about and
439732001f49Smrg             have already dealt with, above (inluding dump-script), then
439832001f49Smrg             report an error. Otherwise, targets might begin to believe
439932001f49Smrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
440032001f49Smrg             namespace. The first time any user complains about this, we'll
440132001f49Smrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
440232001f49Smrg             or a configure.ac-settable value.
440332001f49Smrg           */
440432001f49Smrg          lt_fatal (__FILE__, __LINE__,
440532001f49Smrg		    "unrecognized %s option: '%s'",
440632001f49Smrg                    ltwrapper_option_prefix, argv[i]);
440732001f49Smrg        }
440832001f49Smrg      /* otherwise ... */
440932001f49Smrg      newargz[++newargc] = xstrdup (argv[i]);
441032001f49Smrg    }
441132001f49Smrg  newargz[++newargc] = NULL;
441232001f49Smrg
441332001f49SmrgEOF
441432001f49Smrg	    cat <<EOF
441532001f49Smrg  /* The GNU banner must be the first non-error debug message */
441632001f49Smrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
441732001f49SmrgEOF
441832001f49Smrg	    cat <<"EOF"
441932001f49Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
442032001f49Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
442132001f49Smrg
442232001f49Smrg  tmp_pathspec = find_executable (argv[0]);
442332001f49Smrg  if (tmp_pathspec == NULL)
442432001f49Smrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
442532001f49Smrg  lt_debugprintf (__FILE__, __LINE__,
442632001f49Smrg                  "(main) found exe (before symlink chase) at: %s\n",
442732001f49Smrg		  tmp_pathspec);
442832001f49Smrg
442932001f49Smrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
443032001f49Smrg  lt_debugprintf (__FILE__, __LINE__,
443132001f49Smrg                  "(main) found exe (after symlink chase) at: %s\n",
443232001f49Smrg		  actual_cwrapper_path);
443332001f49Smrg  XFREE (tmp_pathspec);
443432001f49Smrg
443532001f49Smrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
443632001f49Smrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
443732001f49Smrg
443832001f49Smrg  /* wrapper name transforms */
443932001f49Smrg  strendzap (actual_cwrapper_name, ".exe");
444032001f49Smrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
444132001f49Smrg  XFREE (actual_cwrapper_name);
444232001f49Smrg  actual_cwrapper_name = tmp_pathspec;
444332001f49Smrg  tmp_pathspec = 0;
444432001f49Smrg
444532001f49Smrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
444632001f49Smrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
444732001f49Smrg  strendzap (target_name, ".exe");
444832001f49Smrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
444932001f49Smrg  XFREE (target_name);
445032001f49Smrg  target_name = tmp_pathspec;
445132001f49Smrg  tmp_pathspec = 0;
445232001f49Smrg
445332001f49Smrg  lt_debugprintf (__FILE__, __LINE__,
445432001f49Smrg		  "(main) libtool target name: %s\n",
445532001f49Smrg		  target_name);
445632001f49SmrgEOF
445732001f49Smrg
445832001f49Smrg	    cat <<EOF
445932001f49Smrg  newargz[0] =
446032001f49Smrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
446132001f49Smrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
446232001f49Smrg  strcpy (newargz[0], actual_cwrapper_path);
446332001f49Smrg  strcat (newargz[0], "$objdir");
446432001f49Smrg  strcat (newargz[0], "/");
446532001f49SmrgEOF
446632001f49Smrg
446732001f49Smrg	    cat <<"EOF"
446832001f49Smrg  /* stop here, and copy so we don't have to do this twice */
446932001f49Smrg  tmp_pathspec = xstrdup (newargz[0]);
447032001f49Smrg
447132001f49Smrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
447232001f49Smrg  strcat (newargz[0], actual_cwrapper_name);
447332001f49Smrg
447432001f49Smrg  /* DO want the lt- prefix here if it exists, so use target_name */
447532001f49Smrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
447632001f49Smrg  XFREE (tmp_pathspec);
447732001f49Smrg  tmp_pathspec = NULL;
447832001f49SmrgEOF
447932001f49Smrg
448032001f49Smrg	    case $host_os in
448132001f49Smrg	      mingw*)
448232001f49Smrg	    cat <<"EOF"
448332001f49Smrg  {
448432001f49Smrg    char* p;
448532001f49Smrg    while ((p = strchr (newargz[0], '\\')) != NULL)
448632001f49Smrg      {
448732001f49Smrg	*p = '/';
448832001f49Smrg      }
448932001f49Smrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
449032001f49Smrg      {
449132001f49Smrg	*p = '/';
449232001f49Smrg      }
449332001f49Smrg  }
449432001f49SmrgEOF
449532001f49Smrg	    ;;
449632001f49Smrg	    esac
449732001f49Smrg
449832001f49Smrg	    cat <<"EOF"
449932001f49Smrg  XFREE (target_name);
450032001f49Smrg  XFREE (actual_cwrapper_path);
450132001f49Smrg  XFREE (actual_cwrapper_name);
450232001f49Smrg
450332001f49Smrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
450432001f49Smrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
450532001f49Smrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
450632001f49Smrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
450732001f49Smrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
450832001f49Smrg     libraries must come first. */
450932001f49Smrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
451032001f49Smrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
451132001f49Smrg
451232001f49Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
451332001f49Smrg		  nonnull (lt_argv_zero));
451432001f49Smrg  for (i = 0; i < newargc; i++)
451532001f49Smrg    {
451632001f49Smrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
451732001f49Smrg		      i, nonnull (newargz[i]));
451832001f49Smrg    }
451932001f49Smrg
452032001f49SmrgEOF
452132001f49Smrg
452232001f49Smrg	    case $host_os in
452332001f49Smrg	      mingw*)
452432001f49Smrg		cat <<"EOF"
452532001f49Smrg  /* execv doesn't actually work on mingw as expected on unix */
452632001f49Smrg  newargz = prepare_spawn (newargz);
452732001f49Smrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
452832001f49Smrg  if (rval == -1)
452932001f49Smrg    {
453032001f49Smrg      /* failed to start process */
453132001f49Smrg      lt_debugprintf (__FILE__, __LINE__,
453232001f49Smrg		      "(main) failed to launch target \"%s\": %s\n",
453332001f49Smrg		      lt_argv_zero, nonnull (strerror (errno)));
453432001f49Smrg      return 127;
453532001f49Smrg    }
453632001f49Smrg  return rval;
453732001f49SmrgEOF
453832001f49Smrg		;;
453932001f49Smrg	      *)
454032001f49Smrg		cat <<"EOF"
454132001f49Smrg  execv (lt_argv_zero, newargz);
454232001f49Smrg  return rval; /* =127, but avoids unused variable warning */
454332001f49SmrgEOF
454432001f49Smrg		;;
454532001f49Smrg	    esac
454632001f49Smrg
454732001f49Smrg	    cat <<"EOF"
454832001f49Smrg}
454932001f49Smrg
455032001f49Smrgvoid *
455132001f49Smrgxmalloc (size_t num)
455232001f49Smrg{
455332001f49Smrg  void *p = (void *) malloc (num);
455432001f49Smrg  if (!p)
455532001f49Smrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
455632001f49Smrg
455732001f49Smrg  return p;
455832001f49Smrg}
455932001f49Smrg
456032001f49Smrgchar *
456132001f49Smrgxstrdup (const char *string)
456232001f49Smrg{
456332001f49Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
456432001f49Smrg			  string) : NULL;
456532001f49Smrg}
456632001f49Smrg
456732001f49Smrgconst char *
456832001f49Smrgbase_name (const char *name)
456932001f49Smrg{
457032001f49Smrg  const char *base;
457132001f49Smrg
457232001f49Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
457332001f49Smrg  /* Skip over the disk name in MSDOS pathnames. */
457432001f49Smrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
457532001f49Smrg    name += 2;
457632001f49Smrg#endif
457732001f49Smrg
457832001f49Smrg  for (base = name; *name; name++)
457932001f49Smrg    if (IS_DIR_SEPARATOR (*name))
458032001f49Smrg      base = name + 1;
458132001f49Smrg  return base;
458232001f49Smrg}
458332001f49Smrg
458432001f49Smrgint
458532001f49Smrgcheck_executable (const char *path)
458632001f49Smrg{
458732001f49Smrg  struct stat st;
458832001f49Smrg
458932001f49Smrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
459032001f49Smrg                  nonempty (path));
459132001f49Smrg  if ((!path) || (!*path))
459232001f49Smrg    return 0;
459332001f49Smrg
459432001f49Smrg  if ((stat (path, &st) >= 0)
459532001f49Smrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
459632001f49Smrg    return 1;
459732001f49Smrg  else
459832001f49Smrg    return 0;
459932001f49Smrg}
460032001f49Smrg
460132001f49Smrgint
460232001f49Smrgmake_executable (const char *path)
460332001f49Smrg{
460432001f49Smrg  int rval = 0;
460532001f49Smrg  struct stat st;
460632001f49Smrg
460732001f49Smrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
460832001f49Smrg                  nonempty (path));
460932001f49Smrg  if ((!path) || (!*path))
461032001f49Smrg    return 0;
461132001f49Smrg
461232001f49Smrg  if (stat (path, &st) >= 0)
461332001f49Smrg    {
461432001f49Smrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
461532001f49Smrg    }
461632001f49Smrg  return rval;
461732001f49Smrg}
461832001f49Smrg
461932001f49Smrg/* Searches for the full path of the wrapper.  Returns
462032001f49Smrg   newly allocated full path name if found, NULL otherwise
462132001f49Smrg   Does not chase symlinks, even on platforms that support them.
462232001f49Smrg*/
462332001f49Smrgchar *
462432001f49Smrgfind_executable (const char *wrapper)
462532001f49Smrg{
462632001f49Smrg  int has_slash = 0;
462732001f49Smrg  const char *p;
462832001f49Smrg  const char *p_next;
462932001f49Smrg  /* static buffer for getcwd */
463032001f49Smrg  char tmp[LT_PATHMAX + 1];
463132001f49Smrg  int tmp_len;
463232001f49Smrg  char *concat_name;
463332001f49Smrg
463432001f49Smrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
463532001f49Smrg                  nonempty (wrapper));
463632001f49Smrg
463732001f49Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
463832001f49Smrg    return NULL;
463932001f49Smrg
464032001f49Smrg  /* Absolute path? */
464132001f49Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
464232001f49Smrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
464332001f49Smrg    {
464432001f49Smrg      concat_name = xstrdup (wrapper);
464532001f49Smrg      if (check_executable (concat_name))
464632001f49Smrg	return concat_name;
464732001f49Smrg      XFREE (concat_name);
464832001f49Smrg    }
464932001f49Smrg  else
465032001f49Smrg    {
465132001f49Smrg#endif
465232001f49Smrg      if (IS_DIR_SEPARATOR (wrapper[0]))
465332001f49Smrg	{
465432001f49Smrg	  concat_name = xstrdup (wrapper);
465532001f49Smrg	  if (check_executable (concat_name))
465632001f49Smrg	    return concat_name;
465732001f49Smrg	  XFREE (concat_name);
465832001f49Smrg	}
465932001f49Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
466032001f49Smrg    }
466132001f49Smrg#endif
466232001f49Smrg
466332001f49Smrg  for (p = wrapper; *p; p++)
466432001f49Smrg    if (*p == '/')
466532001f49Smrg      {
466632001f49Smrg	has_slash = 1;
466732001f49Smrg	break;
466832001f49Smrg      }
466932001f49Smrg  if (!has_slash)
467032001f49Smrg    {
467132001f49Smrg      /* no slashes; search PATH */
467232001f49Smrg      const char *path = getenv ("PATH");
467332001f49Smrg      if (path != NULL)
467432001f49Smrg	{
467532001f49Smrg	  for (p = path; *p; p = p_next)
467632001f49Smrg	    {
467732001f49Smrg	      const char *q;
467832001f49Smrg	      size_t p_len;
467932001f49Smrg	      for (q = p; *q; q++)
468032001f49Smrg		if (IS_PATH_SEPARATOR (*q))
468132001f49Smrg		  break;
468232001f49Smrg	      p_len = q - p;
468332001f49Smrg	      p_next = (*q == '\0' ? q : q + 1);
468432001f49Smrg	      if (p_len == 0)
468532001f49Smrg		{
468632001f49Smrg		  /* empty path: current directory */
468732001f49Smrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
468832001f49Smrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
468932001f49Smrg                              nonnull (strerror (errno)));
469032001f49Smrg		  tmp_len = strlen (tmp);
469132001f49Smrg		  concat_name =
469232001f49Smrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
469332001f49Smrg		  memcpy (concat_name, tmp, tmp_len);
469432001f49Smrg		  concat_name[tmp_len] = '/';
469532001f49Smrg		  strcpy (concat_name + tmp_len + 1, wrapper);
469632001f49Smrg		}
469732001f49Smrg	      else
469832001f49Smrg		{
469932001f49Smrg		  concat_name =
470032001f49Smrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
470132001f49Smrg		  memcpy (concat_name, p, p_len);
470232001f49Smrg		  concat_name[p_len] = '/';
470332001f49Smrg		  strcpy (concat_name + p_len + 1, wrapper);
470432001f49Smrg		}
470532001f49Smrg	      if (check_executable (concat_name))
470632001f49Smrg		return concat_name;
470732001f49Smrg	      XFREE (concat_name);
470832001f49Smrg	    }
470932001f49Smrg	}
471032001f49Smrg      /* not found in PATH; assume curdir */
471132001f49Smrg    }
471232001f49Smrg  /* Relative path | not found in path: prepend cwd */
471332001f49Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
471432001f49Smrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
471532001f49Smrg              nonnull (strerror (errno)));
471632001f49Smrg  tmp_len = strlen (tmp);
471732001f49Smrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
471832001f49Smrg  memcpy (concat_name, tmp, tmp_len);
471932001f49Smrg  concat_name[tmp_len] = '/';
472032001f49Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
472132001f49Smrg
472232001f49Smrg  if (check_executable (concat_name))
472332001f49Smrg    return concat_name;
472432001f49Smrg  XFREE (concat_name);
472532001f49Smrg  return NULL;
472632001f49Smrg}
472732001f49Smrg
472832001f49Smrgchar *
472932001f49Smrgchase_symlinks (const char *pathspec)
473032001f49Smrg{
473132001f49Smrg#ifndef S_ISLNK
473232001f49Smrg  return xstrdup (pathspec);
473332001f49Smrg#else
473432001f49Smrg  char buf[LT_PATHMAX];
473532001f49Smrg  struct stat s;
473632001f49Smrg  char *tmp_pathspec = xstrdup (pathspec);
473732001f49Smrg  char *p;
473832001f49Smrg  int has_symlinks = 0;
473932001f49Smrg  while (strlen (tmp_pathspec) && !has_symlinks)
474032001f49Smrg    {
474132001f49Smrg      lt_debugprintf (__FILE__, __LINE__,
474232001f49Smrg		      "checking path component for symlinks: %s\n",
474332001f49Smrg		      tmp_pathspec);
474432001f49Smrg      if (lstat (tmp_pathspec, &s) == 0)
474532001f49Smrg	{
474632001f49Smrg	  if (S_ISLNK (s.st_mode) != 0)
474732001f49Smrg	    {
474832001f49Smrg	      has_symlinks = 1;
474932001f49Smrg	      break;
475032001f49Smrg	    }
475132001f49Smrg
475232001f49Smrg	  /* search backwards for last DIR_SEPARATOR */
475332001f49Smrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
475432001f49Smrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
475532001f49Smrg	    p--;
475632001f49Smrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
475732001f49Smrg	    {
475832001f49Smrg	      /* no more DIR_SEPARATORS left */
475932001f49Smrg	      break;
476032001f49Smrg	    }
476132001f49Smrg	  *p = '\0';
476232001f49Smrg	}
476332001f49Smrg      else
476432001f49Smrg	{
476532001f49Smrg	  lt_fatal (__FILE__, __LINE__,
476632001f49Smrg		    "error accessing file \"%s\": %s",
476732001f49Smrg		    tmp_pathspec, nonnull (strerror (errno)));
476832001f49Smrg	}
476932001f49Smrg    }
477032001f49Smrg  XFREE (tmp_pathspec);
477132001f49Smrg
477232001f49Smrg  if (!has_symlinks)
477332001f49Smrg    {
477432001f49Smrg      return xstrdup (pathspec);
477532001f49Smrg    }
477632001f49Smrg
477732001f49Smrg  tmp_pathspec = realpath (pathspec, buf);
477832001f49Smrg  if (tmp_pathspec == 0)
477932001f49Smrg    {
478032001f49Smrg      lt_fatal (__FILE__, __LINE__,
478132001f49Smrg		"could not follow symlinks for %s", pathspec);
478232001f49Smrg    }
478332001f49Smrg  return xstrdup (tmp_pathspec);
478432001f49Smrg#endif
478532001f49Smrg}
478632001f49Smrg
478732001f49Smrgchar *
478832001f49Smrgstrendzap (char *str, const char *pat)
478932001f49Smrg{
479032001f49Smrg  size_t len, patlen;
479132001f49Smrg
479232001f49Smrg  assert (str != NULL);
479332001f49Smrg  assert (pat != NULL);
479432001f49Smrg
479532001f49Smrg  len = strlen (str);
479632001f49Smrg  patlen = strlen (pat);
479732001f49Smrg
479832001f49Smrg  if (patlen <= len)
479932001f49Smrg    {
480032001f49Smrg      str += len - patlen;
480132001f49Smrg      if (strcmp (str, pat) == 0)
480232001f49Smrg	*str = '\0';
480332001f49Smrg    }
480432001f49Smrg  return str;
480532001f49Smrg}
480632001f49Smrg
480732001f49Smrgvoid
480832001f49Smrglt_debugprintf (const char *file, int line, const char *fmt, ...)
480932001f49Smrg{
481032001f49Smrg  va_list args;
481132001f49Smrg  if (lt_debug)
481232001f49Smrg    {
481332001f49Smrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
481432001f49Smrg      va_start (args, fmt);
481532001f49Smrg      (void) vfprintf (stderr, fmt, args);
481632001f49Smrg      va_end (args);
481732001f49Smrg    }
481832001f49Smrg}
481932001f49Smrg
482032001f49Smrgstatic void
482132001f49Smrglt_error_core (int exit_status, const char *file,
482232001f49Smrg	       int line, const char *mode,
482332001f49Smrg	       const char *message, va_list ap)
482432001f49Smrg{
482532001f49Smrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
482632001f49Smrg  vfprintf (stderr, message, ap);
482732001f49Smrg  fprintf (stderr, ".\n");
482832001f49Smrg
482932001f49Smrg  if (exit_status >= 0)
483032001f49Smrg    exit (exit_status);
483132001f49Smrg}
483232001f49Smrg
483332001f49Smrgvoid
483432001f49Smrglt_fatal (const char *file, int line, const char *message, ...)
483532001f49Smrg{
483632001f49Smrg  va_list ap;
483732001f49Smrg  va_start (ap, message);
483832001f49Smrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
483932001f49Smrg  va_end (ap);
484032001f49Smrg}
484132001f49Smrg
484232001f49Smrgstatic const char *
484332001f49Smrgnonnull (const char *s)
484432001f49Smrg{
484532001f49Smrg  return s ? s : "(null)";
484632001f49Smrg}
484732001f49Smrg
484832001f49Smrgstatic const char *
484932001f49Smrgnonempty (const char *s)
485032001f49Smrg{
485132001f49Smrg  return (s && !*s) ? "(empty)" : nonnull (s);
485232001f49Smrg}
485332001f49Smrg
485432001f49Smrgvoid
485532001f49Smrglt_setenv (const char *name, const char *value)
485632001f49Smrg{
485732001f49Smrg  lt_debugprintf (__FILE__, __LINE__,
485832001f49Smrg		  "(lt_setenv) setting '%s' to '%s'\n",
485932001f49Smrg                  nonnull (name), nonnull (value));
486032001f49Smrg  {
486132001f49Smrg#ifdef HAVE_SETENV
486232001f49Smrg    /* always make a copy, for consistency with !HAVE_SETENV */
486332001f49Smrg    char *str = xstrdup (value);
486432001f49Smrg    setenv (name, str, 1);
486532001f49Smrg#else
486632001f49Smrg    int len = strlen (name) + 1 + strlen (value) + 1;
486732001f49Smrg    char *str = XMALLOC (char, len);
486832001f49Smrg    sprintf (str, "%s=%s", name, value);
486932001f49Smrg    if (putenv (str) != EXIT_SUCCESS)
487032001f49Smrg      {
487132001f49Smrg        XFREE (str);
487232001f49Smrg      }
487332001f49Smrg#endif
487432001f49Smrg  }
487532001f49Smrg}
487632001f49Smrg
487732001f49Smrgchar *
487832001f49Smrglt_extend_str (const char *orig_value, const char *add, int to_end)
487932001f49Smrg{
488032001f49Smrg  char *new_value;
488132001f49Smrg  if (orig_value && *orig_value)
488232001f49Smrg    {
488332001f49Smrg      int orig_value_len = strlen (orig_value);
488432001f49Smrg      int add_len = strlen (add);
488532001f49Smrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
488632001f49Smrg      if (to_end)
488732001f49Smrg        {
488832001f49Smrg          strcpy (new_value, orig_value);
488932001f49Smrg          strcpy (new_value + orig_value_len, add);
489032001f49Smrg        }
489132001f49Smrg      else
489232001f49Smrg        {
489332001f49Smrg          strcpy (new_value, add);
489432001f49Smrg          strcpy (new_value + add_len, orig_value);
489532001f49Smrg        }
489632001f49Smrg    }
489732001f49Smrg  else
489832001f49Smrg    {
489932001f49Smrg      new_value = xstrdup (add);
490032001f49Smrg    }
490132001f49Smrg  return new_value;
490232001f49Smrg}
490332001f49Smrg
490432001f49Smrgvoid
490532001f49Smrglt_update_exe_path (const char *name, const char *value)
490632001f49Smrg{
490732001f49Smrg  lt_debugprintf (__FILE__, __LINE__,
490832001f49Smrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
490932001f49Smrg                  nonnull (name), nonnull (value));
491032001f49Smrg
491132001f49Smrg  if (name && *name && value && *value)
491232001f49Smrg    {
491332001f49Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
491432001f49Smrg      /* some systems can't cope with a ':'-terminated path #' */
491532001f49Smrg      int len = strlen (new_value);
491632001f49Smrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
491732001f49Smrg        {
491832001f49Smrg          new_value[len-1] = '\0';
491932001f49Smrg        }
492032001f49Smrg      lt_setenv (name, new_value);
492132001f49Smrg      XFREE (new_value);
492232001f49Smrg    }
492332001f49Smrg}
492432001f49Smrg
492532001f49Smrgvoid
492632001f49Smrglt_update_lib_path (const char *name, const char *value)
492732001f49Smrg{
492832001f49Smrg  lt_debugprintf (__FILE__, __LINE__,
492932001f49Smrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
493032001f49Smrg                  nonnull (name), nonnull (value));
493132001f49Smrg
493232001f49Smrg  if (name && *name && value && *value)
493332001f49Smrg    {
493432001f49Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
493532001f49Smrg      lt_setenv (name, new_value);
493632001f49Smrg      XFREE (new_value);
493732001f49Smrg    }
493832001f49Smrg}
493932001f49Smrg
494032001f49SmrgEOF
494132001f49Smrg	    case $host_os in
494232001f49Smrg	      mingw*)
494332001f49Smrg		cat <<"EOF"
494432001f49Smrg
494532001f49Smrg/* Prepares an argument vector before calling spawn().
494632001f49Smrg   Note that spawn() does not by itself call the command interpreter
494732001f49Smrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
494832001f49Smrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
494932001f49Smrg         GetVersionEx(&v);
495032001f49Smrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
495132001f49Smrg      }) ? "cmd.exe" : "command.com").
495232001f49Smrg   Instead it simply concatenates the arguments, separated by ' ', and calls
495332001f49Smrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
495432001f49Smrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
495532001f49Smrg   special way:
495632001f49Smrg   - Space and tab are interpreted as delimiters. They are not treated as
495732001f49Smrg     delimiters if they are surrounded by double quotes: "...".
495832001f49Smrg   - Unescaped double quotes are removed from the input. Their only effect is
495932001f49Smrg     that within double quotes, space and tab are treated like normal
496032001f49Smrg     characters.
496132001f49Smrg   - Backslashes not followed by double quotes are not special.
496232001f49Smrg   - But 2*n+1 backslashes followed by a double quote become
496332001f49Smrg     n backslashes followed by a double quote (n >= 0):
496432001f49Smrg       \" -> "
496532001f49Smrg       \\\" -> \"
496632001f49Smrg       \\\\\" -> \\"
496732001f49Smrg */
496832001f49Smrg#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"
496932001f49Smrg#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"
497032001f49Smrgchar **
497132001f49Smrgprepare_spawn (char **argv)
497232001f49Smrg{
497332001f49Smrg  size_t argc;
497432001f49Smrg  char **new_argv;
497532001f49Smrg  size_t i;
497632001f49Smrg
497732001f49Smrg  /* Count number of arguments.  */
497832001f49Smrg  for (argc = 0; argv[argc] != NULL; argc++)
497932001f49Smrg    ;
498032001f49Smrg
498132001f49Smrg  /* Allocate new argument vector.  */
498232001f49Smrg  new_argv = XMALLOC (char *, argc + 1);
498332001f49Smrg
498432001f49Smrg  /* Put quoted arguments into the new argument vector.  */
498532001f49Smrg  for (i = 0; i < argc; i++)
498632001f49Smrg    {
498732001f49Smrg      const char *string = argv[i];
498832001f49Smrg
498932001f49Smrg      if (string[0] == '\0')
499032001f49Smrg	new_argv[i] = xstrdup ("\"\"");
499132001f49Smrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
499232001f49Smrg	{
499332001f49Smrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
499432001f49Smrg	  size_t length;
499532001f49Smrg	  unsigned int backslashes;
499632001f49Smrg	  const char *s;
499732001f49Smrg	  char *quoted_string;
499832001f49Smrg	  char *p;
499932001f49Smrg
500032001f49Smrg	  length = 0;
500132001f49Smrg	  backslashes = 0;
500232001f49Smrg	  if (quote_around)
500332001f49Smrg	    length++;
500432001f49Smrg	  for (s = string; *s != '\0'; s++)
500532001f49Smrg	    {
500632001f49Smrg	      char c = *s;
500732001f49Smrg	      if (c == '"')
500832001f49Smrg		length += backslashes + 1;
500932001f49Smrg	      length++;
501032001f49Smrg	      if (c == '\\')
501132001f49Smrg		backslashes++;
501232001f49Smrg	      else
501332001f49Smrg		backslashes = 0;
501432001f49Smrg	    }
501532001f49Smrg	  if (quote_around)
501632001f49Smrg	    length += backslashes + 1;
501732001f49Smrg
501832001f49Smrg	  quoted_string = XMALLOC (char, length + 1);
501932001f49Smrg
502032001f49Smrg	  p = quoted_string;
502132001f49Smrg	  backslashes = 0;
502232001f49Smrg	  if (quote_around)
502332001f49Smrg	    *p++ = '"';
502432001f49Smrg	  for (s = string; *s != '\0'; s++)
502532001f49Smrg	    {
502632001f49Smrg	      char c = *s;
502732001f49Smrg	      if (c == '"')
502832001f49Smrg		{
502932001f49Smrg		  unsigned int j;
503032001f49Smrg		  for (j = backslashes + 1; j > 0; j--)
503132001f49Smrg		    *p++ = '\\';
503232001f49Smrg		}
503332001f49Smrg	      *p++ = c;
503432001f49Smrg	      if (c == '\\')
503532001f49Smrg		backslashes++;
503632001f49Smrg	      else
503732001f49Smrg		backslashes = 0;
503832001f49Smrg	    }
503932001f49Smrg	  if (quote_around)
504032001f49Smrg	    {
504132001f49Smrg	      unsigned int j;
504232001f49Smrg	      for (j = backslashes; j > 0; j--)
504332001f49Smrg		*p++ = '\\';
504432001f49Smrg	      *p++ = '"';
504532001f49Smrg	    }
504632001f49Smrg	  *p = '\0';
504732001f49Smrg
504832001f49Smrg	  new_argv[i] = quoted_string;
504932001f49Smrg	}
505032001f49Smrg      else
505132001f49Smrg	new_argv[i] = (char *) string;
505232001f49Smrg    }
505332001f49Smrg  new_argv[argc] = NULL;
505432001f49Smrg
505532001f49Smrg  return new_argv;
505632001f49Smrg}
505732001f49SmrgEOF
505832001f49Smrg		;;
505932001f49Smrg	    esac
506032001f49Smrg
506132001f49Smrg            cat <<"EOF"
506232001f49Smrgvoid lt_dump_script (FILE* f)
506332001f49Smrg{
506432001f49SmrgEOF
506532001f49Smrg	    func_emit_wrapper yes |
506632001f49Smrg	      $SED -n -e '
506732001f49Smrgs/^\(.\{79\}\)\(..*\)/\1\
506832001f49Smrg\2/
506932001f49Smrgh
507032001f49Smrgs/\([\\"]\)/\\\1/g
507132001f49Smrgs/$/\\n/
507232001f49Smrgs/\([^\n]*\).*/  fputs ("\1", f);/p
507332001f49Smrgg
507432001f49SmrgD'
507532001f49Smrg            cat <<"EOF"
507632001f49Smrg}
507732001f49SmrgEOF
507832001f49Smrg}
507932001f49Smrg# end: func_emit_cwrapperexe_src
508032001f49Smrg
508132001f49Smrg# func_win32_import_lib_p ARG
508232001f49Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd
508332001f49Smrgfunc_win32_import_lib_p ()
508432001f49Smrg{
508532001f49Smrg    $opt_debug
508632001f49Smrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
508732001f49Smrg    *import*) : ;;
508832001f49Smrg    *) false ;;
508932001f49Smrg    esac
509032001f49Smrg}
509132001f49Smrg
509232001f49Smrg# func_mode_link arg...
509332001f49Smrgfunc_mode_link ()
509432001f49Smrg{
509532001f49Smrg    $opt_debug
509632001f49Smrg    case $host in
509732001f49Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
509832001f49Smrg      # It is impossible to link a dll without this setting, and
509932001f49Smrg      # we shouldn't force the makefile maintainer to figure out
510032001f49Smrg      # which system we are compiling for in order to pass an extra
510132001f49Smrg      # flag for every libtool invocation.
510232001f49Smrg      # allow_undefined=no
510332001f49Smrg
510432001f49Smrg      # FIXME: Unfortunately, there are problems with the above when trying
510532001f49Smrg      # to make a dll which has undefined symbols, in which case not
510632001f49Smrg      # even a static library is built.  For now, we need to specify
510732001f49Smrg      # -no-undefined on the libtool link line when we can be certain
510832001f49Smrg      # that all symbols are satisfied, otherwise we get a static library.
510932001f49Smrg      allow_undefined=yes
511032001f49Smrg      ;;
511132001f49Smrg    *)
511232001f49Smrg      allow_undefined=yes
511332001f49Smrg      ;;
511432001f49Smrg    esac
511532001f49Smrg    libtool_args=$nonopt
511632001f49Smrg    base_compile="$nonopt $@"
511732001f49Smrg    compile_command=$nonopt
511832001f49Smrg    finalize_command=$nonopt
511932001f49Smrg
512032001f49Smrg    compile_rpath=
512132001f49Smrg    finalize_rpath=
512232001f49Smrg    compile_shlibpath=
512332001f49Smrg    finalize_shlibpath=
512432001f49Smrg    convenience=
512532001f49Smrg    old_convenience=
512632001f49Smrg    deplibs=
512732001f49Smrg    old_deplibs=
512832001f49Smrg    compiler_flags=
512932001f49Smrg    linker_flags=
513032001f49Smrg    dllsearchpath=
513132001f49Smrg    lib_search_path=`pwd`
513232001f49Smrg    inst_prefix_dir=
513332001f49Smrg    new_inherited_linker_flags=
513432001f49Smrg
513532001f49Smrg    avoid_version=no
513632001f49Smrg    bindir=
513732001f49Smrg    dlfiles=
513832001f49Smrg    dlprefiles=
513932001f49Smrg    dlself=no
514032001f49Smrg    export_dynamic=no
514132001f49Smrg    export_symbols=
514232001f49Smrg    export_symbols_regex=
514332001f49Smrg    generated=
514432001f49Smrg    libobjs=
514532001f49Smrg    ltlibs=
514632001f49Smrg    module=no
514732001f49Smrg    no_install=no
514832001f49Smrg    objs=
514932001f49Smrg    non_pic_objects=
515032001f49Smrg    precious_files_regex=
515132001f49Smrg    prefer_static_libs=no
515232001f49Smrg    preload=no
515332001f49Smrg    prev=
515432001f49Smrg    prevarg=
515532001f49Smrg    release=
515632001f49Smrg    rpath=
515732001f49Smrg    xrpath=
515832001f49Smrg    perm_rpath=
515932001f49Smrg    temp_rpath=
516032001f49Smrg    thread_safe=no
516132001f49Smrg    vinfo=
516232001f49Smrg    vinfo_number=no
516332001f49Smrg    weak_libs=
516432001f49Smrg    single_module="${wl}-single_module"
516532001f49Smrg    func_infer_tag $base_compile
516632001f49Smrg
516732001f49Smrg    # We need to know -static, to get the right output filenames.
516832001f49Smrg    for arg
516932001f49Smrg    do
517032001f49Smrg      case $arg in
517132001f49Smrg      -shared)
517232001f49Smrg	test "$build_libtool_libs" != yes && \
517332001f49Smrg	  func_fatal_configuration "can not build a shared library"
517432001f49Smrg	build_old_libs=no
517532001f49Smrg	break
517632001f49Smrg	;;
517732001f49Smrg      -all-static | -static | -static-libtool-libs)
517832001f49Smrg	case $arg in
517932001f49Smrg	-all-static)
518032001f49Smrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
518132001f49Smrg	    func_warning "complete static linking is impossible in this configuration"
518232001f49Smrg	  fi
518332001f49Smrg	  if test -n "$link_static_flag"; then
518432001f49Smrg	    dlopen_self=$dlopen_self_static
518532001f49Smrg	  fi
518632001f49Smrg	  prefer_static_libs=yes
518732001f49Smrg	  ;;
518832001f49Smrg	-static)
518932001f49Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
519032001f49Smrg	    dlopen_self=$dlopen_self_static
519132001f49Smrg	  fi
519232001f49Smrg	  prefer_static_libs=built
519332001f49Smrg	  ;;
519432001f49Smrg	-static-libtool-libs)
519532001f49Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
519632001f49Smrg	    dlopen_self=$dlopen_self_static
519732001f49Smrg	  fi
519832001f49Smrg	  prefer_static_libs=yes
519932001f49Smrg	  ;;
520032001f49Smrg	esac
520132001f49Smrg	build_libtool_libs=no
520232001f49Smrg	build_old_libs=yes
520332001f49Smrg	break
520432001f49Smrg	;;
520532001f49Smrg      esac
520632001f49Smrg    done
520732001f49Smrg
520832001f49Smrg    # See if our shared archives depend on static archives.
520932001f49Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
521032001f49Smrg
521132001f49Smrg    # Go through the arguments, transforming them on the way.
521232001f49Smrg    while test "$#" -gt 0; do
521332001f49Smrg      arg="$1"
521432001f49Smrg      shift
521532001f49Smrg      func_quote_for_eval "$arg"
521632001f49Smrg      qarg=$func_quote_for_eval_unquoted_result
521732001f49Smrg      func_append libtool_args " $func_quote_for_eval_result"
521832001f49Smrg
521932001f49Smrg      # If the previous option needs an argument, assign it.
522032001f49Smrg      if test -n "$prev"; then
522132001f49Smrg	case $prev in
522232001f49Smrg	output)
522332001f49Smrg	  func_append compile_command " @OUTPUT@"
522432001f49Smrg	  func_append finalize_command " @OUTPUT@"
522532001f49Smrg	  ;;
522632001f49Smrg	esac
522732001f49Smrg
522832001f49Smrg	case $prev in
522932001f49Smrg	bindir)
523032001f49Smrg	  bindir="$arg"
523132001f49Smrg	  prev=
523232001f49Smrg	  continue
523332001f49Smrg	  ;;
523432001f49Smrg	dlfiles|dlprefiles)
523532001f49Smrg	  if test "$preload" = no; then
523632001f49Smrg	    # Add the symbol object into the linking commands.
523732001f49Smrg	    func_append compile_command " @SYMFILE@"
523832001f49Smrg	    func_append finalize_command " @SYMFILE@"
523932001f49Smrg	    preload=yes
524032001f49Smrg	  fi
524132001f49Smrg	  case $arg in
524232001f49Smrg	  *.la | *.lo) ;;  # We handle these cases below.
524332001f49Smrg	  force)
524432001f49Smrg	    if test "$dlself" = no; then
524532001f49Smrg	      dlself=needless
524632001f49Smrg	      export_dynamic=yes
524732001f49Smrg	    fi
524832001f49Smrg	    prev=
524932001f49Smrg	    continue
525032001f49Smrg	    ;;
525132001f49Smrg	  self)
525232001f49Smrg	    if test "$prev" = dlprefiles; then
525332001f49Smrg	      dlself=yes
525432001f49Smrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
525532001f49Smrg	      dlself=yes
525632001f49Smrg	    else
525732001f49Smrg	      dlself=needless
525832001f49Smrg	      export_dynamic=yes
525932001f49Smrg	    fi
526032001f49Smrg	    prev=
526132001f49Smrg	    continue
526232001f49Smrg	    ;;
526332001f49Smrg	  *)
526432001f49Smrg	    if test "$prev" = dlfiles; then
526532001f49Smrg	      func_append dlfiles " $arg"
526632001f49Smrg	    else
526732001f49Smrg	      func_append dlprefiles " $arg"
526832001f49Smrg	    fi
526932001f49Smrg	    prev=
527032001f49Smrg	    continue
527132001f49Smrg	    ;;
527232001f49Smrg	  esac
527332001f49Smrg	  ;;
527432001f49Smrg	expsyms)
527532001f49Smrg	  export_symbols="$arg"
527632001f49Smrg	  test -f "$arg" \
527732001f49Smrg	    || func_fatal_error "symbol file \`$arg' does not exist"
527832001f49Smrg	  prev=
527932001f49Smrg	  continue
528032001f49Smrg	  ;;
528132001f49Smrg	expsyms_regex)
528232001f49Smrg	  export_symbols_regex="$arg"
528332001f49Smrg	  prev=
528432001f49Smrg	  continue
528532001f49Smrg	  ;;
528632001f49Smrg	framework)
528732001f49Smrg	  case $host in
528832001f49Smrg	    *-*-darwin*)
528932001f49Smrg	      case "$deplibs " in
529032001f49Smrg		*" $qarg.ltframework "*) ;;
529132001f49Smrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
529232001f49Smrg		   ;;
529332001f49Smrg	      esac
529432001f49Smrg	      ;;
529532001f49Smrg	  esac
529632001f49Smrg	  prev=
529732001f49Smrg	  continue
529832001f49Smrg	  ;;
529932001f49Smrg	inst_prefix)
530032001f49Smrg	  inst_prefix_dir="$arg"
530132001f49Smrg	  prev=
530232001f49Smrg	  continue
530332001f49Smrg	  ;;
530432001f49Smrg	objectlist)
530532001f49Smrg	  if test -f "$arg"; then
530632001f49Smrg	    save_arg=$arg
530732001f49Smrg	    moreargs=
530832001f49Smrg	    for fil in `cat "$save_arg"`
530932001f49Smrg	    do
531032001f49Smrg#	      func_append moreargs " $fil"
531132001f49Smrg	      arg=$fil
531232001f49Smrg	      # A libtool-controlled object.
531332001f49Smrg
531432001f49Smrg	      # Check to see that this really is a libtool object.
531532001f49Smrg	      if func_lalib_unsafe_p "$arg"; then
531632001f49Smrg		pic_object=
531732001f49Smrg		non_pic_object=
531832001f49Smrg
531932001f49Smrg		# Read the .lo file
532032001f49Smrg		func_source "$arg"
532132001f49Smrg
532232001f49Smrg		if test -z "$pic_object" ||
532332001f49Smrg		   test -z "$non_pic_object" ||
532432001f49Smrg		   test "$pic_object" = none &&
532532001f49Smrg		   test "$non_pic_object" = none; then
532632001f49Smrg		  func_fatal_error "cannot find name of object for \`$arg'"
532732001f49Smrg		fi
532832001f49Smrg
532932001f49Smrg		# Extract subdirectory from the argument.
533032001f49Smrg		func_dirname "$arg" "/" ""
533132001f49Smrg		xdir="$func_dirname_result"
533232001f49Smrg
533332001f49Smrg		if test "$pic_object" != none; then
533432001f49Smrg		  # Prepend the subdirectory the object is found in.
533532001f49Smrg		  pic_object="$xdir$pic_object"
533632001f49Smrg
533732001f49Smrg		  if test "$prev" = dlfiles; then
533832001f49Smrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
533932001f49Smrg		      func_append dlfiles " $pic_object"
534032001f49Smrg		      prev=
534132001f49Smrg		      continue
534232001f49Smrg		    else
534332001f49Smrg		      # If libtool objects are unsupported, then we need to preload.
534432001f49Smrg		      prev=dlprefiles
534532001f49Smrg		    fi
534632001f49Smrg		  fi
534732001f49Smrg
534832001f49Smrg		  # CHECK ME:  I think I busted this.  -Ossama
534932001f49Smrg		  if test "$prev" = dlprefiles; then
535032001f49Smrg		    # Preload the old-style object.
535132001f49Smrg		    func_append dlprefiles " $pic_object"
535232001f49Smrg		    prev=
535332001f49Smrg		  fi
535432001f49Smrg
535532001f49Smrg		  # A PIC object.
535632001f49Smrg		  func_append libobjs " $pic_object"
535732001f49Smrg		  arg="$pic_object"
535832001f49Smrg		fi
535932001f49Smrg
536032001f49Smrg		# Non-PIC object.
536132001f49Smrg		if test "$non_pic_object" != none; then
536232001f49Smrg		  # Prepend the subdirectory the object is found in.
536332001f49Smrg		  non_pic_object="$xdir$non_pic_object"
536432001f49Smrg
536532001f49Smrg		  # A standard non-PIC object
536632001f49Smrg		  func_append non_pic_objects " $non_pic_object"
536732001f49Smrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
536832001f49Smrg		    arg="$non_pic_object"
536932001f49Smrg		  fi
537032001f49Smrg		else
537132001f49Smrg		  # If the PIC object exists, use it instead.
537232001f49Smrg		  # $xdir was prepended to $pic_object above.
537332001f49Smrg		  non_pic_object="$pic_object"
537432001f49Smrg		  func_append non_pic_objects " $non_pic_object"
537532001f49Smrg		fi
537632001f49Smrg	      else
537732001f49Smrg		# Only an error if not doing a dry-run.
537832001f49Smrg		if $opt_dry_run; then
537932001f49Smrg		  # Extract subdirectory from the argument.
538032001f49Smrg		  func_dirname "$arg" "/" ""
538132001f49Smrg		  xdir="$func_dirname_result"
538232001f49Smrg
538332001f49Smrg		  func_lo2o "$arg"
538432001f49Smrg		  pic_object=$xdir$objdir/$func_lo2o_result
538532001f49Smrg		  non_pic_object=$xdir$func_lo2o_result
538632001f49Smrg		  func_append libobjs " $pic_object"
538732001f49Smrg		  func_append non_pic_objects " $non_pic_object"
538832001f49Smrg	        else
538932001f49Smrg		  func_fatal_error "\`$arg' is not a valid libtool object"
539032001f49Smrg		fi
539132001f49Smrg	      fi
539232001f49Smrg	    done
539332001f49Smrg	  else
539432001f49Smrg	    func_fatal_error "link input file \`$arg' does not exist"
539532001f49Smrg	  fi
539632001f49Smrg	  arg=$save_arg
539732001f49Smrg	  prev=
539832001f49Smrg	  continue
539932001f49Smrg	  ;;
540032001f49Smrg	precious_regex)
540132001f49Smrg	  precious_files_regex="$arg"
540232001f49Smrg	  prev=
540332001f49Smrg	  continue
540432001f49Smrg	  ;;
540532001f49Smrg	release)
540632001f49Smrg	  release="-$arg"
540732001f49Smrg	  prev=
540832001f49Smrg	  continue
540932001f49Smrg	  ;;
541032001f49Smrg	rpath | xrpath)
541132001f49Smrg	  # We need an absolute path.
541232001f49Smrg	  case $arg in
541332001f49Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
541432001f49Smrg	  *)
541532001f49Smrg	    func_fatal_error "only absolute run-paths are allowed"
541632001f49Smrg	    ;;
541732001f49Smrg	  esac
541832001f49Smrg	  if test "$prev" = rpath; then
541932001f49Smrg	    case "$rpath " in
542032001f49Smrg	    *" $arg "*) ;;
542132001f49Smrg	    *) func_append rpath " $arg" ;;
542232001f49Smrg	    esac
542332001f49Smrg	  else
542432001f49Smrg	    case "$xrpath " in
542532001f49Smrg	    *" $arg "*) ;;
542632001f49Smrg	    *) func_append xrpath " $arg" ;;
542732001f49Smrg	    esac
542832001f49Smrg	  fi
542932001f49Smrg	  prev=
543032001f49Smrg	  continue
543132001f49Smrg	  ;;
543232001f49Smrg	shrext)
543332001f49Smrg	  shrext_cmds="$arg"
543432001f49Smrg	  prev=
543532001f49Smrg	  continue
543632001f49Smrg	  ;;
543732001f49Smrg	weak)
543832001f49Smrg	  func_append weak_libs " $arg"
543932001f49Smrg	  prev=
544032001f49Smrg	  continue
544132001f49Smrg	  ;;
544232001f49Smrg	xcclinker)
544332001f49Smrg	  func_append linker_flags " $qarg"
544432001f49Smrg	  func_append compiler_flags " $qarg"
544532001f49Smrg	  prev=
544632001f49Smrg	  func_append compile_command " $qarg"
544732001f49Smrg	  func_append finalize_command " $qarg"
544832001f49Smrg	  continue
544932001f49Smrg	  ;;
545032001f49Smrg	xcompiler)
545132001f49Smrg	  func_append compiler_flags " $qarg"
545232001f49Smrg	  prev=
545332001f49Smrg	  func_append compile_command " $qarg"
545432001f49Smrg	  func_append finalize_command " $qarg"
545532001f49Smrg	  continue
545632001f49Smrg	  ;;
545732001f49Smrg	xlinker)
545832001f49Smrg	  func_append linker_flags " $qarg"
545932001f49Smrg	  func_append compiler_flags " $wl$qarg"
546032001f49Smrg	  prev=
546132001f49Smrg	  func_append compile_command " $wl$qarg"
546232001f49Smrg	  func_append finalize_command " $wl$qarg"
546332001f49Smrg	  continue
546432001f49Smrg	  ;;
546532001f49Smrg	*)
546632001f49Smrg	  eval "$prev=\"\$arg\""
546732001f49Smrg	  prev=
546832001f49Smrg	  continue
546932001f49Smrg	  ;;
547032001f49Smrg	esac
547132001f49Smrg      fi # test -n "$prev"
547232001f49Smrg
547332001f49Smrg      prevarg="$arg"
547432001f49Smrg
547532001f49Smrg      case $arg in
547632001f49Smrg      -all-static)
547732001f49Smrg	if test -n "$link_static_flag"; then
547832001f49Smrg	  # See comment for -static flag below, for more details.
547932001f49Smrg	  func_append compile_command " $link_static_flag"
548032001f49Smrg	  func_append finalize_command " $link_static_flag"
548132001f49Smrg	fi
548232001f49Smrg	continue
548332001f49Smrg	;;
548432001f49Smrg
548532001f49Smrg      -allow-undefined)
548632001f49Smrg	# FIXME: remove this flag sometime in the future.
548732001f49Smrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
548832001f49Smrg	;;
548932001f49Smrg
549032001f49Smrg      -avoid-version)
549132001f49Smrg	avoid_version=yes
549232001f49Smrg	continue
549332001f49Smrg	;;
549432001f49Smrg
549532001f49Smrg      -bindir)
549632001f49Smrg	prev=bindir
549732001f49Smrg	continue
549832001f49Smrg	;;
549932001f49Smrg
550032001f49Smrg      -dlopen)
550132001f49Smrg	prev=dlfiles
550232001f49Smrg	continue
550332001f49Smrg	;;
550432001f49Smrg
550532001f49Smrg      -dlpreopen)
550632001f49Smrg	prev=dlprefiles
550732001f49Smrg	continue
550832001f49Smrg	;;
550932001f49Smrg
551032001f49Smrg      -export-dynamic)
551132001f49Smrg	export_dynamic=yes
551232001f49Smrg	continue
551332001f49Smrg	;;
551432001f49Smrg
551532001f49Smrg      -export-symbols | -export-symbols-regex)
551632001f49Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
551732001f49Smrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
551832001f49Smrg	fi
551932001f49Smrg	if test "X$arg" = "X-export-symbols"; then
552032001f49Smrg	  prev=expsyms
552132001f49Smrg	else
552232001f49Smrg	  prev=expsyms_regex
552332001f49Smrg	fi
552432001f49Smrg	continue
552532001f49Smrg	;;
552632001f49Smrg
552732001f49Smrg      -framework)
552832001f49Smrg	prev=framework
552932001f49Smrg	continue
553032001f49Smrg	;;
553132001f49Smrg
553232001f49Smrg      -inst-prefix-dir)
553332001f49Smrg	prev=inst_prefix
553432001f49Smrg	continue
553532001f49Smrg	;;
553632001f49Smrg
553732001f49Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
553832001f49Smrg      # so, if we see these flags be careful not to treat them like -L
553932001f49Smrg      -L[A-Z][A-Z]*:*)
554032001f49Smrg	case $with_gcc/$host in
554132001f49Smrg	no/*-*-irix* | /*-*-irix*)
554232001f49Smrg	  func_append compile_command " $arg"
554332001f49Smrg	  func_append finalize_command " $arg"
554432001f49Smrg	  ;;
554532001f49Smrg	esac
554632001f49Smrg	continue
554732001f49Smrg	;;
554832001f49Smrg
554932001f49Smrg      -L*)
555032001f49Smrg	func_stripname "-L" '' "$arg"
555132001f49Smrg	if test -z "$func_stripname_result"; then
555232001f49Smrg	  if test "$#" -gt 0; then
555332001f49Smrg	    func_fatal_error "require no space between \`-L' and \`$1'"
555432001f49Smrg	  else
555532001f49Smrg	    func_fatal_error "need path for \`-L' option"
555632001f49Smrg	  fi
555732001f49Smrg	fi
555832001f49Smrg	func_resolve_sysroot "$func_stripname_result"
555932001f49Smrg	dir=$func_resolve_sysroot_result
556032001f49Smrg	# We need an absolute path.
556132001f49Smrg	case $dir in
556232001f49Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
556332001f49Smrg	*)
556432001f49Smrg	  absdir=`cd "$dir" && pwd`
556532001f49Smrg	  test -z "$absdir" && \
556632001f49Smrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
556732001f49Smrg	  dir="$absdir"
556832001f49Smrg	  ;;
556932001f49Smrg	esac
557032001f49Smrg	case "$deplibs " in
557132001f49Smrg	*" -L$dir "* | *" $arg "*)
557232001f49Smrg	  # Will only happen for absolute or sysroot arguments
557332001f49Smrg	  ;;
557432001f49Smrg	*)
557532001f49Smrg	  # Preserve sysroot, but never include relative directories
557632001f49Smrg	  case $dir in
557732001f49Smrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
557832001f49Smrg	    *) func_append deplibs " -L$dir" ;;
557932001f49Smrg	  esac
558032001f49Smrg	  func_append lib_search_path " $dir"
558132001f49Smrg	  ;;
558232001f49Smrg	esac
558332001f49Smrg	case $host in
558432001f49Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
558532001f49Smrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
558632001f49Smrg	  case :$dllsearchpath: in
558732001f49Smrg	  *":$dir:"*) ;;
558832001f49Smrg	  ::) dllsearchpath=$dir;;
558932001f49Smrg	  *) func_append dllsearchpath ":$dir";;
559032001f49Smrg	  esac
559132001f49Smrg	  case :$dllsearchpath: in
559232001f49Smrg	  *":$testbindir:"*) ;;
559332001f49Smrg	  ::) dllsearchpath=$testbindir;;
559432001f49Smrg	  *) func_append dllsearchpath ":$testbindir";;
559532001f49Smrg	  esac
559632001f49Smrg	  ;;
559732001f49Smrg	esac
559832001f49Smrg	continue
559932001f49Smrg	;;
560032001f49Smrg
560132001f49Smrg      -l*)
560232001f49Smrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
560332001f49Smrg	  case $host in
560432001f49Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
560532001f49Smrg	    # These systems don't actually have a C or math library (as such)
560632001f49Smrg	    continue
560732001f49Smrg	    ;;
560832001f49Smrg	  *-*-os2*)
560932001f49Smrg	    # These systems don't actually have a C library (as such)
561032001f49Smrg	    test "X$arg" = "X-lc" && continue
561132001f49Smrg	    ;;
561232001f49Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
561332001f49Smrg	    # Do not include libc due to us having libc/libc_r.
561432001f49Smrg	    test "X$arg" = "X-lc" && continue
561532001f49Smrg	    ;;
561632001f49Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
561732001f49Smrg	    # Rhapsody C and math libraries are in the System framework
561832001f49Smrg	    func_append deplibs " System.ltframework"
561932001f49Smrg	    continue
562032001f49Smrg	    ;;
562132001f49Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
562232001f49Smrg	    # Causes problems with __ctype
562332001f49Smrg	    test "X$arg" = "X-lc" && continue
562432001f49Smrg	    ;;
562532001f49Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
562632001f49Smrg	    # Compiler inserts libc in the correct place for threads to work
562732001f49Smrg	    test "X$arg" = "X-lc" && continue
562832001f49Smrg	    ;;
562932001f49Smrg	  esac
563032001f49Smrg	elif test "X$arg" = "X-lc_r"; then
563132001f49Smrg	 case $host in
563232001f49Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
563332001f49Smrg	   # Do not include libc_r directly, use -pthread flag.
563432001f49Smrg	   continue
563532001f49Smrg	   ;;
563632001f49Smrg	 esac
563732001f49Smrg	fi
563832001f49Smrg	func_append deplibs " $arg"
563932001f49Smrg	continue
564032001f49Smrg	;;
564132001f49Smrg
564232001f49Smrg      -module)
564332001f49Smrg	module=yes
564432001f49Smrg	continue
564532001f49Smrg	;;
564632001f49Smrg
564732001f49Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
564832001f49Smrg      # classes, name mangling, and exception handling.
564932001f49Smrg      # Darwin uses the -arch flag to determine output architecture.
565032001f49Smrg      -model|-arch|-isysroot|--sysroot)
565132001f49Smrg	func_append compiler_flags " $arg"
565232001f49Smrg	func_append compile_command " $arg"
565332001f49Smrg	func_append finalize_command " $arg"
565432001f49Smrg	prev=xcompiler
565532001f49Smrg	continue
565632001f49Smrg	;;
565732001f49Smrg
565832001f49Smrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
565932001f49Smrg      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
566032001f49Smrg	func_append compiler_flags " $arg"
566132001f49Smrg	func_append compile_command " $arg"
566232001f49Smrg	func_append finalize_command " $arg"
566332001f49Smrg	case "$new_inherited_linker_flags " in
566432001f49Smrg	    *" $arg "*) ;;
566532001f49Smrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
566632001f49Smrg	esac
566732001f49Smrg	continue
566832001f49Smrg	;;
566932001f49Smrg
567032001f49Smrg      -multi_module)
567132001f49Smrg	single_module="${wl}-multi_module"
567232001f49Smrg	continue
567332001f49Smrg	;;
567432001f49Smrg
567532001f49Smrg      -no-fast-install)
567632001f49Smrg	fast_install=no
567732001f49Smrg	continue
567832001f49Smrg	;;
567932001f49Smrg
568032001f49Smrg      -no-install)
568132001f49Smrg	case $host in
568232001f49Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
568332001f49Smrg	  # The PATH hackery in wrapper scripts is required on Windows
568432001f49Smrg	  # and Darwin in order for the loader to find any dlls it needs.
568532001f49Smrg	  func_warning "\`-no-install' is ignored for $host"
568632001f49Smrg	  func_warning "assuming \`-no-fast-install' instead"
568732001f49Smrg	  fast_install=no
568832001f49Smrg	  ;;
568932001f49Smrg	*) no_install=yes ;;
569032001f49Smrg	esac
569132001f49Smrg	continue
569232001f49Smrg	;;
569332001f49Smrg
569432001f49Smrg      -no-undefined)
569532001f49Smrg	allow_undefined=no
569632001f49Smrg	continue
569732001f49Smrg	;;
569832001f49Smrg
569932001f49Smrg      -objectlist)
570032001f49Smrg	prev=objectlist
570132001f49Smrg	continue
570232001f49Smrg	;;
570332001f49Smrg
570432001f49Smrg      -o) prev=output ;;
570532001f49Smrg
570632001f49Smrg      -precious-files-regex)
570732001f49Smrg	prev=precious_regex
570832001f49Smrg	continue
570932001f49Smrg	;;
571032001f49Smrg
571132001f49Smrg      -release)
571232001f49Smrg	prev=release
571332001f49Smrg	continue
571432001f49Smrg	;;
571532001f49Smrg
571632001f49Smrg      -rpath)
571732001f49Smrg	prev=rpath
571832001f49Smrg	continue
571932001f49Smrg	;;
572032001f49Smrg
572132001f49Smrg      -R)
572232001f49Smrg	prev=xrpath
572332001f49Smrg	continue
572432001f49Smrg	;;
572532001f49Smrg
572632001f49Smrg      -R*)
572732001f49Smrg	func_stripname '-R' '' "$arg"
572832001f49Smrg	dir=$func_stripname_result
572932001f49Smrg	# We need an absolute path.
573032001f49Smrg	case $dir in
573132001f49Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
573232001f49Smrg	=*)
573332001f49Smrg	  func_stripname '=' '' "$dir"
573432001f49Smrg	  dir=$lt_sysroot$func_stripname_result
573532001f49Smrg	  ;;
573632001f49Smrg	*)
573732001f49Smrg	  func_fatal_error "only absolute run-paths are allowed"
573832001f49Smrg	  ;;
573932001f49Smrg	esac
574032001f49Smrg	case "$xrpath " in
574132001f49Smrg	*" $dir "*) ;;
574232001f49Smrg	*) func_append xrpath " $dir" ;;
574332001f49Smrg	esac
574432001f49Smrg	continue
574532001f49Smrg	;;
574632001f49Smrg
574732001f49Smrg      -shared)
574832001f49Smrg	# The effects of -shared are defined in a previous loop.
574932001f49Smrg	continue
575032001f49Smrg	;;
575132001f49Smrg
575232001f49Smrg      -shrext)
575332001f49Smrg	prev=shrext
575432001f49Smrg	continue
575532001f49Smrg	;;
575632001f49Smrg
575732001f49Smrg      -static | -static-libtool-libs)
575832001f49Smrg	# The effects of -static are defined in a previous loop.
575932001f49Smrg	# We used to do the same as -all-static on platforms that
576032001f49Smrg	# didn't have a PIC flag, but the assumption that the effects
576132001f49Smrg	# would be equivalent was wrong.  It would break on at least
576232001f49Smrg	# Digital Unix and AIX.
576332001f49Smrg	continue
576432001f49Smrg	;;
576532001f49Smrg
576632001f49Smrg      -thread-safe)
576732001f49Smrg	thread_safe=yes
576832001f49Smrg	continue
576932001f49Smrg	;;
577032001f49Smrg
577132001f49Smrg      -version-info)
577232001f49Smrg	prev=vinfo
577332001f49Smrg	continue
577432001f49Smrg	;;
577532001f49Smrg
577632001f49Smrg      -version-number)
577732001f49Smrg	prev=vinfo
577832001f49Smrg	vinfo_number=yes
577932001f49Smrg	continue
578032001f49Smrg	;;
578132001f49Smrg
578232001f49Smrg      -weak)
578332001f49Smrg        prev=weak
578432001f49Smrg	continue
578532001f49Smrg	;;
578632001f49Smrg
578732001f49Smrg      -Wc,*)
578832001f49Smrg	func_stripname '-Wc,' '' "$arg"
578932001f49Smrg	args=$func_stripname_result
579032001f49Smrg	arg=
579132001f49Smrg	save_ifs="$IFS"; IFS=','
579232001f49Smrg	for flag in $args; do
579332001f49Smrg	  IFS="$save_ifs"
579432001f49Smrg          func_quote_for_eval "$flag"
579532001f49Smrg	  func_append arg " $func_quote_for_eval_result"
579632001f49Smrg	  func_append compiler_flags " $func_quote_for_eval_result"
579732001f49Smrg	done
579832001f49Smrg	IFS="$save_ifs"
579932001f49Smrg	func_stripname ' ' '' "$arg"
580032001f49Smrg	arg=$func_stripname_result
580132001f49Smrg	;;
580232001f49Smrg
580332001f49Smrg      -Wl,*)
580432001f49Smrg	func_stripname '-Wl,' '' "$arg"
580532001f49Smrg	args=$func_stripname_result
580632001f49Smrg	arg=
580732001f49Smrg	save_ifs="$IFS"; IFS=','
580832001f49Smrg	for flag in $args; do
580932001f49Smrg	  IFS="$save_ifs"
581032001f49Smrg          func_quote_for_eval "$flag"
581132001f49Smrg	  func_append arg " $wl$func_quote_for_eval_result"
581232001f49Smrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
581332001f49Smrg	  func_append linker_flags " $func_quote_for_eval_result"
581432001f49Smrg	done
581532001f49Smrg	IFS="$save_ifs"
581632001f49Smrg	func_stripname ' ' '' "$arg"
581732001f49Smrg	arg=$func_stripname_result
581832001f49Smrg	;;
581932001f49Smrg
582032001f49Smrg      -Xcompiler)
582132001f49Smrg	prev=xcompiler
582232001f49Smrg	continue
582332001f49Smrg	;;
582432001f49Smrg
582532001f49Smrg      -Xlinker)
582632001f49Smrg	prev=xlinker
582732001f49Smrg	continue
582832001f49Smrg	;;
582932001f49Smrg
583032001f49Smrg      -XCClinker)
583132001f49Smrg	prev=xcclinker
583232001f49Smrg	continue
583332001f49Smrg	;;
583432001f49Smrg
583532001f49Smrg      # -msg_* for osf cc
583632001f49Smrg      -msg_*)
583732001f49Smrg	func_quote_for_eval "$arg"
583832001f49Smrg	arg="$func_quote_for_eval_result"
583932001f49Smrg	;;
584032001f49Smrg
584132001f49Smrg      # Flags to be passed through unchanged, with rationale:
584232001f49Smrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
584332001f49Smrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
584432001f49Smrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
584532001f49Smrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
584632001f49Smrg      # -q*                  compiler args for the IBM compiler
584732001f49Smrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
584832001f49Smrg      # -F/path              path to uninstalled frameworks, gcc on darwin
584932001f49Smrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
585032001f49Smrg      # @file                GCC response files
585132001f49Smrg      # -tp=*                Portland pgcc target processor selection
585232001f49Smrg      # --sysroot=*          for sysroot support
585332001f49Smrg      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
585432001f49Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
585532001f49Smrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
585632001f49Smrg      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
585732001f49Smrg        func_quote_for_eval "$arg"
585832001f49Smrg	arg="$func_quote_for_eval_result"
585932001f49Smrg        func_append compile_command " $arg"
586032001f49Smrg        func_append finalize_command " $arg"
586132001f49Smrg        func_append compiler_flags " $arg"
586232001f49Smrg        continue
586332001f49Smrg        ;;
586432001f49Smrg
586532001f49Smrg      # Some other compiler flag.
586632001f49Smrg      -* | +*)
586732001f49Smrg        func_quote_for_eval "$arg"
586832001f49Smrg	arg="$func_quote_for_eval_result"
586932001f49Smrg	;;
587032001f49Smrg
587132001f49Smrg      *.$objext)
587232001f49Smrg	# A standard object.
587332001f49Smrg	func_append objs " $arg"
587432001f49Smrg	;;
587532001f49Smrg
587632001f49Smrg      *.lo)
587732001f49Smrg	# A libtool-controlled object.
587832001f49Smrg
587932001f49Smrg	# Check to see that this really is a libtool object.
588032001f49Smrg	if func_lalib_unsafe_p "$arg"; then
588132001f49Smrg	  pic_object=
588232001f49Smrg	  non_pic_object=
588332001f49Smrg
588432001f49Smrg	  # Read the .lo file
588532001f49Smrg	  func_source "$arg"
588632001f49Smrg
588732001f49Smrg	  if test -z "$pic_object" ||
588832001f49Smrg	     test -z "$non_pic_object" ||
588932001f49Smrg	     test "$pic_object" = none &&
589032001f49Smrg	     test "$non_pic_object" = none; then
589132001f49Smrg	    func_fatal_error "cannot find name of object for \`$arg'"
589232001f49Smrg	  fi
589332001f49Smrg
589432001f49Smrg	  # Extract subdirectory from the argument.
589532001f49Smrg	  func_dirname "$arg" "/" ""
589632001f49Smrg	  xdir="$func_dirname_result"
589732001f49Smrg
589832001f49Smrg	  if test "$pic_object" != none; then
589932001f49Smrg	    # Prepend the subdirectory the object is found in.
590032001f49Smrg	    pic_object="$xdir$pic_object"
590132001f49Smrg
590232001f49Smrg	    if test "$prev" = dlfiles; then
590332001f49Smrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
590432001f49Smrg		func_append dlfiles " $pic_object"
590532001f49Smrg		prev=
590632001f49Smrg		continue
590732001f49Smrg	      else
590832001f49Smrg		# If libtool objects are unsupported, then we need to preload.
590932001f49Smrg		prev=dlprefiles
591032001f49Smrg	      fi
591132001f49Smrg	    fi
591232001f49Smrg
591332001f49Smrg	    # CHECK ME:  I think I busted this.  -Ossama
591432001f49Smrg	    if test "$prev" = dlprefiles; then
591532001f49Smrg	      # Preload the old-style object.
591632001f49Smrg	      func_append dlprefiles " $pic_object"
591732001f49Smrg	      prev=
591832001f49Smrg	    fi
591932001f49Smrg
592032001f49Smrg	    # A PIC object.
592132001f49Smrg	    func_append libobjs " $pic_object"
592232001f49Smrg	    arg="$pic_object"
592332001f49Smrg	  fi
592432001f49Smrg
592532001f49Smrg	  # Non-PIC object.
592632001f49Smrg	  if test "$non_pic_object" != none; then
592732001f49Smrg	    # Prepend the subdirectory the object is found in.
592832001f49Smrg	    non_pic_object="$xdir$non_pic_object"
592932001f49Smrg
593032001f49Smrg	    # A standard non-PIC object
593132001f49Smrg	    func_append non_pic_objects " $non_pic_object"
593232001f49Smrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
593332001f49Smrg	      arg="$non_pic_object"
593432001f49Smrg	    fi
593532001f49Smrg	  else
593632001f49Smrg	    # If the PIC object exists, use it instead.
593732001f49Smrg	    # $xdir was prepended to $pic_object above.
593832001f49Smrg	    non_pic_object="$pic_object"
593932001f49Smrg	    func_append non_pic_objects " $non_pic_object"
594032001f49Smrg	  fi
594132001f49Smrg	else
594232001f49Smrg	  # Only an error if not doing a dry-run.
594332001f49Smrg	  if $opt_dry_run; then
594432001f49Smrg	    # Extract subdirectory from the argument.
594532001f49Smrg	    func_dirname "$arg" "/" ""
594632001f49Smrg	    xdir="$func_dirname_result"
594732001f49Smrg
594832001f49Smrg	    func_lo2o "$arg"
594932001f49Smrg	    pic_object=$xdir$objdir/$func_lo2o_result
595032001f49Smrg	    non_pic_object=$xdir$func_lo2o_result
595132001f49Smrg	    func_append libobjs " $pic_object"
595232001f49Smrg	    func_append non_pic_objects " $non_pic_object"
595332001f49Smrg	  else
595432001f49Smrg	    func_fatal_error "\`$arg' is not a valid libtool object"
595532001f49Smrg	  fi
595632001f49Smrg	fi
595732001f49Smrg	;;
595832001f49Smrg
595932001f49Smrg      *.$libext)
596032001f49Smrg	# An archive.
596132001f49Smrg	func_append deplibs " $arg"
596232001f49Smrg	func_append old_deplibs " $arg"
596332001f49Smrg	continue
596432001f49Smrg	;;
596532001f49Smrg
596632001f49Smrg      *.la)
596732001f49Smrg	# A libtool-controlled library.
596832001f49Smrg
596932001f49Smrg	func_resolve_sysroot "$arg"
597032001f49Smrg	if test "$prev" = dlfiles; then
597132001f49Smrg	  # This library was specified with -dlopen.
597232001f49Smrg	  func_append dlfiles " $func_resolve_sysroot_result"
597332001f49Smrg	  prev=
597432001f49Smrg	elif test "$prev" = dlprefiles; then
597532001f49Smrg	  # The library was specified with -dlpreopen.
597632001f49Smrg	  func_append dlprefiles " $func_resolve_sysroot_result"
597732001f49Smrg	  prev=
597832001f49Smrg	else
597932001f49Smrg	  func_append deplibs " $func_resolve_sysroot_result"
598032001f49Smrg	fi
598132001f49Smrg	continue
598232001f49Smrg	;;
598332001f49Smrg
598432001f49Smrg      # Some other compiler argument.
598532001f49Smrg      *)
598632001f49Smrg	# Unknown arguments in both finalize_command and compile_command need
598732001f49Smrg	# to be aesthetically quoted because they are evaled later.
598832001f49Smrg	func_quote_for_eval "$arg"
598932001f49Smrg	arg="$func_quote_for_eval_result"
599032001f49Smrg	;;
599132001f49Smrg      esac # arg
599232001f49Smrg
599332001f49Smrg      # Now actually substitute the argument into the commands.
599432001f49Smrg      if test -n "$arg"; then
599532001f49Smrg	func_append compile_command " $arg"
599632001f49Smrg	func_append finalize_command " $arg"
599732001f49Smrg      fi
599832001f49Smrg    done # argument parsing loop
599932001f49Smrg
600032001f49Smrg    test -n "$prev" && \
600132001f49Smrg      func_fatal_help "the \`$prevarg' option requires an argument"
600232001f49Smrg
600332001f49Smrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
600432001f49Smrg      eval arg=\"$export_dynamic_flag_spec\"
600532001f49Smrg      func_append compile_command " $arg"
600632001f49Smrg      func_append finalize_command " $arg"
600732001f49Smrg    fi
600832001f49Smrg
600932001f49Smrg    oldlibs=
601032001f49Smrg    # calculate the name of the file, without its directory
601132001f49Smrg    func_basename "$output"
601232001f49Smrg    outputname="$func_basename_result"
601332001f49Smrg    libobjs_save="$libobjs"
601432001f49Smrg
601532001f49Smrg    if test -n "$shlibpath_var"; then
601632001f49Smrg      # get the directories listed in $shlibpath_var
601732001f49Smrg      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
601832001f49Smrg    else
601932001f49Smrg      shlib_search_path=
602032001f49Smrg    fi
602132001f49Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
602232001f49Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
602332001f49Smrg
602432001f49Smrg    func_dirname "$output" "/" ""
602532001f49Smrg    output_objdir="$func_dirname_result$objdir"
602632001f49Smrg    func_to_tool_file "$output_objdir/"
602732001f49Smrg    tool_output_objdir=$func_to_tool_file_result
602832001f49Smrg    # Create the object directory.
602932001f49Smrg    func_mkdir_p "$output_objdir"
603032001f49Smrg
603132001f49Smrg    # Determine the type of output
603232001f49Smrg    case $output in
603332001f49Smrg    "")
603432001f49Smrg      func_fatal_help "you must specify an output file"
603532001f49Smrg      ;;
603632001f49Smrg    *.$libext) linkmode=oldlib ;;
603732001f49Smrg    *.lo | *.$objext) linkmode=obj ;;
603832001f49Smrg    *.la) linkmode=lib ;;
603932001f49Smrg    *) linkmode=prog ;; # Anything else should be a program.
604032001f49Smrg    esac
604132001f49Smrg
604232001f49Smrg    specialdeplibs=
604332001f49Smrg
604432001f49Smrg    libs=
604532001f49Smrg    # Find all interdependent deplibs by searching for libraries
604632001f49Smrg    # that are linked more than once (e.g. -la -lb -la)
604732001f49Smrg    for deplib in $deplibs; do
604832001f49Smrg      if $opt_preserve_dup_deps ; then
604932001f49Smrg	case "$libs " in
605032001f49Smrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
605132001f49Smrg	esac
605232001f49Smrg      fi
605332001f49Smrg      func_append libs " $deplib"
605432001f49Smrg    done
605532001f49Smrg
605632001f49Smrg    if test "$linkmode" = lib; then
605732001f49Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
605832001f49Smrg
605932001f49Smrg      # Compute libraries that are listed more than once in $predeps
606032001f49Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
606132001f49Smrg      # not to be eliminated).
606232001f49Smrg      pre_post_deps=
606332001f49Smrg      if $opt_duplicate_compiler_generated_deps; then
606432001f49Smrg	for pre_post_dep in $predeps $postdeps; do
606532001f49Smrg	  case "$pre_post_deps " in
606632001f49Smrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
606732001f49Smrg	  esac
606832001f49Smrg	  func_append pre_post_deps " $pre_post_dep"
606932001f49Smrg	done
607032001f49Smrg      fi
607132001f49Smrg      pre_post_deps=
607232001f49Smrg    fi
607332001f49Smrg
607432001f49Smrg    deplibs=
607532001f49Smrg    newdependency_libs=
607632001f49Smrg    newlib_search_path=
607732001f49Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
607832001f49Smrg    notinst_deplibs= # not-installed libtool libraries
607932001f49Smrg    notinst_path= # paths that contain not-installed libtool libraries
608032001f49Smrg
608132001f49Smrg    case $linkmode in
608232001f49Smrg    lib)
608332001f49Smrg	passes="conv dlpreopen link"
608432001f49Smrg	for file in $dlfiles $dlprefiles; do
608532001f49Smrg	  case $file in
608632001f49Smrg	  *.la) ;;
608732001f49Smrg	  *)
608832001f49Smrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
608932001f49Smrg	    ;;
609032001f49Smrg	  esac
609132001f49Smrg	done
609232001f49Smrg	;;
609332001f49Smrg    prog)
609432001f49Smrg	compile_deplibs=
609532001f49Smrg	finalize_deplibs=
609632001f49Smrg	alldeplibs=no
609732001f49Smrg	newdlfiles=
609832001f49Smrg	newdlprefiles=
609932001f49Smrg	passes="conv scan dlopen dlpreopen link"
610032001f49Smrg	;;
610132001f49Smrg    *)  passes="conv"
610232001f49Smrg	;;
610332001f49Smrg    esac
610432001f49Smrg
610532001f49Smrg    for pass in $passes; do
610632001f49Smrg      # The preopen pass in lib mode reverses $deplibs; put it back here
610732001f49Smrg      # so that -L comes before libs that need it for instance...
610832001f49Smrg      if test "$linkmode,$pass" = "lib,link"; then
610932001f49Smrg	## FIXME: Find the place where the list is rebuilt in the wrong
611032001f49Smrg	##        order, and fix it there properly
611132001f49Smrg        tmp_deplibs=
611232001f49Smrg	for deplib in $deplibs; do
611332001f49Smrg	  tmp_deplibs="$deplib $tmp_deplibs"
611432001f49Smrg	done
611532001f49Smrg	deplibs="$tmp_deplibs"
611632001f49Smrg      fi
611732001f49Smrg
611832001f49Smrg      if test "$linkmode,$pass" = "lib,link" ||
611932001f49Smrg	 test "$linkmode,$pass" = "prog,scan"; then
612032001f49Smrg	libs="$deplibs"
612132001f49Smrg	deplibs=
612232001f49Smrg      fi
612332001f49Smrg      if test "$linkmode" = prog; then
612432001f49Smrg	case $pass in
612532001f49Smrg	dlopen) libs="$dlfiles" ;;
612632001f49Smrg	dlpreopen) libs="$dlprefiles" ;;
612732001f49Smrg	link)
612832001f49Smrg	  libs="$deplibs %DEPLIBS%"
612932001f49Smrg	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
613032001f49Smrg	  ;;
613132001f49Smrg	esac
613232001f49Smrg      fi
613332001f49Smrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
613432001f49Smrg	# Collect and forward deplibs of preopened libtool libs
613532001f49Smrg	for lib in $dlprefiles; do
613632001f49Smrg	  # Ignore non-libtool-libs
613732001f49Smrg	  dependency_libs=
613832001f49Smrg	  func_resolve_sysroot "$lib"
613932001f49Smrg	  case $lib in
614032001f49Smrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
614132001f49Smrg	  esac
614232001f49Smrg
614332001f49Smrg	  # Collect preopened libtool deplibs, except any this library
614432001f49Smrg	  # has declared as weak libs
614532001f49Smrg	  for deplib in $dependency_libs; do
614632001f49Smrg	    func_basename "$deplib"
614732001f49Smrg            deplib_base=$func_basename_result
614832001f49Smrg	    case " $weak_libs " in
614932001f49Smrg	    *" $deplib_base "*) ;;
615032001f49Smrg	    *) func_append deplibs " $deplib" ;;
615132001f49Smrg	    esac
615232001f49Smrg	  done
615332001f49Smrg	done
615432001f49Smrg	libs="$dlprefiles"
615532001f49Smrg      fi
615632001f49Smrg      if test "$pass" = dlopen; then
615732001f49Smrg	# Collect dlpreopened libraries
615832001f49Smrg	save_deplibs="$deplibs"
615932001f49Smrg	deplibs=
616032001f49Smrg      fi
616132001f49Smrg
616232001f49Smrg      for deplib in $libs; do
616332001f49Smrg	lib=
616432001f49Smrg	found=no
616532001f49Smrg	case $deplib in
616632001f49Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
616732001f49Smrg        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
616832001f49Smrg	  if test "$linkmode,$pass" = "prog,link"; then
616932001f49Smrg	    compile_deplibs="$deplib $compile_deplibs"
617032001f49Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
617132001f49Smrg	  else
617232001f49Smrg	    func_append compiler_flags " $deplib"
617332001f49Smrg	    if test "$linkmode" = lib ; then
617432001f49Smrg		case "$new_inherited_linker_flags " in
617532001f49Smrg		    *" $deplib "*) ;;
617632001f49Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
617732001f49Smrg		esac
617832001f49Smrg	    fi
617932001f49Smrg	  fi
618032001f49Smrg	  continue
618132001f49Smrg	  ;;
618232001f49Smrg	-l*)
618332001f49Smrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
618432001f49Smrg	    func_warning "\`-l' is ignored for archives/objects"
618532001f49Smrg	    continue
618632001f49Smrg	  fi
618732001f49Smrg	  func_stripname '-l' '' "$deplib"
618832001f49Smrg	  name=$func_stripname_result
618932001f49Smrg	  if test "$linkmode" = lib; then
619032001f49Smrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
619132001f49Smrg	  else
619232001f49Smrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
619332001f49Smrg	  fi
619432001f49Smrg	  for searchdir in $searchdirs; do
619532001f49Smrg	    for search_ext in .la $std_shrext .so .a; do
619632001f49Smrg	      # Search the libtool library
619732001f49Smrg	      lib="$searchdir/lib${name}${search_ext}"
619832001f49Smrg	      if test -f "$lib"; then
619932001f49Smrg		if test "$search_ext" = ".la"; then
620032001f49Smrg		  found=yes
620132001f49Smrg		else
620232001f49Smrg		  found=no
620332001f49Smrg		fi
620432001f49Smrg		break 2
620532001f49Smrg	      fi
620632001f49Smrg	    done
620732001f49Smrg	  done
620832001f49Smrg	  if test "$found" != yes; then
620932001f49Smrg	    # deplib doesn't seem to be a libtool library
621032001f49Smrg	    if test "$linkmode,$pass" = "prog,link"; then
621132001f49Smrg	      compile_deplibs="$deplib $compile_deplibs"
621232001f49Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
621332001f49Smrg	    else
621432001f49Smrg	      deplibs="$deplib $deplibs"
621532001f49Smrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
621632001f49Smrg	    fi
621732001f49Smrg	    continue
621832001f49Smrg	  else # deplib is a libtool library
621932001f49Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
622032001f49Smrg	    # We need to do some special things here, and not later.
622132001f49Smrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
622232001f49Smrg	      case " $predeps $postdeps " in
622332001f49Smrg	      *" $deplib "*)
622432001f49Smrg		if func_lalib_p "$lib"; then
622532001f49Smrg		  library_names=
622632001f49Smrg		  old_library=
622732001f49Smrg		  func_source "$lib"
622832001f49Smrg		  for l in $old_library $library_names; do
622932001f49Smrg		    ll="$l"
623032001f49Smrg		  done
623132001f49Smrg		  if test "X$ll" = "X$old_library" ; then # only static version available
623232001f49Smrg		    found=no
623332001f49Smrg		    func_dirname "$lib" "" "."
623432001f49Smrg		    ladir="$func_dirname_result"
623532001f49Smrg		    lib=$ladir/$old_library
623632001f49Smrg		    if test "$linkmode,$pass" = "prog,link"; then
623732001f49Smrg		      compile_deplibs="$deplib $compile_deplibs"
623832001f49Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
623932001f49Smrg		    else
624032001f49Smrg		      deplibs="$deplib $deplibs"
624132001f49Smrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
624232001f49Smrg		    fi
624332001f49Smrg		    continue
624432001f49Smrg		  fi
624532001f49Smrg		fi
624632001f49Smrg		;;
624732001f49Smrg	      *) ;;
624832001f49Smrg	      esac
624932001f49Smrg	    fi
625032001f49Smrg	  fi
625132001f49Smrg	  ;; # -l
625232001f49Smrg	*.ltframework)
625332001f49Smrg	  if test "$linkmode,$pass" = "prog,link"; then
625432001f49Smrg	    compile_deplibs="$deplib $compile_deplibs"
625532001f49Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
625632001f49Smrg	  else
625732001f49Smrg	    deplibs="$deplib $deplibs"
625832001f49Smrg	    if test "$linkmode" = lib ; then
625932001f49Smrg		case "$new_inherited_linker_flags " in
626032001f49Smrg		    *" $deplib "*) ;;
626132001f49Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
626232001f49Smrg		esac
626332001f49Smrg	    fi
626432001f49Smrg	  fi
626532001f49Smrg	  continue
626632001f49Smrg	  ;;
626732001f49Smrg	-L*)
626832001f49Smrg	  case $linkmode in
626932001f49Smrg	  lib)
627032001f49Smrg	    deplibs="$deplib $deplibs"
627132001f49Smrg	    test "$pass" = conv && continue
627232001f49Smrg	    newdependency_libs="$deplib $newdependency_libs"
627332001f49Smrg	    func_stripname '-L' '' "$deplib"
627432001f49Smrg	    func_resolve_sysroot "$func_stripname_result"
627532001f49Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
627632001f49Smrg	    ;;
627732001f49Smrg	  prog)
627832001f49Smrg	    if test "$pass" = conv; then
627932001f49Smrg	      deplibs="$deplib $deplibs"
628032001f49Smrg	      continue
628132001f49Smrg	    fi
628232001f49Smrg	    if test "$pass" = scan; then
628332001f49Smrg	      deplibs="$deplib $deplibs"
628432001f49Smrg	    else
628532001f49Smrg	      compile_deplibs="$deplib $compile_deplibs"
628632001f49Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
628732001f49Smrg	    fi
628832001f49Smrg	    func_stripname '-L' '' "$deplib"
628932001f49Smrg	    func_resolve_sysroot "$func_stripname_result"
629032001f49Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
629132001f49Smrg	    ;;
629232001f49Smrg	  *)
629332001f49Smrg	    func_warning "\`-L' is ignored for archives/objects"
629432001f49Smrg	    ;;
629532001f49Smrg	  esac # linkmode
629632001f49Smrg	  continue
629732001f49Smrg	  ;; # -L
629832001f49Smrg	-R*)
629932001f49Smrg	  if test "$pass" = link; then
630032001f49Smrg	    func_stripname '-R' '' "$deplib"
630132001f49Smrg	    func_resolve_sysroot "$func_stripname_result"
630232001f49Smrg	    dir=$func_resolve_sysroot_result
630332001f49Smrg	    # Make sure the xrpath contains only unique directories.
630432001f49Smrg	    case "$xrpath " in
630532001f49Smrg	    *" $dir "*) ;;
630632001f49Smrg	    *) func_append xrpath " $dir" ;;
630732001f49Smrg	    esac
630832001f49Smrg	  fi
630932001f49Smrg	  deplibs="$deplib $deplibs"
631032001f49Smrg	  continue
631132001f49Smrg	  ;;
631232001f49Smrg	*.la)
631332001f49Smrg	  func_resolve_sysroot "$deplib"
631432001f49Smrg	  lib=$func_resolve_sysroot_result
631532001f49Smrg	  ;;
631632001f49Smrg	*.$libext)
631732001f49Smrg	  if test "$pass" = conv; then
631832001f49Smrg	    deplibs="$deplib $deplibs"
631932001f49Smrg	    continue
632032001f49Smrg	  fi
632132001f49Smrg	  case $linkmode in
632232001f49Smrg	  lib)
632332001f49Smrg	    # Linking convenience modules into shared libraries is allowed,
632432001f49Smrg	    # but linking other static libraries is non-portable.
632532001f49Smrg	    case " $dlpreconveniencelibs " in
632632001f49Smrg	    *" $deplib "*) ;;
632732001f49Smrg	    *)
632832001f49Smrg	      valid_a_lib=no
632932001f49Smrg	      case $deplibs_check_method in
633032001f49Smrg		match_pattern*)
633132001f49Smrg		  set dummy $deplibs_check_method; shift
633232001f49Smrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
633332001f49Smrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
633432001f49Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
633532001f49Smrg		    valid_a_lib=yes
633632001f49Smrg		  fi
633732001f49Smrg		;;
633832001f49Smrg		pass_all)
633932001f49Smrg		  valid_a_lib=yes
634032001f49Smrg		;;
634132001f49Smrg	      esac
634232001f49Smrg	      if test "$valid_a_lib" != yes; then
634332001f49Smrg		echo
634432001f49Smrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
634532001f49Smrg		echo "*** I have the capability to make that library automatically link in when"
634632001f49Smrg		echo "*** you link to this library.  But I can only do this if you have a"
634732001f49Smrg		echo "*** shared version of the library, which you do not appear to have"
634832001f49Smrg		echo "*** because the file extensions .$libext of this argument makes me believe"
634932001f49Smrg		echo "*** that it is just a static archive that I should not use here."
635032001f49Smrg	      else
635132001f49Smrg		echo
635232001f49Smrg		$ECHO "*** Warning: Linking the shared library $output against the"
635332001f49Smrg		$ECHO "*** static library $deplib is not portable!"
635432001f49Smrg		deplibs="$deplib $deplibs"
635532001f49Smrg	      fi
635632001f49Smrg	      ;;
635732001f49Smrg	    esac
635832001f49Smrg	    continue
635932001f49Smrg	    ;;
636032001f49Smrg	  prog)
636132001f49Smrg	    if test "$pass" != link; then
636232001f49Smrg	      deplibs="$deplib $deplibs"
636332001f49Smrg	    else
636432001f49Smrg	      compile_deplibs="$deplib $compile_deplibs"
636532001f49Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
636632001f49Smrg	    fi
636732001f49Smrg	    continue
636832001f49Smrg	    ;;
636932001f49Smrg	  esac # linkmode
637032001f49Smrg	  ;; # *.$libext
637132001f49Smrg	*.lo | *.$objext)
637232001f49Smrg	  if test "$pass" = conv; then
637332001f49Smrg	    deplibs="$deplib $deplibs"
637432001f49Smrg	  elif test "$linkmode" = prog; then
637532001f49Smrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
637632001f49Smrg	      # If there is no dlopen support or we're linking statically,
637732001f49Smrg	      # we need to preload.
637832001f49Smrg	      func_append newdlprefiles " $deplib"
637932001f49Smrg	      compile_deplibs="$deplib $compile_deplibs"
638032001f49Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
638132001f49Smrg	    else
638232001f49Smrg	      func_append newdlfiles " $deplib"
638332001f49Smrg	    fi
638432001f49Smrg	  fi
638532001f49Smrg	  continue
638632001f49Smrg	  ;;
638732001f49Smrg	%DEPLIBS%)
638832001f49Smrg	  alldeplibs=yes
638932001f49Smrg	  continue
639032001f49Smrg	  ;;
639132001f49Smrg	esac # case $deplib
639232001f49Smrg
639332001f49Smrg	if test "$found" = yes || test -f "$lib"; then :
639432001f49Smrg	else
639532001f49Smrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
639632001f49Smrg	fi
639732001f49Smrg
639832001f49Smrg	# Check to see that this really is a libtool archive.
639932001f49Smrg	func_lalib_unsafe_p "$lib" \
640032001f49Smrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
640132001f49Smrg
640232001f49Smrg	func_dirname "$lib" "" "."
640332001f49Smrg	ladir="$func_dirname_result"
640432001f49Smrg
640532001f49Smrg	dlname=
640632001f49Smrg	dlopen=
640732001f49Smrg	dlpreopen=
640832001f49Smrg	libdir=
640932001f49Smrg	library_names=
641032001f49Smrg	old_library=
641132001f49Smrg	inherited_linker_flags=
641232001f49Smrg	# If the library was installed with an old release of libtool,
641332001f49Smrg	# it will not redefine variables installed, or shouldnotlink
641432001f49Smrg	installed=yes
641532001f49Smrg	shouldnotlink=no
641632001f49Smrg	avoidtemprpath=
641732001f49Smrg
641832001f49Smrg
641932001f49Smrg	# Read the .la file
642032001f49Smrg	func_source "$lib"
642132001f49Smrg
642232001f49Smrg	# Convert "-framework foo" to "foo.ltframework"
642332001f49Smrg	if test -n "$inherited_linker_flags"; then
642432001f49Smrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
642532001f49Smrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
642632001f49Smrg	    case " $new_inherited_linker_flags " in
642732001f49Smrg	      *" $tmp_inherited_linker_flag "*) ;;
642832001f49Smrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
642932001f49Smrg	    esac
643032001f49Smrg	  done
643132001f49Smrg	fi
643232001f49Smrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
643332001f49Smrg	if test "$linkmode,$pass" = "lib,link" ||
643432001f49Smrg	   test "$linkmode,$pass" = "prog,scan" ||
643532001f49Smrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
643632001f49Smrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
643732001f49Smrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
643832001f49Smrg	fi
643932001f49Smrg
644032001f49Smrg	if test "$pass" = conv; then
644132001f49Smrg	  # Only check for convenience libraries
644232001f49Smrg	  deplibs="$lib $deplibs"
644332001f49Smrg	  if test -z "$libdir"; then
644432001f49Smrg	    if test -z "$old_library"; then
644532001f49Smrg	      func_fatal_error "cannot find name of link library for \`$lib'"
644632001f49Smrg	    fi
644732001f49Smrg	    # It is a libtool convenience library, so add in its objects.
644832001f49Smrg	    func_append convenience " $ladir/$objdir/$old_library"
644932001f49Smrg	    func_append old_convenience " $ladir/$objdir/$old_library"
645032001f49Smrg	    tmp_libs=
645132001f49Smrg	    for deplib in $dependency_libs; do
645232001f49Smrg	      deplibs="$deplib $deplibs"
645332001f49Smrg	      if $opt_preserve_dup_deps ; then
645432001f49Smrg		case "$tmp_libs " in
645532001f49Smrg		*" $deplib "*) func_append specialdeplibs " $deplib" ;;
645632001f49Smrg		esac
645732001f49Smrg	      fi
645832001f49Smrg	      func_append tmp_libs " $deplib"
645932001f49Smrg	    done
646032001f49Smrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
646132001f49Smrg	    func_fatal_error "\`$lib' is not a convenience library"
646232001f49Smrg	  fi
646332001f49Smrg	  continue
646432001f49Smrg	fi # $pass = conv
646532001f49Smrg
646632001f49Smrg
646732001f49Smrg	# Get the name of the library we link against.
646832001f49Smrg	linklib=
646932001f49Smrg	if test -n "$old_library" &&
647032001f49Smrg	   { test "$prefer_static_libs" = yes ||
647132001f49Smrg	     test "$prefer_static_libs,$installed" = "built,no"; }; then
647232001f49Smrg	  linklib=$old_library
647332001f49Smrg	else
647432001f49Smrg	  for l in $old_library $library_names; do
647532001f49Smrg	    linklib="$l"
647632001f49Smrg	  done
647732001f49Smrg	fi
647832001f49Smrg	if test -z "$linklib"; then
647932001f49Smrg	  func_fatal_error "cannot find name of link library for \`$lib'"
648032001f49Smrg	fi
648132001f49Smrg
648232001f49Smrg	# This library was specified with -dlopen.
648332001f49Smrg	if test "$pass" = dlopen; then
648432001f49Smrg	  if test -z "$libdir"; then
648532001f49Smrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
648632001f49Smrg	  fi
648732001f49Smrg	  if test -z "$dlname" ||
648832001f49Smrg	     test "$dlopen_support" != yes ||
648932001f49Smrg	     test "$build_libtool_libs" = no; then
649032001f49Smrg	    # If there is no dlname, no dlopen support or we're linking
649132001f49Smrg	    # statically, we need to preload.  We also need to preload any
649232001f49Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
649332001f49Smrg	    # bomb out in the load deplibs phase.
649432001f49Smrg	    func_append dlprefiles " $lib $dependency_libs"
649532001f49Smrg	  else
649632001f49Smrg	    func_append newdlfiles " $lib"
649732001f49Smrg	  fi
649832001f49Smrg	  continue
649932001f49Smrg	fi # $pass = dlopen
650032001f49Smrg
650132001f49Smrg	# We need an absolute path.
650232001f49Smrg	case $ladir in
650332001f49Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
650432001f49Smrg	*)
650532001f49Smrg	  abs_ladir=`cd "$ladir" && pwd`
650632001f49Smrg	  if test -z "$abs_ladir"; then
650732001f49Smrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
650832001f49Smrg	    func_warning "passing it literally to the linker, although it might fail"
650932001f49Smrg	    abs_ladir="$ladir"
651032001f49Smrg	  fi
651132001f49Smrg	  ;;
651232001f49Smrg	esac
651332001f49Smrg	func_basename "$lib"
651432001f49Smrg	laname="$func_basename_result"
651532001f49Smrg
651632001f49Smrg	# Find the relevant object directory and library name.
651732001f49Smrg	if test "X$installed" = Xyes; then
651832001f49Smrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
651932001f49Smrg	    func_warning "library \`$lib' was moved."
652032001f49Smrg	    dir="$ladir"
652132001f49Smrg	    absdir="$abs_ladir"
652232001f49Smrg	    libdir="$abs_ladir"
652332001f49Smrg	  else
652432001f49Smrg	    dir="$lt_sysroot$libdir"
652532001f49Smrg	    absdir="$lt_sysroot$libdir"
652632001f49Smrg	  fi
652732001f49Smrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
652832001f49Smrg	else
652932001f49Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
653032001f49Smrg	    dir="$ladir"
653132001f49Smrg	    absdir="$abs_ladir"
653232001f49Smrg	    # Remove this search path later
653332001f49Smrg	    func_append notinst_path " $abs_ladir"
653432001f49Smrg	  else
653532001f49Smrg	    dir="$ladir/$objdir"
653632001f49Smrg	    absdir="$abs_ladir/$objdir"
653732001f49Smrg	    # Remove this search path later
653832001f49Smrg	    func_append notinst_path " $abs_ladir"
653932001f49Smrg	  fi
654032001f49Smrg	fi # $installed = yes
654132001f49Smrg	func_stripname 'lib' '.la' "$laname"
654232001f49Smrg	name=$func_stripname_result
654332001f49Smrg
654432001f49Smrg	# This library was specified with -dlpreopen.
654532001f49Smrg	if test "$pass" = dlpreopen; then
654632001f49Smrg	  if test -z "$libdir" && test "$linkmode" = prog; then
654732001f49Smrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
654832001f49Smrg	  fi
654932001f49Smrg	  case "$host" in
655032001f49Smrg	    # special handling for platforms with PE-DLLs.
655132001f49Smrg	    *cygwin* | *mingw* | *cegcc* )
655232001f49Smrg	      # Linker will automatically link against shared library if both
655332001f49Smrg	      # static and shared are present.  Therefore, ensure we extract
655432001f49Smrg	      # symbols from the import library if a shared library is present
655532001f49Smrg	      # (otherwise, the dlopen module name will be incorrect).  We do
655632001f49Smrg	      # this by putting the import library name into $newdlprefiles.
655732001f49Smrg	      # We recover the dlopen module name by 'saving' the la file
655832001f49Smrg	      # name in a special purpose variable, and (later) extracting the
655932001f49Smrg	      # dlname from the la file.
656032001f49Smrg	      if test -n "$dlname"; then
656132001f49Smrg	        func_tr_sh "$dir/$linklib"
656232001f49Smrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
656332001f49Smrg	        func_append newdlprefiles " $dir/$linklib"
656432001f49Smrg	      else
656532001f49Smrg	        func_append newdlprefiles " $dir/$old_library"
656632001f49Smrg	        # Keep a list of preopened convenience libraries to check
656732001f49Smrg	        # that they are being used correctly in the link pass.
656832001f49Smrg	        test -z "$libdir" && \
656932001f49Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
657032001f49Smrg	      fi
657132001f49Smrg	    ;;
657232001f49Smrg	    * )
657332001f49Smrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
657432001f49Smrg	      # are required to link).
657532001f49Smrg	      if test -n "$old_library"; then
657632001f49Smrg	        func_append newdlprefiles " $dir/$old_library"
657732001f49Smrg	        # Keep a list of preopened convenience libraries to check
657832001f49Smrg	        # that they are being used correctly in the link pass.
657932001f49Smrg	        test -z "$libdir" && \
658032001f49Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
658132001f49Smrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
658232001f49Smrg	      elif test -n "$dlname"; then
658332001f49Smrg	        func_append newdlprefiles " $dir/$dlname"
658432001f49Smrg	      else
658532001f49Smrg	        func_append newdlprefiles " $dir/$linklib"
658632001f49Smrg	      fi
658732001f49Smrg	    ;;
658832001f49Smrg	  esac
658932001f49Smrg	fi # $pass = dlpreopen
659032001f49Smrg
659132001f49Smrg	if test -z "$libdir"; then
659232001f49Smrg	  # Link the convenience library
659332001f49Smrg	  if test "$linkmode" = lib; then
659432001f49Smrg	    deplibs="$dir/$old_library $deplibs"
659532001f49Smrg	  elif test "$linkmode,$pass" = "prog,link"; then
659632001f49Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
659732001f49Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
659832001f49Smrg	  else
659932001f49Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
660032001f49Smrg	  fi
660132001f49Smrg	  continue
660232001f49Smrg	fi
660332001f49Smrg
660432001f49Smrg
660532001f49Smrg	if test "$linkmode" = prog && test "$pass" != link; then
660632001f49Smrg	  func_append newlib_search_path " $ladir"
660732001f49Smrg	  deplibs="$lib $deplibs"
660832001f49Smrg
660932001f49Smrg	  linkalldeplibs=no
661032001f49Smrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
661132001f49Smrg	     test "$build_libtool_libs" = no; then
661232001f49Smrg	    linkalldeplibs=yes
661332001f49Smrg	  fi
661432001f49Smrg
661532001f49Smrg	  tmp_libs=
661632001f49Smrg	  for deplib in $dependency_libs; do
661732001f49Smrg	    case $deplib in
661832001f49Smrg	    -L*) func_stripname '-L' '' "$deplib"
661932001f49Smrg	         func_resolve_sysroot "$func_stripname_result"
662032001f49Smrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
662132001f49Smrg		 ;;
662232001f49Smrg	    esac
662332001f49Smrg	    # Need to link against all dependency_libs?
662432001f49Smrg	    if test "$linkalldeplibs" = yes; then
662532001f49Smrg	      deplibs="$deplib $deplibs"
662632001f49Smrg	    else
662732001f49Smrg	      # Need to hardcode shared library paths
662832001f49Smrg	      # or/and link against static libraries
662932001f49Smrg	      newdependency_libs="$deplib $newdependency_libs"
663032001f49Smrg	    fi
663132001f49Smrg	    if $opt_preserve_dup_deps ; then
663232001f49Smrg	      case "$tmp_libs " in
663332001f49Smrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
663432001f49Smrg	      esac
663532001f49Smrg	    fi
663632001f49Smrg	    func_append tmp_libs " $deplib"
663732001f49Smrg	  done # for deplib
663832001f49Smrg	  continue
663932001f49Smrg	fi # $linkmode = prog...
664032001f49Smrg
664132001f49Smrg	if test "$linkmode,$pass" = "prog,link"; then
664232001f49Smrg	  if test -n "$library_names" &&
664332001f49Smrg	     { { test "$prefer_static_libs" = no ||
664432001f49Smrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
664532001f49Smrg	       test -z "$old_library"; }; then
664632001f49Smrg	    # We need to hardcode the library path
664732001f49Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
664832001f49Smrg	      # Make sure the rpath contains only unique directories.
664932001f49Smrg	      case "$temp_rpath:" in
665032001f49Smrg	      *"$absdir:"*) ;;
665132001f49Smrg	      *) func_append temp_rpath "$absdir:" ;;
665232001f49Smrg	      esac
665332001f49Smrg	    fi
665432001f49Smrg
665532001f49Smrg	    # Hardcode the library path.
665632001f49Smrg	    # Skip directories that are in the system default run-time
665732001f49Smrg	    # search path.
665832001f49Smrg	    case " $sys_lib_dlsearch_path " in
665932001f49Smrg	    *" $absdir "*) ;;
666032001f49Smrg	    *)
666132001f49Smrg	      case "$compile_rpath " in
666232001f49Smrg	      *" $absdir "*) ;;
666332001f49Smrg	      *) func_append compile_rpath " $absdir" ;;
666432001f49Smrg	      esac
666532001f49Smrg	      ;;
666632001f49Smrg	    esac
666732001f49Smrg	    case " $sys_lib_dlsearch_path " in
666832001f49Smrg	    *" $libdir "*) ;;
666932001f49Smrg	    *)
667032001f49Smrg	      case "$finalize_rpath " in
667132001f49Smrg	      *" $libdir "*) ;;
667232001f49Smrg	      *) func_append finalize_rpath " $libdir" ;;
667332001f49Smrg	      esac
667432001f49Smrg	      ;;
667532001f49Smrg	    esac
667632001f49Smrg	  fi # $linkmode,$pass = prog,link...
667732001f49Smrg
667832001f49Smrg	  if test "$alldeplibs" = yes &&
667932001f49Smrg	     { test "$deplibs_check_method" = pass_all ||
668032001f49Smrg	       { test "$build_libtool_libs" = yes &&
668132001f49Smrg		 test -n "$library_names"; }; }; then
668232001f49Smrg	    # We only need to search for static libraries
668332001f49Smrg	    continue
668432001f49Smrg	  fi
668532001f49Smrg	fi
668632001f49Smrg
668732001f49Smrg	link_static=no # Whether the deplib will be linked statically
668832001f49Smrg	use_static_libs=$prefer_static_libs
668932001f49Smrg	if test "$use_static_libs" = built && test "$installed" = yes; then
669032001f49Smrg	  use_static_libs=no
669132001f49Smrg	fi
669232001f49Smrg	if test -n "$library_names" &&
669332001f49Smrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
669432001f49Smrg	  case $host in
669532001f49Smrg	  *cygwin* | *mingw* | *cegcc*)
669632001f49Smrg	      # No point in relinking DLLs because paths are not encoded
669732001f49Smrg	      func_append notinst_deplibs " $lib"
669832001f49Smrg	      need_relink=no
669932001f49Smrg	    ;;
670032001f49Smrg	  *)
670132001f49Smrg	    if test "$installed" = no; then
670232001f49Smrg	      func_append notinst_deplibs " $lib"
670332001f49Smrg	      need_relink=yes
670432001f49Smrg	    fi
670532001f49Smrg	    ;;
670632001f49Smrg	  esac
670732001f49Smrg	  # This is a shared library
670832001f49Smrg
670932001f49Smrg	  # Warn about portability, can't link against -module's on some
671032001f49Smrg	  # systems (darwin).  Don't bleat about dlopened modules though!
671132001f49Smrg	  dlopenmodule=""
671232001f49Smrg	  for dlpremoduletest in $dlprefiles; do
671332001f49Smrg	    if test "X$dlpremoduletest" = "X$lib"; then
671432001f49Smrg	      dlopenmodule="$dlpremoduletest"
671532001f49Smrg	      break
671632001f49Smrg	    fi
671732001f49Smrg	  done
671832001f49Smrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
671932001f49Smrg	    echo
672032001f49Smrg	    if test "$linkmode" = prog; then
672132001f49Smrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
672232001f49Smrg	    else
672332001f49Smrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
672432001f49Smrg	    fi
672532001f49Smrg	    $ECHO "*** $linklib is not portable!"
672632001f49Smrg	  fi
672732001f49Smrg	  if test "$linkmode" = lib &&
672832001f49Smrg	     test "$hardcode_into_libs" = yes; then
672932001f49Smrg	    # Hardcode the library path.
673032001f49Smrg	    # Skip directories that are in the system default run-time
673132001f49Smrg	    # search path.
673232001f49Smrg	    case " $sys_lib_dlsearch_path " in
673332001f49Smrg	    *" $absdir "*) ;;
673432001f49Smrg	    *)
673532001f49Smrg	      case "$compile_rpath " in
673632001f49Smrg	      *" $absdir "*) ;;
673732001f49Smrg	      *) func_append compile_rpath " $absdir" ;;
673832001f49Smrg	      esac
673932001f49Smrg	      ;;
674032001f49Smrg	    esac
674132001f49Smrg	    case " $sys_lib_dlsearch_path " in
674232001f49Smrg	    *" $libdir "*) ;;
674332001f49Smrg	    *)
674432001f49Smrg	      case "$finalize_rpath " in
674532001f49Smrg	      *" $libdir "*) ;;
674632001f49Smrg	      *) func_append finalize_rpath " $libdir" ;;
674732001f49Smrg	      esac
674832001f49Smrg	      ;;
674932001f49Smrg	    esac
675032001f49Smrg	  fi
675132001f49Smrg
675232001f49Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
675332001f49Smrg	    # figure out the soname
675432001f49Smrg	    set dummy $library_names
675532001f49Smrg	    shift
675632001f49Smrg	    realname="$1"
675732001f49Smrg	    shift
675832001f49Smrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
675932001f49Smrg	    # use dlname if we got it. it's perfectly good, no?
676032001f49Smrg	    if test -n "$dlname"; then
676132001f49Smrg	      soname="$dlname"
676232001f49Smrg	    elif test -n "$soname_spec"; then
676332001f49Smrg	      # bleh windows
676432001f49Smrg	      case $host in
676532001f49Smrg	      *cygwin* | mingw* | *cegcc*)
676632001f49Smrg	        func_arith $current - $age
676732001f49Smrg		major=$func_arith_result
676832001f49Smrg		versuffix="-$major"
676932001f49Smrg		;;
677032001f49Smrg	      esac
677132001f49Smrg	      eval soname=\"$soname_spec\"
677232001f49Smrg	    else
677332001f49Smrg	      soname="$realname"
677432001f49Smrg	    fi
677532001f49Smrg
677632001f49Smrg	    # Make a new name for the extract_expsyms_cmds to use
677732001f49Smrg	    soroot="$soname"
677832001f49Smrg	    func_basename "$soroot"
677932001f49Smrg	    soname="$func_basename_result"
678032001f49Smrg	    func_stripname 'lib' '.dll' "$soname"
678132001f49Smrg	    newlib=libimp-$func_stripname_result.a
678232001f49Smrg
678332001f49Smrg	    # If the library has no export list, then create one now
678432001f49Smrg	    if test -f "$output_objdir/$soname-def"; then :
678532001f49Smrg	    else
678632001f49Smrg	      func_verbose "extracting exported symbol list from \`$soname'"
678732001f49Smrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
678832001f49Smrg	    fi
678932001f49Smrg
679032001f49Smrg	    # Create $newlib
679132001f49Smrg	    if test -f "$output_objdir/$newlib"; then :; else
679232001f49Smrg	      func_verbose "generating import library for \`$soname'"
679332001f49Smrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
679432001f49Smrg	    fi
679532001f49Smrg	    # make sure the library variables are pointing to the new library
679632001f49Smrg	    dir=$output_objdir
679732001f49Smrg	    linklib=$newlib
679832001f49Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
679932001f49Smrg
680032001f49Smrg	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
680132001f49Smrg	    add_shlibpath=
680232001f49Smrg	    add_dir=
680332001f49Smrg	    add=
680432001f49Smrg	    lib_linked=yes
680532001f49Smrg	    case $hardcode_action in
680632001f49Smrg	    immediate | unsupported)
680732001f49Smrg	      if test "$hardcode_direct" = no; then
680832001f49Smrg		add="$dir/$linklib"
680932001f49Smrg		case $host in
681032001f49Smrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
681132001f49Smrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
681232001f49Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
681332001f49Smrg		    *-*-unixware7*) add_dir="-L$dir" ;;
681432001f49Smrg		  *-*-darwin* )
681532001f49Smrg		    # if the lib is a (non-dlopened) module then we can not
681632001f49Smrg		    # link against it, someone is ignoring the earlier warnings
681732001f49Smrg		    if /usr/bin/file -L $add 2> /dev/null |
681832001f49Smrg			 $GREP ": [^:]* bundle" >/dev/null ; then
681932001f49Smrg		      if test "X$dlopenmodule" != "X$lib"; then
682032001f49Smrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
682132001f49Smrg			if test -z "$old_library" ; then
682232001f49Smrg			  echo
682332001f49Smrg			  echo "*** And there doesn't seem to be a static archive available"
682432001f49Smrg			  echo "*** The link will probably fail, sorry"
682532001f49Smrg			else
682632001f49Smrg			  add="$dir/$old_library"
682732001f49Smrg			fi
682832001f49Smrg		      elif test -n "$old_library"; then
682932001f49Smrg			add="$dir/$old_library"
683032001f49Smrg		      fi
683132001f49Smrg		    fi
683232001f49Smrg		esac
683332001f49Smrg	      elif test "$hardcode_minus_L" = no; then
683432001f49Smrg		case $host in
683532001f49Smrg		*-*-sunos*) add_shlibpath="$dir" ;;
683632001f49Smrg		esac
683732001f49Smrg		add_dir="-L$dir"
683832001f49Smrg		add="-l$name"
683932001f49Smrg	      elif test "$hardcode_shlibpath_var" = no; then
684032001f49Smrg		add_shlibpath="$dir"
684132001f49Smrg		add="-l$name"
684232001f49Smrg	      else
684332001f49Smrg		lib_linked=no
684432001f49Smrg	      fi
684532001f49Smrg	      ;;
684632001f49Smrg	    relink)
684732001f49Smrg	      if test "$hardcode_direct" = yes &&
684832001f49Smrg	         test "$hardcode_direct_absolute" = no; then
684932001f49Smrg		add="$dir/$linklib"
685032001f49Smrg	      elif test "$hardcode_minus_L" = yes; then
685132001f49Smrg		add_dir="-L$absdir"
685232001f49Smrg		# Try looking first in the location we're being installed to.
685332001f49Smrg		if test -n "$inst_prefix_dir"; then
685432001f49Smrg		  case $libdir in
685532001f49Smrg		    [\\/]*)
685632001f49Smrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
685732001f49Smrg		      ;;
685832001f49Smrg		  esac
685932001f49Smrg		fi
686032001f49Smrg		add="-l$name"
686132001f49Smrg	      elif test "$hardcode_shlibpath_var" = yes; then
686232001f49Smrg		add_shlibpath="$dir"
686332001f49Smrg		add="-l$name"
686432001f49Smrg	      else
686532001f49Smrg		lib_linked=no
686632001f49Smrg	      fi
686732001f49Smrg	      ;;
686832001f49Smrg	    *) lib_linked=no ;;
686932001f49Smrg	    esac
687032001f49Smrg
687132001f49Smrg	    if test "$lib_linked" != yes; then
687232001f49Smrg	      func_fatal_configuration "unsupported hardcode properties"
687332001f49Smrg	    fi
687432001f49Smrg
687532001f49Smrg	    if test -n "$add_shlibpath"; then
687632001f49Smrg	      case :$compile_shlibpath: in
687732001f49Smrg	      *":$add_shlibpath:"*) ;;
687832001f49Smrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
687932001f49Smrg	      esac
688032001f49Smrg	    fi
688132001f49Smrg	    if test "$linkmode" = prog; then
688232001f49Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
688332001f49Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
688432001f49Smrg	    else
688532001f49Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
688632001f49Smrg	      test -n "$add" && deplibs="$add $deplibs"
688732001f49Smrg	      if test "$hardcode_direct" != yes &&
688832001f49Smrg		 test "$hardcode_minus_L" != yes &&
688932001f49Smrg		 test "$hardcode_shlibpath_var" = yes; then
689032001f49Smrg		case :$finalize_shlibpath: in
689132001f49Smrg		*":$libdir:"*) ;;
689232001f49Smrg		*) func_append finalize_shlibpath "$libdir:" ;;
689332001f49Smrg		esac
689432001f49Smrg	      fi
689532001f49Smrg	    fi
689632001f49Smrg	  fi
689732001f49Smrg
689832001f49Smrg	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
689932001f49Smrg	    add_shlibpath=
690032001f49Smrg	    add_dir=
690132001f49Smrg	    add=
690232001f49Smrg	    # Finalize command for both is simple: just hardcode it.
690332001f49Smrg	    if test "$hardcode_direct" = yes &&
690432001f49Smrg	       test "$hardcode_direct_absolute" = no; then
690532001f49Smrg	      add="$libdir/$linklib"
690632001f49Smrg	    elif test "$hardcode_minus_L" = yes; then
690732001f49Smrg	      add_dir="-L$libdir"
690832001f49Smrg	      add="-l$name"
690932001f49Smrg	    elif test "$hardcode_shlibpath_var" = yes; then
691032001f49Smrg	      case :$finalize_shlibpath: in
691132001f49Smrg	      *":$libdir:"*) ;;
691232001f49Smrg	      *) func_append finalize_shlibpath "$libdir:" ;;
691332001f49Smrg	      esac
691432001f49Smrg	      add="-l$name"
691532001f49Smrg	    elif test "$hardcode_automatic" = yes; then
691632001f49Smrg	      if test -n "$inst_prefix_dir" &&
691732001f49Smrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
691832001f49Smrg		add="$inst_prefix_dir$libdir/$linklib"
691932001f49Smrg	      else
692032001f49Smrg		add="$libdir/$linklib"
692132001f49Smrg	      fi
692232001f49Smrg	    else
692332001f49Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
692432001f49Smrg	      add_dir="-L$libdir"
692532001f49Smrg	      # Try looking first in the location we're being installed to.
692632001f49Smrg	      if test -n "$inst_prefix_dir"; then
692732001f49Smrg		case $libdir in
692832001f49Smrg		  [\\/]*)
692932001f49Smrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
693032001f49Smrg		    ;;
693132001f49Smrg		esac
693232001f49Smrg	      fi
693332001f49Smrg	      add="-l$name"
693432001f49Smrg	    fi
693532001f49Smrg
693632001f49Smrg	    if test "$linkmode" = prog; then
693732001f49Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
693832001f49Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
693932001f49Smrg	    else
694032001f49Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
694132001f49Smrg	      test -n "$add" && deplibs="$add $deplibs"
694232001f49Smrg	    fi
694332001f49Smrg	  fi
694432001f49Smrg	elif test "$linkmode" = prog; then
694532001f49Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
694632001f49Smrg	  # is not unsupported.  This is valid on all known static and
694732001f49Smrg	  # shared platforms.
694832001f49Smrg	  if test "$hardcode_direct" != unsupported; then
694932001f49Smrg	    test -n "$old_library" && linklib="$old_library"
695032001f49Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
695132001f49Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
695232001f49Smrg	  else
695332001f49Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
695432001f49Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
695532001f49Smrg	  fi
695632001f49Smrg	elif test "$build_libtool_libs" = yes; then
695732001f49Smrg	  # Not a shared library
695832001f49Smrg	  if test "$deplibs_check_method" != pass_all; then
695932001f49Smrg	    # We're trying link a shared library against a static one
696032001f49Smrg	    # but the system doesn't support it.
696132001f49Smrg
696232001f49Smrg	    # Just print a warning and add the library to dependency_libs so
696332001f49Smrg	    # that the program can be linked against the static library.
696432001f49Smrg	    echo
696532001f49Smrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
696632001f49Smrg	    echo "*** I have the capability to make that library automatically link in when"
696732001f49Smrg	    echo "*** you link to this library.  But I can only do this if you have a"
696832001f49Smrg	    echo "*** shared version of the library, which you do not appear to have."
696932001f49Smrg	    if test "$module" = yes; then
697032001f49Smrg	      echo "*** But as you try to build a module library, libtool will still create "
697132001f49Smrg	      echo "*** a static module, that should work as long as the dlopening application"
697232001f49Smrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
697332001f49Smrg	      if test -z "$global_symbol_pipe"; then
697432001f49Smrg		echo
697532001f49Smrg		echo "*** However, this would only work if libtool was able to extract symbol"
697632001f49Smrg		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
697732001f49Smrg		echo "*** not find such a program.  So, this module is probably useless."
697832001f49Smrg		echo "*** \`nm' from GNU binutils and a full rebuild may help."
697932001f49Smrg	      fi
698032001f49Smrg	      if test "$build_old_libs" = no; then
698132001f49Smrg		build_libtool_libs=module
698232001f49Smrg		build_old_libs=yes
698332001f49Smrg	      else
698432001f49Smrg		build_libtool_libs=no
698532001f49Smrg	      fi
698632001f49Smrg	    fi
698732001f49Smrg	  else
698832001f49Smrg	    deplibs="$dir/$old_library $deplibs"
698932001f49Smrg	    link_static=yes
699032001f49Smrg	  fi
699132001f49Smrg	fi # link shared/static library?
699232001f49Smrg
699332001f49Smrg	if test "$linkmode" = lib; then
699432001f49Smrg	  if test -n "$dependency_libs" &&
699532001f49Smrg	     { test "$hardcode_into_libs" != yes ||
699632001f49Smrg	       test "$build_old_libs" = yes ||
699732001f49Smrg	       test "$link_static" = yes; }; then
699832001f49Smrg	    # Extract -R from dependency_libs
699932001f49Smrg	    temp_deplibs=
700032001f49Smrg	    for libdir in $dependency_libs; do
700132001f49Smrg	      case $libdir in
700232001f49Smrg	      -R*) func_stripname '-R' '' "$libdir"
700332001f49Smrg	           temp_xrpath=$func_stripname_result
700432001f49Smrg		   case " $xrpath " in
700532001f49Smrg		   *" $temp_xrpath "*) ;;
700632001f49Smrg		   *) func_append xrpath " $temp_xrpath";;
700732001f49Smrg		   esac;;
700832001f49Smrg	      *) func_append temp_deplibs " $libdir";;
700932001f49Smrg	      esac
701032001f49Smrg	    done
701132001f49Smrg	    dependency_libs="$temp_deplibs"
701232001f49Smrg	  fi
701332001f49Smrg
701432001f49Smrg	  func_append newlib_search_path " $absdir"
701532001f49Smrg	  # Link against this library
701632001f49Smrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
701732001f49Smrg	  # ... and its dependency_libs
701832001f49Smrg	  tmp_libs=
701932001f49Smrg	  for deplib in $dependency_libs; do
702032001f49Smrg	    newdependency_libs="$deplib $newdependency_libs"
702132001f49Smrg	    case $deplib in
702232001f49Smrg              -L*) func_stripname '-L' '' "$deplib"
702332001f49Smrg                   func_resolve_sysroot "$func_stripname_result";;
702432001f49Smrg              *) func_resolve_sysroot "$deplib" ;;
702532001f49Smrg            esac
702632001f49Smrg	    if $opt_preserve_dup_deps ; then
702732001f49Smrg	      case "$tmp_libs " in
702832001f49Smrg	      *" $func_resolve_sysroot_result "*)
702932001f49Smrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
703032001f49Smrg	      esac
703132001f49Smrg	    fi
703232001f49Smrg	    func_append tmp_libs " $func_resolve_sysroot_result"
703332001f49Smrg	  done
703432001f49Smrg
703532001f49Smrg	  if test "$link_all_deplibs" != no; then
703632001f49Smrg	    # Add the search paths of all dependency libraries
703732001f49Smrg	    for deplib in $dependency_libs; do
703832001f49Smrg	      path=
703932001f49Smrg	      case $deplib in
704032001f49Smrg	      -L*) path="$deplib" ;;
704132001f49Smrg	      *.la)
704232001f49Smrg	        func_resolve_sysroot "$deplib"
704332001f49Smrg	        deplib=$func_resolve_sysroot_result
704432001f49Smrg	        func_dirname "$deplib" "" "."
704532001f49Smrg		dir=$func_dirname_result
704632001f49Smrg		# We need an absolute path.
704732001f49Smrg		case $dir in
704832001f49Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
704932001f49Smrg		*)
705032001f49Smrg		  absdir=`cd "$dir" && pwd`
705132001f49Smrg		  if test -z "$absdir"; then
705232001f49Smrg		    func_warning "cannot determine absolute directory name of \`$dir'"
705332001f49Smrg		    absdir="$dir"
705432001f49Smrg		  fi
705532001f49Smrg		  ;;
705632001f49Smrg		esac
705732001f49Smrg		if $GREP "^installed=no" $deplib > /dev/null; then
705832001f49Smrg		case $host in
705932001f49Smrg		*-*-darwin*)
706032001f49Smrg		  depdepl=
706132001f49Smrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
706232001f49Smrg		  if test -n "$deplibrary_names" ; then
706332001f49Smrg		    for tmp in $deplibrary_names ; do
706432001f49Smrg		      depdepl=$tmp
706532001f49Smrg		    done
706632001f49Smrg		    if test -f "$absdir/$objdir/$depdepl" ; then
706732001f49Smrg		      depdepl="$absdir/$objdir/$depdepl"
706832001f49Smrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
706932001f49Smrg                      if test -z "$darwin_install_name"; then
707032001f49Smrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
707132001f49Smrg                      fi
707232001f49Smrg		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
707332001f49Smrg		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
707432001f49Smrg		      path=
707532001f49Smrg		    fi
707632001f49Smrg		  fi
707732001f49Smrg		  ;;
707832001f49Smrg		*)
707932001f49Smrg		  path="-L$absdir/$objdir"
708032001f49Smrg		  ;;
708132001f49Smrg		esac
708232001f49Smrg		else
708332001f49Smrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
708432001f49Smrg		  test -z "$libdir" && \
708532001f49Smrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
708632001f49Smrg		  test "$absdir" != "$libdir" && \
708732001f49Smrg		    func_warning "\`$deplib' seems to be moved"
708832001f49Smrg
708932001f49Smrg		  path="-L$absdir"
709032001f49Smrg		fi
709132001f49Smrg		;;
709232001f49Smrg	      esac
709332001f49Smrg	      case " $deplibs " in
709432001f49Smrg	      *" $path "*) ;;
709532001f49Smrg	      *) deplibs="$path $deplibs" ;;
709632001f49Smrg	      esac
709732001f49Smrg	    done
709832001f49Smrg	  fi # link_all_deplibs != no
709932001f49Smrg	fi # linkmode = lib
710032001f49Smrg      done # for deplib in $libs
710132001f49Smrg      if test "$pass" = link; then
710232001f49Smrg	if test "$linkmode" = "prog"; then
710332001f49Smrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
710432001f49Smrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
710532001f49Smrg	else
710632001f49Smrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
710732001f49Smrg	fi
710832001f49Smrg      fi
710932001f49Smrg      dependency_libs="$newdependency_libs"
711032001f49Smrg      if test "$pass" = dlpreopen; then
711132001f49Smrg	# Link the dlpreopened libraries before other libraries
711232001f49Smrg	for deplib in $save_deplibs; do
711332001f49Smrg	  deplibs="$deplib $deplibs"
711432001f49Smrg	done
711532001f49Smrg      fi
711632001f49Smrg      if test "$pass" != dlopen; then
711732001f49Smrg	if test "$pass" != conv; then
711832001f49Smrg	  # Make sure lib_search_path contains only unique directories.
711932001f49Smrg	  lib_search_path=
712032001f49Smrg	  for dir in $newlib_search_path; do
712132001f49Smrg	    case "$lib_search_path " in
712232001f49Smrg	    *" $dir "*) ;;
712332001f49Smrg	    *) func_append lib_search_path " $dir" ;;
712432001f49Smrg	    esac
712532001f49Smrg	  done
712632001f49Smrg	  newlib_search_path=
712732001f49Smrg	fi
712832001f49Smrg
712932001f49Smrg	if test "$linkmode,$pass" != "prog,link"; then
713032001f49Smrg	  vars="deplibs"
713132001f49Smrg	else
713232001f49Smrg	  vars="compile_deplibs finalize_deplibs"
713332001f49Smrg	fi
713432001f49Smrg	for var in $vars dependency_libs; do
713532001f49Smrg	  # Add libraries to $var in reverse order
713632001f49Smrg	  eval tmp_libs=\"\$$var\"
713732001f49Smrg	  new_libs=
713832001f49Smrg	  for deplib in $tmp_libs; do
713932001f49Smrg	    # FIXME: Pedantically, this is the right thing to do, so
714032001f49Smrg	    #        that some nasty dependency loop isn't accidentally
714132001f49Smrg	    #        broken:
714232001f49Smrg	    #new_libs="$deplib $new_libs"
714332001f49Smrg	    # Pragmatically, this seems to cause very few problems in
714432001f49Smrg	    # practice:
714532001f49Smrg	    case $deplib in
714632001f49Smrg	    -L*) new_libs="$deplib $new_libs" ;;
714732001f49Smrg	    -R*) ;;
714832001f49Smrg	    *)
714932001f49Smrg	      # And here is the reason: when a library appears more
715032001f49Smrg	      # than once as an explicit dependence of a library, or
715132001f49Smrg	      # is implicitly linked in more than once by the
715232001f49Smrg	      # compiler, it is considered special, and multiple
715332001f49Smrg	      # occurrences thereof are not removed.  Compare this
715432001f49Smrg	      # with having the same library being listed as a
715532001f49Smrg	      # dependency of multiple other libraries: in this case,
715632001f49Smrg	      # we know (pedantically, we assume) the library does not
715732001f49Smrg	      # need to be listed more than once, so we keep only the
715832001f49Smrg	      # last copy.  This is not always right, but it is rare
715932001f49Smrg	      # enough that we require users that really mean to play
716032001f49Smrg	      # such unportable linking tricks to link the library
716132001f49Smrg	      # using -Wl,-lname, so that libtool does not consider it
716232001f49Smrg	      # for duplicate removal.
716332001f49Smrg	      case " $specialdeplibs " in
716432001f49Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
716532001f49Smrg	      *)
716632001f49Smrg		case " $new_libs " in
716732001f49Smrg		*" $deplib "*) ;;
716832001f49Smrg		*) new_libs="$deplib $new_libs" ;;
716932001f49Smrg		esac
717032001f49Smrg		;;
717132001f49Smrg	      esac
717232001f49Smrg	      ;;
717332001f49Smrg	    esac
717432001f49Smrg	  done
717532001f49Smrg	  tmp_libs=
717632001f49Smrg	  for deplib in $new_libs; do
717732001f49Smrg	    case $deplib in
717832001f49Smrg	    -L*)
717932001f49Smrg	      case " $tmp_libs " in
718032001f49Smrg	      *" $deplib "*) ;;
718132001f49Smrg	      *) func_append tmp_libs " $deplib" ;;
718232001f49Smrg	      esac
718332001f49Smrg	      ;;
718432001f49Smrg	    *) func_append tmp_libs " $deplib" ;;
718532001f49Smrg	    esac
718632001f49Smrg	  done
718732001f49Smrg	  eval $var=\"$tmp_libs\"
718832001f49Smrg	done # for var
718932001f49Smrg      fi
719032001f49Smrg      # Last step: remove runtime libs from dependency_libs
719132001f49Smrg      # (they stay in deplibs)
719232001f49Smrg      tmp_libs=
719332001f49Smrg      for i in $dependency_libs ; do
719432001f49Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
719532001f49Smrg	*" $i "*)
719632001f49Smrg	  i=""
719732001f49Smrg	  ;;
719832001f49Smrg	esac
719932001f49Smrg	if test -n "$i" ; then
720032001f49Smrg	  func_append tmp_libs " $i"
720132001f49Smrg	fi
720232001f49Smrg      done
720332001f49Smrg      dependency_libs=$tmp_libs
720432001f49Smrg    done # for pass
720532001f49Smrg    if test "$linkmode" = prog; then
720632001f49Smrg      dlfiles="$newdlfiles"
720732001f49Smrg    fi
720832001f49Smrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
720932001f49Smrg      dlprefiles="$newdlprefiles"
721032001f49Smrg    fi
721132001f49Smrg
721232001f49Smrg    case $linkmode in
721332001f49Smrg    oldlib)
721432001f49Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
721532001f49Smrg	func_warning "\`-dlopen' is ignored for archives"
721632001f49Smrg      fi
721732001f49Smrg
721832001f49Smrg      case " $deplibs" in
721932001f49Smrg      *\ -l* | *\ -L*)
722032001f49Smrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
722132001f49Smrg      esac
722232001f49Smrg
722332001f49Smrg      test -n "$rpath" && \
722432001f49Smrg	func_warning "\`-rpath' is ignored for archives"
722532001f49Smrg
722632001f49Smrg      test -n "$xrpath" && \
722732001f49Smrg	func_warning "\`-R' is ignored for archives"
722832001f49Smrg
722932001f49Smrg      test -n "$vinfo" && \
723032001f49Smrg	func_warning "\`-version-info/-version-number' is ignored for archives"
723132001f49Smrg
723232001f49Smrg      test -n "$release" && \
723332001f49Smrg	func_warning "\`-release' is ignored for archives"
723432001f49Smrg
723532001f49Smrg      test -n "$export_symbols$export_symbols_regex" && \
723632001f49Smrg	func_warning "\`-export-symbols' is ignored for archives"
723732001f49Smrg
723832001f49Smrg      # Now set the variables for building old libraries.
723932001f49Smrg      build_libtool_libs=no
724032001f49Smrg      oldlibs="$output"
724132001f49Smrg      func_append objs "$old_deplibs"
724232001f49Smrg      ;;
724332001f49Smrg
724432001f49Smrg    lib)
724532001f49Smrg      # Make sure we only generate libraries of the form `libNAME.la'.
724632001f49Smrg      case $outputname in
724732001f49Smrg      lib*)
724832001f49Smrg	func_stripname 'lib' '.la' "$outputname"
724932001f49Smrg	name=$func_stripname_result
725032001f49Smrg	eval shared_ext=\"$shrext_cmds\"
725132001f49Smrg	eval libname=\"$libname_spec\"
725232001f49Smrg	;;
725332001f49Smrg      *)
725432001f49Smrg	test "$module" = no && \
725532001f49Smrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
725632001f49Smrg
725732001f49Smrg	if test "$need_lib_prefix" != no; then
725832001f49Smrg	  # Add the "lib" prefix for modules if required
725932001f49Smrg	  func_stripname '' '.la' "$outputname"
726032001f49Smrg	  name=$func_stripname_result
726132001f49Smrg	  eval shared_ext=\"$shrext_cmds\"
726232001f49Smrg	  eval libname=\"$libname_spec\"
726332001f49Smrg	else
726432001f49Smrg	  func_stripname '' '.la' "$outputname"
726532001f49Smrg	  libname=$func_stripname_result
726632001f49Smrg	fi
726732001f49Smrg	;;
726832001f49Smrg      esac
726932001f49Smrg
727032001f49Smrg      if test -n "$objs"; then
727132001f49Smrg	if test "$deplibs_check_method" != pass_all; then
727232001f49Smrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
727332001f49Smrg	else
727432001f49Smrg	  echo
727532001f49Smrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
727632001f49Smrg	  $ECHO "*** objects $objs is not portable!"
727732001f49Smrg	  func_append libobjs " $objs"
727832001f49Smrg	fi
727932001f49Smrg      fi
728032001f49Smrg
728132001f49Smrg      test "$dlself" != no && \
728232001f49Smrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
728332001f49Smrg
728432001f49Smrg      set dummy $rpath
728532001f49Smrg      shift
728632001f49Smrg      test "$#" -gt 1 && \
728732001f49Smrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
728832001f49Smrg
728932001f49Smrg      install_libdir="$1"
729032001f49Smrg
729132001f49Smrg      oldlibs=
729232001f49Smrg      if test -z "$rpath"; then
729332001f49Smrg	if test "$build_libtool_libs" = yes; then
729432001f49Smrg	  # Building a libtool convenience library.
729532001f49Smrg	  # Some compilers have problems with a `.al' extension so
729632001f49Smrg	  # convenience libraries should have the same extension an
729732001f49Smrg	  # archive normally would.
729832001f49Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
729932001f49Smrg	  build_libtool_libs=convenience
730032001f49Smrg	  build_old_libs=yes
730132001f49Smrg	fi
730232001f49Smrg
730332001f49Smrg	test -n "$vinfo" && \
730432001f49Smrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
730532001f49Smrg
730632001f49Smrg	test -n "$release" && \
730732001f49Smrg	  func_warning "\`-release' is ignored for convenience libraries"
730832001f49Smrg      else
730932001f49Smrg
731032001f49Smrg	# Parse the version information argument.
731132001f49Smrg	save_ifs="$IFS"; IFS=':'
731232001f49Smrg	set dummy $vinfo 0 0 0
731332001f49Smrg	shift
731432001f49Smrg	IFS="$save_ifs"
731532001f49Smrg
731632001f49Smrg	test -n "$7" && \
731732001f49Smrg	  func_fatal_help "too many parameters to \`-version-info'"
731832001f49Smrg
731932001f49Smrg	# convert absolute version numbers to libtool ages
732032001f49Smrg	# this retains compatibility with .la files and attempts
732132001f49Smrg	# to make the code below a bit more comprehensible
732232001f49Smrg
732332001f49Smrg	case $vinfo_number in
732432001f49Smrg	yes)
732532001f49Smrg	  number_major="$1"
732632001f49Smrg	  number_minor="$2"
732732001f49Smrg	  number_revision="$3"
732832001f49Smrg	  #
732932001f49Smrg	  # There are really only two kinds -- those that
733032001f49Smrg	  # use the current revision as the major version
733132001f49Smrg	  # and those that subtract age and use age as
733232001f49Smrg	  # a minor version.  But, then there is irix
733332001f49Smrg	  # which has an extra 1 added just for fun
733432001f49Smrg	  #
733532001f49Smrg	  case $version_type in
733632001f49Smrg	  # correct linux to gnu/linux during the next big refactor
733732001f49Smrg	  darwin|linux|osf|windows|none)
733832001f49Smrg	    func_arith $number_major + $number_minor
733932001f49Smrg	    current=$func_arith_result
734032001f49Smrg	    age="$number_minor"
734132001f49Smrg	    revision="$number_revision"
734232001f49Smrg	    ;;
734332001f49Smrg	  freebsd-aout|freebsd-elf|qnx|sunos)
734432001f49Smrg	    current="$number_major"
734532001f49Smrg	    revision="$number_minor"
734632001f49Smrg	    age="0"
734732001f49Smrg	    ;;
734832001f49Smrg	  irix|nonstopux)
734932001f49Smrg	    func_arith $number_major + $number_minor
735032001f49Smrg	    current=$func_arith_result
735132001f49Smrg	    age="$number_minor"
735232001f49Smrg	    revision="$number_minor"
735332001f49Smrg	    lt_irix_increment=no
735432001f49Smrg	    ;;
735532001f49Smrg	  *)
735632001f49Smrg	    func_fatal_configuration "$modename: unknown library version type \`$version_type'"
735732001f49Smrg	    ;;
735832001f49Smrg	  esac
735932001f49Smrg	  ;;
736032001f49Smrg	no)
736132001f49Smrg	  current="$1"
736232001f49Smrg	  revision="$2"
736332001f49Smrg	  age="$3"
736432001f49Smrg	  ;;
736532001f49Smrg	esac
736632001f49Smrg
736732001f49Smrg	# Check that each of the things are valid numbers.
736832001f49Smrg	case $current in
736932001f49Smrg	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]) ;;
737032001f49Smrg	*)
737132001f49Smrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
737232001f49Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
737332001f49Smrg	  ;;
737432001f49Smrg	esac
737532001f49Smrg
737632001f49Smrg	case $revision in
737732001f49Smrg	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]) ;;
737832001f49Smrg	*)
737932001f49Smrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
738032001f49Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
738132001f49Smrg	  ;;
738232001f49Smrg	esac
738332001f49Smrg
738432001f49Smrg	case $age in
738532001f49Smrg	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]) ;;
738632001f49Smrg	*)
738732001f49Smrg	  func_error "AGE \`$age' must be a nonnegative integer"
738832001f49Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
738932001f49Smrg	  ;;
739032001f49Smrg	esac
739132001f49Smrg
739232001f49Smrg	if test "$age" -gt "$current"; then
739332001f49Smrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
739432001f49Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
739532001f49Smrg	fi
739632001f49Smrg
739732001f49Smrg	# Calculate the version variables.
739832001f49Smrg	major=
739932001f49Smrg	versuffix=
740032001f49Smrg	verstring=
740132001f49Smrg	case $version_type in
740232001f49Smrg	none) ;;
740332001f49Smrg
740432001f49Smrg	darwin)
740532001f49Smrg	  # Like Linux, but with the current version available in
740632001f49Smrg	  # verstring for coding it into the library header
740732001f49Smrg	  func_arith $current - $age
740832001f49Smrg	  major=.$func_arith_result
740932001f49Smrg	  versuffix="$major.$age.$revision"
741032001f49Smrg	  # Darwin ld doesn't like 0 for these options...
741132001f49Smrg	  func_arith $current + 1
741232001f49Smrg	  minor_current=$func_arith_result
741332001f49Smrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
741432001f49Smrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
741532001f49Smrg	  ;;
741632001f49Smrg
741732001f49Smrg	freebsd-aout)
741832001f49Smrg	  major=".$current"
741932001f49Smrg	  versuffix=".$current.$revision";
742032001f49Smrg	  ;;
742132001f49Smrg
742232001f49Smrg	freebsd-elf)
742332001f49Smrg	  major=".$current"
742432001f49Smrg	  versuffix=".$current"
742532001f49Smrg	  ;;
742632001f49Smrg
742732001f49Smrg	irix | nonstopux)
742832001f49Smrg	  if test "X$lt_irix_increment" = "Xno"; then
742932001f49Smrg	    func_arith $current - $age
743032001f49Smrg	  else
743132001f49Smrg	    func_arith $current - $age + 1
743232001f49Smrg	  fi
743332001f49Smrg	  major=$func_arith_result
743432001f49Smrg
743532001f49Smrg	  case $version_type in
743632001f49Smrg	    nonstopux) verstring_prefix=nonstopux ;;
743732001f49Smrg	    *)         verstring_prefix=sgi ;;
743832001f49Smrg	  esac
743932001f49Smrg	  verstring="$verstring_prefix$major.$revision"
744032001f49Smrg
744132001f49Smrg	  # Add in all the interfaces that we are compatible with.
744232001f49Smrg	  loop=$revision
744332001f49Smrg	  while test "$loop" -ne 0; do
744432001f49Smrg	    func_arith $revision - $loop
744532001f49Smrg	    iface=$func_arith_result
744632001f49Smrg	    func_arith $loop - 1
744732001f49Smrg	    loop=$func_arith_result
744832001f49Smrg	    verstring="$verstring_prefix$major.$iface:$verstring"
744932001f49Smrg	  done
745032001f49Smrg
745132001f49Smrg	  # Before this point, $major must not contain `.'.
745232001f49Smrg	  major=.$major
745332001f49Smrg	  versuffix="$major.$revision"
745432001f49Smrg	  ;;
745532001f49Smrg
745632001f49Smrg	linux) # correct to gnu/linux during the next big refactor
745732001f49Smrg	  func_arith $current - $age
745832001f49Smrg	  major=.$func_arith_result
745932001f49Smrg	  versuffix="$major.$age.$revision"
746032001f49Smrg	  ;;
746132001f49Smrg
746232001f49Smrg	osf)
746332001f49Smrg	  func_arith $current - $age
746432001f49Smrg	  major=.$func_arith_result
746532001f49Smrg	  versuffix=".$current.$age.$revision"
746632001f49Smrg	  verstring="$current.$age.$revision"
746732001f49Smrg
746832001f49Smrg	  # Add in all the interfaces that we are compatible with.
746932001f49Smrg	  loop=$age
747032001f49Smrg	  while test "$loop" -ne 0; do
747132001f49Smrg	    func_arith $current - $loop
747232001f49Smrg	    iface=$func_arith_result
747332001f49Smrg	    func_arith $loop - 1
747432001f49Smrg	    loop=$func_arith_result
747532001f49Smrg	    verstring="$verstring:${iface}.0"
747632001f49Smrg	  done
747732001f49Smrg
747832001f49Smrg	  # Make executables depend on our current version.
747932001f49Smrg	  func_append verstring ":${current}.0"
748032001f49Smrg	  ;;
748132001f49Smrg
748232001f49Smrg	qnx)
748332001f49Smrg	  major=".$current"
748432001f49Smrg	  versuffix=".$current"
748532001f49Smrg	  ;;
748632001f49Smrg
748732001f49Smrg	sunos)
748832001f49Smrg	  major=".$current"
748932001f49Smrg	  versuffix=".$current.$revision"
749032001f49Smrg	  ;;
749132001f49Smrg
749232001f49Smrg	windows)
749332001f49Smrg	  # Use '-' rather than '.', since we only want one
749432001f49Smrg	  # extension on DOS 8.3 filesystems.
749532001f49Smrg	  func_arith $current - $age
749632001f49Smrg	  major=$func_arith_result
749732001f49Smrg	  versuffix="-$major"
749832001f49Smrg	  ;;
749932001f49Smrg
750032001f49Smrg	*)
750132001f49Smrg	  func_fatal_configuration "unknown library version type \`$version_type'"
750232001f49Smrg	  ;;
750332001f49Smrg	esac
750432001f49Smrg
750532001f49Smrg	# Clear the version info if we defaulted, and they specified a release.
750632001f49Smrg	if test -z "$vinfo" && test -n "$release"; then
750732001f49Smrg	  major=
750832001f49Smrg	  case $version_type in
750932001f49Smrg	  darwin)
751032001f49Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
751132001f49Smrg	    # problems, so we reset it completely
751232001f49Smrg	    verstring=
751332001f49Smrg	    ;;
751432001f49Smrg	  *)
751532001f49Smrg	    verstring="0.0"
751632001f49Smrg	    ;;
751732001f49Smrg	  esac
751832001f49Smrg	  if test "$need_version" = no; then
751932001f49Smrg	    versuffix=
752032001f49Smrg	  else
752132001f49Smrg	    versuffix=".0.0"
752232001f49Smrg	  fi
752332001f49Smrg	fi
752432001f49Smrg
752532001f49Smrg	# Remove version info from name if versioning should be avoided
752632001f49Smrg	if test "$avoid_version" = yes && test "$need_version" = no; then
752732001f49Smrg	  major=
752832001f49Smrg	  versuffix=
752932001f49Smrg	  verstring=""
753032001f49Smrg	fi
753132001f49Smrg
753232001f49Smrg	# Check to see if the archive will have undefined symbols.
753332001f49Smrg	if test "$allow_undefined" = yes; then
753432001f49Smrg	  if test "$allow_undefined_flag" = unsupported; then
753532001f49Smrg	    func_warning "undefined symbols not allowed in $host shared libraries"
753632001f49Smrg	    build_libtool_libs=no
753732001f49Smrg	    build_old_libs=yes
753832001f49Smrg	  fi
753932001f49Smrg	else
754032001f49Smrg	  # Don't allow undefined symbols.
754132001f49Smrg	  allow_undefined_flag="$no_undefined_flag"
754232001f49Smrg	fi
754332001f49Smrg
754432001f49Smrg      fi
754532001f49Smrg
754632001f49Smrg      func_generate_dlsyms "$libname" "$libname" "yes"
754732001f49Smrg      func_append libobjs " $symfileobj"
754832001f49Smrg      test "X$libobjs" = "X " && libobjs=
754932001f49Smrg
755032001f49Smrg      if test "$opt_mode" != relink; then
755132001f49Smrg	# Remove our outputs, but don't remove object files since they
755232001f49Smrg	# may have been created when compiling PIC objects.
755332001f49Smrg	removelist=
755432001f49Smrg	tempremovelist=`$ECHO "$output_objdir/*"`
755532001f49Smrg	for p in $tempremovelist; do
755632001f49Smrg	  case $p in
755732001f49Smrg	    *.$objext | *.gcno)
755832001f49Smrg	       ;;
755932001f49Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
756032001f49Smrg	       if test "X$precious_files_regex" != "X"; then
756132001f49Smrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
756232001f49Smrg		 then
756332001f49Smrg		   continue
756432001f49Smrg		 fi
756532001f49Smrg	       fi
756632001f49Smrg	       func_append removelist " $p"
756732001f49Smrg	       ;;
756832001f49Smrg	    *) ;;
756932001f49Smrg	  esac
757032001f49Smrg	done
757132001f49Smrg	test -n "$removelist" && \
757232001f49Smrg	  func_show_eval "${RM}r \$removelist"
757332001f49Smrg      fi
757432001f49Smrg
757532001f49Smrg      # Now set the variables for building old libraries.
757632001f49Smrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
757732001f49Smrg	func_append oldlibs " $output_objdir/$libname.$libext"
757832001f49Smrg
757932001f49Smrg	# Transform .lo files to .o files.
758032001f49Smrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
758132001f49Smrg      fi
758232001f49Smrg
758332001f49Smrg      # Eliminate all temporary directories.
758432001f49Smrg      #for path in $notinst_path; do
758532001f49Smrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
758632001f49Smrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
758732001f49Smrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
758832001f49Smrg      #done
758932001f49Smrg
759032001f49Smrg      if test -n "$xrpath"; then
759132001f49Smrg	# If the user specified any rpath flags, then add them.
759232001f49Smrg	temp_xrpath=
759332001f49Smrg	for libdir in $xrpath; do
759432001f49Smrg	  func_replace_sysroot "$libdir"
759532001f49Smrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
759632001f49Smrg	  case "$finalize_rpath " in
759732001f49Smrg	  *" $libdir "*) ;;
759832001f49Smrg	  *) func_append finalize_rpath " $libdir" ;;
759932001f49Smrg	  esac
760032001f49Smrg	done
760132001f49Smrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
760232001f49Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
760332001f49Smrg	fi
760432001f49Smrg      fi
760532001f49Smrg
760632001f49Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
760732001f49Smrg      old_dlfiles="$dlfiles"
760832001f49Smrg      dlfiles=
760932001f49Smrg      for lib in $old_dlfiles; do
761032001f49Smrg	case " $dlprefiles $dlfiles " in
761132001f49Smrg	*" $lib "*) ;;
761232001f49Smrg	*) func_append dlfiles " $lib" ;;
761332001f49Smrg	esac
761432001f49Smrg      done
761532001f49Smrg
761632001f49Smrg      # Make sure dlprefiles contains only unique files
761732001f49Smrg      old_dlprefiles="$dlprefiles"
761832001f49Smrg      dlprefiles=
761932001f49Smrg      for lib in $old_dlprefiles; do
762032001f49Smrg	case "$dlprefiles " in
762132001f49Smrg	*" $lib "*) ;;
762232001f49Smrg	*) func_append dlprefiles " $lib" ;;
762332001f49Smrg	esac
762432001f49Smrg      done
762532001f49Smrg
762632001f49Smrg      if test "$build_libtool_libs" = yes; then
762732001f49Smrg	if test -n "$rpath"; then
762832001f49Smrg	  case $host in
762932001f49Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
763032001f49Smrg	    # these systems don't actually have a c library (as such)!
763132001f49Smrg	    ;;
763232001f49Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
763332001f49Smrg	    # Rhapsody C library is in the System framework
763432001f49Smrg	    func_append deplibs " System.ltframework"
763532001f49Smrg	    ;;
763632001f49Smrg	  *-*-netbsd*)
763732001f49Smrg	    # Don't link with libc until the a.out ld.so is fixed.
763832001f49Smrg	    ;;
763932001f49Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
764032001f49Smrg	    # Do not include libc due to us having libc/libc_r.
764132001f49Smrg	    ;;
764232001f49Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
764332001f49Smrg	    # Causes problems with __ctype
764432001f49Smrg	    ;;
764532001f49Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
764632001f49Smrg	    # Compiler inserts libc in the correct place for threads to work
764732001f49Smrg	    ;;
764832001f49Smrg	  *)
764932001f49Smrg	    # Add libc to deplibs on all other systems if necessary.
765032001f49Smrg	    if test "$build_libtool_need_lc" = "yes"; then
765132001f49Smrg	      func_append deplibs " -lc"
765232001f49Smrg	    fi
765332001f49Smrg	    ;;
765432001f49Smrg	  esac
765532001f49Smrg	fi
765632001f49Smrg
765732001f49Smrg	# Transform deplibs into only deplibs that can be linked in shared.
765832001f49Smrg	name_save=$name
765932001f49Smrg	libname_save=$libname
766032001f49Smrg	release_save=$release
766132001f49Smrg	versuffix_save=$versuffix
766232001f49Smrg	major_save=$major
766332001f49Smrg	# I'm not sure if I'm treating the release correctly.  I think
766432001f49Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
766532001f49Smrg	# add it in twice.  Is that correct?
766632001f49Smrg	release=""
766732001f49Smrg	versuffix=""
766832001f49Smrg	major=""
766932001f49Smrg	newdeplibs=
767032001f49Smrg	droppeddeps=no
767132001f49Smrg	case $deplibs_check_method in
767232001f49Smrg	pass_all)
767332001f49Smrg	  # Don't check for shared/static.  Everything works.
767432001f49Smrg	  # This might be a little naive.  We might want to check
767532001f49Smrg	  # whether the library exists or not.  But this is on
767632001f49Smrg	  # osf3 & osf4 and I'm not really sure... Just
767732001f49Smrg	  # implementing what was already the behavior.
767832001f49Smrg	  newdeplibs=$deplibs
767932001f49Smrg	  ;;
768032001f49Smrg	test_compile)
768132001f49Smrg	  # This code stresses the "libraries are programs" paradigm to its
768232001f49Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
768332001f49Smrg	  # against the deplibs as a proxy for the library.  Then we can check
768432001f49Smrg	  # whether they linked in statically or dynamically with ldd.
768532001f49Smrg	  $opt_dry_run || $RM conftest.c
768632001f49Smrg	  cat > conftest.c <<EOF
768732001f49Smrg	  int main() { return 0; }
768832001f49SmrgEOF
768932001f49Smrg	  $opt_dry_run || $RM conftest
769032001f49Smrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
769132001f49Smrg	    ldd_output=`ldd conftest`
769232001f49Smrg	    for i in $deplibs; do
769332001f49Smrg	      case $i in
769432001f49Smrg	      -l*)
769532001f49Smrg		func_stripname -l '' "$i"
769632001f49Smrg		name=$func_stripname_result
769732001f49Smrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
769832001f49Smrg		  case " $predeps $postdeps " in
769932001f49Smrg		  *" $i "*)
770032001f49Smrg		    func_append newdeplibs " $i"
770132001f49Smrg		    i=""
770232001f49Smrg		    ;;
770332001f49Smrg		  esac
770432001f49Smrg		fi
770532001f49Smrg		if test -n "$i" ; then
770632001f49Smrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
770732001f49Smrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
770832001f49Smrg		  set dummy $deplib_matches; shift
770932001f49Smrg		  deplib_match=$1
771032001f49Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
771132001f49Smrg		    func_append newdeplibs " $i"
771232001f49Smrg		  else
771332001f49Smrg		    droppeddeps=yes
771432001f49Smrg		    echo
771532001f49Smrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
771632001f49Smrg		    echo "*** I have the capability to make that library automatically link in when"
771732001f49Smrg		    echo "*** you link to this library.  But I can only do this if you have a"
771832001f49Smrg		    echo "*** shared version of the library, which I believe you do not have"
771932001f49Smrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
772032001f49Smrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
772132001f49Smrg		  fi
772232001f49Smrg		fi
772332001f49Smrg		;;
772432001f49Smrg	      *)
772532001f49Smrg		func_append newdeplibs " $i"
772632001f49Smrg		;;
772732001f49Smrg	      esac
772832001f49Smrg	    done
772932001f49Smrg	  else
773032001f49Smrg	    # Error occurred in the first compile.  Let's try to salvage
773132001f49Smrg	    # the situation: Compile a separate program for each library.
773232001f49Smrg	    for i in $deplibs; do
773332001f49Smrg	      case $i in
773432001f49Smrg	      -l*)
773532001f49Smrg		func_stripname -l '' "$i"
773632001f49Smrg		name=$func_stripname_result
773732001f49Smrg		$opt_dry_run || $RM conftest
773832001f49Smrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
773932001f49Smrg		  ldd_output=`ldd conftest`
774032001f49Smrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
774132001f49Smrg		    case " $predeps $postdeps " in
774232001f49Smrg		    *" $i "*)
774332001f49Smrg		      func_append newdeplibs " $i"
774432001f49Smrg		      i=""
774532001f49Smrg		      ;;
774632001f49Smrg		    esac
774732001f49Smrg		  fi
774832001f49Smrg		  if test -n "$i" ; then
774932001f49Smrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
775032001f49Smrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
775132001f49Smrg		    set dummy $deplib_matches; shift
775232001f49Smrg		    deplib_match=$1
775332001f49Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
775432001f49Smrg		      func_append newdeplibs " $i"
775532001f49Smrg		    else
775632001f49Smrg		      droppeddeps=yes
775732001f49Smrg		      echo
775832001f49Smrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
775932001f49Smrg		      echo "*** I have the capability to make that library automatically link in when"
776032001f49Smrg		      echo "*** you link to this library.  But I can only do this if you have a"
776132001f49Smrg		      echo "*** shared version of the library, which you do not appear to have"
776232001f49Smrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
776332001f49Smrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
776432001f49Smrg		    fi
776532001f49Smrg		  fi
776632001f49Smrg		else
776732001f49Smrg		  droppeddeps=yes
776832001f49Smrg		  echo
776932001f49Smrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
777032001f49Smrg		  echo "*** make it link in!  You will probably need to install it or some"
777132001f49Smrg		  echo "*** library that it depends on before this library will be fully"
777232001f49Smrg		  echo "*** functional.  Installing it before continuing would be even better."
777332001f49Smrg		fi
777432001f49Smrg		;;
777532001f49Smrg	      *)
777632001f49Smrg		func_append newdeplibs " $i"
777732001f49Smrg		;;
777832001f49Smrg	      esac
777932001f49Smrg	    done
778032001f49Smrg	  fi
778132001f49Smrg	  ;;
778232001f49Smrg	file_magic*)
778332001f49Smrg	  set dummy $deplibs_check_method; shift
778432001f49Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
778532001f49Smrg	  for a_deplib in $deplibs; do
778632001f49Smrg	    case $a_deplib in
778732001f49Smrg	    -l*)
778832001f49Smrg	      func_stripname -l '' "$a_deplib"
778932001f49Smrg	      name=$func_stripname_result
779032001f49Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
779132001f49Smrg		case " $predeps $postdeps " in
779232001f49Smrg		*" $a_deplib "*)
779332001f49Smrg		  func_append newdeplibs " $a_deplib"
779432001f49Smrg		  a_deplib=""
779532001f49Smrg		  ;;
779632001f49Smrg		esac
779732001f49Smrg	      fi
779832001f49Smrg	      if test -n "$a_deplib" ; then
779932001f49Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
780032001f49Smrg		if test -n "$file_magic_glob"; then
780132001f49Smrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
780232001f49Smrg		else
780332001f49Smrg		  libnameglob=$libname
780432001f49Smrg		fi
780532001f49Smrg		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
780632001f49Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
780732001f49Smrg		  if test "$want_nocaseglob" = yes; then
780832001f49Smrg		    shopt -s nocaseglob
780932001f49Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
781032001f49Smrg		    $nocaseglob
781132001f49Smrg		  else
781232001f49Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
781332001f49Smrg		  fi
781432001f49Smrg		  for potent_lib in $potential_libs; do
781532001f49Smrg		      # Follow soft links.
781632001f49Smrg		      if ls -lLd "$potent_lib" 2>/dev/null |
781732001f49Smrg			 $GREP " -> " >/dev/null; then
781832001f49Smrg			continue
781932001f49Smrg		      fi
782032001f49Smrg		      # The statement above tries to avoid entering an
782132001f49Smrg		      # endless loop below, in case of cyclic links.
782232001f49Smrg		      # We might still enter an endless loop, since a link
782332001f49Smrg		      # loop can be closed while we follow links,
782432001f49Smrg		      # but so what?
782532001f49Smrg		      potlib="$potent_lib"
782632001f49Smrg		      while test -h "$potlib" 2>/dev/null; do
782732001f49Smrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
782832001f49Smrg			case $potliblink in
782932001f49Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
783032001f49Smrg			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
783132001f49Smrg			esac
783232001f49Smrg		      done
783332001f49Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
783432001f49Smrg			 $SED -e 10q |
783532001f49Smrg			 $EGREP "$file_magic_regex" > /dev/null; then
783632001f49Smrg			func_append newdeplibs " $a_deplib"
783732001f49Smrg			a_deplib=""
783832001f49Smrg			break 2
783932001f49Smrg		      fi
784032001f49Smrg		  done
784132001f49Smrg		done
784232001f49Smrg	      fi
784332001f49Smrg	      if test -n "$a_deplib" ; then
784432001f49Smrg		droppeddeps=yes
784532001f49Smrg		echo
784632001f49Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
784732001f49Smrg		echo "*** I have the capability to make that library automatically link in when"
784832001f49Smrg		echo "*** you link to this library.  But I can only do this if you have a"
784932001f49Smrg		echo "*** shared version of the library, which you do not appear to have"
785032001f49Smrg		echo "*** because I did check the linker path looking for a file starting"
785132001f49Smrg		if test -z "$potlib" ; then
785232001f49Smrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
785332001f49Smrg		else
785432001f49Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
785532001f49Smrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
785632001f49Smrg		fi
785732001f49Smrg	      fi
785832001f49Smrg	      ;;
785932001f49Smrg	    *)
786032001f49Smrg	      # Add a -L argument.
786132001f49Smrg	      func_append newdeplibs " $a_deplib"
786232001f49Smrg	      ;;
786332001f49Smrg	    esac
786432001f49Smrg	  done # Gone through all deplibs.
786532001f49Smrg	  ;;
786632001f49Smrg	match_pattern*)
786732001f49Smrg	  set dummy $deplibs_check_method; shift
786832001f49Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
786932001f49Smrg	  for a_deplib in $deplibs; do
787032001f49Smrg	    case $a_deplib in
787132001f49Smrg	    -l*)
787232001f49Smrg	      func_stripname -l '' "$a_deplib"
787332001f49Smrg	      name=$func_stripname_result
787432001f49Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
787532001f49Smrg		case " $predeps $postdeps " in
787632001f49Smrg		*" $a_deplib "*)
787732001f49Smrg		  func_append newdeplibs " $a_deplib"
787832001f49Smrg		  a_deplib=""
787932001f49Smrg		  ;;
788032001f49Smrg		esac
788132001f49Smrg	      fi
788232001f49Smrg	      if test -n "$a_deplib" ; then
788332001f49Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
788432001f49Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
788532001f49Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
788632001f49Smrg		  for potent_lib in $potential_libs; do
788732001f49Smrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
788832001f49Smrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
788932001f49Smrg		       $EGREP "$match_pattern_regex" > /dev/null; then
789032001f49Smrg		      func_append newdeplibs " $a_deplib"
789132001f49Smrg		      a_deplib=""
789232001f49Smrg		      break 2
789332001f49Smrg		    fi
789432001f49Smrg		  done
789532001f49Smrg		done
789632001f49Smrg	      fi
789732001f49Smrg	      if test -n "$a_deplib" ; then
789832001f49Smrg		droppeddeps=yes
789932001f49Smrg		echo
790032001f49Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
790132001f49Smrg		echo "*** I have the capability to make that library automatically link in when"
790232001f49Smrg		echo "*** you link to this library.  But I can only do this if you have a"
790332001f49Smrg		echo "*** shared version of the library, which you do not appear to have"
790432001f49Smrg		echo "*** because I did check the linker path looking for a file starting"
790532001f49Smrg		if test -z "$potlib" ; then
790632001f49Smrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
790732001f49Smrg		else
790832001f49Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
790932001f49Smrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
791032001f49Smrg		fi
791132001f49Smrg	      fi
791232001f49Smrg	      ;;
791332001f49Smrg	    *)
791432001f49Smrg	      # Add a -L argument.
791532001f49Smrg	      func_append newdeplibs " $a_deplib"
791632001f49Smrg	      ;;
791732001f49Smrg	    esac
791832001f49Smrg	  done # Gone through all deplibs.
791932001f49Smrg	  ;;
792032001f49Smrg	none | unknown | *)
792132001f49Smrg	  newdeplibs=""
792232001f49Smrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
792332001f49Smrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
792432001f49Smrg	    for i in $predeps $postdeps ; do
792532001f49Smrg	      # can't use Xsed below, because $i might contain '/'
792632001f49Smrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
792732001f49Smrg	    done
792832001f49Smrg	  fi
792932001f49Smrg	  case $tmp_deplibs in
793032001f49Smrg	  *[!\	\ ]*)
793132001f49Smrg	    echo
793232001f49Smrg	    if test "X$deplibs_check_method" = "Xnone"; then
793332001f49Smrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
793432001f49Smrg	    else
793532001f49Smrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
793632001f49Smrg	    fi
793732001f49Smrg	    echo "*** All declared inter-library dependencies are being dropped."
793832001f49Smrg	    droppeddeps=yes
793932001f49Smrg	    ;;
794032001f49Smrg	  esac
794132001f49Smrg	  ;;
794232001f49Smrg	esac
794332001f49Smrg	versuffix=$versuffix_save
794432001f49Smrg	major=$major_save
794532001f49Smrg	release=$release_save
794632001f49Smrg	libname=$libname_save
794732001f49Smrg	name=$name_save
794832001f49Smrg
794932001f49Smrg	case $host in
795032001f49Smrg	*-*-rhapsody* | *-*-darwin1.[012])
795132001f49Smrg	  # On Rhapsody replace the C library with the System framework
795232001f49Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
795332001f49Smrg	  ;;
795432001f49Smrg	esac
795532001f49Smrg
795632001f49Smrg	if test "$droppeddeps" = yes; then
795732001f49Smrg	  if test "$module" = yes; then
795832001f49Smrg	    echo
795932001f49Smrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
796032001f49Smrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
796132001f49Smrg	    echo "*** a static module, that should work as long as the dlopening"
796232001f49Smrg	    echo "*** application is linked with the -dlopen flag."
796332001f49Smrg	    if test -z "$global_symbol_pipe"; then
796432001f49Smrg	      echo
796532001f49Smrg	      echo "*** However, this would only work if libtool was able to extract symbol"
796632001f49Smrg	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
796732001f49Smrg	      echo "*** not find such a program.  So, this module is probably useless."
796832001f49Smrg	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
796932001f49Smrg	    fi
797032001f49Smrg	    if test "$build_old_libs" = no; then
797132001f49Smrg	      oldlibs="$output_objdir/$libname.$libext"
797232001f49Smrg	      build_libtool_libs=module
797332001f49Smrg	      build_old_libs=yes
797432001f49Smrg	    else
797532001f49Smrg	      build_libtool_libs=no
797632001f49Smrg	    fi
797732001f49Smrg	  else
797832001f49Smrg	    echo "*** The inter-library dependencies that have been dropped here will be"
797932001f49Smrg	    echo "*** automatically added whenever a program is linked with this library"
798032001f49Smrg	    echo "*** or is declared to -dlopen it."
798132001f49Smrg
798232001f49Smrg	    if test "$allow_undefined" = no; then
798332001f49Smrg	      echo
798432001f49Smrg	      echo "*** Since this library must not contain undefined symbols,"
798532001f49Smrg	      echo "*** because either the platform does not support them or"
798632001f49Smrg	      echo "*** it was explicitly requested with -no-undefined,"
798732001f49Smrg	      echo "*** libtool will only create a static version of it."
798832001f49Smrg	      if test "$build_old_libs" = no; then
798932001f49Smrg		oldlibs="$output_objdir/$libname.$libext"
799032001f49Smrg		build_libtool_libs=module
799132001f49Smrg		build_old_libs=yes
799232001f49Smrg	      else
799332001f49Smrg		build_libtool_libs=no
799432001f49Smrg	      fi
799532001f49Smrg	    fi
799632001f49Smrg	  fi
799732001f49Smrg	fi
799832001f49Smrg	# Done checking deplibs!
799932001f49Smrg	deplibs=$newdeplibs
800032001f49Smrg      fi
800132001f49Smrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
800232001f49Smrg      case $host in
800332001f49Smrg	*-*-darwin*)
800432001f49Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
800532001f49Smrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
800632001f49Smrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
800732001f49Smrg	  ;;
800832001f49Smrg      esac
800932001f49Smrg
801032001f49Smrg      # move library search paths that coincide with paths to not yet
801132001f49Smrg      # installed libraries to the beginning of the library search list
801232001f49Smrg      new_libs=
801332001f49Smrg      for path in $notinst_path; do
801432001f49Smrg	case " $new_libs " in
801532001f49Smrg	*" -L$path/$objdir "*) ;;
801632001f49Smrg	*)
801732001f49Smrg	  case " $deplibs " in
801832001f49Smrg	  *" -L$path/$objdir "*)
801932001f49Smrg	    func_append new_libs " -L$path/$objdir" ;;
802032001f49Smrg	  esac
802132001f49Smrg	  ;;
802232001f49Smrg	esac
802332001f49Smrg      done
802432001f49Smrg      for deplib in $deplibs; do
802532001f49Smrg	case $deplib in
802632001f49Smrg	-L*)
802732001f49Smrg	  case " $new_libs " in
802832001f49Smrg	  *" $deplib "*) ;;
802932001f49Smrg	  *) func_append new_libs " $deplib" ;;
803032001f49Smrg	  esac
803132001f49Smrg	  ;;
803232001f49Smrg	*) func_append new_libs " $deplib" ;;
803332001f49Smrg	esac
803432001f49Smrg      done
803532001f49Smrg      deplibs="$new_libs"
803632001f49Smrg
803732001f49Smrg      # All the library-specific variables (install_libdir is set above).
803832001f49Smrg      library_names=
803932001f49Smrg      old_library=
804032001f49Smrg      dlname=
804132001f49Smrg
804232001f49Smrg      # Test again, we may have decided not to build it any more
804332001f49Smrg      if test "$build_libtool_libs" = yes; then
804432001f49Smrg	# Remove ${wl} instances when linking with ld.
804532001f49Smrg	# FIXME: should test the right _cmds variable.
804632001f49Smrg	case $archive_cmds in
804732001f49Smrg	  *\$LD\ *) wl= ;;
804832001f49Smrg        esac
804932001f49Smrg	if test "$hardcode_into_libs" = yes; then
805032001f49Smrg	  # Hardcode the library paths
805132001f49Smrg	  hardcode_libdirs=
805232001f49Smrg	  dep_rpath=
805332001f49Smrg	  rpath="$finalize_rpath"
805432001f49Smrg	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
805532001f49Smrg	  for libdir in $rpath; do
805632001f49Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
805732001f49Smrg	      if test -n "$hardcode_libdir_separator"; then
805832001f49Smrg		func_replace_sysroot "$libdir"
805932001f49Smrg		libdir=$func_replace_sysroot_result
806032001f49Smrg		if test -z "$hardcode_libdirs"; then
806132001f49Smrg		  hardcode_libdirs="$libdir"
806232001f49Smrg		else
806332001f49Smrg		  # Just accumulate the unique libdirs.
806432001f49Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
806532001f49Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
806632001f49Smrg		    ;;
806732001f49Smrg		  *)
806832001f49Smrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
806932001f49Smrg		    ;;
807032001f49Smrg		  esac
807132001f49Smrg		fi
807232001f49Smrg	      else
807332001f49Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
807432001f49Smrg		func_append dep_rpath " $flag"
807532001f49Smrg	      fi
807632001f49Smrg	    elif test -n "$runpath_var"; then
807732001f49Smrg	      case "$perm_rpath " in
807832001f49Smrg	      *" $libdir "*) ;;
807932001f49Smrg	      *) func_append perm_rpath " $libdir" ;;
808032001f49Smrg	      esac
808132001f49Smrg	    fi
808232001f49Smrg	  done
808332001f49Smrg	  # Substitute the hardcoded libdirs into the rpath.
808432001f49Smrg	  if test -n "$hardcode_libdir_separator" &&
808532001f49Smrg	     test -n "$hardcode_libdirs"; then
808632001f49Smrg	    libdir="$hardcode_libdirs"
808732001f49Smrg	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
808832001f49Smrg	  fi
808932001f49Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
809032001f49Smrg	    # We should set the runpath_var.
809132001f49Smrg	    rpath=
809232001f49Smrg	    for dir in $perm_rpath; do
809332001f49Smrg	      func_append rpath "$dir:"
809432001f49Smrg	    done
809532001f49Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
809632001f49Smrg	  fi
809732001f49Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
809832001f49Smrg	fi
809932001f49Smrg
810032001f49Smrg	shlibpath="$finalize_shlibpath"
810132001f49Smrg	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
810232001f49Smrg	if test -n "$shlibpath"; then
810332001f49Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
810432001f49Smrg	fi
810532001f49Smrg
810632001f49Smrg	# Get the real and link names of the library.
810732001f49Smrg	eval shared_ext=\"$shrext_cmds\"
810832001f49Smrg	eval library_names=\"$library_names_spec\"
810932001f49Smrg	set dummy $library_names
811032001f49Smrg	shift
811132001f49Smrg	realname="$1"
811232001f49Smrg	shift
811332001f49Smrg
811432001f49Smrg	if test -n "$soname_spec"; then
811532001f49Smrg	  eval soname=\"$soname_spec\"
811632001f49Smrg	else
811732001f49Smrg	  soname="$realname"
811832001f49Smrg	fi
811932001f49Smrg	if test -z "$dlname"; then
812032001f49Smrg	  dlname=$soname
812132001f49Smrg	fi
812232001f49Smrg
812332001f49Smrg	lib="$output_objdir/$realname"
812432001f49Smrg	linknames=
812532001f49Smrg	for link
812632001f49Smrg	do
812732001f49Smrg	  func_append linknames " $link"
812832001f49Smrg	done
812932001f49Smrg
813032001f49Smrg	# Use standard objects if they are pic
813132001f49Smrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
813232001f49Smrg	test "X$libobjs" = "X " && libobjs=
813332001f49Smrg
813432001f49Smrg	delfiles=
813532001f49Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
813632001f49Smrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
813732001f49Smrg	  export_symbols="$output_objdir/$libname.uexp"
813832001f49Smrg	  func_append delfiles " $export_symbols"
813932001f49Smrg	fi
814032001f49Smrg
814132001f49Smrg	orig_export_symbols=
814232001f49Smrg	case $host_os in
814332001f49Smrg	cygwin* | mingw* | cegcc*)
814432001f49Smrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
814532001f49Smrg	    # exporting using user supplied symfile
814632001f49Smrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
814732001f49Smrg	      # and it's NOT already a .def file. Must figure out
814832001f49Smrg	      # which of the given symbols are data symbols and tag
814932001f49Smrg	      # them as such. So, trigger use of export_symbols_cmds.
815032001f49Smrg	      # export_symbols gets reassigned inside the "prepare
815132001f49Smrg	      # the list of exported symbols" if statement, so the
815232001f49Smrg	      # include_expsyms logic still works.
815332001f49Smrg	      orig_export_symbols="$export_symbols"
815432001f49Smrg	      export_symbols=
815532001f49Smrg	      always_export_symbols=yes
815632001f49Smrg	    fi
815732001f49Smrg	  fi
815832001f49Smrg	  ;;
815932001f49Smrg	esac
816032001f49Smrg
816132001f49Smrg	# Prepare the list of exported symbols
816232001f49Smrg	if test -z "$export_symbols"; then
816332001f49Smrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
816432001f49Smrg	    func_verbose "generating symbol list for \`$libname.la'"
816532001f49Smrg	    export_symbols="$output_objdir/$libname.exp"
816632001f49Smrg	    $opt_dry_run || $RM $export_symbols
816732001f49Smrg	    cmds=$export_symbols_cmds
816832001f49Smrg	    save_ifs="$IFS"; IFS='~'
816932001f49Smrg	    for cmd1 in $cmds; do
817032001f49Smrg	      IFS="$save_ifs"
817132001f49Smrg	      # Take the normal branch if the nm_file_list_spec branch
817232001f49Smrg	      # doesn't work or if tool conversion is not needed.
817332001f49Smrg	      case $nm_file_list_spec~$to_tool_file_cmd in
817432001f49Smrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
817532001f49Smrg		  try_normal_branch=yes
817632001f49Smrg		  eval cmd=\"$cmd1\"
817732001f49Smrg		  func_len " $cmd"
817832001f49Smrg		  len=$func_len_result
817932001f49Smrg		  ;;
818032001f49Smrg		*)
818132001f49Smrg		  try_normal_branch=no
818232001f49Smrg		  ;;
818332001f49Smrg	      esac
818432001f49Smrg	      if test "$try_normal_branch" = yes \
818532001f49Smrg		 && { test "$len" -lt "$max_cmd_len" \
818632001f49Smrg		      || test "$max_cmd_len" -le -1; }
818732001f49Smrg	      then
818832001f49Smrg		func_show_eval "$cmd" 'exit $?'
818932001f49Smrg		skipped_export=false
819032001f49Smrg	      elif test -n "$nm_file_list_spec"; then
819132001f49Smrg		func_basename "$output"
819232001f49Smrg		output_la=$func_basename_result
819332001f49Smrg		save_libobjs=$libobjs
819432001f49Smrg		save_output=$output
819532001f49Smrg		output=${output_objdir}/${output_la}.nm
819632001f49Smrg		func_to_tool_file "$output"
819732001f49Smrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
819832001f49Smrg		func_append delfiles " $output"
819932001f49Smrg		func_verbose "creating $NM input file list: $output"
820032001f49Smrg		for obj in $save_libobjs; do
820132001f49Smrg		  func_to_tool_file "$obj"
820232001f49Smrg		  $ECHO "$func_to_tool_file_result"
820332001f49Smrg		done > "$output"
820432001f49Smrg		eval cmd=\"$cmd1\"
820532001f49Smrg		func_show_eval "$cmd" 'exit $?'
820632001f49Smrg		output=$save_output
820732001f49Smrg		libobjs=$save_libobjs
820832001f49Smrg		skipped_export=false
820932001f49Smrg	      else
821032001f49Smrg		# The command line is too long to execute in one step.
821132001f49Smrg		func_verbose "using reloadable object file for export list..."
821232001f49Smrg		skipped_export=:
821332001f49Smrg		# Break out early, otherwise skipped_export may be
821432001f49Smrg		# set to false by a later but shorter cmd.
821532001f49Smrg		break
821632001f49Smrg	      fi
821732001f49Smrg	    done
821832001f49Smrg	    IFS="$save_ifs"
821932001f49Smrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
822032001f49Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
822132001f49Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
822232001f49Smrg	    fi
822332001f49Smrg	  fi
822432001f49Smrg	fi
822532001f49Smrg
822632001f49Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
822732001f49Smrg	  tmp_export_symbols="$export_symbols"
822832001f49Smrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
822932001f49Smrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
823032001f49Smrg	fi
823132001f49Smrg
823232001f49Smrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
823332001f49Smrg	  # The given exports_symbols file has to be filtered, so filter it.
823432001f49Smrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
823532001f49Smrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
823632001f49Smrg	  # 's' commands which not all seds can handle. GNU sed should be fine
823732001f49Smrg	  # though. Also, the filter scales superlinearly with the number of
823832001f49Smrg	  # global variables. join(1) would be nice here, but unfortunately
823932001f49Smrg	  # isn't a blessed tool.
824032001f49Smrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
824132001f49Smrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
824232001f49Smrg	  export_symbols=$output_objdir/$libname.def
824332001f49Smrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
824432001f49Smrg	fi
824532001f49Smrg
824632001f49Smrg	tmp_deplibs=
824732001f49Smrg	for test_deplib in $deplibs; do
824832001f49Smrg	  case " $convenience " in
824932001f49Smrg	  *" $test_deplib "*) ;;
825032001f49Smrg	  *)
825132001f49Smrg	    func_append tmp_deplibs " $test_deplib"
825232001f49Smrg	    ;;
825332001f49Smrg	  esac
825432001f49Smrg	done
825532001f49Smrg	deplibs="$tmp_deplibs"
825632001f49Smrg
825732001f49Smrg	if test -n "$convenience"; then
825832001f49Smrg	  if test -n "$whole_archive_flag_spec" &&
825932001f49Smrg	    test "$compiler_needs_object" = yes &&
826032001f49Smrg	    test -z "$libobjs"; then
826132001f49Smrg	    # extract the archives, so we have objects to list.
826232001f49Smrg	    # TODO: could optimize this to just extract one archive.
826332001f49Smrg	    whole_archive_flag_spec=
826432001f49Smrg	  fi
826532001f49Smrg	  if test -n "$whole_archive_flag_spec"; then
826632001f49Smrg	    save_libobjs=$libobjs
826732001f49Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
826832001f49Smrg	    test "X$libobjs" = "X " && libobjs=
826932001f49Smrg	  else
827032001f49Smrg	    gentop="$output_objdir/${outputname}x"
827132001f49Smrg	    func_append generated " $gentop"
827232001f49Smrg
827332001f49Smrg	    func_extract_archives $gentop $convenience
827432001f49Smrg	    func_append libobjs " $func_extract_archives_result"
827532001f49Smrg	    test "X$libobjs" = "X " && libobjs=
827632001f49Smrg	  fi
827732001f49Smrg	fi
827832001f49Smrg
827932001f49Smrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
828032001f49Smrg	  eval flag=\"$thread_safe_flag_spec\"
828132001f49Smrg	  func_append linker_flags " $flag"
828232001f49Smrg	fi
828332001f49Smrg
828432001f49Smrg	# Make a backup of the uninstalled library when relinking
828532001f49Smrg	if test "$opt_mode" = relink; then
828632001f49Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
828732001f49Smrg	fi
828832001f49Smrg
828932001f49Smrg	# Do each of the archive commands.
829032001f49Smrg	if test "$module" = yes && test -n "$module_cmds" ; then
829132001f49Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
829232001f49Smrg	    eval test_cmds=\"$module_expsym_cmds\"
829332001f49Smrg	    cmds=$module_expsym_cmds
829432001f49Smrg	  else
829532001f49Smrg	    eval test_cmds=\"$module_cmds\"
829632001f49Smrg	    cmds=$module_cmds
829732001f49Smrg	  fi
829832001f49Smrg	else
829932001f49Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
830032001f49Smrg	    eval test_cmds=\"$archive_expsym_cmds\"
830132001f49Smrg	    cmds=$archive_expsym_cmds
830232001f49Smrg	  else
830332001f49Smrg	    eval test_cmds=\"$archive_cmds\"
830432001f49Smrg	    cmds=$archive_cmds
830532001f49Smrg	  fi
830632001f49Smrg	fi
830732001f49Smrg
830832001f49Smrg	if test "X$skipped_export" != "X:" &&
830932001f49Smrg	   func_len " $test_cmds" &&
831032001f49Smrg	   len=$func_len_result &&
831132001f49Smrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
831232001f49Smrg	  :
831332001f49Smrg	else
831432001f49Smrg	  # The command line is too long to link in one step, link piecewise
831532001f49Smrg	  # or, if using GNU ld and skipped_export is not :, use a linker
831632001f49Smrg	  # script.
831732001f49Smrg
831832001f49Smrg	  # Save the value of $output and $libobjs because we want to
831932001f49Smrg	  # use them later.  If we have whole_archive_flag_spec, we
832032001f49Smrg	  # want to use save_libobjs as it was before
832132001f49Smrg	  # whole_archive_flag_spec was expanded, because we can't
832232001f49Smrg	  # assume the linker understands whole_archive_flag_spec.
832332001f49Smrg	  # This may have to be revisited, in case too many
832432001f49Smrg	  # convenience libraries get linked in and end up exceeding
832532001f49Smrg	  # the spec.
832632001f49Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
832732001f49Smrg	    save_libobjs=$libobjs
832832001f49Smrg	  fi
832932001f49Smrg	  save_output=$output
833032001f49Smrg	  func_basename "$output"
833132001f49Smrg	  output_la=$func_basename_result
833232001f49Smrg
833332001f49Smrg	  # Clear the reloadable object creation command queue and
833432001f49Smrg	  # initialize k to one.
833532001f49Smrg	  test_cmds=
833632001f49Smrg	  concat_cmds=
833732001f49Smrg	  objlist=
833832001f49Smrg	  last_robj=
833932001f49Smrg	  k=1
834032001f49Smrg
834132001f49Smrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
834232001f49Smrg	    output=${output_objdir}/${output_la}.lnkscript
834332001f49Smrg	    func_verbose "creating GNU ld script: $output"
834432001f49Smrg	    echo 'INPUT (' > $output
834532001f49Smrg	    for obj in $save_libobjs
834632001f49Smrg	    do
834732001f49Smrg	      func_to_tool_file "$obj"
834832001f49Smrg	      $ECHO "$func_to_tool_file_result" >> $output
834932001f49Smrg	    done
835032001f49Smrg	    echo ')' >> $output
835132001f49Smrg	    func_append delfiles " $output"
835232001f49Smrg	    func_to_tool_file "$output"
835332001f49Smrg	    output=$func_to_tool_file_result
835432001f49Smrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
835532001f49Smrg	    output=${output_objdir}/${output_la}.lnk
835632001f49Smrg	    func_verbose "creating linker input file list: $output"
835732001f49Smrg	    : > $output
835832001f49Smrg	    set x $save_libobjs
835932001f49Smrg	    shift
836032001f49Smrg	    firstobj=
836132001f49Smrg	    if test "$compiler_needs_object" = yes; then
836232001f49Smrg	      firstobj="$1 "
836332001f49Smrg	      shift
836432001f49Smrg	    fi
836532001f49Smrg	    for obj
836632001f49Smrg	    do
836732001f49Smrg	      func_to_tool_file "$obj"
836832001f49Smrg	      $ECHO "$func_to_tool_file_result" >> $output
836932001f49Smrg	    done
837032001f49Smrg	    func_append delfiles " $output"
837132001f49Smrg	    func_to_tool_file "$output"
837232001f49Smrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
837332001f49Smrg	  else
837432001f49Smrg	    if test -n "$save_libobjs"; then
837532001f49Smrg	      func_verbose "creating reloadable object files..."
837632001f49Smrg	      output=$output_objdir/$output_la-${k}.$objext
837732001f49Smrg	      eval test_cmds=\"$reload_cmds\"
837832001f49Smrg	      func_len " $test_cmds"
837932001f49Smrg	      len0=$func_len_result
838032001f49Smrg	      len=$len0
838132001f49Smrg
838232001f49Smrg	      # Loop over the list of objects to be linked.
838332001f49Smrg	      for obj in $save_libobjs
838432001f49Smrg	      do
838532001f49Smrg		func_len " $obj"
838632001f49Smrg		func_arith $len + $func_len_result
838732001f49Smrg		len=$func_arith_result
838832001f49Smrg		if test "X$objlist" = X ||
838932001f49Smrg		   test "$len" -lt "$max_cmd_len"; then
839032001f49Smrg		  func_append objlist " $obj"
839132001f49Smrg		else
839232001f49Smrg		  # The command $test_cmds is almost too long, add a
839332001f49Smrg		  # command to the queue.
839432001f49Smrg		  if test "$k" -eq 1 ; then
839532001f49Smrg		    # The first file doesn't have a previous command to add.
839632001f49Smrg		    reload_objs=$objlist
839732001f49Smrg		    eval concat_cmds=\"$reload_cmds\"
839832001f49Smrg		  else
839932001f49Smrg		    # All subsequent reloadable object files will link in
840032001f49Smrg		    # the last one created.
840132001f49Smrg		    reload_objs="$objlist $last_robj"
840232001f49Smrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
840332001f49Smrg		  fi
840432001f49Smrg		  last_robj=$output_objdir/$output_la-${k}.$objext
840532001f49Smrg		  func_arith $k + 1
840632001f49Smrg		  k=$func_arith_result
840732001f49Smrg		  output=$output_objdir/$output_la-${k}.$objext
840832001f49Smrg		  objlist=" $obj"
840932001f49Smrg		  func_len " $last_robj"
841032001f49Smrg		  func_arith $len0 + $func_len_result
841132001f49Smrg		  len=$func_arith_result
841232001f49Smrg		fi
841332001f49Smrg	      done
841432001f49Smrg	      # Handle the remaining objects by creating one last
841532001f49Smrg	      # reloadable object file.  All subsequent reloadable object
841632001f49Smrg	      # files will link in the last one created.
841732001f49Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
841832001f49Smrg	      reload_objs="$objlist $last_robj"
841932001f49Smrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
842032001f49Smrg	      if test -n "$last_robj"; then
842132001f49Smrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
842232001f49Smrg	      fi
842332001f49Smrg	      func_append delfiles " $output"
842432001f49Smrg
842532001f49Smrg	    else
842632001f49Smrg	      output=
842732001f49Smrg	    fi
842832001f49Smrg
842932001f49Smrg	    if ${skipped_export-false}; then
843032001f49Smrg	      func_verbose "generating symbol list for \`$libname.la'"
843132001f49Smrg	      export_symbols="$output_objdir/$libname.exp"
843232001f49Smrg	      $opt_dry_run || $RM $export_symbols
843332001f49Smrg	      libobjs=$output
843432001f49Smrg	      # Append the command to create the export file.
843532001f49Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
843632001f49Smrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
843732001f49Smrg	      if test -n "$last_robj"; then
843832001f49Smrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
843932001f49Smrg	      fi
844032001f49Smrg	    fi
844132001f49Smrg
844232001f49Smrg	    test -n "$save_libobjs" &&
844332001f49Smrg	      func_verbose "creating a temporary reloadable object file: $output"
844432001f49Smrg
844532001f49Smrg	    # Loop through the commands generated above and execute them.
844632001f49Smrg	    save_ifs="$IFS"; IFS='~'
844732001f49Smrg	    for cmd in $concat_cmds; do
844832001f49Smrg	      IFS="$save_ifs"
844932001f49Smrg	      $opt_silent || {
845032001f49Smrg		  func_quote_for_expand "$cmd"
845132001f49Smrg		  eval "func_echo $func_quote_for_expand_result"
845232001f49Smrg	      }
845332001f49Smrg	      $opt_dry_run || eval "$cmd" || {
845432001f49Smrg		lt_exit=$?
845532001f49Smrg
845632001f49Smrg		# Restore the uninstalled library and exit
845732001f49Smrg		if test "$opt_mode" = relink; then
845832001f49Smrg		  ( cd "$output_objdir" && \
845932001f49Smrg		    $RM "${realname}T" && \
846032001f49Smrg		    $MV "${realname}U" "$realname" )
846132001f49Smrg		fi
846232001f49Smrg
846332001f49Smrg		exit $lt_exit
846432001f49Smrg	      }
846532001f49Smrg	    done
846632001f49Smrg	    IFS="$save_ifs"
846732001f49Smrg
846832001f49Smrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
846932001f49Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
847032001f49Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
847132001f49Smrg	    fi
847232001f49Smrg	  fi
847332001f49Smrg
847432001f49Smrg          if ${skipped_export-false}; then
847532001f49Smrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
847632001f49Smrg	      tmp_export_symbols="$export_symbols"
847732001f49Smrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
847832001f49Smrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
847932001f49Smrg	    fi
848032001f49Smrg
848132001f49Smrg	    if test -n "$orig_export_symbols"; then
848232001f49Smrg	      # The given exports_symbols file has to be filtered, so filter it.
848332001f49Smrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
848432001f49Smrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
848532001f49Smrg	      # 's' commands which not all seds can handle. GNU sed should be fine
848632001f49Smrg	      # though. Also, the filter scales superlinearly with the number of
848732001f49Smrg	      # global variables. join(1) would be nice here, but unfortunately
848832001f49Smrg	      # isn't a blessed tool.
848932001f49Smrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
849032001f49Smrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
849132001f49Smrg	      export_symbols=$output_objdir/$libname.def
849232001f49Smrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
849332001f49Smrg	    fi
849432001f49Smrg	  fi
849532001f49Smrg
849632001f49Smrg	  libobjs=$output
849732001f49Smrg	  # Restore the value of output.
849832001f49Smrg	  output=$save_output
849932001f49Smrg
850032001f49Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
850132001f49Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
850232001f49Smrg	    test "X$libobjs" = "X " && libobjs=
850332001f49Smrg	  fi
850432001f49Smrg	  # Expand the library linking commands again to reset the
850532001f49Smrg	  # value of $libobjs for piecewise linking.
850632001f49Smrg
850732001f49Smrg	  # Do each of the archive commands.
850832001f49Smrg	  if test "$module" = yes && test -n "$module_cmds" ; then
850932001f49Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
851032001f49Smrg	      cmds=$module_expsym_cmds
851132001f49Smrg	    else
851232001f49Smrg	      cmds=$module_cmds
851332001f49Smrg	    fi
851432001f49Smrg	  else
851532001f49Smrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
851632001f49Smrg	      cmds=$archive_expsym_cmds
851732001f49Smrg	    else
851832001f49Smrg	      cmds=$archive_cmds
851932001f49Smrg	    fi
852032001f49Smrg	  fi
852132001f49Smrg	fi
852232001f49Smrg
852332001f49Smrg	if test -n "$delfiles"; then
852432001f49Smrg	  # Append the command to remove temporary files to $cmds.
852532001f49Smrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
852632001f49Smrg	fi
852732001f49Smrg
852832001f49Smrg	# Add any objects from preloaded convenience libraries
852932001f49Smrg	if test -n "$dlprefiles"; then
853032001f49Smrg	  gentop="$output_objdir/${outputname}x"
853132001f49Smrg	  func_append generated " $gentop"
853232001f49Smrg
853332001f49Smrg	  func_extract_archives $gentop $dlprefiles
853432001f49Smrg	  func_append libobjs " $func_extract_archives_result"
853532001f49Smrg	  test "X$libobjs" = "X " && libobjs=
853632001f49Smrg	fi
853732001f49Smrg
853832001f49Smrg	save_ifs="$IFS"; IFS='~'
853932001f49Smrg	for cmd in $cmds; do
854032001f49Smrg	  IFS="$save_ifs"
854132001f49Smrg	  eval cmd=\"$cmd\"
854232001f49Smrg	  $opt_silent || {
854332001f49Smrg	    func_quote_for_expand "$cmd"
854432001f49Smrg	    eval "func_echo $func_quote_for_expand_result"
854532001f49Smrg	  }
854632001f49Smrg	  $opt_dry_run || eval "$cmd" || {
854732001f49Smrg	    lt_exit=$?
854832001f49Smrg
854932001f49Smrg	    # Restore the uninstalled library and exit
855032001f49Smrg	    if test "$opt_mode" = relink; then
855132001f49Smrg	      ( cd "$output_objdir" && \
855232001f49Smrg	        $RM "${realname}T" && \
855332001f49Smrg		$MV "${realname}U" "$realname" )
855432001f49Smrg	    fi
855532001f49Smrg
855632001f49Smrg	    exit $lt_exit
855732001f49Smrg	  }
855832001f49Smrg	done
855932001f49Smrg	IFS="$save_ifs"
856032001f49Smrg
856132001f49Smrg	# Restore the uninstalled library and exit
856232001f49Smrg	if test "$opt_mode" = relink; then
856332001f49Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
856432001f49Smrg
856532001f49Smrg	  if test -n "$convenience"; then
856632001f49Smrg	    if test -z "$whole_archive_flag_spec"; then
856732001f49Smrg	      func_show_eval '${RM}r "$gentop"'
856832001f49Smrg	    fi
856932001f49Smrg	  fi
857032001f49Smrg
857132001f49Smrg	  exit $EXIT_SUCCESS
857232001f49Smrg	fi
857332001f49Smrg
857432001f49Smrg	# Create links to the real library.
857532001f49Smrg	for linkname in $linknames; do
857632001f49Smrg	  if test "$realname" != "$linkname"; then
857732001f49Smrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
857832001f49Smrg	  fi
857932001f49Smrg	done
858032001f49Smrg
858132001f49Smrg	# If -module or -export-dynamic was specified, set the dlname.
858232001f49Smrg	if test "$module" = yes || test "$export_dynamic" = yes; then
858332001f49Smrg	  # On all known operating systems, these are identical.
858432001f49Smrg	  dlname="$soname"
858532001f49Smrg	fi
858632001f49Smrg      fi
858732001f49Smrg      ;;
858832001f49Smrg
858932001f49Smrg    obj)
859032001f49Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
859132001f49Smrg	func_warning "\`-dlopen' is ignored for objects"
859232001f49Smrg      fi
859332001f49Smrg
859432001f49Smrg      case " $deplibs" in
859532001f49Smrg      *\ -l* | *\ -L*)
859632001f49Smrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
859732001f49Smrg      esac
859832001f49Smrg
859932001f49Smrg      test -n "$rpath" && \
860032001f49Smrg	func_warning "\`-rpath' is ignored for objects"
860132001f49Smrg
860232001f49Smrg      test -n "$xrpath" && \
860332001f49Smrg	func_warning "\`-R' is ignored for objects"
860432001f49Smrg
860532001f49Smrg      test -n "$vinfo" && \
860632001f49Smrg	func_warning "\`-version-info' is ignored for objects"
860732001f49Smrg
860832001f49Smrg      test -n "$release" && \
860932001f49Smrg	func_warning "\`-release' is ignored for objects"
861032001f49Smrg
861132001f49Smrg      case $output in
861232001f49Smrg      *.lo)
861332001f49Smrg	test -n "$objs$old_deplibs" && \
861432001f49Smrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
861532001f49Smrg
861632001f49Smrg	libobj=$output
861732001f49Smrg	func_lo2o "$libobj"
861832001f49Smrg	obj=$func_lo2o_result
861932001f49Smrg	;;
862032001f49Smrg      *)
862132001f49Smrg	libobj=
862232001f49Smrg	obj="$output"
862332001f49Smrg	;;
862432001f49Smrg      esac
862532001f49Smrg
862632001f49Smrg      # Delete the old objects.
862732001f49Smrg      $opt_dry_run || $RM $obj $libobj
862832001f49Smrg
862932001f49Smrg      # Objects from convenience libraries.  This assumes
863032001f49Smrg      # single-version convenience libraries.  Whenever we create
863132001f49Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
863232001f49Smrg      # the extraction.
863332001f49Smrg      reload_conv_objs=
863432001f49Smrg      gentop=
863532001f49Smrg      # reload_cmds runs $LD directly, so let us get rid of
863632001f49Smrg      # -Wl from whole_archive_flag_spec and hope we can get by with
863732001f49Smrg      # turning comma into space..
863832001f49Smrg      wl=
863932001f49Smrg
864032001f49Smrg      if test -n "$convenience"; then
864132001f49Smrg	if test -n "$whole_archive_flag_spec"; then
864232001f49Smrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
864332001f49Smrg	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
864432001f49Smrg	else
864532001f49Smrg	  gentop="$output_objdir/${obj}x"
864632001f49Smrg	  func_append generated " $gentop"
864732001f49Smrg
864832001f49Smrg	  func_extract_archives $gentop $convenience
864932001f49Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
865032001f49Smrg	fi
865132001f49Smrg      fi
865232001f49Smrg
865332001f49Smrg      # If we're not building shared, we need to use non_pic_objs
865432001f49Smrg      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
865532001f49Smrg
865632001f49Smrg      # Create the old-style object.
865732001f49Smrg      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
865832001f49Smrg
865932001f49Smrg      output="$obj"
866032001f49Smrg      func_execute_cmds "$reload_cmds" 'exit $?'
866132001f49Smrg
866232001f49Smrg      # Exit if we aren't doing a library object file.
866332001f49Smrg      if test -z "$libobj"; then
866432001f49Smrg	if test -n "$gentop"; then
866532001f49Smrg	  func_show_eval '${RM}r "$gentop"'
866632001f49Smrg	fi
866732001f49Smrg
866832001f49Smrg	exit $EXIT_SUCCESS
866932001f49Smrg      fi
867032001f49Smrg
867132001f49Smrg      if test "$build_libtool_libs" != yes; then
867232001f49Smrg	if test -n "$gentop"; then
867332001f49Smrg	  func_show_eval '${RM}r "$gentop"'
867432001f49Smrg	fi
867532001f49Smrg
867632001f49Smrg	# Create an invalid libtool object if no PIC, so that we don't
867732001f49Smrg	# accidentally link it into a program.
867832001f49Smrg	# $show "echo timestamp > $libobj"
867932001f49Smrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
868032001f49Smrg	exit $EXIT_SUCCESS
868132001f49Smrg      fi
868232001f49Smrg
868332001f49Smrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
868432001f49Smrg	# Only do commands if we really have different PIC objects.
868532001f49Smrg	reload_objs="$libobjs $reload_conv_objs"
868632001f49Smrg	output="$libobj"
868732001f49Smrg	func_execute_cmds "$reload_cmds" 'exit $?'
868832001f49Smrg      fi
868932001f49Smrg
869032001f49Smrg      if test -n "$gentop"; then
869132001f49Smrg	func_show_eval '${RM}r "$gentop"'
869232001f49Smrg      fi
869332001f49Smrg
869432001f49Smrg      exit $EXIT_SUCCESS
869532001f49Smrg      ;;
869632001f49Smrg
869732001f49Smrg    prog)
869832001f49Smrg      case $host in
869932001f49Smrg	*cygwin*) func_stripname '' '.exe' "$output"
870032001f49Smrg	          output=$func_stripname_result.exe;;
870132001f49Smrg      esac
870232001f49Smrg      test -n "$vinfo" && \
870332001f49Smrg	func_warning "\`-version-info' is ignored for programs"
870432001f49Smrg
870532001f49Smrg      test -n "$release" && \
870632001f49Smrg	func_warning "\`-release' is ignored for programs"
870732001f49Smrg
870832001f49Smrg      test "$preload" = yes \
870932001f49Smrg        && test "$dlopen_support" = unknown \
871032001f49Smrg	&& test "$dlopen_self" = unknown \
871132001f49Smrg	&& test "$dlopen_self_static" = unknown && \
871232001f49Smrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
871332001f49Smrg
871432001f49Smrg      case $host in
871532001f49Smrg      *-*-rhapsody* | *-*-darwin1.[012])
871632001f49Smrg	# On Rhapsody replace the C library is the System framework
871732001f49Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
871832001f49Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
871932001f49Smrg	;;
872032001f49Smrg      esac
872132001f49Smrg
872232001f49Smrg      case $host in
872332001f49Smrg      *-*-darwin*)
872432001f49Smrg	# Don't allow lazy linking, it breaks C++ global constructors
872532001f49Smrg	# But is supposedly fixed on 10.4 or later (yay!).
872632001f49Smrg	if test "$tagname" = CXX ; then
872732001f49Smrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
872832001f49Smrg	    10.[0123])
872932001f49Smrg	      func_append compile_command " ${wl}-bind_at_load"
873032001f49Smrg	      func_append finalize_command " ${wl}-bind_at_load"
873132001f49Smrg	    ;;
873232001f49Smrg	  esac
873332001f49Smrg	fi
873432001f49Smrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
873532001f49Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
873632001f49Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
873732001f49Smrg	;;
873832001f49Smrg      esac
873932001f49Smrg
874032001f49Smrg
874132001f49Smrg      # move library search paths that coincide with paths to not yet
874232001f49Smrg      # installed libraries to the beginning of the library search list
874332001f49Smrg      new_libs=
874432001f49Smrg      for path in $notinst_path; do
874532001f49Smrg	case " $new_libs " in
874632001f49Smrg	*" -L$path/$objdir "*) ;;
874732001f49Smrg	*)
874832001f49Smrg	  case " $compile_deplibs " in
874932001f49Smrg	  *" -L$path/$objdir "*)
875032001f49Smrg	    func_append new_libs " -L$path/$objdir" ;;
875132001f49Smrg	  esac
875232001f49Smrg	  ;;
875332001f49Smrg	esac
875432001f49Smrg      done
875532001f49Smrg      for deplib in $compile_deplibs; do
875632001f49Smrg	case $deplib in
875732001f49Smrg	-L*)
875832001f49Smrg	  case " $new_libs " in
875932001f49Smrg	  *" $deplib "*) ;;
876032001f49Smrg	  *) func_append new_libs " $deplib" ;;
876132001f49Smrg	  esac
876232001f49Smrg	  ;;
876332001f49Smrg	*) func_append new_libs " $deplib" ;;
876432001f49Smrg	esac
876532001f49Smrg      done
876632001f49Smrg      compile_deplibs="$new_libs"
876732001f49Smrg
876832001f49Smrg
876932001f49Smrg      func_append compile_command " $compile_deplibs"
877032001f49Smrg      func_append finalize_command " $finalize_deplibs"
877132001f49Smrg
877232001f49Smrg      if test -n "$rpath$xrpath"; then
877332001f49Smrg	# If the user specified any rpath flags, then add them.
877432001f49Smrg	for libdir in $rpath $xrpath; do
877532001f49Smrg	  # This is the magic to use -rpath.
877632001f49Smrg	  case "$finalize_rpath " in
877732001f49Smrg	  *" $libdir "*) ;;
877832001f49Smrg	  *) func_append finalize_rpath " $libdir" ;;
877932001f49Smrg	  esac
878032001f49Smrg	done
878132001f49Smrg      fi
878232001f49Smrg
878332001f49Smrg      # Now hardcode the library paths
878432001f49Smrg      rpath=
878532001f49Smrg      hardcode_libdirs=
878632001f49Smrg      for libdir in $compile_rpath $finalize_rpath; do
878732001f49Smrg	if test -n "$hardcode_libdir_flag_spec"; then
878832001f49Smrg	  if test -n "$hardcode_libdir_separator"; then
878932001f49Smrg	    if test -z "$hardcode_libdirs"; then
879032001f49Smrg	      hardcode_libdirs="$libdir"
879132001f49Smrg	    else
879232001f49Smrg	      # Just accumulate the unique libdirs.
879332001f49Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
879432001f49Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
879532001f49Smrg		;;
879632001f49Smrg	      *)
879732001f49Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
879832001f49Smrg		;;
879932001f49Smrg	      esac
880032001f49Smrg	    fi
880132001f49Smrg	  else
880232001f49Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
880332001f49Smrg	    func_append rpath " $flag"
880432001f49Smrg	  fi
880532001f49Smrg	elif test -n "$runpath_var"; then
880632001f49Smrg	  case "$perm_rpath " in
880732001f49Smrg	  *" $libdir "*) ;;
880832001f49Smrg	  *) func_append perm_rpath " $libdir" ;;
880932001f49Smrg	  esac
881032001f49Smrg	fi
881132001f49Smrg	case $host in
881232001f49Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
881332001f49Smrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
881432001f49Smrg	  case :$dllsearchpath: in
881532001f49Smrg	  *":$libdir:"*) ;;
881632001f49Smrg	  ::) dllsearchpath=$libdir;;
881732001f49Smrg	  *) func_append dllsearchpath ":$libdir";;
881832001f49Smrg	  esac
881932001f49Smrg	  case :$dllsearchpath: in
882032001f49Smrg	  *":$testbindir:"*) ;;
882132001f49Smrg	  ::) dllsearchpath=$testbindir;;
882232001f49Smrg	  *) func_append dllsearchpath ":$testbindir";;
882332001f49Smrg	  esac
882432001f49Smrg	  ;;
882532001f49Smrg	esac
882632001f49Smrg      done
882732001f49Smrg      # Substitute the hardcoded libdirs into the rpath.
882832001f49Smrg      if test -n "$hardcode_libdir_separator" &&
882932001f49Smrg	 test -n "$hardcode_libdirs"; then
883032001f49Smrg	libdir="$hardcode_libdirs"
883132001f49Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
883232001f49Smrg      fi
883332001f49Smrg      compile_rpath="$rpath"
883432001f49Smrg
883532001f49Smrg      rpath=
883632001f49Smrg      hardcode_libdirs=
883732001f49Smrg      for libdir in $finalize_rpath; do
883832001f49Smrg	if test -n "$hardcode_libdir_flag_spec"; then
883932001f49Smrg	  if test -n "$hardcode_libdir_separator"; then
884032001f49Smrg	    if test -z "$hardcode_libdirs"; then
884132001f49Smrg	      hardcode_libdirs="$libdir"
884232001f49Smrg	    else
884332001f49Smrg	      # Just accumulate the unique libdirs.
884432001f49Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
884532001f49Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
884632001f49Smrg		;;
884732001f49Smrg	      *)
884832001f49Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
884932001f49Smrg		;;
885032001f49Smrg	      esac
885132001f49Smrg	    fi
885232001f49Smrg	  else
885332001f49Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
885432001f49Smrg	    func_append rpath " $flag"
885532001f49Smrg	  fi
885632001f49Smrg	elif test -n "$runpath_var"; then
885732001f49Smrg	  case "$finalize_perm_rpath " in
885832001f49Smrg	  *" $libdir "*) ;;
885932001f49Smrg	  *) func_append finalize_perm_rpath " $libdir" ;;
886032001f49Smrg	  esac
886132001f49Smrg	fi
886232001f49Smrg      done
886332001f49Smrg      # Substitute the hardcoded libdirs into the rpath.
886432001f49Smrg      if test -n "$hardcode_libdir_separator" &&
886532001f49Smrg	 test -n "$hardcode_libdirs"; then
886632001f49Smrg	libdir="$hardcode_libdirs"
886732001f49Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
886832001f49Smrg      fi
886932001f49Smrg      finalize_rpath="$rpath"
887032001f49Smrg
887132001f49Smrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
887232001f49Smrg	# Transform all the library objects into standard objects.
887332001f49Smrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
887432001f49Smrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
887532001f49Smrg      fi
887632001f49Smrg
887732001f49Smrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
887832001f49Smrg
887932001f49Smrg      # template prelinking step
888032001f49Smrg      if test -n "$prelink_cmds"; then
888132001f49Smrg	func_execute_cmds "$prelink_cmds" 'exit $?'
888232001f49Smrg      fi
888332001f49Smrg
888432001f49Smrg      wrappers_required=yes
888532001f49Smrg      case $host in
888632001f49Smrg      *cegcc* | *mingw32ce*)
888732001f49Smrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
888832001f49Smrg        wrappers_required=no
888932001f49Smrg        ;;
889032001f49Smrg      *cygwin* | *mingw* )
889132001f49Smrg        if test "$build_libtool_libs" != yes; then
889232001f49Smrg          wrappers_required=no
889332001f49Smrg        fi
889432001f49Smrg        ;;
889532001f49Smrg      *)
889632001f49Smrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
889732001f49Smrg          wrappers_required=no
889832001f49Smrg        fi
889932001f49Smrg        ;;
890032001f49Smrg      esac
890132001f49Smrg      if test "$wrappers_required" = no; then
890232001f49Smrg	# Replace the output file specification.
890332001f49Smrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
890432001f49Smrg	link_command="$compile_command$compile_rpath"
890532001f49Smrg
890632001f49Smrg	# We have no uninstalled library dependencies, so finalize right now.
890732001f49Smrg	exit_status=0
890832001f49Smrg	func_show_eval "$link_command" 'exit_status=$?'
890932001f49Smrg
891032001f49Smrg	if test -n "$postlink_cmds"; then
891132001f49Smrg	  func_to_tool_file "$output"
891232001f49Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
891332001f49Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
891432001f49Smrg	fi
891532001f49Smrg
891632001f49Smrg	# Delete the generated files.
891732001f49Smrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
891832001f49Smrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
891932001f49Smrg	fi
892032001f49Smrg
892132001f49Smrg	exit $exit_status
892232001f49Smrg      fi
892332001f49Smrg
892432001f49Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
892532001f49Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
892632001f49Smrg      fi
892732001f49Smrg      if test -n "$finalize_shlibpath"; then
892832001f49Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
892932001f49Smrg      fi
893032001f49Smrg
893132001f49Smrg      compile_var=
893232001f49Smrg      finalize_var=
893332001f49Smrg      if test -n "$runpath_var"; then
893432001f49Smrg	if test -n "$perm_rpath"; then
893532001f49Smrg	  # We should set the runpath_var.
893632001f49Smrg	  rpath=
893732001f49Smrg	  for dir in $perm_rpath; do
893832001f49Smrg	    func_append rpath "$dir:"
893932001f49Smrg	  done
894032001f49Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
894132001f49Smrg	fi
894232001f49Smrg	if test -n "$finalize_perm_rpath"; then
894332001f49Smrg	  # We should set the runpath_var.
894432001f49Smrg	  rpath=
894532001f49Smrg	  for dir in $finalize_perm_rpath; do
894632001f49Smrg	    func_append rpath "$dir:"
894732001f49Smrg	  done
894832001f49Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
894932001f49Smrg	fi
895032001f49Smrg      fi
895132001f49Smrg
895232001f49Smrg      if test "$no_install" = yes; then
895332001f49Smrg	# We don't need to create a wrapper script.
895432001f49Smrg	link_command="$compile_var$compile_command$compile_rpath"
895532001f49Smrg	# Replace the output file specification.
895632001f49Smrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
895732001f49Smrg	# Delete the old output file.
895832001f49Smrg	$opt_dry_run || $RM $output
895932001f49Smrg	# Link the executable and exit
896032001f49Smrg	func_show_eval "$link_command" 'exit $?'
896132001f49Smrg
896232001f49Smrg	if test -n "$postlink_cmds"; then
896332001f49Smrg	  func_to_tool_file "$output"
896432001f49Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
896532001f49Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
896632001f49Smrg	fi
896732001f49Smrg
896832001f49Smrg	exit $EXIT_SUCCESS
896932001f49Smrg      fi
897032001f49Smrg
897132001f49Smrg      if test "$hardcode_action" = relink; then
897232001f49Smrg	# Fast installation is not supported
897332001f49Smrg	link_command="$compile_var$compile_command$compile_rpath"
897432001f49Smrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
897532001f49Smrg
897632001f49Smrg	func_warning "this platform does not like uninstalled shared libraries"
897732001f49Smrg	func_warning "\`$output' will be relinked during installation"
897832001f49Smrg      else
897932001f49Smrg	if test "$fast_install" != no; then
898032001f49Smrg	  link_command="$finalize_var$compile_command$finalize_rpath"
898132001f49Smrg	  if test "$fast_install" = yes; then
898232001f49Smrg	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
898332001f49Smrg	  else
898432001f49Smrg	    # fast_install is set to needless
898532001f49Smrg	    relink_command=
898632001f49Smrg	  fi
898732001f49Smrg	else
898832001f49Smrg	  link_command="$compile_var$compile_command$compile_rpath"
898932001f49Smrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
899032001f49Smrg	fi
899132001f49Smrg      fi
899232001f49Smrg
899332001f49Smrg      # Replace the output file specification.
899432001f49Smrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
899532001f49Smrg
899632001f49Smrg      # Delete the old output files.
899732001f49Smrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
899832001f49Smrg
899932001f49Smrg      func_show_eval "$link_command" 'exit $?'
900032001f49Smrg
900132001f49Smrg      if test -n "$postlink_cmds"; then
900232001f49Smrg	func_to_tool_file "$output_objdir/$outputname"
900332001f49Smrg	postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
900432001f49Smrg	func_execute_cmds "$postlink_cmds" 'exit $?'
900532001f49Smrg      fi
900632001f49Smrg
900732001f49Smrg      # Now create the wrapper script.
900832001f49Smrg      func_verbose "creating $output"
900932001f49Smrg
901032001f49Smrg      # Quote the relink command for shipping.
901132001f49Smrg      if test -n "$relink_command"; then
901232001f49Smrg	# Preserve any variables that may affect compiler behavior
901332001f49Smrg	for var in $variables_saved_for_relink; do
901432001f49Smrg	  if eval test -z \"\${$var+set}\"; then
901532001f49Smrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
901632001f49Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
901732001f49Smrg	    relink_command="$var=; export $var; $relink_command"
901832001f49Smrg	  else
901932001f49Smrg	    func_quote_for_eval "$var_value"
902032001f49Smrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
902132001f49Smrg	  fi
902232001f49Smrg	done
902332001f49Smrg	relink_command="(cd `pwd`; $relink_command)"
902432001f49Smrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
902532001f49Smrg      fi
902632001f49Smrg
902732001f49Smrg      # Only actually do things if not in dry run mode.
902832001f49Smrg      $opt_dry_run || {
902932001f49Smrg	# win32 will think the script is a binary if it has
903032001f49Smrg	# a .exe suffix, so we strip it off here.
903132001f49Smrg	case $output in
903232001f49Smrg	  *.exe) func_stripname '' '.exe' "$output"
903332001f49Smrg	         output=$func_stripname_result ;;
903432001f49Smrg	esac
903532001f49Smrg	# test for cygwin because mv fails w/o .exe extensions
903632001f49Smrg	case $host in
903732001f49Smrg	  *cygwin*)
903832001f49Smrg	    exeext=.exe
903932001f49Smrg	    func_stripname '' '.exe' "$outputname"
904032001f49Smrg	    outputname=$func_stripname_result ;;
904132001f49Smrg	  *) exeext= ;;
904232001f49Smrg	esac
904332001f49Smrg	case $host in
904432001f49Smrg	  *cygwin* | *mingw* )
904532001f49Smrg	    func_dirname_and_basename "$output" "" "."
904632001f49Smrg	    output_name=$func_basename_result
904732001f49Smrg	    output_path=$func_dirname_result
904832001f49Smrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
904932001f49Smrg	    cwrapper="$output_path/$output_name.exe"
905032001f49Smrg	    $RM $cwrappersource $cwrapper
905132001f49Smrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
905232001f49Smrg
905332001f49Smrg	    func_emit_cwrapperexe_src > $cwrappersource
905432001f49Smrg
905532001f49Smrg	    # The wrapper executable is built using the $host compiler,
905632001f49Smrg	    # because it contains $host paths and files. If cross-
905732001f49Smrg	    # compiling, it, like the target executable, must be
905832001f49Smrg	    # executed on the $host or under an emulation environment.
905932001f49Smrg	    $opt_dry_run || {
906032001f49Smrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
906132001f49Smrg	      $STRIP $cwrapper
906232001f49Smrg	    }
906332001f49Smrg
906432001f49Smrg	    # Now, create the wrapper script for func_source use:
906532001f49Smrg	    func_ltwrapper_scriptname $cwrapper
906632001f49Smrg	    $RM $func_ltwrapper_scriptname_result
906732001f49Smrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
906832001f49Smrg	    $opt_dry_run || {
906932001f49Smrg	      # note: this script will not be executed, so do not chmod.
907032001f49Smrg	      if test "x$build" = "x$host" ; then
907132001f49Smrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
907232001f49Smrg	      else
907332001f49Smrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
907432001f49Smrg	      fi
907532001f49Smrg	    }
907632001f49Smrg	  ;;
907732001f49Smrg	  * )
907832001f49Smrg	    $RM $output
907932001f49Smrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
908032001f49Smrg
908132001f49Smrg	    func_emit_wrapper no > $output
908232001f49Smrg	    chmod +x $output
908332001f49Smrg	  ;;
908432001f49Smrg	esac
908532001f49Smrg      }
908632001f49Smrg      exit $EXIT_SUCCESS
908732001f49Smrg      ;;
908832001f49Smrg    esac
908932001f49Smrg
909032001f49Smrg    # See if we need to build an old-fashioned archive.
909132001f49Smrg    for oldlib in $oldlibs; do
909232001f49Smrg
909332001f49Smrg      if test "$build_libtool_libs" = convenience; then
909432001f49Smrg	oldobjs="$libobjs_save $symfileobj"
909532001f49Smrg	addlibs="$convenience"
909632001f49Smrg	build_libtool_libs=no
909732001f49Smrg      else
909832001f49Smrg	if test "$build_libtool_libs" = module; then
909932001f49Smrg	  oldobjs="$libobjs_save"
910032001f49Smrg	  build_libtool_libs=no
910132001f49Smrg	else
910232001f49Smrg	  oldobjs="$old_deplibs $non_pic_objects"
910332001f49Smrg	  if test "$preload" = yes && test -f "$symfileobj"; then
910432001f49Smrg	    func_append oldobjs " $symfileobj"
910532001f49Smrg	  fi
910632001f49Smrg	fi
910732001f49Smrg	addlibs="$old_convenience"
910832001f49Smrg      fi
910932001f49Smrg
911032001f49Smrg      if test -n "$addlibs"; then
911132001f49Smrg	gentop="$output_objdir/${outputname}x"
911232001f49Smrg	func_append generated " $gentop"
911332001f49Smrg
911432001f49Smrg	func_extract_archives $gentop $addlibs
911532001f49Smrg	func_append oldobjs " $func_extract_archives_result"
911632001f49Smrg      fi
911732001f49Smrg
911832001f49Smrg      # Do each command in the archive commands.
911932001f49Smrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
912032001f49Smrg	cmds=$old_archive_from_new_cmds
912132001f49Smrg      else
912232001f49Smrg
912332001f49Smrg	# Add any objects from preloaded convenience libraries
912432001f49Smrg	if test -n "$dlprefiles"; then
912532001f49Smrg	  gentop="$output_objdir/${outputname}x"
912632001f49Smrg	  func_append generated " $gentop"
912732001f49Smrg
912832001f49Smrg	  func_extract_archives $gentop $dlprefiles
912932001f49Smrg	  func_append oldobjs " $func_extract_archives_result"
913032001f49Smrg	fi
913132001f49Smrg
913232001f49Smrg	# POSIX demands no paths to be encoded in archives.  We have
913332001f49Smrg	# to avoid creating archives with duplicate basenames if we
913432001f49Smrg	# might have to extract them afterwards, e.g., when creating a
913532001f49Smrg	# static archive out of a convenience library, or when linking
913632001f49Smrg	# the entirety of a libtool archive into another (currently
913732001f49Smrg	# not supported by libtool).
913832001f49Smrg	if (for obj in $oldobjs
913932001f49Smrg	    do
914032001f49Smrg	      func_basename "$obj"
914132001f49Smrg	      $ECHO "$func_basename_result"
914232001f49Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
914332001f49Smrg	  :
914432001f49Smrg	else
914532001f49Smrg	  echo "copying selected object files to avoid basename conflicts..."
914632001f49Smrg	  gentop="$output_objdir/${outputname}x"
914732001f49Smrg	  func_append generated " $gentop"
914832001f49Smrg	  func_mkdir_p "$gentop"
914932001f49Smrg	  save_oldobjs=$oldobjs
915032001f49Smrg	  oldobjs=
915132001f49Smrg	  counter=1
915232001f49Smrg	  for obj in $save_oldobjs
915332001f49Smrg	  do
915432001f49Smrg	    func_basename "$obj"
915532001f49Smrg	    objbase="$func_basename_result"
915632001f49Smrg	    case " $oldobjs " in
915732001f49Smrg	    " ") oldobjs=$obj ;;
915832001f49Smrg	    *[\ /]"$objbase "*)
915932001f49Smrg	      while :; do
916032001f49Smrg		# Make sure we don't pick an alternate name that also
916132001f49Smrg		# overlaps.
916232001f49Smrg		newobj=lt$counter-$objbase
916332001f49Smrg		func_arith $counter + 1
916432001f49Smrg		counter=$func_arith_result
916532001f49Smrg		case " $oldobjs " in
916632001f49Smrg		*[\ /]"$newobj "*) ;;
916732001f49Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
916832001f49Smrg		esac
916932001f49Smrg	      done
917032001f49Smrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
917132001f49Smrg	      func_append oldobjs " $gentop/$newobj"
917232001f49Smrg	      ;;
917332001f49Smrg	    *) func_append oldobjs " $obj" ;;
917432001f49Smrg	    esac
917532001f49Smrg	  done
917632001f49Smrg	fi
917732001f49Smrg	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
917832001f49Smrg	tool_oldlib=$func_to_tool_file_result
917932001f49Smrg	eval cmds=\"$old_archive_cmds\"
918032001f49Smrg
918132001f49Smrg	func_len " $cmds"
918232001f49Smrg	len=$func_len_result
918332001f49Smrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
918432001f49Smrg	  cmds=$old_archive_cmds
918532001f49Smrg	elif test -n "$archiver_list_spec"; then
918632001f49Smrg	  func_verbose "using command file archive linking..."
918732001f49Smrg	  for obj in $oldobjs
918832001f49Smrg	  do
918932001f49Smrg	    func_to_tool_file "$obj"
919032001f49Smrg	    $ECHO "$func_to_tool_file_result"
919132001f49Smrg	  done > $output_objdir/$libname.libcmd
919232001f49Smrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
919332001f49Smrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
919432001f49Smrg	  cmds=$old_archive_cmds
919532001f49Smrg	else
919632001f49Smrg	  # the command line is too long to link in one step, link in parts
919732001f49Smrg	  func_verbose "using piecewise archive linking..."
919832001f49Smrg	  save_RANLIB=$RANLIB
919932001f49Smrg	  RANLIB=:
920032001f49Smrg	  objlist=
920132001f49Smrg	  concat_cmds=
920232001f49Smrg	  save_oldobjs=$oldobjs
920332001f49Smrg	  oldobjs=
920432001f49Smrg	  # Is there a better way of finding the last object in the list?
920532001f49Smrg	  for obj in $save_oldobjs
920632001f49Smrg	  do
920732001f49Smrg	    last_oldobj=$obj
920832001f49Smrg	  done
920932001f49Smrg	  eval test_cmds=\"$old_archive_cmds\"
921032001f49Smrg	  func_len " $test_cmds"
921132001f49Smrg	  len0=$func_len_result
921232001f49Smrg	  len=$len0
921332001f49Smrg	  for obj in $save_oldobjs
921432001f49Smrg	  do
921532001f49Smrg	    func_len " $obj"
921632001f49Smrg	    func_arith $len + $func_len_result
921732001f49Smrg	    len=$func_arith_result
921832001f49Smrg	    func_append objlist " $obj"
921932001f49Smrg	    if test "$len" -lt "$max_cmd_len"; then
922032001f49Smrg	      :
922132001f49Smrg	    else
922232001f49Smrg	      # the above command should be used before it gets too long
922332001f49Smrg	      oldobjs=$objlist
922432001f49Smrg	      if test "$obj" = "$last_oldobj" ; then
922532001f49Smrg		RANLIB=$save_RANLIB
922632001f49Smrg	      fi
922732001f49Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
922832001f49Smrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
922932001f49Smrg	      objlist=
923032001f49Smrg	      len=$len0
923132001f49Smrg	    fi
923232001f49Smrg	  done
923332001f49Smrg	  RANLIB=$save_RANLIB
923432001f49Smrg	  oldobjs=$objlist
923532001f49Smrg	  if test "X$oldobjs" = "X" ; then
923632001f49Smrg	    eval cmds=\"\$concat_cmds\"
923732001f49Smrg	  else
923832001f49Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
923932001f49Smrg	  fi
924032001f49Smrg	fi
924132001f49Smrg      fi
924232001f49Smrg      func_execute_cmds "$cmds" 'exit $?'
924332001f49Smrg    done
924432001f49Smrg
924532001f49Smrg    test -n "$generated" && \
924632001f49Smrg      func_show_eval "${RM}r$generated"
924732001f49Smrg
924832001f49Smrg    # Now create the libtool archive.
924932001f49Smrg    case $output in
925032001f49Smrg    *.la)
925132001f49Smrg      old_library=
925232001f49Smrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
925332001f49Smrg      func_verbose "creating $output"
925432001f49Smrg
925532001f49Smrg      # Preserve any variables that may affect compiler behavior
925632001f49Smrg      for var in $variables_saved_for_relink; do
925732001f49Smrg	if eval test -z \"\${$var+set}\"; then
925832001f49Smrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
925932001f49Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
926032001f49Smrg	  relink_command="$var=; export $var; $relink_command"
926132001f49Smrg	else
926232001f49Smrg	  func_quote_for_eval "$var_value"
926332001f49Smrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
926432001f49Smrg	fi
926532001f49Smrg      done
926632001f49Smrg      # Quote the link command for shipping.
926732001f49Smrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
926832001f49Smrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
926932001f49Smrg      if test "$hardcode_automatic" = yes ; then
927032001f49Smrg	relink_command=
927132001f49Smrg      fi
927232001f49Smrg
927332001f49Smrg      # Only create the output if not a dry run.
927432001f49Smrg      $opt_dry_run || {
927532001f49Smrg	for installed in no yes; do
927632001f49Smrg	  if test "$installed" = yes; then
927732001f49Smrg	    if test -z "$install_libdir"; then
927832001f49Smrg	      break
927932001f49Smrg	    fi
928032001f49Smrg	    output="$output_objdir/$outputname"i
928132001f49Smrg	    # Replace all uninstalled libtool libraries with the installed ones
928232001f49Smrg	    newdependency_libs=
928332001f49Smrg	    for deplib in $dependency_libs; do
928432001f49Smrg	      case $deplib in
928532001f49Smrg	      *.la)
928632001f49Smrg		func_basename "$deplib"
928732001f49Smrg		name="$func_basename_result"
928832001f49Smrg		func_resolve_sysroot "$deplib"
928932001f49Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
929032001f49Smrg		test -z "$libdir" && \
929132001f49Smrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
929232001f49Smrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
929332001f49Smrg		;;
929432001f49Smrg	      -L*)
929532001f49Smrg		func_stripname -L '' "$deplib"
929632001f49Smrg		func_replace_sysroot "$func_stripname_result"
929732001f49Smrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
929832001f49Smrg		;;
929932001f49Smrg	      -R*)
930032001f49Smrg		func_stripname -R '' "$deplib"
930132001f49Smrg		func_replace_sysroot "$func_stripname_result"
930232001f49Smrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
930332001f49Smrg		;;
930432001f49Smrg	      *) func_append newdependency_libs " $deplib" ;;
930532001f49Smrg	      esac
930632001f49Smrg	    done
930732001f49Smrg	    dependency_libs="$newdependency_libs"
930832001f49Smrg	    newdlfiles=
930932001f49Smrg
931032001f49Smrg	    for lib in $dlfiles; do
931132001f49Smrg	      case $lib in
931232001f49Smrg	      *.la)
931332001f49Smrg	        func_basename "$lib"
931432001f49Smrg		name="$func_basename_result"
931532001f49Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
931632001f49Smrg		test -z "$libdir" && \
931732001f49Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
931832001f49Smrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
931932001f49Smrg		;;
932032001f49Smrg	      *) func_append newdlfiles " $lib" ;;
932132001f49Smrg	      esac
932232001f49Smrg	    done
932332001f49Smrg	    dlfiles="$newdlfiles"
932432001f49Smrg	    newdlprefiles=
932532001f49Smrg	    for lib in $dlprefiles; do
932632001f49Smrg	      case $lib in
932732001f49Smrg	      *.la)
932832001f49Smrg		# Only pass preopened files to the pseudo-archive (for
932932001f49Smrg		# eventual linking with the app. that links it) if we
933032001f49Smrg		# didn't already link the preopened objects directly into
933132001f49Smrg		# the library:
933232001f49Smrg		func_basename "$lib"
933332001f49Smrg		name="$func_basename_result"
933432001f49Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
933532001f49Smrg		test -z "$libdir" && \
933632001f49Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
933732001f49Smrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
933832001f49Smrg		;;
933932001f49Smrg	      esac
934032001f49Smrg	    done
934132001f49Smrg	    dlprefiles="$newdlprefiles"
934232001f49Smrg	  else
934332001f49Smrg	    newdlfiles=
934432001f49Smrg	    for lib in $dlfiles; do
934532001f49Smrg	      case $lib in
934632001f49Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
934732001f49Smrg		*) abs=`pwd`"/$lib" ;;
934832001f49Smrg	      esac
934932001f49Smrg	      func_append newdlfiles " $abs"
935032001f49Smrg	    done
935132001f49Smrg	    dlfiles="$newdlfiles"
935232001f49Smrg	    newdlprefiles=
935332001f49Smrg	    for lib in $dlprefiles; do
935432001f49Smrg	      case $lib in
935532001f49Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
935632001f49Smrg		*) abs=`pwd`"/$lib" ;;
935732001f49Smrg	      esac
935832001f49Smrg	      func_append newdlprefiles " $abs"
935932001f49Smrg	    done
936032001f49Smrg	    dlprefiles="$newdlprefiles"
936132001f49Smrg	  fi
936232001f49Smrg	  $RM $output
936332001f49Smrg	  # place dlname in correct position for cygwin
936432001f49Smrg	  # In fact, it would be nice if we could use this code for all target
936532001f49Smrg	  # systems that can't hard-code library paths into their executables
936632001f49Smrg	  # and that have no shared library path variable independent of PATH,
936732001f49Smrg	  # but it turns out we can't easily determine that from inspecting
936832001f49Smrg	  # libtool variables, so we have to hard-code the OSs to which it
936932001f49Smrg	  # applies here; at the moment, that means platforms that use the PE
937032001f49Smrg	  # object format with DLL files.  See the long comment at the top of
937132001f49Smrg	  # tests/bindir.at for full details.
937232001f49Smrg	  tdlname=$dlname
937332001f49Smrg	  case $host,$output,$installed,$module,$dlname in
937432001f49Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
937532001f49Smrg	      # If a -bindir argument was supplied, place the dll there.
937632001f49Smrg	      if test "x$bindir" != x ;
937732001f49Smrg	      then
937832001f49Smrg		func_relative_path "$install_libdir" "$bindir"
937932001f49Smrg		tdlname=$func_relative_path_result$dlname
938032001f49Smrg	      else
938132001f49Smrg		# Otherwise fall back on heuristic.
938232001f49Smrg		tdlname=../bin/$dlname
938332001f49Smrg	      fi
938432001f49Smrg	      ;;
938532001f49Smrg	  esac
938632001f49Smrg	  $ECHO > $output "\
938732001f49Smrg# $outputname - a libtool library file
938832001f49Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
938932001f49Smrg#
939032001f49Smrg# Please DO NOT delete this file!
939132001f49Smrg# It is necessary for linking the library.
939232001f49Smrg
939332001f49Smrg# The name that we can dlopen(3).
939432001f49Smrgdlname='$tdlname'
939532001f49Smrg
939632001f49Smrg# Names of this library.
939732001f49Smrglibrary_names='$library_names'
939832001f49Smrg
939932001f49Smrg# The name of the static archive.
940032001f49Smrgold_library='$old_library'
940132001f49Smrg
940232001f49Smrg# Linker flags that can not go in dependency_libs.
940332001f49Smrginherited_linker_flags='$new_inherited_linker_flags'
940432001f49Smrg
940532001f49Smrg# Libraries that this one depends upon.
940632001f49Smrgdependency_libs='$dependency_libs'
940732001f49Smrg
940832001f49Smrg# Names of additional weak libraries provided by this library
940932001f49Smrgweak_library_names='$weak_libs'
941032001f49Smrg
941132001f49Smrg# Version information for $libname.
941232001f49Smrgcurrent=$current
941332001f49Smrgage=$age
941432001f49Smrgrevision=$revision
941532001f49Smrg
941632001f49Smrg# Is this an already installed library?
941732001f49Smrginstalled=$installed
941832001f49Smrg
941932001f49Smrg# Should we warn about portability when linking against -modules?
942032001f49Smrgshouldnotlink=$module
942132001f49Smrg
942232001f49Smrg# Files to dlopen/dlpreopen
942332001f49Smrgdlopen='$dlfiles'
942432001f49Smrgdlpreopen='$dlprefiles'
942532001f49Smrg
942632001f49Smrg# Directory that this library needs to be installed in:
942732001f49Smrglibdir='$install_libdir'"
942832001f49Smrg	  if test "$installed" = no && test "$need_relink" = yes; then
942932001f49Smrg	    $ECHO >> $output "\
943032001f49Smrgrelink_command=\"$relink_command\""
943132001f49Smrg	  fi
943232001f49Smrg	done
943332001f49Smrg      }
943432001f49Smrg
943532001f49Smrg      # Do a symbolic link so that the libtool archive can be found in
943632001f49Smrg      # LD_LIBRARY_PATH before the program is installed.
943732001f49Smrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
943832001f49Smrg      ;;
943932001f49Smrg    esac
944032001f49Smrg    exit $EXIT_SUCCESS
944132001f49Smrg}
944232001f49Smrg
944332001f49Smrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
944432001f49Smrg    func_mode_link ${1+"$@"}
944532001f49Smrg
944632001f49Smrg
944732001f49Smrg# func_mode_uninstall arg...
944832001f49Smrgfunc_mode_uninstall ()
944932001f49Smrg{
945032001f49Smrg    $opt_debug
945132001f49Smrg    RM="$nonopt"
945232001f49Smrg    files=
945332001f49Smrg    rmforce=
945432001f49Smrg    exit_status=0
945532001f49Smrg
945632001f49Smrg    # This variable tells wrapper scripts just to set variables rather
945732001f49Smrg    # than running their programs.
945832001f49Smrg    libtool_install_magic="$magic"
945932001f49Smrg
946032001f49Smrg    for arg
946132001f49Smrg    do
946232001f49Smrg      case $arg in
946332001f49Smrg      -f) func_append RM " $arg"; rmforce=yes ;;
946432001f49Smrg      -*) func_append RM " $arg" ;;
946532001f49Smrg      *) func_append files " $arg" ;;
946632001f49Smrg      esac
946732001f49Smrg    done
946832001f49Smrg
946932001f49Smrg    test -z "$RM" && \
947032001f49Smrg      func_fatal_help "you must specify an RM program"
947132001f49Smrg
947232001f49Smrg    rmdirs=
947332001f49Smrg
947432001f49Smrg    for file in $files; do
947532001f49Smrg      func_dirname "$file" "" "."
947632001f49Smrg      dir="$func_dirname_result"
947732001f49Smrg      if test "X$dir" = X.; then
947832001f49Smrg	odir="$objdir"
947932001f49Smrg      else
948032001f49Smrg	odir="$dir/$objdir"
948132001f49Smrg      fi
948232001f49Smrg      func_basename "$file"
948332001f49Smrg      name="$func_basename_result"
948432001f49Smrg      test "$opt_mode" = uninstall && odir="$dir"
948532001f49Smrg
948632001f49Smrg      # Remember odir for removal later, being careful to avoid duplicates
948732001f49Smrg      if test "$opt_mode" = clean; then
948832001f49Smrg	case " $rmdirs " in
948932001f49Smrg	  *" $odir "*) ;;
949032001f49Smrg	  *) func_append rmdirs " $odir" ;;
949132001f49Smrg	esac
949232001f49Smrg      fi
949332001f49Smrg
949432001f49Smrg      # Don't error if the file doesn't exist and rm -f was used.
949532001f49Smrg      if { test -L "$file"; } >/dev/null 2>&1 ||
949632001f49Smrg	 { test -h "$file"; } >/dev/null 2>&1 ||
949732001f49Smrg	 test -f "$file"; then
949832001f49Smrg	:
949932001f49Smrg      elif test -d "$file"; then
950032001f49Smrg	exit_status=1
950132001f49Smrg	continue
950232001f49Smrg      elif test "$rmforce" = yes; then
950332001f49Smrg	continue
950432001f49Smrg      fi
950532001f49Smrg
950632001f49Smrg      rmfiles="$file"
950732001f49Smrg
950832001f49Smrg      case $name in
950932001f49Smrg      *.la)
951032001f49Smrg	# Possibly a libtool archive, so verify it.
951132001f49Smrg	if func_lalib_p "$file"; then
951232001f49Smrg	  func_source $dir/$name
951332001f49Smrg
951432001f49Smrg	  # Delete the libtool libraries and symlinks.
951532001f49Smrg	  for n in $library_names; do
951632001f49Smrg	    func_append rmfiles " $odir/$n"
951732001f49Smrg	  done
951832001f49Smrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
951932001f49Smrg
952032001f49Smrg	  case "$opt_mode" in
952132001f49Smrg	  clean)
952232001f49Smrg	    case " $library_names " in
952332001f49Smrg	    *" $dlname "*) ;;
952432001f49Smrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
952532001f49Smrg	    esac
952632001f49Smrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
952732001f49Smrg	    ;;
952832001f49Smrg	  uninstall)
952932001f49Smrg	    if test -n "$library_names"; then
953032001f49Smrg	      # Do each command in the postuninstall commands.
953132001f49Smrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
953232001f49Smrg	    fi
953332001f49Smrg
953432001f49Smrg	    if test -n "$old_library"; then
953532001f49Smrg	      # Do each command in the old_postuninstall commands.
953632001f49Smrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
953732001f49Smrg	    fi
953832001f49Smrg	    # FIXME: should reinstall the best remaining shared library.
953932001f49Smrg	    ;;
954032001f49Smrg	  esac
954132001f49Smrg	fi
954232001f49Smrg	;;
954332001f49Smrg
954432001f49Smrg      *.lo)
954532001f49Smrg	# Possibly a libtool object, so verify it.
954632001f49Smrg	if func_lalib_p "$file"; then
954732001f49Smrg
954832001f49Smrg	  # Read the .lo file
954932001f49Smrg	  func_source $dir/$name
955032001f49Smrg
955132001f49Smrg	  # Add PIC object to the list of files to remove.
955232001f49Smrg	  if test -n "$pic_object" &&
955332001f49Smrg	     test "$pic_object" != none; then
955432001f49Smrg	    func_append rmfiles " $dir/$pic_object"
955532001f49Smrg	  fi
955632001f49Smrg
955732001f49Smrg	  # Add non-PIC object to the list of files to remove.
955832001f49Smrg	  if test -n "$non_pic_object" &&
955932001f49Smrg	     test "$non_pic_object" != none; then
956032001f49Smrg	    func_append rmfiles " $dir/$non_pic_object"
956132001f49Smrg	  fi
956232001f49Smrg	fi
956332001f49Smrg	;;
956432001f49Smrg
956532001f49Smrg      *)
956632001f49Smrg	if test "$opt_mode" = clean ; then
956732001f49Smrg	  noexename=$name
956832001f49Smrg	  case $file in
956932001f49Smrg	  *.exe)
957032001f49Smrg	    func_stripname '' '.exe' "$file"
957132001f49Smrg	    file=$func_stripname_result
957232001f49Smrg	    func_stripname '' '.exe' "$name"
957332001f49Smrg	    noexename=$func_stripname_result
957432001f49Smrg	    # $file with .exe has already been added to rmfiles,
957532001f49Smrg	    # add $file without .exe
957632001f49Smrg	    func_append rmfiles " $file"
957732001f49Smrg	    ;;
957832001f49Smrg	  esac
957932001f49Smrg	  # Do a test to see if this is a libtool program.
958032001f49Smrg	  if func_ltwrapper_p "$file"; then
958132001f49Smrg	    if func_ltwrapper_executable_p "$file"; then
958232001f49Smrg	      func_ltwrapper_scriptname "$file"
958332001f49Smrg	      relink_command=
958432001f49Smrg	      func_source $func_ltwrapper_scriptname_result
958532001f49Smrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
958632001f49Smrg	    else
958732001f49Smrg	      relink_command=
958832001f49Smrg	      func_source $dir/$noexename
958932001f49Smrg	    fi
959032001f49Smrg
959132001f49Smrg	    # note $name still contains .exe if it was in $file originally
959232001f49Smrg	    # as does the version of $file that was added into $rmfiles
959332001f49Smrg	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
959432001f49Smrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
959532001f49Smrg	      func_append rmfiles " $odir/lt-$name"
959632001f49Smrg	    fi
959732001f49Smrg	    if test "X$noexename" != "X$name" ; then
959832001f49Smrg	      func_append rmfiles " $odir/lt-${noexename}.c"
959932001f49Smrg	    fi
960032001f49Smrg	  fi
960132001f49Smrg	fi
960232001f49Smrg	;;
960332001f49Smrg      esac
960432001f49Smrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
960532001f49Smrg    done
960632001f49Smrg
960732001f49Smrg    # Try to remove the ${objdir}s in the directories where we deleted files
960832001f49Smrg    for dir in $rmdirs; do
960932001f49Smrg      if test -d "$dir"; then
961032001f49Smrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
961132001f49Smrg      fi
961232001f49Smrg    done
961332001f49Smrg
961432001f49Smrg    exit $exit_status
961532001f49Smrg}
961632001f49Smrg
961732001f49Smrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
961832001f49Smrg    func_mode_uninstall ${1+"$@"}
961932001f49Smrg
962032001f49Smrgtest -z "$opt_mode" && {
962132001f49Smrg  help="$generic_help"
962232001f49Smrg  func_fatal_help "you must specify a MODE"
962332001f49Smrg}
962432001f49Smrg
962532001f49Smrgtest -z "$exec_cmd" && \
962632001f49Smrg  func_fatal_help "invalid operation mode \`$opt_mode'"
962732001f49Smrg
962832001f49Smrgif test -n "$exec_cmd"; then
962932001f49Smrg  eval exec "$exec_cmd"
963032001f49Smrg  exit $EXIT_FAILURE
963132001f49Smrgfi
963232001f49Smrg
963332001f49Smrgexit $exit_status
963432001f49Smrg
963532001f49Smrg
963632001f49Smrg# The TAGs below are defined such that we never get into a situation
963732001f49Smrg# in which we disable both kinds of libraries.  Given conflicting
963832001f49Smrg# choices, we go for a static library, that is the most portable,
963932001f49Smrg# since we can't tell whether shared libraries were disabled because
964032001f49Smrg# the user asked for that or because the platform doesn't support
964132001f49Smrg# them.  This is particularly important on AIX, because we don't
964232001f49Smrg# support having both static and shared libraries enabled at the same
964332001f49Smrg# time on that platform, so we default to a shared-only configuration.
964432001f49Smrg# If a disable-shared tag is given, we'll fallback to a static-only
964532001f49Smrg# configuration.  But we'll never go from static-only to shared-only.
964632001f49Smrg
964732001f49Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
964832001f49Smrgbuild_libtool_libs=no
964932001f49Smrgbuild_old_libs=yes
965032001f49Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
965132001f49Smrg
965232001f49Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
965332001f49Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
965432001f49Smrg# ### END LIBTOOL TAG CONFIG: disable-static
965532001f49Smrg
965632001f49Smrg# Local Variables:
965732001f49Smrg# mode:shell-script
965832001f49Smrg# sh-indentation:2
965932001f49Smrg# End:
966032001f49Smrg# vi:sw=2
966132001f49Smrg
9662