ltmain.sh revision 3bfa90b6
1b68e1f86Smrg
23bfa90b6Smrg# libtool (GNU libtool) 2.4.2
3b68e1f86Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
4b68e1f86Smrg
53bfa90b6Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
63bfa90b6Smrg# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
7b68e1f86Smrg# This is free software; see the source for copying conditions.  There is NO
8b68e1f86Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9b68e1f86Smrg
10b68e1f86Smrg# GNU Libtool is free software; you can redistribute it and/or modify
116df26cacSmrg# it under the terms of the GNU General Public License as published by
126df26cacSmrg# the Free Software Foundation; either version 2 of the License, or
136df26cacSmrg# (at your option) any later version.
146df26cacSmrg#
15b68e1f86Smrg# As a special exception to the GNU General Public License,
16b68e1f86Smrg# if you distribute this file as part of a program or library that
17b68e1f86Smrg# is built using GNU Libtool, you may include this file under the
18b68e1f86Smrg# same distribution terms that you use for the rest of that program.
19b68e1f86Smrg#
20b68e1f86Smrg# GNU Libtool is distributed in the hope that it will be useful, but
216df26cacSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
226df26cacSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
236df26cacSmrg# General Public License for more details.
246df26cacSmrg#
256df26cacSmrg# You should have received a copy of the GNU General Public License
26b68e1f86Smrg# along with GNU Libtool; see the file COPYING.  If not, a copy
27b68e1f86Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html,
28b68e1f86Smrg# or obtained by writing to the Free Software Foundation, Inc.,
29b68e1f86Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
306df26cacSmrg
31b68e1f86Smrg# Usage: $progname [OPTION]... [MODE-ARG]...
32b68e1f86Smrg#
33b68e1f86Smrg# Provide generalized library-building support services.
34b68e1f86Smrg#
353bfa90b6Smrg#       --config             show all configuration variables
363bfa90b6Smrg#       --debug              enable verbose shell tracing
373bfa90b6Smrg#   -n, --dry-run            display commands without modifying any files
383bfa90b6Smrg#       --features           display basic configuration information and exit
393bfa90b6Smrg#       --mode=MODE          use operation mode MODE
403bfa90b6Smrg#       --preserve-dup-deps  don't remove duplicate dependency libraries
413bfa90b6Smrg#       --quiet, --silent    don't print informational messages
423bfa90b6Smrg#       --no-quiet, --no-silent
433bfa90b6Smrg#                            print informational messages (default)
443bfa90b6Smrg#       --no-warn            don't display warning messages
453bfa90b6Smrg#       --tag=TAG            use configuration variables from tag TAG
463bfa90b6Smrg#   -v, --verbose            print more informational messages than default
473bfa90b6Smrg#       --no-verbose         don't print the extra informational messages
483bfa90b6Smrg#       --version            print version information
493bfa90b6Smrg#   -h, --help, --help-all   print short, long, or detailed help message
50b68e1f86Smrg#
51b68e1f86Smrg# MODE must be one of the following:
52b68e1f86Smrg#
533bfa90b6Smrg#         clean              remove files from the build directory
543bfa90b6Smrg#         compile            compile a source file into a libtool object
553bfa90b6Smrg#         execute            automatically set library path, then run a program
563bfa90b6Smrg#         finish             complete the installation of libtool libraries
573bfa90b6Smrg#         install            install libraries or executables
583bfa90b6Smrg#         link               create a library or an executable
593bfa90b6Smrg#         uninstall          remove libraries from an installed directory
60b68e1f86Smrg#
613bfa90b6Smrg# MODE-ARGS vary depending on the MODE.  When passed as first option,
623bfa90b6Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
63b68e1f86Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
64b68e1f86Smrg#
65b68e1f86Smrg# When reporting a bug, please describe a test case to reproduce it and
66b68e1f86Smrg# include the following information:
67b68e1f86Smrg#
683bfa90b6Smrg#         host-triplet:	$host
693bfa90b6Smrg#         shell:		$SHELL
703bfa90b6Smrg#         compiler:		$LTCC
713bfa90b6Smrg#         compiler flags:		$LTCFLAGS
723bfa90b6Smrg#         linker:		$LD (gnu? $with_gnu_ld)
733bfa90b6Smrg#         $progname:	(GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1
743bfa90b6Smrg#         automake:	$automake_version
753bfa90b6Smrg#         autoconf:	$autoconf_version
76b68e1f86Smrg#
77b68e1f86Smrg# Report bugs to <bug-libtool@gnu.org>.
783bfa90b6Smrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
793bfa90b6Smrg# General help using GNU software: <http://www.gnu.org/gethelp/>.
806df26cacSmrg
813bfa90b6SmrgPROGRAM=libtool
826df26cacSmrgPACKAGE=libtool
833bfa90b6SmrgVERSION="2.4.2 Debian-2.4.2-1ubuntu1"
84b68e1f86SmrgTIMESTAMP=""
853bfa90b6Smrgpackage_revision=1.3337
8616fd1166Smrg
87b68e1f86Smrg# Be Bourne compatible
8816fd1166Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
8916fd1166Smrg  emulate sh
9016fd1166Smrg  NULLCMD=:
9116fd1166Smrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
9216fd1166Smrg  # is contrary to our usage.  Disable this feature.
9316fd1166Smrg  alias -g '${1+"$@"}'='"$@"'
946df26cacSmrg  setopt NO_GLOB_SUBST
9516fd1166Smrgelse
9616fd1166Smrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
976df26cacSmrgfi
9816fd1166SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
9916fd1166SmrgDUALCASE=1; export DUALCASE # for MKS sh
1006df26cacSmrg
1013bfa90b6Smrg# A function that is used when there is no print builtin or printf.
1023bfa90b6Smrgfunc_fallback_echo ()
1033bfa90b6Smrg{
1043bfa90b6Smrg  eval 'cat <<_LTECHO_EOF
1053bfa90b6Smrg$1
1063bfa90b6Smrg_LTECHO_EOF'
1073bfa90b6Smrg}
1083bfa90b6Smrg
109b68e1f86Smrg# NLS nuisances: We save the old values to restore during execute mode.
110b68e1f86Smrglt_user_locale=
111b68e1f86Smrglt_safe_locale=
112b68e1f86Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
11316fd1166Smrgdo
11416fd1166Smrg  eval "if test \"\${$lt_var+set}\" = set; then
115b68e1f86Smrg          save_$lt_var=\$$lt_var
116b68e1f86Smrg          $lt_var=C
11716fd1166Smrg	  export $lt_var
118b68e1f86Smrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
119b68e1f86Smrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
12016fd1166Smrg	fi"
12116fd1166Smrgdone
1223bfa90b6SmrgLC_ALL=C
1233bfa90b6SmrgLANGUAGE=C
1243bfa90b6Smrgexport LANGUAGE LC_ALL
1256df26cacSmrg
126b68e1f86Smrg$lt_unset CDPATH
127b68e1f86Smrg
128b68e1f86Smrg
1293bfa90b6Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
1303bfa90b6Smrg# is ksh but when the shell is invoked as "sh" and the current value of
1313bfa90b6Smrg# the _XPG environment variable is not equal to 1 (one), the special
1323bfa90b6Smrg# positional parameter $0, within a function call, is the name of the
1333bfa90b6Smrg# function.
1343bfa90b6Smrgprogpath="$0"
135b68e1f86Smrg
136b68e1f86Smrg
137b68e1f86Smrg
138b68e1f86Smrg: ${CP="cp -f"}
1393bfa90b6Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
140b68e1f86Smrg: ${MAKE="make"}
141b68e1f86Smrg: ${MKDIR="mkdir"}
142b68e1f86Smrg: ${MV="mv -f"}
143b68e1f86Smrg: ${RM="rm -f"}
144b68e1f86Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
145b68e1f86Smrg: ${Xsed="$SED -e 1s/^X//"}
146b68e1f86Smrg
147b68e1f86Smrg# Global variables:
148b68e1f86SmrgEXIT_SUCCESS=0
149b68e1f86SmrgEXIT_FAILURE=1
150b68e1f86SmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
151b68e1f86SmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
152b68e1f86Smrg
153b68e1f86Smrgexit_status=$EXIT_SUCCESS
154b68e1f86Smrg
1556df26cacSmrg# Make sure IFS has a sensible default
1566df26cacSmrglt_nl='
1576df26cacSmrg'
1586df26cacSmrgIFS=" 	$lt_nl"
1596df26cacSmrg
160b68e1f86Smrgdirname="s,/[^/]*$,,"
161b68e1f86Smrgbasename="s,^.*/,,"
162b68e1f86Smrg
1633bfa90b6Smrg# func_dirname file append nondir_replacement
1643bfa90b6Smrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
1653bfa90b6Smrg# otherwise set result to NONDIR_REPLACEMENT.
1663bfa90b6Smrgfunc_dirname ()
1673bfa90b6Smrg{
1683bfa90b6Smrg    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
1693bfa90b6Smrg    if test "X$func_dirname_result" = "X${1}"; then
1703bfa90b6Smrg      func_dirname_result="${3}"
1713bfa90b6Smrg    else
1723bfa90b6Smrg      func_dirname_result="$func_dirname_result${2}"
1733bfa90b6Smrg    fi
1743bfa90b6Smrg} # func_dirname may be replaced by extended shell implementation
1753bfa90b6Smrg
1763bfa90b6Smrg
1773bfa90b6Smrg# func_basename file
1783bfa90b6Smrgfunc_basename ()
1793bfa90b6Smrg{
1803bfa90b6Smrg    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
1813bfa90b6Smrg} # func_basename may be replaced by extended shell implementation
1823bfa90b6Smrg
1833bfa90b6Smrg
184b68e1f86Smrg# func_dirname_and_basename file append nondir_replacement
185b68e1f86Smrg# perform func_basename and func_dirname in a single function
186b68e1f86Smrg# call:
187b68e1f86Smrg#   dirname:  Compute the dirname of FILE.  If nonempty,
188b68e1f86Smrg#             add APPEND to the result, otherwise set result
189b68e1f86Smrg#             to NONDIR_REPLACEMENT.
190b68e1f86Smrg#             value returned in "$func_dirname_result"
191b68e1f86Smrg#   basename: Compute filename of FILE.
192b68e1f86Smrg#             value retuned in "$func_basename_result"
193b68e1f86Smrg# Implementation must be kept synchronized with func_dirname
194b68e1f86Smrg# and func_basename. For efficiency, we do not delegate to
195b68e1f86Smrg# those functions but instead duplicate the functionality here.
196b68e1f86Smrgfunc_dirname_and_basename ()
197b68e1f86Smrg{
1983bfa90b6Smrg    # Extract subdirectory from the argument.
1993bfa90b6Smrg    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
2003bfa90b6Smrg    if test "X$func_dirname_result" = "X${1}"; then
2013bfa90b6Smrg      func_dirname_result="${3}"
2023bfa90b6Smrg    else
2033bfa90b6Smrg      func_dirname_result="$func_dirname_result${2}"
2043bfa90b6Smrg    fi
2053bfa90b6Smrg    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
2063bfa90b6Smrg} # func_dirname_and_basename may be replaced by extended shell implementation
2073bfa90b6Smrg
2083bfa90b6Smrg
2093bfa90b6Smrg# func_stripname prefix suffix name
2103bfa90b6Smrg# strip PREFIX and SUFFIX off of NAME.
2113bfa90b6Smrg# PREFIX and SUFFIX must not contain globbing or regex special
2123bfa90b6Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading
2133bfa90b6Smrg# dot (in which case that matches only a dot).
2143bfa90b6Smrg# func_strip_suffix prefix name
2153bfa90b6Smrgfunc_stripname ()
2163bfa90b6Smrg{
2173bfa90b6Smrg    case ${2} in
2183bfa90b6Smrg      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
2193bfa90b6Smrg      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
2203bfa90b6Smrg    esac
2213bfa90b6Smrg} # func_stripname may be replaced by extended shell implementation
2223bfa90b6Smrg
2233bfa90b6Smrg
2243bfa90b6Smrg# These SED scripts presuppose an absolute path with a trailing slash.
2253bfa90b6Smrgpathcar='s,^/\([^/]*\).*$,\1,'
2263bfa90b6Smrgpathcdr='s,^/[^/]*,,'
2273bfa90b6Smrgremovedotparts=':dotsl
2283bfa90b6Smrg		s@/\./@/@g
2293bfa90b6Smrg		t dotsl
2303bfa90b6Smrg		s,/\.$,/,'
2313bfa90b6Smrgcollapseslashes='s@/\{1,\}@/@g'
2323bfa90b6Smrgfinalslash='s,/*$,/,'
2333bfa90b6Smrg
2343bfa90b6Smrg# func_normal_abspath PATH
2353bfa90b6Smrg# Remove doubled-up and trailing slashes, "." path components,
2363bfa90b6Smrg# and cancel out any ".." path components in PATH after making
2373bfa90b6Smrg# it an absolute path.
2383bfa90b6Smrg#             value returned in "$func_normal_abspath_result"
2393bfa90b6Smrgfunc_normal_abspath ()
2403bfa90b6Smrg{
2413bfa90b6Smrg  # Start from root dir and reassemble the path.
2423bfa90b6Smrg  func_normal_abspath_result=
2433bfa90b6Smrg  func_normal_abspath_tpath=$1
2443bfa90b6Smrg  func_normal_abspath_altnamespace=
2453bfa90b6Smrg  case $func_normal_abspath_tpath in
2463bfa90b6Smrg    "")
2473bfa90b6Smrg      # Empty path, that just means $cwd.
2483bfa90b6Smrg      func_stripname '' '/' "`pwd`"
2493bfa90b6Smrg      func_normal_abspath_result=$func_stripname_result
2503bfa90b6Smrg      return
2513bfa90b6Smrg    ;;
2523bfa90b6Smrg    # The next three entries are used to spot a run of precisely
2533bfa90b6Smrg    # two leading slashes without using negated character classes;
2543bfa90b6Smrg    # we take advantage of case's first-match behaviour.
2553bfa90b6Smrg    ///*)
2563bfa90b6Smrg      # Unusual form of absolute path, do nothing.
2573bfa90b6Smrg    ;;
2583bfa90b6Smrg    //*)
2593bfa90b6Smrg      # Not necessarily an ordinary path; POSIX reserves leading '//'
2603bfa90b6Smrg      # and for example Cygwin uses it to access remote file shares
2613bfa90b6Smrg      # over CIFS/SMB, so we conserve a leading double slash if found.
2623bfa90b6Smrg      func_normal_abspath_altnamespace=/
2633bfa90b6Smrg    ;;
2643bfa90b6Smrg    /*)
2653bfa90b6Smrg      # Absolute path, do nothing.
2663bfa90b6Smrg    ;;
2673bfa90b6Smrg    *)
2683bfa90b6Smrg      # Relative path, prepend $cwd.
2693bfa90b6Smrg      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
2703bfa90b6Smrg    ;;
2713bfa90b6Smrg  esac
2723bfa90b6Smrg  # Cancel out all the simple stuff to save iterations.  We also want
2733bfa90b6Smrg  # the path to end with a slash for ease of parsing, so make sure
2743bfa90b6Smrg  # there is one (and only one) here.
2753bfa90b6Smrg  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
2763bfa90b6Smrg        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
2773bfa90b6Smrg  while :; do
2783bfa90b6Smrg    # Processed it all yet?
2793bfa90b6Smrg    if test "$func_normal_abspath_tpath" = / ; then
2803bfa90b6Smrg      # If we ascended to the root using ".." the result may be empty now.
2813bfa90b6Smrg      if test -z "$func_normal_abspath_result" ; then
2823bfa90b6Smrg        func_normal_abspath_result=/
2833bfa90b6Smrg      fi
2843bfa90b6Smrg      break
2853bfa90b6Smrg    fi
2863bfa90b6Smrg    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
2873bfa90b6Smrg        -e "$pathcar"`
2883bfa90b6Smrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
2893bfa90b6Smrg        -e "$pathcdr"`
2903bfa90b6Smrg    # Figure out what to do with it
2913bfa90b6Smrg    case $func_normal_abspath_tcomponent in
2923bfa90b6Smrg      "")
2933bfa90b6Smrg        # Trailing empty path component, ignore it.
2943bfa90b6Smrg      ;;
2953bfa90b6Smrg      ..)
2963bfa90b6Smrg        # Parent dir; strip last assembled component from result.
2973bfa90b6Smrg        func_dirname "$func_normal_abspath_result"
2983bfa90b6Smrg        func_normal_abspath_result=$func_dirname_result
2993bfa90b6Smrg      ;;
3003bfa90b6Smrg      *)
3013bfa90b6Smrg        # Actual path component, append it.
3023bfa90b6Smrg        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
3033bfa90b6Smrg      ;;
3043bfa90b6Smrg    esac
3053bfa90b6Smrg  done
3063bfa90b6Smrg  # Restore leading double-slash if one was found on entry.
3073bfa90b6Smrg  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
308b68e1f86Smrg}
3096df26cacSmrg
3103bfa90b6Smrg# func_relative_path SRCDIR DSTDIR
3113bfa90b6Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing
3123bfa90b6Smrg# slash if non-empty, suitable for immediately appending a filename
3133bfa90b6Smrg# without needing to append a separator.
3143bfa90b6Smrg#             value returned in "$func_relative_path_result"
3153bfa90b6Smrgfunc_relative_path ()
3163bfa90b6Smrg{
3173bfa90b6Smrg  func_relative_path_result=
3183bfa90b6Smrg  func_normal_abspath "$1"
3193bfa90b6Smrg  func_relative_path_tlibdir=$func_normal_abspath_result
3203bfa90b6Smrg  func_normal_abspath "$2"
3213bfa90b6Smrg  func_relative_path_tbindir=$func_normal_abspath_result
3223bfa90b6Smrg
3233bfa90b6Smrg  # Ascend the tree starting from libdir
3243bfa90b6Smrg  while :; do
3253bfa90b6Smrg    # check if we have found a prefix of bindir
3263bfa90b6Smrg    case $func_relative_path_tbindir in
3273bfa90b6Smrg      $func_relative_path_tlibdir)
3283bfa90b6Smrg        # found an exact match
3293bfa90b6Smrg        func_relative_path_tcancelled=
3303bfa90b6Smrg        break
3313bfa90b6Smrg        ;;
3323bfa90b6Smrg      $func_relative_path_tlibdir*)
3333bfa90b6Smrg        # found a matching prefix
3343bfa90b6Smrg        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
3353bfa90b6Smrg        func_relative_path_tcancelled=$func_stripname_result
3363bfa90b6Smrg        if test -z "$func_relative_path_result"; then
3373bfa90b6Smrg          func_relative_path_result=.
3383bfa90b6Smrg        fi
3393bfa90b6Smrg        break
3403bfa90b6Smrg        ;;
3413bfa90b6Smrg      *)
3423bfa90b6Smrg        func_dirname $func_relative_path_tlibdir
3433bfa90b6Smrg        func_relative_path_tlibdir=${func_dirname_result}
3443bfa90b6Smrg        if test "x$func_relative_path_tlibdir" = x ; then
3453bfa90b6Smrg          # Have to descend all the way to the root!
3463bfa90b6Smrg          func_relative_path_result=../$func_relative_path_result
3473bfa90b6Smrg          func_relative_path_tcancelled=$func_relative_path_tbindir
3483bfa90b6Smrg          break
3493bfa90b6Smrg        fi
3503bfa90b6Smrg        func_relative_path_result=../$func_relative_path_result
3513bfa90b6Smrg        ;;
3523bfa90b6Smrg    esac
3533bfa90b6Smrg  done
3543bfa90b6Smrg
3553bfa90b6Smrg  # Now calculate path; take care to avoid doubling-up slashes.
3563bfa90b6Smrg  func_stripname '' '/' "$func_relative_path_result"
3573bfa90b6Smrg  func_relative_path_result=$func_stripname_result
3583bfa90b6Smrg  func_stripname '/' '/' "$func_relative_path_tcancelled"
3593bfa90b6Smrg  if test "x$func_stripname_result" != x ; then
3603bfa90b6Smrg    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
3613bfa90b6Smrg  fi
362b68e1f86Smrg
3633bfa90b6Smrg  # Normalisation. If bindir is libdir, return empty string,
3643bfa90b6Smrg  # else relative path ending with a slash; either way, target
3653bfa90b6Smrg  # file name can be directly appended.
3663bfa90b6Smrg  if test ! -z "$func_relative_path_result"; then
3673bfa90b6Smrg    func_stripname './' '' "$func_relative_path_result/"
3683bfa90b6Smrg    func_relative_path_result=$func_stripname_result
3693bfa90b6Smrg  fi
3703bfa90b6Smrg}
371b68e1f86Smrg
372b68e1f86Smrg# The name of this program:
373b68e1f86Smrgfunc_dirname_and_basename "$progpath"
374b68e1f86Smrgprogname=$func_basename_result
375b68e1f86Smrg
376b68e1f86Smrg# Make sure we have an absolute path for reexecution:
377b68e1f86Smrgcase $progpath in
378b68e1f86Smrg  [\\/]*|[A-Za-z]:\\*) ;;
379b68e1f86Smrg  *[\\/]*)
380b68e1f86Smrg     progdir=$func_dirname_result
381b68e1f86Smrg     progdir=`cd "$progdir" && pwd`
382b68e1f86Smrg     progpath="$progdir/$progname"
383b68e1f86Smrg     ;;
384b68e1f86Smrg  *)
385b68e1f86Smrg     save_IFS="$IFS"
3863bfa90b6Smrg     IFS=${PATH_SEPARATOR-:}
387b68e1f86Smrg     for progdir in $PATH; do
388b68e1f86Smrg       IFS="$save_IFS"
389b68e1f86Smrg       test -x "$progdir/$progname" && break
390b68e1f86Smrg     done
391b68e1f86Smrg     IFS="$save_IFS"
392b68e1f86Smrg     test -n "$progdir" || progdir=`pwd`
393b68e1f86Smrg     progpath="$progdir/$progname"
394b68e1f86Smrg     ;;
395b68e1f86Smrgesac
396b68e1f86Smrg
397b68e1f86Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
398b68e1f86Smrg# metacharacters that are still active within double-quoted strings.
399b68e1f86SmrgXsed="${SED}"' -e 1s/^X//'
400b68e1f86Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
401b68e1f86Smrg
402b68e1f86Smrg# Same as above, but do not quote variable references.
403b68e1f86Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
404b68e1f86Smrg
4053bfa90b6Smrg# Sed substitution that turns a string into a regex matching for the
4063bfa90b6Smrg# string literally.
4073bfa90b6Smrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
4083bfa90b6Smrg
4093bfa90b6Smrg# Sed substitution that converts a w32 file name or path
4103bfa90b6Smrg# which contains forward slashes, into one that contains
4113bfa90b6Smrg# (escaped) backslashes.  A very naive implementation.
4123bfa90b6Smrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
4133bfa90b6Smrg
414b68e1f86Smrg# Re-`\' parameter expansions in output of double_quote_subst that were
415b68e1f86Smrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
416b68e1f86Smrg# in input to double_quote_subst, that '$' was protected from expansion.
417b68e1f86Smrg# Since each input `\' is now two `\'s, look for any number of runs of
418b68e1f86Smrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
419b68e1f86Smrgbs='\\'
420b68e1f86Smrgbs2='\\\\'
421b68e1f86Smrgbs4='\\\\\\\\'
422b68e1f86Smrgdollar='\$'
423b68e1f86Smrgsed_double_backslash="\
424b68e1f86Smrg  s/$bs4/&\\
425b68e1f86Smrg/g
426b68e1f86Smrg  s/^$bs2$dollar/$bs&/
427b68e1f86Smrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
428b68e1f86Smrg  s/\n//g"
429b68e1f86Smrg
430b68e1f86Smrg# Standard options:
431b68e1f86Smrgopt_dry_run=false
432b68e1f86Smrgopt_help=false
433b68e1f86Smrgopt_quiet=false
434b68e1f86Smrgopt_verbose=false
435b68e1f86Smrgopt_warning=:
436b68e1f86Smrg
437b68e1f86Smrg# func_echo arg...
438b68e1f86Smrg# Echo program name prefixed message, along with the current mode
439b68e1f86Smrg# name if it has been set yet.
440b68e1f86Smrgfunc_echo ()
441b68e1f86Smrg{
4423bfa90b6Smrg    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
443b68e1f86Smrg}
444b68e1f86Smrg
445b68e1f86Smrg# func_verbose arg...
446b68e1f86Smrg# Echo program name prefixed message in verbose mode only.
447b68e1f86Smrgfunc_verbose ()
448b68e1f86Smrg{
449b68e1f86Smrg    $opt_verbose && func_echo ${1+"$@"}
450b68e1f86Smrg
451b68e1f86Smrg    # A bug in bash halts the script if the last line of a function
452b68e1f86Smrg    # fails when set -e is in force, so we need another command to
453b68e1f86Smrg    # work around that:
454b68e1f86Smrg    :
455b68e1f86Smrg}
456b68e1f86Smrg
4573bfa90b6Smrg# func_echo_all arg...
4583bfa90b6Smrg# Invoke $ECHO with all args, space-separated.
4593bfa90b6Smrgfunc_echo_all ()
4603bfa90b6Smrg{
4613bfa90b6Smrg    $ECHO "$*"
4623bfa90b6Smrg}
4633bfa90b6Smrg
464b68e1f86Smrg# func_error arg...
465b68e1f86Smrg# Echo program name prefixed message to standard error.
466b68e1f86Smrgfunc_error ()
467b68e1f86Smrg{
4683bfa90b6Smrg    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
469b68e1f86Smrg}
470b68e1f86Smrg
471b68e1f86Smrg# func_warning arg...
472b68e1f86Smrg# Echo program name prefixed warning message to standard error.
473b68e1f86Smrgfunc_warning ()
474b68e1f86Smrg{
4753bfa90b6Smrg    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
476b68e1f86Smrg
477b68e1f86Smrg    # bash bug again:
478b68e1f86Smrg    :
479b68e1f86Smrg}
480b68e1f86Smrg
481b68e1f86Smrg# func_fatal_error arg...
482b68e1f86Smrg# Echo program name prefixed message to standard error, and exit.
483b68e1f86Smrgfunc_fatal_error ()
484b68e1f86Smrg{
485b68e1f86Smrg    func_error ${1+"$@"}
486b68e1f86Smrg    exit $EXIT_FAILURE
487b68e1f86Smrg}
488b68e1f86Smrg
489b68e1f86Smrg# func_fatal_help arg...
490b68e1f86Smrg# Echo program name prefixed message to standard error, followed by
491b68e1f86Smrg# a help hint, and exit.
492b68e1f86Smrgfunc_fatal_help ()
493b68e1f86Smrg{
494b68e1f86Smrg    func_error ${1+"$@"}
495b68e1f86Smrg    func_fatal_error "$help"
496b68e1f86Smrg}
497b68e1f86Smrghelp="Try \`$progname --help' for more information."  ## default
498b68e1f86Smrg
499b68e1f86Smrg
500b68e1f86Smrg# func_grep expression filename
501b68e1f86Smrg# Check whether EXPRESSION matches any line of FILENAME, without output.
502b68e1f86Smrgfunc_grep ()
503b68e1f86Smrg{
504b68e1f86Smrg    $GREP "$1" "$2" >/dev/null 2>&1
505b68e1f86Smrg}
506b68e1f86Smrg
507b68e1f86Smrg
508b68e1f86Smrg# func_mkdir_p directory-path
509b68e1f86Smrg# Make sure the entire path to DIRECTORY-PATH is available.
510b68e1f86Smrgfunc_mkdir_p ()
511b68e1f86Smrg{
512b68e1f86Smrg    my_directory_path="$1"
513b68e1f86Smrg    my_dir_list=
514b68e1f86Smrg
515b68e1f86Smrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
516b68e1f86Smrg
517b68e1f86Smrg      # Protect directory names starting with `-'
518b68e1f86Smrg      case $my_directory_path in
519b68e1f86Smrg        -*) my_directory_path="./$my_directory_path" ;;
520b68e1f86Smrg      esac
521b68e1f86Smrg
522b68e1f86Smrg      # While some portion of DIR does not yet exist...
523b68e1f86Smrg      while test ! -d "$my_directory_path"; do
524b68e1f86Smrg        # ...make a list in topmost first order.  Use a colon delimited
525b68e1f86Smrg	# list incase some portion of path contains whitespace.
526b68e1f86Smrg        my_dir_list="$my_directory_path:$my_dir_list"
527b68e1f86Smrg
528b68e1f86Smrg        # If the last portion added has no slash in it, the list is done
529b68e1f86Smrg        case $my_directory_path in */*) ;; *) break ;; esac
530b68e1f86Smrg
531b68e1f86Smrg        # ...otherwise throw away the child directory and loop
5323bfa90b6Smrg        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
533b68e1f86Smrg      done
5343bfa90b6Smrg      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
535b68e1f86Smrg
536b68e1f86Smrg      save_mkdir_p_IFS="$IFS"; IFS=':'
537b68e1f86Smrg      for my_dir in $my_dir_list; do
538b68e1f86Smrg	IFS="$save_mkdir_p_IFS"
539b68e1f86Smrg        # mkdir can fail with a `File exist' error if two processes
540b68e1f86Smrg        # try to create one of the directories concurrently.  Don't
541b68e1f86Smrg        # stop in that case!
542b68e1f86Smrg        $MKDIR "$my_dir" 2>/dev/null || :
543b68e1f86Smrg      done
544b68e1f86Smrg      IFS="$save_mkdir_p_IFS"
545b68e1f86Smrg
546b68e1f86Smrg      # Bail out if we (or some other process) failed to create a directory.
547b68e1f86Smrg      test -d "$my_directory_path" || \
548b68e1f86Smrg        func_fatal_error "Failed to create \`$1'"
549b68e1f86Smrg    fi
550b68e1f86Smrg}
5516df26cacSmrg
5526df26cacSmrg
5536df26cacSmrg# func_mktempdir [string]
5546df26cacSmrg# Make a temporary directory that won't clash with other running
5556df26cacSmrg# libtool processes, and avoids race conditions if possible.  If
5566df26cacSmrg# given, STRING is the basename for that directory.
5576df26cacSmrgfunc_mktempdir ()
5586df26cacSmrg{
5596df26cacSmrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
5606df26cacSmrg
561b68e1f86Smrg    if test "$opt_dry_run" = ":"; then
5626df26cacSmrg      # Return a directory name, but don't create it in dry-run mode
5636df26cacSmrg      my_tmpdir="${my_template}-$$"
5646df26cacSmrg    else
5656df26cacSmrg
5666df26cacSmrg      # If mktemp works, use that first and foremost
5676df26cacSmrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
5686df26cacSmrg
5696df26cacSmrg      if test ! -d "$my_tmpdir"; then
570b68e1f86Smrg        # Failing that, at least try and use $RANDOM to avoid a race
571b68e1f86Smrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
5726df26cacSmrg
573b68e1f86Smrg        save_mktempdir_umask=`umask`
574b68e1f86Smrg        umask 0077
575b68e1f86Smrg        $MKDIR "$my_tmpdir"
576b68e1f86Smrg        umask $save_mktempdir_umask
5776df26cacSmrg      fi
5786df26cacSmrg
5796df26cacSmrg      # If we're not in dry-run mode, bomb out on failure
580b68e1f86Smrg      test -d "$my_tmpdir" || \
581b68e1f86Smrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
5826df26cacSmrg    fi
5836df26cacSmrg
5843bfa90b6Smrg    $ECHO "$my_tmpdir"
5856df26cacSmrg}
5866df26cacSmrg
5876df26cacSmrg
588b68e1f86Smrg# func_quote_for_eval arg
589b68e1f86Smrg# Aesthetically quote ARG to be evaled later.
590b68e1f86Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
591b68e1f86Smrg# is double-quoted, suitable for a subsequent eval, whereas
592b68e1f86Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
593b68e1f86Smrg# which are still active within double quotes backslashified.
594b68e1f86Smrgfunc_quote_for_eval ()
5956df26cacSmrg{
596b68e1f86Smrg    case $1 in
597b68e1f86Smrg      *[\\\`\"\$]*)
5983bfa90b6Smrg	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
599b68e1f86Smrg      *)
600b68e1f86Smrg        func_quote_for_eval_unquoted_result="$1" ;;
601b68e1f86Smrg    esac
602b68e1f86Smrg
603b68e1f86Smrg    case $func_quote_for_eval_unquoted_result in
604b68e1f86Smrg      # Double-quote args containing shell metacharacters to delay
605b68e1f86Smrg      # word splitting, command substitution and and variable
606b68e1f86Smrg      # expansion for a subsequent eval.
607b68e1f86Smrg      # Many Bourne shells cannot handle close brackets correctly
608b68e1f86Smrg      # in scan sets, so we specify it separately.
609b68e1f86Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
610b68e1f86Smrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
611b68e1f86Smrg        ;;
612b68e1f86Smrg      *)
613b68e1f86Smrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
6146df26cacSmrg    esac
6156df26cacSmrg}
6166df26cacSmrg
6176df26cacSmrg
618b68e1f86Smrg# func_quote_for_expand arg
619b68e1f86Smrg# Aesthetically quote ARG to be evaled later; same as above,
620b68e1f86Smrg# but do not quote variable references.
621b68e1f86Smrgfunc_quote_for_expand ()
6226df26cacSmrg{
623b68e1f86Smrg    case $1 in
624b68e1f86Smrg      *[\\\`\"]*)
6253bfa90b6Smrg	my_arg=`$ECHO "$1" | $SED \
626b68e1f86Smrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
6276df26cacSmrg      *)
628b68e1f86Smrg        my_arg="$1" ;;
629b68e1f86Smrg    esac
630b68e1f86Smrg
631b68e1f86Smrg    case $my_arg in
632b68e1f86Smrg      # Double-quote args containing shell metacharacters to delay
633b68e1f86Smrg      # word splitting and command substitution for a subsequent eval.
634b68e1f86Smrg      # Many Bourne shells cannot handle close brackets correctly
635b68e1f86Smrg      # in scan sets, so we specify it separately.
636b68e1f86Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
637b68e1f86Smrg        my_arg="\"$my_arg\""
638b68e1f86Smrg        ;;
639b68e1f86Smrg    esac
640b68e1f86Smrg
641b68e1f86Smrg    func_quote_for_expand_result="$my_arg"
6426df26cacSmrg}
6436df26cacSmrg
6446df26cacSmrg
645b68e1f86Smrg# func_show_eval cmd [fail_exp]
646b68e1f86Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
647b68e1f86Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
648b68e1f86Smrg# is given, then evaluate it.
649b68e1f86Smrgfunc_show_eval ()
6506df26cacSmrg{
651b68e1f86Smrg    my_cmd="$1"
652b68e1f86Smrg    my_fail_exp="${2-:}"
6536df26cacSmrg
654b68e1f86Smrg    ${opt_silent-false} || {
655b68e1f86Smrg      func_quote_for_expand "$my_cmd"
656b68e1f86Smrg      eval "func_echo $func_quote_for_expand_result"
657b68e1f86Smrg    }
658b68e1f86Smrg
659b68e1f86Smrg    if ${opt_dry_run-false}; then :; else
660b68e1f86Smrg      eval "$my_cmd"
661b68e1f86Smrg      my_status=$?
662b68e1f86Smrg      if test "$my_status" -eq 0; then :; else
663b68e1f86Smrg	eval "(exit $my_status); $my_fail_exp"
664b68e1f86Smrg      fi
6656df26cacSmrg    fi
6666df26cacSmrg}
6676df26cacSmrg
668b68e1f86Smrg
669b68e1f86Smrg# func_show_eval_locale cmd [fail_exp]
670b68e1f86Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
671b68e1f86Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
672b68e1f86Smrg# is given, then evaluate it.  Use the saved locale for evaluation.
673b68e1f86Smrgfunc_show_eval_locale ()
6746df26cacSmrg{
675b68e1f86Smrg    my_cmd="$1"
676b68e1f86Smrg    my_fail_exp="${2-:}"
677b68e1f86Smrg
678b68e1f86Smrg    ${opt_silent-false} || {
679b68e1f86Smrg      func_quote_for_expand "$my_cmd"
680b68e1f86Smrg      eval "func_echo $func_quote_for_expand_result"
681b68e1f86Smrg    }
682b68e1f86Smrg
683b68e1f86Smrg    if ${opt_dry_run-false}; then :; else
684b68e1f86Smrg      eval "$lt_user_locale
685b68e1f86Smrg	    $my_cmd"
686b68e1f86Smrg      my_status=$?
687b68e1f86Smrg      eval "$lt_safe_locale"
688b68e1f86Smrg      if test "$my_status" -eq 0; then :; else
689b68e1f86Smrg	eval "(exit $my_status); $my_fail_exp"
690b68e1f86Smrg      fi
6916df26cacSmrg    fi
692b68e1f86Smrg}
6936df26cacSmrg
6943bfa90b6Smrg# func_tr_sh
6953bfa90b6Smrg# Turn $1 into a string suitable for a shell variable name.
6963bfa90b6Smrg# Result is stored in $func_tr_sh_result.  All characters
6973bfa90b6Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
6983bfa90b6Smrg# if $1 begins with a digit, a '_' is prepended as well.
6993bfa90b6Smrgfunc_tr_sh ()
7003bfa90b6Smrg{
7013bfa90b6Smrg  case $1 in
7023bfa90b6Smrg  [0-9]* | *[!a-zA-Z0-9_]*)
7033bfa90b6Smrg    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
7043bfa90b6Smrg    ;;
7053bfa90b6Smrg  * )
7063bfa90b6Smrg    func_tr_sh_result=$1
7073bfa90b6Smrg    ;;
7083bfa90b6Smrg  esac
7093bfa90b6Smrg}
710b68e1f86Smrg
711b68e1f86Smrg
712b68e1f86Smrg# func_version
713b68e1f86Smrg# Echo version message to standard output and exit.
714b68e1f86Smrgfunc_version ()
715b68e1f86Smrg{
7163bfa90b6Smrg    $opt_debug
7173bfa90b6Smrg
7183bfa90b6Smrg    $SED -n '/(C)/!b go
7193bfa90b6Smrg	:more
7203bfa90b6Smrg	/\./!{
7213bfa90b6Smrg	  N
7223bfa90b6Smrg	  s/\n# / /
7233bfa90b6Smrg	  b more
7243bfa90b6Smrg	}
7253bfa90b6Smrg	:go
7263bfa90b6Smrg	/^# '$PROGRAM' (GNU /,/# warranty; / {
727b68e1f86Smrg        s/^# //
728b68e1f86Smrg	s/^# *$//
729b68e1f86Smrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
730b68e1f86Smrg        p
731b68e1f86Smrg     }' < "$progpath"
732b68e1f86Smrg     exit $?
733b68e1f86Smrg}
734b68e1f86Smrg
735b68e1f86Smrg# func_usage
736b68e1f86Smrg# Echo short help message to standard output and exit.
737b68e1f86Smrgfunc_usage ()
738b68e1f86Smrg{
7393bfa90b6Smrg    $opt_debug
7403bfa90b6Smrg
7413bfa90b6Smrg    $SED -n '/^# Usage:/,/^#  *.*--help/ {
742b68e1f86Smrg        s/^# //
743b68e1f86Smrg	s/^# *$//
744b68e1f86Smrg	s/\$progname/'$progname'/
745b68e1f86Smrg	p
746b68e1f86Smrg    }' < "$progpath"
7473bfa90b6Smrg    echo
748b68e1f86Smrg    $ECHO "run \`$progname --help | more' for full usage"
749b68e1f86Smrg    exit $?
750b68e1f86Smrg}
751b68e1f86Smrg
7523bfa90b6Smrg# func_help [NOEXIT]
7533bfa90b6Smrg# Echo long help message to standard output and exit,
7543bfa90b6Smrg# unless 'noexit' is passed as argument.
755b68e1f86Smrgfunc_help ()
756b68e1f86Smrg{
7573bfa90b6Smrg    $opt_debug
7583bfa90b6Smrg
759b68e1f86Smrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
7603bfa90b6Smrg	:print
761b68e1f86Smrg        s/^# //
762b68e1f86Smrg	s/^# *$//
763b68e1f86Smrg	s*\$progname*'$progname'*
764b68e1f86Smrg	s*\$host*'"$host"'*
765b68e1f86Smrg	s*\$SHELL*'"$SHELL"'*
766b68e1f86Smrg	s*\$LTCC*'"$LTCC"'*
767b68e1f86Smrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
768b68e1f86Smrg	s*\$LD*'"$LD"'*
769b68e1f86Smrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
7703bfa90b6Smrg	s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
7713bfa90b6Smrg	s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
772b68e1f86Smrg	p
7733bfa90b6Smrg	d
7743bfa90b6Smrg     }
7753bfa90b6Smrg     /^# .* home page:/b print
7763bfa90b6Smrg     /^# General help using/b print
7773bfa90b6Smrg     ' < "$progpath"
7783bfa90b6Smrg    ret=$?
7793bfa90b6Smrg    if test -z "$1"; then
7803bfa90b6Smrg      exit $ret
7813bfa90b6Smrg    fi
782b68e1f86Smrg}
783b68e1f86Smrg
784b68e1f86Smrg# func_missing_arg argname
785b68e1f86Smrg# Echo program name prefixed message to standard error and set global
786b68e1f86Smrg# exit_cmd.
787b68e1f86Smrgfunc_missing_arg ()
788b68e1f86Smrg{
7893bfa90b6Smrg    $opt_debug
7903bfa90b6Smrg
7913bfa90b6Smrg    func_error "missing argument for $1."
792b68e1f86Smrg    exit_cmd=exit
7936df26cacSmrg}
7946df26cacSmrg
7956df26cacSmrg
7963bfa90b6Smrg# func_split_short_opt shortopt
7973bfa90b6Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
7983bfa90b6Smrg# variables after splitting SHORTOPT after the 2nd character.
7993bfa90b6Smrgfunc_split_short_opt ()
8003bfa90b6Smrg{
8013bfa90b6Smrg    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
8023bfa90b6Smrg    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
8036df26cacSmrg
8043bfa90b6Smrg    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
8053bfa90b6Smrg    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
8063bfa90b6Smrg} # func_split_short_opt may be replaced by extended shell implementation
8073bfa90b6Smrg
8083bfa90b6Smrg
8093bfa90b6Smrg# func_split_long_opt longopt
8103bfa90b6Smrg# Set func_split_long_opt_name and func_split_long_opt_arg shell
8113bfa90b6Smrg# variables after splitting LONGOPT at the `=' sign.
8123bfa90b6Smrgfunc_split_long_opt ()
8133bfa90b6Smrg{
8143bfa90b6Smrg    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
8153bfa90b6Smrg    my_sed_long_arg='1s/^--[^=]*=//'
8163bfa90b6Smrg
8173bfa90b6Smrg    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
8183bfa90b6Smrg    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
8193bfa90b6Smrg} # func_split_long_opt may be replaced by extended shell implementation
8203bfa90b6Smrg
8213bfa90b6Smrgexit_cmd=:
822b68e1f86Smrg
823b68e1f86Smrg
824b68e1f86Smrg
8256df26cacSmrg
8266df26cacSmrg
827b68e1f86Smrgmagic="%%%MAGIC variable%%%"
828b68e1f86Smrgmagic_exe="%%%MAGIC EXE variable%%%"
8296df26cacSmrg
830b68e1f86Smrg# Global variables.
831b68e1f86Smrgnonopt=
832b68e1f86Smrgpreserve_args=
833b68e1f86Smrglo2o="s/\\.lo\$/.${objext}/"
834b68e1f86Smrgo2lo="s/\\.${objext}\$/.lo/"
835b68e1f86Smrgextracted_archives=
836b68e1f86Smrgextracted_serial=0
8376df26cacSmrg
838b68e1f86Smrg# If this variable is set in any of the actions, the command in it
839b68e1f86Smrg# will be execed at the end.  This prevents here-documents from being
840b68e1f86Smrg# left over by shells.
841b68e1f86Smrgexec_cmd=
842b68e1f86Smrg
8433bfa90b6Smrg# func_append var value
8443bfa90b6Smrg# Append VALUE to the end of shell variable VAR.
8453bfa90b6Smrgfunc_append ()
8463bfa90b6Smrg{
8473bfa90b6Smrg    eval "${1}=\$${1}\${2}"
8483bfa90b6Smrg} # func_append may be replaced by extended shell implementation
8493bfa90b6Smrg
8503bfa90b6Smrg# func_append_quoted var value
8513bfa90b6Smrg# Quote VALUE and append to the end of shell variable VAR, separated
8523bfa90b6Smrg# by a space.
8533bfa90b6Smrgfunc_append_quoted ()
8543bfa90b6Smrg{
8553bfa90b6Smrg    func_quote_for_eval "${2}"
8563bfa90b6Smrg    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
8573bfa90b6Smrg} # func_append_quoted may be replaced by extended shell implementation
8583bfa90b6Smrg
8593bfa90b6Smrg
8603bfa90b6Smrg# func_arith arithmetic-term...
8613bfa90b6Smrgfunc_arith ()
8623bfa90b6Smrg{
8633bfa90b6Smrg    func_arith_result=`expr "${@}"`
8643bfa90b6Smrg} # func_arith may be replaced by extended shell implementation
8653bfa90b6Smrg
8663bfa90b6Smrg
8673bfa90b6Smrg# func_len string
8683bfa90b6Smrg# STRING may not start with a hyphen.
8693bfa90b6Smrgfunc_len ()
8703bfa90b6Smrg{
8713bfa90b6Smrg    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
8723bfa90b6Smrg} # func_len may be replaced by extended shell implementation
8733bfa90b6Smrg
8743bfa90b6Smrg
8753bfa90b6Smrg# func_lo2o object
8763bfa90b6Smrgfunc_lo2o ()
8773bfa90b6Smrg{
8783bfa90b6Smrg    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
8793bfa90b6Smrg} # func_lo2o may be replaced by extended shell implementation
8803bfa90b6Smrg
8813bfa90b6Smrg
8823bfa90b6Smrg# func_xform libobj-or-source
8833bfa90b6Smrgfunc_xform ()
8843bfa90b6Smrg{
8853bfa90b6Smrg    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
8863bfa90b6Smrg} # func_xform may be replaced by extended shell implementation
8873bfa90b6Smrg
8883bfa90b6Smrg
889b68e1f86Smrg# func_fatal_configuration arg...
890b68e1f86Smrg# Echo program name prefixed message to standard error, followed by
891b68e1f86Smrg# a configuration failure hint, and exit.
892b68e1f86Smrgfunc_fatal_configuration ()
893b68e1f86Smrg{
894b68e1f86Smrg    func_error ${1+"$@"}
895b68e1f86Smrg    func_error "See the $PACKAGE documentation for more information."
896b68e1f86Smrg    func_fatal_error "Fatal configuration error."
897b68e1f86Smrg}
8986df26cacSmrg
89916fd1166Smrg
900b68e1f86Smrg# func_config
901b68e1f86Smrg# Display the configuration for all the tags in this script.
902b68e1f86Smrgfunc_config ()
903b68e1f86Smrg{
904b68e1f86Smrg    re_begincf='^# ### BEGIN LIBTOOL'
905b68e1f86Smrg    re_endcf='^# ### END LIBTOOL'
906b68e1f86Smrg
907b68e1f86Smrg    # Default configuration.
908b68e1f86Smrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
9096df26cacSmrg
9106df26cacSmrg    # Now print the configurations for the tags.
9116df26cacSmrg    for tagname in $taglist; do
912b68e1f86Smrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
9136df26cacSmrg    done
9146df26cacSmrg
915b68e1f86Smrg    exit $?
916b68e1f86Smrg}
9176df26cacSmrg
918b68e1f86Smrg# func_features
919b68e1f86Smrg# Display the features supported by this script.
920b68e1f86Smrgfunc_features ()
921b68e1f86Smrg{
9223bfa90b6Smrg    echo "host: $host"
9236df26cacSmrg    if test "$build_libtool_libs" = yes; then
9243bfa90b6Smrg      echo "enable shared libraries"
9256df26cacSmrg    else
9263bfa90b6Smrg      echo "disable shared libraries"
9276df26cacSmrg    fi
9286df26cacSmrg    if test "$build_old_libs" = yes; then
9293bfa90b6Smrg      echo "enable static libraries"
9306df26cacSmrg    else
9313bfa90b6Smrg      echo "disable static libraries"
9326df26cacSmrg    fi
933b68e1f86Smrg
9346df26cacSmrg    exit $?
935b68e1f86Smrg}
9366df26cacSmrg
937b68e1f86Smrg# func_enable_tag tagname
938b68e1f86Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or
939b68e1f86Smrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
940b68e1f86Smrg# variable here.
941b68e1f86Smrgfunc_enable_tag ()
942b68e1f86Smrg{
943b68e1f86Smrg  # Global variable:
944b68e1f86Smrg  tagname="$1"
9456df26cacSmrg
946b68e1f86Smrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
947b68e1f86Smrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
948b68e1f86Smrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
9496df26cacSmrg
950b68e1f86Smrg  # Validate tagname.
951b68e1f86Smrg  case $tagname in
952b68e1f86Smrg    *[!-_A-Za-z0-9,/]*)
953b68e1f86Smrg      func_fatal_error "invalid tag name: $tagname"
954b68e1f86Smrg      ;;
955b68e1f86Smrg  esac
9566df26cacSmrg
957b68e1f86Smrg  # Don't test for the "default" C tag, as we know it's
958b68e1f86Smrg  # there but not specially marked.
959b68e1f86Smrg  case $tagname in
960b68e1f86Smrg    CC) ;;
961b68e1f86Smrg    *)
962b68e1f86Smrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
963b68e1f86Smrg	taglist="$taglist $tagname"
964b68e1f86Smrg
965b68e1f86Smrg	# Evaluate the configuration.  Be careful to quote the path
966b68e1f86Smrg	# and the sed script, to avoid splitting on whitespace, but
967b68e1f86Smrg	# also don't use non-portable quotes within backquotes within
968b68e1f86Smrg	# quotes we have to do it in 2 steps:
969b68e1f86Smrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
970b68e1f86Smrg	eval "$extractedcf"
971b68e1f86Smrg      else
972b68e1f86Smrg	func_error "ignoring unknown tag $tagname"
973b68e1f86Smrg      fi
974b68e1f86Smrg      ;;
975b68e1f86Smrg  esac
976b68e1f86Smrg}
977b68e1f86Smrg
9783bfa90b6Smrg# func_check_version_match
9793bfa90b6Smrg# Ensure that we are using m4 macros, and libtool script from the same
9803bfa90b6Smrg# release of libtool.
9813bfa90b6Smrgfunc_check_version_match ()
982b68e1f86Smrg{
9833bfa90b6Smrg  if test "$package_revision" != "$macro_revision"; then
9843bfa90b6Smrg    if test "$VERSION" != "$macro_version"; then
9853bfa90b6Smrg      if test -z "$macro_version"; then
9863bfa90b6Smrg        cat >&2 <<_LT_EOF
9873bfa90b6Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
9883bfa90b6Smrg$progname: definition of this LT_INIT comes from an older release.
9893bfa90b6Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
9903bfa90b6Smrg$progname: and run autoconf again.
9913bfa90b6Smrg_LT_EOF
9923bfa90b6Smrg      else
9933bfa90b6Smrg        cat >&2 <<_LT_EOF
9943bfa90b6Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
9953bfa90b6Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
9963bfa90b6Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
9973bfa90b6Smrg$progname: and run autoconf again.
9983bfa90b6Smrg_LT_EOF
9993bfa90b6Smrg      fi
10003bfa90b6Smrg    else
10013bfa90b6Smrg      cat >&2 <<_LT_EOF
10023bfa90b6Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
10033bfa90b6Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
10043bfa90b6Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
10053bfa90b6Smrg$progname: of $PACKAGE $VERSION and run autoconf again.
10063bfa90b6Smrg_LT_EOF
10073bfa90b6Smrg    fi
10086df26cacSmrg
10093bfa90b6Smrg    exit $EXIT_MISMATCH
10103bfa90b6Smrg  fi
10113bfa90b6Smrg}
10123bfa90b6Smrg
10133bfa90b6Smrg
10143bfa90b6Smrg# Shorthand for --mode=foo, only valid as the first argument
10153bfa90b6Smrgcase $1 in
10163bfa90b6Smrgclean|clea|cle|cl)
10173bfa90b6Smrg  shift; set dummy --mode clean ${1+"$@"}; shift
10183bfa90b6Smrg  ;;
10193bfa90b6Smrgcompile|compil|compi|comp|com|co|c)
10203bfa90b6Smrg  shift; set dummy --mode compile ${1+"$@"}; shift
10213bfa90b6Smrg  ;;
10223bfa90b6Smrgexecute|execut|execu|exec|exe|ex|e)
10233bfa90b6Smrg  shift; set dummy --mode execute ${1+"$@"}; shift
10243bfa90b6Smrg  ;;
10253bfa90b6Smrgfinish|finis|fini|fin|fi|f)
10263bfa90b6Smrg  shift; set dummy --mode finish ${1+"$@"}; shift
10273bfa90b6Smrg  ;;
10283bfa90b6Smrginstall|instal|insta|inst|ins|in|i)
10293bfa90b6Smrg  shift; set dummy --mode install ${1+"$@"}; shift
10303bfa90b6Smrg  ;;
10313bfa90b6Smrglink|lin|li|l)
10323bfa90b6Smrg  shift; set dummy --mode link ${1+"$@"}; shift
10333bfa90b6Smrg  ;;
10343bfa90b6Smrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
10353bfa90b6Smrg  shift; set dummy --mode uninstall ${1+"$@"}; shift
10363bfa90b6Smrg  ;;
10373bfa90b6Smrgesac
10386df26cacSmrg
10393bfa90b6Smrg
10403bfa90b6Smrg
10413bfa90b6Smrg# Option defaults:
10423bfa90b6Smrgopt_debug=:
10433bfa90b6Smrgopt_dry_run=false
10443bfa90b6Smrgopt_config=false
10453bfa90b6Smrgopt_preserve_dup_deps=false
10463bfa90b6Smrgopt_features=false
10473bfa90b6Smrgopt_finish=false
10483bfa90b6Smrgopt_help=false
10493bfa90b6Smrgopt_help_all=false
10503bfa90b6Smrgopt_silent=:
10513bfa90b6Smrgopt_warning=:
10523bfa90b6Smrgopt_verbose=:
10533bfa90b6Smrgopt_silent=false
10543bfa90b6Smrgopt_verbose=false
10553bfa90b6Smrg
10563bfa90b6Smrg
10573bfa90b6Smrg# Parse options once, thoroughly.  This comes as soon as possible in the
10583bfa90b6Smrg# script to make things like `--version' happen as quickly as we can.
10593bfa90b6Smrg{
10603bfa90b6Smrg  # this just eases exit handling
10613bfa90b6Smrg  while test $# -gt 0; do
1062b68e1f86Smrg    opt="$1"
1063b68e1f86Smrg    shift
1064b68e1f86Smrg    case $opt in
10653bfa90b6Smrg      --debug|-x)	opt_debug='set -x'
1066b68e1f86Smrg			func_echo "enabling shell trace mode"
1067b68e1f86Smrg			$opt_debug
1068b68e1f86Smrg			;;
10693bfa90b6Smrg      --dry-run|--dryrun|-n)
10703bfa90b6Smrg			opt_dry_run=:
1071b68e1f86Smrg			;;
10723bfa90b6Smrg      --config)
10733bfa90b6Smrg			opt_config=:
10743bfa90b6Smrgfunc_config
10753bfa90b6Smrg			;;
10763bfa90b6Smrg      --dlopen|-dlopen)
10773bfa90b6Smrg			optarg="$1"
10783bfa90b6Smrg			opt_dlopen="${opt_dlopen+$opt_dlopen
10793bfa90b6Smrg}$optarg"
1080b68e1f86Smrg			shift
1081b68e1f86Smrg			;;
1082b68e1f86Smrg      --preserve-dup-deps)
10833bfa90b6Smrg			opt_preserve_dup_deps=:
1084b68e1f86Smrg			;;
10853bfa90b6Smrg      --features)
10863bfa90b6Smrg			opt_features=:
10873bfa90b6Smrgfunc_features
10883bfa90b6Smrg			;;
10893bfa90b6Smrg      --finish)
10903bfa90b6Smrg			opt_finish=:
10913bfa90b6Smrgset dummy --mode finish ${1+"$@"}; shift
10923bfa90b6Smrg			;;
10933bfa90b6Smrg      --help)
10943bfa90b6Smrg			opt_help=:
10953bfa90b6Smrg			;;
10963bfa90b6Smrg      --help-all)
10973bfa90b6Smrg			opt_help_all=:
10983bfa90b6Smrgopt_help=': help-all'
10993bfa90b6Smrg			;;
11003bfa90b6Smrg      --mode)
11013bfa90b6Smrg			test $# = 0 && func_missing_arg $opt && break
11023bfa90b6Smrg			optarg="$1"
11033bfa90b6Smrg			opt_mode="$optarg"
11043bfa90b6Smrgcase $optarg in
11053bfa90b6Smrg  # Valid mode arguments:
11063bfa90b6Smrg  clean|compile|execute|finish|install|link|relink|uninstall) ;;
11073bfa90b6Smrg
11083bfa90b6Smrg  # Catch anything else as an error
11093bfa90b6Smrg  *) func_error "invalid argument for $opt"
11103bfa90b6Smrg     exit_cmd=exit
11113bfa90b6Smrg     break
11123bfa90b6Smrg     ;;
11133bfa90b6Smrgesac
11143bfa90b6Smrg			shift
11153bfa90b6Smrg			;;
11163bfa90b6Smrg      --no-silent|--no-quiet)
1117b68e1f86Smrg			opt_silent=false
11183bfa90b6Smrgfunc_append preserve_args " $opt"
1119b68e1f86Smrg			;;
11203bfa90b6Smrg      --no-warning|--no-warn)
11213bfa90b6Smrg			opt_warning=false
11223bfa90b6Smrgfunc_append preserve_args " $opt"
11233bfa90b6Smrg			;;
11243bfa90b6Smrg      --no-verbose)
11253bfa90b6Smrg			opt_verbose=false
11263bfa90b6Smrgfunc_append preserve_args " $opt"
11273bfa90b6Smrg			;;
11283bfa90b6Smrg      --silent|--quiet)
11293bfa90b6Smrg			opt_silent=:
11303bfa90b6Smrgfunc_append preserve_args " $opt"
11313bfa90b6Smrg        opt_verbose=false
11323bfa90b6Smrg			;;
11333bfa90b6Smrg      --verbose|-v)
11343bfa90b6Smrg			opt_verbose=:
11353bfa90b6Smrgfunc_append preserve_args " $opt"
11363bfa90b6Smrgopt_silent=false
11373bfa90b6Smrg			;;
11383bfa90b6Smrg      --tag)
11393bfa90b6Smrg			test $# = 0 && func_missing_arg $opt && break
11403bfa90b6Smrg			optarg="$1"
11413bfa90b6Smrg			opt_tag="$optarg"
11423bfa90b6Smrgfunc_append preserve_args " $opt $optarg"
11433bfa90b6Smrgfunc_enable_tag "$optarg"
1144b68e1f86Smrg			shift
1145b68e1f86Smrg			;;
1146b68e1f86Smrg
11473bfa90b6Smrg      -\?|-h)		func_usage				;;
11483bfa90b6Smrg      --help)		func_help				;;
11493bfa90b6Smrg      --version)	func_version				;;
11503bfa90b6Smrg
1151b68e1f86Smrg      # Separate optargs to long options:
11523bfa90b6Smrg      --*=*)
11533bfa90b6Smrg			func_split_long_opt "$opt"
11543bfa90b6Smrg			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
1155b68e1f86Smrg			shift
1156b68e1f86Smrg			;;
1157b68e1f86Smrg
11583bfa90b6Smrg      # Separate non-argument short options:
11593bfa90b6Smrg      -\?*|-h*|-n*|-v*)
11603bfa90b6Smrg			func_split_short_opt "$opt"
11613bfa90b6Smrg			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
11623bfa90b6Smrg			shift
1163b68e1f86Smrg			;;
11643bfa90b6Smrg
11653bfa90b6Smrg      --)		break					;;
11663bfa90b6Smrg      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
11673bfa90b6Smrg      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
1168b68e1f86Smrg    esac
1169b68e1f86Smrg  done
1170b68e1f86Smrg
11713bfa90b6Smrg  # Validate options:
11723bfa90b6Smrg
11733bfa90b6Smrg  # save first non-option argument
11743bfa90b6Smrg  if test "$#" -gt 0; then
11753bfa90b6Smrg    nonopt="$opt"
11763bfa90b6Smrg    shift
11773bfa90b6Smrg  fi
11783bfa90b6Smrg
11793bfa90b6Smrg  # preserve --debug
11803bfa90b6Smrg  test "$opt_debug" = : || func_append preserve_args " --debug"
1181b68e1f86Smrg
1182b68e1f86Smrg  case $host in
1183b68e1f86Smrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
1184b68e1f86Smrg      # don't eliminate duplications in $postdeps and $predeps
1185b68e1f86Smrg      opt_duplicate_compiler_generated_deps=:
11866df26cacSmrg      ;;
11876df26cacSmrg    *)
11883bfa90b6Smrg      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
1189b68e1f86Smrg      ;;
1190b68e1f86Smrg  esac
11916df26cacSmrg
11923bfa90b6Smrg  $opt_help || {
11933bfa90b6Smrg    # Sanity checks first:
11943bfa90b6Smrg    func_check_version_match
1195b68e1f86Smrg
11963bfa90b6Smrg    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
11973bfa90b6Smrg      func_fatal_configuration "not configured to build any kind of library"
1198b68e1f86Smrg    fi
1199b68e1f86Smrg
12003bfa90b6Smrg    # Darwin sucks
12013bfa90b6Smrg    eval std_shrext=\"$shrext_cmds\"
1202b68e1f86Smrg
12033bfa90b6Smrg    # Only execute mode is allowed to have -dlopen flags.
12043bfa90b6Smrg    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
12053bfa90b6Smrg      func_error "unrecognized option \`-dlopen'"
12063bfa90b6Smrg      $ECHO "$help" 1>&2
12073bfa90b6Smrg      exit $EXIT_FAILURE
12083bfa90b6Smrg    fi
1209b68e1f86Smrg
12103bfa90b6Smrg    # Change the help message to a mode-specific one.
12113bfa90b6Smrg    generic_help="$help"
12123bfa90b6Smrg    help="Try \`$progname --help --mode=$opt_mode' for more information."
12133bfa90b6Smrg  }
1214b68e1f86Smrg
12156df26cacSmrg
12163bfa90b6Smrg  # Bail if the options were screwed
12173bfa90b6Smrg  $exit_cmd $EXIT_FAILURE
12183bfa90b6Smrg}
1219b68e1f86Smrg
1220b68e1f86Smrg
1221b68e1f86Smrg
1222b68e1f86Smrg
12233bfa90b6Smrg## ----------- ##
12243bfa90b6Smrg##    Main.    ##
12253bfa90b6Smrg## ----------- ##
12266df26cacSmrg
1227b68e1f86Smrg# func_lalib_p file
1228b68e1f86Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
1229b68e1f86Smrg# This function is only a basic sanity check; it will hardly flush out
1230b68e1f86Smrg# determined imposters.
1231b68e1f86Smrgfunc_lalib_p ()
1232b68e1f86Smrg{
1233b68e1f86Smrg    test -f "$1" &&
1234b68e1f86Smrg      $SED -e 4q "$1" 2>/dev/null \
1235b68e1f86Smrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
1236b68e1f86Smrg}
12376df26cacSmrg
1238b68e1f86Smrg# func_lalib_unsafe_p file
1239b68e1f86Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
1240b68e1f86Smrg# This function implements the same check as func_lalib_p without
1241b68e1f86Smrg# resorting to external programs.  To this end, it redirects stdin and
1242b68e1f86Smrg# closes it afterwards, without saving the original file descriptor.
1243b68e1f86Smrg# As a safety measure, use it only where a negative result would be
1244b68e1f86Smrg# fatal anyway.  Works if `file' does not exist.
1245b68e1f86Smrgfunc_lalib_unsafe_p ()
1246b68e1f86Smrg{
1247b68e1f86Smrg    lalib_p=no
1248b68e1f86Smrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
1249b68e1f86Smrg	for lalib_p_l in 1 2 3 4
1250b68e1f86Smrg	do
1251b68e1f86Smrg	    read lalib_p_line
1252b68e1f86Smrg	    case "$lalib_p_line" in
1253b68e1f86Smrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
1254b68e1f86Smrg	    esac
1255b68e1f86Smrg	done
1256b68e1f86Smrg	exec 0<&5 5<&-
1257b68e1f86Smrg    fi
1258b68e1f86Smrg    test "$lalib_p" = yes
1259b68e1f86Smrg}
12606df26cacSmrg
1261b68e1f86Smrg# func_ltwrapper_script_p file
1262b68e1f86Smrg# True iff FILE is a libtool wrapper script
1263b68e1f86Smrg# This function is only a basic sanity check; it will hardly flush out
1264b68e1f86Smrg# determined imposters.
1265b68e1f86Smrgfunc_ltwrapper_script_p ()
1266b68e1f86Smrg{
1267b68e1f86Smrg    func_lalib_p "$1"
1268b68e1f86Smrg}
12696df26cacSmrg
1270b68e1f86Smrg# func_ltwrapper_executable_p file
1271b68e1f86Smrg# True iff FILE is a libtool wrapper executable
1272b68e1f86Smrg# This function is only a basic sanity check; it will hardly flush out
1273b68e1f86Smrg# determined imposters.
1274b68e1f86Smrgfunc_ltwrapper_executable_p ()
1275b68e1f86Smrg{
1276b68e1f86Smrg    func_ltwrapper_exec_suffix=
1277b68e1f86Smrg    case $1 in
1278b68e1f86Smrg    *.exe) ;;
1279b68e1f86Smrg    *) func_ltwrapper_exec_suffix=.exe ;;
1280b68e1f86Smrg    esac
1281b68e1f86Smrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
1282b68e1f86Smrg}
12836df26cacSmrg
1284b68e1f86Smrg# func_ltwrapper_scriptname file
1285b68e1f86Smrg# Assumes file is an ltwrapper_executable
1286b68e1f86Smrg# uses $file to determine the appropriate filename for a
1287b68e1f86Smrg# temporary ltwrapper_script.
1288b68e1f86Smrgfunc_ltwrapper_scriptname ()
1289b68e1f86Smrg{
12903bfa90b6Smrg    func_dirname_and_basename "$1" "" "."
12913bfa90b6Smrg    func_stripname '' '.exe' "$func_basename_result"
12923bfa90b6Smrg    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
1293b68e1f86Smrg}
1294b68e1f86Smrg
1295b68e1f86Smrg# func_ltwrapper_p file
1296b68e1f86Smrg# True iff FILE is a libtool wrapper script or wrapper executable
1297b68e1f86Smrg# This function is only a basic sanity check; it will hardly flush out
1298b68e1f86Smrg# determined imposters.
1299b68e1f86Smrgfunc_ltwrapper_p ()
1300b68e1f86Smrg{
1301b68e1f86Smrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
1302b68e1f86Smrg}
1303b68e1f86Smrg
1304b68e1f86Smrg
1305b68e1f86Smrg# func_execute_cmds commands fail_cmd
1306b68e1f86Smrg# Execute tilde-delimited COMMANDS.
1307b68e1f86Smrg# If FAIL_CMD is given, eval that upon failure.
1308b68e1f86Smrg# FAIL_CMD may read-access the current command in variable CMD!
1309b68e1f86Smrgfunc_execute_cmds ()
1310b68e1f86Smrg{
1311b68e1f86Smrg    $opt_debug
1312b68e1f86Smrg    save_ifs=$IFS; IFS='~'
1313b68e1f86Smrg    for cmd in $1; do
1314b68e1f86Smrg      IFS=$save_ifs
1315b68e1f86Smrg      eval cmd=\"$cmd\"
1316b68e1f86Smrg      func_show_eval "$cmd" "${2-:}"
1317b68e1f86Smrg    done
1318b68e1f86Smrg    IFS=$save_ifs
1319b68e1f86Smrg}
1320b68e1f86Smrg
1321b68e1f86Smrg
1322b68e1f86Smrg# func_source file
1323b68e1f86Smrg# Source FILE, adding directory component if necessary.
1324b68e1f86Smrg# Note that it is not necessary on cygwin/mingw to append a dot to
1325b68e1f86Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
1326b68e1f86Smrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
1327b68e1f86Smrg# `FILE.' does not work on cygwin managed mounts.
1328b68e1f86Smrgfunc_source ()
1329b68e1f86Smrg{
1330b68e1f86Smrg    $opt_debug
1331b68e1f86Smrg    case $1 in
1332b68e1f86Smrg    */* | *\\*)	. "$1" ;;
1333b68e1f86Smrg    *)		. "./$1" ;;
1334b68e1f86Smrg    esac
1335b68e1f86Smrg}
1336b68e1f86Smrg
1337b68e1f86Smrg
13383bfa90b6Smrg# func_resolve_sysroot PATH
13393bfa90b6Smrg# Replace a leading = in PATH with a sysroot.  Store the result into
13403bfa90b6Smrg# func_resolve_sysroot_result
13413bfa90b6Smrgfunc_resolve_sysroot ()
13423bfa90b6Smrg{
13433bfa90b6Smrg  func_resolve_sysroot_result=$1
13443bfa90b6Smrg  case $func_resolve_sysroot_result in
13453bfa90b6Smrg  =*)
13463bfa90b6Smrg    func_stripname '=' '' "$func_resolve_sysroot_result"
13473bfa90b6Smrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
13483bfa90b6Smrg    ;;
13493bfa90b6Smrg  esac
13503bfa90b6Smrg}
13513bfa90b6Smrg
13523bfa90b6Smrg# func_replace_sysroot PATH
13533bfa90b6Smrg# If PATH begins with the sysroot, replace it with = and
13543bfa90b6Smrg# store the result into func_replace_sysroot_result.
13553bfa90b6Smrgfunc_replace_sysroot ()
13563bfa90b6Smrg{
13573bfa90b6Smrg  case "$lt_sysroot:$1" in
13583bfa90b6Smrg  ?*:"$lt_sysroot"*)
13593bfa90b6Smrg    func_stripname "$lt_sysroot" '' "$1"
13603bfa90b6Smrg    func_replace_sysroot_result="=$func_stripname_result"
13613bfa90b6Smrg    ;;
13623bfa90b6Smrg  *)
13633bfa90b6Smrg    # Including no sysroot.
13643bfa90b6Smrg    func_replace_sysroot_result=$1
13653bfa90b6Smrg    ;;
13663bfa90b6Smrg  esac
13673bfa90b6Smrg}
13683bfa90b6Smrg
1369b68e1f86Smrg# func_infer_tag arg
1370b68e1f86Smrg# Infer tagged configuration to use if any are available and
1371b68e1f86Smrg# if one wasn't chosen via the "--tag" command line option.
1372b68e1f86Smrg# Only attempt this if the compiler in the base compile
1373b68e1f86Smrg# command doesn't match the default compiler.
1374b68e1f86Smrg# arg is usually of the form 'gcc ...'
1375b68e1f86Smrgfunc_infer_tag ()
1376b68e1f86Smrg{
1377b68e1f86Smrg    $opt_debug
1378b68e1f86Smrg    if test -n "$available_tags" && test -z "$tagname"; then
1379b68e1f86Smrg      CC_quoted=
1380b68e1f86Smrg      for arg in $CC; do
13813bfa90b6Smrg	func_append_quoted CC_quoted "$arg"
1382b68e1f86Smrg      done
13833bfa90b6Smrg      CC_expanded=`func_echo_all $CC`
13843bfa90b6Smrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
1385b68e1f86Smrg      case $@ in
1386b68e1f86Smrg      # Blanks in the command may have been stripped by the calling shell,
1387b68e1f86Smrg      # but not from the CC environment variable when configure was run.
13883bfa90b6Smrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
13893bfa90b6Smrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
1390b68e1f86Smrg      # Blanks at the start of $base_compile will cause this to fail
1391b68e1f86Smrg      # if we don't check for them as well.
1392b68e1f86Smrg      *)
1393b68e1f86Smrg	for z in $available_tags; do
1394b68e1f86Smrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1395b68e1f86Smrg	    # Evaluate the configuration.
1396b68e1f86Smrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1397b68e1f86Smrg	    CC_quoted=
1398b68e1f86Smrg	    for arg in $CC; do
1399b68e1f86Smrg	      # Double-quote args containing other shell metacharacters.
14003bfa90b6Smrg	      func_append_quoted CC_quoted "$arg"
1401b68e1f86Smrg	    done
14023bfa90b6Smrg	    CC_expanded=`func_echo_all $CC`
14033bfa90b6Smrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
1404b68e1f86Smrg	    case "$@ " in
14053bfa90b6Smrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
14063bfa90b6Smrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
1407b68e1f86Smrg	      # The compiler in the base compile command matches
1408b68e1f86Smrg	      # the one in the tagged configuration.
1409b68e1f86Smrg	      # Assume this is the tagged configuration we want.
1410b68e1f86Smrg	      tagname=$z
1411b68e1f86Smrg	      break
1412b68e1f86Smrg	      ;;
1413b68e1f86Smrg	    esac
1414b68e1f86Smrg	  fi
1415b68e1f86Smrg	done
1416b68e1f86Smrg	# If $tagname still isn't set, then no tagged configuration
1417b68e1f86Smrg	# was found and let the user know that the "--tag" command
1418b68e1f86Smrg	# line option must be used.
1419b68e1f86Smrg	if test -z "$tagname"; then
1420b68e1f86Smrg	  func_echo "unable to infer tagged configuration"
1421b68e1f86Smrg	  func_fatal_error "specify a tag with \`--tag'"
1422b68e1f86Smrg#	else
1423b68e1f86Smrg#	  func_verbose "using $tagname tagged configuration"
1424b68e1f86Smrg	fi
1425b68e1f86Smrg	;;
1426b68e1f86Smrg      esac
1427b68e1f86Smrg    fi
1428b68e1f86Smrg}
1429b68e1f86Smrg
1430b68e1f86Smrg
1431b68e1f86Smrg
1432b68e1f86Smrg# func_write_libtool_object output_name pic_name nonpic_name
1433b68e1f86Smrg# Create a libtool object file (analogous to a ".la" file),
1434b68e1f86Smrg# but don't create it if we're doing a dry run.
1435b68e1f86Smrgfunc_write_libtool_object ()
1436b68e1f86Smrg{
1437b68e1f86Smrg    write_libobj=${1}
1438b68e1f86Smrg    if test "$build_libtool_libs" = yes; then
1439b68e1f86Smrg      write_lobj=\'${2}\'
1440b68e1f86Smrg    else
1441b68e1f86Smrg      write_lobj=none
1442b68e1f86Smrg    fi
1443b68e1f86Smrg
1444b68e1f86Smrg    if test "$build_old_libs" = yes; then
1445b68e1f86Smrg      write_oldobj=\'${3}\'
1446b68e1f86Smrg    else
1447b68e1f86Smrg      write_oldobj=none
1448b68e1f86Smrg    fi
1449b68e1f86Smrg
1450b68e1f86Smrg    $opt_dry_run || {
1451b68e1f86Smrg      cat >${write_libobj}T <<EOF
1452b68e1f86Smrg# $write_libobj - a libtool object file
1453b68e1f86Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1454b68e1f86Smrg#
1455b68e1f86Smrg# Please DO NOT delete this file!
1456b68e1f86Smrg# It is necessary for linking the library.
1457b68e1f86Smrg
1458b68e1f86Smrg# Name of the PIC object.
1459b68e1f86Smrgpic_object=$write_lobj
1460b68e1f86Smrg
1461b68e1f86Smrg# Name of the non-PIC object
1462b68e1f86Smrgnon_pic_object=$write_oldobj
1463b68e1f86Smrg
1464b68e1f86SmrgEOF
1465b68e1f86Smrg      $MV "${write_libobj}T" "${write_libobj}"
1466b68e1f86Smrg    }
1467b68e1f86Smrg}
1468b68e1f86Smrg
14693bfa90b6Smrg
14703bfa90b6Smrg##################################################
14713bfa90b6Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
14723bfa90b6Smrg##################################################
14733bfa90b6Smrg
14743bfa90b6Smrg# func_convert_core_file_wine_to_w32 ARG
14753bfa90b6Smrg# Helper function used by file name conversion functions when $build is *nix,
14763bfa90b6Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
14773bfa90b6Smrg# correctly configured wine environment available, with the winepath program
14783bfa90b6Smrg# in $build's $PATH.
14793bfa90b6Smrg#
14803bfa90b6Smrg# ARG is the $build file name to be converted to w32 format.
14813bfa90b6Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
14823bfa90b6Smrg# be empty on error (or when ARG is empty)
14833bfa90b6Smrgfunc_convert_core_file_wine_to_w32 ()
14843bfa90b6Smrg{
14853bfa90b6Smrg  $opt_debug
14863bfa90b6Smrg  func_convert_core_file_wine_to_w32_result="$1"
14873bfa90b6Smrg  if test -n "$1"; then
14883bfa90b6Smrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
14893bfa90b6Smrg    # are forced to check the contents of stdout. On the other hand, if the
14903bfa90b6Smrg    # command is not found, the shell will set an exit code of 127 and print
14913bfa90b6Smrg    # *an error message* to stdout. So we must check for both error code of
14923bfa90b6Smrg    # zero AND non-empty stdout, which explains the odd construction:
14933bfa90b6Smrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
14943bfa90b6Smrg    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
14953bfa90b6Smrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
14963bfa90b6Smrg        $SED -e "$lt_sed_naive_backslashify"`
14973bfa90b6Smrg    else
14983bfa90b6Smrg      func_convert_core_file_wine_to_w32_result=
14993bfa90b6Smrg    fi
15003bfa90b6Smrg  fi
15013bfa90b6Smrg}
15023bfa90b6Smrg# end: func_convert_core_file_wine_to_w32
15033bfa90b6Smrg
15043bfa90b6Smrg
15053bfa90b6Smrg# func_convert_core_path_wine_to_w32 ARG
15063bfa90b6Smrg# Helper function used by path conversion functions when $build is *nix, and
15073bfa90b6Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
15083bfa90b6Smrg# configured wine environment available, with the winepath program in $build's
15093bfa90b6Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
15103bfa90b6Smrg#
15113bfa90b6Smrg# ARG is path to be converted from $build format to win32.
15123bfa90b6Smrg# Result is available in $func_convert_core_path_wine_to_w32_result.
15133bfa90b6Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
15143bfa90b6Smrg# are convertible, then the result may be empty.
15153bfa90b6Smrgfunc_convert_core_path_wine_to_w32 ()
15163bfa90b6Smrg{
15173bfa90b6Smrg  $opt_debug
15183bfa90b6Smrg  # unfortunately, winepath doesn't convert paths, only file names
15193bfa90b6Smrg  func_convert_core_path_wine_to_w32_result=""
15203bfa90b6Smrg  if test -n "$1"; then
15213bfa90b6Smrg    oldIFS=$IFS
15223bfa90b6Smrg    IFS=:
15233bfa90b6Smrg    for func_convert_core_path_wine_to_w32_f in $1; do
15243bfa90b6Smrg      IFS=$oldIFS
15253bfa90b6Smrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
15263bfa90b6Smrg      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
15273bfa90b6Smrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
15283bfa90b6Smrg          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
15293bfa90b6Smrg        else
15303bfa90b6Smrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
15313bfa90b6Smrg        fi
15323bfa90b6Smrg      fi
15333bfa90b6Smrg    done
15343bfa90b6Smrg    IFS=$oldIFS
15353bfa90b6Smrg  fi
15363bfa90b6Smrg}
15373bfa90b6Smrg# end: func_convert_core_path_wine_to_w32
15383bfa90b6Smrg
15393bfa90b6Smrg
15403bfa90b6Smrg# func_cygpath ARGS...
15413bfa90b6Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
15423bfa90b6Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
15433bfa90b6Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
15443bfa90b6Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
15453bfa90b6Smrg# file name or path is assumed to be in w32 format, as previously converted
15463bfa90b6Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
15473bfa90b6Smrg# or path in func_cygpath_result (input file name or path is assumed to be in
15483bfa90b6Smrg# Cygwin format). Returns an empty string on error.
15493bfa90b6Smrg#
15503bfa90b6Smrg# ARGS are passed to cygpath, with the last one being the file name or path to
15513bfa90b6Smrg# be converted.
15523bfa90b6Smrg#
15533bfa90b6Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
15543bfa90b6Smrg# environment variable; do not put it in $PATH.
15553bfa90b6Smrgfunc_cygpath ()
15563bfa90b6Smrg{
15573bfa90b6Smrg  $opt_debug
15583bfa90b6Smrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
15593bfa90b6Smrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
15603bfa90b6Smrg    if test "$?" -ne 0; then
15613bfa90b6Smrg      # on failure, ensure result is empty
15623bfa90b6Smrg      func_cygpath_result=
15633bfa90b6Smrg    fi
15643bfa90b6Smrg  else
15653bfa90b6Smrg    func_cygpath_result=
15663bfa90b6Smrg    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
15673bfa90b6Smrg  fi
15683bfa90b6Smrg}
15693bfa90b6Smrg#end: func_cygpath
15703bfa90b6Smrg
15713bfa90b6Smrg
15723bfa90b6Smrg# func_convert_core_msys_to_w32 ARG
15733bfa90b6Smrg# Convert file name or path ARG from MSYS format to w32 format.  Return
15743bfa90b6Smrg# result in func_convert_core_msys_to_w32_result.
15753bfa90b6Smrgfunc_convert_core_msys_to_w32 ()
15763bfa90b6Smrg{
15773bfa90b6Smrg  $opt_debug
15783bfa90b6Smrg  # awkward: cmd appends spaces to result
15793bfa90b6Smrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
15803bfa90b6Smrg    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
15813bfa90b6Smrg}
15823bfa90b6Smrg#end: func_convert_core_msys_to_w32
15833bfa90b6Smrg
15843bfa90b6Smrg
15853bfa90b6Smrg# func_convert_file_check ARG1 ARG2
15863bfa90b6Smrg# Verify that ARG1 (a file name in $build format) was converted to $host
15873bfa90b6Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
15883bfa90b6Smrg# func_to_host_file_result to ARG1).
15893bfa90b6Smrgfunc_convert_file_check ()
15903bfa90b6Smrg{
15913bfa90b6Smrg  $opt_debug
15923bfa90b6Smrg  if test -z "$2" && test -n "$1" ; then
15933bfa90b6Smrg    func_error "Could not determine host file name corresponding to"
15943bfa90b6Smrg    func_error "  \`$1'"
15953bfa90b6Smrg    func_error "Continuing, but uninstalled executables may not work."
15963bfa90b6Smrg    # Fallback:
15973bfa90b6Smrg    func_to_host_file_result="$1"
15983bfa90b6Smrg  fi
15993bfa90b6Smrg}
16003bfa90b6Smrg# end func_convert_file_check
16013bfa90b6Smrg
16023bfa90b6Smrg
16033bfa90b6Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
16043bfa90b6Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host
16053bfa90b6Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
16063bfa90b6Smrg# func_to_host_file_result to a simplistic fallback value (see below).
16073bfa90b6Smrgfunc_convert_path_check ()
16083bfa90b6Smrg{
16093bfa90b6Smrg  $opt_debug
16103bfa90b6Smrg  if test -z "$4" && test -n "$3"; then
16113bfa90b6Smrg    func_error "Could not determine the host path corresponding to"
16123bfa90b6Smrg    func_error "  \`$3'"
16133bfa90b6Smrg    func_error "Continuing, but uninstalled executables may not work."
16143bfa90b6Smrg    # Fallback.  This is a deliberately simplistic "conversion" and
16153bfa90b6Smrg    # should not be "improved".  See libtool.info.
16163bfa90b6Smrg    if test "x$1" != "x$2"; then
16173bfa90b6Smrg      lt_replace_pathsep_chars="s|$1|$2|g"
16183bfa90b6Smrg      func_to_host_path_result=`echo "$3" |
16193bfa90b6Smrg        $SED -e "$lt_replace_pathsep_chars"`
16203bfa90b6Smrg    else
16213bfa90b6Smrg      func_to_host_path_result="$3"
16223bfa90b6Smrg    fi
16233bfa90b6Smrg  fi
16243bfa90b6Smrg}
16253bfa90b6Smrg# end func_convert_path_check
16263bfa90b6Smrg
16273bfa90b6Smrg
16283bfa90b6Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
16293bfa90b6Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
16303bfa90b6Smrg# and appending REPL if ORIG matches BACKPAT.
16313bfa90b6Smrgfunc_convert_path_front_back_pathsep ()
16323bfa90b6Smrg{
16333bfa90b6Smrg  $opt_debug
16343bfa90b6Smrg  case $4 in
16353bfa90b6Smrg  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
16363bfa90b6Smrg    ;;
16373bfa90b6Smrg  esac
16383bfa90b6Smrg  case $4 in
16393bfa90b6Smrg  $2 ) func_append func_to_host_path_result "$3"
16403bfa90b6Smrg    ;;
16413bfa90b6Smrg  esac
16423bfa90b6Smrg}
16433bfa90b6Smrg# end func_convert_path_front_back_pathsep
16443bfa90b6Smrg
16453bfa90b6Smrg
16463bfa90b6Smrg##################################################
16473bfa90b6Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
16483bfa90b6Smrg##################################################
16493bfa90b6Smrg# invoked via `$to_host_file_cmd ARG'
16503bfa90b6Smrg#
16513bfa90b6Smrg# In each case, ARG is the path to be converted from $build to $host format.
16523bfa90b6Smrg# Result will be available in $func_to_host_file_result.
16533bfa90b6Smrg
16543bfa90b6Smrg
16553bfa90b6Smrg# func_to_host_file ARG
16563bfa90b6Smrg# Converts the file name ARG from $build format to $host format. Return result
16573bfa90b6Smrg# in func_to_host_file_result.
16583bfa90b6Smrgfunc_to_host_file ()
16593bfa90b6Smrg{
16603bfa90b6Smrg  $opt_debug
16613bfa90b6Smrg  $to_host_file_cmd "$1"
16623bfa90b6Smrg}
16633bfa90b6Smrg# end func_to_host_file
16643bfa90b6Smrg
16653bfa90b6Smrg
16663bfa90b6Smrg# func_to_tool_file ARG LAZY
16673bfa90b6Smrg# converts the file name ARG from $build format to toolchain format. Return
16683bfa90b6Smrg# result in func_to_tool_file_result.  If the conversion in use is listed
16693bfa90b6Smrg# in (the comma separated) LAZY, no conversion takes place.
16703bfa90b6Smrgfunc_to_tool_file ()
16713bfa90b6Smrg{
16723bfa90b6Smrg  $opt_debug
16733bfa90b6Smrg  case ,$2, in
16743bfa90b6Smrg    *,"$to_tool_file_cmd",*)
16753bfa90b6Smrg      func_to_tool_file_result=$1
16763bfa90b6Smrg      ;;
16773bfa90b6Smrg    *)
16783bfa90b6Smrg      $to_tool_file_cmd "$1"
16793bfa90b6Smrg      func_to_tool_file_result=$func_to_host_file_result
16803bfa90b6Smrg      ;;
16813bfa90b6Smrg  esac
16823bfa90b6Smrg}
16833bfa90b6Smrg# end func_to_tool_file
16843bfa90b6Smrg
16853bfa90b6Smrg
16863bfa90b6Smrg# func_convert_file_noop ARG
16873bfa90b6Smrg# Copy ARG to func_to_host_file_result.
16883bfa90b6Smrgfunc_convert_file_noop ()
16893bfa90b6Smrg{
16903bfa90b6Smrg  func_to_host_file_result="$1"
16913bfa90b6Smrg}
16923bfa90b6Smrg# end func_convert_file_noop
16933bfa90b6Smrg
16943bfa90b6Smrg
16953bfa90b6Smrg# func_convert_file_msys_to_w32 ARG
16963bfa90b6Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
16973bfa90b6Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
16983bfa90b6Smrg# func_to_host_file_result.
16993bfa90b6Smrgfunc_convert_file_msys_to_w32 ()
17003bfa90b6Smrg{
17013bfa90b6Smrg  $opt_debug
17023bfa90b6Smrg  func_to_host_file_result="$1"
17033bfa90b6Smrg  if test -n "$1"; then
17043bfa90b6Smrg    func_convert_core_msys_to_w32 "$1"
17053bfa90b6Smrg    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
17063bfa90b6Smrg  fi
17073bfa90b6Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
17083bfa90b6Smrg}
17093bfa90b6Smrg# end func_convert_file_msys_to_w32
17103bfa90b6Smrg
17113bfa90b6Smrg
17123bfa90b6Smrg# func_convert_file_cygwin_to_w32 ARG
17133bfa90b6Smrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
17143bfa90b6Smrg# func_to_host_file_result.
17153bfa90b6Smrgfunc_convert_file_cygwin_to_w32 ()
17163bfa90b6Smrg{
17173bfa90b6Smrg  $opt_debug
17183bfa90b6Smrg  func_to_host_file_result="$1"
17193bfa90b6Smrg  if test -n "$1"; then
17203bfa90b6Smrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
17213bfa90b6Smrg    # LT_CYGPATH in this case.
17223bfa90b6Smrg    func_to_host_file_result=`cygpath -m "$1"`
17233bfa90b6Smrg  fi
17243bfa90b6Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
17253bfa90b6Smrg}
17263bfa90b6Smrg# end func_convert_file_cygwin_to_w32
17273bfa90b6Smrg
17283bfa90b6Smrg
17293bfa90b6Smrg# func_convert_file_nix_to_w32 ARG
17303bfa90b6Smrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
17313bfa90b6Smrg# and a working winepath. Returns result in func_to_host_file_result.
17323bfa90b6Smrgfunc_convert_file_nix_to_w32 ()
17333bfa90b6Smrg{
17343bfa90b6Smrg  $opt_debug
17353bfa90b6Smrg  func_to_host_file_result="$1"
17363bfa90b6Smrg  if test -n "$1"; then
17373bfa90b6Smrg    func_convert_core_file_wine_to_w32 "$1"
17383bfa90b6Smrg    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
17393bfa90b6Smrg  fi
17403bfa90b6Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
17413bfa90b6Smrg}
17423bfa90b6Smrg# end func_convert_file_nix_to_w32
17433bfa90b6Smrg
17443bfa90b6Smrg
17453bfa90b6Smrg# func_convert_file_msys_to_cygwin ARG
17463bfa90b6Smrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
17473bfa90b6Smrg# Returns result in func_to_host_file_result.
17483bfa90b6Smrgfunc_convert_file_msys_to_cygwin ()
17493bfa90b6Smrg{
17503bfa90b6Smrg  $opt_debug
17513bfa90b6Smrg  func_to_host_file_result="$1"
17523bfa90b6Smrg  if test -n "$1"; then
17533bfa90b6Smrg    func_convert_core_msys_to_w32 "$1"
17543bfa90b6Smrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
17553bfa90b6Smrg    func_to_host_file_result="$func_cygpath_result"
17563bfa90b6Smrg  fi
17573bfa90b6Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
17583bfa90b6Smrg}
17593bfa90b6Smrg# end func_convert_file_msys_to_cygwin
17603bfa90b6Smrg
17613bfa90b6Smrg
17623bfa90b6Smrg# func_convert_file_nix_to_cygwin ARG
17633bfa90b6Smrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
17643bfa90b6Smrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
17653bfa90b6Smrg# in func_to_host_file_result.
17663bfa90b6Smrgfunc_convert_file_nix_to_cygwin ()
17673bfa90b6Smrg{
17683bfa90b6Smrg  $opt_debug
17693bfa90b6Smrg  func_to_host_file_result="$1"
17703bfa90b6Smrg  if test -n "$1"; then
17713bfa90b6Smrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
17723bfa90b6Smrg    func_convert_core_file_wine_to_w32 "$1"
17733bfa90b6Smrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
17743bfa90b6Smrg    func_to_host_file_result="$func_cygpath_result"
17753bfa90b6Smrg  fi
17763bfa90b6Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
17773bfa90b6Smrg}
17783bfa90b6Smrg# end func_convert_file_nix_to_cygwin
17793bfa90b6Smrg
17803bfa90b6Smrg
17813bfa90b6Smrg#############################################
17823bfa90b6Smrg# $build to $host PATH CONVERSION FUNCTIONS #
17833bfa90b6Smrg#############################################
17843bfa90b6Smrg# invoked via `$to_host_path_cmd ARG'
17853bfa90b6Smrg#
17863bfa90b6Smrg# In each case, ARG is the path to be converted from $build to $host format.
17873bfa90b6Smrg# The result will be available in $func_to_host_path_result.
17883bfa90b6Smrg#
17893bfa90b6Smrg# Path separators are also converted from $build format to $host format.  If
17903bfa90b6Smrg# ARG begins or ends with a path separator character, it is preserved (but
17913bfa90b6Smrg# converted to $host format) on output.
17923bfa90b6Smrg#
17933bfa90b6Smrg# All path conversion functions are named using the following convention:
17943bfa90b6Smrg#   file name conversion function    : func_convert_file_X_to_Y ()
17953bfa90b6Smrg#   path conversion function         : func_convert_path_X_to_Y ()
17963bfa90b6Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the
17973bfa90b6Smrg# same.  If conversion functions are added for new $build/$host combinations,
17983bfa90b6Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
17993bfa90b6Smrg# will break.
18003bfa90b6Smrg
18013bfa90b6Smrg
18023bfa90b6Smrg# func_init_to_host_path_cmd
18033bfa90b6Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
18043bfa90b6Smrg# appropriate value, based on the value of $to_host_file_cmd.
18053bfa90b6Smrgto_host_path_cmd=
18063bfa90b6Smrgfunc_init_to_host_path_cmd ()
18073bfa90b6Smrg{
18083bfa90b6Smrg  $opt_debug
18093bfa90b6Smrg  if test -z "$to_host_path_cmd"; then
18103bfa90b6Smrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
18113bfa90b6Smrg    to_host_path_cmd="func_convert_path_${func_stripname_result}"
18123bfa90b6Smrg  fi
18133bfa90b6Smrg}
18143bfa90b6Smrg
18153bfa90b6Smrg
18163bfa90b6Smrg# func_to_host_path ARG
18173bfa90b6Smrg# Converts the path ARG from $build format to $host format. Return result
18183bfa90b6Smrg# in func_to_host_path_result.
18193bfa90b6Smrgfunc_to_host_path ()
18203bfa90b6Smrg{
18213bfa90b6Smrg  $opt_debug
18223bfa90b6Smrg  func_init_to_host_path_cmd
18233bfa90b6Smrg  $to_host_path_cmd "$1"
18243bfa90b6Smrg}
18253bfa90b6Smrg# end func_to_host_path
18263bfa90b6Smrg
18273bfa90b6Smrg
18283bfa90b6Smrg# func_convert_path_noop ARG
18293bfa90b6Smrg# Copy ARG to func_to_host_path_result.
18303bfa90b6Smrgfunc_convert_path_noop ()
18313bfa90b6Smrg{
18323bfa90b6Smrg  func_to_host_path_result="$1"
18333bfa90b6Smrg}
18343bfa90b6Smrg# end func_convert_path_noop
18353bfa90b6Smrg
18363bfa90b6Smrg
18373bfa90b6Smrg# func_convert_path_msys_to_w32 ARG
18383bfa90b6Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
18393bfa90b6Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
18403bfa90b6Smrg# func_to_host_path_result.
18413bfa90b6Smrgfunc_convert_path_msys_to_w32 ()
18423bfa90b6Smrg{
18433bfa90b6Smrg  $opt_debug
18443bfa90b6Smrg  func_to_host_path_result="$1"
18453bfa90b6Smrg  if test -n "$1"; then
18463bfa90b6Smrg    # Remove leading and trailing path separator characters from ARG.  MSYS
18473bfa90b6Smrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
18483bfa90b6Smrg    # and winepath ignores them completely.
18493bfa90b6Smrg    func_stripname : : "$1"
18503bfa90b6Smrg    func_to_host_path_tmp1=$func_stripname_result
18513bfa90b6Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
18523bfa90b6Smrg    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
18533bfa90b6Smrg    func_convert_path_check : ";" \
18543bfa90b6Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
18553bfa90b6Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
18563bfa90b6Smrg  fi
18573bfa90b6Smrg}
18583bfa90b6Smrg# end func_convert_path_msys_to_w32
18593bfa90b6Smrg
18603bfa90b6Smrg
18613bfa90b6Smrg# func_convert_path_cygwin_to_w32 ARG
18623bfa90b6Smrg# Convert path ARG from Cygwin to w32 format.  Returns result in
18633bfa90b6Smrg# func_to_host_file_result.
18643bfa90b6Smrgfunc_convert_path_cygwin_to_w32 ()
18653bfa90b6Smrg{
18663bfa90b6Smrg  $opt_debug
18673bfa90b6Smrg  func_to_host_path_result="$1"
18683bfa90b6Smrg  if test -n "$1"; then
18693bfa90b6Smrg    # See func_convert_path_msys_to_w32:
18703bfa90b6Smrg    func_stripname : : "$1"
18713bfa90b6Smrg    func_to_host_path_tmp1=$func_stripname_result
18723bfa90b6Smrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
18733bfa90b6Smrg    func_convert_path_check : ";" \
18743bfa90b6Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
18753bfa90b6Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
18763bfa90b6Smrg  fi
18773bfa90b6Smrg}
18783bfa90b6Smrg# end func_convert_path_cygwin_to_w32
18793bfa90b6Smrg
18803bfa90b6Smrg
18813bfa90b6Smrg# func_convert_path_nix_to_w32 ARG
18823bfa90b6Smrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
18833bfa90b6Smrg# a working winepath.  Returns result in func_to_host_file_result.
18843bfa90b6Smrgfunc_convert_path_nix_to_w32 ()
18853bfa90b6Smrg{
18863bfa90b6Smrg  $opt_debug
18873bfa90b6Smrg  func_to_host_path_result="$1"
18883bfa90b6Smrg  if test -n "$1"; then
18893bfa90b6Smrg    # See func_convert_path_msys_to_w32:
18903bfa90b6Smrg    func_stripname : : "$1"
18913bfa90b6Smrg    func_to_host_path_tmp1=$func_stripname_result
18923bfa90b6Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
18933bfa90b6Smrg    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
18943bfa90b6Smrg    func_convert_path_check : ";" \
18953bfa90b6Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
18963bfa90b6Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
18973bfa90b6Smrg  fi
18983bfa90b6Smrg}
18993bfa90b6Smrg# end func_convert_path_nix_to_w32
19003bfa90b6Smrg
19013bfa90b6Smrg
19023bfa90b6Smrg# func_convert_path_msys_to_cygwin ARG
19033bfa90b6Smrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
19043bfa90b6Smrg# Returns result in func_to_host_file_result.
19053bfa90b6Smrgfunc_convert_path_msys_to_cygwin ()
19063bfa90b6Smrg{
19073bfa90b6Smrg  $opt_debug
19083bfa90b6Smrg  func_to_host_path_result="$1"
19093bfa90b6Smrg  if test -n "$1"; then
19103bfa90b6Smrg    # See func_convert_path_msys_to_w32:
19113bfa90b6Smrg    func_stripname : : "$1"
19123bfa90b6Smrg    func_to_host_path_tmp1=$func_stripname_result
19133bfa90b6Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
19143bfa90b6Smrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
19153bfa90b6Smrg    func_to_host_path_result="$func_cygpath_result"
19163bfa90b6Smrg    func_convert_path_check : : \
19173bfa90b6Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
19183bfa90b6Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
19193bfa90b6Smrg  fi
19203bfa90b6Smrg}
19213bfa90b6Smrg# end func_convert_path_msys_to_cygwin
19223bfa90b6Smrg
19233bfa90b6Smrg
19243bfa90b6Smrg# func_convert_path_nix_to_cygwin ARG
19253bfa90b6Smrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
19263bfa90b6Smrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
19273bfa90b6Smrg# func_to_host_file_result.
19283bfa90b6Smrgfunc_convert_path_nix_to_cygwin ()
19293bfa90b6Smrg{
19303bfa90b6Smrg  $opt_debug
19313bfa90b6Smrg  func_to_host_path_result="$1"
19323bfa90b6Smrg  if test -n "$1"; then
19333bfa90b6Smrg    # Remove leading and trailing path separator characters from
19343bfa90b6Smrg    # ARG. msys behavior is inconsistent here, cygpath turns them
19353bfa90b6Smrg    # into '.;' and ';.', and winepath ignores them completely.
19363bfa90b6Smrg    func_stripname : : "$1"
19373bfa90b6Smrg    func_to_host_path_tmp1=$func_stripname_result
19383bfa90b6Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
19393bfa90b6Smrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
19403bfa90b6Smrg    func_to_host_path_result="$func_cygpath_result"
19413bfa90b6Smrg    func_convert_path_check : : \
19423bfa90b6Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
19433bfa90b6Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
19443bfa90b6Smrg  fi
19453bfa90b6Smrg}
19463bfa90b6Smrg# end func_convert_path_nix_to_cygwin
19473bfa90b6Smrg
19483bfa90b6Smrg
1949b68e1f86Smrg# func_mode_compile arg...
1950b68e1f86Smrgfunc_mode_compile ()
1951b68e1f86Smrg{
1952b68e1f86Smrg    $opt_debug
1953b68e1f86Smrg    # Get the compilation command and the source file.
1954b68e1f86Smrg    base_compile=
1955b68e1f86Smrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
1956b68e1f86Smrg    suppress_opt=yes
1957b68e1f86Smrg    suppress_output=
1958b68e1f86Smrg    arg_mode=normal
1959b68e1f86Smrg    libobj=
1960b68e1f86Smrg    later=
1961b68e1f86Smrg    pie_flag=
1962b68e1f86Smrg
1963b68e1f86Smrg    for arg
1964b68e1f86Smrg    do
1965b68e1f86Smrg      case $arg_mode in
1966b68e1f86Smrg      arg  )
1967b68e1f86Smrg	# do not "continue".  Instead, add this to base_compile
1968b68e1f86Smrg	lastarg="$arg"
1969b68e1f86Smrg	arg_mode=normal
1970b68e1f86Smrg	;;
1971b68e1f86Smrg
1972b68e1f86Smrg      target )
1973b68e1f86Smrg	libobj="$arg"
1974b68e1f86Smrg	arg_mode=normal
1975b68e1f86Smrg	continue
1976b68e1f86Smrg	;;
1977b68e1f86Smrg
1978b68e1f86Smrg      normal )
1979b68e1f86Smrg	# Accept any command-line options.
1980b68e1f86Smrg	case $arg in
1981b68e1f86Smrg	-o)
1982b68e1f86Smrg	  test -n "$libobj" && \
1983b68e1f86Smrg	    func_fatal_error "you cannot specify \`-o' more than once"
1984b68e1f86Smrg	  arg_mode=target
1985b68e1f86Smrg	  continue
1986b68e1f86Smrg	  ;;
1987b68e1f86Smrg
1988b68e1f86Smrg	-pie | -fpie | -fPIE)
19893bfa90b6Smrg          func_append pie_flag " $arg"
1990b68e1f86Smrg	  continue
1991b68e1f86Smrg	  ;;
1992b68e1f86Smrg
1993b68e1f86Smrg	-shared | -static | -prefer-pic | -prefer-non-pic)
19943bfa90b6Smrg	  func_append later " $arg"
1995b68e1f86Smrg	  continue
1996b68e1f86Smrg	  ;;
1997b68e1f86Smrg
1998b68e1f86Smrg	-no-suppress)
19996df26cacSmrg	  suppress_opt=no
20006df26cacSmrg	  continue
20016df26cacSmrg	  ;;
20026df26cacSmrg
20036df26cacSmrg	-Xcompiler)
20046df26cacSmrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
20056df26cacSmrg	  continue      #  The current "srcfile" will either be retained or
20066df26cacSmrg	  ;;            #  replaced later.  I would guess that would be a bug.
20076df26cacSmrg
20086df26cacSmrg	-Wc,*)
2009b68e1f86Smrg	  func_stripname '-Wc,' '' "$arg"
2010b68e1f86Smrg	  args=$func_stripname_result
20116df26cacSmrg	  lastarg=
20126df26cacSmrg	  save_ifs="$IFS"; IFS=','
2013b68e1f86Smrg	  for arg in $args; do
20146df26cacSmrg	    IFS="$save_ifs"
20153bfa90b6Smrg	    func_append_quoted lastarg "$arg"
20166df26cacSmrg	  done
20176df26cacSmrg	  IFS="$save_ifs"
2018b68e1f86Smrg	  func_stripname ' ' '' "$lastarg"
2019b68e1f86Smrg	  lastarg=$func_stripname_result
20206df26cacSmrg
20216df26cacSmrg	  # Add the arguments to base_compile.
20223bfa90b6Smrg	  func_append base_compile " $lastarg"
20236df26cacSmrg	  continue
20246df26cacSmrg	  ;;
20256df26cacSmrg
2026b68e1f86Smrg	*)
20276df26cacSmrg	  # Accept the current argument as the source file.
20286df26cacSmrg	  # The previous "srcfile" becomes the current argument.
20296df26cacSmrg	  #
20306df26cacSmrg	  lastarg="$srcfile"
20316df26cacSmrg	  srcfile="$arg"
20326df26cacSmrg	  ;;
20336df26cacSmrg	esac  #  case $arg
20346df26cacSmrg	;;
20356df26cacSmrg      esac    #  case $arg_mode
20366df26cacSmrg
20376df26cacSmrg      # Aesthetically quote the previous argument.
20383bfa90b6Smrg      func_append_quoted base_compile "$lastarg"
20396df26cacSmrg    done # for arg
20406df26cacSmrg
20416df26cacSmrg    case $arg_mode in
20426df26cacSmrg    arg)
2043b68e1f86Smrg      func_fatal_error "you must specify an argument for -Xcompile"
20446df26cacSmrg      ;;
20456df26cacSmrg    target)
2046b68e1f86Smrg      func_fatal_error "you must specify a target with \`-o'"
20476df26cacSmrg      ;;
20486df26cacSmrg    *)
20496df26cacSmrg      # Get the name of the library object.
2050b68e1f86Smrg      test -z "$libobj" && {
2051b68e1f86Smrg	func_basename "$srcfile"
2052b68e1f86Smrg	libobj="$func_basename_result"
2053b68e1f86Smrg      }
20546df26cacSmrg      ;;
20556df26cacSmrg    esac
20566df26cacSmrg
20576df26cacSmrg    # Recognize several different file suffixes.
20586df26cacSmrg    # If the user specifies -o file.o, it is replaced with file.lo
20596df26cacSmrg    case $libobj in
2060b68e1f86Smrg    *.[cCFSifmso] | \
2061b68e1f86Smrg    *.ada | *.adb | *.ads | *.asm | \
2062b68e1f86Smrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
20633bfa90b6Smrg    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
2064b68e1f86Smrg      func_xform "$libobj"
2065b68e1f86Smrg      libobj=$func_xform_result
2066b68e1f86Smrg      ;;
20676df26cacSmrg    esac
20686df26cacSmrg
20696df26cacSmrg    case $libobj in
2070b68e1f86Smrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
20716df26cacSmrg    *)
2072b68e1f86Smrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
20736df26cacSmrg      ;;
20746df26cacSmrg    esac
20756df26cacSmrg
20766df26cacSmrg    func_infer_tag $base_compile
20776df26cacSmrg
20786df26cacSmrg    for arg in $later; do
20796df26cacSmrg      case $arg in
2080b68e1f86Smrg      -shared)
2081b68e1f86Smrg	test "$build_libtool_libs" != yes && \
2082b68e1f86Smrg	  func_fatal_configuration "can not build a shared library"
2083b68e1f86Smrg	build_old_libs=no
2084b68e1f86Smrg	continue
2085b68e1f86Smrg	;;
2086b68e1f86Smrg
20876df26cacSmrg      -static)
2088b68e1f86Smrg	build_libtool_libs=no
20896df26cacSmrg	build_old_libs=yes
20906df26cacSmrg	continue
20916df26cacSmrg	;;
20926df26cacSmrg
20936df26cacSmrg      -prefer-pic)
20946df26cacSmrg	pic_mode=yes
20956df26cacSmrg	continue
20966df26cacSmrg	;;
20976df26cacSmrg
20986df26cacSmrg      -prefer-non-pic)
20996df26cacSmrg	pic_mode=no
21006df26cacSmrg	continue
21016df26cacSmrg	;;
21026df26cacSmrg      esac
21036df26cacSmrg    done
21046df26cacSmrg
2105b68e1f86Smrg    func_quote_for_eval "$libobj"
2106b68e1f86Smrg    test "X$libobj" != "X$func_quote_for_eval_result" \
2107b68e1f86Smrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
2108b68e1f86Smrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
2109b68e1f86Smrg    func_dirname_and_basename "$obj" "/" ""
2110b68e1f86Smrg    objname="$func_basename_result"
2111b68e1f86Smrg    xdir="$func_dirname_result"
21126df26cacSmrg    lobj=${xdir}$objdir/$objname
21136df26cacSmrg
2114b68e1f86Smrg    test -z "$base_compile" && \
2115b68e1f86Smrg      func_fatal_help "you must specify a compilation command"
21166df26cacSmrg
21176df26cacSmrg    # Delete any leftover library objects.
21186df26cacSmrg    if test "$build_old_libs" = yes; then
21196df26cacSmrg      removelist="$obj $lobj $libobj ${libobj}T"
21206df26cacSmrg    else
21216df26cacSmrg      removelist="$lobj $libobj ${libobj}T"
21226df26cacSmrg    fi
21236df26cacSmrg
21246df26cacSmrg    # On Cygwin there's no "real" PIC flag so we must build both object types
21256df26cacSmrg    case $host_os in
2126b68e1f86Smrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
21276df26cacSmrg      pic_mode=default
21286df26cacSmrg      ;;
21296df26cacSmrg    esac
21306df26cacSmrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
21316df26cacSmrg      # non-PIC code in shared libraries is not supported
21326df26cacSmrg      pic_mode=default
21336df26cacSmrg    fi
21346df26cacSmrg
21356df26cacSmrg    # Calculate the filename of the output object if compiler does
21366df26cacSmrg    # not support -o with -c
21376df26cacSmrg    if test "$compiler_c_o" = no; then
21383bfa90b6Smrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
21396df26cacSmrg      lockfile="$output_obj.lock"
21406df26cacSmrg    else
21416df26cacSmrg      output_obj=
21426df26cacSmrg      need_locks=no
21436df26cacSmrg      lockfile=
21446df26cacSmrg    fi
21456df26cacSmrg
21466df26cacSmrg    # Lock this critical section if it is needed
21476df26cacSmrg    # We use this script file to make the link, it avoids creating a new file
21486df26cacSmrg    if test "$need_locks" = yes; then
2149b68e1f86Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
2150b68e1f86Smrg	func_echo "Waiting for $lockfile to be removed"
21516df26cacSmrg	sleep 2
21526df26cacSmrg      done
21536df26cacSmrg    elif test "$need_locks" = warn; then
21546df26cacSmrg      if test -f "$lockfile"; then
2155b68e1f86Smrg	$ECHO "\
21566df26cacSmrg*** ERROR, $lockfile exists and contains:
21576df26cacSmrg`cat $lockfile 2>/dev/null`
21586df26cacSmrg
21596df26cacSmrgThis indicates that another process is trying to use the same
21606df26cacSmrgtemporary object file, and libtool could not work around it because
21616df26cacSmrgyour compiler does not support \`-c' and \`-o' together.  If you
21626df26cacSmrgrepeat this compilation, it may succeed, by chance, but you had better
21636df26cacSmrgavoid parallel builds (make -j) in this platform, or get a better
21646df26cacSmrgcompiler."
21656df26cacSmrg
2166b68e1f86Smrg	$opt_dry_run || $RM $removelist
21676df26cacSmrg	exit $EXIT_FAILURE
21686df26cacSmrg      fi
21693bfa90b6Smrg      func_append removelist " $output_obj"
2170b68e1f86Smrg      $ECHO "$srcfile" > "$lockfile"
21716df26cacSmrg    fi
21726df26cacSmrg
2173b68e1f86Smrg    $opt_dry_run || $RM $removelist
21743bfa90b6Smrg    func_append removelist " $lockfile"
2175b68e1f86Smrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
2176b68e1f86Smrg
21773bfa90b6Smrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
21783bfa90b6Smrg    srcfile=$func_to_tool_file_result
2179b68e1f86Smrg    func_quote_for_eval "$srcfile"
2180b68e1f86Smrg    qsrcfile=$func_quote_for_eval_result
21816df26cacSmrg
21826df26cacSmrg    # Only build a PIC object if we are building libtool libraries.
21836df26cacSmrg    if test "$build_libtool_libs" = yes; then
21846df26cacSmrg      # Without this assignment, base_compile gets emptied.
21856df26cacSmrg      fbsd_hideous_sh_bug=$base_compile
21866df26cacSmrg
21876df26cacSmrg      if test "$pic_mode" != no; then
21886df26cacSmrg	command="$base_compile $qsrcfile $pic_flag"
21896df26cacSmrg      else
21906df26cacSmrg	# Don't build PIC code
21916df26cacSmrg	command="$base_compile $qsrcfile"
21926df26cacSmrg      fi
21936df26cacSmrg
2194b68e1f86Smrg      func_mkdir_p "$xdir$objdir"
21956df26cacSmrg
21966df26cacSmrg      if test -z "$output_obj"; then
21976df26cacSmrg	# Place PIC objects in $objdir
21983bfa90b6Smrg	func_append command " -o $lobj"
21996df26cacSmrg      fi
22006df26cacSmrg
2201b68e1f86Smrg      func_show_eval_locale "$command"	\
2202b68e1f86Smrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
22036df26cacSmrg
22046df26cacSmrg      if test "$need_locks" = warn &&
22056df26cacSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2206b68e1f86Smrg	$ECHO "\
22076df26cacSmrg*** ERROR, $lockfile contains:
22086df26cacSmrg`cat $lockfile 2>/dev/null`
22096df26cacSmrg
22106df26cacSmrgbut it should contain:
22116df26cacSmrg$srcfile
22126df26cacSmrg
22136df26cacSmrgThis indicates that another process is trying to use the same
22146df26cacSmrgtemporary object file, and libtool could not work around it because
22156df26cacSmrgyour compiler does not support \`-c' and \`-o' together.  If you
22166df26cacSmrgrepeat this compilation, it may succeed, by chance, but you had better
22176df26cacSmrgavoid parallel builds (make -j) in this platform, or get a better
22186df26cacSmrgcompiler."
22196df26cacSmrg
2220b68e1f86Smrg	$opt_dry_run || $RM $removelist
22216df26cacSmrg	exit $EXIT_FAILURE
22226df26cacSmrg      fi
22236df26cacSmrg
22246df26cacSmrg      # Just move the object if needed, then go on to compile the next one
22256df26cacSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
2226b68e1f86Smrg	func_show_eval '$MV "$output_obj" "$lobj"' \
2227b68e1f86Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
22286df26cacSmrg      fi
22296df26cacSmrg
22306df26cacSmrg      # Allow error messages only from the first compilation.
22316df26cacSmrg      if test "$suppress_opt" = yes; then
2232b68e1f86Smrg	suppress_output=' >/dev/null 2>&1'
22336df26cacSmrg      fi
22346df26cacSmrg    fi
22356df26cacSmrg
22366df26cacSmrg    # Only build a position-dependent object if we build old libraries.
22376df26cacSmrg    if test "$build_old_libs" = yes; then
22386df26cacSmrg      if test "$pic_mode" != yes; then
22396df26cacSmrg	# Don't build PIC code
2240b68e1f86Smrg	command="$base_compile $qsrcfile$pie_flag"
22416df26cacSmrg      else
22426df26cacSmrg	command="$base_compile $qsrcfile $pic_flag"
22436df26cacSmrg      fi
22446df26cacSmrg      if test "$compiler_c_o" = yes; then
22453bfa90b6Smrg	func_append command " -o $obj"
22466df26cacSmrg      fi
22476df26cacSmrg
22486df26cacSmrg      # Suppress compiler output if we already did a PIC compilation.
22493bfa90b6Smrg      func_append command "$suppress_output"
2250b68e1f86Smrg      func_show_eval_locale "$command" \
2251b68e1f86Smrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
22526df26cacSmrg
22536df26cacSmrg      if test "$need_locks" = warn &&
22546df26cacSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2255b68e1f86Smrg	$ECHO "\
22566df26cacSmrg*** ERROR, $lockfile contains:
22576df26cacSmrg`cat $lockfile 2>/dev/null`
22586df26cacSmrg
22596df26cacSmrgbut it should contain:
22606df26cacSmrg$srcfile
22616df26cacSmrg
22626df26cacSmrgThis indicates that another process is trying to use the same
22636df26cacSmrgtemporary object file, and libtool could not work around it because
22646df26cacSmrgyour compiler does not support \`-c' and \`-o' together.  If you
22656df26cacSmrgrepeat this compilation, it may succeed, by chance, but you had better
22666df26cacSmrgavoid parallel builds (make -j) in this platform, or get a better
22676df26cacSmrgcompiler."
22686df26cacSmrg
2269b68e1f86Smrg	$opt_dry_run || $RM $removelist
22706df26cacSmrg	exit $EXIT_FAILURE
22716df26cacSmrg      fi
22726df26cacSmrg
22736df26cacSmrg      # Just move the object if needed
22746df26cacSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
2275b68e1f86Smrg	func_show_eval '$MV "$output_obj" "$obj"' \
2276b68e1f86Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
22776df26cacSmrg      fi
22786df26cacSmrg    fi
22796df26cacSmrg
2280b68e1f86Smrg    $opt_dry_run || {
2281b68e1f86Smrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
22826df26cacSmrg
2283b68e1f86Smrg      # Unlock the critical section if it was locked
2284b68e1f86Smrg      if test "$need_locks" != no; then
2285b68e1f86Smrg	removelist=$lockfile
2286b68e1f86Smrg        $RM "$lockfile"
2287b68e1f86Smrg      fi
2288b68e1f86Smrg    }
22896df26cacSmrg
22906df26cacSmrg    exit $EXIT_SUCCESS
2291b68e1f86Smrg}
22926df26cacSmrg
2293b68e1f86Smrg$opt_help || {
22943bfa90b6Smrg  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
2295b68e1f86Smrg}
22966df26cacSmrg
2297b68e1f86Smrgfunc_mode_help ()
2298b68e1f86Smrg{
2299b68e1f86Smrg    # We need to display help for each of the modes.
23003bfa90b6Smrg    case $opt_mode in
2301b68e1f86Smrg      "")
2302b68e1f86Smrg        # Generic help is extracted from the usage comments
2303b68e1f86Smrg        # at the start of this file.
2304b68e1f86Smrg        func_help
2305b68e1f86Smrg        ;;
23066df26cacSmrg
2307b68e1f86Smrg      clean)
2308b68e1f86Smrg        $ECHO \
2309b68e1f86Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
23106df26cacSmrg
2311b68e1f86SmrgRemove files from the build directory.
23126df26cacSmrg
2313b68e1f86SmrgRM is the name of the program to use to delete files associated with each FILE
2314b68e1f86Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2315b68e1f86Smrgto RM.
23166df26cacSmrg
2317b68e1f86SmrgIf FILE is a libtool library, object or program, all the files associated
2318b68e1f86Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
2319b68e1f86Smrg        ;;
23206df26cacSmrg
2321b68e1f86Smrg      compile)
2322b68e1f86Smrg      $ECHO \
2323b68e1f86Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
23246df26cacSmrg
2325b68e1f86SmrgCompile a source file into a libtool library object.
23266df26cacSmrg
2327b68e1f86SmrgThis mode accepts the following additional options:
23286df26cacSmrg
2329b68e1f86Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
2330b68e1f86Smrg  -no-suppress      do not suppress compiler output for multiple passes
23313bfa90b6Smrg  -prefer-pic       try to build PIC objects only
23323bfa90b6Smrg  -prefer-non-pic   try to build non-PIC objects only
2333b68e1f86Smrg  -shared           do not build a \`.o' file suitable for static linking
2334b68e1f86Smrg  -static           only build a \`.o' file suitable for static linking
23353bfa90b6Smrg  -Wc,FLAG          pass FLAG directly to the compiler
23366df26cacSmrg
2337b68e1f86SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
2338b68e1f86Smrgfrom the given SOURCEFILE.
23396df26cacSmrg
2340b68e1f86SmrgThe output file name is determined by removing the directory component from
2341b68e1f86SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
2342b68e1f86Smrglibrary object suffix, \`.lo'."
2343b68e1f86Smrg        ;;
23446df26cacSmrg
2345b68e1f86Smrg      execute)
2346b68e1f86Smrg        $ECHO \
2347b68e1f86Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
23486df26cacSmrg
2349b68e1f86SmrgAutomatically set library path, then run a program.
23506df26cacSmrg
2351b68e1f86SmrgThis mode accepts the following additional options:
23526df26cacSmrg
2353b68e1f86Smrg  -dlopen FILE      add the directory containing FILE to the library path
23546df26cacSmrg
2355b68e1f86SmrgThis mode sets the library path environment variable according to \`-dlopen'
2356b68e1f86Smrgflags.
23576df26cacSmrg
2358b68e1f86SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
2359b68e1f86Smrginto their corresponding uninstalled binary, and any of their required library
2360b68e1f86Smrgdirectories are added to the library path.
23616df26cacSmrg
2362b68e1f86SmrgThen, COMMAND is executed, with ARGS as arguments."
2363b68e1f86Smrg        ;;
23646df26cacSmrg
2365b68e1f86Smrg      finish)
2366b68e1f86Smrg        $ECHO \
2367b68e1f86Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
23686df26cacSmrg
2369b68e1f86SmrgComplete the installation of libtool libraries.
23706df26cacSmrg
2371b68e1f86SmrgEach LIBDIR is a directory that contains libtool libraries.
23726df26cacSmrg
2373b68e1f86SmrgThe commands that this mode executes may require superuser privileges.  Use
2374b68e1f86Smrgthe \`--dry-run' option if you just want to see what would be executed."
2375b68e1f86Smrg        ;;
23766df26cacSmrg
2377b68e1f86Smrg      install)
2378b68e1f86Smrg        $ECHO \
2379b68e1f86Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
23806df26cacSmrg
2381b68e1f86SmrgInstall executables or libraries.
23826df26cacSmrg
2383b68e1f86SmrgINSTALL-COMMAND is the installation command.  The first component should be
2384b68e1f86Smrgeither the \`install' or \`cp' program.
23856df26cacSmrg
2386b68e1f86SmrgThe following components of INSTALL-COMMAND are treated specially:
23876df26cacSmrg
23883bfa90b6Smrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
23896df26cacSmrg
2390b68e1f86SmrgThe rest of the components are interpreted as arguments to that command (only
2391b68e1f86SmrgBSD-compatible install options are recognized)."
2392b68e1f86Smrg        ;;
23936df26cacSmrg
2394b68e1f86Smrg      link)
2395b68e1f86Smrg        $ECHO \
2396b68e1f86Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
23976df26cacSmrg
2398b68e1f86SmrgLink object files or libraries together to form another library, or to
2399b68e1f86Smrgcreate an executable program.
24006df26cacSmrg
2401b68e1f86SmrgLINK-COMMAND is a command using the C compiler that you would use to create
2402b68e1f86Smrga program from several object files.
24036df26cacSmrg
2404b68e1f86SmrgThe following components of LINK-COMMAND are treated specially:
24056df26cacSmrg
2406b68e1f86Smrg  -all-static       do not do any dynamic linking at all
2407b68e1f86Smrg  -avoid-version    do not add a version suffix if possible
24083bfa90b6Smrg  -bindir BINDIR    specify path to binaries directory (for systems where
24093bfa90b6Smrg                    libraries must be found in the PATH setting at runtime)
2410b68e1f86Smrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
2411b68e1f86Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
2412b68e1f86Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
2413b68e1f86Smrg  -export-symbols SYMFILE
2414b68e1f86Smrg                    try to export only the symbols listed in SYMFILE
2415b68e1f86Smrg  -export-symbols-regex REGEX
2416b68e1f86Smrg                    try to export only the symbols matching REGEX
2417b68e1f86Smrg  -LLIBDIR          search LIBDIR for required installed libraries
2418b68e1f86Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
2419b68e1f86Smrg  -module           build a library that can dlopened
2420b68e1f86Smrg  -no-fast-install  disable the fast-install mode
2421b68e1f86Smrg  -no-install       link a not-installable executable
2422b68e1f86Smrg  -no-undefined     declare that a library does not refer to external symbols
2423b68e1f86Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
2424b68e1f86Smrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
2425b68e1f86Smrg  -precious-files-regex REGEX
2426b68e1f86Smrg                    don't remove output files matching REGEX
2427b68e1f86Smrg  -release RELEASE  specify package release information
2428b68e1f86Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
2429b68e1f86Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
2430b68e1f86Smrg  -shared           only do dynamic linking of libtool libraries
2431b68e1f86Smrg  -shrext SUFFIX    override the standard shared library file extension
2432b68e1f86Smrg  -static           do not do any dynamic linking of uninstalled libtool libraries
2433b68e1f86Smrg  -static-libtool-libs
2434b68e1f86Smrg                    do not do any dynamic linking of libtool libraries
2435b68e1f86Smrg  -version-info CURRENT[:REVISION[:AGE]]
2436b68e1f86Smrg                    specify library version info [each variable defaults to 0]
2437b68e1f86Smrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
24383bfa90b6Smrg  -Wc,FLAG
24393bfa90b6Smrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
24403bfa90b6Smrg  -Wl,FLAG
24413bfa90b6Smrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
24423bfa90b6Smrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
24436df26cacSmrg
2444b68e1f86SmrgAll other options (arguments beginning with \`-') are ignored.
24456df26cacSmrg
2446b68e1f86SmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
2447b68e1f86Smrgtreated as uninstalled libtool libraries, other files are standard or library
2448b68e1f86Smrgobject files.
24496df26cacSmrg
2450b68e1f86SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
2451b68e1f86Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
2452b68e1f86Smrgrequired, except when creating a convenience library.
24536df26cacSmrg
2454b68e1f86SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
2455b68e1f86Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
24566df26cacSmrg
2457b68e1f86SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
2458b68e1f86Smrgis created, otherwise an executable program is created."
24596df26cacSmrg        ;;
24606df26cacSmrg
2461b68e1f86Smrg      uninstall)
2462b68e1f86Smrg        $ECHO \
2463b68e1f86Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
24646df26cacSmrg
2465b68e1f86SmrgRemove libraries from an installation directory.
24666df26cacSmrg
2467b68e1f86SmrgRM is the name of the program to use to delete files associated with each FILE
2468b68e1f86Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2469b68e1f86Smrgto RM.
24706df26cacSmrg
2471b68e1f86SmrgIf FILE is a libtool library, all the files associated with it are deleted.
2472b68e1f86SmrgOtherwise, only FILE itself is deleted using RM."
2473b68e1f86Smrg        ;;
24746df26cacSmrg
2475b68e1f86Smrg      *)
24763bfa90b6Smrg        func_fatal_help "invalid operation mode \`$opt_mode'"
2477b68e1f86Smrg        ;;
2478b68e1f86Smrg    esac
24796df26cacSmrg
24803bfa90b6Smrg    echo
2481b68e1f86Smrg    $ECHO "Try \`$progname --help' for more information about other modes."
2482b68e1f86Smrg}
24836df26cacSmrg
24843bfa90b6Smrg# Now that we've collected a possible --mode arg, show help if necessary
24853bfa90b6Smrgif $opt_help; then
24863bfa90b6Smrg  if test "$opt_help" = :; then
24873bfa90b6Smrg    func_mode_help
24883bfa90b6Smrg  else
24893bfa90b6Smrg    {
24903bfa90b6Smrg      func_help noexit
24913bfa90b6Smrg      for opt_mode in compile link execute install finish uninstall clean; do
24923bfa90b6Smrg	func_mode_help
24933bfa90b6Smrg      done
24943bfa90b6Smrg    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
24953bfa90b6Smrg    {
24963bfa90b6Smrg      func_help noexit
24973bfa90b6Smrg      for opt_mode in compile link execute install finish uninstall clean; do
24983bfa90b6Smrg	echo
24993bfa90b6Smrg	func_mode_help
25003bfa90b6Smrg      done
25013bfa90b6Smrg    } |
25023bfa90b6Smrg    sed '1d
25033bfa90b6Smrg      /^When reporting/,/^Report/{
25043bfa90b6Smrg	H
25053bfa90b6Smrg	d
25063bfa90b6Smrg      }
25073bfa90b6Smrg      $x
25083bfa90b6Smrg      /information about other modes/d
25093bfa90b6Smrg      /more detailed .*MODE/d
25103bfa90b6Smrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
25113bfa90b6Smrg  fi
25123bfa90b6Smrg  exit $?
25133bfa90b6Smrgfi
25146df26cacSmrg
25156df26cacSmrg
2516b68e1f86Smrg# func_mode_execute arg...
2517b68e1f86Smrgfunc_mode_execute ()
2518b68e1f86Smrg{
2519b68e1f86Smrg    $opt_debug
2520b68e1f86Smrg    # The first argument is the command name.
2521b68e1f86Smrg    cmd="$nonopt"
2522b68e1f86Smrg    test -z "$cmd" && \
2523b68e1f86Smrg      func_fatal_help "you must specify a COMMAND"
25246df26cacSmrg
2525b68e1f86Smrg    # Handle -dlopen flags immediately.
25263bfa90b6Smrg    for file in $opt_dlopen; do
2527b68e1f86Smrg      test -f "$file" \
2528b68e1f86Smrg	|| func_fatal_help "\`$file' is not a file"
25296df26cacSmrg
2530b68e1f86Smrg      dir=
2531b68e1f86Smrg      case $file in
2532b68e1f86Smrg      *.la)
25333bfa90b6Smrg	func_resolve_sysroot "$file"
25343bfa90b6Smrg	file=$func_resolve_sysroot_result
25353bfa90b6Smrg
2536b68e1f86Smrg	# Check to see that this really is a libtool archive.
2537b68e1f86Smrg	func_lalib_unsafe_p "$file" \
2538b68e1f86Smrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
25396df26cacSmrg
2540b68e1f86Smrg	# Read the libtool library.
2541b68e1f86Smrg	dlname=
2542b68e1f86Smrg	library_names=
2543b68e1f86Smrg	func_source "$file"
25446df26cacSmrg
2545b68e1f86Smrg	# Skip this library if it cannot be dlopened.
2546b68e1f86Smrg	if test -z "$dlname"; then
2547b68e1f86Smrg	  # Warn if it was a shared library.
2548b68e1f86Smrg	  test -n "$library_names" && \
2549b68e1f86Smrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
2550b68e1f86Smrg	  continue
2551b68e1f86Smrg	fi
25526df26cacSmrg
2553b68e1f86Smrg	func_dirname "$file" "" "."
2554b68e1f86Smrg	dir="$func_dirname_result"
25556df26cacSmrg
2556b68e1f86Smrg	if test -f "$dir/$objdir/$dlname"; then
25573bfa90b6Smrg	  func_append dir "/$objdir"
2558b68e1f86Smrg	else
2559b68e1f86Smrg	  if test ! -f "$dir/$dlname"; then
2560b68e1f86Smrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
2561b68e1f86Smrg	  fi
2562b68e1f86Smrg	fi
25636df26cacSmrg	;;
25646df26cacSmrg
2565b68e1f86Smrg      *.lo)
2566b68e1f86Smrg	# Just add the directory containing the .lo file.
2567b68e1f86Smrg	func_dirname "$file" "" "."
2568b68e1f86Smrg	dir="$func_dirname_result"
25696df26cacSmrg	;;
25706df26cacSmrg
2571b68e1f86Smrg      *)
2572b68e1f86Smrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
25736df26cacSmrg	continue
25746df26cacSmrg	;;
2575b68e1f86Smrg      esac
25766df26cacSmrg
2577b68e1f86Smrg      # Get the absolute pathname.
2578b68e1f86Smrg      absdir=`cd "$dir" && pwd`
2579b68e1f86Smrg      test -n "$absdir" && dir="$absdir"
25806df26cacSmrg
2581b68e1f86Smrg      # Now add the directory to shlibpath_var.
2582b68e1f86Smrg      if eval "test -z \"\$$shlibpath_var\""; then
2583b68e1f86Smrg	eval "$shlibpath_var=\"\$dir\""
2584b68e1f86Smrg      else
2585b68e1f86Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
2586b68e1f86Smrg      fi
2587b68e1f86Smrg    done
25886df26cacSmrg
2589b68e1f86Smrg    # This variable tells wrapper scripts just to set shlibpath_var
2590b68e1f86Smrg    # rather than running their programs.
2591b68e1f86Smrg    libtool_execute_magic="$magic"
25926df26cacSmrg
2593b68e1f86Smrg    # Check if any of the arguments is a wrapper script.
2594b68e1f86Smrg    args=
2595b68e1f86Smrg    for file
2596b68e1f86Smrg    do
2597b68e1f86Smrg      case $file in
25983bfa90b6Smrg      -* | *.la | *.lo ) ;;
2599b68e1f86Smrg      *)
2600b68e1f86Smrg	# Do a test to see if this is really a libtool program.
2601b68e1f86Smrg	if func_ltwrapper_script_p "$file"; then
2602b68e1f86Smrg	  func_source "$file"
2603b68e1f86Smrg	  # Transform arg to wrapped name.
2604b68e1f86Smrg	  file="$progdir/$program"
2605b68e1f86Smrg	elif func_ltwrapper_executable_p "$file"; then
2606b68e1f86Smrg	  func_ltwrapper_scriptname "$file"
2607b68e1f86Smrg	  func_source "$func_ltwrapper_scriptname_result"
2608b68e1f86Smrg	  # Transform arg to wrapped name.
2609b68e1f86Smrg	  file="$progdir/$program"
2610b68e1f86Smrg	fi
2611b68e1f86Smrg	;;
2612b68e1f86Smrg      esac
2613b68e1f86Smrg      # Quote arguments (to preserve shell metacharacters).
26143bfa90b6Smrg      func_append_quoted args "$file"
2615b68e1f86Smrg    done
26166df26cacSmrg
2617b68e1f86Smrg    if test "X$opt_dry_run" = Xfalse; then
2618b68e1f86Smrg      if test -n "$shlibpath_var"; then
2619b68e1f86Smrg	# Export the shlibpath_var.
2620b68e1f86Smrg	eval "export $shlibpath_var"
2621b68e1f86Smrg      fi
26226df26cacSmrg
2623b68e1f86Smrg      # Restore saved environment variables
2624b68e1f86Smrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
2625b68e1f86Smrg      do
2626b68e1f86Smrg	eval "if test \"\${save_$lt_var+set}\" = set; then
2627b68e1f86Smrg                $lt_var=\$save_$lt_var; export $lt_var
26286df26cacSmrg	      else
2629b68e1f86Smrg		$lt_unset $lt_var
2630b68e1f86Smrg	      fi"
2631b68e1f86Smrg      done
26326df26cacSmrg
2633b68e1f86Smrg      # Now prepare to actually exec the command.
2634b68e1f86Smrg      exec_cmd="\$cmd$args"
2635b68e1f86Smrg    else
2636b68e1f86Smrg      # Display what would be done.
2637b68e1f86Smrg      if test -n "$shlibpath_var"; then
2638b68e1f86Smrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
26393bfa90b6Smrg	echo "export $shlibpath_var"
2640b68e1f86Smrg      fi
2641b68e1f86Smrg      $ECHO "$cmd$args"
2642b68e1f86Smrg      exit $EXIT_SUCCESS
2643b68e1f86Smrg    fi
2644b68e1f86Smrg}
26456df26cacSmrg
26463bfa90b6Smrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"}
26476df26cacSmrg
26486df26cacSmrg
2649b68e1f86Smrg# func_mode_finish arg...
2650b68e1f86Smrgfunc_mode_finish ()
2651b68e1f86Smrg{
2652b68e1f86Smrg    $opt_debug
26533bfa90b6Smrg    libs=
26543bfa90b6Smrg    libdirs=
2655b68e1f86Smrg    admincmds=
26566df26cacSmrg
26573bfa90b6Smrg    for opt in "$nonopt" ${1+"$@"}
26583bfa90b6Smrg    do
26593bfa90b6Smrg      if test -d "$opt"; then
26603bfa90b6Smrg	func_append libdirs " $opt"
26613bfa90b6Smrg
26623bfa90b6Smrg      elif test -f "$opt"; then
26633bfa90b6Smrg	if func_lalib_unsafe_p "$opt"; then
26643bfa90b6Smrg	  func_append libs " $opt"
26653bfa90b6Smrg	else
26663bfa90b6Smrg	  func_warning "\`$opt' is not a valid libtool archive"
26673bfa90b6Smrg	fi
26683bfa90b6Smrg
26693bfa90b6Smrg      else
26703bfa90b6Smrg	func_fatal_error "invalid argument \`$opt'"
26713bfa90b6Smrg      fi
26723bfa90b6Smrg    done
26733bfa90b6Smrg
26743bfa90b6Smrg    if test -n "$libs"; then
26753bfa90b6Smrg      if test -n "$lt_sysroot"; then
26763bfa90b6Smrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
26773bfa90b6Smrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
26783bfa90b6Smrg      else
26793bfa90b6Smrg        sysroot_cmd=
26803bfa90b6Smrg      fi
26813bfa90b6Smrg
26823bfa90b6Smrg      # Remove sysroot references
26833bfa90b6Smrg      if $opt_dry_run; then
26843bfa90b6Smrg        for lib in $libs; do
26853bfa90b6Smrg          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
26863bfa90b6Smrg        done
26873bfa90b6Smrg      else
26883bfa90b6Smrg        tmpdir=`func_mktempdir`
26893bfa90b6Smrg        for lib in $libs; do
26903bfa90b6Smrg	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
26913bfa90b6Smrg	    > $tmpdir/tmp-la
26923bfa90b6Smrg	  mv -f $tmpdir/tmp-la $lib
26933bfa90b6Smrg	done
26943bfa90b6Smrg        ${RM}r "$tmpdir"
26953bfa90b6Smrg      fi
26963bfa90b6Smrg    fi
26976df26cacSmrg
26983bfa90b6Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2699b68e1f86Smrg      for libdir in $libdirs; do
2700b68e1f86Smrg	if test -n "$finish_cmds"; then
2701b68e1f86Smrg	  # Do each command in the finish commands.
2702b68e1f86Smrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
2703b68e1f86Smrg'"$cmd"'"'
27046df26cacSmrg	fi
2705b68e1f86Smrg	if test -n "$finish_eval"; then
2706b68e1f86Smrg	  # Do the single finish_eval.
2707b68e1f86Smrg	  eval cmds=\"$finish_eval\"
27083bfa90b6Smrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
2709b68e1f86Smrg       $cmds"
2710b68e1f86Smrg	fi
2711b68e1f86Smrg      done
2712b68e1f86Smrg    fi
27136df26cacSmrg
2714b68e1f86Smrg    # Exit here if they wanted silent mode.
2715b68e1f86Smrg    $opt_silent && exit $EXIT_SUCCESS
27166df26cacSmrg
27173bfa90b6Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
27183bfa90b6Smrg      echo "----------------------------------------------------------------------"
27193bfa90b6Smrg      echo "Libraries have been installed in:"
27203bfa90b6Smrg      for libdir in $libdirs; do
27213bfa90b6Smrg	$ECHO "   $libdir"
27223bfa90b6Smrg      done
27233bfa90b6Smrg      echo
27243bfa90b6Smrg      echo "If you ever happen to want to link against installed libraries"
27253bfa90b6Smrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
27263bfa90b6Smrg      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
27273bfa90b6Smrg      echo "flag during linking and do at least one of the following:"
27283bfa90b6Smrg      if test -n "$shlibpath_var"; then
27293bfa90b6Smrg	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
27303bfa90b6Smrg	echo "     during execution"
27313bfa90b6Smrg      fi
27323bfa90b6Smrg      if test -n "$runpath_var"; then
27333bfa90b6Smrg	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
27343bfa90b6Smrg	echo "     during linking"
27353bfa90b6Smrg      fi
27363bfa90b6Smrg      if test -n "$hardcode_libdir_flag_spec"; then
27373bfa90b6Smrg	libdir=LIBDIR
27383bfa90b6Smrg	eval flag=\"$hardcode_libdir_flag_spec\"
27396df26cacSmrg
27403bfa90b6Smrg	$ECHO "   - use the \`$flag' linker flag"
27413bfa90b6Smrg      fi
27423bfa90b6Smrg      if test -n "$admincmds"; then
27433bfa90b6Smrg	$ECHO "   - have your system administrator run these commands:$admincmds"
27443bfa90b6Smrg      fi
27453bfa90b6Smrg      if test -f /etc/ld.so.conf; then
27463bfa90b6Smrg	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
27473bfa90b6Smrg      fi
27483bfa90b6Smrg      echo
2749b68e1f86Smrg
27503bfa90b6Smrg      echo "See any operating system documentation about shared libraries for"
27513bfa90b6Smrg      case $host in
27523bfa90b6Smrg	solaris2.[6789]|solaris2.1[0-9])
27533bfa90b6Smrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
27543bfa90b6Smrg	  echo "pages."
27553bfa90b6Smrg	  ;;
27563bfa90b6Smrg	*)
27573bfa90b6Smrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
27583bfa90b6Smrg	  ;;
27593bfa90b6Smrg      esac
27603bfa90b6Smrg      echo "----------------------------------------------------------------------"
27613bfa90b6Smrg    fi
2762b68e1f86Smrg    exit $EXIT_SUCCESS
2763b68e1f86Smrg}
2764b68e1f86Smrg
27653bfa90b6Smrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"}
2766b68e1f86Smrg
2767b68e1f86Smrg
2768b68e1f86Smrg# func_mode_install arg...
2769b68e1f86Smrgfunc_mode_install ()
2770b68e1f86Smrg{
2771b68e1f86Smrg    $opt_debug
2772b68e1f86Smrg    # There may be an optional sh(1) argument at the beginning of
2773b68e1f86Smrg    # install_prog (especially on Windows NT).
2774b68e1f86Smrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
2775b68e1f86Smrg       # Allow the use of GNU shtool's install command.
27763bfa90b6Smrg       case $nonopt in *shtool*) :;; *) false;; esac; then
2777b68e1f86Smrg      # Aesthetically quote it.
2778b68e1f86Smrg      func_quote_for_eval "$nonopt"
2779b68e1f86Smrg      install_prog="$func_quote_for_eval_result "
2780b68e1f86Smrg      arg=$1
2781b68e1f86Smrg      shift
2782b68e1f86Smrg    else
2783b68e1f86Smrg      install_prog=
2784b68e1f86Smrg      arg=$nonopt
2785b68e1f86Smrg    fi
2786b68e1f86Smrg
2787b68e1f86Smrg    # The real first argument should be the name of the installation program.
2788b68e1f86Smrg    # Aesthetically quote it.
2789b68e1f86Smrg    func_quote_for_eval "$arg"
27903bfa90b6Smrg    func_append install_prog "$func_quote_for_eval_result"
27913bfa90b6Smrg    install_shared_prog=$install_prog
27923bfa90b6Smrg    case " $install_prog " in
27933bfa90b6Smrg      *[\\\ /]cp\ *) install_cp=: ;;
27943bfa90b6Smrg      *) install_cp=false ;;
27953bfa90b6Smrg    esac
2796b68e1f86Smrg
2797b68e1f86Smrg    # We need to accept at least all the BSD install flags.
2798b68e1f86Smrg    dest=
2799b68e1f86Smrg    files=
2800b68e1f86Smrg    opts=
2801b68e1f86Smrg    prev=
2802b68e1f86Smrg    install_type=
2803b68e1f86Smrg    isdir=no
2804b68e1f86Smrg    stripme=
28053bfa90b6Smrg    no_mode=:
2806b68e1f86Smrg    for arg
2807b68e1f86Smrg    do
28083bfa90b6Smrg      arg2=
2809b68e1f86Smrg      if test -n "$dest"; then
28103bfa90b6Smrg	func_append files " $dest"
2811b68e1f86Smrg	dest=$arg
2812b68e1f86Smrg	continue
2813b68e1f86Smrg      fi
2814b68e1f86Smrg
2815b68e1f86Smrg      case $arg in
2816b68e1f86Smrg      -d) isdir=yes ;;
2817b68e1f86Smrg      -f)
28183bfa90b6Smrg	if $install_cp; then :; else
28193bfa90b6Smrg	  prev=$arg
28203bfa90b6Smrg	fi
2821b68e1f86Smrg	;;
2822b68e1f86Smrg      -g | -m | -o)
2823b68e1f86Smrg	prev=$arg
2824b68e1f86Smrg	;;
2825b68e1f86Smrg      -s)
2826b68e1f86Smrg	stripme=" -s"
2827b68e1f86Smrg	continue
2828b68e1f86Smrg	;;
2829b68e1f86Smrg      -*)
2830b68e1f86Smrg	;;
2831b68e1f86Smrg      *)
2832b68e1f86Smrg	# If the previous option needed an argument, then skip it.
2833b68e1f86Smrg	if test -n "$prev"; then
28343bfa90b6Smrg	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
28353bfa90b6Smrg	    arg2=$install_override_mode
28363bfa90b6Smrg	    no_mode=false
28373bfa90b6Smrg	  fi
28386df26cacSmrg	  prev=
28396df26cacSmrg	else
2840b68e1f86Smrg	  dest=$arg
2841b68e1f86Smrg	  continue
28426df26cacSmrg	fi
28436df26cacSmrg	;;
2844b68e1f86Smrg      esac
28456df26cacSmrg
2846b68e1f86Smrg      # Aesthetically quote the argument.
2847b68e1f86Smrg      func_quote_for_eval "$arg"
28483bfa90b6Smrg      func_append install_prog " $func_quote_for_eval_result"
28493bfa90b6Smrg      if test -n "$arg2"; then
28503bfa90b6Smrg	func_quote_for_eval "$arg2"
28513bfa90b6Smrg      fi
28523bfa90b6Smrg      func_append install_shared_prog " $func_quote_for_eval_result"
2853b68e1f86Smrg    done
28546df26cacSmrg
2855b68e1f86Smrg    test -z "$install_prog" && \
2856b68e1f86Smrg      func_fatal_help "you must specify an install program"
28576df26cacSmrg
2858b68e1f86Smrg    test -n "$prev" && \
2859b68e1f86Smrg      func_fatal_help "the \`$prev' option requires an argument"
28606df26cacSmrg
28613bfa90b6Smrg    if test -n "$install_override_mode" && $no_mode; then
28623bfa90b6Smrg      if $install_cp; then :; else
28633bfa90b6Smrg	func_quote_for_eval "$install_override_mode"
28643bfa90b6Smrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
28653bfa90b6Smrg      fi
28663bfa90b6Smrg    fi
28673bfa90b6Smrg
2868b68e1f86Smrg    if test -z "$files"; then
2869b68e1f86Smrg      if test -z "$dest"; then
2870b68e1f86Smrg	func_fatal_help "no file or destination specified"
2871b68e1f86Smrg      else
2872b68e1f86Smrg	func_fatal_help "you must specify a destination"
2873b68e1f86Smrg      fi
28746df26cacSmrg    fi
28756df26cacSmrg
2876b68e1f86Smrg    # Strip any trailing slash from the destination.
2877b68e1f86Smrg    func_stripname '' '/' "$dest"
2878b68e1f86Smrg    dest=$func_stripname_result
28796df26cacSmrg
2880b68e1f86Smrg    # Check to see that the destination is a directory.
2881b68e1f86Smrg    test -d "$dest" && isdir=yes
2882b68e1f86Smrg    if test "$isdir" = yes; then
2883b68e1f86Smrg      destdir="$dest"
2884b68e1f86Smrg      destname=
28856df26cacSmrg    else
2886b68e1f86Smrg      func_dirname_and_basename "$dest" "" "."
2887b68e1f86Smrg      destdir="$func_dirname_result"
2888b68e1f86Smrg      destname="$func_basename_result"
28896df26cacSmrg
2890b68e1f86Smrg      # Not a directory, so check to see that there is only one file specified.
2891b68e1f86Smrg      set dummy $files; shift
2892b68e1f86Smrg      test "$#" -gt 1 && \
2893b68e1f86Smrg	func_fatal_help "\`$dest' is not a directory"
28946df26cacSmrg    fi
2895b68e1f86Smrg    case $destdir in
2896b68e1f86Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
28976df26cacSmrg    *)
2898b68e1f86Smrg      for file in $files; do
2899b68e1f86Smrg	case $file in
2900b68e1f86Smrg	*.lo) ;;
2901b68e1f86Smrg	*)
2902b68e1f86Smrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
2903b68e1f86Smrg	  ;;
2904b68e1f86Smrg	esac
2905b68e1f86Smrg      done
29066df26cacSmrg      ;;
29076df26cacSmrg    esac
29086df26cacSmrg
2909b68e1f86Smrg    # This variable tells wrapper scripts just to set variables rather
2910b68e1f86Smrg    # than running their programs.
2911b68e1f86Smrg    libtool_install_magic="$magic"
29126df26cacSmrg
2913b68e1f86Smrg    staticlibs=
2914b68e1f86Smrg    future_libdirs=
2915b68e1f86Smrg    current_libdirs=
2916b68e1f86Smrg    for file in $files; do
29176df26cacSmrg
2918b68e1f86Smrg      # Do each installation.
2919b68e1f86Smrg      case $file in
2920b68e1f86Smrg      *.$libext)
2921b68e1f86Smrg	# Do the static libraries later.
29223bfa90b6Smrg	func_append staticlibs " $file"
2923b68e1f86Smrg	;;
2924b68e1f86Smrg
2925b68e1f86Smrg      *.la)
29263bfa90b6Smrg	func_resolve_sysroot "$file"
29273bfa90b6Smrg	file=$func_resolve_sysroot_result
29283bfa90b6Smrg
2929b68e1f86Smrg	# Check to see that this really is a libtool archive.
2930b68e1f86Smrg	func_lalib_unsafe_p "$file" \
2931b68e1f86Smrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
2932b68e1f86Smrg
2933b68e1f86Smrg	library_names=
2934b68e1f86Smrg	old_library=
2935b68e1f86Smrg	relink_command=
2936b68e1f86Smrg	func_source "$file"
2937b68e1f86Smrg
2938b68e1f86Smrg	# Add the libdir to current_libdirs if it is the destination.
2939b68e1f86Smrg	if test "X$destdir" = "X$libdir"; then
2940b68e1f86Smrg	  case "$current_libdirs " in
2941b68e1f86Smrg	  *" $libdir "*) ;;
29423bfa90b6Smrg	  *) func_append current_libdirs " $libdir" ;;
29436df26cacSmrg	  esac
2944b68e1f86Smrg	else
2945b68e1f86Smrg	  # Note the libdir as a future libdir.
2946b68e1f86Smrg	  case "$future_libdirs " in
2947b68e1f86Smrg	  *" $libdir "*) ;;
29483bfa90b6Smrg	  *) func_append future_libdirs " $libdir" ;;
2949b68e1f86Smrg	  esac
2950b68e1f86Smrg	fi
29516df26cacSmrg
2952b68e1f86Smrg	func_dirname "$file" "/" ""
2953b68e1f86Smrg	dir="$func_dirname_result"
29543bfa90b6Smrg	func_append dir "$objdir"
2955b68e1f86Smrg
2956b68e1f86Smrg	if test -n "$relink_command"; then
2957b68e1f86Smrg	  # Determine the prefix the user has applied to our future dir.
29583bfa90b6Smrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
2959b68e1f86Smrg
2960b68e1f86Smrg	  # Don't allow the user to place us outside of our expected
2961b68e1f86Smrg	  # location b/c this prevents finding dependent libraries that
2962b68e1f86Smrg	  # are installed to the same prefix.
2963b68e1f86Smrg	  # At present, this check doesn't affect windows .dll's that
2964b68e1f86Smrg	  # are installed into $libdir/../bin (currently, that works fine)
2965b68e1f86Smrg	  # but it's something to keep an eye on.
2966b68e1f86Smrg	  test "$inst_prefix_dir" = "$destdir" && \
2967b68e1f86Smrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2968b68e1f86Smrg
2969b68e1f86Smrg	  if test -n "$inst_prefix_dir"; then
2970b68e1f86Smrg	    # Stick the inst_prefix_dir data into the link command.
29713bfa90b6Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2972b68e1f86Smrg	  else
29733bfa90b6Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
2974b68e1f86Smrg	  fi
2975b68e1f86Smrg
2976b68e1f86Smrg	  func_warning "relinking \`$file'"
2977b68e1f86Smrg	  func_show_eval "$relink_command" \
2978b68e1f86Smrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2979b68e1f86Smrg	fi
2980b68e1f86Smrg
2981b68e1f86Smrg	# See the names of the shared library.
2982b68e1f86Smrg	set dummy $library_names; shift
2983b68e1f86Smrg	if test -n "$1"; then
2984b68e1f86Smrg	  realname="$1"
2985b68e1f86Smrg	  shift
2986b68e1f86Smrg
2987b68e1f86Smrg	  srcname="$realname"
2988b68e1f86Smrg	  test -n "$relink_command" && srcname="$realname"T
2989b68e1f86Smrg
2990b68e1f86Smrg	  # Install the shared library and build the symlinks.
29913bfa90b6Smrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
2992b68e1f86Smrg	      'exit $?'
2993b68e1f86Smrg	  tstripme="$stripme"
2994b68e1f86Smrg	  case $host_os in
2995b68e1f86Smrg	  cygwin* | mingw* | pw32* | cegcc*)
2996b68e1f86Smrg	    case $realname in
2997b68e1f86Smrg	    *.dll.a)
2998b68e1f86Smrg	      tstripme=""
2999b68e1f86Smrg	      ;;
3000b68e1f86Smrg	    esac
30016df26cacSmrg	    ;;
30026df26cacSmrg	  esac
3003b68e1f86Smrg	  if test -n "$tstripme" && test -n "$striplib"; then
3004b68e1f86Smrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
30056df26cacSmrg	  fi
3006b68e1f86Smrg
3007b68e1f86Smrg	  if test "$#" -gt 0; then
3008b68e1f86Smrg	    # Delete the old symlinks, and create new ones.
3009b68e1f86Smrg	    # Try `ln -sf' first, because the `ln' binary might depend on
3010b68e1f86Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
3011b68e1f86Smrg	    # so we also need to try rm && ln -s.
3012b68e1f86Smrg	    for linkname
3013b68e1f86Smrg	    do
3014b68e1f86Smrg	      test "$linkname" != "$realname" \
3015b68e1f86Smrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
30166df26cacSmrg	    done
30176df26cacSmrg	  fi
30186df26cacSmrg
3019b68e1f86Smrg	  # Do each command in the postinstall commands.
3020b68e1f86Smrg	  lib="$destdir/$realname"
3021b68e1f86Smrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
30226df26cacSmrg	fi
30236df26cacSmrg
3024b68e1f86Smrg	# Install the pseudo-library for information purposes.
3025b68e1f86Smrg	func_basename "$file"
3026b68e1f86Smrg	name="$func_basename_result"
3027b68e1f86Smrg	instname="$dir/$name"i
3028b68e1f86Smrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
30296df26cacSmrg
3030b68e1f86Smrg	# Maybe install the static library, too.
30313bfa90b6Smrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
3032b68e1f86Smrg	;;
30336df26cacSmrg
3034b68e1f86Smrg      *.lo)
3035b68e1f86Smrg	# Install (i.e. copy) a libtool object.
30366df26cacSmrg
3037b68e1f86Smrg	# Figure out destination file name, if it wasn't already specified.
3038b68e1f86Smrg	if test -n "$destname"; then
3039b68e1f86Smrg	  destfile="$destdir/$destname"
3040b68e1f86Smrg	else
3041b68e1f86Smrg	  func_basename "$file"
3042b68e1f86Smrg	  destfile="$func_basename_result"
3043b68e1f86Smrg	  destfile="$destdir/$destfile"
30446df26cacSmrg	fi
30456df26cacSmrg
3046b68e1f86Smrg	# Deduce the name of the destination old-style object file.
3047b68e1f86Smrg	case $destfile in
3048b68e1f86Smrg	*.lo)
3049b68e1f86Smrg	  func_lo2o "$destfile"
3050b68e1f86Smrg	  staticdest=$func_lo2o_result
3051b68e1f86Smrg	  ;;
3052b68e1f86Smrg	*.$objext)
3053b68e1f86Smrg	  staticdest="$destfile"
3054b68e1f86Smrg	  destfile=
3055b68e1f86Smrg	  ;;
3056b68e1f86Smrg	*)
3057b68e1f86Smrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
3058b68e1f86Smrg	  ;;
3059b68e1f86Smrg	esac
30606df26cacSmrg
3061b68e1f86Smrg	# Install the libtool object if requested.
3062b68e1f86Smrg	test -n "$destfile" && \
3063b68e1f86Smrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
30646df26cacSmrg
3065b68e1f86Smrg	# Install the old object if enabled.
3066b68e1f86Smrg	if test "$build_old_libs" = yes; then
3067b68e1f86Smrg	  # Deduce the name of the old-style object file.
3068b68e1f86Smrg	  func_lo2o "$file"
3069b68e1f86Smrg	  staticobj=$func_lo2o_result
3070b68e1f86Smrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
30716df26cacSmrg	fi
3072b68e1f86Smrg	exit $EXIT_SUCCESS
3073b68e1f86Smrg	;;
30746df26cacSmrg
3075b68e1f86Smrg      *)
3076b68e1f86Smrg	# Figure out destination file name, if it wasn't already specified.
3077b68e1f86Smrg	if test -n "$destname"; then
3078b68e1f86Smrg	  destfile="$destdir/$destname"
3079b68e1f86Smrg	else
3080b68e1f86Smrg	  func_basename "$file"
3081b68e1f86Smrg	  destfile="$func_basename_result"
3082b68e1f86Smrg	  destfile="$destdir/$destfile"
3083b68e1f86Smrg	fi
30846df26cacSmrg
3085b68e1f86Smrg	# If the file is missing, and there is a .exe on the end, strip it
3086b68e1f86Smrg	# because it is most likely a libtool script we actually want to
3087b68e1f86Smrg	# install
3088b68e1f86Smrg	stripped_ext=""
3089b68e1f86Smrg	case $file in
3090b68e1f86Smrg	  *.exe)
3091b68e1f86Smrg	    if test ! -f "$file"; then
3092b68e1f86Smrg	      func_stripname '' '.exe' "$file"
3093b68e1f86Smrg	      file=$func_stripname_result
3094b68e1f86Smrg	      stripped_ext=".exe"
3095b68e1f86Smrg	    fi
3096b68e1f86Smrg	    ;;
3097b68e1f86Smrg	esac
3098b68e1f86Smrg
3099b68e1f86Smrg	# Do a test to see if this is really a libtool program.
3100b68e1f86Smrg	case $host in
3101b68e1f86Smrg	*cygwin* | *mingw*)
3102b68e1f86Smrg	    if func_ltwrapper_executable_p "$file"; then
3103b68e1f86Smrg	      func_ltwrapper_scriptname "$file"
3104b68e1f86Smrg	      wrapper=$func_ltwrapper_scriptname_result
3105b68e1f86Smrg	    else
3106b68e1f86Smrg	      func_stripname '' '.exe' "$file"
3107b68e1f86Smrg	      wrapper=$func_stripname_result
3108b68e1f86Smrg	    fi
3109b68e1f86Smrg	    ;;
31106df26cacSmrg	*)
3111b68e1f86Smrg	    wrapper=$file
3112b68e1f86Smrg	    ;;
3113b68e1f86Smrg	esac
3114b68e1f86Smrg	if func_ltwrapper_script_p "$wrapper"; then
3115b68e1f86Smrg	  notinst_deplibs=
3116b68e1f86Smrg	  relink_command=
3117b68e1f86Smrg
3118b68e1f86Smrg	  func_source "$wrapper"
3119b68e1f86Smrg
3120b68e1f86Smrg	  # Check the variables that should have been set.
3121b68e1f86Smrg	  test -z "$generated_by_libtool_version" && \
3122b68e1f86Smrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
3123b68e1f86Smrg
3124b68e1f86Smrg	  finalize=yes
3125b68e1f86Smrg	  for lib in $notinst_deplibs; do
3126b68e1f86Smrg	    # Check to see that each library is installed.
3127b68e1f86Smrg	    libdir=
3128b68e1f86Smrg	    if test -f "$lib"; then
3129b68e1f86Smrg	      func_source "$lib"
3130b68e1f86Smrg	    fi
31313bfa90b6Smrg	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
3132b68e1f86Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
3133b68e1f86Smrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
3134b68e1f86Smrg	      finalize=no
3135b68e1f86Smrg	    fi
3136b68e1f86Smrg	  done
3137b68e1f86Smrg
3138b68e1f86Smrg	  relink_command=
3139b68e1f86Smrg	  func_source "$wrapper"
3140b68e1f86Smrg
3141b68e1f86Smrg	  outputname=
3142b68e1f86Smrg	  if test "$fast_install" = no && test -n "$relink_command"; then
3143b68e1f86Smrg	    $opt_dry_run || {
3144b68e1f86Smrg	      if test "$finalize" = yes; then
3145b68e1f86Smrg	        tmpdir=`func_mktempdir`
3146b68e1f86Smrg		func_basename "$file$stripped_ext"
3147b68e1f86Smrg		file="$func_basename_result"
3148b68e1f86Smrg	        outputname="$tmpdir/$file"
3149b68e1f86Smrg	        # Replace the output file specification.
31503bfa90b6Smrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
3151b68e1f86Smrg
3152b68e1f86Smrg	        $opt_silent || {
3153b68e1f86Smrg	          func_quote_for_expand "$relink_command"
3154b68e1f86Smrg		  eval "func_echo $func_quote_for_expand_result"
3155b68e1f86Smrg	        }
3156b68e1f86Smrg	        if eval "$relink_command"; then :
3157b68e1f86Smrg	          else
3158b68e1f86Smrg		  func_error "error: relink \`$file' with the above command before installing it"
3159b68e1f86Smrg		  $opt_dry_run || ${RM}r "$tmpdir"
3160b68e1f86Smrg		  continue
3161b68e1f86Smrg	        fi
3162b68e1f86Smrg	        file="$outputname"
3163b68e1f86Smrg	      else
3164b68e1f86Smrg	        func_warning "cannot relink \`$file'"
3165b68e1f86Smrg	      fi
3166b68e1f86Smrg	    }
3167b68e1f86Smrg	  else
3168b68e1f86Smrg	    # Install the binary that we compiled earlier.
31693bfa90b6Smrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
31706df26cacSmrg	  fi
3171b68e1f86Smrg	fi
3172b68e1f86Smrg
3173b68e1f86Smrg	# remove .exe since cygwin /usr/bin/install will append another
3174b68e1f86Smrg	# one anyway
3175b68e1f86Smrg	case $install_prog,$host in
3176b68e1f86Smrg	*/usr/bin/install*,*cygwin*)
3177b68e1f86Smrg	  case $file:$destfile in
3178b68e1f86Smrg	  *.exe:*.exe)
3179b68e1f86Smrg	    # this is ok
3180b68e1f86Smrg	    ;;
3181b68e1f86Smrg	  *.exe:*)
3182b68e1f86Smrg	    destfile=$destfile.exe
3183b68e1f86Smrg	    ;;
3184b68e1f86Smrg	  *:*.exe)
3185b68e1f86Smrg	    func_stripname '' '.exe' "$destfile"
3186b68e1f86Smrg	    destfile=$func_stripname_result
3187b68e1f86Smrg	    ;;
3188b68e1f86Smrg	  esac
31896df26cacSmrg	  ;;
31906df26cacSmrg	esac
3191b68e1f86Smrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
3192b68e1f86Smrg	$opt_dry_run || if test -n "$outputname"; then
3193b68e1f86Smrg	  ${RM}r "$tmpdir"
3194b68e1f86Smrg	fi
3195b68e1f86Smrg	;;
3196b68e1f86Smrg      esac
3197b68e1f86Smrg    done
31986df26cacSmrg
3199b68e1f86Smrg    for file in $staticlibs; do
3200b68e1f86Smrg      func_basename "$file"
3201b68e1f86Smrg      name="$func_basename_result"
3202b68e1f86Smrg
3203b68e1f86Smrg      # Set up the ranlib parameters.
3204b68e1f86Smrg      oldlib="$destdir/$name"
32053bfa90b6Smrg      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
32063bfa90b6Smrg      tool_oldlib=$func_to_tool_file_result
3207b68e1f86Smrg
3208b68e1f86Smrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
3209b68e1f86Smrg
3210b68e1f86Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
32113bfa90b6Smrg	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
3212b68e1f86Smrg      fi
3213b68e1f86Smrg
3214b68e1f86Smrg      # Do each command in the postinstall commands.
3215b68e1f86Smrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
3216b68e1f86Smrg    done
3217b68e1f86Smrg
3218b68e1f86Smrg    test -n "$future_libdirs" && \
3219b68e1f86Smrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
3220b68e1f86Smrg
3221b68e1f86Smrg    if test -n "$current_libdirs"; then
3222b68e1f86Smrg      # Maybe just do a dry run.
3223b68e1f86Smrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
3224b68e1f86Smrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
3225b68e1f86Smrg    else
3226b68e1f86Smrg      exit $EXIT_SUCCESS
3227b68e1f86Smrg    fi
3228b68e1f86Smrg}
3229b68e1f86Smrg
32303bfa90b6Smrgtest "$opt_mode" = install && func_mode_install ${1+"$@"}
3231b68e1f86Smrg
3232b68e1f86Smrg
3233b68e1f86Smrg# func_generate_dlsyms outputname originator pic_p
3234b68e1f86Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with
3235b68e1f86Smrg# a dlpreopen symbol table.
3236b68e1f86Smrgfunc_generate_dlsyms ()
3237b68e1f86Smrg{
3238b68e1f86Smrg    $opt_debug
3239b68e1f86Smrg    my_outputname="$1"
3240b68e1f86Smrg    my_originator="$2"
3241b68e1f86Smrg    my_pic_p="${3-no}"
3242b68e1f86Smrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
3243b68e1f86Smrg    my_dlsyms=
3244b68e1f86Smrg
3245b68e1f86Smrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
3246b68e1f86Smrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
3247b68e1f86Smrg	my_dlsyms="${my_outputname}S.c"
3248b68e1f86Smrg      else
3249b68e1f86Smrg	func_error "not configured to extract global symbols from dlpreopened files"
3250b68e1f86Smrg      fi
3251b68e1f86Smrg    fi
3252b68e1f86Smrg
3253b68e1f86Smrg    if test -n "$my_dlsyms"; then
3254b68e1f86Smrg      case $my_dlsyms in
3255b68e1f86Smrg      "") ;;
3256b68e1f86Smrg      *.c)
3257b68e1f86Smrg	# Discover the nlist of each of the dlfiles.
3258b68e1f86Smrg	nlist="$output_objdir/${my_outputname}.nm"
3259b68e1f86Smrg
3260b68e1f86Smrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
3261b68e1f86Smrg
3262b68e1f86Smrg	# Parse the name list into a source file.
3263b68e1f86Smrg	func_verbose "creating $output_objdir/$my_dlsyms"
3264b68e1f86Smrg
3265b68e1f86Smrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
3266b68e1f86Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
3267b68e1f86Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
3268b68e1f86Smrg
3269b68e1f86Smrg#ifdef __cplusplus
3270b68e1f86Smrgextern \"C\" {
3271b68e1f86Smrg#endif
3272b68e1f86Smrg
32733bfa90b6Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
32743bfa90b6Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
32753bfa90b6Smrg#endif
32763bfa90b6Smrg
32773bfa90b6Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
32783bfa90b6Smrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
32793bfa90b6Smrg/* DATA imports from DLLs on WIN32 con't be const, because runtime
32803bfa90b6Smrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
32813bfa90b6Smrg# define LT_DLSYM_CONST
32823bfa90b6Smrg#elif defined(__osf__)
32833bfa90b6Smrg/* This system does not cope well with relocations in const data.  */
32843bfa90b6Smrg# define LT_DLSYM_CONST
32853bfa90b6Smrg#else
32863bfa90b6Smrg# define LT_DLSYM_CONST const
32873bfa90b6Smrg#endif
32883bfa90b6Smrg
3289b68e1f86Smrg/* External symbol declarations for the compiler. */\
3290b68e1f86Smrg"
3291b68e1f86Smrg
3292b68e1f86Smrg	if test "$dlself" = yes; then
3293b68e1f86Smrg	  func_verbose "generating symbol list for \`$output'"
3294b68e1f86Smrg
3295b68e1f86Smrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
3296b68e1f86Smrg
3297b68e1f86Smrg	  # Add our own program objects to the symbol list.
32983bfa90b6Smrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
3299b68e1f86Smrg	  for progfile in $progfiles; do
33003bfa90b6Smrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
33013bfa90b6Smrg	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
33023bfa90b6Smrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
3303b68e1f86Smrg	  done
3304b68e1f86Smrg
3305b68e1f86Smrg	  if test -n "$exclude_expsyms"; then
3306b68e1f86Smrg	    $opt_dry_run || {
3307b68e1f86Smrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
3308b68e1f86Smrg	      eval '$MV "$nlist"T "$nlist"'
3309b68e1f86Smrg	    }
33106df26cacSmrg	  fi
3311b68e1f86Smrg
3312b68e1f86Smrg	  if test -n "$export_symbols_regex"; then
3313b68e1f86Smrg	    $opt_dry_run || {
3314b68e1f86Smrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
3315b68e1f86Smrg	      eval '$MV "$nlist"T "$nlist"'
3316b68e1f86Smrg	    }
3317b68e1f86Smrg	  fi
3318b68e1f86Smrg
3319b68e1f86Smrg	  # Prepare the list of exported symbols
3320b68e1f86Smrg	  if test -z "$export_symbols"; then
3321b68e1f86Smrg	    export_symbols="$output_objdir/$outputname.exp"
3322b68e1f86Smrg	    $opt_dry_run || {
3323b68e1f86Smrg	      $RM $export_symbols
3324b68e1f86Smrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
3325b68e1f86Smrg	      case $host in
3326b68e1f86Smrg	      *cygwin* | *mingw* | *cegcc* )
3327b68e1f86Smrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3328b68e1f86Smrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
3329b68e1f86Smrg	        ;;
3330b68e1f86Smrg	      esac
3331b68e1f86Smrg	    }
33326df26cacSmrg	  else
3333b68e1f86Smrg	    $opt_dry_run || {
3334b68e1f86Smrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
3335b68e1f86Smrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
3336b68e1f86Smrg	      eval '$MV "$nlist"T "$nlist"'
3337b68e1f86Smrg	      case $host in
33383bfa90b6Smrg	        *cygwin* | *mingw* | *cegcc* )
3339b68e1f86Smrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3340b68e1f86Smrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
3341b68e1f86Smrg	          ;;
3342b68e1f86Smrg	      esac
3343b68e1f86Smrg	    }
33446df26cacSmrg	  fi
3345b68e1f86Smrg	fi
33466df26cacSmrg
3347b68e1f86Smrg	for dlprefile in $dlprefiles; do
3348b68e1f86Smrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
3349b68e1f86Smrg	  func_basename "$dlprefile"
3350b68e1f86Smrg	  name="$func_basename_result"
33513bfa90b6Smrg          case $host in
33523bfa90b6Smrg	    *cygwin* | *mingw* | *cegcc* )
33533bfa90b6Smrg	      # if an import library, we need to obtain dlname
33543bfa90b6Smrg	      if func_win32_import_lib_p "$dlprefile"; then
33553bfa90b6Smrg	        func_tr_sh "$dlprefile"
33563bfa90b6Smrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
33573bfa90b6Smrg	        dlprefile_dlbasename=""
33583bfa90b6Smrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
33593bfa90b6Smrg	          # Use subshell, to avoid clobbering current variable values
33603bfa90b6Smrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
33613bfa90b6Smrg	          if test -n "$dlprefile_dlname" ; then
33623bfa90b6Smrg	            func_basename "$dlprefile_dlname"
33633bfa90b6Smrg	            dlprefile_dlbasename="$func_basename_result"
33643bfa90b6Smrg	          else
33653bfa90b6Smrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
33663bfa90b6Smrg	            $sharedlib_from_linklib_cmd "$dlprefile"
33673bfa90b6Smrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
33683bfa90b6Smrg	          fi
33693bfa90b6Smrg	        fi
33703bfa90b6Smrg	        $opt_dry_run || {
33713bfa90b6Smrg	          if test -n "$dlprefile_dlbasename" ; then
33723bfa90b6Smrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
33733bfa90b6Smrg	          else
33743bfa90b6Smrg	            func_warning "Could not compute DLL name from $name"
33753bfa90b6Smrg	            eval '$ECHO ": $name " >> "$nlist"'
33763bfa90b6Smrg	          fi
33773bfa90b6Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
33783bfa90b6Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
33793bfa90b6Smrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
33803bfa90b6Smrg	        }
33813bfa90b6Smrg	      else # not an import lib
33823bfa90b6Smrg	        $opt_dry_run || {
33833bfa90b6Smrg	          eval '$ECHO ": $name " >> "$nlist"'
33843bfa90b6Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
33853bfa90b6Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
33863bfa90b6Smrg	        }
33873bfa90b6Smrg	      fi
33883bfa90b6Smrg	    ;;
33893bfa90b6Smrg	    *)
33903bfa90b6Smrg	      $opt_dry_run || {
33913bfa90b6Smrg	        eval '$ECHO ": $name " >> "$nlist"'
33923bfa90b6Smrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
33933bfa90b6Smrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
33943bfa90b6Smrg	      }
33953bfa90b6Smrg	    ;;
33963bfa90b6Smrg          esac
3397b68e1f86Smrg	done
3398b68e1f86Smrg
3399b68e1f86Smrg	$opt_dry_run || {
3400b68e1f86Smrg	  # Make sure we have at least an empty file.
3401b68e1f86Smrg	  test -f "$nlist" || : > "$nlist"
3402b68e1f86Smrg
3403b68e1f86Smrg	  if test -n "$exclude_expsyms"; then
3404b68e1f86Smrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
3405b68e1f86Smrg	    $MV "$nlist"T "$nlist"
34066df26cacSmrg	  fi
3407b68e1f86Smrg
3408b68e1f86Smrg	  # Try sorting and uniquifying the output.
3409b68e1f86Smrg	  if $GREP -v "^: " < "$nlist" |
3410b68e1f86Smrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
3411b68e1f86Smrg		sort -k 3
3412b68e1f86Smrg	      else
3413b68e1f86Smrg		sort +2
3414b68e1f86Smrg	      fi |
3415b68e1f86Smrg	      uniq > "$nlist"S; then
3416b68e1f86Smrg	    :
34176df26cacSmrg	  else
3418b68e1f86Smrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
34196df26cacSmrg	  fi
34206df26cacSmrg
3421b68e1f86Smrg	  if test -f "$nlist"S; then
3422b68e1f86Smrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
34236df26cacSmrg	  else
34243bfa90b6Smrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
34256df26cacSmrg	  fi
34266df26cacSmrg
34273bfa90b6Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
34286df26cacSmrg
3429b68e1f86Smrg/* The mapping between symbol names and symbols.  */
3430b68e1f86Smrgtypedef struct {
3431b68e1f86Smrg  const char *name;
3432b68e1f86Smrg  void *address;
3433b68e1f86Smrg} lt_dlsymlist;
34343bfa90b6Smrgextern LT_DLSYM_CONST lt_dlsymlist
3435b68e1f86Smrglt_${my_prefix}_LTX_preloaded_symbols[];
34363bfa90b6SmrgLT_DLSYM_CONST lt_dlsymlist
3437b68e1f86Smrglt_${my_prefix}_LTX_preloaded_symbols[] =
3438b68e1f86Smrg{\
3439b68e1f86Smrg  { \"$my_originator\", (void *) 0 },"
34406df26cacSmrg
3441b68e1f86Smrg	  case $need_lib_prefix in
3442b68e1f86Smrg	  no)
3443b68e1f86Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
3444b68e1f86Smrg	    ;;
3445b68e1f86Smrg	  *)
3446b68e1f86Smrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
3447b68e1f86Smrg	    ;;
3448b68e1f86Smrg	  esac
34493bfa90b6Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
3450b68e1f86Smrg  {0, (void *) 0}
3451b68e1f86Smrg};
34526df26cacSmrg
3453b68e1f86Smrg/* This works around a problem in FreeBSD linker */
3454b68e1f86Smrg#ifdef FREEBSD_WORKAROUND
3455b68e1f86Smrgstatic const void *lt_preloaded_setup() {
3456b68e1f86Smrg  return lt_${my_prefix}_LTX_preloaded_symbols;
3457b68e1f86Smrg}
3458b68e1f86Smrg#endif
34596df26cacSmrg
3460b68e1f86Smrg#ifdef __cplusplus
3461b68e1f86Smrg}
3462b68e1f86Smrg#endif\
3463b68e1f86Smrg"
3464b68e1f86Smrg	} # !$opt_dry_run
34656df26cacSmrg
3466b68e1f86Smrg	pic_flag_for_symtable=
3467b68e1f86Smrg	case "$compile_command " in
3468b68e1f86Smrg	*" -static "*) ;;
3469b68e1f86Smrg	*)
3470b68e1f86Smrg	  case $host in
3471b68e1f86Smrg	  # compiling the symbol table file with pic_flag works around
3472b68e1f86Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
3473b68e1f86Smrg	  # linked before any other PIC object.  But we must not use
3474b68e1f86Smrg	  # pic_flag when linking with -static.  The problem exists in
3475b68e1f86Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
34763bfa90b6Smrg	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
3477b68e1f86Smrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
3478b68e1f86Smrg	  *-*-hpux*)
3479b68e1f86Smrg	    pic_flag_for_symtable=" $pic_flag"  ;;
3480b68e1f86Smrg	  *)
3481b68e1f86Smrg	    if test "X$my_pic_p" != Xno; then
3482b68e1f86Smrg	      pic_flag_for_symtable=" $pic_flag"
3483b68e1f86Smrg	    fi
3484b68e1f86Smrg	    ;;
3485b68e1f86Smrg	  esac
3486b68e1f86Smrg	  ;;
3487b68e1f86Smrg	esac
3488b68e1f86Smrg	symtab_cflags=
3489b68e1f86Smrg	for arg in $LTCFLAGS; do
3490b68e1f86Smrg	  case $arg in
3491b68e1f86Smrg	  -pie | -fpie | -fPIE) ;;
34923bfa90b6Smrg	  *) func_append symtab_cflags " $arg" ;;
3493b68e1f86Smrg	  esac
3494b68e1f86Smrg	done
34956df26cacSmrg
3496b68e1f86Smrg	# Now compile the dynamic symbol file.
3497b68e1f86Smrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
34986df26cacSmrg
3499b68e1f86Smrg	# Clean up the generated files.
3500b68e1f86Smrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
35016df26cacSmrg
3502b68e1f86Smrg	# Transform the symbol file into the correct name.
3503b68e1f86Smrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
3504b68e1f86Smrg	case $host in
3505b68e1f86Smrg	*cygwin* | *mingw* | *cegcc* )
3506b68e1f86Smrg	  if test -f "$output_objdir/$my_outputname.def"; then
35073bfa90b6Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
35083bfa90b6Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3509b68e1f86Smrg	  else
35103bfa90b6Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
35113bfa90b6Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3512b68e1f86Smrg	  fi
3513b68e1f86Smrg	  ;;
3514b68e1f86Smrg	*)
35153bfa90b6Smrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
35163bfa90b6Smrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3517b68e1f86Smrg	  ;;
3518b68e1f86Smrg	esac
3519b68e1f86Smrg	;;
3520b68e1f86Smrg      *)
3521b68e1f86Smrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
3522b68e1f86Smrg	;;
3523b68e1f86Smrg      esac
3524b68e1f86Smrg    else
3525b68e1f86Smrg      # We keep going just in case the user didn't refer to
3526b68e1f86Smrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
3527b68e1f86Smrg      # really was required.
35286df26cacSmrg
3529b68e1f86Smrg      # Nullify the symbol file.
35303bfa90b6Smrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
35313bfa90b6Smrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
3532b68e1f86Smrg    fi
3533b68e1f86Smrg}
35346df26cacSmrg
3535b68e1f86Smrg# func_win32_libid arg
3536b68e1f86Smrg# return the library type of file 'arg'
3537b68e1f86Smrg#
3538b68e1f86Smrg# Need a lot of goo to handle *both* DLLs and import libs
3539b68e1f86Smrg# Has to be a shell function in order to 'eat' the argument
3540b68e1f86Smrg# that is supplied when $file_magic_command is called.
35413bfa90b6Smrg# Despite the name, also deal with 64 bit binaries.
3542b68e1f86Smrgfunc_win32_libid ()
3543b68e1f86Smrg{
3544b68e1f86Smrg  $opt_debug
3545b68e1f86Smrg  win32_libid_type="unknown"
3546b68e1f86Smrg  win32_fileres=`file -L $1 2>/dev/null`
3547b68e1f86Smrg  case $win32_fileres in
3548b68e1f86Smrg  *ar\ archive\ import\ library*) # definitely import
3549b68e1f86Smrg    win32_libid_type="x86 archive import"
3550b68e1f86Smrg    ;;
3551b68e1f86Smrg  *ar\ archive*) # could be an import, or static
35523bfa90b6Smrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
3553b68e1f86Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
35543bfa90b6Smrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
35553bfa90b6Smrg      func_to_tool_file "$1" func_convert_file_msys_to_w32
35563bfa90b6Smrg      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
3557b68e1f86Smrg	$SED -n -e '
3558b68e1f86Smrg	    1,100{
3559b68e1f86Smrg		/ I /{
3560b68e1f86Smrg		    s,.*,import,
3561b68e1f86Smrg		    p
3562b68e1f86Smrg		    q
3563b68e1f86Smrg		}
3564b68e1f86Smrg	    }'`
3565b68e1f86Smrg      case $win32_nmres in
3566b68e1f86Smrg      import*)  win32_libid_type="x86 archive import";;
3567b68e1f86Smrg      *)        win32_libid_type="x86 archive static";;
3568b68e1f86Smrg      esac
3569b68e1f86Smrg    fi
3570b68e1f86Smrg    ;;
3571b68e1f86Smrg  *DLL*)
3572b68e1f86Smrg    win32_libid_type="x86 DLL"
3573b68e1f86Smrg    ;;
3574b68e1f86Smrg  *executable*) # but shell scripts are "executable" too...
3575b68e1f86Smrg    case $win32_fileres in
3576b68e1f86Smrg    *MS\ Windows\ PE\ Intel*)
3577b68e1f86Smrg      win32_libid_type="x86 DLL"
3578b68e1f86Smrg      ;;
3579b68e1f86Smrg    esac
3580b68e1f86Smrg    ;;
3581b68e1f86Smrg  esac
3582b68e1f86Smrg  $ECHO "$win32_libid_type"
3583b68e1f86Smrg}
35846df26cacSmrg
35853bfa90b6Smrg# func_cygming_dll_for_implib ARG
35863bfa90b6Smrg#
35873bfa90b6Smrg# Platform-specific function to extract the
35883bfa90b6Smrg# name of the DLL associated with the specified
35893bfa90b6Smrg# import library ARG.
35903bfa90b6Smrg# Invoked by eval'ing the libtool variable
35913bfa90b6Smrg#    $sharedlib_from_linklib_cmd
35923bfa90b6Smrg# Result is available in the variable
35933bfa90b6Smrg#    $sharedlib_from_linklib_result
35943bfa90b6Smrgfunc_cygming_dll_for_implib ()
35953bfa90b6Smrg{
35963bfa90b6Smrg  $opt_debug
35973bfa90b6Smrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
35983bfa90b6Smrg}
35993bfa90b6Smrg
36003bfa90b6Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
36013bfa90b6Smrg#
36023bfa90b6Smrg# The is the core of a fallback implementation of a
36033bfa90b6Smrg# platform-specific function to extract the name of the
36043bfa90b6Smrg# DLL associated with the specified import library LIBNAME.
36053bfa90b6Smrg#
36063bfa90b6Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending
36073bfa90b6Smrg# on the platform and compiler that created the implib.
36083bfa90b6Smrg#
36093bfa90b6Smrg# Echos the name of the DLL associated with the
36103bfa90b6Smrg# specified import library.
36113bfa90b6Smrgfunc_cygming_dll_for_implib_fallback_core ()
36123bfa90b6Smrg{
36133bfa90b6Smrg  $opt_debug
36143bfa90b6Smrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
36153bfa90b6Smrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
36163bfa90b6Smrg    $SED '/^Contents of section '"$match_literal"':/{
36173bfa90b6Smrg      # Place marker at beginning of archive member dllname section
36183bfa90b6Smrg      s/.*/====MARK====/
36193bfa90b6Smrg      p
36203bfa90b6Smrg      d
36213bfa90b6Smrg    }
36223bfa90b6Smrg    # These lines can sometimes be longer than 43 characters, but
36233bfa90b6Smrg    # are always uninteresting
36243bfa90b6Smrg    /:[	 ]*file format pe[i]\{,1\}-/d
36253bfa90b6Smrg    /^In archive [^:]*:/d
36263bfa90b6Smrg    # Ensure marker is printed
36273bfa90b6Smrg    /^====MARK====/p
36283bfa90b6Smrg    # Remove all lines with less than 43 characters
36293bfa90b6Smrg    /^.\{43\}/!d
36303bfa90b6Smrg    # From remaining lines, remove first 43 characters
36313bfa90b6Smrg    s/^.\{43\}//' |
36323bfa90b6Smrg    $SED -n '
36333bfa90b6Smrg      # Join marker and all lines until next marker into a single line
36343bfa90b6Smrg      /^====MARK====/ b para
36353bfa90b6Smrg      H
36363bfa90b6Smrg      $ b para
36373bfa90b6Smrg      b
36383bfa90b6Smrg      :para
36393bfa90b6Smrg      x
36403bfa90b6Smrg      s/\n//g
36413bfa90b6Smrg      # Remove the marker
36423bfa90b6Smrg      s/^====MARK====//
36433bfa90b6Smrg      # Remove trailing dots and whitespace
36443bfa90b6Smrg      s/[\. \t]*$//
36453bfa90b6Smrg      # Print
36463bfa90b6Smrg      /./p' |
36473bfa90b6Smrg    # we now have a list, one entry per line, of the stringified
36483bfa90b6Smrg    # contents of the appropriate section of all members of the
36493bfa90b6Smrg    # archive which possess that section. Heuristic: eliminate
36503bfa90b6Smrg    # all those which have a first or second character that is
36513bfa90b6Smrg    # a '.' (that is, objdump's representation of an unprintable
36523bfa90b6Smrg    # character.) This should work for all archives with less than
36533bfa90b6Smrg    # 0x302f exports -- but will fail for DLLs whose name actually
36543bfa90b6Smrg    # begins with a literal '.' or a single character followed by
36553bfa90b6Smrg    # a '.'.
36563bfa90b6Smrg    #
36573bfa90b6Smrg    # Of those that remain, print the first one.
36583bfa90b6Smrg    $SED -e '/^\./d;/^.\./d;q'
36593bfa90b6Smrg}
36603bfa90b6Smrg
36613bfa90b6Smrg# func_cygming_gnu_implib_p ARG
36623bfa90b6Smrg# This predicate returns with zero status (TRUE) if
36633bfa90b6Smrg# ARG is a GNU/binutils-style import library. Returns
36643bfa90b6Smrg# with nonzero status (FALSE) otherwise.
36653bfa90b6Smrgfunc_cygming_gnu_implib_p ()
36663bfa90b6Smrg{
36673bfa90b6Smrg  $opt_debug
36683bfa90b6Smrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
36693bfa90b6Smrg  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)$'`
36703bfa90b6Smrg  test -n "$func_cygming_gnu_implib_tmp"
36713bfa90b6Smrg}
36723bfa90b6Smrg
36733bfa90b6Smrg# func_cygming_ms_implib_p ARG
36743bfa90b6Smrg# This predicate returns with zero status (TRUE) if
36753bfa90b6Smrg# ARG is an MS-style import library. Returns
36763bfa90b6Smrg# with nonzero status (FALSE) otherwise.
36773bfa90b6Smrgfunc_cygming_ms_implib_p ()
36783bfa90b6Smrg{
36793bfa90b6Smrg  $opt_debug
36803bfa90b6Smrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
36813bfa90b6Smrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
36823bfa90b6Smrg  test -n "$func_cygming_ms_implib_tmp"
36833bfa90b6Smrg}
36843bfa90b6Smrg
36853bfa90b6Smrg# func_cygming_dll_for_implib_fallback ARG
36863bfa90b6Smrg# Platform-specific function to extract the
36873bfa90b6Smrg# name of the DLL associated with the specified
36883bfa90b6Smrg# import library ARG.
36893bfa90b6Smrg#
36903bfa90b6Smrg# This fallback implementation is for use when $DLLTOOL
36913bfa90b6Smrg# does not support the --identify-strict option.
36923bfa90b6Smrg# Invoked by eval'ing the libtool variable
36933bfa90b6Smrg#    $sharedlib_from_linklib_cmd
36943bfa90b6Smrg# Result is available in the variable
36953bfa90b6Smrg#    $sharedlib_from_linklib_result
36963bfa90b6Smrgfunc_cygming_dll_for_implib_fallback ()
36973bfa90b6Smrg{
36983bfa90b6Smrg  $opt_debug
36993bfa90b6Smrg  if func_cygming_gnu_implib_p "$1" ; then
37003bfa90b6Smrg    # binutils import library
37013bfa90b6Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
37023bfa90b6Smrg  elif func_cygming_ms_implib_p "$1" ; then
37033bfa90b6Smrg    # ms-generated import library
37043bfa90b6Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
37053bfa90b6Smrg  else
37063bfa90b6Smrg    # unknown
37073bfa90b6Smrg    sharedlib_from_linklib_result=""
37083bfa90b6Smrg  fi
37093bfa90b6Smrg}
37106df26cacSmrg
37116df26cacSmrg
3712b68e1f86Smrg# func_extract_an_archive dir oldlib
3713b68e1f86Smrgfunc_extract_an_archive ()
3714b68e1f86Smrg{
3715b68e1f86Smrg    $opt_debug
3716b68e1f86Smrg    f_ex_an_ar_dir="$1"; shift
3717b68e1f86Smrg    f_ex_an_ar_oldlib="$1"
37183bfa90b6Smrg    if test "$lock_old_archive_extraction" = yes; then
37193bfa90b6Smrg      lockfile=$f_ex_an_ar_oldlib.lock
37203bfa90b6Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
37213bfa90b6Smrg	func_echo "Waiting for $lockfile to be removed"
37223bfa90b6Smrg	sleep 2
37233bfa90b6Smrg      done
37243bfa90b6Smrg    fi
37253bfa90b6Smrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
37263bfa90b6Smrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
37273bfa90b6Smrg    if test "$lock_old_archive_extraction" = yes; then
37283bfa90b6Smrg      $opt_dry_run || rm -f "$lockfile"
37293bfa90b6Smrg    fi
3730b68e1f86Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
3731b68e1f86Smrg     :
3732b68e1f86Smrg    else
3733b68e1f86Smrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
3734b68e1f86Smrg    fi
3735b68e1f86Smrg}
37366df26cacSmrg
37376df26cacSmrg
3738b68e1f86Smrg# func_extract_archives gentop oldlib ...
3739b68e1f86Smrgfunc_extract_archives ()
3740b68e1f86Smrg{
3741b68e1f86Smrg    $opt_debug
3742b68e1f86Smrg    my_gentop="$1"; shift
3743b68e1f86Smrg    my_oldlibs=${1+"$@"}
3744b68e1f86Smrg    my_oldobjs=""
3745b68e1f86Smrg    my_xlib=""
3746b68e1f86Smrg    my_xabs=""
3747b68e1f86Smrg    my_xdir=""
37486df26cacSmrg
3749b68e1f86Smrg    for my_xlib in $my_oldlibs; do
3750b68e1f86Smrg      # Extract the objects.
3751b68e1f86Smrg      case $my_xlib in
3752b68e1f86Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
3753b68e1f86Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
3754b68e1f86Smrg      esac
3755b68e1f86Smrg      func_basename "$my_xlib"
3756b68e1f86Smrg      my_xlib="$func_basename_result"
3757b68e1f86Smrg      my_xlib_u=$my_xlib
3758b68e1f86Smrg      while :; do
3759b68e1f86Smrg        case " $extracted_archives " in
3760b68e1f86Smrg	*" $my_xlib_u "*)
3761b68e1f86Smrg	  func_arith $extracted_serial + 1
3762b68e1f86Smrg	  extracted_serial=$func_arith_result
3763b68e1f86Smrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
3764b68e1f86Smrg	*) break ;;
3765b68e1f86Smrg	esac
3766b68e1f86Smrg      done
3767b68e1f86Smrg      extracted_archives="$extracted_archives $my_xlib_u"
3768b68e1f86Smrg      my_xdir="$my_gentop/$my_xlib_u"
37696df26cacSmrg
3770b68e1f86Smrg      func_mkdir_p "$my_xdir"
3771b68e1f86Smrg
3772b68e1f86Smrg      case $host in
3773b68e1f86Smrg      *-darwin*)
3774b68e1f86Smrg	func_verbose "Extracting $my_xabs"
3775b68e1f86Smrg	# Do not bother doing anything if just a dry run
3776b68e1f86Smrg	$opt_dry_run || {
3777b68e1f86Smrg	  darwin_orig_dir=`pwd`
3778b68e1f86Smrg	  cd $my_xdir || exit $?
3779b68e1f86Smrg	  darwin_archive=$my_xabs
3780b68e1f86Smrg	  darwin_curdir=`pwd`
3781b68e1f86Smrg	  darwin_base_archive=`basename "$darwin_archive"`
3782b68e1f86Smrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
3783b68e1f86Smrg	  if test -n "$darwin_arches"; then
3784b68e1f86Smrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
3785b68e1f86Smrg	    darwin_arch=
3786b68e1f86Smrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
3787b68e1f86Smrg	    for darwin_arch in  $darwin_arches ; do
3788b68e1f86Smrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3789b68e1f86Smrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
3790b68e1f86Smrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3791b68e1f86Smrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
3792b68e1f86Smrg	      cd "$darwin_curdir"
3793b68e1f86Smrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
3794b68e1f86Smrg	    done # $darwin_arches
3795b68e1f86Smrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
3796b68e1f86Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
3797b68e1f86Smrg	    darwin_file=
3798b68e1f86Smrg	    darwin_files=
3799b68e1f86Smrg	    for darwin_file in $darwin_filelist; do
38003bfa90b6Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
3801b68e1f86Smrg	      $LIPO -create -output "$darwin_file" $darwin_files
3802b68e1f86Smrg	    done # $darwin_filelist
3803b68e1f86Smrg	    $RM -rf unfat-$$
3804b68e1f86Smrg	    cd "$darwin_orig_dir"
38056df26cacSmrg	  else
3806b68e1f86Smrg	    cd $darwin_orig_dir
3807b68e1f86Smrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
3808b68e1f86Smrg	  fi # $darwin_arches
3809b68e1f86Smrg	} # !$opt_dry_run
3810b68e1f86Smrg	;;
3811b68e1f86Smrg      *)
3812b68e1f86Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
3813b68e1f86Smrg	;;
3814b68e1f86Smrg      esac
38153bfa90b6Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
3816b68e1f86Smrg    done
38176df26cacSmrg
3818b68e1f86Smrg    func_extract_archives_result="$my_oldobjs"
3819b68e1f86Smrg}
38206df26cacSmrg
38216df26cacSmrg
38223bfa90b6Smrg# func_emit_wrapper [arg=no]
38233bfa90b6Smrg#
38243bfa90b6Smrg# Emit a libtool wrapper script on stdout.
38253bfa90b6Smrg# Don't directly open a file because we may want to
38263bfa90b6Smrg# incorporate the script contents within a cygwin/mingw
38273bfa90b6Smrg# wrapper executable.  Must ONLY be called from within
38283bfa90b6Smrg# func_mode_link because it depends on a number of variables
38293bfa90b6Smrg# set therein.
3830b68e1f86Smrg#
38313bfa90b6Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
38323bfa90b6Smrg# variable will take.  If 'yes', then the emitted script
38333bfa90b6Smrg# will assume that the directory in which it is stored is
38343bfa90b6Smrg# the $objdir directory.  This is a cygwin/mingw-specific
38353bfa90b6Smrg# behavior.
38363bfa90b6Smrgfunc_emit_wrapper ()
3837b68e1f86Smrg{
38383bfa90b6Smrg	func_emit_wrapper_arg1=${1-no}
38396df26cacSmrg
3840b68e1f86Smrg	$ECHO "\
3841b68e1f86Smrg#! $SHELL
38426df26cacSmrg
3843b68e1f86Smrg# $output - temporary wrapper script for $objdir/$outputname
3844b68e1f86Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3845b68e1f86Smrg#
3846b68e1f86Smrg# The $output program cannot be directly executed until all the libtool
3847b68e1f86Smrg# libraries that it depends on are installed.
3848b68e1f86Smrg#
3849b68e1f86Smrg# This wrapper script should never be moved out of the build directory.
3850b68e1f86Smrg# If it is, it will not operate correctly.
38516df26cacSmrg
3852b68e1f86Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
3853b68e1f86Smrg# metacharacters that are still active within double-quoted strings.
3854b68e1f86Smrgsed_quote_subst='$sed_quote_subst'
38556df26cacSmrg
3856b68e1f86Smrg# Be Bourne compatible
3857b68e1f86Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
3858b68e1f86Smrg  emulate sh
3859b68e1f86Smrg  NULLCMD=:
3860b68e1f86Smrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
3861b68e1f86Smrg  # is contrary to our usage.  Disable this feature.
3862b68e1f86Smrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
3863b68e1f86Smrg  setopt NO_GLOB_SUBST
3864b68e1f86Smrgelse
3865b68e1f86Smrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
3866b68e1f86Smrgfi
3867b68e1f86SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
3868b68e1f86SmrgDUALCASE=1; export DUALCASE # for MKS sh
38696df26cacSmrg
3870b68e1f86Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
3871b68e1f86Smrg# if CDPATH is set.
3872b68e1f86Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
38736df26cacSmrg
3874b68e1f86Smrgrelink_command=\"$relink_command\"
38756df26cacSmrg
3876b68e1f86Smrg# This environment variable determines our operation mode.
3877b68e1f86Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
3878b68e1f86Smrg  # install mode needs the following variables:
3879b68e1f86Smrg  generated_by_libtool_version='$macro_version'
3880b68e1f86Smrg  notinst_deplibs='$notinst_deplibs'
3881b68e1f86Smrgelse
3882b68e1f86Smrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
3883b68e1f86Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
38843bfa90b6Smrg    file=\"\$0\""
38853bfa90b6Smrg
38863bfa90b6Smrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
38873bfa90b6Smrg    $ECHO "\
38883bfa90b6Smrg
38893bfa90b6Smrg# A function that is used when there is no print builtin or printf.
38903bfa90b6Smrgfunc_fallback_echo ()
38913bfa90b6Smrg{
38923bfa90b6Smrg  eval 'cat <<_LTECHO_EOF
38933bfa90b6Smrg\$1
38943bfa90b6Smrg_LTECHO_EOF'
38953bfa90b6Smrg}
38963bfa90b6Smrg    ECHO=\"$qECHO\"
38973bfa90b6Smrg  fi
38983bfa90b6Smrg
38993bfa90b6Smrg# Very basic option parsing. These options are (a) specific to
39003bfa90b6Smrg# the libtool wrapper, (b) are identical between the wrapper
39013bfa90b6Smrg# /script/ and the wrapper /executable/ which is used only on
39023bfa90b6Smrg# windows platforms, and (c) all begin with the string "--lt-"
39033bfa90b6Smrg# (application programs are unlikely to have options which match
39043bfa90b6Smrg# this pattern).
39053bfa90b6Smrg#
39063bfa90b6Smrg# There are only two supported options: --lt-debug and
39073bfa90b6Smrg# --lt-dump-script. There is, deliberately, no --lt-help.
39083bfa90b6Smrg#
39093bfa90b6Smrg# The first argument to this parsing function should be the
39103bfa90b6Smrg# script's $0 value, followed by "$@".
39113bfa90b6Smrglt_option_debug=
39123bfa90b6Smrgfunc_parse_lt_options ()
39133bfa90b6Smrg{
39143bfa90b6Smrg  lt_script_arg0=\$0
39153bfa90b6Smrg  shift
39163bfa90b6Smrg  for lt_opt
39173bfa90b6Smrg  do
39183bfa90b6Smrg    case \"\$lt_opt\" in
39193bfa90b6Smrg    --lt-debug) lt_option_debug=1 ;;
39203bfa90b6Smrg    --lt-dump-script)
39213bfa90b6Smrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
39223bfa90b6Smrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
39233bfa90b6Smrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
39243bfa90b6Smrg        cat \"\$lt_dump_D/\$lt_dump_F\"
39253bfa90b6Smrg        exit 0
39263bfa90b6Smrg      ;;
39273bfa90b6Smrg    --lt-*)
39283bfa90b6Smrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
39293bfa90b6Smrg        exit 1
39303bfa90b6Smrg      ;;
39313bfa90b6Smrg    esac
39323bfa90b6Smrg  done
39333bfa90b6Smrg
39343bfa90b6Smrg  # Print the debug banner immediately:
39353bfa90b6Smrg  if test -n \"\$lt_option_debug\"; then
39363bfa90b6Smrg    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
39373bfa90b6Smrg  fi
39383bfa90b6Smrg}
39393bfa90b6Smrg
39403bfa90b6Smrg# Used when --lt-debug. Prints its arguments to stdout
39413bfa90b6Smrg# (redirection is the responsibility of the caller)
39423bfa90b6Smrgfunc_lt_dump_args ()
39433bfa90b6Smrg{
39443bfa90b6Smrg  lt_dump_args_N=1;
39453bfa90b6Smrg  for lt_arg
39463bfa90b6Smrg  do
39473bfa90b6Smrg    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
39483bfa90b6Smrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
39493bfa90b6Smrg  done
39503bfa90b6Smrg}
39513bfa90b6Smrg
39523bfa90b6Smrg# Core function for launching the target application
39533bfa90b6Smrgfunc_exec_program_core ()
39543bfa90b6Smrg{
3955b68e1f86Smrg"
39563bfa90b6Smrg  case $host in
39573bfa90b6Smrg  # Backslashes separate directories on plain windows
39583bfa90b6Smrg  *-*-mingw | *-*-os2* | *-cegcc*)
39593bfa90b6Smrg    $ECHO "\
39603bfa90b6Smrg      if test -n \"\$lt_option_debug\"; then
39613bfa90b6Smrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
39623bfa90b6Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
39633bfa90b6Smrg      fi
39643bfa90b6Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
39653bfa90b6Smrg"
39663bfa90b6Smrg    ;;
39673bfa90b6Smrg
39683bfa90b6Smrg  *)
39693bfa90b6Smrg    $ECHO "\
39703bfa90b6Smrg      if test -n \"\$lt_option_debug\"; then
39713bfa90b6Smrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
39723bfa90b6Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
39733bfa90b6Smrg      fi
39743bfa90b6Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
39753bfa90b6Smrg"
39763bfa90b6Smrg    ;;
39773bfa90b6Smrg  esac
39783bfa90b6Smrg  $ECHO "\
39793bfa90b6Smrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
39803bfa90b6Smrg      exit 1
39813bfa90b6Smrg}
39823bfa90b6Smrg
39833bfa90b6Smrg# A function to encapsulate launching the target application
39843bfa90b6Smrg# Strips options in the --lt-* namespace from \$@ and
39853bfa90b6Smrg# launches target application with the remaining arguments.
39863bfa90b6Smrgfunc_exec_program ()
39873bfa90b6Smrg{
39883bfa90b6Smrg  case \" \$* \" in
39893bfa90b6Smrg  *\\ --lt-*)
39903bfa90b6Smrg    for lt_wr_arg
39913bfa90b6Smrg    do
39923bfa90b6Smrg      case \$lt_wr_arg in
39933bfa90b6Smrg      --lt-*) ;;
39943bfa90b6Smrg      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
39953bfa90b6Smrg      esac
39963bfa90b6Smrg      shift
39973bfa90b6Smrg    done ;;
39983bfa90b6Smrg  esac
39993bfa90b6Smrg  func_exec_program_core \${1+\"\$@\"}
40003bfa90b6Smrg}
40013bfa90b6Smrg
40023bfa90b6Smrg  # Parse options
40033bfa90b6Smrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
40046df26cacSmrg
4005b68e1f86Smrg  # Find the directory that this script lives in.
40063bfa90b6Smrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
4007b68e1f86Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
40086df26cacSmrg
4009b68e1f86Smrg  # Follow symbolic links until we get to the real thisdir.
40103bfa90b6Smrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
4011b68e1f86Smrg  while test -n \"\$file\"; do
40123bfa90b6Smrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
4013b68e1f86Smrg
4014b68e1f86Smrg    # If there was a directory component, then change thisdir.
4015b68e1f86Smrg    if test \"x\$destdir\" != \"x\$file\"; then
4016b68e1f86Smrg      case \"\$destdir\" in
4017b68e1f86Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
4018b68e1f86Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
40196df26cacSmrg      esac
4020b68e1f86Smrg    fi
40216df26cacSmrg
40223bfa90b6Smrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
40233bfa90b6Smrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
4024b68e1f86Smrg  done
40256df26cacSmrg
4026b68e1f86Smrg  # Usually 'no', except on cygwin/mingw when embedded into
4027b68e1f86Smrg  # the cwrapper.
40283bfa90b6Smrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
4029b68e1f86Smrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
4030b68e1f86Smrg    # special case for '.'
4031b68e1f86Smrg    if test \"\$thisdir\" = \".\"; then
4032b68e1f86Smrg      thisdir=\`pwd\`
4033b68e1f86Smrg    fi
4034b68e1f86Smrg    # remove .libs from thisdir
4035b68e1f86Smrg    case \"\$thisdir\" in
40363bfa90b6Smrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
4037b68e1f86Smrg    $objdir )   thisdir=. ;;
4038b68e1f86Smrg    esac
4039b68e1f86Smrg  fi
4040b68e1f86Smrg
4041b68e1f86Smrg  # Try to get the absolute directory name.
4042b68e1f86Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
4043b68e1f86Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
4044b68e1f86Smrg"
4045b68e1f86Smrg
4046b68e1f86Smrg	if test "$fast_install" = yes; then
4047b68e1f86Smrg	  $ECHO "\
4048b68e1f86Smrg  program=lt-'$outputname'$exeext
4049b68e1f86Smrg  progdir=\"\$thisdir/$objdir\"
4050b68e1f86Smrg
4051b68e1f86Smrg  if test ! -f \"\$progdir/\$program\" ||
4052b68e1f86Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
4053b68e1f86Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
4054b68e1f86Smrg
4055b68e1f86Smrg    file=\"\$\$-\$program\"
4056b68e1f86Smrg
4057b68e1f86Smrg    if test ! -d \"\$progdir\"; then
4058b68e1f86Smrg      $MKDIR \"\$progdir\"
4059b68e1f86Smrg    else
4060b68e1f86Smrg      $RM \"\$progdir/\$file\"
4061b68e1f86Smrg    fi"
4062b68e1f86Smrg
4063b68e1f86Smrg	  $ECHO "\
4064b68e1f86Smrg
4065b68e1f86Smrg    # relink executable if necessary
4066b68e1f86Smrg    if test -n \"\$relink_command\"; then
4067b68e1f86Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
4068b68e1f86Smrg      else
4069b68e1f86Smrg	$ECHO \"\$relink_command_output\" >&2
4070b68e1f86Smrg	$RM \"\$progdir/\$file\"
4071b68e1f86Smrg	exit 1
40726df26cacSmrg      fi
4073b68e1f86Smrg    fi
40746df26cacSmrg
4075b68e1f86Smrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
4076b68e1f86Smrg    { $RM \"\$progdir/\$program\";
4077b68e1f86Smrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
4078b68e1f86Smrg    $RM \"\$progdir/\$file\"
4079b68e1f86Smrg  fi"
4080b68e1f86Smrg	else
4081b68e1f86Smrg	  $ECHO "\
4082b68e1f86Smrg  program='$outputname'
4083b68e1f86Smrg  progdir=\"\$thisdir/$objdir\"
4084b68e1f86Smrg"
40856df26cacSmrg	fi
40866df26cacSmrg
4087b68e1f86Smrg	$ECHO "\
4088b68e1f86Smrg
4089b68e1f86Smrg  if test -f \"\$progdir/\$program\"; then"
4090b68e1f86Smrg
40913bfa90b6Smrg	# fixup the dll searchpath if we need to.
40923bfa90b6Smrg	#
40933bfa90b6Smrg	# Fix the DLL searchpath if we need to.  Do this before prepending
40943bfa90b6Smrg	# to shlibpath, because on Windows, both are PATH and uninstalled
40953bfa90b6Smrg	# libraries must come first.
40963bfa90b6Smrg	if test -n "$dllsearchpath"; then
40973bfa90b6Smrg	  $ECHO "\
40983bfa90b6Smrg    # Add the dll search path components to the executable PATH
40993bfa90b6Smrg    PATH=$dllsearchpath:\$PATH
41003bfa90b6Smrg"
41013bfa90b6Smrg	fi
41023bfa90b6Smrg
4103b68e1f86Smrg	# Export our shlibpath_var if we have one.
4104b68e1f86Smrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4105b68e1f86Smrg	  $ECHO "\
4106b68e1f86Smrg    # Add our own library path to $shlibpath_var
4107b68e1f86Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
4108b68e1f86Smrg
4109b68e1f86Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
4110b68e1f86Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
41113bfa90b6Smrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
4112b68e1f86Smrg
4113b68e1f86Smrg    export $shlibpath_var
4114b68e1f86Smrg"
41156df26cacSmrg	fi
41166df26cacSmrg
4117b68e1f86Smrg	$ECHO "\
4118b68e1f86Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
4119b68e1f86Smrg      # Run the actual program with our arguments.
41203bfa90b6Smrg      func_exec_program \${1+\"\$@\"}
4121b68e1f86Smrg    fi
4122b68e1f86Smrg  else
4123b68e1f86Smrg    # The program doesn't exist.
4124b68e1f86Smrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
4125b68e1f86Smrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
41263bfa90b6Smrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
4127b68e1f86Smrg    exit 1
4128b68e1f86Smrg  fi
4129b68e1f86Smrgfi\
4130b68e1f86Smrg"
4131b68e1f86Smrg}
41326df26cacSmrg
41336df26cacSmrg
4134b68e1f86Smrg# func_emit_cwrapperexe_src
4135b68e1f86Smrg# emit the source code for a wrapper executable on stdout
4136b68e1f86Smrg# Must ONLY be called from within func_mode_link because
4137b68e1f86Smrg# it depends on a number of variable set therein.
4138b68e1f86Smrgfunc_emit_cwrapperexe_src ()
4139b68e1f86Smrg{
4140b68e1f86Smrg	cat <<EOF
41416df26cacSmrg
4142b68e1f86Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
4143b68e1f86Smrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
41446df26cacSmrg
4145b68e1f86Smrg   The $output program cannot be directly executed until all the libtool
4146b68e1f86Smrg   libraries that it depends on are installed.
41476df26cacSmrg
4148b68e1f86Smrg   This wrapper executable should never be moved out of the build directory.
4149b68e1f86Smrg   If it is, it will not operate correctly.
4150b68e1f86Smrg*/
4151b68e1f86SmrgEOF
4152b68e1f86Smrg	    cat <<"EOF"
41533bfa90b6Smrg#ifdef _MSC_VER
41543bfa90b6Smrg# define _CRT_SECURE_NO_DEPRECATE 1
41553bfa90b6Smrg#endif
4156b68e1f86Smrg#include <stdio.h>
4157b68e1f86Smrg#include <stdlib.h>
4158b68e1f86Smrg#ifdef _MSC_VER
4159b68e1f86Smrg# include <direct.h>
4160b68e1f86Smrg# include <process.h>
4161b68e1f86Smrg# include <io.h>
4162b68e1f86Smrg#else
4163b68e1f86Smrg# include <unistd.h>
4164b68e1f86Smrg# include <stdint.h>
4165b68e1f86Smrg# ifdef __CYGWIN__
4166b68e1f86Smrg#  include <io.h>
4167b68e1f86Smrg# endif
4168b68e1f86Smrg#endif
4169b68e1f86Smrg#include <malloc.h>
4170b68e1f86Smrg#include <stdarg.h>
4171b68e1f86Smrg#include <assert.h>
4172b68e1f86Smrg#include <string.h>
4173b68e1f86Smrg#include <ctype.h>
4174b68e1f86Smrg#include <errno.h>
4175b68e1f86Smrg#include <fcntl.h>
4176b68e1f86Smrg#include <sys/stat.h>
41776df26cacSmrg
41783bfa90b6Smrg/* declarations of non-ANSI functions */
41793bfa90b6Smrg#if defined(__MINGW32__)
41803bfa90b6Smrg# ifdef __STRICT_ANSI__
41813bfa90b6Smrgint _putenv (const char *);
41823bfa90b6Smrg# endif
41833bfa90b6Smrg#elif defined(__CYGWIN__)
41843bfa90b6Smrg# ifdef __STRICT_ANSI__
41853bfa90b6Smrgchar *realpath (const char *, char *);
41863bfa90b6Smrgint putenv (char *);
41873bfa90b6Smrgint setenv (const char *, const char *, int);
41883bfa90b6Smrg# endif
41893bfa90b6Smrg/* #elif defined (other platforms) ... */
41903bfa90b6Smrg#endif
41913bfa90b6Smrg
41923bfa90b6Smrg/* portability defines, excluding path handling macros */
41933bfa90b6Smrg#if defined(_MSC_VER)
41943bfa90b6Smrg# define setmode _setmode
41953bfa90b6Smrg# define stat    _stat
41963bfa90b6Smrg# define chmod   _chmod
41973bfa90b6Smrg# define getcwd  _getcwd
41983bfa90b6Smrg# define putenv  _putenv
41993bfa90b6Smrg# define S_IXUSR _S_IEXEC
42003bfa90b6Smrg# ifndef _INTPTR_T_DEFINED
42013bfa90b6Smrg#  define _INTPTR_T_DEFINED
42023bfa90b6Smrg#  define intptr_t int
42033bfa90b6Smrg# endif
42043bfa90b6Smrg#elif defined(__MINGW32__)
42053bfa90b6Smrg# define setmode _setmode
42063bfa90b6Smrg# define stat    _stat
42073bfa90b6Smrg# define chmod   _chmod
42083bfa90b6Smrg# define getcwd  _getcwd
42093bfa90b6Smrg# define putenv  _putenv
42103bfa90b6Smrg#elif defined(__CYGWIN__)
42113bfa90b6Smrg# define HAVE_SETENV
42123bfa90b6Smrg# define FOPEN_WB "wb"
42133bfa90b6Smrg/* #elif defined (other platforms) ... */
42143bfa90b6Smrg#endif
42153bfa90b6Smrg
4216b68e1f86Smrg#if defined(PATH_MAX)
4217b68e1f86Smrg# define LT_PATHMAX PATH_MAX
4218b68e1f86Smrg#elif defined(MAXPATHLEN)
4219b68e1f86Smrg# define LT_PATHMAX MAXPATHLEN
4220b68e1f86Smrg#else
4221b68e1f86Smrg# define LT_PATHMAX 1024
4222b68e1f86Smrg#endif
42236df26cacSmrg
4224b68e1f86Smrg#ifndef S_IXOTH
4225b68e1f86Smrg# define S_IXOTH 0
4226b68e1f86Smrg#endif
4227b68e1f86Smrg#ifndef S_IXGRP
4228b68e1f86Smrg# define S_IXGRP 0
4229b68e1f86Smrg#endif
42306df26cacSmrg
42313bfa90b6Smrg/* path handling portability macros */
4232b68e1f86Smrg#ifndef DIR_SEPARATOR
4233b68e1f86Smrg# define DIR_SEPARATOR '/'
4234b68e1f86Smrg# define PATH_SEPARATOR ':'
4235b68e1f86Smrg#endif
42366df26cacSmrg
4237b68e1f86Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
4238b68e1f86Smrg  defined (__OS2__)
4239b68e1f86Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
4240b68e1f86Smrg# define FOPEN_WB "wb"
4241b68e1f86Smrg# ifndef DIR_SEPARATOR_2
4242b68e1f86Smrg#  define DIR_SEPARATOR_2 '\\'
4243b68e1f86Smrg# endif
4244b68e1f86Smrg# ifndef PATH_SEPARATOR_2
4245b68e1f86Smrg#  define PATH_SEPARATOR_2 ';'
4246b68e1f86Smrg# endif
4247b68e1f86Smrg#endif
42486df26cacSmrg
4249b68e1f86Smrg#ifndef DIR_SEPARATOR_2
4250b68e1f86Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
4251b68e1f86Smrg#else /* DIR_SEPARATOR_2 */
4252b68e1f86Smrg# define IS_DIR_SEPARATOR(ch) \
4253b68e1f86Smrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4254b68e1f86Smrg#endif /* DIR_SEPARATOR_2 */
42556df26cacSmrg
4256b68e1f86Smrg#ifndef PATH_SEPARATOR_2
4257b68e1f86Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
4258b68e1f86Smrg#else /* PATH_SEPARATOR_2 */
4259b68e1f86Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
4260b68e1f86Smrg#endif /* PATH_SEPARATOR_2 */
42616df26cacSmrg
4262b68e1f86Smrg#ifndef FOPEN_WB
4263b68e1f86Smrg# define FOPEN_WB "w"
4264b68e1f86Smrg#endif
4265b68e1f86Smrg#ifndef _O_BINARY
4266b68e1f86Smrg# define _O_BINARY 0
4267b68e1f86Smrg#endif
42686df26cacSmrg
4269b68e1f86Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
4270b68e1f86Smrg#define XFREE(stale) do { \
4271b68e1f86Smrg  if (stale) { free ((void *) stale); stale = 0; } \
4272b68e1f86Smrg} while (0)
42736df26cacSmrg
42743bfa90b6Smrg#if defined(LT_DEBUGWRAPPER)
42753bfa90b6Smrgstatic int lt_debug = 1;
4276b68e1f86Smrg#else
42773bfa90b6Smrgstatic int lt_debug = 0;
4278b68e1f86Smrg#endif
42796df26cacSmrg
42803bfa90b6Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
42816df26cacSmrg
4282b68e1f86Smrgvoid *xmalloc (size_t num);
4283b68e1f86Smrgchar *xstrdup (const char *string);
4284b68e1f86Smrgconst char *base_name (const char *name);
4285b68e1f86Smrgchar *find_executable (const char *wrapper);
4286b68e1f86Smrgchar *chase_symlinks (const char *pathspec);
4287b68e1f86Smrgint make_executable (const char *path);
4288b68e1f86Smrgint check_executable (const char *path);
4289b68e1f86Smrgchar *strendzap (char *str, const char *pat);
42903bfa90b6Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
42913bfa90b6Smrgvoid lt_fatal (const char *file, int line, const char *message, ...);
42923bfa90b6Smrgstatic const char *nonnull (const char *s);
42933bfa90b6Smrgstatic const char *nonempty (const char *s);
4294b68e1f86Smrgvoid lt_setenv (const char *name, const char *value);
4295b68e1f86Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
4296b68e1f86Smrgvoid lt_update_exe_path (const char *name, const char *value);
4297b68e1f86Smrgvoid lt_update_lib_path (const char *name, const char *value);
42983bfa90b6Smrgchar **prepare_spawn (char **argv);
42993bfa90b6Smrgvoid lt_dump_script (FILE *f);
4300b68e1f86SmrgEOF
4301b68e1f86Smrg
4302b68e1f86Smrg	    cat <<EOF
43033bfa90b6Smrgvolatile const char * MAGIC_EXE = "$magic_exe";
4304b68e1f86Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
4305b68e1f86SmrgEOF
43066df26cacSmrg
4307b68e1f86Smrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
43083bfa90b6Smrg              func_to_host_path "$temp_rpath"
4309b68e1f86Smrg	      cat <<EOF
43103bfa90b6Smrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
4311b68e1f86SmrgEOF
4312b68e1f86Smrg	    else
4313b68e1f86Smrg	      cat <<"EOF"
4314b68e1f86Smrgconst char * LIB_PATH_VALUE   = "";
4315b68e1f86SmrgEOF
4316b68e1f86Smrg	    fi
43176df26cacSmrg
4318b68e1f86Smrg	    if test -n "$dllsearchpath"; then
43193bfa90b6Smrg              func_to_host_path "$dllsearchpath:"
4320b68e1f86Smrg	      cat <<EOF
4321b68e1f86Smrgconst char * EXE_PATH_VARNAME = "PATH";
43223bfa90b6Smrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
4323b68e1f86SmrgEOF
4324b68e1f86Smrg	    else
4325b68e1f86Smrg	      cat <<"EOF"
4326b68e1f86Smrgconst char * EXE_PATH_VARNAME = "";
4327b68e1f86Smrgconst char * EXE_PATH_VALUE   = "";
4328b68e1f86SmrgEOF
4329b68e1f86Smrg	    fi
43306df26cacSmrg
4331b68e1f86Smrg	    if test "$fast_install" = yes; then
4332b68e1f86Smrg	      cat <<EOF
4333b68e1f86Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
4334b68e1f86SmrgEOF
4335b68e1f86Smrg	    else
4336b68e1f86Smrg	      cat <<EOF
4337b68e1f86Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
4338b68e1f86SmrgEOF
4339b68e1f86Smrg	    fi
43406df26cacSmrg
43416df26cacSmrg
4342b68e1f86Smrg	    cat <<"EOF"
43436df26cacSmrg
4344b68e1f86Smrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
43456df26cacSmrg
4346b68e1f86Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
4347b68e1f86Smrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
43483bfa90b6Smrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
4349b68e1f86Smrg
4350b68e1f86Smrgint
4351b68e1f86Smrgmain (int argc, char *argv[])
4352b68e1f86Smrg{
4353b68e1f86Smrg  char **newargz;
4354b68e1f86Smrg  int  newargc;
4355b68e1f86Smrg  char *tmp_pathspec;
4356b68e1f86Smrg  char *actual_cwrapper_path;
4357b68e1f86Smrg  char *actual_cwrapper_name;
4358b68e1f86Smrg  char *target_name;
4359b68e1f86Smrg  char *lt_argv_zero;
4360b68e1f86Smrg  intptr_t rval = 127;
4361b68e1f86Smrg
4362b68e1f86Smrg  int i;
4363b68e1f86Smrg
4364b68e1f86Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
43653bfa90b6Smrg  newargz = XMALLOC (char *, argc + 1);
4366b68e1f86Smrg
43673bfa90b6Smrg  /* very simple arg parsing; don't want to rely on getopt
43683bfa90b6Smrg   * also, copy all non cwrapper options to newargz, except
43693bfa90b6Smrg   * argz[0], which is handled differently
43703bfa90b6Smrg   */
43713bfa90b6Smrg  newargc=0;
4372b68e1f86Smrg  for (i = 1; i < argc; i++)
4373b68e1f86Smrg    {
4374b68e1f86Smrg      if (strcmp (argv[i], dumpscript_opt) == 0)
4375b68e1f86Smrg	{
4376b68e1f86SmrgEOF
4377b68e1f86Smrg	    case "$host" in
4378b68e1f86Smrg	      *mingw* | *cygwin* )
4379b68e1f86Smrg		# make stdout use "unix" line endings
4380b68e1f86Smrg		echo "          setmode(1,_O_BINARY);"
4381b68e1f86Smrg		;;
4382b68e1f86Smrg	      esac
4383b68e1f86Smrg
4384b68e1f86Smrg	    cat <<"EOF"
43853bfa90b6Smrg	  lt_dump_script (stdout);
4386b68e1f86Smrg	  return 0;
4387b68e1f86Smrg	}
43883bfa90b6Smrg      if (strcmp (argv[i], debug_opt) == 0)
43893bfa90b6Smrg	{
43903bfa90b6Smrg          lt_debug = 1;
43913bfa90b6Smrg          continue;
43923bfa90b6Smrg	}
43933bfa90b6Smrg      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
43943bfa90b6Smrg        {
43953bfa90b6Smrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
43963bfa90b6Smrg             namespace, but it is not one of the ones we know about and
43973bfa90b6Smrg             have already dealt with, above (inluding dump-script), then
43983bfa90b6Smrg             report an error. Otherwise, targets might begin to believe
43993bfa90b6Smrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
44003bfa90b6Smrg             namespace. The first time any user complains about this, we'll
44013bfa90b6Smrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
44023bfa90b6Smrg             or a configure.ac-settable value.
44033bfa90b6Smrg           */
44043bfa90b6Smrg          lt_fatal (__FILE__, __LINE__,
44053bfa90b6Smrg		    "unrecognized %s option: '%s'",
44063bfa90b6Smrg                    ltwrapper_option_prefix, argv[i]);
44073bfa90b6Smrg        }
44083bfa90b6Smrg      /* otherwise ... */
44093bfa90b6Smrg      newargz[++newargc] = xstrdup (argv[i]);
4410b68e1f86Smrg    }
44113bfa90b6Smrg  newargz[++newargc] = NULL;
44123bfa90b6Smrg
44133bfa90b6SmrgEOF
44143bfa90b6Smrg	    cat <<EOF
44153bfa90b6Smrg  /* The GNU banner must be the first non-error debug message */
44163bfa90b6Smrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
44173bfa90b6SmrgEOF
44183bfa90b6Smrg	    cat <<"EOF"
44193bfa90b6Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
44203bfa90b6Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
4421b68e1f86Smrg
4422b68e1f86Smrg  tmp_pathspec = find_executable (argv[0]);
4423b68e1f86Smrg  if (tmp_pathspec == NULL)
44243bfa90b6Smrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
44253bfa90b6Smrg  lt_debugprintf (__FILE__, __LINE__,
44263bfa90b6Smrg                  "(main) found exe (before symlink chase) at: %s\n",
44273bfa90b6Smrg		  tmp_pathspec);
4428b68e1f86Smrg
4429b68e1f86Smrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
44303bfa90b6Smrg  lt_debugprintf (__FILE__, __LINE__,
44313bfa90b6Smrg                  "(main) found exe (after symlink chase) at: %s\n",
44323bfa90b6Smrg		  actual_cwrapper_path);
4433b68e1f86Smrg  XFREE (tmp_pathspec);
4434b68e1f86Smrg
44353bfa90b6Smrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
4436b68e1f86Smrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
4437b68e1f86Smrg
4438b68e1f86Smrg  /* wrapper name transforms */
4439b68e1f86Smrg  strendzap (actual_cwrapper_name, ".exe");
4440b68e1f86Smrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
4441b68e1f86Smrg  XFREE (actual_cwrapper_name);
4442b68e1f86Smrg  actual_cwrapper_name = tmp_pathspec;
4443b68e1f86Smrg  tmp_pathspec = 0;
4444b68e1f86Smrg
4445b68e1f86Smrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
4446b68e1f86Smrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
4447b68e1f86Smrg  strendzap (target_name, ".exe");
4448b68e1f86Smrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
4449b68e1f86Smrg  XFREE (target_name);
4450b68e1f86Smrg  target_name = tmp_pathspec;
4451b68e1f86Smrg  tmp_pathspec = 0;
4452b68e1f86Smrg
44533bfa90b6Smrg  lt_debugprintf (__FILE__, __LINE__,
44543bfa90b6Smrg		  "(main) libtool target name: %s\n",
44553bfa90b6Smrg		  target_name);
4456b68e1f86SmrgEOF
4457b68e1f86Smrg
4458b68e1f86Smrg	    cat <<EOF
4459b68e1f86Smrg  newargz[0] =
4460b68e1f86Smrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
4461b68e1f86Smrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
4462b68e1f86Smrg  strcpy (newargz[0], actual_cwrapper_path);
4463b68e1f86Smrg  strcat (newargz[0], "$objdir");
4464b68e1f86Smrg  strcat (newargz[0], "/");
4465b68e1f86SmrgEOF
4466b68e1f86Smrg
4467b68e1f86Smrg	    cat <<"EOF"
4468b68e1f86Smrg  /* stop here, and copy so we don't have to do this twice */
4469b68e1f86Smrg  tmp_pathspec = xstrdup (newargz[0]);
4470b68e1f86Smrg
4471b68e1f86Smrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
4472b68e1f86Smrg  strcat (newargz[0], actual_cwrapper_name);
4473b68e1f86Smrg
4474b68e1f86Smrg  /* DO want the lt- prefix here if it exists, so use target_name */
4475b68e1f86Smrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
4476b68e1f86Smrg  XFREE (tmp_pathspec);
4477b68e1f86Smrg  tmp_pathspec = NULL;
4478b68e1f86SmrgEOF
4479b68e1f86Smrg
4480b68e1f86Smrg	    case $host_os in
4481b68e1f86Smrg	      mingw*)
4482b68e1f86Smrg	    cat <<"EOF"
4483b68e1f86Smrg  {
4484b68e1f86Smrg    char* p;
4485b68e1f86Smrg    while ((p = strchr (newargz[0], '\\')) != NULL)
4486b68e1f86Smrg      {
4487b68e1f86Smrg	*p = '/';
4488b68e1f86Smrg      }
4489b68e1f86Smrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
4490b68e1f86Smrg      {
4491b68e1f86Smrg	*p = '/';
4492b68e1f86Smrg      }
4493b68e1f86Smrg  }
4494b68e1f86SmrgEOF
44956df26cacSmrg	    ;;
4496b68e1f86Smrg	    esac
4497b68e1f86Smrg
4498b68e1f86Smrg	    cat <<"EOF"
4499b68e1f86Smrg  XFREE (target_name);
4500b68e1f86Smrg  XFREE (actual_cwrapper_path);
4501b68e1f86Smrg  XFREE (actual_cwrapper_name);
4502b68e1f86Smrg
4503b68e1f86Smrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
4504b68e1f86Smrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
45053bfa90b6Smrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
45063bfa90b6Smrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
45073bfa90b6Smrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
45083bfa90b6Smrg     libraries must come first. */
4509b68e1f86Smrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
45103bfa90b6Smrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
4511b68e1f86Smrg
45123bfa90b6Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
45133bfa90b6Smrg		  nonnull (lt_argv_zero));
4514b68e1f86Smrg  for (i = 0; i < newargc; i++)
4515b68e1f86Smrg    {
45163bfa90b6Smrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
45173bfa90b6Smrg		      i, nonnull (newargz[i]));
4518b68e1f86Smrg    }
45196df26cacSmrg
45206df26cacSmrgEOF
45216df26cacSmrg
4522b68e1f86Smrg	    case $host_os in
4523b68e1f86Smrg	      mingw*)
4524b68e1f86Smrg		cat <<"EOF"
4525b68e1f86Smrg  /* execv doesn't actually work on mingw as expected on unix */
45263bfa90b6Smrg  newargz = prepare_spawn (newargz);
4527b68e1f86Smrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
4528b68e1f86Smrg  if (rval == -1)
4529b68e1f86Smrg    {
4530b68e1f86Smrg      /* failed to start process */
45313bfa90b6Smrg      lt_debugprintf (__FILE__, __LINE__,
45323bfa90b6Smrg		      "(main) failed to launch target \"%s\": %s\n",
45333bfa90b6Smrg		      lt_argv_zero, nonnull (strerror (errno)));
4534b68e1f86Smrg      return 127;
4535b68e1f86Smrg    }
4536b68e1f86Smrg  return rval;
4537b68e1f86SmrgEOF
4538b68e1f86Smrg		;;
4539b68e1f86Smrg	      *)
4540b68e1f86Smrg		cat <<"EOF"
4541b68e1f86Smrg  execv (lt_argv_zero, newargz);
4542b68e1f86Smrg  return rval; /* =127, but avoids unused variable warning */
4543b68e1f86SmrgEOF
4544b68e1f86Smrg		;;
4545b68e1f86Smrg	    esac
45466df26cacSmrg
4547b68e1f86Smrg	    cat <<"EOF"
4548b68e1f86Smrg}
45496df26cacSmrg
4550b68e1f86Smrgvoid *
4551b68e1f86Smrgxmalloc (size_t num)
4552b68e1f86Smrg{
4553b68e1f86Smrg  void *p = (void *) malloc (num);
4554b68e1f86Smrg  if (!p)
45553bfa90b6Smrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
45566df26cacSmrg
4557b68e1f86Smrg  return p;
4558b68e1f86Smrg}
45596df26cacSmrg
4560b68e1f86Smrgchar *
4561b68e1f86Smrgxstrdup (const char *string)
4562b68e1f86Smrg{
4563b68e1f86Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
4564b68e1f86Smrg			  string) : NULL;
4565b68e1f86Smrg}
45666df26cacSmrg
4567b68e1f86Smrgconst char *
4568b68e1f86Smrgbase_name (const char *name)
4569b68e1f86Smrg{
4570b68e1f86Smrg  const char *base;
45716df26cacSmrg
4572b68e1f86Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4573b68e1f86Smrg  /* Skip over the disk name in MSDOS pathnames. */
4574b68e1f86Smrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
4575b68e1f86Smrg    name += 2;
4576b68e1f86Smrg#endif
45776df26cacSmrg
4578b68e1f86Smrg  for (base = name; *name; name++)
4579b68e1f86Smrg    if (IS_DIR_SEPARATOR (*name))
4580b68e1f86Smrg      base = name + 1;
4581b68e1f86Smrg  return base;
4582b68e1f86Smrg}
45836df26cacSmrg
4584b68e1f86Smrgint
4585b68e1f86Smrgcheck_executable (const char *path)
4586b68e1f86Smrg{
4587b68e1f86Smrg  struct stat st;
45886df26cacSmrg
45893bfa90b6Smrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
45903bfa90b6Smrg                  nonempty (path));
4591b68e1f86Smrg  if ((!path) || (!*path))
4592b68e1f86Smrg    return 0;
45936df26cacSmrg
4594b68e1f86Smrg  if ((stat (path, &st) >= 0)
4595b68e1f86Smrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
4596b68e1f86Smrg    return 1;
4597b68e1f86Smrg  else
4598b68e1f86Smrg    return 0;
4599b68e1f86Smrg}
46006df26cacSmrg
4601b68e1f86Smrgint
4602b68e1f86Smrgmake_executable (const char *path)
4603b68e1f86Smrg{
4604b68e1f86Smrg  int rval = 0;
4605b68e1f86Smrg  struct stat st;
46066df26cacSmrg
46073bfa90b6Smrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
46083bfa90b6Smrg                  nonempty (path));
4609b68e1f86Smrg  if ((!path) || (!*path))
4610b68e1f86Smrg    return 0;
46116df26cacSmrg
4612b68e1f86Smrg  if (stat (path, &st) >= 0)
4613b68e1f86Smrg    {
4614b68e1f86Smrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
4615b68e1f86Smrg    }
4616b68e1f86Smrg  return rval;
4617b68e1f86Smrg}
46186df26cacSmrg
4619b68e1f86Smrg/* Searches for the full path of the wrapper.  Returns
4620b68e1f86Smrg   newly allocated full path name if found, NULL otherwise
4621b68e1f86Smrg   Does not chase symlinks, even on platforms that support them.
4622b68e1f86Smrg*/
4623b68e1f86Smrgchar *
4624b68e1f86Smrgfind_executable (const char *wrapper)
4625b68e1f86Smrg{
4626b68e1f86Smrg  int has_slash = 0;
4627b68e1f86Smrg  const char *p;
4628b68e1f86Smrg  const char *p_next;
4629b68e1f86Smrg  /* static buffer for getcwd */
4630b68e1f86Smrg  char tmp[LT_PATHMAX + 1];
4631b68e1f86Smrg  int tmp_len;
4632b68e1f86Smrg  char *concat_name;
46336df26cacSmrg
46343bfa90b6Smrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
46353bfa90b6Smrg                  nonempty (wrapper));
46366df26cacSmrg
4637b68e1f86Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
4638b68e1f86Smrg    return NULL;
46396df26cacSmrg
4640b68e1f86Smrg  /* Absolute path? */
4641b68e1f86Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4642b68e1f86Smrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
4643b68e1f86Smrg    {
4644b68e1f86Smrg      concat_name = xstrdup (wrapper);
4645b68e1f86Smrg      if (check_executable (concat_name))
4646b68e1f86Smrg	return concat_name;
4647b68e1f86Smrg      XFREE (concat_name);
4648b68e1f86Smrg    }
4649b68e1f86Smrg  else
4650b68e1f86Smrg    {
4651b68e1f86Smrg#endif
4652b68e1f86Smrg      if (IS_DIR_SEPARATOR (wrapper[0]))
4653b68e1f86Smrg	{
4654b68e1f86Smrg	  concat_name = xstrdup (wrapper);
4655b68e1f86Smrg	  if (check_executable (concat_name))
4656b68e1f86Smrg	    return concat_name;
4657b68e1f86Smrg	  XFREE (concat_name);
4658b68e1f86Smrg	}
4659b68e1f86Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4660b68e1f86Smrg    }
4661b68e1f86Smrg#endif
46626df26cacSmrg
4663b68e1f86Smrg  for (p = wrapper; *p; p++)
4664b68e1f86Smrg    if (*p == '/')
4665b68e1f86Smrg      {
4666b68e1f86Smrg	has_slash = 1;
4667b68e1f86Smrg	break;
4668b68e1f86Smrg      }
4669b68e1f86Smrg  if (!has_slash)
4670b68e1f86Smrg    {
4671b68e1f86Smrg      /* no slashes; search PATH */
4672b68e1f86Smrg      const char *path = getenv ("PATH");
4673b68e1f86Smrg      if (path != NULL)
4674b68e1f86Smrg	{
4675b68e1f86Smrg	  for (p = path; *p; p = p_next)
4676b68e1f86Smrg	    {
4677b68e1f86Smrg	      const char *q;
4678b68e1f86Smrg	      size_t p_len;
4679b68e1f86Smrg	      for (q = p; *q; q++)
4680b68e1f86Smrg		if (IS_PATH_SEPARATOR (*q))
4681b68e1f86Smrg		  break;
4682b68e1f86Smrg	      p_len = q - p;
4683b68e1f86Smrg	      p_next = (*q == '\0' ? q : q + 1);
4684b68e1f86Smrg	      if (p_len == 0)
4685b68e1f86Smrg		{
4686b68e1f86Smrg		  /* empty path: current directory */
4687b68e1f86Smrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
46883bfa90b6Smrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
46893bfa90b6Smrg                              nonnull (strerror (errno)));
4690b68e1f86Smrg		  tmp_len = strlen (tmp);
4691b68e1f86Smrg		  concat_name =
4692b68e1f86Smrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4693b68e1f86Smrg		  memcpy (concat_name, tmp, tmp_len);
4694b68e1f86Smrg		  concat_name[tmp_len] = '/';
4695b68e1f86Smrg		  strcpy (concat_name + tmp_len + 1, wrapper);
4696b68e1f86Smrg		}
4697b68e1f86Smrg	      else
4698b68e1f86Smrg		{
4699b68e1f86Smrg		  concat_name =
4700b68e1f86Smrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
4701b68e1f86Smrg		  memcpy (concat_name, p, p_len);
4702b68e1f86Smrg		  concat_name[p_len] = '/';
4703b68e1f86Smrg		  strcpy (concat_name + p_len + 1, wrapper);
4704b68e1f86Smrg		}
4705b68e1f86Smrg	      if (check_executable (concat_name))
4706b68e1f86Smrg		return concat_name;
4707b68e1f86Smrg	      XFREE (concat_name);
4708b68e1f86Smrg	    }
4709b68e1f86Smrg	}
4710b68e1f86Smrg      /* not found in PATH; assume curdir */
4711b68e1f86Smrg    }
4712b68e1f86Smrg  /* Relative path | not found in path: prepend cwd */
4713b68e1f86Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
47143bfa90b6Smrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
47153bfa90b6Smrg              nonnull (strerror (errno)));
4716b68e1f86Smrg  tmp_len = strlen (tmp);
4717b68e1f86Smrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4718b68e1f86Smrg  memcpy (concat_name, tmp, tmp_len);
4719b68e1f86Smrg  concat_name[tmp_len] = '/';
4720b68e1f86Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
47216df26cacSmrg
4722b68e1f86Smrg  if (check_executable (concat_name))
4723b68e1f86Smrg    return concat_name;
4724b68e1f86Smrg  XFREE (concat_name);
4725b68e1f86Smrg  return NULL;
4726b68e1f86Smrg}
47276df26cacSmrg
4728b68e1f86Smrgchar *
4729b68e1f86Smrgchase_symlinks (const char *pathspec)
4730b68e1f86Smrg{
4731b68e1f86Smrg#ifndef S_ISLNK
4732b68e1f86Smrg  return xstrdup (pathspec);
4733b68e1f86Smrg#else
4734b68e1f86Smrg  char buf[LT_PATHMAX];
4735b68e1f86Smrg  struct stat s;
4736b68e1f86Smrg  char *tmp_pathspec = xstrdup (pathspec);
4737b68e1f86Smrg  char *p;
4738b68e1f86Smrg  int has_symlinks = 0;
4739b68e1f86Smrg  while (strlen (tmp_pathspec) && !has_symlinks)
4740b68e1f86Smrg    {
47413bfa90b6Smrg      lt_debugprintf (__FILE__, __LINE__,
47423bfa90b6Smrg		      "checking path component for symlinks: %s\n",
47433bfa90b6Smrg		      tmp_pathspec);
4744b68e1f86Smrg      if (lstat (tmp_pathspec, &s) == 0)
4745b68e1f86Smrg	{
4746b68e1f86Smrg	  if (S_ISLNK (s.st_mode) != 0)
4747b68e1f86Smrg	    {
4748b68e1f86Smrg	      has_symlinks = 1;
4749b68e1f86Smrg	      break;
4750b68e1f86Smrg	    }
47516df26cacSmrg
4752b68e1f86Smrg	  /* search backwards for last DIR_SEPARATOR */
4753b68e1f86Smrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
4754b68e1f86Smrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4755b68e1f86Smrg	    p--;
4756b68e1f86Smrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4757b68e1f86Smrg	    {
4758b68e1f86Smrg	      /* no more DIR_SEPARATORS left */
4759b68e1f86Smrg	      break;
4760b68e1f86Smrg	    }
4761b68e1f86Smrg	  *p = '\0';
4762b68e1f86Smrg	}
4763b68e1f86Smrg      else
4764b68e1f86Smrg	{
47653bfa90b6Smrg	  lt_fatal (__FILE__, __LINE__,
47663bfa90b6Smrg		    "error accessing file \"%s\": %s",
47673bfa90b6Smrg		    tmp_pathspec, nonnull (strerror (errno)));
4768b68e1f86Smrg	}
4769b68e1f86Smrg    }
4770b68e1f86Smrg  XFREE (tmp_pathspec);
47716df26cacSmrg
4772b68e1f86Smrg  if (!has_symlinks)
4773b68e1f86Smrg    {
4774b68e1f86Smrg      return xstrdup (pathspec);
4775b68e1f86Smrg    }
47766df26cacSmrg
4777b68e1f86Smrg  tmp_pathspec = realpath (pathspec, buf);
4778b68e1f86Smrg  if (tmp_pathspec == 0)
4779b68e1f86Smrg    {
47803bfa90b6Smrg      lt_fatal (__FILE__, __LINE__,
47813bfa90b6Smrg		"could not follow symlinks for %s", pathspec);
4782b68e1f86Smrg    }
4783b68e1f86Smrg  return xstrdup (tmp_pathspec);
4784b68e1f86Smrg#endif
4785b68e1f86Smrg}
47866df26cacSmrg
4787b68e1f86Smrgchar *
4788b68e1f86Smrgstrendzap (char *str, const char *pat)
4789b68e1f86Smrg{
4790b68e1f86Smrg  size_t len, patlen;
47916df26cacSmrg
4792b68e1f86Smrg  assert (str != NULL);
4793b68e1f86Smrg  assert (pat != NULL);
47946df26cacSmrg
4795b68e1f86Smrg  len = strlen (str);
4796b68e1f86Smrg  patlen = strlen (pat);
47976df26cacSmrg
4798b68e1f86Smrg  if (patlen <= len)
4799b68e1f86Smrg    {
4800b68e1f86Smrg      str += len - patlen;
4801b68e1f86Smrg      if (strcmp (str, pat) == 0)
4802b68e1f86Smrg	*str = '\0';
4803b68e1f86Smrg    }
4804b68e1f86Smrg  return str;
4805b68e1f86Smrg}
48066df26cacSmrg
48073bfa90b6Smrgvoid
48083bfa90b6Smrglt_debugprintf (const char *file, int line, const char *fmt, ...)
48093bfa90b6Smrg{
48103bfa90b6Smrg  va_list args;
48113bfa90b6Smrg  if (lt_debug)
48123bfa90b6Smrg    {
48133bfa90b6Smrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
48143bfa90b6Smrg      va_start (args, fmt);
48153bfa90b6Smrg      (void) vfprintf (stderr, fmt, args);
48163bfa90b6Smrg      va_end (args);
48173bfa90b6Smrg    }
48183bfa90b6Smrg}
48193bfa90b6Smrg
4820b68e1f86Smrgstatic void
48213bfa90b6Smrglt_error_core (int exit_status, const char *file,
48223bfa90b6Smrg	       int line, const char *mode,
4823b68e1f86Smrg	       const char *message, va_list ap)
4824b68e1f86Smrg{
48253bfa90b6Smrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
4826b68e1f86Smrg  vfprintf (stderr, message, ap);
4827b68e1f86Smrg  fprintf (stderr, ".\n");
48286df26cacSmrg
4829b68e1f86Smrg  if (exit_status >= 0)
4830b68e1f86Smrg    exit (exit_status);
4831b68e1f86Smrg}
48326df26cacSmrg
4833b68e1f86Smrgvoid
48343bfa90b6Smrglt_fatal (const char *file, int line, const char *message, ...)
4835b68e1f86Smrg{
4836b68e1f86Smrg  va_list ap;
4837b68e1f86Smrg  va_start (ap, message);
48383bfa90b6Smrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
4839b68e1f86Smrg  va_end (ap);
4840b68e1f86Smrg}
48416df26cacSmrg
48423bfa90b6Smrgstatic const char *
48433bfa90b6Smrgnonnull (const char *s)
48443bfa90b6Smrg{
48453bfa90b6Smrg  return s ? s : "(null)";
48463bfa90b6Smrg}
48473bfa90b6Smrg
48483bfa90b6Smrgstatic const char *
48493bfa90b6Smrgnonempty (const char *s)
48503bfa90b6Smrg{
48513bfa90b6Smrg  return (s && !*s) ? "(empty)" : nonnull (s);
48523bfa90b6Smrg}
48533bfa90b6Smrg
4854b68e1f86Smrgvoid
4855b68e1f86Smrglt_setenv (const char *name, const char *value)
4856b68e1f86Smrg{
48573bfa90b6Smrg  lt_debugprintf (__FILE__, __LINE__,
48583bfa90b6Smrg		  "(lt_setenv) setting '%s' to '%s'\n",
48593bfa90b6Smrg                  nonnull (name), nonnull (value));
4860b68e1f86Smrg  {
4861b68e1f86Smrg#ifdef HAVE_SETENV
4862b68e1f86Smrg    /* always make a copy, for consistency with !HAVE_SETENV */
4863b68e1f86Smrg    char *str = xstrdup (value);
4864b68e1f86Smrg    setenv (name, str, 1);
4865b68e1f86Smrg#else
4866b68e1f86Smrg    int len = strlen (name) + 1 + strlen (value) + 1;
4867b68e1f86Smrg    char *str = XMALLOC (char, len);
4868b68e1f86Smrg    sprintf (str, "%s=%s", name, value);
4869b68e1f86Smrg    if (putenv (str) != EXIT_SUCCESS)
4870b68e1f86Smrg      {
4871b68e1f86Smrg        XFREE (str);
4872b68e1f86Smrg      }
4873b68e1f86Smrg#endif
4874b68e1f86Smrg  }
4875b68e1f86Smrg}
48766df26cacSmrg
4877b68e1f86Smrgchar *
4878b68e1f86Smrglt_extend_str (const char *orig_value, const char *add, int to_end)
4879b68e1f86Smrg{
4880b68e1f86Smrg  char *new_value;
4881b68e1f86Smrg  if (orig_value && *orig_value)
4882b68e1f86Smrg    {
4883b68e1f86Smrg      int orig_value_len = strlen (orig_value);
4884b68e1f86Smrg      int add_len = strlen (add);
4885b68e1f86Smrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
4886b68e1f86Smrg      if (to_end)
4887b68e1f86Smrg        {
4888b68e1f86Smrg          strcpy (new_value, orig_value);
4889b68e1f86Smrg          strcpy (new_value + orig_value_len, add);
4890b68e1f86Smrg        }
4891b68e1f86Smrg      else
4892b68e1f86Smrg        {
4893b68e1f86Smrg          strcpy (new_value, add);
4894b68e1f86Smrg          strcpy (new_value + add_len, orig_value);
4895b68e1f86Smrg        }
4896b68e1f86Smrg    }
4897b68e1f86Smrg  else
4898b68e1f86Smrg    {
4899b68e1f86Smrg      new_value = xstrdup (add);
4900b68e1f86Smrg    }
4901b68e1f86Smrg  return new_value;
4902b68e1f86Smrg}
49036df26cacSmrg
4904b68e1f86Smrgvoid
4905b68e1f86Smrglt_update_exe_path (const char *name, const char *value)
4906b68e1f86Smrg{
49073bfa90b6Smrg  lt_debugprintf (__FILE__, __LINE__,
49083bfa90b6Smrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
49093bfa90b6Smrg                  nonnull (name), nonnull (value));
49106df26cacSmrg
4911b68e1f86Smrg  if (name && *name && value && *value)
4912b68e1f86Smrg    {
4913b68e1f86Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4914b68e1f86Smrg      /* some systems can't cope with a ':'-terminated path #' */
4915b68e1f86Smrg      int len = strlen (new_value);
4916b68e1f86Smrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4917b68e1f86Smrg        {
4918b68e1f86Smrg          new_value[len-1] = '\0';
4919b68e1f86Smrg        }
4920b68e1f86Smrg      lt_setenv (name, new_value);
4921b68e1f86Smrg      XFREE (new_value);
4922b68e1f86Smrg    }
4923b68e1f86Smrg}
49246df26cacSmrg
4925b68e1f86Smrgvoid
4926b68e1f86Smrglt_update_lib_path (const char *name, const char *value)
4927b68e1f86Smrg{
49283bfa90b6Smrg  lt_debugprintf (__FILE__, __LINE__,
49293bfa90b6Smrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
49303bfa90b6Smrg                  nonnull (name), nonnull (value));
49316df26cacSmrg
4932b68e1f86Smrg  if (name && *name && value && *value)
4933b68e1f86Smrg    {
4934b68e1f86Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4935b68e1f86Smrg      lt_setenv (name, new_value);
4936b68e1f86Smrg      XFREE (new_value);
4937b68e1f86Smrg    }
4938b68e1f86Smrg}
49396df26cacSmrg
49403bfa90b6SmrgEOF
49413bfa90b6Smrg	    case $host_os in
49423bfa90b6Smrg	      mingw*)
49433bfa90b6Smrg		cat <<"EOF"
49443bfa90b6Smrg
49453bfa90b6Smrg/* Prepares an argument vector before calling spawn().
49463bfa90b6Smrg   Note that spawn() does not by itself call the command interpreter
49473bfa90b6Smrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
49483bfa90b6Smrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
49493bfa90b6Smrg         GetVersionEx(&v);
49503bfa90b6Smrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
49513bfa90b6Smrg      }) ? "cmd.exe" : "command.com").
49523bfa90b6Smrg   Instead it simply concatenates the arguments, separated by ' ', and calls
49533bfa90b6Smrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
49543bfa90b6Smrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
49553bfa90b6Smrg   special way:
49563bfa90b6Smrg   - Space and tab are interpreted as delimiters. They are not treated as
49573bfa90b6Smrg     delimiters if they are surrounded by double quotes: "...".
49583bfa90b6Smrg   - Unescaped double quotes are removed from the input. Their only effect is
49593bfa90b6Smrg     that within double quotes, space and tab are treated like normal
49603bfa90b6Smrg     characters.
49613bfa90b6Smrg   - Backslashes not followed by double quotes are not special.
49623bfa90b6Smrg   - But 2*n+1 backslashes followed by a double quote become
49633bfa90b6Smrg     n backslashes followed by a double quote (n >= 0):
49643bfa90b6Smrg       \" -> "
49653bfa90b6Smrg       \\\" -> \"
49663bfa90b6Smrg       \\\\\" -> \\"
49673bfa90b6Smrg */
49683bfa90b6Smrg#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"
49693bfa90b6Smrg#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"
49703bfa90b6Smrgchar **
49713bfa90b6Smrgprepare_spawn (char **argv)
49723bfa90b6Smrg{
49733bfa90b6Smrg  size_t argc;
49743bfa90b6Smrg  char **new_argv;
49753bfa90b6Smrg  size_t i;
49763bfa90b6Smrg
49773bfa90b6Smrg  /* Count number of arguments.  */
49783bfa90b6Smrg  for (argc = 0; argv[argc] != NULL; argc++)
49793bfa90b6Smrg    ;
49803bfa90b6Smrg
49813bfa90b6Smrg  /* Allocate new argument vector.  */
49823bfa90b6Smrg  new_argv = XMALLOC (char *, argc + 1);
49833bfa90b6Smrg
49843bfa90b6Smrg  /* Put quoted arguments into the new argument vector.  */
49853bfa90b6Smrg  for (i = 0; i < argc; i++)
49863bfa90b6Smrg    {
49873bfa90b6Smrg      const char *string = argv[i];
49883bfa90b6Smrg
49893bfa90b6Smrg      if (string[0] == '\0')
49903bfa90b6Smrg	new_argv[i] = xstrdup ("\"\"");
49913bfa90b6Smrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
49923bfa90b6Smrg	{
49933bfa90b6Smrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
49943bfa90b6Smrg	  size_t length;
49953bfa90b6Smrg	  unsigned int backslashes;
49963bfa90b6Smrg	  const char *s;
49973bfa90b6Smrg	  char *quoted_string;
49983bfa90b6Smrg	  char *p;
49993bfa90b6Smrg
50003bfa90b6Smrg	  length = 0;
50013bfa90b6Smrg	  backslashes = 0;
50023bfa90b6Smrg	  if (quote_around)
50033bfa90b6Smrg	    length++;
50043bfa90b6Smrg	  for (s = string; *s != '\0'; s++)
50053bfa90b6Smrg	    {
50063bfa90b6Smrg	      char c = *s;
50073bfa90b6Smrg	      if (c == '"')
50083bfa90b6Smrg		length += backslashes + 1;
50093bfa90b6Smrg	      length++;
50103bfa90b6Smrg	      if (c == '\\')
50113bfa90b6Smrg		backslashes++;
50123bfa90b6Smrg	      else
50133bfa90b6Smrg		backslashes = 0;
50143bfa90b6Smrg	    }
50153bfa90b6Smrg	  if (quote_around)
50163bfa90b6Smrg	    length += backslashes + 1;
50173bfa90b6Smrg
50183bfa90b6Smrg	  quoted_string = XMALLOC (char, length + 1);
50193bfa90b6Smrg
50203bfa90b6Smrg	  p = quoted_string;
50213bfa90b6Smrg	  backslashes = 0;
50223bfa90b6Smrg	  if (quote_around)
50233bfa90b6Smrg	    *p++ = '"';
50243bfa90b6Smrg	  for (s = string; *s != '\0'; s++)
50253bfa90b6Smrg	    {
50263bfa90b6Smrg	      char c = *s;
50273bfa90b6Smrg	      if (c == '"')
50283bfa90b6Smrg		{
50293bfa90b6Smrg		  unsigned int j;
50303bfa90b6Smrg		  for (j = backslashes + 1; j > 0; j--)
50313bfa90b6Smrg		    *p++ = '\\';
50323bfa90b6Smrg		}
50333bfa90b6Smrg	      *p++ = c;
50343bfa90b6Smrg	      if (c == '\\')
50353bfa90b6Smrg		backslashes++;
50363bfa90b6Smrg	      else
50373bfa90b6Smrg		backslashes = 0;
50383bfa90b6Smrg	    }
50393bfa90b6Smrg	  if (quote_around)
50403bfa90b6Smrg	    {
50413bfa90b6Smrg	      unsigned int j;
50423bfa90b6Smrg	      for (j = backslashes; j > 0; j--)
50433bfa90b6Smrg		*p++ = '\\';
50443bfa90b6Smrg	      *p++ = '"';
50453bfa90b6Smrg	    }
50463bfa90b6Smrg	  *p = '\0';
50473bfa90b6Smrg
50483bfa90b6Smrg	  new_argv[i] = quoted_string;
50493bfa90b6Smrg	}
50503bfa90b6Smrg      else
50513bfa90b6Smrg	new_argv[i] = (char *) string;
50523bfa90b6Smrg    }
50533bfa90b6Smrg  new_argv[argc] = NULL;
50543bfa90b6Smrg
50553bfa90b6Smrg  return new_argv;
50563bfa90b6Smrg}
50573bfa90b6SmrgEOF
50583bfa90b6Smrg		;;
50593bfa90b6Smrg	    esac
50606df26cacSmrg
50613bfa90b6Smrg            cat <<"EOF"
50623bfa90b6Smrgvoid lt_dump_script (FILE* f)
50633bfa90b6Smrg{
50643bfa90b6SmrgEOF
50653bfa90b6Smrg	    func_emit_wrapper yes |
50663bfa90b6Smrg	      $SED -n -e '
50673bfa90b6Smrgs/^\(.\{79\}\)\(..*\)/\1\
50683bfa90b6Smrg\2/
50693bfa90b6Smrgh
50703bfa90b6Smrgs/\([\\"]\)/\\\1/g
50713bfa90b6Smrgs/$/\\n/
50723bfa90b6Smrgs/\([^\n]*\).*/  fputs ("\1", f);/p
50733bfa90b6Smrgg
50743bfa90b6SmrgD'
50753bfa90b6Smrg            cat <<"EOF"
50763bfa90b6Smrg}
5077b68e1f86SmrgEOF
5078b68e1f86Smrg}
5079b68e1f86Smrg# end: func_emit_cwrapperexe_src
50806df26cacSmrg
50813bfa90b6Smrg# func_win32_import_lib_p ARG
50823bfa90b6Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd
50833bfa90b6Smrgfunc_win32_import_lib_p ()
50843bfa90b6Smrg{
50853bfa90b6Smrg    $opt_debug
50863bfa90b6Smrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
50873bfa90b6Smrg    *import*) : ;;
50883bfa90b6Smrg    *) false ;;
50893bfa90b6Smrg    esac
50903bfa90b6Smrg}
50913bfa90b6Smrg
5092b68e1f86Smrg# func_mode_link arg...
5093b68e1f86Smrgfunc_mode_link ()
5094b68e1f86Smrg{
5095b68e1f86Smrg    $opt_debug
5096b68e1f86Smrg    case $host in
5097b68e1f86Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5098b68e1f86Smrg      # It is impossible to link a dll without this setting, and
5099b68e1f86Smrg      # we shouldn't force the makefile maintainer to figure out
5100b68e1f86Smrg      # which system we are compiling for in order to pass an extra
5101b68e1f86Smrg      # flag for every libtool invocation.
5102b68e1f86Smrg      # allow_undefined=no
51036df26cacSmrg
5104b68e1f86Smrg      # FIXME: Unfortunately, there are problems with the above when trying
5105b68e1f86Smrg      # to make a dll which has undefined symbols, in which case not
5106b68e1f86Smrg      # even a static library is built.  For now, we need to specify
5107b68e1f86Smrg      # -no-undefined on the libtool link line when we can be certain
5108b68e1f86Smrg      # that all symbols are satisfied, otherwise we get a static library.
5109b68e1f86Smrg      allow_undefined=yes
51106df26cacSmrg      ;;
5111b68e1f86Smrg    *)
5112b68e1f86Smrg      allow_undefined=yes
5113b68e1f86Smrg      ;;
5114b68e1f86Smrg    esac
5115b68e1f86Smrg    libtool_args=$nonopt
5116b68e1f86Smrg    base_compile="$nonopt $@"
5117b68e1f86Smrg    compile_command=$nonopt
5118b68e1f86Smrg    finalize_command=$nonopt
51196df26cacSmrg
5120b68e1f86Smrg    compile_rpath=
5121b68e1f86Smrg    finalize_rpath=
5122b68e1f86Smrg    compile_shlibpath=
5123b68e1f86Smrg    finalize_shlibpath=
5124b68e1f86Smrg    convenience=
5125b68e1f86Smrg    old_convenience=
5126b68e1f86Smrg    deplibs=
5127b68e1f86Smrg    old_deplibs=
5128b68e1f86Smrg    compiler_flags=
5129b68e1f86Smrg    linker_flags=
5130b68e1f86Smrg    dllsearchpath=
5131b68e1f86Smrg    lib_search_path=`pwd`
5132b68e1f86Smrg    inst_prefix_dir=
5133b68e1f86Smrg    new_inherited_linker_flags=
51346df26cacSmrg
5135b68e1f86Smrg    avoid_version=no
51363bfa90b6Smrg    bindir=
5137b68e1f86Smrg    dlfiles=
5138b68e1f86Smrg    dlprefiles=
5139b68e1f86Smrg    dlself=no
5140b68e1f86Smrg    export_dynamic=no
5141b68e1f86Smrg    export_symbols=
5142b68e1f86Smrg    export_symbols_regex=
5143b68e1f86Smrg    generated=
5144b68e1f86Smrg    libobjs=
5145b68e1f86Smrg    ltlibs=
5146b68e1f86Smrg    module=no
5147b68e1f86Smrg    no_install=no
5148b68e1f86Smrg    objs=
5149b68e1f86Smrg    non_pic_objects=
5150b68e1f86Smrg    precious_files_regex=
5151b68e1f86Smrg    prefer_static_libs=no
5152b68e1f86Smrg    preload=no
5153b68e1f86Smrg    prev=
5154b68e1f86Smrg    prevarg=
5155b68e1f86Smrg    release=
5156b68e1f86Smrg    rpath=
5157b68e1f86Smrg    xrpath=
5158b68e1f86Smrg    perm_rpath=
5159b68e1f86Smrg    temp_rpath=
5160b68e1f86Smrg    thread_safe=no
5161b68e1f86Smrg    vinfo=
5162b68e1f86Smrg    vinfo_number=no
5163b68e1f86Smrg    weak_libs=
5164b68e1f86Smrg    single_module="${wl}-single_module"
5165b68e1f86Smrg    func_infer_tag $base_compile
51666df26cacSmrg
5167b68e1f86Smrg    # We need to know -static, to get the right output filenames.
5168b68e1f86Smrg    for arg
5169b68e1f86Smrg    do
5170b68e1f86Smrg      case $arg in
5171b68e1f86Smrg      -shared)
5172b68e1f86Smrg	test "$build_libtool_libs" != yes && \
5173b68e1f86Smrg	  func_fatal_configuration "can not build a shared library"
5174b68e1f86Smrg	build_old_libs=no
5175b68e1f86Smrg	break
5176b68e1f86Smrg	;;
5177b68e1f86Smrg      -all-static | -static | -static-libtool-libs)
5178b68e1f86Smrg	case $arg in
5179b68e1f86Smrg	-all-static)
5180b68e1f86Smrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
5181b68e1f86Smrg	    func_warning "complete static linking is impossible in this configuration"
5182b68e1f86Smrg	  fi
5183b68e1f86Smrg	  if test -n "$link_static_flag"; then
5184b68e1f86Smrg	    dlopen_self=$dlopen_self_static
5185b68e1f86Smrg	  fi
5186b68e1f86Smrg	  prefer_static_libs=yes
5187b68e1f86Smrg	  ;;
5188b68e1f86Smrg	-static)
5189b68e1f86Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5190b68e1f86Smrg	    dlopen_self=$dlopen_self_static
5191b68e1f86Smrg	  fi
5192b68e1f86Smrg	  prefer_static_libs=built
5193b68e1f86Smrg	  ;;
5194b68e1f86Smrg	-static-libtool-libs)
5195b68e1f86Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5196b68e1f86Smrg	    dlopen_self=$dlopen_self_static
5197b68e1f86Smrg	  fi
5198b68e1f86Smrg	  prefer_static_libs=yes
5199b68e1f86Smrg	  ;;
5200b68e1f86Smrg	esac
5201b68e1f86Smrg	build_libtool_libs=no
5202b68e1f86Smrg	build_old_libs=yes
5203b68e1f86Smrg	break
52046df26cacSmrg	;;
52056df26cacSmrg      esac
5206b68e1f86Smrg    done
52076df26cacSmrg
5208b68e1f86Smrg    # See if our shared archives depend on static archives.
5209b68e1f86Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
52106df26cacSmrg
5211b68e1f86Smrg    # Go through the arguments, transforming them on the way.
5212b68e1f86Smrg    while test "$#" -gt 0; do
5213b68e1f86Smrg      arg="$1"
5214b68e1f86Smrg      shift
5215b68e1f86Smrg      func_quote_for_eval "$arg"
5216b68e1f86Smrg      qarg=$func_quote_for_eval_unquoted_result
5217b68e1f86Smrg      func_append libtool_args " $func_quote_for_eval_result"
52186df26cacSmrg
5219b68e1f86Smrg      # If the previous option needs an argument, assign it.
5220b68e1f86Smrg      if test -n "$prev"; then
5221b68e1f86Smrg	case $prev in
5222b68e1f86Smrg	output)
5223b68e1f86Smrg	  func_append compile_command " @OUTPUT@"
5224b68e1f86Smrg	  func_append finalize_command " @OUTPUT@"
52256df26cacSmrg	  ;;
52266df26cacSmrg	esac
52276df26cacSmrg
5228b68e1f86Smrg	case $prev in
52293bfa90b6Smrg	bindir)
52303bfa90b6Smrg	  bindir="$arg"
52313bfa90b6Smrg	  prev=
52323bfa90b6Smrg	  continue
52333bfa90b6Smrg	  ;;
5234b68e1f86Smrg	dlfiles|dlprefiles)
5235b68e1f86Smrg	  if test "$preload" = no; then
5236b68e1f86Smrg	    # Add the symbol object into the linking commands.
5237b68e1f86Smrg	    func_append compile_command " @SYMFILE@"
5238b68e1f86Smrg	    func_append finalize_command " @SYMFILE@"
5239b68e1f86Smrg	    preload=yes
5240b68e1f86Smrg	  fi
5241b68e1f86Smrg	  case $arg in
5242b68e1f86Smrg	  *.la | *.lo) ;;  # We handle these cases below.
5243b68e1f86Smrg	  force)
5244b68e1f86Smrg	    if test "$dlself" = no; then
5245b68e1f86Smrg	      dlself=needless
5246b68e1f86Smrg	      export_dynamic=yes
5247b68e1f86Smrg	    fi
5248b68e1f86Smrg	    prev=
5249b68e1f86Smrg	    continue
5250b68e1f86Smrg	    ;;
5251b68e1f86Smrg	  self)
5252b68e1f86Smrg	    if test "$prev" = dlprefiles; then
5253b68e1f86Smrg	      dlself=yes
5254b68e1f86Smrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
5255b68e1f86Smrg	      dlself=yes
52566df26cacSmrg	    else
5257b68e1f86Smrg	      dlself=needless
5258b68e1f86Smrg	      export_dynamic=yes
52596df26cacSmrg	    fi
5260b68e1f86Smrg	    prev=
5261b68e1f86Smrg	    continue
5262b68e1f86Smrg	    ;;
5263b68e1f86Smrg	  *)
5264b68e1f86Smrg	    if test "$prev" = dlfiles; then
52653bfa90b6Smrg	      func_append dlfiles " $arg"
5266b68e1f86Smrg	    else
52673bfa90b6Smrg	      func_append dlprefiles " $arg"
5268b68e1f86Smrg	    fi
5269b68e1f86Smrg	    prev=
5270b68e1f86Smrg	    continue
5271b68e1f86Smrg	    ;;
52726df26cacSmrg	  esac
52736df26cacSmrg	  ;;
5274b68e1f86Smrg	expsyms)
5275b68e1f86Smrg	  export_symbols="$arg"
5276b68e1f86Smrg	  test -f "$arg" \
5277b68e1f86Smrg	    || func_fatal_error "symbol file \`$arg' does not exist"
5278b68e1f86Smrg	  prev=
5279b68e1f86Smrg	  continue
5280b68e1f86Smrg	  ;;
5281b68e1f86Smrg	expsyms_regex)
5282b68e1f86Smrg	  export_symbols_regex="$arg"
5283b68e1f86Smrg	  prev=
5284b68e1f86Smrg	  continue
5285b68e1f86Smrg	  ;;
5286b68e1f86Smrg	framework)
5287b68e1f86Smrg	  case $host in
5288b68e1f86Smrg	    *-*-darwin*)
5289b68e1f86Smrg	      case "$deplibs " in
5290b68e1f86Smrg		*" $qarg.ltframework "*) ;;
52913bfa90b6Smrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
5292b68e1f86Smrg		   ;;
52936df26cacSmrg	      esac
5294b68e1f86Smrg	      ;;
52956df26cacSmrg	  esac
5296b68e1f86Smrg	  prev=
5297b68e1f86Smrg	  continue
5298b68e1f86Smrg	  ;;
5299b68e1f86Smrg	inst_prefix)
5300b68e1f86Smrg	  inst_prefix_dir="$arg"
5301b68e1f86Smrg	  prev=
5302b68e1f86Smrg	  continue
5303b68e1f86Smrg	  ;;
5304b68e1f86Smrg	objectlist)
5305b68e1f86Smrg	  if test -f "$arg"; then
5306b68e1f86Smrg	    save_arg=$arg
5307b68e1f86Smrg	    moreargs=
5308b68e1f86Smrg	    for fil in `cat "$save_arg"`
5309b68e1f86Smrg	    do
53103bfa90b6Smrg#	      func_append moreargs " $fil"
5311b68e1f86Smrg	      arg=$fil
5312b68e1f86Smrg	      # A libtool-controlled object.
53136df26cacSmrg
5314b68e1f86Smrg	      # Check to see that this really is a libtool object.
5315b68e1f86Smrg	      if func_lalib_unsafe_p "$arg"; then
5316b68e1f86Smrg		pic_object=
5317b68e1f86Smrg		non_pic_object=
53186df26cacSmrg
5319b68e1f86Smrg		# Read the .lo file
5320b68e1f86Smrg		func_source "$arg"
53216df26cacSmrg
5322b68e1f86Smrg		if test -z "$pic_object" ||
5323b68e1f86Smrg		   test -z "$non_pic_object" ||
5324b68e1f86Smrg		   test "$pic_object" = none &&
5325b68e1f86Smrg		   test "$non_pic_object" = none; then
5326b68e1f86Smrg		  func_fatal_error "cannot find name of object for \`$arg'"
5327b68e1f86Smrg		fi
53286df26cacSmrg
5329b68e1f86Smrg		# Extract subdirectory from the argument.
5330b68e1f86Smrg		func_dirname "$arg" "/" ""
5331b68e1f86Smrg		xdir="$func_dirname_result"
53326df26cacSmrg
5333b68e1f86Smrg		if test "$pic_object" != none; then
5334b68e1f86Smrg		  # Prepend the subdirectory the object is found in.
5335b68e1f86Smrg		  pic_object="$xdir$pic_object"
53366df26cacSmrg
5337b68e1f86Smrg		  if test "$prev" = dlfiles; then
5338b68e1f86Smrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
53393bfa90b6Smrg		      func_append dlfiles " $pic_object"
5340b68e1f86Smrg		      prev=
5341b68e1f86Smrg		      continue
5342b68e1f86Smrg		    else
5343b68e1f86Smrg		      # If libtool objects are unsupported, then we need to preload.
5344b68e1f86Smrg		      prev=dlprefiles
5345b68e1f86Smrg		    fi
5346b68e1f86Smrg		  fi
53476df26cacSmrg
5348b68e1f86Smrg		  # CHECK ME:  I think I busted this.  -Ossama
5349b68e1f86Smrg		  if test "$prev" = dlprefiles; then
5350b68e1f86Smrg		    # Preload the old-style object.
53513bfa90b6Smrg		    func_append dlprefiles " $pic_object"
5352b68e1f86Smrg		    prev=
5353b68e1f86Smrg		  fi
53546df26cacSmrg
5355b68e1f86Smrg		  # A PIC object.
5356b68e1f86Smrg		  func_append libobjs " $pic_object"
5357b68e1f86Smrg		  arg="$pic_object"
5358b68e1f86Smrg		fi
53596df26cacSmrg
5360b68e1f86Smrg		# Non-PIC object.
5361b68e1f86Smrg		if test "$non_pic_object" != none; then
5362b68e1f86Smrg		  # Prepend the subdirectory the object is found in.
5363b68e1f86Smrg		  non_pic_object="$xdir$non_pic_object"
53646df26cacSmrg
5365b68e1f86Smrg		  # A standard non-PIC object
5366b68e1f86Smrg		  func_append non_pic_objects " $non_pic_object"
5367b68e1f86Smrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
5368b68e1f86Smrg		    arg="$non_pic_object"
5369b68e1f86Smrg		  fi
5370b68e1f86Smrg		else
5371b68e1f86Smrg		  # If the PIC object exists, use it instead.
5372b68e1f86Smrg		  # $xdir was prepended to $pic_object above.
5373b68e1f86Smrg		  non_pic_object="$pic_object"
5374b68e1f86Smrg		  func_append non_pic_objects " $non_pic_object"
5375b68e1f86Smrg		fi
5376b68e1f86Smrg	      else
5377b68e1f86Smrg		# Only an error if not doing a dry-run.
5378b68e1f86Smrg		if $opt_dry_run; then
5379b68e1f86Smrg		  # Extract subdirectory from the argument.
5380b68e1f86Smrg		  func_dirname "$arg" "/" ""
5381b68e1f86Smrg		  xdir="$func_dirname_result"
5382b68e1f86Smrg
5383b68e1f86Smrg		  func_lo2o "$arg"
5384b68e1f86Smrg		  pic_object=$xdir$objdir/$func_lo2o_result
5385b68e1f86Smrg		  non_pic_object=$xdir$func_lo2o_result
5386b68e1f86Smrg		  func_append libobjs " $pic_object"
5387b68e1f86Smrg		  func_append non_pic_objects " $non_pic_object"
5388b68e1f86Smrg	        else
5389b68e1f86Smrg		  func_fatal_error "\`$arg' is not a valid libtool object"
5390b68e1f86Smrg		fi
5391b68e1f86Smrg	      fi
53926df26cacSmrg	    done
5393b68e1f86Smrg	  else
5394b68e1f86Smrg	    func_fatal_error "link input file \`$arg' does not exist"
53956df26cacSmrg	  fi
5396b68e1f86Smrg	  arg=$save_arg
5397b68e1f86Smrg	  prev=
5398b68e1f86Smrg	  continue
5399b68e1f86Smrg	  ;;
5400b68e1f86Smrg	precious_regex)
5401b68e1f86Smrg	  precious_files_regex="$arg"
5402b68e1f86Smrg	  prev=
5403b68e1f86Smrg	  continue
5404b68e1f86Smrg	  ;;
5405b68e1f86Smrg	release)
5406b68e1f86Smrg	  release="-$arg"
5407b68e1f86Smrg	  prev=
5408b68e1f86Smrg	  continue
5409b68e1f86Smrg	  ;;
5410b68e1f86Smrg	rpath | xrpath)
5411b68e1f86Smrg	  # We need an absolute path.
5412b68e1f86Smrg	  case $arg in
5413b68e1f86Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
5414b68e1f86Smrg	  *)
5415b68e1f86Smrg	    func_fatal_error "only absolute run-paths are allowed"
5416b68e1f86Smrg	    ;;
54176df26cacSmrg	  esac
5418b68e1f86Smrg	  if test "$prev" = rpath; then
5419b68e1f86Smrg	    case "$rpath " in
5420b68e1f86Smrg	    *" $arg "*) ;;
54213bfa90b6Smrg	    *) func_append rpath " $arg" ;;
5422b68e1f86Smrg	    esac
5423b68e1f86Smrg	  else
5424b68e1f86Smrg	    case "$xrpath " in
5425b68e1f86Smrg	    *" $arg "*) ;;
54263bfa90b6Smrg	    *) func_append xrpath " $arg" ;;
5427b68e1f86Smrg	    esac
5428b68e1f86Smrg	  fi
5429b68e1f86Smrg	  prev=
5430b68e1f86Smrg	  continue
5431b68e1f86Smrg	  ;;
5432b68e1f86Smrg	shrext)
5433b68e1f86Smrg	  shrext_cmds="$arg"
5434b68e1f86Smrg	  prev=
5435b68e1f86Smrg	  continue
5436b68e1f86Smrg	  ;;
5437b68e1f86Smrg	weak)
54383bfa90b6Smrg	  func_append weak_libs " $arg"
5439b68e1f86Smrg	  prev=
5440b68e1f86Smrg	  continue
5441b68e1f86Smrg	  ;;
5442b68e1f86Smrg	xcclinker)
54433bfa90b6Smrg	  func_append linker_flags " $qarg"
54443bfa90b6Smrg	  func_append compiler_flags " $qarg"
5445b68e1f86Smrg	  prev=
5446b68e1f86Smrg	  func_append compile_command " $qarg"
5447b68e1f86Smrg	  func_append finalize_command " $qarg"
5448b68e1f86Smrg	  continue
5449b68e1f86Smrg	  ;;
5450b68e1f86Smrg	xcompiler)
54513bfa90b6Smrg	  func_append compiler_flags " $qarg"
5452b68e1f86Smrg	  prev=
5453b68e1f86Smrg	  func_append compile_command " $qarg"
5454b68e1f86Smrg	  func_append finalize_command " $qarg"
5455b68e1f86Smrg	  continue
5456b68e1f86Smrg	  ;;
5457b68e1f86Smrg	xlinker)
54583bfa90b6Smrg	  func_append linker_flags " $qarg"
54593bfa90b6Smrg	  func_append compiler_flags " $wl$qarg"
5460b68e1f86Smrg	  prev=
5461b68e1f86Smrg	  func_append compile_command " $wl$qarg"
5462b68e1f86Smrg	  func_append finalize_command " $wl$qarg"
5463b68e1f86Smrg	  continue
54646df26cacSmrg	  ;;
54656df26cacSmrg	*)
5466b68e1f86Smrg	  eval "$prev=\"\$arg\""
5467b68e1f86Smrg	  prev=
5468b68e1f86Smrg	  continue
54696df26cacSmrg	  ;;
54706df26cacSmrg	esac
5471b68e1f86Smrg      fi # test -n "$prev"
54726df26cacSmrg
5473b68e1f86Smrg      prevarg="$arg"
54746df26cacSmrg
5475b68e1f86Smrg      case $arg in
5476b68e1f86Smrg      -all-static)
5477b68e1f86Smrg	if test -n "$link_static_flag"; then
5478b68e1f86Smrg	  # See comment for -static flag below, for more details.
5479b68e1f86Smrg	  func_append compile_command " $link_static_flag"
5480b68e1f86Smrg	  func_append finalize_command " $link_static_flag"
54816df26cacSmrg	fi
5482b68e1f86Smrg	continue
5483b68e1f86Smrg	;;
54846df26cacSmrg
5485b68e1f86Smrg      -allow-undefined)
5486b68e1f86Smrg	# FIXME: remove this flag sometime in the future.
5487b68e1f86Smrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
5488b68e1f86Smrg	;;
54896df26cacSmrg
5490b68e1f86Smrg      -avoid-version)
5491b68e1f86Smrg	avoid_version=yes
5492b68e1f86Smrg	continue
5493b68e1f86Smrg	;;
54946df26cacSmrg
54953bfa90b6Smrg      -bindir)
54963bfa90b6Smrg	prev=bindir
54973bfa90b6Smrg	continue
54983bfa90b6Smrg	;;
54993bfa90b6Smrg
5500b68e1f86Smrg      -dlopen)
5501b68e1f86Smrg	prev=dlfiles
5502b68e1f86Smrg	continue
5503b68e1f86Smrg	;;
55046df26cacSmrg
5505b68e1f86Smrg      -dlpreopen)
5506b68e1f86Smrg	prev=dlprefiles
5507b68e1f86Smrg	continue
5508b68e1f86Smrg	;;
55096df26cacSmrg
5510b68e1f86Smrg      -export-dynamic)
5511b68e1f86Smrg	export_dynamic=yes
5512b68e1f86Smrg	continue
5513b68e1f86Smrg	;;
55146df26cacSmrg
5515b68e1f86Smrg      -export-symbols | -export-symbols-regex)
5516b68e1f86Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
5517b68e1f86Smrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
5518b68e1f86Smrg	fi
5519b68e1f86Smrg	if test "X$arg" = "X-export-symbols"; then
5520b68e1f86Smrg	  prev=expsyms
55216df26cacSmrg	else
5522b68e1f86Smrg	  prev=expsyms_regex
55236df26cacSmrg	fi
5524b68e1f86Smrg	continue
5525b68e1f86Smrg	;;
55266df26cacSmrg
5527b68e1f86Smrg      -framework)
5528b68e1f86Smrg	prev=framework
5529b68e1f86Smrg	continue
5530b68e1f86Smrg	;;
55316df26cacSmrg
5532b68e1f86Smrg      -inst-prefix-dir)
5533b68e1f86Smrg	prev=inst_prefix
5534b68e1f86Smrg	continue
5535b68e1f86Smrg	;;
55366df26cacSmrg
5537b68e1f86Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
5538b68e1f86Smrg      # so, if we see these flags be careful not to treat them like -L
5539b68e1f86Smrg      -L[A-Z][A-Z]*:*)
5540b68e1f86Smrg	case $with_gcc/$host in
5541b68e1f86Smrg	no/*-*-irix* | /*-*-irix*)
5542b68e1f86Smrg	  func_append compile_command " $arg"
5543b68e1f86Smrg	  func_append finalize_command " $arg"
5544b68e1f86Smrg	  ;;
5545b68e1f86Smrg	esac
5546b68e1f86Smrg	continue
5547b68e1f86Smrg	;;
55486df26cacSmrg
5549b68e1f86Smrg      -L*)
55503bfa90b6Smrg	func_stripname "-L" '' "$arg"
55513bfa90b6Smrg	if test -z "$func_stripname_result"; then
5552b68e1f86Smrg	  if test "$#" -gt 0; then
5553b68e1f86Smrg	    func_fatal_error "require no space between \`-L' and \`$1'"
55546df26cacSmrg	  else
5555b68e1f86Smrg	    func_fatal_error "need path for \`-L' option"
55566df26cacSmrg	  fi
5557b68e1f86Smrg	fi
55583bfa90b6Smrg	func_resolve_sysroot "$func_stripname_result"
55593bfa90b6Smrg	dir=$func_resolve_sysroot_result
5560b68e1f86Smrg	# We need an absolute path.
5561b68e1f86Smrg	case $dir in
5562b68e1f86Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
5563b68e1f86Smrg	*)
5564b68e1f86Smrg	  absdir=`cd "$dir" && pwd`
5565b68e1f86Smrg	  test -z "$absdir" && \
5566b68e1f86Smrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
5567b68e1f86Smrg	  dir="$absdir"
5568b68e1f86Smrg	  ;;
55696df26cacSmrg	esac
5570b68e1f86Smrg	case "$deplibs " in
55713bfa90b6Smrg	*" -L$dir "* | *" $arg "*)
55723bfa90b6Smrg	  # Will only happen for absolute or sysroot arguments
55733bfa90b6Smrg	  ;;
5574b68e1f86Smrg	*)
55753bfa90b6Smrg	  # Preserve sysroot, but never include relative directories
55763bfa90b6Smrg	  case $dir in
55773bfa90b6Smrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
55783bfa90b6Smrg	    *) func_append deplibs " -L$dir" ;;
55793bfa90b6Smrg	  esac
55803bfa90b6Smrg	  func_append lib_search_path " $dir"
5581b68e1f86Smrg	  ;;
55826df26cacSmrg	esac
55836df26cacSmrg	case $host in
5584b68e1f86Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
55853bfa90b6Smrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
5586b68e1f86Smrg	  case :$dllsearchpath: in
5587b68e1f86Smrg	  *":$dir:"*) ;;
5588b68e1f86Smrg	  ::) dllsearchpath=$dir;;
55893bfa90b6Smrg	  *) func_append dllsearchpath ":$dir";;
5590b68e1f86Smrg	  esac
5591b68e1f86Smrg	  case :$dllsearchpath: in
5592b68e1f86Smrg	  *":$testbindir:"*) ;;
5593b68e1f86Smrg	  ::) dllsearchpath=$testbindir;;
55943bfa90b6Smrg	  *) func_append dllsearchpath ":$testbindir";;
5595b68e1f86Smrg	  esac
5596b68e1f86Smrg	  ;;
55976df26cacSmrg	esac
5598b68e1f86Smrg	continue
5599b68e1f86Smrg	;;
56006df26cacSmrg
5601b68e1f86Smrg      -l*)
5602b68e1f86Smrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
5603b68e1f86Smrg	  case $host in
56043bfa90b6Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
5605b68e1f86Smrg	    # These systems don't actually have a C or math library (as such)
5606b68e1f86Smrg	    continue
5607b68e1f86Smrg	    ;;
5608b68e1f86Smrg	  *-*-os2*)
5609b68e1f86Smrg	    # These systems don't actually have a C library (as such)
5610b68e1f86Smrg	    test "X$arg" = "X-lc" && continue
5611b68e1f86Smrg	    ;;
5612b68e1f86Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5613b68e1f86Smrg	    # Do not include libc due to us having libc/libc_r.
5614b68e1f86Smrg	    test "X$arg" = "X-lc" && continue
5615b68e1f86Smrg	    ;;
5616b68e1f86Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
5617b68e1f86Smrg	    # Rhapsody C and math libraries are in the System framework
56183bfa90b6Smrg	    func_append deplibs " System.ltframework"
5619b68e1f86Smrg	    continue
5620b68e1f86Smrg	    ;;
5621b68e1f86Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
5622b68e1f86Smrg	    # Causes problems with __ctype
5623b68e1f86Smrg	    test "X$arg" = "X-lc" && continue
5624b68e1f86Smrg	    ;;
5625b68e1f86Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
5626b68e1f86Smrg	    # Compiler inserts libc in the correct place for threads to work
5627b68e1f86Smrg	    test "X$arg" = "X-lc" && continue
5628b68e1f86Smrg	    ;;
5629b68e1f86Smrg	  esac
5630b68e1f86Smrg	elif test "X$arg" = "X-lc_r"; then
5631b68e1f86Smrg	 case $host in
5632b68e1f86Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5633b68e1f86Smrg	   # Do not include libc_r directly, use -pthread flag.
5634b68e1f86Smrg	   continue
5635b68e1f86Smrg	   ;;
5636b68e1f86Smrg	 esac
5637b68e1f86Smrg	fi
56383bfa90b6Smrg	func_append deplibs " $arg"
5639b68e1f86Smrg	continue
5640b68e1f86Smrg	;;
56416df26cacSmrg
5642b68e1f86Smrg      -module)
5643b68e1f86Smrg	module=yes
5644b68e1f86Smrg	continue
5645b68e1f86Smrg	;;
56466df26cacSmrg
5647b68e1f86Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
5648b68e1f86Smrg      # classes, name mangling, and exception handling.
5649b68e1f86Smrg      # Darwin uses the -arch flag to determine output architecture.
56503bfa90b6Smrg      -model|-arch|-isysroot|--sysroot)
56513bfa90b6Smrg	func_append compiler_flags " $arg"
5652b68e1f86Smrg	func_append compile_command " $arg"
5653b68e1f86Smrg	func_append finalize_command " $arg"
5654b68e1f86Smrg	prev=xcompiler
5655b68e1f86Smrg	continue
5656b68e1f86Smrg	;;
56576df26cacSmrg
56583bfa90b6Smrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
56593bfa90b6Smrg      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
56603bfa90b6Smrg	func_append compiler_flags " $arg"
5661b68e1f86Smrg	func_append compile_command " $arg"
5662b68e1f86Smrg	func_append finalize_command " $arg"
5663b68e1f86Smrg	case "$new_inherited_linker_flags " in
5664b68e1f86Smrg	    *" $arg "*) ;;
56653bfa90b6Smrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
5666b68e1f86Smrg	esac
5667b68e1f86Smrg	continue
5668b68e1f86Smrg	;;
56696df26cacSmrg
5670b68e1f86Smrg      -multi_module)
5671b68e1f86Smrg	single_module="${wl}-multi_module"
5672b68e1f86Smrg	continue
5673b68e1f86Smrg	;;
56746df26cacSmrg
5675b68e1f86Smrg      -no-fast-install)
5676b68e1f86Smrg	fast_install=no
5677b68e1f86Smrg	continue
5678b68e1f86Smrg	;;
56796df26cacSmrg
5680b68e1f86Smrg      -no-install)
5681b68e1f86Smrg	case $host in
5682b68e1f86Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
5683b68e1f86Smrg	  # The PATH hackery in wrapper scripts is required on Windows
5684b68e1f86Smrg	  # and Darwin in order for the loader to find any dlls it needs.
5685b68e1f86Smrg	  func_warning "\`-no-install' is ignored for $host"
5686b68e1f86Smrg	  func_warning "assuming \`-no-fast-install' instead"
5687b68e1f86Smrg	  fast_install=no
5688b68e1f86Smrg	  ;;
5689b68e1f86Smrg	*) no_install=yes ;;
5690b68e1f86Smrg	esac
5691b68e1f86Smrg	continue
5692b68e1f86Smrg	;;
56936df26cacSmrg
5694b68e1f86Smrg      -no-undefined)
5695b68e1f86Smrg	allow_undefined=no
5696b68e1f86Smrg	continue
5697b68e1f86Smrg	;;
56986df26cacSmrg
5699b68e1f86Smrg      -objectlist)
5700b68e1f86Smrg	prev=objectlist
5701b68e1f86Smrg	continue
5702b68e1f86Smrg	;;
57036df26cacSmrg
5704b68e1f86Smrg      -o) prev=output ;;
57056df26cacSmrg
5706b68e1f86Smrg      -precious-files-regex)
5707b68e1f86Smrg	prev=precious_regex
5708b68e1f86Smrg	continue
5709b68e1f86Smrg	;;
57106df26cacSmrg
5711b68e1f86Smrg      -release)
5712b68e1f86Smrg	prev=release
5713b68e1f86Smrg	continue
5714b68e1f86Smrg	;;
57156df26cacSmrg
5716b68e1f86Smrg      -rpath)
5717b68e1f86Smrg	prev=rpath
5718b68e1f86Smrg	continue
5719b68e1f86Smrg	;;
57206df26cacSmrg
5721b68e1f86Smrg      -R)
5722b68e1f86Smrg	prev=xrpath
5723b68e1f86Smrg	continue
5724b68e1f86Smrg	;;
57256df26cacSmrg
5726b68e1f86Smrg      -R*)
5727b68e1f86Smrg	func_stripname '-R' '' "$arg"
5728b68e1f86Smrg	dir=$func_stripname_result
5729b68e1f86Smrg	# We need an absolute path.
5730b68e1f86Smrg	case $dir in
5731b68e1f86Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
57323bfa90b6Smrg	=*)
57333bfa90b6Smrg	  func_stripname '=' '' "$dir"
57343bfa90b6Smrg	  dir=$lt_sysroot$func_stripname_result
57353bfa90b6Smrg	  ;;
5736b68e1f86Smrg	*)
5737b68e1f86Smrg	  func_fatal_error "only absolute run-paths are allowed"
5738b68e1f86Smrg	  ;;
5739b68e1f86Smrg	esac
5740b68e1f86Smrg	case "$xrpath " in
5741b68e1f86Smrg	*" $dir "*) ;;
57423bfa90b6Smrg	*) func_append xrpath " $dir" ;;
5743b68e1f86Smrg	esac
5744b68e1f86Smrg	continue
5745b68e1f86Smrg	;;
57466df26cacSmrg
5747b68e1f86Smrg      -shared)
5748b68e1f86Smrg	# The effects of -shared are defined in a previous loop.
5749b68e1f86Smrg	continue
5750b68e1f86Smrg	;;
57516df26cacSmrg
5752b68e1f86Smrg      -shrext)
5753b68e1f86Smrg	prev=shrext
5754b68e1f86Smrg	continue
5755b68e1f86Smrg	;;
57566df26cacSmrg
5757b68e1f86Smrg      -static | -static-libtool-libs)
5758b68e1f86Smrg	# The effects of -static are defined in a previous loop.
5759b68e1f86Smrg	# We used to do the same as -all-static on platforms that
5760b68e1f86Smrg	# didn't have a PIC flag, but the assumption that the effects
5761b68e1f86Smrg	# would be equivalent was wrong.  It would break on at least
5762b68e1f86Smrg	# Digital Unix and AIX.
5763b68e1f86Smrg	continue
5764b68e1f86Smrg	;;
57656df26cacSmrg
5766b68e1f86Smrg      -thread-safe)
5767b68e1f86Smrg	thread_safe=yes
5768b68e1f86Smrg	continue
5769b68e1f86Smrg	;;
57706df26cacSmrg
5771b68e1f86Smrg      -version-info)
5772b68e1f86Smrg	prev=vinfo
5773b68e1f86Smrg	continue
5774b68e1f86Smrg	;;
57756df26cacSmrg
5776b68e1f86Smrg      -version-number)
5777b68e1f86Smrg	prev=vinfo
5778b68e1f86Smrg	vinfo_number=yes
5779b68e1f86Smrg	continue
5780b68e1f86Smrg	;;
57816df26cacSmrg
5782b68e1f86Smrg      -weak)
5783b68e1f86Smrg        prev=weak
5784b68e1f86Smrg	continue
5785b68e1f86Smrg	;;
57866df26cacSmrg
5787b68e1f86Smrg      -Wc,*)
5788b68e1f86Smrg	func_stripname '-Wc,' '' "$arg"
5789b68e1f86Smrg	args=$func_stripname_result
5790b68e1f86Smrg	arg=
5791b68e1f86Smrg	save_ifs="$IFS"; IFS=','
5792b68e1f86Smrg	for flag in $args; do
5793b68e1f86Smrg	  IFS="$save_ifs"
5794b68e1f86Smrg          func_quote_for_eval "$flag"
57953bfa90b6Smrg	  func_append arg " $func_quote_for_eval_result"
57963bfa90b6Smrg	  func_append compiler_flags " $func_quote_for_eval_result"
5797b68e1f86Smrg	done
5798b68e1f86Smrg	IFS="$save_ifs"
5799b68e1f86Smrg	func_stripname ' ' '' "$arg"
5800b68e1f86Smrg	arg=$func_stripname_result
5801b68e1f86Smrg	;;
58026df26cacSmrg
5803b68e1f86Smrg      -Wl,*)
5804b68e1f86Smrg	func_stripname '-Wl,' '' "$arg"
5805b68e1f86Smrg	args=$func_stripname_result
5806b68e1f86Smrg	arg=
5807b68e1f86Smrg	save_ifs="$IFS"; IFS=','
5808b68e1f86Smrg	for flag in $args; do
5809b68e1f86Smrg	  IFS="$save_ifs"
5810b68e1f86Smrg          func_quote_for_eval "$flag"
58113bfa90b6Smrg	  func_append arg " $wl$func_quote_for_eval_result"
58123bfa90b6Smrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
58133bfa90b6Smrg	  func_append linker_flags " $func_quote_for_eval_result"
5814b68e1f86Smrg	done
5815b68e1f86Smrg	IFS="$save_ifs"
5816b68e1f86Smrg	func_stripname ' ' '' "$arg"
5817b68e1f86Smrg	arg=$func_stripname_result
5818b68e1f86Smrg	;;
58196df26cacSmrg
5820b68e1f86Smrg      -Xcompiler)
5821b68e1f86Smrg	prev=xcompiler
5822b68e1f86Smrg	continue
5823b68e1f86Smrg	;;
58246df26cacSmrg
5825b68e1f86Smrg      -Xlinker)
5826b68e1f86Smrg	prev=xlinker
5827b68e1f86Smrg	continue
5828b68e1f86Smrg	;;
58296df26cacSmrg
5830b68e1f86Smrg      -XCClinker)
5831b68e1f86Smrg	prev=xcclinker
5832b68e1f86Smrg	continue
5833b68e1f86Smrg	;;
58346df26cacSmrg
5835b68e1f86Smrg      # -msg_* for osf cc
5836b68e1f86Smrg      -msg_*)
5837b68e1f86Smrg	func_quote_for_eval "$arg"
5838b68e1f86Smrg	arg="$func_quote_for_eval_result"
5839b68e1f86Smrg	;;
58406df26cacSmrg
58413bfa90b6Smrg      # Flags to be passed through unchanged, with rationale:
58423bfa90b6Smrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
58433bfa90b6Smrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
58443bfa90b6Smrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
58453bfa90b6Smrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
58463bfa90b6Smrg      # -q*                  compiler args for the IBM compiler
58473bfa90b6Smrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
58483bfa90b6Smrg      # -F/path              path to uninstalled frameworks, gcc on darwin
58493bfa90b6Smrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
58503bfa90b6Smrg      # @file                GCC response files
58513bfa90b6Smrg      # -tp=*                Portland pgcc target processor selection
58523bfa90b6Smrg      # --sysroot=*          for sysroot support
58533bfa90b6Smrg      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
5854b68e1f86Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
58553bfa90b6Smrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
58563bfa90b6Smrg      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
5857b68e1f86Smrg        func_quote_for_eval "$arg"
5858b68e1f86Smrg	arg="$func_quote_for_eval_result"
5859b68e1f86Smrg        func_append compile_command " $arg"
5860b68e1f86Smrg        func_append finalize_command " $arg"
58613bfa90b6Smrg        func_append compiler_flags " $arg"
5862b68e1f86Smrg        continue
5863b68e1f86Smrg        ;;
58646df26cacSmrg
5865b68e1f86Smrg      # Some other compiler flag.
5866b68e1f86Smrg      -* | +*)
5867b68e1f86Smrg        func_quote_for_eval "$arg"
5868b68e1f86Smrg	arg="$func_quote_for_eval_result"
5869b68e1f86Smrg	;;
58706df26cacSmrg
5871b68e1f86Smrg      *.$objext)
5872b68e1f86Smrg	# A standard object.
58733bfa90b6Smrg	func_append objs " $arg"
5874b68e1f86Smrg	;;
58756df26cacSmrg
5876b68e1f86Smrg      *.lo)
5877b68e1f86Smrg	# A libtool-controlled object.
58786df26cacSmrg
5879b68e1f86Smrg	# Check to see that this really is a libtool object.
5880b68e1f86Smrg	if func_lalib_unsafe_p "$arg"; then
5881b68e1f86Smrg	  pic_object=
5882b68e1f86Smrg	  non_pic_object=
58836df26cacSmrg
5884b68e1f86Smrg	  # Read the .lo file
5885b68e1f86Smrg	  func_source "$arg"
58866df26cacSmrg
5887b68e1f86Smrg	  if test -z "$pic_object" ||
5888b68e1f86Smrg	     test -z "$non_pic_object" ||
5889b68e1f86Smrg	     test "$pic_object" = none &&
5890b68e1f86Smrg	     test "$non_pic_object" = none; then
5891b68e1f86Smrg	    func_fatal_error "cannot find name of object for \`$arg'"
5892b68e1f86Smrg	  fi
58936df26cacSmrg
5894b68e1f86Smrg	  # Extract subdirectory from the argument.
5895b68e1f86Smrg	  func_dirname "$arg" "/" ""
5896b68e1f86Smrg	  xdir="$func_dirname_result"
58976df26cacSmrg
5898b68e1f86Smrg	  if test "$pic_object" != none; then
5899b68e1f86Smrg	    # Prepend the subdirectory the object is found in.
5900b68e1f86Smrg	    pic_object="$xdir$pic_object"
59016df26cacSmrg
5902b68e1f86Smrg	    if test "$prev" = dlfiles; then
5903b68e1f86Smrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
59043bfa90b6Smrg		func_append dlfiles " $pic_object"
5905b68e1f86Smrg		prev=
5906b68e1f86Smrg		continue
5907b68e1f86Smrg	      else
5908b68e1f86Smrg		# If libtool objects are unsupported, then we need to preload.
5909b68e1f86Smrg		prev=dlprefiles
5910b68e1f86Smrg	      fi
5911b68e1f86Smrg	    fi
59126df26cacSmrg
5913b68e1f86Smrg	    # CHECK ME:  I think I busted this.  -Ossama
5914b68e1f86Smrg	    if test "$prev" = dlprefiles; then
5915b68e1f86Smrg	      # Preload the old-style object.
59163bfa90b6Smrg	      func_append dlprefiles " $pic_object"
5917b68e1f86Smrg	      prev=
5918b68e1f86Smrg	    fi
59196df26cacSmrg
5920b68e1f86Smrg	    # A PIC object.
5921b68e1f86Smrg	    func_append libobjs " $pic_object"
5922b68e1f86Smrg	    arg="$pic_object"
5923b68e1f86Smrg	  fi
59246df26cacSmrg
5925b68e1f86Smrg	  # Non-PIC object.
5926b68e1f86Smrg	  if test "$non_pic_object" != none; then
5927b68e1f86Smrg	    # Prepend the subdirectory the object is found in.
5928b68e1f86Smrg	    non_pic_object="$xdir$non_pic_object"
59296df26cacSmrg
5930b68e1f86Smrg	    # A standard non-PIC object
5931b68e1f86Smrg	    func_append non_pic_objects " $non_pic_object"
5932b68e1f86Smrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
5933b68e1f86Smrg	      arg="$non_pic_object"
5934b68e1f86Smrg	    fi
5935b68e1f86Smrg	  else
5936b68e1f86Smrg	    # If the PIC object exists, use it instead.
5937b68e1f86Smrg	    # $xdir was prepended to $pic_object above.
5938b68e1f86Smrg	    non_pic_object="$pic_object"
5939b68e1f86Smrg	    func_append non_pic_objects " $non_pic_object"
5940b68e1f86Smrg	  fi
5941b68e1f86Smrg	else
5942b68e1f86Smrg	  # Only an error if not doing a dry-run.
5943b68e1f86Smrg	  if $opt_dry_run; then
5944b68e1f86Smrg	    # Extract subdirectory from the argument.
5945b68e1f86Smrg	    func_dirname "$arg" "/" ""
5946b68e1f86Smrg	    xdir="$func_dirname_result"
5947b68e1f86Smrg
5948b68e1f86Smrg	    func_lo2o "$arg"
5949b68e1f86Smrg	    pic_object=$xdir$objdir/$func_lo2o_result
5950b68e1f86Smrg	    non_pic_object=$xdir$func_lo2o_result
5951b68e1f86Smrg	    func_append libobjs " $pic_object"
5952b68e1f86Smrg	    func_append non_pic_objects " $non_pic_object"
5953b68e1f86Smrg	  else
5954b68e1f86Smrg	    func_fatal_error "\`$arg' is not a valid libtool object"
5955b68e1f86Smrg	  fi
5956b68e1f86Smrg	fi
5957b68e1f86Smrg	;;
59586df26cacSmrg
5959b68e1f86Smrg      *.$libext)
5960b68e1f86Smrg	# An archive.
59613bfa90b6Smrg	func_append deplibs " $arg"
59623bfa90b6Smrg	func_append old_deplibs " $arg"
5963b68e1f86Smrg	continue
5964b68e1f86Smrg	;;
59656df26cacSmrg
5966b68e1f86Smrg      *.la)
5967b68e1f86Smrg	# A libtool-controlled library.
59686df26cacSmrg
59693bfa90b6Smrg	func_resolve_sysroot "$arg"
5970b68e1f86Smrg	if test "$prev" = dlfiles; then
5971b68e1f86Smrg	  # This library was specified with -dlopen.
59723bfa90b6Smrg	  func_append dlfiles " $func_resolve_sysroot_result"
5973b68e1f86Smrg	  prev=
5974b68e1f86Smrg	elif test "$prev" = dlprefiles; then
5975b68e1f86Smrg	  # The library was specified with -dlpreopen.
59763bfa90b6Smrg	  func_append dlprefiles " $func_resolve_sysroot_result"
5977b68e1f86Smrg	  prev=
5978b68e1f86Smrg	else
59793bfa90b6Smrg	  func_append deplibs " $func_resolve_sysroot_result"
5980b68e1f86Smrg	fi
5981b68e1f86Smrg	continue
5982b68e1f86Smrg	;;
59836df26cacSmrg
5984b68e1f86Smrg      # Some other compiler argument.
5985b68e1f86Smrg      *)
5986b68e1f86Smrg	# Unknown arguments in both finalize_command and compile_command need
5987b68e1f86Smrg	# to be aesthetically quoted because they are evaled later.
5988b68e1f86Smrg	func_quote_for_eval "$arg"
5989b68e1f86Smrg	arg="$func_quote_for_eval_result"
5990b68e1f86Smrg	;;
5991b68e1f86Smrg      esac # arg
59926df26cacSmrg
5993b68e1f86Smrg      # Now actually substitute the argument into the commands.
5994b68e1f86Smrg      if test -n "$arg"; then
5995b68e1f86Smrg	func_append compile_command " $arg"
5996b68e1f86Smrg	func_append finalize_command " $arg"
5997b68e1f86Smrg      fi
5998b68e1f86Smrg    done # argument parsing loop
59996df26cacSmrg
6000b68e1f86Smrg    test -n "$prev" && \
6001b68e1f86Smrg      func_fatal_help "the \`$prevarg' option requires an argument"
600216fd1166Smrg
6003b68e1f86Smrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
6004b68e1f86Smrg      eval arg=\"$export_dynamic_flag_spec\"
6005b68e1f86Smrg      func_append compile_command " $arg"
6006b68e1f86Smrg      func_append finalize_command " $arg"
6007b68e1f86Smrg    fi
60086df26cacSmrg
6009b68e1f86Smrg    oldlibs=
6010b68e1f86Smrg    # calculate the name of the file, without its directory
6011b68e1f86Smrg    func_basename "$output"
6012b68e1f86Smrg    outputname="$func_basename_result"
6013b68e1f86Smrg    libobjs_save="$libobjs"
60146df26cacSmrg
6015b68e1f86Smrg    if test -n "$shlibpath_var"; then
6016b68e1f86Smrg      # get the directories listed in $shlibpath_var
60173bfa90b6Smrg      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
60186df26cacSmrg    else
6019b68e1f86Smrg      shlib_search_path=
60206df26cacSmrg    fi
6021b68e1f86Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
6022b68e1f86Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
60236df26cacSmrg
6024b68e1f86Smrg    func_dirname "$output" "/" ""
6025b68e1f86Smrg    output_objdir="$func_dirname_result$objdir"
60263bfa90b6Smrg    func_to_tool_file "$output_objdir/"
60273bfa90b6Smrg    tool_output_objdir=$func_to_tool_file_result
6028b68e1f86Smrg    # Create the object directory.
6029b68e1f86Smrg    func_mkdir_p "$output_objdir"
60306df26cacSmrg
6031b68e1f86Smrg    # Determine the type of output
6032b68e1f86Smrg    case $output in
6033b68e1f86Smrg    "")
6034b68e1f86Smrg      func_fatal_help "you must specify an output file"
6035b68e1f86Smrg      ;;
6036b68e1f86Smrg    *.$libext) linkmode=oldlib ;;
6037b68e1f86Smrg    *.lo | *.$objext) linkmode=obj ;;
6038b68e1f86Smrg    *.la) linkmode=lib ;;
6039b68e1f86Smrg    *) linkmode=prog ;; # Anything else should be a program.
6040b68e1f86Smrg    esac
6041b68e1f86Smrg
6042b68e1f86Smrg    specialdeplibs=
6043b68e1f86Smrg
6044b68e1f86Smrg    libs=
6045b68e1f86Smrg    # Find all interdependent deplibs by searching for libraries
6046b68e1f86Smrg    # that are linked more than once (e.g. -la -lb -la)
6047b68e1f86Smrg    for deplib in $deplibs; do
60483bfa90b6Smrg      if $opt_preserve_dup_deps ; then
6049b68e1f86Smrg	case "$libs " in
60503bfa90b6Smrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
6051b68e1f86Smrg	esac
6052b68e1f86Smrg      fi
60533bfa90b6Smrg      func_append libs " $deplib"
6054b68e1f86Smrg    done
6055b68e1f86Smrg
6056b68e1f86Smrg    if test "$linkmode" = lib; then
6057b68e1f86Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
6058b68e1f86Smrg
6059b68e1f86Smrg      # Compute libraries that are listed more than once in $predeps
6060b68e1f86Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
6061b68e1f86Smrg      # not to be eliminated).
6062b68e1f86Smrg      pre_post_deps=
6063b68e1f86Smrg      if $opt_duplicate_compiler_generated_deps; then
6064b68e1f86Smrg	for pre_post_dep in $predeps $postdeps; do
6065b68e1f86Smrg	  case "$pre_post_deps " in
60663bfa90b6Smrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
6067b68e1f86Smrg	  esac
60683bfa90b6Smrg	  func_append pre_post_deps " $pre_post_dep"
6069b68e1f86Smrg	done
6070b68e1f86Smrg      fi
6071b68e1f86Smrg      pre_post_deps=
6072b68e1f86Smrg    fi
6073b68e1f86Smrg
6074b68e1f86Smrg    deplibs=
6075b68e1f86Smrg    newdependency_libs=
6076b68e1f86Smrg    newlib_search_path=
6077b68e1f86Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
6078b68e1f86Smrg    notinst_deplibs= # not-installed libtool libraries
6079b68e1f86Smrg    notinst_path= # paths that contain not-installed libtool libraries
6080b68e1f86Smrg
6081b68e1f86Smrg    case $linkmode in
6082b68e1f86Smrg    lib)
6083b68e1f86Smrg	passes="conv dlpreopen link"
6084b68e1f86Smrg	for file in $dlfiles $dlprefiles; do
6085b68e1f86Smrg	  case $file in
6086b68e1f86Smrg	  *.la) ;;
6087b68e1f86Smrg	  *)
6088b68e1f86Smrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
6089b68e1f86Smrg	    ;;
6090b68e1f86Smrg	  esac
6091b68e1f86Smrg	done
6092b68e1f86Smrg	;;
6093b68e1f86Smrg    prog)
6094b68e1f86Smrg	compile_deplibs=
6095b68e1f86Smrg	finalize_deplibs=
6096b68e1f86Smrg	alldeplibs=no
6097b68e1f86Smrg	newdlfiles=
6098b68e1f86Smrg	newdlprefiles=
6099b68e1f86Smrg	passes="conv scan dlopen dlpreopen link"
6100b68e1f86Smrg	;;
6101b68e1f86Smrg    *)  passes="conv"
6102b68e1f86Smrg	;;
6103b68e1f86Smrg    esac
6104b68e1f86Smrg
6105b68e1f86Smrg    for pass in $passes; do
6106b68e1f86Smrg      # The preopen pass in lib mode reverses $deplibs; put it back here
6107b68e1f86Smrg      # so that -L comes before libs that need it for instance...
6108b68e1f86Smrg      if test "$linkmode,$pass" = "lib,link"; then
6109b68e1f86Smrg	## FIXME: Find the place where the list is rebuilt in the wrong
6110b68e1f86Smrg	##        order, and fix it there properly
6111b68e1f86Smrg        tmp_deplibs=
6112b68e1f86Smrg	for deplib in $deplibs; do
6113b68e1f86Smrg	  tmp_deplibs="$deplib $tmp_deplibs"
6114b68e1f86Smrg	done
6115b68e1f86Smrg	deplibs="$tmp_deplibs"
6116b68e1f86Smrg      fi
6117b68e1f86Smrg
6118b68e1f86Smrg      if test "$linkmode,$pass" = "lib,link" ||
6119b68e1f86Smrg	 test "$linkmode,$pass" = "prog,scan"; then
6120b68e1f86Smrg	libs="$deplibs"
6121b68e1f86Smrg	deplibs=
6122b68e1f86Smrg      fi
6123b68e1f86Smrg      if test "$linkmode" = prog; then
6124b68e1f86Smrg	case $pass in
6125b68e1f86Smrg	dlopen) libs="$dlfiles" ;;
6126b68e1f86Smrg	dlpreopen) libs="$dlprefiles" ;;
6127a241306cSmrg	link)
6128a241306cSmrg	  libs="$deplibs %DEPLIBS%"
6129a241306cSmrg	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
6130a241306cSmrg	  ;;
6131b68e1f86Smrg	esac
6132b68e1f86Smrg      fi
6133b68e1f86Smrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
6134b68e1f86Smrg	# Collect and forward deplibs of preopened libtool libs
6135b68e1f86Smrg	for lib in $dlprefiles; do
6136b68e1f86Smrg	  # Ignore non-libtool-libs
6137b68e1f86Smrg	  dependency_libs=
61383bfa90b6Smrg	  func_resolve_sysroot "$lib"
6139b68e1f86Smrg	  case $lib in
61403bfa90b6Smrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
6141b68e1f86Smrg	  esac
6142b68e1f86Smrg
6143b68e1f86Smrg	  # Collect preopened libtool deplibs, except any this library
6144b68e1f86Smrg	  # has declared as weak libs
6145b68e1f86Smrg	  for deplib in $dependency_libs; do
61463bfa90b6Smrg	    func_basename "$deplib"
61473bfa90b6Smrg            deplib_base=$func_basename_result
6148b68e1f86Smrg	    case " $weak_libs " in
6149b68e1f86Smrg	    *" $deplib_base "*) ;;
61503bfa90b6Smrg	    *) func_append deplibs " $deplib" ;;
6151b68e1f86Smrg	    esac
6152b68e1f86Smrg	  done
6153b68e1f86Smrg	done
6154b68e1f86Smrg	libs="$dlprefiles"
6155b68e1f86Smrg      fi
6156b68e1f86Smrg      if test "$pass" = dlopen; then
6157b68e1f86Smrg	# Collect dlpreopened libraries
6158b68e1f86Smrg	save_deplibs="$deplibs"
6159b68e1f86Smrg	deplibs=
6160b68e1f86Smrg      fi
6161b68e1f86Smrg
6162b68e1f86Smrg      for deplib in $libs; do
6163b68e1f86Smrg	lib=
6164b68e1f86Smrg	found=no
6165b68e1f86Smrg	case $deplib in
61663bfa90b6Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
61673bfa90b6Smrg        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
6168b68e1f86Smrg	  if test "$linkmode,$pass" = "prog,link"; then
6169b68e1f86Smrg	    compile_deplibs="$deplib $compile_deplibs"
6170b68e1f86Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
6171b68e1f86Smrg	  else
61723bfa90b6Smrg	    func_append compiler_flags " $deplib"
6173b68e1f86Smrg	    if test "$linkmode" = lib ; then
6174b68e1f86Smrg		case "$new_inherited_linker_flags " in
6175b68e1f86Smrg		    *" $deplib "*) ;;
61763bfa90b6Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6177b68e1f86Smrg		esac
6178b68e1f86Smrg	    fi
6179b68e1f86Smrg	  fi
6180b68e1f86Smrg	  continue
6181b68e1f86Smrg	  ;;
6182b68e1f86Smrg	-l*)
6183b68e1f86Smrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
6184b68e1f86Smrg	    func_warning "\`-l' is ignored for archives/objects"
6185b68e1f86Smrg	    continue
6186b68e1f86Smrg	  fi
6187b68e1f86Smrg	  func_stripname '-l' '' "$deplib"
6188b68e1f86Smrg	  name=$func_stripname_result
6189b68e1f86Smrg	  if test "$linkmode" = lib; then
6190b68e1f86Smrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
6191b68e1f86Smrg	  else
6192b68e1f86Smrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
6193b68e1f86Smrg	  fi
6194b68e1f86Smrg	  for searchdir in $searchdirs; do
6195b68e1f86Smrg	    for search_ext in .la $std_shrext .so .a; do
6196b68e1f86Smrg	      # Search the libtool library
6197b68e1f86Smrg	      lib="$searchdir/lib${name}${search_ext}"
6198b68e1f86Smrg	      if test -f "$lib"; then
6199b68e1f86Smrg		if test "$search_ext" = ".la"; then
6200b68e1f86Smrg		  found=yes
6201b68e1f86Smrg		else
6202b68e1f86Smrg		  found=no
6203b68e1f86Smrg		fi
6204b68e1f86Smrg		break 2
6205b68e1f86Smrg	      fi
6206b68e1f86Smrg	    done
6207b68e1f86Smrg	  done
6208b68e1f86Smrg	  if test "$found" != yes; then
6209b68e1f86Smrg	    # deplib doesn't seem to be a libtool library
6210b68e1f86Smrg	    if test "$linkmode,$pass" = "prog,link"; then
6211b68e1f86Smrg	      compile_deplibs="$deplib $compile_deplibs"
6212b68e1f86Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
6213b68e1f86Smrg	    else
6214b68e1f86Smrg	      deplibs="$deplib $deplibs"
6215b68e1f86Smrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6216b68e1f86Smrg	    fi
6217b68e1f86Smrg	    continue
6218b68e1f86Smrg	  else # deplib is a libtool library
6219b68e1f86Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
6220b68e1f86Smrg	    # We need to do some special things here, and not later.
6221b68e1f86Smrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6222b68e1f86Smrg	      case " $predeps $postdeps " in
6223b68e1f86Smrg	      *" $deplib "*)
6224b68e1f86Smrg		if func_lalib_p "$lib"; then
6225b68e1f86Smrg		  library_names=
6226b68e1f86Smrg		  old_library=
6227b68e1f86Smrg		  func_source "$lib"
6228b68e1f86Smrg		  for l in $old_library $library_names; do
6229b68e1f86Smrg		    ll="$l"
6230b68e1f86Smrg		  done
6231b68e1f86Smrg		  if test "X$ll" = "X$old_library" ; then # only static version available
6232b68e1f86Smrg		    found=no
6233b68e1f86Smrg		    func_dirname "$lib" "" "."
6234b68e1f86Smrg		    ladir="$func_dirname_result"
6235b68e1f86Smrg		    lib=$ladir/$old_library
6236b68e1f86Smrg		    if test "$linkmode,$pass" = "prog,link"; then
6237b68e1f86Smrg		      compile_deplibs="$deplib $compile_deplibs"
6238b68e1f86Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
6239b68e1f86Smrg		    else
6240b68e1f86Smrg		      deplibs="$deplib $deplibs"
6241b68e1f86Smrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6242b68e1f86Smrg		    fi
6243b68e1f86Smrg		    continue
6244b68e1f86Smrg		  fi
6245b68e1f86Smrg		fi
6246b68e1f86Smrg		;;
6247b68e1f86Smrg	      *) ;;
6248b68e1f86Smrg	      esac
6249b68e1f86Smrg	    fi
6250b68e1f86Smrg	  fi
6251b68e1f86Smrg	  ;; # -l
6252b68e1f86Smrg	*.ltframework)
6253b68e1f86Smrg	  if test "$linkmode,$pass" = "prog,link"; then
6254b68e1f86Smrg	    compile_deplibs="$deplib $compile_deplibs"
6255b68e1f86Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
6256b68e1f86Smrg	  else
6257b68e1f86Smrg	    deplibs="$deplib $deplibs"
6258b68e1f86Smrg	    if test "$linkmode" = lib ; then
6259b68e1f86Smrg		case "$new_inherited_linker_flags " in
6260b68e1f86Smrg		    *" $deplib "*) ;;
62613bfa90b6Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6262b68e1f86Smrg		esac
6263b68e1f86Smrg	    fi
6264b68e1f86Smrg	  fi
6265b68e1f86Smrg	  continue
6266b68e1f86Smrg	  ;;
6267b68e1f86Smrg	-L*)
6268b68e1f86Smrg	  case $linkmode in
6269b68e1f86Smrg	  lib)
6270b68e1f86Smrg	    deplibs="$deplib $deplibs"
6271b68e1f86Smrg	    test "$pass" = conv && continue
6272b68e1f86Smrg	    newdependency_libs="$deplib $newdependency_libs"
6273b68e1f86Smrg	    func_stripname '-L' '' "$deplib"
62743bfa90b6Smrg	    func_resolve_sysroot "$func_stripname_result"
62753bfa90b6Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
6276b68e1f86Smrg	    ;;
6277b68e1f86Smrg	  prog)
6278b68e1f86Smrg	    if test "$pass" = conv; then
6279b68e1f86Smrg	      deplibs="$deplib $deplibs"
6280b68e1f86Smrg	      continue
6281b68e1f86Smrg	    fi
6282b68e1f86Smrg	    if test "$pass" = scan; then
6283b68e1f86Smrg	      deplibs="$deplib $deplibs"
6284b68e1f86Smrg	    else
6285b68e1f86Smrg	      compile_deplibs="$deplib $compile_deplibs"
6286b68e1f86Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
6287b68e1f86Smrg	    fi
6288b68e1f86Smrg	    func_stripname '-L' '' "$deplib"
62893bfa90b6Smrg	    func_resolve_sysroot "$func_stripname_result"
62903bfa90b6Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
6291b68e1f86Smrg	    ;;
6292b68e1f86Smrg	  *)
6293b68e1f86Smrg	    func_warning "\`-L' is ignored for archives/objects"
6294b68e1f86Smrg	    ;;
6295b68e1f86Smrg	  esac # linkmode
6296b68e1f86Smrg	  continue
6297b68e1f86Smrg	  ;; # -L
6298b68e1f86Smrg	-R*)
6299b68e1f86Smrg	  if test "$pass" = link; then
6300b68e1f86Smrg	    func_stripname '-R' '' "$deplib"
63013bfa90b6Smrg	    func_resolve_sysroot "$func_stripname_result"
63023bfa90b6Smrg	    dir=$func_resolve_sysroot_result
6303b68e1f86Smrg	    # Make sure the xrpath contains only unique directories.
6304b68e1f86Smrg	    case "$xrpath " in
6305b68e1f86Smrg	    *" $dir "*) ;;
63063bfa90b6Smrg	    *) func_append xrpath " $dir" ;;
6307b68e1f86Smrg	    esac
6308b68e1f86Smrg	  fi
6309b68e1f86Smrg	  deplibs="$deplib $deplibs"
6310b68e1f86Smrg	  continue
6311b68e1f86Smrg	  ;;
63123bfa90b6Smrg	*.la)
63133bfa90b6Smrg	  func_resolve_sysroot "$deplib"
63143bfa90b6Smrg	  lib=$func_resolve_sysroot_result
63153bfa90b6Smrg	  ;;
6316b68e1f86Smrg	*.$libext)
6317b68e1f86Smrg	  if test "$pass" = conv; then
6318b68e1f86Smrg	    deplibs="$deplib $deplibs"
6319b68e1f86Smrg	    continue
6320b68e1f86Smrg	  fi
6321b68e1f86Smrg	  case $linkmode in
6322b68e1f86Smrg	  lib)
6323b68e1f86Smrg	    # Linking convenience modules into shared libraries is allowed,
6324b68e1f86Smrg	    # but linking other static libraries is non-portable.
6325b68e1f86Smrg	    case " $dlpreconveniencelibs " in
6326b68e1f86Smrg	    *" $deplib "*) ;;
6327b68e1f86Smrg	    *)
6328b68e1f86Smrg	      valid_a_lib=no
6329b68e1f86Smrg	      case $deplibs_check_method in
6330b68e1f86Smrg		match_pattern*)
6331b68e1f86Smrg		  set dummy $deplibs_check_method; shift
6332b68e1f86Smrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
63333bfa90b6Smrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
6334b68e1f86Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
6335b68e1f86Smrg		    valid_a_lib=yes
6336b68e1f86Smrg		  fi
6337b68e1f86Smrg		;;
6338b68e1f86Smrg		pass_all)
6339b68e1f86Smrg		  valid_a_lib=yes
6340b68e1f86Smrg		;;
6341b68e1f86Smrg	      esac
6342b68e1f86Smrg	      if test "$valid_a_lib" != yes; then
63433bfa90b6Smrg		echo
6344b68e1f86Smrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
63453bfa90b6Smrg		echo "*** I have the capability to make that library automatically link in when"
63463bfa90b6Smrg		echo "*** you link to this library.  But I can only do this if you have a"
63473bfa90b6Smrg		echo "*** shared version of the library, which you do not appear to have"
63483bfa90b6Smrg		echo "*** because the file extensions .$libext of this argument makes me believe"
63493bfa90b6Smrg		echo "*** that it is just a static archive that I should not use here."
6350b68e1f86Smrg	      else
63513bfa90b6Smrg		echo
6352b68e1f86Smrg		$ECHO "*** Warning: Linking the shared library $output against the"
6353b68e1f86Smrg		$ECHO "*** static library $deplib is not portable!"
6354b68e1f86Smrg		deplibs="$deplib $deplibs"
6355b68e1f86Smrg	      fi
6356b68e1f86Smrg	      ;;
6357b68e1f86Smrg	    esac
6358b68e1f86Smrg	    continue
6359b68e1f86Smrg	    ;;
6360b68e1f86Smrg	  prog)
6361b68e1f86Smrg	    if test "$pass" != link; then
6362b68e1f86Smrg	      deplibs="$deplib $deplibs"
6363b68e1f86Smrg	    else
6364b68e1f86Smrg	      compile_deplibs="$deplib $compile_deplibs"
6365b68e1f86Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
6366b68e1f86Smrg	    fi
6367b68e1f86Smrg	    continue
6368b68e1f86Smrg	    ;;
6369b68e1f86Smrg	  esac # linkmode
6370b68e1f86Smrg	  ;; # *.$libext
6371b68e1f86Smrg	*.lo | *.$objext)
6372b68e1f86Smrg	  if test "$pass" = conv; then
6373b68e1f86Smrg	    deplibs="$deplib $deplibs"
6374b68e1f86Smrg	  elif test "$linkmode" = prog; then
6375b68e1f86Smrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
6376b68e1f86Smrg	      # If there is no dlopen support or we're linking statically,
6377b68e1f86Smrg	      # we need to preload.
63783bfa90b6Smrg	      func_append newdlprefiles " $deplib"
6379b68e1f86Smrg	      compile_deplibs="$deplib $compile_deplibs"
6380b68e1f86Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
6381b68e1f86Smrg	    else
63823bfa90b6Smrg	      func_append newdlfiles " $deplib"
6383b68e1f86Smrg	    fi
6384b68e1f86Smrg	  fi
6385b68e1f86Smrg	  continue
6386b68e1f86Smrg	  ;;
6387b68e1f86Smrg	%DEPLIBS%)
6388b68e1f86Smrg	  alldeplibs=yes
6389b68e1f86Smrg	  continue
6390b68e1f86Smrg	  ;;
6391b68e1f86Smrg	esac # case $deplib
6392b68e1f86Smrg
6393b68e1f86Smrg	if test "$found" = yes || test -f "$lib"; then :
6394b68e1f86Smrg	else
6395b68e1f86Smrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
6396b68e1f86Smrg	fi
6397b68e1f86Smrg
6398b68e1f86Smrg	# Check to see that this really is a libtool archive.
6399b68e1f86Smrg	func_lalib_unsafe_p "$lib" \
6400b68e1f86Smrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
6401b68e1f86Smrg
6402b68e1f86Smrg	func_dirname "$lib" "" "."
6403b68e1f86Smrg	ladir="$func_dirname_result"
6404b68e1f86Smrg
6405b68e1f86Smrg	dlname=
6406b68e1f86Smrg	dlopen=
6407b68e1f86Smrg	dlpreopen=
6408b68e1f86Smrg	libdir=
6409b68e1f86Smrg	library_names=
6410b68e1f86Smrg	old_library=
6411b68e1f86Smrg	inherited_linker_flags=
6412b68e1f86Smrg	# If the library was installed with an old release of libtool,
6413b68e1f86Smrg	# it will not redefine variables installed, or shouldnotlink
6414b68e1f86Smrg	installed=yes
6415b68e1f86Smrg	shouldnotlink=no
6416b68e1f86Smrg	avoidtemprpath=
6417b68e1f86Smrg
6418b68e1f86Smrg
6419b68e1f86Smrg	# Read the .la file
6420b68e1f86Smrg	func_source "$lib"
6421b68e1f86Smrg
6422b68e1f86Smrg	# Convert "-framework foo" to "foo.ltframework"
6423b68e1f86Smrg	if test -n "$inherited_linker_flags"; then
64243bfa90b6Smrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
6425b68e1f86Smrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
6426b68e1f86Smrg	    case " $new_inherited_linker_flags " in
6427b68e1f86Smrg	      *" $tmp_inherited_linker_flag "*) ;;
64283bfa90b6Smrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
6429b68e1f86Smrg	    esac
6430b68e1f86Smrg	  done
6431b68e1f86Smrg	fi
64323bfa90b6Smrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
6433b68e1f86Smrg	if test "$linkmode,$pass" = "lib,link" ||
6434b68e1f86Smrg	   test "$linkmode,$pass" = "prog,scan" ||
6435b68e1f86Smrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
64363bfa90b6Smrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
64373bfa90b6Smrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
6438b68e1f86Smrg	fi
6439b68e1f86Smrg
6440b68e1f86Smrg	if test "$pass" = conv; then
6441b68e1f86Smrg	  # Only check for convenience libraries
6442b68e1f86Smrg	  deplibs="$lib $deplibs"
6443b68e1f86Smrg	  if test -z "$libdir"; then
6444b68e1f86Smrg	    if test -z "$old_library"; then
6445b68e1f86Smrg	      func_fatal_error "cannot find name of link library for \`$lib'"
6446b68e1f86Smrg	    fi
6447b68e1f86Smrg	    # It is a libtool convenience library, so add in its objects.
64483bfa90b6Smrg	    func_append convenience " $ladir/$objdir/$old_library"
64493bfa90b6Smrg	    func_append old_convenience " $ladir/$objdir/$old_library"
64503bfa90b6Smrg	    tmp_libs=
64513bfa90b6Smrg	    for deplib in $dependency_libs; do
64523bfa90b6Smrg	      deplibs="$deplib $deplibs"
64533bfa90b6Smrg	      if $opt_preserve_dup_deps ; then
64543bfa90b6Smrg		case "$tmp_libs " in
64553bfa90b6Smrg		*" $deplib "*) func_append specialdeplibs " $deplib" ;;
64563bfa90b6Smrg		esac
64573bfa90b6Smrg	      fi
64583bfa90b6Smrg	      func_append tmp_libs " $deplib"
64593bfa90b6Smrg	    done
6460b68e1f86Smrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
6461b68e1f86Smrg	    func_fatal_error "\`$lib' is not a convenience library"
6462b68e1f86Smrg	  fi
6463b68e1f86Smrg	  continue
6464b68e1f86Smrg	fi # $pass = conv
6465b68e1f86Smrg
6466b68e1f86Smrg
6467b68e1f86Smrg	# Get the name of the library we link against.
6468b68e1f86Smrg	linklib=
64693bfa90b6Smrg	if test -n "$old_library" &&
64703bfa90b6Smrg	   { test "$prefer_static_libs" = yes ||
64713bfa90b6Smrg	     test "$prefer_static_libs,$installed" = "built,no"; }; then
64723bfa90b6Smrg	  linklib=$old_library
64733bfa90b6Smrg	else
64743bfa90b6Smrg	  for l in $old_library $library_names; do
64753bfa90b6Smrg	    linklib="$l"
64763bfa90b6Smrg	  done
64773bfa90b6Smrg	fi
6478b68e1f86Smrg	if test -z "$linklib"; then
6479b68e1f86Smrg	  func_fatal_error "cannot find name of link library for \`$lib'"
6480b68e1f86Smrg	fi
6481b68e1f86Smrg
6482b68e1f86Smrg	# This library was specified with -dlopen.
6483b68e1f86Smrg	if test "$pass" = dlopen; then
6484b68e1f86Smrg	  if test -z "$libdir"; then
6485b68e1f86Smrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
6486b68e1f86Smrg	  fi
6487b68e1f86Smrg	  if test -z "$dlname" ||
6488b68e1f86Smrg	     test "$dlopen_support" != yes ||
6489b68e1f86Smrg	     test "$build_libtool_libs" = no; then
6490b68e1f86Smrg	    # If there is no dlname, no dlopen support or we're linking
6491b68e1f86Smrg	    # statically, we need to preload.  We also need to preload any
6492b68e1f86Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
6493b68e1f86Smrg	    # bomb out in the load deplibs phase.
64943bfa90b6Smrg	    func_append dlprefiles " $lib $dependency_libs"
6495b68e1f86Smrg	  else
64963bfa90b6Smrg	    func_append newdlfiles " $lib"
6497b68e1f86Smrg	  fi
6498b68e1f86Smrg	  continue
6499b68e1f86Smrg	fi # $pass = dlopen
6500b68e1f86Smrg
6501b68e1f86Smrg	# We need an absolute path.
6502b68e1f86Smrg	case $ladir in
6503b68e1f86Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
6504b68e1f86Smrg	*)
6505b68e1f86Smrg	  abs_ladir=`cd "$ladir" && pwd`
6506b68e1f86Smrg	  if test -z "$abs_ladir"; then
6507b68e1f86Smrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
6508b68e1f86Smrg	    func_warning "passing it literally to the linker, although it might fail"
6509b68e1f86Smrg	    abs_ladir="$ladir"
6510b68e1f86Smrg	  fi
6511b68e1f86Smrg	  ;;
6512b68e1f86Smrg	esac
6513b68e1f86Smrg	func_basename "$lib"
6514b68e1f86Smrg	laname="$func_basename_result"
6515b68e1f86Smrg
6516b68e1f86Smrg	# Find the relevant object directory and library name.
6517b68e1f86Smrg	if test "X$installed" = Xyes; then
65183bfa90b6Smrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6519b68e1f86Smrg	    func_warning "library \`$lib' was moved."
6520b68e1f86Smrg	    dir="$ladir"
6521b68e1f86Smrg	    absdir="$abs_ladir"
6522b68e1f86Smrg	    libdir="$abs_ladir"
6523b68e1f86Smrg	  else
65243bfa90b6Smrg	    dir="$lt_sysroot$libdir"
65253bfa90b6Smrg	    absdir="$lt_sysroot$libdir"
6526b68e1f86Smrg	  fi
6527b68e1f86Smrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
6528b68e1f86Smrg	else
6529b68e1f86Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6530b68e1f86Smrg	    dir="$ladir"
6531b68e1f86Smrg	    absdir="$abs_ladir"
6532b68e1f86Smrg	    # Remove this search path later
65333bfa90b6Smrg	    func_append notinst_path " $abs_ladir"
6534b68e1f86Smrg	  else
6535b68e1f86Smrg	    dir="$ladir/$objdir"
6536b68e1f86Smrg	    absdir="$abs_ladir/$objdir"
6537b68e1f86Smrg	    # Remove this search path later
65383bfa90b6Smrg	    func_append notinst_path " $abs_ladir"
6539b68e1f86Smrg	  fi
6540b68e1f86Smrg	fi # $installed = yes
6541b68e1f86Smrg	func_stripname 'lib' '.la' "$laname"
6542b68e1f86Smrg	name=$func_stripname_result
6543b68e1f86Smrg
6544b68e1f86Smrg	# This library was specified with -dlpreopen.
6545b68e1f86Smrg	if test "$pass" = dlpreopen; then
6546b68e1f86Smrg	  if test -z "$libdir" && test "$linkmode" = prog; then
6547b68e1f86Smrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
6548b68e1f86Smrg	  fi
65493bfa90b6Smrg	  case "$host" in
65503bfa90b6Smrg	    # special handling for platforms with PE-DLLs.
65513bfa90b6Smrg	    *cygwin* | *mingw* | *cegcc* )
65523bfa90b6Smrg	      # Linker will automatically link against shared library if both
65533bfa90b6Smrg	      # static and shared are present.  Therefore, ensure we extract
65543bfa90b6Smrg	      # symbols from the import library if a shared library is present
65553bfa90b6Smrg	      # (otherwise, the dlopen module name will be incorrect).  We do
65563bfa90b6Smrg	      # this by putting the import library name into $newdlprefiles.
65573bfa90b6Smrg	      # We recover the dlopen module name by 'saving' the la file
65583bfa90b6Smrg	      # name in a special purpose variable, and (later) extracting the
65593bfa90b6Smrg	      # dlname from the la file.
65603bfa90b6Smrg	      if test -n "$dlname"; then
65613bfa90b6Smrg	        func_tr_sh "$dir/$linklib"
65623bfa90b6Smrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
65633bfa90b6Smrg	        func_append newdlprefiles " $dir/$linklib"
65643bfa90b6Smrg	      else
65653bfa90b6Smrg	        func_append newdlprefiles " $dir/$old_library"
65663bfa90b6Smrg	        # Keep a list of preopened convenience libraries to check
65673bfa90b6Smrg	        # that they are being used correctly in the link pass.
65683bfa90b6Smrg	        test -z "$libdir" && \
65693bfa90b6Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
65703bfa90b6Smrg	      fi
65713bfa90b6Smrg	    ;;
65723bfa90b6Smrg	    * )
65733bfa90b6Smrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
65743bfa90b6Smrg	      # are required to link).
65753bfa90b6Smrg	      if test -n "$old_library"; then
65763bfa90b6Smrg	        func_append newdlprefiles " $dir/$old_library"
65773bfa90b6Smrg	        # Keep a list of preopened convenience libraries to check
65783bfa90b6Smrg	        # that they are being used correctly in the link pass.
65793bfa90b6Smrg	        test -z "$libdir" && \
65803bfa90b6Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
65813bfa90b6Smrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
65823bfa90b6Smrg	      elif test -n "$dlname"; then
65833bfa90b6Smrg	        func_append newdlprefiles " $dir/$dlname"
65843bfa90b6Smrg	      else
65853bfa90b6Smrg	        func_append newdlprefiles " $dir/$linklib"
65863bfa90b6Smrg	      fi
65873bfa90b6Smrg	    ;;
65883bfa90b6Smrg	  esac
6589b68e1f86Smrg	fi # $pass = dlpreopen
6590b68e1f86Smrg
6591b68e1f86Smrg	if test -z "$libdir"; then
6592b68e1f86Smrg	  # Link the convenience library
6593b68e1f86Smrg	  if test "$linkmode" = lib; then
6594b68e1f86Smrg	    deplibs="$dir/$old_library $deplibs"
6595b68e1f86Smrg	  elif test "$linkmode,$pass" = "prog,link"; then
6596b68e1f86Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
6597b68e1f86Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
6598b68e1f86Smrg	  else
6599b68e1f86Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
6600b68e1f86Smrg	  fi
6601b68e1f86Smrg	  continue
6602b68e1f86Smrg	fi
6603b68e1f86Smrg
6604b68e1f86Smrg
6605b68e1f86Smrg	if test "$linkmode" = prog && test "$pass" != link; then
66063bfa90b6Smrg	  func_append newlib_search_path " $ladir"
6607b68e1f86Smrg	  deplibs="$lib $deplibs"
6608b68e1f86Smrg
6609b68e1f86Smrg	  linkalldeplibs=no
6610b68e1f86Smrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
6611b68e1f86Smrg	     test "$build_libtool_libs" = no; then
6612b68e1f86Smrg	    linkalldeplibs=yes
6613b68e1f86Smrg	  fi
6614b68e1f86Smrg
6615b68e1f86Smrg	  tmp_libs=
6616b68e1f86Smrg	  for deplib in $dependency_libs; do
6617b68e1f86Smrg	    case $deplib in
6618b68e1f86Smrg	    -L*) func_stripname '-L' '' "$deplib"
66193bfa90b6Smrg	         func_resolve_sysroot "$func_stripname_result"
66203bfa90b6Smrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
6621b68e1f86Smrg		 ;;
6622b68e1f86Smrg	    esac
6623b68e1f86Smrg	    # Need to link against all dependency_libs?
6624b68e1f86Smrg	    if test "$linkalldeplibs" = yes; then
6625b68e1f86Smrg	      deplibs="$deplib $deplibs"
6626b68e1f86Smrg	    else
6627b68e1f86Smrg	      # Need to hardcode shared library paths
6628b68e1f86Smrg	      # or/and link against static libraries
6629b68e1f86Smrg	      newdependency_libs="$deplib $newdependency_libs"
6630b68e1f86Smrg	    fi
66313bfa90b6Smrg	    if $opt_preserve_dup_deps ; then
6632b68e1f86Smrg	      case "$tmp_libs " in
66333bfa90b6Smrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6634b68e1f86Smrg	      esac
6635b68e1f86Smrg	    fi
66363bfa90b6Smrg	    func_append tmp_libs " $deplib"
6637b68e1f86Smrg	  done # for deplib
6638b68e1f86Smrg	  continue
6639b68e1f86Smrg	fi # $linkmode = prog...
6640b68e1f86Smrg
6641b68e1f86Smrg	if test "$linkmode,$pass" = "prog,link"; then
6642b68e1f86Smrg	  if test -n "$library_names" &&
6643b68e1f86Smrg	     { { test "$prefer_static_libs" = no ||
6644b68e1f86Smrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
6645b68e1f86Smrg	       test -z "$old_library"; }; then
6646b68e1f86Smrg	    # We need to hardcode the library path
6647b68e1f86Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
6648b68e1f86Smrg	      # Make sure the rpath contains only unique directories.
6649b68e1f86Smrg	      case "$temp_rpath:" in
6650b68e1f86Smrg	      *"$absdir:"*) ;;
66513bfa90b6Smrg	      *) func_append temp_rpath "$absdir:" ;;
6652b68e1f86Smrg	      esac
6653b68e1f86Smrg	    fi
6654b68e1f86Smrg
6655b68e1f86Smrg	    # Hardcode the library path.
6656b68e1f86Smrg	    # Skip directories that are in the system default run-time
6657b68e1f86Smrg	    # search path.
6658b68e1f86Smrg	    case " $sys_lib_dlsearch_path " in
6659b68e1f86Smrg	    *" $absdir "*) ;;
6660b68e1f86Smrg	    *)
6661b68e1f86Smrg	      case "$compile_rpath " in
6662b68e1f86Smrg	      *" $absdir "*) ;;
66633bfa90b6Smrg	      *) func_append compile_rpath " $absdir" ;;
6664b68e1f86Smrg	      esac
6665b68e1f86Smrg	      ;;
6666b68e1f86Smrg	    esac
6667b68e1f86Smrg	    case " $sys_lib_dlsearch_path " in
6668b68e1f86Smrg	    *" $libdir "*) ;;
6669b68e1f86Smrg	    *)
6670b68e1f86Smrg	      case "$finalize_rpath " in
6671b68e1f86Smrg	      *" $libdir "*) ;;
66723bfa90b6Smrg	      *) func_append finalize_rpath " $libdir" ;;
6673b68e1f86Smrg	      esac
6674b68e1f86Smrg	      ;;
6675b68e1f86Smrg	    esac
6676b68e1f86Smrg	  fi # $linkmode,$pass = prog,link...
6677b68e1f86Smrg
6678b68e1f86Smrg	  if test "$alldeplibs" = yes &&
6679b68e1f86Smrg	     { test "$deplibs_check_method" = pass_all ||
6680b68e1f86Smrg	       { test "$build_libtool_libs" = yes &&
6681b68e1f86Smrg		 test -n "$library_names"; }; }; then
6682b68e1f86Smrg	    # We only need to search for static libraries
6683b68e1f86Smrg	    continue
6684b68e1f86Smrg	  fi
6685b68e1f86Smrg	fi
6686b68e1f86Smrg
6687b68e1f86Smrg	link_static=no # Whether the deplib will be linked statically
6688b68e1f86Smrg	use_static_libs=$prefer_static_libs
6689b68e1f86Smrg	if test "$use_static_libs" = built && test "$installed" = yes; then
6690b68e1f86Smrg	  use_static_libs=no
6691b68e1f86Smrg	fi
6692b68e1f86Smrg	if test -n "$library_names" &&
6693b68e1f86Smrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
6694b68e1f86Smrg	  case $host in
6695b68e1f86Smrg	  *cygwin* | *mingw* | *cegcc*)
6696b68e1f86Smrg	      # No point in relinking DLLs because paths are not encoded
66973bfa90b6Smrg	      func_append notinst_deplibs " $lib"
6698b68e1f86Smrg	      need_relink=no
6699b68e1f86Smrg	    ;;
6700b68e1f86Smrg	  *)
6701b68e1f86Smrg	    if test "$installed" = no; then
67023bfa90b6Smrg	      func_append notinst_deplibs " $lib"
6703b68e1f86Smrg	      need_relink=yes
6704b68e1f86Smrg	    fi
6705b68e1f86Smrg	    ;;
6706b68e1f86Smrg	  esac
6707b68e1f86Smrg	  # This is a shared library
6708b68e1f86Smrg
6709b68e1f86Smrg	  # Warn about portability, can't link against -module's on some
6710b68e1f86Smrg	  # systems (darwin).  Don't bleat about dlopened modules though!
6711b68e1f86Smrg	  dlopenmodule=""
6712b68e1f86Smrg	  for dlpremoduletest in $dlprefiles; do
6713b68e1f86Smrg	    if test "X$dlpremoduletest" = "X$lib"; then
6714b68e1f86Smrg	      dlopenmodule="$dlpremoduletest"
6715b68e1f86Smrg	      break
6716b68e1f86Smrg	    fi
6717b68e1f86Smrg	  done
6718b68e1f86Smrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
67193bfa90b6Smrg	    echo
6720b68e1f86Smrg	    if test "$linkmode" = prog; then
6721b68e1f86Smrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
6722b68e1f86Smrg	    else
6723b68e1f86Smrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
6724b68e1f86Smrg	    fi
6725b68e1f86Smrg	    $ECHO "*** $linklib is not portable!"
6726b68e1f86Smrg	  fi
6727b68e1f86Smrg	  if test "$linkmode" = lib &&
6728b68e1f86Smrg	     test "$hardcode_into_libs" = yes; then
6729b68e1f86Smrg	    # Hardcode the library path.
6730b68e1f86Smrg	    # Skip directories that are in the system default run-time
6731b68e1f86Smrg	    # search path.
6732b68e1f86Smrg	    case " $sys_lib_dlsearch_path " in
6733b68e1f86Smrg	    *" $absdir "*) ;;
6734b68e1f86Smrg	    *)
6735b68e1f86Smrg	      case "$compile_rpath " in
6736b68e1f86Smrg	      *" $absdir "*) ;;
67373bfa90b6Smrg	      *) func_append compile_rpath " $absdir" ;;
6738b68e1f86Smrg	      esac
6739b68e1f86Smrg	      ;;
6740b68e1f86Smrg	    esac
6741b68e1f86Smrg	    case " $sys_lib_dlsearch_path " in
6742b68e1f86Smrg	    *" $libdir "*) ;;
6743b68e1f86Smrg	    *)
6744b68e1f86Smrg	      case "$finalize_rpath " in
6745b68e1f86Smrg	      *" $libdir "*) ;;
67463bfa90b6Smrg	      *) func_append finalize_rpath " $libdir" ;;
6747b68e1f86Smrg	      esac
6748b68e1f86Smrg	      ;;
6749b68e1f86Smrg	    esac
6750b68e1f86Smrg	  fi
6751b68e1f86Smrg
6752b68e1f86Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
6753b68e1f86Smrg	    # figure out the soname
6754b68e1f86Smrg	    set dummy $library_names
6755b68e1f86Smrg	    shift
6756b68e1f86Smrg	    realname="$1"
6757b68e1f86Smrg	    shift
6758b68e1f86Smrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
6759b68e1f86Smrg	    # use dlname if we got it. it's perfectly good, no?
6760b68e1f86Smrg	    if test -n "$dlname"; then
6761b68e1f86Smrg	      soname="$dlname"
6762b68e1f86Smrg	    elif test -n "$soname_spec"; then
6763b68e1f86Smrg	      # bleh windows
6764b68e1f86Smrg	      case $host in
6765b68e1f86Smrg	      *cygwin* | mingw* | *cegcc*)
6766b68e1f86Smrg	        func_arith $current - $age
6767b68e1f86Smrg		major=$func_arith_result
6768b68e1f86Smrg		versuffix="-$major"
6769b68e1f86Smrg		;;
6770b68e1f86Smrg	      esac
6771b68e1f86Smrg	      eval soname=\"$soname_spec\"
6772b68e1f86Smrg	    else
6773b68e1f86Smrg	      soname="$realname"
6774b68e1f86Smrg	    fi
6775b68e1f86Smrg
6776b68e1f86Smrg	    # Make a new name for the extract_expsyms_cmds to use
6777b68e1f86Smrg	    soroot="$soname"
6778b68e1f86Smrg	    func_basename "$soroot"
6779b68e1f86Smrg	    soname="$func_basename_result"
6780b68e1f86Smrg	    func_stripname 'lib' '.dll' "$soname"
6781b68e1f86Smrg	    newlib=libimp-$func_stripname_result.a
6782b68e1f86Smrg
6783b68e1f86Smrg	    # If the library has no export list, then create one now
6784b68e1f86Smrg	    if test -f "$output_objdir/$soname-def"; then :
6785b68e1f86Smrg	    else
6786b68e1f86Smrg	      func_verbose "extracting exported symbol list from \`$soname'"
6787b68e1f86Smrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
6788b68e1f86Smrg	    fi
6789b68e1f86Smrg
6790b68e1f86Smrg	    # Create $newlib
6791b68e1f86Smrg	    if test -f "$output_objdir/$newlib"; then :; else
6792b68e1f86Smrg	      func_verbose "generating import library for \`$soname'"
6793b68e1f86Smrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
6794b68e1f86Smrg	    fi
6795b68e1f86Smrg	    # make sure the library variables are pointing to the new library
6796b68e1f86Smrg	    dir=$output_objdir
6797b68e1f86Smrg	    linklib=$newlib
6798b68e1f86Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
6799b68e1f86Smrg
68003bfa90b6Smrg	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
6801b68e1f86Smrg	    add_shlibpath=
6802b68e1f86Smrg	    add_dir=
6803b68e1f86Smrg	    add=
6804b68e1f86Smrg	    lib_linked=yes
6805b68e1f86Smrg	    case $hardcode_action in
6806b68e1f86Smrg	    immediate | unsupported)
6807b68e1f86Smrg	      if test "$hardcode_direct" = no; then
6808b68e1f86Smrg		add="$dir/$linklib"
6809b68e1f86Smrg		case $host in
6810b68e1f86Smrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
6811b68e1f86Smrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
6812b68e1f86Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
6813b68e1f86Smrg		    *-*-unixware7*) add_dir="-L$dir" ;;
6814b68e1f86Smrg		  *-*-darwin* )
6815b68e1f86Smrg		    # if the lib is a (non-dlopened) module then we can not
6816b68e1f86Smrg		    # link against it, someone is ignoring the earlier warnings
6817b68e1f86Smrg		    if /usr/bin/file -L $add 2> /dev/null |
6818b68e1f86Smrg			 $GREP ": [^:]* bundle" >/dev/null ; then
6819b68e1f86Smrg		      if test "X$dlopenmodule" != "X$lib"; then
6820b68e1f86Smrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
6821b68e1f86Smrg			if test -z "$old_library" ; then
68223bfa90b6Smrg			  echo
68233bfa90b6Smrg			  echo "*** And there doesn't seem to be a static archive available"
68243bfa90b6Smrg			  echo "*** The link will probably fail, sorry"
6825b68e1f86Smrg			else
6826b68e1f86Smrg			  add="$dir/$old_library"
6827b68e1f86Smrg			fi
6828b68e1f86Smrg		      elif test -n "$old_library"; then
6829b68e1f86Smrg			add="$dir/$old_library"
6830b68e1f86Smrg		      fi
6831b68e1f86Smrg		    fi
6832b68e1f86Smrg		esac
6833b68e1f86Smrg	      elif test "$hardcode_minus_L" = no; then
6834b68e1f86Smrg		case $host in
6835b68e1f86Smrg		*-*-sunos*) add_shlibpath="$dir" ;;
6836b68e1f86Smrg		esac
6837b68e1f86Smrg		add_dir="-L$dir"
6838b68e1f86Smrg		add="-l$name"
6839b68e1f86Smrg	      elif test "$hardcode_shlibpath_var" = no; then
6840b68e1f86Smrg		add_shlibpath="$dir"
6841b68e1f86Smrg		add="-l$name"
6842b68e1f86Smrg	      else
6843b68e1f86Smrg		lib_linked=no
6844b68e1f86Smrg	      fi
6845b68e1f86Smrg	      ;;
6846b68e1f86Smrg	    relink)
6847b68e1f86Smrg	      if test "$hardcode_direct" = yes &&
6848b68e1f86Smrg	         test "$hardcode_direct_absolute" = no; then
6849b68e1f86Smrg		add="$dir/$linklib"
6850b68e1f86Smrg	      elif test "$hardcode_minus_L" = yes; then
68513bfa90b6Smrg		add_dir="-L$absdir"
6852b68e1f86Smrg		# Try looking first in the location we're being installed to.
6853b68e1f86Smrg		if test -n "$inst_prefix_dir"; then
6854b68e1f86Smrg		  case $libdir in
6855b68e1f86Smrg		    [\\/]*)
68563bfa90b6Smrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
6857b68e1f86Smrg		      ;;
6858b68e1f86Smrg		  esac
6859b68e1f86Smrg		fi
6860b68e1f86Smrg		add="-l$name"
6861b68e1f86Smrg	      elif test "$hardcode_shlibpath_var" = yes; then
6862b68e1f86Smrg		add_shlibpath="$dir"
6863b68e1f86Smrg		add="-l$name"
6864b68e1f86Smrg	      else
6865b68e1f86Smrg		lib_linked=no
6866b68e1f86Smrg	      fi
6867b68e1f86Smrg	      ;;
6868b68e1f86Smrg	    *) lib_linked=no ;;
6869b68e1f86Smrg	    esac
6870b68e1f86Smrg
6871b68e1f86Smrg	    if test "$lib_linked" != yes; then
6872b68e1f86Smrg	      func_fatal_configuration "unsupported hardcode properties"
6873b68e1f86Smrg	    fi
6874b68e1f86Smrg
6875b68e1f86Smrg	    if test -n "$add_shlibpath"; then
6876b68e1f86Smrg	      case :$compile_shlibpath: in
6877b68e1f86Smrg	      *":$add_shlibpath:"*) ;;
68783bfa90b6Smrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
6879b68e1f86Smrg	      esac
6880b68e1f86Smrg	    fi
6881b68e1f86Smrg	    if test "$linkmode" = prog; then
6882b68e1f86Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
6883b68e1f86Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
6884b68e1f86Smrg	    else
6885b68e1f86Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6886b68e1f86Smrg	      test -n "$add" && deplibs="$add $deplibs"
6887b68e1f86Smrg	      if test "$hardcode_direct" != yes &&
6888b68e1f86Smrg		 test "$hardcode_minus_L" != yes &&
6889b68e1f86Smrg		 test "$hardcode_shlibpath_var" = yes; then
6890b68e1f86Smrg		case :$finalize_shlibpath: in
6891b68e1f86Smrg		*":$libdir:"*) ;;
68923bfa90b6Smrg		*) func_append finalize_shlibpath "$libdir:" ;;
6893b68e1f86Smrg		esac
6894b68e1f86Smrg	      fi
6895b68e1f86Smrg	    fi
6896b68e1f86Smrg	  fi
6897b68e1f86Smrg
68983bfa90b6Smrg	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
6899b68e1f86Smrg	    add_shlibpath=
6900b68e1f86Smrg	    add_dir=
6901b68e1f86Smrg	    add=
6902b68e1f86Smrg	    # Finalize command for both is simple: just hardcode it.
6903b68e1f86Smrg	    if test "$hardcode_direct" = yes &&
6904b68e1f86Smrg	       test "$hardcode_direct_absolute" = no; then
6905b68e1f86Smrg	      add="$libdir/$linklib"
6906b68e1f86Smrg	    elif test "$hardcode_minus_L" = yes; then
6907b68e1f86Smrg	      add_dir="-L$libdir"
6908b68e1f86Smrg	      add="-l$name"
6909b68e1f86Smrg	    elif test "$hardcode_shlibpath_var" = yes; then
6910b68e1f86Smrg	      case :$finalize_shlibpath: in
6911b68e1f86Smrg	      *":$libdir:"*) ;;
69123bfa90b6Smrg	      *) func_append finalize_shlibpath "$libdir:" ;;
6913b68e1f86Smrg	      esac
6914b68e1f86Smrg	      add="-l$name"
6915b68e1f86Smrg	    elif test "$hardcode_automatic" = yes; then
6916b68e1f86Smrg	      if test -n "$inst_prefix_dir" &&
6917b68e1f86Smrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
6918b68e1f86Smrg		add="$inst_prefix_dir$libdir/$linklib"
6919b68e1f86Smrg	      else
6920b68e1f86Smrg		add="$libdir/$linklib"
6921b68e1f86Smrg	      fi
6922b68e1f86Smrg	    else
6923b68e1f86Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
6924b68e1f86Smrg	      add_dir="-L$libdir"
6925b68e1f86Smrg	      # Try looking first in the location we're being installed to.
6926b68e1f86Smrg	      if test -n "$inst_prefix_dir"; then
6927b68e1f86Smrg		case $libdir in
6928b68e1f86Smrg		  [\\/]*)
69293bfa90b6Smrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
6930b68e1f86Smrg		    ;;
6931b68e1f86Smrg		esac
6932b68e1f86Smrg	      fi
6933b68e1f86Smrg	      add="-l$name"
6934b68e1f86Smrg	    fi
6935b68e1f86Smrg
6936b68e1f86Smrg	    if test "$linkmode" = prog; then
6937b68e1f86Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
6938b68e1f86Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
6939b68e1f86Smrg	    else
6940b68e1f86Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6941b68e1f86Smrg	      test -n "$add" && deplibs="$add $deplibs"
6942b68e1f86Smrg	    fi
6943b68e1f86Smrg	  fi
6944b68e1f86Smrg	elif test "$linkmode" = prog; then
6945b68e1f86Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
6946b68e1f86Smrg	  # is not unsupported.  This is valid on all known static and
6947b68e1f86Smrg	  # shared platforms.
6948b68e1f86Smrg	  if test "$hardcode_direct" != unsupported; then
6949b68e1f86Smrg	    test -n "$old_library" && linklib="$old_library"
6950b68e1f86Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
6951b68e1f86Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
6952b68e1f86Smrg	  else
6953b68e1f86Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
6954b68e1f86Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
6955b68e1f86Smrg	  fi
6956b68e1f86Smrg	elif test "$build_libtool_libs" = yes; then
6957b68e1f86Smrg	  # Not a shared library
6958b68e1f86Smrg	  if test "$deplibs_check_method" != pass_all; then
6959b68e1f86Smrg	    # We're trying link a shared library against a static one
6960b68e1f86Smrg	    # but the system doesn't support it.
6961b68e1f86Smrg
6962b68e1f86Smrg	    # Just print a warning and add the library to dependency_libs so
6963b68e1f86Smrg	    # that the program can be linked against the static library.
69643bfa90b6Smrg	    echo
6965b68e1f86Smrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
69663bfa90b6Smrg	    echo "*** I have the capability to make that library automatically link in when"
69673bfa90b6Smrg	    echo "*** you link to this library.  But I can only do this if you have a"
69683bfa90b6Smrg	    echo "*** shared version of the library, which you do not appear to have."
6969b68e1f86Smrg	    if test "$module" = yes; then
69703bfa90b6Smrg	      echo "*** But as you try to build a module library, libtool will still create "
69713bfa90b6Smrg	      echo "*** a static module, that should work as long as the dlopening application"
69723bfa90b6Smrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
6973b68e1f86Smrg	      if test -z "$global_symbol_pipe"; then
69743bfa90b6Smrg		echo
69753bfa90b6Smrg		echo "*** However, this would only work if libtool was able to extract symbol"
69763bfa90b6Smrg		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
69773bfa90b6Smrg		echo "*** not find such a program.  So, this module is probably useless."
69783bfa90b6Smrg		echo "*** \`nm' from GNU binutils and a full rebuild may help."
6979b68e1f86Smrg	      fi
6980b68e1f86Smrg	      if test "$build_old_libs" = no; then
6981b68e1f86Smrg		build_libtool_libs=module
6982b68e1f86Smrg		build_old_libs=yes
6983b68e1f86Smrg	      else
6984b68e1f86Smrg		build_libtool_libs=no
6985b68e1f86Smrg	      fi
6986b68e1f86Smrg	    fi
6987b68e1f86Smrg	  else
6988b68e1f86Smrg	    deplibs="$dir/$old_library $deplibs"
6989b68e1f86Smrg	    link_static=yes
6990b68e1f86Smrg	  fi
6991b68e1f86Smrg	fi # link shared/static library?
6992b68e1f86Smrg
6993b68e1f86Smrg	if test "$linkmode" = lib; then
6994b68e1f86Smrg	  if test -n "$dependency_libs" &&
6995b68e1f86Smrg	     { test "$hardcode_into_libs" != yes ||
6996b68e1f86Smrg	       test "$build_old_libs" = yes ||
6997b68e1f86Smrg	       test "$link_static" = yes; }; then
6998b68e1f86Smrg	    # Extract -R from dependency_libs
6999b68e1f86Smrg	    temp_deplibs=
7000b68e1f86Smrg	    for libdir in $dependency_libs; do
7001b68e1f86Smrg	      case $libdir in
7002b68e1f86Smrg	      -R*) func_stripname '-R' '' "$libdir"
7003b68e1f86Smrg	           temp_xrpath=$func_stripname_result
7004b68e1f86Smrg		   case " $xrpath " in
7005b68e1f86Smrg		   *" $temp_xrpath "*) ;;
70063bfa90b6Smrg		   *) func_append xrpath " $temp_xrpath";;
7007b68e1f86Smrg		   esac;;
70083bfa90b6Smrg	      *) func_append temp_deplibs " $libdir";;
7009b68e1f86Smrg	      esac
7010b68e1f86Smrg	    done
7011b68e1f86Smrg	    dependency_libs="$temp_deplibs"
7012b68e1f86Smrg	  fi
7013b68e1f86Smrg
70143bfa90b6Smrg	  func_append newlib_search_path " $absdir"
7015b68e1f86Smrg	  # Link against this library
7016b68e1f86Smrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
7017b68e1f86Smrg	  # ... and its dependency_libs
7018b68e1f86Smrg	  tmp_libs=
7019b68e1f86Smrg	  for deplib in $dependency_libs; do
7020b68e1f86Smrg	    newdependency_libs="$deplib $newdependency_libs"
70213bfa90b6Smrg	    case $deplib in
70223bfa90b6Smrg              -L*) func_stripname '-L' '' "$deplib"
70233bfa90b6Smrg                   func_resolve_sysroot "$func_stripname_result";;
70243bfa90b6Smrg              *) func_resolve_sysroot "$deplib" ;;
70253bfa90b6Smrg            esac
70263bfa90b6Smrg	    if $opt_preserve_dup_deps ; then
7027b68e1f86Smrg	      case "$tmp_libs " in
70283bfa90b6Smrg	      *" $func_resolve_sysroot_result "*)
70293bfa90b6Smrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
7030b68e1f86Smrg	      esac
7031b68e1f86Smrg	    fi
70323bfa90b6Smrg	    func_append tmp_libs " $func_resolve_sysroot_result"
7033b68e1f86Smrg	  done
7034b68e1f86Smrg
7035b68e1f86Smrg	  if test "$link_all_deplibs" != no; then
7036b68e1f86Smrg	    # Add the search paths of all dependency libraries
7037b68e1f86Smrg	    for deplib in $dependency_libs; do
70383bfa90b6Smrg	      path=
7039b68e1f86Smrg	      case $deplib in
7040b68e1f86Smrg	      -L*) path="$deplib" ;;
7041b68e1f86Smrg	      *.la)
70423bfa90b6Smrg	        func_resolve_sysroot "$deplib"
70433bfa90b6Smrg	        deplib=$func_resolve_sysroot_result
7044b68e1f86Smrg	        func_dirname "$deplib" "" "."
70453bfa90b6Smrg		dir=$func_dirname_result
7046b68e1f86Smrg		# We need an absolute path.
7047b68e1f86Smrg		case $dir in
7048b68e1f86Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
7049b68e1f86Smrg		*)
7050b68e1f86Smrg		  absdir=`cd "$dir" && pwd`
7051b68e1f86Smrg		  if test -z "$absdir"; then
7052b68e1f86Smrg		    func_warning "cannot determine absolute directory name of \`$dir'"
7053b68e1f86Smrg		    absdir="$dir"
7054b68e1f86Smrg		  fi
7055b68e1f86Smrg		  ;;
7056b68e1f86Smrg		esac
7057b68e1f86Smrg		if $GREP "^installed=no" $deplib > /dev/null; then
7058b68e1f86Smrg		case $host in
7059b68e1f86Smrg		*-*-darwin*)
7060b68e1f86Smrg		  depdepl=
7061b68e1f86Smrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
7062b68e1f86Smrg		  if test -n "$deplibrary_names" ; then
7063b68e1f86Smrg		    for tmp in $deplibrary_names ; do
7064b68e1f86Smrg		      depdepl=$tmp
7065b68e1f86Smrg		    done
7066b68e1f86Smrg		    if test -f "$absdir/$objdir/$depdepl" ; then
7067b68e1f86Smrg		      depdepl="$absdir/$objdir/$depdepl"
7068b68e1f86Smrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
7069b68e1f86Smrg                      if test -z "$darwin_install_name"; then
7070b68e1f86Smrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
7071b68e1f86Smrg                      fi
70723bfa90b6Smrg		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
70733bfa90b6Smrg		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
7074b68e1f86Smrg		      path=
7075b68e1f86Smrg		    fi
7076b68e1f86Smrg		  fi
7077b68e1f86Smrg		  ;;
7078b68e1f86Smrg		*)
7079b68e1f86Smrg		  path="-L$absdir/$objdir"
7080b68e1f86Smrg		  ;;
7081b68e1f86Smrg		esac
7082b68e1f86Smrg		else
7083b68e1f86Smrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
7084b68e1f86Smrg		  test -z "$libdir" && \
7085b68e1f86Smrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
7086b68e1f86Smrg		  test "$absdir" != "$libdir" && \
7087b68e1f86Smrg		    func_warning "\`$deplib' seems to be moved"
7088b68e1f86Smrg
7089b68e1f86Smrg		  path="-L$absdir"
7090b68e1f86Smrg		fi
7091b68e1f86Smrg		;;
7092b68e1f86Smrg	      esac
7093b68e1f86Smrg	      case " $deplibs " in
7094b68e1f86Smrg	      *" $path "*) ;;
7095b68e1f86Smrg	      *) deplibs="$path $deplibs" ;;
7096b68e1f86Smrg	      esac
7097b68e1f86Smrg	    done
7098b68e1f86Smrg	  fi # link_all_deplibs != no
7099b68e1f86Smrg	fi # linkmode = lib
7100b68e1f86Smrg      done # for deplib in $libs
7101b68e1f86Smrg      if test "$pass" = link; then
7102b68e1f86Smrg	if test "$linkmode" = "prog"; then
7103b68e1f86Smrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
7104b68e1f86Smrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
7105b68e1f86Smrg	else
71063bfa90b6Smrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7107b68e1f86Smrg	fi
7108b68e1f86Smrg      fi
7109b68e1f86Smrg      dependency_libs="$newdependency_libs"
7110b68e1f86Smrg      if test "$pass" = dlpreopen; then
7111b68e1f86Smrg	# Link the dlpreopened libraries before other libraries
7112b68e1f86Smrg	for deplib in $save_deplibs; do
7113b68e1f86Smrg	  deplibs="$deplib $deplibs"
7114b68e1f86Smrg	done
7115b68e1f86Smrg      fi
7116b68e1f86Smrg      if test "$pass" != dlopen; then
7117b68e1f86Smrg	if test "$pass" != conv; then
7118b68e1f86Smrg	  # Make sure lib_search_path contains only unique directories.
7119b68e1f86Smrg	  lib_search_path=
7120b68e1f86Smrg	  for dir in $newlib_search_path; do
7121b68e1f86Smrg	    case "$lib_search_path " in
7122b68e1f86Smrg	    *" $dir "*) ;;
71233bfa90b6Smrg	    *) func_append lib_search_path " $dir" ;;
7124b68e1f86Smrg	    esac
7125b68e1f86Smrg	  done
7126b68e1f86Smrg	  newlib_search_path=
7127b68e1f86Smrg	fi
7128b68e1f86Smrg
7129b68e1f86Smrg	if test "$linkmode,$pass" != "prog,link"; then
7130b68e1f86Smrg	  vars="deplibs"
7131b68e1f86Smrg	else
7132b68e1f86Smrg	  vars="compile_deplibs finalize_deplibs"
7133b68e1f86Smrg	fi
7134b68e1f86Smrg	for var in $vars dependency_libs; do
7135b68e1f86Smrg	  # Add libraries to $var in reverse order
7136b68e1f86Smrg	  eval tmp_libs=\"\$$var\"
7137b68e1f86Smrg	  new_libs=
7138b68e1f86Smrg	  for deplib in $tmp_libs; do
7139b68e1f86Smrg	    # FIXME: Pedantically, this is the right thing to do, so
7140b68e1f86Smrg	    #        that some nasty dependency loop isn't accidentally
7141b68e1f86Smrg	    #        broken:
7142b68e1f86Smrg	    #new_libs="$deplib $new_libs"
7143b68e1f86Smrg	    # Pragmatically, this seems to cause very few problems in
7144b68e1f86Smrg	    # practice:
7145b68e1f86Smrg	    case $deplib in
7146b68e1f86Smrg	    -L*) new_libs="$deplib $new_libs" ;;
7147b68e1f86Smrg	    -R*) ;;
7148b68e1f86Smrg	    *)
7149b68e1f86Smrg	      # And here is the reason: when a library appears more
7150b68e1f86Smrg	      # than once as an explicit dependence of a library, or
7151b68e1f86Smrg	      # is implicitly linked in more than once by the
7152b68e1f86Smrg	      # compiler, it is considered special, and multiple
7153b68e1f86Smrg	      # occurrences thereof are not removed.  Compare this
7154b68e1f86Smrg	      # with having the same library being listed as a
7155b68e1f86Smrg	      # dependency of multiple other libraries: in this case,
7156b68e1f86Smrg	      # we know (pedantically, we assume) the library does not
7157b68e1f86Smrg	      # need to be listed more than once, so we keep only the
7158b68e1f86Smrg	      # last copy.  This is not always right, but it is rare
7159b68e1f86Smrg	      # enough that we require users that really mean to play
7160b68e1f86Smrg	      # such unportable linking tricks to link the library
7161b68e1f86Smrg	      # using -Wl,-lname, so that libtool does not consider it
7162b68e1f86Smrg	      # for duplicate removal.
7163b68e1f86Smrg	      case " $specialdeplibs " in
7164b68e1f86Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
7165b68e1f86Smrg	      *)
7166b68e1f86Smrg		case " $new_libs " in
7167b68e1f86Smrg		*" $deplib "*) ;;
7168b68e1f86Smrg		*) new_libs="$deplib $new_libs" ;;
7169b68e1f86Smrg		esac
7170b68e1f86Smrg		;;
7171b68e1f86Smrg	      esac
7172b68e1f86Smrg	      ;;
7173b68e1f86Smrg	    esac
7174b68e1f86Smrg	  done
7175b68e1f86Smrg	  tmp_libs=
7176b68e1f86Smrg	  for deplib in $new_libs; do
7177b68e1f86Smrg	    case $deplib in
7178b68e1f86Smrg	    -L*)
7179b68e1f86Smrg	      case " $tmp_libs " in
7180b68e1f86Smrg	      *" $deplib "*) ;;
71813bfa90b6Smrg	      *) func_append tmp_libs " $deplib" ;;
7182b68e1f86Smrg	      esac
7183b68e1f86Smrg	      ;;
71843bfa90b6Smrg	    *) func_append tmp_libs " $deplib" ;;
7185b68e1f86Smrg	    esac
7186b68e1f86Smrg	  done
7187b68e1f86Smrg	  eval $var=\"$tmp_libs\"
7188b68e1f86Smrg	done # for var
7189b68e1f86Smrg      fi
7190b68e1f86Smrg      # Last step: remove runtime libs from dependency_libs
7191b68e1f86Smrg      # (they stay in deplibs)
7192b68e1f86Smrg      tmp_libs=
7193b68e1f86Smrg      for i in $dependency_libs ; do
7194b68e1f86Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
7195b68e1f86Smrg	*" $i "*)
7196b68e1f86Smrg	  i=""
7197b68e1f86Smrg	  ;;
7198b68e1f86Smrg	esac
7199b68e1f86Smrg	if test -n "$i" ; then
72003bfa90b6Smrg	  func_append tmp_libs " $i"
7201b68e1f86Smrg	fi
7202b68e1f86Smrg      done
7203b68e1f86Smrg      dependency_libs=$tmp_libs
7204b68e1f86Smrg    done # for pass
7205b68e1f86Smrg    if test "$linkmode" = prog; then
7206b68e1f86Smrg      dlfiles="$newdlfiles"
7207b68e1f86Smrg    fi
7208b68e1f86Smrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
7209b68e1f86Smrg      dlprefiles="$newdlprefiles"
7210b68e1f86Smrg    fi
7211b68e1f86Smrg
7212b68e1f86Smrg    case $linkmode in
7213b68e1f86Smrg    oldlib)
7214b68e1f86Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7215b68e1f86Smrg	func_warning "\`-dlopen' is ignored for archives"
7216b68e1f86Smrg      fi
7217b68e1f86Smrg
7218b68e1f86Smrg      case " $deplibs" in
7219b68e1f86Smrg      *\ -l* | *\ -L*)
7220b68e1f86Smrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
7221b68e1f86Smrg      esac
7222b68e1f86Smrg
7223b68e1f86Smrg      test -n "$rpath" && \
7224b68e1f86Smrg	func_warning "\`-rpath' is ignored for archives"
7225b68e1f86Smrg
7226b68e1f86Smrg      test -n "$xrpath" && \
7227b68e1f86Smrg	func_warning "\`-R' is ignored for archives"
7228b68e1f86Smrg
7229b68e1f86Smrg      test -n "$vinfo" && \
7230b68e1f86Smrg	func_warning "\`-version-info/-version-number' is ignored for archives"
7231b68e1f86Smrg
7232b68e1f86Smrg      test -n "$release" && \
7233b68e1f86Smrg	func_warning "\`-release' is ignored for archives"
7234b68e1f86Smrg
7235b68e1f86Smrg      test -n "$export_symbols$export_symbols_regex" && \
7236b68e1f86Smrg	func_warning "\`-export-symbols' is ignored for archives"
7237b68e1f86Smrg
7238b68e1f86Smrg      # Now set the variables for building old libraries.
7239b68e1f86Smrg      build_libtool_libs=no
7240b68e1f86Smrg      oldlibs="$output"
72413bfa90b6Smrg      func_append objs "$old_deplibs"
7242b68e1f86Smrg      ;;
7243b68e1f86Smrg
7244b68e1f86Smrg    lib)
7245b68e1f86Smrg      # Make sure we only generate libraries of the form `libNAME.la'.
7246b68e1f86Smrg      case $outputname in
7247b68e1f86Smrg      lib*)
7248b68e1f86Smrg	func_stripname 'lib' '.la' "$outputname"
7249b68e1f86Smrg	name=$func_stripname_result
7250b68e1f86Smrg	eval shared_ext=\"$shrext_cmds\"
7251b68e1f86Smrg	eval libname=\"$libname_spec\"
7252b68e1f86Smrg	;;
7253b68e1f86Smrg      *)
7254b68e1f86Smrg	test "$module" = no && \
7255b68e1f86Smrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
7256b68e1f86Smrg
7257b68e1f86Smrg	if test "$need_lib_prefix" != no; then
7258b68e1f86Smrg	  # Add the "lib" prefix for modules if required
7259b68e1f86Smrg	  func_stripname '' '.la' "$outputname"
7260b68e1f86Smrg	  name=$func_stripname_result
7261b68e1f86Smrg	  eval shared_ext=\"$shrext_cmds\"
7262b68e1f86Smrg	  eval libname=\"$libname_spec\"
7263b68e1f86Smrg	else
7264b68e1f86Smrg	  func_stripname '' '.la' "$outputname"
7265b68e1f86Smrg	  libname=$func_stripname_result
7266b68e1f86Smrg	fi
7267b68e1f86Smrg	;;
7268b68e1f86Smrg      esac
7269b68e1f86Smrg
7270b68e1f86Smrg      if test -n "$objs"; then
7271b68e1f86Smrg	if test "$deplibs_check_method" != pass_all; then
7272b68e1f86Smrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
7273b68e1f86Smrg	else
72743bfa90b6Smrg	  echo
7275b68e1f86Smrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
7276b68e1f86Smrg	  $ECHO "*** objects $objs is not portable!"
72773bfa90b6Smrg	  func_append libobjs " $objs"
7278b68e1f86Smrg	fi
7279b68e1f86Smrg      fi
7280b68e1f86Smrg
7281b68e1f86Smrg      test "$dlself" != no && \
7282b68e1f86Smrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
7283b68e1f86Smrg
7284b68e1f86Smrg      set dummy $rpath
7285b68e1f86Smrg      shift
7286b68e1f86Smrg      test "$#" -gt 1 && \
7287b68e1f86Smrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
7288b68e1f86Smrg
7289b68e1f86Smrg      install_libdir="$1"
7290b68e1f86Smrg
7291b68e1f86Smrg      oldlibs=
7292b68e1f86Smrg      if test -z "$rpath"; then
7293b68e1f86Smrg	if test "$build_libtool_libs" = yes; then
7294b68e1f86Smrg	  # Building a libtool convenience library.
7295b68e1f86Smrg	  # Some compilers have problems with a `.al' extension so
7296b68e1f86Smrg	  # convenience libraries should have the same extension an
7297b68e1f86Smrg	  # archive normally would.
7298b68e1f86Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
7299b68e1f86Smrg	  build_libtool_libs=convenience
7300b68e1f86Smrg	  build_old_libs=yes
7301b68e1f86Smrg	fi
7302b68e1f86Smrg
7303b68e1f86Smrg	test -n "$vinfo" && \
7304b68e1f86Smrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
7305b68e1f86Smrg
7306b68e1f86Smrg	test -n "$release" && \
7307b68e1f86Smrg	  func_warning "\`-release' is ignored for convenience libraries"
7308b68e1f86Smrg      else
7309b68e1f86Smrg
7310b68e1f86Smrg	# Parse the version information argument.
7311b68e1f86Smrg	save_ifs="$IFS"; IFS=':'
7312b68e1f86Smrg	set dummy $vinfo 0 0 0
7313b68e1f86Smrg	shift
7314b68e1f86Smrg	IFS="$save_ifs"
7315b68e1f86Smrg
7316b68e1f86Smrg	test -n "$7" && \
7317b68e1f86Smrg	  func_fatal_help "too many parameters to \`-version-info'"
7318b68e1f86Smrg
7319b68e1f86Smrg	# convert absolute version numbers to libtool ages
7320b68e1f86Smrg	# this retains compatibility with .la files and attempts
7321b68e1f86Smrg	# to make the code below a bit more comprehensible
7322b68e1f86Smrg
7323b68e1f86Smrg	case $vinfo_number in
7324b68e1f86Smrg	yes)
7325b68e1f86Smrg	  number_major="$1"
7326b68e1f86Smrg	  number_minor="$2"
7327b68e1f86Smrg	  number_revision="$3"
7328b68e1f86Smrg	  #
7329b68e1f86Smrg	  # There are really only two kinds -- those that
7330b68e1f86Smrg	  # use the current revision as the major version
7331b68e1f86Smrg	  # and those that subtract age and use age as
7332b68e1f86Smrg	  # a minor version.  But, then there is irix
7333b68e1f86Smrg	  # which has an extra 1 added just for fun
7334b68e1f86Smrg	  #
7335b68e1f86Smrg	  case $version_type in
73363bfa90b6Smrg	  # correct linux to gnu/linux during the next big refactor
7337b68e1f86Smrg	  darwin|linux|osf|windows|none)
7338b68e1f86Smrg	    func_arith $number_major + $number_minor
7339b68e1f86Smrg	    current=$func_arith_result
7340b68e1f86Smrg	    age="$number_minor"
7341b68e1f86Smrg	    revision="$number_revision"
7342b68e1f86Smrg	    ;;
73433bfa90b6Smrg	  freebsd-aout|freebsd-elf|qnx|sunos)
7344b68e1f86Smrg	    current="$number_major"
7345b68e1f86Smrg	    revision="$number_minor"
7346b68e1f86Smrg	    age="0"
7347b68e1f86Smrg	    ;;
7348b68e1f86Smrg	  irix|nonstopux)
7349b68e1f86Smrg	    func_arith $number_major + $number_minor
7350b68e1f86Smrg	    current=$func_arith_result
7351b68e1f86Smrg	    age="$number_minor"
7352b68e1f86Smrg	    revision="$number_minor"
7353b68e1f86Smrg	    lt_irix_increment=no
7354b68e1f86Smrg	    ;;
73553bfa90b6Smrg	  *)
73563bfa90b6Smrg	    func_fatal_configuration "$modename: unknown library version type \`$version_type'"
73573bfa90b6Smrg	    ;;
7358b68e1f86Smrg	  esac
7359b68e1f86Smrg	  ;;
7360b68e1f86Smrg	no)
7361b68e1f86Smrg	  current="$1"
7362b68e1f86Smrg	  revision="$2"
7363b68e1f86Smrg	  age="$3"
7364b68e1f86Smrg	  ;;
7365b68e1f86Smrg	esac
7366b68e1f86Smrg
7367b68e1f86Smrg	# Check that each of the things are valid numbers.
7368b68e1f86Smrg	case $current in
7369b68e1f86Smrg	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]) ;;
7370b68e1f86Smrg	*)
7371b68e1f86Smrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
7372b68e1f86Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
7373b68e1f86Smrg	  ;;
7374b68e1f86Smrg	esac
7375b68e1f86Smrg
7376b68e1f86Smrg	case $revision in
7377b68e1f86Smrg	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]) ;;
7378b68e1f86Smrg	*)
7379b68e1f86Smrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
7380b68e1f86Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
7381b68e1f86Smrg	  ;;
7382b68e1f86Smrg	esac
7383b68e1f86Smrg
7384b68e1f86Smrg	case $age in
7385b68e1f86Smrg	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]) ;;
7386b68e1f86Smrg	*)
7387b68e1f86Smrg	  func_error "AGE \`$age' must be a nonnegative integer"
7388b68e1f86Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
7389b68e1f86Smrg	  ;;
7390b68e1f86Smrg	esac
7391b68e1f86Smrg
7392b68e1f86Smrg	if test "$age" -gt "$current"; then
7393b68e1f86Smrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
7394b68e1f86Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
7395b68e1f86Smrg	fi
7396b68e1f86Smrg
7397b68e1f86Smrg	# Calculate the version variables.
7398b68e1f86Smrg	major=
7399b68e1f86Smrg	versuffix=
7400b68e1f86Smrg	verstring=
7401b68e1f86Smrg	case $version_type in
7402b68e1f86Smrg	none) ;;
7403b68e1f86Smrg
7404b68e1f86Smrg	darwin)
7405b68e1f86Smrg	  # Like Linux, but with the current version available in
7406b68e1f86Smrg	  # verstring for coding it into the library header
7407b68e1f86Smrg	  func_arith $current - $age
7408b68e1f86Smrg	  major=.$func_arith_result
7409b68e1f86Smrg	  versuffix="$major.$age.$revision"
7410b68e1f86Smrg	  # Darwin ld doesn't like 0 for these options...
7411b68e1f86Smrg	  func_arith $current + 1
7412b68e1f86Smrg	  minor_current=$func_arith_result
7413b68e1f86Smrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
7414b68e1f86Smrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
7415b68e1f86Smrg	  ;;
7416b68e1f86Smrg
7417b68e1f86Smrg	freebsd-aout)
7418b68e1f86Smrg	  major=".$current"
7419b68e1f86Smrg	  versuffix=".$current.$revision";
7420b68e1f86Smrg	  ;;
7421b68e1f86Smrg
7422b68e1f86Smrg	freebsd-elf)
7423b68e1f86Smrg	  major=".$current"
7424b68e1f86Smrg	  versuffix=".$current"
7425b68e1f86Smrg	  ;;
7426b68e1f86Smrg
7427b68e1f86Smrg	irix | nonstopux)
7428b68e1f86Smrg	  if test "X$lt_irix_increment" = "Xno"; then
7429b68e1f86Smrg	    func_arith $current - $age
7430b68e1f86Smrg	  else
7431b68e1f86Smrg	    func_arith $current - $age + 1
7432b68e1f86Smrg	  fi
7433b68e1f86Smrg	  major=$func_arith_result
7434b68e1f86Smrg
7435b68e1f86Smrg	  case $version_type in
7436b68e1f86Smrg	    nonstopux) verstring_prefix=nonstopux ;;
7437b68e1f86Smrg	    *)         verstring_prefix=sgi ;;
7438b68e1f86Smrg	  esac
7439b68e1f86Smrg	  verstring="$verstring_prefix$major.$revision"
7440b68e1f86Smrg
7441b68e1f86Smrg	  # Add in all the interfaces that we are compatible with.
7442b68e1f86Smrg	  loop=$revision
7443b68e1f86Smrg	  while test "$loop" -ne 0; do
7444b68e1f86Smrg	    func_arith $revision - $loop
7445b68e1f86Smrg	    iface=$func_arith_result
7446b68e1f86Smrg	    func_arith $loop - 1
7447b68e1f86Smrg	    loop=$func_arith_result
7448b68e1f86Smrg	    verstring="$verstring_prefix$major.$iface:$verstring"
7449b68e1f86Smrg	  done
7450b68e1f86Smrg
7451b68e1f86Smrg	  # Before this point, $major must not contain `.'.
7452b68e1f86Smrg	  major=.$major
7453b68e1f86Smrg	  versuffix="$major.$revision"
7454b68e1f86Smrg	  ;;
7455b68e1f86Smrg
74563bfa90b6Smrg	linux) # correct to gnu/linux during the next big refactor
7457b68e1f86Smrg	  func_arith $current - $age
7458b68e1f86Smrg	  major=.$func_arith_result
7459b68e1f86Smrg	  versuffix="$major.$age.$revision"
7460b68e1f86Smrg	  ;;
7461b68e1f86Smrg
7462b68e1f86Smrg	osf)
7463b68e1f86Smrg	  func_arith $current - $age
7464b68e1f86Smrg	  major=.$func_arith_result
7465b68e1f86Smrg	  versuffix=".$current.$age.$revision"
7466b68e1f86Smrg	  verstring="$current.$age.$revision"
7467b68e1f86Smrg
7468b68e1f86Smrg	  # Add in all the interfaces that we are compatible with.
7469b68e1f86Smrg	  loop=$age
7470b68e1f86Smrg	  while test "$loop" -ne 0; do
7471b68e1f86Smrg	    func_arith $current - $loop
7472b68e1f86Smrg	    iface=$func_arith_result
7473b68e1f86Smrg	    func_arith $loop - 1
7474b68e1f86Smrg	    loop=$func_arith_result
7475b68e1f86Smrg	    verstring="$verstring:${iface}.0"
7476b68e1f86Smrg	  done
7477b68e1f86Smrg
7478b68e1f86Smrg	  # Make executables depend on our current version.
74793bfa90b6Smrg	  func_append verstring ":${current}.0"
7480b68e1f86Smrg	  ;;
7481b68e1f86Smrg
7482b68e1f86Smrg	qnx)
7483b68e1f86Smrg	  major=".$current"
7484b68e1f86Smrg	  versuffix=".$current"
7485b68e1f86Smrg	  ;;
7486b68e1f86Smrg
7487b68e1f86Smrg	sunos)
7488b68e1f86Smrg	  major=".$current"
7489b68e1f86Smrg	  versuffix=".$current.$revision"
7490b68e1f86Smrg	  ;;
7491b68e1f86Smrg
7492b68e1f86Smrg	windows)
7493b68e1f86Smrg	  # Use '-' rather than '.', since we only want one
7494b68e1f86Smrg	  # extension on DOS 8.3 filesystems.
7495b68e1f86Smrg	  func_arith $current - $age
7496b68e1f86Smrg	  major=$func_arith_result
7497b68e1f86Smrg	  versuffix="-$major"
7498b68e1f86Smrg	  ;;
7499b68e1f86Smrg
7500b68e1f86Smrg	*)
7501b68e1f86Smrg	  func_fatal_configuration "unknown library version type \`$version_type'"
7502b68e1f86Smrg	  ;;
7503b68e1f86Smrg	esac
7504b68e1f86Smrg
7505b68e1f86Smrg	# Clear the version info if we defaulted, and they specified a release.
7506b68e1f86Smrg	if test -z "$vinfo" && test -n "$release"; then
7507b68e1f86Smrg	  major=
7508b68e1f86Smrg	  case $version_type in
7509b68e1f86Smrg	  darwin)
7510b68e1f86Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
7511b68e1f86Smrg	    # problems, so we reset it completely
7512b68e1f86Smrg	    verstring=
7513b68e1f86Smrg	    ;;
7514b68e1f86Smrg	  *)
7515b68e1f86Smrg	    verstring="0.0"
7516b68e1f86Smrg	    ;;
7517b68e1f86Smrg	  esac
7518b68e1f86Smrg	  if test "$need_version" = no; then
7519b68e1f86Smrg	    versuffix=
7520b68e1f86Smrg	  else
7521b68e1f86Smrg	    versuffix=".0.0"
7522b68e1f86Smrg	  fi
7523b68e1f86Smrg	fi
7524b68e1f86Smrg
7525b68e1f86Smrg	# Remove version info from name if versioning should be avoided
7526b68e1f86Smrg	if test "$avoid_version" = yes && test "$need_version" = no; then
7527b68e1f86Smrg	  major=
7528b68e1f86Smrg	  versuffix=
7529b68e1f86Smrg	  verstring=""
7530b68e1f86Smrg	fi
7531b68e1f86Smrg
7532b68e1f86Smrg	# Check to see if the archive will have undefined symbols.
7533b68e1f86Smrg	if test "$allow_undefined" = yes; then
7534b68e1f86Smrg	  if test "$allow_undefined_flag" = unsupported; then
7535b68e1f86Smrg	    func_warning "undefined symbols not allowed in $host shared libraries"
7536b68e1f86Smrg	    build_libtool_libs=no
7537b68e1f86Smrg	    build_old_libs=yes
7538b68e1f86Smrg	  fi
7539b68e1f86Smrg	else
7540b68e1f86Smrg	  # Don't allow undefined symbols.
7541b68e1f86Smrg	  allow_undefined_flag="$no_undefined_flag"
7542b68e1f86Smrg	fi
7543b68e1f86Smrg
7544b68e1f86Smrg      fi
7545b68e1f86Smrg
7546b68e1f86Smrg      func_generate_dlsyms "$libname" "$libname" "yes"
75473bfa90b6Smrg      func_append libobjs " $symfileobj"
7548b68e1f86Smrg      test "X$libobjs" = "X " && libobjs=
7549b68e1f86Smrg
75503bfa90b6Smrg      if test "$opt_mode" != relink; then
7551b68e1f86Smrg	# Remove our outputs, but don't remove object files since they
7552b68e1f86Smrg	# may have been created when compiling PIC objects.
7553b68e1f86Smrg	removelist=
7554b68e1f86Smrg	tempremovelist=`$ECHO "$output_objdir/*"`
7555b68e1f86Smrg	for p in $tempremovelist; do
7556b68e1f86Smrg	  case $p in
7557b68e1f86Smrg	    *.$objext | *.gcno)
7558b68e1f86Smrg	       ;;
7559b68e1f86Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
7560b68e1f86Smrg	       if test "X$precious_files_regex" != "X"; then
7561b68e1f86Smrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
7562b68e1f86Smrg		 then
7563b68e1f86Smrg		   continue
7564b68e1f86Smrg		 fi
7565b68e1f86Smrg	       fi
75663bfa90b6Smrg	       func_append removelist " $p"
7567b68e1f86Smrg	       ;;
7568b68e1f86Smrg	    *) ;;
7569b68e1f86Smrg	  esac
7570b68e1f86Smrg	done
7571b68e1f86Smrg	test -n "$removelist" && \
7572b68e1f86Smrg	  func_show_eval "${RM}r \$removelist"
7573b68e1f86Smrg      fi
7574b68e1f86Smrg
7575b68e1f86Smrg      # Now set the variables for building old libraries.
7576b68e1f86Smrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
75773bfa90b6Smrg	func_append oldlibs " $output_objdir/$libname.$libext"
7578b68e1f86Smrg
7579b68e1f86Smrg	# Transform .lo files to .o files.
75803bfa90b6Smrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
7581b68e1f86Smrg      fi
7582b68e1f86Smrg
7583b68e1f86Smrg      # Eliminate all temporary directories.
7584b68e1f86Smrg      #for path in $notinst_path; do
75853bfa90b6Smrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
75863bfa90b6Smrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
75873bfa90b6Smrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
7588b68e1f86Smrg      #done
7589b68e1f86Smrg
7590b68e1f86Smrg      if test -n "$xrpath"; then
7591b68e1f86Smrg	# If the user specified any rpath flags, then add them.
7592b68e1f86Smrg	temp_xrpath=
7593b68e1f86Smrg	for libdir in $xrpath; do
75943bfa90b6Smrg	  func_replace_sysroot "$libdir"
75953bfa90b6Smrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
7596b68e1f86Smrg	  case "$finalize_rpath " in
7597b68e1f86Smrg	  *" $libdir "*) ;;
75983bfa90b6Smrg	  *) func_append finalize_rpath " $libdir" ;;
7599b68e1f86Smrg	  esac
7600b68e1f86Smrg	done
7601b68e1f86Smrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
7602b68e1f86Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
7603b68e1f86Smrg	fi
7604b68e1f86Smrg      fi
7605b68e1f86Smrg
7606b68e1f86Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
7607b68e1f86Smrg      old_dlfiles="$dlfiles"
7608b68e1f86Smrg      dlfiles=
7609b68e1f86Smrg      for lib in $old_dlfiles; do
7610b68e1f86Smrg	case " $dlprefiles $dlfiles " in
7611b68e1f86Smrg	*" $lib "*) ;;
76123bfa90b6Smrg	*) func_append dlfiles " $lib" ;;
7613b68e1f86Smrg	esac
7614b68e1f86Smrg      done
7615b68e1f86Smrg
7616b68e1f86Smrg      # Make sure dlprefiles contains only unique files
7617b68e1f86Smrg      old_dlprefiles="$dlprefiles"
7618b68e1f86Smrg      dlprefiles=
7619b68e1f86Smrg      for lib in $old_dlprefiles; do
7620b68e1f86Smrg	case "$dlprefiles " in
7621b68e1f86Smrg	*" $lib "*) ;;
76223bfa90b6Smrg	*) func_append dlprefiles " $lib" ;;
7623b68e1f86Smrg	esac
7624b68e1f86Smrg      done
7625b68e1f86Smrg
7626b68e1f86Smrg      if test "$build_libtool_libs" = yes; then
7627b68e1f86Smrg	if test -n "$rpath"; then
7628b68e1f86Smrg	  case $host in
76293bfa90b6Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
7630b68e1f86Smrg	    # these systems don't actually have a c library (as such)!
7631b68e1f86Smrg	    ;;
7632b68e1f86Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
7633b68e1f86Smrg	    # Rhapsody C library is in the System framework
76343bfa90b6Smrg	    func_append deplibs " System.ltframework"
7635b68e1f86Smrg	    ;;
7636b68e1f86Smrg	  *-*-netbsd*)
7637b68e1f86Smrg	    # Don't link with libc until the a.out ld.so is fixed.
7638b68e1f86Smrg	    ;;
7639b68e1f86Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
7640b68e1f86Smrg	    # Do not include libc due to us having libc/libc_r.
7641b68e1f86Smrg	    ;;
7642b68e1f86Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
7643b68e1f86Smrg	    # Causes problems with __ctype
7644b68e1f86Smrg	    ;;
7645b68e1f86Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7646b68e1f86Smrg	    # Compiler inserts libc in the correct place for threads to work
7647b68e1f86Smrg	    ;;
7648b68e1f86Smrg	  *)
7649b68e1f86Smrg	    # Add libc to deplibs on all other systems if necessary.
7650b68e1f86Smrg	    if test "$build_libtool_need_lc" = "yes"; then
76513bfa90b6Smrg	      func_append deplibs " -lc"
7652b68e1f86Smrg	    fi
7653b68e1f86Smrg	    ;;
7654b68e1f86Smrg	  esac
7655b68e1f86Smrg	fi
7656b68e1f86Smrg
7657b68e1f86Smrg	# Transform deplibs into only deplibs that can be linked in shared.
7658b68e1f86Smrg	name_save=$name
7659b68e1f86Smrg	libname_save=$libname
7660b68e1f86Smrg	release_save=$release
7661b68e1f86Smrg	versuffix_save=$versuffix
7662b68e1f86Smrg	major_save=$major
7663b68e1f86Smrg	# I'm not sure if I'm treating the release correctly.  I think
7664b68e1f86Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
7665b68e1f86Smrg	# add it in twice.  Is that correct?
7666b68e1f86Smrg	release=""
7667b68e1f86Smrg	versuffix=""
7668b68e1f86Smrg	major=""
7669b68e1f86Smrg	newdeplibs=
7670b68e1f86Smrg	droppeddeps=no
7671b68e1f86Smrg	case $deplibs_check_method in
7672b68e1f86Smrg	pass_all)
7673b68e1f86Smrg	  # Don't check for shared/static.  Everything works.
7674b68e1f86Smrg	  # This might be a little naive.  We might want to check
7675b68e1f86Smrg	  # whether the library exists or not.  But this is on
7676b68e1f86Smrg	  # osf3 & osf4 and I'm not really sure... Just
7677b68e1f86Smrg	  # implementing what was already the behavior.
7678b68e1f86Smrg	  newdeplibs=$deplibs
7679b68e1f86Smrg	  ;;
7680b68e1f86Smrg	test_compile)
7681b68e1f86Smrg	  # This code stresses the "libraries are programs" paradigm to its
7682b68e1f86Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
7683b68e1f86Smrg	  # against the deplibs as a proxy for the library.  Then we can check
7684b68e1f86Smrg	  # whether they linked in statically or dynamically with ldd.
7685b68e1f86Smrg	  $opt_dry_run || $RM conftest.c
7686b68e1f86Smrg	  cat > conftest.c <<EOF
7687b68e1f86Smrg	  int main() { return 0; }
7688b68e1f86SmrgEOF
7689b68e1f86Smrg	  $opt_dry_run || $RM conftest
7690b68e1f86Smrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
7691b68e1f86Smrg	    ldd_output=`ldd conftest`
7692b68e1f86Smrg	    for i in $deplibs; do
7693b68e1f86Smrg	      case $i in
7694b68e1f86Smrg	      -l*)
7695b68e1f86Smrg		func_stripname -l '' "$i"
7696b68e1f86Smrg		name=$func_stripname_result
7697b68e1f86Smrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7698b68e1f86Smrg		  case " $predeps $postdeps " in
7699b68e1f86Smrg		  *" $i "*)
77003bfa90b6Smrg		    func_append newdeplibs " $i"
7701b68e1f86Smrg		    i=""
7702b68e1f86Smrg		    ;;
7703b68e1f86Smrg		  esac
7704b68e1f86Smrg		fi
7705b68e1f86Smrg		if test -n "$i" ; then
7706b68e1f86Smrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
7707b68e1f86Smrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7708b68e1f86Smrg		  set dummy $deplib_matches; shift
7709b68e1f86Smrg		  deplib_match=$1
7710b68e1f86Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
77113bfa90b6Smrg		    func_append newdeplibs " $i"
7712b68e1f86Smrg		  else
7713b68e1f86Smrg		    droppeddeps=yes
77143bfa90b6Smrg		    echo
7715b68e1f86Smrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
77163bfa90b6Smrg		    echo "*** I have the capability to make that library automatically link in when"
77173bfa90b6Smrg		    echo "*** you link to this library.  But I can only do this if you have a"
77183bfa90b6Smrg		    echo "*** shared version of the library, which I believe you do not have"
77193bfa90b6Smrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
77203bfa90b6Smrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
7721b68e1f86Smrg		  fi
7722b68e1f86Smrg		fi
7723b68e1f86Smrg		;;
7724b68e1f86Smrg	      *)
77253bfa90b6Smrg		func_append newdeplibs " $i"
7726b68e1f86Smrg		;;
7727b68e1f86Smrg	      esac
7728b68e1f86Smrg	    done
7729b68e1f86Smrg	  else
7730b68e1f86Smrg	    # Error occurred in the first compile.  Let's try to salvage
7731b68e1f86Smrg	    # the situation: Compile a separate program for each library.
7732b68e1f86Smrg	    for i in $deplibs; do
7733b68e1f86Smrg	      case $i in
7734b68e1f86Smrg	      -l*)
7735b68e1f86Smrg		func_stripname -l '' "$i"
7736b68e1f86Smrg		name=$func_stripname_result
7737b68e1f86Smrg		$opt_dry_run || $RM conftest
7738b68e1f86Smrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
7739b68e1f86Smrg		  ldd_output=`ldd conftest`
7740b68e1f86Smrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7741b68e1f86Smrg		    case " $predeps $postdeps " in
7742b68e1f86Smrg		    *" $i "*)
77433bfa90b6Smrg		      func_append newdeplibs " $i"
7744b68e1f86Smrg		      i=""
7745b68e1f86Smrg		      ;;
7746b68e1f86Smrg		    esac
7747b68e1f86Smrg		  fi
7748b68e1f86Smrg		  if test -n "$i" ; then
7749b68e1f86Smrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
7750b68e1f86Smrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7751b68e1f86Smrg		    set dummy $deplib_matches; shift
7752b68e1f86Smrg		    deplib_match=$1
7753b68e1f86Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
77543bfa90b6Smrg		      func_append newdeplibs " $i"
7755b68e1f86Smrg		    else
7756b68e1f86Smrg		      droppeddeps=yes
77573bfa90b6Smrg		      echo
7758b68e1f86Smrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
77593bfa90b6Smrg		      echo "*** I have the capability to make that library automatically link in when"
77603bfa90b6Smrg		      echo "*** you link to this library.  But I can only do this if you have a"
77613bfa90b6Smrg		      echo "*** shared version of the library, which you do not appear to have"
77623bfa90b6Smrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
77633bfa90b6Smrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
7764b68e1f86Smrg		    fi
7765b68e1f86Smrg		  fi
7766b68e1f86Smrg		else
7767b68e1f86Smrg		  droppeddeps=yes
77683bfa90b6Smrg		  echo
7769b68e1f86Smrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
77703bfa90b6Smrg		  echo "*** make it link in!  You will probably need to install it or some"
77713bfa90b6Smrg		  echo "*** library that it depends on before this library will be fully"
77723bfa90b6Smrg		  echo "*** functional.  Installing it before continuing would be even better."
7773b68e1f86Smrg		fi
7774b68e1f86Smrg		;;
7775b68e1f86Smrg	      *)
77763bfa90b6Smrg		func_append newdeplibs " $i"
7777b68e1f86Smrg		;;
7778b68e1f86Smrg	      esac
7779b68e1f86Smrg	    done
7780b68e1f86Smrg	  fi
7781b68e1f86Smrg	  ;;
7782b68e1f86Smrg	file_magic*)
7783b68e1f86Smrg	  set dummy $deplibs_check_method; shift
7784b68e1f86Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7785b68e1f86Smrg	  for a_deplib in $deplibs; do
7786b68e1f86Smrg	    case $a_deplib in
7787b68e1f86Smrg	    -l*)
7788b68e1f86Smrg	      func_stripname -l '' "$a_deplib"
7789b68e1f86Smrg	      name=$func_stripname_result
7790b68e1f86Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7791b68e1f86Smrg		case " $predeps $postdeps " in
7792b68e1f86Smrg		*" $a_deplib "*)
77933bfa90b6Smrg		  func_append newdeplibs " $a_deplib"
7794b68e1f86Smrg		  a_deplib=""
7795b68e1f86Smrg		  ;;
7796b68e1f86Smrg		esac
7797b68e1f86Smrg	      fi
7798b68e1f86Smrg	      if test -n "$a_deplib" ; then
7799b68e1f86Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
78003bfa90b6Smrg		if test -n "$file_magic_glob"; then
78013bfa90b6Smrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
78023bfa90b6Smrg		else
78033bfa90b6Smrg		  libnameglob=$libname
78043bfa90b6Smrg		fi
78053bfa90b6Smrg		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
7806b68e1f86Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
78073bfa90b6Smrg		  if test "$want_nocaseglob" = yes; then
78083bfa90b6Smrg		    shopt -s nocaseglob
78093bfa90b6Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
78103bfa90b6Smrg		    $nocaseglob
78113bfa90b6Smrg		  else
78123bfa90b6Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
78133bfa90b6Smrg		  fi
7814b68e1f86Smrg		  for potent_lib in $potential_libs; do
7815b68e1f86Smrg		      # Follow soft links.
7816b68e1f86Smrg		      if ls -lLd "$potent_lib" 2>/dev/null |
7817b68e1f86Smrg			 $GREP " -> " >/dev/null; then
7818b68e1f86Smrg			continue
7819b68e1f86Smrg		      fi
7820b68e1f86Smrg		      # The statement above tries to avoid entering an
7821b68e1f86Smrg		      # endless loop below, in case of cyclic links.
7822b68e1f86Smrg		      # We might still enter an endless loop, since a link
7823b68e1f86Smrg		      # loop can be closed while we follow links,
7824b68e1f86Smrg		      # but so what?
7825b68e1f86Smrg		      potlib="$potent_lib"
7826b68e1f86Smrg		      while test -h "$potlib" 2>/dev/null; do
7827b68e1f86Smrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
7828b68e1f86Smrg			case $potliblink in
7829b68e1f86Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
78303bfa90b6Smrg			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
7831b68e1f86Smrg			esac
7832b68e1f86Smrg		      done
7833b68e1f86Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
7834b68e1f86Smrg			 $SED -e 10q |
7835b68e1f86Smrg			 $EGREP "$file_magic_regex" > /dev/null; then
78363bfa90b6Smrg			func_append newdeplibs " $a_deplib"
7837b68e1f86Smrg			a_deplib=""
7838b68e1f86Smrg			break 2
7839b68e1f86Smrg		      fi
7840b68e1f86Smrg		  done
7841b68e1f86Smrg		done
7842b68e1f86Smrg	      fi
7843b68e1f86Smrg	      if test -n "$a_deplib" ; then
7844b68e1f86Smrg		droppeddeps=yes
78453bfa90b6Smrg		echo
7846b68e1f86Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
78473bfa90b6Smrg		echo "*** I have the capability to make that library automatically link in when"
78483bfa90b6Smrg		echo "*** you link to this library.  But I can only do this if you have a"
78493bfa90b6Smrg		echo "*** shared version of the library, which you do not appear to have"
78503bfa90b6Smrg		echo "*** because I did check the linker path looking for a file starting"
7851b68e1f86Smrg		if test -z "$potlib" ; then
7852b68e1f86Smrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
7853b68e1f86Smrg		else
7854b68e1f86Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7855b68e1f86Smrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
7856b68e1f86Smrg		fi
7857b68e1f86Smrg	      fi
7858b68e1f86Smrg	      ;;
7859b68e1f86Smrg	    *)
7860b68e1f86Smrg	      # Add a -L argument.
78613bfa90b6Smrg	      func_append newdeplibs " $a_deplib"
7862b68e1f86Smrg	      ;;
7863b68e1f86Smrg	    esac
7864b68e1f86Smrg	  done # Gone through all deplibs.
7865b68e1f86Smrg	  ;;
7866b68e1f86Smrg	match_pattern*)
7867b68e1f86Smrg	  set dummy $deplibs_check_method; shift
7868b68e1f86Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7869b68e1f86Smrg	  for a_deplib in $deplibs; do
7870b68e1f86Smrg	    case $a_deplib in
7871b68e1f86Smrg	    -l*)
7872b68e1f86Smrg	      func_stripname -l '' "$a_deplib"
7873b68e1f86Smrg	      name=$func_stripname_result
7874b68e1f86Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7875b68e1f86Smrg		case " $predeps $postdeps " in
7876b68e1f86Smrg		*" $a_deplib "*)
78773bfa90b6Smrg		  func_append newdeplibs " $a_deplib"
7878b68e1f86Smrg		  a_deplib=""
7879b68e1f86Smrg		  ;;
7880b68e1f86Smrg		esac
7881b68e1f86Smrg	      fi
7882b68e1f86Smrg	      if test -n "$a_deplib" ; then
7883b68e1f86Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
7884b68e1f86Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7885b68e1f86Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
7886b68e1f86Smrg		  for potent_lib in $potential_libs; do
7887b68e1f86Smrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
78883bfa90b6Smrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
7889b68e1f86Smrg		       $EGREP "$match_pattern_regex" > /dev/null; then
78903bfa90b6Smrg		      func_append newdeplibs " $a_deplib"
7891b68e1f86Smrg		      a_deplib=""
7892b68e1f86Smrg		      break 2
7893b68e1f86Smrg		    fi
7894b68e1f86Smrg		  done
7895b68e1f86Smrg		done
7896b68e1f86Smrg	      fi
7897b68e1f86Smrg	      if test -n "$a_deplib" ; then
7898b68e1f86Smrg		droppeddeps=yes
78993bfa90b6Smrg		echo
7900b68e1f86Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
79013bfa90b6Smrg		echo "*** I have the capability to make that library automatically link in when"
79023bfa90b6Smrg		echo "*** you link to this library.  But I can only do this if you have a"
79033bfa90b6Smrg		echo "*** shared version of the library, which you do not appear to have"
79043bfa90b6Smrg		echo "*** because I did check the linker path looking for a file starting"
7905b68e1f86Smrg		if test -z "$potlib" ; then
7906b68e1f86Smrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
7907b68e1f86Smrg		else
7908b68e1f86Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7909b68e1f86Smrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
7910b68e1f86Smrg		fi
7911b68e1f86Smrg	      fi
7912b68e1f86Smrg	      ;;
7913b68e1f86Smrg	    *)
7914b68e1f86Smrg	      # Add a -L argument.
79153bfa90b6Smrg	      func_append newdeplibs " $a_deplib"
7916b68e1f86Smrg	      ;;
7917b68e1f86Smrg	    esac
7918b68e1f86Smrg	  done # Gone through all deplibs.
7919b68e1f86Smrg	  ;;
7920b68e1f86Smrg	none | unknown | *)
7921b68e1f86Smrg	  newdeplibs=""
79223bfa90b6Smrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
7923b68e1f86Smrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7924b68e1f86Smrg	    for i in $predeps $postdeps ; do
7925b68e1f86Smrg	      # can't use Xsed below, because $i might contain '/'
79263bfa90b6Smrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
7927b68e1f86Smrg	    done
7928b68e1f86Smrg	  fi
79293bfa90b6Smrg	  case $tmp_deplibs in
79303bfa90b6Smrg	  *[!\	\ ]*)
79313bfa90b6Smrg	    echo
7932b68e1f86Smrg	    if test "X$deplibs_check_method" = "Xnone"; then
79333bfa90b6Smrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
7934b68e1f86Smrg	    else
79353bfa90b6Smrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
7936b68e1f86Smrg	    fi
79373bfa90b6Smrg	    echo "*** All declared inter-library dependencies are being dropped."
7938b68e1f86Smrg	    droppeddeps=yes
79393bfa90b6Smrg	    ;;
79403bfa90b6Smrg	  esac
7941b68e1f86Smrg	  ;;
7942b68e1f86Smrg	esac
7943b68e1f86Smrg	versuffix=$versuffix_save
7944b68e1f86Smrg	major=$major_save
7945b68e1f86Smrg	release=$release_save
7946b68e1f86Smrg	libname=$libname_save
7947b68e1f86Smrg	name=$name_save
7948b68e1f86Smrg
7949b68e1f86Smrg	case $host in
7950b68e1f86Smrg	*-*-rhapsody* | *-*-darwin1.[012])
7951b68e1f86Smrg	  # On Rhapsody replace the C library with the System framework
79523bfa90b6Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
7953b68e1f86Smrg	  ;;
7954b68e1f86Smrg	esac
7955b68e1f86Smrg
7956b68e1f86Smrg	if test "$droppeddeps" = yes; then
7957b68e1f86Smrg	  if test "$module" = yes; then
79583bfa90b6Smrg	    echo
79593bfa90b6Smrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
7960b68e1f86Smrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
79613bfa90b6Smrg	    echo "*** a static module, that should work as long as the dlopening"
79623bfa90b6Smrg	    echo "*** application is linked with the -dlopen flag."
7963b68e1f86Smrg	    if test -z "$global_symbol_pipe"; then
79643bfa90b6Smrg	      echo
79653bfa90b6Smrg	      echo "*** However, this would only work if libtool was able to extract symbol"
79663bfa90b6Smrg	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
79673bfa90b6Smrg	      echo "*** not find such a program.  So, this module is probably useless."
79683bfa90b6Smrg	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
7969b68e1f86Smrg	    fi
7970b68e1f86Smrg	    if test "$build_old_libs" = no; then
7971b68e1f86Smrg	      oldlibs="$output_objdir/$libname.$libext"
7972b68e1f86Smrg	      build_libtool_libs=module
7973b68e1f86Smrg	      build_old_libs=yes
7974b68e1f86Smrg	    else
7975b68e1f86Smrg	      build_libtool_libs=no
7976b68e1f86Smrg	    fi
7977b68e1f86Smrg	  else
79783bfa90b6Smrg	    echo "*** The inter-library dependencies that have been dropped here will be"
79793bfa90b6Smrg	    echo "*** automatically added whenever a program is linked with this library"
79803bfa90b6Smrg	    echo "*** or is declared to -dlopen it."
7981b68e1f86Smrg
7982b68e1f86Smrg	    if test "$allow_undefined" = no; then
79833bfa90b6Smrg	      echo
79843bfa90b6Smrg	      echo "*** Since this library must not contain undefined symbols,"
79853bfa90b6Smrg	      echo "*** because either the platform does not support them or"
79863bfa90b6Smrg	      echo "*** it was explicitly requested with -no-undefined,"
79873bfa90b6Smrg	      echo "*** libtool will only create a static version of it."
7988b68e1f86Smrg	      if test "$build_old_libs" = no; then
7989b68e1f86Smrg		oldlibs="$output_objdir/$libname.$libext"
7990b68e1f86Smrg		build_libtool_libs=module
7991b68e1f86Smrg		build_old_libs=yes
7992b68e1f86Smrg	      else
7993b68e1f86Smrg		build_libtool_libs=no
7994b68e1f86Smrg	      fi
7995b68e1f86Smrg	    fi
7996b68e1f86Smrg	  fi
7997b68e1f86Smrg	fi
7998b68e1f86Smrg	# Done checking deplibs!
7999b68e1f86Smrg	deplibs=$newdeplibs
8000b68e1f86Smrg      fi
8001b68e1f86Smrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
8002b68e1f86Smrg      case $host in
8003b68e1f86Smrg	*-*-darwin*)
80043bfa90b6Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
80053bfa90b6Smrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
80063bfa90b6Smrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8007b68e1f86Smrg	  ;;
8008b68e1f86Smrg      esac
8009b68e1f86Smrg
8010b68e1f86Smrg      # move library search paths that coincide with paths to not yet
8011b68e1f86Smrg      # installed libraries to the beginning of the library search list
8012b68e1f86Smrg      new_libs=
8013b68e1f86Smrg      for path in $notinst_path; do
8014b68e1f86Smrg	case " $new_libs " in
8015b68e1f86Smrg	*" -L$path/$objdir "*) ;;
8016b68e1f86Smrg	*)
8017b68e1f86Smrg	  case " $deplibs " in
8018b68e1f86Smrg	  *" -L$path/$objdir "*)
80193bfa90b6Smrg	    func_append new_libs " -L$path/$objdir" ;;
8020b68e1f86Smrg	  esac
8021b68e1f86Smrg	  ;;
8022b68e1f86Smrg	esac
8023b68e1f86Smrg      done
8024b68e1f86Smrg      for deplib in $deplibs; do
8025b68e1f86Smrg	case $deplib in
8026b68e1f86Smrg	-L*)
8027b68e1f86Smrg	  case " $new_libs " in
8028b68e1f86Smrg	  *" $deplib "*) ;;
80293bfa90b6Smrg	  *) func_append new_libs " $deplib" ;;
8030b68e1f86Smrg	  esac
8031b68e1f86Smrg	  ;;
80323bfa90b6Smrg	*) func_append new_libs " $deplib" ;;
8033b68e1f86Smrg	esac
8034b68e1f86Smrg      done
8035b68e1f86Smrg      deplibs="$new_libs"
8036b68e1f86Smrg
8037b68e1f86Smrg      # All the library-specific variables (install_libdir is set above).
8038b68e1f86Smrg      library_names=
8039b68e1f86Smrg      old_library=
8040b68e1f86Smrg      dlname=
8041b68e1f86Smrg
8042b68e1f86Smrg      # Test again, we may have decided not to build it any more
8043b68e1f86Smrg      if test "$build_libtool_libs" = yes; then
80443bfa90b6Smrg	# Remove ${wl} instances when linking with ld.
80453bfa90b6Smrg	# FIXME: should test the right _cmds variable.
80463bfa90b6Smrg	case $archive_cmds in
80473bfa90b6Smrg	  *\$LD\ *) wl= ;;
80483bfa90b6Smrg        esac
8049b68e1f86Smrg	if test "$hardcode_into_libs" = yes; then
8050b68e1f86Smrg	  # Hardcode the library paths
8051b68e1f86Smrg	  hardcode_libdirs=
8052b68e1f86Smrg	  dep_rpath=
8053b68e1f86Smrg	  rpath="$finalize_rpath"
80543bfa90b6Smrg	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
8055b68e1f86Smrg	  for libdir in $rpath; do
8056b68e1f86Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
8057b68e1f86Smrg	      if test -n "$hardcode_libdir_separator"; then
80583bfa90b6Smrg		func_replace_sysroot "$libdir"
80593bfa90b6Smrg		libdir=$func_replace_sysroot_result
8060b68e1f86Smrg		if test -z "$hardcode_libdirs"; then
8061b68e1f86Smrg		  hardcode_libdirs="$libdir"
8062b68e1f86Smrg		else
8063b68e1f86Smrg		  # Just accumulate the unique libdirs.
8064b68e1f86Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8065b68e1f86Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8066b68e1f86Smrg		    ;;
8067b68e1f86Smrg		  *)
80683bfa90b6Smrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8069b68e1f86Smrg		    ;;
8070b68e1f86Smrg		  esac
8071b68e1f86Smrg		fi
8072b68e1f86Smrg	      else
8073b68e1f86Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
80743bfa90b6Smrg		func_append dep_rpath " $flag"
8075b68e1f86Smrg	      fi
8076b68e1f86Smrg	    elif test -n "$runpath_var"; then
8077b68e1f86Smrg	      case "$perm_rpath " in
8078b68e1f86Smrg	      *" $libdir "*) ;;
80793bfa90b6Smrg	      *) func_append perm_rpath " $libdir" ;;
8080b68e1f86Smrg	      esac
8081b68e1f86Smrg	    fi
8082b68e1f86Smrg	  done
8083b68e1f86Smrg	  # Substitute the hardcoded libdirs into the rpath.
8084b68e1f86Smrg	  if test -n "$hardcode_libdir_separator" &&
8085b68e1f86Smrg	     test -n "$hardcode_libdirs"; then
8086b68e1f86Smrg	    libdir="$hardcode_libdirs"
80873bfa90b6Smrg	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
8088b68e1f86Smrg	  fi
8089b68e1f86Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
8090b68e1f86Smrg	    # We should set the runpath_var.
8091b68e1f86Smrg	    rpath=
8092b68e1f86Smrg	    for dir in $perm_rpath; do
80933bfa90b6Smrg	      func_append rpath "$dir:"
8094b68e1f86Smrg	    done
8095b68e1f86Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
8096b68e1f86Smrg	  fi
8097b68e1f86Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
8098b68e1f86Smrg	fi
80996df26cacSmrg
8100b68e1f86Smrg	shlibpath="$finalize_shlibpath"
81013bfa90b6Smrg	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
8102b68e1f86Smrg	if test -n "$shlibpath"; then
8103b68e1f86Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
8104b68e1f86Smrg	fi
81056df26cacSmrg
8106b68e1f86Smrg	# Get the real and link names of the library.
8107b68e1f86Smrg	eval shared_ext=\"$shrext_cmds\"
8108b68e1f86Smrg	eval library_names=\"$library_names_spec\"
8109b68e1f86Smrg	set dummy $library_names
8110b68e1f86Smrg	shift
8111b68e1f86Smrg	realname="$1"
8112b68e1f86Smrg	shift
81136df26cacSmrg
8114b68e1f86Smrg	if test -n "$soname_spec"; then
8115b68e1f86Smrg	  eval soname=\"$soname_spec\"
8116b68e1f86Smrg	else
8117b68e1f86Smrg	  soname="$realname"
8118b68e1f86Smrg	fi
8119b68e1f86Smrg	if test -z "$dlname"; then
8120b68e1f86Smrg	  dlname=$soname
8121b68e1f86Smrg	fi
81226df26cacSmrg
8123b68e1f86Smrg	lib="$output_objdir/$realname"
8124b68e1f86Smrg	linknames=
8125b68e1f86Smrg	for link
8126b68e1f86Smrg	do
81273bfa90b6Smrg	  func_append linknames " $link"
8128b68e1f86Smrg	done
81296df26cacSmrg
8130b68e1f86Smrg	# Use standard objects if they are pic
81313bfa90b6Smrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
8132b68e1f86Smrg	test "X$libobjs" = "X " && libobjs=
81336df26cacSmrg
8134b68e1f86Smrg	delfiles=
8135b68e1f86Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8136b68e1f86Smrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
8137b68e1f86Smrg	  export_symbols="$output_objdir/$libname.uexp"
81383bfa90b6Smrg	  func_append delfiles " $export_symbols"
8139b68e1f86Smrg	fi
81406df26cacSmrg
8141b68e1f86Smrg	orig_export_symbols=
8142b68e1f86Smrg	case $host_os in
8143b68e1f86Smrg	cygwin* | mingw* | cegcc*)
8144b68e1f86Smrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
8145b68e1f86Smrg	    # exporting using user supplied symfile
8146b68e1f86Smrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
8147b68e1f86Smrg	      # and it's NOT already a .def file. Must figure out
8148b68e1f86Smrg	      # which of the given symbols are data symbols and tag
8149b68e1f86Smrg	      # them as such. So, trigger use of export_symbols_cmds.
8150b68e1f86Smrg	      # export_symbols gets reassigned inside the "prepare
8151b68e1f86Smrg	      # the list of exported symbols" if statement, so the
8152b68e1f86Smrg	      # include_expsyms logic still works.
8153b68e1f86Smrg	      orig_export_symbols="$export_symbols"
8154b68e1f86Smrg	      export_symbols=
8155b68e1f86Smrg	      always_export_symbols=yes
8156b68e1f86Smrg	    fi
8157b68e1f86Smrg	  fi
8158b68e1f86Smrg	  ;;
8159b68e1f86Smrg	esac
81606df26cacSmrg
8161b68e1f86Smrg	# Prepare the list of exported symbols
8162b68e1f86Smrg	if test -z "$export_symbols"; then
8163b68e1f86Smrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
8164b68e1f86Smrg	    func_verbose "generating symbol list for \`$libname.la'"
8165b68e1f86Smrg	    export_symbols="$output_objdir/$libname.exp"
8166b68e1f86Smrg	    $opt_dry_run || $RM $export_symbols
8167b68e1f86Smrg	    cmds=$export_symbols_cmds
8168b68e1f86Smrg	    save_ifs="$IFS"; IFS='~'
81693bfa90b6Smrg	    for cmd1 in $cmds; do
8170b68e1f86Smrg	      IFS="$save_ifs"
81713bfa90b6Smrg	      # Take the normal branch if the nm_file_list_spec branch
81723bfa90b6Smrg	      # doesn't work or if tool conversion is not needed.
81733bfa90b6Smrg	      case $nm_file_list_spec~$to_tool_file_cmd in
81743bfa90b6Smrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
81753bfa90b6Smrg		  try_normal_branch=yes
81763bfa90b6Smrg		  eval cmd=\"$cmd1\"
81773bfa90b6Smrg		  func_len " $cmd"
81783bfa90b6Smrg		  len=$func_len_result
81793bfa90b6Smrg		  ;;
81803bfa90b6Smrg		*)
81813bfa90b6Smrg		  try_normal_branch=no
81823bfa90b6Smrg		  ;;
81833bfa90b6Smrg	      esac
81843bfa90b6Smrg	      if test "$try_normal_branch" = yes \
81853bfa90b6Smrg		 && { test "$len" -lt "$max_cmd_len" \
81863bfa90b6Smrg		      || test "$max_cmd_len" -le -1; }
81873bfa90b6Smrg	      then
8188b68e1f86Smrg		func_show_eval "$cmd" 'exit $?'
8189b68e1f86Smrg		skipped_export=false
81903bfa90b6Smrg	      elif test -n "$nm_file_list_spec"; then
81913bfa90b6Smrg		func_basename "$output"
81923bfa90b6Smrg		output_la=$func_basename_result
81933bfa90b6Smrg		save_libobjs=$libobjs
81943bfa90b6Smrg		save_output=$output
81953bfa90b6Smrg		output=${output_objdir}/${output_la}.nm
81963bfa90b6Smrg		func_to_tool_file "$output"
81973bfa90b6Smrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
81983bfa90b6Smrg		func_append delfiles " $output"
81993bfa90b6Smrg		func_verbose "creating $NM input file list: $output"
82003bfa90b6Smrg		for obj in $save_libobjs; do
82013bfa90b6Smrg		  func_to_tool_file "$obj"
82023bfa90b6Smrg		  $ECHO "$func_to_tool_file_result"
82033bfa90b6Smrg		done > "$output"
82043bfa90b6Smrg		eval cmd=\"$cmd1\"
82053bfa90b6Smrg		func_show_eval "$cmd" 'exit $?'
82063bfa90b6Smrg		output=$save_output
82073bfa90b6Smrg		libobjs=$save_libobjs
82083bfa90b6Smrg		skipped_export=false
8209b68e1f86Smrg	      else
8210b68e1f86Smrg		# The command line is too long to execute in one step.
8211b68e1f86Smrg		func_verbose "using reloadable object file for export list..."
8212b68e1f86Smrg		skipped_export=:
8213b68e1f86Smrg		# Break out early, otherwise skipped_export may be
8214b68e1f86Smrg		# set to false by a later but shorter cmd.
8215b68e1f86Smrg		break
8216b68e1f86Smrg	      fi
8217b68e1f86Smrg	    done
8218b68e1f86Smrg	    IFS="$save_ifs"
8219b68e1f86Smrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
8220b68e1f86Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8221b68e1f86Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8222b68e1f86Smrg	    fi
8223b68e1f86Smrg	  fi
8224b68e1f86Smrg	fi
82256df26cacSmrg
8226b68e1f86Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8227b68e1f86Smrg	  tmp_export_symbols="$export_symbols"
8228b68e1f86Smrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
82293bfa90b6Smrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8230b68e1f86Smrg	fi
82316df26cacSmrg
8232b68e1f86Smrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
8233b68e1f86Smrg	  # The given exports_symbols file has to be filtered, so filter it.
8234b68e1f86Smrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8235b68e1f86Smrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
8236b68e1f86Smrg	  # 's' commands which not all seds can handle. GNU sed should be fine
8237b68e1f86Smrg	  # though. Also, the filter scales superlinearly with the number of
8238b68e1f86Smrg	  # global variables. join(1) would be nice here, but unfortunately
8239b68e1f86Smrg	  # isn't a blessed tool.
8240b68e1f86Smrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
82413bfa90b6Smrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8242b68e1f86Smrg	  export_symbols=$output_objdir/$libname.def
8243b68e1f86Smrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
82446df26cacSmrg	fi
82456df26cacSmrg
8246b68e1f86Smrg	tmp_deplibs=
8247b68e1f86Smrg	for test_deplib in $deplibs; do
8248b68e1f86Smrg	  case " $convenience " in
8249b68e1f86Smrg	  *" $test_deplib "*) ;;
8250b68e1f86Smrg	  *)
82513bfa90b6Smrg	    func_append tmp_deplibs " $test_deplib"
8252b68e1f86Smrg	    ;;
8253b68e1f86Smrg	  esac
8254b68e1f86Smrg	done
8255b68e1f86Smrg	deplibs="$tmp_deplibs"
82566df26cacSmrg
8257b68e1f86Smrg	if test -n "$convenience"; then
8258b68e1f86Smrg	  if test -n "$whole_archive_flag_spec" &&
8259b68e1f86Smrg	    test "$compiler_needs_object" = yes &&
8260b68e1f86Smrg	    test -z "$libobjs"; then
8261b68e1f86Smrg	    # extract the archives, so we have objects to list.
8262b68e1f86Smrg	    # TODO: could optimize this to just extract one archive.
8263b68e1f86Smrg	    whole_archive_flag_spec=
8264b68e1f86Smrg	  fi
8265b68e1f86Smrg	  if test -n "$whole_archive_flag_spec"; then
8266b68e1f86Smrg	    save_libobjs=$libobjs
8267b68e1f86Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8268b68e1f86Smrg	    test "X$libobjs" = "X " && libobjs=
8269b68e1f86Smrg	  else
8270b68e1f86Smrg	    gentop="$output_objdir/${outputname}x"
82713bfa90b6Smrg	    func_append generated " $gentop"
82726df26cacSmrg
8273b68e1f86Smrg	    func_extract_archives $gentop $convenience
82743bfa90b6Smrg	    func_append libobjs " $func_extract_archives_result"
8275b68e1f86Smrg	    test "X$libobjs" = "X " && libobjs=
8276b68e1f86Smrg	  fi
8277b68e1f86Smrg	fi
82786df26cacSmrg
8279b68e1f86Smrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
8280b68e1f86Smrg	  eval flag=\"$thread_safe_flag_spec\"
82813bfa90b6Smrg	  func_append linker_flags " $flag"
8282b68e1f86Smrg	fi
82836df26cacSmrg
8284b68e1f86Smrg	# Make a backup of the uninstalled library when relinking
82853bfa90b6Smrg	if test "$opt_mode" = relink; then
8286b68e1f86Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
82876df26cacSmrg	fi
82886df26cacSmrg
8289b68e1f86Smrg	# Do each of the archive commands.
8290b68e1f86Smrg	if test "$module" = yes && test -n "$module_cmds" ; then
8291b68e1f86Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8292b68e1f86Smrg	    eval test_cmds=\"$module_expsym_cmds\"
8293b68e1f86Smrg	    cmds=$module_expsym_cmds
8294b68e1f86Smrg	  else
8295b68e1f86Smrg	    eval test_cmds=\"$module_cmds\"
8296b68e1f86Smrg	    cmds=$module_cmds
8297b68e1f86Smrg	  fi
8298b68e1f86Smrg	else
8299b68e1f86Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8300b68e1f86Smrg	    eval test_cmds=\"$archive_expsym_cmds\"
8301b68e1f86Smrg	    cmds=$archive_expsym_cmds
8302b68e1f86Smrg	  else
8303b68e1f86Smrg	    eval test_cmds=\"$archive_cmds\"
8304b68e1f86Smrg	    cmds=$archive_cmds
8305b68e1f86Smrg	  fi
83066df26cacSmrg	fi
83076df26cacSmrg
8308b68e1f86Smrg	if test "X$skipped_export" != "X:" &&
8309b68e1f86Smrg	   func_len " $test_cmds" &&
8310b68e1f86Smrg	   len=$func_len_result &&
8311b68e1f86Smrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
8312b68e1f86Smrg	  :
8313b68e1f86Smrg	else
8314b68e1f86Smrg	  # The command line is too long to link in one step, link piecewise
8315b68e1f86Smrg	  # or, if using GNU ld and skipped_export is not :, use a linker
8316b68e1f86Smrg	  # script.
83176df26cacSmrg
8318b68e1f86Smrg	  # Save the value of $output and $libobjs because we want to
8319b68e1f86Smrg	  # use them later.  If we have whole_archive_flag_spec, we
8320b68e1f86Smrg	  # want to use save_libobjs as it was before
8321b68e1f86Smrg	  # whole_archive_flag_spec was expanded, because we can't
8322b68e1f86Smrg	  # assume the linker understands whole_archive_flag_spec.
8323b68e1f86Smrg	  # This may have to be revisited, in case too many
8324b68e1f86Smrg	  # convenience libraries get linked in and end up exceeding
8325b68e1f86Smrg	  # the spec.
8326b68e1f86Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
8327b68e1f86Smrg	    save_libobjs=$libobjs
8328b68e1f86Smrg	  fi
8329b68e1f86Smrg	  save_output=$output
83303bfa90b6Smrg	  func_basename "$output"
83313bfa90b6Smrg	  output_la=$func_basename_result
83326df26cacSmrg
8333b68e1f86Smrg	  # Clear the reloadable object creation command queue and
8334b68e1f86Smrg	  # initialize k to one.
8335b68e1f86Smrg	  test_cmds=
8336b68e1f86Smrg	  concat_cmds=
8337b68e1f86Smrg	  objlist=
8338b68e1f86Smrg	  last_robj=
8339b68e1f86Smrg	  k=1
83406df26cacSmrg
8341b68e1f86Smrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
8342b68e1f86Smrg	    output=${output_objdir}/${output_la}.lnkscript
8343b68e1f86Smrg	    func_verbose "creating GNU ld script: $output"
83443bfa90b6Smrg	    echo 'INPUT (' > $output
8345b68e1f86Smrg	    for obj in $save_libobjs
8346b68e1f86Smrg	    do
83473bfa90b6Smrg	      func_to_tool_file "$obj"
83483bfa90b6Smrg	      $ECHO "$func_to_tool_file_result" >> $output
8349b68e1f86Smrg	    done
83503bfa90b6Smrg	    echo ')' >> $output
83513bfa90b6Smrg	    func_append delfiles " $output"
83523bfa90b6Smrg	    func_to_tool_file "$output"
83533bfa90b6Smrg	    output=$func_to_tool_file_result
8354b68e1f86Smrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
8355b68e1f86Smrg	    output=${output_objdir}/${output_la}.lnk
8356b68e1f86Smrg	    func_verbose "creating linker input file list: $output"
8357b68e1f86Smrg	    : > $output
8358b68e1f86Smrg	    set x $save_libobjs
8359b68e1f86Smrg	    shift
8360b68e1f86Smrg	    firstobj=
8361b68e1f86Smrg	    if test "$compiler_needs_object" = yes; then
8362b68e1f86Smrg	      firstobj="$1 "
8363b68e1f86Smrg	      shift
8364b68e1f86Smrg	    fi
8365b68e1f86Smrg	    for obj
8366b68e1f86Smrg	    do
83673bfa90b6Smrg	      func_to_tool_file "$obj"
83683bfa90b6Smrg	      $ECHO "$func_to_tool_file_result" >> $output
8369b68e1f86Smrg	    done
83703bfa90b6Smrg	    func_append delfiles " $output"
83713bfa90b6Smrg	    func_to_tool_file "$output"
83723bfa90b6Smrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
8373b68e1f86Smrg	  else
8374b68e1f86Smrg	    if test -n "$save_libobjs"; then
8375b68e1f86Smrg	      func_verbose "creating reloadable object files..."
8376b68e1f86Smrg	      output=$output_objdir/$output_la-${k}.$objext
8377b68e1f86Smrg	      eval test_cmds=\"$reload_cmds\"
8378b68e1f86Smrg	      func_len " $test_cmds"
8379b68e1f86Smrg	      len0=$func_len_result
8380b68e1f86Smrg	      len=$len0
8381b68e1f86Smrg
8382b68e1f86Smrg	      # Loop over the list of objects to be linked.
8383b68e1f86Smrg	      for obj in $save_libobjs
8384b68e1f86Smrg	      do
8385b68e1f86Smrg		func_len " $obj"
8386b68e1f86Smrg		func_arith $len + $func_len_result
8387b68e1f86Smrg		len=$func_arith_result
8388b68e1f86Smrg		if test "X$objlist" = X ||
8389b68e1f86Smrg		   test "$len" -lt "$max_cmd_len"; then
8390b68e1f86Smrg		  func_append objlist " $obj"
8391b68e1f86Smrg		else
8392b68e1f86Smrg		  # The command $test_cmds is almost too long, add a
8393b68e1f86Smrg		  # command to the queue.
8394b68e1f86Smrg		  if test "$k" -eq 1 ; then
8395b68e1f86Smrg		    # The first file doesn't have a previous command to add.
83963bfa90b6Smrg		    reload_objs=$objlist
83973bfa90b6Smrg		    eval concat_cmds=\"$reload_cmds\"
8398b68e1f86Smrg		  else
8399b68e1f86Smrg		    # All subsequent reloadable object files will link in
8400b68e1f86Smrg		    # the last one created.
84013bfa90b6Smrg		    reload_objs="$objlist $last_robj"
84023bfa90b6Smrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
8403b68e1f86Smrg		  fi
8404b68e1f86Smrg		  last_robj=$output_objdir/$output_la-${k}.$objext
8405b68e1f86Smrg		  func_arith $k + 1
8406b68e1f86Smrg		  k=$func_arith_result
8407b68e1f86Smrg		  output=$output_objdir/$output_la-${k}.$objext
84083bfa90b6Smrg		  objlist=" $obj"
8409b68e1f86Smrg		  func_len " $last_robj"
8410b68e1f86Smrg		  func_arith $len0 + $func_len_result
8411b68e1f86Smrg		  len=$func_arith_result
8412b68e1f86Smrg		fi
8413b68e1f86Smrg	      done
8414b68e1f86Smrg	      # Handle the remaining objects by creating one last
8415b68e1f86Smrg	      # reloadable object file.  All subsequent reloadable object
8416b68e1f86Smrg	      # files will link in the last one created.
8417b68e1f86Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
84183bfa90b6Smrg	      reload_objs="$objlist $last_robj"
84193bfa90b6Smrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
8420b68e1f86Smrg	      if test -n "$last_robj"; then
8421b68e1f86Smrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
8422b68e1f86Smrg	      fi
84233bfa90b6Smrg	      func_append delfiles " $output"
84246df26cacSmrg
8425b68e1f86Smrg	    else
8426b68e1f86Smrg	      output=
8427b68e1f86Smrg	    fi
8428b68e1f86Smrg
8429b68e1f86Smrg	    if ${skipped_export-false}; then
8430b68e1f86Smrg	      func_verbose "generating symbol list for \`$libname.la'"
8431b68e1f86Smrg	      export_symbols="$output_objdir/$libname.exp"
8432b68e1f86Smrg	      $opt_dry_run || $RM $export_symbols
8433b68e1f86Smrg	      libobjs=$output
8434b68e1f86Smrg	      # Append the command to create the export file.
8435b68e1f86Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8436b68e1f86Smrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
8437b68e1f86Smrg	      if test -n "$last_robj"; then
8438b68e1f86Smrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
8439b68e1f86Smrg	      fi
8440b68e1f86Smrg	    fi
84416df26cacSmrg
8442b68e1f86Smrg	    test -n "$save_libobjs" &&
8443b68e1f86Smrg	      func_verbose "creating a temporary reloadable object file: $output"
84446df26cacSmrg
8445b68e1f86Smrg	    # Loop through the commands generated above and execute them.
8446b68e1f86Smrg	    save_ifs="$IFS"; IFS='~'
8447b68e1f86Smrg	    for cmd in $concat_cmds; do
8448b68e1f86Smrg	      IFS="$save_ifs"
8449b68e1f86Smrg	      $opt_silent || {
8450b68e1f86Smrg		  func_quote_for_expand "$cmd"
8451b68e1f86Smrg		  eval "func_echo $func_quote_for_expand_result"
8452b68e1f86Smrg	      }
8453b68e1f86Smrg	      $opt_dry_run || eval "$cmd" || {
8454b68e1f86Smrg		lt_exit=$?
8455b68e1f86Smrg
8456b68e1f86Smrg		# Restore the uninstalled library and exit
84573bfa90b6Smrg		if test "$opt_mode" = relink; then
8458b68e1f86Smrg		  ( cd "$output_objdir" && \
8459b68e1f86Smrg		    $RM "${realname}T" && \
8460b68e1f86Smrg		    $MV "${realname}U" "$realname" )
8461b68e1f86Smrg		fi
84626df26cacSmrg
8463b68e1f86Smrg		exit $lt_exit
8464b68e1f86Smrg	      }
8465b68e1f86Smrg	    done
8466b68e1f86Smrg	    IFS="$save_ifs"
84676df26cacSmrg
8468b68e1f86Smrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
8469b68e1f86Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8470b68e1f86Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
84716df26cacSmrg	    fi
84726df26cacSmrg	  fi
84736df26cacSmrg
8474b68e1f86Smrg          if ${skipped_export-false}; then
8475b68e1f86Smrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
8476b68e1f86Smrg	      tmp_export_symbols="$export_symbols"
8477b68e1f86Smrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
84783bfa90b6Smrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8479b68e1f86Smrg	    fi
84806df26cacSmrg
8481b68e1f86Smrg	    if test -n "$orig_export_symbols"; then
8482b68e1f86Smrg	      # The given exports_symbols file has to be filtered, so filter it.
8483b68e1f86Smrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8484b68e1f86Smrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
8485b68e1f86Smrg	      # 's' commands which not all seds can handle. GNU sed should be fine
8486b68e1f86Smrg	      # though. Also, the filter scales superlinearly with the number of
8487b68e1f86Smrg	      # global variables. join(1) would be nice here, but unfortunately
8488b68e1f86Smrg	      # isn't a blessed tool.
8489b68e1f86Smrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
84903bfa90b6Smrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8491b68e1f86Smrg	      export_symbols=$output_objdir/$libname.def
8492b68e1f86Smrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8493b68e1f86Smrg	    fi
8494b68e1f86Smrg	  fi
84956df26cacSmrg
8496b68e1f86Smrg	  libobjs=$output
8497b68e1f86Smrg	  # Restore the value of output.
8498b68e1f86Smrg	  output=$save_output
84996df26cacSmrg
8500b68e1f86Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
8501b68e1f86Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8502b68e1f86Smrg	    test "X$libobjs" = "X " && libobjs=
8503b68e1f86Smrg	  fi
8504b68e1f86Smrg	  # Expand the library linking commands again to reset the
8505b68e1f86Smrg	  # value of $libobjs for piecewise linking.
8506b68e1f86Smrg
8507b68e1f86Smrg	  # Do each of the archive commands.
8508b68e1f86Smrg	  if test "$module" = yes && test -n "$module_cmds" ; then
8509b68e1f86Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8510b68e1f86Smrg	      cmds=$module_expsym_cmds
85116df26cacSmrg	    else
8512b68e1f86Smrg	      cmds=$module_cmds
85136df26cacSmrg	    fi
85146df26cacSmrg	  else
8515b68e1f86Smrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8516b68e1f86Smrg	      cmds=$archive_expsym_cmds
8517b68e1f86Smrg	    else
8518b68e1f86Smrg	      cmds=$archive_cmds
8519b68e1f86Smrg	    fi
85206df26cacSmrg	  fi
85216df26cacSmrg	fi
85226df26cacSmrg
8523b68e1f86Smrg	if test -n "$delfiles"; then
8524b68e1f86Smrg	  # Append the command to remove temporary files to $cmds.
8525b68e1f86Smrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
8526b68e1f86Smrg	fi
85276df26cacSmrg
8528b68e1f86Smrg	# Add any objects from preloaded convenience libraries
8529b68e1f86Smrg	if test -n "$dlprefiles"; then
8530b68e1f86Smrg	  gentop="$output_objdir/${outputname}x"
85313bfa90b6Smrg	  func_append generated " $gentop"
85326df26cacSmrg
8533b68e1f86Smrg	  func_extract_archives $gentop $dlprefiles
85343bfa90b6Smrg	  func_append libobjs " $func_extract_archives_result"
8535b68e1f86Smrg	  test "X$libobjs" = "X " && libobjs=
85366df26cacSmrg	fi
85376df26cacSmrg
8538b68e1f86Smrg	save_ifs="$IFS"; IFS='~'
8539b68e1f86Smrg	for cmd in $cmds; do
8540b68e1f86Smrg	  IFS="$save_ifs"
8541b68e1f86Smrg	  eval cmd=\"$cmd\"
8542b68e1f86Smrg	  $opt_silent || {
8543b68e1f86Smrg	    func_quote_for_expand "$cmd"
8544b68e1f86Smrg	    eval "func_echo $func_quote_for_expand_result"
8545b68e1f86Smrg	  }
8546b68e1f86Smrg	  $opt_dry_run || eval "$cmd" || {
8547b68e1f86Smrg	    lt_exit=$?
85486df26cacSmrg
8549b68e1f86Smrg	    # Restore the uninstalled library and exit
85503bfa90b6Smrg	    if test "$opt_mode" = relink; then
8551b68e1f86Smrg	      ( cd "$output_objdir" && \
8552b68e1f86Smrg	        $RM "${realname}T" && \
8553b68e1f86Smrg		$MV "${realname}U" "$realname" )
85546df26cacSmrg	    fi
85556df26cacSmrg
8556b68e1f86Smrg	    exit $lt_exit
8557b68e1f86Smrg	  }
8558b68e1f86Smrg	done
8559b68e1f86Smrg	IFS="$save_ifs"
85606df26cacSmrg
8561b68e1f86Smrg	# Restore the uninstalled library and exit
85623bfa90b6Smrg	if test "$opt_mode" = relink; then
8563b68e1f86Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
85646df26cacSmrg
8565b68e1f86Smrg	  if test -n "$convenience"; then
8566b68e1f86Smrg	    if test -z "$whole_archive_flag_spec"; then
8567b68e1f86Smrg	      func_show_eval '${RM}r "$gentop"'
8568b68e1f86Smrg	    fi
8569b68e1f86Smrg	  fi
85706df26cacSmrg
8571b68e1f86Smrg	  exit $EXIT_SUCCESS
8572b68e1f86Smrg	fi
85736df26cacSmrg
8574b68e1f86Smrg	# Create links to the real library.
8575b68e1f86Smrg	for linkname in $linknames; do
8576b68e1f86Smrg	  if test "$realname" != "$linkname"; then
8577b68e1f86Smrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
85786df26cacSmrg	  fi
85796df26cacSmrg	done
85806df26cacSmrg
8581b68e1f86Smrg	# If -module or -export-dynamic was specified, set the dlname.
8582b68e1f86Smrg	if test "$module" = yes || test "$export_dynamic" = yes; then
8583b68e1f86Smrg	  # On all known operating systems, these are identical.
8584b68e1f86Smrg	  dlname="$soname"
8585b68e1f86Smrg	fi
8586b68e1f86Smrg      fi
85876df26cacSmrg      ;;
85886df26cacSmrg
8589b68e1f86Smrg    obj)
8590b68e1f86Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
8591b68e1f86Smrg	func_warning "\`-dlopen' is ignored for objects"
8592b68e1f86Smrg      fi
85936df26cacSmrg
8594b68e1f86Smrg      case " $deplibs" in
8595b68e1f86Smrg      *\ -l* | *\ -L*)
8596b68e1f86Smrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
85976df26cacSmrg      esac
85986df26cacSmrg
8599b68e1f86Smrg      test -n "$rpath" && \
8600b68e1f86Smrg	func_warning "\`-rpath' is ignored for objects"
86016df26cacSmrg
8602b68e1f86Smrg      test -n "$xrpath" && \
8603b68e1f86Smrg	func_warning "\`-R' is ignored for objects"
86046df26cacSmrg
8605b68e1f86Smrg      test -n "$vinfo" && \
8606b68e1f86Smrg	func_warning "\`-version-info' is ignored for objects"
8607b68e1f86Smrg
8608b68e1f86Smrg      test -n "$release" && \
8609b68e1f86Smrg	func_warning "\`-release' is ignored for objects"
8610b68e1f86Smrg
8611b68e1f86Smrg      case $output in
8612b68e1f86Smrg      *.lo)
8613b68e1f86Smrg	test -n "$objs$old_deplibs" && \
8614b68e1f86Smrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
8615b68e1f86Smrg
8616b68e1f86Smrg	libobj=$output
8617b68e1f86Smrg	func_lo2o "$libobj"
8618b68e1f86Smrg	obj=$func_lo2o_result
86196df26cacSmrg	;;
86206df26cacSmrg      *)
8621b68e1f86Smrg	libobj=
8622b68e1f86Smrg	obj="$output"
86236df26cacSmrg	;;
86246df26cacSmrg      esac
86256df26cacSmrg
8626b68e1f86Smrg      # Delete the old objects.
8627b68e1f86Smrg      $opt_dry_run || $RM $obj $libobj
86286df26cacSmrg
8629b68e1f86Smrg      # Objects from convenience libraries.  This assumes
8630b68e1f86Smrg      # single-version convenience libraries.  Whenever we create
8631b68e1f86Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
8632b68e1f86Smrg      # the extraction.
8633b68e1f86Smrg      reload_conv_objs=
8634b68e1f86Smrg      gentop=
8635b68e1f86Smrg      # reload_cmds runs $LD directly, so let us get rid of
8636b68e1f86Smrg      # -Wl from whole_archive_flag_spec and hope we can get by with
8637b68e1f86Smrg      # turning comma into space..
8638b68e1f86Smrg      wl=
86396df26cacSmrg
8640b68e1f86Smrg      if test -n "$convenience"; then
8641b68e1f86Smrg	if test -n "$whole_archive_flag_spec"; then
8642b68e1f86Smrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
86433bfa90b6Smrg	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
8644b68e1f86Smrg	else
8645b68e1f86Smrg	  gentop="$output_objdir/${obj}x"
86463bfa90b6Smrg	  func_append generated " $gentop"
86476df26cacSmrg
8648b68e1f86Smrg	  func_extract_archives $gentop $convenience
8649b68e1f86Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
8650b68e1f86Smrg	fi
86516df26cacSmrg      fi
86526df26cacSmrg
86533bfa90b6Smrg      # If we're not building shared, we need to use non_pic_objs
86543bfa90b6Smrg      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
86553bfa90b6Smrg
8656b68e1f86Smrg      # Create the old-style object.
86573bfa90b6Smrg      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
86586df26cacSmrg
8659b68e1f86Smrg      output="$obj"
8660b68e1f86Smrg      func_execute_cmds "$reload_cmds" 'exit $?'
86616df26cacSmrg
8662b68e1f86Smrg      # Exit if we aren't doing a library object file.
8663b68e1f86Smrg      if test -z "$libobj"; then
8664b68e1f86Smrg	if test -n "$gentop"; then
8665b68e1f86Smrg	  func_show_eval '${RM}r "$gentop"'
8666b68e1f86Smrg	fi
8667b68e1f86Smrg
8668b68e1f86Smrg	exit $EXIT_SUCCESS
86696df26cacSmrg      fi
8670b68e1f86Smrg
8671b68e1f86Smrg      if test "$build_libtool_libs" != yes; then
8672b68e1f86Smrg	if test -n "$gentop"; then
8673b68e1f86Smrg	  func_show_eval '${RM}r "$gentop"'
8674b68e1f86Smrg	fi
8675b68e1f86Smrg
8676b68e1f86Smrg	# Create an invalid libtool object if no PIC, so that we don't
8677b68e1f86Smrg	# accidentally link it into a program.
8678b68e1f86Smrg	# $show "echo timestamp > $libobj"
8679b68e1f86Smrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
8680b68e1f86Smrg	exit $EXIT_SUCCESS
8681b68e1f86Smrg      fi
8682b68e1f86Smrg
8683b68e1f86Smrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
8684b68e1f86Smrg	# Only do commands if we really have different PIC objects.
8685b68e1f86Smrg	reload_objs="$libobjs $reload_conv_objs"
8686b68e1f86Smrg	output="$libobj"
8687b68e1f86Smrg	func_execute_cmds "$reload_cmds" 'exit $?'
8688b68e1f86Smrg      fi
8689b68e1f86Smrg
8690b68e1f86Smrg      if test -n "$gentop"; then
8691b68e1f86Smrg	func_show_eval '${RM}r "$gentop"'
8692b68e1f86Smrg      fi
8693b68e1f86Smrg
8694b68e1f86Smrg      exit $EXIT_SUCCESS
86956df26cacSmrg      ;;
86966df26cacSmrg
8697b68e1f86Smrg    prog)
8698b68e1f86Smrg      case $host in
8699b68e1f86Smrg	*cygwin*) func_stripname '' '.exe' "$output"
8700b68e1f86Smrg	          output=$func_stripname_result.exe;;
8701b68e1f86Smrg      esac
8702b68e1f86Smrg      test -n "$vinfo" && \
8703b68e1f86Smrg	func_warning "\`-version-info' is ignored for programs"
87046df26cacSmrg
8705b68e1f86Smrg      test -n "$release" && \
8706b68e1f86Smrg	func_warning "\`-release' is ignored for programs"
87076df26cacSmrg
8708b68e1f86Smrg      test "$preload" = yes \
8709b68e1f86Smrg        && test "$dlopen_support" = unknown \
8710b68e1f86Smrg	&& test "$dlopen_self" = unknown \
8711b68e1f86Smrg	&& test "$dlopen_self_static" = unknown && \
8712b68e1f86Smrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
8713b68e1f86Smrg
8714b68e1f86Smrg      case $host in
8715b68e1f86Smrg      *-*-rhapsody* | *-*-darwin1.[012])
8716b68e1f86Smrg	# On Rhapsody replace the C library is the System framework
87173bfa90b6Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
87183bfa90b6Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
87196df26cacSmrg	;;
8720b68e1f86Smrg      esac
87216df26cacSmrg
8722b68e1f86Smrg      case $host in
8723b68e1f86Smrg      *-*-darwin*)
8724b68e1f86Smrg	# Don't allow lazy linking, it breaks C++ global constructors
8725b68e1f86Smrg	# But is supposedly fixed on 10.4 or later (yay!).
8726b68e1f86Smrg	if test "$tagname" = CXX ; then
8727b68e1f86Smrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
8728b68e1f86Smrg	    10.[0123])
87293bfa90b6Smrg	      func_append compile_command " ${wl}-bind_at_load"
87303bfa90b6Smrg	      func_append finalize_command " ${wl}-bind_at_load"
8731b68e1f86Smrg	    ;;
8732b68e1f86Smrg	  esac
87336df26cacSmrg	fi
8734b68e1f86Smrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
87353bfa90b6Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
87363bfa90b6Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8737b68e1f86Smrg	;;
8738b68e1f86Smrg      esac
87396df26cacSmrg
87406df26cacSmrg
8741b68e1f86Smrg      # move library search paths that coincide with paths to not yet
8742b68e1f86Smrg      # installed libraries to the beginning of the library search list
8743b68e1f86Smrg      new_libs=
8744b68e1f86Smrg      for path in $notinst_path; do
8745b68e1f86Smrg	case " $new_libs " in
8746b68e1f86Smrg	*" -L$path/$objdir "*) ;;
8747b68e1f86Smrg	*)
8748b68e1f86Smrg	  case " $compile_deplibs " in
8749b68e1f86Smrg	  *" -L$path/$objdir "*)
87503bfa90b6Smrg	    func_append new_libs " -L$path/$objdir" ;;
87516df26cacSmrg	  esac
8752b68e1f86Smrg	  ;;
8753b68e1f86Smrg	esac
8754b68e1f86Smrg      done
8755b68e1f86Smrg      for deplib in $compile_deplibs; do
8756b68e1f86Smrg	case $deplib in
8757b68e1f86Smrg	-L*)
8758b68e1f86Smrg	  case " $new_libs " in
8759b68e1f86Smrg	  *" $deplib "*) ;;
87603bfa90b6Smrg	  *) func_append new_libs " $deplib" ;;
87616df26cacSmrg	  esac
8762b68e1f86Smrg	  ;;
87633bfa90b6Smrg	*) func_append new_libs " $deplib" ;;
8764b68e1f86Smrg	esac
8765b68e1f86Smrg      done
8766b68e1f86Smrg      compile_deplibs="$new_libs"
87676df26cacSmrg
87686df26cacSmrg
87693bfa90b6Smrg      func_append compile_command " $compile_deplibs"
87703bfa90b6Smrg      func_append finalize_command " $finalize_deplibs"
87716df26cacSmrg
8772b68e1f86Smrg      if test -n "$rpath$xrpath"; then
8773b68e1f86Smrg	# If the user specified any rpath flags, then add them.
8774b68e1f86Smrg	for libdir in $rpath $xrpath; do
8775b68e1f86Smrg	  # This is the magic to use -rpath.
8776b68e1f86Smrg	  case "$finalize_rpath " in
8777b68e1f86Smrg	  *" $libdir "*) ;;
87783bfa90b6Smrg	  *) func_append finalize_rpath " $libdir" ;;
8779b68e1f86Smrg	  esac
8780b68e1f86Smrg	done
8781b68e1f86Smrg      fi
87826df26cacSmrg
8783b68e1f86Smrg      # Now hardcode the library paths
8784b68e1f86Smrg      rpath=
8785b68e1f86Smrg      hardcode_libdirs=
8786b68e1f86Smrg      for libdir in $compile_rpath $finalize_rpath; do
8787b68e1f86Smrg	if test -n "$hardcode_libdir_flag_spec"; then
8788b68e1f86Smrg	  if test -n "$hardcode_libdir_separator"; then
8789b68e1f86Smrg	    if test -z "$hardcode_libdirs"; then
8790b68e1f86Smrg	      hardcode_libdirs="$libdir"
8791b68e1f86Smrg	    else
8792b68e1f86Smrg	      # Just accumulate the unique libdirs.
8793b68e1f86Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8794b68e1f86Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8795b68e1f86Smrg		;;
8796b68e1f86Smrg	      *)
87973bfa90b6Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8798b68e1f86Smrg		;;
8799b68e1f86Smrg	      esac
8800b68e1f86Smrg	    fi
88016df26cacSmrg	  else
8802b68e1f86Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
88033bfa90b6Smrg	    func_append rpath " $flag"
88046df26cacSmrg	  fi
8805b68e1f86Smrg	elif test -n "$runpath_var"; then
8806b68e1f86Smrg	  case "$perm_rpath " in
8807b68e1f86Smrg	  *" $libdir "*) ;;
88083bfa90b6Smrg	  *) func_append perm_rpath " $libdir" ;;
8809b68e1f86Smrg	  esac
8810b68e1f86Smrg	fi
8811b68e1f86Smrg	case $host in
8812b68e1f86Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
8813b68e1f86Smrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
8814b68e1f86Smrg	  case :$dllsearchpath: in
8815b68e1f86Smrg	  *":$libdir:"*) ;;
8816b68e1f86Smrg	  ::) dllsearchpath=$libdir;;
88173bfa90b6Smrg	  *) func_append dllsearchpath ":$libdir";;
8818b68e1f86Smrg	  esac
8819b68e1f86Smrg	  case :$dllsearchpath: in
8820b68e1f86Smrg	  *":$testbindir:"*) ;;
8821b68e1f86Smrg	  ::) dllsearchpath=$testbindir;;
88223bfa90b6Smrg	  *) func_append dllsearchpath ":$testbindir";;
8823b68e1f86Smrg	  esac
8824b68e1f86Smrg	  ;;
8825b68e1f86Smrg	esac
8826b68e1f86Smrg      done
8827b68e1f86Smrg      # Substitute the hardcoded libdirs into the rpath.
8828b68e1f86Smrg      if test -n "$hardcode_libdir_separator" &&
8829b68e1f86Smrg	 test -n "$hardcode_libdirs"; then
8830b68e1f86Smrg	libdir="$hardcode_libdirs"
8831b68e1f86Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
8832b68e1f86Smrg      fi
8833b68e1f86Smrg      compile_rpath="$rpath"
88346df26cacSmrg
8835b68e1f86Smrg      rpath=
8836b68e1f86Smrg      hardcode_libdirs=
8837b68e1f86Smrg      for libdir in $finalize_rpath; do
8838b68e1f86Smrg	if test -n "$hardcode_libdir_flag_spec"; then
8839b68e1f86Smrg	  if test -n "$hardcode_libdir_separator"; then
8840b68e1f86Smrg	    if test -z "$hardcode_libdirs"; then
8841b68e1f86Smrg	      hardcode_libdirs="$libdir"
8842b68e1f86Smrg	    else
8843b68e1f86Smrg	      # Just accumulate the unique libdirs.
8844b68e1f86Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8845b68e1f86Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8846b68e1f86Smrg		;;
8847b68e1f86Smrg	      *)
88483bfa90b6Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8849b68e1f86Smrg		;;
8850b68e1f86Smrg	      esac
8851b68e1f86Smrg	    fi
88526df26cacSmrg	  else
8853b68e1f86Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
88543bfa90b6Smrg	    func_append rpath " $flag"
88556df26cacSmrg	  fi
8856b68e1f86Smrg	elif test -n "$runpath_var"; then
8857b68e1f86Smrg	  case "$finalize_perm_rpath " in
8858b68e1f86Smrg	  *" $libdir "*) ;;
88593bfa90b6Smrg	  *) func_append finalize_perm_rpath " $libdir" ;;
8860b68e1f86Smrg	  esac
88616df26cacSmrg	fi
8862b68e1f86Smrg      done
8863b68e1f86Smrg      # Substitute the hardcoded libdirs into the rpath.
8864b68e1f86Smrg      if test -n "$hardcode_libdir_separator" &&
8865b68e1f86Smrg	 test -n "$hardcode_libdirs"; then
8866b68e1f86Smrg	libdir="$hardcode_libdirs"
8867b68e1f86Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
8868b68e1f86Smrg      fi
8869b68e1f86Smrg      finalize_rpath="$rpath"
88706df26cacSmrg
8871b68e1f86Smrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
8872b68e1f86Smrg	# Transform all the library objects into standard objects.
88733bfa90b6Smrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
88743bfa90b6Smrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8875b68e1f86Smrg      fi
88766df26cacSmrg
8877b68e1f86Smrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
88786df26cacSmrg
8879b68e1f86Smrg      # template prelinking step
8880b68e1f86Smrg      if test -n "$prelink_cmds"; then
8881b68e1f86Smrg	func_execute_cmds "$prelink_cmds" 'exit $?'
8882b68e1f86Smrg      fi
88836df26cacSmrg
8884b68e1f86Smrg      wrappers_required=yes
8885b68e1f86Smrg      case $host in
88863bfa90b6Smrg      *cegcc* | *mingw32ce*)
88873bfa90b6Smrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
88883bfa90b6Smrg        wrappers_required=no
88893bfa90b6Smrg        ;;
8890b68e1f86Smrg      *cygwin* | *mingw* )
8891b68e1f86Smrg        if test "$build_libtool_libs" != yes; then
8892b68e1f86Smrg          wrappers_required=no
8893b68e1f86Smrg        fi
8894b68e1f86Smrg        ;;
8895b68e1f86Smrg      *)
8896b68e1f86Smrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
8897b68e1f86Smrg          wrappers_required=no
8898b68e1f86Smrg        fi
8899b68e1f86Smrg        ;;
8900b68e1f86Smrg      esac
8901b68e1f86Smrg      if test "$wrappers_required" = no; then
8902b68e1f86Smrg	# Replace the output file specification.
89033bfa90b6Smrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8904b68e1f86Smrg	link_command="$compile_command$compile_rpath"
89056df26cacSmrg
8906b68e1f86Smrg	# We have no uninstalled library dependencies, so finalize right now.
8907b68e1f86Smrg	exit_status=0
8908b68e1f86Smrg	func_show_eval "$link_command" 'exit_status=$?'
89096df26cacSmrg
89103bfa90b6Smrg	if test -n "$postlink_cmds"; then
89113bfa90b6Smrg	  func_to_tool_file "$output"
89123bfa90b6Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
89133bfa90b6Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
89143bfa90b6Smrg	fi
89153bfa90b6Smrg
8916b68e1f86Smrg	# Delete the generated files.
8917b68e1f86Smrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
8918b68e1f86Smrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
89196df26cacSmrg	fi
89206df26cacSmrg
8921b68e1f86Smrg	exit $exit_status
8922b68e1f86Smrg      fi
89236df26cacSmrg
8924b68e1f86Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
8925b68e1f86Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
8926b68e1f86Smrg      fi
8927b68e1f86Smrg      if test -n "$finalize_shlibpath"; then
8928b68e1f86Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
8929b68e1f86Smrg      fi
89306df26cacSmrg
8931b68e1f86Smrg      compile_var=
8932b68e1f86Smrg      finalize_var=
8933b68e1f86Smrg      if test -n "$runpath_var"; then
8934b68e1f86Smrg	if test -n "$perm_rpath"; then
8935b68e1f86Smrg	  # We should set the runpath_var.
8936b68e1f86Smrg	  rpath=
8937b68e1f86Smrg	  for dir in $perm_rpath; do
89383bfa90b6Smrg	    func_append rpath "$dir:"
8939b68e1f86Smrg	  done
8940b68e1f86Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
89416df26cacSmrg	fi
8942b68e1f86Smrg	if test -n "$finalize_perm_rpath"; then
8943b68e1f86Smrg	  # We should set the runpath_var.
8944b68e1f86Smrg	  rpath=
8945b68e1f86Smrg	  for dir in $finalize_perm_rpath; do
89463bfa90b6Smrg	    func_append rpath "$dir:"
8947b68e1f86Smrg	  done
8948b68e1f86Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
89496df26cacSmrg	fi
8950b68e1f86Smrg      fi
89516df26cacSmrg
8952b68e1f86Smrg      if test "$no_install" = yes; then
8953b68e1f86Smrg	# We don't need to create a wrapper script.
8954b68e1f86Smrg	link_command="$compile_var$compile_command$compile_rpath"
8955b68e1f86Smrg	# Replace the output file specification.
89563bfa90b6Smrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8957b68e1f86Smrg	# Delete the old output file.
8958b68e1f86Smrg	$opt_dry_run || $RM $output
8959b68e1f86Smrg	# Link the executable and exit
8960b68e1f86Smrg	func_show_eval "$link_command" 'exit $?'
89613bfa90b6Smrg
89623bfa90b6Smrg	if test -n "$postlink_cmds"; then
89633bfa90b6Smrg	  func_to_tool_file "$output"
89643bfa90b6Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
89653bfa90b6Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
89663bfa90b6Smrg	fi
89673bfa90b6Smrg
89686df26cacSmrg	exit $EXIT_SUCCESS
8969b68e1f86Smrg      fi
89706df26cacSmrg
8971b68e1f86Smrg      if test "$hardcode_action" = relink; then
8972b68e1f86Smrg	# Fast installation is not supported
8973b68e1f86Smrg	link_command="$compile_var$compile_command$compile_rpath"
8974b68e1f86Smrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
8975b68e1f86Smrg
8976b68e1f86Smrg	func_warning "this platform does not like uninstalled shared libraries"
8977b68e1f86Smrg	func_warning "\`$output' will be relinked during installation"
8978b68e1f86Smrg      else
8979b68e1f86Smrg	if test "$fast_install" != no; then
8980b68e1f86Smrg	  link_command="$finalize_var$compile_command$finalize_rpath"
8981b68e1f86Smrg	  if test "$fast_install" = yes; then
89823bfa90b6Smrg	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
8983b68e1f86Smrg	  else
8984b68e1f86Smrg	    # fast_install is set to needless
8985b68e1f86Smrg	    relink_command=
8986b68e1f86Smrg	  fi
89876df26cacSmrg	else
8988b68e1f86Smrg	  link_command="$compile_var$compile_command$compile_rpath"
8989b68e1f86Smrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
89906df26cacSmrg	fi
8991b68e1f86Smrg      fi
89926df26cacSmrg
8993b68e1f86Smrg      # Replace the output file specification.
89943bfa90b6Smrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
89956df26cacSmrg
8996b68e1f86Smrg      # Delete the old output files.
8997b68e1f86Smrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
89986df26cacSmrg
8999b68e1f86Smrg      func_show_eval "$link_command" 'exit $?'
90006df26cacSmrg
90013bfa90b6Smrg      if test -n "$postlink_cmds"; then
90023bfa90b6Smrg	func_to_tool_file "$output_objdir/$outputname"
90033bfa90b6Smrg	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'`
90043bfa90b6Smrg	func_execute_cmds "$postlink_cmds" 'exit $?'
90053bfa90b6Smrg      fi
90063bfa90b6Smrg
9007b68e1f86Smrg      # Now create the wrapper script.
9008b68e1f86Smrg      func_verbose "creating $output"
90096df26cacSmrg
9010b68e1f86Smrg      # Quote the relink command for shipping.
9011b68e1f86Smrg      if test -n "$relink_command"; then
9012b68e1f86Smrg	# Preserve any variables that may affect compiler behavior
9013b68e1f86Smrg	for var in $variables_saved_for_relink; do
9014b68e1f86Smrg	  if eval test -z \"\${$var+set}\"; then
9015b68e1f86Smrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9016b68e1f86Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
9017b68e1f86Smrg	    relink_command="$var=; export $var; $relink_command"
90186df26cacSmrg	  else
9019b68e1f86Smrg	    func_quote_for_eval "$var_value"
9020b68e1f86Smrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
90216df26cacSmrg	  fi
9022b68e1f86Smrg	done
9023b68e1f86Smrg	relink_command="(cd `pwd`; $relink_command)"
90243bfa90b6Smrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9025b68e1f86Smrg      fi
9026b68e1f86Smrg
9027b68e1f86Smrg      # Only actually do things if not in dry run mode.
9028b68e1f86Smrg      $opt_dry_run || {
9029b68e1f86Smrg	# win32 will think the script is a binary if it has
9030b68e1f86Smrg	# a .exe suffix, so we strip it off here.
9031b68e1f86Smrg	case $output in
9032b68e1f86Smrg	  *.exe) func_stripname '' '.exe' "$output"
9033b68e1f86Smrg	         output=$func_stripname_result ;;
9034b68e1f86Smrg	esac
9035b68e1f86Smrg	# test for cygwin because mv fails w/o .exe extensions
9036b68e1f86Smrg	case $host in
9037b68e1f86Smrg	  *cygwin*)
9038b68e1f86Smrg	    exeext=.exe
9039b68e1f86Smrg	    func_stripname '' '.exe' "$outputname"
9040b68e1f86Smrg	    outputname=$func_stripname_result ;;
9041b68e1f86Smrg	  *) exeext= ;;
90426df26cacSmrg	esac
9043b68e1f86Smrg	case $host in
9044b68e1f86Smrg	  *cygwin* | *mingw* )
9045b68e1f86Smrg	    func_dirname_and_basename "$output" "" "."
9046b68e1f86Smrg	    output_name=$func_basename_result
9047b68e1f86Smrg	    output_path=$func_dirname_result
9048b68e1f86Smrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
9049b68e1f86Smrg	    cwrapper="$output_path/$output_name.exe"
9050b68e1f86Smrg	    $RM $cwrappersource $cwrapper
9051b68e1f86Smrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
9052b68e1f86Smrg
9053b68e1f86Smrg	    func_emit_cwrapperexe_src > $cwrappersource
9054b68e1f86Smrg
9055b68e1f86Smrg	    # The wrapper executable is built using the $host compiler,
9056b68e1f86Smrg	    # because it contains $host paths and files. If cross-
9057b68e1f86Smrg	    # compiling, it, like the target executable, must be
9058b68e1f86Smrg	    # executed on the $host or under an emulation environment.
9059b68e1f86Smrg	    $opt_dry_run || {
9060b68e1f86Smrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
9061b68e1f86Smrg	      $STRIP $cwrapper
9062b68e1f86Smrg	    }
90636df26cacSmrg
9064b68e1f86Smrg	    # Now, create the wrapper script for func_source use:
9065b68e1f86Smrg	    func_ltwrapper_scriptname $cwrapper
9066b68e1f86Smrg	    $RM $func_ltwrapper_scriptname_result
9067b68e1f86Smrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
9068b68e1f86Smrg	    $opt_dry_run || {
9069b68e1f86Smrg	      # note: this script will not be executed, so do not chmod.
9070b68e1f86Smrg	      if test "x$build" = "x$host" ; then
9071b68e1f86Smrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
9072b68e1f86Smrg	      else
9073b68e1f86Smrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
9074b68e1f86Smrg	      fi
9075b68e1f86Smrg	    }
9076b68e1f86Smrg	  ;;
9077b68e1f86Smrg	  * )
9078b68e1f86Smrg	    $RM $output
9079b68e1f86Smrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
90806df26cacSmrg
9081b68e1f86Smrg	    func_emit_wrapper no > $output
9082b68e1f86Smrg	    chmod +x $output
9083b68e1f86Smrg	  ;;
9084b68e1f86Smrg	esac
9085b68e1f86Smrg      }
9086b68e1f86Smrg      exit $EXIT_SUCCESS
9087b68e1f86Smrg      ;;
9088b68e1f86Smrg    esac
90896df26cacSmrg
9090b68e1f86Smrg    # See if we need to build an old-fashioned archive.
9091b68e1f86Smrg    for oldlib in $oldlibs; do
90926df26cacSmrg
9093b68e1f86Smrg      if test "$build_libtool_libs" = convenience; then
9094b68e1f86Smrg	oldobjs="$libobjs_save $symfileobj"
9095b68e1f86Smrg	addlibs="$convenience"
9096b68e1f86Smrg	build_libtool_libs=no
9097b68e1f86Smrg      else
9098b68e1f86Smrg	if test "$build_libtool_libs" = module; then
9099b68e1f86Smrg	  oldobjs="$libobjs_save"
9100b68e1f86Smrg	  build_libtool_libs=no
9101b68e1f86Smrg	else
9102b68e1f86Smrg	  oldobjs="$old_deplibs $non_pic_objects"
9103b68e1f86Smrg	  if test "$preload" = yes && test -f "$symfileobj"; then
91043bfa90b6Smrg	    func_append oldobjs " $symfileobj"
9105b68e1f86Smrg	  fi
9106b68e1f86Smrg	fi
9107b68e1f86Smrg	addlibs="$old_convenience"
91086df26cacSmrg      fi
91096df26cacSmrg
9110b68e1f86Smrg      if test -n "$addlibs"; then
9111b68e1f86Smrg	gentop="$output_objdir/${outputname}x"
91123bfa90b6Smrg	func_append generated " $gentop"
91136df26cacSmrg
9114b68e1f86Smrg	func_extract_archives $gentop $addlibs
91153bfa90b6Smrg	func_append oldobjs " $func_extract_archives_result"
9116b68e1f86Smrg      fi
91176df26cacSmrg
9118b68e1f86Smrg      # Do each command in the archive commands.
9119b68e1f86Smrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
9120b68e1f86Smrg	cmds=$old_archive_from_new_cmds
9121b68e1f86Smrg      else
91226df26cacSmrg
9123b68e1f86Smrg	# Add any objects from preloaded convenience libraries
9124b68e1f86Smrg	if test -n "$dlprefiles"; then
9125b68e1f86Smrg	  gentop="$output_objdir/${outputname}x"
91263bfa90b6Smrg	  func_append generated " $gentop"
91276df26cacSmrg
9128b68e1f86Smrg	  func_extract_archives $gentop $dlprefiles
91293bfa90b6Smrg	  func_append oldobjs " $func_extract_archives_result"
9130b68e1f86Smrg	fi
91316df26cacSmrg
9132b68e1f86Smrg	# POSIX demands no paths to be encoded in archives.  We have
9133b68e1f86Smrg	# to avoid creating archives with duplicate basenames if we
9134b68e1f86Smrg	# might have to extract them afterwards, e.g., when creating a
9135b68e1f86Smrg	# static archive out of a convenience library, or when linking
9136b68e1f86Smrg	# the entirety of a libtool archive into another (currently
9137b68e1f86Smrg	# not supported by libtool).
9138b68e1f86Smrg	if (for obj in $oldobjs
9139b68e1f86Smrg	    do
9140b68e1f86Smrg	      func_basename "$obj"
9141b68e1f86Smrg	      $ECHO "$func_basename_result"
9142b68e1f86Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
9143b68e1f86Smrg	  :
9144b68e1f86Smrg	else
91453bfa90b6Smrg	  echo "copying selected object files to avoid basename conflicts..."
9146b68e1f86Smrg	  gentop="$output_objdir/${outputname}x"
91473bfa90b6Smrg	  func_append generated " $gentop"
9148b68e1f86Smrg	  func_mkdir_p "$gentop"
9149b68e1f86Smrg	  save_oldobjs=$oldobjs
9150b68e1f86Smrg	  oldobjs=
9151b68e1f86Smrg	  counter=1
9152b68e1f86Smrg	  for obj in $save_oldobjs
9153b68e1f86Smrg	  do
9154b68e1f86Smrg	    func_basename "$obj"
9155b68e1f86Smrg	    objbase="$func_basename_result"
9156b68e1f86Smrg	    case " $oldobjs " in
9157b68e1f86Smrg	    " ") oldobjs=$obj ;;
9158b68e1f86Smrg	    *[\ /]"$objbase "*)
9159b68e1f86Smrg	      while :; do
9160b68e1f86Smrg		# Make sure we don't pick an alternate name that also
9161b68e1f86Smrg		# overlaps.
9162b68e1f86Smrg		newobj=lt$counter-$objbase
9163b68e1f86Smrg		func_arith $counter + 1
9164b68e1f86Smrg		counter=$func_arith_result
9165b68e1f86Smrg		case " $oldobjs " in
9166b68e1f86Smrg		*[\ /]"$newobj "*) ;;
9167b68e1f86Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
9168b68e1f86Smrg		esac
9169b68e1f86Smrg	      done
9170b68e1f86Smrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
91713bfa90b6Smrg	      func_append oldobjs " $gentop/$newobj"
9172b68e1f86Smrg	      ;;
91733bfa90b6Smrg	    *) func_append oldobjs " $obj" ;;
9174b68e1f86Smrg	    esac
91756df26cacSmrg	  done
91766df26cacSmrg	fi
91773bfa90b6Smrg	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
91783bfa90b6Smrg	tool_oldlib=$func_to_tool_file_result
9179b68e1f86Smrg	eval cmds=\"$old_archive_cmds\"
91806df26cacSmrg
9181b68e1f86Smrg	func_len " $cmds"
9182b68e1f86Smrg	len=$func_len_result
9183b68e1f86Smrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9184b68e1f86Smrg	  cmds=$old_archive_cmds
91853bfa90b6Smrg	elif test -n "$archiver_list_spec"; then
91863bfa90b6Smrg	  func_verbose "using command file archive linking..."
91873bfa90b6Smrg	  for obj in $oldobjs
91883bfa90b6Smrg	  do
91893bfa90b6Smrg	    func_to_tool_file "$obj"
91903bfa90b6Smrg	    $ECHO "$func_to_tool_file_result"
91913bfa90b6Smrg	  done > $output_objdir/$libname.libcmd
91923bfa90b6Smrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
91933bfa90b6Smrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
91943bfa90b6Smrg	  cmds=$old_archive_cmds
9195b68e1f86Smrg	else
9196b68e1f86Smrg	  # the command line is too long to link in one step, link in parts
9197b68e1f86Smrg	  func_verbose "using piecewise archive linking..."
9198b68e1f86Smrg	  save_RANLIB=$RANLIB
9199b68e1f86Smrg	  RANLIB=:
9200b68e1f86Smrg	  objlist=
9201b68e1f86Smrg	  concat_cmds=
9202b68e1f86Smrg	  save_oldobjs=$oldobjs
9203b68e1f86Smrg	  oldobjs=
9204b68e1f86Smrg	  # Is there a better way of finding the last object in the list?
9205b68e1f86Smrg	  for obj in $save_oldobjs
9206b68e1f86Smrg	  do
9207b68e1f86Smrg	    last_oldobj=$obj
9208b68e1f86Smrg	  done
9209b68e1f86Smrg	  eval test_cmds=\"$old_archive_cmds\"
9210b68e1f86Smrg	  func_len " $test_cmds"
9211b68e1f86Smrg	  len0=$func_len_result
9212b68e1f86Smrg	  len=$len0
9213b68e1f86Smrg	  for obj in $save_oldobjs
9214b68e1f86Smrg	  do
9215b68e1f86Smrg	    func_len " $obj"
9216b68e1f86Smrg	    func_arith $len + $func_len_result
9217b68e1f86Smrg	    len=$func_arith_result
9218b68e1f86Smrg	    func_append objlist " $obj"
9219b68e1f86Smrg	    if test "$len" -lt "$max_cmd_len"; then
9220b68e1f86Smrg	      :
9221b68e1f86Smrg	    else
9222b68e1f86Smrg	      # the above command should be used before it gets too long
9223b68e1f86Smrg	      oldobjs=$objlist
9224b68e1f86Smrg	      if test "$obj" = "$last_oldobj" ; then
9225b68e1f86Smrg		RANLIB=$save_RANLIB
9226b68e1f86Smrg	      fi
9227b68e1f86Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9228b68e1f86Smrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
9229b68e1f86Smrg	      objlist=
9230b68e1f86Smrg	      len=$len0
9231b68e1f86Smrg	    fi
9232b68e1f86Smrg	  done
9233b68e1f86Smrg	  RANLIB=$save_RANLIB
9234b68e1f86Smrg	  oldobjs=$objlist
9235b68e1f86Smrg	  if test "X$oldobjs" = "X" ; then
9236b68e1f86Smrg	    eval cmds=\"\$concat_cmds\"
9237b68e1f86Smrg	  else
9238b68e1f86Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
9239b68e1f86Smrg	  fi
9240b68e1f86Smrg	fi
9241b68e1f86Smrg      fi
9242b68e1f86Smrg      func_execute_cmds "$cmds" 'exit $?'
92436df26cacSmrg    done
92446df26cacSmrg
9245b68e1f86Smrg    test -n "$generated" && \
9246b68e1f86Smrg      func_show_eval "${RM}r$generated"
92476df26cacSmrg
9248b68e1f86Smrg    # Now create the libtool archive.
9249b68e1f86Smrg    case $output in
9250b68e1f86Smrg    *.la)
9251b68e1f86Smrg      old_library=
9252b68e1f86Smrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
9253b68e1f86Smrg      func_verbose "creating $output"
92546df26cacSmrg
9255b68e1f86Smrg      # Preserve any variables that may affect compiler behavior
9256b68e1f86Smrg      for var in $variables_saved_for_relink; do
9257b68e1f86Smrg	if eval test -z \"\${$var+set}\"; then
9258b68e1f86Smrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9259b68e1f86Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
9260b68e1f86Smrg	  relink_command="$var=; export $var; $relink_command"
92616df26cacSmrg	else
9262b68e1f86Smrg	  func_quote_for_eval "$var_value"
9263b68e1f86Smrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
92646df26cacSmrg	fi
9265b68e1f86Smrg      done
9266b68e1f86Smrg      # Quote the link command for shipping.
9267b68e1f86Smrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
92683bfa90b6Smrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9269b68e1f86Smrg      if test "$hardcode_automatic" = yes ; then
9270b68e1f86Smrg	relink_command=
9271b68e1f86Smrg      fi
92726df26cacSmrg
9273b68e1f86Smrg      # Only create the output if not a dry run.
9274b68e1f86Smrg      $opt_dry_run || {
9275b68e1f86Smrg	for installed in no yes; do
9276b68e1f86Smrg	  if test "$installed" = yes; then
9277b68e1f86Smrg	    if test -z "$install_libdir"; then
9278b68e1f86Smrg	      break
9279b68e1f86Smrg	    fi
9280b68e1f86Smrg	    output="$output_objdir/$outputname"i
9281b68e1f86Smrg	    # Replace all uninstalled libtool libraries with the installed ones
9282b68e1f86Smrg	    newdependency_libs=
9283b68e1f86Smrg	    for deplib in $dependency_libs; do
9284b68e1f86Smrg	      case $deplib in
9285b68e1f86Smrg	      *.la)
9286b68e1f86Smrg		func_basename "$deplib"
9287b68e1f86Smrg		name="$func_basename_result"
92883bfa90b6Smrg		func_resolve_sysroot "$deplib"
92893bfa90b6Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
9290b68e1f86Smrg		test -z "$libdir" && \
9291b68e1f86Smrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
92923bfa90b6Smrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
92933bfa90b6Smrg		;;
92943bfa90b6Smrg	      -L*)
92953bfa90b6Smrg		func_stripname -L '' "$deplib"
92963bfa90b6Smrg		func_replace_sysroot "$func_stripname_result"
92973bfa90b6Smrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
9298b68e1f86Smrg		;;
92993bfa90b6Smrg	      -R*)
93003bfa90b6Smrg		func_stripname -R '' "$deplib"
93013bfa90b6Smrg		func_replace_sysroot "$func_stripname_result"
93023bfa90b6Smrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
93033bfa90b6Smrg		;;
93043bfa90b6Smrg	      *) func_append newdependency_libs " $deplib" ;;
9305b68e1f86Smrg	      esac
9306b68e1f86Smrg	    done
9307b68e1f86Smrg	    dependency_libs="$newdependency_libs"
9308b68e1f86Smrg	    newdlfiles=
9309b68e1f86Smrg
9310b68e1f86Smrg	    for lib in $dlfiles; do
9311b68e1f86Smrg	      case $lib in
9312b68e1f86Smrg	      *.la)
9313b68e1f86Smrg	        func_basename "$lib"
9314b68e1f86Smrg		name="$func_basename_result"
9315b68e1f86Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9316b68e1f86Smrg		test -z "$libdir" && \
9317b68e1f86Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
93183bfa90b6Smrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
9319b68e1f86Smrg		;;
93203bfa90b6Smrg	      *) func_append newdlfiles " $lib" ;;
9321b68e1f86Smrg	      esac
9322b68e1f86Smrg	    done
9323b68e1f86Smrg	    dlfiles="$newdlfiles"
9324b68e1f86Smrg	    newdlprefiles=
9325b68e1f86Smrg	    for lib in $dlprefiles; do
9326b68e1f86Smrg	      case $lib in
9327b68e1f86Smrg	      *.la)
9328b68e1f86Smrg		# Only pass preopened files to the pseudo-archive (for
9329b68e1f86Smrg		# eventual linking with the app. that links it) if we
9330b68e1f86Smrg		# didn't already link the preopened objects directly into
9331b68e1f86Smrg		# the library:
9332b68e1f86Smrg		func_basename "$lib"
9333b68e1f86Smrg		name="$func_basename_result"
9334b68e1f86Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9335b68e1f86Smrg		test -z "$libdir" && \
9336b68e1f86Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
93373bfa90b6Smrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
9338b68e1f86Smrg		;;
9339b68e1f86Smrg	      esac
9340b68e1f86Smrg	    done
9341b68e1f86Smrg	    dlprefiles="$newdlprefiles"
9342b68e1f86Smrg	  else
9343b68e1f86Smrg	    newdlfiles=
9344b68e1f86Smrg	    for lib in $dlfiles; do
9345b68e1f86Smrg	      case $lib in
9346b68e1f86Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9347b68e1f86Smrg		*) abs=`pwd`"/$lib" ;;
9348b68e1f86Smrg	      esac
93493bfa90b6Smrg	      func_append newdlfiles " $abs"
9350b68e1f86Smrg	    done
9351b68e1f86Smrg	    dlfiles="$newdlfiles"
9352b68e1f86Smrg	    newdlprefiles=
9353b68e1f86Smrg	    for lib in $dlprefiles; do
9354b68e1f86Smrg	      case $lib in
9355b68e1f86Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9356b68e1f86Smrg		*) abs=`pwd`"/$lib" ;;
9357b68e1f86Smrg	      esac
93583bfa90b6Smrg	      func_append newdlprefiles " $abs"
9359b68e1f86Smrg	    done
9360b68e1f86Smrg	    dlprefiles="$newdlprefiles"
9361b68e1f86Smrg	  fi
9362b68e1f86Smrg	  $RM $output
9363b68e1f86Smrg	  # place dlname in correct position for cygwin
93643bfa90b6Smrg	  # In fact, it would be nice if we could use this code for all target
93653bfa90b6Smrg	  # systems that can't hard-code library paths into their executables
93663bfa90b6Smrg	  # and that have no shared library path variable independent of PATH,
93673bfa90b6Smrg	  # but it turns out we can't easily determine that from inspecting
93683bfa90b6Smrg	  # libtool variables, so we have to hard-code the OSs to which it
93693bfa90b6Smrg	  # applies here; at the moment, that means platforms that use the PE
93703bfa90b6Smrg	  # object format with DLL files.  See the long comment at the top of
93713bfa90b6Smrg	  # tests/bindir.at for full details.
9372b68e1f86Smrg	  tdlname=$dlname
9373b68e1f86Smrg	  case $host,$output,$installed,$module,$dlname in
93743bfa90b6Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
93753bfa90b6Smrg	      # If a -bindir argument was supplied, place the dll there.
93763bfa90b6Smrg	      if test "x$bindir" != x ;
93773bfa90b6Smrg	      then
93783bfa90b6Smrg		func_relative_path "$install_libdir" "$bindir"
93793bfa90b6Smrg		tdlname=$func_relative_path_result$dlname
93803bfa90b6Smrg	      else
93813bfa90b6Smrg		# Otherwise fall back on heuristic.
93823bfa90b6Smrg		tdlname=../bin/$dlname
93833bfa90b6Smrg	      fi
93843bfa90b6Smrg	      ;;
9385b68e1f86Smrg	  esac
9386b68e1f86Smrg	  $ECHO > $output "\
9387b68e1f86Smrg# $outputname - a libtool library file
9388b68e1f86Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
9389b68e1f86Smrg#
9390b68e1f86Smrg# Please DO NOT delete this file!
9391b68e1f86Smrg# It is necessary for linking the library.
93926df26cacSmrg
9393b68e1f86Smrg# The name that we can dlopen(3).
9394b68e1f86Smrgdlname='$tdlname'
93956df26cacSmrg
9396b68e1f86Smrg# Names of this library.
9397b68e1f86Smrglibrary_names='$library_names'
93986df26cacSmrg
9399b68e1f86Smrg# The name of the static archive.
9400b68e1f86Smrgold_library='$old_library'
94016df26cacSmrg
9402b68e1f86Smrg# Linker flags that can not go in dependency_libs.
9403b68e1f86Smrginherited_linker_flags='$new_inherited_linker_flags'
94046df26cacSmrg
9405b68e1f86Smrg# Libraries that this one depends upon.
9406b68e1f86Smrgdependency_libs='$dependency_libs'
94076df26cacSmrg
9408b68e1f86Smrg# Names of additional weak libraries provided by this library
9409b68e1f86Smrgweak_library_names='$weak_libs'
94106df26cacSmrg
9411b68e1f86Smrg# Version information for $libname.
9412b68e1f86Smrgcurrent=$current
9413b68e1f86Smrgage=$age
9414b68e1f86Smrgrevision=$revision
94156df26cacSmrg
9416b68e1f86Smrg# Is this an already installed library?
9417b68e1f86Smrginstalled=$installed
94186df26cacSmrg
9419b68e1f86Smrg# Should we warn about portability when linking against -modules?
9420b68e1f86Smrgshouldnotlink=$module
94216df26cacSmrg
9422b68e1f86Smrg# Files to dlopen/dlpreopen
9423b68e1f86Smrgdlopen='$dlfiles'
9424b68e1f86Smrgdlpreopen='$dlprefiles'
94256df26cacSmrg
9426b68e1f86Smrg# Directory that this library needs to be installed in:
9427b68e1f86Smrglibdir='$install_libdir'"
9428b68e1f86Smrg	  if test "$installed" = no && test "$need_relink" = yes; then
9429b68e1f86Smrg	    $ECHO >> $output "\
9430b68e1f86Smrgrelink_command=\"$relink_command\""
9431b68e1f86Smrg	  fi
9432b68e1f86Smrg	done
9433b68e1f86Smrg      }
94346df26cacSmrg
9435b68e1f86Smrg      # Do a symbolic link so that the libtool archive can be found in
9436b68e1f86Smrg      # LD_LIBRARY_PATH before the program is installed.
9437b68e1f86Smrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
9438b68e1f86Smrg      ;;
9439b68e1f86Smrg    esac
9440b68e1f86Smrg    exit $EXIT_SUCCESS
9441b68e1f86Smrg}
94426df26cacSmrg
94433bfa90b6Smrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
9444b68e1f86Smrg    func_mode_link ${1+"$@"}
94456df26cacSmrg
94466df26cacSmrg
9447b68e1f86Smrg# func_mode_uninstall arg...
9448b68e1f86Smrgfunc_mode_uninstall ()
9449b68e1f86Smrg{
9450b68e1f86Smrg    $opt_debug
9451b68e1f86Smrg    RM="$nonopt"
94526df26cacSmrg    files=
94536df26cacSmrg    rmforce=
94546df26cacSmrg    exit_status=0
94556df26cacSmrg
94566df26cacSmrg    # This variable tells wrapper scripts just to set variables rather
94576df26cacSmrg    # than running their programs.
94586df26cacSmrg    libtool_install_magic="$magic"
94596df26cacSmrg
94606df26cacSmrg    for arg
94616df26cacSmrg    do
94626df26cacSmrg      case $arg in
94633bfa90b6Smrg      -f) func_append RM " $arg"; rmforce=yes ;;
94643bfa90b6Smrg      -*) func_append RM " $arg" ;;
94653bfa90b6Smrg      *) func_append files " $arg" ;;
94666df26cacSmrg      esac
94676df26cacSmrg    done
94686df26cacSmrg
9469b68e1f86Smrg    test -z "$RM" && \
9470b68e1f86Smrg      func_fatal_help "you must specify an RM program"
94716df26cacSmrg
94726df26cacSmrg    rmdirs=
94736df26cacSmrg
94746df26cacSmrg    for file in $files; do
9475b68e1f86Smrg      func_dirname "$file" "" "."
9476b68e1f86Smrg      dir="$func_dirname_result"
9477b68e1f86Smrg      if test "X$dir" = X.; then
94783bfa90b6Smrg	odir="$objdir"
94796df26cacSmrg      else
94803bfa90b6Smrg	odir="$dir/$objdir"
94816df26cacSmrg      fi
9482b68e1f86Smrg      func_basename "$file"
9483b68e1f86Smrg      name="$func_basename_result"
94843bfa90b6Smrg      test "$opt_mode" = uninstall && odir="$dir"
94856df26cacSmrg
94863bfa90b6Smrg      # Remember odir for removal later, being careful to avoid duplicates
94873bfa90b6Smrg      if test "$opt_mode" = clean; then
94886df26cacSmrg	case " $rmdirs " in
94893bfa90b6Smrg	  *" $odir "*) ;;
94903bfa90b6Smrg	  *) func_append rmdirs " $odir" ;;
94916df26cacSmrg	esac
94926df26cacSmrg      fi
94936df26cacSmrg
94946df26cacSmrg      # Don't error if the file doesn't exist and rm -f was used.
9495b68e1f86Smrg      if { test -L "$file"; } >/dev/null 2>&1 ||
9496b68e1f86Smrg	 { test -h "$file"; } >/dev/null 2>&1 ||
9497b68e1f86Smrg	 test -f "$file"; then
94986df26cacSmrg	:
94996df26cacSmrg      elif test -d "$file"; then
95006df26cacSmrg	exit_status=1
95016df26cacSmrg	continue
95026df26cacSmrg      elif test "$rmforce" = yes; then
95036df26cacSmrg	continue
95046df26cacSmrg      fi
95056df26cacSmrg
95066df26cacSmrg      rmfiles="$file"
95076df26cacSmrg
95086df26cacSmrg      case $name in
95096df26cacSmrg      *.la)
95106df26cacSmrg	# Possibly a libtool archive, so verify it.
9511b68e1f86Smrg	if func_lalib_p "$file"; then
9512b68e1f86Smrg	  func_source $dir/$name
95136df26cacSmrg
95146df26cacSmrg	  # Delete the libtool libraries and symlinks.
95156df26cacSmrg	  for n in $library_names; do
95163bfa90b6Smrg	    func_append rmfiles " $odir/$n"
95176df26cacSmrg	  done
95183bfa90b6Smrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
95196df26cacSmrg
95203bfa90b6Smrg	  case "$opt_mode" in
95216df26cacSmrg	  clean)
95223bfa90b6Smrg	    case " $library_names " in
95236df26cacSmrg	    *" $dlname "*) ;;
95243bfa90b6Smrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
95256df26cacSmrg	    esac
95263bfa90b6Smrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
95276df26cacSmrg	    ;;
95286df26cacSmrg	  uninstall)
95296df26cacSmrg	    if test -n "$library_names"; then
95306df26cacSmrg	      # Do each command in the postuninstall commands.
9531b68e1f86Smrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
95326df26cacSmrg	    fi
95336df26cacSmrg
95346df26cacSmrg	    if test -n "$old_library"; then
95356df26cacSmrg	      # Do each command in the old_postuninstall commands.
9536b68e1f86Smrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
95376df26cacSmrg	    fi
95386df26cacSmrg	    # FIXME: should reinstall the best remaining shared library.
95396df26cacSmrg	    ;;
95406df26cacSmrg	  esac
95416df26cacSmrg	fi
95426df26cacSmrg	;;
95436df26cacSmrg
95446df26cacSmrg      *.lo)
95456df26cacSmrg	# Possibly a libtool object, so verify it.
9546b68e1f86Smrg	if func_lalib_p "$file"; then
95476df26cacSmrg
95486df26cacSmrg	  # Read the .lo file
9549b68e1f86Smrg	  func_source $dir/$name
95506df26cacSmrg
95516df26cacSmrg	  # Add PIC object to the list of files to remove.
9552b68e1f86Smrg	  if test -n "$pic_object" &&
9553b68e1f86Smrg	     test "$pic_object" != none; then
95543bfa90b6Smrg	    func_append rmfiles " $dir/$pic_object"
95556df26cacSmrg	  fi
95566df26cacSmrg
95576df26cacSmrg	  # Add non-PIC object to the list of files to remove.
9558b68e1f86Smrg	  if test -n "$non_pic_object" &&
9559b68e1f86Smrg	     test "$non_pic_object" != none; then
95603bfa90b6Smrg	    func_append rmfiles " $dir/$non_pic_object"
95616df26cacSmrg	  fi
95626df26cacSmrg	fi
95636df26cacSmrg	;;
95646df26cacSmrg
95656df26cacSmrg      *)
95663bfa90b6Smrg	if test "$opt_mode" = clean ; then
95676df26cacSmrg	  noexename=$name
95686df26cacSmrg	  case $file in
95696df26cacSmrg	  *.exe)
9570b68e1f86Smrg	    func_stripname '' '.exe' "$file"
9571b68e1f86Smrg	    file=$func_stripname_result
9572b68e1f86Smrg	    func_stripname '' '.exe' "$name"
9573b68e1f86Smrg	    noexename=$func_stripname_result
95746df26cacSmrg	    # $file with .exe has already been added to rmfiles,
95756df26cacSmrg	    # add $file without .exe
95763bfa90b6Smrg	    func_append rmfiles " $file"
95776df26cacSmrg	    ;;
95786df26cacSmrg	  esac
95796df26cacSmrg	  # Do a test to see if this is a libtool program.
9580b68e1f86Smrg	  if func_ltwrapper_p "$file"; then
9581b68e1f86Smrg	    if func_ltwrapper_executable_p "$file"; then
9582b68e1f86Smrg	      func_ltwrapper_scriptname "$file"
9583b68e1f86Smrg	      relink_command=
9584b68e1f86Smrg	      func_source $func_ltwrapper_scriptname_result
95853bfa90b6Smrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
9586b68e1f86Smrg	    else
9587b68e1f86Smrg	      relink_command=
9588b68e1f86Smrg	      func_source $dir/$noexename
9589b68e1f86Smrg	    fi
95906df26cacSmrg
95916df26cacSmrg	    # note $name still contains .exe if it was in $file originally
95926df26cacSmrg	    # as does the version of $file that was added into $rmfiles
95933bfa90b6Smrg	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
95946df26cacSmrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
95953bfa90b6Smrg	      func_append rmfiles " $odir/lt-$name"
95966df26cacSmrg	    fi
95976df26cacSmrg	    if test "X$noexename" != "X$name" ; then
95983bfa90b6Smrg	      func_append rmfiles " $odir/lt-${noexename}.c"
95996df26cacSmrg	    fi
96006df26cacSmrg	  fi
96016df26cacSmrg	fi
96026df26cacSmrg	;;
96036df26cacSmrg      esac
9604b68e1f86Smrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
96056df26cacSmrg    done
96066df26cacSmrg
96076df26cacSmrg    # Try to remove the ${objdir}s in the directories where we deleted files
96086df26cacSmrg    for dir in $rmdirs; do
96096df26cacSmrg      if test -d "$dir"; then
9610b68e1f86Smrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
96116df26cacSmrg      fi
96126df26cacSmrg    done
96136df26cacSmrg
96146df26cacSmrg    exit $exit_status
9615b68e1f86Smrg}
96166df26cacSmrg
96173bfa90b6Smrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
9618b68e1f86Smrg    func_mode_uninstall ${1+"$@"}
96196df26cacSmrg
96203bfa90b6Smrgtest -z "$opt_mode" && {
9621b68e1f86Smrg  help="$generic_help"
9622b68e1f86Smrg  func_fatal_help "you must specify a MODE"
9623b68e1f86Smrg}
9624b68e1f86Smrg
9625b68e1f86Smrgtest -z "$exec_cmd" && \
96263bfa90b6Smrg  func_fatal_help "invalid operation mode \`$opt_mode'"
96276df26cacSmrg
96286df26cacSmrgif test -n "$exec_cmd"; then
9629b68e1f86Smrg  eval exec "$exec_cmd"
96306df26cacSmrg  exit $EXIT_FAILURE
96316df26cacSmrgfi
96326df26cacSmrg
9633b68e1f86Smrgexit $exit_status
96346df26cacSmrg
96356df26cacSmrg
96366df26cacSmrg# The TAGs below are defined such that we never get into a situation
96376df26cacSmrg# in which we disable both kinds of libraries.  Given conflicting
96386df26cacSmrg# choices, we go for a static library, that is the most portable,
96396df26cacSmrg# since we can't tell whether shared libraries were disabled because
96406df26cacSmrg# the user asked for that or because the platform doesn't support
96416df26cacSmrg# them.  This is particularly important on AIX, because we don't
96426df26cacSmrg# support having both static and shared libraries enabled at the same
96436df26cacSmrg# time on that platform, so we default to a shared-only configuration.
96446df26cacSmrg# If a disable-shared tag is given, we'll fallback to a static-only
96456df26cacSmrg# configuration.  But we'll never go from static-only to shared-only.
96466df26cacSmrg
96476df26cacSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
9648b68e1f86Smrgbuild_libtool_libs=no
9649b68e1f86Smrgbuild_old_libs=yes
96506df26cacSmrg# ### END LIBTOOL TAG CONFIG: disable-shared
96516df26cacSmrg
96526df26cacSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
9653b68e1f86Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
96546df26cacSmrg# ### END LIBTOOL TAG CONFIG: disable-static
96556df26cacSmrg
96566df26cacSmrg# Local Variables:
96576df26cacSmrg# mode:shell-script
96586df26cacSmrg# sh-indentation:2
96596df26cacSmrg# End:
9660b68e1f86Smrg# vi:sw=2
9661b68e1f86Smrg
9662